You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
window.addEventListener('load', function () {
|
|
const preloader = document.querySelector('#preloader')
|
|
preloader.classList.add('hidden')
|
|
setTimeout(function () {
|
|
preloader.remove()
|
|
}, 500)
|
|
})
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
let modalBg = document.querySelector('#modal__bg')
|
|
if (modalBg) {
|
|
let modalBtnAll = document.querySelectorAll('.modal__btn')
|
|
let modalBtnCloseAll = document.querySelectorAll('.modal__close')
|
|
for (const modalBtnItem of modalBtnAll) {
|
|
modalBtnItem.addEventListener('click', function (e) {
|
|
e.preventDefault()
|
|
let modalBtnData = this.dataset.modal
|
|
let modalSection = document.querySelector(
|
|
'section.modal[data-id=' + modalBtnData + ']'
|
|
)
|
|
modalBg.classList.add('opened')
|
|
modalSection.classList.add('opened')
|
|
})
|
|
}
|
|
modalBg.addEventListener('click', function () {
|
|
modalBg.classList.remove('opened')
|
|
document.querySelector('section.modal.opened').classList.remove('opened')
|
|
})
|
|
for (const modalBtnCloseItem of modalBtnCloseAll) {
|
|
modalBtnCloseItem.addEventListener('click', function () {
|
|
modalBg.classList.remove('opened')
|
|
document
|
|
.querySelector('section.modal.opened')
|
|
.classList.remove('opened')
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|