From 2560f1886ea3860fe27f9e62386f7a647b3bdac3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 6 Jan 2012 16:02:05 +0000 Subject: [PATCH] (bug 29309) allow CSS class per tooltip (tipsy) Let us use the new "className" upstream option to add a class per tooltip. Partial merges of upstreams changes: - 602f2fe5 Per-tooltip classes - f5563566 Helper function for call or return idiom --- RELEASE-NOTES-1.19 | 1 + resources/jquery.tipsy/jquery.tipsy.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 3db8153a70..634f5ac292 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -119,6 +119,7 @@ production. * (bug 33456) Show $wgQueryCacheLimit on cached query pages. * (bug 10574) Add an option to allow all pages to be exported by Special:Export. * Use mw.jqueryMsg parser for message parsing to support PLURAL and GENDER +* (bug 29309) allow CSS class per tooltip (tipsy) === Bug fixes in 1.19 === * $wgUploadNavigationUrl should be used for file redlinks if. diff --git a/resources/jquery.tipsy/jquery.tipsy.js b/resources/jquery.tipsy/jquery.tipsy.js index 7c80873434..cca0a2ef56 100644 --- a/resources/jquery.tipsy/jquery.tipsy.js +++ b/resources/jquery.tipsy/jquery.tipsy.js @@ -4,7 +4,11 @@ // releated under the MIT license (function($) { - + + function maybeCall(thing, ctx) { + 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'); @@ -71,6 +75,9 @@ } $tip.css(tp).addClass('tipsy-' + gravity); + if (this.options.className) { + $tip.addClass(maybeCall(this.options.className, this.$element[0])); + } if (this.options.fade) { $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity}, 100); @@ -174,6 +181,7 @@ }; $.fn.tipsy.defaults = { + className: null, delayIn: 0, delayOut: 0, fade: true, -- 2.20.1