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