(bug 29309) allow CSS class per tooltip (tipsy)
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 6 Jan 2012 16:02:05 +0000 (16:02 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 6 Jan 2012 16:02:05 +0000 (16:02 +0000)
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
resources/jquery.tipsy/jquery.tipsy.js

index 3db8153..634f5ac 100644 (file)
@@ -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.
index 7c80873..cca0a2e 100644 (file)
@@ -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);
     };
     
     $.fn.tipsy.defaults = {
+        className: null,
         delayIn: 0,
         delayOut: 0,
         fade: true,