From c39544e541ef5dc90aa15d368bc9af7f35cbb37f Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 11 Aug 2011 20:34:48 +0200 Subject: [PATCH] Support for balloon tooltips added --- wcfsetup/install/files/js/WCF.js | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index fae2ff0475..867d3ddd58 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1573,6 +1573,61 @@ WCF.Effect.SmoothScroll.prototype = { } }; +/** + * Creates a smooth scroll effect. + */ +WCF.Effect.BalloonTooltip = function() { this.init(); }; +WCF.Effect.BalloonTooltip.prototype = { + init: function() { + // create empty div + this.tooltip = $('
').appendTo(document.body).hide(); + + // init elements + $('.balloonTooltip').each($.proxy(this._initTooltip, this)); + }, + + _initTooltip: function(index, element) { + $(element).hover( + $.proxy(this._mouseEnterHandler, this), + $.proxy(this._mouseLeaveHandler, this) + ); + + $(element).mousemove( + $.proxy(this._mouseMoveHandler, this) + ); + }, + + _mouseEnterHandler: function(event) { + var $element = $(event.currentTarget); + if ($element.attr('title')) { + $element.data('tooltip', $element.attr('title')); + $element.attr('title', ''); + + this.tooltip.text($element.data('tooltip')).fadeIn('fast'); + } + }, + + _mouseLeaveHandler: function(event) { + var $element = $(event.currentTarget); + if ($element.data('tooltip')) { + $element.attr('title', $element.data('tooltip')); + $element.data('tooltip', ''); + + this.tooltip.hide(); + } + }, + + /** + * Moves tooltip to cursor position. + */ + _mouseMoveHandler: function(event) { + this.tooltip.css({ + top: (event.pageY - 0) + "px", + left: (event.pageX + 15) + "px" + }); + } +}; + /** * Basic implementation for WCF dialogs. */ -- 2.20.1