1//shop2.facets.search.wrapper = ""; 2shop2.options.msgTime = 2000; 3 4shop2.queue.kindAvailable = function(){ 5 var sentAjax_preorder = function(data, callback){ 6 $.ajax({ 7 url: '/-/x-api/v1/public/?method=shop2/addKindEmailNotification', 8 method: 'post', 9 xhrFields: { 10 withCredentials: true 11 }, 12 data: data, 13 success: function(result) { 14 callback(result); 15 } 16 }); 17 }; 18 19 var object_preorder = {}; 20 $(document).on('click', '.preorder-btn-js', function(e) { 21 e.preventDefault(); 22 object_preorder.data = {}; 23 24 object_preorder.jQbtn = $(this); 25 object_preorder.data.kind_id = object_preorder.jQbtn.data('product-kind_id'); 26 object_preorder.data.email = object_preorder.jQbtn.data('user-email') || 0; 27 28 if( object_preorder.data.email ){ 29 var temp_email = ` 30 <div class="preorder-field preorder-email tpl-field type-email field-required"> 31 <span class="preorder-email_text"> 32 ${shop2.my.preorder_email_text||'ÐаннÑй email Ñказан пÑи ÑегиÑÑÑаÑии.'} 33 </span> 34 <div class="preorder-email-input"> 35 <div class="preorder-field-title field-title">E-mail: <span class="field-required-mark">*</span></div> 36 <div class="preorder-field-value"> 37 <input type="text" name="email" required value="${object_preorder.data.email}"> 38 </div> 39 </div> 40 </div> 41 `; 42 43 }else { 44 var temp_email = ` 45 <div class="preorder-field preorder-email tpl-field type-email field-required"> 46 <div class="preorder-email-input"> 47 <div class="preorder-field-title field-title">E-mail: <span class="field-required-mark">*</span></div> 48 <div class="preorder-field-value"> 49 <input type="text" name="email" required value=""> 50 </div> 51 </div> 52 </div> 53 `; 54 } 55 56 let temp_html = ` 57 <div class="preorder-form-wrap preorder-block"> 58 <form class="preorder_body" action="/-/x-api/v1/public/?method=shop2/addKindEmailNotification" method="get"> 59 <div class="preorder-title tpl-anketa__title"> 60 ${shop2.my.preorder_form_title||'УзнаÑÑ Ð¾ поÑÑÑплении'} 61 </div> 62 <div class="preorder_text preorder-field type-html tpl-field type-html"> 63 ${shop2.my.preorder_form_text||'ÐÑÑавÑÑе поÑÑÑ Ð¸ Ð¼Ñ Ð½Ð°Ð¿Ð¸Ñем вам, когда ÑÐ¾Ð²Ð°Ñ Ð¿Ð¾ÑвиÑÑÑ Ð² налиÑии.'} 64 </div> 65 ${temp_email} 66 <input type="hidden" name="kind_id" value="${object_preorder.data.kind_id}"> 67 68 <div class="preorder-field tpl-field tpl-field-button"> 69 <button type="submit" class="tpl-form-button">${shop2.my.preorder_form_submitt||'ÐÑпÑавиÑÑ'}</button> 70 </div> 71 72 </form> 73 <div class="block-recaptcha"></div> 74 </div> 75 `; 76 77 let this_remodal = $('.remodal[data-remodal-id="buy-one-click"]'); 78 79 this_remodal.find('.preorder-form-wrap').add( this_remodal.find('.tpl-anketa') ).remove(); 80 81 this_remodal.append(temp_html); 82 83 this_remodal.remodal().open(); 84 85 this_remodal.on('closed.preorder', function(e){ 86 87 this_remodal.find('.preorder-form-wrap').remove(); 88 this_remodal.off('closed.preorder'); 89 }); 90 });
91 92 $(document).on('submit', '.block-recaptcha form', function(e) { 93 e.preventDefault(); 94 95 var serializeArray = $(this).serializeArray(); 96 97 for(let i = 0; i < serializeArray.length; i++){ 98 if( serializeArray[i]['name'] == '_sitekey' ){ object_preorder.data['_sitekey'] = serializeArray[i]['value'];} 99 if( serializeArray[i]['name'] == 'g-recaptcha-response' ){ object_preorder.data['g-recaptcha-response'] = serializeArray[i]['value'];} 100 }; 101 102 sentAjax_preorder( object_preorder.data, (data)=>{ 103 104 object_preorder.jQbtn.addClass('disabled').get(0).setAttribute('disabled', 'disabled'); 105 106 $('.preorder-form-wrap').html(` 107 <div class="preorder_success tpl-anketa__right tpl-anketa__posted"> 108 <div class="tpl-anketa-success-note">${shop2.my.preorder_form_success||'СпаÑибо!'}</div> 109 </div> 110 `); 111 112 if( object_preorder.jQbtn.closest('form').length ){ 113 let $favorite_btn = object_preorder.jQbtn.closest('form').find('.gr-favorite-btn'); 114 115 if( $favorite_btn.length && !$favorite_btn.is(":hidden") ){ 116 $favorite_btn.trigger('click'); 117 }; 118 }; 119 }); 120 121 }); 122 123 shop2.on('afterFavoriteAddItem', function(){ 124 if ($('.preorder-form-wrap').length) { 125 $('#shop2-msg').hide(); 126 }; 127 }); 128 129 $(document).on('submit', '.preorder_body', function(e) { 130 e.preventDefault(); 131 var $form = $(this); 132 133 object_preorder.data.email = this.email.value; 134 const _regexEmeil = /^[\w-\.]+@[\w-]+\.[a-z]{2,4}$/i; 135 136 let valid = _regexEmeil.test(object_preorder.data.email); 137 138 if (valid){ 139 $.get( '/-/x-api/v1/public/?method=shop2/addKindEmailNotification', function( data ) { 140 console.log(object_preorder); 141 142 const _regexBody = new RegExp(/<body[^>]*>(.*?)<\/body>/ig); 143 144 let body = data.result.html.match( _regexBody ); 145 146 $form.parent('.preorder-block').find('.block-recaptcha').html( body ); 147 }); 148 }else { 149 150 if( !$form.find('.preorder-email').hasClass('field-error') ) 151 $form 152 .find('.preorder-email') 153 .addClass('field-error') 154 .find('.preorder-email-input .preorder-field-value') 155 .before(`<div class="error-message">ÐевеÑнÑй ÑоÑÐ¼Ð°Ñ Ð°Ð´ÑеÑа ÑлекÑÑонной поÑÑÑ</div>`); 156 } 157 158 }); 159}; 160 161(function(){ 162 if (!!document.querySelector('#product-tabs')) { 163 let gr_active_tab = localStorage.getItem('gr_tab_href'); 164 165 if (gr_active_tab!=null && $(gr_active_tab).length) { 166 let desktopFirst = document.querySelectorAll('.shop-product-data__nav li')[0]; 167 let mobileFirst = document.querySelectorAll('.r-tabs-accordion-title')[0]; 168 let firstTab = document.querySelectorAll('.shop-product-data__desc .desc-area')[0]; 169 170 if (!!desktopFirst && !!mobileFirst) { 171 desktopFirst.classList.remove('r-tabs-state-active'); 172 mobileFirst.classList.remove('r-tabs-state-active'); 173 }; 174 if (!!firstTab) { 175 firstTab.style.display = 'none'; 176 }; 177 178 document.querySelectorAll(gr_active_tab)[0].style.display = 'block'; 179 180 let gr_active_tabs = document.querySelectorAll('[href="'+gr_active_tab+'"]'); 181 for (i = 0; i < gr_active_tabs.length; i++) { 182 gr_active_tabs[i].parentNode.classList.add('r-tabs-state-active'); 183 }; 184 }; 185 }; 186})(); 187 188shop2.search.getParams = function (folder_id, func) { 189 var gr_filter_max_count = shop2.my.gr_filter_max_count; 190 var url; 191 192 shop2.trigger("beforeGetFolderCustomFields"); 193 194 if (folder_id > 0) { 195 url = 196 "/-/shop2-api/?cmd=getFolderCustomFields" + 197 "&hash=" + 198 shop2.apiHash.getFolderCustomFields + 199 "&ver_id=" + 200 shop2.verId + 201 "&folder_id=" + 202 folder_id + 203 "&" + 204 decodeURIComponent(document.location.search).replace(/[^&]*=(&|$)/g,""); 205 206 if (gr_filter_max_count) { 207 url = url + `gr_filter_max_count=${gr_filter_max_count}&`; 208 }; 209 210 $.getJSON(url, function (d, status) { 211 shop2.fire("afterGetFolderCustomFields", func, d, status); 212 shop2.trigger("afterGetFolderCustomFields", d, status); 213 }); 214 }; 215};
216 217shop2.queue.product = function () { 218 219 shop2.product._reload = function (node) { 220 var $node = $(node); 221 var kinds = shop2.product.getNodeData(node, 'kinds', true); 222 var paramName = shop2.product.getNodeData(node, 'name'); 223 var paramValue = shop2.product.getNodeData(node, 'value'); 224 var $form = $node.closest('form'); 225 var form = $form.get(0); 226 var meta; 227 var kind_id; 228 var product_id; 229 var keys = {}; 230 var params = {}; 231 var is_param_select = false; 232 233 window.gr_reloaded_product_node = $node.parents('.shop2-product-item'); 234 window.gr_reloaded_product_index = $node.parents('.shop2-product-item').index(); 235 236 if (kinds && $.type(paramName) !== 'undefined' && $.type(paramValue) !== 'undefined' && form) { 237 meta = $form.find('input[name=meta]').val(); 238 product_id = $form.find('input[name=product_id]').val(); 239 $form.find('[name=submit]').prop('disabled', true); 240 $form.find('select.shop2-cf>option, li.shop2-cf, li.shop2-color-ext-selected, ul.shop2-color-ext-list>li').each(function () { 241 var name = $(this).data('name'); 242 if (name) { 243 keys[name] = true; 244 } 245 }); 246 kind_id = shop2.product.findKindId(product_id, kinds, paramName, paramValue, meta, keys); 247 if (!kind_id) { 248 kind_id = $form.find('[name=kind_id]').val(); 249 is_param_select = true; 250 } 251 // select 252 $form.find('.js-calc-custom-fields.additional-cart-params').each(function () { 253 var ref_code = $(this).attr('name'); 254 params[ref_code] = $(this).find('option:selected').data('item-id'); 255 }); 256 // colore ref 257 $form.find('.js-calc-custom-fields.shop2-color-ext-selected').each(function () { 258 var ref_code = $(this).data('name'); 259 params[ref_code] = $(this).data('item-id'); 260 }); 261 // Selected params 262 if (is_param_select) { 263 shop2.product.getProductListItem(product_id, kind_id, function (d, status) { 264 if (status === 'success') { 265 var body = $.trim(d.data.body); 266 var product_price = $(".product-price", body).html(); 267 var product_actions = $(".shop2-product-actions", body).html(); 268 $form.find('.product-price').html(product_price); 269 $form.find('.shop2-product-actions').html(product_actions); 270 shop2.trigger('afterProductReloaded'); 271 shop2.queue.heights(); 272 } 273 }, params); 274 } else { 275 if (shop2.mode === 'product') { 276 if (shop2.uri) { 277 document.location = shop2.uri + '/product/' + kind_id; 278 } else { 279 document.location = document.location.href.replace(/\/product\/.+/, '/product/' + kind_id); 280 } 281 } else { 282 shop2.product.getProductListItem(product_id, kind_id, function (d, status) { 283 var cont, newCont, body; 284 if (status === 'success') { 285 shop2.trigger('afterProductReloaded'); 286 cont = $node.closest('.shop2-product-item'); 287 cont.hide(); 288 body = $.trim(d.data.body); 289 newCont = $(body).insertBefore(cont); 290 cont.remove(); 291 shop2.queue.heights(); 292 } 293 }, params); 294 } 295 } 296 } 297 }; 298 299 $.on('select.shop2-cf', { 300 change: function () { 301 shop2.product._reload(this); 302 } 303 });
304 305 $.on('li.shop2-cf:not(.active-color, .active-texture)', { 306 click: function () { 307 shop2.product._reload(this); 308 } 309 }); 310 311 $.on('span.shop2-path-show-folders', { 312 click: function (e) { 313 e.preventDefault(); 314 $(this).next().show(); 315 $(this).hide(); 316 } 317 }); 318 319}; 320 321shop2.msg = function(text, obj) { 322 var selector = '#shop2-msg', 323 msg = $(selector), 324 offset = obj.offset(), 325 width = obj.outerWidth(true), 326 height = obj.outerHeight(true); 327 328 if (!msg.get(0)) { 329 msg = $('<div id="shop2-msg">'); 330 $(document.body).append(msg); 331 msg = $(selector); 332 } 333 334 msg.html(text).fadeIn(150); 335 336 var msgWidth = msg.outerWidth(); 337 var msgHeight = msg.outerHeight(); 338 var left = offset.left + width; 339 var top = offset.top + height; 340 341 if (left + msgWidth > $(window).width()) { 342 left = offset.left - msgWidth; 343 } 344 345 msg.css({ 346 left: 50 + '%', 347 top: 50 + '%', 348 'position': 'fixed', 349 'margin-left': msgWidth / 2 * -1, 350 'margin-top': msgHeight / 2 * -1 351 }); 352 353 $.s3throttle('msg', function() { 354 msg.hide(); 355 }, shop2.options.msgTime); 356 357 $(document).on('click', '#shop2-msg', function() { 358 $(this).fadeOut(150); 359 }); 360}; 361 362shop2.queue.question = function() { 363 var cls = '.price-old.question, .cart-total .question'; 364 365 $(document) 366 .on("mouseenter", cls, function () { 367 var $this = $(this), 368 win = $this.next().show(), 369 position = $this.position(), 370 height = win.outerHeight(true); 371 372 win.css({ 373 top: position.top - height - 5, 374 left: position.left, 375 }); 376 377 if (win.offset().left + win.outerWidth() > $(window).width()) { 378 win.css({ 379 left: (win.outerWidth() - win.offset().left) * -1, 380 }); 381 }; 382 }) 383 .on("mouseleave", cls, function () { 384 var $this = $(this), 385 win = $this.next(); 386 387 win.hide(); 388 }); 389}; 390 391shop2.queue.compare = function() { 392 var popup_data; 393 var compare_arrow = '<i><svg class="gr-svg-icon"><use xlink:href="#icon_shop_notify_arr"></use></svg></i>'; 394 if (shop2.my.gr_popup_compare) { 395 popup_data = ' data-remodal-target="compare-preview-popup"'; 396 }; 397 398 let $document = $(document); 399 if ($('html').attr('lang') == 'ru') { 400 var compareBtn = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn"'+popup_data+' target="_blank">к ÑÑавнениÑ'+compare_arrow+'</a>'; 401 var compareBtn2 = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn"'+popup_data+' target="_blank">ÐеÑейÑи к ÑÑавнениÑ'+compare_arrow+'</a>'; 402 } else { 403 var compareBtn = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn"'+popup_data+' target="_blank">Ñompare'+compare_arrow+'</a>'; 404 var compareBtn2 = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn"'+popup_data+' target="_blank">Compare'+compare_arrow+'</a>'; 405 }; 406 407 function update(el, res) { 408 409 $('input[type=checkbox][value=' + el.val() + ']').closest('.product-compare').replaceWith(res.data); 410 $('.product-compare-added a span').html(res.count); 411 $('.gr-compare-btn .gr-compare-btn-amount').html(res.count); 412 413 if (+$('.gr-compare-btn .gr-compare-btn-amount').text() == '0') { 414 $('.gr-compare-btn').removeClass('active'); 415 } else { 416 $('.gr-compare-btn').addClass('active'); 417 }; 418 419 if (!$('.compare-remodal').hasClass('remodal-is-opened')) { 420 if ($('html').attr('lang') == 'ru') { 421 shop2.msg('<span class="go-to-compare-count">'+res.count+'</span>' + 'Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½ ' + compareBtn, $('body')); 422 } else { 423 shop2.msg('<span class="go-to-compare-count">'+res.count+'</span>' + 'Added to ' + compareBtn, $('body')); 424 }; 425 }; 426 427 if (res.panel) { 428 $('#shop2-panel').replaceWith(res.panel); 429 }; 430 431 } 432 433 $document.on('click', '.product-compare input:checkbox', function() {
434 let $this = $(this), 435 action = $this.attr('checked') ? 'del' : 'add'; 436 437 shop2.compare.action(action, $this.val(), function(res, status) { 438 if (status == 'success') { 439 440 441 if (res.errstr) { 442 if (!$('.compare-remodal').hasClass('remodal-is-opened')) { 443 shop2.msg(res.errstr + '<div class="go-to-compare-error">'+compareBtn2+'</div>', $('body')); 444 } 445 $this.prop('checked', false); 446 } else { 447 update($this, res); 448 449 if (action == 'del' && !$('.compare-remodal').hasClass('remodal-is-opened')) { 450 if ($('html').attr('lang') == 'ru') { 451 shop2.msg('Ð¢Ð¾Ð²Ð°Ñ Ñдален из ÑÑавнениÑ', $('body')); 452 } else { 453 shop2.msg('Product removed from comparison', $('body')); 454 }; 455 } 456 } 457 458 } 459 }); 460 }); 461}; 462 463shop2.product.getProductListItem = function(product_id, kind_id, func) { 464 var gr_images_size = $('.product-list').data('images-size'); 465 var gr_images_view = $(".product-list").data("images-view"); 466 var gr_mode_catalog = $(".product-list").data("mode-catalog"); 467 var url = "/-/shop2-api/?cmd=getProductListItem&hash=" + shop2.apiHash.getProductListItem + "&ver_id=" + shop2.verId + "&gr_images_view=" + gr_images_view + "&gr_images_size=" + gr_images_size + "&gr_mode_catalog=" + gr_mode_catalog; 468 469 shop2.trigger('beforeGetProductListItem', kind_id); 470 471 $.post( 472 url, { 473 product_id: product_id, 474 kind_id: kind_id 475 }, 476 function(d, status) { 477 shop2.fire('afterGetProductListItem', func, d, status); 478 shop2.trigger('afterGetProductListItem', d, status); 479 } 480 ); 481}; 482 483shop2.queue.lazyLoad = function() { 484 var $document = $(document), 485 $window = $(window), 486 blocked = false, 487 products = $('.product-list'); 488 489 function path(url, param, value) { 490 return url + (~url.indexOf("?") ? "&" : "?") + param + "=" + value; 491 } 492 493 if (shop2.my.lazy_load_subpages && products.get(0)) { 494 $document.on('click', '.lazy-pagelist-btn', function(e){ 495 496 e.preventDefault(); 497 498 var pagelist = $('.shop-pagelist'); 499 var next = pagelist.find('.active-num').next().find('a'); 500 501 if (!next.length) { 502 return; 503 } 504 505 if (!blocked && next.get(0)) { 506 blocked = true; 507 508 $.get(path(next.attr('href'), 'products_only', 1), function(data) { 509 510 var productsHtml = $(data).filter('.product-list').html(); 511 var $lazyLoad = $(data).filter('.lazy-pagelist'); 512 513 $('.lazy-pagelist').remove(); 514 515 $('.product-list').append(productsHtml); 516 $('.product-list').after($lazyLoad); 517 518 shop2.trigger('afterProductsLazyLoaded'); 519 520 pagelist = $('.shop-pagelist'); 521 522 pagelist.find('a').each(function() { 523 var $this = $(this), 524 href = $this.attr('href'); 525 $this.attr('href', href.replace(/[&|\?]*products_only=[^&]/, "")); 526 }); 527 528 blocked = false; 529 }); 530 } 531 }); 532 } 533}; 534 535shop2.queue.addToCart = function() { 536 $(document).on('click', '.shop-product-btn', function(e) { 537 538 var $this = $(this), 539 $form = $this.closest('form'), 540 form = $form.get(0), 541 adds = $form.find('.additional-cart-params'), 542 len = adds.length, 543 i, el, 544 a4 = form.amount.value, 545 kind_id = form.kind_id.value; 546 547 e.preventDefault(); 548 549 if (len) { 550 a4 = { 551 amount: a4 552 }; 553 554 for (i = 0; i < len; i += 1) { 555 el = adds[i]; 556 if (el.value) { 557 a4[el.name] = el.value; 558 } 559 } 560 } 561 562 shop2.cart.add(kind_id, a4, function(d) { 563 $('#shop2-cart-preview').replaceWith(d.data); 564 565 var totalCartAmount = +$(d.data).find('.gr-cart-total-amount').text(); 566 var totalCartSum = $(d.data).find('.gr-cart-total-sum').data('total-price'); 567 568 if (totalCartAmount>0) { 569 $('.gr-cart-popup-btn').removeClass('pointer_events_none'); 570 $('.gr-cart-total-amount').text(totalCartAmount); 571 $('.gr-cart-total-sum ins').text(totalCartSum); 572 } else{ 573 $('.gr-cart-popup-btn').addClass('pointer_events_none'); 574 $('.gr-cart-total-amount').text('0'); 575 $('.gr-cart-total-sum ins').text('0'); 576 }; 577 578 if (d.errstr) { 579 shop2.msg(d.errstr, $this); 580 } else { 581 var $text = window._s3Lang.JS_SHOP2_ADD_CART_WITH_LINK; 582 var $text = $text.replace("</a>", "<i><svg class='gr-svg-icon'><use xlink:href='#icon_shop_notify_arr'></use></svg></i></a>"); 583 584 shop2.msg($text.replace("%s", shop2.uri + "/cart"), $this); 585 } 586 587 if (d.panel) { 588 $('#shop2-panel').replaceWith(d.panel); 589 }; 590 }); 591 }); 592}; 593 594shop2.filter.sort = function(name, elem) { 595 var re = new RegExp(this.escape('s[sort_by]') + '=([^&]*)'), 596 params = this.str.match(re), 597 desc = name + ' desc', 598 asc = name + ' asc', 599 isDesc = (elem.is('.sort-param-desc')); 600 601 602 params = (params && params.length > 1) ? params[1] : ""; 603 604 params = (isDesc) ? desc : asc; 605 606 this.remove('s[sort_by]'); 607 this.add('s[sort_by]', params); 608 return this; 609};
610 611shop2.queue.sort = function() { 612 var wrap = $('.sorting'); 613 614 wrap.find('.sort-param').on('click', function(e) { 615 var $this = $(this), 616 name = $this.data('name'); 617 618 e.preventDefault(); 619 shop2.filter.sort(name, $this); 620 shop2.filter.go(); 621 }); 622 623 wrap.find('.sort-reset').on('click', function(e) { 624 e.preventDefault(); 625 shop2.filter.remove('s[sort_by]'); 626 shop2.filter.go(); 627 }); 628}; 629 630shop2.queue.colorPopup = function() { 631 var handle; 632 633 $(document).on('click', '.shop2-color-ext-list li', function() { 634 var caption = $(this); 635 var wrap = caption.closest('.shop2-color-ext-popup'); 636 var ul = wrap.find('.shop2-color-ext-list'); 637 var offset = caption.offset(); 638 var $this = $(this); 639 var data = $this.data(); 640 var input = $this.parent().find('input.additional-cart-params'); 641 var isSelected = $this.is('.shop2-color-ext-selected'); 642 643 colors = ul.children('li'); 644 645 if (typeof data.kinds !== 'undefined' || input.length) { 646 $this.addClass('shop2-color-ext-selected').siblings().removeClass('shop2-color-ext-selected'); 647 648 if (input.length) { 649 input.val(data.value); 650 } else { 651 if (!isSelected) { 652 shop2.product._reload(this); 653 } 654 } 655 656 } else { 657 var index = $this.index(); 658 659 colors.eq(index).toggleClass('shop2-color-ext-selected'); 660 shop2.filter.toggle(data.name, data.value); 661 shop2.filter.count(); 662 663 var offsetTop = $(this).position().top; 664 665 $('.result-popup').css({ 666 'top': offsetTop, 667 'visibility': 'visible', 668 'opacity': '1', 669 'display': 'block' 670 }); 671 672 } 673 return false; 674 }); 675}; 676 677shop2.queue.coupon = function () { 678 shop2.on('afterCartAddCoupon, afterCartRemoveCoupon', function () { 679 document.location.reload(); 680 }); 681 682 $('.coupon-btn').on('click', function (e) { 683 var coupon = $('#coupon'), 684 code = coupon.val(); 685 686 e.preventDefault(); 687 688 if (code) { 689 shop2.cart.addCoupon(code); 690 } else { 691 shop2.msg('ÐведиÑе код кÑпона', $(this)); 692 } 693 694 }); 695 696 697 $('.coupon-delete').on('click', function (e) { 698 var $this = $(this), 699 code = $this.data('code'); 700 701 e.preventDefault(); 702 703 if (code) { 704 shop2.cart.removeCoupon(code); 705 } 706 }); 707}; 708 709shop2.cart.applyBonusPoint = function (bonus_points, func) { 710 711 shop2.trigger('beforeCartApplyBonus'); 712 713 $.getJSON( 714 '/-/x-api/v1/public/?method=cart/applyBonusPoints', { 715 param: { 716 hash: shop2.hash.cart, 717 bonus_points: bonus_points 718 } 719 }, 720 function (d, status) { 721 shop2.fire('afterCartApplyBonusPoints', func, d, status); 722 shop2.trigger('afterCartApplyBonusPoints', d, status); 723 } 724 ); 725 726 return false; 727}; 728 729shop2.cart.removeBonusPoint = function (func) { 730 731 shop2.trigger('beforeCartRemoveCartBonusPoints'); 732 733 $.getJSON( 734 '/-/x-api/v1/public/?method=cart/RemoveBonusPoints', { 735 param: { 736 hash: shop2.hash.cart 737 } 738 }, 739 function (d, status) { 740 shop2.fire('afterCartRemoveCartBonusPoints', func, d, status); 741 shop2.trigger('afterCartRemoveCartBonusPoints', d, status); 742 } 743 ); 744}; 745 746shop2.queue.bonus = function () { 747 748 shop2.on('afterCartApplyBonusPoints, afterCartRemoveCartBonusPoints', function () { 749 document.location.reload(); 750 }); 751 752 $('.bonus-apply').on('click', function (e) { 753 var bonus = $('#bonus-points'), 754 points = Number(bonus.val()), 755 bonus_user = Number($('.bonus-amount').data('bonus-amount')); 756 757 switch (true) { 758 case points == "": 759 760 e.preventDefault(); 761 762 shop2.msg('ÐведиÑе знаÑение', $(this)); 763 764 break; 765 766 case points > bonus_user: 767 768 shop2.msg('Ðам доÑÑÑпно ÑолÑко '+bonus_user+' бонÑÑов', $(this)); 769 770 break; 771 772 case bonus_user >= points: 773 774 shop2.cart.applyBonusPoint(points); 775 776 break; 777 }; 778 }); 779 780 $('.bonus-delete').on('click', function (e) { 781 shop2.cart.removeBonusPoint(); 782 }); 783 784 $('.cart-bonuses__title label').on('click', function(e){ 785 e.preventDefault(); 786 var $check = $(':checkbox', this); 787 $check.prop('checked', !$check.prop('checked')); 788 789 $('.cart-bonuses__container').toggleClass('show_bonuses'); 790 $('.accrual_or_using_js').toggle(); 791 792 if (!$check.prop('checked') && $('.cart-total__item.bonus_item').length) { 793 shop2.cart.removeBonusPoint(); 794 }; 795 }); 796 797 $.fn.inputFilter = function (inputFilter) { 798 return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function () { 799 if (inputFilter(this.value)) { 800 this.oldValue = this.value; 801 this.oldSelectionStart = this.selectionStart; 802 this.oldSelectionEnd = this.selectionEnd; 803 } else if (this.hasOwnProperty("oldValue")) { 804 this.value = this.oldValue; 805 this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd); 806 } 807 }); 808 }; 809 810 $("#bonus-points").inputFilter(function (value) { 811 return /^\d*$/.test(value); 812 }); 813}; 814 815(function($, myObject) { 816 817 var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), 818 isApple = /iPod|iPad|iPhone/i.test(navigator.userAgent), 819 $doc = $(document), 820 $win = $(window), 821 $html = $(document.documentElement); 822 823 var shop2_gr = { 824 queue: {}, 825 methods : {}, 826 init: function() { 827 828 $(function() { 829 830 let queue = shop2_gr.queue; 831 832 if (isMobile) $html.addClass('mobile'); 833 834 for (key in queue) { 835 let f = queue[key]; 836 if (typeof f === 'function') { 837 setTimeout(function(){ 838 f(); 839 }, 5); 840 }; 841 } 842 843 }); 844 845 } 846 }; 847 848 shop2_gr.queue = { 849 ajaxRequestsComplete: function() { 850 851 $.ajaxSetup({ 852 complete: function() { 853 setTimeout(function(){ 854 shop2_gr.methods.changeFlagsColor(); 855 });
856 } 857 }); 858 859 shop2.on('afterProductReloaded', function(){ 860 861 setTimeout(function(){ 862 shop2_gr.methods.viewLots(); 863 shop2_gr.methods.amountInit(); 864 shop2_gr.methods.changeFlagsColor(); 865 866 $('.shop2-product-item .buy-one-click').attr('data-api-url', $('.product-list').data('popup-form')); 867 $('.shop2-product-item .buy-one-click.product_info_form').attr('data-api-url', $('.product-list').data('info-popup-form')); 868 869 $('.product-list .gr_images_lazy_load').each(function(){ 870 $(this).attr('src', $(this).attr('data-src')); 871 }); 872 873 if (!isMobile) { 874 $('.quick-view-trigger').elemToolTip({ 875 text: 'ÐÑÑÑÑÑй пÑоÑмоÑÑ', 876 margin: 12 877 }); 878 }; 879 880 $('#shop2-tooltip').hide(); 881 882 $('.shop2-product-item').eq(gr_reloaded_product_index).addClass('active'); 883 884 setTimeout(function () { 885 var hideText = $('html').attr('lang') == 'ru' ? 'СвеÑнÑÑÑ' : 'Hide'; 886 887 $('.shop2-product-item.active .gr-options-more__btn').addClass('active'); 888 $('.shop2-product-item.active .gr-options-more__btn ins').text(hideText); 889 $('.shop2-product-item.active .gr-options-container').show(); 890 $('.shop2-product-item').removeClass('active'); 891 892 $('.product-list.thumbs .product-price').matchHeight('remove'); 893 $('.product-list.thumbs .product-price').matchHeight(); 894 }); 895 }); 896 }); 897 898 shop2.on('afterProductsLazyLoaded', function(){ 899 $('.product-list .gr_images_lazy_load').each(function(){ 900 $(this).attr('src', $(this).attr('data-src')); 901 }); 902 903 $('.quick-view-trigger').elemToolTip({ 904 text: 'ÐÑÑÑÑÑй пÑоÑмоÑÑ', 905 margin: 12 906 }); 907 908 //$('.product-list.thumbs .product-item__bottom-left').matchHeight('remove'); 909 $('.product-list.thumbs .product-item__bottom-right').matchHeight('remove'); 910 $('.product-list.thumbs .product-price').matchHeight('remove'); 911 //$('.product-list.thumbs .product-item__bottom').matchHeight('remove'); 912 913 $('.product-list.thumbs .product-item__bottom-right').matchHeight(); 914 $('.product-list.thumbs .product-price').matchHeight(); 915 //$('.product-list.thumbs .product-item__bottom-left').matchHeight(); 916 //$('.product-list.thumbs .product-item__bottom').matchHeight(); 917 918 shop2_gr.methods.viewLots(); 919 shop2_gr.methods.amountInit(); 920 }); 921 922 }, /*Ðбновление ÑкÑипÑов пÑи аÑкÑ-запÑоÑÐ°Ñ */ 923 924 /*ajaxCompare: function(){ 925 if (shop2.mode=="") { 926 var url = document.location.origin; 927 $.ajax({
928 url: url, 929 success: function(data){ 930 var compare_btn = $(data).find('.gr-compare-btn'); 931 var cart_btn = $(data).find('.gr-cart-popup-btn'); 932 $('.gr-compare-btn').replaceWith(compare_btn); 933 $('.gr-cart-popup-btn').replaceWith(cart_btn); 934 } 935 }); 936 } 937 },*/ /*СÑавнение на ÑÑÑаниÑÐ°Ñ "не магазина"*/ 938 939 checkboxes: function() { 940 $('#orderForm input[name="personal_data"]').parents('label').next('a').appendTo($('#orderForm input[name="personal_data"]').parents('label')); 941 942 $('.shop2-order-form input[type="checkbox"], .shop2-order-form input[type="radio"], .comments-block .tpl-field.checkbox input, .tpl-field-reg input, .gr-authorization-checkbox, .shop2-order-options.shop2-payment-options .payment_methods-column input[type="radio"], #orderForm input[name="personal_data"]').mgStyler(); 943 944 $('#orderForm .mg-styler-label--checkbox a').on('click', function(e){ 945 var $label = $(this).parent(); 946 var $input = $(this).parents('label').find('input'); 947 var href = $(this).attr('href'); 948 window.open(href, '_blank'); 949 950 if ($('.mg-styler-label--checkbox input').is(':checked')) { 951 setTimeout(function(){ 952 $input.prop('checked', true); 953 $label.addClass('checked'); 954 }, 10); 955 } else { 956 setTimeout(function(){ 957 $input.prop('checked', false); 958 $label.removeClass('checked'); 959 }, 10); 960 } 961 }); 962 963 $(document).on('click', '.shop2-edost-variant > label', function(){ 964 if ($('.shop2-edost-variant > label > .shop2-edost-control input[type="radio"]:checked')) { 965 $('.shop2-edost-variant > label > .shop2-edost-control').removeClass("active"); 966 $('.shop2-edost-variant > label > .shop2-edost-control input[type="radio"]:checked').parent().addClass('active'); 967 } 968 969 if ($('.shop2-edost-office > label > .shop2-edost-control input[type="radio"]:checked')) { 970 $('.shop2-edost-office > label > .shop2-edost-control').removeClass("active"); 971 $('.shop2-edost-office > label > .shop2-edost-control input[type="radio"]:checked').parent().addClass('active'); 972 } 973 }); 974 975 $(document).on("click", ".shop2-edost-office > label", function(){ 976 if ($('.shop2-edost-office > label > .shop2-edost-control input[type="radio"]:checked')) { 977 $('.shop2-edost-office > label > .shop2-edost-control').removeClass("active"); 978 $('.shop2-edost-office > label > .shop2-edost-control input[type="radio"]:checked').parent().addClass('active'); 979 } 980 }); 981 }, /*ЧекбокÑÑ*/ 982 983 facetSelect: function() { 984 $(document).on('click', '.shop-search-color-select li', function(){ 985 var $input = $(this).find('input'); 986 var value = $(this).data('value'); 987 988 if ($(this).hasClass('shop2-color-ext-selected')) { 989 $input.val(""); 990 $(this).removeClass('shop2-color-ext-selected'); 991 } else { 992 $(this).addClass('shop2-color-ext-selected'); 993 $input.val(value); 994 } 995 996 if (shop2.facets.enabled) { 997 var url = '/-/shop2-api/?cmd=getSearchMatches&hash=' + 998 shop2.apiHash.getSearchMatches + 999 '&ver_id=' + shop2.verId + '&', 1000 fullUrl = url + $(shop2.facets.search.wrapper).serialize(); 1001 1002 shop2.facets.getDataSearch(fullUrl); 1003 }; 1004 }); 1005 1006 $(document).on('click', '.type-checkbox [data-name]', function(){ 1007 if (shop2.facets.enabled) { 1008 var url = '/-/shop2-api/?cmd=getSearchMatches&hash=' + 1009 shop2.apiHash.getSearchMatches + 1010 '&ver_id=' + shop2.verId + '&', 1011 fullUrl = url + $(shop2.facets.search.wrapper).serialize(); 1012 1013 shop2.facets.getDataSearch(fullUrl); 1014 }; 1015 }); 1016 }, /*ÐÐ¾Ð¿Ð¿Ð¾Ð»Ñ Ð² ÑаÑеÑном поиÑке*/ 1017 1018 recentBlock: function() { 1019 1020 var sliderAutoplay = $('.recent-block__items').data("autoplay"); 1021 var respSettings = { 1022 320: {controls: true,items: 1,gutter: 8,disable: true}, 1023 740: {controls: true,items: 2,gutter: 16,disable: true}, 1024 1024: {controls: true,items: 2,gutter: 20,disable: false}, 1025 1261: {controls: true,items: 3,gutter: 20,disable: false}, 1026 1341: {controls: true,items: 3,gutter: 20,disable: false} 1027 }; 1028 1029 if ($('.recent-block__items').length>0) { 1030 var recentSlider = tns({ 1031 loop: true, 1032 container: '.recent-block__items', 1033 slideBy: 1, 1034 autoplayHoverPause: true, 1035 mode: "carousel", 1036 axis: "horizontal", 1037 autoplay: sliderAutoplay, 1038 autoplayButtonOutput: false, 1039 mouseDrag: true, 1040 center: false, 1041 autoWidth: false, 1042 nav: false, 1043 navPosition: "bottom", 1044 controlsText: shop2_gr.settings.sliderControls, 1045 preventActionWhenRunning: false, 1046 responsive: respSettings 1047 }); 1048 }; 1049 1050 // shop2_gr.methods.arrowsPosition('.recent-block__items', '.gr-recent-image'); 1051 1052 }, /*Ðедавно пÑоÑмоÑÑеннÑе ÑоваÑÑ*/ 1053 1054 sortingPanel : function() { 1055 1056 $('.shop-view').on('click', '.shop-view__btn', function(){ 1057 $(this).parents('.shop-view__inner').toggleClass('active'); 1058 }); 1059 1060 $(document).on('click', function(e){
1061 if (!$(e.target).closest('.shop-view .shop-view__btn').length) { 1062 $('.shop-view .shop-view__inner').removeClass('active'); 1063 }; 1064 }); 1065 1066 /*$(document).on('click', '.sorting-button', function(){ 1067 $('.sorting-block').addClass('active'); 1068 }); 1069 1070 $(document).on('click', '.sorting-block__title', function(){ 1071 $('.sorting-block').removeClass('active'); 1072 });*/ 1073 1074 $('.sorting-block__body').on('click', function(){ 1075 $(this).next().stop().slideToggle(250); 1076 $(this).parent().toggleClass('active'); 1077 }); 1078 1079 shop2_gr.methods.viewLots(); 1080 1081 }, /*СоÑÑиÑовка и видÑ*/ 1082 1083 searchBlock: function() { 1084 1085 /*$(document).on('click', '.search-form .row-title', function(){ 1086 $(this).toggleClass('active'); 1087 $(this).next().slideToggle(250); 1088 });*/ 1089 1090 function searchMoreFields() { 1091 var hideText = $('html').attr('lang') == 'ru' ? 'СвеÑнÑÑÑ' : 'Hide'; 1092 var currentText = $('html').attr('lang') == 'ru' ? shop2.my.gr_filter_select_btn || 'ÐоказаÑÑ ÐµÑÑ' : shop2.my.gr_filter_select_btn || 'Show more'; 1093 1094 $('.search-rows__row').each(function() { 1095 var $this = $(this); 1096 var $btn = $this.find('.gr-filter-more__btn'); 1097 1098 $btn.find('.gr-filter-more__text').text(currentText); 1099 1100 $btn.off('click').on('click', function(){ 1101 var $hiddenCkeckbox = $this.find('ul li:hidden'); 1102 1103 $hiddenCkeckbox.addClass('hidden_item'); 1104 1105 if ($this.find('.hidden_item').hasClass('active')) { 1106 $btn.find('.gr-filter-more__text').text(currentText); 1107 $this.find('.hidden_item').removeClass('active'); 1108 } else { 1109 $btn.find('.gr-filter-more__text').text(hideText); 1110 $this.find('.hidden_item').addClass('active'); 1111 }; 1112 1113 setTimeout(function(){ 1114 $('.search-rows__row').matchHeight(); 1115 }); 1116 }); 1117 }); 1118 }; 1119 1120 searchMoreFields(); 1121 1122 shop2.on('afterGetFolderCustomFields', function(){ 1123 searchMoreFields(); 1124 1125 if (shop2.facets.enabled) { 1126 var url = '/-/shop2-api/?cmd=getSearchMatches&hash=' + 1127 shop2.apiHash.getSearchMatches + 1128 '&ver_id=' + shop2.verId + '&', 1129 fullUrl = url + $(shop2.facets.search.wrapper).serialize(); 1130 1131 shop2.facets.getDataSearch(fullUrl); 1132 }; 1133 }); 1134 1135 $(document).on('opening', '.remodal_search', function () { 1136 $('.search-container-inner-wr').prependTo('.search-popup-wrap'); 1137 }); 1138 1139 $(document).on('closing', '.remodal_search', function () { 1140 $('.search-container-inner-wr').prependTo('.search-container-inner'); 1141 }); 1142 1143 $('.search-mobile-btn').on('click', function(){ 1144 $('.search-container').addClass('active'); 1145 1146 }); 1147 1148 $('.search-container-inner .close-btn-panel').on('click', function(){ 1149 $('.search-container').removeClass('active'); 1150 }); 1151 1152 }, /*ÐоиÑк*/ 1153 1154 loginBlock: function(){ 1155 $(document).on('opening', '.remodal_login', function () { 1156 $('.login-container-inner-wr').prependTo('.login-popup-wrap'); 1157 }); 1158 1159 $(document).on('closing', '.remodal_login', function () { 1160 $('.login-container-inner-wr').prependTo('.login-container-inner'); 1161 }); 1162 1163 $('.login-mobile-btn').on('click', function(){ 1164 $('.login-container').addClass('active'); 1165 1166 }); 1167 1168 $('.login-container-inner .close-btn-panel').on('click', function(){ 1169 $('.login-container').removeClass('active'); 1170 }); 1171 }, 1172 1173 actionsBlock: function() { 1174 var actionEventName = 'mouseenter'; 1175 if (isMobile) { 1176 actionEventName = 'click'; 1177 }; 1178 $(document).on(actionEventName, '.shop2-product-actions dt:not(.promo-action)', function(){ 1179 $('.shop2-product-actions dt').removeClass('dt_hover'); 1180 $('.shop2-product-actions dd').css('left', 'auto'); 1181 1182 if (!isMobile) { 1183 $(this).addClass('dt_hover'); 1184 }; 1185 1186 $(this).next().css('left', $(this).position().left); 1187 $(this).next().css('top', $(this).position().top - $(this).next().outerHeight()); 1188 1189 var nextLeft = $(this).next().offset().left; 1190 var nextWidth = $(this).next().outerWidth(); 1191 var offsetSum = nextLeft + nextWidth; 1192 var winWidth = $(window).width(); 1193 1194 if ((offsetSum) > winWidth) { 1195 $(this).next().css('left', $(this).position().left - (offsetSum - winWidth)) 1196 } 1197 }); 1198 1199 $(document).on('mouseleave', '.shop2-product-actions dl', function(){ 1200 $('.shop2-product-actions dt').removeClass('dt_hover'); 1201 $('.shop2-product-actions dd').css('left', 'auto'); 1202 }); 1203 1204 $(document).off('click.getPromoLink').off('click.promoPagelist'); 1205 1206 var gr_promo_info = {}; 1207 1208 $(document).on('click', '.get-promo-link', function (e) { 1209 e.preventDefault(); 1210 var ver_id = $(this).data('ver-id'), 1211 cmd = $(this).data('cmd'), 1212 hash = shop2.apiHash.getPromoProducts, 1213 is_main = $(this).data('is-main'), 1214 kind_id = $(this).data('kind-id'), 1215 discount_id = $(this).data('discount-id'); 1216 1217 gr_promo_title = $(this).text(), 1218 gr_promo_desc = $(this).parents('.promo-action').find('.promo-action__text').html(); 1219 1220 var gr_images_size = $('.product-list').data('images-size'); 1221 var gr_images_view = $(".product-list").data("images-view"); 1222 1223 var url = '/-/shop2-api/?ver_id=' + ver_id + '&cmd=' + cmd + '&hash=' + hash + '&kind_id=' + kind_id + '&discount_id=' + discount_id + '&is_main=' + is_main; 1224 1225 if (gr_images_view){ 1226 url += "&gr_images_view=" + gr_images_view; 1227 }; 1228 1229 if (gr_images_size){ 1230 url += "&gr_images_size=" + gr_images_size; 1231 }; 1232 1233 1234 $.ajax({
1235 url: url, 1236 type: 'POST', 1237 dataType: 'json', 1238 data: {}, 1239 success: function (res) { 1240 shop2.alert(res.data, 'ÐакÑÑÑÑ', 'promo-products-list'); 1241 1242 setTimeout(function () { 1243 $('.promo-header__title').html(gr_promo_title); 1244 if (!gr_promo_desc) { 1245 $('.promo-header__desc').hide(); 1246 }; 1247 $('.promo-header__desc').html(gr_promo_desc); 1248 1249 if (!$('.promo-products-list .shop-pagelist').length) { 1250 $('.promo-products-list .product-list.list .product-item:last-child').css('border-bottom', 'none'); 1251 }; 1252 1253 $('.promo-products-list').click().addClass('custom-scroll scroll-width-thin scroll'); 1254 $('.promo-products-list .product-item').each(function() { 1255 var $flags = $(this).find('.product-flags'); 1256 var $flagsContainer = $(this).find('.product-item__bottom-left'); 1257 1258 $flags.prependTo($flagsContainer); 1259 }); 1260 1261 $('.product-list .gr_images_lazy_load').each(function () { 1262 $(this).attr('src', $(this).attr('data-src')); 1263 }); 1264 1265 shop2_gr.methods.amountInit(); 1266 }, 100); 1267 } 1268 }); 1269 1270 return gr_promo_info = { 1271 gr_promo_title: gr_promo_title, 1272 gr_promo_desc: gr_promo_desc 1273 } 1274 }); 1275 1276 $(document).on('click', '.promo-products-list li', function (e) { 1277 e.preventDefault(); 1278 var url = $(this).find('a').attr('href'); 1279 1280 $.ajax({
1281 url: url, 1282 type: 'POST', 1283 dataType: 'json', 1284 data: {}, 1285 success: function (res) { 1286 shop2.alert(res.data, 'ÐакÑÑÑÑ', 'promo-products-list'); 1287 1288 setTimeout(function () { 1289 $('.promo-header__title').html(gr_promo_info.gr_promo_title); 1290 if (!gr_promo_info.gr_promo_desc) { 1291 $('.promo-header__desc').hide(); 1292 }; 1293 $('.promo-header__desc').html(gr_promo_info.gr_promo_desc); 1294 1295 $('.promo-products-list').click().addClass('custom-scroll scroll-width-thin scroll'); 1296 $('.promo-products-list .product-item').each(function() { 1297 var $flags = $(this).find('.product-flags'); 1298 var $flagsContainer = $(this).find('.product-item__bottom-left'); 1299 1300 $flags.prependTo($flagsContainer); 1301 }); 1302 1303 $('.product-list .gr_images_lazy_load').each(function () { 1304 $(this).attr('src', $(this).attr('data-src')); 1305 }); 1306 shop2_gr.methods.amountInit(); 1307 }, 100); 1308 } 1309 }); 1310 }); 1311 1312 }, /*ÐодаÑок/ÐкÑиÑ*/ 1313 1314 filterBlock: function() { 1315 1316 /*$('.shop2-filter__title').on('click', function(){ 1317 $(this).toggleClass('active'); 1318 $(this).next().slideToggle(250); 1319 });*/ 1320 1321 $('.shop2-filter__item').each(function() { 1322 var $this = $(this); 1323 var $btn = $this.find('.gr-filter-more__btn'); 1324 var hideText = $('html').attr('lang') == 'ru' ? 'СвеÑнÑÑÑ' : 'Hide'; 1325 1326 $btn.on('click', function(){ 1327 var $hiddenCkeckbox = $this.find('.shop2-filter__checkbox:hidden'); 1328 var $hiddenColor = $this.find('.shop2-color-ext-list__item:hidden'); 1329 var currentText = $btn.data('text'); 1330 1331 $hiddenCkeckbox.addClass('hidden_item'); 1332 $hiddenColor.addClass('hidden_item'); 1333 1334 if ($this.find('.hidden_item').hasClass('active')) { 1335 $btn.find('.gr-filter-more__text').text(currentText); 1336 $this.find('.hidden_item').removeClass('active'); 1337 } else { 1338 $btn.find('.gr-filter-more__text').text(hideText); 1339 $this.find('.hidden_item').addClass('active'); 1340 }; 1341 }); 1342 }); 1343 1344 }, /*ФилÑÑÑ*/ 1345 1346 productsBlock: function() { 1347 1348 $(document).on('click', '.gr-options-more__btn', function(){ 1349 var $parent = $(this).parents('.gr-product-options'); 1350 var $params = $parent.find('.gr-options-container'); 1351 var currentText = $(this).data('text'); 1352 var hideText = $('html').attr('lang') == 'ru' ? 'СвеÑнÑÑÑ' : 'Hide'; 1353 1354 if ($(this).hasClass('active')) { 1355 $(this).removeClass('active'); 1356 $(this).find('ins').text(currentText); 1357 } else { 1358 $(this).addClass('active'); 1359 $(this).find('ins').text(hideText); 1360 }; 1361 1362 $params.stop().slideToggle(250); 1363 }); 1364 1365 $('.shop2-color-ext-select .shop2-color-ext-options').on('click', function() { 1366 if ($(this).closest('.shop2-color-ext-select').hasClass('active')) { 1367 $(this).closest('.shop2-color-ext-select').removeClass('active'); 1368 } else { 1369 $(this).closest('.shop2-color-ext-select').addClass('active'); 1370 } 1371 }); 1372 1373 $('#shop2-color-ext-select').on('click', function() { 1374 $('.shop2-color-ext-select').removeClass('active'); 1375 }); 1376 1377 $(document).on('click', '.shop2-color-ext-select', function() { 1378 if ($(this).parents('.product-item').length>0) { 1379 $('#shop2-color-ext-select').addClass('product_item_color'); 1380 } 1381 1382 if ($(this).parents('.shop2-product').length>0) { 1383 $('#shop2-color-ext-select').addClass('shop_product_color'); 1384 } 1385 }); 1386 1387 $(document).on('click', '#shop2-color-ext-select', function() { 1388 $(this).removeClass('product_item_color'); 1389 $(this).removeClass('shop_product_color'); 1390 }); 1391 1392 $(document).on('click', function(e){ 1393 if (!$(e.target).closest('#shop2-color-ext-select').length) { 1394 $('#shop2-color-ext-select').removeClass('product_item_color'); 1395 $('#shop2-color-ext-select').removeClass('shop_product_color'); 1396 } 1397 }); 1398 1399 }, /*ТоваÑ*/ 1400 1401 cardPage: function(){ 1402 1403 if ($('.order-info-block').length) { 1404 if (!isMobile) { 1405 $('.order-info-block__title').hover(function(){ 1406 $(this).next().show(); 1407 $('.order-info-block__popup').removeClass('right_popup'); 1408 1409 if ($(document).outerWidth() > $(window).outerWidth()) { 1410 $(this).next().addClass('right_popup'); 1411 }; 1412 }, function(e){
1413 $(this).next().hide(); 1414 $('.order-info-block__popup').removeClass('right_popup'); 1415 }); 1416 } else { 1417 $('.order-info-block__title').on('click', function(){ 1418 $('.order-info-block__popup').hide(); 1419 $('.order-info-block__popup').removeClass('right_popup'); 1420 $(this).next().show(); 1421 1422 if ($(document).outerWidth() > $(window).outerWidth()) { 1423 $(this).next().addClass('right_popup'); 1424 }; 1425 }); 1426 1427 $('.order-info-block__close').on('click', function(){ 1428 $('.order-info-block__popup').hide(); 1429 $('.order-info-block__popup').removeClass('right_popup'); 1430 }); 1431 }; 1432 }; 1433 1434 var $cardHiddenOptions = $('.card-page .shop2-product .gr-product-options .option-item:hidden'); 1435 1436 if ($cardHiddenOptions.length>0) { 1437 $('.shop2-product .gr-product-options-more').addClass('show_more_btn'); 1438 }; 1439 1440 $(document).on('click', '.card-page .shop2-product .gr-product-options-more__btn', function(){ 1441 var currentText = $(this).data('text'); 1442 var hideText = $('html').attr('lang') == 'ru' ? 'СвеÑнÑÑÑ' : 'Hide'; 1443 1444 if ($(this).hasClass('active')) { 1445 $(this).removeClass('active'); 1446 $(this).find('ins').text(currentText); 1447 } else { 1448 $(this).addClass('active'); 1449 $(this).find('ins').text(hideText); 1450 }; 1451 1452 $cardHiddenOptions.stop().slideToggle(250); 1453 }); 1454 1455 1456 //if ($('.card-slider__thumbs-slider').length>0) { 1457 1458 if ($('.card-slider__items-slider').length>0) { 1459 var vslider = tns({ 1460 container: '.card-slider__items-slider', 1461 slideBy: 1, 1462 mode: 'gallery', 1463 axis: 'horizontal', 1464 autoplay: false, 1465 mouseDrag: true, 1466 center: true, 1467 autoWidth: false, 1468 loop: false, 1469 rewind: true, 1470 preventActionWhenRunning: false, 1471 controls: false, 1472 nav: true, 1473 lazyload: true, 1474 swipeAngle: 50, 1475 navPosition: 'bottom', 1476 controlsText: shop2_gr.settings.sliderControls 1477 /*responsive: { 1478 320: { 1479 nav: true 1480 }, 1481 768: { 1482 nav: true 1483 } 1484 }*/ 1485 }); 1486 1487 /*var small_slider = tns({ 1488 container: '.card-slider__thumbs-slider', 1489 loop: false, 1490 gutter: 10, 1491 center:false, 1492 mouseDrag: true, 1493 nav: false, 1494 controls: false, 1495 navPosition: 'bottom', 1496 preventActionWhenRunning: false, 1497 axis: 'horizontal', 1498 responsive: { 1499 320: { 1500 items: 3 1501 }, 1502 640: { 1503 items: 3 1504 }, 1505 768: { 1506 items: 3 1507 }, 1508 1024: { 1509 items: 4 1510 }, 1511 1261: { 1512 items: 4 1513 }, 1514 1340: { 1515 items: 4 1516 } 1517 } 1518 });*/ 1519 1520 var navIndex = $('.card-slider__items .tns-nav-active').index(); 1521 $('.card-slider__thumbs-slider .card-slider__thumb').removeClass('tns-nav-active'); 1522 $('.card-slider__thumbs-slider .card-slider__thumb').eq(navIndex).addClass('tns-nav-active'); 1523 1524 vslider.events.on('indexChanged', function(){ 1525 var navIndex = $('.card-slider__items .tns-nav-active').index(); 1526 $('.card-slider__thumbs-slider .card-slider__thumb').removeClass('tns-nav-active'); 1527 $('.card-slider__thumbs-slider .card-slider__thumb').eq(navIndex).addClass('tns-nav-active'); 1528 1529 /*if (vslider.getInfo().index>vslider.getInfo().indexCached) { 1530 //console.log('right') 1531 } else { 1532 //console.log('left') 1533 }*/ 1534 }); 1535 1536 $(document).on('click', '.card-slider__thumbs-slider .card-slider__thumb', function(){ 1537 var thisIndex = $(this).index(); 1538 $('.card-slider__items .tns-nav button').eq(thisIndex).click(); 1539 });
1540 1541 /*vslider.events.on('indexChanged', function(){ 1542 small_slider.goTo(vslider.getInfo().index); 1543 });*/ 1544 }; 1545 1546 if (!isMobile && jQuery().zoom) { 1547 $('.gr-image-zoom').zoom({ 1548 magnify: 1, 1549 duration: 10, 1550 onZoomIn: function(){ 1551 $(this).parent().addClass('hide_small_pic'); 1552 }, 1553 onZoomOut: function(){ 1554 $(this).parent().removeClass('hide_small_pic'); 1555 }, 1556 callback: function(){ 1557 var $zoomImg = $(this); 1558 var containerHeight = $zoomImg.parent().outerHeight(); 1559 var containerWidth = $zoomImg.parent().outerWidth(); 1560 var zoomImgHeight = Math.floor($zoomImg.height()); 1561 var zoomImgWidth = Math.floor($zoomImg.width()); 1562 var floatHeight = Math.floor(20 * zoomImgHeight / 100); 1563 var floatWidth = Math.floor(20 * zoomImgWidth / 100); 1564 var prevWidth = Math.floor($(this).prev().outerWidth()); 1565 var prevHeight = Math.floor($(this).prev().outerHeight()); 1566 1567 var zoomFloatHeight = zoomImgHeight + floatHeight; 1568 var zoomFloatWidth = zoomImgWidth + floatWidth; 1569 var finalHeight = prevHeight+floatHeight; 1570 var finalWidth = prevWidth+floatWidth; 1571 1572 if (zoomFloatHeight<=prevHeight-floatHeight || zoomFloatWidth<=prevWidth-floatWidth) { 1573 $(this).parent().addClass('hide_big_pic'); 1574 }; 1575 1576 if (zoomImgHeight<=prevHeight || zoomImgWidth <=prevWidth) { 1577 $zoomImg.css({ 1578 'width': finalWidth, 1579 'height': finalHeight 1580 }); 1581 } 1582 1583 if (finalHeight<=containerHeight && finalWidth<=containerWidth) { 1584 $(this).parent().addClass('hide_zoom_pic'); 1585 } 1586 } 1587 }); 1588 }; 1589 1590 1591 if (shop2.mode == 'product') { 1592 shop2_gr.methods.grLazyFunc({selector:'.shop-product-share'}, function(){ 1593 var url_1 = 'https://yastatic.net/es5-shims/0.0.2/es5-shims.min.js'; 1594 var url_2 = 'https://yastatic.net/share2/share.js'; 1595 1596 $('.shop-product-share').append('<script src="'+url_1+'"></script><script src="'+url_2+'"></script>'); 1597 $('#product-yashare-noscript').remove(); 1598 }); 1599 }; 1600 1601 }, /*Ð¡Ð»Ð°Ð¹Ð´ÐµÑ Ð² каÑÑоÑке ÑоваÑа*/ 1602 1603 responsiveTabs: function() { 1604 if ($('#product-tabs').length) { 1605 $('.shop-product-data__nav li, .r-tabs-accordion-title').on('click', function(e){ 1606 e.preventDefault(); 1607 let href = $(this).find('a').attr('href'); 1608 let $descArea = $(href); 1609 1610 localStorage.setItem('gr_tab_href', href); 1611 1612 if ($descArea.is(':hidden')) { 1613 $('.shop-product-data__nav li, .r-tabs-accordion-title').removeClass('r-tabs-state-active'); 1614 $('.shop-product-data__desc .desc-area').stop().slideUp(300); 1615 }; 1616 1617 if (window.matchMedia("(min-width: 768px)").matches) { 1618 $('#product-tabs a[href="'+ href +'"]').parent().addClass('r-tabs-state-active'); 1619 $descArea.stop().slideDown(300); 1620 } else { 1621 $('#product-tabs a[href="'+ href +'"]').parent().toggleClass('r-tabs-state-active'); 1622 $descArea.stop().slideToggle(300); 1623 if ($('.r-tabs-accordion-title.r-tabs-state-active').length) { 1624 setTimeout(function(){ 1625 $('html, body').stop().animate({ 1626 scrollTop: $('.r-tabs-accordion-title.r-tabs-state-active').offset().top - 70 1627 }, 500); 1628 }, 301); 1629 }; 1630 }; 1631 }); 1632 }; 1633 1634 }, /*ТабÑ*/ 1635 1636 commentsBlock: function() { 1637 $('.comments-form__btn').on('click', function(){ 1638 $(this).next().slideToggle(200); 1639 }); 1640 }, /*ÐомменÑаÑии*/ 1641 1642 amountBlock: function() { 1643 var lazyAmount = false; 1644 1645 shop2_gr.methods.grLazyFunc({selector:'.shop2-product-amount'}, function() { 1646 if (!lazyAmount) { 1647 shop2_gr.methods.amountInit(); 1648 }; 1649 return lazyAmount = true; 1650 }); 1651 }, /*ÐолиÑеÑÑво*/ 1652 1653 buyOneClick: function() { 1654 1655 $(document).on('click', '.buy-one-click:not(.preorder-btn-js):not(.buy-one-click-js)', function(e) { 1656 var productName = $(this).data('product-name'); 1657 var productLink = $(this).data('product-link'); 1658 var $this = $(this); 1659 1660 if (shop2.mode == 'product' && $(this).parents('.kind-item').length<1) { 1661 var productAmount = $(this).parents('.shop2-product').find('.shop2-product-amount input').val(); 1662 } else if ($('.product-quick-view').length>0 && $(this).parents('.kind-item').length<1) { 1663 var productAmount = $(this).parents('.shop2-product').find('.shop2-product-amount input').val(); 1664 } else if ($(this).parents('.kind-item').length>0) { 1665 var productAmount = $(this).parents('.kind-item').find('.shop2-product-amount input').val(); 1666 } else { 1667 var productAmount = $(this).parents('.shop2-product-item').find('.shop2-product-amount input').val(); 1668 } 1669 1670 $.ajax({
1671 url: $(this).data('api-url'), 1672 dataType: 'json', 1673 success: function(response) { 1674 if (!response.result.error) { 1675 1676 $('.remodal[data-remodal-id="buy-one-click"] .tpl-anketa').remove(); 1677 $(response.result.html).appendTo('.remodal[data-remodal-id="buy-one-click"]'); 1678 if ($this.hasClass('product_info_form')) { 1679 var nameValue = productName; 1680 } else { 1681 var nameValue = productName + ', колиÑеÑÑво - ' + productAmount; 1682 } 1683 1684 $('.remodal[data-remodal-id="buy-one-click"] .tpl-field__product-link input').val(productLink); 1685 $('.remodal[data-remodal-id="buy-one-click"] .tpl-field__product-name input').val(nameValue); 1686 1687 s3From.initForms($('.remodal[data-remodal-id="buy-one-click"]'), function(){ 1688 $('.remodal[data-remodal-id="buy-one-click"] .tpl-field__product-link input').val(productLink); 1689 $('.remodal[data-remodal-id="buy-one-click"] .tpl-field__product-name input').val(nameValue); 1690 }); 1691 grFormDatePicker.init(); 1692 1693 } 1694 } 1695 }); 1696 }); 1697 1698 }, /*ÐÑпиÑÑ Ð² 1 клик*/ 1699 1700 cartPreview: function(){ 1701 1702 $(document).on('click', '.gr_order_one_page', function(e){ 1703 eraseCookie('gr_delivery_scroll'); 1704 createCookie('gr_delivery_scroll', 1, 30); 1705 }); 1706 1707 if (readCookie('gr_delivery_scroll') == '1') { 1708 eraseCookie('gr_delivery_scroll'); 1709 1710 setTimeout(function(){ 1711 $('html, body').animate({ 1712 scrollTop: $('.shop2-delivery').offset().top - 30 1713 }, 800); 1714 }, 1000); 1715 }; 1716 1717 }, /*СкÑолл на ÑÑÑаниÑе коÑÐ·Ð¸Ð½Ñ Ð´Ð¾ доÑÑавки*/ 1718 1719 cartPage: function() { 1720 1721 $(document).on('click', '.cart-params__more-btn', function(){ 1722 var $parent = $(this).parents('.cart-params'); 1723 var $params = $parent.find('.cart-params__body'); 1724 var currentText = $(this).data('text'); 1725 var hideText = $('html').attr('lang') == 'ru' ? 'СвеÑнÑÑÑ' : 'Hide'; 1726 1727 if ($(this).hasClass('active')) { 1728 $(this).removeClass('active'); 1729 $(this).find('ins').text(currentText); 1730 } else { 1731 $(this).addClass('active'); 1732 $(this).find('ins').text(hideText); 1733 }; 1734 1735 $params.stop().slideToggle(250); 1736 }); 1737 1738 1739 if (shop2.mode=='cart') { 1740 $('.shop2-warning').prependTo('.cart-page__left'); 1741 }; 1742 1743 /*ÐвÑопеÑеÑÑÐµÑ Ð² коÑзине*/ 1744 if (shop2.mode=='cart') { 1745 var cartURL = shop2.uri + "/cart", 1746 hash = { 1747 del: shop2.apiHash.cartRemoveItem, 1748 up: shop2.apiHash.cartUpdate 1749 }, 1750 ajax, $idd, 1751 shopCartDiv = $('.cart-page'), 1752 cartPreloader = '<div class="gr-preloader-holder"><div class="gr-preloader"><svg xmlns="http://www.w3.org/2000/svg" width="34" height="26" viewBox="0 0 120 30" fill="#fff"><script xmlns=""></script> <circle cx="15" cy="15" r="15"> <animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate> <animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributeName="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcMode="linear" repeatCount="indefinite"></animate> <animate attributeName="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcMode="linear" repeatCount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate> <animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate> </circle></svg></div></div>'; 1753 1754 $('.shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').append(cartPreloader); 1755 1756 shop2.on("afterCartAddItem", function(d, status) { 1757 if (!d.errstr.length) { 1758 getCart(); 1759 }; 1760 }); 1761 1762 $(document).on('click', '#shop2-color-ext-select li.param-value:not(.shop2-color-ext-selected)', function() { 1763 clearTimeout($idd); 1764 $idd = setTimeout(updateForm, 500); 1765 $('.shop2-cart-update').hide(); 1766 }); 1767 1768 function getCart(callback) { 1769 if (ajax) ajax.abort(); 1770 ajax = $.ajax({
1771 url: cartURL + "?cart_only=1", 1772 async: true, 1773 success: function(data) { 1774 var $shopWarning = $(data).filter('.shop2-warning').clone(); 1775 1776 $('.cart-page__top').html($(data).find('.cart-page__top').html()); 1777 $('.cart-page__bottom').html($(data).find('.cart-page__bottom').html()); 1778 1779 $shopWarning.prependTo('.cart-page__left'); 1780 initCart(shopCartDiv); 1781 1782 $('.shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').removeClass('gr-preloader-active'); 1783 1784 if (typeof callback === 'function') { 1785 setTimeout(function(){ 1786 callback(); 1787 }, 100); 1788 } 1789 1790 setTimeout(function(){ 1791 shop2.queue.edost2(); 1792 shop2.queue.bonus(); 1793 1794 $('.shop2-order-form input[type="checkbox"], .shop2-order-form input[type="radio"], .tpl-field-reg input, .gr-authorization-checkbox, .shop2-order-options.shop2-payment-options .payment_methods-column input[type="radio"], #orderForm input[name="personal_data"]').mgStyler(); 1795 }, 100); 1796 } 1797 }); 1798 }; 1799 1800 function initDelivery() { 1801 if ($('.shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').find('.gr-preloader-holder').length<1) { 1802 $('.shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').append(cartPreloader); 1803 }; 1804 1805 /*Ðод из shop2.queue.cart*/ 1806 $('#shop2-deligate-calc').on('click', function(e) { 1807 var data = {}, 1808 delivery = $('#shop2-order-delivery'), 1809 tabs = delivery.find('.shop2-delivery--item__tab'); 1810 1811 $('#shop2-perfect-form').find('input, textearea, select').each(function() { 1812 var $this = $(this); 1813 if (this.tagName === 'INPUT' && this.type === 'checkbox') { 1814 if (this.checked) { 1815 data[this.name] = 'on'; 1816 } 1817 } else { 1818 data[this.name] = $(this).val(); 1819 } 1820 }); 1821 1822 e.preventDefault(); 1823 tabs.removeClass('active-tab'); 1824 tabs.removeClass('point'); 1825 delivery.addClass('preloader'); 1826 $('#shop2-delivery-wait').show(); 1827 $('input#address').blur(); 1828 $('#shop2-deligate-calc').hide(); 1829 1830 $.ajax({
1831 url: '/-/x-api/v1/public/?method=deligate/calc¶m[get_vars][]', 1832 type: 'post', 1833 dataType: 'json', 1834 data: data, 1835 success: function(result) { 1836 delivery.removeClass('preloader'); 1837 $('#shop2-delivery-wait').hide(); 1838 $('#shop2-order-delivery').html(result.result.html); 1839 $('#shop2-order-delivery').append('<div class="preloader"><div class="spinner"></div></div>'); 1840 $('#shop2-order-delivery').find('.delivery-items').each(function() { 1841 var $this = $(this); 1842 if ($.trim($this.text()) == "") { 1843 $this.parents('.shop2-delivery--item__tab:first').addClass('disabled'); 1844 } 1845 }); 1846 if (result.result.error) { 1847 shop2.alert(result.result.error); 1848 } else { 1849 1850 var dadataJson = $.parseJSON($('#dadata').val()), 1851 coordsCenter = [dadataJson.geo_lat, dadataJson.geo_lon]; 1852 1853 shop2.queue.edost2(); 1854 $('#shop2-ems-calc, #shop2-edost-calc').on('click', function(e) { 1855 var $this = $(this); 1856 var attach_id = $this.data('attach-id'); 1857 var to = $('select[name=' + attach_id + '\\[to\\]]'); 1858 var zip = $('input[name=' + attach_id + '\\[zip\\]]'); 1859 var order_value = $('input[name=' + attach_id + '\\[order_value\\]]'); 1860 1861 if (to.length == 0) { 1862 to = $('#shop2-edost2-to'); 1863 } 1864 1865 e.preventDefault(); 1866 1867 to = to.get(0) ? to.val() : ''; 1868 zip = zip.get(0) ? zip.val() : ''; 1869 order_value = order_value.prop("checked") ? 'on' : ''; 1870 1871 shop2.delivery.calc(attach_id, 'to=' + to + '&zip=' + zip + '&order_value=' + order_value, function(d) { 1872 if (!d.data && d.errstr) { 1873 shop2.alert(d.errstr); 1874 $('#delivery-' + attach_id + '-cost').html(0); 1875 } else { 1876 $('#delivery-' + attach_id + '-cost').html(d.data.cost); 1877 1878 if (d.data.html) { 1879 $('#delivery-' + attach_id + '-html').html(d.data.html); 1880 shop2.queue.edost(); 1881 } 1882 } 1883 }); 1884 1885 }); 1886 $('#shop2-deligate-calc').hide(); 1887 } 1888 } 1889 }); 1890 }); 1891 /*Ðод из shop2.queue.cart*/ 1892 1893 /*Ðод из shop2.queue.delivery*/ 1894 $('#shop2-order-delivery').find('.delivery-items').each(function() { 1895 var $this = $(this); 1896 if ($.trim($this.text()) == "") { 1897 $this.parents('.shop2-delivery--item__tab:first').addClass('disabled'); 1898 } 1899 }); 1900 $('#shop2-ems-calc, #shop2-edost-calc').on('click', function(e) { 1901 var $this = $(this); 1902 var attach_id = $this.data('attach-id'); 1903 var to = $('select[name=' + attach_id + '\\[to\\]]'); 1904 var zip = $('input[name=' + attach_id + '\\[zip\\]]'); 1905 var order_value = $('input[name=' + attach_id + '\\[order_value\\]]'); 1906 1907 if (to.length == 0) { 1908 to = $('#shop2-edost2-to'); 1909 } 1910 1911 e.preventDefault(); 1912 1913 to = to.get(0) ? to.val() : ''; 1914 zip = zip.get(0) ? zip.val() : ''; 1915 order_value = order_value.prop("checked") ? 'on' : ''; 1916 1917 shop2.delivery.calc(attach_id, 'to=' + to + '&zip=' + zip + '&order_value=' + order_value, function(d) { 1918 if (!d.data && d.errstr) { 1919 shop2.alert(d.errstr); 1920 $('#delivery-' + attach_id + '-cost').html(0); 1921 } else { 1922 $('#delivery-' + attach_id + '-cost').html(d.data.cost); 1923 1924 if (d.data.html) { 1925 $('#delivery-' + attach_id + '-html').html(d.data.html); 1926 shop2.queue.edost(); 1927 } 1928 } 1929 }); 1930 1931 });
1932 /*Ðод из shop2.queue.delivery*/ 1933 }; 1934 1935 function initCart($div) { 1936 var $form = $div.find("#shop2-cart"), 1937 $inp = $form.find("input:text"), 1938 $item = $form.find(".cart-products__item"), 1939 $recalc = $("a.shop2-cart-update"), 1940 $minus = $form.find(".amount-minus"), 1941 $plus = $form.find(".amount-plus"); 1942 1943 if (!$form.length) return; 1944 1945 shop2_gr.methods.amountInit(); 1946 1947 if (shop2.mode=='cart') { 1948 $('.shop2-warning').prependTo('.cart-page__left'); 1949 }; 1950 1951 $('.cart-total-checkout, .cart-total-order-checkout, .cart-registration-btn').append(cartPreloader); 1952 1953 $('[data-remodal-id="cart-auth-remodal"]').remodal({ 1954 hashTracking: false 1955 }); 1956 1957 $('[data-remodal-id="coupon-remodal"]').remodal({ 1958 hashTracking: false 1959 }); 1960 1961 $('#shop2-cart .cart-delete a').off('click'); 1962 1963 $item.each(function(){ 1964 var $del = $(this).find(".cart-delete a"); 1965 var $input = $(this).find(".shop2-product-amount input"); 1966 var $button = $(this).find(".shop2-product-amount button"); 1967 var $select = $(this).find("select.param-value"); 1968 1969 1970 $select.on('change', function() { 1971 clearTimeout($idd); 1972 $idd = setTimeout(updateForm, 500); 1973 $('.shop2-cart-update').hide(); 1974 }); 1975 1976 $input.on('change', function() { 1977 clearTimeout($idd); 1978 $idd = setTimeout(updateForm, 1000); 1979 $('.shop2-cart-update').hide(); 1980 1981 $('.cart-total-checkout, .cart-total-order-checkout, .cart-registration-btn, .shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').addClass('gr-preloader-active'); 1982 }); 1983 1984 $button.on('click', function() { 1985 clearTimeout($idd); 1986 $idd = setTimeout(updateForm, 1000); 1987 $('.shop2-cart-update').hide(); 1988 1989 $('.cart-total-checkout, .cart-total-order-checkout, .cart-registration-btn, .shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').addClass('gr-preloader-active'); 1990 }); 1991 1992 $del.on("click", function(e) { 1993 var $this = $(this), 1994 kind_id = $this.data('id'); 1995 1996 e.preventDefault(); 1997 1998 $('.cart-total-checkout, .cart-total-order-checkout, .cart-registration-btn, .shop2-order-form ~ .form-item.form-item-submit button.shop2-btn').addClass('gr-preloader-active'); 1999 2000 kind_id = kind_id.toString().replace(/\"/g, '\\"').replace(/\'/g, '"'); 2001 kind_id = $.parseJSON(kind_id); 2002 2003 shop2.trigger('beforeCartRemoveItem'); 2004 2005 $.ajax({
2006 url: '/-/shop2-api/?cmd=cartRemoveItem', 2007 async: true, 2008 dataType: "json", 2009 data: { 2010 hash: hash.del, 2011 ver_id: shop2.verId, 2012 kind_id: kind_id 2013 }, 2014 success: function (d, status) { 2015 sessionStorage.setItem('cart-reload', 1); 2016 getCart(); 2017 setTimeout(function(){ 2018 $('.gr-cart-total-amount').text($('#shop2-cart').data('cart-amount') || '0'); 2019 }, 1100); 2020 2021 //console.log(123) 2022 2023 if (d.data.cart.length == 0) { 2024 document.location = shop2.uri + "?mode=cart&action=cleanup"; 2025 }; 2026 } 2027 }); 2028 2029 return false; 2030 }); 2031 }); 2032 2033 $recalc.on("click", function(e) { 2034 e.preventDefault(); 2035 updateForm(); 2036 return false; 2037 }); 2038 2039 2040 shop2.on('afterCartAddCoupon, afterCartRemoveCoupon', function() { 2041 document.location.reload(); 2042 }); 2043 2044 $('.coupon-btn').on('click', function(e) { 2045 var coupon = $('#coupon'), 2046 code = coupon.val(); 2047 2048 e.preventDefault(); 2049 2050 if (code) { 2051 shop2.cart.addCoupon(code); 2052 } 2053 }); 2054 2055 2056 $('.coupon-delete').on('click', function(e) { 2057 var $this = $(this), 2058 code = $this.data('code'); 2059 2060 e.preventDefault(); 2061 2062 if (code) { 2063 shop2.cart.removeCoupon(code); 2064 } 2065 }); 2066 }; 2067 2068 function updateForm() { 2069 var data = $("#shop2-cart").serialize(); 2070 2071 shop2.trigger('beforeCartUpdate'); 2072 2073 $.ajax({
2074 type: "POST", 2075 url: 2076 '/-/shop2-api/?cmd=cartUpdate' + 2077 '&ver_id=' + shop2.verId + 2078 '&hash=' + hash.up + 2079 '&' + data, 2080 async: true, 2081 success: function (d, status) { 2082 sessionStorage.setItem('cart-reload', 1); 2083 getCart(function(){ 2084 $('.gr-cart-total-amount').text($('#shop2-cart').data('cart-amount') || '0'); 2085 $('.gr-cart-total-sum ins').text($('.last_item .cart-total__body').data('total-price')); 2086 }); 2087 shop2.trigger('afterCartUpdated'); 2088 initDelivery(); 2089 } 2090 }); 2091 2092 return false; 2093 }; 2094 2095 initCart(shopCartDiv); 2096 }; 2097 /*ÐвÑопеÑеÑÑÐµÑ Ð² коÑзине*/ 2098 2099 $('.cart-products__item').each(function(){ 2100 if ($(this).find('.amount-min').length) { 2101 $(this).find('.cart-sum').css('margin-top', $(this).find('.amount-min').outerHeight(true)) 2102 }; 2103 }); 2104 2105 var cart_amount_min_timeout; 2106 2107 $(window).on('resize', function() { 2108 if (cart_amount_min_timeout) { 2109 clearTimeout(cart_amount_min_timeout); 2110 }; 2111 2112 cart_amount_min_timeout = setTimeout(function() { 2113 $('.cart-products__item').each(function(){ 2114 if ($(this).find('.amount-min').length) { 2115 $(this).find('.cart-sum').css('margin-top', $(this).find('.amount-min').outerHeight(true)) 2116 }; 2117 }); 2118 }, 50); 2119 }); 2120 2121 }, /*ÐоÑзина*/ 2122 2123 lightGallery: function() { 2124 if ($('.card-slider__items').length) { 2125 $('.card-slider__items').lightGallery({ 2126 thumbnail: false, 2127 download: false, 2128 loop: false, 2129 counter: false, 2130 getCaptionFromTitleOrAlt: true, 2131 selector: '.card-slider__image a' 2132 }); 2133 }; 2134 2135 if ($('.gr_cart_param_img').length) { 2136 $('.gr_cart_param_img').lightGallery({ 2137 thumbnail: false, 2138 download: false, 2139 loop: false, 2140 counter: false, 2141 getCaptionFromTitleOrAlt: true, 2142 selector: 'a' 2143 }); 2144 }; 2145 2146 }, /*ÐалеÑеÑ*/ 2147 2148 toolTips: function(){ 2149 if (!isMobile) { 2150 $('.shop-view .shop-view__item.thumbs').elemToolTip({ 2151 position: 'top', 2152 text: 'ÐиÑÑина', 2153 margin: 12 2154 }); 2155 2156 $('.shop-view .shop-view__item.simple').elemToolTip({ 2157 position: 'top', 2158 text: 'ÐÑоÑÑой', 2159 margin: 12 2160 }); 2161 2162 $('.shop-view .shop-view__item.pricelist').elemToolTip({ 2163 position: 'top', 2164 text: 'ÐÑайÑ-лиÑÑ', 2165 margin: 12 2166 }); 2167 2168 $('.quick-view-trigger').elemToolTip({ 2169 position: 'top', 2170 text: 'ÐÑÑÑÑÑй пÑоÑмоÑÑ', 2171 margin: 12 2172 }); 2173 2174 $('.favorite-block-wrap.favorite-desc').elemToolTip({ 2175 position: 'bottom', 2176 text: 'ÐзбÑаннÑе', 2177 margin: 18 2178 }); 2179 2180 $('.gr-compare-btn-wrap.compare-desc').elemToolTip({ 2181 position: 'bottom', 2182 text: 'СÑавнение', 2183 margin: 18 2184 }); 2185 2186 $('.site-header .cart-prew-wrap').elemToolTip({ 2187 position: 'bottom', 2188 text: 'ÐоÑзина', 2189 margin: 18 2190 }); 2191 2192 $('.site-header .login-form-btn').elemToolTip({ 2193 position: 'bottom', 2194 text: 'ÐабинеÑ', 2195 margin: 8 2196 }); 2197 }; 2198 }, /*ТÑлÑипÑ*/ 2199 2200 mainSlider: function(){ 2201 var $mainSliderClass = $(".js__main_slider"); 2202 2203 if ($mainSliderClass.length>0) { 2204 2205 var sliderAutoplay = $(".main-slider__slider").data("autoplay"); 2206 2207 var multislider = document.querySelectorAll(".js__main_slider"); 2208 2209 shop2_gr.methods.resizeController(1023, function() { 2210 2211 if ($('.js__main_slider').hasClass('tns-carousel')) { 2212 multislider.destroy(); 2213 }; 2214 2215 multislider = tns({ 2216 loop: true, 2217 container: '.js__main_slider', 2218 autoHeight: false, 2219 slideBy: 1, 2220 items: 1, 2221 lazyload: true, 2222 swipeAngle: false, 2223 speed: 400, 2224 autoplayHoverPause: true, 2225 autoplay: sliderAutoplay, 2226 autoplayButtonOutput: false, 2227 nav: true, 2228 axis: "horizontal", 2229 preventActionWhenRunning: false, 2230 navPosition: 'bottom', 2231 controlsPosition: 'bottom', 2232 controlsContainer: ".main-slider__controls", 2233 navContainer: ".main-slider__nav" 2234 }); 2235 2236 2237 }, function() { 2238 2239 if ($('.js__main_slider').hasClass('tns-carousel')) { 2240 multislider.destroy(); 2241 }; 2242 2243 multislider = tns({ 2244 loop: true, 2245 container: '.js__main_slider', 2246 autoHeight: false, 2247 slideBy: 1, 2248 items: 1, 2249 lazyload: true, 2250 swipeAngle: false, 2251 speed: 400, 2252 autoplayHoverPause: true, 2253 autoplay: sliderAutoplay, 2254 autoplayButtonOutput: false, 2255 nav: true, 2256 axis: "vertical", 2257 preventActionWhenRunning: false, 2258 navPosition: 'bottom', 2259 controlsPosition: 'bottom', 2260 controlsContainer: ".main-slider__controls", 2261 navContainer: ".main-slider__nav" 2262 }); 2263 2264 }); 2265 2266 } 2267 }, 2268 2269 folderBlock : function(){ 2270 $('.folder_items_hidden .folders-block__btn').on('click', function(){ 2271 2272 var $currentText = $(this).data('text'); 2273 var $hideText = $('html').attr('lang') == 'ru' ? 'ÑкÑÑÑÑ' : 'hide'; 2274 2275 if($(this).hasClass('active')){ 2276 $(this).removeClass('active'); 2277 $(this).find('span').text($currentText); 2278 $('.folder_items_hidden .folders-block__item.active').removeClass('active').slideUp(200); 2279 } else{ 2280 $(this).addClass('active'); 2281 $(this).find('span').text($hideText); 2282 $('.folder_items_hidden .folders-block__item:hidden').addClass('active').slideDown(200); 2283 } 2284 }); 2285 2286 setTimeout(function(){ 2287 $('.folder_items_hidden .folders-block__item:hidden').addClass('hidden_fold'); 2288 2289 if($('.folder_items_hidden .folders-block__item').hasClass('hidden_fold')){ 2290 $('.folder_items_hidden .folders-block__bottom').removeClass('hide'); 2291 } 2292 2293 2294 $('.folders-block__item_in').each(function(){ 2295 2296 $(this).find('> ul >li:hidden').addClass('hidden_li'); 2297 2298 if($(this).find('> ul >li:hidden').hasClass('hidden_li')){ 2299 $(this).find('.folders-block__item_more').removeClass('hide'); 2300 } 2301 }); 2302 2303 }, 200); 2304 2305 var $folders = $('.folder_items_slider .folders-block__body'); 2306 2307 if ($folders.length>0) { 2308 2309 var sliderAutoplay = $('.folder_items_slider .folders-block__body').data('autoplay'); 2310 2311
2312 var forEach = function(array, callback, scope) { 2313 for (var i = 0; i < array.length; i++) { 2314 callback.call(scope, i, array[i]); 2315 } 2316 }; 2317 2318 // tiny-slider initialisation 2319 var sliders = document.querySelectorAll('.folder_items_slider .folders-block__body'); 2320 forEach(sliders, function(index, value) { 2321 let thumbnail = value.dataset.name; 2322 2323 var respSettings = { 2324 320: {controls: false,items: 1,gutter: 0,disable: true}, 2325 740: {controls: false,items: 2,gutter: 16,disable: true}, 2326 1024: {controls: true,items: 4,gutter: 20,disable: false}, 2327 1261: {controls: true,items: 5,gutter: 20,disable: false} 2328 }; 2329 2330 let multislider = tns({ 2331 loop: false, 2332 rewind: true, 2333 container: value, 2334 slideBy: 1, 2335 autoplayHoverPause: true, 2336 mode: 'carousel', 2337 axis: 'horizontal', 2338 autoplay: sliderAutoplay, 2339 autoplayButtonOutput: false, 2340 mouseDrag: true, 2341 center: false, 2342 lazyload: true, 2343 autoWidth: false, 2344 nav: false, 2345 controls: true, 2346 navPosition: 'bottom', 2347 controlsPosition: 'top', 2348 preventActionWhenRunning: false, 2349 controlsText: ['<svg class="gr-svg-icon"><use xlink:href="#icon_site_arr_left_small"></use></svg>', '<svg class="gr-svg-icon "><use xlink:href="#icon_site_arr_right_small"></use></svg>'], 2350 responsive: respSettings 2351 }); 2352 }); 2353 2354 } 2355 2356 shop2_gr.methods.grLazyFunc({selector:'.folder_items_slider'}, function(){ 2357 $('.folders-block__item_in').matchHeight(); 2358 }); 2359 }, 2360 2361 2362 /*editSlider : function(){ 2363 2364 var $mainSliderClass = $(".js__edit_slider"); 2365 2366 if ($mainSliderClass.length>0) { 2367 2368 var sliderAutoplay = $(".edit-slider__slider").data("autoplay"); 2369 2370 var multislider = document.querySelectorAll(".js__edit_slider"); 2371 2372 shop2_gr.methods.resizeController(1023, function() { 2373 2374 if ($('.js__edit_slider').hasClass('tns-carousel')) { 2375 multislider.destroy(); 2376 }; 2377 2378 multislider = tns({ 2379 loop: true, 2380 container: '.js__edit_slider', 2381 autoHeight: false, 2382 slideBy: 1, 2383 items: 1, 2384 lazyload: true, 2385 swipeAngle: false, 2386 speed: 400, 2387 autoplayHoverPause: true, 2388 autoplay: sliderAutoplay, 2389 autoplayButtonOutput: false, 2390 nav: true, 2391 axis: "horizontal", 2392 preventActionWhenRunning: false, 2393 navPosition: 'bottom', 2394 controlsPosition: 'bottom', 2395 controlsContainer: ".edit-slider__controls", 2396 navContainer: ".edit-slider__nav" 2397 }); 2398 2399 2400 }, function() { 2401 2402 if ($('.js__edit_slider').hasClass('tns-carousel')) { 2403 multislider.destroy(); 2404 }; 2405 2406 multislider = tns({ 2407 loop: true, 2408 container: '.js__edit_slider', 2409 autoHeight: false, 2410 slideBy: 1, 2411 items: 1, 2412 lazyload: true, 2413 swipeAngle: false, 2414 speed: 400, 2415 autoplayHoverPause: true, 2416 autoplay: sliderAutoplay, 2417 autoplayButtonOutput: false, 2418 nav: true, 2419 axis: "vertical", 2420 preventActionWhenRunning: false, 2421 navPosition: 'bottom', 2422 controlsPosition: 'bottom', 2423 controlsContainer: ".edit-slider__controls", 2424 navContainer: ".edit-slider__nav" 2425 }); 2426 2427 }); 2428 2429 } 2430 },*/ 2431 2432 btnUp : function(){ 2433 let btnUp = document.querySelector('.btn_up'); 2434 2435 //let height; 2436 2437 let animScroll; 2438 2439 if(btnUp){ 2440 2441 btnUp.addEventListener('click', function(){ 2442 //height = document.documentElement.scrollTop; 2443 this.classList.add('btn_off'); 2444 2445 //console.log(height) 2446 animScroll = setInterval(function(){ 2447 2448 document.documentElement.scrollBy(0,-50); 2449 2450 //document.documentElement.scrollTo(0,0); 2451 }, 5); 2452 }); 2453 2454 2455 window.addEventListener('scroll', function(){ 2456 if(pageYOffset == 0 && btnUp.classList.contains('btn_off')){ 2457 console.log('pip') 2458 2459 clearInterval(animScroll); 2460 btnUp.classList.remove('btn_off'); 2461 } 2462 2463 if(document.documentElement.scrollTop >= document.documentElement.clientHeight){ 2464 btnUp.classList.add('active'); 2465 } else{ 2466 btnUp.classList.remove('active'); 2467 } 2468 }); 2469 } 2470 }, 2471 2472 topContats : function(){ 2473 $('.top-contacts__phone_btn').on('click', function(){ 2474 $(this).toggleClass('active'); 2475 $('.top-contacts__popup').fadeToggle(200); 2476 }); 2477 }, 2478 2479 topMenu : function(){ 2480 2481 if (window.matchMedia("(min-width: 1261px)").matches) { 2482 2483 $('.top-menu li').each(function(){ 2484 2485 var $thisli = $(this); 2486 var $menu = $thisli.find('ul'); 2487 2488 if(!$menu.length){ 2489 $thisli.removeClass('sublevel'); 2490 } 2491 }); 2492 2493 2494 $('.menu-nav .top-menu').rowMenu({ 2495 "moreText":"...", 2496 "moreWidth": 100 2497 }); 2498 2499 $('.menu-nav').removeClass('hideOverflow'); 2500 2501 2502 2503 }; 2504 2505 if (!isMobile) { 2506 2507 setTimeout(function(){ 2508 2509 $('.top-menu ul').parent().each(function() { 2510 var o = $(this); 2511 var s = o.find('>ul'); 2512 var l = o.parents('ul').length; 2513 var k = false; 2514 o.hover( 2515 function() { 2516 o.find('>a').addClass('active').removeClass('normal'); 2517 for (i=$('.top-menu ul').length; i>=0; i--){ 2518 o.parent().find('>li').not(o).find('ul').eq(i).hide(); 2519 } 2520 k = true; 2521 2522 s.show(); 2523 2524 if ($(document).outerWidth()>$(window).outerWidth()) { 2525 o.find('>ul').addClass('right_level'); 2526 }; 2527 }, 2528 function() { 2529 o.find('>a').removeClass('active').addClass('normal'); 2530 k = false; 2531 window.setTimeout(function() { 2532 if (!k) { 2533 s.hide() 2534 o.find('>ul').removeClass('right_level'); 2535 }; 2536 }, 500); 2537 } 2538 ); 2539 }); 2540 2541 }, 200); 2542 2543 } else{ 2544 2545 setTimeout(function(){ 2546 2547 $('.top-menu ul').parent().each(function(){ 2548 2549 var $this = $(this); 2550 var $subMenu = $this.find('>ul'); 2551 var $link = $this.find('>a'); 2552 2553 $link.on('click', function(e){
2554 e.preventDefault(); 2555 2556 if ($(this).hasClass('active')) { 2557 document.location.href = $(this).attr('href'); 2558 } 2559 2560 $subMenu.show(); 2561 2562 $link.addClass('active'); 2563 }); 2564 }); 2565 2566 }, 200); 2567 2568 } 2569 2570 }, 2571 2572 catMenu : function(){ 2573 $(".cat-menu ul").each(function(index, el) { 2574 $(el).closest("li").find("> a > .open_ul_span").on("click", function(event) { 2575 $(this).closest("li").toggleClass("active").find('> ul').slideToggle(150); 2576 return false; 2577 }); 2578 }); 2579 2580 $('.cat-menu li').each(function(){ 2581 2582 var $this = $(this); 2583 var link = $this.find('> .cat-menu-link'); 2584 var image = $this.find('> .folders-image'); 2585 2586 link.mouseenter(function(){ 2587 link.parent($this).find(image).addClass('vis'); 2588 }); 2589 2590 link.mouseleave(function(){ 2591 link.parent($this).find(image).removeClass('vis'); 2592 }); 2593 2594 }); 2595 }, 2596 2597 mobileBurger : function(){ 2598 $('.burger_event').on('click', function(){ 2599 $('.mobile-burger').addClass('active'); 2600 2601 $('.folders-image').remove(); 2602 2603 if(!$('.mobile-cat').length){ 2604 var $catClone = $('.cat-menu').clone().removeAttr('class').addClass('mobile-cat'); 2605 $('.mobile-burger__cat_wrap').append($catClone); 2606 } 2607 2608 var waSlideLang = ($html.attr('lang') == 'en' || $html.attr('lang') == 'de') ? 'back' : 'Ðазад'; 2609 $('.mobile-burger__cat_wrap').waSlideMenu({ 2610 backOnTop: true, 2611 scrollToTopSpeed: 100, 2612 minHeightMenu: 0, 2613 slideSpeed: 100, 2614 backLinkContent: waSlideLang, 2615 onSlideForward : function(){ 2616 $('.mobile-burger__btns').hide(); 2617 }, 2618 onLatestClick: function(){ 2619 document.location.href = $(this).attr('href'); 2620 } 2621 }); 2622 2623 $('body').on('touchstart', '.mobile-cat > li > ul > li.waSlideMenu-back a', function(){ 2624 setTimeout(function(){ 2625 $('.mobile-burger__btns').show(); 2626 }, 300); 2627 }); 2628 2629 if(!$('.mobile-menu').length){ 2630 var $menuClone = $('.top-menu').clone().removeClass('top-menu').addClass('mobile-menu'); 2631 $('.mobile-burger__menu_wrap').append($menuClone); 2632 } 2633 2634 if($('.mobile-menu .row-menu-btn').length){ 2635 $('.mobile-menu').append($('.mobile-menu .row-menu-container').html()); 2636 $('.mobile-menu .row-menu-btn').remove(); 2637 } 2638 2639 2640 var waSlideLang = ($html.attr('lang') == 'en' || $html.attr('lang') == 'de') ? 'back' : 'Ðазад'; 2641 $('.mobile-burger__menu_wrap').waSlideMenu({ 2642 backOnTop: true, 2643 scrollToTopSpeed: 100, 2644 minHeightMenu: 0, 2645 slideSpeed: 100, 2646 backLinkContent: waSlideLang, 2647 onSlideForward : function(){ 2648 $('.mobile-burger__btns').hide(); 2649 }, 2650 onLatestClick: function(){ 2651 document.location.href = $(this).attr('href'); 2652 } 2653 }); 2654 2655 $('body').on('touchstart', '.mobile-menu > li > ul > li.waSlideMenu-back a', function(){ 2656 setTimeout(function(){
2657 $('.mobile-burger__btns').show(); 2658 }, 300); 2659 }); 2660 2661 $('.mobile-menu li').each(function(){ 2662 2663 var $this = $(this); 2664 var $subMenu = $this.find('> ul'); 2665 2666 if(!$subMenu.length){ 2667 /* $this.removeClass('sublevel');*/ 2668 2669 $this.find('> a .open_ul_span').hide(); 2670 } 2671 }); 2672 2673 if(!$('.mobile-vendor-menu').length){ 2674 var brendsClone = $('.select-vendor-menu').clone().removeClass('select-vendor-menu').addClass('mobile-vendor-menu'); 2675 $('.mobile-burger__brends_wrap').append(brendsClone); 2676 2677 2678 $('.mobile-vendor-menu > li > a').on('click', function(e){ 2679 e.preventDefault(); 2680 2681 if ($(this).hasClass('active')) { 2682 document.location.href = $(this).attr('href'); 2683 } 2684 2685 $(this).addClass('active'); 2686 2687 $('.mobile-vendor-menu > li > a').not(this).removeClass('active'); 2688 2689 $(this).parents('li').find('ul').addClass('active'); 2690 2691 $('.mobile-vendor-menu > li > a').not(this).parents('li').find('ul').removeClass('active'); 2692 2693 }); 2694 } 2695 2696 2697 //setTimeout(function(){ 2698 $('.burger_tabs_btn').first().addClass('active'); 2699 2700 $('.burger_tabs_block').first().show(); 2701 //}, 50); 2702 2703 $('.burger_tabs_btn').on('click', function(){ 2704 2705 $('.burger_tabs_btn').removeClass('active'); 2706 $(this).addClass('active'); 2707 2708 var $btnIndex = $(this).index(); 2709 2710 2711 2712 $('.burger_tabs_block').each(function(){ 2713 2714 if($(this).index() == $btnIndex){ 2715 $(this).show(); 2716 } else{ 2717 $(this).hide(); 2718 } 2719 }); 2720 2721 }); 2722 }); 2723 2724 2725 $('.mobile-burger__panel .close-btn-panel').on('click', function(){ 2726 $('.mobile-burger').removeClass('active'); 2727 }); 2728 2729 }, 2730 2731 call_form: function() { 2732 2733 var $callButton = $('.call-form-btn'), 2734 $callMeForm = $('.remodal[data-remodal-id="call-form"]'); 2735 2736 $callButton.on('click', function(e) { 2737 2738 $.ajax({
2739 url: $callButton.data('api-url'), 2740 dataType: 'json', 2741 success: function(response) { 2742 if (!response.result.error) { 2743 2744 $('.remodal[data-remodal-id="call-form"] .tpl-anketa').remove(); 2745 $callMeForm.append($(response.result.html)); 2746 2747 s3From.initForms(); 2748 grFormDatePicker.init(); 2749 2750 $callButton.removeClass('ajax-form'); 2751 } 2752 } 2753 }); 2754 }); 2755 }, 2756 2757 fixedPanel : function(){ 2758 2759 if ($('.header_top_fixed').length){ 2760 2761 $(window).on('scroll', function(){ 2762 var top = $(document).scrollTop(); 2763 2764 var headerHeight = $('.header-top').outerHeight(); 2765 2766 var timerHeight = 0; 2767 2768 if($('.timer-block:not(.timer_bottom)').length){ 2769 var timerHeight = $('.timer-block').outerHeight(); 2770 } 2771 2772 if (top>(headerHeight + timerHeight)) { 2773 $('.header-bottom__panel').addClass('header_fix'); 2774 } else { 2775 $('.header-bottom__panel').removeClass('header_fix'); 2776 } 2777 }); 2778 2779 } 2780 }, 2781 2782 alignElements : function() { 2783 window.addEventListener('orientationchange', function() { 2784 setTimeout(function(){ 2785 $.fn.matchHeight._update(); 2786 }, 300); 2787 }, false); 2788 2789 var lazyFuncTime, lazyFuncScroll = false; 2790 2791 if ($(window).scrollTop()>0) { 2792 if (lazyFuncTime) { 2793 clearTimeout(lazyFuncTime); 2794 }; 2795 2796 lazyFuncTime = setTimeout(function() { 2797 if (!lazyFuncScroll) { 2798 shop2_gr.methods.grLazyFunc({selector:'.product-list.thumbs'}, function(){ 2799 if (!$('.main-blocks').length) { 2800 $('.product-list.thumbs .product-price').matchHeight('remove'); 2801 $('.product-list.thumbs .product-price').matchHeight(); 2802 }; 2803 }); 2804 }; 2805 2806 return lazyFuncScroll = true; 2807 }, 50); 2808 }; 2809 2810 $(window).on('scroll', function() { 2811 if (lazyFuncTime) { 2812 clearTimeout(lazyFuncTime); 2813 }; 2814 2815 lazyFuncTime = setTimeout(function() { 2816 if (!lazyFuncScroll) { 2817 shop2_gr.methods.grLazyFunc({selector:'.product-list.thumbs'}, function(){ 2818 if (!$('.main-blocks').length) { 2819 $('.product-list.thumbs .product-price').matchHeight('remove'); 2820 $('.product-list.thumbs .product-price').matchHeight(); 2821 }; 2822 /*setTimeout(function(){ 2823 new window.ProductImageSlider().init(); 2824 }, 500)*/ 2825 }); 2826 }; 2827 2828 return lazyFuncScroll = true; 2829 }, 50); 2830 2831 return lazyFuncScroll; 2832 }); 2833 2834 2835 shop2_gr.methods.grLazyFunc({selector:'.mods_block'}, function(){ 2836 $('.mods_block .kinds-block__items .kind-item__top').matchHeight(); 2837 $('.mods_block .kinds-block__items .kind-additional').matchHeight(); 2838 $('.mods_block .kinds-block__items .kind-price').matchHeight(); 2839 }); 2840 }, /*ÐÑÑавнивание блоков по вÑÑоÑе*/ 2841 2842 otherScripts : function() { 2843 if ($('table').length) { 2844 $('table').wrap('<div class="table-wrapper"></div>'); 2845 }; 2846 if (shop2.facets.enabled && $('.shop2-filter').length) { 2847 shop2.filter.count(); 2848 }; 2849 2850 $('body').removeClass('gr_hide_onload'); 2851 2852 // ÐажаÑие на клавиÑÑ Esc 2853 $(document).on('keyup.esc_keyup', function(keyUp){ 2854 if (keyUp.keyCode 2855 == 27) { 2856 $('html').removeClass('overflowHidden'); 2857 $('.sorting-block').removeClass('active'); 2858 $('.shop2-color-ext-select').removeClass('active'); 2859 $('.gr-favorite-popup').removeClass('opened'); 2860 $('#shop2-alert-ok').trigger('click'); 2861 $('.top-contacts__phone_btn').removeClass('active'); 2862 $('.top-contacts__popup').fadeOut(200); 2863 return false; 2864 }; 2865 }); 2866 // ÐажаÑие на клавиÑÑ Esc 2867
2868 // Ðлик по докÑменÑÑ 2869 $(document).on('click', function(e){ 2870 if (!$(e.target).closest('.price-old.question, .shop2-cart-total .question, .cart-total__title .question').length) { 2871 $('.shop2-product-discount-desc').hide(); 2872 }; 2873 2874 if (!$(e.target).closest('.sorting-block').length && !$(e.target).closest('.sorting-button').length) { 2875 $('.sorting-block').removeClass('active'); 2876 }; 2877 2878 if (!$(e.target).closest('.shop2-color-ext-select .shop2-color-ext-options, #shop2-color-ext-select').length) { 2879 $('.shop2-color-ext-select').removeClass('active'); 2880 }; 2881 2882 if (!$(e.target).closest('.top-contacts').length) { 2883 $('.top-contacts__phone_btn').removeClass('active'); 2884 $('.top-contacts__popup').fadeOut(200); 2885 }; 2886 2887 if (!$(e.target).closest('.mobile-burger__panel, .burger_event').length){ 2888 $('.mobile-burger').removeClass('active'); 2889 } 2890 2891 if (!$(e.target).closest('.login-container-inner, .login-mobile-btn').length){ 2892 $('.login-container').removeClass('active'); 2893 } 2894 2895 if (!$(e.target).closest('.search-container-inner, .search-mobile-btn').length){ 2896 $('.search-container').removeClass('active'); 2897 } 2898 2899 setTimeout(function(){ 2900 $('#shop2-alert-ok').html('<span><svg class="gr-svg-icon gr_big_icon"><use xlink:href="#icon_site_close"></use></svg><svg class="gr-svg-icon"><use xlink:href="#icon_site_close_small"></use></svg><svg class="gr-svg-icon gr_small_icon"><use xlink:href="#icon_site_close_mini"></use></svg></span>'); 2901 }, 250) 2902 }); 2903 // Ðлик по докÑменÑÑ 2904 2905 shop2_gr.methods.changeFlagsColor(); 2906 2907 shop2_gr.methods.grLazyLoad(); 2908 2909 if (readCookie('rootMarginCookie')) { 2910 shop2_gr.methods.grLazyLoad({ 2911 selector: 'gr_lazy_load_block', 2912 margin: '10px' 2913 }); 2914 } else { 2915 shop2_gr.methods.grLazyLoad({ 2916 selector: 'gr_lazy_load_block' 2917 }); 2918 }; 2919 if (!readCookie('rootMarginCookie')) { 2920 createCookie('rootMarginCookie', 1, 1); // Создаем кÑкÑ, ÑÑÐ¾Ð±Ñ ÑвелиÑиÑÑ ÑаÑÑÑоÑние, пÑи коÑоÑом поÑвлÑÑÑÑÑ Ð±Ð»Ð¾ÐºÐ¸ 2921 }; 2922 2923 jQuery.event.special.touchstart = { 2924 setup: function( _, ns, handle ){ 2925 this.addEventListener("touchstart", handle, { passive: true }); 2926 } 2927 }; 2928 2929 jQuery.event.special.touchend = { 2930 setup: function( _, ns, handle ){ 2931 this.addEventListener("touchend", handle, { passive: true }); 2932 } 2933 }; 2934 2935 jQuery.event.special.touchmove = { 2936 setup: function( _, ns, handle ){ 2937 this.addEventListener("touchmove", handle, { passive: true }); 2938 } 2939 }; 2940 } /*Разное*/ 2941 2942 2943 }; 2944 2945 shop2_gr.settings = { 2946 imageObserver: null, 2947 searchIcon: '<i class="search-block__icon"><svg class="gr-svg-icon"><use xlink:href="#icon_shop_search"></use></svg></i>', 2948 sliderControls: ['<svg class="gr-svg-icon"><use xlink:href="#icon_site_arr_left"></use></svg><svg class="gr-svg-icon gr_small_icon"><use xlink:href="#icon_site_arr_left_small"></use></svg>', '<svg class="gr-svg-icon"><use xlink:href="#icon_site_arr_right"></use></svg><svg class="gr-svg-icon gr_small_icon"><use xlink:href="#icon_site_arr_right_small"></use></svg>'] 2949 }; 2950 2951 shop2_gr.methods = { 2952 grLazyFunc: function(params, callback) { 2953 var elem = params.selector; 2954 var margin = '10px'; 2955 2956 if (params.margin) { 2957 margin = params.margin 2958 } 2959 2960 let options = { 2961 rootMargin: margin 2962 }; 2963 2964 const imageObserver = new IntersectionObserver((entries, imgObserver) => { 2965 entries.forEach((entry) => { 2966 if (entry.isIntersecting) { 2967 const lazyItem = entry.target // ТекÑÑий ÑÐ»ÐµÐ¼ÐµÐ½Ñ 2968 2969 if (callback) { 2970 callback(); 2971 }; 2972 2973 imgObserver.unobserve(lazyItem); 2974 } 2975 }) 2976 }, options); 2977 2978 if (typeof elem == 'object') { 2979 imageObserver.observe(elem); 2980 } else { 2981 if (document.querySelector(elem)!=null) { 2982 if (document.querySelectorAll(elem).length>1) { 2983 const arr = document.querySelectorAll(elem); 2984 arr.forEach((v) => { 2985 imageObserver.observe(v); 2986 }); 2987 } else { 2988 imageObserver.observe(document.querySelector(elem)); 2989 } 2990 } 2991 } 2992 }, /*ÐÑÐ»Ð¾Ð¶ÐµÐ½Ð½Ð°Ñ Ð·Ð°Ð³ÑÑзка ÑкÑипÑа*/ 2993 2994 grLazyLoad: function(params) { 2995 var elem = 'gr_images_lazy_load'; 2996 var margin = '10px'; 2997 2998 if (params) { 2999 if (params.selector) { 3000 elem = params.selector; 3001 }; 3002 3003 if (params.margin) { 3004 margin = params.margin; 3005 }; 3006 }; 3007 3008 let options = { 3009 rootMargin: margin 3010 }; 3011 shop2_gr.settings.imageObserver = new IntersectionObserver((entries, imgObserver) => {
3012 entries.forEach((entry) => { 3013 if (entry.isIntersecting) { 3014 const lazyImage = entry.target // ТекÑÑий ÑÐ»ÐµÐ¼ÐµÐ½Ñ 3015 3016 if (lazyImage.tagName == 'IMG') { // Ð´Ð»Ñ Ð¾Ð±ÑÑнÑÑ ÐºÐ°ÑÑинок 3017 if (lazyImage.dataset.srcset) { 3018 // ЧÑÐ¾Ð±Ñ Ð·Ð°Ð³ÑÑжаÑÑ ÐºÐ°ÑÑинки маленÑÐºÐ¸Ñ ÑазмеÑов Ñ Ð¿Ð¾Ð¼Ð¾ÑÑÑ srcset 3019 lazyImage.srcset = lazyImage.dataset.srcset // ÐдÑÐµÑ ÐºÐ°ÑÑинки data-srcset="" 3020 lazyImage.classList.remove(elem); 3021 imgObserver.unobserve(lazyImage); 3022 } else { 3023 lazyImage.src = lazyImage.dataset.src // ÐдÑÐµÑ ÐºÐ°ÑÑинки data-src="" 3024 lazyImage.classList.remove(elem); 3025 imgObserver.unobserve(lazyImage); 3026 } 3027 } else if (lazyImage.dataset.bg) { 3028 if (window.innerWidth <= 768 && lazyImage.dataset.minbg) { 3029 lazyImage.style.backgroundImage = 'url(' + lazyImage.dataset.minbg + ')'; 3030 lazyImage.classList.remove(elem); 3031 imgObserver.unobserve(lazyImage); 3032 } else { 3033 lazyImage.style.backgroundImage = 'url(' + lazyImage.dataset.bg + ')'; 3034 lazyImage.classList.remove(elem); 3035 imgObserver.unobserve(lazyImage); 3036 } 3037 } else if (lazyImage.dataset.func) { // ÐÑли ÑÐ»ÐµÐ¼ÐµÐ½Ñ ÑодеÑÐ¶Ð¸Ñ data-func 3038 if (typeof shop2_gr.methods[lazyImage.dataset.func] == 'function') { 3039 shop2_gr.methods[lazyImage.dataset.func](lazyImage); // ÐÑзов ÑÑнкÑии 3040 lazyImage.classList.remove(elem); 3041 imgObserver.unobserve(lazyImage); 3042 } 3043 } else { 3044 lazyImage.classList.remove(elem); 3045 imgObserver.unobserve(lazyImage); 3046 } 3047 } 3048 }) 3049 }, options); 3050 3051 const arr = document.querySelectorAll('.' + elem); 3052 3053 arr.forEach((v) => { 3054 shop2_gr.settings.imageObserver.observe(v); 3055 }); 3056 }, /*ÐÑÐ»Ð¾Ð¶ÐµÐ½Ð½Ð°Ñ Ð·Ð°Ð³ÑÑзка*/ 3057 3058 forEach: function(array, callback, scope) { 3059 for (var i = 0; i < array.length; i++) { 3060 callback.call(scope, i, array[i]); 3061 }; 3062 }, /*ÐÐ»Ñ Ñини ÑлайдеÑа*/ 3063 3064 changeFlagsColor: function(){ 3065 $('.product-flags__item.custom_item span').each(function(){ 3066 if ($(this).data('custom-bg')) { 3067 var custom_bg = shop2_gr.methods.grConvertToRgb($(this).data('custom-bg')); 3068 var text_color = Math.round(((parseInt(custom_bg[0]) * 299) + (parseInt(custom_bg[1]) * 587) + (parseInt(custom_bg[2]) * 114)) /1000); 3069 3070 if(text_color > 140) { 3071 $(this).css('color', '#000'); 3072 }else{ 3073 $(this).css('color', '#fff'); 3074 }; 3075 }; 3076 }); 3077 }, /*ÐеÑекÑаÑка ÑвеÑа ÑекÑÑа каÑÑомнÑÑ Ñлагов*/ 3078 3079 mainBlocks: function(lazyElem) { 3080 if ($('.main-products').length) { 3081 $('.product-list').removeClass('simple').removeClass('list').addClass('thumbs'); 3082 3083 if($('.site-main').hasClass('product_items_slider')){ 3084 3085 var slider = lazyElem.querySelector('.main_blocks_list'); 3086 var main_items = slider.getAttribute('data-main-items'); 3087 var respSettings = {}; 3088 3089 var gr_images_size = slider.dataset["imagesSize"]; 3090 var gr_images_view = slider.dataset["imagesView"]; 3091 var gr_mode_catalog = slider.dataset["modeCatalog"]; 3092 var url = '/-/x-api/v1/public/?method=shop2/getProductsBySearchMatches'; 3093 3094 if (gr_images_view){ 3095 url += "&gr_images_view=" + gr_images_view; 3096 }; 3097 3098 if (gr_images_size){ 3099 url += "&gr_images_size=" + gr_images_size; 3100 }; 3101 3102 if (gr_mode_catalog){ 3103 url += "&gr_mode_catalog=" + gr_mode_catalog; 3104 }; 3105 3106 if (main_items == 5) { 3107 var main_items_1280 = 5,main_items_1024 = 4,main_items_768 = 3,main_items_320 = 2; 3108 } else if (main_items == 4) { 3109 var main_items_1280 = 4,main_items_1024 = 4,main_items_768 = 3,main_items_320 = 2; 3110 } else if (main_items == 3) { 3111 var main_items_1280 = 3,main_items_1024 = 3,main_items_768 = 3,main_items_320 = 2; 3112 } else if (main_items == 2) { 3113 var main_items_1280 = 2,main_items_1024 = 2,main_items_768 = 2,main_items_320 = 2; 3114 }; 3115 3116 respSettings = { 3117 320: {controls: false,items: main_items_320,gutter: 8,disable: true}, 3118 740: {controls: false,items: main_items_768,gutter: 16,disable: true}, 3119 1024: {controls: true,items: main_items_1024,gutter: 20,disable: false}, 3120 1261: {controls: true,items: main_items_1280,gutter: 20,disable: false}, 3121 1341: {controls: true,items: main_items_1280,gutter: 20,disable: false} 3122 }; 3123 3124 if ($(slider).length) { 3125 var sliderAutoplay = +slider.getAttribute('data-autoplay'); 3126 var multislider = tns({ 3127 loop: false, 3128 rewind: true, 3129 container: slider, 3130 slideBy: 1, 3131 autoplayHoverPause: true, 3132 mode: 'carousel', 3133 axis: 'horizontal', 3134 autoplay: sliderAutoplay, 3135 autoplayButtonOutput: false, 3136 mouseDrag: true, 3137 center: false, 3138 autoWidth: false, 3139 nav: false, 3140 swipeAngle: 50, 3141 controlsText: shop2_gr.settings.sliderControls, 3142 navPosition: 'bottom', 3143 preventActionWhenRunning: false, 3144 responsive: respSettings 3145 }); 3146 3147 setTimeout(function(){ 3148 //shop2_gr.methods.arrowsPosition($(lazyElem).find('.main_blocks_list'), '.gr-product-image'); 3149 if (!shop2.my.gr_main_blocks_ajax) { 3150 $(lazyElem).addClass('main_products_loaded'); 3151 } 3152 }, 10); 3153 3154 if (shop2.my.gr_main_blocks_ajax) { 3155 var empty_products = slider.querySelectorAll('.gr_empty_product'); 3156 var active_products = slider.querySelectorAll('.tns-slide-active'); 3157 var active_array = []; 3158 3159 Array.prototype.forEach.call(active_products, function(item, i){ 3160 active_array[i] = item.dataset['mainProductId']; 3161 });
3162 3163 shop2_gr.methods.getMainProducts(url, active_array, empty_products, function(){ 3164 shop2_gr.methods.arrowsPosition($(lazyElem).find('.main_blocks_list'), '.gr-product-image'); 3165 3166 shop2_gr.methods.changeFlagsColor(); 3167 3168 setTimeout(function(){ 3169 $(lazyElem).find('.product-item__bottom').matchHeight('remove'); 3170 $(lazyElem).find('.product-item__bottom-left').matchHeight('remove'); 3171 $(lazyElem).find('.product-item__bottom-right').matchHeight('remove'); 3172 $(lazyElem).find('.product-price').matchHeight('remove'); 3173 3174 $(lazyElem).find('.product-item__bottom').matchHeight(); 3175 $(lazyElem).find('.product-item__bottom-left').matchHeight(); 3176 $(lazyElem).find('.product-item__bottom-right').matchHeight(); 3177 $(lazyElem).find('.product-price').matchHeight(); 3178 }, 300); 3179 3180 $(slider).find('.gr_images_lazy_load').each(function(){ 3181 $(this).attr('src', $(this).attr('data-src')); 3182 });
3183 $(lazyElem).addClass('main_products_loaded'); 3184 $(slider).find('.buy-one-click').attr('data-api-url', $(slider).data('popup-form')); 3185 $(slider).find('.buy-one-click.product_info_form').attr('data-api-url', $(slider).data('info-popup-form')); 3186 shop2_gr.methods.viewLots($(lazyElem).find('.product-list')); 3187 shop2_gr.methods.amountInit($(lazyElem).find('.shop2-product-item')); 3188 3189 3190 if (!isMobile) { 3191 $(lazyElem).find('.quick-view-trigger').elemToolTip({ 3192 text: 'ÐÑÑÑÑÑй пÑоÑмоÑÑ', 3193 margin: 12 3194 }); 3195 }; 3196 }); 3197 3198 3199 function slider_handler(current_slider) { 3200 if (!current_slider.container.classList.contains('all_products_done')) { 3201 var simple_products = current_slider.container.querySelectorAll('.gr_empty_product'); 3202 3203 if (simple_products[0]) { 3204 var active_array = []; 3205 3206 Array.prototype.forEach.call(simple_products, function(simple_product, i){ 3207 active_array[i] = simple_product.dataset['mainProductId']; 3208 }); 3209 3210 shop2_gr.methods.getMainProducts(url, active_array, simple_products, function(){ 3211 shop2_gr.methods.arrowsPosition($(current_slider.container).find('.main_blocks_list'), '.gr-product-image'); 3212 3213 $(current_slider.container).find('.gr_images_lazy_load').each(function(){ 3214 $(this).attr('src', $(this).attr('data-src')); 3215 }); 3216 $(lazyElem).addClass('main_products_loaded'); 3217 $(current_slider.container).find('.buy-one-click').attr('data-api-url', $(current_slider.container).data('popup-form')); 3218 $(current_slider.container).find('.buy-one-click.product_info_form').attr('data-api-url', $(current_slider.container).data('info-popup-form')); 3219 shop2_gr.methods.viewLots($(current_slider.container).find('.product-list')); 3220 shop2_gr.methods.amountInit($(current_slider.container).find('.shop2-product-item')); 3221 3222 if (!isMobile) { 3223 $(current_slider.container).find('.quick-view-trigger').elemToolTip({ 3224 text: 'ÐÑÑÑÑÑй пÑоÑмоÑÑ', 3225 margin: 12 3226 }); 3227 }; 3228 3229 shop2_gr.methods.changeFlagsColor(); 3230 3231 setTimeout(function(){ 3232 $(current_slider.container).find('.product-item__bottom').matchHeight('remove'); 3233 $(current_slider.container).find('.product-item__bottom-left').matchHeight('remove'); 3234 $(current_slider.container).find('.product-item__bottom-right').matchHeight('remove'); 3235 $(current_slider.container).find('.product-price').matchHeight('remove'); 3236 3237 $(current_slider.container).find('.product-item__bottom').matchHeight(); 3238 $(current_slider.container).find('.product-item__bottom-left').matchHeight(); 3239 $(current_slider.container).find('.product-item__bottom-right').matchHeight(); 3240 $(current_slider.container).find('.product-price').matchHeight(); 3241 }, 300); 3242 }); 3243 3244 current_slider.container.classList.add('all_products_done'); 3245 }; 3246 } else { 3247 return; 3248 }; 3249 }; 3250 3251 3252 3253 multislider.events.on('indexChanged', slider_handler); 3254 multislider.events.on('newBreakpointEnd', slider_handler); 3255 }; 3256 3257 if (!shop2.my.gr_main_blocks_ajax) { 3258 shop2_gr.methods.grLazyFunc({selector:lazyElem}, function() { 3259 $(lazyElem).find('.product-item__bottom').matchHeight('remove'); 3260 $(lazyElem).find('.product-item__bottom-left').matchHeight('remove'); 3261 $(lazyElem).find('.product-item__bottom-right').matchHeight('remove'); 3262 $(lazyElem).find('.product-price').matchHeight('remove'); 3263 3264 $(lazyElem).find('.product-item__bottom').matchHeight(); 3265 $(lazyElem).find('.product-item__bottom-left').matchHeight(); 3266 $(lazyElem).find('.product-item__bottom-right').matchHeight(); 3267 $(lazyElem).find('.product-price').matchHeight(); 3268 }); 3269 }; 3270 3271 var mainLazyFuncTime, mainLazyFuncScroll = false; 3272 $(window).on('scroll', function() { 3273 if (mainLazyFuncTime) { 3274 clearTimeout(mainLazyFuncTime); 3275 }; 3276 mainLazyFuncTime = setTimeout(function() { 3277 if (!mainLazyFuncScroll) { 3278 shop2_gr.methods.grLazyFunc({selector:lazyElem}, function() { 3279 $(lazyElem).find('.product-item__bottom').matchHeight('remove'); 3280 $(lazyElem).find('.product-item__bottom-left').matchHeight('remove'); 3281 $(lazyElem).find('.product-item__bottom-right').matchHeight('remove'); 3282 $(lazyElem).find('.product-price').matchHeight('remove'); 3283 3284 $(lazyElem).find('.product-item__bottom').matchHeight(); 3285 $(lazyElem).find('.product-item__bottom-left').matchHeight(); 3286 $(lazyElem).find('.product-item__bottom-right').matchHeight(); 3287 $(lazyElem).find('.product-price').matchHeight(); 3288 }); 3289 }; 3290 return mainLazyFuncScroll = true; 3291 }, 50); 3292 return mainLazyFuncScroll; 3293 });
3294 }; 3295 3296 } else{ 3297 3298 setTimeout(function(){ 3299 shop2_gr.methods.moreBtn(lazyElem); 3300 3301 $(lazyElem).addClass('main_products_loaded'); 3302 }, 100); 3303 3304 3305 } 3306 }; 3307 }, /*Ðлоки на главной*/ 3308 3309 kindsBlock: function(lazyElem) { 3310 3311 if ($('.kinds-block__items.kinds_slider').length>0) { 3312 var slider = lazyElem.querySelector('.kinds-block__items.kinds_slider'); 3313 var kind_items = slider.getAttribute('data-kind-items'); 3314 var respSettings = {}; 3315 3316 if (kind_items == 5) { 3317 var kind_items_1280 = 5,kind_items_1024 = 4,kind_items_768 = 3,kind_items_320 = 2; 3318 } else if (kind_items == 4) { 3319 var kind_items_1280 = 4,kind_items_1024 = 4,kind_items_768 = 3,kind_items_320 = 2; 3320 } else if (kind_items == 3) { 3321 var kind_items_1280 = 3,kind_items_1024 = 3,kind_items_768 = 3,kind_items_320 = 2; 3322 } else if (kind_items == 2) { 3323 var kind_items_1280 = 2,kind_items_1024 = 2,kind_items_768 = 2,kind_items_320 = 2; 3324 } 3325 3326 respSettings = { 3327 320: {controls: false,items: kind_items_320,gutter: 8}, 3328 740: {controls: false,items: kind_items_768,gutter: 16}, 3329 1024: {controls: true,items: kind_items_1024,gutter: 20}, 3330 1261: {controls: true,items: kind_items_1280,gutter: 20}, 3331 1341: {controls: true,items: kind_items_1280,gutter: 20} 3332 }; 3333 3334 if ($(slider).length) { 3335 var sliderAutoplay = +slider.getAttribute('data-autoplay'); 3336 3337 var multislider = tns({ 3338 loop: false, 3339 rewind: true, 3340 container: slider, 3341 slideBy: 1, 3342 autoplayHoverPause: true, 3343 mode: 'carousel', 3344 axis: 'horizontal', 3345 autoplay: sliderAutoplay, 3346 autoplayButtonOutput: false, 3347 mouseDrag: true, 3348 center: false, 3349 autoWidth: false, 3350 nav: true, 3351 swipeAngle: 50, 3352 controlsText: shop2_gr.settings.sliderControls, 3353 navPosition: 'bottom', 3354 preventActionWhenRunning: false, 3355 responsive: respSettings 3356 }); 3357 3358 /* setTimeout(function(){ 3359 shop2_gr.methods.arrowsPosition($(lazyElem).find('.kinds-block__items.kinds_slider'), '.kind-image'); 3360 }, 10);*/ 3361 3362 var kindLazyFuncTime, kindLazyFuncScroll = false; 3363 3364 if ($(window).scrollTop()>0) { 3365 if (kindLazyFuncTime) { 3366 clearTimeout(kindLazyFuncTime); 3367 }; 3368 kindLazyFuncTime = setTimeout(function() { 3369 if (!kindLazyFuncScroll) { 3370 if (readCookie('rootMarginCookie')) { 3371 shop2_gr.methods.grLazyFunc({selector:lazyElem, margin: '200px'}, function() { 3372 3373 setTimeout(function(){ 3374 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__top').matchHeight('remove'); 3375 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__bottom').matchHeight('remove'); 3376 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-price').matchHeight('remove'); 3377 3378 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__top').matchHeight(); 3379 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__bottom').matchHeight(); 3380 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-price').matchHeight(); 3381 }, 300); 3382 }); 3383 } else { 3384 shop2_gr.methods.grLazyFunc({selector:lazyElem}, function() { 3385 setTimeout(function(){ 3386 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__top').matchHeight('remove'); 3387 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__bottom').matchHeight('remove'); 3388 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-price').matchHeight('remove'); 3389 3390 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__top').matchHeight(); 3391 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-item__bottom').matchHeight(); 3392 $(lazyElem).find('.kinds-block__items.kinds_slider .kind-price').matchHeight(); 3393 }, 300); 3394 }); 3395 }; 3396 }; 3397 3398 return kindLazyFuncScroll = true; 3399 }, 50); 3400 }; 3401 }; 3402 }; 3403 3404 }, /*ÐоллекÑии*/ 3405 3406 moreBtn: function(wrapper) { 3407 let $hidden = $(wrapper).find('.product-item-wrap:hidden').addClass('hidden_item'); 3408 let $btn = $(wrapper).find('.main_more_btn'); 3409 3410 if ($hidden.length) { 3411 $btn.parents('.main_more').addClass('active'); 3412 }; 3413 3414 $btn.on('click', function(){ 3415 $hidden.slideToggle(250); 3416 3417 var $currentText = $(this).data('text'); 3418 var $hideText = $('html').attr('lang') == 'ru' ? 'ÑкÑÑÑÑ' : 'hide'; 3419 3420 if($(this).hasClass('active')){ 3421 $(this).removeClass('active'); 3422 $(this).find('span').text($currentText); 3423 } else{ 3424 $(this).addClass('active'); 3425 $(this).find('span').text($hideText); 3426 } 3427 }); 3428 }, 3429 3430 moreBtnAll: function(wrapper){ 3431 let $hidden = $(wrapper).find('.unit_item_block:hidden').addClass('hidden_item'); 3432 let $btn = $(wrapper).find('.bottom_more_btn'); 3433 3434 if ($hidden.length) { 3435 $btn.parents('.bottom_more_panel').removeClass('hide'); 3436 }; 3437 3438 $btn.on('click', function(){ 3439 $hidden.slideToggle(250); 3440 3441 var $currentText = $(this).data('text'); 3442 var $hideText = $('html').attr('lang') == 'ru' ? 'ÑкÑÑÑÑ' : 'hide'; 3443 3444 if($(this).hasClass('active')){ 3445 $(this).removeClass('active'); 3446 $(this).find('span').text($currentText); 3447 } else{ 3448 $(this).addClass('active'); 3449 $(this).find('span').text($hideText); 3450 } 3451 }); 3452 }, 3453 3454 brendsBlock : function(lazyElem){ 3455 3456 if (!$(lazyElem).hasClass('brends_items_slider')) { 3457 3458 setTimeout(function(){ 3459 shop2_gr.methods.moreBtnAll(lazyElem); 3460 }, 100); 3461 3462 } else { 3463 var slider = lazyElem.querySelector('.brends_items_slider .brends-block__body'); 3464 var sliderAutoplay = +slider.getAttribute('data-autoplay'); 3465 3466 var respSettings = { 3467 320: {controls: false,items: 1,gutter: 0,disable: true}, 3468 740: {controls: false,items: 2,gutter: 16,disable: true}, 3469 1024: {controls: true,items: 4,gutter: 20,disable: false}, 3470 1261: {controls: true,items: 5,gutter: 20,disable: false} 3471 }; 3472 3473 var brends = tns({ 3474 loop: false, 3475 rewind: true, 3476 container: slider, 3477 slideBy: 1, 3478 autoplayHoverPause: true, 3479 mode: 'carousel', 3480 axis: 'horizontal', 3481 autoplay: sliderAutoplay, 3482 autoplayButtonOutput: false, 3483 mouseDrag: true, 3484 center: false, 3485 lazyload: true, 3486 autoWidth: false, 3487 nav: false, 3488 controls: true, 3489 navPosition: 'bottom', 3490 controlsPosition: 'top', 3491 preventActionWhenRunning: false, 3492 controlsText: ['<svg class="gr-svg-icon"><use xlink:href="#icon_site_arr_left_small"></use></svg>', '<svg class="gr-svg-icon "><use xlink:href="#icon_site_arr_right_small"></use></svg>'], 3493 responsive: respSettings 3494 }); 3495 3496 }; 3497 3498 /*shop2_gr.methods.grLazyFunc({selector:'.brends_items_slider'}, function(){ 3499 $('.brends-block__item_in').matchHeight(); 3500 });*/ 3501 }, 3502 3503 subscrip_form: function(lazyElem) { 3504 3505 function subscripForm() { 3506 3507 $.ajax({
3508 url: $('.bottom-form__body').data('api-url'), 3509 dataType: 'json', 3510 success: function(response) { 3511 if (!response.result.error) { 3512 3513 $('.bottom-form__body .tpl-anketa').remove(); 3514 $(response.result.html).appendTo('.bottom-form__body'); 3515 3516 s3From.initForms(); 3517 grFormDatePicker.init(); 3518 } 3519 } 3520 }); 3521 }; 3522 3523 subscripForm(); 3524 }, 3525 3526 question_form_mob: function(lazyElem) { 3527 3528 function question_form_mob() { 3529 3530 $.ajax({ 3531 url: $('.question-form__body').data('api-url'), 3532 dataType: 'json', 3533 success: function(response) { 3534 if (!response.result.error) { 3535 3536 $('.question-form__body .tpl-anketa').remove(); 3537 $(response.result.html).appendTo('.question-form__body'); 3538 3539 s3From.initForms(); 3540 grFormDatePicker.init(); 3541 } 3542 } 3543 }); 3544 }; 3545 3546 question_form_mob(); 3547 }, 3548 3549 question_form: function(lazyElem) { 3550 3551 var $callButton = $('.question-form__btn'), 3552 $callMeForm = $('.remodal[data-remodal-id="question-form"]'); 3553 3554 $callButton.on('click', function(e) { 3555 3556 $.ajax({
3557 url: $callButton.data('api-url'), 3558 dataType: 'json', 3559 success: function(response) { 3560 if (!response.result.error) { 3561 3562 $('.remodal[data-remodal-id="question-form"] .tpl-anketa').remove(); 3563 $callMeForm.append($(response.result.html)); 3564 3565 s3From.initForms(); 3566 grFormDatePicker.init(); 3567 3568 $callButton.removeClass('ajax-form'); 3569 } 3570 } 3571 }); 3572 }); 3573 }, 3574 3575 editSlider : function(lazyElem){ 3576 3577 var $mainSliderClass = $(".js__edit_slider"); 3578 3579 if ($mainSliderClass.length>0) { 3580 3581 var sliderAutoplay = $(".edit-slider__slider").data("autoplay"); 3582 3583 var multislider = document.querySelectorAll(".js__edit_slider"); 3584 3585 setTimeout(function(){ 3586 3587 shop2_gr.methods.resizeController(1023, function() { 3588 3589 if ($('.js__edit_slider').hasClass('tns-carousel')) { 3590 multislider.destroy(); 3591 }; 3592 3593 multislider = tns({ 3594 loop: true, 3595 container: '.js__edit_slider', 3596 autoHeight: false, 3597 slideBy: 1, 3598 items: 1, 3599 lazyload: true, 3600 swipeAngle: false, 3601 speed: 400, 3602 autoplayHoverPause: true, 3603 autoplay: sliderAutoplay, 3604 autoplayButtonOutput: false, 3605 nav: true, 3606 axis: "horizontal", 3607 preventActionWhenRunning: false, 3608 navPosition: 'bottom', 3609 controlsPosition: 'bottom', 3610 controlsContainer: ".edit-slider__controls", 3611 navContainer: ".edit-slider__nav" 3612 }); 3613 3614 3615 }, function() { 3616 3617 if ($('.js__edit_slider').hasClass('tns-carousel')) { 3618 multislider.destroy(); 3619 }; 3620 3621 multislider = tns({ 3622 loop: true, 3623 container: '.js__edit_slider', 3624 autoHeight: false, 3625 slideBy: 1, 3626 items: 1, 3627 lazyload: true, 3628 swipeAngle: false, 3629 speed: 400, 3630 autoplayHoverPause: true, 3631 autoplay: sliderAutoplay, 3632 autoplayButtonOutput: false, 3633 nav: true, 3634 axis: "vertical", 3635 preventActionWhenRunning: false, 3636 navPosition: 'bottom', 3637 controlsPosition: 'bottom', 3638 controlsContainer: ".edit-slider__controls", 3639 navContainer: ".edit-slider__nav" 3640 }); 3641 3642 }); 3643 3644 }, 200) 3645 3646 } 3647 }, 3648 3649 newsBlock : function(lazyElem){ 3650 if (!$(lazyElem).hasClass('news_items_slider')) { 3651 3652 setTimeout(function(){ 3653 shop2_gr.methods.moreBtnAll(lazyElem); 3654 }, 100); 3655 3656 } else { 3657 var slider = lazyElem.querySelector('.news_items_slider .news-block__body'); 3658 var sliderAutoplay = +slider.getAttribute('data-autoplay'); 3659 3660 var respSettings = { 3661 320: {controls: false,items: 1,gutter: 0,disable: true}, 3662 740: {controls: false,items: 2,gutter: 16,disable: true}, 3663 1024: {controls: true,items: 2,gutter: 20,disable: false}, 3664 1261: {controls: true,items: 2,gutter: 20,disable: false} 3665 }; 3666 3667 var news = tns({ 3668 loop: false, 3669 rewind: true, 3670 container: slider, 3671 slideBy: 1, 3672 autoplayHoverPause: true, 3673 mode: 'carousel', 3674 axis: 'horizontal', 3675 autoplay: sliderAutoplay, 3676 autoplayButtonOutput: false, 3677 mouseDrag: true, 3678 center: false, 3679 lazyload: true, 3680 autoWidth: false, 3681 nav: false, 3682 controls: true, 3683 navPosition: 'bottom', 3684 controlsPosition: 'top', 3685 preventActionWhenRunning: false, 3686 controlsText: ['<svg class="gr-svg-icon"><use xlink:href="#icon_site_arr_left_small"></use></svg>', '<svg class="gr-svg-icon "><use xlink:href="#icon_site_arr_right_small"></use></svg>'], 3687 responsive: respSettings 3688 }); 3689 3690 }; 3691 3692 shop2_gr.methods.grLazyFunc({selector:'.news_items_slider'}, function(){ 3693 $('.news-block__item_in').matchHeight(); 3694 }); 3695 }, 3696 3697 reviewsBlock : function(lazyElem){ 3698 if (!$(lazyElem).hasClass('reviews_items_slider')) { 3699 3700 setTimeout(function(){ 3701 shop2_gr.methods.moreBtnAll(lazyElem); 3702 }, 100); 3703 3704 } else { 3705 var slider = lazyElem.querySelector('.reviews_items_slider .reviews-block__body'); 3706 var sliderAutoplay = +slider.getAttribute('data-autoplay'); 3707 3708 var respSettings = { 3709 320: {controls: false,items: 1,gutter: 0,disable: true}, 3710 740: {controls: false,items: 2,gutter: 16,disable: true}, 3711 1024: {controls: true,items: 2,gutter: 20,disable: false}, 3712 1261: {controls: true,items: 2,gutter: 20,disable: false} 3713 }; 3714 3715 var reviews = tns({ 3716 loop: false, 3717 rewind: true, 3718 container: slider, 3719 slideBy: 1, 3720 autoplayHoverPause: true, 3721 mode: 'carousel', 3722 axis: 'horizontal', 3723 autoplay: sliderAutoplay, 3724 autoplayButtonOutput: false, 3725 mouseDrag: true, 3726 center: false, 3727 lazyload: true, 3728 autoWidth: false, 3729 nav: false, 3730 controls: true, 3731 navPosition: 'bottom', 3732 controlsPosition: 'top', 3733 preventActionWhenRunning: false, 3734 controlsText: ['<svg class="gr-svg-icon"><use xlink:href="#icon_site_arr_left_small"></use></svg>', '<svg class="gr-svg-icon "><use xlink:href="#icon_site_arr_right_small"></use></svg>'], 3735 responsive: respSettings 3736 }); 3737 3738 }; 3739 3740 shop2_gr.methods.grLazyFunc({selector:'.reviews_items_slider'}, function(){ 3741 $('.reviews-block__item_in').matchHeight(); 3742 }); 3743 }, 3744 3745 galleryBlock : function(lazyElem){ 3746 if (!$(lazyElem).hasClass('gallery_items_slider')) { 3747 3748 setTimeout(function(){ 3749 shop2_gr.methods.moreBtnAll(lazyElem); 3750 }, 100); 3751 3752 } else { 3753 var slider = lazyElem.querySelector('.gallery_items_slider .gallery-block__body'); 3754 var sliderAutoplay = +slider.getAttribute('data-autoplay'); 3755 3756 var respSettings = { 3757 320: {controls: false,items: 2,gutter: 16,disable: true}, 3758 640: {controls: false,items: 2,gutter: 16,disable: true}, 3759 740: {controls: false,items: 3,gutter: 16,disable: true}, 3760 1024: {controls: true,items: 3,gutter: 20,disable: false}, 3761 1261: {controls: true,items: 3,gutter: 20,disable: false}, 3762 1421: {controls: true,items: 5,gutter: 20,disable: false} 3763 }; 3764 3765 var gallery = tns({ 3766 loop: false, 3767 rewind: true, 3768 container: slider, 3769 slideBy: 1, 3770 mode: "carousel", 3771 axis: "horizontal", 3772 autoplayHoverPause: true, 3773 autoplay: sliderAutoplay, 3774 autoplayButtonOutput: false, 3775 mouseDrag: true, 3776 nav: true, 3777 navPosition: "bottom", 3778 controlsText: shop2_gr.settings.sliderControls, 3779 preventActionWhenRunning: false, 3780 responsive: respSettings 3781 }); 3782 3783 }; 3784 3785 $('.gallery-block__body').lightGallery({ 3786 thumbnail: false, 3787 download: true, 3788 loop: false, 3789 counter: false, 3790 getCaptionFromTitleOrAlt: true, 3791 selector: '.gallery-block__item_image' 3792 }); 3793 }, 3794 3795 getMainProducts: function (url, active_array_id, empty_products, callback){ 3796 $.ajax({
3797 url: url, 3798 dataType: "JSON", 3799 data: { 3800 param: { 3801 s: { 3802 product_id: active_array_id 3803 }, 3804 limit: (active_array_id.length + 1), 3805 template: "global:shop2.2.130-product-list.tpl" 3806 } 3807 }, 3808 error: (error) => { 3809 alert(error); 3810 console.warn(error); 3811 return false; 3812 }, 3813 success: (response) => { 3814 if( response.error ){ 3815 console.warn('ÐÑибка аÑкÑа: ', response); 3816 }else if (response.result.success) { 3817 var gr_has_compare = typeof gr_compare_kind_id; 3818 $(response.result.html).find('.shop2-product-item').each(function(){ 3819 var _this_item = this; 3820 var id_product = _this_item.querySelector('[name="product_id"]').value; 3821 Array.prototype.forEach.call(empty_products, function(item, i){ 3822 if( +item.dataset['mainProductId'] == +id_product ){ 3823 item.innerHTML = ''; 3824 item.appendChild(_this_item.cloneNode(true)); 3825 3826 if (gr_has_compare!='undefined' && gr_compare_kind_id[item.querySelector('[name="kind_id"]').value]) { 3827 product_compare = item.querySelector('.product-compare'); 3828 product_compare.classList.add( 'product-compare-added' ); 3829 product_compare.innerHTML = `<label class="gr-compare-checkbox"> 3830 <svg class="gr-svg-icon"><use xlink:href="#icon_shop_compare_added"></use></svg> 3831 <svg class="gr-svg-icon gr_small_icon"><use xlink:href="#icon_shop_compare_added_small"></use></svg> 3832 <input type="checkbox" value="`+item.querySelector('[name="kind_id"]').value+`" checked="true" autocomplete="off"></label> 3833 <a class="link-reset custom-underlined-link" data-remodal-target="compare-preview-popup" href="/magazin/compare" target="_blank">CÑавниÑÑ <span>`+Object.keys(gr_compare_kind_id).length+`</span></a> 3834 </div>`; 3835 }; 3836 item.classList.remove('gr_empty_product'); 3837 }; 3838 }); 3839 }); 3840 3841 if (callback) { 3842 callback(); 3843 }; 3844 } 3845 } 3846 }); 3847 }, /*ÐолÑÑение ÑоваÑов на главной*/ 3848 3849 grConvertToRgb: function(hexCode){ 3850 var hex = hexCode.replace('#',''); 3851 3852 if (hex.length === 3) { 3853 hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; 3854 } 3855 3856 var r = parseInt(hex.substring(0,2), 16), 3857 g = parseInt(hex.substring(2,4), 16), 3858 b = parseInt(hex.substring(4,6), 16); 3859 3860 return [r,g,b]; 3861 }, /*ÐонвеÑÑаÑÐ¸Ñ HEX в RGB*/ 3862 3863 viewLots: function(elem) { 3864 if (elem) { 3865 var $productList = $(elem); 3866 var $productItem = $productList.find('.product-item'); 3867 var loadedValue = $('.shop-view__item.active-view').data('value'); 3868 } else { 3869 var $productList = $('.product-list'); 3870 var $productItem = $('.product-item'); 3871 var loadedValue = $('.shop-view__item.active-view').data('value'); 3872 }; 3873 3874 if ( loadedValue == 'thumbs' ) { 3875 $('.product-list-titles').addClass('hide'); 3876 3877 $productItem.each(function() { 3878 var $flags = $(this).find('.product-flags'); 3879 var $flagsContainer = $(this).find('.product-item__top'); 3880 3881 $flags.appendTo($flagsContainer); 3882 }); 3883 } else if ( loadedValue == 'simple' ) { 3884 $('.product-list-titles').addClass('hide'); 3885 3886 $productItem.each(function() { 3887 var $flags = $(this).find('.product-flags'); 3888 var $flagsContainer = $(this).find('.product-item__top'); 3889 3890 $flags.appendTo($flagsContainer); 3891 }); 3892 } else if ( loadedValue == 'list' ) { 3893 $('.product-list-titles').removeClass('hide'); 3894 3895 $productItem.each(function() { 3896 var $flags = $(this).find('.product-flags'); 3897 var $flagsContainer = $(this).find('.product-item__bottom-left'); 3898 3899 $flags.prependTo($flagsContainer); 3900 }); 3901 }; 3902 3903 $('.shop-view .shop-view__item').on('click', function(e) { 3904 var $this = $(this), 3905 value = $this.data('value'); 3906 3907 if ( value == 'thumbs' ) { 3908 $('.product-list-titles').addClass('hide'); 3909 3910 $productItem.each(function() { 3911 var $flags = $(this).find('.product-flags'); 3912 var $flagsContainer = $(this).find('.product-item__top'); 3913 3914 $flags.appendTo($flagsContainer); 3915 });
3916 } else if ( value == 'simple' ) { 3917 $('.product-list-titles').addClass('hide'); 3918 3919 $productItem.each(function() { 3920 var $flags = $(this).find('.product-flags'); 3921 var $flagsContainer = $(this).find('.product-item__top'); 3922 3923 $flags.appendTo($flagsContainer); 3924 }); 3925 } else if ( value == 'list' ) { 3926 $('.product-list-titles').removeClass('hide'); 3927 3928 $productItem.each(function() { 3929 var $flags = $(this).find('.product-flags'); 3930 var $flagsContainer = $(this).find('.product-item__bottom-left'); 3931 3932 $flags.prependTo($flagsContainer); 3933 }); 3934 }; 3935 3936 $this 3937 .addClass('active-view') 3938 .siblings() 3939 .removeClass('active-view'); 3940 3941 if ($productList.length>0) { 3942 $productList 3943 .removeClass($productList.attr('class').replace( /[a-zA-Z0-9_-]+(?=\s)/, "" )) 3944 .addClass(value); 3945 }; 3946 3947 $(this).parents('.shop-view__inner').removeClass('active'); 3948 3949 createCookie('views', value, 30); 3950 3951 setTimeout(function() { 3952 $.fn.matchHeight._update(); 3953 }, 300); 3954 3955 e.preventDefault(); 3956 3957 return false; 3958 }); 3959 }, /*ÐÑеклÑÑение видов оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ ÑоваÑов в каÑегоÑии*/ 3960 3961 amountInit: function(elem) { 3962 var items = '.cart-products__item, .shop2-product-item, .shop2-product, .kind-item, .popup-product'; 3963 if (elem) { 3964 var items = elem; 3965 }; 3966 $(items).each(function() { 3967 var $this = $(this); 3968 var $amountWrap = $this.find('.shop2-product-amount'); 3969 var $input = $amountWrap.find('input[type="text"]'); 3970 var $buttons = $amountWrap.find('button'); 3971 var $minus = $amountWrap.find('button.amount-minus'); 3972 var $plus = $amountWrap.find('button.amount-plus'); 3973 var min = $amountWrap.find('input').data('min'); 3974 var inputVal = +$input.val(); 3975 3976 3977 if (inputVal<=min) { 3978 $minus.attr('disabled', 'disabled'); 3979 } 3980 3981 $buttons.on('click', function(){ 3982 var parent = $(this).parent(); 3983 var input = parent.find('input'); 3984 3985 setTimeout(function(){ 3986 var inputVal = +input.val(); 3987 3988 if (inputVal<=min) { 3989 $minus.attr('disabled', 'disabled'); 3990 } else { 3991 $minus.removeAttr('disabled'); 3992 } 3993 }, 100); 3994 }); 3995 3996 $input.on('change', function(e) { 3997 var curVal = +$(this).val(); 3998 3999 if (curVal < min) { 4000 $(this).val(min); 4001 } else if (curVal == min) { 4002 $minus.attr('disabled', 'disabled'); 4003 } else if (curVal > min) { 4004 $minus.removeAttr('disabled'); 4005 } 4006 }); 4007 }); 4008 }, /*ÐолиÑеÑÑво*/ 4009 4010 resizeController: function(elem) { 4011 var $win = $(window), 4012 winWidth = window.innerWidth, 4013 range = [], 4014 func = [], 4015 toggleState = [undefined, undefined]; 4016 4017 if (!!arguments.length) { 4018 for (var i = 0; i <= arguments.length-1; i++) { 4019 4020 if ($.isArray(arguments[i])) { 4021 range = arguments[i]; 4022 } else if ($.isNumeric(arguments[i])) { 4023 range.push(arguments[i]); 4024 } else if ($.isFunction(arguments[i])) { 4025 func.push(arguments[i]); 4026 } 4027 }; 4028 } 4029 4030 $win.resize(function(event) { 4031 winWidth = window.innerWidth; 4032 4033 if (range.length > 1) { 4034 if (winWidth >= range[0] && winWidth <= range[range.length-1] && typeof toggleState[0] === 'undefined') { 4035 func[0](); 4036 toggleState[0] = true; 4037 toggleState[1] = undefined; 4038 } else if ((winWidth < range[0] || winWidth > range[range.length-1]) && typeof toggleState[1] === 'undefined') { 4039 toggleState[0] = undefined; 4040 toggleState[1] = true; 4041 4042 if ($.isFunction(func[1])) { 4043 func[1](); 4044 } 4045 } 4046 } else if (range.length == 1) { 4047 if (winWidth <= range[0] && typeof toggleState[0] === 'undefined') { 4048 func[0](); 4049 toggleState[0] = true; 4050 toggleState[1] = undefined; 4051 } else if (winWidth > range[0] && typeof toggleState[1] === 'undefined') { 4052 toggleState[0] = undefined; 4053 toggleState[1] = true; 4054 4055 if ($.isFunction(func[1])) { 4056 func[1](); 4057 } 4058 } 4059 } 4060 }).trigger('resize'); 4061 }, 4062 4063 arrowsPosition: function(slider, item) { 4064 if ($(slider).length){ 4065 var arrows_timeout; 4066 4067 $(slider).each(function() { 4068 var $this = $(this); 4069 var $image = $this.find(item); 4070 var $controls = $this.parents('.tns-outer').find('.tns-controls'); 4071 4072 if ($image.parents('form').length) { 4073 var paddingTop = $image.offset().top - $image.parents('form').offset().top; 4074 var imgHeight = ($image.outerHeight() + paddingTop) - ($image.outerHeight() / 2); 4075 } else { 4076 var imgHeight = $image.outerHeight() / 2; 4077 }; 4078 4079 $controls.css({ 4080 "top": imgHeight 4081 }); 4082 }); 4083 4084 $(window).on('resize', function() { 4085 if (arrows_timeout) { 4086 clearTimeout(arrows_timeout); 4087 }; 4088 4089 arrows_timeout = setTimeout(function() { 4090 $(slider).each(function() { 4091 var $this = $(this); 4092 var $image = $this.find(item); 4093 var $controls = $this.parents('.tns-outer').find('.tns-controls'); 4094 4095 if ($image.parents('form').length) { 4096 var paddingTop = $image.offset().top - $image.parents('form').offset().top; 4097 var imgHeight = ($image.outerHeight() + paddingTop) - ($image.outerHeight() / 2); 4098 } else { 4099 var imgHeight = $image.outerHeight() / 2; 4100 }; 4101 4102 $controls.css({ 4103 "top": imgHeight 4104 }); 4105 }); 4106 }, 50); 4107 }); 4108 }; 4109 }, /*ÐозиÑиониÑование навигаÑии ÑлайдеÑа оÑноÑиÑелÑно блоков*/ 4110 4111 } 4112 4113 shop2_gr.init(); 4114 myObject.shop2_gr = shop2_gr; 4115 4116})(jQuery, window); 4117 4118shop2.margin_price = { 4119 price_change: function(j_this, selector_parent){ 4120 4121 if( shop2.mode == 'cart' ){ 4122 form = $('#shop2-cart'); 4123 shop2.cart.update(form); 4124 4125 return; 4126 } 4127 4128 var 4129 $form = $(j_this).closest(selector_parent), 4130 form = $form.get(0), 4131 kind_id = form.kind_id.value, 4132 4133 adds = $form.find('.additional-cart-params'), 4134 len = adds.length, 4135 el; 4136 4137 4138 var param = { 4139 'kind_id': form.kind_id.value, 4140 'params': {} 4141 } 4142 4143 if (len) { 4144 4145 for (var i = 0; i < len; i += 1) { 4146 el = adds[i]; 4147 if (el.value) { 4148 param.params[el.name] = el.value; 4149 } 4150 } 4151 } 4152 $.ajax({
4153 url: '/-/x-api/v1/public/?method=shop2/getPrice', 4154 type: "get", 4155 data: {"param": param}, 4156 dataType: "json", 4157 success: function(data){ 4158 4159 $form.find('.price-current').replaceWith( data.result.data.html.price ); 4160 $form.find('.price-old ').replaceWith( data.result.data.html.price_old ); 4161 4162 let pr_price = $form.find('.price-current strong').html().replace(" ",""), 4163 pr_percentage = $form.find('.price-current2').data('percentage'), 4164 pr_discount_price = pr_price - (pr_price * pr_percentage); 4165 4166 $form.find('.price-current2 strong').text(pr_discount_price.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1 ')); 4167 } 4168 4169 }); 4170 }, 4171 select_change: function(){ 4172 if( !shop2.cf_margin_price_enabled ){ 4173 return; 4174 }else{ 4175 $(document).on('click', '.shop2-color-ext-list li', function() { 4176 var $this = $(this); 4177 4178 setTimeout(function(){ 4179 shop2.margin_price.price_change($this, 'form'); 4180 }, 10) 4181 }) 4182 var additional_cart_params = $('select.additional-cart-params'); 4183 4184 if( additional_cart_params.length ){ 4185 $.on('select.additional-cart-params', { 4186 change: function(e) { 4187 shop2.margin_price.price_change( $( e.target ), 'form'); 4188 } 4189 }); 4190 }else { 4191 return; 4192 } 4193 } 4194 4195 } 4196 };
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.