Skip to content

Commit 67e068a

Browse files
committed
Add missing jquery plugin tab.js
1 parent 2dbee62 commit 67e068a

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

assets/common/bootstrap-tab.js

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/* ========================================================
2+
* bootstrap-tab.js v2.0.4
3+
* https://getbootstrap.com/2.0.4/javascript.html#tabs
4+
* ========================================================
5+
* Copyright 2012 Twitter, Inc.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* ======================================================== */
19+
20+
21+
export default function ($) {
22+
23+
"use strict"; // jshint ;_;
24+
25+
26+
/* TAB CLASS DEFINITION
27+
* ==================== */
28+
29+
var Tab = function ( element ) {
30+
this.element = $(element)
31+
}
32+
33+
Tab.prototype = {
34+
35+
constructor: Tab
36+
37+
, show: function () {
38+
var $this = this.element
39+
, $ul = $this.closest('ul:not(.dropdown-menu)')
40+
, selector = $this.attr('data-target')
41+
, previous
42+
, $target
43+
, e
44+
45+
if (!selector) {
46+
selector = $this.attr('href')
47+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
48+
}
49+
50+
if ( $this.parent('li').hasClass('active') ) return
51+
52+
previous = $ul.find('.active a').last()[0]
53+
54+
e = $.Event('show', {
55+
relatedTarget: previous
56+
})
57+
58+
$this.trigger(e)
59+
60+
if (e.isDefaultPrevented()) return
61+
62+
$target = $(selector)
63+
64+
this.activate($this.parent('li'), $ul)
65+
this.activate($target, $target.parent(), function () {
66+
$this.trigger({
67+
type: 'shown'
68+
, relatedTarget: previous
69+
})
70+
})
71+
}
72+
73+
, activate: function ( element, container, callback) {
74+
var $active = container.find('> .active')
75+
, transition = callback
76+
&& $.support.transition
77+
&& $active.hasClass('fade')
78+
79+
function next() {
80+
$active
81+
.removeClass('active')
82+
.find('> .dropdown-menu > .active')
83+
.removeClass('active')
84+
85+
element.addClass('active')
86+
87+
if (transition) {
88+
element[0].offsetWidth // reflow for transition
89+
element.addClass('in')
90+
} else {
91+
element.removeClass('fade')
92+
}
93+
94+
if ( element.parent('.dropdown-menu') ) {
95+
element.closest('li.dropdown').addClass('active')
96+
}
97+
98+
callback && callback()
99+
}
100+
101+
transition ?
102+
$active.one($.support.transition.end, next) :
103+
next()
104+
105+
$active.removeClass('in')
106+
}
107+
}
108+
109+
110+
/* TAB PLUGIN DEFINITION
111+
* ===================== */
112+
113+
$.fn.tab = function ( option ) {
114+
return this.each(function () {
115+
var $this = $(this)
116+
, data = $this.data('tab')
117+
if (!data) $this.data('tab', (data = new Tab(this)))
118+
if (typeof option == 'string') data[option]()
119+
})
120+
}
121+
122+
$.fn.tab.Constructor = Tab
123+
124+
125+
/* TAB DATA-API
126+
* ============ */
127+
128+
$(function () {
129+
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
130+
e.preventDefault()
131+
$(this).tab('show')
132+
})
133+
})
134+
135+
}

assets/dashboard/events/events.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import jQuery from 'jquery';
22
import { plainUserTypeahead } from 'common/typeahead';
33
import { ajax, showStatusMessage } from 'common/utils';
4+
import bootstrapTabJs from 'common/bootstrap-tab';
5+
6+
bootstrapTabJs(jQuery);
47

58
/*
69
The event module provides dynamic functions to event objects

0 commit comments

Comments
 (0)