1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/bootstrap-source/bootstrap-3.0.3/js/tab.js Fri Jan 17 11:59:43 2014 +0100
1.3 @@ -0,0 +1,135 @@
1.4 +/* ========================================================================
1.5 + * Bootstrap: tab.js v3.0.3
1.6 + * http://getbootstrap.com/javascript/#tabs
1.7 + * ========================================================================
1.8 + * Copyright 2013 Twitter, Inc.
1.9 + *
1.10 + * Licensed under the Apache License, Version 2.0 (the "License");
1.11 + * you may not use this file except in compliance with the License.
1.12 + * You may obtain a copy of the License at
1.13 + *
1.14 + * http://www.apache.org/licenses/LICENSE-2.0
1.15 + *
1.16 + * Unless required by applicable law or agreed to in writing, software
1.17 + * distributed under the License is distributed on an "AS IS" BASIS,
1.18 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1.19 + * See the License for the specific language governing permissions and
1.20 + * limitations under the License.
1.21 + * ======================================================================== */
1.22 +
1.23 +
1.24 ++function ($) { "use strict";
1.25 +
1.26 + // TAB CLASS DEFINITION
1.27 + // ====================
1.28 +
1.29 + var Tab = function (element) {
1.30 + this.element = $(element)
1.31 + }
1.32 +
1.33 + Tab.prototype.show = function () {
1.34 + var $this = this.element
1.35 + var $ul = $this.closest('ul:not(.dropdown-menu)')
1.36 + var selector = $this.data('target')
1.37 +
1.38 + if (!selector) {
1.39 + selector = $this.attr('href')
1.40 + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1.41 + }
1.42 +
1.43 + if ($this.parent('li').hasClass('active')) return
1.44 +
1.45 + var previous = $ul.find('.active:last a')[0]
1.46 + var e = $.Event('show.bs.tab', {
1.47 + relatedTarget: previous
1.48 + })
1.49 +
1.50 + $this.trigger(e)
1.51 +
1.52 + if (e.isDefaultPrevented()) return
1.53 +
1.54 + var $target = $(selector)
1.55 +
1.56 + this.activate($this.parent('li'), $ul)
1.57 + this.activate($target, $target.parent(), function () {
1.58 + $this.trigger({
1.59 + type: 'shown.bs.tab'
1.60 + , relatedTarget: previous
1.61 + })
1.62 + })
1.63 + }
1.64 +
1.65 + Tab.prototype.activate = function (element, container, callback) {
1.66 + var $active = container.find('> .active')
1.67 + var transition = callback
1.68 + && $.support.transition
1.69 + && $active.hasClass('fade')
1.70 +
1.71 + function next() {
1.72 + $active
1.73 + .removeClass('active')
1.74 + .find('> .dropdown-menu > .active')
1.75 + .removeClass('active')
1.76 +
1.77 + element.addClass('active')
1.78 +
1.79 + if (transition) {
1.80 + element[0].offsetWidth // reflow for transition
1.81 + element.addClass('in')
1.82 + } else {
1.83 + element.removeClass('fade')
1.84 + }
1.85 +
1.86 + if (element.parent('.dropdown-menu')) {
1.87 + element.closest('li.dropdown').addClass('active')
1.88 + }
1.89 +
1.90 + callback && callback()
1.91 + }
1.92 +
1.93 + transition ?
1.94 + $active
1.95 + .one($.support.transition.end, next)
1.96 + .emulateTransitionEnd(150) :
1.97 + next()
1.98 +
1.99 + $active.removeClass('in')
1.100 + }
1.101 +
1.102 +
1.103 + // TAB PLUGIN DEFINITION
1.104 + // =====================
1.105 +
1.106 + var old = $.fn.tab
1.107 +
1.108 + $.fn.tab = function ( option ) {
1.109 + return this.each(function () {
1.110 + var $this = $(this)
1.111 + var data = $this.data('bs.tab')
1.112 +
1.113 + if (!data) $this.data('bs.tab', (data = new Tab(this)))
1.114 + if (typeof option == 'string') data[option]()
1.115 + })
1.116 + }
1.117 +
1.118 + $.fn.tab.Constructor = Tab
1.119 +
1.120 +
1.121 + // TAB NO CONFLICT
1.122 + // ===============
1.123 +
1.124 + $.fn.tab.noConflict = function () {
1.125 + $.fn.tab = old
1.126 + return this
1.127 + }
1.128 +
1.129 +
1.130 + // TAB DATA-API
1.131 + // ============
1.132 +
1.133 + $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1.134 + e.preventDefault()
1.135 + $(this).tab('show')
1.136 + })
1.137 +
1.138 +}(jQuery);