polyglot/app/javascript/packs/application.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

import "bootstrap";
2018-08-31 09:17:26 +00:00
import { triggerModalEvent } from "../components/modal.js";
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);
}
2018-09-03 17:32:03 +00:00
const triggerCalleeModalEvent = () => {
$("#calleeModal").modal('show');
}
// export { triggerCalleeModalEvent }