vendor/assets/javascripts/bootstrap/bootstrap-tab.js in jombo-0.0.1.beta10 vs vendor/assets/javascripts/bootstrap/bootstrap-tab.js in jombo-0.0.1.beta11
- old
+ new
@@ -50,55 +50,74 @@
})
$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')
- element.addClass('active')
+ function next() {
+ $active
+ .removeClass('active')
+ .find('> .dropdown-menu > .active')
+ .removeClass('active')
- if ( element.parent('.dropdown-menu') ) {
- element.closest('li.dropdown').addClass('active')
+ element.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')
}
}
/* TAB PLUGIN DEFINITION
* ===================== */
- $.fn.tab = function (option) {
+ $.fn.tab = function ( option ) {
return this.each(function () {
var $this = $(this)
, data = $this.data('tab')
if (!data) $this.data('tab', (data = new Tab(this)))
if (typeof option == 'string') data[option]()
})
}
- $.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 )
+}( window.jQuery )
\ No newline at end of file