1$(document).ready(function () { 2 3 /* if (localStorage.foundElementCount) { 4 $('#found-items-count').html(`Ðайдено ${localStorage.foundElementCount} ÑоваÑ${countEnd(localStorage.foundElementCount)}`); 5 $('#catalog-title-items-count').html(`${localStorage.foundElementCount} ÑоваÑ${countEnd(localStorage.foundElementCount)}`); 6 }*/ 7 8 /*$('#del_filter').click(function () { 9 if (localStorage.foundElementCount) { 10 localStorage.removeItem('foundElementCount'); 11 } 12 });*/ 13 14 let min_val = parseInt(($('#input-0').val().replace(/ /g, '')), 10); 15 let max_val = parseInt(($('#input-1').val().replace(/ /g, '')), 10); 16 if (rangeSlider && min_val && max_val) { 17 rangeSlider.noUiSlider.updateOptions({ 18 start: [min_val, max_val], 19 range: { 20 'min': [min_val], 21 'max': [max_val] 22 } 23 }); 24 var input0 = document.getElementById('NEXT_SMART_FILTER_P1_MIN'); 25 var input1 = document.getElementById('NEXT_SMART_FILTER_P1_MAX'); 26 var inputs = [input0, input1]; 27 rangeSlider.noUiSlider.on('update', function (values, handle) { 28 inputs[handle].value = Math.round(values[handle]) + ' ÑÑб.'; 29 $(inputs[handle]).attr('value', Math.round(values[handle]) + ' ÑÑб.'); 30 }); 31 rangeSlider.noUiSlider.on('end', function (values, handle) { 32 if (handle == 0) { 33 smartFilter.keyup($('#NEXT_SMART_FILTER_P1_MIN')[0]); 34 } else { 35 smartFilter.keyup($('#NEXT_SMART_FILTER_P1_MAX')[0]) 36 } 37 }); 38 var setRangeSlider = function setRangeSlider(i, value) { 39 var arr = [null, null]; 40 arr[i] = value; 41 rangeSlider.noUiSlider.set(arr); 42 }; 43 inputs.forEach(function (el, index) { 44 el.addEventListener('change', function (e) { 45 setRangeSlider(index, e.currentTarget.value); 46 }); 47 }); 48 49 function updateRangeSlider() { 50 let qString = location.href; 51 let ar_qStr_params = qString.split("/"); 52 let filter_val = ar_qStr_params[ar_qStr_params.indexOf('filter') + 1] 53 let price_from = null; 54 let price_to = null; 55 if (filter_val) { 56 let filter_params = filter_val.split('-'); 57 price_from = filter_params[filter_params.indexOf("from") + 1]; 58 price_to = filter_params[filter_params.indexOf("to") + 1]; 59 } 60 if (price_from) { 61 setRangeSlider(0, Number(price_from)); 62 } 63 if (price_to) { 64 setRangeSlider(1, Number(price_to)); 65 } 66 } 67 68 updateRangeSlider(); 69 } 70 $('.bx_filter_parameters_box').each(function () { 71 if ($.cookie("NEXT_filter_prop_" + $(this).data('prop_code')) == 2) { 72 $(this).removeClass('active'); 73 $(this).find('.bx_filter_block').hide(); 74 } else if ($.cookie("NEXT_filter_prop_" + $(this).data('prop_code')) == 3) { 75 $(this).addClass('active'); 76 $(this).find('.bx_filter_block').show(); 77 } 78 }) 79 $(".hint .icon").click(function (e) { 80 e.stopPropagation(); 81 var tooltipWrapp = $(this).parents(".hint"); 82 var bActive = tooltipWrapp.is('.active'); 83 $('.bx_filter .hint.active').removeClass("active").find(".tooltip").slideUp(200); 84 if (!bActive) { 85 tooltipWrapp.addClass("active").find(".tooltip").slideDown(200); 86 tooltipWrapp.find(".tooltip_close").click(function (e) { 87 e.stopPropagation(); 88 tooltipWrapp.removeClass("active").find(".tooltip").slideUp(200); 89 }); 90 } 91 }); 92 $(document).click(function (e) { 93 if (!$(e.target).hasClass('tooltip')) { 94 $('.bx_filter .hint.active').removeClass("active").find(".tooltip").slideUp(200); 95 } 96 }); 97 98 $('.bx_filter_parameters_box').each(function (btn) { 99 $(this).on('click', function (e) { 100 $(e.currentTarget).find('input[type="checkbox"]').each(function () { 101 if ($(this).prop("checked")) { 102 resetBtn(true); 103 } else { 104 resetBtn(false); 105 } 106 }); 107 }); 108 }); 109 110 const pathname = window.location.pathname; 111 if (pathname.includes('/filter/') && pathname.includes('/apply/')) { 112 const $smartFilter = $('.smartfilter'); 113 if ($smartFilter.length) { 114 $('html, body').animate({ 115 scrollTop: $smartFilter.offset().top 116 }, 1000, 'swing'); 117 } 118 } 119 120}) 121 122//ÑÑнкÑÐ¸Ñ ÐºÐ¾ÑоÑÐ°Ñ Ð¼ÐµÐ½ÑÐµÑ ÐºÐ»Ð°ÑÑ ÐºÐ½Ð¾Ð¿ÐºÐµ ÑбÑоÑа ÑилÑÑÑа 123function resetBtn(checked = false) { 124 let _checked = checked; 125 let first_slider_val = false;
126 let second_slider_val = false; 127 128 $('.bx_filter_parameters_box').find('input[type="checkbox"]').each(function () { 129 if ($(this).prop("checked")) { 130 _checked = true; 131 } 132 }); 133 134 if (parseInt($('#NEXT_SMART_FILTER_P1_MIN').val()) !== parseInt($('#input-0').val())) { 135 first_slider_val = true; 136 } else { 137 first_slider_val = false; 138 } 139 if (parseInt($('#NEXT_SMART_FILTER_P1_MAX').val()) !== parseInt($('#input-1').val())) { 140 second_slider_val = true; 141 } else { 142 second_slider_val = false; 143 } 144 145 if (_checked || first_slider_val || second_slider_val) { 146 if ($('#del_filter').hasClass("filter-btn--reset")) { 147 $('#del_filter').removeClass("filter-btn--reset"); 148 } 149 } else { 150 if (!$('#del_filter').hasClass("filter-btn--reset")) { 151 $('#del_filter').addClass("filter-btn--reset"); 152 } 153 } 154 155} 156 157function JCSmartFilter(ajaxURL, viewMode, params) { 158 this.ajaxURL = ajaxURL; 159 this.form = null; 160 this.timer = null; 161 this.cacheKey = ''; 162 this.cache = []; 163 this.viewMode = viewMode; 164 if (params && params.SEF_SET_FILTER_URL) { 165 this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL); 166 this.sef = true; 167 } 168 if (params && params.SEF_DEL_FILTER_URL) { 169 this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL); 170 } 171} 172 173JCSmartFilter.prototype.keyup = function (input) { 174 175 resetBtn(); 176 177 if (!!this.timer) { 178 clearTimeout(this.timer); 179 } 180 if (!$(input).hasClass('disabled')) { 181 this.timer = setTimeout(BX.delegate(function () { 182 this.reload(input); 183 }, this), 500); 184 } 185}; 186 187JCSmartFilter.prototype.click = function (checkbox) { 188 if (!!this.timer) { 189 clearTimeout(this.timer); 190 } 191 this.timer = setTimeout(BX.delegate(function () { 192 this.reload(checkbox); 193 }, this), 500); 194}; 195 196JCSmartFilter.prototype.reload = function (input) { 197 if (this.cacheKey !== '') { 198 //Postprone backend query 199 if (!!this.timer) { 200 clearTimeout(this.timer); 201 } 202 this.timer = setTimeout(BX.delegate(function () { 203 this.reload(input); 204 }, this), 1000); 205 return; 206 } 207 this.cacheKey = '|'; 208 209 var isSelecBox = false; 210 isSelecBox = $(input).closest('.bx_filter_select_container').length; 211 212 this.position_input = 0; 213 214 //this.label_input = $('label[data-role=label_' + $(input).attr('id').replace("all_", "") + ']'); 215 /*if (isSelecBox) { 216 this.label_input = $(input).closest('.bx_filter_select_container'); 217 } 218 if (this.label_input.length) { 219 this.position_input = this.label_input.offset().top - this.label_input.height() / 2; 220 if (this.label_input.hasClass('nab')) { 221 this.position_input += 7; 222 } 223 if (isSelecBox) { 224 this.position_input += 10; 225 } 226 }*/ 227 228 this.position = BX.pos(input, true); 229 this.form = BX.findParent(input, {'tag': 'form'}); 230 if (this.form) { 231 var values = []; 232 values[0] = {name: 'ajax', value: 'y'}; 233 this.gatherInputsValues(values, BX.findChildren(this.form, {'tag': new RegExp('^(input|select)$', 'i')}, true)); 234 235 for (var i = 0; i < values.length; i++) 236 this.cacheKey += values[i].name + ':' + values[i].value + '|'; 237 238 if (this.cache[this.cacheKey]) { 239 this.curFilterinput = input; 240 this.postHandler(this.cache[this.cacheKey], true); 241 } else { 242 if (this.sef) { 243 var set_filter = BX('set_filter'); 244 set_filter.disabled = true; 245 } 246 this.curFilterinput = input; 247 BX.ajax.loadJSON( 248 this.ajaxURL, 249 this.values2post(values), 250 BX.delegate(this.postHandler, this) 251 ); 252 } 253 } 254}; 255 256JCSmartFilter.prototype.postHandler = function (result, fromCache) { 257 var hrefFILTER, url, curProp; 258 var modef = BX('modef'); 259 var modef_mobile = BX('modef_mobile'); 260 var modef_num = BX('modef_num'); 261 var modef_num_mobile = BX('modef_num_mobile'); 262 263 if (!!result && !!result.ITEMS) { 264 265 if (!!modef && !!modef_num) { 266 //вÑводим кол-во ÑоваÑа на ÐºÐ½Ð¾Ð¿ÐºÑ 267 $('#set_filter').val(`ÐоказаÑÑ (${result.ELEMENT_COUNT})`); 268 269 localStorage.setItem('foundElementCount', result.ELEMENT_COUNT); 270 271 modef_num.innerHTML = result.ELEMENT_COUNT; 272 modef_num_mobile.innerHTML = result.ELEMENT_COUNT; 273 hrefFILTER = BX.findChildren(modef, {tag: 'A'}, true); 274 hrefFILTER_mobile = BX.findChildren(modef_mobile, {tag: 'A'}, true); 275 276 if (result.FILTER_URL && hrefFILTER) { 277 hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL.replace('/filter/clear/apply/', '/')); 278 hrefFILTER_mobile[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL.replace('/filter/clear/apply/', '/')); 279 } 280 281 if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID) { 282 BX.unbindAll(hrefFILTER[0]); 283 BX.unbindAll(hrefFILTER_mobile[0]); 284 BX.bind(hrefFILTER[0], 'click', function (e) { 285 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 286 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 287 return BX.PreventDefault(e); 288 }); 289 } 290 291 if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID) { 292 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 293 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 294 } else { 295 if (this.viewMode == "vertical") { 296 curProp = BX.findChild(BX.findParent(this.curFilterinput, {'class': 'bx_filter_parameters_box'}), {'class': 'bx_filter_container_modef'}, true, false); 297 //curProp.appendChild(modef); 298 } 299 300 if (result.SEF_SET_FILTER_URL) { 301 this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL); 302 } 303 } 304 } 305 } 306 307 if (this.sef) { 308 var set_filter = BX('set_filter'); 309 set_filter.disabled = false;
310 } 311 312 if (!fromCache && this.cacheKey !== '') { 313 this.cache[this.cacheKey] = result; 314 } 315 this.cacheKey = ''; 316}; 317 318JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url) { 319 var button = BX(buttonId); 320 if (button) { 321 var proxy = function (j, func) { 322 return function () { 323 return func(j); 324 } 325 }; 326 327 if (button.type == 'submit') 328 button.type = 'button'; 329 330 BX.bind(button, 'click', proxy(url, function (url) { 331 window.location.href = url; 332 return false; 333 })); 334 } 335}; 336 337JCSmartFilter.prototype.gatherInputsValues = function (values, elements) { 338 if (elements) { 339 for (var i = 0; i < elements.length; i++) { 340 var el = elements[i]; 341 if (el.disabled || !el.type) 342 continue; 343 344 switch (el.type.toLowerCase()) { 345 case 'text': 346 case 'textarea': 347 case 'password': 348 case 'hidden': 349 case 'select-one': 350 if (el.value.length) 351 values[values.length] = {name: el.name, value: el.value.replace(' ÑÑб.', '')}; 352 break; 353 case 'radio': 354 case 'checkbox': 355 if (el.checked) 356 values[values.length] = {name: el.name, value: el.value}; 357 break; 358 case 'select-multiple': 359 for (var j = 0; j < el.options.length; j++) { 360 if (el.options[j].selected) 361 values[values.length] = {name: el.name, value: el.options[j].value}; 362 } 363 break; 364 default: 365 break; 366 } 367 } 368 } 369}; 370 371JCSmartFilter.prototype.values2post = function (values) { 372 var post = []; 373 var current = post; 374 var i = 0; 375 376 while (i < values.length) { 377 var p = values[i].name.indexOf('['); 378 if (p == -1) { 379 current[values[i].name] = values[i].value; 380 current = post; 381 i++; 382 } else { 383 var name = values[i].name.substring(0, p); 384 var rest = values[i].name.substring(p + 1); 385 if (!current[name]) 386 current[name] = []; 387 388 var pp = rest.indexOf(']'); 389 if (pp == -1) { 390 //Error - not balanced brackets 391 current = post; 392 i++; 393 } else if (pp == 0) { 394 //No index specified - so take the next integer 395 current = current[name]; 396 values[i].name = '' + current.length; 397 } else { 398 //Now index name becomes and name and we go deeper into the array 399 current = current[name]; 400 values[i].name = rest.substring(0, pp) + rest.substring(pp + 1); 401 } 402 } 403 } 404 return post; 405};
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.