]> _ Git - fluidbook-html5.git/commitdiff
Integrate tooltip links
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jul 2015 15:33:50 +0000 (15:33 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jul 2015 15:33:50 +0000 (15:33 +0000)
js/libs/fluidbook/fluidbook.tooltip.js
js/main.js
style/fluidbook.css

index c0fe1b5563d9deebbb23faf8e8827d85f443a630..d1087d5f9c5668383b3760b86714111204b2968b 100644 (file)
@@ -1,42 +1,54 @@
 function FluidbookTooltip(fluidbook) {
-       this.fluidbook = fluidbook;
-       this.init();
+    this.fluidbook = fluidbook;
+    this.init();
 }
 
 FluidbookTooltip.prototype = {
-       init: function() {
-               var $this = this;
-               if (!Modernizr.ftouch) {
-
-                       $(document).on('mouseover', 'a[data-tooltip]', function() {
-                               var position = $(this).offset();
-                               position.top += $(this).outerHeight() + 20;
-
-                               var text = $(this).data('tooltip');
-                               if (text.substr(0, 1) == '~') {
-                                       var text = $this.fluidbook.l10n.__(text.substring(1));
-                                       $(this).data('tooltip', text);
-                               }
-                               var ok = $this.displayTooltip(text, position);
-                               if (ok) {
-                                       $(this).one('mouseout', function() {
-                                               $this.hideTooltip();
-                                       });
-                               }
-                               return false;
-                       });
-                       $("body").append('<div id="tooltip"></div>');
-               }
-       },
-       displayTooltip: function(tooltip, position) {
-               if (tooltip == undefined || tooltip == '') {
-                       return false;
-               }
-               position.left -= 10;
-               $("#tooltip").text(tooltip).css(position).show();
-               return true;
-       },
-       hideTooltip: function() {
-               $("#tooltip").hide().text('');
-       }
+    init: function () {
+        var $this = this;
+        if (!Modernizr.ftouch) {
+
+            $(document).on('mouseover', 'a[data-tooltip]', function () {
+                var maxWidth = 140;
+                if ($(this).data('tooltip-maxwidth') !== null) {
+                    maxWidth = $(this).data('tooltip-maxwidth');
+                }
+
+                maxWidth *= 1.28;
+                maxWidth = Math.round(maxWidth);
+
+
+                var position = $(this).offset();
+                position.top += $(this).outerHeight() + 20;
+
+                var text = $(this).data('tooltip');
+                if (text.substr(0, 1) == '~') {
+                    var text = $this.fluidbook.l10n.__(text.substring(1));
+                    $(this).data('tooltip', text);
+                }
+                var ok = $this.displayTooltip(text, position, maxWidth);
+                if (ok) {
+                    $(this).one('mouseout', function () {
+                        $this.hideTooltip();
+                    });
+                }
+                return false;
+            });
+            $("body").append('<div id="tooltip"></div>');
+
+        }
+    },
+    displayTooltip: function (tooltip, position, maxWidth) {
+        if (tooltip == undefined || tooltip == '') {
+            return false;
+        }
+        position.left -= 10;
+        position.width = maxWidth;
+        $("#tooltip").text(tooltip).css(position).show();
+
+        return true;
+    },
+    hideTooltip: function () {
+        $("#tooltip").hide().text('');
+    }
 }
\ No newline at end of file
index 8b1e112e9bfea3d074b33202255b74c8e0b79540..ad2ae536d3925e444fff6abdb33fd0782970dc75 100644 (file)
@@ -399,6 +399,10 @@ try {
             }
         });
 
+        $(document).on('click', '.lazy', function () {
+            return false;
+        });
+
         $(document).on('click', '.share', function () {
             var f = 'send' + ucfirst($(this).data('service'));
             fluidbook[f]();
index 1db8cf6bc18f161cdac9f0e2e670d536e578c02b..15add7f718d2af9d1417970ef620cb64c4621619 100644 (file)
@@ -1576,6 +1576,7 @@ a.button {
        font-size: 0.8rem;
        max-width: 180px;
        z-index: 100;
+       white-space: pre-wrap;
 }
 
 @media handled and (orientation: portrait) {