Advertisement
valeraplusplus

lpc main.js 27.02.25

Feb 27th, 2025
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*const lpcQueryString = window.location.search; // НЕ УДАЛЯТЬ - НГ оформление
  2.  
  3. if (lpcQueryString.includes('lpc_disable_snow')) {
  4.    
  5.     createCookie('lpc_disable_snow', 1, 30);
  6. }
  7.  
  8. function letItSnow() {
  9.       var COUNT = 30;
  10.       var masthead = document.querySelector('.sky');
  11.       var canvas = document.createElement('canvas');
  12.       var ctx = canvas.getContext('2d');
  13.       var width = masthead.clientWidth;
  14.       var height = masthead.clientHeight;
  15.       var i = 0;
  16.       var active = false;
  17.    
  18.       function onResize() {
  19.         width = masthead.clientWidth;
  20.         height = masthead.clientHeight;
  21.         canvas.width = width;
  22.         canvas.height = height;
  23.         ctx.fillStyle = '#FFF';
  24.    
  25.         var wasActive = active;
  26.         active = width > 600;
  27.    
  28.         if (!wasActive && active)
  29.           requestAnimFrame(update);
  30.       }
  31.    
  32.       var Snowflake = function () {
  33.         this.x = 0;
  34.         this.y = 0;
  35.         this.vy = 0;
  36.         this.vx = 0;
  37.         this.r = 0;
  38.    
  39.         this.reset();
  40.       }
  41.    
  42.       Snowflake.prototype.reset = function() {
  43.         this.x = Math.random() * width;
  44.         this.y = Math.random() * -height;
  45.         this.vy = 1 + Math.random() * 3;
  46.         this.vx = 0.5 - Math.random();
  47.         this.r = 1 + Math.random() * 2;
  48.         this.o = 0.5 + Math.random() * 0.5;
  49.       }
  50.    
  51.       canvas.style.position = 'absolute';
  52.       canvas.style.left = canvas.style.top = '0';
  53.    
  54.       var snowflakes = [], snowflake;
  55.       for (i = 0; i < COUNT; i++) {
  56.         snowflake = new Snowflake();
  57.         snowflake.reset();
  58.         snowflakes.push(snowflake);
  59.       }
  60.    
  61.       function update() {
  62.    
  63.         ctx.clearRect(0, 0, width, height);
  64.    
  65.         if (!active)
  66.           return;
  67.    
  68.         for (i = 0; i < COUNT; i++) {
  69.           snowflake = snowflakes[i];
  70.           snowflake.y += snowflake.vy;
  71.           snowflake.x += snowflake.vx;
  72.    
  73.           ctx.globalAlpha = snowflake.o;
  74.           ctx.beginPath();
  75.           ctx.arc(snowflake.x, snowflake.y, snowflake.r, 0, Math.PI * 2, false);
  76.           ctx.closePath();
  77.           ctx.fill();
  78.    
  79.           if (snowflake.y > height) {
  80.             snowflake.reset();
  81.           }
  82.         }
  83.    
  84.         requestAnimFrame(update);
  85.       }
  86.    
  87.       // shim layer with setTimeout fallback
  88.       window.requestAnimFrame = (function(){
  89.         return  window.requestAnimationFrame       ||
  90.                 window.webkitRequestAnimationFrame ||
  91.                 window.mozRequestAnimationFrame    ||
  92.                 function( callback ){
  93.                   window.setTimeout(callback, 1000 / 60);
  94.                 };
  95.       })();
  96.    
  97.       onResize();
  98.       window.addEventListener('resize', onResize, false);
  99.    
  100.       masthead.appendChild(canvas);
  101. };*/
  102.  
  103. ;(function () {
  104.   var $win = $(window),
  105.     $doc = $(document),
  106.     $body = $("body"),
  107.     initializedMaps = [],
  108.     lpc_template = {},
  109.     isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
  110.     isApple = /iPod|iPad|iPhone/i.test(navigator.userAgent);
  111.  
  112.     window.lpc_template = lpc_template;
  113.  
  114.     lpc_template.queue = {};
  115.    
  116.     $body.on('click', 'a[href^="popup:"]', function (e) {
  117.         e.preventDefault();
  118.     });
  119.  
  120.     function lpcCreateBlockProducts(
  121.         jquery_block,
  122.         dataOptionOption,
  123.         callBack = { beforeAjax: null, complete: null }
  124.     ){
  125.         class createBLockProduct {
  126.                    
  127.             constructor($block) {
  128.                 this.$block = $block;
  129.                 this.response = null;
  130.                 this.dataSliderInit = null,
  131.                 this.spoilerInit = null,
  132.                 this.extenSettingBegin = function() {
  133.                     let _this = this;
  134.                     _this.dataSliderInit = _this.$block.attr('data-ajax-slider-init') ? _this.$block : _this.$block.find('.splide-init');
  135.                     if (_this.dataSliderInit.length && _this.dataSliderInit.find('.splide .is-active').length) {
  136.                         _this.dataSliderInit.each(function() {
  137.                             $(this).removeAttr('data-ajax-slider-init');
  138.                             let slider = $(this).find(".splide")[0];
  139.                             let splide = new Splide(slider);
  140.                             splide.mount();
  141.                             splide.destroy();
  142.                         })
  143.                     }
  144.                
  145.                     _this.spoilerInit = _this.$block.hasClass('spoiler-init') ? _this.$block : _this.$block.find('.spoiler-init');
  146.                     if (_this.spoilerInit.length) {
  147.                         _this.spoilerInit.each(function() {
  148.                             $(this).removeClass('spoiler-init');
  149.                         })
  150.                     }
  151.                 };
  152.                 this.extenSettingFinish = function(){
  153.                     let _this = this;
  154.                     if (_this.dataSliderInit.length) {
  155.                         _this.dataSliderInit.each(function() {
  156.                             $(this).attr('data-ajax-slider-init', 'true');
  157.                             $(this).find('.splide.is-active').removeClass('.is-active');
  158.                         })
  159.                     }
  160.                     if (_this.spoilerInit.length) {
  161.                         _this.spoilerInit.each(function() {
  162.                             $(this).addClass('spoiler-init');
  163.                         })
  164.                     }
  165.                     setTimeout(() => {
  166.                         lpc_template.queue.spoilerBlock(_this.$block);
  167.                         _this.setAjaxSlider(_this.$block);
  168.                         setTimeout(() => {
  169.                             lpc_template.queue.lg(_this.$block);
  170.                         }, 300);
  171.                     }, 300);
  172.        
  173.                 };
  174.                 this.setAjaxSlider = function() {
  175.                    
  176.                     let _this = this;
  177.                     let $block = _this.$block.attr('data-ajax-slider-init') ? _this.$block : _this.$block.find('[data-ajax-slider-init]');
  178.                     if ($block.length) {
  179.            
  180.                         if ($block.data('slider-thumb-init') != true) {
  181.                             $block.each(function() {
  182.                                 let $this = $(this);
  183.                                 let $alignItem = $this.find($this.data('align-item'));
  184.                                 let mediaGap = $this.data('margin');
  185.                                 let mediaPerPage = $(this).data('count');
  186.                                 if ($(this).data('move')) {
  187.                                     var $mediaMove = $(this).data('move');
  188.            
  189.                                 } else {
  190.                                     var $mediaMove = 1;
  191.                                 }
  192.                                
  193.                                 if ($this.find('.splide').not('.is-active').length != 0) {
  194.                                     let splide = new Splide($this.find('.splide').not('.is-active')[0], {
  195.                                         autoplay: $this.data('autoplay'),
  196.                                         speed: $this.data('speed'),
  197.                                         interval: $this.data('pause'),
  198.                                         /*rewind: $this.data('infinite'),*/
  199.                                         lazyLoad: $this.data('lazy-load'),
  200.                                         rewind: true,
  201.                                         perMove: $mediaMove,
  202.                                         perPage: checkInitPerPage()
  203.                                     });
  204.            
  205.            
  206.                                     splide.mount();
  207.            
  208.                                     sliderBreakPoints();
  209.            
  210.                                     document.addEventListener('lpcPopupOpened', function() {
  211.                                         splide.refresh();
  212.                                     });
  213.            
  214.                                     document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  215.            
  216.                                     function sliderBreakPoints() {
  217.                                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  218.            
  219.                                         setTimeout(function() {
  220.                                             if ($alignItem.length) {
  221.                                                 let itemHeight = $alignItem.outerHeight() / 2;
  222.                                                 let arrowsPosition = itemHeight + $alignItem.position().top;
  223.            
  224.                                                 $this.find('.splide__arrow').css('top', arrowsPosition);
  225.                                             }
  226.                                         }, 100);
  227.            
  228.                                         switch (dataMediaSource) {
  229.                                             case 'media-xl':
  230.                                                 splide.options = {
  231.                                                     arrows: true,
  232.                                                     pagination: true,
  233.                                                     gap: mediaGap[0],
  234.                                                     perPage: mediaPerPage[0],
  235.                                                 };
  236.            
  237.                                                 break;
  238.                                             case 'media-lg':
  239.                                                 splide.options = {
  240.                                                     arrows: true,
  241.                                                     pagination: true,
  242.                                                     gap: mediaGap[1],
  243.                                                     perPage: mediaPerPage[1],
  244.                                                 };
  245.            
  246.                                                 break;
  247.                                             case 'media-md':
  248.                                                 splide.options = {
  249.                                                     arrows: true,
  250.                                                     pagination: true,
  251.                                                     gap: mediaGap[2],
  252.                                                     perPage: mediaPerPage[2],
  253.                                                 };
  254.            
  255.                                                 break;
  256.                                             case 'media-sm':
  257.                                                 splide.options = {
  258.                                                     arrows: false,
  259.                                                     pagination: true,
  260.                                                     rewindByDrag: true,
  261.                                                     gap: mediaGap[3],
  262.                                                     perPage: mediaPerPage[3],
  263.                                                 };
  264.            
  265.                                                 break;
  266.                                             case 'media-xs':
  267.                                                 splide.options = {
  268.                                                     arrows: false,
  269.                                                     pagination: true,
  270.                                                     rewindByDrag: true,
  271.                                                     gap: mediaGap[4],
  272.                                                     perPage: mediaPerPage[4],
  273.                                                 };
  274.            
  275.                                                 break;
  276.                                         }
  277.                                     };
  278.            
  279.                                     function checkInitPerPage() {
  280.                                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  281.            
  282.                                         switch (dataMediaSource) {
  283.                                             case 'media-xl':
  284.                                                 return mediaPerPage[0]
  285.                                                 break;
  286.                                             case 'media-lg':
  287.                                                 return mediaPerPage[1]
  288.                                                 break;
  289.                                             case 'media-md':
  290.                                                 return mediaPerPage[2]
  291.                                                 break;
  292.                                             case 'media-sm':
  293.                                                 return mediaPerPage[3]
  294.                                                 break;
  295.                                             case 'media-xs':
  296.                                                 return mediaPerPage[4]
  297.                                                 break;
  298.                                         };
  299.                                     };
  300.            
  301.                                     //sliderObjectItems[splide.root.id] = splide;
  302.                                 }
  303.                             });
  304.                         }
  305.                     }
  306.                 };
  307.                 this.getCompare = function() {
  308.                     var popup_data;
  309.                    
  310.                     if (shop2.my.gr_new_notification) {
  311.                         var compare_arrow = '<i class="gr-mask-icon"><svg class="gr-svg-icon"><use xlink:href="#icon_shop_notify_arr"></use></svg></i>';
  312.                     } else {
  313.                         var compare_arrow = '<i><svg class="gr-svg-icon"><use xlink:href="#icon_shop_notify_arr"></use></svg></i>';
  314.                     }
  315.                    
  316.                     if (shop2.my.gr_popup_compare) {
  317.                         popup_data = ' data-remodal-target="compare-preview-popup"';
  318.                     };
  319.                    
  320.                     let $document = $(document);
  321.                    
  322.                     if (shop2.my.gr_new_notification) {
  323.                         var compareBtn = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn gr-compare-tooltip-btn"'+popup_data+' target="_blank">'+ _s3Lang.SHOP2_ADD_TO_COMPARE3 +' '+compare_arrow+'</a>';
  324.                         var compareBtn2 = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn gr-compare-tooltip-btn"'+popup_data+' target="_blank">'+ _s3Lang.SHOP2_GO_TO_COMPARE +' '+compare_arrow+'</a>';
  325.                
  326.                     } else {
  327.                         var compareBtn = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn"'+popup_data+' target="_blank">'+ _s3Lang.SHOP2_ADD_TO_COMPARE3 +' '+compare_arrow+'</a>';
  328.                         var compareBtn2 = '<a href="' + shop2.uri + '/compare" class="go-to-compare-btn"'+popup_data+' target="_blank">'+ _s3Lang.SHOP2_GO_TO_COMPARE +' '+compare_arrow+'</a>';
  329.                
  330.                     }
  331.                    
  332.                     function update(el, res) {
  333.                        
  334.                         if (shop2.my.gr_new_notification) {
  335.                             var $form = $(el).closest('form');
  336.                             var $image = $form.find('.gr-product-image--js');
  337.                             var isAdded = $(el).closest('.lpc-product-compare ').hasClass('product-compare--added');
  338.                         }
  339.                        
  340.                         $('input[type=checkbox][value=' + el.val() + ']').closest('.lpc-product-compare').replaceWith(res.data);
  341.                         $('input[type=checkbox][value=' + el.val() + ']').closest('.product-compare').addClass('lpc-product-compare lp-header-text-3').removeClass('product-compare');
  342.                         $('input[type=checkbox][value=' + el.val() + ']').closest('.gr-compare-checkbox').addClass('lpc-product-compare__checkbox').prepend('<i class="lpc-product-compare__icon"></i>');
  343.                         $('input[type=checkbox][value=' + el.val() + ']').closest('.gr-compare-plus').addClass('lpc-compare-plus').prepend('<i class="lpc-product-compare__icon"></i>');
  344.                        
  345.                        
  346.                         //$('.lpc-product-compare-added a span').html(res.count);
  347.                         //$('.gr-compare-btn .gr-compare-btn-amount').html(res.count);
  348.                        
  349.                         if (+$('.gr-compare-btn .gr-compare-btn-amount').text() == '0') {
  350.                             $('.gr-compare-btn').removeClass('active');
  351.                         } else {
  352.                             $('.gr-compare-btn').addClass('active');
  353.                         };
  354.                        
  355.                         if (!$('.compare-remodal').hasClass('remodal-is-opened')) {
  356.                             if (shop2.my.gr_new_notification) {
  357.                                 if (!isAdded) {
  358.                                     shop2.popupNotification({
  359.                                         "itemContent": '<span class="gr-compare-tooltip-counter">'+res.count+'</span>' + ' '+ _s3Lang.SHOP2_PRODUCT_ADDED +' ' + compareBtn,
  360.                                         "itemClass": "gr-notification__item--compare",
  361.                                         "itemImage": shop2.my.gr_hide_msg_image ? false : true,
  362.                                         "itemSrc": $image.find('img').attr('src'),
  363.                                         "itemHref": $image.attr('href'),
  364.                                         "itemContain": $image.data('image-view'),
  365.                                         "itemSize": $image.data('image-size'),
  366.                                     });
  367.                                 };
  368.                             } else {
  369.                                 shop2.msg('<span class="go-to-compare-count">'+res.count+'</span>' + ' '+ _s3Lang.SHOP2_PRODUCT_ADDED +' ' + compareBtn, $('body'));
  370.                             }
  371.                         };
  372.                
  373.                         if (res.panel) {
  374.                             $('#shop2-panel').replaceWith(res.panel);
  375.                         };
  376.                     }
  377.                
  378.                     $document.on('click', '.lpc-product-compare input:checkbox', function(d) {
  379.                        
  380.                         let $this = $(this),
  381.                             action = $this.attr('checked') ? 'del' : 'add';
  382.                            
  383.                             if (shop2.my.gr_new_notification) {
  384.                                 var $form = $($this).closest('form');
  385.                                 var $image = $form.find('.gr-product-image--js');
  386.                             }
  387.                            
  388.                         lpc_template.queue.lpcCompare.action(action, $this.val(), function(res, status) {
  389.                             if (status == 'success') {
  390.                                 if (res.errstr) {
  391.                                     if (!$('.compare-remodal').hasClass('remodal-is-opened')) {
  392.                                         if (shop2.my.gr_new_notification) {
  393.                        
  394.                                             shop2.popupNotification({
  395.                                                 "itemContent": res.errstr + '<div class="go-to-compare-error">'+compareBtn2+'</div>',
  396.                                                 "itemClass": "gr-notification__item--compare",
  397.                                                 "itemImage": shop2.my.gr_hide_msg_image ? false : true,
  398.                                                 "itemSrc": $image.find('img').attr('src'),
  399.                                                 "itemHref": $image.attr('href'),
  400.                                                 "itemContain": $image.data('image-view'),
  401.                                                 "itemSize": $image.data('image-size'),
  402.                                             });
  403.                                         } else {
  404.                                             shop2.msg(res.errstr + '<div class="go-to-compare-error">'+compareBtn2+'</div>', $('body'));
  405.                                         }
  406.                                     }
  407.                                     $this.prop('checked', false);
  408.                                 } else {
  409.                                     update($this, res);
  410.                                    
  411.                                     if (action == 'del' && !$('.compare-remodal').hasClass('remodal-is-opened')) {
  412.                                         if (shop2.my.gr_new_notification) {
  413.                        
  414.                                             shop2.popupNotification({
  415.                                                 "itemContent": _s3Lang.SHOP2_PRODUCT_REMOVED_COMPARE,
  416.                                                 "itemClass": "gr-notification__item--compare",
  417.                                                 "itemImage": shop2.my.gr_hide_msg_image ? false : true,
  418.                                                 "itemSrc": $image.find('img').attr('src'),
  419.                                                 "itemHref": $image.attr('href'),
  420.                                                 "itemContain": $image.data('image-view'),
  421.                                                 "itemSize": $image.data('image-size'),
  422.                                             });
  423.                                         } else {
  424.                                             shop2.msg(_s3Lang.SHOP2_PRODUCT_REMOVED_COMPARE, $('body'));
  425.                                         }
  426.                                     }
  427.                                     if (d.panel) {
  428.                                         $('#shop2-panel').replaceWith(d.panel);
  429.                                     }
  430.                                 }
  431.                             }
  432.                             $('.gr-compare-btn .gr-compare-btn-amount').html(res.count);
  433.                         });
  434.                     });
  435.                 }
  436.                
  437.                 this.receivingDataPopup = function() {
  438.                     var _this = this;
  439.                     let $blockList = _this.$block.find('.lpc-query-products');
  440.                     let optionLpcDecorPopup = {};
  441.                    
  442.                     optionLpcDecorPopup['lpc_product_show_options'] = $blockList.attr('data-lpc-product-show-options');
  443.                     optionLpcDecorPopup['lpc_product_on_lg'] = $blockList.attr('data-lpc-product-on-lg');
  444.                     optionLpcDecorPopup['lpc_product_vendor'] = $blockList.attr('data-lpc-product-vendor');
  445.                     optionLpcDecorPopup['lpc_product_rating'] = $blockList.attr('data-lpc-product-rating');
  446.                     optionLpcDecorPopup['lpc_product_article'] = $blockList.attr('data-lpc-product-article');
  447.                     optionLpcDecorPopup['lpc_product_annonce'] = $blockList.attr('data-lpc-product-annonce');
  448.                     optionLpcDecorPopup['lpc_product_sale'] = $blockList.attr('data-lpc-product-sale');
  449.                     optionLpcDecorPopup['lpc_product_amount_flag'] = $blockList.attr('data-lpc-product-amount-flag');
  450.                     optionLpcDecorPopup['lpc_product_amount'] = $blockList.attr('data-lpc-product-amount');
  451.                     optionLpcDecorPopup['lpc_product_one_click'] = $blockList.attr('data-lpc-product-one-click');
  452.                     optionLpcDecorPopup['lpc_product_img'] = $blockList.attr('data-lpc-product-img');
  453.  
  454.                    
  455.                     $(document).on('click', '.lpc-shop-lot__quick-trigger', function(e) {
  456.                         if(_this.$block.attr('id') == $(this).closest('.lpc-shop-lot').attr('id')){
  457.                             var $parentBlock = $(this).closest('.lpc-shop-lot'),
  458.                                 $popupBody = $parentBlock.find(".lpc-shop-lot__popup-body"),
  459.                                 $popupFixPanel = $parentBlock.find(".lpc-shop-lot__popup-fix-panel");
  460.                                
  461.                             e.preventDefault();
  462.    
  463.                             let $this = this;
  464.                             var url = $(this).attr("data-url") || $this.attr("href");
  465.                                 url += '?&products_only=1';
  466.                                 url += '?&lpc_product_card_popup=1';
  467.                            
  468.                             $.ajax({
  469.                                 url: url,
  470.                                 data: {
  471.                                     'option_decor_popup': JSON.stringify(optionLpcDecorPopup),
  472.                                 },
  473.                                 success: function(response) {
  474.                                     $popupBody.html(response);
  475.                                 },
  476.                                 // success
  477.                            
  478.                                 complete: function() {
  479.                                     var $blockWidth = $('.lpc-shop-lot:not(._not-data)').width();
  480.                                     var $priceClone = $parentBlock.find(".lpc-product-additional__top").find(".lpc-lot-popup__price-inner")
  481.                                     var $buyBtnClone = $parentBlock.find(".lpc-product-additional__top").find(".lpc-lot-popup-btns");
  482.                                      
  483.                                     $("html").addClass('lpc-shop-popup-scroll');
  484.                                    
  485.                                     setTimeout(function() {
  486.                                         $('.lpc-lot-popup').css('max-width',$blockWidth);
  487.                                     }, 1);
  488.                                    
  489.                                    
  490.                                     $(window).on("resize", function () {
  491.                                         var $blockWidth = $('.lpc-shop-lot').width();
  492.                                         $('.lpc-lot-popup').css('max-width',$blockWidth);
  493.                                     }).trigger("resize");
  494.        
  495.                                
  496.                                     setTimeout(function() {
  497.                                         lpc_template.queue.sliderBlockThumbGallery($('body'));
  498.                                     }, 200);
  499.                                    
  500.                                     $parentBlock.find('.lpc-favorite-btn').on('click', function(){
  501.                                         $(this).find("a").addClass("lp-header-text-3");
  502.                                     });
  503.                                    
  504.                                     setTimeout(function() {
  505.                                         if ($popupFixPanel.find('.lpc-lot-popup__price-inner').length == 0) {
  506.                                             $priceClone.clone().appendTo($popupFixPanel);
  507.                                             $buyBtnClone.clone().appendTo($popupFixPanel);
  508.                                         }
  509.                                     }, 200);
  510.                                    
  511.                                     var $sliderItemsLength = $parentBlock.find('.lpc-lot-popup-slider__thumb').length,
  512.                                         $sliderArrowHideCountXl = $parentBlock.find('.lpc-lot-popup-slider__thumbs').data('count-hide-xl'),
  513.                                         $sliderArrowHideCountLg = $parentBlock.find('.lpc-lot-popup-slider__thumbs').data('count-hide-lg');
  514.                                        
  515.                                     if($sliderItemsLength < $sliderArrowHideCountXl) {
  516.                                         $parentBlock.find('.lpc-lot-popup-slider__thumbs-body').addClass('xl-not-arrow');
  517.                                     }
  518.                                     if($sliderItemsLength < $sliderArrowHideCountLg) {
  519.                                         $parentBlock.find('.lpc-lot-popup-slider__thumbs-body').addClass('lg-not-arrow');
  520.                                     }
  521.                                    
  522.                                     setTimeout(function() {
  523.                                         lpc_template.queue.lgNew($('body'));
  524.                                     }, 100);
  525.                                    
  526.                                     /*$('.lpc-shop-lot__popup .lpc-options-more').each(function(){
  527.                                         $(this).on('click', function(){
  528.                                             $(this).toggleClass('active');
  529.                                             $(this).siblings('.lpc-options-container').slideToggle();
  530.                                         });
  531.                                     });*/
  532.                                    
  533.                                     lpc_template.queue.fixingPanelShow($('body'));
  534.                                 }//complete
  535.                             });
  536.                             setTimeout(function() {
  537.                                 $parentBlock.find(".lpc-shop-lot__popup").addClass('active');
  538.                             }, 50);
  539.                         }
  540.                     });
  541.                     $('.lpc-shop-lot__popup-back, .lpc-shop-lot__popup-close').on('click', function(){
  542.                         $(".lpc-shop-lot__popup").removeClass('active');
  543.                        
  544.                         $(this).closest('.lpc-shop-lot__popup').find(".lpc-lot-popup").html("");
  545.                         $('.lpc-shop-lot__popup-fix-panel').find('div').remove();
  546.                         $("html").removeClass('lpc-shop-popup-scroll');
  547.                     });
  548.                 };
  549.             }
  550.             /*
  551.             getProducts() {
  552.                 let _this = this;
  553.                 let folderId = _this.$block.find('.block-id-folder').text();
  554.                 let params = new URLSearchParams();
  555.                 params.append('param[type]', 'shop2');
  556.                 params.append('param[depth]', '99');
  557.  
  558.                 // Формируем URL для GET-запроса
  559.                 let url = '/-/x-api/v1/public/?method=folder/getTree&' + params.toString();
  560.                 $.ajax({
  561.                     url: url,
  562.                     success: function(data){
  563.                         window.item_f = data.result.items;
  564.                        
  565.                         if (folderId == 'not_found') {
  566.                             return;
  567.                         }
  568.                        
  569.                         let arrayFolder = []
  570.                         data.result.items.forEach( function( item, index){
  571.                             arrayFolder.push(item.folder_id);
  572.                         })
  573.  
  574.                         if( !arrayFolder.includes(folderId) ){
  575.                             return;
  576.                         }
  577.  
  578.  
  579.                         dataOptionOption.param.search.folder_id = folderId;
  580.                         var url = '/-/x-api/v1/public/?method=shop2/getProductsBySearch';
  581.                        
  582.                         if( typeof callBack.beforeAjax == 'function'){
  583.                             callBack.beforeAjax(_this);
  584.                         }
  585.                    
  586.                         $.ajax({
  587.                             url: url,
  588.                             dataType: "JSON",
  589.                             data: dataOptionOption,
  590.        
  591.                             success: function(response) {
  592.                                 if (response.result.success) {
  593.                                     _this.response = response;
  594.                                     _this.$block.find('.lpc_product_not_found_vv').removeClass('show');
  595.        
  596.                                     var dataHTML = response.result.html;
  597.                                    
  598.                                    
  599.                                     let containerProductForTemplate = _this.$block.find(`.containerProductForTemplate`);
  600.                                  
  601.                                     if (!response.result.html) {
  602.                                         containerProductForTemplate.closest('.lpc-block').addClass("_not-data");
  603.                                         return false;
  604.                                     };
  605.                                    
  606.                                     containerProductForTemplate.html(dataHTML);
  607.                                 }
  608.                             }, // success
  609.                    
  610.                             complete: function() {
  611.                                 if( typeof callBack.complete == 'function'){
  612.                                     callBack.complete(_this);
  613.                                 }
  614.                             } //complete
  615.                         });
  616.                     }
  617.                 })
  618.             }
  619.             */
  620.             getProducts() {
  621.                 let _this = this;
  622.                 let folderId = _this.$block.find('.block-id-folder').text();
  623.                 // Формируем URL для GET-запроса
  624.                 dataOptionOption.param.search.folder_id = folderId;
  625.                 var url = '/-/x-api/v1/public/?method=shop2/getProductsBySearch';
  626.                
  627.                 if( typeof callBack.beforeAjax == 'function'){
  628.                     callBack.beforeAjax(_this);
  629.                 }
  630.            
  631.                 if (folderId == 'not_found') {
  632.                     return;
  633.                 }else{
  634.                     $.ajax({
  635.                         url: url,
  636.                         dataType: "JSON",
  637.                         data: dataOptionOption,
  638.                
  639.                         success: function(response) {
  640.                             if (response.result.success) {
  641.                                 _this.response = response;
  642.                                 _this.$block.find('.lpc_product_not_found_vv').removeClass('show');
  643.                
  644.                                 var dataHTML = response.result.html;
  645.                                
  646.                                
  647.                                 let containerProductForTemplate = _this.$block.find(`.containerProductForTemplate`);
  648.                              
  649.                                 if (!response.result.html) {
  650.                                     containerProductForTemplate.closest('.lpc-block').addClass("_not-data");
  651.                                    
  652.                                     return false;
  653.                                 };
  654.                                
  655.                                 containerProductForTemplate.removeAttr('style');
  656.                                 containerProductForTemplate.html(dataHTML);
  657.                                
  658.                             }
  659.                         }, // success
  660.                
  661.                         complete: function() {
  662.                             if( typeof callBack.complete == 'function'){
  663.                                 callBack.complete(_this);
  664.                             }
  665.                         } //complete
  666.                     });
  667.                 }
  668.             }
  669.             changeFolder(folderId) {
  670.                 let _this = this;
  671.                 _this.$block.find('.block-id-folder').text(folderId).addClass('modified modified-text');
  672.        
  673.                 _this.getProducts();
  674.             }
  675.            
  676.             createSelect() {
  677.                 var _this = this;
  678.                 /*parent wraper */
  679.                 let containerFolder = _this.$block.find(`.lpc-select-folder-container`); // mainContainer
  680.        
  681.        
  682.                 let queryFolder = containerFolder.find(`.lpc-query-folder`); // Logic query
  683.                 let selectFolder = queryFolder.find('.lpc-query-folder__select');
  684.                 /*parent wraper */
  685.        
  686.                 let folderInputSelected = queryFolder.find('.lpc-query-folder__input'); /* preview BTN */
  687.        
  688.                 let folderId = queryFolder.attr('data-folder_id');
  689.        
  690.                 let selectFolderBody = queryFolder.find('.lpc-query-folder__body'); /* option BOdy */
  691.        
  692.                 let flagLoadFolder = 0;
  693.        
  694.                 async function fetchAndCreateSelect() {
  695.                     try {
  696.                         // Создаем параметры запроса
  697.                         let params = new URLSearchParams();
  698.                         params.append('param[type]', 'shop2');
  699.                         params.append('param[depth]', '99');
  700.        
  701.                         // Формируем URL для GET-запроса
  702.                         let url = '/-/x-api/v1/public/?method=folder/getTree&' + params.toString();
  703.        
  704.                         // Отправляем GET-запрос с использованием fetch
  705.                         let response = await fetch(url, {
  706.                             method: 'GET',
  707.                             headers: {
  708.                                 'Content-Type': 'application/json'
  709.                             }
  710.                         });
  711.                        
  712.                         if (!response.ok) {
  713.                             throw new Error('Ошибка при выполнении запроса');
  714.                         }
  715.        
  716.                         let data = await response.json();
  717.                        
  718.                         if (data.result.success) {
  719.                             let items = data.result.items;
  720.                            
  721.                             // Нет категории магазина
  722.                             if (!items.length) {
  723.                                 queryFolder.addClass('lpc-shop-not-found');
  724.                                 return false;
  725.                             }
  726.        
  727.                             items.shift(); // удаляет первую категорию
  728.                             // Создаем варианты (option) выпадающего списка и добавляем их к существующему select
  729.        
  730.                             function createSelector(data) {
  731.                                 var rootUL = document.createElement('ul');
  732.                                 var levelObject = {};
  733.                                 var parentLi = null;
  734.        
  735.                                 data.forEach(item => {
  736.                                     var li = document.createElement('li');
  737.                                     var div = document.createElement('div');
  738.                                     div.className = 'lpc-query-folder__option lpc-query__option';
  739.                                     div.setAttribute('data-folder_id', item.folder_id);
  740.        
  741.                                     var span = document.createElement('span');
  742.        
  743.                                     function decodeHtmlEntities(input) {
  744.                                         var doc = new DOMParser().parseFromString(input, "text/html");
  745.                                         return doc.documentElement.textContent;
  746.                                     }
  747.                                     span.textContent = decodeHtmlEntities(item.folder_name);
  748.                                     div.title = decodeHtmlEntities(item.folder_name);
  749.        
  750.                                     var i = document.createElement('i');
  751.                                     i.textContent = `(${item.items})`;
  752.        
  753.                                     div.appendChild(span);
  754.                                     div.appendChild(i);
  755.                                     li.appendChild(div);
  756.        
  757.                                     let level = Number(item._level);
  758.        
  759.                                     if (level == 1) {
  760.                                         rootUL.appendChild(li);
  761.                                         parentLi = li;
  762.                                         levelObject = {};
  763.                                     } else {
  764.                                         if (!levelObject[level]) {
  765.                                             levelObject[level] = document.createElement('ul');
  766.                                             parentLi.appendChild(levelObject[level]);
  767.                                         }
  768.                                         levelObject[level].appendChild(li);
  769.                                         parentLi = li;
  770.                                     }
  771.        
  772.                                     if (folderId && folderId == item.folder_id) {
  773.                                         folderInputSelected.find('span').text(
  774.                                             $(div)
  775.                                             .addClass('selected active')
  776.                                             .find('span')
  777.                                             .text()
  778.                                         );
  779.                                         //$( div ).addClass('active');
  780.                                     }
  781.                                 });
  782.        
  783.                                 return rootUL;
  784.                             }
  785.                             selectFolderBody.append(createSelector(items));
  786.        
  787.                             var itemOption = selectFolderBody.find('.lpc-query__option');
  788.        
  789.                             selectFolderBody.find('.search-folder-input').on('input', function() {
  790.                                 var value = $(this).val();
  791.                                 var searchText = value.toLowerCase();
  792.        
  793.                                 for (var i = 0; i < itemOption.length; i++) {
  794.                                     var $this = $(itemOption[i]);
  795.        
  796.                                     if (value) {
  797.                                         $this.removeClass('unfiltered');
  798.                                     }
  799.        
  800.                                     var title = $this.attr('title').toLowerCase();
  801.        
  802.                                     if (title.includes(searchText)) {
  803.                                         $this.removeClass('unfiltered');
  804.                                     } else {
  805.                                         $this.addClass('unfiltered');
  806.                                     }
  807.                                 }
  808.                             })
  809.        
  810.                             return true;
  811.                         }
  812.                     } catch (error) {
  813.                         console.error('Ошибка при выполнении запроса:', error);
  814.                         return false;
  815.                     }
  816.                 }
  817.        
  818.                 async function loadSelectedOption() {
  819.                     let awaitCreateSelect = await fetchAndCreateSelect(); // Ждем выполнения
  820.        
  821.                     if (awaitCreateSelect) {
  822.                         queryFolder
  823.                             .removeClass('load')
  824.                             .addClass('loaded');
  825.        
  826.                         folderInputSelected.on('click', function(e) {
  827.                             selectFolder.toggleClass("open");
  828.                         });
  829.                         let queryFolderOption = queryFolder.find('.lpc-query-folder__option'); /* option select */
  830.        
  831.                         queryFolderOption.on('click', function(e) {
  832.                             let $this = $(this);
  833.                             let folderId = $this.data('folder_id');
  834.                             queryFolderOption.removeClass('active');
  835.                             $this
  836.                                 .addClass('active')
  837.                                 .siblings()
  838.                                 .removeClass('active');
  839.                             folderInputSelected.find('span').text($this.find('span').text());
  840.                             selectFolder.toggleClass("open");
  841.        
  842.                             _this.changeFolder(folderId);
  843.        
  844.                             if (!flagLoadFolder) {
  845.                                 queryFolder.addClass('folder-selected')
  846.                             }
  847.        
  848.                         });
  849.                     }
  850.                 }
  851.                 loadSelectedOption();
  852.             }
  853.         };
  854.         if( typeof jquery_block != 'undefined' ){
  855.             var getProductDataLpcCLass = new createBLockProduct(jquery_block);
  856.                  
  857.             if (s3LP.is_cms) {
  858.                 getProductDataLpcCLass.createSelect();
  859.             }
  860.            
  861.             getProductDataLpcCLass.getProducts();
  862.  
  863.             return getProductDataLpcCLass;
  864.         }
  865.     };
  866.  
  867.     lpc_template.queue.folderBlock = function ($self) {
  868.  
  869.         class folderMenuBlock {
  870.             constructor($self) {
  871.                 var _this = this;
  872.                 this.$block = $self;
  873.                 this.items = null,
  874.                 this.itemsFolderId = this.$block.find('.items-folder-id');
  875.                 this.queryFolder = this.$block.find(`.lpc-query-folder`); // Logic query
  876.                 this.selectFolder = this.queryFolder.find('.lpc-query-folder__select');
  877.                 this.prefixFirstItem = "first_";
  878.                 this.stopWord = 'top-levels';
  879.                
  880.                 this.firstItem = null;
  881.                 this.arrayItemsFolder = null;
  882.                 if (_this.itemsFolderId.text() && _this.itemsFolderId.text() != 'not_found') {
  883.                     this.arrayItemsFolder = this.itemsFolderId.text().split(',');
  884.                     this.firstItem = this.arrayItemsFolder[0].replace(new RegExp("^" + this.prefixFirstItem), "");
  885.                 }
  886.                 this.helperFunction = {
  887.                     selectOpen() {
  888.                         _this.queryFolder
  889.                             .find('.lpc-query-folder__input')
  890.                             .on('click', function (e) {
  891.                                 _this.selectFolder.toggleClass("open");
  892.                             });
  893.                     }
  894.                 }
  895.                 this.eventHandler = {
  896.                     selected(e) {
  897.    
  898.                     },
  899.                 }
  900.                 this.createSelectOption = async function () {
  901.                     _this.items = await _this.getFolderFetch(() => { // get ITEMS and callback
  902.                         _this.queryFolder.addClass('lpc-shop-not-found');
  903.                     });
  904.                     let dropDownList = _this.dropDownListHtml(_this.items);
  905.    
  906.                     _this.queryFolder
  907.                         .removeClass('load')
  908.                         .addClass('loaded')
  909.                         .find('.lpc-query-folder__body')
  910.                         .append(dropDownList);
  911.    
  912.                     let allUl = $(dropDownList).find('ul');
  913.                     let counterItem = function (elem) {
  914.                         $(elem).each(function (i, el) {
  915.                             let $this = $(this);
  916.                             let $li = $this.children('li');
  917.                             let $div = $this.prev();
  918.    
  919.                             $div.append(`<i>(${$li.length})</i>`);
  920.                         });
  921.                     }
  922.                     counterItem(dropDownList);
  923.                     counterItem(allUl);
  924.                     return true;
  925.                 }
  926.             }
  927.             createButton() { // создания кнопок
  928.                 let $list = this.$block.find('.lpc-folder-menu-horizontal__list');
  929.    
  930.                 let lpcMenuView = $list.attr('data-lpc-menu-view');
  931.                 let lpcButtons = $list.attr('data-lpc-buttons');
  932.                 let itemsFolder = this.itemsFolderId.text().split(',');
  933.                 $list.find('.lpc-row-button').addClass('show');
  934.                 if( itemsFolder.length < 12 ) {$list.find('.lpc-row-button').removeClass('show')}
  935.                 let lpcRowButtonClone = $list.find('.lpc-row-button').clone();
  936.                 $list.find('.lpc-row-button').remove()
  937.                
  938.                 this.itemsFolder_length = itemsFolder.length;
  939.    
  940.                 let templatesContainer = '';
  941.                 this.items.forEach(item => {
  942.    
  943.                     for (let i = 0; i < itemsFolder.length; i++) {
  944.                         if (itemsFolder[i] == item.folder_id) {
  945.    
  946.                             let link = '/' + item.alias;
  947.    
  948.                             let name = item.folder_name;
  949.                             let template = `<li class="lpc-folder-menu-horizontal__item ${lpcMenuView}" data-lp-selector=".lpc-folder-menu-horizontal__item" data-elem-type="container">
  950.                                   <a class="lpc-folder-menu-horizontal__link lp-button ${lpcButtons}" href="${link}" data-lp-selector=".lpc-folder-menu-horizontal__link" data-elem-type="text">
  951.                                       ${name}
  952.                                       <span class="lpc-folder-menu-horizontal__arrow" data-elem-type="container" data-lp-selector=".lpc-folder-menu-horizontal__arrow-line">
  953.                                           <span class="lpc-folder-menu-horizontal__arrow-line"></span>
  954.                                           <span class="lpc-folder-menu-horizontal__arrow-line"></span>
  955.                                       </span>
  956.                                   </a>
  957.                               </li>`;
  958.                             templatesContainer += template;
  959.    
  960.                         }
  961.                     }
  962.                 });
  963.                 $list.html(templatesContainer);
  964.                 $list.append(lpcRowButtonClone);
  965.    
  966.                 if (!this.$block.hasClass('lpc-simple-menu')) {
  967.                     this.$block.addClass('lpc-row-menu');
  968.                     lpc_template.queue.rowMenu($('body'));
  969.                 }
  970.    
  971.             }
  972.             dropDownListHtml(data) {
  973.                 var rootUL = document.createElement('ul');
  974.                 var levelObject = {};
  975.                 var parentLi = null;
  976.                 data.shift();
  977.    
  978.                 data.forEach(item => {
  979.                     var li = document.createElement('li');
  980.                     var div = document.createElement('div');
  981.                     div.className = 'lpc-query-folder__option lpc-folder-item-div';
  982.                     div.setAttribute('data-folder_id', item.folder_id);
  983.  
  984.                     var span = document.createElement('span');
  985.    
  986.                     function decodeHtmlEntities(input) {
  987.                         var doc = new DOMParser().parseFromString(input, "text/html");
  988.                         return doc.documentElement.textContent;
  989.                     }
  990.                     span.textContent = decodeHtmlEntities(item.folder_name);
  991.                     div.title = decodeHtmlEntities(item.folder_name);
  992.    
  993.                     //var i = document.createElement('i');
  994.                     //i.textContent = `(${item.items})`;
  995.    
  996.                     div.appendChild(span);
  997.                     //div.appendChild(i);
  998.                     li.appendChild(div);
  999.    
  1000.    
  1001.                     let level = Number(item._level);
  1002.    
  1003.                     if (level == 1) {
  1004.                         li.classList.add('first-level')
  1005.                         rootUL.appendChild(li);
  1006.                         parentLi = li;
  1007.                         levelObject = {};
  1008.                     } else {
  1009.                         if (!levelObject[level]) {
  1010.                             levelObject[level] = document.createElement('ul');
  1011.                             parentLi.appendChild(levelObject[level]);
  1012.                             parentLi.classList.add('hasChild')
  1013.                         }
  1014.                         levelObject[level].appendChild(li);
  1015.                         parentLi = li;
  1016.                     }
  1017.                     if (this.firstItem && this.firstItem == item.folder_id) {
  1018.    
  1019.                         div.classList.add('trigger_click');
  1020.                     } else if (this.firstItem && this.firstItem == this.stopWord) {
  1021.                         this.queryFolder.find('.all-folders').addClass('trigger_click');
  1022.                     }
  1023.                 });
  1024.    
  1025.                 return rootUL;
  1026.             }
  1027.             async getFolderFetch(notFolder) {
  1028.                 try {
  1029.                     // Создаем параметры запроса
  1030.                     let params = new URLSearchParams();
  1031.                     params.append('param[type]', 'shop2');
  1032.                     params.append('param[depth]', 99);
  1033.    
  1034.                     // Формируем URL для GET-запроса
  1035.                     let url = '/-/x-api/v1/public/?method=folder/getTree&' + params.toString();
  1036.    
  1037.                     // Отправляем GET-запрос с использованием fetch
  1038.                     let response = await fetch(url, {
  1039.                         method: 'GET',
  1040.                         headers: {
  1041.                             'Content-Type': 'application/json'
  1042.                         }
  1043.                     });
  1044.    
  1045.                     if (!response.ok) {
  1046.                         throw new Error('Ошибка при выполнении запроса');
  1047.                     }
  1048.    
  1049.                     let data = await response.json();
  1050.    
  1051.                     if (data.result.success) {
  1052.                         let items = data.result.items;
  1053.    
  1054.                         // Нет категории магазина
  1055.                         if (!items.length) {
  1056.                             notFolder();
  1057.                             return false;
  1058.                         }
  1059.    
  1060.                         return items;
  1061.                     }
  1062.                 } catch (error) {
  1063.                     console.error('Ошибка при выполнении запроса:', error);
  1064.                     return false;
  1065.                 }
  1066.             }
  1067.             initSelect() {
  1068.                 let _this = this;
  1069.                 (async function () {
  1070.                     _this.helperFunction.selectOpen();
  1071.    
  1072.                     await _this.createSelectOption();
  1073.    
  1074.                     let queryFolderOption = _this.queryFolder.find('.lpc-query-folder__option'); /* option select */
  1075.                     let folderInputSelected = _this.queryFolder.find('.lpc-query-folder__input'); /* preview BTN */
  1076.                     let $allLi = _this.queryFolder.find('li');
  1077.    
  1078.                     let flagLoadFolder = 0;
  1079.    
  1080.                     queryFolderOption.on('click', function (e, trig=false) {
  1081.                         queryFolderOption.removeClass('choose').removeClass('opted');
  1082.                         $allLi.removeClass('active');
  1083.    
  1084.                         let $this = $(this);
  1085.                         let $li = $this.closest('li');
  1086.                         let $ul = $li.children('ul');
  1087.    
  1088.                         $this.addClass('opted');
  1089.    
  1090.    
  1091.                         folderInputSelected.find('span').text(
  1092.                             $this.find('span').text()
  1093.                         );
  1094.    
  1095.                         $li.addClass('active');
  1096.    
  1097.                         $li.parents('.hasChild').addClass('active');
  1098.    
  1099.    
  1100.                         var $firstLevel = _this.queryFolder.find('.first-level')
  1101.    
  1102.                         let $option = $ul.children('li').children('.lpc-query-folder__option');
  1103.                         let firstItem = '';
  1104.                         if ($this.hasClass('all-folders')) {
  1105.                             $option = $firstLevel.find(' > .lpc-query-folder__option');
  1106.                             firstItem = _this.stopWord;
  1107.                         } else {
  1108.                             firstItem = _this.prefixFirstItem + $this.attr('data-folder_id');
  1109.                         }
  1110.    
  1111.                         $option.addClass('choose');
  1112.    
  1113.    
  1114.                         let srtBlock = '';
  1115.                         let len = $option.length - 1;
  1116.    
  1117.                         $option.each(function (index) {
  1118.                             let last = ',';
  1119.    
  1120.                             if (index == len) {
  1121.                                 last = '';
  1122.                             }
  1123.                             if (index == 0) {
  1124.                                 srtBlock += firstItem + ',';
  1125.                             }
  1126.                             srtBlock += $(this).attr('data-folder_id') + last;
  1127.                         });
  1128.    
  1129.                         _this.itemsFolderId
  1130.                             .text(srtBlock)
  1131.                             .addClass('modified modified-text');
  1132.    
  1133.                         _this.createButton();
  1134.    
  1135.                         if(!flagLoadFolder) {
  1136.                             _this.queryFolder.addClass('folder-selected');
  1137.                             flagLoadFolder = 1;
  1138.                         }
  1139.    
  1140.                         // if( !trig ) {
  1141.                         //  _this.selectFolder.toggleClass("open");
  1142.                         // }
  1143.                        
  1144.                     });
  1145.    
  1146.                     if (_this.itemsFolderId.text() && _this.itemsFolderId.text() != 'not_found') {
  1147.                         _this.createButton();
  1148.                         _this.queryFolder.find('.trigger_click').removeClass('trigger_click').trigger('click', [true]);
  1149.                     }
  1150.                    
  1151.                 })();
  1152.             }
  1153.            
  1154.             rowMenuItems() {
  1155.                 let _this = this;
  1156.            
  1157.                 function rowMenuItems() {
  1158.                     let $this = _this.$block;
  1159.                     let $menu = $this.find('.lpc-folder-menu-horizontal__list');
  1160.                     let $toggleButton = $this.find('.lpc-folder-menu-horizontal__more');
  1161.        
  1162.                     let hideText = document.querySelector('html').getAttribute('lang') === 'ru' ? 'Скрыть' : 'Hide';
  1163.                     let currentText = document.querySelector('html').getAttribute('lang') === 'ru' ? 'Ещё' : 'Show more';
  1164.        
  1165.                     let $insTextButton = $toggleButton.find('ins');
  1166.                     let $hiddenItems = $menu.find('li:not(.lpc-folder-menu-horizontal__more):hidden');
  1167.                    
  1168.                     if ($hiddenItems.length) {
  1169.                         $toggleButton.addClass('show');
  1170.                     }
  1171.                    
  1172.                     $toggleButton.off('click').on('click', function () {
  1173.                         $toggleButton.toggleClass('active');
  1174.                         $menu.toggleClass('lpc-folder-menu-horizontal__list--show-items');
  1175.                         $insTextButton.text($toggleButton.hasClass('active') ? hideText : currentText);
  1176.                     });
  1177.                 }
  1178.            
  1179.                 rowMenuItems();
  1180.            
  1181.                 document.addEventListener('dataMediaSourceChange', rowMenuItems);
  1182.             }
  1183.            
  1184.             init() {
  1185.                 this.initSelect();
  1186.             }
  1187.         };
  1188.  
  1189.         let $blocks = $self.hasClass('lpc-folder-block') ? $self : $self.find('.lpc-folder-block');
  1190.  
  1191.         if ($blocks.length) {
  1192.  
  1193.             $blocks.each(function () {
  1194.                 let $block = $(this);
  1195.  
  1196.                 if (s3LP.is_cms) {
  1197.                     setTimeout(()=>{
  1198.                         var folderBlock = new folderMenuBlock($block);
  1199.                         folderBlock.init();
  1200.                     }, 300)
  1201.                 }else {
  1202.                     var folderBlock = new folderMenuBlock($block);
  1203.                     folderBlock.rowMenuItems();
  1204.                 }
  1205.             });
  1206.         }
  1207.     };
  1208.  
  1209.     lpc_template.queue.lpcAjaxProduct = function($self) {
  1210.      
  1211.         let $blocks = $self.hasClass('.lpc-ajax-product') ? $self : $self.find('.lpc-ajax-product');
  1212.        
  1213.         if ($blocks.length) {
  1214.            
  1215.             $blocks.each(function() {
  1216.                 let $block = $(this);
  1217.                
  1218.                 var optionLpcDecor = {};
  1219.  
  1220.                 optionLpcDecor['columns'] = $block.attr('data-columns');
  1221.                 optionLpcDecor['block_type'] = $block.attr('data-block-type');
  1222.                 optionLpcDecor['img_proportions'] = $block.attr('data-img-proportions');
  1223.                 optionLpcDecor['landing_page_mode'] = $block.attr('data-landing-page-mode');
  1224.                 optionLpcDecor['card_block'] = $block.attr('data-card-block');
  1225.                 optionLpcDecor['contain'] = $block.attr('data-contain');
  1226.                 optionLpcDecor['lpc_no_image'] = $block.attr('data-lpc-no-image');
  1227.                 optionLpcDecor['product_link_on'] = $block.attr('data-product-link-on');
  1228.  
  1229.                 var dataQuery = {
  1230.                     param: {
  1231.                         offset: 0,
  1232.                         limit: 100,
  1233.                         search: {
  1234.                             folder_id: null
  1235.                         },
  1236.                         mode: 'custom',
  1237.                     },
  1238.                     custom_products_version: 'lpc_blocks',
  1239.                     block_layout: 672708,
  1240.                     special_away: '0',
  1241.                     option_decor: JSON.stringify(optionLpcDecor),
  1242.                 };
  1243.                
  1244.                 lpcCreateBlockProducts(
  1245.                     $block,
  1246.                     dataQuery,
  1247.                     {
  1248.                         beforeAjax: function(contextObject){
  1249.                             contextObject.extenSettingBegin();
  1250.                         },
  1251.                         complete: function(contextObject){
  1252.                            
  1253.                             $block.find('.lpc_product_not_found_vv').removeClass('show');
  1254.                            
  1255.                             contextObject.extenSettingFinish();
  1256.                            
  1257.                             if(contextObject.response.result.found < 1){
  1258.                                 $block.find('.lpc_product_not_found_vv').addClass('show');
  1259.                                 $block.find('.block-id-folder').text('not_found')
  1260.                             }
  1261.                         }
  1262.                     }
  1263.                 );
  1264.  
  1265.             });
  1266.         }
  1267.     };
  1268.    
  1269.     lpc_template.queue.lpcAjaxParamsProduct = function($self) {
  1270.  
  1271.         let $blocks = $self.hasClass('.lpc-ajax-params-product') ? $self : $self.find('.lpc-ajax-params-product');
  1272.        
  1273.         if ($blocks.length) {
  1274.             $blocks.each(function() {
  1275.                 let $block = $(this);
  1276.  
  1277.  
  1278.                 let optionLpcDecor = {};
  1279.                 optionLpcDecor['columns'] = $block.attr('data-columns');
  1280.                 optionLpcDecor['lpc_width'] = $block.attr('data-lpc-width');
  1281.                 optionLpcDecor['lpc_even'] = $block.attr('data-lpc-even');
  1282.  
  1283.                 var dataQuery = {
  1284.                     param: {
  1285.                         offset: 0,
  1286.                         limit: 100,
  1287.                         search: {
  1288.                             folder_id: null
  1289.                         },
  1290.                         mode: 'custom',
  1291.                     },
  1292.                     custom_products_version: 'lpc_blocks',
  1293.                     block_layout: 30109,
  1294.                     special_away: '0',
  1295.                     option_decor: JSON.stringify(optionLpcDecor),
  1296.                 };
  1297.                 lpcCreateBlockProducts(
  1298.                     $block,
  1299.                     dataQuery,
  1300.                     {
  1301.                         complete: function(contextObject){
  1302.                            
  1303.                             $block.find('.lpc_product_not_found_vv').removeClass('show');
  1304.                            
  1305.  
  1306.                             if(contextObject.response.result.found < 1){
  1307.                                 $block.find('.lpc_product_not_found_vv').addClass('show');
  1308.                                 $block.find('.block-id-folder').text('not_found')
  1309.                             }
  1310.                         }
  1311.                     }
  1312.                 );
  1313.             });
  1314.         }
  1315.     };
  1316.  
  1317.     lpc_template.queue.lpcQueryProduct = function ($self) {
  1318.         let $blocks = $self.hasClass('lpc-shop-lot') ? $self : $self.find('.lpc-shop-lot');
  1319.         let initCompareFlag = false;
  1320.        
  1321.         if ($blocks.length) {
  1322.            
  1323.             /*$(document).on('click', '.lpc-shop-lot__button-buy', function(e){
  1324.                 e.preventDefault();
  1325.                 $(this).parent('.lpc-shop-lot-btns').find('.shop-product-btn').click();
  1326.             });*/// триггер кнопки купить
  1327.             $(document).on('click', '.lpc-shop-lot__button', function(e) {
  1328.    
  1329.                 var $this = $(this),
  1330.                     $form = $this.closest('form'),
  1331.                     form = $form.get(0),
  1332.                     adds = $form.find('.additional-cart-params'),
  1333.                     len = adds.length,
  1334.                     i, el,
  1335.                     a4 = form.amount.value,
  1336.                     kind_id = form.kind_id.value;
  1337.            
  1338.        
  1339.                     if (shop2.my.gr_new_notification) {
  1340.                         // Находим картинку товара
  1341.                         var $image = $form.find('.gr-product-image--js');
  1342.                     }
  1343.                 e.preventDefault();
  1344.        
  1345.                 if (len) {
  1346.                     a4 = {
  1347.                         amount: a4
  1348.                     };
  1349.        
  1350.                     for (i = 0; i < len; i += 1) {
  1351.                         el = adds[i];
  1352.                         if (el.value) {
  1353.                             a4[el.name] = el.value;
  1354.                         }
  1355.                     }
  1356.                 }
  1357.                
  1358.                 lpc_template.queue.lpcAddCard.add(kind_id, a4, function(d) {
  1359.                     $('#shop2-cart-preview').replaceWith(d.data);
  1360.                    
  1361.                     var totalCartAmount = +$(d.data).find('.gr-cart-total-amount').text();
  1362.                     var totalCartSum = $(d.data).find('.gr-cart-total-sum').data('total-price');
  1363.                    
  1364.                     if (totalCartAmount>0) {
  1365.                         $('.head-cart__btn').removeClass('pointer_events_none');
  1366.                         $('.gr-cart-total-amount').text(totalCartAmount);
  1367.                         $('.gr-cart-total-sum ins').text(totalCartSum);
  1368.                     } else{
  1369.                         $('.mosaic-shop2-cart-preview__total-count').text('0'); // 1935 04.12.2024 внес правку для 140 шаблона. при покупке из попап карточки товара лпц, не обновлялась маленькая корзина
  1370.                         $('.gr-cart-total-amount').text('0');
  1371.                         $('.gr-cart-total-sum ins').text('0');
  1372.                     };
  1373.                    
  1374.                     if (d.errstr) {
  1375.                         if (shop2.my.gr_new_notification) {
  1376.        
  1377.                             shop2.popupNotification({
  1378.                                 "itemContent": d.errstr,
  1379.                                 "itemClass": "gr-notification__item--purchase",
  1380.                             });
  1381.                         } else {
  1382.                             shop2.msg(d.errstr, $this);
  1383.                         }
  1384.                     } else {
  1385.                         var $text = window._s3Lang.JS_SHOP2_ADD_CART_WITH_LINK;
  1386.                         //var $text = $text.replace("</a>", "<i><svg class='gr-svg-icon'><use xlink:href='#icon_shop_notify_arr'></use></svg></i></a>");
  1387.                        
  1388.                         if (shop2.my.gr_new_notification) {
  1389.        
  1390.                             // Выводим сообщение пользователю
  1391.                             /*shop2.popupNotification({
  1392.                                 "itemContent": $text,
  1393.                                 "itemClass": "gr-notification__item--purchase",
  1394.                                 "itemImage": shop2.my.gr_hide_msg_image ? false : true,
  1395.                                 "itemSrc": $image.find('img').attr('src'),
  1396.                                 "itemHref": $image.data('product-href') || $image.find('a').attr('href'),
  1397.                                 "itemContain": $image.data('image-view'),
  1398.                                 "itemSize": $image.data('image-size'),
  1399.                             });*/
  1400.                         } else {
  1401.                             shop2.msg($text.replace("%s", shop2.uri + "/cart"), $this);
  1402.                         }
  1403.                        
  1404.                         shop2.on('afterCartAddItem', function(res, status) {
  1405.                            /* const productPreviewPopup = $('.remodal[data-remodal-id="card-preview-remodal"]');
  1406.                            
  1407.                             shop2.msg($text.replace("%s", shop2.uri + "/cart"), $this);*/
  1408.                         });
  1409.                     }
  1410.        
  1411.                     if (d.panel) {
  1412.                         $('#shop2-panel').replaceWith(d.panel);
  1413.                     };
  1414.                 });
  1415.             });
  1416.            
  1417.             $(document).on('click', '.lpc-product-amount-btn.lpc-amount-minus', function() {
  1418.                   var $this = $(this),
  1419.                       text = $this.siblings('input:text'),
  1420.                       value = text.getVal(),
  1421.                       amount_min = parseFloat(text.data('min')),
  1422.                       multiplicity = parseFloat(text.data('multiplicity'));
  1423.          
  1424.                   if (value) {
  1425.                       value = value[0];
  1426.                   }
  1427.          
  1428.                   if (amount_min && value <= amount_min) {
  1429.                       return;
  1430.                   }
  1431.          
  1432.                   value = checkAmount(value, amount_min, multiplicity, -1);
  1433.                  
  1434.                   if (amount_min > 0) {
  1435.                     if (value <= amount_min) {
  1436.                         value = amount_min;
  1437.                     }
  1438.                   } else {
  1439.                     if (value <= shop2.options.amountDefaultValue) {
  1440.                        value = shop2.options.amountDefaultValue;
  1441.                     }
  1442.                   }
  1443.                  
  1444.                  
  1445.                  
  1446.                   text.val(value);
  1447.                   text.trigger('change');
  1448.               });
  1449.               $(document).on('click', '.lpc-product-amount-btn.lpc-amount-plus', function() {
  1450.                   var $this = $(this),
  1451.                       text = $this.siblings('input:text'),
  1452.                       value = text.getVal(),
  1453.                       amount_min = parseFloat(text.data('min')),
  1454.                       multiplicity = parseFloat(text.data('multiplicity'));
  1455.                    
  1456.                   if (value) {
  1457.                       var value = value[0];
  1458.                   }          
  1459.                  
  1460.                   var value = checkAmount(value, amount_min, multiplicity, 1);
  1461.                   text.val(value);
  1462.                   text.trigger('change');
  1463.             });
  1464.             function checkAmount(amount, amount_min, multiplicity, sign) {
  1465.  
  1466.               if (multiplicity > 0) {
  1467.                   amount += multiplicity * sign;
  1468.               } else {
  1469.                   amount += shop2.options.amountDefaultInc * sign;
  1470.               }
  1471.              
  1472.               amount = amount.toFixed(2) - 0;
  1473.    
  1474.               return amount
  1475.             }
  1476.            
  1477.             $blocks.each(function() {
  1478.  
  1479.                 let $block = $(this);
  1480.                 let $blockList = $block.find('.lpc-query-products');
  1481.                
  1482.                 let optionLpcDecor = {};
  1483.                 optionLpcDecor['block-lot-id'] = $blockList.attr('data-lots-block-id');
  1484.                 optionLpcDecor['on_lg'] = $blockList.attr('data-on-lg');
  1485.                 optionLpcDecor['columns'] = $blockList.attr('data-columns');
  1486.                 optionLpcDecor['block_type'] = $blockList.attr('data-block-type');
  1487.                 optionLpcDecor['img_proportions'] = $blockList.attr('data-img-proportions');
  1488.                 optionLpcDecor['landing_page_mode'] = $blockList.attr('data-landing-page-mode');
  1489.                 optionLpcDecor['card_block'] = $blockList.attr('data-card-block');
  1490.                 optionLpcDecor['contain'] = $blockList.attr('data-contain');
  1491.                 optionLpcDecor['lpc_no_image'] = $blockList.attr('data-lpc-no-image');
  1492.                 optionLpcDecor['lpc_view_show_option'] = $blockList.attr('data-lpc-view-show-options');
  1493.                 optionLpcDecor['lpc_view_vendor'] = $blockList.attr('data-lpc-view-vendor');
  1494.                 optionLpcDecor['lpc_view_rating'] = $blockList.attr('data-lpc-view-rating');
  1495.                 optionLpcDecor['lpc_view_article'] = $blockList.attr('data-lpc-view-article');
  1496.                 optionLpcDecor['lpc_view_annonce'] = $blockList.attr('data-lpc-view-annonce');
  1497.                 optionLpcDecor['lpc_view_sale'] = $blockList.attr('data-lpc-view-sale');
  1498.                 optionLpcDecor['lpc_view_amount_flag'] = $blockList.attr('data-lpc-view-amount-flag');
  1499.                 optionLpcDecor['lpc_view_buy_btn'] = $blockList.attr('data-lpc-view-buy-btn');
  1500.                 optionLpcDecor['lpc_view_amount'] = $blockList.attr('data-lpc-view-amount');
  1501.                 optionLpcDecor['lpc_view_one_click'] = $blockList.attr('data-lpc-view-one-click');
  1502.  
  1503.  
  1504.                 var dataQuery = {
  1505.                     param: {
  1506.                         search: {
  1507.                             folder_id: null
  1508.                         },
  1509.                         mode: 'custom',
  1510.                         limit: 32
  1511.                     },
  1512.                     custom_products_version: 'lpc_blocks',
  1513.                     block_layout: '134709',
  1514.                     special_away: '1',
  1515.                     lpc_lot_products_option: '1',
  1516.                     'option_decor': JSON.stringify(optionLpcDecor),
  1517.                 };
  1518.                
  1519.                
  1520.                
  1521.                 $(document).on('click', '.lpc-options-more', function(){
  1522.                     if(optionLpcDecor['block-lot-id'] == $(this).closest('.lpc-shop-lot').attr('id')) {
  1523.                         $(this).toggleClass('active');
  1524.                         $(this).siblings('.lpc-options-container').slideToggle();
  1525.                     }
  1526.                 });
  1527.            
  1528.                 $(document).on('click', '.lpc-shop-lot__image', function(e){
  1529.                     if(optionLpcDecor['block-lot-id'] == $(this).closest('.lpc-shop-lot').attr('id')) {
  1530.                         e.preventDefault();
  1531.                         $(this).closest('.lpc-shop-lot__inner').find(".lpc-shop-lot__quick-trigger").trigger('click');
  1532.                     }
  1533.                 });// клик на картинку
  1534.                
  1535.                 $(document).on('click', '.lpc-product-compare-custom-text', function(e){
  1536.                     if(optionLpcDecor['block-lot-id'] == $(this).closest('.lpc-shop-lot').attr('id')) {
  1537.                         $(this).siblings('.lpc-product-compare').trigger('click'); 
  1538.                     }
  1539.                 });
  1540.                
  1541.                 lpcCreateBlockProducts(
  1542.                     $block,
  1543.                     dataQuery,
  1544.                     {
  1545.                         beforeAjax: function(contextObject){
  1546.                             contextObject.extenSettingBegin();
  1547.                         },
  1548.                         complete: function(contextObject){
  1549.                            
  1550.                             if (!s3LP.is_cms) {
  1551.                                 shop2.trigger('afterProductsLazyLoaded');
  1552.                             }
  1553.                            
  1554.                             if (!s3LP.is_cms) {
  1555.                                 if (!initCompareFlag) {
  1556.                                     contextObject.getCompare($blockList);
  1557.                                     initCompareFlag = true;
  1558.                                 }
  1559.                             }
  1560.  
  1561.                             contextObject.extenSettingFinish();
  1562.                            
  1563.                             $('.lpc-shop-lot__popup-back, .lpc-shop-lot__popup-close').on('click', function(){
  1564.                                 $(".lpc-shop-lot__popup").removeClass('active');
  1565.                                 $("html").removeClass('lpc-shop-popup-scroll');
  1566.                             });
  1567.                            
  1568.                             if ($('.lpc-shop-lot__list-check-mobile').length){
  1569.                                 $(window).on("resize", function () {
  1570.                                     setTimeout(function() {
  1571.                                         var mediaTypeCheck = $('.decor-wrap').attr('data-media-source');
  1572.                                         if( mediaTypeCheck == "media-xs") {
  1573.                                             $('.lpc-shop-lot__list-check-mobile').addClass('lpc-card--type-1');
  1574.                                         }else{
  1575.                                             $('.lpc-shop-lot__list-check-mobile').removeClass('lpc-card--type-1');
  1576.                                         }
  1577.                                     }, 200);
  1578.                                    
  1579.                                  }).trigger("resize");
  1580.                             }//для мобильной версии объеденить карточку
  1581.                            
  1582.                            
  1583.                            
  1584.                             $('.lpc-shop-lot__popup .lpc-shop-lot__image').on('click', function(e){
  1585.                                 $e.preventDefault();
  1586.                             });
  1587.                            
  1588.                             contextObject.receivingDataPopup();
  1589.                         }
  1590.                     }
  1591.                 );
  1592.             });
  1593.         }
  1594.     };
  1595.  
  1596.     if ($('.s3-preloader').length) {
  1597.         s3PreloaderMutation($('.s3-preloader')[0]);
  1598.     };
  1599.    
  1600.     /*lpc_template.queue.newYear = function($self) { // НЕ УДАЛЯТЬ - НГ оформление
  1601.         if (!!document.querySelector('#lp_constructor')) {
  1602.             let lpcSnow = `<div id="lpc-snow-block" class="sky"></div>`;
  1603.             let newYearTpl = `<div class="lpc-new-year">
  1604.                 <ul class="lpc-new-year__items">
  1605.                     <li></li>
  1606.                     <li></li>
  1607.                     <li></li>
  1608.                     <li></li>
  1609.                     <li></li>
  1610.                     <li></li>
  1611.                     <li></li>
  1612.                 </ul>
  1613.                 <ul class="lpc-new-year__items">
  1614.                     <li></li>
  1615.                     <li></li>
  1616.                     <li></li>
  1617.                     <li></li>
  1618.                     <li></li>
  1619.                     <li></li>
  1620.                     <li></li>
  1621.                     <li class="first_red_toy"></li>
  1622.                     <li class="green_toy"></li>
  1623.                 </ul>
  1624.                 <ul class="lpc-new-year__items second_items">
  1625.                     <li></li>
  1626.                     <li></li>
  1627.                     <li></li>
  1628.                     <li></li>
  1629.                     <li></li>
  1630.                     <li></li>
  1631.                     <li></li>
  1632.                     <li class="red_toy"></li>
  1633.                 </ul>
  1634.                 <ul class="lpc-new-year__items">
  1635.                     <li></li>
  1636.                     <li></li>
  1637.                     <li></li>
  1638.                     <li></li>
  1639.                     <li></li>
  1640.                     <li></li>
  1641.                     <li></li>
  1642.                     <li class="last_green_toy"></li>
  1643.                 </ul>
  1644.                 <ul class="lpc-new-year__items">
  1645.                     <li></li>
  1646.                     <li></li>
  1647.                     <li></li>
  1648.                     <li></li>
  1649.                     <li></li>
  1650.                     <li></li>
  1651.                     <li></li>
  1652.                 </ul>
  1653.             </div>`;
  1654.        
  1655.             if (!!document.querySelector('#lp_constructor') && !$('.lpc-new-year__items').length) {
  1656.                 $('#landing_page_controls').append(newYearTpl);
  1657.                 //$('#landing_page_site').append(newYearTpl);
  1658.                 $('#landing_page_controls').append(lpcSnow);
  1659.  
  1660.                 if (readCookie('lpc_disable_snow') != '1') {
  1661.                     letItSnow();
  1662.                 };
  1663.             };
  1664.        
  1665.             let $snow = $('#lpc-snow-block');
  1666.            
  1667.             const config = {
  1668.                 attributes: true
  1669.             };
  1670.        
  1671.             const callback = function (mutationsList, observer) {
  1672.                
  1673.                 for (let mutation of mutationsList) {
  1674.                     if (!$(target).hasClass('hidden')) {
  1675.                        
  1676.                         $('#lp_constructor').addClass('opened');
  1677.                         $snow.appendTo($('#landing_page_controls'));
  1678.                        
  1679.                     } else {
  1680.                        
  1681.                         $('#lp_constructor').removeClass('opened');
  1682.                         $snow.appendTo($('#landing_page_site'));
  1683.                        
  1684.                     }
  1685.  
  1686.                     if (!$(target2).is(':hidden')) {
  1687.                         $('._live._live--lp ._live__header').addClass('hide_live_header');
  1688.                     } else {
  1689.                         $('._live._live--lp ._live__header').removeClass('hide_live_header');
  1690.                     }
  1691.                 }
  1692.             };
  1693.        
  1694.             let target = document.querySelector('.folders-menu-wrapper');
  1695.             let target2 = document.querySelector('.block-css-controls');
  1696.        
  1697.             const observer = new MutationObserver(callback);
  1698.             const observer2 = new MutationObserver(callback);
  1699.        
  1700.             observer.observe(target, config);
  1701.             observer2.observe(target2, config);
  1702.         };
  1703.     };*/
  1704.  
  1705.    
  1706.     lpc_template.queue.lpcWatchPreloader = function($self) {
  1707.         s3PreloaderMutation($('.decor-wrap')[0]);
  1708.     };
  1709.  
  1710.     lpc_template.queue.checkBgImg = function ($self) {
  1711.         $('.lp-block-bg._photo_avaiable').each(function(){
  1712.             var bgWh = $(this).css('background-image');
  1713.            
  1714.             if(bgWh != "none") {
  1715.                 $(this).addClass('_there-photo');
  1716.             }
  1717.         })
  1718.     };
  1719.  
  1720.  
  1721.     lpc_template.queue.lpcAboutPopupLink  = function($self) {
  1722.        
  1723.         document.addEventListener('lpcPopupFormInitDone', function(){
  1724.           $('a[href^="popup:"]').removeClass('lpc_pointer_events_none');
  1725.         });
  1726.     };
  1727.    
  1728.     lpc_template.queue.lpcSharePopupBtn  = function($self) {
  1729.         var $block = $self.find('.lpc-share-1');
  1730.            
  1731.         if ($block.length && $block.find('.lpc-share-1__button').length) { 
  1732.                 $('.lpc-share-1__button').each(function(){
  1733.                     var $shareItems = $(this).parents('.lpc-share-1').find(".ya-share2__popup"),
  1734.                         $sharePopup = $(this).parents('.lpc-share-1').find(".lpc-share-1__popup"),
  1735.                         $sharePopupParent = $(this).parents('.lpc-share-1').find(".ya-share2_custom"),
  1736.                         $buttonWidth = $(this).parents('.lpc-share-1').find(".lpc-share-1__button").outerWidth();
  1737.                        
  1738.                        
  1739.                     $shareItems.clone().appendTo($sharePopup);
  1740.                     $sharePopupParent.css('width', $buttonWidth);
  1741.                 });
  1742.            
  1743.            
  1744.             $doc.on("click", function (e) {
  1745.                 if (!$(e.target).closest($('.lpc-share-1__button')).length && !$(e.target).closest($('.ya-share2_custom')).length) {
  1746.                     $doc.find(".lpc-share-1__popup").removeClass("_opened");
  1747.                 };
  1748.             });
  1749.            
  1750.             $('.lpc-share-1__button').on('click', function(){
  1751.            
  1752.                 if($(this).closest('.lpc-share-1__wrap').find('.lpc-share-1__popup').hasClass('_opened')){
  1753.                     $(this).closest('.lpc-share-1__wrap').find('.lpc-share-1__popup').removeClass('_opened');
  1754.                 }else {
  1755.                     $('.lpc-share-1__popup._opened').removeClass('_opened');
  1756.                     $(this).closest('.lpc-share-1__wrap').find('.lpc-share-1__popup').addClass('_opened');
  1757.                 }
  1758.                
  1759.                 var popupHeight = $(this).closest('.lpc-share-1__wrap').find('.ya-share2_custom .ya-share2__popup').height();
  1760.             });
  1761.         }
  1762.     };
  1763.    
  1764.     lpc_template.queue.lpcAddCard = {
  1765.         add: function(kind_id, a4, func) {
  1766.  
  1767.             shop2.trigger('beforeCartAddItem');
  1768.        
  1769.             $.post(
  1770.               '/-/shop2-api/?cmd=cartAddItem', {
  1771.                 hash: shop2.apiHash.cartAddItem,
  1772.                 ver_id: shop2.verId,
  1773.                 kind_id: kind_id,
  1774.                 amount: a4
  1775.               },
  1776.               function(d, status) {
  1777.                 shop2.fire('afterCartAddItemLpc', func, d, status);
  1778.                 shop2.trigger('afterCartAddItemLpc', d, status);
  1779.               },
  1780.               'json'
  1781.             );
  1782.         }
  1783.     };
  1784.  
  1785.    
  1786.     lpc_template.queue.lpcCompare = {
  1787.         add: function(kind_id, callback) {
  1788.           this.action('add', kind_id, callback);
  1789.         },
  1790.         remove: function(kind_id, callback) {
  1791.           this.action('del', kind_id, callback);
  1792.         },
  1793.         clear: function(callback) {
  1794.           this.action('clear', null, callback);
  1795.         },
  1796.         action: function(action, kind_id, func) {
  1797.    
  1798.           var eventName = $.camelCase('Compare-' + action);
  1799.    
  1800.           shop2.trigger('before' + eventName);
  1801.    
  1802.           $.post(
  1803.             '/-/x-api/v1/public/?method=shop2/compare', {
  1804.                 kind_id,
  1805.                 action,
  1806.                 lpc_block_compare: "1",
  1807.             },
  1808.             function(d, status) {
  1809.               shop2.fire('after' + eventName, func, d.result, status);
  1810.               shop2.trigger('after' + eventName, d.result, status);
  1811.             }
  1812.           );
  1813.         }
  1814.     };
  1815.    
  1816.     lpc_template.queue.menuSimplePopup = function($self) {
  1817.        
  1818.         var $block = $self.hasClass('js-menu-wrap') ? $self : $self.find('.js-menu-wrap');
  1819.        
  1820.         $block.each(function(){
  1821.             var $this = $(this),
  1822.                 $topMenuWrap = $this.find('.js-menu__wrap'),
  1823.                 $menu = $this.find('.js-menu_appedable'),
  1824.                 $burger = $this.find('.js-burger'),
  1825.                 $popup = $this.find('.js-popup'),
  1826.                 popupHeight = $(window).height() - $this.height(),
  1827.                 menuHeight = $this.outerHeight(),
  1828.                 popupTop = menuHeight < 0 ? 0 : menuHeight,
  1829.                 popupTop = s3LP.is_cms ? popupTop + 72 : popupTop,
  1830.                 $bgTop = $this.height() + 50 < 0 ? 0 : $this.height() + 50,
  1831.                 $bgTop = s3LP.is_cms ? $bgTop + 72 : $bgTop,
  1832.                 $liHaschild = $this.find('.haschild');
  1833.            
  1834.             $this.find('.lp-menu-block-bg').animate({top: $bgTop}, 400);
  1835.            
  1836.             $popup.css('top', popupTop);
  1837.                
  1838.             $menu.clone().prependTo($topMenuWrap);
  1839.            
  1840.             $(this).append('<div class="lp-menu-block-bg"></div>');
  1841.            
  1842.             function menuShow() {
  1843.                 var $ulWidth = 0,
  1844.                     $ulWrapWidth = $this.find('.js-menu__wrap').width();
  1845.        
  1846.                 $($menu).children('li').each(function(){
  1847.                     var $width = $(this).children('a').outerWidth(true);
  1848.                     $ulWidth += $width;
  1849.                 });
  1850.                
  1851.                 if (window.matchMedia('(min-width : 960px)').matches) {
  1852.                     if ($ulWidth < $ulWrapWidth) {
  1853.                         $this.find('.js-menu__wrap').addClass('show');
  1854.                         $this.find('.js-burger').hide();
  1855.                     }
  1856.                     else {
  1857.                         $this.find('.js-menu__wrap').removeClass('show');
  1858.                         $this.find('.js-burger').show();
  1859.                     }
  1860.                 } else if (window.matchMedia('(max-width : 959px)').matches && $menu.find('li').length == 0) {
  1861.                     $this.find('.js-menu__wrap').addClass('show');
  1862.                     $this.find('.js-burger').hide();
  1863.                    
  1864.                 } else if (window.matchMedia('(max-width : 959px)').matches) {
  1865.                     $this.find('.js-menu__wrap').removeClass('show');
  1866.                     $this.find('.js-burger').show();
  1867.                 }
  1868.                
  1869.                 var $bgTop = $this.offset().top + $this.height();
  1870.                
  1871.                 menuHeight = $this.outerHeight(),
  1872.                 popupTop = menuHeight < 0 ? 0 : menuHeight,
  1873.                 popupTop = s3LP.is_cms ? popupTop + 72 : popupTop,
  1874.                 $bgTop = $this.height() < 0 ? 0 : $this.height(),
  1875.                 $bgTop = s3LP.is_cms ? $bgTop + 72 : $bgTop;
  1876.                
  1877.                 $this.find('.lp-menu-block-bg').animate({top: $bgTop}, 400);
  1878.                
  1879.                 $popup.css('top', popupTop);
  1880.                
  1881.                 $this.find('.lp-menu-block-bg').css('top', $bgTop);
  1882.             }
  1883.            
  1884.             $(window).on('resize', function(){
  1885.                
  1886.                 setTimeout(function(){
  1887.                     menuShow();
  1888.                 },500);
  1889.                
  1890.             }).trigger('resize');
  1891.        
  1892.             $burger.on('click', function(){
  1893.                 $menu.find('li a').addClass('menu-popup-item-custom');
  1894.                 if ($(this).hasClass('_in-side')) {
  1895.                     $popup.animate({top: 0}, 400);
  1896.                     $this.find('.lp-menu-block-bg').css('top', 0);
  1897.                 }
  1898.                 if (!$(this).hasClass('_in-side')) {
  1899.                     if (s3LP.is_cms) {
  1900.                         $('html, body').animate({
  1901.                             scrollTop: $this.offset().top - 72
  1902.                         }, 100);
  1903.                     }
  1904.                     else {
  1905.                         $('html, body').animate({
  1906.                             scrollTop: $this.offset().top
  1907.                         }, 100);
  1908.                     }
  1909.                 }
  1910.                
  1911.                 $popup.find('.js-popup__inner').css({
  1912.                     'overflow' : 'auto',
  1913.                     'max-height' : '100%'
  1914.                 });
  1915.                
  1916.                 $burger.toggleClass('opened');
  1917.                 if ($popup.hasClass('opened')) {
  1918.                     $popup.animate({height: "0%"}, {duration: 800, complete: function() {$this.css('z-index', '')}}).removeClass('opened');
  1919.                     $this.find('.lp-menu-block-bg').fadeOut(600);
  1920.                    
  1921.                     $('html').css('overflow', '');
  1922.                 }
  1923.                 else {
  1924.                     $popup.animate({height: popupHeight}, {duration: 800}).addClass('opened');
  1925.                     $this.find('.lp-menu-block-bg').fadeIn(600);
  1926.                     $this.css('z-index', '999')
  1927.                     $('html').css('overflow', 'hidden');
  1928.                 }
  1929.             });
  1930.            
  1931.             $this.find('.haschild').on('click', function(e){
  1932.                 e.stopPropagation();
  1933.                 $(this).toggleClass('_open').children('ul').slideToggle();
  1934.             });
  1935.            
  1936.             $popup.find('.js-menu_appedable').on('click', 'a', function(){
  1937.                 $burger.toggleClass('opened');
  1938.                 $popup.animate({height: "0%"}, 800).removeClass('opened');
  1939.                 $this.find('.lp-menu-block-bg').fadeOut(600);
  1940.                 $this.css('z-index', '');
  1941.                 $('html').css('overflow', '');
  1942.             });
  1943.            
  1944.             if (s3LP.is_cms) {
  1945.                 setTimeout(function(){
  1946.                     LpController.afterSave(function () {
  1947.                         menuShow();
  1948.                         setTimeout(function(){
  1949.                             $(window).trigger('resize');
  1950.                         },500);
  1951.                     });
  1952.                 },2000);
  1953.             }
  1954.         });
  1955.     }
  1956.  
  1957.     lpc_template.queue.fpInit = function($self) {
  1958.         var $block = $self.find('.js-lp-fastpay');
  1959.        
  1960.         if ($block.length) {
  1961.    
  1962.             $block.on('click', '.js-fp-show-form', function(e) {
  1963.                 e.preventDefault();
  1964.    
  1965.                 var $this = $(this),
  1966.                     $parent = $this.closest('.js-lp-fastpay'),
  1967.                     //$currentParent = $this.parents('.lp-payment-service-item'),
  1968.                     //currentPrice = $currentParent.find('.lp-payment-service-item_price').html(),
  1969.                     needHref = $parent.data('page-path'),
  1970.                     serviceID = $this.data('service-id'),
  1971.                     fastPayID = $this.closest('.lp-payment-service-item').attr('data-fastpay-id');
  1972.                    
  1973.                     $this.addClass('_opened');
  1974.                    
  1975.                 $.ajax({
  1976.                     url: '/-/x-api/v1/public/?method=fastpay/getService&param[service_id]='+serviceID+'&param[fast_pay_id]='+ fastPayID +'&param[tpl]=global:lpc4.fast_payment.tpl',
  1977.                     success: function(data) {
  1978.                         var htmlForm = data.result.html;
  1979.                         var $newBlock = $this.closest('.lp-payment-service-item').append(htmlForm);
  1980.                         //let $btn = $currentParent.find('.lp-form-tpl__button-wrapper .lp-button');
  1981.                        
  1982.                         //$btn.text($btn.text() + ' ' + currentPrice);
  1983.                        
  1984.                        
  1985.                         s3LP.initForms($newBlock);
  1986.                         $this.closest('.lp-payment-service-item').find('.lp-payment-service-item_button').hide();
  1987.                         var needAttr = $self.find('.lp-payment__form').attr('data-api-url') + "&param[href]=" + needHref;
  1988.                         $newBlock.find('.lp-payment__form').attr('data-api-url', needAttr);
  1989.                         $newBlock.find('.lp-payment__form').data('api-url', needAttr);
  1990.                         $this.closest('.lp-payment-service-item').find('.payment-selection:first').addClass('_active');
  1991.                     }
  1992.                 });
  1993.                
  1994.             });
  1995.    
  1996.             $block.find('.fp_free_wrap').each(function() {
  1997.                 var $this = $(this).find('.js-lp-fp-form'),
  1998.                     $parent = $this.closest('.js-lp-fastpay'),
  1999.                     needHref = $parent.data('page-path'),
  2000.                     needAttr = $this.attr('data-api-url') + "&param[href]=" + needHref;
  2001.        
  2002.                 $this.attr('data-api-url', needAttr);
  2003.                 $this.data('api-url', needAttr);
  2004.        
  2005.             });
  2006.            
  2007.             $block.on('click', '.payment-selection-in', function(e) {
  2008.                 $(this).each(function () {
  2009.                     e.preventDefault();
  2010.                     $(this).parent('.payment-selection').siblings('.payment-selection').removeClass('_active');
  2011.                     $(this).parent('.payment-selection').addClass('_active');
  2012.                     $(this).siblings('.type-radio-payment').click();
  2013.                 });
  2014.             });
  2015.         }
  2016.        
  2017.        
  2018.     };
  2019.    
  2020.     lpc_template.queue.donationsBlock = function($self) {
  2021.         let $block = $self.find('.lpc-payment-block-2');
  2022.        
  2023.         if (!s3LP.is_cms) {
  2024.             $block.each(function(){
  2025.                 let $this = $(this);
  2026.                 let $price = $this.find('.lp-payment__form .lp-form-tpl__item:first-of-type').addClass('custom_price_input');
  2027.    
  2028.                 let $email = $this.find('.lp-payment__form input[name="email"]').val('example@gmail.com');
  2029.                 let $phone = $this.find('.lp-payment__form input[name="phone"]').val('+1234567890');
  2030.                
  2031.                 $price.find('input[name="price"]').val($block.find('.lpc_payment_buttons_js .lpc-button--type-1').text().replace(/\D/g, ''));
  2032.  
  2033.                 $this.find('.lpc_payment_buttons_js .lp-button').on('click', function(){
  2034.                     let currentValue = $(this).text().replace(/\D/g, '');
  2035.                    
  2036.                     $this.find('.lpc_payment_buttons_js .lp-button').removeClass('lpc-button--type-1').addClass('lpc-button--type-2');
  2037.                     $(this).removeClass('lpc-button--type-2').addClass('lpc-button--type-1');
  2038.                    
  2039.                     if ($(this).hasClass('custom_price_btn')) {
  2040.                         $price.fadeIn(200);
  2041.                         $this.find('input[name="price"]').val('').focus();
  2042.                     } else {
  2043.                         $this.find('input[name="price"]').val(currentValue);
  2044.                         $price.hide();
  2045.                     };
  2046.                 });
  2047.             });
  2048.         }
  2049.     };
  2050.    
  2051.  
  2052.   lpc_template.queue.popupTouch = function(){
  2053.     $('a[href^="popup:"]').on('click', function (){
  2054.         setTimeout(function() {
  2055.             lpc_template.popupAdaptiveBlock();
  2056.            
  2057.             document.dispatchEvent(new Event(`lpcPopupOpened`, {bubbles: true}));
  2058.            
  2059.             if ($('.lp-popup-wrapper form').find('input[data-alias=product_name]').val() == ""){
  2060.                 $('.lp-popup-wrapper form').find('input[data-alias=product_name]').val("Форма");
  2061.             }
  2062.          }, 80);
  2063.     })
  2064.   };
  2065.  
  2066.   lpc_template.queue.popupTouchClose = function(){
  2067.     $('.js-close-popup').bind('click', function(event){
  2068.     })
  2069.   };
  2070.  
  2071.   const adaptiveBlockEvent = new Event('dataMediaSourceChange');
  2072.   window.adaptiveBlockEvent = adaptiveBlockEvent; // сделано чтобы была возможность дергать скрипт, для сайтов с версией для слабовидящих
  2073.  
  2074.   if ($('.color-theme a').length > 0) {
  2075.       $(document).on('click', '.color-theme a', function(){
  2076.             setTimeout(function(){
  2077.                 document.dispatchEvent(adaptiveBlockEvent);
  2078.             }, 100);
  2079.       }); // исправление переключение цвета в старой версии для слабовидящих https://staff.megagroup.ru/staff/sites/?site_id=1085232
  2080.   }
  2081.  
  2082.   checkMediaSource = function(media) {
  2083.     if(lpc_template.media_source != media) {
  2084.       lpc_template.media_source = media;
  2085.       document.dispatchEvent(adaptiveBlockEvent);
  2086.     }
  2087.   }
  2088.  
  2089.  
  2090.   lpc_template.adaptiveBlock = function () {
  2091.  
  2092.     let decorWrap = document.querySelector(".decor-wrap");
  2093.  
  2094.     if(decorWrap) {
  2095.        
  2096.     let decorWrapWidth = decorWrap.offsetWidth;
  2097.       if (decorWrapWidth < 480) {
  2098.         decorWrap.setAttribute("data-media-source", "media-xs");
  2099.         checkMediaSource('media-xs');
  2100.       } else if (decorWrapWidth < 768) {
  2101.         decorWrap.setAttribute("data-media-source", "media-sm");
  2102.         checkMediaSource('media-sm');
  2103.       } else if (decorWrapWidth < 992) {
  2104.         decorWrap.setAttribute("data-media-source", "media-md");
  2105.         checkMediaSource('media-md');
  2106.       } else if (decorWrapWidth < 1280) {
  2107.         decorWrap.setAttribute("data-media-source", "media-lg");
  2108.         checkMediaSource('media-lg');
  2109.       } else if (decorWrapWidth >= 1280) {
  2110.         decorWrap.setAttribute("data-media-source", "media-xl");
  2111.         checkMediaSource('media-xl');
  2112.       }
  2113.     }
  2114.   };
  2115.  
  2116.   lpc_template.popupAdaptiveBlock = function () {
  2117.  
  2118.     let decorPopupWrap = document.querySelector(".lp-popup-inner .decor-wrap");
  2119.    
  2120.     if(decorPopupWrap) {
  2121.     let decorPopupWrapWidth = decorPopupWrap.offsetWidth;
  2122.       if (decorPopupWrapWidth < 468) {
  2123.         decorPopupWrap.setAttribute("data-media-source", "media-xs");
  2124.         checkMediaSource('media-xs');
  2125.       } else if (decorPopupWrapWidth < 740) {
  2126.         decorPopupWrap.setAttribute("data-media-source", "media-sm");
  2127.         checkMediaSource('media-sm');
  2128.       } else if (decorPopupWrapWidth < 992) {
  2129.         decorPopupWrap.setAttribute("data-media-source", "media-md");
  2130.         checkMediaSource('media-md');
  2131.       } else if (decorPopupWrapWidth < 1280) {
  2132.         decorPopupWrap.setAttribute("data-media-source", "media-lg");
  2133.         checkMediaSource('media-lg');
  2134.       } else if (decorPopupWrapWidth >= 1280) {
  2135.         decorPopupWrap.setAttribute("data-media-source", "media-xl");
  2136.         checkMediaSource('media-xl');
  2137.       }
  2138.     }
  2139.   };
  2140.  
  2141.  
  2142.  
  2143.  
  2144.   lpc_template.checkMapInitialization = function ($blocks) {
  2145.     $blocks.each(function () {
  2146.       var $this = $(this),
  2147.         id = $this.attr("id");
  2148.  
  2149.       if (initializedMaps.includes(id)) {
  2150.         return;
  2151.       }
  2152.  
  2153.       var inViewport = isElementInViewport(this);
  2154.      
  2155.       if (inViewport) {
  2156.         initializedMaps.push(id);
  2157.  
  2158.         lpc_template.initMaps($this);
  2159.       }
  2160.     });
  2161.   };
  2162.  
  2163.   lpc_template.initGoogleMaps = function (options) {
  2164.     var map = new google.maps.Map(document.getElementById(options.id), {
  2165.       zoom: parseInt(options.zoom),
  2166.       scrollwheel: false,
  2167.       center: new google.maps.LatLng(options.center[0], options.center[1]),
  2168.     });
  2169.  
  2170.     $.each(options.data, function (key, item) {
  2171.       var marker = new google.maps.Marker({
  2172.         position: new google.maps.LatLng(item.coords[0], item.coords[1]),
  2173.         map: map,
  2174.         title: item.name,
  2175.       });
  2176.  
  2177.       var infowindow = new google.maps.InfoWindow({
  2178.         content:
  2179.           '<div class="baloon-content">' +
  2180.           '<h5 class="lp-header-title-5" style="margin: 0; padding-bottom: 3px; color: inherit;">' +
  2181.           item.name +
  2182.           "</h5>" +
  2183.           item.desc +
  2184.           "</div>",
  2185.       });
  2186.  
  2187.       google.maps.event.addListener(marker, "click", function () {
  2188.         infowindow.open(map, marker);
  2189.       });
  2190.     });
  2191.   };
  2192.  
  2193.   lpc_template.initYandexMaps = function (options, objectListFlag) {
  2194.     let $wrapper = $('#'+options.id).parents('.lpc-block');
  2195.    
  2196.     if (objectListFlag) {
  2197.         let groups = options.data;
  2198.        
  2199.         var map = new ymaps.Map(options.id, {
  2200.             center: options.center,
  2201.             zoom: options.zoom,
  2202.             behaviors: ["drag", "rightMouseButtonMagnifier"],
  2203.         }, {
  2204.             searchControlProvider: 'yandex#search'
  2205.         });
  2206.  
  2207.         for (var i = 0; i < groups.length; i++) {
  2208.             createGroup(groups[i]);
  2209.         }
  2210.        
  2211.         if (options.data[0].items.length > 1) {
  2212.             map.setBounds(map.geoObjects.getBounds());
  2213.             map.setZoom(map.getZoom() - 1);
  2214.         }
  2215.        
  2216.        
  2217.     } else {
  2218.         var map = new ymaps.Map(options.id, {
  2219.           center: options.center,
  2220.           zoom: options.zoom,
  2221.           behaviors: ["drag", "rightMouseButtonMagnifier"],
  2222.         });
  2223.        
  2224.     };
  2225.  
  2226.     map.controls.add(new ymaps.control.ZoomControl());
  2227.  
  2228.     var MyBalloonContentLayoutClass = ymaps.templateLayoutFactory.createClass(
  2229.       '<div class="baloon-content" style="padding: 0 10px; ">' +
  2230.         '<h5 class="lp-header-title-5" style="margin: 0; color: inherit;">$[properties.name]</h3>' +
  2231.         '<p class="lp-header-text-3" style="color: inherit;">$[properties.desc]</p>' +
  2232.         "</div>"
  2233.     );
  2234.    
  2235.     var myCollection = new ymaps.GeoObjectCollection();
  2236.  
  2237.     $.each(options.data, function (key, item) {
  2238.         if(this.image){
  2239.             myCollection.add(
  2240.             new ymaps.Placemark(item.coords, item, {
  2241.                balloonContentLayout: MyBalloonContentLayoutClass,
  2242.                iconLayout: 'default#image',
  2243.                iconImageHref: this.image,
  2244.                iconImageOffset: [-15, -15],
  2245.             })
  2246.           );
  2247.         }   else{
  2248.           myCollection.add(
  2249.             new ymaps.Placemark(item.coords, item, {
  2250.                balloonContentLayout: MyBalloonContentLayoutClass,
  2251.                iconImageOffset: [-15, -15],
  2252.                preset: this.icon,
  2253.                iconColor: this.color,
  2254.             })
  2255.           );
  2256.         }
  2257.     });
  2258.  
  2259.     map.geoObjects.add(myCollection);
  2260.  
  2261.     $("#" + options.id).data("ymaps", map);
  2262.  
  2263.     function createGroup(group) {
  2264.         if(group.image){
  2265.             var collection = new ymaps.GeoObjectCollection(null, {iconImageHref: group.image, iconImageOffset: [-15, -15], iconLayout: 'default#image', iconColor: group.color});
  2266.         }else{
  2267.             var collection = new ymaps.GeoObjectCollection(null, {preset: group.style,  iconColor: group.color});
  2268.         }
  2269.         map.geoObjects.add(collection);
  2270.    
  2271.         for (var j = 0; j < group.items.length; j++) {
  2272.             createItems(group.items[j], collection, j);
  2273.         }
  2274.        
  2275.     }
  2276.    
  2277.     function createItems(item, collection, index) {
  2278.         var placemark = new ymaps.Placemark(item.center, { balloonContent: item.name });
  2279.         collection.add(placemark);
  2280.  
  2281.    
  2282.         $wrapper.find('.lpc-map-click').eq(index).on('click', function () {
  2283.             var $clickedItem = $(this);
  2284.            
  2285.             $wrapper.find('.lpc-map-click').removeClass('active');
  2286.            
  2287.             $clickedItem.addClass('active');
  2288.            
  2289.             if (!placemark.balloon.isOpen()) {
  2290.                 placemark.balloon.open();
  2291.             } else {
  2292.                 placemark.balloon.close();
  2293.             }
  2294.             map.setCenter(placemark.geometry.getCoordinates(), map.getZoom(), {
  2295.                 duration: 500
  2296.             });
  2297.            
  2298.             return false;
  2299.         });
  2300.        
  2301.     }
  2302.   };
  2303.  
  2304.   lpc_template.initMaps = function ($block) {
  2305.     var options = $block.data("init-params");
  2306.     var isObjectList = $block.data("object-list");
  2307.    
  2308.     options = typeof options === "string" ? JSON.parse(options.replace(/\n/g, "\\n")) : options;
  2309.    
  2310.     if (typeof options.center === "string") {
  2311.       options.center = options.center.split(",");
  2312.     }
  2313.  
  2314.     $.each(options.data, function (key, item) {
  2315.       if (typeof item.coords === "string") {
  2316.         item.coords = item.coords.split(",");
  2317.       }
  2318.     });
  2319.    
  2320.    
  2321.    
  2322.  
  2323.     var keyMap = options.key;
  2324.  
  2325.     if (options.type === "google") {
  2326.       if (window.google && window.google.maps) {
  2327.         lpc_template.initGoogleMaps(options);
  2328.       } else {
  2329.         var script = document.createElement("script");
  2330.         script.async = "async";
  2331.         script.src = `//maps.googleapis.com/maps/api/js?key=${keyMap}`;
  2332.         document.body.append(script);
  2333.  
  2334.         script.onload = function () {
  2335.           lpc_template.initGoogleMaps(options);
  2336.         };
  2337.       }
  2338.     } else {
  2339.       if (window.ymaps && window.ymaps.Map) {
  2340.         lpc_template.initYandexMaps(options, isObjectList);
  2341.       } else {
  2342.         var htmlLang = document.documentElement.lang;
  2343.         var script = document.createElement("script");
  2344.         script.async = "async";
  2345.         if (htmlLang == "en") {
  2346.           if (options.key!="") {
  2347.             script.src = `//api-maps.yandex.ru/2.1/?apikey=${keyMap}&lang=en_RU`;
  2348.           } else {
  2349.             script.src = `//api-maps.yandex.ru/2.1/?lang=en_RU`;  
  2350.           }
  2351.         } else {
  2352.           if (options.key!="") {
  2353.             script.src = `//api-maps.yandex.ru/2.1/?apikey=${keyMap}&lang=ru_RU`;
  2354.           } else {
  2355.             script.src = `//api-maps.yandex.ru/2.1/?lang=ru_RU`;  
  2356.           }
  2357.         }
  2358.  
  2359.         document.body.append(script);
  2360.  
  2361.         script.onload = function () {
  2362.           ymaps.ready(function () {
  2363.             lpc_template.initYandexMaps(options, isObjectList);
  2364.           });
  2365.         };
  2366.       }
  2367.     }
  2368.   };
  2369.  
  2370.  
  2371.     /*lpc_template.queue.lpcTriggerButton = function ($self) {
  2372.         let $block = $self.find('.lpc-constructor');
  2373.         let $button = $block.find('.lpc-video-editor__button');
  2374.         let $fillingButton = $block.find('.edit-layout');
  2375.        
  2376.         if (s3LP.is_cms && $block.length && $button.length && $fillingButton.length) {
  2377.             $button.on('click', function() {
  2378.                 $fillingButton.trigger('click');
  2379.             });
  2380.         }
  2381.     };*/
  2382.  
  2383.  
  2384.   lpc_template.queue.lpcTriggerPopupBlock = function ($self) {
  2385.         var $block = $self.find("[data-popup-type]");
  2386.        
  2387.         if($block.length){
  2388.             document.addEventListener('lpcTriggerPopupInitDone', function(){
  2389.                 lpc_template.popupAdaptiveBlock();
  2390.             });
  2391.         }
  2392.   };
  2393.  
  2394.     lpc_template.queue.lpcTimer = function ($self) {
  2395.         var $block = $self.find(".js-lp-timer"),
  2396.             htmlLang = document.documentElement.lang,
  2397.             timerDays,
  2398.             timerHours,
  2399.             timerMinutes,
  2400.             timerSeconds,
  2401.             formatOut;
  2402.  
  2403.         if (htmlLang == "de" || htmlLang == "en") {
  2404.             timerDays = "Days";
  2405.             timerHours = "Hours";
  2406.             timerMinutes = "Minutes";
  2407.             timerSeconds = "Seconds";
  2408.         } else {
  2409.             timerDays = "Дней";
  2410.             timerHours = "Часов";
  2411.             timerMinutes = "Минут";
  2412.             timerSeconds = "Секунд";
  2413.         }
  2414.  
  2415.         var formatOut =
  2416.             '<div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">%d</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2417.             timerDays +
  2418.             '</div></div><div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">%h</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2419.             timerHours +
  2420.             '</div></div><div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">%m</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2421.             timerMinutes +
  2422.             '</div></div><div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">%s</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2423.             timerSeconds +
  2424.             "</div></div>";
  2425.            
  2426.         var formatEnd =
  2427.             '<div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">00</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2428.             timerDays +
  2429.             '</div></div><div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">00</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2430.             timerHours +
  2431.             '</div></div><div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">00</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2432.             timerMinutes +
  2433.             '</div></div><div class="lp-ui-timer__item"><div class="lp-ui-timer__item-number lp-header-title-2" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-number">00</div><div class="lp-ui-timer__item-text lp-header-text-3" data-elem-type="text" data-lp-selector=".lp-ui-timer__item-text">' +
  2434.             timerSeconds +
  2435.             "</div></div>";
  2436.  
  2437.     if ($block.length) {
  2438.         $block.each(function () {
  2439.             var $this = $(this);
  2440.            
  2441.             $this.lpcTimer({
  2442.                 format_in: "%d.%M.%y %h:%m:%s",
  2443.                 language: htmlLang,
  2444.                 update_time: s3LP.is_cms ? 100000 : 1000,
  2445.                 format_out: formatOut,
  2446.                     onEnd: function () {
  2447.                         if ($this.closest('.lpc-banner__timer').length) {
  2448.                             $this.closest('.lpc-banner__timer').hide();
  2449.                         } else {
  2450.                             $this.closest('.lp-ui-timer-wrapper').hide();
  2451.                         }
  2452.                     },
  2453.                 });
  2454.             });
  2455.         }
  2456.     };
  2457.  
  2458.   lpc_template.queue.formInputs = function ($self) {
  2459.     $doc.on("click", ".js-select, .js-multi_select", function () {
  2460.       var $this = $(this),
  2461.         openedClass = "_opened",
  2462.         $thisParent = $this.closest(
  2463.           ".lp-form-tpl__field-select, .lp-form-tpl__field-multi_select"
  2464.         ),
  2465.         $thisList = $thisParent.find(
  2466.           ".lp-form-tpl__field-select__list, .lp-form-tpl__field-multi_select__list"
  2467.         );
  2468.  
  2469.        if(!s3LP.is_cms){
  2470.           if ($thisParent.hasClass(openedClass)) {
  2471.             $thisParent.removeClass(openedClass);
  2472.             //$thisList.slideUp();
  2473.            
  2474.           } else {
  2475.             $thisParent.addClass(openedClass);
  2476.             //$thisList.slideDown();
  2477.           }
  2478.       }
  2479.      
  2480.       if(s3LP.is_cms){
  2481.        
  2482.         if ($thisList.hasClass(openedClass)) {
  2483.             $thisList.removeClass(openedClass);
  2484.           } else {
  2485.             $thisList.addClass(openedClass);
  2486.           }
  2487.       }
  2488.     });
  2489.     $(document).ready(function () {
  2490.       $(".js-choose-select._checked").each(function () {
  2491.         var $this = $(this),
  2492.           thisText = $this.text(),
  2493.           $thisParent = $this.closest(".lp-form-tpl__field-select"),
  2494.           checkedClass = "_checked";
  2495.  
  2496.         $thisParent.find(".js-choose-select").removeClass(checkedClass);
  2497.         $thisParent.find(".lp-form-tpl__field-select__input").text(thisText);
  2498.         $thisParent.parent().find("input").val(thisText);
  2499.       });
  2500.     });
  2501.  
  2502.     $doc.on("click", ".js-choose-select", function () {
  2503.       var $this = $(this),
  2504.         thisText = $this.text(),
  2505.         $thisParent = $this.closest(".lp-form-tpl__field-select"),
  2506.         checkedClass = "_checked";
  2507.  
  2508.       if (!$this.hasClass(checkedClass)) {
  2509.         $thisParent.find(".js-choose-select").removeClass(checkedClass);
  2510.         $this.addClass(checkedClass);
  2511.         $thisParent.find(".lp-form-tpl__field-select__input").text(thisText);
  2512.         $thisParent.parent().find("input").val(thisText);
  2513.       }
  2514.  
  2515.       //$thisParent.find(".lp-form-tpl__field-select__list").slideUp();
  2516.       $thisParent.removeClass("_opened");
  2517.     });
  2518.  
  2519.     $doc.on("click", ".js-choose-milti_select", function () {
  2520.       var $this = $(this),
  2521.         $thisParent = $this.closest(".lp-form-tpl__field-multi_select"),
  2522.         checkedClass = "_checked";
  2523.  
  2524.       if (!$this.hasClass(checkedClass)) {
  2525.         $this.addClass(checkedClass);
  2526.       } else {
  2527.         $this.removeClass(checkedClass);
  2528.       }
  2529.  
  2530.       var choosenElements = $thisParent.find("." + checkedClass),
  2531.         choosenElementsText = [];
  2532.  
  2533.       choosenElements.each(function () {
  2534.         choosenElementsText.push($(this).text());
  2535.       });
  2536.  
  2537.       $thisParent
  2538.         .find(".lp-form-tpl__field-multi_select__input--count")
  2539.         .text(choosenElements.length);
  2540.       $thisParent.parent().find("input").val(choosenElementsText.join(", "));
  2541.     });
  2542.  
  2543.     $doc.on("click", function (e) {
  2544.         if(!s3LP.is_cms) {
  2545.             if (!$(e.target).closest('.lp-form-tpl__field-select').length) {
  2546.                 $doc.find(".lp-form-tpl__field-select").removeClass("_opened");
  2547.                 //$doc.find(".lp-form-tpl__field-select__list") .slideUp();
  2548.             };
  2549.            
  2550.             if (!$(e.target).closest('.lp-form-tpl__field-multi_select').length) {
  2551.                 $doc.find(".lp-form-tpl__field-multi_select").removeClass("_opened");
  2552.                 //$doc.find(".lp-form-tpl__field-multi_select__list") .slideUp();
  2553.             }
  2554.         }
  2555.     });
  2556.   };
  2557.  
  2558.     lpc_template.queue.productPopupFormHiddenInput = function ($self) {
  2559.         let $blocks = $self.find('.lpc-product-9');
  2560.    
  2561.         if ($blocks.length) {
  2562.             $self.on("click", ".lpc-popup-hide-input-check", function (e) {
  2563.                
  2564.                 $blocks.each(function () {
  2565.                     var $productBlock = $(this);
  2566.                    
  2567.                     if ($productBlock.find("input[data-alias='product_name']").length && $productBlock.find(".lpc-product-name [data-name-product]").length) {
  2568.                        
  2569.                         var prodName = $productBlock.find('.lpc-product-name [data-name-product]').data('name-product');
  2570.    
  2571.                         if (prodName) {
  2572.                             setTimeout(function () {
  2573.                                 $productBlock.find('form input[data-alias="product_name"]').val(prodName);
  2574.                             }, 100);
  2575.                         }
  2576.                     }
  2577.                 });
  2578.             });
  2579.         }
  2580.     };
  2581.  
  2582.  
  2583.     lpc_template.queue.popupFormHiddenInput = function ($self) {
  2584.         if($doc.find("[data-alias='product_name']" && $doc.find("[data-form-hide-input]"))){
  2585.             $doc.on("click", function (e) {
  2586.                
  2587.                 if($(e.target).closest('.lpc-popup-hide-input-check').length) {
  2588.                     var $this = $(this);
  2589.                    
  2590.                        
  2591.                     if($(e.target).closest('.lpc-tarifs-compare').length){
  2592.                         var prodName = $(e.target).closest('.lpc-popup-hide-input-check').data('button-name');
  2593.                     }   else {
  2594.                         var prodName = $(e.target).closest('.lpc-product-name').find('[data-name-product]').data('name-product');
  2595.                     }
  2596.                    
  2597.                     $('.lp-popup-wrapper form input[data-alias=product_name]').val(prodName);
  2598.                 }
  2599.             });
  2600.         }
  2601.     };
  2602.    
  2603.     lpc_template.queue.popupFastPayData = function ($self) {
  2604.         var searchLinkPopupText = "popup";
  2605.         var searchLinkScrollText = "popup";
  2606.        
  2607.         if(s3LP.is_cms) {
  2608.             $(document).ready(function () {
  2609.                 $(".lpc-popup-fastpay .lpc-popup-fastpay__form-price").text('0');
  2610.             });
  2611.         }
  2612.  
  2613.        
  2614.         $doc.on("click", function (e) {
  2615.             if($(e.target).closest('.lpc-tarifs-compare').length){
  2616.                 if($(e.target).closest('.lpc-popup-hide-input-check').length) {
  2617.                     $(e.target).closest('.lpc-popup-hide-input-check').each(function(){
  2618.                         var prodPrice = $(this).data('button-index');
  2619.                         var prodPriceCustom = prodPrice.replace(/\D/g, '');
  2620.                        
  2621.                         if (prodPrice.indexOf('/') !== -1) {
  2622.                             var prodPrice = false;
  2623.                         }
  2624.                        
  2625.                         if(prodPrice) {
  2626.                             $('.lpc-popup-fastpay__form').show();
  2627.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').val(prodPriceCustom).hide();
  2628.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lp-payment__form').removeClass('_input-active');
  2629.                            
  2630.                             if($('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lpc-popup-fastpay__content').find('.lpc-popup-fastpay__form-price').length == 0){
  2631.                                 $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lpc-popup-fastpay__content').find('.lpc-popup-fastpay__form-price').text(prodPrice).show();
  2632.                             }else {
  2633.                                 $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lpc-popup-fastpay__content').find('.lpc-popup-fastpay__form-price').text(prodPrice);
  2634.                             }
  2635.                         }
  2636.                         else {
  2637.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lp-payment__form').addClass('_input-active');
  2638.                             $('.lpc-popup-fastpay__form').hide();
  2639.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').val("").show();
  2640.                         }
  2641.                     });
  2642.                    
  2643.                     var prodName = $(e.target).closest('.lpc-popup-hide-input-check').data('button-name');
  2644.                    
  2645.                     if ($('.lp-popup-wrapper .lp-payment__form form').find('input[name=_order_details]').length) {
  2646.                         $('.lp-popup-wrapper .lp-payment__form form').find('input[name=_order_details]').val(prodName);
  2647.                     }
  2648.                 }
  2649.             } else {
  2650.                 if($(e.target).closest('.lpc-popup-hide-input-check').length) {
  2651.                     if($doc.find("[name='price']") && $doc.find(".lp-payment__form") && $(e.target).attr('href').includes(searchLinkPopupText) && $(e.target).closest('.lpc-product-name').find('[data-price-product]').length){
  2652.                         var $this = $(this),
  2653.                         prodPrice = $(e.target).closest('.lpc-product-name').find('[data-price-product]').data('price-product');
  2654.                         if (prodPrice.indexOf('/') !== -1) {
  2655.                             var prodPrice = false;
  2656.                         }else{
  2657.                             var prodPriceCustom = $(e.target).closest('.lpc-product-name').find('[data-price-product]').data('price-product').replace(/\D/g, '');
  2658.                         }
  2659.                        
  2660.                         if(prodPrice) {
  2661.                             $('.lpc-popup-fastpay__form').show();
  2662.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').val(prodPriceCustom).hide();
  2663.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lp-payment__form').removeClass('_input-active');
  2664.                            
  2665.                             if($('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lpc-popup-fastpay__content').find('.lpc-popup-fastpay__form-price').length == 0){
  2666.                                 $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lpc-popup-fastpay__content').find('.lpc-popup-fastpay__form-price').text(prodPrice).show();
  2667.                             }else {
  2668.                                 $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lpc-popup-fastpay__content').find('.lpc-popup-fastpay__form-price').text(prodPrice);
  2669.                             }
  2670.                         }else {
  2671.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lp-payment__form').addClass('_input-active');
  2672.                             $('.lpc-popup-fastpay__form').hide();
  2673.                             $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').val("").show();
  2674.                         }
  2675.                        
  2676.                     } else if($doc.find("[name='price']") && $doc.find(".lp-payment__form") && $(e.target).attr('href').includes(searchLinkPopupText) && !$(e.target).closest('.lpc-product-name').find('[data-price-product]').length) {
  2677.                         $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lp-payment__form').addClass('_input-active');
  2678.                         $('.lpc-popup-fastpay__form').hide();
  2679.                         $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').val("").show();
  2680.                         $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').siblings('.lp-form-tpl__field-text-elem').hide();
  2681.                     }
  2682.                     var prodName = $(e.target).closest('.lpc-product-name').find('[data-name-product]').data('name-product');
  2683.                     if ($('.lp-popup-wrapper .lp-payment__form form').find('input[name=_order_details]').length) {
  2684.                         $('.lp-popup-wrapper .lp-payment__form form').find('input[name=_order_details]').val(prodName);
  2685.                     }
  2686.                 }
  2687.                
  2688.                 /*if($(e.target).closest('.lpc-popup-hide-input-check').length && (!$(e.target).attr('href').includes(searchLinkPopupText) && !$(e.target).attr('href').includes(searchLinkScrollText)) && $(e.target).closest('.lpc-product-name').find('[data-price-product]').length){
  2689.                     var buttonLink = $(e.target).attr('href');
  2690.                     prodPrice = $(e.target).closest('.lpc-product-name').find('[data-price-product]').data('price-product');
  2691.                     var fastPayLink = buttonLink + '?price=' + prodPrice;
  2692.                     e.preventDefault();
  2693.                     window.location.href = fastPayLink;
  2694.                 }*/
  2695.             }
  2696.             if ($(e.target).closest('a').length && $(e.target).closest('.lpc-popup-hide-input-check').length == 0) {
  2697.                 $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').closest('.lp-payment__form').addClass('_input-active');
  2698.                 $('.lpc-popup-fastpay__form').hide();
  2699.                 $('.lpc-popup-fastpay .lp-payment-inner form input[name="price"]').val("").show();
  2700.             }
  2701.         });
  2702.     };
  2703.    
  2704.     lpc_template.queue.fortuneWheel = function ($self) {
  2705.         let $block = $self.find('.fortune-wheel'),
  2706.             $timeCookies = $block.closest('.lpc-fortuna-1').attr('data-timer-hide'),
  2707.             $timeCookies2 = $block.closest('.lpc-popup-fortune').attr('data-timer-hide'),
  2708.             $new_minut = $timeCookies,
  2709.             $new_minut2 = $timeCookies2;
  2710.            
  2711.            
  2712.         function createCookie(name, value, minutes) {
  2713.             let expires = "";
  2714.             if (minutes) {
  2715.                 const date = new Date();
  2716.                 date.setTime(date.getTime() + (minutes * 60 * 1000));
  2717.                 expires = "; expires=" + date.toUTCString();
  2718.             }
  2719.             document.cookie = name + "=" + value + expires + "; path=/";
  2720.         }
  2721.        
  2722.         if ($block.length) {
  2723.             $block.each(function(){
  2724.                 let $this = $(this);
  2725.                 var parent = $this.closest('.lpc-block');
  2726.                 var parentId = parent.attr('id');
  2727.  
  2728.                 var padding = {
  2729.                 top: 0,
  2730.                 right: 0,
  2731.                 bottom: 0,
  2732.                 left: 0
  2733.                 },
  2734.                 w = 460 - padding.left - padding.right,
  2735.                 h = 460 - padding.top - padding.bottom,
  2736.                 r = Math.min(w, h) / 2,
  2737.                 rotation = 0,
  2738.                 oldrotation = 0,
  2739.                 picked = 100000,
  2740.                 oldpick = [],
  2741.                 rotate = 0,
  2742.                 color = d3.scale.category20(); //category20c()
  2743.                 var form = parent.find('form');
  2744.                 var sendText = parent.find('.question__after-send').data('send-text');
  2745.                 var checkPopupBlock = parent.attr('data-popup-block');
  2746.                 var popupBlockBtn = parent.find('.lpc-popup-fortune__custom-btn');
  2747.                
  2748.                 if ($timeCookies) {
  2749.                     $this.closest('.lpc-fortuna-1').find('form').submit(function (e) {
  2750.                         e.preventDefault();
  2751.                         createCookie("lpcfortune", "1", parseInt($timeCookies));
  2752.                         console.log("Cookie создана!");
  2753.                     });
  2754.                 }
  2755.                
  2756.                 /*if ($timeCookies) {
  2757.                     $this.closest('.lpc-fortuna-1').find('form').submit(function(){
  2758.                         createCookie("lpcfortune", "1", $new_minut);
  2759.                     });
  2760.                 }*/
  2761.                 if ($timeCookies2) {
  2762.                     $this.closest('.lpc-popup-fortune').find('form').submit(function(){
  2763.                         createCookie("lpcfortune2", "1", $new_minut2);
  2764.                     });
  2765.                 }
  2766.                
  2767.                 function hexToRgb(hex) {
  2768.                   // Удаляем возможный символ #
  2769.                   hex = hex.replace(/^#/, '');
  2770.                
  2771.                   // Проверяем наличие корректной длины
  2772.                   if (hex.length !== 6) {
  2773.                     throw new Error('Неправильный формат шестнадцатеричного цвета. Ожидается формат "#RRGGBB".');
  2774.                   }
  2775.                
  2776.                   // Разбиваем на составляющие R, G и B
  2777.                   const r = parseInt(hex.slice(0, 2), 16);
  2778.                   const g = parseInt(hex.slice(2, 4), 16);
  2779.                   const b = parseInt(hex.slice(4, 6), 16);
  2780.                
  2781.                   return { r, g, b };
  2782.                 }
  2783.                
  2784.                 function getContrastColor(rgbStr) {
  2785.                   let customBg = hexToRgb(rgbStr);
  2786.                   let textColor = Math.round((customBg.r * 299 + customBg.g * 587 + customBg.b * 114) / 1000);
  2787.                   return (textColor > 150) ? '#000' : '#fff';
  2788.                 }
  2789.            
  2790.                 var data = $this.data("labels");
  2791.                 data = data.replace(/,$/, '');
  2792.                 data = data.replace(/"/g, '\\"');
  2793.                 data = data.replace(/'/g, '"');
  2794.                 data = JSON.parse('[' + data + ']');
  2795.                
  2796.                 var infiniteRotate = $this.data("infinite")
  2797.                
  2798.                 var svg = d3.select('#'+parentId + ' .fortune-wheel')
  2799.                     .append("svg")
  2800.                     .data([data])
  2801.                     .attr("width", w + padding.left + padding.right)
  2802.                     .attr("height", h + padding.top + padding.bottom);
  2803.                
  2804.                 var container = svg.append("g")
  2805.                     .attr("class", "chartholder")
  2806.                     .attr("transform", "translate(" + (w / 2 + padding.left) + "," + (h / 2 + padding.top) + ")");
  2807.                    
  2808.                 container.append("circle")
  2809.                     .attr("cx", 0)
  2810.                     .attr("cy", 0)
  2811.                     .attr("r", 230)
  2812.                     .style({
  2813.                         "fill": "var(--primary-color-base)"
  2814.                     });
  2815.                
  2816.                 var vis = container
  2817.                     .append("g");
  2818.                    
  2819.                 if(infiniteRotate) {
  2820.                     vis.attr("class", "infinite-rotate");
  2821.                 } else {
  2822.                     if(data.length % 2 === 0 && data.length / 2 % 2 !== 0) {
  2823.                         rotate = 360 / data.length / 2;
  2824.                         vis.style({
  2825.                             "transform": "rotate(" + rotate + "deg)"
  2826.                         });
  2827.                         oldrotation = rotate
  2828.                     }  
  2829.                 }
  2830.                
  2831.                 var pie = d3.layout.pie().sort(null).value(function(d) {
  2832.                     return 1;
  2833.                 });
  2834.                
  2835.                 // declare an arc generator function
  2836.                 var arc = d3.svg.arc().outerRadius(r);
  2837.                
  2838.                 // select paths, use arc generator to draw
  2839.                 var arcs = vis.selectAll("g.slice")
  2840.                     .data(pie)
  2841.                     .enter()
  2842.                     .append("g")
  2843.                     .attr("class", "slice");
  2844.                
  2845.                
  2846.                 arcs.append("path")
  2847.                     .attr("fill", function(d, i) {
  2848.                         return i % 2 ? 'var(--primary-color-base)' : 'var(--primary-color-l-5)';
  2849.                     })
  2850.                     .attr("d", function(d) {
  2851.                         return arc(d);
  2852.                     });
  2853.                
  2854.                 // add the text
  2855.                 arcs.append("text")
  2856.                     .attr("text-anchor", "middle")
  2857.                     .attr("class", "lp-header-text-3")
  2858.                     .style({
  2859.                         "fill": function() {
  2860.                             // Получаем fill у path, к которому относится текущий текстовый элемент
  2861.                             let pathFill = d3.select(this.parentNode).select("path").attr("fill");
  2862.                             let pathFillColor = getComputedStyle(document.documentElement).getPropertyValue(pathFill.match(/var\((.*?)\)/)?.[1])
  2863.                             return getContrastColor(pathFillColor);
  2864.                           }
  2865.                     })
  2866.                     .text(function(d, i) {
  2867.                         return data[i].label;
  2868.                 });
  2869.  
  2870.  
  2871.                 function beforeSubmitActions(event) {
  2872.                     event.preventDefault();
  2873.                     container.call(spin);
  2874.                 }
  2875.                
  2876.                
  2877.                 function firstStepSpin(event) {
  2878.                     event.preventDefault();
  2879.                     popupBlockBtn.addClass('lpc_pointer_events_none');
  2880.                     container.call(popupspin);
  2881.                    
  2882.                     setTimeout(function() {
  2883.                         parent.find('.lpc-popup-fortune__step-1').hide();
  2884.                         parent.find('.lpc-popup-fortune__step-2').show();
  2885.                     }, 3000);
  2886.                    
  2887.                 }
  2888.                
  2889.                 if(checkPopupBlock) {
  2890.                     popupBlockBtn.on('click', firstStepSpin);
  2891.                    
  2892.                     form.on('submit', popupSubmit);
  2893.                    
  2894.                     $('.lpc-popup-fortune__finish-btn').on('click', function(){
  2895.                         $(this).closest('.lp-popup-wrapper').find('.js-close-popup').trigger('click'); 
  2896.                     });
  2897.                 }else {
  2898.                     form.on('submit', beforeSubmitActions);
  2899.                 }
  2900.                
  2901.                
  2902.                 wrap(arcs.selectAll("text"), 140);
  2903.                
  2904.                 function wrap(text, width) {
  2905.                
  2906.                     text.each(function() {
  2907.                         var text = d3.select(this),
  2908.                             words = text.text().split(/\s+/).reverse(),
  2909.                             word,
  2910.                             line = [],
  2911.                             lineNumber = 0,
  2912.                             lineHeight = 1, // ems
  2913.                             y = text.attr("y"),
  2914.                             dy = 0,
  2915.                             tspan = text.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", dy + "em");
  2916.                         while (word = words.pop()) {
  2917.                             line.push(word);
  2918.                             tspan.text(line.join(" "));
  2919.                             if (tspan.node().getComputedTextLength() > width) {
  2920.                                 line.pop();
  2921.                                 tspan.text(line.join(" "));
  2922.                                 line = [word];
  2923.                                 tspan = text.append("tspan").attr("x", 0).attr("y", y).attr("dy", Math.sqrt(++lineNumber) * lineHeight + dy + "em").text(word);
  2924.                             }
  2925.                             text.attr("transform", function(d) {
  2926.                                 d.innerRadius = 0;
  2927.                                 d.outerRadius = r;
  2928.                                 d.angle = (d.startAngle + d.endAngle) / 2;
  2929.                                 return "rotate(" + (d.angle * 180 / Math.PI - 90 + 1.75 - lineNumber * 2) + ")translate(" + (d.outerRadius - 90) + ")";
  2930.                             })
  2931.                         }
  2932.                     });
  2933.                 }
  2934.                
  2935.                
  2936.                 function spin(d) {
  2937.                
  2938.                     container.on("click", null);
  2939.                
  2940.                     //all slices have been seen, all done
  2941.                     //console.log("OldPick: " + oldpick.length, "Data length: " + data.length);
  2942.                     if (oldpick.length == data.length) {
  2943.                         container.on("click", null);
  2944.                         return;
  2945.                     }
  2946.                
  2947.                     var ps = 360 / data.length,
  2948.                         pieslice = Math.round(1440 / data.length),
  2949.                        
  2950.                         rng = Math.floor((Math.random() * 1440) + 360);
  2951.                        
  2952.                     rotation = (Math.round(rng / ps) * ps);
  2953.                
  2954.                     picked = Math.round(data.length - (rotation % 360) / ps);
  2955.                     picked = picked >= data.length ? (picked % data.length) : picked;
  2956.                
  2957.                
  2958.                     if (oldpick.indexOf(picked) !== -1) {
  2959.                         d3.select(this).call(spin);
  2960.                         return;
  2961.                     } else {
  2962.                         oldpick.push(picked);
  2963.                     }
  2964.                
  2965.                     rotation += 90 - Math.round(ps / 2) - rotate;
  2966.                    
  2967.                     if(infiniteRotate) {
  2968.                         setTimeout(function () {
  2969.                             vis.attr("class", "stop-rotate");
  2970.                         }, 2600);
  2971.                     }
  2972.                    
  2973.                    
  2974.                     vis.transition()
  2975.                         .style({
  2976.                             "animation-duration": "2.9s"
  2977.                         })
  2978.                         .duration(3000)
  2979.                         .attrTween("style", rotTween)
  2980.                         .each("end", function() {
  2981.                            
  2982.                             //mark question as seen
  2983.                             d3.select('#' + parentId + ' .slice:nth-child(' + (picked + 1) + ') path')
  2984.                                 .attr("fill", "var(--primary-color-d-10)");
  2985.                                
  2986.                             d3.select('#' + parentId + ' .slice:nth-child(' + (picked + 1) + ') text').style({
  2987.                                 "fill": function() {
  2988.                                     // Получаем fill у path, к которому относится текущий текстовый элемент
  2989.                                     let pathFillColor = getComputedStyle(document.documentElement).getPropertyValue('--primary-color-d-10')
  2990.                                     return getContrastColor(pathFillColor);
  2991.                                   }
  2992.                             })
  2993.                
  2994.                             //populate question
  2995.                             $('#'+parentId).find('[data-alias="prize"]').val(data[picked].label);
  2996.                            
  2997.                             $('#'+parentId + ' .lp-form-tpl__button').click();
  2998.                            
  2999.                             d3.select('#'+parentId + ' .question__after-send h2')
  3000.                                 .text(sendText + ' ' + data[picked].label);
  3001.                                
  3002.                             $('#'+parentId + ' .question__before-send').hide();
  3003.                             $('#'+parentId + ' .question__after-send').show("slow").fadeOut;
  3004.                             $('#'+parentId + ' .question-message').hide();
  3005.  
  3006.                                
  3007.                             $('#'+parentId + ' form').hide();
  3008.                            
  3009.                             console.log(sendText + ' ' + data[picked].label);
  3010.                             createCookie("lpcfortunetext", sendText + ' ' + data[picked].label, $new_minut);
  3011.                             //container.on("click", spin);
  3012.                         });
  3013.                    
  3014.                 }
  3015.                
  3016.                 function popupSubmit(d) {
  3017.                     $('#'+parentId + ' .lp-form-tpl__button').click();
  3018.                            
  3019.                     /*d3.select('#'+parentId + ' .question__after-send h2')
  3020.                     .text(sendText + ' ' + data[picked].label);*/
  3021.                        
  3022.                     $('#'+parentId + ' .question__before-send').hide();
  3023.                     $('#'+parentId + ' .question__after-send').hide()
  3024.                     $('#'+parentId + ' .question-message').hide();
  3025.                     $('#'+parentId + ' form').hide();
  3026.                    
  3027.                     setTimeout(function() {
  3028.                         $('#'+parentId + ' .lpc-popup-fortune__step-2').addClass('_last-step');
  3029.                         $('#'+parentId + ' .lpc-popup-fortune__finish-btn').show();
  3030.                     }, 950);
  3031.                    
  3032.                 }
  3033.                
  3034.                 function popupspin(d) {
  3035.                
  3036.                     container.on("click", null);
  3037.                
  3038.                     //all slices have been seen, all done
  3039.                     if (oldpick.length == data.length) {
  3040.                         container.on("click", null);
  3041.                         return;
  3042.                     }
  3043.                
  3044.                     var ps = 360 / data.length,
  3045.                         pieslice = Math.round(1440 / data.length),
  3046.                        
  3047.                         rng = Math.floor((Math.random() * 1440) + 360);
  3048.                        
  3049.                     rotation = (Math.round(rng / ps) * ps);
  3050.                
  3051.                     picked = Math.round(data.length - (rotation % 360) / ps);
  3052.                     picked = picked >= data.length ? (picked % data.length) : picked;
  3053.                
  3054.                
  3055.                     if (oldpick.indexOf(picked) !== -1) {
  3056.                         d3.select(this).call(spin);
  3057.                         return;
  3058.                     } else {
  3059.                         oldpick.push(picked);
  3060.                     }
  3061.                
  3062.                     rotation += 90 - Math.round(ps / 2) - rotate;
  3063.                    
  3064.                     if(infiniteRotate) {
  3065.                         setTimeout(function () {
  3066.                             vis.attr("class", "stop-rotate");
  3067.                         }, 2600);
  3068.                     }
  3069.                    
  3070.                    
  3071.                     vis.transition()
  3072.                         .style({
  3073.                             "animation-duration": "2.9s"
  3074.                         })
  3075.                         .duration(3000)
  3076.                         .attrTween("style", rotTween)
  3077.                         .each("end", function() {
  3078.                            
  3079.                             //mark question as seen
  3080.                             d3.select('#' + parentId + ' .slice:nth-child(' + (picked + 1) + ') path')
  3081.                                 .attr("fill", "var(--primary-color-d-10)");
  3082.                                
  3083.                             d3.select('#' + parentId + ' .slice:nth-child(' + (picked + 1) + ') text').style({
  3084.                                 "fill": function() {
  3085.                                     // Получаем fill у path, к которому относится текущий текстовый элемент
  3086.                                     let pathFillColor = getComputedStyle(document.documentElement).getPropertyValue('--primary-color-d-10')
  3087.                                     return getContrastColor(pathFillColor);
  3088.                                   }
  3089.                             })
  3090.                
  3091.                             //populate question
  3092.                             $('#'+parentId).find('[data-alias="prize"]').val(data[picked].label);
  3093.                            
  3094.                             /*if(!checkPopupBlock) {
  3095.                             $('#'+parentId + ' .lp-form-tpl__button').click();
  3096.                            
  3097.                             d3.select('#'+parentId + ' .question__after-send h2')
  3098.                             .text(sendText + ' ' + data[picked].label);
  3099.                                
  3100.                             $('#'+parentId + ' .question__before-send').hide();
  3101.                             $('#'+parentId + ' .question__after-send').show();
  3102.                             $('#'+parentId + ' .question-message').hide();
  3103.  
  3104.                                
  3105.                             $('#'+parentId + ' form').hide();
  3106.                             }*/
  3107.                            
  3108.                             d3.select('#'+parentId + ' .question__after-send h2')
  3109.                             .text(sendText + ' ' + data[picked].label);
  3110.                            
  3111.                             $('#'+parentId + ' .question__after-send').show();
  3112.                             $('#'+parentId + ' .lpc-popup-fortune__step-2').show();
  3113.                            
  3114.                             createCookie("lpcfortune2text", sendText + ' ' + data[picked].label, $new_minut2);
  3115.                            
  3116.                             //container.on("click", spin);
  3117.                         });
  3118.                    
  3119.                 }
  3120.                
  3121.                 //make arrow
  3122.                 svg.append("g")
  3123.                     .attr("transform", "translate(" + (w - 42) + "," + ((h / 2) - 25) + ")")
  3124.                     .append("path")
  3125.                     .attr("class", "wheel-indicator")
  3126.                     .attr("d", "M40.0261 10.6195L11.9636 23.1737C10.386 23.8795 10.386 26.1192 11.9637 26.825L40.0261 39.3793C41.3491 39.9712 42.8428 39.003 42.8428 37.5536V12.4451C42.8428 10.9957 41.3491 10.0276 40.0261 10.6195Z")
  3127.                     .style({
  3128.                         "fill": "white"
  3129.                     });
  3130.                
  3131.                 //draw spin circle
  3132.                 container.append("circle")
  3133.                     .attr("cx", 0)
  3134.                     .attr("cy", 0)
  3135.                     .attr("r", 20)
  3136.                     .attr("stroke", "#fff")
  3137.                     .attr("stroke-width", "7")
  3138.                     .attr("class", "inner-circle")
  3139.                     .style({
  3140.                         "fill": "var(--primary-color-base)"
  3141.                     });
  3142.  
  3143.                 container.append("circle")
  3144.                     .attr("cx", 0)
  3145.                     .attr("cy", 0)
  3146.                     .attr("r", 230)
  3147.                     .attr("stroke", "#fff")
  3148.                     .attr("class", "outer-circle")
  3149.                     .attr("stroke-width", "10")
  3150.                     .style({
  3151.                         "fill": "transparent"
  3152.                     });
  3153.                    
  3154.                 function rotTween(to) {
  3155.                     var i = d3.interpolate(oldrotation % 360, rotation + rotate);
  3156.                     return function(t) {
  3157.                         return "transform: rotate(" + i(t) + "deg)";
  3158.                     };
  3159.                 }
  3160.             });
  3161.         }
  3162.     };
  3163.  
  3164.     lpc_template.queue.calendar = function ($self) {
  3165.         $doc.on("click", ".lpc-js-form-calendar", function () {
  3166.             var $this = $(this),
  3167.                 thisCalendarInited = $this.data("calendarInited");
  3168.                
  3169.             var clickPosY = event.clientY || event.pageY;
  3170.             var windowHeight = $(window).height();
  3171.             var clickPosition = (windowHeight - clickPosY);
  3172.                
  3173.             //if (!thisCalendarInited) {
  3174.             if (clickPosition < 263) {
  3175.                 var bb = $this
  3176.                     .datepickerlpc({
  3177.                         position: 'top left'
  3178.                     })
  3179.                     .data("datepickerlpc");
  3180.                 bb.show();
  3181.                 thisCalendarInited = $this.data("calendarInited", true);
  3182.             }else {
  3183.                 var bb = $this
  3184.                     .datepickerlpc({
  3185.                         position: 'bottom left'
  3186.                     })
  3187.                     .data("datepickerlpc");
  3188.                 bb.show();
  3189.                 thisCalendarInited = $this.data("calendarInited", true);
  3190.             }
  3191.         });
  3192.    
  3193.         $doc.on("click", ".lpc-js-form-calendar-interval", function () {
  3194.             var $this = $(this),
  3195.                 thisCalendarInited = $this.data("calendarInited");
  3196.                
  3197.             var clickPosY = event.clientY || event.pageY;
  3198.             var windowHeight = $(window).height();
  3199.             var clickPosition = (windowHeight - clickPosY);    
  3200.    
  3201.             //if (!thisCalendarInited) {
  3202.             if (clickPosition < 263) { 
  3203.                 var bb = $this
  3204.                     .datepickerlpc({
  3205.                         position: 'top left',
  3206.                         range: true,
  3207.                         multipleDatesSeparator: " - ",
  3208.                     })
  3209.                     .data("datepickerlpc");
  3210.                 bb.show();
  3211.                 thisCalendarInited = $this.data("calendarInited", true);
  3212.             }else {
  3213.                 var bb = $this
  3214.                     .datepickerlpc({
  3215.                         position: 'bottom left',
  3216.                         range: true,
  3217.                         multipleDatesSeparator: " - ",
  3218.                     })
  3219.                     .data("datepickerlpc");
  3220.                 bb.show();
  3221.                 thisCalendarInited = $this.data("calendarInited", true);
  3222.             }
  3223.         });
  3224.     };
  3225.    
  3226.     lpc_template.queue.anchorMenu = function ($self) {
  3227.         let $block = $self.find('.lpc_anchor_menu_init');
  3228.    
  3229.         if ($block.length) {
  3230.             let links = $block.find('.lpc-anchor-menu-fixed__link');
  3231.             let choiceElem = $block.attr('data-lpc-choice-elem');
  3232.             let booleanValue = (choiceElem === 'true');
  3233.             let fixedBlock = $block.find('.lpc-anchor-menu-fixed');
  3234.             let mosaicWrap = $(document).find('.mosaic-wrap');
  3235.             let button = $block.find('.lpc-anchor-menu-fixed__button-text');
  3236.             let $lpcWrap = $('.decor-wrap');
  3237.  
  3238.             let hiddenBlockIds = [];
  3239.            
  3240.             $lpcWrap.each(function () {
  3241.                 let $this = $(this);
  3242.            
  3243.                 if (s3LP.is_cms) {
  3244.                     $this.find('.popup-row-block').each(function() {
  3245.                         let s3lpPopupValue = $(this).find('[data-blocks-popup]').data('blocks-popup');
  3246.                         hiddenBlockIds.push(s3lpPopupValue);
  3247.                     });
  3248.                 } else {
  3249.                     let blocksPopupValue = $this.find('[data-blocks-popup]').data('blocks-popup');
  3250.                     let blocksPopupValue2 = $this.find('._hide-block').data('block-id');
  3251.                    
  3252.                     hiddenBlockIds.push(blocksPopupValue === undefined ? blocksPopupValue2 : blocksPopupValue);
  3253.                 }
  3254.             });
  3255.            
  3256.             if (isMobile) {
  3257.                 let touchStartX = 0, touchEndX = 0;
  3258.                 let isActive = false;
  3259.                
  3260.                 button.on('click', function () {
  3261.                     if (isActive && fixedBlock.hasClass('active')) {
  3262.                         fixedBlock.removeClass('active');
  3263.                         isActive = false;
  3264.                     } else {
  3265.                         fixedBlock.addClass('active');
  3266.                         isActive = true;
  3267.                     }
  3268.                 });
  3269.            
  3270.                 button.on('touchstart', function(e) {
  3271.                     touchStartX = e.originalEvent.touches[0].clientX;
  3272.                 });
  3273.            
  3274.                 button.on('touchmove', function(e) {
  3275.                     touchEndX = e.originalEvent.touches[0].clientX;
  3276.                 });
  3277.            
  3278.                 button.on('touchend', function(e) {
  3279.                     handleButtonSwipe();
  3280.                 });
  3281.            
  3282.                 function handleButtonSwipe() {
  3283.                     var swipeLength = touchEndX - touchStartX;
  3284.                     if (swipeLength > 100) {
  3285.                         fixedBlock.removeClass('active');
  3286.                     } else if (swipeLength < -100) {
  3287.                         fixedBlock.addClass('active');
  3288.                     }
  3289.                    
  3290.                     touchStartX = 0;
  3291.                     touchEndX = 0;
  3292.                 }
  3293.                
  3294.                 $(document).on('keydown', function (e) {
  3295.                     if (e.keyCode === 27) {
  3296.                         fixedBlock.removeClass('active');
  3297.                     }
  3298.                 });
  3299.            
  3300.                 $(document).on('click', function (e) {
  3301.                     if (!$(e.target).closest('.lpc-anchor-menu-fixed').length) {
  3302.                         fixedBlock.removeClass('active');
  3303.                     }
  3304.                 });
  3305.             }
  3306.  
  3307.             setTimeout(function(){
  3308.                 let buttonHeight = $block.find('.lpc-anchor-menu-fixed__button').outerHeight();
  3309.                 let listHeight = $block.find('.lpc-anchor-menu-fixed__list').outerHeight();
  3310.                 let listBlock = $block.find('.lpc-anchor-menu-fixed__list');
  3311.                
  3312.                 var $wrapBlock = $block.closest('.lpc-anchor-menu');
  3313.                 var blockId = $wrapBlock.attr('id');
  3314.                 var blockLayout = $wrapBlock.attr('data-block-layout');
  3315.                
  3316.                 if (buttonHeight === listHeight) {
  3317.                     listBlock.addClass('no-border-radius');
  3318.                 } else {
  3319.                     listBlock.removeClass('no-border-radius');
  3320.                 }
  3321.                
  3322.                 if (mosaicWrap.length && !$block.hasClass('lpc_constructor')) {
  3323.                     mosaicWrap.prepend(fixedBlock);
  3324.                    
  3325.                     fixedBlock.attr('id', blockId);
  3326.                     fixedBlock.attr('data-block-layout', blockLayout);
  3327.                 }
  3328.                
  3329.             }, 350);
  3330.            
  3331.             links.each(function () {
  3332.                 let $this = $(this);
  3333.                 let blockId = $this.attr('href').replace('#', '');
  3334.                 let offsetValue = parseFloat($this.attr('data-lpc-offset'));
  3335.                 let offsetValueMobile = parseFloat($this.attr('data-lpc-offset-mobile'));
  3336.                 let targetBlock = $('#' + blockId);
  3337.                 let headerElements = targetBlock.find('[data-elem-type="header"]:not(.lpc-list-illustration__title--hidden)');
  3338.                
  3339.                 let blockPopupId = parseFloat($this.attr('href').replace(/\D/g, '')); // Получаем id блока из атрибута href
  3340.                
  3341.                 if (hiddenBlockIds.includes(blockPopupId)) {
  3342.                     $this.parent('.lpc-anchor-menu-fixed__item').remove();
  3343.                 }
  3344.                
  3345.                 if (headerElements.length > 0 && $this.hasClass('lpc-has-block-name')) {
  3346.                     let headerText = headerElements.first().text();
  3347.                     $this.text(headerText);
  3348.                 }
  3349.            
  3350.                 if (booleanValue === false && headerElements.length === 0) {
  3351.                     if ($this.length > 0) {
  3352.                         $this.parent().remove();
  3353.                     }
  3354.                 } else {
  3355.                     $this.on('click', function (event) {
  3356.                         event.preventDefault();
  3357.            
  3358.                         links.removeClass('active');
  3359.                         $this.addClass('active');
  3360.        
  3361.                         if (targetBlock.length) {
  3362.                            
  3363.                             var targetBlockOffset = isMobile ? targetBlock.offset().top - offsetValueMobile : targetBlock.offset().top - offsetValue;
  3364.                            
  3365.                             $('html, body').stop().animate({
  3366.                                 scrollTop: targetBlockOffset
  3367.                             }, 800, function () {
  3368.                                 history.pushState(null, null, '#' + blockId);
  3369.                             });
  3370.                         }
  3371.                     });
  3372.                 }
  3373.                
  3374.                 links.removeClass('lpc-opacity');
  3375.                
  3376.             });
  3377.         }
  3378.     };
  3379.    
  3380.     lpc_template.queue.movingPictures = function ($self) {
  3381.         let $block = $self.find('.lpc_moving_pictures_init');
  3382.    
  3383.         if ($block.length) {
  3384.            
  3385.             setTimeout(function () {
  3386.                
  3387.                 $block.each(function () {
  3388.                     let $this = $(this),
  3389.                         $wrapper = $this.find('.lpc_moving_pictures_wrap'),
  3390.                         $marquee = $this.find('.lpc_moving_pictures_move'),
  3391.                         marqueeSpeed = $this.data('marquee-speed') || 1,
  3392.                         speed = marqueeSpeed,
  3393.                         position = 0,
  3394.                         animationFrame,
  3395.                         wrapperWidth = $wrapper[0].offsetWidth,
  3396.                         direction = 'left',
  3397.                         isInMiddle = false,
  3398.                         totalWidth = 0;
  3399.    
  3400.                     if (!s3LP.is_cms) {
  3401.                        
  3402.                         $marquee.find('.lpc_moving_pictures_item').each(function () {
  3403.                             totalWidth += $(this).outerWidth(true);
  3404.                         });
  3405.    
  3406.                         while (totalWidth < wrapperWidth) {
  3407.                             $marquee.find('.lpc_moving_pictures_item').each(function () {
  3408.                                 let $clone = $(this).clone();
  3409.                                 $marquee.append($clone);
  3410.                                 totalWidth += $clone.outerWidth(true);
  3411.                             });
  3412.                         }
  3413.    
  3414.                         let clonedContent = $marquee.html();
  3415.                         $marquee.html(clonedContent + clonedContent);
  3416.                        
  3417.                     } else {
  3418.                        
  3419.                         function s3lazyLoadImages() {
  3420.                            
  3421.                             const $s3lazyImage = $(".lpc-ticker__carousel-mask-item img[data-src]");
  3422.                            
  3423.                             const s3LoadImage = (image) => {
  3424.                                 const src = $(image).attr('data-src');
  3425.                                
  3426.                                 if (src) {
  3427.                                     $(image).attr('src', src);
  3428.                                     $(image).removeAttr('data-src');
  3429.                                 }
  3430.                             };
  3431.                            
  3432.                             $s3lazyImage.each(function () {
  3433.                                 s3LoadImage(this);
  3434.                             });
  3435.                         }
  3436.                        
  3437.                         s3lazyLoadImages();
  3438.                     }
  3439.    
  3440.                     let marqueeWidth = totalWidth;
  3441.                    
  3442.                     function lazyLoadImages() {
  3443.                         const $lazyImage = $(".lpc-ticker__carousel-mask-item img[data-src]");
  3444.                        
  3445.                         const loadImage = (image) => {
  3446.                             const src = $(image).attr('data-src');
  3447.                            
  3448.                             if (src) {
  3449.                                 $(image).attr('src', src);
  3450.                                 $(image).removeAttr('data-src');
  3451.                             }
  3452.                         };
  3453.                        
  3454.                         const isImageVisible = (image) => {
  3455.                             let imgLeft = $(image).offset().left,
  3456.                                 imgRight = imgLeft + $(image).outerWidth(),
  3457.                                 wrapperLeft = $wrapper.offset().left,
  3458.                                 wrapperRight = wrapperLeft + $wrapper.outerWidth();
  3459.    
  3460.                             return imgRight > wrapperLeft && imgLeft < wrapperRight;
  3461.                         };
  3462.                        
  3463.                         $lazyImage.each(function () {
  3464.                             if (isImageVisible(this)) {
  3465.                                 loadImage(this);
  3466.                             }
  3467.                         });
  3468.                     }
  3469.    
  3470.                     function move() {
  3471.                         window.cancelAnimationFrame(animationFrame);
  3472.    
  3473.                         if (direction === 'left') {
  3474.                             position -= speed;
  3475.                         } else {
  3476.                             position += speed;
  3477.                         }
  3478.    
  3479.                         if (!s3LP.is_cms) {
  3480.                            
  3481.                             if (direction === 'left' && position <= -marqueeWidth) {
  3482.                                 position = 0;
  3483.                             } else if (direction === 'right' && position >= 0) {
  3484.                                 position = -marqueeWidth;
  3485.                             }
  3486.    
  3487.                             $marquee.css('transform', 'translate3d(' + position + 'px, 0, 0)');
  3488.    
  3489.                             animationFrame = window.requestAnimationFrame(move);
  3490.                            
  3491.                             lazyLoadImages();
  3492.    
  3493.                         } else {
  3494.                            
  3495.                             if (direction === 'left' && position <= -(marqueeWidth - wrapperWidth)) {
  3496.                                 window.cancelAnimationFrame(animationFrame);
  3497.                                 return;
  3498.                             } else if (direction === 'right' && position >= 0) {
  3499.                                 window.cancelAnimationFrame(animationFrame);
  3500.                                 return;
  3501.                             }
  3502.    
  3503.                             $marquee.css('transform', 'translate3d(' + position + 'px, 0, 0)');
  3504.    
  3505.                             animationFrame = window.requestAnimationFrame(move);
  3506.                         }
  3507.                     }
  3508.    
  3509.                     move();
  3510.    
  3511.                     var leftRightZoneWidth = wrapperWidth * 0.4;
  3512.                     var middleZoneWidth = wrapperWidth * 0.2;
  3513.    
  3514.                     var getZone = function (posX) {
  3515.                         if (posX < leftRightZoneWidth) {
  3516.                             return 'left';
  3517.                         } else if (posX > wrapperWidth - leftRightZoneWidth) {
  3518.                             return 'right';
  3519.                         } else {
  3520.                             return 'middle';
  3521.                         }
  3522.                     };
  3523.    
  3524.                     var prevMouseX;
  3525.                     var minSpeed = speed;
  3526.    
  3527.                     var handleMove = function (event, isTouch = false) {
  3528.                         var posX = isTouch ? event.originalEvent.touches[0].pageX - $wrapper[0].getBoundingClientRect().left : event.pageX - $wrapper[0].getBoundingClientRect().left;
  3529.                         var zone = getZone(posX);
  3530.                         var speedIncrement = 0.03;
  3531.                         var maxSpeed = speed + (speed * 0.5);
  3532.    
  3533.                         if (zone === 'left') {
  3534.                             direction = 'right';
  3535.    
  3536.                             if (prevMouseX !== undefined) {
  3537.                                 var distanceMoved = prevMouseX - posX;
  3538.                                 speed += distanceMoved * speedIncrement;
  3539.                                 speed = Math.max(minSpeed, Math.min(speed, maxSpeed));
  3540.                             }
  3541.    
  3542.                             prevMouseX = posX;
  3543.    
  3544.                         } else if (zone === 'right') {
  3545.                             direction = 'left';
  3546.    
  3547.                             if (prevMouseX !== undefined) {
  3548.                                 var distanceMoved = posX - prevMouseX;
  3549.                                 speed += distanceMoved * speedIncrement;
  3550.                                 speed = Math.max(minSpeed, Math.min(speed, maxSpeed));
  3551.                             }
  3552.    
  3553.                             prevMouseX = posX;
  3554.    
  3555.                         } else if (zone === 'middle') {
  3556.                             window.cancelAnimationFrame(animationFrame);
  3557.                             isInMiddle = true;
  3558.                             prevMouseX = posX;
  3559.                             return;
  3560.                         }
  3561.    
  3562.                         if (isInMiddle) {
  3563.                             isInMiddle = false;
  3564.                             move();
  3565.                         }
  3566.                     };
  3567.    
  3568.                     if (isMobile) {
  3569.                         $wrapper.on('touchmove', function (event) {
  3570.                             handleMove(event, true);
  3571.                         });
  3572.    
  3573.                         $wrapper.on('touchend', function () {
  3574.                             speed = minSpeed;
  3575.                             prevMouseX = undefined;
  3576.                             move();
  3577.                         });
  3578.                     } else {
  3579.                         $wrapper.on('mousemove', handleMove);
  3580.    
  3581.                         $wrapper.on('mouseleave', function () {
  3582.                             speed = minSpeed;
  3583.                             prevMouseX = undefined;
  3584.                             move();
  3585.                         });
  3586.                     }
  3587.                 });
  3588.                
  3589.                 lpc_template.queue.lgNew($block);
  3590.    
  3591.             }, 500);
  3592.         }
  3593.     };
  3594.  
  3595.    
  3596.     lpc_template.queue.QRcode = function ($self) {
  3597.         let $block = $self.find('.lpc_qr_init');
  3598.    
  3599.         if ($block.length) {
  3600.             $block.each(function () {
  3601.                 let item = $(this);
  3602.                 let messengerWrap = item.find('.lpc_qr_code_item');
  3603.    
  3604.                 messengerWrap.each(function () {
  3605.                     let item = $(this);
  3606.                     let containerQr = item.find('.lpc_qr_code_container');
  3607.                     let containerQrPhone = item.find('.lpc_qr_code_container_phone');
  3608.    
  3609.                     let messengerLinks = item.find('.lpc_qr_code_link');
  3610.                     let messengerLinksPhone = item.find('.lpc_qr_code_link_phone');
  3611.    
  3612.                     let urls = messengerLinks.map(function () {
  3613.                         return $(this).attr('href');
  3614.                     }).get();
  3615.    
  3616.                     let urlsPhone = messengerLinksPhone.map(function () {
  3617.                         return $(this).attr('href').replace(/[^\d+]/g, '');
  3618.                     }).get();
  3619.    
  3620.                     let sizes = messengerLinks.map(function () {
  3621.                         return $(this).attr('data-qr-code-size');
  3622.                     }).get();
  3623.    
  3624.                     let sizesPhone = messengerLinksPhone.map(function () {
  3625.                         return $(this).attr('data-qr-code-size');
  3626.                     }).get();
  3627.    
  3628.                     urls.forEach(function (url, index) {
  3629.                         if (containerQr.length) {
  3630.                             createQR(containerQr.eq(index), sizes[index], url);
  3631.                             $('body').append(containerQr.eq(index));
  3632.                         }
  3633.                     });
  3634.    
  3635.                     urlsPhone.forEach(function (url, index) {
  3636.                         if (containerQrPhone.length) {
  3637.                             createQR(containerQrPhone.eq(index), sizesPhone[index], url);
  3638.                             $('body').append(containerQrPhone.eq(index));
  3639.                         }
  3640.                     });
  3641.    
  3642.                     messengerLinks.hover(function () {
  3643.                         let index = messengerLinks.index(this);
  3644.                         showQR(containerQr.eq(index), $(this));
  3645.                     }, function () {
  3646.                         let index = messengerLinks.index(this);
  3647.                         hideQR(containerQr.eq(index));
  3648.                     });
  3649.    
  3650.                     messengerLinksPhone.hover(function () {
  3651.                         let index = messengerLinksPhone.index(this);
  3652.                         showQR(containerQrPhone.eq(index), $(this));
  3653.                     }, function () {
  3654.                         let index = messengerLinksPhone.index(this);
  3655.                         hideQR(containerQrPhone.eq(index));
  3656.                     });
  3657.                 });
  3658.    
  3659.                 function createQR(container, size, url) {
  3660.                     container.qrcode({
  3661.                         width: size,
  3662.                         height: size,
  3663.                         text: url
  3664.                     }).css({
  3665.                         position: 'absolute',
  3666.                         display: 'none',
  3667.                         zIndex: 1000
  3668.                     });
  3669.                 }
  3670.    
  3671.                  function showQR(container, link) {
  3672.                     let linkOffset = link.offset();
  3673.                     let containerWidth = container.outerWidth();
  3674.                     let containerHeight = container.outerHeight();
  3675.    
  3676.                     let left = linkOffset.left; // Относительно левого края наведенного элемента
  3677.                     let top = linkOffset.top - containerHeight - 10;
  3678.  
  3679.                     // Проверяем, выходит ли контейнер за пределы экрана справа
  3680.                     if (left + containerWidth > $(window).width()) {
  3681.                         left = linkOffset.left - containerWidth + link.outerWidth();
  3682.                     }
  3683.    
  3684.                     container.css({
  3685.                         top: top,
  3686.                         left: left,
  3687.                         display: 'block'
  3688.                     });
  3689.                 }
  3690.    
  3691.                 function hideQR(container) {
  3692.                     container.css({
  3693.                         display: 'none'
  3694.                     });
  3695.                 }
  3696.             });
  3697.         }
  3698.     };
  3699.    
  3700.    
  3701.     lpc_template.queue.rowMenu = function ($self) {
  3702.         let $block = $self.find('.lpc-row-menu');
  3703.    
  3704.         function rowMenuItems() {
  3705.             $block.each(function () {
  3706.                 let $this = $(this);
  3707.                 let $menu = $this.find('.lpc-menu-horizontal__list');
  3708.                 let $toggleButton = $this.find('.lpc-menu-horizontal__more');
  3709.    
  3710.                 let hideText = document.querySelector('html').getAttribute('lang') === 'ru' ? 'Скрыть' : 'Hide';
  3711.                 let currentText = document.querySelector('html').getAttribute('lang') === 'ru' ? 'Ещё' : 'Show more';
  3712.    
  3713.                 let $insTextButton = $toggleButton.find('ins');
  3714.                 let $hiddenItems = $menu.find('li:not(.lpc-menu-horizontal__more):hidden');
  3715.                
  3716.                 if ($hiddenItems.length) {
  3717.                     $toggleButton.addClass('show');
  3718.                 }
  3719.                
  3720.                 $toggleButton.off('click').on('click', function () {
  3721.                     $toggleButton.toggleClass('active');
  3722.                     $menu.toggleClass('lpc-menu-horizontal__list--show-items');
  3723.                     $insTextButton.text($toggleButton.hasClass('active') ? hideText : currentText);
  3724.                 });
  3725.             });
  3726.         }
  3727.    
  3728.         rowMenuItems();
  3729.    
  3730.         document.addEventListener('dataMediaSourceChange', rowMenuItems);
  3731.     };
  3732.    
  3733.     lpc_template.queue.spoilerText = function ($self) {
  3734.         let $block = $self.find('.lpc-spoiler-text-init');
  3735.    
  3736.         if ($block.length) {
  3737.             $block.each(function () {
  3738.                 let $this = $(this);
  3739.                 let $item = $this.find('.lpc-spoiler-text-item');
  3740.    
  3741.                 if ($item.length != 0) {
  3742.                     $item.each(function () {
  3743.                         let $title = $(this).find('.lpc-spoiler-title-click');
  3744.                         let $text = $(this).find('.lpc-spoiler-text-hide');
  3745.                         let $button = $(this).find('.lpc-spoiler-more');
  3746.    
  3747.                         let hideText = document.querySelector('html').getAttribute('lang') === 'ru' ? 'Свернуть' : 'Collapse';
  3748.                         let currentText = document.querySelector('html').getAttribute('lang') === 'ru' ? 'Читать полностью' : 'Read completely';
  3749.    
  3750.                         let originalText = $text.html().trim(); // Используем .html() вместо .text() чтобы сохранить HTML-структуру.
  3751.                         let limit = parseInt($text.attr('data-limit'), 10);
  3752.    
  3753.                         if (isNaN(limit)) {
  3754.                             limit = 200;
  3755.                         }
  3756.    
  3757.                         function expandText() {
  3758.                             $text.html(originalText);
  3759.                             $button.text(hideText).show();
  3760.                         }
  3761.    
  3762.                         function collapseText() {
  3763.                             let trimmedText = originalText.substr(0, limit);
  3764.                             $text.html(trimmedText + '...');
  3765.                             $button.text(currentText).hide();
  3766.                             $block.addClass('is-active');
  3767.                         }
  3768.    
  3769.                         function toggleText() {
  3770.                             if ($text.html() === originalText) {
  3771.                                 collapseText();
  3772.                             } else {
  3773.                                 expandText();
  3774.                             }
  3775.                         }
  3776.    
  3777.                         if (limit === 0) {
  3778.                             expandText();
  3779.                             $button.hide();
  3780.                             $title.off('click').removeClass('lpc-spoiler-title-click');
  3781.                         } else if (originalText.length > limit) {
  3782.                             collapseText();
  3783.                             $title.click(function () {
  3784.                                 expandText();
  3785.                             });
  3786.                         } else if (limit > originalText.length) {
  3787.                             expandText();
  3788.                             $button.hide();
  3789.                             $title.off('click');
  3790.                             $block.addClass('is-active');
  3791.                         } else {
  3792.                             $button.hide();
  3793.                             $title.off('click');
  3794.                         }
  3795.    
  3796.                         $button.click(function () {
  3797.                             collapseText();
  3798.                         });
  3799.                     });
  3800.                 }
  3801.             });
  3802.         }
  3803.     };
  3804.    
  3805.     lpc_template.queue.accordeon = function ($self) {
  3806.         var $block = $self.find('.js-accordeon');
  3807.        
  3808.         $block.each(function(){
  3809.             var $tabsRemember = $(this).closest('.lpc-block').find('._item');
  3810.            
  3811.             $(this).on('click', function (event) {
  3812.                 var $thisParent = $(this).closest('._item'),
  3813.                     $thisText = $thisParent.find('._text'),
  3814.                     $maps = $(this).parents('.lpc-maps-parent').find('.js-lpc-simple-map'),
  3815.                     $thisBlock = $(this).closest('.lpc-block').data('block-layout');
  3816.                  
  3817.                 if ($(event.target).hasClass('_text')) {
  3818.                     event.stopPropagation();
  3819.                     return;
  3820.                 }
  3821.                
  3822.                 if (!$thisText.is(':animated')) {
  3823.                     $thisParent.toggleClass('active');
  3824.                     $thisText.slideToggle();
  3825.        
  3826.                     if ($maps.length && !$maps.hasClass('initialized')) {
  3827.                         $maps.each(function () {
  3828.                             var $map = $(this);
  3829.        
  3830.                             setTimeout(function(){
  3831.                                 lpc_template.checkMapInitialization($map);
  3832.                                 $map.addClass('initialized');
  3833.                             }, 400)
  3834.                         });
  3835.                     }
  3836.                 }
  3837.                    
  3838.                 var openTabsArray = [];
  3839.                
  3840.                 $tabsRemember.each(function(index) {
  3841.                     if ($(this).hasClass('active')) {
  3842.                         openTabsArray.push(index);
  3843.                     }
  3844.                 });
  3845.                
  3846.                 var jsonStrOpenTabsArray = JSON.stringify(openTabsArray);
  3847.                
  3848.                 createCookie($thisBlock, jsonStrOpenTabsArray, 1);
  3849.             });
  3850.  
  3851.             $tabsRemember.each(function(){
  3852.                 if ($(this).hasClass('active')) {
  3853.                     $(this).find('._text').slideDown();
  3854.                 }
  3855.             });
  3856.            
  3857.             if ($(this).data('accordeon-opened') == 1) {
  3858.                 $(this).trigger('click', function(){});
  3859.                
  3860.                 if (s3LP.is_cms) {
  3861.                     $('.content_contructor').trigger('click', function(){});
  3862.                 }
  3863.             }
  3864.         });
  3865.    
  3866.     };
  3867.  
  3868.     lpc_template.queue.lpcSimpleAccordeon = function ($self) {
  3869.         var $block = $self.find(".js_accordeon_title"),
  3870.             activeClass = "active";
  3871.    
  3872.         if ($block.length) {
  3873.             $block.on("click", function (e) {
  3874.                 e.preventDefault();
  3875.    
  3876.                 var $this = $(this),
  3877.                     $ymap = $this
  3878.                         .closest("[data-block-layout]")
  3879.                         .find(".js-lpc-simple-map");
  3880.                 ($thisParent = $this.closest("._parent")),
  3881.                     ($thisBody = $thisParent.find("._content"));
  3882.    
  3883.                 if ($thisParent.hasClass(activeClass)) {
  3884.                     $thisBody.slideUp(400, function () {
  3885.                         $thisParent.removeClass(activeClass);
  3886.                         if ($ymap.length && $ymap.data("ymaps")) {
  3887.                             $ymap.data("ymaps").container.fitToViewport();
  3888.                         }
  3889.                     });
  3890.                 } else {
  3891.                     $thisBody.slideDown(400, function () {
  3892.                         $thisParent.addClass(activeClass);
  3893.                         if ($ymap.length && $ymap.data("ymaps")) {
  3894.                             $ymap.data("ymaps").container.fitToViewport();
  3895.                         }
  3896.                     });
  3897.                 }
  3898.             });
  3899.         }
  3900.     };
  3901.  
  3902.     lpc_template.queue.lpcSimpleColumn = function ($self) {
  3903.         var $block = $self.find(".js-lpc-simple-colum");
  3904.    
  3905.         if ($block.length) {
  3906.             $block.each(function () {
  3907.                 var $this = $(this),
  3908.                     $items = $this.find("._parent");
  3909.                 countArray = $this.data("column-count");
  3910.    
  3911.                 $doc.on("checkDeviceType", function (e, param) {
  3912.                     var thisCount =
  3913.                         param === "mobile"
  3914.                             ? countArray[2]
  3915.                             : param === "tablet"
  3916.                                 ? countArray[1]
  3917.                                 : countArray[0];
  3918.    
  3919.                     unwrap($items);
  3920.    
  3921.                     if (thisCount == 1) {
  3922.                         $items.wrap('<div class="_simple-col"></div>');
  3923.                         return;
  3924.                     }
  3925.    
  3926.                     var itemsLengthInColumn = Math.round($items.length / thisCount);
  3927.    
  3928.                     for (let i = 1; i < thisCount + 1; i += 1) {
  3929.                         $items
  3930.                             .filter(function (index) {
  3931.                                 return (
  3932.                                     index >= (i - 1) * itemsLengthInColumn &&
  3933.                                     index < i * itemsLengthInColumn
  3934.                                 );
  3935.                             })
  3936.                             .wrapAll('<div class="_simple-col"></div>');
  3937.                     }
  3938.                 });
  3939.             });
  3940.    
  3941.             function unwrap($list) {
  3942.                 $list.each(function () {
  3943.                     if (!this.parentNode.classList.contains("_simple-col")) return;
  3944.                     $(this).unwrap();
  3945.                 });
  3946.             }
  3947.         }
  3948.     };
  3949.    
  3950.     lpc_template.queue.blockAfterBefore = function ($self) {
  3951.         var $block = $self.find(".lpc-before-and-after-init");
  3952.    
  3953.         if ($block.length) {
  3954.             (() => {'use strict';
  3955.    
  3956.                 class BeforeAfter {
  3957.                     constructor(selector = '.before-after') {
  3958.                         this.selector = selector;
  3959.                         this.items = [];
  3960.                     }
  3961.    
  3962.                     init() {
  3963.                         let wrappers = document.querySelectorAll(this.selector);
  3964.    
  3965.                         for (let wrapper of wrappers) {
  3966.                             if (wrapper.dataset.beforeAfterInitialized === 'true') {
  3967.                                 continue;
  3968.                             }
  3969.                             let item = new BeforeAfterItem(wrapper).init();
  3970.                             this.items.push(item);
  3971.                            
  3972.                             wrapper.dataset.beforeAfterInitialized = 'true';
  3973.                            
  3974.                             let observer = new MutationObserver(function (mutations) {
  3975.                                 mutations.forEach(function (mutation) {
  3976.                                     if ($(mutation.target).hasClass('lp-selected-element')) {
  3977.                                         $(mutation.target).parent().addClass('active');
  3978.                                     } else {
  3979.                                         $(mutation.target).parent().removeClass('active');
  3980.                                     }
  3981.                                 });
  3982.                             });
  3983.                             let config = {
  3984.                                 attributes: true,
  3985.                                 attributeFilter: ['class']
  3986.                             };
  3987.                            
  3988.                             observer.observe($(wrapper).find('.before-after__img-before')[0], config);
  3989.                             observer.observe($(wrapper).find('.before-after__img-after')[0], config);
  3990.                         }
  3991.                     }
  3992.                 }
  3993.    
  3994.                 class BeforeAfterItem {
  3995.                     constructor(el) {
  3996.                         this.wrapper = el;
  3997.                         this.dragElWrapper = null;
  3998.                         this.viewport = null;
  3999.                         this.before = null;
  4000.                         this.after = null;
  4001.                         this.offset = 0;
  4002.                         this.pageXStart = 0;
  4003.                         this.startOffset = 0;
  4004.                         this.onPointerDown = this.onPointerDown.bind(this);
  4005.                         this.onPointerMove = this.onPointerMove.bind(this);
  4006.                         this.onPointerUp = this.onPointerUp.bind(this);
  4007.                     }
  4008.                     init() {
  4009.                         let wrapper = this.wrapper;
  4010.    
  4011.                         let dragElWrapper = this.dragElWrapper = document.createElement('div');
  4012.    
  4013.                         dragElWrapper.classList.add('before-after__drag-wrapper');
  4014.                         dragElWrapper.style.left = '50%';
  4015.    
  4016.                         let dragEl = document.createElement('div');
  4017.    
  4018.                         dragEl.classList.add('before-after__drag');
  4019.    
  4020.                         dragElWrapper.append(dragEl);
  4021.    
  4022.                         let viewport = this.viewport = wrapper.querySelector('.before-after__viewport');
  4023.    
  4024.                         viewport.append(dragElWrapper);
  4025.                         wrapper.classList.add('before-after--loaded');
  4026.    
  4027.                         this.before = viewport.querySelector('.lpc-image-before');
  4028.                         this.after = viewport.querySelector('.lpc-image-after');
  4029.    
  4030.                         this.move(this.offset);
  4031.    
  4032.                         dragElWrapper.addEventListener('mousedown', this.onPointerDown);
  4033.                         dragElWrapper.addEventListener('touchstart', this.onPointerDown);
  4034.    
  4035.                         dragElWrapper.addEventListener('dragstart', () => {
  4036.                             return false;
  4037.                         });
  4038.    
  4039.                         return this;
  4040.                     }
  4041.    
  4042.                     onPointerDown(e) {
  4043.                         e.stopPropagation();
  4044.    
  4045.                         if (e.touches) {
  4046.                             this.pageXStart = e.touches[0].pageX;
  4047.                         } else {
  4048.                             this.pageXStart = e.pageX;
  4049.                         }
  4050.                         this.startOffset = this.offset;
  4051.    
  4052.                         document.addEventListener('mousemove', this.onPointerMove);
  4053.                         document.addEventListener('touchmove', this.onPointerMove);
  4054.                         document.addEventListener('mouseup', this.onPointerUp);
  4055.                         document.addEventListener('touchend', this.onPointerUp);
  4056.                     }
  4057.    
  4058.                     onPointerMove(e) {
  4059.                         let viewport = this.viewport,
  4060.                             pxOffset = 0,
  4061.                             percentOffset = 0;
  4062.    
  4063.                         if (e.touches) {
  4064.                             pxOffset = e.touches[0].pageX - this.pageXStart;
  4065.                         } else {
  4066.                             pxOffset = e.pageX - this.pageXStart;
  4067.                         }
  4068.    
  4069.                         percentOffset = parseFloat((pxOffset / viewport.clientWidth * 100).toFixed(6));
  4070.    
  4071.                         this.offset = this.startOffset + percentOffset;
  4072.    
  4073.                         if (this.offset >= 50) {
  4074.                             this.offset = 50;
  4075.                         } else if (this.offset <= -50) {
  4076.                             this.offset = -50;
  4077.                         }
  4078.    
  4079.                         this.move(this.offset);
  4080.                     }
  4081.    
  4082.                     onPointerUp() {
  4083.                         document.removeEventListener('mousemove', this.onPointerMove);
  4084.                         document.removeEventListener('touchmove', this.onPointerMove);
  4085.                         document.removeEventListener('mouseup', this.onPointerUp);
  4086.                         document.removeEventListener('touchend', this.onPointerUp);
  4087.                     }
  4088.    
  4089.                     move(offset) {
  4090.                         this.dragElWrapper.style.left = 'calc(50% + ' + offset + '%)';
  4091.                         this.before.style.clipPath = 'inset(0 calc(50% - ' + offset + '%) 0 0)';
  4092.                         this.after.style.clipPath = 'inset(0 0 0 calc(50% + ' + offset + '%))';
  4093.                     }
  4094.    
  4095.                 }
  4096.                 window.BeforeAfter = BeforeAfter;
  4097.             })();
  4098.    
  4099.             new BeforeAfter().init();
  4100.         }
  4101.     };
  4102.    
  4103.     lpc_template.queue.spoilerBlock = function ($self) {
  4104.         let $block = $self.hasClass('spoiler-init') ? $self : $self.find('.spoiler-init');
  4105.  
  4106.         $block.each(function(){
  4107.             let $this = $(this);
  4108.  
  4109.             initSpoiler();
  4110.             document.addEventListener('dataMediaSourceChange', initSpoiler);
  4111.            
  4112.             function initSpoiler() {
  4113.                 let $hidden = $this.find('.spoiler-item:hidden');
  4114.                 let $firstNotHidden = $this.find('.spoiler-item').first();
  4115.                 let $btn = $this.find('.spoiler-btn');
  4116.                 let $btnWrap = $this.find('.spoiler-btn-wrap');
  4117.  
  4118.  
  4119.                 if ($hidden.length) {
  4120.                     $btnWrap.addClass('show_spoiler');
  4121.                    
  4122.                     $btn.on('click', function(){
  4123.                         $hidden.slideDown('150', function(){
  4124.                             if ($firstNotHidden.css('display') == 'flex') {
  4125.                                 $hidden.css('display', 'flex');
  4126.                             }
  4127.                         });
  4128.                         $(this).hide();
  4129.                     });
  4130.                 } else  {
  4131.                     $btnWrap.removeClass('show_spoiler');
  4132.                 }
  4133.             }
  4134.         });
  4135.     };
  4136.    
  4137.     lpc_template.queue.iframeLazyLoading = function($self) {
  4138.         var $block = $self.find('.lpc-lazy-iframe-js');
  4139.         var iframes = $block.find($('iframe'));
  4140.        
  4141.         if($block.length && iframes.length) {
  4142.           iframes.each(function() {
  4143.               var iframe = $(this);
  4144.               /*var src = iframe.attr('src');
  4145.               iframe.removeAttr('src');
  4146.               iframe.attr('loading', 'lazy');
  4147.               iframe.attr('data-src', src);*/
  4148.               iframe.addClass('lazy lazyload');
  4149.           });
  4150.         }
  4151.     };
  4152.    
  4153.     lpc_template.queue.lazyLoading = function($self) {
  4154.         var $block = $self.find('.lpc-lazy-loading-init');
  4155.    
  4156.         if ($block.length) {
  4157.             $block.each(function () {
  4158.                 const $this = $(this);
  4159.                 const blocks = $this.find('.lpc-lazy-loading-item');
  4160.                 const blocksScrollShow = 1;
  4161.                 let visibleBlockCount = blocksScrollShow;
  4162.    
  4163.                 function showBlocks(startIndex, endIndex) {
  4164.                     for (let i = startIndex; i < endIndex; i++) {
  4165.                         blocks.eq(i).removeClass('hidden');
  4166.                     }
  4167.                 }
  4168.    
  4169.                 function hideAllBlocks() {
  4170.                     blocks.addClass('hidden');
  4171.                 }
  4172.    
  4173.                 hideAllBlocks();
  4174.                 showBlocks(0, 3);
  4175.    
  4176.                 function handleScroll() {
  4177.                     const scrollTop = $(window).scrollTop();
  4178.                     const windowHeight = $(window).height();
  4179.                     const totalBlockCount = blocks.length;
  4180.                     const totalVisibleBlocks = Math.min(visibleBlockCount, totalBlockCount);
  4181.                     const lazyLoadingListBottom = $this.find('.lpc-lazy-loading-list').offset().top + $this.find('.lpc-lazy-loading-list').outerHeight() + 100;
  4182.    
  4183.                     if (scrollTop + windowHeight >= lazyLoadingListBottom) {
  4184.                         if (visibleBlockCount < totalBlockCount) {
  4185.                             const newVisibleCount = Math.min(visibleBlockCount + blocksScrollShow, totalBlockCount);
  4186.                             showBlocks(visibleBlockCount, newVisibleCount);
  4187.                             visibleBlockCount = newVisibleCount;
  4188.                         }
  4189.                     }
  4190.                 }
  4191.    
  4192.                 $(window).on('scroll', handleScroll);
  4193.             });
  4194.         }
  4195.     };
  4196.    
  4197.     lpc_template.queue.typeWriter = function ($self) {
  4198.         let $block = $self.find('.lpc-typewriter-init');
  4199.    
  4200.         if ($block.length) {
  4201.             $block.each(function () {
  4202.                 const $this = $(this);
  4203.                 const stringElements = $this.find(".lpc-typewriter-string");
  4204.                 const delay = $this.attr("data-delay");
  4205.                 const delayDeletion = $this.attr("data-delay-deletion");
  4206.                 const stopDialing = $this.attr("data-stop-dialing");
  4207.    
  4208.                 function typeText(element, text, delay, callback) {
  4209.                     let index = 0;
  4210.                     const textLength = text.length;
  4211.    
  4212.                     function addCharacter() {
  4213.                         if (index < textLength) {
  4214.                             element.textContent += text.charAt(index);
  4215.                             index++;
  4216.                             setTimeout(addCharacter, delay);
  4217.                         } else {
  4218.                             setTimeout(callback, delayDeletion);
  4219.                         }
  4220.                     }
  4221.    
  4222.                     addCharacter();
  4223.                 }
  4224.    
  4225.                 function eraseText(element, delay, callback) {
  4226.                     const text = element.textContent;
  4227.                     let index = text.length;
  4228.    
  4229.                     function removeCharacter() {
  4230.                         if (index > 0) {
  4231.                             element.textContent = text.substring(0, index - 1);
  4232.                             index--;
  4233.                             setTimeout(removeCharacter, delay);
  4234.                         } else {
  4235.                             callback();
  4236.                         }
  4237.                     }
  4238.    
  4239.                     removeCharacter();
  4240.                 }
  4241.    
  4242.                 function animateElements(index) {
  4243.                     if (index < stringElements.length) {
  4244.                         const element = stringElements[index];
  4245.                         const text = element.getAttribute("data-text");
  4246.                
  4247.                         typeText(element, text, delay, function () {
  4248.                             if (index === stringElements.length - 1 && stopDialing === "1") {
  4249.                                
  4250.                                 setTimeout(function () {
  4251.                                     element.style.display = "inline";
  4252.                                     animateElements(index + 1);
  4253.                                 }, 250);
  4254.                                
  4255.                             } else {
  4256.                                
  4257.                                 eraseText(element, delay, function () {
  4258.                                     element.style.display = "none";
  4259.                                     setTimeout(function () {
  4260.                                         animateElements(index + 1);
  4261.                                     }, 250);
  4262.                                 });
  4263.                             }
  4264.                         });
  4265.                     } else {
  4266.                         if (stopDialing === "1") {
  4267.                             const lastElement = stringElements[stringElements.length - 1];
  4268.                             const lastText = lastElement.getAttribute("data-text");
  4269.                             lastElement.textContent = lastText;
  4270.                         } else {
  4271.                             setTimeout(function () {
  4272.                                 $this.find(".lpc-typewriter-string").each(function () {
  4273.                                     $(this).text("");
  4274.                                     $(this).css("display", "inline");
  4275.                                 });
  4276.                                 animateElements(0);
  4277.                             }, delay);
  4278.                         }
  4279.                     }
  4280.                 }
  4281.    
  4282.                 animateElements(0);
  4283.             });
  4284.         }
  4285.     };
  4286.    
  4287.     lpc_template.queue.albumGallery = function ($self) {
  4288.         let $block = $self.find('.lpc-album-gallery-init');
  4289.    
  4290.         if ($block.length) {
  4291.             $block.each(function () {
  4292.                 let $this = $(this);
  4293.                 let item = $this.find('.lpc-gallery-click');
  4294.                 let popup = $this.find('.lpc-album-gallery-popup');
  4295.                 let popupItems = $this.find('.lpc-album-gallery-popup__item');
  4296.                 let buttonBack = $this.find('.lpc-album-gallery-popup__back');
  4297.                 let buttonClose = $this.find('.lpc-album-gallery-popup__close');
  4298.    
  4299.                 let body = $('body');
  4300.                 let popupImageBox = popup.find('.lpc-album-gallery-popup__image-box');
  4301.                 let mosaicWrap = $(document).find('.mosaic-wrap');
  4302.                
  4303.                 setTimeout(function(){
  4304.                     if (mosaicWrap.length && !$block.hasClass('lpc_constructor')) {
  4305.                         mosaicWrap.prepend(popup);
  4306.                         popup.addClass('lpc-block');
  4307.                     }
  4308.                 }, 300);
  4309.                
  4310.                 if (popup.find('.js-new-lg-init').length) {
  4311.                    
  4312.                     popupImageBox.click(function () {
  4313.                         popup.addClass('is-hidden');
  4314.                     });
  4315.        
  4316.                     body.on('click', function (event) {
  4317.                         if (!$(event.target).closest('.lg-prev, .lg-next, .lg-toolbar, .lg-image, .lpc-album-gallery-popup, .lpc-album-gallery-popup__image-box').length) {
  4318.                             popup.removeClass('is-hidden');
  4319.                         }
  4320.                        
  4321.                         if ($(event.target).closest('.lg-close').length) {
  4322.                             popup.removeClass('is-hidden');
  4323.                         }
  4324.                     });
  4325.                 }
  4326.    
  4327.                 item.click(function () {
  4328.                     let dataIndex = $(this).data("index");
  4329.    
  4330.                     popup.fadeIn().addClass("active");
  4331.    
  4332.                     if (!isMobile) {
  4333.                         $("body").css({ 'padding-right': '17px' });
  4334.                     }
  4335.    
  4336.                     $("html").addClass("lpc-no-scroll");
  4337.                     popupItems.removeClass("active");
  4338.                     popupItems.filter("[data-index='" + dataIndex + "']").addClass("active");
  4339.                 });
  4340.    
  4341.                 buttonBack.click(function () {
  4342.                     popup.fadeOut().removeClass("active");
  4343.                     $("body").css({ 'padding-right': '' });
  4344.                     $("html").removeClass("lpc-no-scroll");
  4345.                     popupItems.removeClass("active");
  4346.                 });
  4347.    
  4348.                 buttonClose.click(function () {
  4349.                     popup.fadeOut().removeClass("active");
  4350.                     $("body").css({ 'padding-right': '' });
  4351.                     $("html").removeClass("lpc-no-scroll");
  4352.                     popupItems.removeClass("active");
  4353.                 });
  4354.    
  4355.                 $(document).keydown(function (e) {
  4356.                     if (e.keyCode === 27 && !$('.lg-outer').length) {
  4357.                         popup.fadeOut().removeClass("active");
  4358.                         $("body").css({ 'padding-right': '' });
  4359.                         $("html").removeClass("lpc-no-scroll");
  4360.                         popupItems.removeClass("active");
  4361.                     }
  4362.                    
  4363.                     popup.removeClass('is-hidden');
  4364.                 });
  4365.             });
  4366.         }
  4367.     };
  4368.    
  4369.     lpc_template.queue.splideMarquee = function ($self) {
  4370.         let $block = $self.attr('data-marquee-init') ? $self : $self.find('[data-marquee-init]');
  4371.    
  4372.         setTimeout(function(){
  4373.        
  4374.             if ($block.length) {
  4375.                 $block.each(function () {
  4376.                     let $this = $(this);
  4377.                     let mediaGap = $this.data('marquee-margin');
  4378.                     let mediaPerPage = $this.data('marquee-count');
  4379.                     let margueeDrag = $this.data('marquee-drag');
  4380.                     let margueePause = $this.data('marquee-pause');
  4381.                     let margueeSpeed = $this.data('marquee-speed');
  4382.                     let margueeReverse = $this.data('marquee-revese');
  4383.    
  4384.                     let autoScrollSpeed = (margueeReverse === true || margueeReverse === 'true') ? -margueeSpeed : margueeSpeed;
  4385.        
  4386.                     if ($(this).data('move')) {
  4387.                         var $mediaMove = $(this).data('move');
  4388.                     } else {
  4389.                         var $mediaMove = 1;
  4390.                     }
  4391.        
  4392.                     if ($this.find('.splide').not('.is-active').length != 0) {
  4393.        
  4394.                         $this.find('.splide').not('.is-active').each(function () {
  4395.                        
  4396.                             let splide = new Splide($(this)[0], {
  4397.                                 type: 'loop',
  4398.                                 drag: margueeDrag,
  4399.                                 focus: 'center',
  4400.                                 arrows: false,
  4401.                                 pagination: false,
  4402.                                 perMove: $mediaMove,
  4403.                                 perPage: checkInitPerPage(),
  4404.                                 lazyLoad: 'nearby',
  4405.                                 autoScroll: {
  4406.                                     speed: autoScrollSpeed,
  4407.                                     pauseOnHover: margueePause,
  4408.                                     pauseOnFocus: margueePause,
  4409.                                 }
  4410.                             });
  4411.                            
  4412.                             splide.mount(window.splide.Extensions);
  4413.        
  4414.                             sliderBreakPoints();
  4415.        
  4416.                             document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  4417.        
  4418.                             function sliderBreakPoints() {
  4419.                                 let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  4420.        
  4421.                                 switch (dataMediaSource) {
  4422.                                     case 'media-xl':
  4423.                                         splide.options = {
  4424.                                             gap: mediaGap[0],
  4425.                                             perPage: mediaPerPage[0],
  4426.                                         };
  4427.                                         break;
  4428.                                     case 'media-lg':
  4429.                                         splide.options = {
  4430.                                             gap: mediaGap[1],
  4431.                                             perPage: mediaPerPage[1],
  4432.                                         };
  4433.                                         break;
  4434.                                     case 'media-md':
  4435.                                         splide.options = {
  4436.                                             gap: mediaGap[2],
  4437.                                             perPage: mediaPerPage[2],
  4438.                                         };
  4439.                                         break;
  4440.                                     case 'media-sm':
  4441.                                         splide.options = {
  4442.                                             gap: mediaGap[3],
  4443.                                             perPage: mediaPerPage[3],
  4444.                                         };
  4445.                                         break;
  4446.                                     case 'media-xs':
  4447.                                         splide.options = {
  4448.                                             gap: mediaGap[4],
  4449.                                             perPage: mediaPerPage[4],
  4450.                                         };
  4451.                                         break;
  4452.                                 }
  4453.                             };
  4454.        
  4455.                             function checkInitPerPage() {
  4456.                                 let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  4457.        
  4458.                                 switch (dataMediaSource) {
  4459.                                     case 'media-xl':
  4460.                                         return mediaPerPage[0]
  4461.                                         break;
  4462.                                     case 'media-lg':
  4463.                                         return mediaPerPage[1]
  4464.                                         break;
  4465.                                     case 'media-md':
  4466.                                         return mediaPerPage[2]
  4467.                                         break;
  4468.                                     case 'media-sm':
  4469.                                         return mediaPerPage[3]
  4470.                                         break;
  4471.                                     case 'media-xs':
  4472.                                         return mediaPerPage[4]
  4473.                                         break;
  4474.                                 };
  4475.                             };
  4476.                         });
  4477.                     }
  4478.                 });
  4479.             }
  4480.        
  4481.         }, 1000);
  4482.     };
  4483.    
  4484.     lpc_template.queue.masonGallery = function ($self) {
  4485.         let $block = $self.find('.lpc-masonry-init');
  4486.    
  4487.         if ($block.length) {
  4488.             $block.each(function () {
  4489.                 let $this = $(this);
  4490.                 let listbox = $this.find(".lpc-image-mason__list");
  4491.                 let lazyItems = $this.find(".lpc-image-mason__item img[data-src]");
  4492.                 let windowHeight = $(window).height();
  4493.    
  4494.                 function loadVisibleItems() {
  4495.                     lazyItems.each(function (index, item) {
  4496.                         const rect = item.getBoundingClientRect();
  4497.    
  4498.                         if (rect.top < windowHeight) {
  4499.                             const img = $(item);
  4500.    
  4501.                             if (!img.hasClass('is-loaded')) {
  4502.                                 img.on('load', function () {
  4503.                                     img.closest('.lpc-image-mason__item').addClass('is-show');
  4504.                                     resizeGridItem(img.closest('.lpc-image-mason__item'));
  4505.                                 });
  4506.    
  4507.                                 img.attr('src', img.data('src'));
  4508.                                 img.addClass('is-loaded');
  4509.                             }
  4510.                         }
  4511.                     });
  4512.    
  4513.                     lazyItems = $this.find(".lpc-image-mason__item img[data-src]");
  4514.                 }
  4515.    
  4516.                 function resizeGridItem(item) {
  4517.                     let grid = $this.find('.lpc-image-mason__list');
  4518.                     let rowHeight = parseInt(grid.css("grid-auto-rows"));
  4519.                     let rowGap = parseInt(grid.css("grid-row-gap"));
  4520.    
  4521.                     let rowSpan = Math.ceil(
  4522.                         (item.find('.lpc-image-mason__image').outerHeight() + rowGap) / (rowHeight + rowGap)
  4523.                     );
  4524.                     item.css("grid-row-end", "span " + rowSpan);
  4525.    
  4526.                     let image = item.find('.lpc-image-mason__image');
  4527.                     image.css("height", "100%");
  4528.                 }
  4529.    
  4530.                 $(window).on('scroll', function () {
  4531.                     loadVisibleItems();
  4532.                 });
  4533.    
  4534.                 loadVisibleItems();
  4535.             });
  4536.         }
  4537.     };
  4538.    
  4539.     lpc_template.queue.dinamicPadding = function ($self) {
  4540.         let $block = $self.find('.lpc-vertical-wrap');
  4541.    
  4542.         if ($block.length) {
  4543.             let item = $block.find('.lpc-timeline-vertical__item');
  4544.    
  4545.             function updatePadding() {
  4546.                 item.each(function() {
  4547.                     let $this = $(this);
  4548.                     let numBlock = $this.find('#numBlock');
  4549.                     let bodyBlock = $this.find('#bodyBlock');
  4550.                     let stringBlock = $this.find('#stringBlock');
  4551.  
  4552.                     if (stringBlock.length) {
  4553.                         let numBlockHeight = numBlock.outerHeight() / 2 - stringBlock.outerHeight() / 2;
  4554.                         bodyBlock.css('padding-top', `${numBlockHeight}px`);
  4555.                     }
  4556.                 });
  4557.             }
  4558.    
  4559.             updatePadding();
  4560.            
  4561.             if (!s3LP.is_cms) {
  4562.                 let resizeTimeout;
  4563.  
  4564.                 $(window).on('resize', function () {
  4565.                     if (resizeTimeout) {
  4566.                         clearTimeout(resizeTimeout);
  4567.                     }
  4568.  
  4569.                     resizeTimeout = setTimeout(function () {
  4570.                         updatePadding();
  4571.                     }, 50);
  4572.                 });
  4573.             };
  4574.         }
  4575.     };
  4576.    
  4577.     lpc_template.queue.visibleBlock = function ($self) {
  4578.         var $block = $self.find('.lpc-opacity-block');
  4579.    
  4580.         if (!s3LP.is_cms) {
  4581.            
  4582.             var $images = $self.find('lpc-promotion-slider__image img, .lpc-form-substrate__background img');
  4583.        
  4584.             function removeOpacityClass() {
  4585.                 $block.removeClass('lpc-opacity-block');
  4586.             }
  4587.            
  4588.             var imageCount = $images.length;
  4589.            
  4590.             if (imageCount === 0) {
  4591.                 removeOpacityClass();
  4592.                
  4593.             } else {
  4594.                
  4595.                 $images.each(function () {
  4596.                     if (this.complete) {
  4597.                         imageCount--;
  4598.                     } else {
  4599.                         $(this).on('load', function () {
  4600.                             imageCount--;
  4601.                            
  4602.                             if (imageCount === 0) {
  4603.                                 removeOpacityClass();
  4604.                             }
  4605.                         });
  4606.                     }
  4607.                 });
  4608.    
  4609.                 if (imageCount === 0) {
  4610.                     removeOpacityClass();
  4611.                 }
  4612.             }
  4613.         }
  4614.     };
  4615.    
  4616.     lpc_template.queue.constructorClick = function ($self) {
  4617.         let $block = $self.find('.lpc-constructor');
  4618.    
  4619.         if ($block.length) {
  4620.             $block.each(function () {
  4621.                 let $this = $(this);
  4622.                 let lpcClick = $this.find(".lpc-active-click");
  4623.                 let item = $this.find(".lpc-constructor-click");
  4624.    
  4625.                 if (s3LP.is_cms) {
  4626.                     lpcClick.on('click', function () {
  4627.                         item.toggleClass('lpc-image-show');
  4628.                     });
  4629.                 }
  4630.             });
  4631.         }
  4632.     };
  4633.    
  4634.     lpc_template.queue.tabsInit = function ($self) {
  4635.         let $block = $self.find('.lpc-tabs-init');
  4636.    
  4637.         if ($block.length) {
  4638.             $block.each(function () {
  4639.                 let $this = $(this);
  4640.                 let $tab = $this.find('.lpc-tabs-title');
  4641.                 let $acc = $this.find('.lpc-accord-title');
  4642.                 let $body = $this.find('.lpc-tabs-body');
  4643.                 let blockId = $this.data('blockId');
  4644.                 let isVertical = $this.hasClass('lpc-tabs-vertical');
  4645.                
  4646.    
  4647.                 function accord() {
  4648.                     $tab.off('click.tabs');
  4649.                     $acc.off('click.accorDeon').on('click.accorDeon', function () {
  4650.                         let $currentAcc = $(this);
  4651.                         let $currentBody = $currentAcc.next('.lpc-tabs-body');
  4652.                         let isActive = $currentAcc.hasClass('active');
  4653.    
  4654.                         $acc.removeClass('active');
  4655.                         $body.slideUp(200).removeClass('active');
  4656.    
  4657.                         if (!isActive) {
  4658.                             $currentAcc.addClass('active');
  4659.                             $currentBody.slideDown(200).addClass('active');
  4660.                             let index = $currentAcc.data('index');
  4661.    
  4662.                             localStorage.setItem('activeTab_' + blockId, index);
  4663.                         }
  4664.    
  4665.                         if ($currentAcc.hasClass('active')) {
  4666.                             setTimeout(function(){
  4667.                                 $('html, body').stop().animate({
  4668.                                     scrollTop: $currentAcc.offset().top - 50
  4669.                                 }, 500);
  4670.                             }, 301);
  4671.                         }
  4672.                     });
  4673.                 }
  4674.    
  4675.                 function tabs() {
  4676.                     $acc.off('click.accorDeon');
  4677.                     $tab.off('click.tabs').on('click.tabs', function () {
  4678.                         let $currentTab = $(this);
  4679.                         let index = $currentTab.data('index');
  4680.                         let $currentBody = $this.find('.lpc-tabs-body[data-index="' + index + '"]');
  4681.    
  4682.                         if (!$currentTab.hasClass('active')) {
  4683.                             $tab.removeClass('active');
  4684.                             $body.removeClass('active');
  4685.                             $currentTab.addClass('active');
  4686.                             $currentBody.addClass('active');
  4687.    
  4688.                             localStorage.setItem('activeTab_' + blockId, index);
  4689.                         }
  4690.                     });
  4691.                 }
  4692.    
  4693.                 function updateActiveTab() {
  4694.                     let dataMedia = document.querySelector('.decor-wrap').dataset.mediaSource;
  4695.    
  4696.                     if ((isVertical && (dataMedia === 'media-md' || dataMedia === 'media-sm' || dataMedia === 'media-xs')) || (!isVertical && dataMedia === 'media-xs')) {
  4697.                         accord();
  4698.                     } else {
  4699.                         tabs();
  4700.                     }                  
  4701.    
  4702.                     let activeBlockId = localStorage.getItem('activeTab_' + blockId);
  4703.                     let index = parseInt(activeBlockId, 10) || 0;
  4704.    
  4705.                     if ((isVertical && (dataMedia === 'media-md' || dataMedia === 'media-sm' || dataMedia === 'media-xs')) || (!isVertical && dataMedia === 'media-xs')) {
  4706.                         $acc.removeClass('active');
  4707.                         $body.hide().removeClass('active');
  4708.    
  4709.                         $acc.eq(index).addClass('active');
  4710.                         $body.eq(index).toggle().addClass('active');
  4711.    
  4712.                     } else {
  4713.                         $tab.removeClass('active').removeAttr('style');
  4714.                         $body.removeClass('active').removeAttr('style');
  4715.    
  4716.                         $tab.eq(index).addClass('active').removeAttr('style');
  4717.                         $body.eq(index).addClass('active').removeAttr('style');
  4718.                     }
  4719.                 }
  4720.    
  4721.                 updateActiveTab();
  4722.  
  4723.                 window.addEventListener('orientationchange', function () {
  4724.                     setTimeout(function () {
  4725.                         updateActiveTab();
  4726.                     }, 300);
  4727.                 });
  4728.             });
  4729.         }
  4730.     };
  4731.    
  4732.     lpc_template.queue.initVideoBlocks = function () {
  4733.         /*const blocks = document.querySelectorAll(".lpc-block");
  4734.    
  4735.         blocks.forEach((block) => {
  4736.             const videoPosters = block.querySelectorAll(".lpc-video-poster");
  4737.             const videoContainers = block.querySelectorAll(".lpc-video-container");
  4738.    
  4739.             videoPosters.forEach((videoPoster, index) => {
  4740.                 const iframe = videoContainers[index].querySelector("iframe");
  4741.    
  4742.                 videoPoster.addEventListener("click", function () {
  4743.                     const dataSrc = videoPoster.getAttribute("data-youtube-id");
  4744.    
  4745.                     if (dataSrc) {
  4746.                         iframe.setAttribute("src", "https://www.youtube.com/embed/" + dataSrc + "?autoplay=1&mute=0");
  4747.                         videoPoster.removeAttribute("data-youtube-id");
  4748.                         videoPoster.style.display = "none";
  4749.                         videoContainers[index].style.display = "block";
  4750.                     }
  4751.                 });
  4752.             });
  4753.         });*/
  4754.         const blocks = document.querySelectorAll(".lpc-block");
  4755.        
  4756.         blocks.forEach((block) => {
  4757.             const videoPosters = block.querySelectorAll(".lpc-video-poster");
  4758.             const videoContainers = block.querySelectorAll(".lpc-video-container");
  4759.    
  4760.             videoPosters.forEach((videoPoster, index) => {
  4761.                
  4762.                 videoPoster.addEventListener("click", function () {
  4763.                     let _this = this;
  4764.                     let parent = _this.closest('.lp-video-block-wrappper');
  4765.                     let container = parent.querySelector(".lpc-video-container");
  4766.                     let iframe = container.querySelector("iframe");
  4767.                     let src = iframe.getAttribute("data-src").replace('autoplay=0','autoplay=1');
  4768.                    
  4769.                     iframe.setAttribute("src", src);
  4770.                     videoPoster.style.display = "none";
  4771.                     container.style.display = "block";
  4772.                 });
  4773.             });
  4774.         });
  4775.     };
  4776.    
  4777.     document.addEventListener("DOMContentLoaded", function () {
  4778.         lpc_template.queue.initVideoBlocks();
  4779.     });
  4780.    
  4781.     lpc_template.queue.sliderReviews = function ($self) {
  4782.         let $block = $self.attr('data-slider-reviews-init') ? $self : $self.find('[data-slider-reviews-init]');
  4783.    
  4784.         if ($block.length) {
  4785.             $block.each(function () {
  4786.                 let $this = $(this);
  4787.                 let $alignItem = $this.find($this.data('align-item'));
  4788.    
  4789.                 if ($this.find('.splide').not('.is-active').length != 0) {
  4790.                     $this.find('.splide').not('.is-active').each(function () {
  4791.                        
  4792.                         let splide = new Splide($(this)[0], {
  4793.                             autoplay: $this.data('autoplay'),
  4794.                             speed: $this.data('speed'),
  4795.                             interval: $this.data('pause'),
  4796.                             lazyLoad: $this.data('lazy-load'),
  4797.                             rewind: true,
  4798.                             arrows: true,
  4799.                             pagination: true,
  4800.                             gap: 0,
  4801.                             perPage: 1
  4802.                         });
  4803.                        
  4804.                         splide.mount();
  4805.                        
  4806.                         if ($(this).find('.lpc-reviews-4__item').length <= 1) {
  4807.                             $(this).addClass('splide--pointer-events');
  4808.                         }
  4809.                     });
  4810.                 }
  4811.             });
  4812.         }
  4813.     };
  4814.    
  4815.     lpc_template.queue.sliderBlockBanner = function ($self) {
  4816.         let $block = $self.attr('data-slider-banner-init') ? $self : $self.find('[data-slider-banner-init]');
  4817.         if ($block.length) {
  4818.         if ($block.data('slider-thumb-init') != true) {
  4819.             $block.each(function(){
  4820.                 let $this = $(this);
  4821.                 let $alignItem = $this.find($this.data('align-item'));
  4822.                 let mediaGap = $this.data('margin');
  4823.                 let mediaPerPage = $(this).data('count');
  4824.                 if ($(this).data('move')) {
  4825.                     var $mediaMove = $(this).data('move');
  4826.                    
  4827.                 } else {
  4828.                     var $mediaMove = 1;
  4829.                 }
  4830.  
  4831.                 if($this.find('.splide').not('.is-active').length != 0) {
  4832.                     let splide = new Splide( $this.find('.splide').not('.is-active')[0], {
  4833.                         autoplay: $this.data('autoplay'),
  4834.                         speed: $this.data('speed'),
  4835.                         interval: $this.data('pause'),
  4836.                         lazyLoad: $this.data('lazy-load'),
  4837.                         rewind: true,
  4838.                         perMove: $mediaMove,
  4839.                         perPage: checkInitPerPage()
  4840.                     });
  4841.                     splide.mount();
  4842.                    
  4843.                     sliderBreakPoints();
  4844.                    
  4845.                     document.addEventListener('lpcPopupOpened', function(){
  4846.                         splide.refresh();
  4847.                     });
  4848.                    
  4849.                     document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  4850.                    
  4851.                     function sliderBreakPoints() {
  4852.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  4853.        
  4854.                         setTimeout(function(){
  4855.                             if ($alignItem.length) {
  4856.                                 let itemHeight = $alignItem.outerHeight() / 2;
  4857.                                 let arrowsPosition = itemHeight + $alignItem.position().top;
  4858.    
  4859.                                 $this.find('.splide__arrow').css('top', arrowsPosition);
  4860.                             }
  4861.                         }, 100);
  4862.                        
  4863.                         switch (dataMediaSource) {
  4864.                             case 'media-xl':
  4865.                                 splide.options = {
  4866.                                     arrows: true,
  4867.                                     pagination: true,
  4868.                                     gap: mediaGap[0],
  4869.                                     perPage: mediaPerPage[0],
  4870.                                 };
  4871.        
  4872.                                 break;
  4873.                             case 'media-lg':
  4874.                                 splide.options = {
  4875.                                     arrows: true,
  4876.                                     pagination: true,
  4877.                                     gap: mediaGap[1],
  4878.                                     perPage: mediaPerPage[1],
  4879.                                 };
  4880.        
  4881.                                 break;
  4882.                             case 'media-md':
  4883.                                 splide.options = {
  4884.                                     arrows: true,
  4885.                                     pagination: true,
  4886.                                     gap: mediaGap[2],
  4887.                                     perPage: mediaPerPage[2],
  4888.                                 };
  4889.        
  4890.                                 break;
  4891.                             case 'media-sm':
  4892.                                 splide.options = {
  4893.                                     arrows: true,
  4894.                                     pagination: true,
  4895.                                     gap: mediaGap[3],
  4896.                                     perPage: mediaPerPage[3],
  4897.                                 };
  4898.        
  4899.                                 break;
  4900.                             case 'media-xs':
  4901.                                 splide.options = {
  4902.                                     arrows: true,
  4903.                                     pagination: true,
  4904.                                     gap: mediaGap[4],
  4905.                                     perPage: mediaPerPage[4],
  4906.                                 };
  4907.                                
  4908.                                 break;
  4909.                         }
  4910.                     };
  4911.                    
  4912.                     function checkInitPerPage() {
  4913.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  4914.                    
  4915.                         switch (dataMediaSource) {
  4916.                             case 'media-xl':
  4917.                                 return mediaPerPage[0]
  4918.                                 break;
  4919.                             case 'media-lg':
  4920.                                 return mediaPerPage[1]
  4921.                                 break;
  4922.                             case 'media-md':
  4923.                                 return mediaPerPage[2]
  4924.                                 break;
  4925.                             case 'media-sm':
  4926.                                 return mediaPerPage[3]
  4927.                                 break;
  4928.                             case 'media-xs':
  4929.                                 return mediaPerPage[4]
  4930.                                 break;
  4931.                         };
  4932.                     };
  4933.                 }
  4934.             });
  4935.         }
  4936.         }
  4937.     };
  4938.        
  4939.     lpc_template.queue.sliderBlock = function ($self) {
  4940.        
  4941.         let $block = $self.attr('data-slider-init') ? $self : $self.find('[data-slider-init]');
  4942.        
  4943.         if ($block.length) {
  4944.         if ($block.data('slider-thumb-init') != true) {
  4945.             $block.each(function(){
  4946.                 let $this = $(this);
  4947.                 let $alignItem = $this.find($this.data('align-item'));
  4948.                 let mediaGap = $this.data('margin');
  4949.                 let mediaPerPage = $(this).data('count');
  4950.                 if ($(this).data('move')) {
  4951.                     var $mediaMove = $(this).data('move');
  4952.                    
  4953.                 } else {
  4954.                     var $mediaMove = 1;
  4955.                 }
  4956.  
  4957.                 if($this.find('.splide').not('.is-active').length != 0) {
  4958.                     let splide = new Splide( $this.find('.splide').not('.is-active')[0], {
  4959.                         autoplay: $this.data('autoplay'),
  4960.                         speed: $this.data('speed'),
  4961.                         interval: $this.data('pause'),
  4962.                         /*rewind: $this.data('infinite'),*/
  4963.                         lazyLoad: $this.data('lazy-load'),
  4964.                         rewind: false,
  4965.                         rewindByDrag: true,
  4966.                         perMove: $mediaMove,
  4967.                         perPage: checkInitPerPage()
  4968.                     });
  4969.                     splide.mount();
  4970.                    
  4971.                     sliderBreakPoints();
  4972.                    
  4973.                     document.addEventListener('lpcPopupOpened', function(){
  4974.                         splide.refresh();
  4975.                     });
  4976.                    
  4977.                     document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  4978.                    
  4979.                     function sliderBreakPoints() {
  4980.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  4981.        
  4982.                         setTimeout(function(){
  4983.                             if ($alignItem.length) {
  4984.                                 let itemHeight = $alignItem.outerHeight() / 2;
  4985.                                 let arrowsPosition = itemHeight + $alignItem.position().top;
  4986.    
  4987.                                 $this.find('.splide__arrow').css('top', arrowsPosition);
  4988.                             }
  4989.                         }, 100);
  4990.                        
  4991.                         switch (dataMediaSource) {
  4992.                             case 'media-xl':
  4993.                                 splide.options = {
  4994.                                     arrows: true,
  4995.                                     pagination: true,
  4996.                                     gap: mediaGap[0],
  4997.                                     perPage: mediaPerPage[0],
  4998.                                 };
  4999.        
  5000.                                 break;
  5001.                             case 'media-lg':
  5002.                                 splide.options = {
  5003.                                     arrows: true,
  5004.                                     pagination: true,
  5005.                                     gap: mediaGap[1],
  5006.                                     perPage: mediaPerPage[1],
  5007.                                 };
  5008.        
  5009.                                 break;
  5010.                             case 'media-md':
  5011.                                 splide.options = {
  5012.                                     arrows: true,
  5013.                                     pagination: true,
  5014.                                     gap: mediaGap[2],
  5015.                                     perPage: mediaPerPage[2],
  5016.                                 };
  5017.        
  5018.                                 break;
  5019.                             case 'media-sm':
  5020.                                 splide.options = {
  5021.                                     arrows: false,
  5022.                                     pagination: true,
  5023.                                     rewindByDrag: true,
  5024.                                     gap: mediaGap[3],
  5025.                                     perPage: mediaPerPage[3],
  5026.                                 };
  5027.        
  5028.                                 break;
  5029.                             case 'media-xs':
  5030.                                 splide.options = {
  5031.                                     arrows: false,
  5032.                                     pagination: true,
  5033.                                     rewindByDrag: true,
  5034.                                     gap: mediaGap[4],
  5035.                                     perPage: mediaPerPage[4],
  5036.                                 };
  5037.                                
  5038.                                 break;
  5039.                         }
  5040.                     };
  5041.                    
  5042.                     function checkInitPerPage() {
  5043.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5044.                    
  5045.                         switch (dataMediaSource) {
  5046.                             case 'media-xl':
  5047.                                 return mediaPerPage[0]
  5048.                                 break;
  5049.                             case 'media-lg':
  5050.                                 return mediaPerPage[1]
  5051.                                 break;
  5052.                             case 'media-md':
  5053.                                 return mediaPerPage[2]
  5054.                                 break;
  5055.                             case 'media-sm':
  5056.                                 return mediaPerPage[3]
  5057.                                 break;
  5058.                             case 'media-xs':
  5059.                                 return mediaPerPage[4]
  5060.                                 break;
  5061.                         };
  5062.                     };
  5063.                 }
  5064.             });
  5065.         }
  5066.         }
  5067.     };
  5068.    
  5069.     lpc_template.queue.sliderTabBlock = function ($self) {
  5070.        
  5071.         let $block = $self.attr('data-slider-tab-init') ? $self : $self.find('[data-slider-tab-init]');
  5072.        
  5073.         if ($block.length) {
  5074.         if ($block.data('slider-thumb-init') != true) {
  5075.             $block.each(function(){
  5076.                 let $this = $(this);
  5077.                 let $alignItem = $this.find($this.data('align-item'));
  5078.                 let mediaGap = $this.data('margin');
  5079.                 let mediaPerPage = $(this).data('count');
  5080.                 if ($(this).data('move')) {
  5081.                     var $mediaMove = $(this).data('move');
  5082.                    
  5083.                 } else {
  5084.                     var $mediaMove = 1;
  5085.                 }
  5086.  
  5087.                 if($this.find('.splide').not('.is-active').length != 0) {
  5088.                     let splide = new Splide( $this.find('.splide').not('.is-active')[0], {
  5089.                         autoplay: $this.data('autoplay'),
  5090.                         speed: $this.data('speed'),
  5091.                         interval: $this.data('pause'),
  5092.                         /*rewind: $this.data('infinite'),*/
  5093.                         lazyLoad: $this.data('lazy-load'),
  5094.                         rewind: false,
  5095.                         rewindByDrag: true,
  5096.                         autoWidth: true,
  5097.                         perMove: $mediaMove,
  5098.                         perPage: checkInitPerPage()
  5099.                     });
  5100.                     splide.mount();
  5101.                    
  5102.                     sliderBreakPoints();
  5103.                    
  5104.                     document.addEventListener('lpcPopupOpened', function(){
  5105.                         splide.refresh();
  5106.                     });
  5107.                    
  5108.                     document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  5109.                    
  5110.                     function sliderBreakPoints() {
  5111.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5112.        
  5113.                         setTimeout(function(){
  5114.                             if ($alignItem.length) {
  5115.                                 let itemHeight = $alignItem.outerHeight() / 2;
  5116.                                 let arrowsPosition = itemHeight + $alignItem.position().top;
  5117.    
  5118.                                 $this.find('.splide__arrow').css('top', arrowsPosition);
  5119.                             }
  5120.                         }, 100);
  5121.                        
  5122.                         switch (dataMediaSource) {
  5123.                             case 'media-xl':
  5124.                                 splide.options = {
  5125.                                     arrows: true,
  5126.                                     pagination: false,
  5127.                                     gap: mediaGap[0],
  5128.                                     perPage: mediaPerPage[0],
  5129.                                 };
  5130.        
  5131.                                 break;
  5132.                             case 'media-lg':
  5133.                                 splide.options = {
  5134.                                     arrows: true,
  5135.                                     pagination: false,
  5136.                                     gap: mediaGap[1],
  5137.                                     perPage: mediaPerPage[1],
  5138.                                 };
  5139.        
  5140.                                 break;
  5141.                             case 'media-md':
  5142.                                 splide.options = {
  5143.                                     arrows: true,
  5144.                                     pagination: false,
  5145.                                     gap: mediaGap[2],
  5146.                                     perPage: mediaPerPage[2],
  5147.                                 };
  5148.        
  5149.                                 break;
  5150.                             case 'media-sm':
  5151.                                 splide.options = {
  5152.                                     arrows: false,
  5153.                                     pagination: false,
  5154.                                     rewindByDrag: true,
  5155.                                     gap: mediaGap[3],
  5156.                                     perPage: mediaPerPage[3],
  5157.                                 };
  5158.        
  5159.                                 break;
  5160.                             case 'media-xs':
  5161.                                 splide.options = {
  5162.                                     arrows: false,
  5163.                                     pagination: false,
  5164.                                     rewindByDrag: true,
  5165.                                     gap: mediaGap[4],
  5166.                                     perPage: mediaPerPage[4],
  5167.                                 };
  5168.                                
  5169.                                 break;
  5170.                         }
  5171.                     };
  5172.                    
  5173.                     function checkInitPerPage() {
  5174.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5175.                    
  5176.                         switch (dataMediaSource) {
  5177.                             case 'media-xl':
  5178.                                 return mediaPerPage[0]
  5179.                                 break;
  5180.                             case 'media-lg':
  5181.                                 return mediaPerPage[1]
  5182.                                 break;
  5183.                             case 'media-md':
  5184.                                 return mediaPerPage[2]
  5185.                                 break;
  5186.                             case 'media-sm':
  5187.                                 return mediaPerPage[3]
  5188.                                 break;
  5189.                             case 'media-xs':
  5190.                                 return mediaPerPage[4]
  5191.                                 break;
  5192.                         };
  5193.                     };
  5194.                 }
  5195.             });
  5196.         }
  5197.         }
  5198.     };
  5199.    
  5200.     lpc_template.queue.sliderBlockThumb = function ($self) {
  5201.         var $block = $self.attr('data-slider-thumb-init') ? $self : $self.find('[data-slider-thumb-init]');
  5202.         if ($block.length) {
  5203.             $block.each(function(){
  5204.                 let $this = $(this);
  5205.                 let $alignItem = $this.find($this.data('align-item'));
  5206.                 let mediaGap = $this.data('margin');
  5207.                 let mediaPerPage = $(this).data('count');
  5208.                 let mediaThumbGap = $this.data('thumb-margin');
  5209.                 let mediaThumbFixedWidth = $this.data('thumb-width');
  5210.                 let mediaThumbFixedHeight = $this.data('thumb-height');
  5211.                    
  5212.                 if($this.find('#main-slider').not('.is-active').length != 0 ) {
  5213.                     let splideThumb = new Splide( $this.find('.splide').not('.is-active')[0], {
  5214.                         autoplay: $this.data('autoplay'),
  5215.                         speed: $this.data('speed'),
  5216.                         interval: $this.data('pause'),
  5217.                         /*rewind: $this.data('infinite'),*/
  5218.                         lazyLoad: $this.data('lazy-load'),
  5219.                         rewind: true,
  5220.                         perMove: 1,
  5221.                         perPage: checkInitPerPage(),
  5222.                         dragMinThreshold: {
  5223.                             mouse: 5,
  5224.                             touch: 10,
  5225.                         }  
  5226.                     });
  5227.                    
  5228.                     let thumbnails = new Splide($this.find('.thumbnail-slider').not('.is-active')[0], {
  5229.                       rewind          : $this.data('rewind'),
  5230.                       fixedWidth      : checkInitThumbWidth(),
  5231.                       fixedHeight     : checkInitThumbHeight(),
  5232.                       isNavigation    : true,
  5233.                       focus           : $this.data('thumb-focus'),
  5234.                       pagination      : false,
  5235.                       cover           : false,
  5236.                       arrows          : $this.data('thumb-arrow'),
  5237.                       drag            : false,
  5238.                       padding         : 4,
  5239.                       gap             : checkInitThumbGap(),
  5240.                       dragMinThreshold: {
  5241.                         mouse: 5,
  5242.                         touch: 10,
  5243.                       } ,
  5244.                       classes         : {
  5245.                         arrows: "splide__arrows splide__custom__arrows"
  5246.                       }
  5247.                     });
  5248.  
  5249.                     splideThumb.sync( thumbnails );
  5250.                    
  5251.                     splideThumb.mount();
  5252.                    
  5253.                     thumbnails.mount();
  5254.                    
  5255.                     sliderBreakPoints();
  5256.                    
  5257.                     sliderPaginationChecking();
  5258.                    
  5259.                     document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  5260.                    
  5261.                    
  5262.                    
  5263.                     function sliderBreakPoints() {
  5264.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5265.        
  5266.                         setTimeout(function(){
  5267.                             if ($alignItem.length) {
  5268.                                 let itemHeight = $alignItem.outerHeight() / 2;
  5269.                                 let arrowsPosition = itemHeight + $alignItem.position().top;
  5270.    
  5271.                                 $this.find('.splide__arrow').css('top', arrowsPosition);
  5272.                             }
  5273.                         }, 100);
  5274.                        
  5275.                         switch (dataMediaSource) {
  5276.                             case 'media-xl':
  5277.                                 splideThumb.options = {
  5278.                                     arrows: true,
  5279.                                     pagination: true,
  5280.                                     gap: mediaGap[0],
  5281.                                     perPage: mediaPerPage[0],
  5282.                                 };
  5283.  
  5284.                                 break;
  5285.                             case 'media-lg':
  5286.                                 splideThumb.options = {
  5287.                                     arrows: true,
  5288.                                     pagination: true,
  5289.                                     gap: mediaGap[1],
  5290.                                     perPage: mediaPerPage[1],
  5291.                                 };
  5292.        
  5293.                                 break;
  5294.                             case 'media-md':
  5295.                                 splideThumb.options = {
  5296.                                     arrows: true,
  5297.                                     pagination: true,
  5298.                                     gap: mediaGap[2],
  5299.                                     perPage: mediaPerPage[2],
  5300.                                 };
  5301.                                 break;
  5302.                             case 'media-sm':
  5303.                                 splideThumb.options = {
  5304.                                     arrows: false,
  5305.                                     pagination: true,
  5306.                                     gap: mediaGap[3],
  5307.                                     perPage: mediaPerPage[3],
  5308.                                 };
  5309.        
  5310.                                 break;
  5311.                             case 'media-xs':
  5312.                                 splideThumb.options = {
  5313.                                     arrows: false,
  5314.                                     pagination: true,
  5315.                                     gap: mediaGap[4],
  5316.                                     perPage: mediaPerPage[4],
  5317.                                 };
  5318.  
  5319.                                 break;
  5320.                         }
  5321.                         if($block.data('slider-thumb-init') == true) {
  5322.                             switch (dataMediaSource) {
  5323.                                 case 'media-xl':
  5324.                                     thumbnails.options = {
  5325.                                         gap: mediaThumbGap[0],
  5326.                                         fixedWidth: mediaThumbFixedWidth[0],
  5327.                                         fixedHeight: mediaThumbFixedHeight[0],
  5328.                                     };
  5329.            
  5330.                                     break;
  5331.                                 case 'media-lg':
  5332.                                     thumbnails.options = {
  5333.                                         gap: mediaThumbGap[1],
  5334.                                         fixedWidth: mediaThumbFixedWidth[1],
  5335.                                         fixedHeight: mediaThumbFixedHeight[1],
  5336.                                     };
  5337.            
  5338.                                     break;
  5339.                                 case 'media-md':
  5340.                                     thumbnails.options = {
  5341.                                         gap: mediaThumbGap[2],
  5342.                                         fixedWidth: mediaThumbFixedWidth[2],
  5343.                                         fixedHeight: mediaThumbFixedHeight[2],
  5344.                                     };
  5345.            
  5346.                                     break;
  5347.                                 case 'media-sm':
  5348.                                     thumbnails.options = {
  5349.                                         gap: mediaThumbGap[3],
  5350.                                         fixedWidth: mediaThumbFixedWidth[3],
  5351.                                         fixedHeight: mediaThumbFixedHeight[3],
  5352.                                     };
  5353.            
  5354.                                     break;
  5355.                                 case 'media-xs':
  5356.                                     thumbnails.options = {
  5357.                                         gap: mediaThumbGap[4],
  5358.                                         fixedWidth: mediaThumbFixedWidth[4],
  5359.                                         fixedHeight: mediaThumbFixedHeight[4],
  5360.                                     };
  5361.                                    
  5362.                                     break;
  5363.                             }
  5364.                         }
  5365.                     };
  5366.                    
  5367.                     function checkInitPerPage() {
  5368.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5369.                    
  5370.                         switch (dataMediaSource) {
  5371.                             case 'media-xl':
  5372.                                 return mediaPerPage[0]
  5373.                                 break;
  5374.                             case 'media-lg':
  5375.                                 return mediaPerPage[1]
  5376.                                 break;
  5377.                             case 'media-md':
  5378.                                 return mediaPerPage[2]
  5379.                                 break;
  5380.                             case 'media-sm':
  5381.                                 return mediaPerPage[3]
  5382.                                 break;
  5383.                             case 'media-xs':
  5384.                                 return mediaPerPage[4]
  5385.                                 break;
  5386.                         };
  5387.                     };
  5388.                    
  5389.                     function checkInitThumbWidth() {
  5390.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5391.                    
  5392.                         switch (dataMediaSource) {
  5393.                             case 'media-xl':
  5394.                                 return mediaThumbFixedWidth[0]
  5395.                                 break;
  5396.                             case 'media-lg':
  5397.                                 return mediaThumbFixedWidth[1]
  5398.                                 break;
  5399.                             case 'media-md':
  5400.                                 return mediaThumbFixedWidth[2]
  5401.                                 break;
  5402.                             case 'media-sm':
  5403.                                 return mediaThumbFixedWidth[3]
  5404.                                 break;
  5405.                             case 'media-xs':
  5406.                                 return mediaThumbFixedWidth[4]
  5407.                                 break;
  5408.                         };
  5409.                     };
  5410.                    
  5411.                     function checkInitThumbHeight() {
  5412.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5413.                    
  5414.                         switch (dataMediaSource) {
  5415.                             case 'media-xl':
  5416.                                 return mediaThumbFixedHeight[0]
  5417.                                 break;
  5418.                             case 'media-lg':
  5419.                                 return mediaThumbFixedHeight[1]
  5420.                                 break;
  5421.                             case 'media-md':
  5422.                                 return mediaThumbFixedHeight[2]
  5423.                                 break;
  5424.                             case 'media-sm':
  5425.                                 return mediaThumbFixedHeight[3]
  5426.                                 break;
  5427.                             case 'media-xs':
  5428.                                 return mediaThumbFixedHeight[4]
  5429.                                 break;
  5430.                         };
  5431.                     };
  5432.                    
  5433.                     function checkInitThumbGap() {
  5434.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5435.                    
  5436.                         switch (dataMediaSource) {
  5437.                             case 'media-xl':
  5438.                                 return mediaThumbGap[0]
  5439.                                 break;
  5440.                             case 'media-lg':
  5441.                                 return mediaThumbGap[1]
  5442.                                 break;
  5443.                             case 'media-md':
  5444.                                 return mediaThumbGap[2]
  5445.                                 break;
  5446.                             case 'media-sm':
  5447.                                 return mediaThumbGap[3]
  5448.                                 break;
  5449.                             case 'media-xs':
  5450.                                 return mediaThumbGap[4]
  5451.                                 break;
  5452.                         };
  5453.                     };
  5454.                     function sliderPaginationChecking() {
  5455.                         let sliderPaginationBlock = $this.find('.splide__custom__pagination');
  5456.                         setTimeout(function() {
  5457.                         if (sliderPaginationBlock.find('li').length == 1) {
  5458.                             sliderPaginationBlock.hide();
  5459.                         }
  5460.                          }, 200);
  5461.                        
  5462.                     };
  5463.                 }
  5464.             });
  5465.         }  
  5466.     };
  5467.    
  5468.     lpc_template.queue.sliderBlockThumbGallery = function ($self) {
  5469.         var $block = $self.attr('data-slider-gallary-thumb-init') ? $self : $self.find('[data-slider-gallary-thumb-init]');
  5470.        
  5471.         if ($block.length) {
  5472.             $block.each(function(){
  5473.                 let $this = $(this);
  5474.                 let $alignItem = $this.find($this.data('align-item'));
  5475.                 let mediaGap = $this.data('margin');
  5476.                 let mediaPerPage = $(this).data('count');
  5477.                 let mediaThumbGap = $this.data('thumb-margin');
  5478.                 let mediaThumbFixedWidth = $this.data('thumb-width');
  5479.                 let mediaThumbFixedHeight = $this.data('thumb-height');
  5480.                 let mediaThumbDirectionItems = $this.data('thumb-direction');
  5481.                 let mediaThumbDirection = [];
  5482.  
  5483.                 mediaThumbDirectionItems.forEach(function (item){
  5484.                     if(item == 1) {
  5485.                         item = 'ttb'
  5486.                     }
  5487.                     if(item == 0) {
  5488.                         item = 'ltr'
  5489.                     }
  5490.                     mediaThumbDirection.push(item)
  5491.                 });
  5492.                    
  5493.                 if($this.find('#main-slider').not('.is-active').length != 0 ) {
  5494.                     let splideThumbGallary = new Splide( $this.find('.splide').not('.is-active')[0], {
  5495.                         autoplay: $this.data('autoplay'),
  5496.                         speed: $this.data('speed'),
  5497.                         interval: $this.data('pause'),
  5498.                         /*rewind: $this.data('infinite'),*/
  5499.                         lazyLoad: $this.data('lazy-load'),
  5500.                         rewind: true,
  5501.                         perMove: 1,
  5502.                         perPage: checkInitPerPage(),
  5503.                         dragMinThreshold: {
  5504.                             mouse: 5,
  5505.                             touch: 10,
  5506.                         }  
  5507.                     });
  5508.                    
  5509.                     let thumbnailsGallary = new Splide($this.find('.thumbnail-slider').not('.is-active')[0], {
  5510.                       direction       : checkInitThumbDirection(),
  5511.                       rewind          : true,
  5512.                       count           : 6,
  5513.                       fixedWidth      : checkInitThumbWidth(),
  5514.                       fixedHeight     : checkInitThumbHeight(),
  5515.                       isNavigation    : true,
  5516.                       pagination      : false,
  5517.                       perPage         : 6,
  5518.                       cover           : false,
  5519.                       arrows          : $this.data('thumb-arrow'),
  5520.                       drag            : true,
  5521.                       padding         : 4,
  5522.                       gap             : checkInitThumbGap(),
  5523.                       clones          : 5,
  5524.                       heightRatio     : $this.data('height'),
  5525.                       dragMinThreshold: {
  5526.                         mouse: 5,
  5527.                         touch: 10,
  5528.                       } ,
  5529.                       classes         : {
  5530.                         arrows: "splide__arrows splide__custom__arrows"
  5531.                       }
  5532.                     });
  5533.  
  5534.                     splideThumbGallary.sync( thumbnailsGallary );
  5535.                    
  5536.                     splideThumbGallary.mount();
  5537.                    
  5538.                     thumbnailsGallary.mount();
  5539.                    
  5540.                     sliderBreakPoints();
  5541.                    
  5542.                     sliderPaginationChecking();
  5543.                    
  5544.                     document.addEventListener('dataMediaSourceChange', sliderBreakPoints);
  5545.                    
  5546.                     function sliderBreakPoints() {
  5547.                        
  5548.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5549.                         setTimeout(function(){
  5550.                             if ($alignItem.length) {
  5551.                                 let itemHeight = $alignItem.outerHeight() / 2;
  5552.                                 let arrowsPosition = itemHeight + $alignItem.position().top;
  5553.    
  5554.                                 $this.find('.splide__arrow').css('top', arrowsPosition);
  5555.                             }
  5556.                         }, 100);
  5557.                        
  5558.                         switch (dataMediaSource) {
  5559.                             case 'media-xl':
  5560.                                 splideThumbGallary.options = {
  5561.                                     arrows: true,
  5562.                                     pagination: true,
  5563.                                     gap: mediaGap[0],
  5564.                                     perPage: mediaPerPage[0],
  5565.                                    
  5566.                                 };
  5567.  
  5568.                                 break;
  5569.                             case 'media-lg':
  5570.                                 splideThumbGallary.options = {
  5571.                                     arrows: true,
  5572.                                     pagination: true,
  5573.                                     gap: mediaGap[1],
  5574.                                     perPage: mediaPerPage[1],
  5575.                                 };
  5576.        
  5577.                                 break;
  5578.                             case 'media-md':
  5579.                                 splideThumbGallary.options = {
  5580.                                     arrows: true,
  5581.                                     pagination: true,
  5582.                                     gap: mediaGap[2],
  5583.                                     perPage: mediaPerPage[2],
  5584.                                 };
  5585.                                 break;
  5586.                             case 'media-sm':
  5587.                                 splideThumbGallary.options = {
  5588.                                     arrows: false,
  5589.                                     pagination: true,
  5590.                                     gap: mediaGap[3],
  5591.                                     perPage: mediaPerPage[3],
  5592.                                 };
  5593.        
  5594.                                 break;
  5595.                             case 'media-xs':
  5596.                                 splideThumbGallary.options = {
  5597.                                     arrows: false,
  5598.                                     pagination: true,
  5599.                                     gap: mediaGap[4],
  5600.                                     perPage: mediaPerPage[4],
  5601.                                 };
  5602.  
  5603.                                 break;
  5604.                         }
  5605.                         if($block.data('slider-gallary-thumb-init') == true) {
  5606.                             switch (dataMediaSource) {
  5607.                                 case 'media-xl':
  5608.                                     thumbnailsGallary.options = {
  5609.                                         gap: mediaThumbGap[0],
  5610.                                         fixedWidth: mediaThumbFixedWidth[0],
  5611.                                         fixedHeight: mediaThumbFixedHeight[0],
  5612.                                         direction: mediaThumbDirection[0],
  5613.                                         heightRatio     : 3.2,
  5614.                                     };
  5615.            
  5616.                                     break;
  5617.                                 case 'media-lg':
  5618.                                     thumbnailsGallary.options = {
  5619.                                         gap: mediaThumbGap[1],
  5620.                                         fixedWidth: mediaThumbFixedWidth[1],
  5621.                                         fixedHeight: mediaThumbFixedHeight[1],
  5622.                                         direction: mediaThumbDirection[1],
  5623.                                         heightRatio     : 3.2,
  5624.                                     };
  5625.            
  5626.                                     break;
  5627.                                 case 'media-md':
  5628.                                     thumbnailsGallary.options = {
  5629.                                         gap: mediaThumbGap[2],
  5630.                                         fixedWidth: mediaThumbFixedWidth[2],
  5631.                                         fixedHeight: mediaThumbFixedHeight[2],
  5632.                                         direction: mediaThumbDirection[2],
  5633.                                         heightRatio     : 3.2,
  5634.                                     };
  5635.            
  5636.                                     break;
  5637.                                 case 'media-sm':
  5638.                                     thumbnailsGallary.options = {
  5639.                                         gap: mediaThumbGap[3],
  5640.                                         fixedWidth: mediaThumbFixedWidth[3],
  5641.                                         fixedHeight: mediaThumbFixedHeight[3],
  5642.                                         direction: mediaThumbDirection[3],
  5643.                                         heightRatio     : 3.2,
  5644.                                     };
  5645.            
  5646.                                     break;
  5647.                                 case 'media-xs':
  5648.                                     thumbnailsGallary.options = {
  5649.                                         gap: mediaThumbGap[4],
  5650.                                         fixedWidth: mediaThumbFixedWidth[4],
  5651.                                         fixedHeight: mediaThumbFixedHeight[4],
  5652.                                         direction: mediaThumbDirection[4],
  5653.                                         heightRatio     : 3.2,
  5654.                                     };
  5655.                                    
  5656.                                     break;
  5657.                             }
  5658.                         }
  5659.                     };
  5660.                    
  5661.                     function checkInitPerPage() {
  5662.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5663.                    
  5664.                         switch (dataMediaSource) {
  5665.                             case 'media-xl':
  5666.                                 return mediaPerPage[0]
  5667.                                 break;
  5668.                             case 'media-lg':
  5669.                                 return mediaPerPage[1]
  5670.                                 break;
  5671.                             case 'media-md':
  5672.                                 return mediaPerPage[2]
  5673.                                 break;
  5674.                             case 'media-sm':
  5675.                                 return mediaPerPage[3]
  5676.                                 break;
  5677.                             case 'media-xs':
  5678.                                 return mediaPerPage[4]
  5679.                                 break;
  5680.                         };
  5681.                     };
  5682.                    
  5683.                     function checkInitThumbWidth() {
  5684.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5685.                    
  5686.                         switch (dataMediaSource) {
  5687.                             case 'media-xl':
  5688.                                 return mediaThumbFixedWidth[0]
  5689.                                 break;
  5690.                             case 'media-lg':
  5691.                                 return mediaThumbFixedWidth[1]
  5692.                                 break;
  5693.                             case 'media-md':
  5694.                                 return mediaThumbFixedWidth[2]
  5695.                                 break;
  5696.                             case 'media-sm':
  5697.                                 return mediaThumbFixedWidth[3]
  5698.                                 break;
  5699.                             case 'media-xs':
  5700.                                 return mediaThumbFixedWidth[4]
  5701.                                 break;
  5702.                         };
  5703.                     };
  5704.                    
  5705.                     function checkInitThumbHeight() {
  5706.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5707.                    
  5708.                         switch (dataMediaSource) {
  5709.                             case 'media-xl':
  5710.                                 return mediaThumbFixedHeight[0]
  5711.                                 break;
  5712.                             case 'media-lg':
  5713.                                 return mediaThumbFixedHeight[1]
  5714.                                 break;
  5715.                             case 'media-md':
  5716.                                 return mediaThumbFixedHeight[2]
  5717.                                 break;
  5718.                             case 'media-sm':
  5719.                                 return mediaThumbFixedHeight[3]
  5720.                                 break;
  5721.                             case 'media-xs':
  5722.                                 return mediaThumbFixedHeight[4]
  5723.                                 break;
  5724.                         };
  5725.                     };
  5726.                    
  5727.                     function checkInitThumbGap() {
  5728.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5729.                    
  5730.                         switch (dataMediaSource) {
  5731.                             case 'media-xl':
  5732.                                 return mediaThumbGap[0]
  5733.                                 break;
  5734.                             case 'media-lg':
  5735.                                 return mediaThumbGap[1]
  5736.                                 break;
  5737.                             case 'media-md':
  5738.                                 return mediaThumbGap[2]
  5739.                                 break;
  5740.                             case 'media-sm':
  5741.                                 return mediaThumbGap[3]
  5742.                                 break;
  5743.                             case 'media-xs':
  5744.                                 return mediaThumbGap[4]
  5745.                                 break;
  5746.                         };
  5747.                     };
  5748.                    
  5749.                     function checkInitThumbDirection() {
  5750.                         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  5751.                    
  5752.                         switch (dataMediaSource) {
  5753.                             case 'media-xl':
  5754.                                 return mediaThumbDirection[0]
  5755.                                 break;
  5756.                             case 'media-lg':
  5757.                                 return mediaThumbDirection[1]
  5758.                                 break;
  5759.                             case 'media-md':
  5760.                                 return mediaThumbDirection[2]
  5761.                                 break;
  5762.                             case 'media-sm':
  5763.                                 return mediaThumbDirection[3]
  5764.                                 break;
  5765.                             case 'media-xs':
  5766.                                 return mediaThumbDirection[4]
  5767.                                 break;
  5768.                         };
  5769.                     };
  5770.                    
  5771.                     function sliderPaginationChecking() {
  5772.                         let sliderPaginationBlock = $this.find('.splide__custom__pagination');
  5773.                        
  5774.                         setTimeout(function() {
  5775.                         if (sliderPaginationBlock.find('li').length == 1) {
  5776.                             sliderPaginationBlock.hide();
  5777.                         }
  5778.                          }, 200);
  5779.                        
  5780.                     };
  5781.                 }
  5782.             });
  5783.         }  
  5784.     };
  5785.    
  5786.    
  5787.     lpc_template.queue.tabsBlocks = function($self) {
  5788.         var $block = $self.find('.lp-js-tabs');
  5789.         if ($block.length) {
  5790.             var $tab = $block.find(".lpc-tab-gallery__tab");
  5791.             var $tabs = $block.find(".lpc-tab-gallery__tabs");
  5792.             var $item = $block.find(".lpc-tab-gallery__image");
  5793.            
  5794.            
  5795.             if ($tabs.hasClass('_type-group')) {
  5796.                 $tab.first().find('.lp-button').addClass('lpc-button--type-1');
  5797.                 $tab.first().find('.lp-button').removeClass('lpc-button--type-2');
  5798.             }
  5799.             $tab.first().addClass('active');
  5800.             $item.first().addClass('active');
  5801.        
  5802.             $tab.on('click', function () {
  5803.                 const index = $(this).index();
  5804.        
  5805.                 $tab.removeClass('active');
  5806.                
  5807.                 $item.removeClass('active');
  5808.        
  5809.                 $(this).addClass('active');
  5810.                 $item.eq(index).addClass('active');
  5811.                 if ($(this).closest('._type-group').length){
  5812.                     if ($(this).hasClass('active')) {
  5813.                         $(this).find('.lp-button').removeClass('lpc-button--type-2');
  5814.                         $(this).find('.lp-button').addClass('lpc-button--type-1');
  5815.                         $(this).siblings('.lpc-tab-gallery__tab').find('.lp-button').removeClass('lpc-button--type-1');
  5816.                         $(this).siblings('.lpc-tab-gallery__tab').find('.lp-button').addClass('lpc-button--type-2');
  5817.                     }
  5818.                 }
  5819.             });
  5820.         }
  5821.     };
  5822.    
  5823.    
  5824.     lpc_template.queue.fixingPanelShow = function($self) {
  5825.         var $fixPanelBasis = $self.find('.lpc-block-fix-panel-basis');
  5826.         if($fixPanelBasis.length) {
  5827.             $fixPanelBasis.each(function(){
  5828.                 var $fixPanel = $(this).closest('.lpc-block').find('.lpc-block-fix-panel');
  5829.                 var $fixPanelWrap = $(this).closest('.lpc-block-fix-panel-wrap');
  5830.                
  5831.                 function isElementInViewport($el) {
  5832.                     var rect = $el[0].getBoundingClientRect();
  5833.                     return (
  5834.                         rect.top >= 0 &&
  5835.                         rect.left >= 0 &&
  5836.                         rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
  5837.                         rect.right <= (window.innerWidth || document.documentElement.clientWidth)
  5838.                     );
  5839.                    
  5840.                 }
  5841.                
  5842.                 var $sectionTarget = $(this);
  5843.                
  5844.                 if (isElementInViewport($sectionTarget)) {
  5845.                      $fixPanel.hide();
  5846.                 }
  5847.                
  5848.                 $fixPanelWrap.on("scroll", function () {
  5849.                     if (isElementInViewport($sectionTarget)) {
  5850.                         $fixPanel.hide();
  5851.                     } else {
  5852.                         $fixPanel.css("display", "flex");
  5853.                     }
  5854.                 });
  5855.             });
  5856.         }
  5857.     };
  5858.    
  5859.     lpc_template.queue.videoPlayButtonDefolt = function($self) {
  5860.         var $allVideoParents = $self.find('.js-lp-play-video').closest('.lp-video-block-wrappper');
  5861.    
  5862.         $self.on('touchend click', '.js-lp-play-video', function(e) {
  5863.             e.preventDefault();
  5864.    
  5865.             var $this = $(this);
  5866.             var thisVideo = $this.parent('.lp-video-block-wrappper').find('video')[0];
  5867.    
  5868.             $this.addClass('hide');
  5869.             thisVideo.setAttribute('controls', 1);
  5870.             thisVideo.play();
  5871.            
  5872.             console.log("allvideo");
  5873.         });
  5874.        
  5875.         $allVideoParents.find('video').each(function(){
  5876.             var $video = $(this);
  5877.            
  5878.             this.addEventListener('play', function() {
  5879.                 $video.parent('.lp-video-block-wrappper').find('.js-lp-play-video').addClass('hide');
  5880.             });
  5881.            
  5882.             this.addEventListener('pause', function(){
  5883.                 $video.parent('.lp-video-block-wrappper').find('.js-lp-play-video').removeClass('hide');
  5884.             });
  5885.         });
  5886.     };
  5887.    
  5888.     lpc_template.queue.videoPlayButton = function($self) {
  5889.         let $block = $self.find('.lpc-play-video-init');
  5890.        
  5891.         if ($block.length) {
  5892.             $block.each(function() {
  5893.                 let $this = $(this);
  5894.                 let $videoPlayButton = $this.find('.js-lp-play-video');
  5895.                 let $allVideoParets = $this.find('.lp-video-block-wrappper');
  5896.                 let thisVideo = $allVideoParets.find('video')[0];
  5897.                    
  5898.                 function isMobile() {
  5899.                     return /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(navigator.userAgent) || window.innerWidth <= 768;
  5900.                 }
  5901.    
  5902.                 function togglePlayButton($video, show) {
  5903.                     let $button = $video.parent('.lp-video-block-wrappper').find('.js-lp-play-video');
  5904.                     if (show) {
  5905.                         $button.removeClass('hide');
  5906.                     } else {
  5907.                         $button.addClass('hide');
  5908.                     }
  5909.                 }
  5910.                            
  5911.                 if (isMobile()) {
  5912.                     $videoPlayButton.addClass('hide');
  5913.                     if (thisVideo) {
  5914.                         thisVideo.play();
  5915.                         thisVideo.setAttribute('controls', 1);
  5916.                     }
  5917.                     return;
  5918.                 }
  5919.                
  5920.                 $videoPlayButton.on('touchstart click', function(event) {
  5921.                     event.preventDefault();
  5922.                     let $this = $(this);
  5923.    
  5924.                     if (thisVideo) {
  5925.                         $this.addClass('hide');
  5926.                         thisVideo.play();
  5927.                         thisVideo.setAttribute('controls', 1);
  5928.                     }
  5929.                     console.log('touch start');
  5930.                 });
  5931.    
  5932.                 $allVideoParets.find('video').each(function() {
  5933.                     let $video = $(this);
  5934.                    
  5935.                     this.addEventListener('play', function() {
  5936.                         togglePlayButton($video, false);
  5937.                     });
  5938.            
  5939.                     this.addEventListener('pause', function() {
  5940.                         togglePlayButton($video, true);
  5941.                     });
  5942.                 });
  5943.             });
  5944.         }
  5945.     };
  5946.  
  5947.     lpc_template.queue.autoplayVideo = function ($self) {
  5948.     var $block = $self.find('[data-autoplay-video="1"]');
  5949.    
  5950.     if ($block.length) {
  5951.       $block.on("autoplayVideo", function (e, type, nodeName) {
  5952.         var video = this.querySelector(nodeName);
  5953.  
  5954.         if (nodeName === "video") {
  5955.           if (type === "play") {
  5956.             video.play();
  5957.           } else {
  5958.             video.pause();
  5959.           }
  5960.         } else if (nodeName === "iframe") {
  5961.           var video = $(video).data("youtube");
  5962.  
  5963.           if (type === "play") {
  5964.             video.playVideo();
  5965.           } else {
  5966.             video.pauseVideo();
  5967.           }
  5968.         }
  5969.       });
  5970.     }
  5971.  
  5972.     //setTimeout(function(){
  5973.     //  $win.trigger('scroll');
  5974.     //}, 1000);
  5975.   };
  5976.  
  5977.     lpc_template.queue.lpcLazyLoadImage = function ($self) {
  5978.         let $block = $self.find('.lpc_images_lazy_load');
  5979.    
  5980.         if ($block.length) {
  5981.             $block.each(function () {
  5982.                 const elem = this;
  5983.                 const margin = '10px';
  5984.                
  5985.                 let options = {
  5986.                     rootMargin: margin
  5987.                 };
  5988.            
  5989.                 let imageObserver = new IntersectionObserver((entries, imgObserver) => {
  5990.                     entries.forEach((entry) => {
  5991.                         if (entry.isIntersecting) {
  5992.                             const lazyImage = entry.target;
  5993.                            
  5994.                             if (lazyImage.dataset.srcset) {
  5995.                                 lazyImage.srcset = lazyImage.dataset.srcset;
  5996.                             } else {
  5997.                                 lazyImage.src = lazyImage.dataset.src;
  5998.                             }
  5999.    
  6000.                             lazyImage.classList.remove('lpc_images_lazy_load');
  6001.                             imgObserver.unobserve(lazyImage);
  6002.                         }
  6003.                     });
  6004.                 }, options);
  6005.                
  6006.                 imageObserver.observe(elem);
  6007.                
  6008.             });
  6009.         }
  6010.     };
  6011.    
  6012.     lpc_template.queue.lgNew = function($self) {
  6013.         let $block = $self.find('.js-new-lg-init');
  6014.  
  6015.         if ($block.length) {
  6016.             $block.each(function() {
  6017.                 let $block = $(this);
  6018.                 let lgCounter = $block.data('lg-counter');
  6019.                 let lgThumbnail = $block.data('lg-thumbnail');
  6020.                
  6021.                 //setTimeout(function() {
  6022.                     lightGallery($block[0], {
  6023.                         plugins: [Zoom, Thumbnail, Video],
  6024.                         counter: lgCounter,
  6025.                         thumbnail: lgThumbnail,
  6026.                         selector: '.lpc-lg-item',
  6027.                         download: false,
  6028.                         mobileSettings: {
  6029.                             preload: 2,
  6030.                             controls: false,
  6031.                             showCloseIcon: true
  6032.                         }
  6033.                     });
  6034.                 //}, 2000);
  6035.                
  6036.                 $block.find('.lpc-lg-item').removeClass('lpc_lg_pointer_events');
  6037.             });
  6038.         }
  6039.     };
  6040.  
  6041.     lpc_template.queue.lg = function ($self) {
  6042.     var $block = $self.find(".js-lg-init");
  6043.  
  6044.     if ($block.length) {
  6045.       //setTimeout(function () {
  6046.         $block.lightGallery({
  6047.           selector: ".lg-item",
  6048.           toogleThumb: false,
  6049.           getCaptionFromTitleOrAlt: false,
  6050.           download: false,
  6051.           thumbWidth: 64,
  6052.           thumbHeight: "64px",
  6053.           addClass: "_lpc-lg",
  6054.           nextHtml:
  6055.             '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.98528 4.32805C9.3758 3.93753 10.009 3.93753 10.3995 4.32805L17.0563 10.9849C17.4469 11.3754 17.4469 12.0086 17.0563 12.3991L10.3995 19.056C10.009 19.4465 9.3758 19.4465 8.98528 19.056C8.59475 18.6654 8.59475 18.0323 8.98528 17.6418L14.935 11.692L8.98528 5.74226C8.59475 5.35174 8.59475 4.71857 8.98528 4.32805Z" fill="white"/></svg>',
  6056.           prevHtml:
  6057.             '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.8492 5.03516L8.19239 11.692L14.8492 18.3489" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
  6058.         });
  6059.        
  6060.         $block.find('.lg-item').removeClass('lpc_lg_pointer_events');
  6061.        
  6062.       //}, 500);
  6063.     }
  6064.   };
  6065.  
  6066.  
  6067.     // ================================= НЕ УДАЛЯТЬ! Тестовый код ================================= //
  6068.    
  6069.     // Заголовки для LPCv4 для медиа-запросов
  6070.     lpc_template.queue.adaptiveTitle = function ($self) {
  6071.         let $block = $self.find('.adaptive_text_init');
  6072.    
  6073.         if ($block.length) {
  6074.    
  6075.             // Объект для хранения состояния фиксации размеров шрифтов для каждого заголовка и разрешения
  6076.             let fixedSizes = {
  6077.                 'media-lg': {},
  6078.                 'media-md': {},
  6079.                 'media-sm': {},
  6080.                 'media-xs': {}
  6081.             };
  6082.    
  6083.             $block.each(function() {
  6084.                 $(this).find('.font-size-input').each(function() {
  6085.                     const media = $(this).data('media');
  6086.                     const heading = $(this).data('title'); // Заголовки (h1, h2, ..., h6)
  6087.                     const fontSize = parseFloat($(this).val());
  6088.                     const textElement = $self.find(`.lpc-adaptive-text__box[data-media="${media}"] .lpc-adaptive-text__title[data-title="${heading}"]`);
  6089.    
  6090.                     // Установка начального размера шрифта
  6091.                     textElement.css('fontSize', `${fontSize}px`);
  6092.    
  6093.                     $(this).on('input', function() {
  6094.                         let newFontSize = parseFloat($(this).val());
  6095.    
  6096.                         if (newFontSize < 0 || isNaN(newFontSize)) {
  6097.                             newFontSize = Math.abs(newFontSize) || 0;
  6098.                             $(this).val(newFontSize);
  6099.                         }
  6100.    
  6101.                         if (!isNaN(newFontSize)) {
  6102.                             newFontSize = Math.round(newFontSize);
  6103.                         }
  6104.    
  6105.                         if (media === 'media-xl') {
  6106.    
  6107.                             // Диапазоны для других разрешений
  6108.                             const sizeLimits = {
  6109.                                 'h1': {
  6110.                                     'media-lg': { min: 34, max: 68 },
  6111.                                     'media-md': { min: 32, max: 64 },
  6112.                                     'media-sm': { min: 30, max: 60 },
  6113.                                     'media-xs': { min: 28, max: 56 }
  6114.                                 },
  6115.                                 'h2': {
  6116.                                     'media-lg': { min: 32, max: 62 },
  6117.                                     'media-md': { min: 30, max: 58 },
  6118.                                     'media-sm': { min: 28, max: 54 },
  6119.                                     'media-xs': { min: 26, max: 50 }
  6120.                                 },
  6121.                                 'h3': {
  6122.                                     'media-lg': { min: 30, max: 56 },
  6123.                                     'media-md': { min: 28, max: 52 },
  6124.                                     'media-sm': { min: 26, max: 48 },
  6125.                                     'media-xs': { min: 24, max: 44 }
  6126.                                 },
  6127.                                 'h4': {
  6128.                                     'media-lg': { min: 28, max: 50 },
  6129.                                     'media-md': { min: 26, max: 46 },
  6130.                                     'media-sm': { min: 24, max: 42 },
  6131.                                     'media-xs': { min: 22, max: 38 }
  6132.                                 },
  6133.                                 'h5': {
  6134.                                     'media-lg': { min: 26, max: 44 },
  6135.                                     'media-md': { min: 24, max: 40 },
  6136.                                     'media-sm': { min: 22, max: 36 },
  6137.                                     'media-xs': { min: 20, max: 32 }
  6138.                                 },
  6139.                                 'h6': {
  6140.                                     'media-lg': { min: 24, max: 40 },
  6141.                                     'media-md': { min: 22, max: 36 },
  6142.                                     'media-sm': { min: 20, max: 32 },
  6143.                                     'media-xs': { min: 18, max: 28 }
  6144.                                 }
  6145.                             };
  6146.                            
  6147.                             // Адаптация размеров для других медиа-устройств
  6148.                             const sizeRatios = {
  6149.                                 'media-lg': 0.9,
  6150.                                 'media-md': 0.9,
  6151.                                 'media-sm': 0.75,
  6152.                                 'media-xs': 0.65
  6153.                             };
  6154.    
  6155.                             $self.find('.font-size-input').each(function() {
  6156.                                 const otherMedia = $(this).data('media');
  6157.                                 const otherHeading = $(this).data('title');
  6158.                                 const otherTextElement = $self.find(`.lpc-adaptive-text__box[data-media="${otherMedia}"] .lpc-adaptive-text__title[data-title="${otherHeading}"]`);
  6159.    
  6160.                                 if (otherHeading === heading && (otherMedia === 'media-xl' || !fixedSizes[otherMedia][heading])) {
  6161.                                     let adaptedSize = otherMedia === 'media-xl' ? newFontSize : Math.round(newFontSize * sizeRatios[otherMedia]);
  6162.    
  6163.                                     // Применение ограничений для других медиа-устройств
  6164.                                     if (sizeLimits[heading] && sizeLimits[heading][otherMedia]) {
  6165.                                         const { min, max } = sizeLimits[heading][otherMedia];
  6166.                                         adaptedSize = Math.min(Math.max(adaptedSize, min), max);
  6167.                                     }
  6168.    
  6169.                                     $(this).val(adaptedSize);
  6170.                                     otherTextElement.css('fontSize', `${adaptedSize}px`);
  6171.                                     $(this).css('color', 'green');
  6172.                                 }
  6173.                             });
  6174.    
  6175.                         } else {
  6176.                             fixedSizes[media][heading] = true;
  6177.                             textElement.css('fontSize', `${newFontSize}px`);
  6178.                             $(this).css('color', 'red');
  6179.                             $(this).val(newFontSize);
  6180.                         }
  6181.                     });
  6182.                 });
  6183.             });
  6184.         }
  6185.     };
  6186.    
  6187.     // Заголовки для LP для ширины сайта
  6188.     lpc_template.queue.adaptiveTitleContent = function ($self) {
  6189.         let $block = $self.find('.adaptive_width_init');
  6190.    
  6191.         if ($block.length) {
  6192.             const sizeRatios = {
  6193.                 'h1': 1,
  6194.                 'h2': 0.9,
  6195.                 'h3': 0.8,
  6196.                 'h4': 0.7,
  6197.                 'h5': 0.6,
  6198.                 'h6': 0.5
  6199.             };
  6200.            
  6201.             const sizeLimits = {
  6202.                 'h2': {
  6203.                     'media-xl': { min: 34, max: 66 },
  6204.                     'media-lg': { min: 32, max: 62 },
  6205.                     'media-md': { min: 30, max: 58 },
  6206.                     'media-sm': { min: 28, max: 54 },
  6207.                     'media-xs': { min: 26, max: 50 }
  6208.                 },
  6209.                 'h3': {
  6210.                     'media-xl': { min: 32, max: 60 },
  6211.                     'media-lg': { min: 30, max: 56 },
  6212.                     'media-md': { min: 28, max: 52 },
  6213.                     'media-sm': { min: 26, max: 48 },
  6214.                     'media-xs': { min: 24, max: 44 }
  6215.                 },
  6216.                 'h4': {
  6217.                     'media-xl': { min: 30, max: 54 },
  6218.                     'media-lg': { min: 28, max: 50 },
  6219.                     'media-md': { min: 26, max: 46 },
  6220.                     'media-sm': { min: 24, max: 42 },
  6221.                     'media-xs': { min: 22, max: 38 }
  6222.                 },
  6223.                 'h5': {
  6224.                     'media-xl': { min: 28, max: 48 },
  6225.                     'media-lg': { min: 26, max: 44 },
  6226.                     'media-md': { min: 24, max: 40 },
  6227.                     'media-sm': { min: 22, max: 36 },
  6228.                     'media-xs': { min: 20, max: 32 }
  6229.                 },
  6230.                 'h6': {
  6231.                     'media-xl': { min: 26, max: 44 },
  6232.                     'media-lg': { min: 24, max: 40 },
  6233.                     'media-md': { min: 22, max: 36 },
  6234.                     'media-sm': { min: 20, max: 32 },
  6235.                     'media-xs': { min: 18, max: 28 }
  6236.                 }
  6237.             };
  6238.    
  6239.             $block.each(function() {
  6240.                 $(this).find('.font-size-input').each(function() {
  6241.                     const media = $(this).data('media');
  6242.                     const heading = $(this).data('title'); // Заголовки (h1, h2, ..., h6)
  6243.                     const fontSize = parseFloat($(this).val());
  6244.                     const textElement = $self.find(`.lpc-adap-title-bl__container[data-media="${media}"] .lpc-title-js[data-title="${heading}"]`);
  6245.    
  6246.                     // Установка начального размера шрифта
  6247.                     textElement.css('fontSize', `${fontSize}px`);
  6248.    
  6249.                     $(this).on('input', function() {
  6250.                         let newFontSize = parseFloat($(this).val());
  6251.    
  6252.                         if (newFontSize < 0 || isNaN(newFontSize)) {
  6253.                             newFontSize = Math.abs(newFontSize) || 0;
  6254.                             $(this).val(newFontSize);
  6255.                         }
  6256.    
  6257.                         if (!isNaN(newFontSize)) {
  6258.                             newFontSize = Math.round(newFontSize);
  6259.                         }
  6260.                        
  6261.                         if (heading === 'h1') {
  6262.                             $self.find(`.font-size-input[data-media="${media}"]`).each(function() {
  6263.                                 const otherHeading = $(this).data('title');
  6264.                                 const otherTextElement = $self.find(`.lpc-adap-title-bl__container[data-media="${media}"] .lpc-title-js[data-title="${otherHeading}"]`);
  6265.    
  6266.                                 // Рассчитываем размер шрифта на основе соотношения
  6267.                                 let adjustedSize = Math.round(newFontSize * sizeRatios[otherHeading]);
  6268.    
  6269.                                 // Применение ограничений для размера шрифта
  6270.                                 if (sizeLimits[otherHeading] && sizeLimits[otherHeading][media]) {
  6271.                                     const { min, max } = sizeLimits[otherHeading][media];
  6272.                                     adjustedSize = Math.min(Math.max(adjustedSize, min), max);
  6273.                                 }
  6274.    
  6275.                                 $(this).val(adjustedSize);
  6276.                                 otherTextElement.css('fontSize', `${adjustedSize}px`);
  6277.                                 $(this).css('color', 'green');
  6278.                             });
  6279.                         } else {
  6280.                             textElement.css('fontSize', `${newFontSize}px`);
  6281.                             $(this).css('color', 'red');
  6282.                         }
  6283.                     });
  6284.                 });
  6285.             });
  6286.         }
  6287.     };
  6288.    
  6289.     lpc_template.queue.adaptiveTexeContent = function ($self) {
  6290.         let $block = $self.find('.adaptive_text_width_init');
  6291.    
  6292.         if ($block.length) {
  6293.            
  6294.             const sizeRatios = {
  6295.                 'p1': 1,
  6296.                 'p2': 0.95,
  6297.                 'p3': 0.9,
  6298.                 'p4': 0.85,
  6299.             };
  6300.    
  6301.            
  6302.             const sizeLimits = {
  6303.                 'p2': {
  6304.                     'media-xl': { min: 20, max: 22 },
  6305.                     'media-lg': { min: 20, max: 22 },
  6306.                     'media-md': { min: 18, max: 20 },
  6307.                     'media-sm': { min: 18, max: 20 },
  6308.                     'media-xs': { min: 16, max: 18 }
  6309.                 },
  6310.                 'p3': {
  6311.                     'media-xl': { min: 18, max: 20 },
  6312.                     'media-lg': { min: 18, max: 20 },
  6313.                     'media-md': { min: 16, max: 18 },
  6314.                     'media-sm': { min: 16, max: 18 },
  6315.                     'media-xs': { min: 15, max: 16 }
  6316.                 },
  6317.                 'p4': {
  6318.                     'media-xl': { min: 16, max: 18 },
  6319.                     'media-lg': { min: 16, max: 18 },
  6320.                     'media-md': { min: 16, max: 16 },
  6321.                     'media-sm': { min: 14, max: 16 },
  6322.                     'media-xs': { min: 14, max: 14 }
  6323.                 }
  6324.             };
  6325.    
  6326.             $block.each(function() {
  6327.                 $(this).find('.font-size-input').each(function() {
  6328.                     const media = $(this).data('media');
  6329.                     const heading = $(this).data('text'); // Заголовки (p1, p2, ..., h4)
  6330.                     const fontSize = parseFloat($(this).val());
  6331.                     const textElement = $self.find(`.lpc-adap-text-bl__container[data-media="${media}"] .lpc-text-js[data-text="${heading}"]`);
  6332.    
  6333.                    
  6334.                     textElement.css('fontSize', `${fontSize}px`);
  6335.    
  6336.                     $(this).on('input', function() {
  6337.                         let newFontSize = parseFloat($(this).val());
  6338.    
  6339.                         if (newFontSize < 0 || isNaN(newFontSize)) {
  6340.                             newFontSize = Math.abs(newFontSize) || 0;
  6341.                             $(this).val(newFontSize);
  6342.                         }
  6343.    
  6344.                         if (!isNaN(newFontSize)) {
  6345.                             newFontSize = Math.round(newFontSize);
  6346.                         }
  6347.    
  6348.                        
  6349.                         if (heading === 'p1') {
  6350.                            
  6351.                             $self.find(`.font-size-input[data-media="${media}"]`).each(function() {
  6352.                                 const otherHeading = $(this).data('text');
  6353.                                 const otherTextElement = $self.find(`.lpc-adap-text-bl__container[data-media="${media}"] .lpc-text-js[data-text="${otherHeading}"]`);
  6354.    
  6355.                                
  6356.                                 let adjustedSize = Math.round(newFontSize * sizeRatios[otherHeading]);
  6357.    
  6358.                                
  6359.                                 if (sizeLimits[otherHeading] && sizeLimits[otherHeading][media]) {
  6360.                                     const { min, max } = sizeLimits[otherHeading][media];
  6361.                                     adjustedSize = Math.min(Math.max(adjustedSize, min), max);
  6362.                                 }
  6363.    
  6364.                                 $(this).val(adjustedSize);
  6365.                                 otherTextElement.css('fontSize', `${adjustedSize}px`);
  6366.                                 $(this).css('color', 'green');
  6367.                             });
  6368.                         } else {
  6369.                            
  6370.                             textElement.css('fontSize', `${newFontSize}px`);
  6371.                             $(this).css('color', 'red');
  6372.                         }
  6373.                     });
  6374.                 });
  6375.             });
  6376.         }
  6377.     };
  6378.    
  6379.     lpc_template.queue.tabsInitTest = function ($self) {
  6380.         let $block = $self.find('.adaptive_width_init');
  6381.    
  6382.         if ($block.length) {
  6383.             $block.each(function() {
  6384.                 let $this = $(this);
  6385.                 let $button = $this.find('.lp-button');
  6386.                 let $tab = $this.find('.tab');
  6387.                
  6388.                 $button.click(function() {
  6389.                     $button.removeClass('active');
  6390.                     $tab.removeClass('active');
  6391.                    
  6392.                     $(this).addClass('active');
  6393.                     $('#' + $(this).data('tab')).addClass('active');
  6394.                 });
  6395.             });
  6396.         }
  6397.     };
  6398.     // ================================= НЕ УДАЛЯТЬ! Тестовый код ================================= //
  6399.    
  6400.    
  6401.     lpc_template.queue.lpcContact2 = function ($blocks) {
  6402.         var $block = $blocks.find(".lpc-contact-2");
  6403.         let dataMediaSource = document.querySelector('.decor-wrap').dataset.mediaSource;
  6404.        
  6405.         if ($block.length && (dataMediaSource != 'media-sm' && dataMediaSource != 'media-xs')) {
  6406.             $block.each(function(){
  6407.                 var $this = $(this),
  6408.                 lpcMapBlockHeight = $this.find('.lpc-contact-2__content').height(),
  6409.                 lpcMapBlock = $this.find('.lpc-contact-2__map-wrap');
  6410.                
  6411.                 setTimeout(function() {
  6412.                     lpcMapBlock.css('max-height', lpcMapBlockHeight)
  6413.                 }, 1000);
  6414.             });
  6415.            
  6416.         }
  6417.     };
  6418.    
  6419.     lpc_template.queue.lpcConstructorFrameSelection = function ($blocks) {
  6420.         if(window.location.pathname == "/my/s3/cms/v1/lp/live.edit.php") {
  6421.             $('.content-lp-wrapper').addClass("lpc-const-frame-selection");
  6422.         }
  6423.         /*if(window.location.host == "mf1.ravshan95.oml.ru") {
  6424.             $('.content-lp-wrapper').addClass("lpc-const-frame-selection-fix");
  6425.         }*/
  6426.     };
  6427.    
  6428.     lpc_template.queue.lpcForm5 = function ($blocks) {
  6429.         var $block = $blocks.find(".lpc-form-5");
  6430.        
  6431.         if ($block.length) {
  6432.             if($block.find("textarea").length != 0) {
  6433.             document.querySelector('.lpc-form-5 textarea').addEventListener('input', function (e) {
  6434.                
  6435.               e.target.style.height = 50 + "px";
  6436.               e.target.style.height = e.target.scrollHeight + 2 + "px"
  6437.             });
  6438.            
  6439.             }
  6440.         }
  6441.     };
  6442.    
  6443.     lpc_template.queue.lpStepForm = function($self) {
  6444.       var $block = $self.find('.js-lp-steps-form');
  6445.    
  6446.       if ($block.length) {
  6447.         $block.formsteps();
  6448.       }
  6449.     };
  6450.  
  6451.   lpc_template.checkAutoplayVideo = function ($blocks) {
  6452.     $blocks.each(function () {
  6453.       var $this = $(this),
  6454.         playStatus = $this.data("playStatus"),
  6455.         inViewport = isElementInViewport(this),
  6456.         $video = $this.find("video"),
  6457.         $thisVideo = $video.length ? $video : $this.find("iframe");
  6458.  
  6459.       if (inViewport && playStatus !== "play") {
  6460.         $this.trigger("autoplayVideo", [
  6461.           "play",
  6462.           $thisVideo[0].nodeName.toLowerCase(),
  6463.         ]);
  6464.         $this.data("playStatus", "play");
  6465.       } else if (!inViewport && playStatus === "play") {
  6466.         $this.trigger("autoplayVideo", [
  6467.           "pause",
  6468.           $thisVideo[0].nodeName.toLowerCase(),
  6469.         ]);
  6470.         $this.data("playStatus", "pause");
  6471.       }
  6472.     });
  6473.   };
  6474.  
  6475.  
  6476.   window.lp_init = function ($block) {
  6477.  
  6478.     var $maps = $block.find(".js-lpc-simple-map");
  6479.  
  6480.     if ($maps.length) {
  6481.       setTimeout(function () {
  6482.         lpc_template.checkMapInitialization($maps);
  6483.       }, 250);
  6484.       $win.on("scroll", function () {
  6485.         lpc_template.checkMapInitialization($maps);
  6486.       });
  6487.      
  6488.     }
  6489.  
  6490.     if (s3LP.is_cms) {
  6491.       var contentColor = $("#lpc_contructor_iframe")
  6492.         .contents()
  6493.         .find(".decor-wrap")
  6494.         .css("color");
  6495.       $("#landing_page_site").css("color", contentColor);
  6496.     }
  6497.  
  6498.     $win
  6499.       .on("resize", function () {
  6500.         var decorWidth = $(".decor-wrap").width();
  6501.         $(".lpc-block").css("max-width", decorWidth);
  6502.       })
  6503.       .trigger("resize");
  6504.  
  6505.     Object.keys(lpc_template.queue).forEach(function (func) {
  6506.       var thisFunction = lpc_template.queue[func];
  6507.       if (typeof thisFunction == "function") {
  6508.         thisFunction($block);
  6509.       }
  6510.     });
  6511.  
  6512.     var $autoplayVideo = $doc.find('[data-autoplay-video="1"]');
  6513.  
  6514.     if ($autoplayVideo.length && !s3LP.is_cms && window.self == window.top) {
  6515.       $win.on("scroll", function () {
  6516.         lpc_template.checkAutoplayVideo($autoplayVideo);
  6517.       });
  6518.     }
  6519.    
  6520.    
  6521.  
  6522.     let timeout;
  6523.  
  6524.     $win
  6525.       .on("resize", function () {
  6526.  
  6527.         clearTimeout(timeout)
  6528.  
  6529.         timeout = setTimeout(function(){
  6530.           lpc_template.adaptiveBlock();
  6531.           lpc_template.popupAdaptiveBlock();
  6532.         }, 80);
  6533.  
  6534.         $(".js-proportion-height").each(function () {
  6535.           var $this = $(this);
  6536.  
  6537.           setProportionHeight($this, $this.data("proportion") || 100);
  6538.         });
  6539.       })
  6540.       .trigger("resize");
  6541.  
  6542.     if (s3LP.is_cms) {
  6543.       LpController.convertImages($block);
  6544.  
  6545.       setTimeout(function () {
  6546.         LpController.convertImages($block);
  6547.         LpController.afterSave(function () {
  6548.           $(".lpc-features-3-chart-item__number").each(function () {
  6549.             var $this = $(this);
  6550.             $this
  6551.               .closest(".lpc-features-3-chart-item")
  6552.               .find(".lpc-features-3-chart-item__bar-inner")
  6553.               .css("width", $this.text());
  6554.           });
  6555.         });
  6556.       }, 1000);
  6557.     }
  6558.  
  6559.     if (document.location.hash.length > 1 && $(document.location.hash).length) {
  6560.       setTimeout(function () {
  6561.         $("html, body").scrollTop($(document.location.hash).offset().top);
  6562.       }, 200);
  6563.     }
  6564.    
  6565.    
  6566.     document.dispatchEvent(new Event('lpc_init_after', {bubbles: true}));
  6567.   };
  6568.  
  6569.   window.onYouTubeIframeAPIReady = function () {
  6570.     $(function () {
  6571.       var listYoutube = $(".js-lp-video-youtube");
  6572.  
  6573.       listYoutube.each(function () {
  6574.         var $this = $(this),
  6575.           isFullFrame = $this.hasClass("_not-paused");
  6576.  
  6577.         var player = new YT.Player(this.id, {
  6578.           iv_load_policy: 3,
  6579.           modestbranding: 1,
  6580.           rel: 0,
  6581.           mute: isFullFrame ? 1 : 0,
  6582.           playsinline: 1,
  6583.           showinfo: isFullFrame ? 0 : 1,
  6584.           events: {
  6585.             onStateChange: function (event) {
  6586.               if (
  6587.                 event.data == YT.PlayerState.ENDED &&
  6588.                 $(event.target.a).hasClass("_not-paused")
  6589.               ) {
  6590.                 event.target.playVideo();
  6591.               }
  6592.             },
  6593.           },
  6594.         });
  6595.  
  6596.         $this.data("youtube", player);
  6597.       });
  6598.     });
  6599.   };
  6600.  
  6601.   function isElementInViewport(el) {
  6602.     var rect = el.getBoundingClientRect();
  6603.     return rect.top <= window.innerHeight - 200 && rect.bottom >= 50;
  6604.   }
  6605.  
  6606.   function setProportionHeight($block, proportion) {
  6607.     $block.height(($block.width() * proportion) / 100);
  6608.   }
  6609.  
  6610.     function s3PreloaderMutation(target) {
  6611.         const config = {
  6612.             attributes: true
  6613.         };
  6614.    
  6615.         const callback = function (mutationsList, observer) {
  6616.             for (let mutation of mutationsList) {
  6617.                 if ($(target).find('.s3-preloader').hasClass('s3-preloader-hide') || $(target).hasClass('s3-preloader-hide')) {
  6618.                     document.dispatchEvent(new Event('lpcLoadingDone', {bubbles: true}));
  6619.                 }
  6620.             }
  6621.         };
  6622.    
  6623.         const observer = new MutationObserver(callback);
  6624.         observer.observe(target, config);
  6625.     };
  6626.  
  6627. })();
  6628.  
  6629. document.addEventListener("DOMContentLoaded", function () {
  6630.     let lpContent = document.getElementById("lp_constructor");
  6631.     let timeout = 20;
  6632.     if (lpContent) {
  6633.         timeout = 1500;
  6634.     }
  6635.     setTimeout(function () {
  6636.  
  6637.         const toRGBArray = rgbStr => rgbStr.match(/\d+/g).map(Number);
  6638.  
  6639.         document.querySelectorAll('.has_custom_bg').forEach(function (element) {
  6640.             let customBg = toRGBArray(window.getComputedStyle(element).backgroundColor);
  6641.             let textColor = Math.round((parseInt(customBg[0]) * 299 + parseInt(customBg[1]) * 587 + parseInt(customBg[2]) * 114) / 1000);
  6642.  
  6643.             if (textColor > 150) {
  6644.                 element.style.color = '#000';
  6645.                 element.querySelectorAll('[data-elem-type="text"]').forEach(function (textElement) {
  6646.                     textElement.style.color = '#000';
  6647.                 });
  6648.                 element.querySelectorAll('[data-elem-type="header"]').forEach(function (headerElement) {
  6649.                     headerElement.style.color = '#000';
  6650.                 });
  6651.                 element.querySelectorAll('[data-elem-type="generate"]').forEach(function (generateElement) {
  6652.                     generateElement.style.color = '#000';
  6653.                 });
  6654.             } else {
  6655.                 element.style.color = '#fff';
  6656.                 element.querySelectorAll('[data-elem-type="text"]').forEach(function (textElement) {
  6657.                     textElement.style.color = '#fff';
  6658.                 });
  6659.                 element.querySelectorAll('[data-elem-type="header"]').forEach(function (headerElement) {
  6660.                     headerElement.style.color = '#fff';
  6661.                 });
  6662.                 element.querySelectorAll('[data-elem-type="generate"]').forEach(function (generateElement) {
  6663.                     generateElement.style.color = '#fff';
  6664.                 });
  6665.             }
  6666.         });
  6667.        
  6668.         document.querySelectorAll('.ya-share2').forEach(function (element) {
  6669.             let customBgShare = toRGBArray(window.getComputedStyle(element).backgroundColor);
  6670.             let textColorShare = Math.round((parseInt(customBgShare[0]) * 299 + parseInt(customBgShare[1]) * 587 + parseInt(customBgShare[2]) * 114) / 1000);
  6671.  
  6672.             if (textColorShare > 150) {
  6673.                 $('.ya-share2').addClass("lpc-share-light-mode");
  6674.             } else {
  6675.                 $('.ya-share2').addClass("lpc-share-dark-mode");
  6676.             }
  6677.         });
  6678.     }, timeout);
  6679.  
  6680.     setTimeout(() => {
  6681.         const calculators = document.querySelectorAll('.lpc-calculator');
  6682.  
  6683.         if (calculators.length) {
  6684.             calculators.forEach(calculator => {
  6685.                 const calc = new Calculator(calculator);
  6686.                 calc.init();
  6687.             });
  6688.         }
  6689.     }, 500);
  6690. });
  6691.  
  6692. class Calculator {
  6693.     constructor(calculator) {
  6694.         this.calculator = calculator;
  6695.         this.calculateButton = this.calculator.querySelector('.calculate_button');
  6696.         this.calculateFormula = this.calculateButton.getAttribute('data-calculator-formula');
  6697.         this.calculateResult = this.calculator.querySelector('.js_calculate_result');
  6698.         this.calculateInputs = Array.from(this.calculator.querySelectorAll('input'));
  6699.         this.calculateErrorBlock = this.calculator.querySelector('.calculate-error-block');
  6700.     }
  6701.  
  6702.     parseCalculatorFormula(formula) {
  6703.         let variableRegex = '([a-zA-Z0-9]?[a-zA-Z]+)';
  6704.         let formulaVariables = Array.from(formula.matchAll(variableRegex));
  6705.         let parsedFormula = formula;
  6706.         for (const formulaVariable of formulaVariables) {
  6707.             let inputValue = this.calculator.querySelector(`input[data-calculator-alias=${formulaVariable[0]}]`).value;
  6708.             parsedFormula = parsedFormula.replace(formulaVariable[0], inputValue ? inputValue : NULL);
  6709.         }
  6710.  
  6711.         return eval(parsedFormula);
  6712.     }
  6713.  
  6714.     initializeRangeFields(fields) {
  6715.         fields.forEach((field) => {
  6716.             let input = field;
  6717.             let parent = input.parentNode;
  6718.             let min = parseFloat(input.min);
  6719.             let max = parseFloat(input.max);
  6720.             let current = parent.querySelector(".lpc-calculator-range--current");
  6721.             let currentLine = parent.querySelector(".lpc-calculator-range--current-line");
  6722.  
  6723.             const updateCurrentPosition = () => {
  6724.                 let value = parseFloat(input.value);
  6725.                 current.textContent = value;
  6726.  
  6727.                 let currentWidth = current.getBoundingClientRect().width;
  6728.                 let currentPos = (100 * (value - min) / (max - min));
  6729.  
  6730.                 if (currentPos < 0) {
  6731.                     currentPos = 0;
  6732.                 } else if (currentPos > 100) {
  6733.                     currentPos = 100;
  6734.                 }
  6735.  
  6736.                 current.style.left = `${(currentPos / 100) * (input.getBoundingClientRect().width - currentWidth)}px`;
  6737.                 currentLine.style.width = `${currentPos}%`;
  6738.             };
  6739.  
  6740.             field.addEventListener("input", updateCurrentPosition);
  6741.             updateCurrentPosition();
  6742.         });
  6743.     }
  6744.  
  6745.     initializeNumberFields(fields) {
  6746.         fields.forEach((field) => {
  6747.             let input = field;
  6748.             let parent = input.parentNode;
  6749.             let min = input.min;
  6750.             let step = input.step;
  6751.             let max = input.max;
  6752.             let decrementButton = parent.querySelector(".lpc-calculator-number--dec");
  6753.             let incrementButton = parent.querySelector(".lpc-calculator-number--inc");
  6754.    
  6755.             input.addEventListener("change", () => {
  6756.                 const value = Number(input.value);
  6757.                 if (value >= max) {
  6758.                     incrementButton.setAttribute("disabled", true);
  6759.                     decrementButton.removeAttribute("disabled");
  6760.                     input.value = max;
  6761.                 } else if (value <= min) {
  6762.                     input.value = min;
  6763.                     incrementButton.removeAttribute("disabled");
  6764.                     decrementButton.setAttribute("disabled", true);
  6765.                 } else {
  6766.                     incrementButton.removeAttribute("disabled");
  6767.                     decrementButton.removeAttribute("disabled");
  6768.                 }
  6769.             });
  6770.    
  6771.             decrementButton.addEventListener("click", () => {
  6772.                 incrementButton.disabled = false
  6773.                 let current = input.value
  6774.                 let currentVal = current - step
  6775.    
  6776.                 if (currentVal <= min) {
  6777.                     input.textContent = min
  6778.                     decrementButton.disabled = true
  6779.                     return input.value = min
  6780.                 }
  6781.    
  6782.                 input.textContent = currentVal
  6783.                 return input.value = currentVal
  6784.             });
  6785.    
  6786.             incrementButton.addEventListener("click", () => {
  6787.                 decrementButton.disabled = false
  6788.                 let current = input.value
  6789.                 let currentVal = Number(current) + Number(step)
  6790.    
  6791.                 if (Number(currentVal) >= Number(max)) {
  6792.                     incrementButton.disabled = true
  6793.                     input.textContent = max
  6794.                     return input.value = max
  6795.                 }
  6796.    
  6797.                 input.textContent = currentVal
  6798.                 return input.value = currentVal
  6799.             });
  6800.         })
  6801.     }
  6802.  
  6803.  
  6804.     initializeFieldTypes() {
  6805.         let rangeFields = this.calculateInputs.filter((item) => item.classList.contains('lpc-calculator-input--range'));
  6806.         let numberFields = this.calculateInputs.filter((item) => item.classList.contains('lpc-calculator-input--number'));
  6807.  
  6808.         this.initializeRangeFields(rangeFields);
  6809.         this.initializeNumberFields(numberFields);
  6810.     }
  6811.    
  6812.     init() {
  6813.         this.initializeFieldTypes();
  6814.         this.calculateButton.addEventListener('click', () => {
  6815.             this.calculateErrorBlock.innerHTML = '';
  6816.             try {
  6817.                 const result = this.parseCalculatorFormula(this.calculateFormula);
  6818.                 if (!isNaN(result) && isFinite(result)) {
  6819.                     this.calculateResult.querySelector('span').textContent = result.toFixed(2);
  6820.                     console.log(result);
  6821.                 } else {
  6822.                     this.calculateErrorBlock.innerHTML += '<p>Проверьте корректность введенных данных</p>';
  6823.                     this.calculateResult.querySelector('span').textContent = 0;
  6824.                 }
  6825.             } catch (e) {
  6826.                 this.calculateErrorBlock.innerHTML += '<p>Проверьте корректность введенных данных</p>';
  6827.                 this.calculateResult.querySelector('span').textContent = 0;
  6828.             }
  6829.         });
  6830.     }
  6831. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement