1var base_url = window.location.protocol + "//" + window.location.host; 2var compare_mark = []; 3var _ra = _ra || {}; 4var mark_ajax = true; 5 6function in_array(val) { 7 var idx = $.inArray(val, compare_mark); 8 if (idx == -1) { 9 return false; 10 //compare_mark.push(val); 11 } else { 12 return true; 13 //selectArr.splice(idx, 1); 14 } 15} 16 17function setC(n, v) { 18 let now = new Date(); 19 20 if (now.getMonth() == 11) { 21 var date = new Date(now.getFullYear() + 1, 0, 1); 22 } else { 23 var date = new Date(now.getFullYear(), now.getMonth() + 1, 1); 24 } 25 26 let dateString = date.toGMTString(); 27 // document.cookie = n + '=' + escape(v) + '; expires=Thu, 2 Aug 2023 20:47:11 UT; path=/'; 28 document.cookie = n + '=' + escape(v) + '; expires='+dateString+'; path=/'; 29} 30 31$.ajaxQ = (function () { 32 var id = 0, Q = {}; 33 34 $(document).ajaxSend(function (e, jqx) { 35 jqx._id = ++id; 36 Q[jqx._id] = jqx; 37 }); 38 $(document).ajaxComplete(function (e, jqx) { 39 delete Q[jqx._id]; 40 }); 41 42 return { 43 abortAll: function () { 44 var r = []; 45 $.each(Q, function (i, jqx) { 46 r.push(jqx._id); 47 jqx.abort(); 48 }); 49 return r; 50 } 51 }; 52 53})(); 54 55function set_idea_form() { 56 $('#dialog').children('p').html('ÐÑаквайÑе ÑкоÑо!'); 57 $('#dialog').dialog({title: 'Ðмам Ð¸Ð´ÐµÑ Ð·Ð° JAR Computers...'}); 58} 59 60function show_loginform(obj) { 61 //var el = '<div id="client_login_form">'; 62 var el = '<h2>Ðанни на Ð²Ñ Ð¾Ð´</h2>'; 63 el += '<div method="post" id="checkout_login_form">'; 64 el += '<div class="row"><div class="col-3"></div><div class="col-1 col-md-2 col-sm-4"><label for="uuname">E-mail: </label></div><div class="col-3 col-md-8 col-sm-8"><input type="text" name="uuname" value=""></div></div>'; 65 el += '<div class="row"><div class="col-3"></div><div class="col-1 col-md-2 col-sm-4"><label for="upassword">ÐаÑола: </label></div><div class="col-3 col-md-8 col-sm-8"><input type="password" name="upassword" value=""></div></div>'; 66 el += '<div class="row"><div class="col-4 col-md-2 col-sm-4"></div><div class="col-3 col-md-8 col-sm-8 checkbox"><input type="checkbox" name="remember_me" value="accept" checked="checked" id="remember_me"><label for="remember_me">Ðапомни ме </label><a class="forgotten_link" target="_blank" href="/auth/forgotten_password">ÐабÑавена паÑола</a></div></div>'; 67 el += '<div class="row"><div class="col-4 col-md-2 col-sm-4"></div><div class="col-3 col-md-8 col-sm-8"><input type="submit" name="ulogin" value="ÐÑ Ð¾Ð´"></div></div>'; 68 el += '</div>'; 69 //el += '</div>'; 70 //$(obj).after(el); //$(obj).hide(); 71 $('#login_container').html(el).toggle(); 72} 73 74function change_delivery_type(obj, type) { 75 var vals = parseInt($(obj).val()); 76 //alert(vals); 77 if (vals == 1) { 78 $('.add_new_address').hide(); 79 $('#make_proform_div').show(); 80 $('#div-address').show(); 81 82 if(type) { 83 $('input[name=oaddress]').val($('input[name=econt_address]').val()); 84 } 85 86 $('.city').hide(); 87 $('.city-br').hide(); 88 $('.oaddress').hide(); 89 $('.econt_office').show(); 90 $('.speedy_office').hide(); 91 $('.speedy_box').hide(); 92 $('.uaddress').hide(); 93 setTimeout(function() { initioal_econt_office(); }, 300); 94 } else if (vals == 4) { 95 $('.add_new_address').hide(); 96 $('#make_proform_div').show(); 97 $('#div-address').show(); 98 99 if(type) { 100 $('input[name=oaddress]').val($('input[name=econt_address]').val()); 101 } 102 103 $('.city').hide(); 104 $('.city-br').hide(); 105 $('.oaddress').hide(); 106 $('.speedy_office').show(); 107 $('.speedy_box').hide(); 108 $('.econt_office').hide(); 109 $('.uaddress').hide(); 110 setTimeout(function() { initioal_speedy_office(); }, 300); 111 } else if(vals == 5) { 112 setTimeout(function() { 113 $('.speedy_new_address').show(); 114 initioal_speedy_address(); 115 }, 300); 116 } else if(vals == 2) { 117 setTimeout(function() { 118 $('.econt_new_address').show(); 119 initioal_econt_address(); 120 }, 300); 121 } else if(vals == 7) { 122 setTimeout(function() { $('.add_new_address').hide(); 123 $('#make_proform_div').show(); 124 $('#div-address').show(); 125 126 if(type) { 127 $('input[name=oaddress]').val($('input[name=econt_address]').val()); 128 } 129 130 $('.city').hide(); 131 $('.city-br').hide(); 132 $('.oaddress').hide(); 133 $('.econt_office').hide(); 134 $('.speedy_office').hide(); 135 $('.speedy_box').show(); 136 $('.uaddress').hide(); 137 initioal_speedy_box(); 138 }, 300); 139 } else if(vals == 6) { 140 $('#make_proform_div').show(); 141 $('#div-address').show(); 142 143 if(type) { 144 $('input[name=oaddress]').val(''); 145 } 146 147 if(parseInt($('.checkout_form select.uaddress').val()) == 0 || !$('.checkout_form select.uaddress').length) { 148 $('.city').show(); 149 $('.city-br').show(); 150 $('.oaddress').show(); 151 } else { 152 $('.city').hide(); 153 $('.city-br').hide(); 154 $('.oaddress').hide(); 155 } 156 157 $('.econt_office').hide(); 158 $('.speedy_office').hide(); 159 $('.speedy_box').hide(); 160 $('.uaddress').show(); 161 $('.uaddress').change(); 162 } else { 163 $('.add_new_address').hide(); 164 $('#make_proform_div').hide(); 165 $('#make_proform').attr("checked", false); 166 $('#div-address').hide(); 167 168 if(type) { 169 $('input[name=oaddress]').val(''); 170 } 171 $('.oaddress').show(); 172 $('.econt_office').hide(); 173 $('.speedy_office').hide(); 174 $('.uaddress').hide(); 175 } 176 $('.delivery_subtype').prev('label').remove(); 177 $('.delivery_subtype').prev('br').remove(); 178 $('.delivery_subtype').remove(); 179 $('.delivery_subtype_div').html(subselect[vals]); 180 181 if(typeof vals != 'undefined') { 182 if(typeof subselect != 'undefined' && !isNaN(subselect) && !isNaN(vals)) { 183 $('.delivery_subtype_div').html(subselect[vals]); 184 } 185 if ($('#payment-type').length > 0) { 186 $('#payment-type').html(payment[vals]); 187 } 188 189 if(typeof address != 'undefined' && !isNaN(address) && !isNaN(vals) && address!= null) { 190 $('.address').html(address[vals]); 191 } 192 } 193 194 $('#econt_office').autocomplete({
195 source: "/ajax/search_econt_offices", 196 minLength: 3, 197 select: function (event, ui) { 198 //var id = $(this).attr('id'); 199 //$('#id_'+id).val(ui.item.id); 200 } 201 }).focus(function () { 202 $(this).autocomplete("search"); 203 }); 204 205 // var speedy_office_selected = ''; 206 // $('#speedy_office').autocomplete({ 207 // source: "/ajax/search_speedy_offices", 208 // minLength: 3, 209 // select: function (event, ui) { 210 // // var id = $(this).attr('id'); 211 // $('.speedy_office_id').val(ui.item.id); 212 // speedy_office_selected = ui.item.value; 213 // }, 214 // change: function(event, ui) { 215 // if (ui.item == null) { 216 // event.currentTarget.value = ''; 217 // event.currentTarget.focus(); 218 // } 219 // } 220 // }).focus(function () { 221 // // $(this).val(""); 222 // $(this).autocomplete("search"); 223 // }); 224 225 226 227 if(typeof change_payment_type === "function") { 228 change_payment_type(); 229 } 230 231 if(typeof show_info === "function") { 232 // show_info(); 233 } 234 235 if(typeof show_more_info === "function") { 236 show_more_info(); 237 } 238 239} 240 241function show_more_info() { 242 var vals = $('.delivery_subtype').val(); 243 if(typeof more_info != 'undefined') { 244 var town = more_info[vals]; 245 } 246 if (typeof vals != 'undefined' && vals.length > 0) { 247 payment_type_for_subtypes(); 248 } 249 if (typeof town !== 'undefined') { 250 $('.delivery_info').click(function () { 251 window.open("/stores/" + town) 252 }).show(); 253 } else { 254 $('.delivery_info').hide(); 255 } 256 257 if(vals == 'ÐÐÐ ÐомпÑÑÑÑÑ - ЦенÑÑала' || vals == 'ÐÐÐ ÐомпÑÑÑÑÑ - ЧеÑковна'){ 258 $('#make_proform_div').show(); 259 }else{ 260 $('#make_proform_div').hide(); 261 $('#make_proform').attr("checked", false); 262 } 263 264 if(typeof change_payment_type === "function") { 265 change_payment_type(); 266 } 267 268 if(typeof show_info === "function") { 269 show_info(); 270 } 271} 272 273function payment_type_for_subtypes() { 274 let dst = $('.delivery_subtype').val(); 275 let dt = $('#delivery_type').val() 276 277 if (dst == 'ÐÐÐ ÐомпÑÑÑÑÑ - ЦенÑÑала') { 278 $('#payment-type').html(payment_2[3]); 279 // console.log(payment_2[3]); 280 } else { 281 $('#payment-type').html(payment_temp); 282 } 283 284} 285 286 287function show_availability(obj) { 288 var container = $(obj).children('.availability_data'); 289 container.html('<img src="/images/loading.gif" style="margin:0 120px">').show();; 290 var code = $(obj).attr('rel'); 291 if(mark_ajax) { 292 mark_ajax = false; 293 let t = $.post('/product/avail_tag', {'code': code}, function (data) { 294 container.html(data).show(); 295 $("body *").not(container).click(function () { 296 container.hide(); 297 }); 298 mark_ajax = true; 299 }); 300 } 301} 302 303function compare_update() { 304 setTimeout(function() { 305 $.post('/compare/all', {'all': 1}, function (data) { 306 $("[name^='compare-'").prop('checked', false); 307 $.each(data, function(i, item) { 308 // console.log(i); 309 // console.log(item); 310 $("[name='compare-" + i + "']").prop('checked', true); 311 }); 312 }, 'json'); 313 }, 700); 314} 315 316function compare_them(prid, catid, pid, redir) { 317 //$.ajaxSetup({async: true}); 318 // console.log(redir, parseInt(redir)); 319 $.post('/compare', {'code': prid, 'catid': catid, 'pid':pid, 'redir': redir}, function (data) { 320 var cnts = parseInt(data.cnt); 321 if (data.flag == 1 || data.flag == 3) { 322 var txt = '<img src="' + $('#img-' + prid + '-' + catid).attr('src') + '" class="compare-' + prid + '-' + catid + '" style="opacity:0;" />'; 323 txt += '<div class="x" onclick="remove_from_compare(\'' + prid + '\', ' + catid + ');" >x</div>'; 324 $('.ui-effects-transfer').css('background', 'url(' + $('#img-' + prid + '-' + catid).attr('src') + ')'); 325 $('#compare' + cnts).html('').append(txt); 326 $('#img-' + prid + '-' + catid).effect("transfer", {to: $('.compare-' + prid + '-' + catid)}, 1000); 327 $('.compare-' + prid + '-' + catid).animate({opacity: 1}, 2000); 328 setTimeout(function() { 329 $('#pr-' + prid + '-' + catid + '-' + pid).removeAttr('disabled'); 330 $('#pr-' + prid + '-' + catid + '-' + pid).prop('checked', true); 331 $('[for=pr-' + prid + '-' + catid+ '-' + pid + ']').css({ 332 "opacity": "1" 333 }); 334 compare_mark.splice($.inArray(prid, compare_mark),1); 335 }, 1000); 336 } else { 337 setTimeout(function() { 338 $('#pr-' + prid + '-' + catid + '-' + pid).removeAttr('disabled'); 339 $('#pr-' + prid + '-' + catid + '-' + pid).prop('checked', false); 340 $('[for=pr-' + prid + '-' + catid+ '-' + pid + ']').css({ 341 "opacity": "1" 342 }); 343 compare_mark.splice($.inArray(prid, compare_mark),1); 344 }, 1000); 345 } 346 347 $('#compare_tab').html(data.html); 348 349 $("[name^='compare-'").prop('checked', false); 350 $.each($.parseJSON(data.all), function(i, item) { 351 // console.log(i); 352 // console.log(item); 353 $("[name='compare-" + i + "']").prop('checked', true); 354 }); 355 356 // console.log(compare_mark); 357 // show_comparetab(); 358 // compare_update(); 359 if (redir != 0) { 360 window.location.href = base_url + "/compare/products"; 361 } 362 }, 'json'); 363 364} 365 366 367function compare_show() { 368 window.location.href = base_url + "/compare/products"; 369} 370 371function addremove_compare(obj) { 372 var clss = $(obj).attr('class').split('-'); 373 if(in_array(clss[1])){ 374 return false;
375 } else { 376 compare_mark.push(clss[1]); 377 $(obj).attr('disabled', 'disabled'); 378 } 379 var input = '#pr-' + clss[1] + '-' + clss[2]; 380 /* if($(input).is(':checked')){ 381 // $(obj).html('ÑÑавни ').css('color', '#3B5998'); 382 $(input).prop('checked', false); 383 } else { 384 // $(obj).html('пÑÐµÐ¼Ð°Ñ Ð½Ð¸ Ð¾Ñ ÑÑавни ').css('color', 'green'); 385 $(input).prop('checked', true); 386 } 387 */ 388 $('#compare_tab').show(); 389 $('[for=pr-' + clss[1] + '-' + clss[2]+']').css({ 390 "opacity": "0.1" 391 }); 392 compare_them(clss[1], clss[2], 0); 393} 394 395function addremove_compare_check(obj) { 396 var clss = $(obj).attr('id').split('-'); 397 if(in_array(clss[1])){ 398 return false; 399 } else { 400 compare_mark.push(clss[1]); 401 $(obj).attr('disabled', 'disabled'); 402 } 403 var txt = '.pr-' + clss[1] + '-' + clss[2]; 404 405// if($(obj).is(':checked')){ 406// $(txt).html('пÑÐµÐ¼Ð°Ñ Ð½Ð¸ Ð¾Ñ ÑÑавни ').css('color', 'green'); 407// } else { 408// $(txt).html('ÑÑавни ').css('color', '#3B5998'); 409// } 410 $('#compare_tab').show(); 411 $('[for=' + $(obj).attr('id') + ']').css({ 412 "opacity": "0.1" 413 }); 414 // console.log('in action'); 415 416 setTimeout(function() { compare_them(clss[1], clss[2], clss[3], 0); }, 800); 417} 418 419function remove_from_compare(prid, catid, pid) { 420 if(in_array(prid)){ 421 return false; 422 } else { 423 compare_mark.push(prid); 424 } 425 var flag = 0; 426 if (window.location.href == "http://fe.jarcomputers.com/compare/products") { 427 flag = 1; 428 } 429 $('#pr-' + prid + '-' + catid + '-' + pid).prop('checked', false); 430 $('[for=pr-' + prid + '-' + catid+'-'+pid+']').css({ 431 "opacity": "0.1" 432 }); 433 setTimeout(function() { compare_them(prid, catid, pid, flag); }, 800); 434} 435 436function show_comparetab() { 437 $.post('/compare/show_comparerab', {}, function (data) { 438 if (parseInt(data.cnt) == 0) { 439 $('#compare_tab').hide(); 440 } 441 $('#compare_tab').html(data.html); 442 }, 'json'); 443} 444 445function switch_view(obj, e) { 446 var pl = $('#product_list'); 447 var c = pl.attr('class'); 448 var type = $(obj).attr('id'); 449 $(obj).closest('tr').find('.active').removeClass('active'); 450 $(obj).toggleClass('active'); 451 switch (type) { 452 case 'switch_table_view': 453 pl.attr('class', 'p2'); 454 $('.pprop').show(); 455 $('.s4').hide(); 456 $('.cart_table_list').hide(); 457 $('.cart_table_table').show(); 458 break; 459 case 'switch_line_view': 460 pl.attr('class', 'p3'); 461 $('.pprop').show(); 462 $('.s4').hide(); 463 $('.cart_table_list').hide(); 464 //$('.list_sku').hide(); $('.list_warranty').hide(); 465 $('.cart_table_table').show(); 466 break; 467 case 'switch_row_view': 468 pl.attr('class', 'p1'); 469 $('.pprop').show(); 470 $('.s4').show(); 471 $('.cart_table_table').hide(); 472 $('.cart_table_list').show(); 473 break; 474 default: 475 break; 476 } 477 setC('plview', pl.attr('class')); 478 e.preventDefault(); 479} 480 481function price_select(e, m) { 482 483 if(m === undefined) { 484 m = false; 485 } 486 487 var keyCode = e.keyCode || e.which; 488 // console.log(keyCode); 489 if (m || keyCode == 13) { 490 var p_from = parseFloat($('.other_pfrom').val()); 491 var p_to = parseFloat($('.other_pto').val()); 492 if (!isNaN(p_from) && !isNaN(p_to)) { 493 var text = 'text text'; 494 if ((p_to > p_from) || ( p_to == 0 && p_from != 0)) { 495 var loc = window.location.href; 496 var isit = loc.search('price-filter-other'); 497 var filter_str = 'fprice[price-filter-other]=p_from-' + p_from + '-p_to-' + p_to; 498 if (isit == -1) { 499 loc += ((loc.indexOf('?')!== -1)?'&':'?')+ filter_str; 500 $(window.location).attr('href', loc); 501 } else { 502 var regex = new RegExp("[\\?&]fprice[\\\[]price-filter-other[\\\]]=([^&#]*)"); 503 var vals = regex.exec(location.search); 504 var old_filter_str = 'fprice[price-filter-other]=' + vals[1]; 505 loc = loc.replace(old_filter_str, ''); 506 loc += ((loc.indexOf('?')!== -1)?'&':'?')+ filter_str; 507 $(window.location).attr('href', loc); 508 } 509 } else { 510 var loc = window.location.href; 511 var regex = new RegExp("[\\?&]fprice[\\\[]price-filter-other[\\\]]=([^&#]*)"); 512 var vals = regex.exec(location.search); 513 var old_filter_str = 'fprice[price-filter-other]=' + vals[1]; 514 loc = loc.replace(old_filter_str, ''); 515 $(window.location).attr('href', loc); 516 } 517 } 518 } 519} 520 521function setFilter3(objs) { 522 var filter_str; 523 var url_part = ''; 524 var loc = decodeURI(window.location.href); 525 // console.log(loc); 526 var locArr = loc.split('/'); 527 var brand = ''; 528 var url = ''; 529 $('.brand:checked').each(function(index) { 530 if (!(brand.indexOf($(this).attr('rel')) >= 0) && $(this).is(":visible")) { 531 //alert($(this).attr('rel') + ' - ' + $(this).prop('checked')); 532 if(brand.length > 0) { 533 brand += '_' + $(this).attr('rel').replace(/ /gi, "+"); 534 } else { 535 brand += $(this).attr('rel').replace(/ /gi, "+"); 536 } 537 } 538 }); 539 540 if(locArr.length == 4) { 541 for(i = 0; i < locArr.length; i++) { 542 if(url.length > 0) { 543 url += '/' + locArr[i]; 544 if(i == 2 && brand.length > 1) { 545 url += '/' + brand; 546 } 547 } else { 548 url += locArr[i]; 549 } 550 } 551 } else if(locArr.length > 4) { 552 for(i = 0; i < locArr.length; i++) { 553 if(url.length > 0) { 554 if(i == 3) { 555 if(brand.length > 1) { 556 url += '/' + brand; 557 } else if(locArr[i] == 'page') { 558 url += '/' + locArr[i]; 559 } else if(locArr[i] == 'promotion') { 560 url += '/' + locArr[i]; 561 } 562 } else { 563 url += '/' + locArr[i]; 564 } 565 } else { 566 url += locArr[i]; 567 } 568 } 569 } 570 571 if(url.length > 0) { 572 loc = url; 573 } 574 575 var loc_arr = loc.split('?'); 576 if (loc_arr.length == 1) { 577 // loc += '?ref=all'; 578 } 579 var obj; 580 for (ii = 0; ii < objs.length; ii++) { 581 obj = objs[ii]; 582 583 584 if ($(obj).is(':checked')) { 585 filter = $(obj).val().split('-'); 586 filter_type = 'add'; 587 } else { 588 filter = $(obj).val().split('-'); 589 filter_type = 'remove'; 590 } 591 var name = $(obj).attr('name'); 592 var filter = $(obj).val().split('-'); 593 if (filter[0] == 'p_from') { 594 /* 595 var vals = location.search.replace(/[\\?&]fprice\[.*?\]=([^&#]*)/g, ""); 596 $('#filpr_price .filter_it').each(function(){ 597 if(this.checked){ 598 vals += '&fprice['+$(this).attr('name')+']='+$(this).val(); 599 } 600 }); 601 loc = vals; 602 filter_str = ''; 603 */
604 filter_str = '&fprice[' + name + ']=' + $(obj).val(); 605 } else if (filter[0] == 'avail_id') { 606 filter_str = '&favail[' + filter[1] + ']=' + $(obj).val(); 607 } else if (filter[0] == 'brand') { 608 filter_str = '&fbrand[' + filter[1] + ']=' + $(obj).val(); 609 } else if (name == 'filter_q') { 610 var isit = loc.search('&filter_q='); 611 if (isit == -1) { 612 filter_type = 'add'; 613 filter_str = '&filter_q=' + $(obj).val(); 614 } else if ($(obj).val().length == 0) { 615 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); 616 var vals = regex.exec(location.search); 617 filter_type = 'remove'; 618 filter_str = '&filter_q=' + vals[1]; 619 } else { 620 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); 621 var vals = regex.exec(location.search); 622 filter_type = 'change'; 623 var old_filter_str = '&filter_q=' + vals[1]; 624 filter_str = '&filter_q=' + $(obj).val(); 625 } 626 } else if (name == 'order') { 627 var isit = loc.search('&order='); 628 if (isit == -1) { 629 filter_type = 'add'; 630 filter_str = '&order=' + $(obj).val(); 631 } else if ($(obj).val().length == 0) { 632 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); 633 var vals = regex.exec(location.search); 634 filter_type = 'remove'; 635 filter_str = '&order=' + vals[1]; 636 } else { 637 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); 638 var vals = regex.exec(location.search); 639 filter_type = 'change'; 640 var old_filter_str = '&order=' + vals[1]; 641 filter_str = '&order=' + $(obj).val(); 642 } 643 644 } else if (name == 'fpromo' || name == 'fnew' || name == 'onlyavail' || name == 'msold') { 645 filter_str = '&' + name + '=' + $(obj).val(); 646 647 } else if (name == 'other-all') { 648 loc = loc.replace('&fnew=1', ''); 649 loc = loc.replace('&favail[1]=avail_id-1', ''); 650 loc = loc.replace('&favail[2]=avail_id-2', ''); 651 loc = loc.replace('&fpromo=1', ''); 652 filter_str = '&avail_all=1'; 653 } else if (name == 'promo') { 654 filter_str = '&' + name + '[' + $(obj).val() + ']=' + $(obj).val(); 655 } else { 656 filter_str = '&fprop[' + filter[1] + '][' + filter[2] + ']=' + filter[2]; 657 } 658// var isit = loc.search(filter_str); 659 if (filter_type == 'add') { 660 loc += filter_str; 661 } else if (filter_type == 'remove') { 662 loc = loc.replace(filter_str, ''); 663 } else { 664 loc = loc.replace(old_filter_str, ''); 665 loc += filter_str; 666 } 667 } 668 // пÑÐµÐ¼Ð°Ñ Ð²Ð°Ð¼Ðµ ÑÑÑаниÑанеÑо пÑи Ð¸Ð·Ð±Ð¾Ñ Ð½Ð° нÑкой ÑилÑÑÑ 669 loc = loc.replace(/\&page=[0-9]+/, ''); 670 $(window.location).attr('href', loc); 671} 672 673 674function setFilter4(objs) { 675 // console.log('setFilter4'); 676 var filter_str; 677 var url_part = ''; 678 var loc = decodeURI(window.location.href); 679 loc = location.protocol + '//' + location.host + location.pathname; 680 681 if(window.location.href.indexOf('/promotion') !== -1) { 682 // loc = loc + '?ref=promo'; 683 var search = window.location.search.substring(1).split("&"); 684 for (let i = 0; i < search.length; i++) { 685 if(search[i].indexOf('order=') == -1) { 686 loc += (loc.indexOf('?') !== -1 ? '&' : '?') + search[i]; 687 } 688 } 689 } 690 691 // console.log('fin', loc); 692 693 var locArr = loc.split('/'); 694 var brand = ''; 695 var url = ''; 696 //console.log(loc, locArr.length); 697 $is_brand = $(objs).hasClass('brand'); 698 $is_checked = $(objs).is(":checked") 699 //console.log($is_brand, $is_checked); 700 $('.brand:checked').each(function(index) { 701 if (!(brand.indexOf($(this).attr('rel')) >= 0)) { 702 //alert($(this).attr('rel') + ' - ' + $(this).prop('checked')); 703 if(brand.length > 0) { 704 brand += '_' + $(this).attr('rel').replace(/ /gi, "+"); 705 } else { 706 brand += $(this).attr('rel').replace(/ /gi, "+"); 707 } 708 } 709 }); 710 //console.log(brand.length); 711 712 //console.log('locArr.length', locArr.length); 713 if(locArr.length == 4) { 714 for(i = 0; i < locArr.length; i++) { 715 if(url.length > 0) { 716 url += '/' + locArr[i]; 717 if(i == 2 && brand.length > 1) { 718 url += '/' + brand; 719 } 720 } else { 721 url += locArr[i]; 722 } 723 } 724 } else if(locArr.length > 4) { 725 for(i = 0; i < locArr.length; i++) { 726 //console.log('locArr[i]', locArr[i]); 727 if(url.length > 0) { 728 if(i == 3) { 729 if(brand.length > 1) { 730 url += '/' + brand; 731 } else if(locArr[i] == 'page') { 732 url += '/' + locArr[i]; 733 } else if(locArr[i] == 'promotion') { 734 url += '/' + locArr[i]; 735 } else if(!$is_brand) { 736 url += '/' + locArr[i]; 737 } 738 } else { 739 url += '/' + locArr[i]; 740 } 741 } else { 742 url += locArr[i]; 743 } 744 } 745 } 746 // console.log(url); 747 // return false;
748 if(url.length > 0) { 749 loc = url; 750 } 751 752 var loc_arr = loc.split('?'); 753 if (loc_arr.length == 1) { 754 // loc += '?ref=all'; 755 } 756 var obj; 757 //console.log('objs', objs); 758 for (ii = 0; ii < objs.length; ii++) { 759 obj = objs[ii]; 760 761 if (($(obj).is(':checkbox') && $(obj).is(':checked')) || (!$(obj).is(':checkbox') && $(obj).val())) { 762 //console.log(obj); 763 filter = $(obj).val().split('-'); 764 765 var name = $(obj).attr('name'); 766 var filter = $(obj).val().split('-'); 767 if (filter[0] == 'p_from') { 768 filter_str = '&fprice[' + name + ']=' + $(obj).val(); 769 } else if (filter[0] == 'avail_id') { 770 filter_str = '&favail[' + filter[1] + ']=' + $(obj).val(); 771 } else if (filter[0] == 'brand') { 772 // !!!!!!! 773 // filter_str = '&fbrand[' + filter[1] + ']=' + $(obj).val(); 774 } else if (name == 'filter_q') { 775 filter_str = '&filter_q=' + $(obj).val(); 776 } else if (name == 'order') { 777 filter_str = 'order=' + $(obj).val(); 778 } else if (name == 'fpromo' || name == 'fnew' || name == 'onlyavail' || name == 'msold') { 779 filter_str = '&' + name + '=' + $(obj).val(); 780 781 } else if (name == 'other-all') { 782 loc = loc.replace('&fnew=1', ''); 783 loc = loc.replace('&favail[1]=avail_id-1', ''); 784 loc = loc.replace('&favail[2]=avail_id-2', ''); 785 loc = loc.replace('&fpromo=1', ''); 786 filter_str = '&avail_all=1'; 787 } else if (name == 'promo') { 788 filter_str = '&' + name + '[' + $(obj).val() + ']=' + $(obj).val(); 789 } else { 790 filter_str = '&fprop[' + filter[1] + '][' + filter[2] + ']=' + filter[2]; 791 } 792 793 if (loc.indexOf(filter_str) < 0) { 794 loc += (loc.indexOf('?') !== -1 ? '&' : '?') +filter_str; 795 } 796 //console.log(obj, filter_str) 797 } 798 } 799 800 let p_from = parseFloat($('.other_pfrom').val()); 801 let p_to = parseFloat($('.other_pto').val()); 802 803 if (!isNaN(p_from) && !isNaN(p_to)) { 804 if ((p_to > p_from) || ( p_to == 0 && p_from != 0)) { 805 var isit = loc.search('price-filter-other'); 806 if (isit == -1) { 807 p_from = new String(p_from); 808 if(p_from.indexOf('.') < 0) { p_from += '.00'; } 809 810 p_to = new String(p_to); 811 if(p_to.indexOf('.') < 0) { p_to += '.00'; } 812 813 loc += '&fprice[price-filter-other]=p_from-' + p_from + '-p_to-' + p_to; 814 } 815 } 816 } 817 // пÑÐµÐ¼Ð°Ñ Ð²Ð°Ð¼Ðµ ÑÑÑаниÑанеÑо пÑи Ð¸Ð·Ð±Ð¾Ñ Ð½Ð° нÑкой ÑилÑÑÑ 818 loc = loc.replace(/\&page=[0-9]+/, ''); 819 // if(getQueryParam('page') != 'page') { 820 // loc += '&page='+getQueryParam('page'); 821 // } 822 // return false; 823 loc.replace('html&', 'html?'); 824 loc.replace('?&', '?'); 825 $(window.location).attr('href', loc); 826} 827 828 829function toggleHidden(obj) { 830 var id = $(obj).attr('id').split('-'); 831 if (id[1] == 'show') { 832 $(obj).attr('id', id[0] + '-hide').html('<span> виж по-малко ... </span>'); 833 $('.' + id[0] + ' .hide').show(); 834 } else { 835 $(obj).attr('id', id[0] + '-show').html('<span> виж повеÑе ... </span>'); 836 $('.' + id[0] + ' .hide').hide(); 837 } 838} 839 840function toogleMenu() { 841 $('#tnb div').toggle(); 842} 843 844var $input = $('.search'); 845var current_index = $('.selected').index(); 846var $number_list = $('.search_result'); 847var $options = $number_list.find('.option'); 848var items_total = $options.length; 849var search_flag = false; 850var search_col = 'col1'; 851var tmpsearch; 852var ajaxtime; 853 854function change_selection() { 855 $options.removeClass('selected'); 856 $options.eq(current_index).addClass('selected'); 857 //$input.val(current_index); 858} 859 860function formsearch(obj, e) { 861 ajaxtime = new Date().getTime(); 862 $('.search_result').attr('id', 'id-' + ajaxtime); 863 var q = $(obj).val().trim(); 864 if (q.length > 0) { 865 $('#q-reset').css({'display' : 'inline-block'}); 866 $.ajaxQ.abortAll(); 867 $input = $('.search'); 868 current_index = $('.selected').index(); 869 $number_list = $('.search_result .' + search_col); 870 $options = $number_list.find('.option'); 871 items_total = $options.length; 872 //$input.val(current_index); 873 var code = e.keyCode || e.which; 874 if (e.keyCode == 40) { 875 // down 876 if (current_index + 1 < items_total) { 877 current_index++; 878 change_selection(); 879 search_flag = true; 880 } 881 } else if (e.keyCode == 38) { 882 // up 883 if (current_index > 0) { 884 current_index--; 885 change_selection(); 886 search_flag = true; 887 } 888 } else if (e.keyCode == 37) { 889 // left 890 $options.removeClass('selected'); 891 $options = $('.search_result .col1').find('.option'); 892 other_total = $options.length; 893 search_col = 'col1'; 894 if (current_index > other_total) { 895 current_index = other_total; 896 } 897 change_selection(); 898 search_flag = true; 899 } else if (e.keyCode == 39) { 900 // right 901 $options.removeClass('selected'); 902 $options = $('.search_result .col2').find('.option'); 903 other_total = $options.length; 904 search_col = 'col2'; 905 if (current_index > other_total) { 906 current_index = other_total; 907 } 908 change_selection(); 909 search_flag = true; 910 } else if (e.keyCode == 13) { 911 // 1. ÐадÑлжиÑелно ÑпиÑаме ÑÑандаÑÑноÑо ÑÑбиÑие и пÑеминаванеÑо кÑм дÑÑги handlers 912 e.preventDefault(); 913 e.stopPropagation(); 914 915 clearTimeout(tmpsearch); 916 if (typeof $.ajaxQ !== 'undefined') { 917 $.ajaxQ.abortAll(); 918 } 919 920 // 2. Ðко поÑÑебиÑелÑÑ Ðµ маÑкиÑал конкÑеÑен пÑодÑÐºÑ Ð¾Ñ Ð¿Ð°Ð´Ð°ÑоÑо Ð¼ÐµÐ½Ñ ÑÑÑ ÑÑÑелкиÑе 921 if (search_flag && $options.eq(current_index).length > 0) { 922 var url = $options.eq(current_index).children('a').attr('href'); 923 if (url) { 924 window.location.href = url; // ÐоÑигиÑан ÑинÑакÑÐ¸Ñ 925 } 926 } else { 927 // 3. ÐалидиÑаме и изпÑаÑаме ÑоÑмаÑа СÐÐÐ ÐÐÐÐЪР928 var form = $(obj).closest('form')[0]; 929 if (validateSearch(form)) { 930 form.submit(); 931 } 932 } 933 return false;
934 } else if (e.keyCode == 27) { 935 $('.search_result').hide(); 936 } else { 937 clearTimeout(tmpsearch); 938 tmpsearch = setTimeout(function () { 939 search_flag = false; 940 $('#id-' + ajaxtime).html('<div class="waiting"><img src="/images/gif/waiting.gif"></div>').show(); 941 $.ajax({ 942 url: '/search/samples', 943 type: 'POST', 944 data: {'q': q, 'time': ajaxtime}, 945 dataType: 'json', 946 beforeSend: null, 947 success: function (data) { 948 $('#id-' + ajaxtime).html(data.html).show(); 949 if(typeof fbq === "function") { 950 // Facebook Pixel Track searches 951 fbq('track', 'Search'); 952 } 953 } 954 }); 955 /* 956 $.post('/search/samples', { 'q': q, 'time': ajaxtime }, function(data){ 957 $('#id-'+data.time).html(data.html).show(); 958 }, 'json'); 959 */ 960 }, 500); 961 } 962 } else { 963 if (e.keyCode == 13) { 964 clearTimeout(tmpsearch); 965 $.ajaxQ.abortAll(); 966 e.preventDefault(); 967 return false; 968 } else { 969 $('#q-reset').hide(); 970 $('.search_result').hide(); 971 } 972 } 973} 974 975function formsearchBlog(obj, e) { 976 ajaxtime = new Date().getTime(); 977 $('.search_result').attr('id', 'id-' + ajaxtime); 978 var q = $(obj).val().trim(); 979 if (q.length > 0) { 980 $('#q-reset').css({'display' : 'inline-block'}); 981 $.ajaxQ.abortAll(); 982 $input = $('.search'); 983 current_index = $('.selected').index(); 984 $number_list = $('.search_result .' + search_col); 985 $options = $number_list.find('.option'); 986 items_total = $options.length; 987 //$input.val(current_index); 988 var code = e.keyCode || e.which; 989 if (e.keyCode == 40) { 990 // down 991 if (current_index + 1 < items_total) { 992 current_index++; 993 change_selection(); 994 search_flag = true; 995 } 996 } else if (e.keyCode == 38) { 997 // up 998 if (current_index > 0) { 999 current_index--; 1000 change_selection(); 1001 search_flag = true; 1002 } 1003 } else if (e.keyCode == 37) { 1004 // left 1005 $options.removeClass('selected'); 1006 $options = $('.search_result .col1').find('.option'); 1007 other_total = $options.length; 1008 search_col = 'col1'; 1009 if (current_index > other_total) { 1010 current_index = other_total; 1011 } 1012 change_selection(); 1013 search_flag = true; 1014 } else if (e.keyCode == 39) { 1015 // right 1016 $options.removeClass('selected'); 1017 $options = $('.search_result .col2').find('.option'); 1018 other_total = $options.length; 1019 search_col = 'col2'; 1020 if (current_index > other_total) { 1021 current_index = other_total; 1022 } 1023 change_selection(); 1024 search_flag = true; 1025 } else if (e.keyCode == 13) { 1026 clearTimeout(tmpsearch); 1027 $.ajaxQ.abortAll(); 1028 if (search_flag) { 1029 var url = $options.eq(current_index).children('a').attr('href'); 1030 $(window.location).attr('href', url); 1031 } else { 1032 $('#head_search form').submit(); 1033 } 1034 } else if (e.keyCode == 27) { 1035 $('.search_result').hide(); 1036 } else { 1037 clearTimeout(tmpsearch); 1038 tmpsearch = setTimeout(function () { 1039 search_flag = false; 1040 $('#id-' + ajaxtime).html('<div class="waiting"><img src="/images/gif/waiting.gif"></div>').show(); 1041 $.ajax({ 1042 url: '/search/blog_samples', 1043 type: 'POST', 1044 data: {'q': q, 'time': ajaxtime}, 1045 dataType: 'json', 1046 beforeSend: null, 1047 success: function (data) { 1048 $('#id-' + ajaxtime).html(data.html).show(); 1049 if(typeof fbq === "function") { 1050 // Facebook Pixel Track searches
1051 fbq('track', 'Search'); 1052 } 1053 } 1054 }); 1055 /* 1056 $.post('/search/samples', { 'q': q, 'time': ajaxtime }, function(data){ 1057 $('#id-'+data.time).html(data.html).show(); 1058 }, 'json'); 1059 */ 1060 }, 500); 1061 } 1062 } else { 1063 if (e.keyCode == 13) { 1064 clearTimeout(tmpsearch); 1065 $.ajaxQ.abortAll(); 1066 e.preventDefault(); 1067 return false; 1068 } else { 1069 $('#q-reset').hide(); 1070 $('.search_result').hide(); 1071 } 1072 } 1073} 1074 1075function toggle_img(obj, flag) { 1076 var name = $(obj).children('img:first').attr('src'); 1077 switch (flag) { 1078 case 'up' : 1079 name = name.replace('_down.', '_up.'); 1080 break; 1081 case 'down': 1082 name = name.replace('_up.', '_down.'); 1083 break; 1084 default: 1085 if (name.search('_down.') > 0) { 1086 name = name.replace('_down.', '_up.'); 1087 } else if (name.search('_up.') > 0) { 1088 name = name.replace('_up.', '_down.'); 1089 } 1090 } 1091 $(obj).children('img:first').attr('src', name); 1092} 1093 1094function hide_dg() { 1095 if ($("#hide_dg").is(':checked')) { 1096 //setC('hide_dg', '1'); 1097 set_meta_hide_dg('1'); 1098 $('.col-my-price').css('opacity', 0); 1099 $('.total_price').show(); 1100 $('.dealer_price').css('opacity', 0); 1101 1102 } else { 1103 //setC('hide_dg', '0'); 1104 set_meta_hide_dg('0'); 1105 $('.col-my-price').css('opacity', 1); 1106 $('.total_price').hide(); 1107 $('.dealer_price').css('opacity', 1); 1108 } 1109 1110} 1111 1112function set_meta_hide_dg(val) { 1113 $.post('/user/set_meta_hide_dg', {'val': val}, function (data) { 1114 1115 }); 1116} 1117 1118function hide_images() { 1119 if ($("#hide_images").is(':checked')) { 1120 setC('hide_images', '1'); 1121 $('.cimg').hide(); 1122 //$('.cprod').css('width', '72%'); 1123 1124 } else { 1125 setC('hide_images', '0'); 1126 $('.cimg').show(); 1127 //$('.cprod').css('width', 'calc(72% - 130px)'); 1128 } 1129} 1130 1131function go_ups() { 1132 //$( document ).scrollTop( 0 ); 1133 $('html, body').delay(300).animate({ 1134 scrollTop: $('html, body').offset().top 1135 }, 400, "swing"); 1136} 1137 1138function remove_favorites(obj) { 1139 var product = $(obj).attr('id').split('-'); 1140 $.post('/ajax/remove_favorites', {'code': product[1]}, function (data) { 1141 1142 }); 1143} 1144 1145 1146 1147var obj = new Array(); 1148var tmpobj; 1149 1150function initfilterIt(first_init = true) { 1151 $('.filter_it').change(function () { 1152 clearTimeout(tmpobj); 1153 obj.push(this); 1154 var name = $(this).attr('name'); 1155 if ($(this).is(':checkbox')){ 1156 $('[name="'+name+'"]').prop('checked', $(this).is(':checked')); 1157 } else { 1158 $('[name="'+name+'"]').val($(this).val()); 1159 } 1160 let with_order = $(this).filter('[name="order"]').length > 0; 1161 tmpobj = setTimeout(function () { 1162 1163 if (typeof category_id === 'undefined' || category_id === null) { 1164 setFilter4($('.filter_it')); 1165 } else { 1166 if($(this)) 1167 setFilterAjax($('.filter_it' + (with_order ? '': ':not([name="order"])'))); 1168 } 1169 //document.body.style.cursor = "none"; 1170 //$('#filter').html('<img src="/images/loading.gif" style="margin: 50px 80px;">'); 1171 }, 800); 1172 }); 1173 1174 1175 $('.filter-clearall').click(function () { 1176 var loc = window.location.pathname; 1177 var locArr = loc.split('/'); 1178 var url = ''; 1179 1180 if(locArr.length == 2) { 1181 url = window.location.pathname; 1182 } else if(locArr.length > 2) { 1183 url = '/'+locArr[2]; 1184 } 1185 var url = window.location.protocol + '//' + window.location.hostname + url; 1186 url = window.location.protocol + '//' + window.location.hostname + '/' + category_url; 1187 window.location.href = url; 1188 }); 1189 1190 $('.clear-price-filter').click(function () { 1191 var loc = window.location.href; 1192 loc = loc.replace(/\&fprice\[price-filter-other\]=[\w-]+/, ''); 1193 $(window.location).attr('href', loc); 1194 }); 1195 $('.clear-text-filter').click(function () { 1196 $('.text-filter').val(''); 1197 setFilterAjax($('.filter_it:not([name="order"])')); 1198 // var loc = decodeURIComponent(window.location.href); 1199 // loc = loc.replace(/\&filter_q=[\wa-ÑÐ-Я-]+/, ''); 1200 // $(window.location).attr('href', loc); 1201 }); 1202 1203 $('.hpath_prop').click(function () { 1204 var id = $(this).attr('id').split('_'); 1205 if (id[1] != 'links') { 1206 if ($('#filpr_' + id[1]).css('display') == 'block') { 1207 $(this).children('span').html('<img src="/images/arrows-left-menu-down.png" />'); 1208 $('#filpr_' + id[1]).hide(); 1209 } else { 1210 $(this).children('span').html('<img src="/images/arrows-left-menu-up.png" />'); 1211 $('#filpr_' + id[1]).show(); 1212 } 1213 } 1214 }); 1215 1216 $('.submit-text-filter').click(function () { 1217 var obj = new Array(); 1218 $('.text-filter').val($(this).closest('li').children('input').val()); 1219 obj.push($('.text-filter')); 1220 if (typeof category_id === 'undefined' || category_id === null) { 1221 setFilter4($('.filter_it')); 1222 } else { 1223 if($(this)) 1224 setFilterAjax($('.filter_it')); 1225 } 1226 1227 }); 1228 1229 $('.span_btn').click(function (event) { 1230 event.preventDefault(); 1231 var this_form = $(this).parent('form'); 1232 1233 let id = this_form.find('#product_id').val(); 1234 1235 if (id !== undefined) { 1236 if(this_form.children('input[type=number]')) { 1237 var qty = this_form.children('input[type=number]').val(); 1238 } else { 1239 var qty = 1; 1240 } 1241 1242 if (typeof fbq === "function") { 1243 //pageTracker._trackEvent('Cart', 'add to cart', 'id', id); 1244 //console.log('Add to cart - '+id); 1245 fbq('track', 'AddToCart', { 1246 content_type: 'product', 1247 content_ids: [id] 1248 }); 1249 } 1250 1251 if(typeof gtag !== "undefined") { 1252 gtag('event', 'add_to_cart_silent', { 1253 "affiliation": "JAR", 1254 "value": qty, 1255 "currency": "EUR", 1256 "items": [ 1257 { 1258 "item_id": id 1259 } 1260 ] 1261 }); 1262 } 1263 1264 if(typeof dataLayer !== "undefined") { 1265 dataLayer.push({ 1266 "ecommerce": { 1267 "add": { 1268 "products": [ 1269 { 1270 "id": id 1271 } 1272 ] 1273 } 1274 } 1275 }); 1276 } 1277 1278 1279 if (_ra.ready !== undefined) { 1280 _ra.addToCart(id, qty, { 1281 "code": id, 1282 "stock": true, 1283 "details": { 1284 "var_code_option": { 1285 "category_name": "var_code_option_category_name", 1286 "category": "var_code_option_category_unique_token", 1287 "value": "var_code_option_value_name" 1288 }, 1289 } 1290 }, function () { 1291 // console.log('retargeting add #'+id) 1292 }); 1293 } 1294 } 1295 if(typeof fbq === "function") { 1296 // Facebook Pixel Add to cart 1297 fbq('track', 'AddToCart'); 1298 } 1299 var pass_data = this_form.serializeArray(); 1300 1301 let cnt = this_form.find('.qty').val(); 1302 if(isInt(cnt) && parseInt(cnt)>0) { 1303 $.post('/cart/add_silent', pass_data, function (data) { 1304 1305 if($('body.wrapper-cart-index').length>0) { 1306 location.reload() 1307 } else { 1308 this_form.find('.qty').addClass('added'); 1309 this_form.children('input[name="no-add"]').val(1); 1310 //$('#cart p.cart a>span.cc').text(data.amount); 1311 $('#cart div.cart a').html('<span class="cc">'+data.amount+'</span>'+data.orig_total); 1312 updateCartPopup(); 1313 if(typeof JarCartPopupObj != "undefined") { 1314 // JarCartPopupObj.getPopup(this_form.find('#product_code').val()); 1315 } 1316 } 1317 }, 'json'); 1318 } else { 1319 this_form.find('.qty').addClass('red-qty'); 1320 setTimeout(function() { 1321 this_form.find('.qty').removeClass('red-qty'); 1322 }, 3000); 1323 } 1324 }); 1325 1326 if(first_init) { 1327 $('.category-filters h2, .category-filters .h2-style').click(function () { 1328 $('.category-filters-data').toggle(400); 1329 }); 1330 } 1331 1332 $('.view_more').click(function () { 1333 var clss = $(this).find('span').attr('id'); 1334 if (!$(this).hasClass('open')) { 1335 $('.' + clss).show(); 1336 $(this).find('span').html('виж по-малко'); 1337 $(this).addClass('open'); 1338 } else { 1339 $('.' + clss).hide(); 1340 $(this).find('span').html('виж повеÑе'); 1341 $(this).removeClass('open'); 1342 } 1343 }); 1344 1345 if($.isFunction($('.lazy').lazy)) { 1346 $('.lazy').lazy(); 1347 } else if($('.lazy').length > 0) { 1348 loadScript('/js/jquery.lazy.min.js', function() { $('.lazy').lazy(); }); 1349 } 1350 1351 $('.form-add-to-cart-list span.qty-container').click(function(e) { 1352 let offset = Math.abs($(this).offset().left - e.pageX); 1353 // console.log(offset); 1354 if (offset < 19) { 1355 calc_cqty($(this), -1); 1356 } else if(e.offsetX > 43) { 1357 calc_cqty($(this), 1); 1358 } 1359 }); 1360 1361 $('.form-add-to-cart span.qty-container').click(function(e) { 1362 let offset = Math.abs($(this).offset().left - e.pageX); 1363 //console.log(offset); 1364 if (offset < 10) { 1365 calc_cqty($(this), -1); 1366 } else if(e.offsetX > 40) { 1367 calc_cqty($(this), 1); 1368 } 1369 }); 1370} 1371 1372function isInt(value) { 1373 return !isNaN(value) && 1374 parseInt(Number(value)) == value && 1375 !isNaN(parseInt(value, 10)); 1376} 1377 1378function setFilterAjax(objs) { 1379 let filter_str; 1380 let url_part = ''; 1381 let loc = decodeURI(window.location.href); 1382 loc = location.protocol + '//' + location.host + location.pathname; 1383 let loc_base = loc.substring(0, loc.search('.html')+5); 1384 let hash_pretty = ''; 1385 let loc_pretty = ''; 1386 let brand_pretty = ''; 1387 let get_param = ''; 1388 1389 let locArr = loc.split('/'); 1390 let brand = ''; 1391 let url = ''; 1392 //console.log(loc, locArr.length); 1393 $is_brand = $(objs).find('.brand:checkbox:checked').hasClass('brand'); 1394 $is_checked = $(objs).is(":checked") 1395 // $is_brand = $('.brand:checkbox:checked').length > 0; 1396 // console.log('$is_brand', $is_brand); 1397 // console.log('$is_checked', $is_checked); 1398 // console.log('objs', objs); 1399 // console.log('ttt', $(objs).find('.brand:checkbox:checked').attr('class')); 1400 $('.brand:checked').each(function(index) { 1401 if (!(brand.indexOf($(this).attr('rel')) >= 0)) { 1402 //alert($(this).attr('rel') + ' - ' + $(this).prop('checked')); 1403 if(brand.length > 0) { 1404 brand += '_' + $(this).attr('rel').replace(/ /gi, "+"); 1405 } else { 1406 brand += $(this).attr('rel').replace(/ /gi, "+"); 1407 } 1408 } 1409 }); 1410 //console.log(brand.length); 1411 1412 //console.log('locArr.length', locArr.length); 1413 if(locArr.length == 4) { 1414 for(i = 0; i < locArr.length; i++) { 1415 if(url.length > 0) { 1416 url += '/' + locArr[i]; 1417 if(i == 2 && brand.length > 1) { 1418 url += '/' + brand; 1419 } 1420 } else { 1421 url += locArr[i]; 1422 } 1423 } 1424 } else if(locArr.length > 4) { 1425 for(i = 0; i < locArr.length; i++) { 1426 //console.log('locArr[i]', locArr[i]); 1427 if(url.length > 0) { 1428 if(i == 3) { 1429 if(brand.length > 1) { 1430 url += '/' + brand; 1431 } else if(locArr[i] == 'page') { 1432 url += '/' + locArr[i]; 1433 } else if(locArr[i] == 'promotion') { 1434 url += '/' + locArr[i]; 1435 } else if(!$is_brand) { 1436 url += '/' + locArr[i]; 1437 } 1438 } else { 1439 url += '/' + locArr[i]; 1440 } 1441 } else { 1442 url += locArr[i]; 1443 } 1444 } 1445 } 1446 // console.log(url); 1447 // return false;
1448 if(url.length > 0) { 1449 // loc = url; 1450 } else { 1451 url = loc; 1452 } 1453 loc=''; 1454 1455 var loc_arr = loc.split('?'); 1456 if (loc_arr.length == 1) { 1457 // loc += '?ref=all'; 1458 } 1459 var obj; 1460 var block = []; 1461 1462 for (ii = 0; ii < objs.length; ii++) { 1463 obj = objs[ii]; 1464 1465 if ((($(obj).closest('li').is(":visible") || $(obj).closest('.category-filters').is(":visible")) && $(obj).is(':checkbox') && $(obj).is(':checked')) || (!$(obj).is(':checkbox') && $(obj).val())) { 1466 1467 if($(obj).closest('li').find('a.f:visible, span.f:visible').length > 0 || $(obj).closest('.category-filters').is(":visible")) { 1468 let elName = $(obj).closest('li').find('a.f, span.f').data('name'); 1469 let elFilter = $(obj).closest('li').find('a.f, span.f').data('filter'); 1470 1471 if(block.includes(elName)) { 1472 hash_pretty += '-' + elFilter; 1473 } else { 1474 hash_pretty += '/' + elName + (elFilter ? '-' + elFilter : ''); 1475 } 1476 1477 if(elName == 'proizvoditel') { 1478 if(block.includes(elName)) { 1479 brand_pretty += '_' + elFilter; 1480 } else { 1481 block.push(elName); 1482 brand_pretty += '/' + (elFilter ? elFilter : ''); 1483 } 1484 } else { 1485 if(block.includes(elName)) { 1486 loc_pretty += '-' + elFilter; 1487 } else { 1488 block.push(elName); 1489 loc_pretty += '/' + elName + (elFilter ? '-' + elFilter : ''); 1490 } 1491 } 1492 } 1493 filter = $(obj).val().split('-'); 1494 1495 var name = $(obj).attr('name'); 1496 var filter = $(obj).val().split('-'); 1497 1498 if (filter[0] == 'p_from') { 1499 filter_str = '&fprice[' + name + ']=' + $(obj).val(); 1500 } else if (filter[0] == 'avail_id') { 1501 filter_str = '&favail[' + filter[1] + ']=' + $(obj).val(); 1502 } else if (filter[0] == 'brand') { 1503 filter_str = '&fbrand[' + filter[1] + ']=' + $(obj).val(); 1504 } else if (name == 'filter_q') { 1505 filter_str = '&filter_q=' + $(obj).val(); 1506 } else if (name == 'order') { 1507 filter_str = '&order=' + $(obj).val(); 1508 } else if (name == 'fpromo' || name == 'fnew' || name == 'onlyavail' || name == 'msold') { 1509 filter_str = '&' + name + '=' + $(obj).val(); 1510 1511 } else if (name == 'other-all') { 1512 loc = loc.replace('&fnew=1', ''); 1513 loc = loc.replace('&favail[1]=avail_id-1', ''); 1514 loc = loc.replace('&favail[2]=avail_id-2', ''); 1515 loc = loc.replace('&fpromo=1', ''); 1516 filter_str = '&avail_all=1'; 1517 } else if (name == 'promo') { 1518 filter_str = '&' + name + '[' + $(obj).val() + ']=' + $(obj).val(); 1519 } else if (name == 'fsold') { 1520 filter_str = '&fsold=' + $(obj).val(); 1521 } else { 1522 filter_str = '&fprop[' + filter[1] + '][' + filter[2] + ']=' + filter[2]; 1523 } 1524 1525 if (loc.indexOf(filter_str) < 0) { 1526 loc += filter_str; 1527 } 1528 //console.log(obj, filter_str) 1529 } 1530 } 1531 1532 1533 if(objs.filter('[name="order"]').length > 0) { 1534 if(get_param.indexOf('?') !== -1) { 1535 get_param += '&order=' + objs.filter('[name="order"]').val(); 1536 } else { 1537 get_param += '?order=' + objs.filter('[name="order"]').val(); 1538 } 1539 } 1540 1541 if(objs.filter('[name="filter_q"]').length > 0 && objs.filter('[name="filter_q"]').val().length > 0) { 1542 if(get_param.indexOf('?') !== -1) { 1543 get_param += '&filter_q=' + objs.filter('[name="filter_q"]').val(); 1544 } else { 1545 get_param += '?filter_q=' + objs.filter('[name="filter_q"]').val(); 1546 } 1547 } 1548 1549 let p_from = parseFloat($('.other_pfrom').val()); 1550 let p_to = parseFloat($('.other_pto').val()); 1551 1552 if (!isNaN(p_from) && !isNaN(p_to)) { 1553 if ((p_to > p_from) || ( p_to == 0 && p_from != 0)) { 1554 var isit = loc.search('price-filter-other'); 1555 if (isit == -1) { 1556 p_from = new String(p_from); 1557 if(p_from.indexOf('.') < 0) { p_from += '.00'; } 1558 1559 p_to = new String(p_to); 1560 if(p_to.indexOf('.') < 0) { p_to += '.00'; } 1561 1562 loc += '&fprice[price-filter-other]=p_from-' + p_from + '-p_to-' + p_to; 1563 } 1564 } 1565 } 1566 $('#products-container').addClass('loading'); 1567 if(loc.charAt(0) === '&') 1568 { 1569 loc = loc.substring(1); 1570 } 1571 1572 if(hash_pretty.length > 3) { 1573 loc += '&loc_pretty=' + loc_pretty + '&brand_pretty=' + brand_pretty; 1574 } 1575 1576 let hUrl = (loc_pretty.length > 3 || brand_pretty.length > 1 ? brand_pretty+'/'+category_url.replace('.html', '')+loc_pretty+'.html' + (get_param.length>1?get_param:'') : '/'+category_url+(loc.length>1?'?'+loc:'')); 1577 loc += '&hurl=' + hUrl; 1578 1579 setTimeout(function() { 1580 $.ajax({ 1581 url: '/category/category/'+category_id, 1582 type: 'POST', 1583 data: loc, 1584 dataType: 'json', 1585 beforeSend: null, 1586 success: function (data) { 1587 $('#products-container').replaceWith(data.products); 1588 $('.resp_600 .spanel_prop').replaceWith(data.filter); 1589 $('.hide_600 .spanel_prop').replaceWith(data.filter.replace( /h1/g, "h2" )); 1590 1591 initfilterIt(false); 1592 initAskForImport(); 1593 if (typeof processToHistory === "function") { 1594 processToHistory(data, hUrl); 1595 } 1596 1597 } 1598 }); 1599 }, 100) 1600} 1601 1602// $(document).scroll(function () { 1603// if ($(window).scrollTop() > 750) { 1604// $("#go_up").show(); 1605// } else { 1606// $("#go_up").hide(); 1607// } 1608// }) 1609 1610document.addEventListener("touchstart", function(e) { 1611 if ($(window).scrollTop() > 750) { 1612 $("#go_up").show(); 1613 } else { 1614 $("#go_up").hide(); 1615 } 1616}, {passive: true} ); 1617 1618$(document).ready(function () { 1619 1620 var type = $('#product_list').attr('class'); 1621 1622 if (navigator.cookieEnabled == false) { 1623 $('.window_info').html('<p>Ðа да използваÑе ÑайÑа ÑÑÑбва да акÑивиÑаÑе биÑквиÑкиÑе Ð¾Ñ Ð¾Ð¿ÑииÑе на ваÑÐ¸Ñ Ð±ÑаÑзÑÑ.</p>'); 1624 } 1625 1626 $('ul.cat_tree > li span').click(function () { 1627 var par_li = $(this).parent('li'); 1628 if (par_li.hasClass('show')) { 1629 $(par_li).removeClass('show').children('ul').hide(); 1630 } else { 1631 $(par_li).addClass('show').children('ul').show(); 1632 } 1633 }); 1634 1635 switch (type) { 1636 case 'p1': 1637 $('.pprop').show(); 1638 $('.s4').show(); 1639 $('.cart_table_table').hide(); 1640 $('.cart_table_list').show(); 1641 break; 1642 case 'p2': 1643 $('.pprop').show(); 1644 $('.s4').hide(); 1645 $('.cart_table_list').hide(); 1646 $('.cart_table_table').show(); 1647 break; 1648 case 'p3': 1649 $('.pprop').show(); 1650 $('.s4').hide(); 1651 $('.cart_table_list').hide(); 1652 $('.cart_table_table').show(); 1653 break; 1654 } 1655 1656 $('.menu_name').css('cursor', 'pointer'); 1657 1658 1659 $('.menu_name').click(function (event) { 1660 //console.log('click menu_name'); 1661 //console.log('click menu_name - ' + $('#tnb div').css('display')); 1662 if($('#tnb').hasClass('open')) { 1663 //console.log('remove open') 1664 if($('body').hasClass('wrapper-home') && window.innerWidth > 960) { 1665 1666 } else { 1667 $('#tnb').removeClass('open'); 1668 $('#tnb>div').hide(); 1669 } 1670 } else { 1671 // console.log('add open', $('#tnb').hasClass('open')); 1672 $('#tnb').addClass('open'); 1673 $('#tnb>div').show(); 1674 } 1675 // toggle_img($('#tnb')); 1676 // $('#tnb').toggleClass('open'); 1677 //event.preventDefault(); 1678 }); 1679 1680 $('#tnb').click(function (event) { 1681 // console.log('click tnb', $('#tnb').hasClass('open')); 1682 // alert('click tnb'); 1683 //console.log('click tnb - ' + $('#tnb div').css('display')); 1684 if($('#tnb').hasClass('open')) { 1685 //console.log('remove open') 1686 if($('body').hasClass('wrapper-home') && window.innerWidth > 960) { 1687 1688 } else { 1689 $('#tnb').removeClass('open'); 1690 $('#tnb>div').hide(); 1691 } 1692 } else { 1693 //console.log('add open') 1694 $('#tnb').addClass('open'); 1695 $('#tnb>div').show(); 1696 } 1697 //event.preventDefault(); 1698 }); 1699 1700 $('.menu_title').hover( 1701 function (event) { 1702 if($(window).width() > 960) { 1703 //console.log('enter'); 1704 $('#tnb').addClass('open'); 1705 $('#tnb>div').show(); 1706 $('#tnb #menu_content').hide(); 1707 $('.pr_categories .menu_subs').hide(); 1708 event.preventDefault(); 1709 } 1710 }, function (event) { 1711 if($(window).width() > 960) { 1712 if($('body').hasClass('wrapper-home') && window.innerWidth > 960) { 1713 1714 } else { 1715 $('#tnb').removeClass('open'); 1716 $('#tnb>div').hide(); 1717 $('#tnb #menu_content').show(); 1718 $('.pr_categories .menu_subs').show(); 1719 } 1720 event.preventDefault(); 1721 } 1722 }); 1723 1724 /* 1725 $('.menu_name').click(function() { 1726 if ($('#categories_all').length){ 1727 $('#categories').hide(); 1728 $('#categories_all').show(); 1729 $('#categories').attr('id', 'categories_all_temp'); 1730 $('#categories_all').attr('id', 'categories'); 1731 $('#categories_all_temp').attr('id', 'categories_all'); 1732 } 1733 var myDiv1 = $('#categories'); 1734 if ( myDiv1.length ){ 1735 $('#content').css('margin-left', '220px'); 1736 } else { 1737 $('#content').css('margin-left', '0px'); 1738 $('.c2c').css('margin-left', '220px'); 1739 } 1740 }); 1741 1742 $('#tnb').click(function (){ 1743 $('#categories').hide(); 1744 $('#categories_all').show(); 1745 $('#categories').attr('id', 'categories_all_temp'); 1746 $('#categories_all').attr('id', 'categories'); 1747 $('#categories_all_temp').attr('id', 'categories_all'); 1748 }); 1749 */ 1750 1751 $('#tnb .pr_categories ul li > div').hide(); 1752 $('#tnb .pr_categories ul li').hover(function () { 1753 var obj = this; 1754 tm1 = setTimeout(function () { 1755 if($('body').hasClass('wrapper-home') && window.innerWidth > 960) { 1756 1757 } else { 1758 $('#tnb #menu_content').show(); 1759 } 1760 1761 $('#tnb .pr_categories ul li').removeClass('active'); 1762 $(obj).addClass('active'); 1763 var id = $(obj).children('.menu_subs').attr('id'); 1764 var bg = '#f3f3f3 ' + $(obj).children('.menu_subs').css('background-image') + ' no-repeat right bottom'; 1765 $('#menu_content').attr('class', id).css('background', bg).show().html($(obj).children('.menu_subs').html()).children('ul').show().children('li'); 1766 }, 75); 1767 }, function () { 1768 $(this).removeClass('active'); 1769 $('#menu_content, .pr_categories').hover( 1770 function () { 1771 $('#menu_content').show(); 1772 }, 1773 function () { 1774 if($('body').hasClass('wrapper-home') && window.innerWidth > 960) { 1775 1776 } else { 1777 $('#tnb').toggleClass('open'); 1778 } 1779 // toggle_img($('#tnb'), 'down'); 1780 $('#menu_content').hide(); 1781 } 1782 ); 1783 clearTimeout(tm1); 1784 }); 1785 1786 $('#categories.spanel ul li > ul').hide(); 1787 $('#categories.spanel ul li').hover(function () { 1788 var obj = this; 1789 tm = setTimeout(function () { 1790 var cls = $('#categories.spanel ul').attr('class'); 1791 if (cls != 'promo_cats') { 1792 $('#categories.spanel ul li').removeClass('active'); 1793 $(obj).addClass('active'); 1794 } 1795 var bg = '#f3f3f3 ' + $(obj).children('.menu_subs').css('background-image') + ' no-repeat right bottom'; 1796 // $('.content_promo').hide(); 1797 $('#menucontent').css('background', bg).show().html($(obj).children('.menu_subs').html()).children('ul').show().children('li'); 1798 }, 75); 1799 }, function () { 1800 $(this).removeClass('active'); 1801 $('#menucontent, #sidebar').hover( 1802 function () { 1803 // $('.content_promo').hide(); 1804 $('#menucontent').show(); 1805 }, 1806 function () { 1807 $('#menucontent').hide(); 1808 // $('.content_promo').show(); 1809 } 1810 ); 1811 if(typeof tm != 'undefined') { 1812 clearTimeout(tm); 1813 } 1814 }); 1815
1816 initfilterIt(); 1817 1818 $('#order-header h1').click(function () { 1819 $(this).parent('td').children('table').toggle(); 1820 }); 1821 if(typeof $.cookieBar === "function") { 1822 $.cookieBar(); 1823 } 1824}); 1825$(document).on('ready', function (event) { 1826 $('filter_it').attr('checked', false); 1827}); 1828 1829function check_valid_name_person() { 1830 var val = $('.get-name-person').val(); 1831 var cirillicAlphabetAndWhiteSpace = /^[Ð-Яа-Ñ ]*$/; 1832 if($('#register_type').val() == 'person' && val.length > 0) { 1833 var result = val.split(' ') 1834 if(!cirillicAlphabetAndWhiteSpace.test(val) || result.length < 3){ 1835 $('#notice-message-reg-name').html('ÐÑепоÑÑÑваме да вÑведеÑе ÑÑиÑе Ñи имена <br />нÑжни за гаÑанÑионаÑа каÑÑа.'); 1836 } else { 1837 $('#notice-message-reg-name').html(''); 1838 } 1839 1840 } 1841} 1842 1843function getQueryParam(param) { 1844 location.search.substr(1) 1845 .split("&") 1846 .some(function(item) { // returns first occurence and stops 1847 return item.split("=")[0] == param && (param = item.split("=")[1]) 1848 }) 1849 return param 1850} 1851 1852function iFisMobile() { 1853 var isMobile = false; //initiate as false 1854 // device detection 1855 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 1856 || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
1856substr(0,4))) { 1857 isMobile = true; 1858 } 1859 1860 return isMobile; 1861} 1862 1863$(function() { 1864 if(iFisMobile()) { 1865 $('.icon-info>span').css({'cssText':'display: none!important;'}); 1866 1867 $(document).click(function(e) { 1868 if($(e.target).hasClass('icon-info') || $(e.target).parent('.info-hover').length) { 1869 if($(e.target).children('span').is(":visible")) { 1870 $(e.target).children('span').css({'cssText':'display: none!important;'}); 1871 } else { 1872 $('.icon-info>span').css({'cssText':'display: none!important;'}); 1873 $(e.target).children('span').css({'cssText':'display: inline-block!important;'}); 1874 } 1875 } else { 1876 // console.log('ne'); 1877 $('.icon-info>span').css({'cssText':'display: none!important;'}); 1878 } 1879 }); 1880 } 1881}); 1882 1883 1884function addremove_favorites(obj) { 1885 var clss = $(obj).attr('id').split('-'); 1886 $.post('/ajax/change_favorites', {'pid': clss[3], 'code': clss[1]}, function (data) { 1887 $('.total-favorites').text(parseInt(data)); 1888 $('.favorites_total').html(parseInt(data)); 1889 $(obj).toggleClass('selected'); 1890 if(window.location.pathname.includes("user/favorites")){ 1891 $(obj).closest('li.p').hide(); 1892 } 1893 1894 if($(obj).hasClass('selected')) { 1895 if (_ra.ready !== undefined) { 1896 _ra.addToWishlist(clss[3], function() { 1897 // console.log('addremove_favorites'); 1898 }); 1899 } 1900 1901 if(typeof fbq === "function") { 1902 // Facebook Pixel Add to wishlist 1903 fbq('track', 'AddToWishlist'); 1904 } 1905 } 1906 }); 1907 //favorites_update(); 1908} 1909 1910function favorites_update() { 1911 $.post('/ajax/favorites_update', {'all': 1}, function (data) { 1912 $('.favorite-btn').removeClass('selected'); 1913 $.each(data, function(i, item) { 1914 // console.log(i); 1915 // console.log(item); 1916 $(".favorite-btn[data='" + i + "']").addClass('selected'); 1917 }); 1918 }, 'json'); 1919} 1920 1921function loadScript(url, callback){ 1922 1923 // console.log(url, callback); 1924 var script = document.createElement("script") 1925 script.type = "text/javascript"; 1926 1927 if (script.readyState){ //IE 1928 script.onreadystatechange = function(){ 1929 if (script.readyState == "loaded" || 1930 script.readyState == "complete"){ 1931 script.onreadystatechange = null; 1932 callback(); 1933 } 1934 }; 1935 } else { //Others 1936 script.onload = function(){ 1937 callback(); 1938 }; 1939 } 1940 1941 script.src = url; 1942 1943 document.getElementsByTagName("head")[0].appendChild(script); 1944} 1945 1946 1947function calc_cqty(obj, $q) { 1948 let val = parseInt($(obj).find('input').val()); 1949 val = val + $q; 1950 if(val > 0 && val < 5001) { 1951 $(obj).find('input').val(val); 1952 } 1953} 1954 1955function googleTranslateElementInit() { 1956 new google.translate.TranslateElement( 1957 {pageLanguage: 'bg', includedLanguages: 'de,el,sr,en,es,fr,pl,ro,ru,tr,bg', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false}, 1958 'header_google_search' 1959 ); 1960} 1961var $jui = $; 1962function base_feedback() { 1963 $.ajax({ 1964 async: false, 1965 type: 'post', 1966 url: '/base/send_feedback/', 1967 data: {}, 1968 success: function (data) { 1969 var width = 600; 1970 if($( window ).width() < width) { width = ($( window ).width() - 20); } 1971 $('#dialog').children('p').html(data); 1972 $jui('#dialog').dialog({ 1973 title: 'ÐбÑаÑна вÑÑзка', 1974 width: width 1975 }); 1976 $('div[aria-describedby="dialog"]').css({'left': ($(window).width() - $('div[aria-describedby="dialog"]').width())/2, 'top':window.scrollY+50, 'background': 'white'}); 1977 // {'border': '1px solid #e8e8ea!important', 'color': '#5c5c5c'} 1978 } 1979 }); 1980} 1981 1982function startSeoSlider() { 1983 if(typeof Swiper === 'function') { 1984 new Swiper('.wrapper-category-index .swiper:not(.swiper-sl), .wrapper-brand-index .swiper:not(.swiper-sl), .wrapper-post-index .swiper:not(.swiper-sl)', { 1985 // Optional parameters 1986 direction: 'horizontal', 1987 loop: true, 1988 spaceBetween: 5, 1989 // If we need pagination 1990 pagination: { 1991 el: '.swiper-pagination', 1992 clickable: true 1993 }, 1994 autoplay: { 1995 delay: 2000,
1996 disableOnInteraction: false, 1997 }, 1998 // Navigation arrows 1999 navigation: { 2000 nextEl: '.right_arow', 2001 prevEl: '.left_arow', 2002 }, 2003 2004 // And if we need scrollbar 2005 // scrollbar: { 2006 // el: '.swiper-scrollbar', 2007 // }, 2008 breakpoints: { 2009 300: { 2010 slidesPerView: 1, 2011 }, 2012 450: { 2013 slidesPerView: 2, 2014 }, 2015 550: { 2016 slidesPerView: 2, 2017 }, 2018 800: { 2019 slidesPerView: 3, 2020 }, 2021 1200: { 2022 slidesPerView: 4, 2023 } 2024 }, 2025 on: { 2026 beforeLoopFix: function () { 2027 2028 }, 2029 }, 2030 }); 2031 } 2032 2033} 2034 2035 2036$(function() { 2037 $('html').click(function(event) { 2038 if ($('#acount-in-search').hasClass('active') && $(event.target).closest('#acount-in-search').length === 0) { 2039 $('#acount-in-search').removeClass('active'); 2040 } 2041 }); 2042 2043 $('#acount-in-search').click(function () { 2044 $(this).toggleClass('active'); 2045 }); 2046 2047 $('.cookie-button-edit-shtf').click(function () { 2048 if("undefined" == typeof JarCookieObj) { 2049 $.getScript('/js/jar_cookie_clear.js?v=1.6', function() { }); 2050 } else { 2051 $.getJSON( "/ajax/jar_cookie_clear_config") 2052 .done(function( json ) { 2053 JarCookieObj = new JarCookie(json); 2054 }); 2055 } 2056 }); 2057}) 2058 2059$(function() { 2060 $('#seo-faq-box h3').click(function(event) { 2061 if ($(this).hasClass('active')) { 2062 $(this).removeClass('active'); 2063 $(this).parent('div[class^="faq-"]').find('div').hide(); 2064 } else { 2065 $(this).addClass('active'); 2066 $(this).parent('div[class^="faq-"]').find('div').show(); 2067 } 2068 }); 2069 2070 $('.energy_class a, .c_energy_class a, .cart_energy_class a').click(function(event) { 2071 if(iFisMobile() && $(this).attr('href').indexOf(".pdf") >= 0) { 2072 return true; 2073 } else { 2074 event.preventDefault(); 2075 2076 $('#image-modal').show(); 2077 if ($(this).attr('href').indexOf(".pdf") >= 0) { 2078 let url = $(this).attr('href'); 2079 $.get(url) 2080 .done(function() { 2081 $('#image-modal embed').replaceWith('<embed class="modal-content" src="'+url+'" frameborder="0" height="100%" style="display:block;">'); 2082 }).fail(function() { 2083 $('#image-modal embed').show().attr('src', 'Файла не е намеÑен.'); 2084 }) 2085 } else { 2086 $('#image-modal img').show().attr('src', $(this).attr('href')); 2087 } 2088 $('#image-modal .caption').attr('src', $(this).attr('alt')); 2089 } 2090 2091 }); 2092 2093 $('#image-modal .close').click(function(event) { 2094 $('#image-modal').hide(); 2095 $('#image-modal img, #image-modal embed').hide(); 2096 }); 2097 2098 $('.clever-link').click(function(){window.open($(this).data('link'), "_self");return false;}); 2099 2100 $('.more-tags').click(function() { 2101 $('#seo-tags').addClass('expanded'); 2102 }); 2103 2104 var tag_container = $('#seo-tags:not(.expanded) div div.seo-tags-container div'); 2105 if(tag_container.length && parseInt(tag_container.height()) <= 110) { 2106 $('#seo-tags').addClass('expanded'); 2107 } 2108 2109 //most computations done at load / resize 2110 $(window).scroll(function() { 2111 try{ 2112 window.requestAnimationFrame(function(){ 2113 doOnScroll(); 2114 }); 2115 } catch(e){ 2116 doOnScroll(); 2117 } 2118 }); 2119 2120 2121 if($('body').hasClass('wrapper-home')) { 2122 $.ajax({ 2123 async: true, 2124 type: 'post', 2125 url: '/ajax/get_home_sliders/', 2126 data: {}, 2127 dataType: 'json', 2128 success: function (data) { 2129 $('#recently_viewed').replaceWith(data.recently_viewed); 2130 $('#bought_and').replaceWith(data.bought_and); 2131 $('#favorites_slider').replaceWith(data.favorites_slider); 2132 $('#buy_again').replaceWith(data.buy_again); 2133 initAddToCart(); 2134 } 2135 }); 2136 } else { 2137 2138 } 2139 2140 initAskForImport(); 2141 2142 $('footer div.h3').click(function() { 2143 $(this).find('span.arrow').toggleClass('open'); 2144 $(this).closest('div[class^=\'fpanel\']').find('ul').toggleClass('open'); 2145 }); 2146 initAddToCart(); 2147 initRemoveFromCart(); 2148 2149 let hideTimer; 2150 2151 $(".cart").on("mouseenter", function () { 2152 clearTimeout(hideTimer); 2153 if(!$('body').hasClass('wrapper-cart-index') && !$('body').hasClass('wrapper-cart-checkout')) { 2154 $("#cart").find("#cart-popup:not(.empty)").stop(true, true).fadeIn(200); 2155 } 2156 }); 2157 2158 $("cart").on("mouseleave", function () { 2159 const popup = $("#cart").find("#cart-popup"); 2160 2161 hideTimer = setTimeout(() => { 2162 popup.stop(true, true).fadeOut(200); 2163 }, 2000); // 3 ÑекÑнди 2164 }); 2165 2166 $(document).on("click", function (e) { 2167 const $target = $(e.target); 2168 if(!$('body').hasClass('wrapper-cart-index') && !$('body').hasClass('wrapper-cart-checkout')) { 2169 // Ðко кликÑÑ ÐРе вÑÑÑе в #cart или #cart-popup 2170 if (!$target.closest("#cart").length && !$target.closest("#cart-popup").length) {
2171 $("#cart-popup").stop(true, true).fadeOut(200); 2172 } 2173 } 2174 }); 2175 2176}) 2177 2178function updateCartPopup() { 2179 if($("#cart-popup").length > 0) { 2180 $.get('/cart/get_cart_popup', {}, function (data) { 2181 if(data.length > 5) { 2182 $("#cart-popup").html(data).removeClass('empty'); 2183 initRemoveFromCart(); 2184 $("#cart-popup:not(.empty)").stop(true, true).fadeIn(200); 2185 2186 const popup = $("#cart-popup"); 2187 2188 hideTimer = setTimeout(() => { 2189 popup.stop(true, true).fadeOut(200); 2190 }, 4000); // 3 ÑекÑнди 2191 } else { 2192 $("#cart-popup").addClass('empty').html(''); 2193 } 2194 2195 }); 2196 } 2197} 2198 2199function initAddToCart() { 2200 $('button.add-btn:not(.r').click(function (event) { 2201 let id = $(this).data('id'); 2202 let code = $(this).data('code'); 2203 let post_data = { 2204 "product_id" : id, 2205 "code" : code, 2206 "qty" : 1, 2207 "no-add" : 0 2208 }; 2209 if(mark_ajax) { 2210 mark_ajax = false; 2211 $.post('/cart/add_silent', post_data, function (data) { 2212 mark_ajax = true; 2213 if($('body.wrapper-cart-index').length>0) { 2214 location.reload() 2215 } else { 2216 updateCartPopup(); 2217 // window.location.replace("/cart"); 2218 $('#cart div.cart a').html('<span class="cc">'+data.amount+'</span>'+data.orig_total); 2219 if(typeof JarCartPopupObj != "undefined") { 2220 // JarCartPopupObj.getPopup(code); 2221 } 2222 } 2223 2224 }, 'json'); 2225 } 2226 }).addClass('r'); 2227} 2228 2229function initRemoveFromCart() { 2230 $('.cart-popup-row .cart-popup-price span.popup-x').click(function() { 2231 let rowid = $(this).data('rowid'); 2232 $.post('/cart/remove_silent', {'rowid' : rowid}, function (data) { 2233 updateCartPopup(); 2234 $('#cart div.cart a').html('<span class="cc">'+data.amount+'</span>'+data.orig_total); 2235 }, 'json'); 2236 }); 2237} 2238 2239function clever_link(el) { 2240 window.open($(el).data('link'), "_self"); 2241 return false; 2242} 2243 2244 2245function doOnScroll(){ 2246 let windowHeight = $(window).height(); 2247 let windowWidth = $(window).width(); 2248 let scrollTop = $(document).scrollTop(); 2249 let headHeight = $('#head').height(); 2250 2251 if($('body').hasClass('wrapper-product-index') || $('body').hasClass('wrapper-suppproduct-index')) { 2252 2253 if($('#sticky-data').length > 0) { 2254 $('#sticky-navbar-product div.sticky-container').html($('#sticky-data').html()); 2255 $('#sticky-data').remove(); 2256 } 2257 2258 if(windowWidth > 600 && scrollTop > 600) { 2259 $('#sticky-navbar-product').addClass('open'); 2260 } else if(scrollTop > 1500) { 2261 $('#sticky-navbar-product').addClass('open'); 2262 } else { 2263 $('#sticky-navbar-product').removeClass('open'); 2264 } 2265 } 2266 2267 2268 if($('body').hasClass('wrapper-home') || $('body').hasClass('wrapper-category-index') || $('body').hasClass('wrapper-brand-index')) { 2269 2270 if(windowWidth > 600 && scrollTop > 800) { 2271 if(!$('body').hasClass('fixed')) { 2272 $('#head, #central_top').stop(true, true).fadeOut(); 2273 $('body').addClass('fixed'); 2274 $('body').css('padding-top',headHeight+'px'); 2275 $('#head, #central_top').stop(true, true).fadeIn(300); 2276 } 2277 } else if(scrollTop > 300) { 2278 if(!$('body').hasClass('fixed')) { 2279 $('#head, #central_top').stop(true, true).fadeOut(); 2280 $('body').addClass('fixed'); 2281 $('body').css('padding-top',headHeight+'px'); 2282 $('#head, #central_top').stop(true, true).fadeIn(300); 2283 } 2284 } else { 2285 if($('body').hasClass('fixed')) { 2286 $('body').removeClass('fixed'); 2287 $('body').css('padding-top',''); 2288 } 2289 } 2290 } 2291 2292}; 2293 2294function initAskForImport() { 2295 $('.ask-for-import').off("click"); 2296 $('.ask-for-import').click(function() { 2297 askForImport($(this)); 2298 }); 2299} 2300 2301function askForImport(el) { 2302 let pcode = $(el).attr('data-code'); 2303 $.ajax({ 2304 async: true, 2305 type: 'post', 2306 url: '/product/ask_for_import/'+pcode, 2307 data: {'pcode':pcode}, 2308 success: function (data) { 2309 var width = 600; 2310 if($( window ).width() < width) { width = ($( window ).width() - 20); } 2311 $('#dialog').children('p').html(data); 2312 $('#dialog').dialog({ 2313 title: 'ÐапиÑване за вноÑ', 2314 width: width 2315 }); 2316 $('div[aria-describedby="dialog"]').css({'left': ($(window).width() - $('div[aria-describedby="dialog"]').width())/2, 'top':window.scrollY+50}); 2317 } 2318 }); 2319} 2320 2321function initioal_speedy_office() { 2322 $('#speedy_office_id').select2({ 2323 ajax: { 2324 minimumInputLength: 2, 2325 tags: [], 2326 url: '/ajax/search_speedy_offices_select2', 2327 data: function (params) { 2328 var query = { 2329 term: params.term 2330 } 2331 2332 // Query parameters will be ?search=[term]&type=public 2333 return query; 2334 }, 2335 processResults: function (data) { console.log(typeof data); 2336 2337 return { 2338 results: data 2339 }; 2340 } 2341 }, 2342 templateResult: formatState, 2343 templateSelection: formatState, 2344 escapeMarkup: function(m) {
2345 // Do not escape HTML in the select options text 2346 return m; 2347 }, 2348 }); 2349} 2350 2351function initioal_speedy_box() { 2352 $('#speedy_box_id').select2({ 2353 ajax: { 2354 minimumInputLength: 2, 2355 tags: [], 2356 url: '/ajax/search_speedy_box_select2', 2357 data: function (params) { 2358 var query = { 2359 term: params.term 2360 } 2361 2362 // Query parameters will be ?search=[term]&type=public 2363 return query; 2364 }, 2365 processResults: function (data) { 2366 2367 return { 2368 results: data 2369 }; 2370 } 2371 }, 2372 templateResult: formatState, 2373 templateSelection: formatState, 2374 escapeMarkup: function(m) { 2375 // Do not escape HTML in the select options text 2376 return m; 2377 }, 2378 }).on("select2:select", function(e) { 2379 $('#speedy_box').val(e.params.data.text); 2380 }); 2381 $('#speedy_box_id').on("select2:clear", function(e) { 2382 $('#speedy_box').val(''); 2383 }); 2384} 2385 2386function initioal_speedy_address() { 2387 $('#receiver_city_id').select2({ 2388 placeholder: "ÐзбеÑеÑе гÑад", 2389 allowClear: true, 2390 ajax: { 2391 minimumInputLength: 2, 2392 tags: [], 2393 url: '/ajax/search_speedy_city', 2394 data: function (params) { 2395 var query = { 2396 term: params.term 2397 } 2398 2399 // Query parameters will be ?search=[term]&type=public 2400 return query; 2401 }, 2402 processResults: function (data) { 2403 return { 2404 results: data 2405 }; 2406 } 2407 }, 2408 }); 2409 2410 $('#receiver_street_id').select2({ 2411 placeholder: "ÐзбеÑеÑе ÑлиÑа", 2412 allowClear: true, 2413 ajax: { 2414 minimumInputLength: 2, 2415 tags: [], 2416 url: '/ajax/search_speedy_street', 2417 data: function (params) { 2418 var query = { 2419 city_id: $('#receiver_city_id').val(), 2420 term: params.term 2421 } 2422 return query; 2423 }, 2424 processResults: function (data) { 2425 return { 2426 results: data 2427 }; 2428 } 2429 }, 2430 }); 2431 2432 2433 $('#receiver_complex_id').select2({ 2434 placeholder: "ÐзбеÑеÑе кваÑÑал", 2435 allowClear: true, 2436 ajax: { 2437 minimumInputLength: 2, 2438 tags: [], 2439 url: '/ajax/search_speedy_complex', 2440 data: function (params) { 2441 var query = { 2442 city_id: $('#receiver_city_id').val(), 2443 term: params.term 2444 } 2445 return query; 2446 }, 2447 processResults: function (data) { 2448 return { 2449 results: data 2450 }; 2451 } 2452 }, 2453 }); 2454} 2455 2456function initioal_econt_office() { 2457 $('#econt_office_id').select2({ 2458 ajax: { 2459 minimumInputLength: 2, 2460 tags: [], 2461 url: '/ajax/search_econt_offices_select2', 2462 data: function (params) { 2463 var query = { 2464 term: params.term 2465 } 2466 2467 // Query parameters will be ?search=[term]&type=public 2468 return query; 2469 }, 2470 processResults: function (data) { 2471 return { 2472 results: data 2473 }; 2474 } 2475 }, 2476 templateResult: formatState, 2477 templateSelection: formatState, 2478 escapeMarkup: function(m) { 2479 // Do not escape HTML in the select options text 2480 return m; 2481 }, 2482 }); 2483} 2484 2485function initioal_econt_address() { 2486 $('#receiver_city_id').select2({ 2487 placeholder: "ÐзбеÑеÑе гÑад", 2488 allowClear: true, 2489 ajax: { 2490 minimumInputLength: 2, 2491 tags: [], 2492 url: '/ajax/search_econt_city', 2493 data: function (params) { 2494 var query = { 2495 term: params.term 2496 } 2497 2498 // Query parameters will be ?search=[term]&type=public 2499 return query; 2500 }, 2501 processResults: function (data) { 2502 return { 2503 results: data 2504 }; 2505 } 2506 }, 2507 }).on("select2:select", function(e) { 2508 $('#receiver_post_code').val(e.params.data.post_code); 2509 }); 2510 $('#receiver_city_id').on("select2:clear", function(e) { 2511 $('#receiver_post_code').val(''); 2512 }); 2513 2514 2515 2516 2517 $('#receiver_street_id').select2({ 2518 placeholder: "ÐзбеÑеÑе ÑлиÑа", 2519 allowClear: true, 2520 ajax: { 2521 minimumInputLength: 2, 2522 tags: [], 2523 url: '/ajax/search_econt_street', 2524 data: function (params) { 2525 var query = { 2526 city_id: $('#receiver_city_id').val(), 2527 term: params.term 2528 } 2529 return query; 2530 }, 2531 processResults: function (data) { 2532 return { 2533 results: data 2534 }; 2535 } 2536 }, 2537 }); 2538 2539 2540 $('#receiver_complex_id').select2({ 2541 placeholder: "ÐзбеÑеÑе кваÑÑал", 2542 allowClear: true, 2543 ajax: { 2544 minimumInputLength: 2, 2545 tags: [], 2546 url: '/ajax/search_econt_quarter', 2547 data: function (params) { 2548 var query = { 2549 city_id: $('#receiver_city_id').val(), 2550 term: params.term 2551 } 2552 return query; 2553 }, 2554 processResults: function (data) { 2555 return { 2556 results: data 2557 }; 2558 } 2559 }, 2560 }); 2561} 2562 2563function formatState (result){ 2564 // console.log(result); 2565 let html = ''; 2566 if(result.hasOwnProperty("address")) { 2567 html = '<div>'+result.office+'<span>'+result.address+'</span></div>'; 2568 } else { 2569 html = result.text; 2570 } 2571 return html; 2572}; 2573 2574function changeSelect2(el, id_elem) { 2575 $('#'+id_elem).val($(el).find(":selected").text()); 2576} 2577 2578function validateSearch(form) { 2579 const input = form.querySelector('#q'); 2580 const raw = input.value.trim(); 2581 2582 // ÐÑÑавÑме Ñамо бÑкви (лаÑиниÑа/киÑилиÑа), ÑиÑÑи, ÑиÑе и инÑеÑвал 2583 const filtered = raw.replace(/[^a-zA-Zа-ÑÐ-Я0-9\- ]+/g, ''); 2584 2585 // ÐÑовеÑÑваме дали Ñлед ÑилÑÑиÑане има поне 3 Ñимвола 2586 if (filtered.length < 3) { 2587 2588 form.classList.add('search-error'); 2589 input.classList.add('input-error'); 2590 2591 setTimeout(() => { 2592 form.classList.remove('search-error'); 2593 input.classList.remove('input-error'); 2594 }, 3000); 2595 2596 return false;
2597 } 2598 2599 return true; 2600}
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.