Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJacob Thornton <jacobthornton@gmail.com>2012-06-01 21:53:47 +0400
committerJacob Thornton <jacobthornton@gmail.com>2012-06-01 21:53:47 +0400
commit5657ab46c5351d5a5718eff3e8f7acf5cb43f752 (patch)
treeef81c0025662070b5a0e265f5c30155189f74e6f /js
parenta85c8fe74e2bea9c99ad405dd667035b5307e31e (diff)
parent4eaeea81fd909e6711f57049fc4372f4045fa5aa (diff)
Merge branch '2.0.4-wip'
Diffstat (limited to 'js')
-rw-r--r--js/README.md10
-rw-r--r--js/bootstrap-tooltip.js4
-rw-r--r--js/tests/unit/bootstrap-tooltip.js43
3 files changed, 38 insertions, 19 deletions
diff --git a/js/README.md b/js/README.md
index c7b71e70f2..b7927ba6b2 100644
--- a/js/README.md
+++ b/js/README.md
@@ -5,9 +5,9 @@ These are the high-level design rules which guide the development of Bootstrap's
### DATA-ATTRIBUTE API
-We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of javascript. This is bootstraps first class api.
+We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first class API.
-We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
+We acknowledge that this isn't always the most performant and it may sometimes be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
$('body').off('.data-api')
@@ -19,7 +19,7 @@ To target a specific plugin, just include the plugins name as a namespace along
### PROGRAMATIC API
-We also believe you should be able to use all plugins provided by Bootstrap purely through the JS API.
+We also believe you should be able to use all plugins provided by Bootstrap purely through the JavaScript API.
All public APIs should be single, chainable methods, and return the collection acted upon.
@@ -45,7 +45,7 @@ An options definition should take the following form:
*noun*: *adjective* - describes or modifies a quality of an instance
-examples:
+Examples:
backdrop: true
keyboard: false
@@ -93,7 +93,7 @@ Data attributes should take the following form:
- data-target || href^=# - defined on "control" element (if element controls an element other than self)
- data-{{noun}} - defines class instance options
-examples:
+Examples:
// control other targets
data-toggle="modal" data-target="#foo"
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index 577ead48b5..6ff2b47086 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -84,9 +84,9 @@
, leave: function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+ if (this.timeout) clearTimeout(this.timeout)
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()
@@ -272,4 +272,4 @@
, delay: 0
}
-}(window.jQuery); \ No newline at end of file
+}(window.jQuery);
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js
index 63f4f0b07c..7b0c10de00 100644
--- a/js/tests/unit/bootstrap-tooltip.js
+++ b/js/tests/unit/bootstrap-tooltip.js
@@ -33,7 +33,7 @@ $(function () {
.tooltip({placement: 'bottom'})
.tooltip('show')
- ok($(".tooltip").hasClass('fade bottom in'), 'has correct classes applied')
+ ok($(".tooltip").is('.fade.bottom.in'), 'has correct classes applied')
tooltip.tooltip('hide')
})
@@ -69,10 +69,29 @@ $(function () {
tooltip.trigger('mouseenter')
setTimeout(function () {
- ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
tooltip.trigger('mouseout')
setTimeout(function () {
- ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
+ start()
+ }, 200)
+ }, 100)
+ })
+
+ test("should not show tooltip if leave event occurs before delay expires, even if hide delay is 0", function () {
+ var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: { show: 200, hide: 0} })
+
+ stop()
+
+ tooltip.trigger('mouseenter')
+
+ setTimeout(function () {
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
start()
}, 200)
}, 100)
@@ -85,10 +104,10 @@ $(function () {
stop()
tooltip.trigger('mouseenter')
setTimeout(function () {
- ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
tooltip.trigger('mouseout')
setTimeout(function () {
- ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
start()
}, 100)
}, 50)
@@ -97,16 +116,16 @@ $(function () {
test("should show tooltip if leave event hasn't occured before delay expires", function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
- .tooltip({ delay: 200 })
+ .tooltip({ delay: 150 })
stop()
tooltip.trigger('mouseenter')
setTimeout(function () {
- ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
- setTimeout(function () {
- ok(!$(".tooltip").hasClass('fade in'), 'tooltip has faded in')
- start()
- }, 200)
+ ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
}, 100)
+ setTimeout(function () {
+ ok($(".tooltip").is('.fade.in'), 'tooltip has faded in')
+ start()
+ }, 200)
})
test("should detect if title string is html or text: foo", function () {
@@ -133,4 +152,4 @@ $(function () {
ok($.fn.tooltip.Constructor.prototype.isHTML($('<div></div>')), 'correctly detected html')
})
-}) \ No newline at end of file
+})