aboutsummaryrefslogtreecommitdiff
path: root/js/tab.js
diff options
context:
space:
mode:
authorJames Friend <[email protected]>2014-08-28 09:32:08 +0800
committerJames Friend <[email protected]>2014-08-28 09:32:08 +0800
commit9aeaf19b1dca68ee71e916ae415a0c270a47d301 (patch)
treebc8385acb8ec7a46bba03ff2ef7e4283cd9f1146 /js/tab.js
parente7991a9a1e2f474c8f1d8a2e0ed113816f1c5e82 (diff)
parent35f09315ed543a0479719afa2143240952c215db (diff)
downloadbootstrap-9aeaf19b1dca68ee71e916ae415a0c270a47d301.tar.xz
bootstrap-9aeaf19b1dca68ee71e916ae415a0c270a47d301.zip
Merge remote-tracking branch 'upstream/master' into node-requirable
Conflicts: Gruntfile.js
Diffstat (limited to 'js/tab.js')
-rw-r--r--js/tab.js184
1 files changed, 90 insertions, 94 deletions
diff --git a/js/tab.js b/js/tab.js
index c8122157f..d7023c817 100644
--- a/js/tab.js
+++ b/js/tab.js
@@ -1,5 +1,5 @@
/* ========================================================================
- * Bootstrap: tab.js v3.1.1
+ * Bootstrap: tab.js v3.2.0
* http://getbootstrap.com/javascript/#tabs
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
@@ -7,128 +7,124 @@
* ======================================================================== */
-+function () { 'use strict';
++function ($) {
+ 'use strict';
- (function (o_o) {
- typeof define == 'function' && define.amd ? define(['jquery'], o_o) :
- typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery)
- })(function ($) {
+ // TAB CLASS DEFINITION
+ // ====================
- // TAB CLASS DEFINITION
- // ====================
+ var Tab = function (element) {
+ this.element = $(element)
+ }
- var Tab = function (element) {
- this.element = $(element)
- }
-
- Tab.VERSION = '3.1.1'
-
- Tab.prototype.show = function () {
- var $this = this.element
- var $ul = $this.closest('ul:not(.dropdown-menu)')
- var selector = $this.data('target')
+ Tab.VERSION = '3.2.0'
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
+ Tab.TRANSITION_DURATION = 150
- if ($this.parent('li').hasClass('active')) return
+ Tab.prototype.show = function () {
+ var $this = this.element
+ var $ul = $this.closest('ul:not(.dropdown-menu)')
+ var selector = $this.data('target')
- var previous = $ul.find('.active:last a')[0]
- var e = $.Event('show.bs.tab', {
- relatedTarget: previous
- })
-
- $this.trigger(e)
-
- if (e.isDefaultPrevented()) return
-
- var $target = $(selector)
-
- this.activate($this.closest('li'), $ul)
- this.activate($target, $target.parent(), function () {
- $this.trigger({
- type: 'shown.bs.tab',
- relatedTarget: previous
- })
- })
+ if (!selector) {
+ selector = $this.attr('href')
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}
- Tab.prototype.activate = function (element, container, callback) {
- var $active = container.find('> .active')
- var transition = callback
- && $.support.transition
- && $active.hasClass('fade')
+ if ($this.parent('li').hasClass('active')) return
- function next() {
- $active
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
+ var previous = $ul.find('.active:last a')[0]
+ var e = $.Event('show.bs.tab', {
+ relatedTarget: previous
+ })
- element.addClass('active')
+ $this.trigger(e)
- if (transition) {
- element[0].offsetWidth // reflow for transition
- element.addClass('in')
- } else {
- element.removeClass('fade')
- }
+ if (e.isDefaultPrevented()) return
- if (element.parent('.dropdown-menu')) {
- element.closest('li.dropdown').addClass('active')
- }
+ var $target = $(selector)
- callback && callback()
+ this.activate($this.closest('li'), $ul)
+ this.activate($target, $target.parent(), function () {
+ $this.trigger({
+ type: 'shown.bs.tab',
+ relatedTarget: previous
+ })
+ })
+ }
+
+ Tab.prototype.activate = function (element, container, callback) {
+ var $active = container.find('> .active')
+ var transition = callback
+ && $.support.transition
+ && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
+
+ function next() {
+ $active
+ .removeClass('active')
+ .find('> .dropdown-menu > .active')
+ .removeClass('active')
+
+ element.addClass('active')
+
+ if (transition) {
+ element[0].offsetWidth // reflow for transition
+ element.addClass('in')
+ } else {
+ element.removeClass('fade')
}
- transition ?
- $active
- .one('bsTransitionEnd', next)
- .emulateTransitionEnd(150) :
- next()
+ if (element.parent('.dropdown-menu')) {
+ element.closest('li.dropdown').addClass('active')
+ }
- $active.removeClass('in')
+ callback && callback()
}
+ $active.length && transition ?
+ $active
+ .one('bsTransitionEnd', next)
+ .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
+ next()
- // TAB PLUGIN DEFINITION
- // =====================
+ $active.removeClass('in')
+ }
- function Plugin(option) {
- return this.each(function () {
- var $this = $(this)
- var data = $this.data('bs.tab')
- if (!data) $this.data('bs.tab', (data = new Tab(this)))
- if (typeof option == 'string') data[option]()
- })
- }
+ // TAB PLUGIN DEFINITION
+ // =====================
- var old = $.fn.tab
+ function Plugin(option) {
+ return this.each(function () {
+ var $this = $(this)
+ var data = $this.data('bs.tab')
- $.fn.tab = Plugin
- $.fn.tab.Constructor = Tab
+ if (!data) $this.data('bs.tab', (data = new Tab(this)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+ var old = $.fn.tab
- // TAB NO CONFLICT
- // ===============
+ $.fn.tab = Plugin
+ $.fn.tab.Constructor = Tab
- $.fn.tab.noConflict = function () {
- $.fn.tab = old
- return this
- }
+ // TAB NO CONFLICT
+ // ===============
- // TAB DATA-API
- // ============
+ $.fn.tab.noConflict = function () {
+ $.fn.tab = old
+ return this
+ }
- $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
- e.preventDefault()
- Plugin.call($(this), 'show')
- })
+ // TAB DATA-API
+ // ============
+
+ $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
+ e.preventDefault()
+ Plugin.call($(this), 'show')
})
-}();
+}(jQuery);