2013-05-21 22:30:33 -04:00
|
|
|
/* ========================================================================
|
2015-01-19 11:32:13 -05:00
|
|
|
* Bootstrap: tab.js v3.3.2
|
2013-10-29 13:10:47 -04:00
|
|
|
* http://getbootstrap.com/javascript/#tabs
|
2013-05-21 22:30:33 -04:00
|
|
|
* ========================================================================
|
2014-12-31 19:23:48 -05:00
|
|
|
* Copyright 2011-2015 Twitter, Inc.
|
2013-12-18 18:28:08 -05:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
2013-05-21 22:30:33 -04:00
|
|
|
* ======================================================================== */
|
2011-11-27 20:04:55 -05:00
|
|
|
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
+function ($) {
|
|
|
|
'use strict';
|
2014-06-10 01:18:05 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// TAB CLASS DEFINITION
|
|
|
|
// ====================
|
2012-04-14 19:29:53 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var Tab = function (element) {
|
|
|
|
this.element = $(element)
|
|
|
|
}
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2015-01-19 11:32:13 -05:00
|
|
|
Tab.VERSION = '3.3.2'
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2014-07-07 07:03:56 -04:00
|
|
|
Tab.TRANSITION_DURATION = 150
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Tab.prototype.show = function () {
|
|
|
|
var $this = this.element
|
|
|
|
var $ul = $this.closest('ul:not(.dropdown-menu)')
|
|
|
|
var selector = $this.data('target')
|
2012-03-24 21:20:09 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (!selector) {
|
|
|
|
selector = $this.attr('href')
|
|
|
|
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
2014-06-12 14:11:04 -04:00
|
|
|
}
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if ($this.parent('li').hasClass('active')) return
|
2011-12-20 22:37:41 -05:00
|
|
|
|
2014-10-10 10:50:00 -04:00
|
|
|
var $previous = $ul.find('.active:last a')
|
|
|
|
var hideEvent = $.Event('hide.bs.tab', {
|
|
|
|
relatedTarget: $this[0]
|
|
|
|
})
|
|
|
|
var showEvent = $.Event('show.bs.tab', {
|
|
|
|
relatedTarget: $previous[0]
|
2014-06-23 14:07:18 -04:00
|
|
|
})
|
2014-06-12 14:11:04 -04:00
|
|
|
|
2014-10-10 10:50:00 -04:00
|
|
|
$previous.trigger(hideEvent)
|
|
|
|
$this.trigger(showEvent)
|
2014-06-12 14:11:04 -04:00
|
|
|
|
2014-10-10 10:50:00 -04:00
|
|
|
if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
|
2014-06-12 14:11:04 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var $target = $(selector)
|
2014-06-12 14:11:04 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.activate($this.closest('li'), $ul)
|
|
|
|
this.activate($target, $target.parent(), function () {
|
2014-10-10 10:50:00 -04:00
|
|
|
$previous.trigger({
|
|
|
|
type: 'hidden.bs.tab',
|
|
|
|
relatedTarget: $this[0]
|
|
|
|
})
|
2014-06-23 14:07:18 -04:00
|
|
|
$this.trigger({
|
|
|
|
type: 'shown.bs.tab',
|
2014-10-10 10:50:00 -04:00
|
|
|
relatedTarget: $previous[0]
|
2014-06-23 14:07:18 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
Tab.prototype.activate = function (element, container, callback) {
|
|
|
|
var $active = container.find('> .active')
|
|
|
|
var transition = callback
|
|
|
|
&& $.support.transition
|
2014-06-13 08:06:55 -04:00
|
|
|
&& (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
|
2014-06-23 14:07:18 -04:00
|
|
|
|
|
|
|
function next() {
|
|
|
|
$active
|
|
|
|
.removeClass('active')
|
|
|
|
.find('> .dropdown-menu > .active')
|
2014-09-09 12:17:56 -04:00
|
|
|
.removeClass('active')
|
|
|
|
.end()
|
|
|
|
.find('[data-toggle="tab"]')
|
|
|
|
.attr('aria-expanded', false)
|
2014-06-23 14:07:18 -04:00
|
|
|
|
2014-09-09 12:17:56 -04:00
|
|
|
element
|
|
|
|
.addClass('active')
|
|
|
|
.find('[data-toggle="tab"]')
|
|
|
|
.attr('aria-expanded', true)
|
2014-06-23 14:07:18 -04:00
|
|
|
|
|
|
|
if (transition) {
|
|
|
|
element[0].offsetWidth // reflow for transition
|
|
|
|
element.addClass('in')
|
|
|
|
} else {
|
|
|
|
element.removeClass('fade')
|
2013-05-16 20:18:15 -04:00
|
|
|
}
|
2011-12-20 22:37:41 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (element.parent('.dropdown-menu')) {
|
2014-09-09 12:17:56 -04:00
|
|
|
element
|
|
|
|
.closest('li.dropdown')
|
|
|
|
.addClass('active')
|
|
|
|
.end()
|
|
|
|
.find('[data-toggle="tab"]')
|
|
|
|
.attr('aria-expanded', true)
|
2014-06-23 14:07:18 -04:00
|
|
|
}
|
2013-05-16 20:18:15 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
callback && callback()
|
2014-06-12 14:11:04 -04:00
|
|
|
}
|
2013-05-16 20:18:15 -04:00
|
|
|
|
2014-06-13 08:06:55 -04:00
|
|
|
$active.length && transition ?
|
2014-06-23 14:07:18 -04:00
|
|
|
$active
|
|
|
|
.one('bsTransitionEnd', next)
|
2014-07-07 07:03:56 -04:00
|
|
|
.emulateTransitionEnd(Tab.TRANSITION_DURATION) :
|
2014-06-23 14:07:18 -04:00
|
|
|
next()
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
$active.removeClass('in')
|
|
|
|
}
|
2011-11-27 20:04:55 -05:00
|
|
|
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// TAB PLUGIN DEFINITION
|
|
|
|
// =====================
|
2013-05-16 20:18:15 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
function Plugin(option) {
|
|
|
|
return this.each(function () {
|
|
|
|
var $this = $(this)
|
|
|
|
var data = $this.data('bs.tab')
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (!data) $this.data('bs.tab', (data = new Tab(this)))
|
|
|
|
if (typeof option == 'string') data[option]()
|
|
|
|
})
|
|
|
|
}
|
2014-04-22 01:03:33 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var old = $.fn.tab
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
$.fn.tab = Plugin
|
|
|
|
$.fn.tab.Constructor = Tab
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2012-12-07 17:06:01 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// TAB NO CONFLICT
|
|
|
|
// ===============
|
2012-12-07 17:06:01 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
$.fn.tab.noConflict = function () {
|
|
|
|
$.fn.tab = old
|
|
|
|
return this
|
|
|
|
}
|
2012-12-07 17:06:01 -05:00
|
|
|
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// TAB DATA-API
|
|
|
|
// ============
|
|
|
|
|
2014-08-26 17:34:21 -04:00
|
|
|
var clickHandler = function (e) {
|
2014-06-23 14:07:18 -04:00
|
|
|
e.preventDefault()
|
|
|
|
Plugin.call($(this), 'show')
|
2014-08-26 17:34:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document)
|
|
|
|
.on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
|
|
|
|
.on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
}(jQuery);
|