From e21b6459ad162296f94b2d9aeaf8807a153d3c8a Mon Sep 17 00:00:00 2001 From: Yohn Date: Thu, 20 Dec 2012 04:34:28 -0500 Subject: fixes tooltip('toggle') --- js/bootstrap-tooltip.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 25bba1589..221d3ef7b 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -234,8 +234,8 @@ } , toggle: function (e) { - var self = $(e.currentTarget)[this.type](this._options).data(this.type) - self[self.tip().hasClass('in') ? 'hide' : 'show']() + var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this + self.tip().hasClass('in') ? self.hide() : self.show() } , destroy: function () { @@ -282,4 +282,4 @@ return this } -}(window.jQuery); \ No newline at end of file +}(window.jQuery); -- cgit v1.2.3 From fad0fb683bdcc71f5ffc9c18300dd19427b588ae Mon Sep 17 00:00:00 2001 From: fat Date: Sat, 22 Dec 2012 13:24:37 -0800 Subject: allow multiple trigger types in tooltip and popover + default tooltip to hover & focus --- js/bootstrap-tooltip.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 25bba1589..adcff7017 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -38,19 +38,27 @@ , init: function (type, element, options) { var eventIn , eventOut + , triggers + , trigger + , i this.type = type this.$element = $(element) this.options = this.getOptions(options) this.enabled = true - if (this.options.trigger == 'click') { - this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) - } else if (this.options.trigger != 'manual') { - eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' - eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' - this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) - this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) + triggers = this.options.trigger.split(' ') + + for (i = triggers.length; i--;) { + trigger = triggers[i] + if (trigger == 'click') { + this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) + } else if (trigger != 'manual') { + eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' + eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' + this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) + this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) + } } this.options.selector ? @@ -267,7 +275,7 @@ , placement: 'top' , selector: false , template: '
' - , trigger: 'hover' + , trigger: 'hover focus' , title: '' , delay: 0 , html: false -- cgit v1.2.3 From 7a3a88acc60f7055720b919e281d3c881d05916f Mon Sep 17 00:00:00 2001 From: KAWACHI Takashi Date: Fri, 14 Dec 2012 16:35:11 +0900 Subject: Tooltips fires show, shown, hide, hidden events It is re-worked from #3691. --- js/bootstrap-tooltip.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index d908b0cf8..2a79490b1 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -110,8 +110,11 @@ , actualHeight , placement , tp + , e if (this.hasContent() && this.enabled) { + this.$element.trigger(e = $.Event('show')) + if (e.isDefaultPrevented()) return $tip = this.tip() this.setContent() @@ -152,6 +155,8 @@ .offset(tp) .addClass(placement) .addClass('in') + + this.$element.trigger('shown') } } @@ -166,6 +171,10 @@ , hide: function () { var that = this , $tip = this.tip() + , e + + this.$element.trigger(e = $.Event('hide')) + if (e.isDefaultPrevented()) return $tip.removeClass('in') @@ -184,6 +193,8 @@ removeWithAnimation() : $tip.detach() + this.$element.trigger('hidden') + return this } -- cgit v1.2.3 From defe85bb51e13ef619c8d0dc1303e3b195c4a772 Mon Sep 17 00:00:00 2001 From: KAWACHI Takashi Date: Sun, 23 Dec 2012 15:17:41 +0900 Subject: Assign event variables at declarations --- js/bootstrap-tooltip.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 2a79490b1..8c8673387 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -110,10 +110,10 @@ , actualHeight , placement , tp - , e + , e = $.Event('show') if (this.hasContent() && this.enabled) { - this.$element.trigger(e = $.Event('show')) + this.$element.trigger(e) if (e.isDefaultPrevented()) return $tip = this.tip() this.setContent() @@ -171,9 +171,9 @@ , hide: function () { var that = this , $tip = this.tip() - , e + , e = $.Event('hide') - this.$element.trigger(e = $.Event('hide')) + this.$element.trigger(e) if (e.isDefaultPrevented()) return $tip.removeClass('in') -- cgit v1.2.3 From d594d6377a7e9cda399c25a450b0d27df704d939 Mon Sep 17 00:00:00 2001 From: Yohn Date: Sun, 23 Dec 2012 04:18:16 -0500 Subject: adding container option to tooltips --- js/bootstrap-tooltip.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index d908b0cf8..82fa96078 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -126,7 +126,8 @@ $tip .detach() .css({ top: 0, left: 0, display: 'block' }) - .insertAfter(this.$element) + + this.options.container && $tip.appendTo(this.options.container).length || $tip.insertAfter(this.$element) pos = this.getPosition() @@ -279,6 +280,7 @@ , title: '' , delay: 0 , html: false + , container: '' } -- cgit v1.2.3 From e867ae7b603f3882832143ff315c9ab3fd3b8f13 Mon Sep 17 00:00:00 2001 From: Yohn Date: Mon, 24 Dec 2012 18:07:41 -0500 Subject: removed the length check updated it to @fat's suggestion --- js/bootstrap-tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 82fa96078..3ad8b6761 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -127,7 +127,7 @@ .detach() .css({ top: 0, left: 0, display: 'block' }) - this.options.container && $tip.appendTo(this.options.container).length || $tip.insertAfter(this.$element) + this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) pos = this.getPosition() -- cgit v1.2.3 From 9835549faf3c00a9f7ce1aa0303c020cc603a4a6 Mon Sep 17 00:00:00 2001 From: Yohn Date: Mon, 24 Dec 2012 18:59:37 -0500 Subject: made container option be false --- js/bootstrap-tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 3ad8b6761..48f9fcc6c 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -280,7 +280,7 @@ , title: '' , delay: 0 , html: false - , container: '' + , container: false } -- cgit v1.2.3