mirror of
https://github.com/jgthms/bulma.git
synced 2024-11-28 12:24:23 +00:00
08ef4df2c0
* Add Bulma v9 * Add vendor dependencies * Fix native * Fix sponsors * Add style attribute
36 lines
901 B
JavaScript
36 lines
901 B
JavaScript
document.addEventListener('DOMContentLoaded', () => {
|
|
// Utils
|
|
|
|
const tabs = getAll('.bd-tabs');
|
|
|
|
if (tabs && tabs.length > 0) {
|
|
tabs.forEach((tab) => {
|
|
const buttons = getAll('.bd-tabs-nav button', tab);
|
|
const items = getAll('.bd-tabs-item', tab);
|
|
|
|
buttons.forEach((button, index) => {
|
|
button.addEventListener('click', (event) => {
|
|
showTab(buttons, items, index);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
function showTab(buttons, items, index) {
|
|
buttons.forEach((button) => {
|
|
button.classList.remove('bd-is-active');
|
|
});
|
|
|
|
items.forEach((item) => {
|
|
item.classList.remove('bd-is-active');
|
|
});
|
|
|
|
buttons[index].classList.add('bd-is-active');
|
|
items[index].classList.add('bd-is-active');
|
|
}
|
|
|
|
function getAll(selector, parent = document) {
|
|
return Array.prototype.slice.call(parent.querySelectorAll(selector), 0);
|
|
}
|
|
});
|