Commit a72d0d6e authored by fat's avatar fat
Browse files

fix tests

parent 19de2e86
Showing with 30 additions and 28 deletions
+30 -28
...@@ -53,12 +53,12 @@ $(function () { ...@@ -53,12 +53,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop(); stop();
$('<div class="tab"/>') $('<div class="tab"/>')
.bind('show', function (e) { .bind('bs:tab:show', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('shown', function () { .bind('bs:tab:shown', function () {
ok(false); ok(false);
}) })
.tab('show') .tab('show')
...@@ -78,7 +78,7 @@ $(function () { ...@@ -78,7 +78,7 @@ $(function () {
$(dropHTML).find('ul>li:first a').tab('show').end() $(dropHTML).find('ul>li:first a').tab('show').end()
.find('ul>li:last a').on('show', function(event){ .find('ul>li:last a').on('show', function(event){
equals(event.relatedTarget.hash, "#1-1") equals(event.relatedTarget.hash, "#1-1")
}).on('shown', function(event){ }).on('bs:tab:shown', function(event){
equals(event.relatedTarget.hash, "#1-1") equals(event.relatedTarget.hash, "#1-1")
}).tab('show') }).tab('show')
}) })
......
...@@ -19,7 +19,7 @@ $(function () { ...@@ -19,7 +19,7 @@ $(function () {
}) })
test("should expose default settings", function () { test("should expose default settings", function () {
ok(!!$.fn.tooltip.defaults, 'defaults is defined') ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined')
}) })
test("should empty title attribute", function () { test("should empty title attribute", function () {
...@@ -69,7 +69,7 @@ $(function () { ...@@ -69,7 +69,7 @@ $(function () {
test("should fire show event", function () { test("should fire show event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("show", function() { .bind("bs:tooltip:show", function() {
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
...@@ -79,7 +79,7 @@ $(function () { ...@@ -79,7 +79,7 @@ $(function () {
test("should fire shown event", function () { test("should fire shown event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
ok(true, "shown was called") ok(true, "shown was called")
start() start()
}) })
...@@ -89,12 +89,12 @@ $(function () { ...@@ -89,12 +89,12 @@ $(function () {
test("should not fire shown event when default prevented", function () { test("should not fire shown event when default prevented", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("show", function(e) { .bind("bs:tooltip:show", function(e) {
e.preventDefault() e.preventDefault()
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
ok(false, "shown was called") ok(false, "shown was called")
}) })
.tooltip('show') .tooltip('show')
...@@ -103,10 +103,10 @@ $(function () { ...@@ -103,10 +103,10 @@ $(function () {
test("should fire hide event", function () { test("should fire hide event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("hide", function() { .bind("bs:tooltip:hide", function() {
ok(true, "hide was called") ok(true, "hide was called")
start() start()
}) })
...@@ -116,10 +116,10 @@ $(function () { ...@@ -116,10 +116,10 @@ $(function () {
test("should fire hidden event", function () { test("should fire hidden event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("hidden", function() { .bind("bs:tooltip:hidden", function() {
ok(true, "hidden was called") ok(true, "hidden was called")
start() start()
}) })
...@@ -129,15 +129,15 @@ $(function () { ...@@ -129,15 +129,15 @@ $(function () {
test("should not fire hidden event when default prevented", function () { test("should not fire hidden event when default prevented", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("hide", function(e) { .bind("bs:tooltip:hide", function(e) {
e.preventDefault() e.preventDefault()
ok(true, "hide was called") ok(true, "hide was called")
start() start()
}) })
.bind("hidden", function() { .bind("bs:tooltip:hidden", function() {
ok(false, "hidden was called") ok(false, "hidden was called")
}) })
.tooltip('show') .tooltip('show')
...@@ -214,13 +214,13 @@ $(function () { ...@@ -214,13 +214,13 @@ $(function () {
test("should destroy tooltip", function () { test("should destroy tooltip", function () {
var tooltip = $('<div/>').tooltip().on('click.foo', function(){}) var tooltip = $('<div/>').tooltip().on('click.foo', function(){})
ok(tooltip.data('tooltip'), 'tooltip has data') ok(tooltip.data('bs-tooltip'), 'tooltip has data')
ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event') ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event') ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
tooltip.tooltip('show') tooltip.tooltip('show')
tooltip.tooltip('destroy') tooltip.tooltip('destroy')
ok(!tooltip.hasClass('in'), 'tooltip is hidden') ok(!tooltip.hasClass('in'), 'tooltip is hidden')
ok(!$._data(tooltip[0], 'tooltip'), 'tooltip does not have data') ok(!$._data(tooltip[0], 'bs-tooltip'), 'tooltip does not have data')
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo') ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo')
ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
}) })
......
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
} }
Tooltip.prototype.init = function (type, element, options) { Tooltip.prototype.init = function (type, element, options) {
this.type = type
this.options = this.getOptions(options)
this.enabled = true this.enabled = true
this.type = type
this.$element = $(element) this.$element = $(element)
this.options = this.getOptions(options)
var triggers = this.options.trigger.split(' ') var triggers = this.options.trigger.split(' ')
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
if (defaults[key] != value) options[key] = value if (defaults[key] != value) options[key] = value
}, this) }, this)
var self = $(e.currentTarget)[this.type](options).data(this.type) var self = $(e.currentTarget)[this.type](options).data('bs-' + this.type)
if (!self.options.delay || !self.options.delay.show) return self.show() if (!self.options.delay || !self.options.delay.show) return self.show()
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
} }
Tooltip.prototype.leave = function (e) { Tooltip.prototype.leave = function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type) var self = $(e.currentTarget)[this.type](this._options).data('bs-' + this.type)
if (this.timeout) clearTimeout(this.timeout) if (this.timeout) clearTimeout(this.timeout)
if (!self.options.delay || !self.options.delay.hide) return self.hide() if (!self.options.delay || !self.options.delay.hide) return self.hide()
...@@ -168,10 +168,12 @@ ...@@ -168,10 +168,12 @@
} }
this.applyPlacement(tp, placement) this.applyPlacement(tp, placement)
this.$element.trigger('shown') this.$element.trigger('bs:' + this.type + ':shown')
} }
}
Tooltip.prototype.applyPlacement = function(offset, placement) { Tooltip.prototype.applyPlacement = function(offset, placement) {
var replace
var $tip = this.tip() var $tip = this.tip()
var width = $tip[0].offsetWidth var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight var height = $tip[0].offsetHeight
...@@ -185,7 +187,7 @@ ...@@ -185,7 +187,7 @@
var actualHeight = $tip[0].offsetHeight var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) { if (placement == 'top' && actualHeight != height) {
var replace = true replace = true
offset.top = offset.top + height - actualHeight offset.top = offset.top + height - actualHeight
} }
...@@ -210,7 +212,7 @@ ...@@ -210,7 +212,7 @@
if (replace) $tip.offset(offset) if (replace) $tip.offset(offset)
} }
Tooltip.prototype.replaceArrow = function(delta, dimension, position){ Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
} }
...@@ -248,7 +250,7 @@ ...@@ -248,7 +250,7 @@
removeWithAnimation() : removeWithAnimation() :
$tip.detach() $tip.detach()
this.$element.trigger('hidden') this.$element.trigger('bs:' + this.type + ':hidden')
return this return this
} }
...@@ -312,12 +314,12 @@ ...@@ -312,12 +314,12 @@
} }
Tooltip.prototype.toggle = function (e) { Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this var self = e ? $(e.currentTarget)[this.type](this._options).data('bs-' + this.type) : this
self.tip().hasClass('in') ? self.hide() : self.show() self.tip().hasClass('in') ? self.hide() : self.show()
} }
Tooltip.prototype.destroy = function () { Tooltip.prototype.destroy = function () {
this.hide().$element.off('.' + this.type).removeData(this.type) this.hide().$element.off('.' + this.type).removeData('bs-' + this.type)
} }
...@@ -326,7 +328,7 @@ ...@@ -326,7 +328,7 @@
var old = $.fn.tooltip var old = $.fn.tooltip
$.fn.tooltip = function ( option ) { $.fn.tooltip = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-tooltip') var data = $this.data('bs-tooltip')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment