diff options
| author | fat <[email protected]> | 2013-05-16 17:44:50 -0700 |
|---|---|---|
| committer | fat <[email protected]> | 2013-05-16 17:44:50 -0700 |
| commit | a72d0d6e3a5f2691eaa7e036a7b081d021097159 (patch) | |
| tree | ca0c1037f00dad04ed1d19bcded06762bbfd2cc5 /js | |
| parent | 19de2e86035746b4cda13d4e3860bc549b4f4841 (diff) | |
| download | bootstrap-a72d0d6e3a5f2691eaa7e036a7b081d021097159.tar.xz bootstrap-a72d0d6e3a5f2691eaa7e036a7b081d021097159.zip | |
fix tests
Diffstat (limited to 'js')
| -rw-r--r-- | js/collapse.js | 4 | ||||
| -rw-r--r-- | js/modal.js | 6 | ||||
| -rw-r--r-- | js/popover.js | 2 | ||||
| -rw-r--r-- | js/tests/unit/alert.js | 4 | ||||
| -rw-r--r-- | js/tests/unit/carousel.js | 14 | ||||
| -rw-r--r-- | js/tests/unit/collapse.js | 12 | ||||
| -rw-r--r-- | js/tests/unit/modal.js | 28 | ||||
| -rw-r--r-- | js/tests/unit/popover.js | 4 | ||||
| -rw-r--r-- | js/tests/unit/tab.js | 6 | ||||
| -rw-r--r-- | js/tests/unit/tooltip.js | 28 | ||||
| -rw-r--r-- | js/tooltip.js | 24 |
11 files changed, 67 insertions, 65 deletions
diff --git a/js/collapse.js b/js/collapse.js index c9db1767f..95c91c299 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -56,7 +56,7 @@ } this.$element[dimension](0) - this.transition('addClass', $.Event('bs:collapse:show'), 'shown') + this.transition('addClass', $.Event('bs:collapse:show'), 'bs:collapse:shown') if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) } @@ -85,7 +85,7 @@ Collapse.prototype.transition = function (method, startEvent, completeEvent) { var that = this var complete = function () { - if (startEvent.type == 'show') that.reset() + if (startEvent.type == 'bs:collapse:show') that.reset() that.transitioning = 0 that.$element.trigger(completeEvent) } diff --git a/js/modal.js b/js/modal.js index 7acd3930a..f58f2000e 100644 --- a/js/modal.js +++ b/js/modal.js @@ -80,7 +80,7 @@ }) } - Modal.prototype.show = function (e) { + Modal.prototype.hide = function (e) { if (e) e.preventDefault() e = $.Event('bs:modal:hide') @@ -144,12 +144,12 @@ }) } - Modal.prototype.removeBackdrop: function () { + Modal.prototype.removeBackdrop = function () { this.$backdrop && this.$backdrop.remove() this.$backdrop = null } - Modal.prototype.backdrop: function (callback) { + Modal.prototype.backdrop = function (callback) { var that = this var animate = this.$element.hasClass('fade') ? 'fade' : '' diff --git a/js/popover.js b/js/popover.js index 1dad9bc3c..20bbaf1a4 100644 --- a/js/popover.js +++ b/js/popover.js @@ -63,7 +63,7 @@ Popover.prototype.getContent = function () { var content = typeof this.options.content == 'function' ? - this.options.content.call($e[0]) : + this.options.content.call(this.$element[0]) : this.options.content return content || this.$element.attr('data-content') diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index 03993d07f..3054767f6 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -48,12 +48,12 @@ $(function () { $.support.transition = false stop(); $('<div class="alert"/>') - .bind('bs-close', function (e) { + .bind('bs:alert:close', function (e) { e.preventDefault(); ok(true); start(); }) - .bind('bs-closed', function () { + .bind('bs:alert:closed', function () { ok(false); }) .alert('close') diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 396217e75..4d0bd6e81 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -20,12 +20,12 @@ $(function () { $.support.transition = false stop() $('<div class="carousel"/>') - .bind('slide', function (e) { + .bind('bs:carousel:slide', function (e) { e.preventDefault(); ok(true); start(); }) - .bind('slid', function () { + .bind('bs:carousel:slid', function () { ok(false); }) .carousel('next') @@ -35,7 +35,7 @@ $(function () { var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div></div><a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>' $.support.transition = false stop() - $(template).on('slide', function (e) { + $(template).on('bs:carousel:slide', function (e) { e.preventDefault() ok(e.direction) ok(e.direction === 'right' || e.direction === 'left') @@ -48,7 +48,7 @@ $(function () { $.support.transition = false stop() $(template) - .on('slide', function (e) { + .on('bs:carousel:slide', function (e) { e.preventDefault(); ok(e.relatedTarget); ok($(e.relatedTarget).hasClass('item')); @@ -63,19 +63,19 @@ $(function () { template.appendTo("body"); $('[data-slide]').first().click(); - ok($('#myCarousel').data('carousel').options.interval == 1814); + ok($('#myCarousel').data('bs-carousel').options.interval == 1814); $('#myCarousel').remove(); template.appendTo("body").attr("data-modal", "foobar"); $('[data-slide]').first().click(); - ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); + ok($('#myCarousel').data('bs-carousel').options.interval == 1814, "even if there is an data-modal attribute set"); $('#myCarousel').remove(); template.appendTo("body"); $('[data-slide]').first().click(); $('#myCarousel').attr('data-interval', 1860); $('[data-slide]').first().click(); - ok($('#myCarousel').data('carousel').options.interval == 1814, "attributes should be read only on intitialization"); + ok($('#myCarousel').data('bs-carousel').options.interval == 1814, "attributes should be read only on intitialization"); $('#myCarousel').remove(); }) }) diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 6750c7a87..832d6d45d 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -32,12 +32,12 @@ $(function () { $.support.transition = false stop() $('<div class="collapse"/>') - .bind('show', function (e) { + .bind('bs:collapse:show', function (e) { e.preventDefault(); ok(true); start(); }) - .bind('shown', function () { + .bind('bs:collapse:shown', function () { ok(false); }) .collapse('show') @@ -47,10 +47,10 @@ $(function () { $.support.transition = false stop() $('<div class="collapse" style="height: 0px"/>') - .bind('show', function () { + .bind('bs:collapse:show', function () { ok(this.style.height == '0px') }) - .bind('shown', function () { + .bind('bs:collapse:shown', function () { ok(this.style.height == 'auto') start() }) @@ -66,7 +66,7 @@ $(function () { var collapsible = $('<div id="test1"></div>') .appendTo($('#qunit-fixture')) - .on('show', function () { + .on('bs:collapse:show', function () { ok(!target.hasClass('collapsed')) start() }) @@ -83,7 +83,7 @@ $(function () { var collapsible = $('<div id="test1" class="in"></div>') .appendTo($('#qunit-fixture')) - .on('hide', function () { + .on('bs:collapse:hide', function () { ok(target.hasClass('collapsed')) start() }) diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 1d3baa812..7d684f3ae 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -20,14 +20,14 @@ $(function () { }) test("should expose defaults var for settings", function () { - ok($.fn.modal.defaults, 'default object exposed') + ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed') }) test("should insert into dom when show method is called", function () { stop() $.support.transition = false $("<div id='modal-test'></div>") - .bind("shown", function () { + .bind("bs:modal:shown", function () { ok($('#modal-test').length, 'modal insterted into dom') $(this).remove() start() @@ -39,10 +39,10 @@ $(function () { stop() $.support.transition = false $("<div id='modal-test'></div>") - .bind("show", function () { + .bind("bs:modal:show", function () { ok(true, "show was called") }) - .bind("shown", function () { + .bind("bs:modal:shown", function () { $(this).remove() start() }) @@ -53,12 +53,12 @@ $(function () { stop() $.support.transition = false $("<div id='modal-test'></div>") - .bind("show", function (e) { + .bind("bs:modal:show", function (e) { e.preventDefault() ok(true, "show was called") start() }) - .bind("shown", function () { + .bind("bs:modal:shown", function () { ok(false, "shown was called") }) .modal("show") @@ -69,12 +69,12 @@ $(function () { $.support.transition = false $("<div id='modal-test'></div>") - .bind("shown", function () { + .bind("bs:modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').length, 'modal insterted into dom') $(this).modal("hide") }) - .bind("hidden", function() { + .bind("bs:modal:hidden", function() { ok(!$('#modal-test').is(":visible"), 'modal hidden') $('#modal-test').remove() start() @@ -87,12 +87,12 @@ $(function () { $.support.transition = false var div = $("<div id='modal-test'></div>") div - .bind("shown", function () { + .bind("bs:modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').length, 'modal insterted into dom') div.modal("toggle") }) - .bind("hidden", function() { + .bind("bs:modal:hidden", function() { ok(!$('#modal-test').is(":visible"), 'modal hidden') div.remove() start() @@ -105,12 +105,12 @@ $(function () { $.support.transition = false var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>") div - .bind("shown", function () { + .bind("bs:modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').length, 'modal insterted into dom') div.find('.close').click() }) - .bind("hidden", function() { + .bind("bs:modal:hidden", function() { ok(!$('#modal-test').is(":visible"), 'modal hidden') div.remove() start() @@ -123,11 +123,11 @@ $(function () { $.support.transition = false var div = $("<div>", { id: 'modal-test', "data-backdrop": false }) div - .bind("shown", function () { + .bind("bs:modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible') div.modal("hide") }) - .bind("hidden", function() { + .bind("bs:modal:hidden", function() { ok(!$('#modal-test').is(":visible"), 'modal hidden') div.remove() start() diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index c62bb8ac1..53980e722 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -34,7 +34,7 @@ $(function () { var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') .popover() - ok(!!popover.data('popover'), 'popover instance exists') + ok(!!popover.data('bs-popover'), 'popover instance exists') }) test("should get title and content from options", function () { @@ -99,7 +99,7 @@ $(function () { test("should destroy popover", function () { var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){}) - ok(popover.data('popover'), 'popover has data') + ok(popover.data('bs-popover'), 'popover has data') ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event') ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event') popover.popover('show') diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index 2a92b4d32..40e4656a7 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -53,12 +53,12 @@ $(function () { $.support.transition = false stop(); $('<div class="tab"/>') - .bind('show', function (e) { + .bind('bs:tab:show', function (e) { e.preventDefault(); ok(true); start(); }) - .bind('shown', function () { + .bind('bs:tab:shown', function () { ok(false); }) .tab('show') @@ -78,7 +78,7 @@ $(function () { $(dropHTML).find('ul>li:first a').tab('show').end() .find('ul>li:last a').on('show', function(event){ equals(event.relatedTarget.hash, "#1-1") - }).on('shown', function(event){ + }).on('bs:tab:shown', function(event){ equals(event.relatedTarget.hash, "#1-1") }).tab('show') }) diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index b97be3c9b..8a1be0eca 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -19,7 +19,7 @@ $(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 () { @@ -69,7 +69,7 @@ $(function () { test("should fire show event", function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .bind("show", function() { + .bind("bs:tooltip:show", function() { ok(true, "show was called") start() }) @@ -79,7 +79,7 @@ $(function () { test("should fire shown event", function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .bind("shown", function() { + .bind("bs:tooltip:shown", function() { ok(true, "shown was called") start() }) @@ -89,12 +89,12 @@ $(function () { test("should not fire shown event when default prevented", function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .bind("show", function(e) { + .bind("bs:tooltip:show", function(e) { e.preventDefault() ok(true, "show was called") start() }) - .bind("shown", function() { + .bind("bs:tooltip:shown", function() { ok(false, "shown was called") }) .tooltip('show') @@ -103,10 +103,10 @@ $(function () { test("should fire hide event", function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .bind("shown", function() { + .bind("bs:tooltip:shown", function() { $(this).tooltip('hide') }) - .bind("hide", function() { + .bind("bs:tooltip:hide", function() { ok(true, "hide was called") start() }) @@ -116,10 +116,10 @@ $(function () { test("should fire hidden event", function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .bind("shown", function() { + .bind("bs:tooltip:shown", function() { $(this).tooltip('hide') }) - .bind("hidden", function() { + .bind("bs:tooltip:hidden", function() { ok(true, "hidden was called") start() }) @@ -129,15 +129,15 @@ $(function () { test("should not fire hidden event when default prevented", function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .bind("shown", function() { + .bind("bs:tooltip:shown", function() { $(this).tooltip('hide') }) - .bind("hide", function(e) { + .bind("bs:tooltip:hide", function(e) { e.preventDefault() ok(true, "hide was called") start() }) - .bind("hidden", function() { + .bind("bs:tooltip:hidden", function() { ok(false, "hidden was called") }) .tooltip('show') @@ -214,13 +214,13 @@ $(function () { test("should destroy tooltip", 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').click[0].namespace == 'foo', 'tooltip has extra click.foo event') tooltip.tooltip('show') tooltip.tooltip('destroy') 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').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') }) diff --git a/js/tooltip.js b/js/tooltip.js index 60cbe1200..a40d242fc 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -48,10 +48,10 @@ } Tooltip.prototype.init = function (type, element, options) { - this.type = type - this.options = this.getOptions(options) this.enabled = true + this.type = type this.$element = $(element) + this.options = this.getOptions(options) var triggers = this.options.trigger.split(' ') @@ -99,7 +99,7 @@ if (defaults[key] != value) options[key] = value }, 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() @@ -112,7 +112,7 @@ } 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 (!self.options.delay || !self.options.delay.hide) return self.hide() @@ -168,10 +168,12 @@ } this.applyPlacement(tp, placement) - this.$element.trigger('shown') + this.$element.trigger('bs:' + this.type + ':shown') } + } Tooltip.prototype.applyPlacement = function(offset, placement) { + var replace var $tip = this.tip() var width = $tip[0].offsetWidth var height = $tip[0].offsetHeight @@ -185,7 +187,7 @@ var actualHeight = $tip[0].offsetHeight if (placement == 'top' && actualHeight != height) { - var replace = true + replace = true offset.top = offset.top + height - actualHeight } @@ -210,7 +212,7 @@ 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) + "%") : '') } @@ -248,7 +250,7 @@ removeWithAnimation() : $tip.detach() - this.$element.trigger('hidden') + this.$element.trigger('bs:' + this.type + ':hidden') return this } @@ -312,12 +314,12 @@ } 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() } 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 @@ var old = $.fn.tooltip - $.fn.tooltip = function ( option ) { + $.fn.tooltip = function (option) { return this.each(function () { var $this = $(this) var data = $this.data('bs-tooltip') |
