function addClickListeners(buttonsSelector, dialogSelector) {
const buttons = document.querySelectorAll(buttonsSelector);
const dialog = document.querySelector(dialogSelector);
buttons.forEach(n => n.addEventListener('click', e => {
e.preventDefault();
dialog.style.display = 'block';
}));
dialog.addEventListener('click', ({ target }) => {
if (target.classList.contains('popup-close')) {
document.getElementById('name_1').disabled = true;
document.getElementById('phone_1').disabled = true;
dialog.style.display = 'none';
} else if (!target.closest('.popup-content')) {
dialog.style.display = 'none';
}
});
}
addClickListeners('header .contacts a', '.popup-call');
addClickListeners('.sentence-btn', '.popup-discount');
addClickListeners('.check-btn', '.popup-check');
</script>
нужно разбивать:$('.map').html('<script charset="utf-8" async src="https://api-maps.yandex.ru/services/constructor/1.0/js/?um=constructor%3A45374b4f36193c2c3bb5a22a9bffed35b78e3e041596ce43450258bbf7529fad&width=100%25&height=598&lang=ru_UA&scroll=false"> </sc' + 'ript>')
var script = document.createElement('script');
script.async = true;
script.src = 'https://api-maps.yandex.ru/services/constructor/1.0/js/?um=constructor%3A45374b4f36193c2c3bb5a22a9bffed35b78e3e041596ce43450258bbf7529fad&width=100%25&height=598&lang=ru_UA&scroll=false';
$('.map').append(script);
$(".map-show").one('mouseover', function() {
var map = $(this).attr("data-map");
var map_width = $(window).width();
var map_height = $(this).attr("data-map-height");
$(this).css("height", map_height);
$(this).html(`<iframe src="${map}" width="${map_width}" style="border:0" allowfullscreen></iframe>`);
});
mouseenter
и mouseleave
.$(this).off('mouseenter mouseleave');
$(".map-show").hover(function () {
var map = $(this).attr("data-map");
var map_width = $(window).width();
var map_height = $(this).attr("data-map-height");
$(this).css("height", map_height);
if (map_width > window) { map_width = window; }
$(this).html('<iframe src="' + map + '" width="' + map_width + '" height="' + map_height + '" frameborder="0" style="border:0" allowfullscreen></iframe>');
$(this).off('mouseenter mouseleave');
});
$('.price').text((i, text) => {
const [ price, currency ] = text.split(' ');
return `${(+price).toLocaleString()} ${currency}`;
});
// или
document.querySelectorAll('.price').forEach(n => {
n.textContent = n.textContent.replace(/\d(?=(\d{3})+\D)/g, '$& ');
});