From: Derk-Jan Hartman Date: Sun, 18 May 2014 14:01:00 +0000 (+0200) Subject: jquery.tipsy: Merge some upstream changes X-Git-Tag: 1.31.0-rc.0~15664^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=d8484cf1e7e653b4f2e19343201a9a948c39fb9f;p=lhc%2Fweb%2Fwiklou.git jquery.tipsy: Merge some upstream changes https://github.com/jaz303/tipsy/tree/2d916c6 4b3e29f: Remove superfluous slash 23994f5: tipsy object proxy method tolerates null object 2d916c6: Always ensure native tooltip is restored Change-Id: Id87ba461265730a56a3212c003b8321bd53a6096 --- diff --git a/resources/src/jquery.tipsy/jquery.tipsy.js b/resources/src/jquery.tipsy/jquery.tipsy.js index f920e8b032..985cd83293 100644 --- a/resources/src/jquery.tipsy/jquery.tipsy.js +++ b/resources/src/jquery.tipsy/jquery.tipsy.js @@ -12,17 +12,11 @@ return (typeof thing == 'function') ? (thing.call(ctx)) : thing; } - function fixTitle($ele) { - if ($ele.attr('title') || typeof($ele.attr('original-title')) != 'string') { - $ele.attr('original-title', $ele.attr('title') || '').removeAttr('title'); - } - } - function Tipsy(element, options) { this.$element = $(element); this.options = options; this.enabled = true; - fixTitle(this.$element); + this.fixTitle(); } Tipsy.prototype = { @@ -104,9 +98,17 @@ } }, + + fixTitle: function() { + var $e = this.$element; + if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') { + $e.attr('original-title', $e.attr('title') || '').removeAttr('title'); + } + }, + getTitle: function() { var title, $e = this.$element, o = this.options; - fixTitle($e); + this.fixTitle(); if (typeof o.title == 'string') { title = $e.attr(o.title == 'title' ? 'original-title' : o.title); } else if (typeof o.title == 'function') { @@ -118,7 +120,7 @@ tip: function() { if (!this.$tip) { - this.$tip = $('
').html('
'); + this.$tip = $('
').html('
'); } return this.$tip; }, @@ -141,7 +143,9 @@ if (options === true) { return this.data('tipsy'); } else if (typeof options == 'string') { - return this.data('tipsy')[options](); + var tipsy = this.data('tipsy'); + if (tipsy) tipsy[options](); + return this; } options = $.extend({}, $.fn.tipsy.defaults, options); @@ -161,6 +165,7 @@ if (options.delayIn == 0) { tipsy.show(); } else { + tipsy.fixTitle(); setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn); } };