From: Vincent Vanwaelscappel Date: Thu, 16 Jul 2015 15:33:50 +0000 (+0000) Subject: Integrate tooltip links X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b471fbe73375a924d4f233fd596a421343b77f1b;p=fluidbook-html5.git Integrate tooltip links --- diff --git a/js/libs/fluidbook/fluidbook.tooltip.js b/js/libs/fluidbook/fluidbook.tooltip.js index c0fe1b55..d1087d5f 100644 --- a/js/libs/fluidbook/fluidbook.tooltip.js +++ b/js/libs/fluidbook/fluidbook.tooltip.js @@ -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('
'); - } - }, - 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('
'); + + } + }, + 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 diff --git a/js/main.js b/js/main.js index 8b1e112e..ad2ae536 100644 --- a/js/main.js +++ b/js/main.js @@ -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](); diff --git a/style/fluidbook.css b/style/fluidbook.css index 1db8cf6b..15add7f7 100644 --- a/style/fluidbook.css +++ b/style/fluidbook.css @@ -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) {