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