1 /* ========================================================================
2 * Bootstrap: tab.js v3.2.0
3 * http://getbootstrap.com/javascript/#tabs
4 * ========================================================================
5 * Copyright 2011-2014 Twitter, Inc.
6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 * ======================================================================== */
13 // TAB CLASS DEFINITION
14 // ====================
16 var Tab = function (element) {
17 this.element = $(element)
22 Tab.prototype.show = function () {
23 var $this = this.element
24 var $ul = $this.closest('ul:not(.dropdown-menu)')
25 var selector = $this.data('target')
28 selector = $this.attr('href')
29 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
32 if ($this.parent('li').hasClass('active')) return
34 var previous = $ul.find('.active:last a')[0]
35 var e = $.Event('show.bs.tab', {
36 relatedTarget: previous
41 if (e.isDefaultPrevented()) return
43 var $target = $(selector)
45 this.activate($this.closest('li'), $ul)
46 this.activate($target, $target.parent(), function () {
49 relatedTarget: previous
54 Tab.prototype.activate = function (element, container, callback) {
55 var $active = container.find('> .active')
56 var transition = callback
57 && $.support.transition
58 && $active.hasClass('fade')
62 .removeClass('active')
63 .find('> .dropdown-menu > .active')
64 .removeClass('active')
66 element.addClass('active')
69 element[0].offsetWidth // reflow for transition
70 element.addClass('in')
72 element.removeClass('fade')
75 if (element.parent('.dropdown-menu')) {
76 element.closest('li.dropdown').addClass('active')
79 callback && callback()
84 .one('bsTransitionEnd', next)
85 .emulateTransitionEnd(150) :
88 $active.removeClass('in')
92 // TAB PLUGIN DEFINITION
93 // =====================
95 function Plugin(option) {
96 return this.each(function () {
98 var data = $this.data('bs.tab')
100 if (!data) $this.data('bs.tab', (data = new Tab(this)))
101 if (typeof option == 'string') data[option]()
108 $.fn.tab.Constructor = Tab
114 $.fn.tab.noConflict = function () {
123 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
125 Plugin.call($(this), 'show')