aboutsummaryrefslogtreecommitdiff
path: root/js/bootstrap-tab.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2011-12-21 18:39:02 -0600
committerMark Otto <[email protected]>2011-12-21 18:39:02 -0600
commit9fb380151d477f1741b7609ade7a9e7fd5450b2c (patch)
treea749f2b6917c09770af1586ae9f83e46115de7eb /js/bootstrap-tab.js
parent12a0d69454a2831031035d19237d36d38bb2c2a9 (diff)
parenta5a98a8a984512011dac1216b432b86c6eff96a4 (diff)
downloadbootstrap-9fb380151d477f1741b7609ade7a9e7fd5450b2c.tar.xz
bootstrap-9fb380151d477f1741b7609ade7a9e7fd5450b2c.zip
Merge branch '2.0-wip' of github.com:twitter/bootstrap into 2.0-wip
Conflicts: bootstrap.css docs/javascript.html
Diffstat (limited to 'js/bootstrap-tab.js')
-rw-r--r--js/bootstrap-tab.js57
1 files changed, 38 insertions, 19 deletions
diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js
index 6aa8ae32c..c7632ded2 100644
--- a/js/bootstrap-tab.js
+++ b/js/bootstrap-tab.js
@@ -52,26 +52,45 @@
$href = $(href)
this.activate($this.parent('li'), $ul)
- this.activate($href, $href.parent())
-
- $this.trigger({
- type: 'shown'
- , relatedTarget: previous
+ this.activate($href, $href.parent(), function () {
+ $this.trigger({
+ type: 'shown'
+ , relatedTarget: previous
+ })
})
}
- , activate: function ( element, container ) {
- container
- .find('> .active')
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
+ , activate: function ( element, container, callback) {
+ var $active = container.find('> .active')
+ , transition = callback
+ && $.support.transition
+ && $active.hasClass('fade')
+
+ function next() {
+ $active
+ .removeClass('active')
+ .find('> .dropdown-menu > .active')
+ .removeClass('active')
- element.addClass('active')
+ element.addClass('active')
- if ( element.parent('.dropdown-menu') ) {
- element.closest('li.dropdown').addClass('active')
+ if (transition) {
+ element[0].offsetWidth // reflow for transition
+ element.addClass('in')
+ }
+
+ if ( element.parent('.dropdown-menu') ) {
+ element.closest('li.dropdown').addClass('active')
+ }
+
+ callback && callback()
}
+
+ transition ?
+ $active.one($.support.transition.end, next) :
+ next()
+
+ $active.removeClass('in')
}
}
@@ -79,7 +98,7 @@
/* TAB PLUGIN DEFINITION
* ===================== */
- $.fn.tab = function (option) {
+ $.fn.tab = function ( option ) {
return this.each(function () {
var $this = $(this)
, data = $this.data('tab')
@@ -88,17 +107,17 @@
})
}
- $.fn.tab.Tab = Tab
+ $.fn.tab.Constructor = Tab
/* TAB DATA-API
* ============ */
- $(document).ready(function () {
- $('body').delegate('[data-toggle="tab"], [data-toggle="pill"]', 'click.tab.data-api', function (e) {
+ $(function () {
+ $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
$(this).tab('show')
})
})
-}( window.jQuery || window.ender ) \ No newline at end of file
+}( window.jQuery ) \ No newline at end of file