[fa375fe] | 1 | /* ========================================================================
|
---|
| 2 | * Bootstrap: tab.js v3.4.1
|
---|
| 3 | * https://getbootstrap.com/docs/3.4/javascript/#tabs
|
---|
| 4 | * ========================================================================
|
---|
| 5 | * Copyright 2011-2019 Twitter, Inc.
|
---|
| 6 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
---|
| 7 | * ======================================================================== */
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | +function ($) {
|
---|
| 11 | 'use strict';
|
---|
| 12 |
|
---|
| 13 | // TAB CLASS DEFINITION
|
---|
| 14 | // ====================
|
---|
| 15 |
|
---|
| 16 | var Tab = function (element) {
|
---|
| 17 | // jscs:disable requireDollarBeforejQueryAssignment
|
---|
| 18 | this.element = $(element)
|
---|
| 19 | // jscs:enable requireDollarBeforejQueryAssignment
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | Tab.VERSION = '3.4.1'
|
---|
| 23 |
|
---|
| 24 | Tab.TRANSITION_DURATION = 150
|
---|
| 25 |
|
---|
| 26 | Tab.prototype.show = function () {
|
---|
| 27 | var $this = this.element
|
---|
| 28 | var $ul = $this.closest('ul:not(.dropdown-menu)')
|
---|
| 29 | var selector = $this.data('target')
|
---|
| 30 |
|
---|
| 31 | if (!selector) {
|
---|
| 32 | selector = $this.attr('href')
|
---|
| 33 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | if ($this.parent('li').hasClass('active')) return
|
---|
| 37 |
|
---|
| 38 | var $previous = $ul.find('.active:last a')
|
---|
| 39 | var hideEvent = $.Event('hide.bs.tab', {
|
---|
| 40 | relatedTarget: $this[0]
|
---|
| 41 | })
|
---|
| 42 | var showEvent = $.Event('show.bs.tab', {
|
---|
| 43 | relatedTarget: $previous[0]
|
---|
| 44 | })
|
---|
| 45 |
|
---|
| 46 | $previous.trigger(hideEvent)
|
---|
| 47 | $this.trigger(showEvent)
|
---|
| 48 |
|
---|
| 49 | if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
|
---|
| 50 |
|
---|
| 51 | var $target = $(document).find(selector)
|
---|
| 52 |
|
---|
| 53 | this.activate($this.closest('li'), $ul)
|
---|
| 54 | this.activate($target, $target.parent(), function () {
|
---|
| 55 | $previous.trigger({
|
---|
| 56 | type: 'hidden.bs.tab',
|
---|
| 57 | relatedTarget: $this[0]
|
---|
| 58 | })
|
---|
| 59 | $this.trigger({
|
---|
| 60 | type: 'shown.bs.tab',
|
---|
| 61 | relatedTarget: $previous[0]
|
---|
| 62 | })
|
---|
| 63 | })
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | Tab.prototype.activate = function (element, container, callback) {
|
---|
| 67 | var $active = container.find('> .active')
|
---|
| 68 | var transition = callback
|
---|
| 69 | && $.support.transition
|
---|
| 70 | && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
|
---|
| 71 |
|
---|
| 72 | function next() {
|
---|
| 73 | $active
|
---|
| 74 | .removeClass('active')
|
---|
| 75 | .find('> .dropdown-menu > .active')
|
---|
| 76 | .removeClass('active')
|
---|
| 77 | .end()
|
---|
| 78 | .find('[data-toggle="tab"]')
|
---|
| 79 | .attr('aria-expanded', false)
|
---|
| 80 |
|
---|
| 81 | element
|
---|
| 82 | .addClass('active')
|
---|
| 83 | .find('[data-toggle="tab"]')
|
---|
| 84 | .attr('aria-expanded', true)
|
---|
| 85 |
|
---|
| 86 | if (transition) {
|
---|
| 87 | element[0].offsetWidth // reflow for transition
|
---|
| 88 | element.addClass('in')
|
---|
| 89 | } else {
|
---|
| 90 | element.removeClass('fade')
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | if (element.parent('.dropdown-menu').length) {
|
---|
| 94 | element
|
---|
| 95 | .closest('li.dropdown')
|
---|
| 96 | .addClass('active')
|
---|
| 97 | .end()
|
---|
| 98 | .find('[data-toggle="tab"]')
|
---|
| 99 | .attr('aria-expanded', true)
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | callback && callback()
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | $active.length && transition ?
|
---|
| 106 | $active
|
---|
| 107 | .one('bsTransitionEnd', next)
|
---|
| 108 | .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
|
---|
| 109 | next()
|
---|
| 110 |
|
---|
| 111 | $active.removeClass('in')
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | // TAB PLUGIN DEFINITION
|
---|
| 116 | // =====================
|
---|
| 117 |
|
---|
| 118 | function Plugin(option) {
|
---|
| 119 | return this.each(function () {
|
---|
| 120 | var $this = $(this)
|
---|
| 121 | var data = $this.data('bs.tab')
|
---|
| 122 |
|
---|
| 123 | if (!data) $this.data('bs.tab', (data = new Tab(this)))
|
---|
| 124 | if (typeof option == 'string') data[option]()
|
---|
| 125 | })
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | var old = $.fn.tab
|
---|
| 129 |
|
---|
| 130 | $.fn.tab = Plugin
|
---|
| 131 | $.fn.tab.Constructor = Tab
|
---|
| 132 |
|
---|
| 133 |
|
---|
| 134 | // TAB NO CONFLICT
|
---|
| 135 | // ===============
|
---|
| 136 |
|
---|
| 137 | $.fn.tab.noConflict = function () {
|
---|
| 138 | $.fn.tab = old
|
---|
| 139 | return this
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | // TAB DATA-API
|
---|
| 144 | // ============
|
---|
| 145 |
|
---|
| 146 | var clickHandler = function (e) {
|
---|
| 147 | e.preventDefault()
|
---|
| 148 | Plugin.call($(this), 'show')
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | $(document)
|
---|
| 152 | .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
|
---|
| 153 | .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
|
---|
| 154 |
|
---|
| 155 | }(jQuery);
|
---|