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.
 
 
 
template-for-verstka/assets/js/script.js

42 lines
1.3 KiB

window.addEventListener('load', function () {
const preloader = document.querySelector('#preloader')
preloader.classList.add('hidden')
setTimeout(function () {
preloader.remove()
}, 500)
})
jQuery(document).ready(function () {
$('input[type="tel"]').mask('+7 (999) 999-9999')
})
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')
})
}
}
})