]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/js/hovercard.js
frio: some css work for help docs
[friendica.git] / view / theme / frio / js / hovercard.js
index 93c87e7a887ec953c14710a262fe6d2b82c607b5..6e2a827cd657a716e02ffde4f2b4b3e100ed615b 100644 (file)
@@ -11,7 +11,7 @@ $(document).ready(function(){
        // Elements with the class "userinfo" will get a hover-card.
        // Note that this elements does need a href attribute which links to
        // a valid profile url
-       $("body").on("mouseover", ".userinfo", function(e) {
+       $("body").on("mouseover", ".userinfo, .wall-item-responses a, .wall-item-bottom .mention a", function(e) {
                        var timeNow = new Date().getTime();
                        removeAllhoverCards(e,timeNow);
                        var hoverCardData = false;
@@ -40,13 +40,21 @@ $(document).ready(function(){
                        // Take link href attribute as link to the profile
                        var profileurl = hrefAttr;
                        // the url to get the contact and template data
-                       var url = baseurl + "/frio_hovercard";
+                       var url = baseurl + "/hovercard";
 
                        // store the title in an other data attribute beause bootstrap
                        // popover destroys the title.attribute. We can restore it later
                        var title = targetElement.attr("title");
                        targetElement.attr({"data-orig-title": title, title: ""});
 
+                       // if the device is a mobile open the hover card by click and not by hover
+                       if(typeof is_mobile != "undefined") {
+                                       targetElement[0].removeAttribute("href");
+                                       var hctrigger = 'click';
+                               } else {
+                                       var hctrigger = 'manual';
+                       };
+
                        // Timeoute until the hover-card does appear
                        setTimeout(function(){
                                if(targetElement.is(":hover") && parseInt(targetElement.attr('data-awaiting-hover-card'),10) == timeNow) {
@@ -69,7 +77,7 @@ $(document).ready(function(){
                                                                                }
                                                                                return "top";
                                                                        },
-                                                                       trigger: 'manual',
+                                                                       trigger: hctrigger,
                                                                        template: '<div class="popover hovercard" data-card-created="' + timeNow + '"><div class="arrow"></div><div class="popover-content hovercard-content"></div></div>',
                                                                        content: data
                                                                }).popover('show');
@@ -78,7 +86,7 @@ $(document).ready(function(){
                                        }
                                }
                        }, 500);
-       }).on("mouseleave", ".userinfo", function(e) { // action when mouse leaves the hover-card
+       }).on("mouseleave", ".userinfo, .wall-item-responses a, .wall-item-bottom .mention a", function(e) { // action when mouse leaves the hover-card
                var timeNow = new Date().getTime();
                // copy the original title to the title atribute
                var title = $(this).attr("data-orig-title");
@@ -90,8 +98,12 @@ $(document).ready(function(){
 
        // hover cards should be removed very easily, e.g. when any of these events happen
        $('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){
-               var timeNow = new Date().getTime();
-               removeAllhoverCards(e,timeNow);
+               // remove hover card only for desktiop user, since on mobile we openen the hovercards
+               // by click event insteadof hover
+               if(typeof is_mobile == "undefined") {
+                       var timeNow = new Date().getTime();
+                       removeAllhoverCards(e,timeNow);
+               };
        });
 
        // if we're hovering a hover card, give it a class, so we don't remove it