Commit 7f3b94c4 authored by Jacob Thornton's avatar Jacob Thornton

Merge branch 'delegate-api-to-document' of git://github.com/badcarl/bootstrap...

Merge branch 'delegate-api-to-document' of git://github.com/badcarl/bootstrap into badcarl-delegate-api-to-document

Conflicts:
	js/bootstrap-carousel.js
parents 280d4aeb e1f6458e
...@@ -83,8 +83,6 @@ ...@@ -83,8 +83,6 @@
/* ALERT DATA-API /* ALERT DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
})
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -85,12 +85,10 @@ ...@@ -85,12 +85,10 @@
/* BUTTON DATA-API /* BUTTON DATA-API
* =============== */ * =============== */
$(function () { $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
$('body').on('click.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')
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -165,14 +165,12 @@ ...@@ -165,14 +165,12 @@
/* CAROUSEL DATA-API /* CAROUSEL DATA-API
* ================= */ * ================= */
$(function () { $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { var $this = $(this), href
var $this = $(this), href , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data())
, options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data()) $target.carousel(options)
$target.carousel(options) e.preventDefault()
e.preventDefault()
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -143,16 +143,14 @@ ...@@ -143,16 +143,14 @@
/* COLLAPSIBLE DATA-API /* COLLAPSIBLE DATA-API
* ==================== */ * ==================== */
$(function () { $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { var $this = $(this), href
var $this = $(this), href , target = $this.attr('data-target')
, target = $this.attr('data-target') || e.preventDefault()
|| e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 , option = $(target).data('collapse') ? 'toggle' : $this.data()
, option = $(target).data('collapse') ? 'toggle' : $this.data() $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') $(target).collapse(option)
$(target).collapse(option)
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -138,13 +138,10 @@ ...@@ -138,13 +138,10 @@
/* APPLY TO STANDARD DROPDOWN ELEMENTS /* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ * =================================== */
$(function () { $(document)
$('html') .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
$('body') .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.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); }(window.jQuery);
\ No newline at end of file
...@@ -214,21 +214,19 @@ ...@@ -214,21 +214,19 @@
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { var $this = $(this)
var $this = $(this) , href = $this.attr('href')
, href = $this.attr('href') , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, $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())
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault()
e.preventDefault()
$target
$target .modal(option)
.modal(option) .one('hide', function () {
.one('hide', function () { $this.focus()
$this.focus() })
})
})
}) })
}(window.jQuery); }(window.jQuery);
...@@ -125,11 +125,9 @@ ...@@ -125,11 +125,9 @@
/* TAB DATA-API /* TAB DATA-API
* ============ */ * ============ */
$(function () { $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { e.preventDefault()
e.preventDefault() $(this).tab('show')
$(this).tab('show')
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -297,13 +297,11 @@ ...@@ -297,13 +297,11 @@
/* TYPEAHEAD DATA-API /* TYPEAHEAD DATA-API
* ================== */ * ================== */
$(function () { $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { var $this = $(this)
var $this = $(this) if ($this.data('typeahead')) return
if ($this.data('typeahead')) return e.preventDefault()
e.preventDefault() $this.typeahead($this.data())
$this.typeahead($this.data())
})
}) })
}(window.jQuery); }(window.jQuery);
...@@ -142,9 +142,7 @@ ...@@ -142,9 +142,7 @@
/* ALERT DATA-API /* ALERT DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
})
}(window.jQuery);/* ============================================================ }(window.jQuery);/* ============================================================
* bootstrap-button.js v2.1.2 * bootstrap-button.js v2.1.2
...@@ -233,12 +231,10 @@ ...@@ -233,12 +231,10 @@
/* BUTTON DATA-API /* BUTTON DATA-API
* =============== */ * =============== */
$(function () { $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
$('body').on('click.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')
})
}) })
}(window.jQuery);/* ========================================================== }(window.jQuery);/* ==========================================================
...@@ -408,14 +404,12 @@ ...@@ -408,14 +404,12 @@
/* CAROUSEL DATA-API /* CAROUSEL DATA-API
* ================= */ * ================= */
$(function () { $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { var $this = $(this), href
var $this = $(this), href , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data())
, options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data()) $target.carousel(options)
$target.carousel(options) e.preventDefault()
e.preventDefault()
})
}) })
}(window.jQuery);/* ============================================================= }(window.jQuery);/* =============================================================
...@@ -563,16 +557,14 @@ ...@@ -563,16 +557,14 @@
/* COLLAPSIBLE DATA-API /* COLLAPSIBLE DATA-API
* ==================== */ * ==================== */
$(function () { $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { var $this = $(this), href
var $this = $(this), href , target = $this.attr('data-target')
, target = $this.attr('data-target') || e.preventDefault()
|| e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 , option = $(target).data('collapse') ? 'toggle' : $this.data()
, option = $(target).data('collapse') ? 'toggle' : $this.data() $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') $(target).collapse(option)
$(target).collapse(option)
})
}) })
}(window.jQuery);/* ============================================================ }(window.jQuery);/* ============================================================
...@@ -715,14 +707,11 @@ ...@@ -715,14 +707,11 @@
/* APPLY TO STANDARD DROPDOWN ELEMENTS /* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ * =================================== */
$(function () { $(document)
$('html') .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
$('body') .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.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);/* ========================================================= }(window.jQuery);/* =========================================================
* bootstrap-modal.js v2.1.2 * bootstrap-modal.js v2.1.2
...@@ -940,21 +929,19 @@ ...@@ -940,21 +929,19 @@
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { var $this = $(this)
var $this = $(this) , href = $this.attr('href')
, href = $this.attr('href') , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, $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())
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault() e.preventDefault()
$target $target
.modal(option) .modal(option)
.one('hide', function () { .one('hide', function () {
$this.focus() $this.focus()
}) })
})
}) })
}(window.jQuery); }(window.jQuery);
...@@ -1612,11 +1599,9 @@ ...@@ -1612,11 +1599,9 @@
/* TAB DATA-API /* TAB DATA-API
* ============ */ * ============ */
$(function () { $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { e.preventDefault()
e.preventDefault() $(this).tab('show')
$(this).tab('show')
})
}) })
}(window.jQuery);/* ============================================================= }(window.jQuery);/* =============================================================
...@@ -1918,13 +1903,11 @@ ...@@ -1918,13 +1903,11 @@
/* TYPEAHEAD DATA-API /* TYPEAHEAD DATA-API
* ================== */ * ================== */
$(function () { $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { var $this = $(this)
var $this = $(this) if ($this.data('typeahead')) return
if ($this.data('typeahead')) return e.preventDefault()
e.preventDefault() $this.typeahead($this.data())
$this.typeahead($this.data())
})
}) })
}(window.jQuery); }(window.jQuery);
......
This diff is collapsed.
...@@ -83,8 +83,6 @@ ...@@ -83,8 +83,6 @@
/* ALERT DATA-API /* ALERT DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
})
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -85,12 +85,10 @@ ...@@ -85,12 +85,10 @@
/* BUTTON DATA-API /* BUTTON DATA-API
* =============== */ * =============== */
$(function () { $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
$('body').on('click.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')
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -165,14 +165,12 @@ ...@@ -165,14 +165,12 @@
/* CAROUSEL DATA-API /* CAROUSEL DATA-API
* ================= */ * ================= */
$(function () { $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { var $this = $(this), href
var $this = $(this), href , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data())
, options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data()) $target.carousel(options)
$target.carousel(options) e.preventDefault()
e.preventDefault()
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -143,16 +143,14 @@ ...@@ -143,16 +143,14 @@
/* COLLAPSIBLE DATA-API /* COLLAPSIBLE DATA-API
* ==================== */ * ==================== */
$(function () { $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { var $this = $(this), href
var $this = $(this), href , target = $this.attr('data-target')
, target = $this.attr('data-target') || e.preventDefault()
|| e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 , option = $(target).data('collapse') ? 'toggle' : $this.data()
, option = $(target).data('collapse') ? 'toggle' : $this.data() $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') $(target).collapse(option)
$(target).collapse(option)
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -138,13 +138,10 @@ ...@@ -138,13 +138,10 @@
/* APPLY TO STANDARD DROPDOWN ELEMENTS /* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ * =================================== */
$(function () { $(document)
$('html') .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
$('body') .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.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); }(window.jQuery);
\ No newline at end of file
...@@ -214,21 +214,19 @@ ...@@ -214,21 +214,19 @@
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { var $this = $(this)
var $this = $(this) , href = $this.attr('href')
, href = $this.attr('href') , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, $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())
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault()
e.preventDefault()
$target
$target .modal(option)
.modal(option) .one('hide', function () {
.one('hide', function () { $this.focus()
$this.focus() })
})
})
}) })
}(window.jQuery); }(window.jQuery);
...@@ -125,11 +125,9 @@ ...@@ -125,11 +125,9 @@
/* TAB DATA-API /* TAB DATA-API
* ============ */ * ============ */
$(function () { $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { e.preventDefault()
e.preventDefault() $(this).tab('show')
$(this).tab('show')
})
}) })
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
...@@ -297,13 +297,11 @@ ...@@ -297,13 +297,11 @@
/* TYPEAHEAD DATA-API /* TYPEAHEAD DATA-API
* ================== */ * ================== */
$(function () { $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { var $this = $(this)
var $this = $(this) if ($this.data('typeahead')) return
if ($this.data('typeahead')) return e.preventDefault()
e.preventDefault() $this.typeahead($this.data())
$this.typeahead($this.data())
})
}) })
}(window.jQuery); }(window.jQuery);
Markdown is supported
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