1if(document.body !== null) { 2 document.body.addEventListener('click', function (e) { 3 if (e.target.parentNode && e.target.parentNode.classList.contains("geo_location")) { 4 getGeoLocation(); 5 } 6 }); 7} 8 9function getGeoLocation(){ 10 axios.get('/local/ajax/geo-modal.php').then(function (response) { 11 document.querySelector('#location-modal .modal-inner').innerHTML = response.data; 12 addJs(window.url + window.SITE_TEMPLATE_PATH + '/assets/js/vendor/fancybox.js', 'fancybox-script', ()=>{ 13 let options = {}; 14 if(document.querySelector('[name="ORDER_FORM"]')){ 15 options = { 16 on: { 17 shouldClose: () => { 18 if(Cookies.get('select_city') == '' || Cookies.get('select_city') == undefined) { 19 return false; 20 } 21 } 22 } 23 } 24 } 25 window.location_modal = new Fancybox([{ src: "#location-modal", type: "inline" }], options); 26 }); 27 addCss(window.url + window.SITE_TEMPLATE_PATH + '/assets/css/vendor/tom-select.css', 'tom-select-style', function (){}); 28 addJs(window.url + window.SITE_TEMPLATE_PATH + '/assets/js/vendor/tom-select.complete.min.js', 'tom-select-script', () => { 29 TomSelect.define('no_close',function(){ 30 this.close = function(){}; 31 }); 32 let selectCitySelect = new TomSelect('#search_location',{ 33 plugins:['no_close'], 34 valueField: 'CODE', 35 labelField: 'NAME_FULL', 36 placeholder: 'ÐоиÑк по гоÑодам', 37 searchField: 'NAME', 38 create: false, 39 sortField: { 40 field: "NAME", 41 direction: "asc" 42 }, 43 maxItems: 1, 44 load: function(query, callback) { 45 axios.post('/api/v2/locations/Search/', {q: query}) 46 .then(response => { 47 window.location_search_items = response.data.items; 48 callback(response.data.items); 49 if(document.querySelector('#search_location-ts-dropdown .spinner')) { 50 document.querySelector('#search_location-ts-dropdown .spinner').remove(); 51 } 52 }).catch(() => { 53 callback(); 54 if(document.querySelector('#search_location-ts-dropdown .spinner')) { 55 document.querySelector('#search_location-ts-dropdown .spinner').remove(); 56 } 57 }); 58 59 }, 60 render: { 61 option: function(item, escape) { 62 return `<div class="py-2 d-flex" onclick="setValueCity('${item.CODE}', '${item.NAME}'); return true;"> 63 <div class="description">${ escape(item.NAME_FULL) }</div> 64 </div>`; 65 }, 66 item: function(item, escape) { 67 return `<div class="py-2 d-flex"> 68 <div class="description">${ escape(item.NAME) }</div> 69 </div>`; 70 } 71 }, 72 }); 73 let formItem = document.querySelectorAll('.form-item'); 74 setFormItem(formItem); 75 }); 76 }); 77} 78 79async function setValueCity(id, name){ 80 // ÐÑполÑзÑем ÑенÑÑализованнÑÑ ÑÑнкÑÐ¸Ñ Ð¸Ð· app.js 81 if (typeof selectCity === 'function') { 82 // Создаем вÑеменнÑй ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ñ Ð½ÑжнÑми аÑÑибÑÑами 83 const tempEl = document.createElement('div'); 84 tempEl.setAttribute('data-code', id); 85 tempEl.setAttribute('data-name', name); 86 87 // ÐолÑÑаем полнÑе даннÑе гоÑода из ÑезÑлÑÑаÑов поиÑка 88 if (window.location_search_items) { 89 const cityData = window.location_search_items.find(item => item.CODE === id);
90 if (cityData) { 91 tempEl.setAttribute('data-item', JSON.stringify(cityData)); 92 } 93 } 94 95 // ÐÑзÑваем selectCity - ÑепеÑÑ Ð¾Ð½Ð° Ð¼Ð¾Ð¶ÐµÑ ÑабоÑаÑÑ Ñ Ð¾Ð´Ð½Ð¸Ð¼ паÑамеÑÑом 96 selectCity(tempEl); 97 } else { 98 // Fallback на ÑлÑÑай, еÑли selectCity недоÑÑÑпна 99 Cookies.set('select_city', id, { expires: 365, domain: '.magok.ru', path: '/' }); 100 Cookies.set('select_city_name', name, { expires: 365, domain: '.magok.ru', path: '/' }); 101 102 // ÐбновлÑем инÑеÑÑÐµÐ¹Ñ 103 document.querySelectorAll('.geo_location span').forEach(el => { 104 el.innerText = name; 105 }); 106 107 if(document.querySelector('[name="ORDER_FORM"]')){ 108 document.querySelector('[name="prop_LOCATION"]').value = id; 109 refreshOrder(); 110 } 111 } 112 113 // ÐбновлÑем доÑÑÐ°Ð²ÐºÑ (еÑли еÑÑÑ) 114 if(document.getElementById('delivery_in_product') && deliveryInProduct !== undefined){ 115 deliveryInProduct.reSet(); 116 } 117 118 // ÐакÑÑваем модалÑное окно 119 if (window.location_modal) { 120 window.location_modal.close(); 121 } 122 123 // Ðдем ÑезÑлÑÑÐ°Ñ Ð¿ÑовеÑки поддомена 124 try { 125 const redirectResult = await checkCitySubdomain(id, name); 126 console.log('РезÑлÑÑÐ°Ñ Ð¿ÑовеÑки поддомена:', redirectResult); 127 128 if (!redirectResult.needsRedirect) { 129 console.log('РедиÑÐµÐºÑ Ð½Ðµ ÑÑебÑеÑÑÑ, оÑÑаемÑÑ Ð½Ð° ÑекÑÑей ÑÑÑаниÑе'); 130 return false; 131 } 132 } catch (error) { 133 console.error('ÐÑибка пÑи пÑовеÑке поддомена:', error); 134 return false; 135 } 136 137 return false; 138} 139 140function setTitle(){ 141 142} 143 144document.querySelectorAll('.geo_location span').forEach(el => { 145 146 if(Cookies.get('select_city_name') != null){ 147 el.innerHTML = Cookies.get('select_city_name'); 148 149 if(document.querySelector('.conform_geo_location')){ 150 document.querySelector('.conform_geo_location').remove(); 151 } 152 } 153 154 155});
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.