notifications

This commit is contained in:
Kyle
2020-12-29 10:32:59 -08:00
parent c83eac81c0
commit d14dc17e0b
14 changed files with 86 additions and 38 deletions

32
js/main-1.js Normal file
View File

@@ -0,0 +1,32 @@
function toggleMenu() {
if (document.querySelector('.hamburger').classList.contains('opened')) {
document.querySelector('.hamburger').classList.remove('opened');
Array.from(document.querySelectorAll('.menu-visible')).forEach(element => element.classList.remove('menu-visible'));
} else {
document.documentElement.style.setProperty('--window-diagonal-size', (Math.floor(Math.sqrt(window.innerWidth ** 2 + window.innerHeight ** 2)) + 100) + 'px');
document.querySelector('.hamburger').classList.add('opened');
document.querySelector('.menu').classList.add('menu-visible');
}
}
function notify(message = '') {
var notification = document.createElement('div');
notification.classList = 'notification padding';
var notificationMessage = document.createElement('h4');
notificationMessage.innerHTML = message;
notification.appendChild(notificationMessage);
var close = document.createElement('h3');
close.innerHTML = 'X';
close.onclick = closeNotification;
notification.appendChild(close);
document.querySelector('.notification-container').appendChild(notification);
}
function closeNotification(event) {
var target = event.target.closest('.notification');
target.classList.add('hidden');
setTimeout(function(){target.remove();}, 500);
}
window.onload = function() {
Array.from(document.querySelectorAll('input')).forEach(element => {
element.autocomplete = 'off';
});
}