1"use strict"; 2 3/* --------- POPUPS --------- */ 4 5function authModal(data) { 6 const body = document.querySelector("body"); 7 const modal_getLoginForm = document.getElementById("modal_getLoginForm"); 8 body.classList.add("modal-open"); 9 if(modal_getLoginForm)modal_getLoginForm.classList.add("hidden"); 10 body.innerHTML = ` 11 <div class="modal fade no-title in" id="authModal" tabindex="-1" role="dialog" aria-labelledby="authModal_label" aria-hidden="false" style="display: block;"> 12 <div class="modal-dialog" style="max-width: 820px; max-height: 800px; position: absolute; top: 50%; left: 50%; transition: all 0.5s ease 0s; transform: translate(-50%, -70%);"> 13 <div class="modal-content" 0=""><div class="modal-header"> 14 <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> 15 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z"></path></svg> 16 </button> 17 </div> 18 <div class="modal-body">${data.body}</div> 19 </div> 20 </div> 21 </div> 22 ` + body.innerHTML; 23} 24 25function checkLoginvk(id_var, first_name_var, last_name_var, photo_var, email_var, city_var, pass_var) { // detailed popup 26 $.get('./ext/auth/login_process.php', { 27 id: id_var, 28 first_name: first_name_var, 29 last_name: last_name_var, 30 photo: photo_var, 31 email: email_var, 32 city: city_var, 33 password: pass_var 34 }, function (data) { 35 var socEmailAddress = email_var; 36 doHookie('complete_registration'); 37 doHookie('login'); 38 authModal({ 39 id: 'check_login', 40 body: data 41 }); 42 43 $.get('./ext/auth/ajax_login_top.php', {ajaxloading: true}, function (data) { 44 $('#kabinet').html(data); 45 $(".close").click(() => window.location.reload()); 46 }); 47 }); 48} 49 50function modal(options) { 51 var settings = { 52 id: Math.floor(Math.random() * (1000 - 1 + 1)) + 1, 53 after: function () { 54 }, 55 width: 0, 56 before: function () { 57 } 58 } 59 $.extend(true, settings, options); 60 var width = ''; 61 var transform = 0; 62 if (settings.width != 0) width = 'style="width:auto;max-width:' + settings.width + 'px"'; 63 if (options.transform) transform = 'style="transform: translateY(' + options.transform + '%)"'; 64 if (jQuery('.modal').length == 0) { 65 var $html = '<div class="modal ' + (settings.unique_styles ? settings.unique_styles.join(' ') : '') + ' fade" id="modal_' + settings.id + '" tabindex="-1" role="dialog" aria-labelledby="' + settings.id + '_label" aria-hidden="true">'; 66 $html += '<div class="modal-dialog" ' + width + '><div class="modal-content" ' + transform + '>'; 67 $html += '<div class="modal-header">'; 68 $html += '<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z"></path></svg></button>'; 69 if (settings.title) { 70 $html += '<h4 class="modal-title" id="modal_' + settings.id + '_label">' + settings.title; 71 if (settings.freeShipping) { 72 $html += '<span class="freeShipping">'+settings.title+'</span>'; 73 } 74 $html += '</h4>'; 75 } 76 $html += '</div>'; 77 $html += '<div class="modal-body">' + settings.body + '</div>\ 78 </div>\ 79 </div>\ 80 </div>'; 81 jQuery('body').append($html).promise().done(function () { 82 var $modal = jQuery('#modal_' + settings.id); 83 var $before = settings.before($modal); 84 if ($before !== false) { 85 if (settings.classes) { 86 $modal.addClass(settings.classes); 87 } 88 89 if (settings.title == null) { 90 $modal.addClass('no-title'); 91 } 92 93 if ($modal.hasClass('valign-false') == false) { 94 centerModal($modal); 95 } 96 $modal.on('hidden.bs.modal', function (e) { 97 $modal.remove(); 98 }); 99 $modal.on('shown.bs.modal', function (e) { 100 if (settings.after) { 101 settings.after($modal); 102 } 103 }); 104 $modal.modal(); 105 106 } else { 107 $modal.remove(); 108 } 109 110 }); 111 } 112} 113 114function centerModal(el) { 115 $(el).css('display', 'block');
116 var $dialog = $(el).find(".modal-dialog"); 117 $dialog.css('position', 'absolute'); 118 $dialog.css('top', '50%'); 119 $dialog.css('left', '50%'); 120 $dialog.css('transition', '0.5s ease'); 121 $dialog.css('transform', 'translate(-50%, -70%)'); 122 $($dialog).animate({'margin-top': '100px'}, 1) 123} 124 125function pop_contact_us() { 126 $.post('./pop_contact_us.php', '', function (data) { 127 modal({ 128 id: 'pop_contact_us', 129 title: data.title, 130 body: data.html 131 // classes: 'valign-false' 132 }); 133 }, 'json'); 134} 135 136function showCartpopup() { 137 if (typeof window.settings != "undefined") { 138 if (window.settings.SHOW_BASKET_ON_ADD_TO_CART == true) { 139 $.get('./popup_cart.php', null, function (response) { 140 modal({ 141 id: 'cart_popup', 142 body: response, 143 classes: 'valign-false', 144 after: function () { 145 // scrollToTop(); 146 } 147 }); 148 }); 149 } 150 } 151} 152 153// call after get response 154function showPopupResponse(res) { 155 $('#popup_cart_form .delete').attr('disabled', false); 156 if (res !== undefined && res !== 0) { 157 res = JSON.parse(res); 158 for (var i = 0; i<res.prod.length; i++) { 159 var product_name = $('.row.cartContent_body.product_id_' + res.prod[i].string_id + res.prod[i].attr_chain + ' .product_name'); 160 if (product_name.html() != res.prod[i].name) { 161 product_name.html(res.prod[i].name); 162 } 163 var product_total = $('.row.cartContent_body.product_id_' + res.prod[i].string_id + res.prod[i].attr_chain + ' .product_total'); 164 if (product_total.html() != res.prod[i].price_full) { 165 product_total.html(res.prod[i].price_full); 166 } 167 } 168 $('#cart_order_total').html(res.total); 169 170 var warning_mess = $('.warning_mess'); 171 if (warning_mess.length == 1) { 172 warning_mess.replaceWith(res.stock_text); 173 } else { 174 $('#cart_order_total').after(res.stock_text); 175 } 176 177 if (res.stock_text != '') { 178 $('#checkoutButton').css({'pointer-events': 'none', 'background': '#999'}); 179 } else { 180 $('#checkoutButton').removeAttr("style"); 181 } 182 } 183 updateCart(); 184 if ($('#voucherRedeem').length) { 185 $('#voucherRedeem').click(); 186 } 187 // reset checkout 188 if (typeof checkout != 'undefined') { 189 checkout.updateShippingMethods(); 190 checkout.updateOrderTotals(); 191 } 192} 193 194// call after get response 195function showPopupResponsev2(res) { 196 updateCart(); 197 // reset checkout 198 if (typeof checkout != 'undefined') { 199 checkout.updateShippingMethods(); 200 checkout.updateOrderTotals(); 201 } 202} 203 204/* --------- /POPUPS --------- */ 205 206// Return cookie by name 207function getCookie(name) { 208 let matches = document.cookie.match(new RegExp( 209 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 210 )); 211 return matches ? decodeURIComponent(matches[1]) : undefined; 212} 213 214/* --------- AJAX-add to cart --------- */ 215 216function doAddProduct(form) { 217 var fe = form.elements; 218 var senddata = new Object(); 219 for (var i = 0; i < fe.length; i++) { 220 if (fe[i].type == "radio" || fe[i].type == "checkbox") { 221 if (fe[i].checked) senddata[fe[i].name] = fe[i].value; 222 } else { 223 senddata[fe[i].name] = fe[i].value; 224 } 225 } 226 var url = form.action; 227 $.post(url, senddata, function (data) { 228 // $('.add2cart[data-id='+senddata["products_id"]+']').replaceWith(sprintf(RTPL_CART_BUTTON, senddata["products_id"])); 229 $('#r_buy_intovar[data-id=' + senddata["products_id"] + ']').html(RTPL_CART_BUTTON_PRODUCT_PAGE); // product page 230 if ($('.fade.tooltip.top.in').length) $('.fade.tooltip.top.in').remove(); 231 if ($(window).width() > 768) { 232 $('[data-toggle="tooltip"]').tooltip({ 233 container: 'body' 234 }); 235 } 236 showCartpopup(); 237 updateCart('add_product'); 238 }); 239} 240 241function doAddProductList(button) { 242 243 $.post('?action=add_product', { 244 'products_id': button.attr('data-id'), 245 'cart_quantity': button.attr('data-qty') 246 }, function (data) { 247 $('.add2cart[data-id=' + button.attr('data-id') + ']').replaceWith(sprintf(RTPL_CART_BUTTON, button.attr('data-id'))); 248 if ($('.fade.tooltip.top.in').length) $('.fade.tooltip.top.in').remove(); 249 if ($(window).width() > 768) { 250 $('[data-toggle="tooltip"]').tooltip({container: 'body'}); 251 } 252 //this variables is global and will be replaced for current product 253 currentProductId = data.id; 254 productPriceOrign = data.price;//$(this).attr('data-orign-price'); 255 currentProductCategoryName = data.category; 256 currentProductName = data.name; 257 doHookie('add2cart'); 258 showCartpopup(); 259 updateCart('add_product'); 260 }, 'json'); 261} 262 263function showAlert(text, parent, type, removeClass) { 264 // if removeClass isn't empty - show close button 265 if (removeClass !== '') var close = '<button class="close" data-dismiss="alert" aria-label="close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z"></path></svg></button>'; 266 267 // adds alert box to parent with next properties 268 parent.after("<div class='alert " + type + " apple-tree fade in " + removeClass + "' data-alert='alert'>" + close + "<span>
268" + text + "</span></div>"); 269 270 setTimeout(function () { 271 parent.next().remove(); 272 }, 5000); 273} 274 275// call before send data 276function showRequest(formData, jqForm, options) { 277 var queryString = $.param(formData); 278 // $('#block').animate({opacity: 0.6}, 50); 279 $('.refresh_icon .fa-spin').fadeIn(20); 280 queryString = '?' + queryString; 281 history.replaceState({foo: "bar"}, "Jesus saves", document.location.pathname.toString() + queryString); 282 return true; 283} 284 285// call after get answer 286function showResponse(responseText, statusText) { 287 // console.log(responseText); 288 // $('#block').animate({opacity: 1}, 50); 289 $('.refresh_icon .fa-spin').fadeOut(20); 290} 291 292/* --------- END AJAX-add to cart --------- */ 293 294function productInCart(cartKey) { // cartKey contain product_id + attributes 295 $('#r_buy_intovar button[type="submit"]').attr('disabled'); 296 $.post('./ajax_product_in_cart.php', 'cartKey=' + cartKey, function (data) { 297 $('#r_buy_intovar').html(data['button_html']); 298 }, 'json'); 299} 300 301function updateCart(action) { // function updateCart(action = ''){ 302 $.post('./ajax_update_cart.php', '', function (data) { 303 $('#divShoppingCard').replaceWith(data.cart_html); // $('#divShoppingCard').html(data.cart_html); 304 $('.mobile_cart_count').html(data.cart_count); 305 // if ($('.xs-menu-actions .popup_cart .counter').length) $('.xs-menu-actions .popup_cart .counter').text(data.count) 306 if (action == 'add_product') { 307 $('.alert').remove(); 308 showAlert(RENDER_TEXT_ADDED_TO_CART, $('#divShoppingCard'), 'alert-success', 'alert-dismissible'); 309 } 310 }, 'json'); 311} 312 313/* --------- ETC --------- */ 314function setLastcols(context, element) { 315 var listing_item = jQuery(context + ' ' + element); 316 var cols = Math.floor(jQuery('#center').width() / listing_item.width()); 317 jQuery(context + ' ' + element + ':nth-of-type(' + cols + 'n+' + cols + ')').addClass('last-col'); 318} 319 320//Scroll to some element on page 321function scrollToEl(element) { 322 var $el = jQuery(element); 323 var $elOffset_top = $el.offset().top; 324 jQuery('body,html').stop(false, false).animate({scrollTop: $elOffset_top}, {duration: 600, easing: 'swing'}, 800); 325} 326 327function scrollToTop() { 328 jQuery('body,html').stop(false, false).animate({scrollTop: 0}, {duration: 600, easing: 'swing'}, 800); 329} 330 331// Item list 332function themeItems() { 333 jQuery('.item-list li').each(function (e) { 334 jQuery(this).addClass('item_' + e); 335 }); 336} 337 338function showLoginvk(url) { 339// set window width and height 340 var w = 635; 341 var h = 250; 342// calculate window position according to screen resolution 343 var lPos = (screen.width) ? (screen.width - w) / 2 : 0; 344 var tPos = (screen.height) ? (screen.height - h) / 2 : 0; 345// newWindow = window.open("","","height="+h+",width="+w+",top="+tPos+",left="+lPos); 346 var params = "menubar=no,location=yes,resizable=yes,scrollbars=no,status=no,height=" + h + ",width=" + w + ",top=" + tPos + ",left=" + lPos; 347 let loginWindow = window.open(url, VK_LOGIN, params); 348 var popupTick = setInterval(function() { 349 if (loginWindow.closed) { 350 $(".close").click(); 351 clearInterval(popupTick); 352 } 353 }, 500); 354 355} 356 357/* 358* Function for fixing dropdown submenu 359* last points by right side, if it`s width more than wrapper`s width 360* Example : fixMenu('.nav','li.parent','.dropdown_div'); 361*/ 362function fixMenu(menu_selector, parent, dropdown) { 363 var $menu = $(menu_selector); 364 var $windowWidth = jQuery(window).width(); 365 var $wrapperWidth = $menu.width(); 366 var $outsideWidth = ($windowWidth - $wrapperWidth) / 2; 367 $(menu_selector + '' + parent).each(function (index, el) { 368 var $dropdown = $(el).find(dropdown); 369 var $curTotalWidth = ($(el).offset().left + $dropdown.outerWidth(true)) - $outsideWidth;
370 var $differenceWidth = ($(el).offset().left - $outsideWidth) / 2; 371 if ($curTotalWidth > $wrapperWidth) { 372 $dropdown.css({marginLeft: '-' + $differenceWidth + "px"}); 373 } 374 }); 375} 376 377/* --------- /ETC --------- */ 378 379 380/* --------- SEARCH --------- */ 381function liFormat(row, i, num) { 382 var st = ''; 383 var result = '<div class="search_image_wrap"><img src="' + row[2] + '" class="picsearch"></div>' + '<p class=qnt1>' + row[0] + ' </p><span><p class=qntp>' + row[4] + '</p>' + '<p class=qnt>' + row[1] + ' </p></span>'; 384 return result; 385} 386 387function selectItem(li) { 388 if (li == null) { 389 var sValue = '!'; 390 window.location = "/search=" + li.extra[2]; 391 } 392 if (!!li.extra) var sValue = li.extra[2]; 393 else var sValue = li.selectValue; 394 var tbox = document.getElementById('searchpr') || document.getElementById('searchpr1'); 395 if (tbox) { 396 window.location = SEARCH_LANG + "product_info.php?products_id=" + li.extra[2]; 397 } 398} 399 400/* --------- SEARCH --------- */ 401 402function calculate_sum(selected_op) { 403 var summ, old_summ, sel_ops; 404 405 if ($('input[name=prod_price]').val() != '-') { 406 if (selected_op.attr('data-prefix') == '=' && $('#id_option_other' + selected_op.val()).val() != '=0') { // if "=" and NOT "=0" then immediately set price 407 summ = ($('#id_option_other' + selected_op.val()).val()).substring(1); 408 409 } else { 410 $('.select_id_option').each(function () { // search first attribute with "=" sign 411 sel_ops = $(this).parent().find($("select option:selected")); 412 if (sel_ops.attr('data-prefix') == '=' && $('#id_option_other' + sel_ops.val()).val() != '=0') { 413 summ = ($('#id_option_other' + sel_ops.val()).val()).substring(1); 414 return false; 415 } 416 }); 417 if (!summ) summ = parseFloat($('input[name=prod_price]').val()); // current product price 418 } 419 420 old_summ = parseFloat($('input[name=old_prod_price]').val()); 421 422 $('select.select_id_option').each(function () { // adding all prices with "+" 423 if ($(this).hasClass('selectized')) { 424 sel_ops = selectizeGetSelectedItem(selectizeWrapper($(this))); 425 if (sel_ops.prefix) { 426 if (sel_ops.prefix == '+' || (sel_ops.prefix == '=' && $('#id_option_other' + sel_ops.value).val() == '=0')) { 427 summ = parseFloat(summ) + parseFloat(($('#id_option_other' + sel_ops.value).val()).substring(1)); 428 old_summ = parseFloat(old_summ) + parseFloat(($('#id_option_other' + sel_ops.value).val()).substring(1)); 429 } else if (sel_ops.prefix == '-') { 430 summ = summ - parseFloat(($('#id_option_other' + sel_ops.value).val()).substring(1)); 431 old_summ = old_summ - parseFloat(($('#id_option_other' + sel_ops.value).val()).substring(1)); 432 } 433 } 434 } else { 435 sel_ops = $(this).parent().find($("select option:selected")); 436 if (sel_ops.attr('data-prefix') == '+' || (sel_ops.attr('data-prefix') == '=' && $('#id_option_other' + sel_ops.val()).val() == '=0')) { 437 summ = parseFloat(summ) + parseFloat(($('#id_option_other' + sel_ops.val()).val()).substring(1)); 438 old_summ = parseFloat(old_summ) + parseFloat(($('#id_option_other'+sel_ops.val()).val()).substring(1)); 439 } else if (sel_ops.attr('data-prefix') == '-') { 440 summ = summ - parseFloat(($('#id_option_other' + sel_ops.val()).val()).substring(1)); 441 old_summ = old_summ - parseFloat(($('#id_option_other'+sel_ops.val()).val()).substring(1)); 442 } 443 } 444 }); 445 446 447 // ------------------format summ!!------------------ 448 449 // add decimal places after decimal point 450 var decimalPlaces = $('input[name=prod_dec_places]').val(); 451 if (decimalPlaces) { 452 summ = parseFloat(summ).toFixed(decimalPlaces); 453 old_summ = parseFloat(old_summ).toFixed(decimalPlaces); 454 455 // replace dot(.) to store decimal point 456 var decimalPoint = $('input[name=prod_dec_point]').val(); 457 if(decimalPoint) { 458 summ = summ.replace('.', decimalPoint); 459 old_summ = old_summ.replace('.', decimalPoint); 460 } 461 } else { 462 // if dec_places empty, make it INT 463 summ = parseInt(summ); 464 old_summ = parseInt(old_summ); 465 } 466 467 // add thousands point 468 var thousandsPoint = $('input[name=prod_thousands_point]').val(); 469 if(thousandsPoint) { 470 summ = numberWithCommas(summ, thousandsPoint); 471 old_summ = numberWithCommas(old_summ, thousandsPoint); 472 } 473 474 // left currency symbol 475 var currencyLeft = $('input[name=prod_currency_left]').val(); 476 if(currencyLeft) { 477 summ = currencyLeft + summ; 478 old_summ = currencyLeft + old_summ; 479 } 480 481 // right currency symbol 482 var currencyRight = $('input[name=prod_currency_right]').val(); 483 if(currencyRight) { 484 summ = summ + ' ' + currencyRight; 485 old_summ = old_summ + ' ' + currencyRight; 486 } 487 488 $(".new_price_card_product").html(summ); 489 $(".old_price_card_product").html(old_summ); 490 } 491} 492 493function ajaxSubmitSerialize(options) { 494 $('#attribs').addClass('pointer_events_none'); // Block filters for processing time
495 $('.refresh_icon .fa-spin').fadeIn(20); 496 if (options.target) { 497 $('#m_srch input[name="page"]').prop("disabled", true); 498 } 499 var pathSerialize = $('#m_srch').attr('action') + '?' + $('#m_srch').serialize(); 500 var queryString = '?' + $('#m_srch').serialize(); 501 $('#m_srch input[name="page"]').prop("disabled", false); 502 if (!(typeof SEO_FILTER == "string" && SEO_FILTER == 1)) { 503 history.replaceState({foo: "bar"}, "Jesus saves", document.location.pathname.toString() + queryString); 504 } 505 var findWidthToUnveil; 506 507 // if($('#m_srch input[name="loadajax"]').val()=='true') { 508 if (options.target) { 509 // $(options.target).html('<div id="r_spisok" class="row row_catalog_products "></div>'); 510 $.post(pathSerialize, function (data) { // get array 511 $('#attribs').removeClass('pointer_events_none'); // unblock filters 512 if (data != null && data['globals'] != undefined) { 513 var ajax_globals = data['globals']; // array with global variables and languages constants 514 515 $(options.target).html(ajax_globals['listing_header']); 516 517 if (typeof RTPL_DEFAULT_COLS !== 'undefined') { 518 var default_cols = JSON.parse(RTPL_DEFAULT_COLS); 519 var default_cols_str = 'cc-xs-' + default_cols[0] + ' cc-sm-' + default_cols[1] + ' cc-md-' + default_cols[2] + ' cc-lg-' + default_cols[3] + ' cc-lg-' + default_cols[4]; 520 $('#r_spisok').addClass(default_cols_str); 521 } 522 523 $.each(data, function (k, v) { // add array directly to html 524 525 //find width to activate unveil in chrome 526 if (v['product_image'] && !findWidthToUnveil) { 527 findWidthToUnveil = v['product_image'].split('&')[1].split('=')[1]; 528 } 529 // 530 if (k != 'globals') $('#r_spisok').append(draw_product_block(v, ajax_globals)); 531 }); 532 showResponse(); 533 if (findWidthToUnveil) { 534 // $("#r_spisok img").width(findWidthToUnveil); 535 findWidthToUnveil = 0; 536 } 537 $("#r_spisok img").unveil(100, addAnimClassToImg); 538 // $("#r_spisok img").width('100%'); // to make lazyload work properlty we need to set dimensions in pixels, and then return "100%" width as in css 539 540 // add "show more" and pagination 541 // $('#r_spisok').after(ajax_globals['load_more']+ajax_globals['pages_html']+ajax_globals['number_of_rows']); 542 $('#r_spisok').after(ajax_globals['listing_footer']); 543 $('#loadMoreProducts').click(function () { 544 loadMoreProducts(); 545 }); 546 547 if (RTPL_PDF_ENABLED) { 548 $(RTPL_PDF_BLOCK_SELECTOR).data("href", ajax_globals['pdf_link']) 549 } 550 // if(RTPL_PDF_ENABLED) $('#block').prepend(sprintf(RTPL_LISTING_HEADER, ajax_globals['pdf_link'])); 551 552 } else { 553 $('#block').html(''); 554 $('#attribs').removeClass('pointer_events_none'); // unblock filters 555 $('.refresh_icon .fa-spin').fadeOut(20); 556 } 557 if (typeof SEO_FILTER == "string" && SEO_FILTER == 1) { 558 if (typeof ajax_globals !== 'undefined') { 559 if ($('#filters_box').length) $('#filters_box').replaceWith(ajax_globals['filtersBlock']) 560 if (ajax_globals['currentHref']) { 561 window.history.pushState('data', 'Title', ajax_globals['currentHref']); 562 } else { 563 history.replaceState({foo: "bar"}, "Jesus saves", document.location.pathname.toString() + queryString); 564 } 565 } else { 566 history.replaceState({foo: "bar"}, "Jesus saves", document.location.pathname.toString() + queryString); 567 } 568 initSlider(); 569 } 570 doHookie('filter'); 571 }, 'json'); 572 } else if (options = "loadMore") { 573 var lastMsg = $('#r_spisok .col_product:last'); 574 var curOffset = lastMsg.offset().top - $(document).scrollTop(); 575 $('#attribs').removeClass('pointer_events_none'); // unblock filters 576 $.get(pathSerialize, function (data) { 577 //from all html get only list of products to add and append them to #r_spisok 578 var ajax_globals = data['globals']; // array with global variables and languages constants 579 $.each(data, function (k, v) { // add array directly to html 580 //find width to activate unveil in chrome 581 if (v['product_image'] && !findWidthToUnveil) { 582 findWidthToUnveil = v['product_image'].split('&')[1].split('=')[1]; 583 } 584 if (k != 'globals') $('#r_spisok').append(draw_product_block(v, ajax_globals)); 585 }); 586 $(document).scrollTop(lastMsg.offset().top - curOffset); 587 $($.find(".pagination .active")).next().attr("class", "active"); //mark next page as active 588 showResponse(); 589 if (findWidthToUnveil) { 590 // $("#r_spisok img").width(findWidthToUnveil); 591 findWidthToUnveil = 0; 592 } 593 $("#r_spisok img").unveil(100, addAnimClassToImg); 594 // $("#r_spisok img").width('100%'); //to make lazyload work properlty we need to set dimensions in pixels, and then return "100%" width as in css 595 596 $('#loadMoreI').removeClass('fa-spin'); //stop font-awesome animation 597 }, 'json'); 598 599 } 600 601} 602 603function loadMoreProducts() { 604 var totalProducts = $('input[name=number_of_rows]').val(); 605 // var productsPerPage=$('select[name=row_by_page] option:selected').text(); 606 var productsPerPage = $('*[name=row_by_page]').val(); //get value from row_by_page 607 var lastRedElement; 608 //find last red page(even it has not li .active)
609 var obj = $('#m_srch').serializeArray(); 610 obj.forEach(function (item) { 611 if (item['name'] == "row_by_page") { 612 productsPerPage = item['value']; 613 } 614 }); 615 616 var foundpage = false; 617 $.each(obj, function (i, field) { 618 if (obj[i].name == "page") { 619 lastRedElement = parseInt(obj[i].value); 620 foundpage = true; 621 622 } 623 }); 624 var totalPagesAdjusted; 625 if (~~(totalProducts / productsPerPage) === (totalProducts / productsPerPage)) { 626 totalPagesAdjusted = (totalProducts / productsPerPage); 627 } else { 628 totalPagesAdjusted = ~~(totalProducts / productsPerPage) + 1; 629 } 630 if (foundpage == false) { 631 lastRedElement = 1; 632 } 633 634 if (lastRedElement >= totalPagesAdjusted) { 635 } else { 636 $('#loadMoreI').addClass('fa-spin');//start font-awesome animation 637 $('.refresh_icon .fa-spin').fadeIn(20); 638 639 //serialize path with attributes 640 var obj = $('#m_srch').serializeArray(); 641 var foundpage = false; 642 $.each(obj, function (i, field) { 643 if (obj[i].name == "page") { 644 lastRedElement = obj[i].value; 645 obj[i].value = parseInt(obj[i].value) + 1; 646 $('#m_srch').prop("page").value = obj[i].value; 647 foundpage = true; 648 649 } 650 }); 651 if (foundpage == false) { 652 $('#m_srch').append('<input id="page1" type="hidden" name="page" value="2">'); 653 lastRedElement = 1; 654 } 655 656 ajaxSubmitSerialize("loadMore"); 657 } 658} 659 660// new draw product block by templates. 03.04.18 by raid 661function draw_product_block($listing, glob) { 662 663 var $id = $listing['p_id']; 664 var $product_name = $listing['p_name']; 665 var $show_button = $listing['show_button']; 666 var $product_info = $listing['p_info']; 667 var $cat_name = $listing['cat_name']; 668 var $product_href = glob['promUrls'] ? glob['catalog_path'] + 'p' + $id + '-' + $listing['p_href'] + '.html' : glob['catalog_path'] + $listing['p_href'] + '/p-' + $id + '.html'; 669 var $product_image = sprintf(RTPL_PRODUCTS_IMAGE, glob['img_end'], ($listing['p_img'] != '' ? $listing['p_img'] : glob['img_default']), $product_name, $product_name, ($listing['p_img2'] ? 'data-hover="getimage/' + glob['img_end'] + '/products/' + $listing['p_img2'] + '"' : '')); 670 var $pmodel = ($listing['p_model'] != '' ? sprintf(RTPL_PRODUCTS_MODEL, glob['pmodel_class'], $listing['p_model']) : ''); 671 var $stock = ($listing['p_qty'] > 0 ? sprintf(RTPL_PRODUCTS_STOCK, glob['stock_pull']) : sprintf(RTPL_PRODUCTS_OUTSTOCK, glob['stock_pull'])); 672 var $label = $listing['lbl'] ? sprintf(RTPL_LABEL, $listing['l_class'], $listing['lbl']) : ''; 673 var $add_classes = glob['add_classes'] ? glob['add_classes'] : ''; // separated old price 674 var $not_available = $listing['p_qty'] == 0 ? ' not_available' : ''; 675 var $p_wishlist, $cart_button; 676 let $modal_button = $listing['modal_button']; 677 678 var $spec_price = $listing['p_specprice'] ? $listing['p_specprice'] : ''; 679 var $old_price = $listing['p_price']; 680 var $final_price = ($spec_price != '' ? sprintf(RTPL_PRODUCTS_SPEC_PRICE, $spec_price, $old_price) : sprintf(RTPL_PRODUCTS_PRICE, $old_price)); 681 682 var $new_price = sprintf(RTPL_PRODUCTS_PRICE, ($spec_price ? $spec_price : $old_price)); // separated new price 683 var $old_price = $spec_price ? sprintf(RTPL_PRODUCTS_OLD_PRICE, $old_price) : ''; // separated old price 684 685 $cart_button = '<input type="hidden" name="cart_quantity" value="1"><input type="hidden" name="products_id" value="' + $id + '">'; 686 if ($listing['p_qty'] <= 0) { 687 if ($show_button == "true") { 688 $cart_button += ($listing['cart_incart'] ? sprintf(RTPL_CART_BUTTON, $id) : sprintf(RTPL_ADD_TO_CART_BUTTON, $id, 1)); 689 } 690 } else { 691 $cart_button += ($listing['cart_incart'] ? sprintf(RTPL_CART_BUTTON, $id) : sprintf(RTPL_ADD_TO_CART_BUTTON, $id, 1)); 692 } 693 694 $listing['compare'] = $listing['compare'] ? $listing['compare'] : ''; 695 $listing['wish'] = $listing['wish'] ? $listing['wish'] : ''; 696 697 // Compare & Wishlist 698 var $compare_output = ''; 699 $p_wishlist = '';
700 if (glob['compa_enabled'] == true || glob['wish_enabled'] == true) { 701 702 if (glob['compa_enabled'] == true) { 703 if (checkTemplate('default')) { 704 $compare_output += sprintf(RTPL_PRODUCTS_COMPARE, $id, $id, $id, $listing['compare'], $listing['compare_link_before'], $id, ($listing['compare'] ? glob['compa_text_in'] : glob['compa_text']), $listing['compare_link_after']); 705 } else { 706 $compare_output += sprintf(RTPL_PRODUCTS_COMPARE, $id, $id, $id, $listing['compare'], $id, ($listing['compare'] ? glob['compa_text_in'] : glob['compa_text'])); 707 708 } 709 } 710 if (glob['wish_enabled'] == true) $p_wishlist = sprintf(RTPL_PRODUCTS_WISHLIST, $id, $id, $id, $listing['wish'], $id, ($listing['wish'] ? glob['wish_text_in'] : glob['wish_text'])); 711 } 712 713 $compare_output = ($compare_output != '' ? sprintf(RTPL_COMPARE_OUTPUT, glob['compare_class'], $compare_output) : ''); 714 715 // Attributes: 716 if ($listing['p_attr']) { 717 var $product_attributes = ''; 718 $.each($listing['p_attr'], function ($ana_name, $ana_vals) { 719 $product_attributes += sprintf(glob['attr_listing'], glob['all_attribs'][$ana_name], $ana_vals); 720 }); 721 $product_attributes = $product_attributes ? sprintf(glob['attr_body'], $product_attributes) : ''; 722 } 723 724 var $array_from_to = { 725 'blocks_num_lg': glob['blocks_num']['lg'], 726 'blocks_num_md': glob['blocks_num']['md'], 727 'blocks_num_sm': glob['blocks_num']['sm'], 728 'blocks_num_xs': glob['blocks_num']['xs'], 729 'blocks_num_xl': glob['blocks_num']['xl'], 730 'product_href': $product_href, 731 'label': $label, 732 'product_image': $product_image, 733 'products_model': $pmodel, 734 'stock': $stock, 735 'final_price': $final_price, 736 'new_price': $new_price, 737 'old_price': $old_price, 738 'id': $id, 739 'category_name': $cat_name, 740 'product_name': $product_name, 741 'product_info': $product_info, 742 'product_attributes': $product_attributes, 743 'compare_output': $compare_output, 744 'wishlist_output': $p_wishlist, 745 'cart_button': $cart_button, 746 'add_classes': $add_classes, 747 'not_available': $not_available, 748 'product_modal_button': $modal_button 749 }; 750 751 return glob['listing_layout'].formatUnicorn($array_from_to); // replace template by variables from $array_from_to 752} 753 754function numberWithCommas(x, comma) { 755 if (typeof x != 'undefined') return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, comma); 756} 757 758// scroll to selected element: 759function multiselectscroll() { 760 $(document).on('click', '.ui-multiselect', function () { 761 // $(".ui-multiselect").on('click', function() { 762 if ($('.ui-multiselect-menu:visible').length != 0) { // if its opened 763 $('.ui-multiselect-menu:visible .ui-multiselect-checkboxes').animate({scrollTop: 0}, 0); // go to top first; 764 $('.ui-multiselect-menu:visible .ui-multiselect-checkboxes').animate({ // go to current element 765 scrollTop: $(".ui-multiselect-menu:visible .ui-multiselect-checkboxes .ui-state-active").position().top 766 }, 0); 767 } 768 }); 769} 770 771// NOT WORKING for IE: 772/* function sprintf(format, ...args) { 773 let i = 0; 774 return format.replace(/%s/g, () => args[i++]); 775} */ 776 777function sprintf() { 778 if (arguments.length < 2) { 779 return arguments[0]; 780 } 781 var args = arguments; 782 var index = 1; 783 var result = (args[0] + '').replace(/%((\d)\$)?([sd%])/g, function (match, group, pos, format) { 784 if (match === '%%') { 785 return '%'; 786 } 787 if (typeof pos === 'undefined') { 788 pos = index++; 789 } 790 if (pos in args && pos > 0) { 791 return args[pos]; 792 } else { 793 return match; 794 } 795 }); 796 return result; 797} 798 799// replace function: 800String.prototype.formatUnicorn = String.prototype.formatUnicorn || 801 function () { 802 "use strict"; 803 var str = this.toString(); 804 if (arguments.length) { 805 var t = typeof arguments[0]; 806 var key; 807 var args = ("string" === t || "number" === t) ? 808 Array.prototype.slice.call(arguments) 809 : arguments[0]; 810 811 for (key in args) { 812 str = str.replace(new RegExp("\\{{" + key + "\\}}", "gi"), args[key]); 813 } 814 } 815 816 return str; 817 }; 818 819function selectizeWrapper($selector) { 820 return $selector[0].selectize; 821} 822
823function selectizeGetSelectedItem(wrapper) { 824 return wrapper.options[wrapper.items[0]]; 825} 826 827function checkTemplate(templateName) { 828 return typeof TEMPLATE_NAME === 'string' && TEMPLATE_NAME === templateName; 829} 830 831function renderSlider(mainPageModules) { 832 if (mainPageModules.length == 0) { 833 return false; 834 } 835 var box = mainPageModules.shift(); 836 $.ajax({ 837 url: './routes.php?get-module=1', 838 type: 'POST', 839 data: {render: box}, 840 success: function (response) { 841 var el = $('.ajax-module-box[data-module-id="' + box + '"]'); 842 el.append((response)); 843 el.find('img').unveil(100, addAnimClassToImg); 844 el.find('.lazy-data-loader').remove(); 845 var block_id = el.find('.product_slider').attr('id'); 846 if (typeof block_id != 'undefined') { 847 eval('make_' + block_id + '_slider();'); 848 } 849 renderSlider(mainPageModules); 850 } 851 }); 852} 853 854//the slider block is loaded when scroll top position near the our block 855function blockUnveil(elements, th) { 856 for (let index in elements) { 857 var element = $('[data-module-id="' + elements[index] + '"]'); 858 var scrollFlag = (typeof (element.attr('data-scroll')) != 'undefined') ? true : false; 859 if (element.length > 0 && !scrollFlag) { 860 var wt = $(window).scrollTop(), 861 wb = wt + $(window).height(), 862 et = element.offset().top, 863 eb = et + element.height(); 864 var ress = eb >= wt - th && et <= wb + th; 865 if (ress) { 866 scrollFlag = true; 867 element.attr('data-scroll', true); 868 renderSlider([elements[index]]); 869 } 870 } 871 } 872} 873 874function renderCustomizationPanel() { 875 $.ajax({ 876 url: '/customization_panel.php', 877 success: function (response) { 878 $('body').append(response); 879 } 880 }); 881} 882 883function checkIsCustomizationPanelVisible() { 884 if (!customizationPanelFlag) { 885 customizationPanelFlag = true; 886 setTimeout(function () { 887 renderCustomizationPanel(); 888 }, timeoutValue); 889 } 890} 891 892function addAnimClassToImg() { 893 $(this).addClass('anim'); 894} 895 896function makeJSConstantsFromJson() { 897 let jsonConstantsElem = document.getElementById('json-constants'); 898 if (jsonConstantsElem != null) { 899 let jsonConstants = JSON.parse(document.getElementById('json-constants').innerHTML); 900 for (let constant in jsonConstants) { 901 window[constant] = jsonConstants[constant]; 902 } 903 } 904} 905 906function checkAndAddMainStyles() { 907 var link = $('#main-style').attr('data-href'); 908 if (typeof link != 'undefined') { 909 $('#main-style').removeAttr('data-href'); 910 $('#main-style').attr('href', link); 911 } 912 if (IS_MOBILE && $('#mobile-main-style[data-href]').length > 0) { 913 link = $('#mobile-main-style').attr('data-href'); 914 $('#mobile-main-style').removeAttr('data-href'); 915 $('#mobile-main-style').attr('href', link); 916 } 917} 918 919// uses in brand filter 920function onlyOneBrandCheckbox(checkbox) { 921 var checkboxes = document.getElementsByName('filter_id[]'); 922 checkboxes.forEach((item) => { 923 if (item !== checkbox) item.checked = false 924 }) 925}
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.