diff options
| author | Jacob Thornton <[email protected]> | 2011-12-20 19:37:41 -0800 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2011-12-20 19:37:41 -0800 |
| commit | 0980a33b4703677e1aaf3cd949c0437512fa6f33 (patch) | |
| tree | e7d2b1ac80580699d50c85c747d195d47be40ed6 /js/bootstrap-tab.js | |
| parent | 1ef5fa7d6b4e50230c0c12919b0a06a9a2ac07f1 (diff) | |
| download | bootstrap-0980a33b4703677e1aaf3cd949c0437512fa6f33.tar.xz bootstrap-0980a33b4703677e1aaf3cd949c0437512fa6f33.zip | |
update all to new on api + add animation support to tabs
Diffstat (limited to 'js/bootstrap-tab.js')
| -rw-r--r-- | js/bootstrap-tab.js | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js index e0a92816d..2f147c59d 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') } } |
