35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
const toast = document.querySelector('.toast');
|
|
let timer;
|
|
|
|
function showToast(message) {
|
|
toast.textContent = message;
|
|
toast.classList.add('show');
|
|
clearTimeout(timer);
|
|
timer = setTimeout(() => toast.classList.remove('show'), 2600);
|
|
}
|
|
|
|
document.querySelectorAll('[data-toast]').forEach((button) => {
|
|
button.addEventListener('click', () => showToast(button.dataset.toast));
|
|
});
|
|
|
|
const modal = document.querySelector('#experiment-modal');
|
|
document.querySelectorAll('[data-modal="experiment"]').forEach((button) => {
|
|
button.addEventListener('click', () => modal.showModal());
|
|
});
|
|
|
|
document.querySelectorAll('[data-tool]').forEach((button) => {
|
|
button.addEventListener('click', () => showToast(`Демо «${button.dataset.tool}» будет доступно в следующем экране.`));
|
|
});
|
|
|
|
document.querySelectorAll('[data-route]').forEach((button) => {
|
|
button.addEventListener('click', () => { window.location.href = button.dataset.route; });
|
|
});
|
|
|
|
modal.addEventListener('close', () => {
|
|
if (modal.returnValue === 'default') showToast('Эксперимент создан в демо-режиме.');
|
|
});
|
|
|
|
document.querySelector('.mobile-menu').addEventListener('click', () => {
|
|
showToast('Мобильное меню будет добавлено вместе с внутренними страницами.');
|
|
});
|