1document.addEventListener('DOMContentLoaded', function() { 2 const popupSelectCity = document.getElementById('popup-select-city'); 3 const closeButton = popupSelectCity.querySelector('.popup__close'); 4 let openedFromPopupTopForm = false; 5 6 // LANDINGI-796: 7 дней Ñ ÑÐ°Ð½ÐµÐ½Ð¸Ñ Ð²ÑбоÑа гоÑода, Ñделанного внÑÑÑи бизнеÑ-попапа 7 const BUSINESS_CITY_COOKIE = 'business_popup_city'; 8 const BUSINESS_CITY_COOKIE_DAYS = 7; 9 10 function saveBusinessCityCookie(id, name) { 11 const value = encodeURIComponent(JSON.stringify({ id: id, name: name })); 12 const expires = new Date(Date.now() + BUSINESS_CITY_COOKIE_DAYS * 24 * 60 * 60 * 1000).toUTCString(); 13 document.cookie = BUSINESS_CITY_COOKIE + '=' + value + '; expires=' + expires + '; path=/'; 14 } 15 16 function showPopup(event) { 17 // ÐÑовеÑÑем, бÑл ли клик на лÑбом ÑлеменÑе .city 18 const clickedCityElement = event.target.closest('.city'); 19 if (clickedCityElement) { 20 openedFromPopupTopForm = true; // Ðлик бÑл по .city 21 } else { 22 openedFromPopupTopForm = false; // Ðлик не бÑл по .city 23 } 24 25 // LANDINGI-796: помеÑаем, ÑÑо попап оÑкÑÑÑ Ð¸Ð· бизнеÑ-попапа â далÑÑе ÑÑо 26 // ÑиÑаÑÑ Ð¸ здеÑÑ (веÑка ниже), и в cf7-address-search.js (handleGlobalCityChange), 27 // ÑÑÐ¾Ð±Ñ Ð½Ðµ задваиваÑÑ ÑабоÑÑ Ð¸ не ÑÑогаÑÑ Ð´ÑÑгие ÑоÑÐ¼Ñ ÑÑÑаниÑÑ. 28 popupSelectCity.dataset.openedFrom = event.target.closest('.popup-business') ? 'business' : ''; 29 30 popupSelectCity.style.display = 'flex'; 31 } 32 33 document.querySelectorAll('.button-select-city').forEach(button => { 34 button.addEventListener('click', showPopup); 35 }); 36 37 document.querySelectorAll('.city').forEach(city => { 38 city.addEventListener('click', showPopup); 39 }); 40 41 popupSelectCity.addEventListener('click', function(e) { 42 if (e.target.classList.contains('region_item')) { 43 const popup_cityId = e.target.getAttribute('id'); 44 const cityName = e.target.textContent.trim(); 45 46 // LANDINGI-842: поÑле вÑбоÑа гоÑода подÑвеÑждение Ñегиона болÑÑе не показÑваем. 47 // Ðока окно оÑкÑÑÑо, плаÑка Ð»ÐµÐ¶Ð¸Ñ Ð¿Ð¾Ð´ его подложкой (z-index 1001 > 1000). 48 const popupConfirmRegion = document.getElementById('popup-confirm-region'); 49 if (popupConfirmRegion) { 50 popupConfirmRegion.style.display = 'none'; 51 } 52 53 if (popupSelectCity.dataset.openedFrom === 'business') { 54 // LANDINGI-796: вÑÐ±Ð¾Ñ Ð³Ð¾Ñода из бизнеÑ-попапа. ÐиÑем ÑолÑко в ÑоÑÐ¼Ñ 55 // внÑÑÑи .popup-business â дÑÑгие ÑоÑÐ¼Ñ ÑÑÑаниÑÑ Ð½Ðµ ÑÑогаем. 56 e.preventDefault(); 57 58 const businessPopup = document.querySelector('.popup-business'); 59 const businessForm = businessPopup ? businessPopup.querySelector('form.wpcf7-form') : null; 60 if (businessForm) { 61 const cityNameDisplay = businessForm.querySelector('.autocomplete-city-name'); 62 const hiddenCityId = businessForm.querySelector('.id_city'); // BusinessCityId 63 const hiddenCityName = businessForm.querySelector('.name_city'); // CityName 64 const addressInput = businessForm.querySelector('[name="City"]'); 65 66 if (cityNameDisplay) { 67 cityNameDisplay.textContent = cityName; 68 cityNameDisplay.setAttribute('data-item', popup_cityId); 69 } 70 if (hiddenCityId) hiddenCityId.value = popup_cityId; 71 if (hiddenCityName) hiddenCityName.value = cityName; 72 if (addressInput) addressInput.disabled = false; 73 74 saveBusinessCityCookie(popup_cityId, cityName); 75 76 // LANDINGI-796: ÑÑÑной вÑÐ±Ð¾Ñ Ð´ÐµÑжиÑÑÑ Ð´Ð¾ пеÑезагÑÑзки/пеÑÐµÑ Ð¾Ð´Ð° на дÑÑгÑÑ 77 // ÑÑÑаниÑÑ, даже на ÑÑÑаниÑе, пÑивÑзанной к гоÑÐ¾Ð´Ñ â инаÑе ÑледÑÑÑее 78 // оÑкÑÑÑие попапа Ñнова подÑÑÐ°Ð²Ð¸Ñ Ð³Ð¾Ñод ÑÑÑаниÑÑ Ð¿Ð¾Ð²ÐµÑÑ Ð²ÑбоÑа 79 // полÑзоваÑелÑ. dataset живÑÑ Ð² DOM, знаÑÐ¸Ñ Ð¿ÐµÑÐµÐ¶Ð¸Ð²Ð°ÐµÑ Ð·Ð°ÐºÑÑÑие попапа, 80 // но не пеÑÐµÐ¶Ð¸Ð²Ð°ÐµÑ Ð¿ÐµÑезагÑÑÐ·ÐºÑ â ÑÑого и ÑÑебÑÐµÑ Ð¢Ð. 81 if (businessPopup) { 82 businessPopup.dataset.manualCityId = popup_cityId; 83 businessPopup.dataset.manualCityName = cityName; 84 } 85 } 86 } else if (!openedFromPopupTopForm) { 87 e.preventDefault(); 88 // ÐÑли не из popupTopForm â вÑÑавлÑем знаÑÐµÐ½Ð¸Ñ 89 const cityNameElements = document.querySelectorAll('.autocomplete-city-name');
90 cityNameElements.forEach(function(cityNameElement) { 91 cityNameElement.textContent = cityName; 92 cityNameElement.setAttribute('data-item', popup_cityId); 93 }); 94 // // ÐÑиÑÑка полей Ñ Ð°Ð´ÑеÑом и домом пÑи Ñмене гоÑода 95 // const addressStreet = document.getElementById('address_street'); 96 // if (addressStreet && addressStreet.value.trim() !== '') { 97 // addressStreet.value = ''; 98 // } 99 100 // const addressHouse = document.getElementById('address_house'); 101 // if (addressHouse && addressHouse.value.trim() !== '') { 102 // addressHouse.value = ''; 103 // addressHouse.removeAttribute('data-street-id'); // еÑли надо ÑбÑаÑÑ Ð¿ÑивÑÐ·ÐºÑ Ðº ÑлиÑе 104 // } 105 106 // ÐÑиÑÑка полей Ñ Ð°Ð´ÑеÑом и домом пÑи Ñмене гоÑода 107 document.querySelectorAll('[name="AddresStreet"]').forEach(streetInput => { 108 streetInput.value = ''; 109 }); 110 111 document.querySelectorAll('[name="AddresHouse"]').forEach(houseInput => { 112 houseInput.value = ''; 113 houseInput.removeAttribute('data-street-id'); // ÑбиÑаем пÑивÑÐ·ÐºÑ Ðº ÑлиÑе 114 houseInput.disabled = true; // блокиÑÑем Ñнова 115 houseInput.placeholder = 'Ðом'; 116 117 // ÐÑиÑÑка блока Ñ Ð°Ð´ÑеÑом 118 const addressDiv = document.getElementById('address-block__title'); 119 if (addressDiv) { 120 addressDiv.textContent = ''; 121 } 122 }); 123 124 } else { 125 // ÐÑли из popupTopForm â не вÑÑавлÑем 126 console.log('ÐÑÐ±Ð¾Ñ Ð³Ð¾Ñода из popupTopForm â не вÑÑавлÑем знаÑениÑ'); 127 } 128 129 popupSelectCity.style.display = 'none'; 130 } 131 132 if (e.target === popupSelectCity) { 133 popupSelectCity.style.display = 'none'; 134 } 135 }); 136 137 closeButton.addEventListener('click', function() { 138 popupSelectCity.style.display = 'none'; 139 }); 140});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.