diff options
| author | Collin Donahue-Oponski <[email protected]> | 2014-04-21 23:03:33 -0600 |
|---|---|---|
| committer | Collin Donahue-Oponski <[email protected]> | 2014-04-21 23:03:33 -0600 |
| commit | a9f2b6ce0fb2ac059e30da259f7ae25282803c09 (patch) | |
| tree | 33aa8358b29db57532dbf2d8560649c7e11f2628 /js/tooltip.js | |
| parent | 9c4afc577253ada54d3ff27965e380a5c9f4e60e (diff) | |
| download | bootstrap-a9f2b6ce0fb2ac059e30da259f7ae25282803c09.tar.xz bootstrap-a9f2b6ce0fb2ac059e30da259f7ae25282803c09.zip | |
#11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object
Diffstat (limited to 'js/tooltip.js')
| -rw-r--r-- | js/tooltip.js | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/js/tooltip.js b/js/tooltip.js index bb47d4336..f688b3020 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -99,7 +99,12 @@ Tooltip.prototype.enter = function (obj) { var self = obj instanceof this.constructor ? - obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) + obj : $(obj.currentTarget).data('bs.' + this.type) + + if (!self) { + self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) + $(obj.currentTarget).data('bs.' + this.type, self) + } clearTimeout(self.timeout) @@ -114,7 +119,12 @@ Tooltip.prototype.leave = function (obj) { var self = obj instanceof this.constructor ? - obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) + obj : $(obj.currentTarget).data('bs.' + this.type) + + if (!self) { + self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) + $(obj.currentTarget).data('bs.' + this.type, self) + } clearTimeout(self.timeout) @@ -381,7 +391,15 @@ } Tooltip.prototype.toggle = function (e) { - var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this + var self = this + if (e) { + self = $(e.currentTarget).data('bs.' + this.type) + if (!self) { + self = new this.constructor(e.currentTarget, this.getDelegateOptions()) + $(e.currentTarget).data('bs.' + this.type, self) + } + } + self.tip().hasClass('in') ? self.leave(self) : self.enter(self) } @@ -394,9 +412,7 @@ // TOOLTIP PLUGIN DEFINITION // ========================= - var old = $.fn.tooltip - - $.fn.tooltip = function (option) { + function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('bs.tooltip') @@ -408,6 +424,9 @@ }) } + var old = $.fn.tooltip + + $.fn.tooltip = Plugin $.fn.tooltip.Constructor = Tooltip |
