0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

change namespace back to dot notation and someother js shizzle

This commit is contained in:
fat 2013-05-16 20:19:51 -07:00
parent 5ab72f7687
commit 140ef2320b
22 changed files with 105 additions and 103 deletions

View File

@ -17,7 +17,7 @@ lead: "Bring Bootstrap's components to life with over a dozen custom jQuery plug
<p>Plugins can be included individually, or all at once. <strong>Do not attempt to include both.</strong> Both <strong>bootstrap.js</strong> and <strong>bootstrap.min.js</strong> contain all plugins in a single file.</p> <p>Plugins can be included individually, or all at once. <strong>Do not attempt to include both.</strong> Both <strong>bootstrap.js</strong> and <strong>bootstrap.min.js</strong> contain all plugins in a single file.</p>
<div class="bs-callout"> <div class="bs-callout">
<h4>Plugin dependencies</h4> <h4>Plugin dependencies</h4>
<p>Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs (in notes like this one).</p> <p>Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs.</p>
</div> </div>
<h3 id="js-data-attrs">Data attributes</h3> <h3 id="js-data-attrs">Data attributes</h3>

View File

@ -26,8 +26,8 @@
var Affix = function (element, options) { var Affix = function (element, options) {
this.options = $.extend({}, Affix.DEFAULTS, options) this.options = $.extend({}, Affix.DEFAULTS, options)
this.$window = $(window) this.$window = $(window)
.on('scroll.bs-affix.bs-data-api', $.proxy(this.checkPosition, this)) .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.bs-affix.bs-data-api', $.proxy(this.checkPositionWithEventLoop, this)) .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
this.$element = $(element) this.$element = $(element)
this.affixed = this.affixed =
@ -80,10 +80,10 @@
$.fn.affix = function (option) { $.fn.affix = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-affix') var data = $this.data('bs.affix')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs-affix', (data = new Affix(this, options))) if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }

View File

@ -45,14 +45,14 @@
$parent = $this.hasClass('alert') ? $this : $this.parent() $parent = $this.hasClass('alert') ? $this : $this.parent()
} }
$parent.trigger(e = $.Event('bs:alert:close')) $parent.trigger(e = $.Event('close.bs.alert'))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$parent.removeClass('in') $parent.removeClass('in')
function removeElement() { function removeElement() {
$parent.trigger('bs-closed').remove() $parent.trigger('closed.bs.alert').remove()
} }
$.support.transition && $parent.hasClass('fade') ? $.support.transition && $parent.hasClass('fade') ?
@ -69,9 +69,9 @@
$.fn.alert = function (option) { $.fn.alert = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-alert') var data = $this.data('bs.alert')
if (!data) $this.data('bs-alert', (data = new Alert(this))) if (!data) $this.data('bs.alert', (data = new Alert(this)))
if (typeof option == 'string') data[option].call($this) if (typeof option == 'string') data[option].call($this)
}) })
} }
@ -91,6 +91,6 @@
// ALERT DATA-API // ALERT DATA-API
// ============== // ==============
$(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close) $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
}(window.jQuery); }(window.jQuery);

View File

@ -74,7 +74,7 @@
var data = $this.data('button') var data = $this.data('button')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs-button', (data = new Button(this, options))) if (!data) $this.data('bs.button', (data = new Button(this, options)))
if (option == 'toggle') data.toggle() if (option == 'toggle') data.toggle()
else if (option) data.setState(option) else if (option) data.setState(option)
@ -96,7 +96,7 @@
// BUTTON DATA-API // BUTTON DATA-API
// =============== // ===============
$(document).on('click.bs-button.bs-data-api', '[data-toggle^=button]', function (e) { $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target) var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle') $btn.button('toggle')

View File

@ -111,7 +111,7 @@
$next = $next.length ? $next : this.$element.find('.item')[fallback]() $next = $next.length ? $next : this.$element.find('.item')[fallback]()
var e = $.Event('bs:carousel:slide', { relatedTarget: $next[0], direction: direction }) var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
if ($next.hasClass('active')) return if ($next.hasClass('active')) return
@ -159,11 +159,11 @@
$.fn.carousel = function (option) { $.fn.carousel = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-carousel') var data = $this.data('bs.carousel')
var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option) var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option)
var action = typeof option == 'string' ? option : options.slide var action = typeof option == 'string' ? option : options.slide
if (!data) $this.data('bs-carousel', (data = new Carousel(this, options))) if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
if (typeof option == 'number') data.to(option) if (typeof option == 'number') data.to(option)
else if (action) data[action]() else if (action) data[action]()
else if (options.interval) data.pause().cycle() else if (options.interval) data.pause().cycle()

View File

@ -56,7 +56,7 @@
} }
this.$element[dimension](0) this.$element[dimension](0)
this.transition('addClass', $.Event('bs:collapse:show'), 'bs:collapse:shown') this.transition('addClass', $.Event('show.bs.collapse'), 'shown.bs.collapse')
if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
} }
@ -65,7 +65,7 @@
if (this.transitioning || !this.$element.hasClass('in')) return if (this.transitioning || !this.$element.hasClass('in')) return
var dimension = this.dimension() var dimension = this.dimension()
this.reset(this.$element[dimension]()) this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('bs:collapse:hide'), 'hidden') this.transition('removeClass', $.Event('hide.bs.collapse'), 'hidden')
this.$element[dimension](0) this.$element[dimension](0)
} }
@ -85,7 +85,7 @@
Collapse.prototype.transition = function (method, startEvent, completeEvent) { Collapse.prototype.transition = function (method, startEvent, completeEvent) {
var that = this var that = this
var complete = function () { var complete = function () {
if (startEvent.type == 'bs:collapse:show') that.reset() if (startEvent.type == 'show') that.reset()
that.transitioning = 0 that.transitioning = 0
that.$element.trigger(completeEvent) that.$element.trigger(completeEvent)
} }

View File

@ -44,7 +44,7 @@
Modal.prototype.show = function () { Modal.prototype.show = function () {
var that = this var that = this
var e = $.Event('bs:modal:show') var e = $.Event('show.bs.modal')
this.$element.trigger(e) this.$element.trigger(e)
@ -74,8 +74,8 @@
that.enforceFocus() that.enforceFocus()
transition ? transition ?
that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('bs:modal:shown') }) : that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown.bs.modal') }) :
that.$element.focus().trigger('bs:modal:shown') that.$element.focus().trigger('shown.bs.modal')
}) })
} }
@ -83,7 +83,7 @@
Modal.prototype.hide = function (e) { Modal.prototype.hide = function (e) {
if (e) e.preventDefault() if (e) e.preventDefault()
e = $.Event('bs:modal:hide') e = $.Event('hide.bs.modal')
this.$element.trigger(e) this.$element.trigger(e)
@ -93,7 +93,7 @@
this.escape() this.escape()
$(document).off('focusin.modal') $(document).off('focusin.bs.modal')
this.$element this.$element
.removeClass('in') .removeClass('in')
@ -105,7 +105,7 @@
} }
Modal.prototype.enforceFocus = function () { Modal.prototype.enforceFocus = function () {
$(document).on('focusin.modal', function (e) { $(document).on('focusin.bs.modal', function (e) {
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.focus() this.$element.focus()
} }
@ -114,11 +114,11 @@
Modal.prototype.escape = function () { Modal.prototype.escape = function () {
if (this.isShown && this.options.keyboard) { if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) { this.$element.on('keyup.dismiss.bs.modal', function ( e ) {
e.which == 27 && this.hide() e.which == 27 && this.hide()
}, this) }, this)
} else if (!this.isShown) { } else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal') this.$element.off('keyup.dismiss.bs.modal')
} }
} }
@ -140,7 +140,7 @@
this.$element.hide() this.$element.hide()
this.backdrop(function () { this.backdrop(function () {
that.removeBackdrop() that.removeBackdrop()
that.$element.trigger('bs:modal:hidden') that.$element.trigger('hidden.bs.modal')
}) })
} }
@ -196,10 +196,10 @@
$.fn.modal = function (option) { $.fn.modal = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-modal') var data = $this.data('bs.modal')
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('bs-modal', (data = new Modal(this, options))) if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
else if (options.show) data.show() else if (options.show) data.show()
}) })
@ -220,7 +220,7 @@
// MODAL DATA-API // MODAL DATA-API
// ============== // ==============
$(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this) var $this = $(this)
var href = $this.attr('href') var href = $this.attr('href')
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
@ -236,7 +236,7 @@
}) })
var $body = $(document.body) var $body = $(document.body)
.on('bs:modal:shown', '.modal', function () { $body.addClass('modal-open') }) .on('bs.modal.shown', '.modal', function () { $body.addClass('modal-open') })
.on('bs:modal:hidden', '.modal', function () { $body.removeClass('modal-open') }) .on('bs.modal.hidden', '.modal', function () { $body.removeClass('modal-open') })
}(window.jQuery); }(window.jQuery);

View File

@ -87,10 +87,10 @@
$.fn.popover = function (option) { $.fn.popover = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-popover') var data = $this.data('bs.popover')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs-popover', (data = new Popover(this, options))) if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }

View File

@ -123,10 +123,10 @@
$.fn.scrollspy = function (option) { $.fn.scrollspy = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-scrollspy') var data = $this.data('bs.scrollspy')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs-scrollspy', (data = new ScrollSpy(this, options))) if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }

View File

@ -40,7 +40,7 @@
if ($this.parent('li').hasClass('active')) return if ($this.parent('li').hasClass('active')) return
var previous = $ul.find('.active:last a')[0] var previous = $ul.find('.active:last a')[0]
var e = $.Event('bs:tab:show', { var e = $.Event('show.bs.tab', {
relatedTarget: previous relatedTarget: previous
}) })
@ -53,7 +53,7 @@
this.activate($this.parent('li'), $ul) this.activate($this.parent('li'), $ul)
this.activate($target, $target.parent(), function () { this.activate($target, $target.parent(), function () {
$this.trigger({ $this.trigger({
type: 'bs:tab:shown' type: 'shown.bs.tab'
, relatedTarget: previous , relatedTarget: previous
}) })
}) })
@ -103,9 +103,9 @@
$.fn.tab = function ( option ) { $.fn.tab = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-tab') var data = $this.data('bs.tab')
if (!data) $this.data('bs-tab', (data = new Tab(this))) if (!data) $this.data('bs.tab', (data = new Tab(this)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
@ -125,7 +125,7 @@
// TAB DATA-API // TAB DATA-API
// ============ // ============
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault() e.preventDefault()
$(this).tab('show') $(this).tab('show')
}) })

View File

@ -41,6 +41,7 @@
<script src="unit/tooltip.js"></script> <script src="unit/tooltip.js"></script>
<script src="unit/popover.js"></script> <script src="unit/popover.js"></script>
<script src="unit/affix.js"></script> <script src="unit/affix.js"></script>
</head> </head>
<body> <body>
<div> <div>

View File

@ -18,7 +18,7 @@ $(function () {
test("should exit early if element is not visible", function () { test("should exit early if element is not visible", function () {
var $affix = $('<div style="display: none"></div>').affix() var $affix = $('<div style="display: none"></div>').affix()
$affix.data('bs-affix').checkPosition() $affix.data('bs.affix').checkPosition()
ok(!$affix.hasClass('affix'), 'affix class was not added') ok(!$affix.hasClass('affix'), 'affix class was not added')
}) })

View File

@ -1,6 +1,6 @@
$(function () { $(function () {
module("alerts") module("alert")
test("should provide no conflict", function () { test("should provide no conflict", function () {
var alert = $.fn.alert.noConflict() var alert = $.fn.alert.noConflict()
@ -48,12 +48,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop(); stop();
$('<div class="alert"/>') $('<div class="alert"/>')
.bind('bs:alert:close', function (e) { .on('close.bs.alert', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('bs:alert:closed', function () { .on('closed.bs.alert', function () {
ok(false); ok(false);
}) })
.alert('close') .alert('close')

View File

@ -1,6 +1,6 @@
$(function () { $(function () {
module("buttons") module("button")
test("should provide no conflict", function () { test("should provide no conflict", function () {
var button = $.fn.button.noConflict() var button = $.fn.button.noConflict()

View File

@ -20,12 +20,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$('<div class="carousel"/>') $('<div class="carousel"/>')
.bind('bs:carousel:slide', function (e) { .on('slide.bs.carousel', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('bs:carousel:slid', function () { .on('slid.bs.carousel', function () {
ok(false); ok(false);
}) })
.carousel('next') .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">&lsaquo;</a><a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a></div>' 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">&lsaquo;</a><a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a></div>'
$.support.transition = false $.support.transition = false
stop() stop()
$(template).on('bs:carousel:slide', function (e) { $(template).on('slide.bs.carousel', function (e) {
e.preventDefault() e.preventDefault()
ok(e.direction) ok(e.direction)
ok(e.direction === 'right' || e.direction === 'left') ok(e.direction === 'right' || e.direction === 'left')
@ -48,7 +48,7 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$(template) $(template)
.on('bs:carousel:slide', function (e) { .on('slide.bs.carousel', function (e) {
e.preventDefault(); e.preventDefault();
ok(e.relatedTarget); ok(e.relatedTarget);
ok($(e.relatedTarget).hasClass('item')); ok($(e.relatedTarget).hasClass('item'));
@ -63,19 +63,19 @@ $(function () {
template.appendTo("body"); template.appendTo("body");
$('[data-slide]').first().click(); $('[data-slide]').first().click();
ok($('#myCarousel').data('bs-carousel').options.interval == 1814); ok($('#myCarousel').data('bs.carousel').options.interval == 1814);
$('#myCarousel').remove(); $('#myCarousel').remove();
template.appendTo("body").attr("data-modal", "foobar"); template.appendTo("body").attr("data-modal", "foobar");
$('[data-slide]').first().click(); $('[data-slide]').first().click();
ok($('#myCarousel').data('bs-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(); $('#myCarousel').remove();
template.appendTo("body"); template.appendTo("body");
$('[data-slide]').first().click(); $('[data-slide]').first().click();
$('#myCarousel').attr('data-interval', 1860); $('#myCarousel').attr('data-interval', 1860);
$('[data-slide]').first().click(); $('[data-slide]').first().click();
ok($('#myCarousel').data('bs-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(); $('#myCarousel').remove();
}) })
}) })

View File

@ -32,12 +32,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$('<div class="collapse"/>') $('<div class="collapse"/>')
.bind('bs:collapse:show', function (e) { .on('show.bs.collapse', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('bs:collapse:shown', function () { .on('shown.bs.collapse', function () {
ok(false); ok(false);
}) })
.collapse('show') .collapse('show')
@ -47,10 +47,10 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$('<div class="collapse" style="height: 0px"/>') $('<div class="collapse" style="height: 0px"/>')
.bind('bs:collapse:show', function () { .on('show.bs.collapse', function () {
ok(this.style.height == '0px') ok(this.style.height == '0px')
}) })
.bind('bs:collapse:shown', function () { .on('shown.bs.collapse', function () {
ok(this.style.height == 'auto') ok(this.style.height == 'auto')
start() start()
}) })
@ -66,7 +66,7 @@ $(function () {
var collapsible = $('<div id="test1"></div>') var collapsible = $('<div id="test1"></div>')
.appendTo($('#qunit-fixture')) .appendTo($('#qunit-fixture'))
.on('bs:collapse:show', function () { .on('show.bs.collapse', function () {
ok(!target.hasClass('collapsed')) ok(!target.hasClass('collapsed'))
start() start()
}) })
@ -83,7 +83,7 @@ $(function () {
var collapsible = $('<div id="test1" class="in"></div>') var collapsible = $('<div id="test1" class="in"></div>')
.appendTo($('#qunit-fixture')) .appendTo($('#qunit-fixture'))
.on('bs:collapse:hide', function () { .on('hide.bs.collapse', function () {
ok(target.hasClass('collapsed')) ok(target.hasClass('collapsed'))
start() start()
}) })

View File

@ -103,8 +103,9 @@ $(function () {
.find('[data-toggle="dropdown"]') .find('[data-toggle="dropdown"]')
.dropdown() .dropdown()
.click() .click()
ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
$('.dropdown-backdrop').click() $('body').click()
ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class removed') ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class removed')
dropdown.remove() dropdown.remove()
}) })
@ -136,13 +137,13 @@ $(function () {
first.click() first.click()
ok(first.parents('.open').length == 1, 'open class added on click') ok(first.parents('.open').length == 1, 'open class added on click')
ok($('#qunit-fixture .open').length == 1, 'only one object is open') ok($('#qunit-fixture .open').length == 1, 'only one object is open')
$('.dropdown-backdrop').click() $('body').click()
ok($("#qunit-fixture .open").length === 0, 'open class removed') ok($("#qunit-fixture .open").length === 0, 'open class removed')
last.click() last.click()
ok(last.parent('.open').length == 1, 'open class added on click') ok(last.parent('.open').length == 1, 'open class added on click')
ok($('#qunit-fixture .open').length == 1, 'only one object is open') ok($('#qunit-fixture .open').length == 1, 'only one object is open')
$('.dropdown-backdrop').click() $('body').click()
ok($("#qunit-fixture .open").length === 0, 'open class removed') ok($("#qunit-fixture .open").length === 0, 'open class removed')
$("#qunit-fixture").html("") $("#qunit-fixture").html("")

View File

@ -27,7 +27,7 @@ $(function () {
stop() stop()
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
$(this).remove() $(this).remove()
start() start()
@ -39,10 +39,10 @@ $(function () {
stop() stop()
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("bs:modal:show", function () { .on("show.bs.modal", function () {
ok(true, "show was called") ok(true, "show was called")
}) })
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
$(this).remove() $(this).remove()
start() start()
}) })
@ -53,12 +53,12 @@ $(function () {
stop() stop()
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("bs:modal:show", function (e) { .on("show.bs.modal", function (e) {
e.preventDefault() e.preventDefault()
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
ok(false, "shown was called") ok(false, "shown was called")
}) })
.modal("show") .modal("show")
@ -69,12 +69,12 @@ $(function () {
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
$(this).modal("hide") $(this).modal("hide")
}) })
.bind("bs:modal:hidden", function() { .on("hidden.bs.modal", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
$('#modal-test').remove() $('#modal-test').remove()
start() start()
@ -87,12 +87,12 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
div div
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.modal("toggle") div.modal("toggle")
}) })
.bind("bs:modal:hidden", function() { .on("hidden.bs.modal", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove() div.remove()
start() start()
@ -105,12 +105,12 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>") var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
div div
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.find('.close').click() div.find('.close').click()
}) })
.bind("bs:modal:hidden", function() { .on("hidden.bs.modal", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove() div.remove()
start() start()
@ -123,11 +123,11 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div>", { id: 'modal-test', "data-backdrop": false }) var div = $("<div>", { id: 'modal-test', "data-backdrop": false })
div div
.bind("bs:modal:shown", function () { .on("shown.bs.modal", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
div.modal("hide") div.modal("hide")
}) })
.bind("bs:modal:hidden", function() { .on("hidden.bs.modal", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove() div.remove()
start() start()

View File

@ -34,7 +34,7 @@ $(function () {
var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
.popover() .popover()
ok(!!popover.data('bs-popover'), 'popover instance exists') ok(!!popover.data('bs.popover'), 'popover instance exists')
}) })
test("should get title and content from options", function () { test("should get title and content from options", function () {
@ -99,7 +99,7 @@ $(function () {
test("should destroy popover", function () { test("should destroy popover", function () {
var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){}) var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){})
ok(popover.data('bs-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').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') ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event')
popover.popover('show') popover.popover('show')

View File

@ -53,12 +53,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop(); stop();
$('<div class="tab"/>') $('<div class="tab"/>')
.bind('bs:tab:show', function (e) { .on('show.bs.tab', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('bs:tab:shown', function () { .on('shown.bs.tab', function () {
ok(false); ok(false);
}) })
.tab('show') .tab('show')
@ -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('bs:tab:shown', function(event){ }).on('shown', function(event){
equals(event.relatedTarget.hash, "#1-1") equals(event.relatedTarget.hash, "#1-1")
}).tab('show') }).tab('show')
}) })

View File

@ -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("bs:tooltip:show", function() { .on("show.bs.tooltip", function() {
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
@ -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("bs:tooltip:shown", function() { .on("shown.bs.tooltip", function() {
ok(true, "shown was called") ok(true, "shown was called")
start() start()
}) })
@ -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("bs:tooltip:show", function(e) { .on("show.bs.tooltip", function(e) {
e.preventDefault() e.preventDefault()
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
.bind("bs:tooltip:shown", function() { .on("shown.bs.tooltip", function() {
ok(false, "shown was called") ok(false, "shown was called")
}) })
.tooltip('show') .tooltip('show')
@ -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("bs:tooltip:shown", function() { .on("shown.bs.tooltip", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("bs:tooltip:hide", function() { .on("hide.bs.tooltip", function() {
ok(true, "hide was called") ok(true, "hide was called")
start() start()
}) })
@ -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("bs:tooltip:shown", function() { .on("shown.bs.tooltip", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("bs:tooltip:hidden", function() { .on("hidden.bs.tooltip", function() {
ok(true, "hidden was called") ok(true, "hidden was called")
start() start()
}) })
@ -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("bs:tooltip:shown", function() { .on("shown.bs.tooltip", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("bs:tooltip:hide", function(e) { .on("hide.bs.tooltip", function(e) {
e.preventDefault() e.preventDefault()
ok(true, "hide was called") ok(true, "hide was called")
start() start()
}) })
.bind("bs:tooltip:hidden", function() { .on("hidden.bs.tooltip", function() {
ok(false, "hidden was called") ok(false, "hidden was called")
}) })
.tooltip('show') .tooltip('show')
@ -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('bs-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], 'bs-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')
}) })

View File

@ -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('bs-' + 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 @@
} }
Tooltip.prototype.leave = function (e) { Tooltip.prototype.leave = function (e) {
var self = $(e.currentTarget)[this.type](this._options).data('bs-' + 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()
@ -124,7 +124,7 @@
} }
Tooltip.prototype.show = function () { Tooltip.prototype.show = function () {
var e = $.Event('bs:'+ this.type + ':show') var e = $.Event('show.bs.'+ this.type)
if (this.hasContent() && this.enabled) { if (this.hasContent() && this.enabled) {
this.$element.trigger(e) this.$element.trigger(e)
@ -168,7 +168,7 @@
} }
this.applyPlacement(tp, placement) this.applyPlacement(tp, placement)
this.$element.trigger('bs:' + this.type + ':shown') this.$element.trigger('shown.bs.' + this.type)
} }
} }
@ -227,7 +227,7 @@
Tooltip.prototype.hide = function () { Tooltip.prototype.hide = function () {
var that = this var that = this
var $tip = this.tip() var $tip = this.tip()
var e = $.Event('bs:' + this.type + ':hide') var e = $.Event('hide.bs.' + this.type)
this.$element.trigger(e) this.$element.trigger(e)
@ -250,7 +250,7 @@
removeWithAnimation() : removeWithAnimation() :
$tip.detach() $tip.detach()
this.$element.trigger('bs:' + this.type + ':hidden') this.$element.trigger('hidden.bs.' + this.type)
return this return this
} }
@ -314,12 +314,12 @@
} }
Tooltip.prototype.toggle = function (e) { Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data('bs-' + 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('bs-' + this.type) this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
} }
@ -331,10 +331,10 @@
$.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')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs-tooltip', (data = new Tooltip(this, options))) if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }