diff options
author | Carl Porth <badcarl@gmail.com> | 2012-09-28 02:00:02 +0400 |
---|---|---|
committer | Carl Porth <badcarl@gmail.com> | 2012-09-28 02:00:02 +0400 |
commit | e1f6458e3640a628cdb6b2e4c63950777d46e141 (patch) | |
tree | cf4f67f4a214999cfb5024f6fbe12697b2c3cc17 | |
parent | 474471b83140350de320f3ba940bd7dd8326b32e (diff) |
don't wait for ready when binding events to document
-rw-r--r-- | js/bootstrap-alert.js | 4 | ||||
-rw-r--r-- | js/bootstrap-button.js | 10 | ||||
-rw-r--r-- | js/bootstrap-carousel.js | 14 | ||||
-rw-r--r-- | js/bootstrap-collapse.js | 18 | ||||
-rw-r--r-- | js/bootstrap-dropdown.js | 13 | ||||
-rw-r--r-- | js/bootstrap-modal.js | 28 | ||||
-rw-r--r-- | js/bootstrap-tab.js | 8 | ||||
-rw-r--r-- | js/bootstrap-typeahead.js | 12 |
8 files changed, 45 insertions, 62 deletions
diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index ea3209ed19..b0bdc4b7d9 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -83,8 +83,6 @@ /* ALERT DATA-API * ============== */ - $(function () { - $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) - }) + $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-button.js b/js/bootstrap-button.js index 4c0b725c7a..dbb2c08ed3 100644 --- a/js/bootstrap-button.js +++ b/js/bootstrap-button.js @@ -85,12 +85,10 @@ /* BUTTON DATA-API * =============== */ - $(function () { - $(document).on('click.button.data-api', '[data-toggle^=button]', function ( e ) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - $btn.button('toggle') - }) + $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') }) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 8751b320cc..6b01f763b4 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -163,14 +163,12 @@ /* CAROUSEL DATA-API * ================= */ - $(function () { - $(document).on('click.carousel.data-api', '[data-slide]', function ( e ) { - var $this = $(this), href - , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) - $target.carousel(options) - e.preventDefault() - }) + $(document).on('click.carousel.data-api', '[data-slide]', function (e) { + var $this = $(this), href + , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) + $target.carousel(options) + e.preventDefault() }) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 781e274374..392e486a89 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -143,16 +143,14 @@ /* COLLAPSIBLE DATA-API * ==================== */ - $(function () { - $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { - var $this = $(this), href - , target = $this.attr('data-target') - || e.preventDefault() - || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 - , option = $(target).data('collapse') ? 'toggle' : $this.data() - $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') - $(target).collapse(option) - }) + $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + , target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + , option = $(target).data('collapse') ? 'toggle' : $this.data() + $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + $(target).collapse(option) }) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js index 5a2766fdea..f50aa64d62 100644 --- a/js/bootstrap-dropdown.js +++ b/js/bootstrap-dropdown.js @@ -138,13 +138,10 @@ /* APPLY TO STANDARD DROPDOWN ELEMENTS * =================================== */ - $(function () { - $('html') - .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) - $(document) - .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) - .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) - .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) - }) + $(document) + .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) + .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) + .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) + .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 8a40c2d4e6..0030ad7c50 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -215,21 +215,19 @@ /* MODAL DATA-API * ============== */ - $(function () { - $(document).on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { - var $this = $(this) - , href = $this.attr('href') - , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 - , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) - - e.preventDefault() - - $target - .modal(option) - .one('hide', function () { - $this.focus() - }) - }) + $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { + var $this = $(this) + , href = $this.attr('href') + , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 + , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) + + e.preventDefault() + + $target + .modal(option) + .one('hide', function () { + $this.focus() + }) }) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js index 14387a1bf4..8d73cd5515 100644 --- a/js/bootstrap-tab.js +++ b/js/bootstrap-tab.js @@ -125,11 +125,9 @@ /* TAB DATA-API * ============ */ - $(function () { - $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { - e.preventDefault() - $(this).tab('show') - }) + $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { + e.preventDefault() + $(this).tab('show') }) }(window.jQuery);
\ No newline at end of file diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index ab1d66879d..dc0c7fa07a 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -297,13 +297,11 @@ /* TYPEAHEAD DATA-API * ================== */ - $(function () { - $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { - var $this = $(this) - if ($this.data('typeahead')) return - e.preventDefault() - $this.typeahead($this.data()) - }) + $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { + var $this = $(this) + if ($this.data('typeahead')) return + e.preventDefault() + $this.typeahead($this.data()) }) }(window.jQuery); |