polyglot/app/javascript/packs/application.js

30 lines
761 B
JavaScript
Raw Normal View History

import "bootstrap";
2018-08-31 09:17:26 +00:00
import { triggerModalEvent } from "../components/modal.js";
triggerModalEvent();
const links = document.querySelector('links');
const linksList = document.querySelectorAll('.links div');
const getSiblings = function (elem) {
const siblings = [];
let sibling = elem.parentNode.firstChild;
const skipMe = elem;
for ( ; sibling; sibling = sibling.nextSibling )
if ( sibling.nodeType == 1 && sibling != elem )
siblings.push( sibling );
return siblings;
}
linksList.forEach(link => {
link.addEventListener('click', event => {
// event.preventDefault()
link.classList.add('active')
const siblings = getSiblings(link)
siblings.forEach(sibling => {
sibling.classList.remove('active');
})
})
})