diff --git a/docs/javascript.html b/docs/javascript.html index 79d5b2c8ea..359dc68c50 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -17,7 +17,7 @@ lead: "Bring Bootstrap's components to life with over a dozen custom jQuery plug

Plugins can be included individually, or all at once. Do not attempt to include both. Both bootstrap.js and bootstrap.min.js contain all plugins in a single file.

Plugin dependencies

-

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).

+

Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs.

Data attributes

diff --git a/js/affix.js b/js/affix.js index c70718c6da..c85726a0c0 100644 --- a/js/affix.js +++ b/js/affix.js @@ -26,8 +26,8 @@ var Affix = function (element, options) { this.options = $.extend({}, Affix.DEFAULTS, options) this.$window = $(window) - .on('scroll.bs-affix.bs-data-api', $.proxy(this.checkPosition, this)) - .on('click.bs-affix.bs-data-api', $.proxy(this.checkPositionWithEventLoop, this)) + .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) + .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) this.$element = $(element) this.affixed = @@ -80,10 +80,10 @@ $.fn.affix = function (option) { return this.each(function () { var $this = $(this) - var data = $this.data('bs-affix') + var data = $this.data('bs.affix') 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]() }) } diff --git a/js/alert.js b/js/alert.js index b841b4f5aa..64eb30ae6e 100644 --- a/js/alert.js +++ b/js/alert.js @@ -45,14 +45,14 @@ $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 $parent.removeClass('in') function removeElement() { - $parent.trigger('bs-closed').remove() + $parent.trigger('closed.bs.alert').remove() } $.support.transition && $parent.hasClass('fade') ? @@ -69,9 +69,9 @@ $.fn.alert = function (option) { return this.each(function () { 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) }) } @@ -91,6 +91,6 @@ // 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); diff --git a/js/button.js b/js/button.js index f43bba18f9..1dbef5ccd5 100644 --- a/js/button.js +++ b/js/button.js @@ -74,7 +74,7 @@ var data = $this.data('button') 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() else if (option) data.setState(option) @@ -96,7 +96,7 @@ // 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) if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') $btn.button('toggle') diff --git a/js/carousel.js b/js/carousel.js index 782f06a07f..e0d74f81f7 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -111,7 +111,7 @@ $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 @@ -159,11 +159,11 @@ $.fn.carousel = function (option) { return this.each(function () { 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 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) else if (action) data[action]() else if (options.interval) data.pause().cycle() diff --git a/js/collapse.js b/js/collapse.js index 95c91c2993..4a94b1505f 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -56,7 +56,7 @@ } 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]) } @@ -65,7 +65,7 @@ if (this.transitioning || !this.$element.hasClass('in')) return var dimension = this.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) } @@ -85,7 +85,7 @@ Collapse.prototype.transition = function (method, startEvent, completeEvent) { var that = this var complete = function () { - if (startEvent.type == 'bs:collapse:show') that.reset() + if (startEvent.type == 'show') that.reset() that.transitioning = 0 that.$element.trigger(completeEvent) } diff --git a/js/modal.js b/js/modal.js index f58f2000eb..605aed10d9 100644 --- a/js/modal.js +++ b/js/modal.js @@ -44,7 +44,7 @@ Modal.prototype.show = function () { var that = this - var e = $.Event('bs:modal:show') + var e = $.Event('show.bs.modal') this.$element.trigger(e) @@ -74,8 +74,8 @@ that.enforceFocus() transition ? - that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('bs:modal:shown') }) : - 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('shown.bs.modal') }) } @@ -83,7 +83,7 @@ Modal.prototype.hide = function (e) { if (e) e.preventDefault() - e = $.Event('bs:modal:hide') + e = $.Event('hide.bs.modal') this.$element.trigger(e) @@ -93,7 +93,7 @@ this.escape() - $(document).off('focusin.modal') + $(document).off('focusin.bs.modal') this.$element .removeClass('in') @@ -105,7 +105,7 @@ } 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) { this.$element.focus() } @@ -114,11 +114,11 @@ Modal.prototype.escape = function () { 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() }, this) } 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.backdrop(function () { that.removeBackdrop() - that.$element.trigger('bs:modal:hidden') + that.$element.trigger('hidden.bs.modal') }) } @@ -196,10 +196,10 @@ $.fn.modal = function (option) { return this.each(function () { 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) - 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]() else if (options.show) data.show() }) @@ -220,7 +220,7 @@ // 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 href = $this.attr('href') var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 @@ -236,7 +236,7 @@ }) var $body = $(document.body) - .on('bs:modal:shown', '.modal', function () { $body.addClass('modal-open') }) - .on('bs:modal:hidden', '.modal', function () { $body.removeClass('modal-open') }) + .on('bs.modal.shown', '.modal', function () { $body.addClass('modal-open') }) + .on('bs.modal.hidden', '.modal', function () { $body.removeClass('modal-open') }) }(window.jQuery); diff --git a/js/popover.js b/js/popover.js index 20bbaf1a42..2fca934f80 100644 --- a/js/popover.js +++ b/js/popover.js @@ -87,10 +87,10 @@ $.fn.popover = function (option) { return this.each(function () { var $this = $(this) - var data = $this.data('bs-popover') + var data = $this.data('bs.popover') 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]() }) } diff --git a/js/scrollspy.js b/js/scrollspy.js index cb257b2ca4..c0ce3c2b71 100644 --- a/js/scrollspy.js +++ b/js/scrollspy.js @@ -123,10 +123,10 @@ $.fn.scrollspy = function (option) { return this.each(function () { var $this = $(this) - var data = $this.data('bs-scrollspy') + var data = $this.data('bs.scrollspy') 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]() }) } diff --git a/js/tab.js b/js/tab.js index 80d6f26180..68fdb09307 100644 --- a/js/tab.js +++ b/js/tab.js @@ -40,7 +40,7 @@ if ($this.parent('li').hasClass('active')) return var previous = $ul.find('.active:last a')[0] - var e = $.Event('bs:tab:show', { + var e = $.Event('show.bs.tab', { relatedTarget: previous }) @@ -53,7 +53,7 @@ this.activate($this.parent('li'), $ul) this.activate($target, $target.parent(), function () { $this.trigger({ - type: 'bs:tab:shown' + type: 'shown.bs.tab' , relatedTarget: previous }) }) @@ -103,9 +103,9 @@ $.fn.tab = function ( option ) { return this.each(function () { 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]() }) } @@ -125,7 +125,7 @@ // 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() $(this).tab('show') }) diff --git a/js/tests/index.html b/js/tests/index.html index 322a8efd37..0cfadc598b 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -41,6 +41,7 @@ +
diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index 9829b05ad9..b74bc51e48 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -18,7 +18,7 @@ $(function () { test("should exit early if element is not visible", function () { var $affix = $('
').affix() - $affix.data('bs-affix').checkPosition() + $affix.data('bs.affix').checkPosition() ok(!$affix.hasClass('affix'), 'affix class was not added') }) diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index 3054767f6b..98b10059e1 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -1,6 +1,6 @@ $(function () { - module("alerts") + module("alert") test("should provide no conflict", function () { var alert = $.fn.alert.noConflict() @@ -48,12 +48,12 @@ $(function () { $.support.transition = false stop(); $('
') - .bind('bs:alert:close', function (e) { + .on('close.bs.alert', function (e) { e.preventDefault(); ok(true); start(); }) - .bind('bs:alert:closed', function () { + .on('closed.bs.alert', function () { ok(false); }) .alert('close') diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index aaf480c32e..943d36d1b4 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -1,6 +1,6 @@ $(function () { - module("buttons") + module("button") test("should provide no conflict", function () { var button = $.fn.button.noConflict() diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 4d0bd6e819..f4acda02a7 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -20,12 +20,12 @@ $(function () { $.support.transition = false stop() $('