PageSourceSearch

https://zincor-lkm.ru/js/main.js

js zincor-lkm.ru collected 2026-10-09 17:45:32 UTC 22,597 bytes, 698 lines download raw bytes

1$(document).ready(function(){
2
3    $('body').activity({
4		'achieveTime':60
5		,'testPeriod':10
6		,useMultiMode: 1
7		,callBack: function (e) {
8			ga('send', 'event', 'Activity', '60_sec');
9			yaCounter13943005.reachGoal('60_sec');
10		}
11	});
12
13    $('.ib-slick').slick({
14        dots: true,
15        arrows: false,
16        infinite: true,
17        fade:false,
18        speed: 600,
19        autoplaySpeed: 4000,
20        slidesToShow: 1,
21        adaptiveHeight: true,
22        autoplay:true
23    });
24
25    $('.g-carousel').slick({
26        dots: true,
27        arrows: false,
28        infinite: false,
29        speed: 300,
30        slidesToShow: 4,
31        slidesToScroll: 4,
32        responsive: [
33            {
34                breakpoint: 979,
35                settings: {
36                    slidesToShow: 3,
37                    slidesToScroll: 3,
38                    infinite: true,
39                    dots: true
40                }
41            },
42            {
43                breakpoint: 767,
44                settings: {
45                    slidesToShow: 3,
46                    slidesToScroll: 3
47                }
48            },
49            {
50                breakpoint: 480,
51                settings: {
52                    slidesToShow: 2,
53                    slidesToScroll: 2
54                }
55            }
56
57        ]
58    });
59
60    // $('.btn-sidebar').click(function(){
61    //     $(this).toggleClass('is-open');
62    //     if($(this).hasClass('is-open')){
63    //         $('.sidebar').slideDown(200);
64    //     }else{
65    //         $('.sidebar').slideUp(200, function(){
66    //             $(this).removeAttr('style');
67    //         });
68    //     }
69
70    //     return false;
71    // });
72
73    $('.btn-sidebar').click(function(){
74        $(this).toggleClass('is-open');
75        if($(this).hasClass('is-open')){
76            $(".js-catalog-nav").appendTo(".js-top-row");
77            $('.sidebar').fadeIn(100);
78            $('body').addClass('themodal-lock');
79            $('.top-row').addClass('top-row-modal');
80            
81            
82            
83
84        }else{
85            $('.sidebar').fadeOut(100, function () {
86                $(this).removeAttr('style');
87                $('body').removeClass('themodal-lock');
88                $('.top-row').removeClass('top-row-modal');
89                
90            });
91        }
92        return false;
93    });
94
95    $( window ).resize(function() {
96        if($( window ).width()<=768){
97            $(".js-catalog-nav").appendTo(".js-top-row");
98        }else{
99            $(".js-catalog-nav").appendTo(".js-lcol-cnt");
100        }
101      });
102
103    //обработчик кнопки закрытия модального окна
104    $(document).on('click', '.modal-close', function(e){
105        e.preventDefault();
106        $.modal().close();
107    });
108
109    $(document).on('focus', 'input.mask-phone', function(){
110        $(this).inputmask("mask", {"mask": "+7 (999) 999-99-999" });
111    });
112
113
114    //$('input.mask-phone').inputmask("mask", {"mask": "+7 (999) 999-99-99"});
115
116
117    /*-----SCROLS-------*/
118
119
120    /*-----SCROLS-------*/
121
122    $.fn.changeContent=function(target, target_global, e){
123        e.preventDefault();
124        $('.'+target_global).hide();
125        $('.'+target).show();
126        $('.content-check-btn').removeClass('active');
127        $(this).addClass('active');
128        return false;
129    };
130
131
132
133    $('.cmi-show-all > a').click(function(e){
134        e.preventDefault();
135        $(this).parent('li').siblings("li.cmi-hide-row").show('fast');
136        $(this).parent('li').hide('fast');
137
138    });
139
140
141
142    $(function(){
143        $(window).scroll(function () {
144            /*if ($(this).scrollTop() > 200) {
145                $('.scroll-top').fadeIn();
146            } else {
147                $('.scroll-top').fadeOut();
148            }*/
149
150            if ($(this).scrollTop() > 200 && !$('.header-menu-line').hasClass("hover-line-fix")) {
151
152                $('.header-menu-line').addClass("hover-line-fix");
153            }else if($(this).scrollTop() <= 200) {
154                $('.header-menu-line').removeClass("hover-line-fix");
155            }
156        });
157
158        $('.scroll-top a').click(function () {
159            $('body,html').animate({
160                scrollTop: 0
161            }, 800);
162            return false;
163        });
164
165    });
166
167    $('.js-goods-count').change(function(){
168        let minQty =  $(this).attr('data-min-qty') * 1;
169        let val = $(this).val() * 1;
170        val = !parseInt(val) ? minQty : val;
171
172        val_result = val < minQty ? minQty : val;
173
174        $(this).val(val_result);
175
176    })
177
178    $('.count_basket').change(function(){
179        let minQty =  $(this).attr('data-min-qty') * 1;
180        let val = $(this).val() * 1;
181        val = !parseInt(val) ? minQty : val;
182
183        val_result = val < minQty ? minQty : val;
184
185        $(this).val(val_result);
186
187    })
188
189    $.fn.addCartCount=function(obj, count){
190        var val=$('.'+obj).val() || 0;
191        val=val*1+count;
192        if(val<=0) val=Math.abs(0);
193        
194        let minQty =  $('.'+obj).attr('data-min-qty') * 1;
195        //console.log(minQty);
196
197        if(val % 1 == 0) {
198            var val_result = val.toFixed(0);
199        }else{
200            var decimail_len=getDecimal(val).toString().length;
201            if(decimail_len>3) {
202                var val_result = val.toFixed(3);
203            }else{
204                var val_result = val;
205            }
206        }
207
208        //console.log(minQty);
209
210        val_result = val_result*1 < minQty ? minQty : val_result;
211
212        $('.'+obj).val(val_result);
213
214    };
215
216    function getDecimal(num) {
217        var str = "" + num;
218        var zeroPos = str.indexOf(".");
219        if (zeroPos == -1) return 0;
220        str = str.slice(zeroPos);
221        return +str;
222    }
223
224    if($("a").is(".fancybox")) {
225        $("a.fancybox").fancybox({
226            openEffect: 'none',
227            closeEffect: 'none',
228
229            prevEffect: 'none',
230            nextEffect: 'none',
231
232            closeBtn: true,
233
234            helpers: {
235                title: {
236                    type: 'inside'
237                },
238                buttons: {}
239            },
240
241            afterLoad: function () {
242                this.title = '<span id="fancybox-title-over"> ' + (this.index + 1) + ' из ' + this.group.length + (this.title ? ' - ' + this.title : '</span>');
243            }
244
245        });
246    }
247
248    $.fn.pushOrderDL=function (e) {
249
250        $.ajax({
251            type: "POST", //Тип запроса
252            dataType: "json", //Тип данных
253            url: "/yatagorder/push/", //Адрес подгружаемой страницы
254            success: function(response){
255                if(response.return){
256                    dataLayer.push({
257                        'ecommerce' : {
258                            'purchase' : {
259                                'actionField' : {
260                                    'id' : response.order_id,
261                                    'revenue' :response.sum
262                                },
263                                'products' : response.products,
264                            }
265                        },
266                        'event': 'gtm-ee-event',
267                        'gtm-ee-event-category': 'Enhanced Ecommerce',
268                        'gtm-ee-event-action': 'Purchase',
269                        'gtm-ee-event-non-interaction': 'False'
270
271                    });
272                }
273            },
274            complete: function () {
275                $('.sendOrderForm').submit();
276            }
277        })
278
279    };
280
281    $(".addToCartForm").submit(function() {
282        //console.log($(this).serialize());
283        $.ajax({
284            type: "POST", //Тип запроса
285            dataType: "json", //Тип данных
286            url: "/cart/add/", //Адрес подгружаемой страницы
287            data: $(this).serialize(),
288            success: function(response){
289                if(!response.return){
290
291                    swal({
292                        title: "Не выбран товар!",
293                        text: "Не указано количество товара",
294                        imageUrl: "/images/how-cart-info-3.jpg",
295                        confirmButtonText: "Вернуться в выбору",
296                        confirmButtonColor:'#ff0000'
297                    });
298                    return false;
299                }else{
300                    if(response.cart_count==1){
301
302                        $('.header-cart-info').html('<span class="cart-info-count">'+response.cart_count+'</span> тов. на <span class="cart-info-sum">'+response.cart_summ+'</span> руб.');
303                        $('.header-cart-title').replaceWith('<a href="/cart/" class="header-cart-title">В заказе</a>');
304                        $('.header-cart-count').html(response.cart_count);
305                    }else {
306                        $('.cart-info-count').html(response.cart_count);
307                        $('.cart-info-sum').html(response.cart_summ);
308                        $('.header-cart-count').html(response.cart_count);
309                    }
310
311                    /*$.each( response.goods_id, function( key, value ) {
312                        alert( key + ": " + value );
313                    });*/
314                    //$('.goods-id-cart-form-'+response.goods_id).html('В корзине. <a href="/cart/" class="green-link">Оформить заказ</a>');
315
316                    var param= {
317                        goods_id :  response.goods_id
318                    };
319
320
321                    /*$('#goods_action_info_win').jqm({
322                        modal: true,
323                        target: 'div.goodsActionInfoContent',
324                        ajax: '/cart/info/?'+$.param(param)
325                    }).jqmAddTrigger($(this)).jqmShow();
326                    */
327
328                    $('.overlay-win').modal().open({
329                        closeOnOverlayClick:true,
330                        onOpen: function (el) {
331                            //console.log($.param(param));
332                            $.get('/cart/info/?'+$.param(param), function (data) {
333                                el.find('.overlay-win_container').html(data);
334                            });
335
336                        }
337
338                    });
339
340                    //console.log(response);
341                    dataLayer.push({
342                        'ecommerce' : {
343                            'add' : { // remove для удаления товара из корзины
344                                'products' : response.goods_info
345                            },
346                        'event': 'gtm-ee-event',
347                        'gtm-ee-event-category': 'Enhanced Ecommerce',
348                        'gtm-ee-event-action': 'Adding a Product to a Shopping Cart',
349                        'gtm-ee-event-non-interaction': 'False',
350                        }
351                    });
352                }
353
354            }
355        });
356
357        return false;
358    });
359
360    $.fn.removeTagManCart=function () {
361
362        dataLayer.push({
363            'ecommerce' : {
364                'remove' : { //  для удаления товара из корзины
365                    'products' : [
366                        {
367                            'name' : $(this).data('name'), // обязательное
368                            'id' : $(this).data('goods-id'), // обязательное
369                            'price' : $(this).data('price'),
370                            'variant' : $(this).data('variant'),
371                            'quantity': $('#count_'+$(this).data('goods-id')).val()
372                        }
373                    ]
374                }
375            },
376            'event': 'gtm-ee-event',
377            'gtm-ee-event-category': 'Enhanced Ecommerce',
378            'gtm-ee-event-action': 'Removing a Product from a Shopping Cart',
379            'gtm-ee-event-non-interaction': 'False',
380        });
381        //alert('hh');
382        //return false;
383    };
384
385    $('.showFastOrderWin').click(function () {
386
387        var goods_id=$(this).attr('goods_id');
388        var count=1;
389        //$('#gcount'+goods_id).val();
390
391        var url='/fast_order/?id='+goods_id+'&count='+count;
392
393        $('.overlay-win').modal().open({
394            closeOnOverlayClick:true,
395            onOpen: function (el) {
396                $.get(url, function (data) {
397                    el.find('.overlay-win_container').html(data);
398                });
399
400            }
401
402        });
403
404
405    });
406
407    $.fn.submitForm=function(form_name){
408        $('form[name='+form_name+']').submit();
409
410    };
411
412    $('.showCallBackWin').click(function () {
413        var url='/callback/';
414
415        $('.overlay-win').modal().open({
416            closeOnOverlayClick:true,
417            onOpen: function (el) {
418                $.get(url, function (data) {
419                    el.find('.overlay-win_container').html(data);
420                });
421
422            }
423
424        });
425
426    });
427
428
429    $.fn.setTabRegionHash=function (hash) {
430        $('.cs-tab-item').removeClass('is-active');
431        $('.cs-tab-'+hash).addClass('is-active');
432        $('.cs-tab-cont').hide();
433        $('.cs-tab-cont-'+hash).show();
434    }
435
436    $(this).setTabRegionHash(location.hash.replace('#',''));
437
438
439    window.addEventListener('hashchange', function(e) {
440        $(this).setTabRegionHash(location.hash.replace('#',''));
441    });
442
443    
444
445    $('.js-pvariant').click(function(){
446        //console.log('sd');
447        if(!$(this).hasClass('active')){
448            var product_id = $(this).data('general-id'),
449                variant_id=$(this).data('id'),
450                cur_price = $(this).data('price'),
451                minQty = $(this).data('min-qty') * 1,
452                metric_name = $(this).data('metric-name'),
453                count_obj = $('.cart-item-count-' + product_id),
454                inpCount = $('.js-goods-count.gcount_'+product_id),
455                count = count_obj.val(),
456                set_price = cur_price;
457
458            $('.js-cart-goods-id').val(variant_id);
459
460            $('.js-goods-count').attr('name', 'goods['+variant_id+']');
461
462            if($(this).data('price-old')!=''){
463                if (!$('.js-old-price').hasClass('is-hide')) $('.js-old-price').removeClass('is-hide');
464                $('.js-old-price').html($(this).data('price-old'));
465            }else{
466                $('.js-old-price').addClass('is-hide');
467            }
468
469            $('.js-cur-price').html(set_price);
470            $('.js-metric-name').html(metric_name);
471
472            $(inpCount).attr('data-min-qty', minQty);
473
474            if($(inpCount).val()*1 < minQty) {
475                $(inpCount).val(minQty);
476            }
477            console.log(minQty);
478            console.log(inpCount);
479            
480
481            //$('.js-goods-count').attr('name', 'goods['+variant_id+']');
482            
483
484            $('.js-pvariant').removeClass('is-active');
485            $(this).addClass('is-active');
486
487            /*
488            if (sale_rules != null) {
489                $.each(sale_rules, function (i, val) {
490                    if (Math.floor(count) >= val['c']) {
491                        //alert(cart_item_count_new+'>='+val['c']);
492                        set_price = Math.round(cur_price - ((cur_price / 100) * val['v']));
493                    }
494                });
495            }
496
497            
498            $('.metric-name-' + product_id).html(metric_name);
499
500
501            $('.variantChange').removeClass('active');
502            $(this).addClass('active');
503            */
504        }
505    })
506
507    $('.cs-tab-item').click(function () {
508       $('.cs-tab-item').removeClass('is-active');
509        $(this).addClass('is-active');
510        $('.cs-tab-cont').hide();
511        $('.'+$(this).data('target')).show();
512    });
513
514    $('.js-variant-1:not(.is-disabled)').click(function(){
515        var v2arr=$(this).data('access_p');
516        //console.log(v2arr);
517        $('.js-variant-1').removeClass('is-active');
518        if(!$(this).hasClass('is-active')) {
519            $(this).addClass('is-active');
520        }
521        
522        $('.js-variant-2').each(function(i,elem){
523            //$(elem).hide();
524            //console.log($.inArray('dd', v2arr ));
525            if($.inArray($(elem).data('value'), v2arr )!== -1 ){
526                $(elem).removeClass('is-disabled');
527            }else{
528                $(elem).addClass('is-disabled');
529                $(elem).removeClass('is-active');
530            }
531        });
532
533        $(this).getVariantId();
534        
535
536        // $.each(v2arr,function(index,value){
537        //     //console.log('Индекс: ' + index + '; Значение: ' + value);  
538        // });
539    })
540
541    $.fn.getVariantId=function(){
542        var param_val_1=$('.js-variant-1.is-active').data('value'),
543            param_val_2=$('.js-variant-2.is-active').data('value'),
544            search_key='v_'+param_val_1+'_'+param_val_2,
545            variant_info=$('.js-cart-btn').data('variant_info');
546
547            // console.log( $('.js-cart-btn').data('variant_info'));
548            // console.log(search_key);
549            if(variant_info[search_key]){
550                //console.log(variant_info[search_key]);
551                $('.js-cart-goods-id').val(variant_info[search_key]['id']);
552                $('.js-goods-count').attr('name', 'goods['+variant_info[search_key]['id']+']');
553                $('.js-cart-btn').removeClass('is-disabled');
554                $('.js-cur-price').html(variant_info[search_key]['cur_price']);
555                $('.js-metric-name').html(variant_info[search_key]['metric_name']);
556                $('.js-price-comment').html(variant_info[search_key]['price_comment']);
557                
558                if(variant_info[search_key]['old_price']!=null){
559                    $('.js-old-price').removeClass('is-hide').html(variant_info[search_key]['old_price']);
560                }else{
561                    $('.js-old-price').addClass('is-hide');
562                }
563                
564            }else{
565                $('.js-cart-btn').addClass('is-disabled');
566            }
567            // $.each(variant_info, function( key, value ) {
568
569            //     // действия, которые будут выполняться для каждого свойства объекта
570            //     // key - текущее имя свойства массива
571            //     // value - значение текущего свойства объекта
572               
573            //     // выведем имя свойства и его значение в консоль
574            //     console.log( 'Свойство: ' +key + '; Значение: ' + value );
575              
576            //   });
577        //console.log(variant_info['v_144_146']);
578
579
580        
581
582    }
583
584
585    $('.js-variant-2:not(.is-disabled)').click(function(){
586        $('.js-variant-2').removeClass('is-active');
587        if(!$(this).hasClass('is-active')) {
588            $(this).addClass('is-active');
589        }
590
591        $(this).getVariantId();
592    });
593
594
595
596    /*-----FORM-------*/
597    $(document).on('submit', 'form', function(event){
598        //console.log(form_name);
599        var form=$(this),
600            form_name=$(this).data('form-name'),
601            is_valid=form.validateForm();
602
603
604    
605        if(!is_valid && $('.popup').length==0){
606            $('html, body').animate({ scrollTop: $(form).offset().top-200 }, 500);
607        }
608        return is_valid;
609    });
610
611    //вешаем обработчик валидации ввода на поля у которых есть ошибка
612    $(document).on('keyup', 'input.js-valid-error[type=text]', function(){
613        $(this).checkValidField();
614    });
615    
616    $(document).on('click', '.js-form-submit', function () {
617        //console.log('dd');
618        $('form[name='+($(this).data('form-name'))+']').submit();
619
620     });
621
622    $.fn.validateForm=function(){
623        var count_validate_true= 0, // счетчки сколько полей true
624            count_validate= 0,
625            form_obj=$(this);
626
627        $(this).find('input[required], textarea[required]').each(function(n,element){
628            count_validate++;
629            //проверяем валидацию
630            if($(this).checkValidField()){
631                //если пройдена увеличиваем счетчикж
632                count_validate_true++;
633            }else{
634                // если не пройдена ставим метку об ошибке по которой будет работать keyup
635                $(this).addClass('js-valid-error');
636            }
637        });
638
639        return count_validate_true==count_validate ? true : false;
640
641    };
642
643    $.fn.checkValidField=function(){
644        var return_value=false,
645            form_valid=$(this).data('form-valid'),
646            element_value= $.trim($(this).val());
647
648        if(element_value==''){
649            $(this).validErrrorMsg('Это поле должно быть заполнено');
650
651        }else if (
652            form_valid=='first_name'
653            &&
654            element_value.search('^[А-ЯЁа-яёA-Za-z\\-]+$', 'i') == -1
655        ) {
656            $(this).validErrrorMsg('Не корректные символы. Допустимы только буквы и -');
657        }else if (
658            form_valid=='full_name'
659            &&
660            element_value.search('^[А-ЯЁа-яёA-Za-z\\-\\s]+$', 'i') == -1
661        ) {
662            $(this).validErrrorMsg('Не корректные символы. Допустимы только буквы, пробелы и -');
663        }else if(
664            form_valid=='phone'
665            &&
666            element_value.replace(/[^0-9]/gim,'').search('^[0-9]{11}$', 'i') == -1
667        ){
668            $(this).validErrrorMsg('Введите номер в формате +7 (999) 999-99-99');
669        }else if(
670            form_valid=='email'
671            &&
672            element_value.search('^[-\\w\\.]+@[-\\w\\.]+\\.[-\\w]+$') == -1
673        ){
674            $(this).validErrrorMsg('Пожалуйста укажите дйствующую электронную почту в формате [email protected]');
675        }else{
676            $(this).validErrrorMsg('');
677            return_value=true;
678        }
679        return return_value;
680    };
681
682    $.fn.validErrrorMsg=function(msg){
683        var erro_container=$('<div/>',{ class: 'field-valid-msg'});
684        if( !$(this).next('div').is('.field-valid-msg') ){
685            $(this).after(erro_container.html(msg));
686        }else{
687            $(this).next('.field-valid-msg').html(msg);
688        }
689    };
690
691    /*----END FORM----*/
692
693});
694
695
696
697
698

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.