added all modified files
This commit is contained in:
38
assets/js/script.js
Normal file
38
assets/js/script.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user