forked from jgthms/bulma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
39 lines (30 loc) · 1022 Bytes
/
Copy pathstart.js
File metadata and controls
39 lines (30 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
document.addEventListener('DOMContentLoaded', function () {
// Utils
var tabs = getAll('.bd-tabs');
if (tabs && tabs.length > 0) {
tabs.forEach(function (tab) {
var buttons = getAll('.bd-tabs-nav button', tab);
var items = getAll('.bd-tabs-item', tab);
buttons.forEach(function (button, index) {
button.addEventListener('click', function (event) {
showTab(buttons, items, index);
});
});
});
}
function showTab(buttons, items, index) {
buttons.forEach(function (button) {
button.classList.remove('bd-is-active');
});
items.forEach(function (item) {
item.classList.remove('bd-is-active');
});
buttons[index].classList.add('bd-is-active');
items[index].classList.add('bd-is-active');
}
function getAll(selector) {
var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
return Array.prototype.slice.call(parent.querySelectorAll(selector), 0);
}
});