PageSourceSearch

https://pharmamex.com.mx/includes/javascript/init.js

js pharmamex.com.mx collected 2026-10-04 02:39:46 UTC 46,027 bytes, 1,126 lines download raw bytes

1"use strict";
2var initSlider;
3jQuery(document).ready(function() {
4
5    $('.input-type-number-custom').on('keyup focus', (event) => {
6        let select = $(event.currentTarget);
7        select.val(select.val().replace(/[^0-9]/gi,''));
8    });
9
10
11    $(".product-carousel-video").click(function (e) {
12        this.pause();
13    });
14    $(document).on('input','form[name="create_account"] input[type="text"]',function(){
15        $(this).val($(this).val().replace(/(<([^>]+)>)/ig,"")); //striptags
16    });
17    //lazyload
18    $(".lazyload").lazyload();//.addClass('anim');
19    //$(".product img").unveil();
20    //$(".product_list img").unveil();
21    setTimeout(function(){
22        if(typeof $.fn.unveil != 'undefined') {
23            $(".row_catalog_products .owl-item.active img").unveil(100, addAnimClassToImg);//for active slider elements
24            $(".row_catalog_products .not-slider img").unveil(100, addAnimClassToImg);//for no slider elements
25            $("#sidebar-left .row_catalog_products img").unveil(100, addAnimClassToImg); // show images in left colunm
26        }
27    },500);
28
29    $('#loadMoreProducts').click(function () {
30        loadMoreProducts();
31    });
32    $(document).on('click', '.ch_link', function(event) {
33        hs.expand(this);
34        return false;
35    });
36    $('.container_top_header .buy_one_click').click(function(event) {
37        doHookie('callback');
38    });
39    $('.prod_buy_btns .buy_one_click').click(function(event) {
40        doHookie('fast_buy');
41    });
42    $('.buy_one_click').click(function(event) {
43        var $modal = null;
44        $.post('./ajax.php', {
45            request: 'getBuyOnClickForm'
46        }, function(data) {
47            modal({
48                id: 'QuickBuy',
49                body: data.html,
50                render: true,
51                after: function(modal) {
52                    $modal = modal;
53
54                }
55            });
56
57            $('#QuickBuyForm').on('submit', function(event) {
58                event.preventDefault();
59
60                var $data = $('#QuickBuyForm,#products_id').serialize();
61                $data += '&prod_price_uah=' + $('.productSpecialPrice').text();
62                $data += '&model=' + $('.art_card_product').text();
63                $.post('./ajax.php', $data, function(data, textStatus, xhr) {
64
65                    if (data.success) {
66                        $('#QuickBuyForm').html(data.message);
67
68                    } else {
69                        alert('Send error!');
70                    }
71                }, 'json');
72            });
73
74        }, 'json');
75        return false;
76    });
77
78    $(document).on('click','.sidebar-toggle-back, .sidebar_fader',function(event) {
79        event.stopPropagation();
80        var $button = jQuery('.sidebar-toggle-back');
81        // $('.sidebar_fader').fadeOut(300);
82        $('.sidebar_fader').removeClass('open');
83        jQuery('#sidebar-left').toggleClass('opened');
84        $button.removeClass('visible-xs').removeClass('visible-sm');
85        $button.addClass('hidden-xs').addClass('hidden-sm');
86        jQuery('#sidebar-left').unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd");
87
88    });
89    $(document).on('click', '.sidebar-toggle-up', function(event) {
90        event.stopPropagation();
91        var $button = $('.sidebar-toggle-back');
92        // $('.sidebar_fader').fadeIn(300);
93        $('.sidebar_fader').addClass('open');
94        jQuery('#sidebar-left').toggleClass('opened');
95        jQuery('#sidebar-left').on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function() {
96            $button.removeClass('hidden-xs').removeClass('hidden-sm');
97            $button.addClass('visible-xs').addClass('visible-sm');
98        });
99
100    });
101
102    // when click on "reviews" it opens for us "reviews" tab
103    $(document).on('click','.quantity_rating', function(e) {
104        e.preventDefault();
105        $('.nav-tabs a[href="#tab-comments"]').tab('show');
106    });
107
108    // show share popup windows
109    $('.share_with_friends a, .social_group_footer a, .social_buttons a').click(function(e) {
110        e.preventDefault();
111        showLoginvk($(this).attr('href'));
112    });
113
114    $('.nav-tabs a').click(function(e) {
115        e.preventDefault();
116        $(this).tab('show')
117    });
118    
119
120    $('#cat_accordion').cutomAccordion({
121        classExpand : "custom_id"+$('input[name=current_hidden_cat_id]').val(),
122        menuClose: false,
123        autoClose: true,
124        saveState: false,
125        disableLink: false,
126        autoExpand: true
127    });
128    $('#left_cat_accordion').cutomAccordion({
129        classExpand : "custom_id"+$('input[name=current_hidden_cat_id]').val(),
130        menuClose: false,
131        autoClose: false,
132        saveState: false,
133        disableLink: false,
134        autoExpand: true
135    });
136
137    /*
138     $(document).on("shown.bs.collapse shown.bs.tab", ".panel-collapse, a[data-toggle='tab']", function(e) {
139     var $elOffset_top = $(e.target).parent('.panel').offset().top;
140     jQuery('body,html').stop(false, false).animate({
141     scrollTop: $elOffset_top
142     }, {
143     duration: 600,
144     easing: 'swing'
145     }, 800);
146     });
147     */
148
149    if($(window).width()>'768') $('.categories_menu ul').superfish();
150
151    jQuery('#slider_product a').click(function(e) {
152        if (jQuery(this).is('.active')) {
153            e.preventDefault();
154            return false;
155        } else {
156            jQuery('#slider_product a').removeClass('active');
157            jQuery(this).addClass('active');
158        }
159    });
160
161    if(typeof $.fn.owlCarousel != 'undefined'){
162        $("#sync1").owlCarousel({
163            items: 1,
164            loop: true,
165            dots: true,
166            slideSpeed: 200,
167            nav: true,
168            navText: ['<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"></path></svg>', '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg>'],
169            dotsContainer: '#sync2',
170            responsiveRefreshRate: 200,
171            onTranslated: function () {
172                var images = this.$element.find('.lazyload');
173                if(images.length) {
174                    this.$element.find('.lazyload').lazyload();
175                }
176            }
177        });
178    }
179
180    /*$("#owl-frontslider").owlCarousel({
181        items: 1,
182        nav: true,
183        lazyLoad: true,
184        loop:true,
185        video:true,
186        navText:['<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"></path></svg>','<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg>'],
187        autoplay:true,
188        autoplayTimeout:5000,
189        dotsContainer: '#carousel-custom-dots',
190        autoplayHoverPause:true,
191        smartSpeed: 2000,
192        onInitialized:function () {$(".owl-carousel, .single_slide").removeAttr('style');$(".active .owl-video-play-icon").trigger("click");}, // autoplay video on slider load
193        onTranslated:function () {$(".active .owl-video-play-icon").trigger("click");} // autoplay video on change slide
194
195    });*/
196    // custom dots:
197    if(typeof $.fn.owlCarousel != 'undefined') {
198        $("#manufacturers > div").owlCarousel({
199            items:  window.manufacturersCarouselCols? window.manufacturersCarouselCols:4,
200            itemsDesktop : window.manufacturersCarouselCols? window.manufacturersCarouselCols:4, 
201            itemsDesktopSmall : window.manufacturersCarouselCols? window.manufacturersCarouselCols:4, 
202            itemsTablet: window.manufacturersCarouselCols? window.manufacturersCarouselCols:4, 
203            itemsMobile :  window.manufacturersCarouselCols? window.manufacturersCarouselCols:4,
204            nav: true,
205            dots: false,
206            loop: true,
207            navText: ['<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"></path></svg>', '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522
207-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg>'],
208            slideSpeed: 200,
209        });
210    }
211    if(typeof $.fn.unveil != 'undefined') {
212        $("#manufacturers > div img").unveil(100, addAnimClassToImg);
213    }
214    $('.owl-carousel img').lazyload();
215    /* ---------  END Additional images --------- */
216
217    /* ---------  Shopping cart --------- */
218    jQuery('body').on('submit', 'form[name="cart_quantity"]', function(event) {
219        event.preventDefault();
220        doAddProduct(this);
221    });
222
223    jQuery('body').on('submit', 'form[name="modal_cart_quantity"]', function(event) {
224        event.preventDefault();
225        $.post('./popup_cart.php?action=update_product', {'products_id[]':jQuery(this).find('[name="products_id"]').val(),'cart_quantity[]':jQuery(this).find('#modal_qty_input').val()}, function(response) {
226            showPopupResponse(response)
227        })
228    });
229
230    // add to cart in product listing
231    jQuery('body').on('click', '.add2cart', function(event) {
232        doAddProductList($(this));
233    });
234
235    jQuery('body').on('click', '#checkoutButton', function(event) {
236        event.preventDefault();
237        var href = jQuery(this).attr('href');
238        jQuery("#popup_cart_form").ajaxSubmit({
239            // target: '#modal_cart_popup .modal-body',
240            success: function() {
241                showPopupResponse();
242                window.location.href = href;
243            }
244        });
245        /*var options={target:'#modal_cart_popup .modal-body', detailhref:href};
246         ajaxSubmitSerializePopup (options);*/
247    });
248    jQuery('body').on('focus', 'input[name="cart_quantity[]"]', function(event) {
249        $(this).parent().next('.ok').fadeIn();
250    });
251    jQuery('body').on('click', '#popup_cart_form .ok', function(event) {
252        jQuery("#popup_cart_form").ajaxSubmit({
253            // target: '#modal_cart_popup .modal-body',
254            success: showPopupResponse
255        });
256        var inputNumber = jQuery(this).siblings('.input-group').find('.inputnumber');
257        inputNumber.val(Math.round(inputNumber.val()));
258        var btnOk = $('#cartContent-page .btn.ok');
259        for (var i = 0; i<btnOk.length; i++) {
260            btnOk[i].style.display = 'none';
261        }
262        //var options={target:'#modal_cart_popup .modal-body'};
263        //ajaxSubmitSerializePopup (options);
264    });
265
266    //by Demo2
267    jQuery(document).on('shown.bs.dropdown','#divShoppingCard', function(event) {
268        event.preventDefault();
269        $.get('./popup_cart.php',null,function(response) {
270            $('#new_basked_block').html(response);
271        });
272    });
273    //by Demo2
274    jQuery(document).on('change', '#new_basked_block input[name="cart_quantity[]"]', function(event) {
275        jQuery("#popup_cart_form").ajaxSubmit({
276            target: '#new_basked_block',
277            success: function(){
278                $.post('./ajax_update_cart.php','', function(data) {
279                    $('.quantity_basket,.mobile_cart_count').html(data.cart_count);
280                    $.get('./popup_cart.php',null,function(response) {
281                        $('#new_basked_block').html(response);
282                    });
283                },'json');
284            }
285        });
286    });
287
288    jQuery('body').on('click', '#popup_cart_form .delete', function(event) {
289        //	jQuery("#cart_delete" + jQuery(this).val()).attr('checked', 'checked');
290        $(this).parent().find($('input[name="cart_delete[]"]')).attr('checked', 'checked');
291        if (jQuery("#popup_cart_form .delete").length == 1) { // if there is only one element, hide other element in shopping cart
292            jQuery("#popup_cart_form").animate({
293                opacity: 0
294            }, 200, function() { // fadeout of deleted element
295                jQuery("#modal_cart_popup .modal-body").animate({
296                    height: jQuery("#modal_cart_popup .modal-body").height() - 163
297                }, 200, function() { // fadeout of deleted element
298                    jQuery("#popup_cart_form").ajaxSubmit({
299                        target: '#modal_cart_popup .modal-body',
300                        success: showPopupResponse
301                    }); // submit form
302                    //var options={target:'#modal_cart_popup .modal-body'};
303                    //ajaxSubmitSerializePopup (options);
304                });
305            });
306        } else {
307            var skipTemplates = [
308                'gadgetorio',
309                'solo_cellphones',
310                'solo_health'
311            ];
312            jQuery('#popup_cart_form .delete').attr('disabled', true);
313            jQuery(this).parent().parent().parent().parent().slideUp(200, function() { // fadeout of deleted element
314                if (jQuery.inArray(TEMPLATE_NAME, skipTemplates) != -1) {
315                    jQuery("#popup_cart_form").ajaxSubmit({
316                        target: '#modal_cart_popup .modal-body',
317                        success: showPopupResponse
318                    }); // submit form
319                } else {
320                    jQuery("#popup_cart_form").ajaxSubmit({
321                        // target: '#modal_cart_popup .modal-body',
322                        success: showPopupResponse
323                    }); // submit form
324                    jQuery(this).remove();
325                }
326                //var options={target:'#modal_cart_popup .modal-body'};
327                //ajaxSubmitSerializePopup (options);
328            });
329        }
330        var _vall = $(this).attr('data-clearpid');
331
332        $('.added2cart[data-id='+_vall+']').replaceWith(sprintf(RTPL_ADD_TO_CART_BUTTON, _vall));
333        $("#r_buy_intovar[data-id="+_vall+"]").html(RTPL_ADD_TO_CART_BUTTON_PRODUCT_PAGE); // replace button in product info page.
334
335    });
336
337    /* ---------  Shopping cart --------- */
338
339    /* ---------  Subscribe --------- */
340    jQuery(document).on('submit', '.form_subscribe_news', function(event) {
341        event.preventDefault();
342        doHookie('subscribe');
343        var this_form = $(this);
344
345        $.post($(this).attr('action'), $(this).serialize(), function(response) {
346            this_form.trigger("reset"); // обнуляем поля
347            modal({
348                id: 'subscribe',
349                body: response.message,
350                render: true,
351                after: function(modal) {
352                    setTimeout(function() {
353                        modal.modal('hide');
354                    }, 3500);
355                }
356            });
357        },'json');
358        /* Act on the event */
359    });
360
361    /* ---------  Popups --------- */
362    jQuery(document).on('submit', '[name="contact_us"]', function(event) {
363        event.preventDefault();
364        doHookie('contact_us');
365        var this_form = $(this);
366        // Sending email
367        $.post($(this).attr('action'), $(this).serialize(), function(response) {
368            if(response.status!='fail') {
369                this_form.trigger("reset");
370                if (typeof grecaptcha === 'object'){
371                    grecaptcha.reset();
372                }
373            } // reset all fields
374            modal({
375                id: 'ContactUs',
376                body: response.msg,
377                render: true,
378                after: function(modal) {
379                    /*   setTimeout(function() {
380                           modal.modal('hide');
381                       }, 3500);  */
382                }
383            });
384        },'json');
385        /* Act on the event */
386    });
387
388
389    jQuery('body').on('click touchstart', '.popup_cart', function(event) {
390        event.preventDefault();
391        if($('[data-dismiss="modal"]')){
392            $('[data-dismiss="modal"]').click();
393            setTimeout(function() {
394                showCartpopup();
395            }, 300);
396        }else{
397            showCartpopup();
398        }
399    });
400
401    jQuery('.call_us_btn').click(function(e) {
402        e.preventDefault();
403        pop_contact_us();
404    });
405
406    $('#user-login-dropdown .dropdown-menu').on('click', function(event){
407        event.stopPropagation();
408    });
409
410    /* --------- End Popups --------- */
411
412    $(document).ready(function() {
413
414        if ($(window).width() > 768) {
415            $('[data-toggle="tooltip"]').tooltip({
416                container: 'body'
417            });
418        }
419
420        jQuery('body').on('click', '.show_search_form', function () {
421            openSearchForm();
422        });
423
424        $(document).on('click', '#search-form-button-close, #search-form-button-close1', function () {
425            closeSearchForm();
426        });
427
428        $(document).on('click', '#search-form-fader', function () {
429            closeSearchForm();
430        });
431
432
433        $(window).on("scroll", function () {
434            // adding shadow to header when scrolling
435            var stickyPosition = Math.abs(parseInt($('header').css('top'), 10));
436
437            if ($(this).scrollTop() > stickyPosition) {
438                $('header').addClass('header_shadow');
439
440            } else {
441                $('header').removeClass('header_shadow');
442            }
443        });
444
445        $('.hover .dropdown-menu').on("click", function (e) {
446            e.stopPropagation();
447            // e.preventDefault();
448        });
449
450        if ($(window).width() >= 992) {
451            $("#user-login-dropdown")
452            // on #user-login-dropdown hovered
453                .mouseenter(function () {
454                    // opens dropdown on hover
455                    // $(this).addClass('open');
456                })
457                // on #user-login-dropdown unhovered
458                .mouseleave(function () {
459                    // closes dropdown on hover
460                    // $(this).removeClass('open');
461                });
462
463
464            $(".dropdown-hover")
465            // on #header-megamenu hovered
466                .mouseenter(function () {
467                    // opens dropdown on hover
468                    $(this).addClass('open');
469                })
470                // on #header-megamenu unhovered
471                .mouseleave(function () {
472                    // closes dropdown on hover
473                    $(this).removeClass('open');
474                });
475        }
476
477        $(".dropdown-submenu a.submenu")
478        // hover on button to open submenu
479            .mouseenter(function() {
480                var headerHeight = Math.abs(parseInt($('header').css('height'), 10));
481                var menuHeight = Math.abs(parseInt($('.add_nav').css('height'), 10));
482
483                // if submenu exists add class .hover for visible effect
484                $(this).parent('li').addClass('hover');
485
486                // when scrolling with opened .submenu
487                $(window).on("scroll", function() {
488                    var windowsScrolled = $(this).scrollTop();
489
490                    // if scrolled less than 164px from top, then change top: value for .dropdown-menu inside .submenu
491                    if ($(this).scrollTop() < 164) {
492                        $('li.hover .dropdown-menu').css({
493                            'top': headerHeight-windowsScrolled+'px'
494                        });
495                        // else set top: value 51px for .dropdown-menu inside .submenu
496                    } else {
497                        $('li.hover .dropdown-menu').css({
498                            'top': '51px'
499                        });
500                    }
501                });
502            })
503
504            // leave mouse from button (that opens submenu) to any direction
505            .mouseleave(function() {
506                $('.dropdown-submenu')
507                // hover mouse on .submenu
508                    .mouseenter(function() {
509                        // removes class .hover when left not to parent button
510                        $(this).siblings('li.hover').removeClass('hover');
511                    });
512            });
513
514
515
516        // delete in two weeks (22.02.19)
517        // $(".dropdown-submenu a.submenu")
518        // // hover on button to open submenu
519        //     .mouseenter(function() {
520        //         var headerHeight = Math.abs(parseInt($('header').css('height'), 10));
521        //         var menuHeight = Math.abs(parseInt($('.add_nav').css('height'), 10));
522        //
523        //         // if submenu exists add class .hover for visible effect
524        //         // $(this).parent('li').addClass('hover');
525        //
526        //         // getting padding-left: of bootstrap class .container
527        //         var pageContainerPaddingLeft =  Math.abs(parseInt($('.container').css('padding-left'), 10));
528        //
529        //         // getting margin-left: of bootstrap class .container
530        //         var pageContainerMarginLeft =  Math.abs(parseInt($('.container').css('margin-left'), 10));
531        //
532        //         // getting width: of .dropdown-menu when opened
533        //         var menuWidth = Math.abs(parseInt($('.dropdown .dropdown-menu').css('width'), 10));
534        //
535        //         // summing padding-left: (.container), margin left (.container) and .dropdown-menu width
536        //         var dropDownMenuLeft = menuWidth+pageContainerMarginLeft+pageContainerPaddingLeft-1;
537        //
538        //         $(this).siblings('.dropdown-menu').css('left', dropDownMenuLeft+'px');
539        //
540        //         if ($(window).scrollTop() >= 164) {
541        //             $(this).siblings('.dropdown-menu').css('top', '51px');
542        //         } else {
543        //             $(this).siblings('.dropdown-menu').css('top', headerHeight+'px');
544        //         }
545        //
546        //         // when scrolling with opened .submenu
547        //         $(window).on("scroll", function() {
548        //             var windowsScrolled = $(this).scrollTop();
549        //
550        //             // if scrolled less than 164px from top, then change top: value for .dropdown-menu inside .submenu
551        //             if ($(this).scrollTop() < 164) {
552        //                 $('li.hover .dropdown-menu').css({
553        //                     'top': headerHeight-windowsScrolled+'px'
554        //                 });
555        //                 // else set top: value 51px for .dropdown-menu inside .submenu
556        //             } else {
557        //                 $('li.hover .dropdown-menu').css({
558        //                     'top': '51px'
559        //                 });
560        //             }
561        //         });
562        //     })
563        //
564        //     // leave mouse from button (that opens submenu) to any direction
565        //     .mouseleave(function() {
566        //         $('.dropdown-submenu')
567        //         // hover mouse on .submenu
568        //             .mouseenter(function() {
569        //                 // removes class .hover when left not to parent button
570        //                 $(this).siblings('li.hover').removeClass('hover');
571        //             });
572        //     });
573
574    });
575
576    $('#pdf_block span.btn-link').click(function(){
577        window.open($(this).data('href'));
578        return false;
579    });
580
581
582    /* ---------   attr_select --------- */
583
584
585    $(function() {
586
587        //  calculate_sum($('.select_id_option:first :selected'));
588        calculate_sum($('.select_id_option:first'));
589
590        $(document).on('change', '.select_id_option', function(e) {
591            if ($(this).hasClass('select_attr_img')){
592                var selected_op = this.options[e.target.selectedIndex];
593            }else {
594                var selectizeLoc = this.selectize;
595                var selected_op = selectizeLoc.$input[0].selectedOptions[0];
596                selected_op.setAttribute("data-prefix", selectizeLoc.options[selected_op.value].prefix);
597            }
598            var attributeKey = $(this).attr('id').replace('select_id_',''),
599            attributeValue = $(selected_op).val();
600            refreshCartKey(attributeKey,attributeValue);
601            calculate_sum($(selected_op));
602        });
603
604        $(document).on('click', '.prod_options_radio label', function (e) {
605            var attribute = $('#' + $(this).attr('for'));
606            // $('#select_id_'+attribute.attr('name')).val(attribute.val()).change();
607            $('#select_id_' + attribute.attr('name'))[0].selectize.setValue(attribute.val());
608        });
609
610        // refresh cart`s key of product with attributes on product page
611        function refreshCartKey (optionKey,optionValue){
612            var form           = $('form[name="cart_quantity"]'),
613                optionKeyToVal = form.data('cart-key').split('{');
614            for(var i = 0; i < optionKeyToVal.length; i++) {
615                if(optionKeyToVal[i].indexOf(optionKey+'}') === 0) {
616                    optionKeyToVal[i] = optionKey + '}' + optionValue;
617                }
618            }
619            var newCartKey = optionKeyToVal.join('{');
620            form.data('cart-key', newCartKey);
621            // console.log(form.data('cart-key'));  //cart key what will be taken when click button "add to cart"
622            productInCart(newCartKey);
623        }
624
625    });
626
627    /* --------- end  attr_select --------- */
628
629    /* --------- DEBUG --------- */
630    if (jQuery('pre.debug').length) {
631        jQuery('pre.debug').remove().insertBefore('body');
632        jQuery('pre.debug').fadeIn(300).animate({
633            top: '100px'
634        }, "slow");
635        jQuery('pre.debug').append('<span class="close">X</span>');
636        jQuery('pre.debug .close').click(function() {
637            jQuery(this).parent('.debug').remove();
638        });
639    }
640    /* --------- /DEBUG --------- */
641
642
643
644
645
646    // ACCORDION
647    if(typeof accordion != 'undefined'){
648        $('.accordion').accordion({
649            heightStyle: 'content',
650            header: 'h3',
651            active: false,
652            collapsible: true,
653            autoHeight: false
654        });
655    }
656
657    $(document).on('click', '.ajax_modal_article', function(e) {
658        e.preventDefault();
659        $.post('./ajax_modal_article.php',{ article_id:$(this).attr('data-id')},function(data) {
660            modal({
661                id: 'ajax_modal_article',
662                title: data.articles_name,
663                body: data.articles_description
664            });
665        },'json');
666    });
667
668    // making "Create Account" button active if "store rules" checked
669    $('#shoprules').click( function(e) {
670        var el = 'form[name=create_account] input[type=submit]';
671        if($(el).hasClass('active_submit')) $(el).removeClass('active_submit');
672        else $(el).addClass('active_submit');
673    });
674
675    // SHOW/HIDE NAVIGATION WHEN WIDTH <= 768 PX
676    $('.main_nav > ul').prepend('<li class="mobile"></li>');
677
678    $('.toggle_nav').click(function(e) {
679        if( $('.main_nav li').hasClass('mobile') ) {
680            e.preventDefault();
681            $('.main_nav').toggleClass('expand');
682        }
683    });
684
685    $('.main_nav li > a').click(function(e) {
686        $('.main_nav li').removeClass('active_page');
687        $(this).closest('li').addClass('active_page');
688    });
689
690    // TABS
691    if(typeof tabs != 'undefined'){
692        $('.tabs').tabs();
693    }
694
695    $('.nav-tabs').children('li:first-child').addClass('active');
696    $('.tab-content').children('.tab-pane.fade:first-child').addClass('in active');
697
698    /* --------- SELECTIZE --------- */
699
700    $("select").not("select[name=billing_country], select[name=shipping_country], select[name=selectCountry], select[name=country], .select_attr_img").selectize({
701        hideSelected:false,
702        maxItems:1
703    });
704
705    $('select[name="currency"], select[name="row_by_page"], select#pl_sort, select.select_attr_select').selectize({
706        hideSelected:false,
707        maxItems:1
708        // plugins: ['hidden_textfield']
709    });
710    $('select[name="selectCountry"], select[name=country], select[name="shipping_zone_id"]').selectize({
711        hideSelected:false,
712        maxItems:1,
713        highlight:true,
714        onFocus: function(){
715            this.clear();
716        }
717
718    });
719    $('select[name="shipping_country"], select[name="billing_country"]').selectize({
720        hideSelected:false,
721        maxItems:1,
722        highlight:true,
723        onDropdownOpen:function() {
724            this.$input.closest('.form-group').find('.error_icon').css('display','none');
725        },
726        onFocus: function(){
727            this.clear();
728        }
729    });
730    /* --------- END SELECTIZE --------- */
731    // Select option region
732    $("select[name=selectCountry], select[name=country]").on('change', function() {
733
734        var country = $(this);
735        var default_region = country.attr('data-zone');
736        var zone_field_name = '';
737        var fieldForInsert = '';
738        country.attr('data-zone',''); // erase default zone for all other countries except default.
739
740        if(country.attr('name')=='selectCountry') {
741            zone_field_name = 'selectRegion';
742            fieldForInsert = $('[name=city]');
743        } else if(country.attr('name')=='country') {
744            zone_field_name = 'zone_id';
745            fieldForInsert = $('[name=city]');
746        }
747
748        $("select[name="+country.attr('name')+"]+button span:last-of-type").html(country.children(':selected').text()); // change country selectize
749        // console.log(11);
750
751        //  $("*[name="+zone_field_name+"]").remove();
752
753        $.get( "./ajax_select_region.php", { country_id:country.val(),'default_region':default_region,'zone_field_name':zone_field_name}, function(data) {
754
755            if($("*[name="+zone_field_name+"]").length!=0) $("*[name="+zone_field_name+"]").parent().replaceWith(data);
756            else if (fieldForInsert.length!=0) fieldForInsert.parent().after(data);
757            else country.parent().after(data);
758
759            if(typeof checkout !== 'undefined') checkout.checkFields();
760            $("select[name="+zone_field_name+"]").selectize({
761                hideSelected:false,
762                maxItems:1,
763                // placeholder:ENTER_KEY,
764                highlight:true,
765                onDropdownOpen:function() {
766                    this.$input.closest('.form-group').find('.error_icon').css('display','none');
767                },
768                onFocus: function(){
769                    this.clear();
770                }
771            });
772        });
773    });
774
775    $('select[name=country]').change();
776    $('select[name=selectCountry]').change();
777
778    var options = {target: '#block',beforeSubmit: showRequest,success:showResponse};
779
780    $('.vivod_columns button, .vivod_list button').on('click', function() {
781        if($("#"+$(this).attr("name")+"2").length!=0){$("#"+$(this).attr("name")+"2").val($(this).val());} // if element ...2 already exists - delete it
782        else{$("#m_srch").append("<input type=hidden name="+$(this).attr("name")+" id="+$(this).attr("name")+"2 value="+$(this).val()+" />");} // create hidden element in form
783        //$('#m_srch').ajaxSubmit(options);// submit form
784        ajaxSubmitSerialize(options);
785
786        // delete class "hover" for all buttons and add this class only for current element
787        $(this).parent().parent().find('button').each(function() {
788            $(this).removeClass('hover');
789        });
790        $(this).addClass('hover');
791    });
792
793    $( "#pl_onpage" ).change(function() {if($("#"+$(this).attr("name")+"2").length!=0){$("#"+$(this).attr("name")+"2").remove();}$("#m_srch").append("<input type=hidden name="+$(this).attr("name")+" id="+$(this).attr("name")+"2 value="+$(this).val()+" />");
794        //$('#m_srch').ajaxSubmit(options);
795        ajaxSubmitSerialize(options);
796    });
797    $( "#pl_sort" ).change(function() {if($("#"+$(this).attr("name")+"2").length!=0){$("#"+$(this).attr("name")+"2").remove();}$("#m_srch").append("<input type=hidden name="+$(this).attr("name")+" id="+$(this).attr("name")+"2 value="+$(this).val()+" />");
798        //$('#m_srch').ajaxSubmit(options);
799        ajaxSubmitSerialize(options);
800    });
801    $( "input:radio[name=sort]" ).change(function() {if($("#"+$(this).attr("name")+"2").length!=0){$("#"+$(this).attr("name")+"2").remove();}$("#m_srch").append("<input type=hidden name="+$(this).attr("name")+" id="+$(this).attr("name")+"2 value="+$(this).val()+" />");
802        //$('#m_srch').ajaxSubmit(options);
803        ajaxSubmitSerialize(options);
804    });
805
806    function changeColor(picker_field, color) {
807        if(picker_field.data('configuration-key')) {
808
809            var configurationCode = picker_field.data('configuration-key');
810            var colorCode = color.toHexString();
811
812            $.ajax({
813                url: "/includes/modules/CustomizationPanel/index.php?action=changeColor",
814                type: "POST",
815                data: {colorCode: colorCode, configurationCode: configurationCode},
816                dataType: 'json'
817            });
818
819        }
820    }
821
822	/*
823	 if($('input[name=displayajax]').val()=='true') {
824	 var options = {target: "#block",beforeSubmit: showRequest,success:showResponse};
825	 ajaxSubmitSerialize(options);
826	 }
827	 */
828
829    // colorpicker on main page:
830
831    // jQuery('body').on('click', '.custom_panel_block.visible .change_color', function(event) {
832    //     event.preventDefault();
833    //     var picker_field = $(this).find('.change_color-input');
834    //
835    //     $(this).ColorPicker({
836    //         color: picker_field.val(),
837    //         onChange: function (hsb, hex, rgb) {
838    //             $(picker_field).val('#'+hex);
839    //             $("body").get(0).style.setProperty("--"+picker_field.attr('data-color'), '#'+hex);
840    //         }
841    //     });
842    //     $(this).click();
843    // });
844    if (IS_MOBILE == '1') {
845        $(document).on('click', '.change_color', function () {
846            var picker_field = $(this).find('.change_color-input'),
847                spectrum_block = $(this).find('.spectrum_block');
848            $(this).closest('.palette_li').find('.close_palette').addClass('visible');
849            spectrum_block.spectrum({
850                color: picker_field.val(),
851                type: "color",
852                showPaletteOnly: true,
853                showPalette:true,
854                hideAfterPaletteSelect:true,
855                showAlpha: false,
856                palette: [
857                    ["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],
858                    ["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],
859                    ["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],
860                    ["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],
861                    ["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],
862                    ["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],
863                    ["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"]
864                ],
865                change: function (color) {
866                    $("body").get(0).style.setProperty("--" + picker_field.attr('data-color'), color.toHexString());
867                    picker_field.attr('value', color.toHexString());
868                    changeColor(picker_field, color);
869                },
870            }).spectrum("show");
871        });
872
873        $(document).on('click', '.close_palette', function (e) {
874            // e.stopPropagation();
875            $('.sp-container').hide();
876            $(this).removeClass('visible');
877        });
878    } else {
879        $(document).on('click', '.change_color', function () {
880            var picker_field = $(this).find('.change_color-input'),
881                spectrum_block = $(this).find('.spectrum_block');
882
883            spectrum_block.spectrum({
884                color: picker_field.val(),
885                type: "color",
886                showPalette: false,
887                togglePaletteOnly: true,
888                hideAfterPaletteSelect: true,
889                showAlpha: false,
890                change: function (color) {
891                    $("body").get(0).style.setProperty("--" + picker_field.attr('data-color'), color.toHexString());
892                    picker_field.attr('value', color.toHexString());
893                    changeColor(picker_field, color);
894                },
895                move: function (color) {
896                    $("body").get(0).style.setProperty("--" + picker_field.attr('data-color'), color.toHexString());
897                    picker_field.attr('value', color.toHexString());
898                }
899            }).spectrum("show");
900        });
901
902        //custom panel
903        $(document).mouseup(function (e){
904            var collapse_block = $('.custom_panel_block .collapse_li, .sp-container');
905            // console.log(collapse_block)
906            if (!collapse_block.is(e.target) && collapse_block.has(e.target).length === 0) {
907                collapse_block.find('.drop_menu.in').collapse('hide');
908                if(typeof spectrum != 'undefined'){
909                    $('.spectrum_block').spectrum("hide");
910                }
911                collapse_block.find('.collapse_btn').addClass('collapsed');
912            }
913        });
914    }
915
916    $(document).on('click', '.open_custom_panel_btn', function () {
917        if($('.custom_panel_block').hasClass('visible')) {
918            $('.custom_panel_fader').removeClass('visible');
919            $('.custom_panel_block .collapse_btn').addClass('collapsed');
920            $('.custom_panel_block .drop_menu.in').collapse('hide');
921            $('.custom_panel_block').removeClass('visible');
922            $('.open_custom_panel_btn').addClass('anim');
923        } else {
924            $('.custom_panel_block').addClass('visible');
925            $('.open_custom_panel_btn').removeClass('anim');
926        }
927    });
928    $(document).on('click', '.custom_panel_close', function () {
929        $('.custom_panel_block').removeClass('visible');
930        $('.custom_panel_fader').removeClass('visible');
931        $('.custom_panel_block .collapse_btn').addClass('collapsed');
932        $('.custom_panel_block .drop_menu.in').collapse('hide');
933        $('.open_custom_panel_btn').addClass('anim');
934    });
935
936    // if ($(window).width()>'991') {
937    //     setTimeout(function() {
938    //         $('.custom_panel_block').addClass('visible');
939    //         $('.open_custom_panel_btn').removeClass('anim');
940    //     }, 1500);
941    // } else {
942    //     $('.open_custom_panel_btn').addClass('anim');
943    // }
944    //end custom panel
945
946
947    $(document).on('click', '.popupPrintReceipt', function(e) {
948        e.preventDefault();
949        window.open($(this).attr('href'),'popupPrintReceipt','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=750');
950    });
951
952    var firstImage, srcImage;
953
954    $(document).on({
955        mouseenter: function () {
956            srcImage = $(this).find('.p_img_href img');
957            if(srcImage.is("[data-hover]")) {
958                firstImage = srcImage.attr('src');
959
960                srcImage.attr('src',srcImage.attr("data-hover"));
961            } else {
962                firstImage = '';
963            }
964        },
965        mouseleave: function () {
966            if(typeof srcImage === 'object' && srcImage.is("[data-hover]") && firstImage!=''){
967                srcImage.attr('src',firstImage);
968            }
969        }
970    }, '.product');
971
972    $('.checkout_authorization, .enter_link').click(function(event) {
973        $.post('./ajax.php', {
974            request: 'getLoginForm'
975        }, function(data) {
976            modal({
977                id: 'getLoginForm',
978                bod
978y: data.html,
979                render: true,
980                width: 320,
981            });
982
983        }, 'json');
984        return false;
985    });
986
987    //Open modal with bug report form, take a screenshot of page and (then) initialize listener of form submit
988    $(document).on('click','.bug_report', function(event) {
989        //Open modal with bug report form
990        doHookie('bug_report');
991        $.post('./ru/ajax.php', {
992            request: 'getBugReportForm'
993        }, function(data) {
994            modal({
995                id: 'getBugReportForm',
996                body: data.html,
997                render: true,
998            });
999        }, 'json');
1000        //take a screenshot of page
1001        $('body').append("<script type='text/javascript' src='includes/javascript/html2canvas.min.js'></script>" );
1002        var element = document.querySelector('html');
1003        html2canvas(element,{
1004            windowHeight: element.offsetHeight,
1005            windowWidth: element.offsetWidth
1006        }).then(canvas => {
1007            var img_base64 = canvas.toDataURL(),    //convert from canvas to base64 screenshot
1008            popup_btn = $('#BugReportForm .btn[type="submit"]'),
1009            load_circle = $('#BugReportForm img.btn-loader');
1010            //Prepare base64 screenshot to post (encode to the url-transported state)
1011            img_base64 = img_base64.split('+').join('.');
1012            img_base64 = img_base64.split('/').join('_');
1013            img_base64 = img_base64.split('=').join('-');
1014            //Show btn Send in modal
1015            popup_btn.removeClass('hidden');
1016            load_circle.addClass('hidden');
1017            $('#BugReportForm').data('screenshot',img_base64);
1018
1019        });
1020
1021        return false;
1022    });
1023    //submit form listener
1024    $(document).on('submit','#BugReportForm', function(event) {
1025        event.preventDefault();
1026        var img_base64 = $(this).data('screenshot'),
1027            popup_btn = $('#BugReportForm .btn[type="submit"]'),
1028            load_circle = $('#BugReportForm img.btn-loader');
1029        //Hide btn Send in modal and show load circle
1030        popup_btn.addClass('hidden');
1031        load_circle.removeClass('hidden');
1032        //Post user`s text and screenshot of page to processing
1033        var data = $('#BugReportForm').serialize()+'&img_base64='+ img_base64;
1034        $.post('./ru/ajax.php', data, function(data, xhr) {
1035            //Show result of processing in modal
1036            if (data.success) {
1037                $('#BugReportForm').html(data.message);
1038            } else {
1039                alert('Send error!');
1040            }
1041        }, 'json');
1042    });
1043    //alert close button for header messages
1044    $(document).on('click', '.alert-danger-header .close', function () {
1045        $('.alert-danger-header').remove();
1046    });
1047
1048    $(document).on('submit','form[name=add_set]',function(e) {
1049        e.preventDefault();
1050        var $this = $(this);
1051        var data = {};
1052        $this.serializeArray().map(function(arr) {
1053            data[arr.name] = arr.value;
1054        });
1055        $.ajax({url:$this.attr('action'), dataType:"json", data:data})
1056            .done(function(response) {
1057                updateCart();
1058                $('.popup_cart').click();
1059            })
1060    });
1061    $(document).on('click','#tab-comments-anchor',function(e) {
1062        if(typeof includeRecaptchaFile == 'function'){
1063            includeRecaptchaFile();
1064        }
1065    });
1066});
1067
1068//special price timer
1069var timer_id = '#timer';
1070if($(timer_id).length) {
1071    var deadline = $(timer_id).data('expired');
1072    setClock(timer_id, deadline);
1073}
1074
1075function setClock(selector, endtime) {
1076    const timer        = document.querySelector(selector),
1077          days         = timer.querySelector('#days'),
1078          hours        = timer.querySelector('#hours'),
1079          minutes      = timer.querySelector('#minutes'),
1080          seconds      = timer.querySelector('#seconds'),
1081          timeInterval = setInterval(updateClock, 1000);
1082
1083    updateClock();
1084
1085    function updateClock() {
1086        const t = getTimeRemaining(endtime);
1087
1088        days.textContent = addZero(t.days);
1089        hours.textContent = addZero(t.hours);
1090        minutes.textContent = addZero(t.minutes);
1091        seconds.textContent = addZero(t.seconds);
1092
1093        if(t.total <= 0) {
1094            days.textContent = '00';
1095            hours.textContent = '00';
1096            minutes.textContent = '00';
1097            seconds.textContent = '00';
1098
1099            clearInterval(timeInterval);
1100        }
1101
1102        function addZero(num) {
1103            if(num <= 9) {
1104                return '0' + num;
1105            }else {
1106                return num;
1107            }
1108        }
1109
1110        function getTimeRemaining(endtime) {
1111            const t       = Date.parse(endtime) - Date.parse(new Date()),
1112                  seconds = Math.floor((t / 1000) % 60),
1113                  minutes = Math.floor((t / 1000 / 60) % 60),
1114                  hours   = Math.floor((t / (1000 * 60 * 60)) % 24),
1115                  days    = Math.floor((t / (1000 * 60 * 60 * 24)));
1116
1117            return {
1118                'total': t,
1119                'days': days,
1120                'hours': hours,
1121                'minutes': minutes,
1122                'seconds': seconds
1123            };
1124        }
1125    }
1126}

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.