aboutsummaryrefslogtreecommitdiff
path: root/js/tab.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tab.js')
-rw-r--r--js/tab.js182
1 files changed, 88 insertions, 94 deletions
diff --git a/js/tab.js b/js/tab.js
index de93ec83f..8e922ddcb 100644
--- a/js/tab.js
+++ b/js/tab.js
@@ -7,128 +7,122 @@
* ======================================================================== */
-+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')
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
- }
-
- if ($this.parent('li').hasClass('active')) return
+ Tab.VERSION = '3.1.1'
- var previous = $ul.find('.active:last a')[0]
- var e = $.Event('show.bs.tab', {
- relatedTarget: previous
- })
-
- $this.trigger(e)
+ Tab.prototype.show = function () {
+ var $this = this.element
+ var $ul = $this.closest('ul:not(.dropdown-menu)')
+ var selector = $this.data('target')
- 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.hasClass('fade')
+
+ 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()
}
+ transition ?
+ $active
+ .one('bsTransitionEnd', next)
+ .emulateTransitionEnd(150) :
+ 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);