2011-11-27 20:04:55 -05:00
|
|
|
/* ========================================================
|
2013-05-16 14:06:30 -04:00
|
|
|
* Bootstrap: tab.js v3.0.0
|
2011-11-27 20:04:55 -05:00
|
|
|
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
|
|
|
* ========================================================
|
2012-01-15 02:28:48 -05:00
|
|
|
* Copyright 2012 Twitter, Inc.
|
2011-11-27 20:04:55 -05:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
* ======================================================== */
|
|
|
|
|
|
|
|
|
2012-04-14 19:29:53 -04:00
|
|
|
!function ($) {
|
|
|
|
|
|
|
|
"use strict"; // jshint ;_;
|
2011-11-27 20:04:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
/* TAB CLASS DEFINITION
|
|
|
|
* ==================== */
|
|
|
|
|
2012-07-22 21:28:39 -04:00
|
|
|
var Tab = function (element) {
|
2011-11-27 20:04:55 -05:00
|
|
|
this.element = $(element)
|
|
|
|
}
|
|
|
|
|
|
|
|
Tab.prototype = {
|
|
|
|
|
2011-12-01 01:42:22 -05:00
|
|
|
constructor: Tab
|
|
|
|
|
|
|
|
, show: function () {
|
2011-11-27 20:04:55 -05:00
|
|
|
var $this = this.element
|
|
|
|
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
2012-01-28 04:35:13 -05:00
|
|
|
, selector = $this.attr('data-target')
|
2011-11-27 20:04:55 -05:00
|
|
|
, previous
|
2012-01-28 04:35:13 -05:00
|
|
|
, $target
|
2012-03-24 21:20:09 -04:00
|
|
|
, e
|
2012-01-28 04:35:13 -05:00
|
|
|
|
|
|
|
if (!selector) {
|
|
|
|
selector = $this.attr('href')
|
|
|
|
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
|
|
|
}
|
2011-11-27 20:04:55 -05:00
|
|
|
|
|
|
|
if ( $this.parent('li').hasClass('active') ) return
|
|
|
|
|
2012-10-01 00:41:37 -04:00
|
|
|
previous = $ul.find('.active:last a')[0]
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2012-03-24 21:20:09 -04:00
|
|
|
e = $.Event('show', {
|
|
|
|
relatedTarget: previous
|
2011-11-27 20:04:55 -05:00
|
|
|
})
|
|
|
|
|
2012-03-24 21:20:09 -04:00
|
|
|
$this.trigger(e)
|
|
|
|
|
|
|
|
if (e.isDefaultPrevented()) return
|
|
|
|
|
2012-01-28 04:35:13 -05:00
|
|
|
$target = $(selector)
|
2011-11-27 20:04:55 -05:00
|
|
|
|
|
|
|
this.activate($this.parent('li'), $ul)
|
2012-01-28 04:35:13 -05:00
|
|
|
this.activate($target, $target.parent(), function () {
|
2011-12-20 22:37:41 -05:00
|
|
|
$this.trigger({
|
|
|
|
type: 'shown'
|
|
|
|
, relatedTarget: previous
|
|
|
|
})
|
2011-11-27 20:04:55 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2011-12-20 22:37:41 -05:00
|
|
|
, activate: function ( element, container, callback) {
|
|
|
|
var $active = container.find('> .active')
|
|
|
|
, transition = callback
|
|
|
|
&& $.support.transition
|
|
|
|
&& $active.hasClass('fade')
|
|
|
|
|
|
|
|
function next() {
|
|
|
|
$active
|
|
|
|
.removeClass('active')
|
|
|
|
.find('> .dropdown-menu > .active')
|
|
|
|
.removeClass('active')
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2011-12-20 22:37:41 -05:00
|
|
|
element.addClass('active')
|
2011-11-27 20:04:55 -05:00
|
|
|
|
2011-12-20 22:37:41 -05:00
|
|
|
if (transition) {
|
|
|
|
element[0].offsetWidth // reflow for transition
|
|
|
|
element.addClass('in')
|
2012-01-08 15:08:00 -05:00
|
|
|
} else {
|
|
|
|
element.removeClass('fade')
|
2011-12-20 22:37:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( element.parent('.dropdown-menu') ) {
|
|
|
|
element.closest('li.dropdown').addClass('active')
|
|
|
|
}
|
|
|
|
|
|
|
|
callback && callback()
|
2011-11-27 20:04:55 -05:00
|
|
|
}
|
2011-12-20 22:37:41 -05:00
|
|
|
|
|
|
|
transition ?
|
|
|
|
$active.one($.support.transition.end, next) :
|
|
|
|
next()
|
|
|
|
|
|
|
|
$active.removeClass('in')
|
2011-11-27 20:04:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* TAB PLUGIN DEFINITION
|
|
|
|
* ===================== */
|
|
|
|
|
2012-12-07 17:06:01 -05:00
|
|
|
var old = $.fn.tab
|
|
|
|
|
2011-12-20 21:02:47 -05:00
|
|
|
$.fn.tab = function ( option ) {
|
2011-11-27 20:04:55 -05:00
|
|
|
return this.each(function () {
|
|
|
|
var $this = $(this)
|
|
|
|
, data = $this.data('tab')
|
|
|
|
if (!data) $this.data('tab', (data = new Tab(this)))
|
|
|
|
if (typeof option == 'string') data[option]()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2011-12-21 02:28:48 -05:00
|
|
|
$.fn.tab.Constructor = Tab
|
2011-11-27 20:04:55 -05:00
|
|
|
|
|
|
|
|
2012-12-07 17:06:01 -05:00
|
|
|
/* TAB NO CONFLICT
|
|
|
|
* =============== */
|
|
|
|
|
|
|
|
$.fn.tab.noConflict = function () {
|
|
|
|
$.fn.tab = old
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-27 20:04:55 -05:00
|
|
|
/* TAB DATA-API
|
|
|
|
* ============ */
|
|
|
|
|
2012-09-27 18:00:02 -04:00
|
|
|
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
|
|
|
e.preventDefault()
|
|
|
|
$(this).tab('show')
|
2011-11-27 20:04:55 -05:00
|
|
|
})
|
|
|
|
|
2013-04-23 03:34:27 -04:00
|
|
|
}(window.jQuery);
|