57 lines
2.2 KiB
JavaScript
57 lines
2.2 KiB
JavaScript
import './bootstrap.js';
|
|
/*
|
|
* Welcome to your app's main JavaScript file!
|
|
*
|
|
* This file will be included onto the page via the importmap() Twig function,
|
|
* which should already be in your base.html.twig.
|
|
*/
|
|
import './styles/app.css';
|
|
|
|
if (! location.pathname.includes('login')) {
|
|
const vocabs = document.querySelector('#vocabs');
|
|
const records = document.querySelector('#records');
|
|
const userMenu = document.querySelector('.dropdown-trigger');
|
|
const userCaret = document.querySelector('#user-caret');
|
|
|
|
const forVocabs = document.querySelector('#for-vocabs')
|
|
const forRecords = document.querySelector('#for-records')
|
|
|
|
if (forVocabs) {
|
|
forVocabs.addEventListener('click', function () {
|
|
vocabs.classList.toggle('is-hidden');
|
|
|
|
if (this.firstElementChild.classList.contains('fa-angle-right')) {
|
|
this.firstElementChild.classList.remove('fa-angle-right');
|
|
this.firstElementChild.classList.add('fa-angle-down');
|
|
} else {
|
|
this.firstElementChild.classList.remove('fa-angle-down');
|
|
this.firstElementChild.classList.add('fa-angle-right');
|
|
}
|
|
});
|
|
}
|
|
|
|
if (forRecords) {
|
|
forRecords.addEventListener('click', function () {
|
|
records.classList.toggle('is-hidden');
|
|
|
|
if (this.firstElementChild.classList.contains('fa-angle-right')) {
|
|
this.firstElementChild.classList.remove('fa-angle-right');
|
|
this.firstElementChild.classList.add('fa-angle-down');
|
|
} else {
|
|
this.firstElementChild.classList.remove('fa-angle-down');
|
|
this.firstElementChild.classList.add('fa-angle-right');
|
|
}
|
|
});
|
|
}
|
|
|
|
userMenu.addEventListener('click', function () {
|
|
document.querySelector('.dropdown').classList.toggle('is-active');
|
|
if (userCaret.classList.contains('fa-caret-down')) {
|
|
userCaret.classList.remove('fa-caret-down');
|
|
userCaret.classList.add('fa-caret-up');
|
|
} else {
|
|
userCaret.classList.remove('fa-caret-up');
|
|
userCaret.classList.add('fa-caret-down');
|
|
}
|
|
});
|
|
} |