From d5fb653914617d63739142f6ecef00afd4d3c796 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 21 Mar 2012 21:35:02 -0700 Subject: top stripping leading and trailing whitespace + always use .html method --- js/bootstrap-tooltip.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 49b5f7286..2b5f146b1 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -206,8 +206,6 @@ title = $e.attr('data-original-title') || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) - title = (title || '').toString().replace(/(^\s*|\s*$)/, "") - return title } -- cgit v1.2.3 From 94b24aaa473755093677cb4eb80faf3daee53357 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 21 Mar 2012 21:57:06 -0700 Subject: clear timeout to reset delays for tooltip/popover --- js/bootstrap-tooltip.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 2b5f146b1..7d58a6c8d 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -73,8 +73,9 @@ if (!self.options.delay || !self.options.delay.show) { self.show() } else { + clearTimeout(this.timeout) self.hoverState = 'in' - setTimeout(function() { + this.timeout = setTimeout(function() { if (self.hoverState == 'in') { self.show() } @@ -88,8 +89,9 @@ if (!self.options.delay || !self.options.delay.hide) { self.hide() } else { + clearTimeout(this.timeout) self.hoverState = 'out' - setTimeout(function() { + this.timeout = setTimeout(function() { if (self.hoverState == 'out') { self.hide() } -- cgit v1.2.3 From f02d017ffa2f63609db034410979f62fde328816 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 24 Mar 2012 18:59:04 -0700 Subject: return matcher value directly + cleanup first lines of files --- js/bootstrap-tooltip.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 7d58a6c8d..4704d1e02 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -18,7 +18,8 @@ * limitations under the License. * ========================================================== */ -!function( $ ) { + +!function ( $ ) { "use strict" -- cgit v1.2.3 From 4bd611884a5f1dd02878f73bccd51d85c1e49186 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 4 Apr 2012 14:58:04 -0700 Subject: detect if title in tooltip is text or html. if text - use `text` method to prevent xss. all add a few notes to js readme about updated event --- js/bootstrap-tooltip.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 4704d1e02..63e903cb4 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -155,9 +155,21 @@ } } + , isHTML: function( text ) { + // html string detection logic adapted from jQuery + return typeof text != 'string' + || ( text.charAt(0) === "<" + && text.charAt( text.length - 1 ) === ">" + && text.length >= 3 + ) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text) + } + , setContent: function () { var $tip = this.tip() - $tip.find('.tooltip-inner').html(this.getTitle()) + , title = this.getTitle() + , isHTML = this.isHTML(title) + + $tip.find('.tooltip-inner')[isHTML ? 'html' : 'text'](title) $tip.removeClass('fade in top bottom left right') } -- cgit v1.2.3 From 83febb3452ecd81241ddc004509ec64de8b13a92 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 4 Apr 2012 15:02:30 -0700 Subject: remake and add isHTML check to popover as well --- js/bootstrap-tooltip.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 63e903cb4..2f9254ed2 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -167,9 +167,8 @@ , setContent: function () { var $tip = this.tip() , title = this.getTitle() - , isHTML = this.isHTML(title) - $tip.find('.tooltip-inner')[isHTML ? 'html' : 'text'](title) + $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title) $tip.removeClass('fade in top bottom left right') } -- cgit v1.2.3 From 575f18aaf49abb0289185f6409bee031947ccf69 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Apr 2012 16:29:53 -0700 Subject: add jshint support + a few minor stylistic changes --- js/bootstrap-tooltip.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 2f9254ed2..454e7a448 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -19,14 +19,15 @@ * ========================================================== */ -!function ( $ ) { +!function ($) { + + "use strict"; // jshint ;_; - "use strict" /* TOOLTIP PUBLIC CLASS DEFINITION * =============================== */ - var Tooltip = function ( element, options ) { + var Tooltip = function (element, options) { this.init('tooltip', element, options) } @@ -34,7 +35,7 @@ constructor: Tooltip - , init: function ( type, element, options ) { + , init: function (type, element, options) { var eventIn , eventOut @@ -55,7 +56,7 @@ this.fixTitle() } - , getOptions: function ( options ) { + , getOptions: function (options) { options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data()) if (options.delay && typeof options.delay == 'number') { @@ -68,7 +69,7 @@ return options } - , enter: function ( e ) { + , enter: function (e) { var self = $(e.currentTarget)[this.type](this._options).data(this.type) if (!self.options.delay || !self.options.delay.show) { @@ -84,7 +85,7 @@ } } - , leave: function ( e ) { + , leave: function (e) { var self = $(e.currentTarget)[this.type](this._options).data(this.type) if (!self.options.delay || !self.options.delay.hide) { @@ -155,7 +156,7 @@ } } - , isHTML: function( text ) { + , isHTML: function(text) { // html string detection logic adapted from jQuery return typeof text != 'string' || ( text.charAt(0) === "<" @@ -271,12 +272,12 @@ $.fn.tooltip.defaults = { animation: true - , delay: 0 - , selector: false , placement: 'top' + , selector: false + , template: '
' , trigger: 'hover' , title: '' - , template: '
' + , delay: 0 } -}( window.jQuery ); \ No newline at end of file +}(window.jQuery); \ No newline at end of file -- cgit v1.2.3 From b14455b03a977cbbf99112d39b55461785666a3f Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Apr 2012 23:10:03 -0700 Subject: add tests for mouseout delay in tooltip --- js/bootstrap-tooltip.js | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'js/bootstrap-tooltip.js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 454e7a448..af2e58968 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -72,33 +72,25 @@ , enter: function (e) { var self = $(e.currentTarget)[this.type](this._options).data(this.type) - if (!self.options.delay || !self.options.delay.show) { - self.show() - } else { - clearTimeout(this.timeout) - self.hoverState = 'in' - this.timeout = setTimeout(function() { - if (self.hoverState == 'in') { - self.show() - } - }, self.options.delay.show) - } + if (!self.options.delay || !self.options.delay.show) return self.show() + + clearTimeout(this.timeout) + self.hoverState = 'in' + this.timeout = setTimeout(function() { + if (self.hoverState == 'in') self.show() + }, self.options.delay.show) } , leave: function (e) { var self = $(e.currentTarget)[this.type](this._options).data(this.type) - if (!self.options.delay || !self.options.delay.hide) { - self.hide() - } else { - clearTimeout(this.timeout) - self.hoverState = 'out' - this.timeout = setTimeout(function() { - if (self.hoverState == 'out') { - self.hide() - } - }, self.options.delay.hide) - } + if (!self.options.delay || !self.options.delay.hide) return self.hide() + + clearTimeout(this.timeout) + self.hoverState = 'out' + this.timeout = setTimeout(function() { + if (self.hoverState == 'out') self.hide() + }, self.options.delay.hide) } , show: function () { -- cgit v1.2.3 From 839ef3a030b355d0f0c35d6c9e42ecba8b072036 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 24 Apr 2012 02:19:02 -0700 Subject: 2.0.2 -> 2.0.3 --- 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 af2e58968..577ead48b 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -1,5 +1,5 @@ /* =========================================================== - * bootstrap-tooltip.js v2.0.2 + * bootstrap-tooltip.js v2.0.3 * http://twitter.github.com/bootstrap/javascript.html#tooltips * Inspired by the original jQuery.tipsy by Jason Frame * =========================================================== -- cgit v1.2.3