polyglot/app/javascript/packs/application.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

import "bootstrap";
2018-08-31 09:17:26 +00:00
import { triggerModalEvent } from "../components/modal.js";
2018-09-04 10:52:10 +00:00
import { loadDynamicBannerText } from '../components/banner';
loadDynamicBannerText();
triggerModalEvent();
2018-09-01 17:27:12 +00:00
const settingsPage = document.getElementById('settings-page');
const contactsPage = document.getElementById('contacts-page');
2018-09-01 17:27:12 +00:00
const getSiblings = (element) => {
const siblings = [];
2018-09-01 17:27:12 +00:00
let sibling = element.parentNode.firstChild;
const skipMe = element;
for ( ; sibling; sibling = sibling.nextSibling )
2018-09-01 17:27:12 +00:00
if ( sibling.nodeType == 1 && sibling != element )
siblings.push( sibling );
return siblings;
}
2018-09-01 17:27:12 +00:00
const removeActiveClass = (element) => {
const siblings = getSiblings(element);
siblings.forEach(sibling => {
sibling.classList.remove('active');
});
}
if (settingsPage) {
const settings = document.getElementById('settings')
settings.classList.add('active');
removeActiveClass(settings);
}
if (contactsPage) {
const contacts = document.getElementById('contacts')
contacts.classList.add('active');
removeActiveClass(contacts);
}