jquery.tipsy: Merge some upstream changes
authorDerk-Jan Hartman <hartman.wiki@gmail.com>
Sun, 18 May 2014 14:01:00 +0000 (16:01 +0200)
committerKrinkle <krinklemail@gmail.com>
Sun, 18 May 2014 15:36:10 +0000 (15:36 +0000)
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

resources/src/jquery.tipsy/jquery.tipsy.js

index f920e8b..985cd83 100644 (file)
         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 = {
             }
         },
 
+
+        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') {
 
         tip: function() {
             if (!this.$tip) {
-                this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"/></div>');
+                this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>');
             }
             return this.$tip;
         },
         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);
             if (options.delayIn == 0) {
                 tipsy.show();
             } else {
+                tipsy.fixTitle();
                 setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn);
             }
         };