PageSourceSearch

https://dogspecial.ru/wa-data/public/site/themes/hypermarket1/js/custom.js?v=1.3.0.97

js dogspecial.ru collected 2026-09-24 13:33:24 UTC 50,408 bytes, 1,639 lines download raw bytes

1// Main Class
2( function($, waTheme) {
3
4    var FixedBlock = ( function($) {
5
6        FixedBlock = function(options) {
7            var that = this;
8
9            // DOM
10            that.$window = $(window);
11            that.$wrapper = options["$section"];
12            that.$wrapperW = options["$wrapper"];
13
14            // VARS
15            that.type = (options["type"] || "bottom");
16            that.lift = (options["lift"] || 0);
17
18            // DYNAMIC VARS
19            that.offset = {};
20            that.$clone = false;
21            that.is_fixed = false;
22
23            // INIT
24            that.initClass();
25        };
26
27        FixedBlock.prototype.initClass = function() {
28            var that = this,
29                $window = that.$window,
30                resize_timeout = 0;
31
32            $window.on("resize", function() {
33                clearTimeout(resize_timeout);
34                resize_timeout = setTimeout( function() {
35                    that.resize();
36                }, 100);
37            });
38
39            $window.on("scroll", watcher);
40
41            that.$wrapper.on("resize", function() {
42                that.resize();
43            });
44
45            that.init();
46
47            function watcher() {
48                var is_exist = $.contains($window[0].document, that.$wrapper[0]);
49                if (is_exist) {
50                    that.onScroll($window.scrollTop());
51                } else {
52                    $window.off("scroll", watcher);
53                }
54            }
55
56            that.$wrapper.data("block", that);
57        };
58
59        FixedBlock.prototype.init = function() {
60            var that = this;
61
62            if (!that.$clone) {
63                var $clone = $("<div />").css("margin", "0");
64                that.$wrapper.after($clone);
65                that.$clone = $clone;
66            }
67
68            that.$clone.hide();
69
70            var offset = that.$wrapper.offset();
71
72            that.offset = {
73                left: offset.left,
74                top: offset.top,
75                width: that.$wrapper.outerWidth(),
76                height: that.$wrapper.outerHeight()
77            };
78        };
79
80        FixedBlock.prototype.resize = function() {
81            var that = this;
82
83            switch (that.type) {
84                case "top":
85                    that.fix2top(false);
86                    break;
87                case "bottom":
88                    that.fix2bottom(false);
89                    break;
90            }
91
92            var offset = that.$wrapper.offset();
93            that.offset = {
94                left: offset.left,
95                top: offset.top,
96                width: that.$wrapper.outerWidth(),
97                height: that.$wrapper.outerHeight()
98            };
99
100            that.$window.trigger("scroll");
101        };
102
103        /**
104         * @param {Number} scroll_top
105         * */
106        FixedBlock.prototype.onScroll = function(scroll_top) {
107            var that = this,
108                window_w = that.$window.width(),
109                window_h = that.$window.height();
110
111            // update top for dynamic content
112            that.offset.top = (that.$clone && that.$clone.is(":visible") ? that.$clone.offset().top : that.$wrapper.offset().top);
113
114            switch (that.type) {
115                case "top":
116                    var bottom_case = (that.$wrapperW ? ((scroll_top + that.offset.height) < that.$wrapperW.height() + that.$wrapperW.offset().top) : true),
117                        use_top_fix = (that.offset.top - that.lift < scroll_top && bottom_case);
118
119                    that.fix2top(use_top_fix);
120                    break;
121                case "bottom":
122                    var use_bottom_fix = (that.offset.top && scroll_top + window_h < that.offset.top + that.offset.height);
123                    that.fix2bottom(use_bottom_fix);
124                    break;
125            }
126
127        };
128
129        /**
130         * @param {Boolean|Object} set
131         * */
132        FixedBlock.prototype.fix2top = function(set) {
133            var that = this,
134                fixed_class = "is-top-fixed";
135
136            if (set) {
137                that.$wrapper
138                    .css({
139                        position: "fixed",
140                        top: that.lift,
141                        left: that.offset.left,
142                        width: that.offset.width
143                    })
144                    .addClass(fixed_class);
145
146                that.$clone.css({
147                    height: that.offset.height
148                }).show();
149
150            } else {
151                that.$wrapper.removeClass(fixed_class).removeAttr("style");
152                that.$clone.removeAttr("style").hide();
153            }
154
155            that.is_fixed = !!set;
156        };
157
158        /**
159         * @param {Boolean|Object} set
160         * */
161        FixedBlock.prototype.fix2bottom = function(set) {
162            var that = this,
163                fixed_class = "is-bottom-fixed";
164
165            if (set) {
166                that.$wrapper
167                    .css({
168                        position: "fixed",
169                        bottom: 0,
170                        left: that.offset.left,
171                        width: that.offset.width
172                    })
173                    .addClass(fixed_class);
174
175                that.$clone.css({
176                    height: that.offset.height
177                }).show();
178
179            } else {
180                that.$wrapper.removeClass(fixed_class).removeAttr("style");
181                that.$clone.removeAttr("style").hide();
182            }
183
184            that.is_fixed = !!set;
185        };
186
187        return FixedBlock;
188
189    })(jQuery);
190
191    // Main class
192    var Layout = ( function($) {
193
194        Layout = function(options) {
195            var that = this;
196
197            // DOM
198            that.$window = $(window);
199            that.$wrapper = waTheme.layout.$wrapper;
200            that.$block = waTheme.layout.$block;
201            that.$content = waTheme.layout.$content;
202            that.$sidebar = waTheme.layout.$sidebar;
203            that.$footer = ( waTheme.layout.$footer && waTheme.layout.$footer.length ? waTheme.layout.$footer : false);
204
205            // VARS
206
207            // DYNAMIC VARS
208
209            // INIT
210            that.initClass();
211        };
212
213        Layout.prototype.initClass = function() {
214            var that = this;
215            //
216            if (that.$footer) {
217                that.initMinSpace();
218            }
219            //
220            that.initAuthAdapters();
221            //
222            that.initCaptcha();
223            //
224            that.initSidebar();
225
226            $.ajaxSetup({
227                cache: false
228            });
229        };
230
231        // Min space before footer
232        Layout.prototype.initMinSpace = function() {
233            var that = this;
234
235            var $window = that.$window,
236                $content = that.$content,
237                $footer = that.$footer.find(".s-footer-block");
238
239            setSpace();
240
241            $window.on("resize", setSpace);
242
243            window.addEventListener("orientationchange", setSpace);
244
245            function setSpace() {
246                $content.removeAttr("style");
247
248                var display_height = $window.height(),
249                    main_height = $content.closest(".s-content-wrapper").height(),
250                    footer_top = $footer.offset().top,
251                    footer_height = $footer.outerHeight(true);
252
253                var delta = ( display_height - (footer_top + footer_height) );
254
255                if (delta > 0) {
256                    $content.css({
257                        "min-height": main_height + delta + "px"
258                    });
259                }
260            }
261
262        };
263
264        Layout.prototype.initAuthAdapters = function() {
265            var that = this;
266
267            $(".s-adapters-section").on("click", "a", function(event) {
268                event.preventDefault();
269                onProviderClick( $(this) );
270            });
271
272            function onProviderClick( $link ) {
273                var $li = $link.closest("li"),
274                    provider = $li.data("provider");
275
276                if (provider !== 'guest' && provider !== 'signup') {
277                    var left = (screen.width-600)/ 2,
278                        top = (screen.height-400)/ 2,
279                        href = $link.attr("href");
280
281                    if ( ( typeof require_authorization !== "undefined" ) && !require_authorization) {
282                        href = href + "&guest=1";
283                    }
284
285                    window.open(href, "oauth", "width=600,height=400,left="+left+",top="+top+",status=no,toolbar=no,menubar=no");
286                }
287            }
288        };
289
290        Layout.prototype.initCaptcha = function() {
291            var that = this;
292
293            // Click on refresh button or image
294            $(".wa-captcha").on("click", ".wa-captcha-refresh, .wa-captcha-img", function(event) {
295                event.preventDefault();
296                refreshCaptcha( $(this) );
297            });
298
299            // Refresh Captcha
300            function refreshCaptcha($target) {
301                var $wrapper = $target.closest(".wa-captcha"),
302                    captcha = $wrapper.find(".wa-captcha-img");
303
304                if (captcha.length) {
305                    var newCaptchaHref = captcha.attr("src").replace( /\?.*$/,'?rid='+Math.random() );
306
307                    captcha.attr("src", newCaptchaHref);
308
309                    captcha.one("load", function() {
310                        $wrapper.find('.wa-captcha-input').focus();
311                    });
312                }
313
314                $wrapper.find("input").val("");
315            }
316        };
317
318        Layout.prototype.initSidebar = function() {
319            var that = this;
320
321            if (!that.$sidebar || !that.$sidebar.length) {
322                return false;
323            }
324
325            var Sidebar = ( function($) {
326
327                Sidebar = function (options) {
328                    var that = this;
329
330                    // DOM
331                    that.$wrapper = options["$wrapper"];
332
333                    // VARS
334
335                    // DYNAMIC VARS
336
337                    // INIT
338                    that.initClass();
339                };
340
341                Sidebar.prototype.initClass = function() {
342                    var that = this;
343
344                    that.initDeepLists();
345                };
346
347                Sidebar.prototype.initDeepLists = function() {
348                    var that = this,
349                        $lists = that.$wrapper.find(".js-deep-list");
350
351                    $lists.each( function() {
352                        var $list = $(this);
353
354                        $list.on("click", ".js-toggle", function(event) {
355                            event.preventDefault();
356
357                            var $li = $(this).closest("li"),
358                                open_class = "is-opened";
359
360                            $li.toggleClass(open_class);
361                        });
362                    });
363                };
364
365                return Sidebar;
366
367            })($);
368
369            new Sidebar({
370                $wrapper: that.$sidebar
371            });
372        };
373
374        return Layout;
375
376    })($);
377
378    // Pane :: bottom panel with store buttons
379    var Pane = (function($) {
380
381        Pane = function(options) {
382            var that = this;
383
384            // DOM
385            that.$wrapper = options["$wrapper"];
386
387            // VARS
388
389            // DYNAMIC VARS
390
391            // INIT
392            that.initClass();
393        };
394
395        Pane.prototype.initClass = function() {
396            var that = this;
397
398            that.initSticky();
399        };
400
401        Pane.prototype.initSticky = function() {
402            var that = this,
403                $wrapper = that.$wrapper.find(".js-pane-wrapper");
404
405            var FixedBlock = ( function($) {
406
407                FixedBlock = function(options) {
408                    var that = this;
409
410                    // DOM
411                    that.$window = $(window);
412                    that.$wrapper = options["$wrapper"];
413                    that.$section = options["$section"];
414                    that.$wrapperContainer = that.$wrapper.parent();
415
416                    // VARS
417                    that.type = (options["type"] || "bottom");
418
419                    // DYNAMIC VARS
420                    that.offset = {};
421                    that.$clone = false;
422                    that.is_fixed = false;
423
424                    // INIT
425                    that.initClass();
426                };
427
428                FixedBlock.prototype.initClass = function() {
429                    var that = this,
430                        $window = that.$window,
431                        resize_timeout = 0;
432
433                    $window.on("resize", function() {
434                        clearTimeout(resize_timeout);
435                        resize_timeout = setTimeout( function() {
436                            that.resize();
437                        }, 100);
438                    });
439
440                    $window.on("scroll", watcher);
441
442                    that.$wrapper.on("resize", function() {
443                        that.resize();
444                    });
445
446                    that.init();
447
448                    watcher();
449
450                    function watcher() {
451                        var is_exist = $.contains($window[0].document, that.$wrapper[0]);
452                        if (is_exist) {
453                            that.onScroll($window.scrollTop());
454                        } else {
455                            $window.off("scroll", watcher);
456                        }
457                    }
458
459                    that.$wrapper.data("block", that);
460                };
461
462                FixedBlock.prototype.init = function() {
463                    var that = this;
464
465                    if (!that.$clone) {
466                        var $clone = $("<div />");
467                        that.$wrapperContainer.append($clone);
468                        that.$clone = $clone;
469                    }
470
471                    that.$clone.hide();
472
473                    var offset = that.$wrapper.offset();
474                    that.offset = {
475                        left: offset.left,
476                        top: offset.top,
477                        width: that.$wrapper.outerWidth(),
478                        height: that.$wrapper.outerHeight()
479                    };
480                };
481
482                FixedBlock.prototype.resize = function() {
483                    var that = this;
484
485                    switch (that.type) {
486                        case "top":
487                            that.fix2top(false);
488                            break;
489                        case "bottom":
490                            that.fix2bottom(false);
491                            break;
492                    }
493
494                    var offset = that.$wrapper.offset();
495                    that.offset = {
496                        left: offset.left,
497                        top: offset.top,
498                        width: that.$wrapper.outerWidth(),
499                        height: that.$wrapper.outerHeight()
500                    };
501
502                    that.$window.trigger("scroll");
503                };
504
505                /**
506                 * @param {Number} scroll_top
507                 * */
508                FixedBlock.prototype.onScroll = function(scroll_top) {
509                    var that = this,
510                        window_w = that.$window.width(),
511                        window_h = that.$window.height();
512
513                    // update top for dynamic content
514                    that.offset.top = that.$wrapperContainer.offset().top;
515
516                    switch (that.type) {
517                        case "top":
518                            var bottom_case = (that.$section ? ((scroll_top + that.offset.height) < that.$section.height() + that.$section.offset().top) : true),
519                                use_top_fix = (that.offset.top < scroll_top && bottom_case);
520
521                            that.fix2top(use_top_fix);
522                            break;
523                        case "bottom":
524                            var use_bottom_fix = (that.offset.top && scroll_top + window_h < that.offset.top + that.offset.height);
525                            that.fix2bottom(use_bottom_fix);
526                            break;
527                    }
528
529                };
530
531                /**
532                 * @param {Boolean|Object} set
533                 * */
534                FixedBlock.prototype.fix2top = function(set) {
535                    var that = this,
536                        fixed_class = "is-top-fixed";
537
538                    if (set) {
539                        that.$wrapper
540                            .css({
541                                left: that.offset.left,
542                                width: that.offset.width
543                            })
544                            .addClass(fixed_class);
545
546                        that.$clone.css({
547                            height: that.offset.height
548                        }).show();
549
550                    } else {
551                        that.$wrapper.removeClass(fixed_class).removeAttr("style");
552                        that.$clone.removeAttr("style").hide();
553                    }
554
555                    that.is_fixed = !!set;
556                };
557
558                /**
559                 * @param {Boolean|Object} set
560                 * */
561                FixedBlock.prototype.fix2bottom = function(set) {
562                    var that = this,
563                        fixed_class = "is-bottom-fixed";
564
565                    if (set) {
566                        that.$wrapper
567                            .css({
568                                left: that.offset.left,
569                                width: that.offset.width
570                            })
571                            .addClass(fixed_class);
572
573                        that.$clone.css({
574                            height: that.offset.height
575                        }).show();
576
577                    } else {
578                        that.$wrapper.removeClass(fixed_class).removeAttr("style");
579                        that.$clone.removeAttr("style").hide();
580                    }
581
582                    that.is_fixed = !!set;
583                };
584
585                return FixedBlock;
586
587            })(jQuery);
588
589            new FixedBlock({
590                $wrapper: $wrapper,
591                type: "bottom"
592            });
593
594        };
595
596        return Pane;
597    })($);
598
599    // Pane :: Compare
600    var Compare = ( function($) {
601
602        var change_functions = [];
603
604        Compare = function(options) {
605            var that = this;
606
607            // DOM
608            that.$wrapper = options["$wrapper"];
609            that.$count = that.$wrapper.find(".js-count");
610            that.$compareIcon = that.$wrapper.find(".js-compare-icon");
611            that.onChange = options["onChange"];
612
613            // VARS
614
615            // DYNAMIC VARS
616            that.count = null;
617
618            // INIT
619            that.initClass();
620        };
621
622        Compare.prototype.initClass = function() {
623            var that = this,
624                is_frame = waTheme.is_frame;
625
626            if (that.onChange && (typeof that.onChange === "function") ) {
627                change_functions.push(that.onChange);
628            }
629
630            if (!is_frame) {
631                that.update();
632            }
633        };
634
635        Compare.prototype.update = function() {
636            var that = this,
637                compare = $.cookie("shop_compare"),
638                count;
639
640            compare = (compare) ? compare.split(',') : [];
641            count = compare.length;
642
643            if ( count > 0 ) {
644                that.$count.text(count);
645                that.toggle(true);
646            } else {
647                that.$count.text(0);
648                that.toggle();
649            }
650
651            that.count = count;
652
653            $.each(change_functions, function(index, func) {
654                try {
655                    func(that);
656                } catch(e) {
657                    console.log(e.message);
658                }
659            });
660        };
661
662        Compare.prototype.toggle = function(show) {
663            var that = this,
664                empty_class = "is-empty",
665                active_class = "active";
666
667            if (show) {
668                that.$wrapper.removeClass(empty_class);
669                that.$compareIcon.addClass(active_class);
670            } else {
671                that.$wrapper.addClass(empty_class);
672                that.$compareIcon.removeClass(active_class);
673            }
674        };
675
676        /**
677         * @param {String|Number} product_id
678         * @param {Object?} $image
679         * @return {Boolean}
680         * */
681        Compare.prototype.addToCompare = function(product_id, $image) {
682            var that = this;
683
684            product_id = product_id + "";
685
686            var cookie_name = "shop_compare",
687                cookie_compare = $.cookie(cookie_name),
688                compare_ids = (cookie_compare) ? cookie_compare.split(',') : [],
689                index = compare_ids.indexOf(product_id),
690                is_added = (index >= 0);
691
692            if (is_added) {
693                remove(product_id);
694                that.update();
695
696            } else {
697                add(product_id);
698
699                if ($image && $image.length) {
700                    animate($image).then( function() {
701                        that.update();
702                    });
703                }
704            }
705
706            return !is_added;
707
708            /**
709             * @param {Object} $image
710             * */
711            function animate($image) {
712                var deferred = $.Deferred();
713
714                // DOM
715                var $clone = $image.clone();
716
717                // VARS
718                var offset = $image.offset(),
719                    image_w = $image.width(),
720                    image_h = $image.height(),
721                    cart_offset = that.$wrapper.offset(),
722                    time = 666;
723
724                var clone_class = "s-clone-wrapper",
725                    animate_to_class = "is-animated";
726
727                $clone
728                    .hide()
729                    .addClass(clone_class);
730
731                $clone.css({
732                    top: offset.top,
733                    left: offset.left,
734                    width: image_w,
735                    height: image_h
736                });
737
738                $clone.appendTo($("body")).show();
739
740                $clone.css({
741                    top: cart_offset.top,
742                    left: cart_offset.left,
743                    width: 0,
744                    height: 0,
745                    opacity: 0
746                }).addClass(animate_to_class);
747
748                setTimeout( function() {
749                    $clone.remove();
750                    deferred.resolve();
751                }, time);
752
753                return deferred.promise();
754            }
755
756            /**
757             * @param {String} product_id
758             * */
759            function add(product_id) {
760                compare_ids.push(product_id);
761                $.cookie(cookie_name, compare_ids.join(','), {expires: 30, path: '/'});
762            }
763
764            /**
765             * @param {String} product_id
766             * */
767            function remove(product_id) {
768                compare_ids.splice(index, 1);
769
770                if (compare_ids.length > 0) {
771                    $.cookie(cookie_name, compare_ids.join(','), { expires: 30, path: '/'});
772                } else {
773                    $.cookie(cookie_name, null, {path: '/'});
774                }
775            }
776        };
777
778        /**
779         * @param {Function} func
780         * */
781        Compare.prototype.onChange = function(func) {
782            if (typeof func === "function") {
783                change_functions.push(func);
784            }
785        };
786
787        return Compare;
788    })($);
789
790    // Pane :: Cart
791    var Cart = (function($) {
792
793        var change_functions = [];
794
795        Cart = function(options) {
796            var that = this;
797
798            // DOM
799            that.$wrapper = options["$wrapper"];
800            that.$count = that.$wrapper.find(".js-cart-count");
801            that.$text = that.$wrapper.find(".js-cart-price");
802
803            // VARS
804
805            // DYNAMIC VARS
806            that.count = options["count"];
807
808            // INIT
809            that.initClass();
810        };
811
812        Cart.prototype.initClass = function() {
813            var that = this;
814
815            $(document).on("cartIsChanged", function(event, data) {
816                that.update(data);
817            });
818
819
820        };
821
822        /**
823         * @param {Object} data
824         * */
825        Cart.prototype.update = function(data) {
826            var that = this;
827
828            if (data.count > 0) {
829                that.$count.text(data.count);
830                that.$text.html(data.text);
831                that.count = (data.count);
832                toggle(true);
833            } else {
834                that.$count.text(0);
835                that.$text.html(data.text);
836                that.count = 0;
837                toggle();
838            }
839
840            function toggle(show) {
841                var empty_class = "is-empty";
842
843                if (show) {
844                    that.$wrapper.removeClass(empty_class);
845                } else {
846                    that.$wrapper.addClass(empty_class);
847                }
848            }
849
850            $.each(change_functions, function(index, func) {
851                try {
852                    func(that);
853                } catch(e) {
854                    console.log(e.message);
855                }
856            });
857        };
858
859        /**
860         * @param {Function} func
861         * */
862        Cart.prototype.onChange = function(func) {
863            if (typeof func === "function") {
864                change_functions.push(func);
865            }
866        };
867
868        /**
869         * @param {Object} $image
870         * */
871        Cart.prototype.animateAddToCart = function($image) {
872            var that = this;
873
874            if ($image && $image.length) {
875                animate($image);
876            }
877
878            /**
879             * @param {Object} $image
880             * */
881            function animate($image) {
882                var deferred = $.Deferred();
883
884                // DOM
885                var $clone = $image.clone();
886
887                // VARS
888                var offset = $image.offset(),
889                    image_w = $image.width(),
890                    image_h = $image.height(),
891                    cart_offset = that.$wrapper.offset(),
892                    time = 666;
893
894                var clone_class = "s-clone-wrapper",
895                    animate_to_class = "is-animated";
896
897                $clone
898                    .hide()
899                    .addClass(clone_class);
900
901                $clone.css({
902                    top: offset.top,
903                    left: offset.left,
904                    width: image_w,
905                    height: image_h
906                });
907
908                $clone.appendTo($("body")).show();
909
910                $clone.css({
911                    top: cart_offset.top,
912                    left: cart_offset.left,
913                    width: 0,
914                    height: 0,
915                    opacity: 0
916                }).addClass(animate_to_class);
917
918                setTimeout( function() {
919                    $clone.remove();
920                    deferred.resolve();
921                }, time);
922
923                return deferred.promise();
924            }
925        };
926
927        return Cart;
928
929    })($);
930
931    // Header :: Catalog
932    var Catalog = ( function($) {
933
934        Catalog = function(options) {
935            var that = this;
936
937            // DOM
938            that.$wrapper = options["$wrapper"];
939            that.$button = that.$wrapper.find(".s-catalog-button");
940            that.$list = that.$wrapper.find(".s-catalog-list");
941
942            // VARS
943            that.open_class = "is-opened";
944            that.hover_class = "is-hover";
945            that.is_locked = options["is_locked"];
946
947            // DYNAMIC VARS
948            that.is_opened = false;
949            that.is_touch_enabled = waTheme.is_touch_enabled;
950            that.$activeMenu = false;
951
952            // TIMERS
953            that.timer_1 = 0;
954            that.timer_2 = 0;
955            that.timer_3 = 0;
956            that.open_timer = 0;
957            that.show_time = 666;
958            that.hide_time = 666;
959
960            // INIT
961            $(document).ready( function() {
962                that.initClass();
963            });
964        };
965
966        Catalog.prototype.initClass = function() {
967            var that = this;
968
969            that.$block = waTheme.layout.$block;
970            that.$sidebar = waTheme.layout.$sidebar;
971
972            // Set sidebar lift
973            if (that.is_locked) {
974                that.$sidebar.css("padding-top", that.$list.outerHeight());
975            }
976            //
977            that.bindEvents();
978        };
979
980        Catalog.prototype.bindEvents = function() {
981            var that = this;
982
983            // Show/hide main menu
984            if (that.is_touch_enabled) {
985                that.$button[0].addEventListener("touchstart", function () {
986                    that.toggleView();
987                });
988
989                var $openedLi = false;
990
991                that.$wrapper.on("click", "a", function(event) {
992                    event.preventDefault();
993
994                    var $link = $(this),
995                        $li = $link.closest("li"),
996                        has_menu = !!$li.find("> .s-sub-wrapper").length;
997
998                    var active_class = "is-opened";
999
1000                    if ($openedLi) {
1001                        $openedLi.removeClass(active_class);
1002                        $openedLi = false;
1003                    }
1004
1005                    if (has_menu) {
1006                        $openedLi = $li.addClass(active_class);
1007
1008                    } else {
1009                        location.href = $link[0].href;
1010                    }
1011                });
1012
1013            } else {
1014                that.$button.on("mouseenter", function() {
1015                    that.open_timer = setTimeout( function() {
1016                        that.toggleView("show");
1017                    }, that.show_time);
1018
1019                });
1020
1021                that.$button.on("click", function() {
1022                    if (!that.is_locked) {
1023                        clearTimeout(that.open_timer);
1024                        if (that.is_opened) {
1025                            that.toggleView("hide");
1026                        } else {
1027                            that.toggleView("show");
1028                        }
1029                    }
1030                });
1031
1032                that.$button.on("mouseleave", function() {
1033                    clearTimeout(that.open_timer);
1034                });
1035
1036                that.$wrapper.on("mouseenter", function() {
1037                    clearTimeout(that.timer_1);
1038                });
1039
1040                that.$wrapper.on("mouseleave", function() {
1041                    that.timer_1 = setTimeout( function() {
1042                        that.hideSubmenu();
1043                        that.toggleView("hide");
1044                    }, that.hide_time);
1045                });
1046            }
1047
1048            // Show/hide submenu
1049            if (!that.is_touch_enabled) {
1050                that.$list.on("mouseenter", "> li", function() {
1051                    var $li = $(this);
1052                    clearTimeout(that.timer_2);
1053                    clearTimeout(that.timer_3);
1054                    that.timer_3 = setTimeout( function() {
1055                        that.hideSubmenu();
1056                        that.showSubmenu($li);
1057                    }, that.show_time);
1058                });
1059                that.$list.on("mouseleave", "> li", function() {
1060                    that.timer_2 = setTimeout( function() {
1061                        that.hideSubmenu();
1062                    }, that.hide_time);
1063                });
1064            }
1065        };
1066
1067        Catalog.prototype.toggleView = function(show) {
1068            var that = this,
1069                show_list;
1070
1071            clearTimeout(that.timer_1);
1072
1073            if (!that.is_locked) {
1074                if (show) {
1075                    if (show === "show") {
1076                        show_list = true;
1077                    } else if (show === "hide") {
1078                        show_list = false;
1079                    }
1080                } else {
1081                    show_list = !that.is_opened;
1082                }
1083
1084                if (show_list) {
1085                    that.$wrapper.addClass(that.open_class);
1086                    that.is_opened = true;
1087                } else {
1088                    that.$wrapper.removeClass(that.open_class);
1089                    that.is_opened = false;
1090                    that.hideSubmenu();
1091                }
1092            }
1093        };
1094
1095        Catalog.prototype.showSubmenu = function($li) {
1096            var that = this,
1097                is_active = $li.hasClass(that.hover_class);
1098
1099            clearTimeout(that.timer_2);
1100
1101            if (!is_active) {
1102                that.hideSubmenu();
1103                //
1104                setSubmenuWidth($li);
1105                //
1106                that.$activeMenu = $li.addClass(that.hover_class);
1107            }
1108
1109            function setSubmenuWidth( $li ) {
1110                var $sub_list = $li.find(".s-sub-wrapper");
1111                if ($sub_list.length) {
1112                    var width = that.$block.outerWidth() - that.$list.outerWidth() - 32 + 8;
1113                    $sub_list.css("width", width + "px");
1114                }
1115            }
1116        };
1117
1118        Catalog.prototype.hideSubmenu = function() {
1119            var that = this;
1120
1121            clearTimeout(that.timer_2);
1122
1123            if (that.$activeMenu) {
1124                that.$activeMenu.removeClass(that.hover_class);
1125                that.$activeMenu = false;
1126            }
1127        };
1128
1129        return Catalog;
1130
1131    })($);
1132
1133    // MAILER app email subscribe form
1134    var SubscribeSection = ( function($) {
1135
1136        SubscribeSection = function(options) {
1137            var that = this;
1138
1139            // DOM
1140            that.$wrapper = options["$wrapper"];
1141            that.$form = that.$wrapper.find("form");
1142            that.$emailField = that.$wrapper.find(".js-email-field");
1143            that.$submitButton = that.$wrapper.find(".js-submit-button");
1144
1145            // VARS
1146            that.request_uri = options["request_uri"];
1147            that.locales = options["locales"];
1148
1149            // DYNAMIC VARS
1150
1151            // INIT
1152            that.initClass();
1153        };
1154
1155        SubscribeSection.prototype.initClass = function() {
1156            var that = this;
1157
1158            if (that.request_uri.substr(0,4) === "http") {
1159                that.request_uri = that.request_uri.replace("http:", "").replace("https:", "");
1160            }
1161
1162            var $invisible_captcha = that.$form.find(".wa-invisible-recaptcha");
1163            if (!$invisible_captcha.length) {
1164                that.initView();
1165            }
1166
1167            that.initSubmit();
1168        };
1169
1170        SubscribeSection.prototype.initView = function() {
1171            var that = this;
1172
1173            that.$emailField.on("focus", function() {
1174                toggleView(true);
1175            });
1176
1177            $(document).on("click", watcher);
1178
1179            function watcher(event) {
1180                var is_exist = $.contains(document, that.$wrapper[0]);
1181                if (is_exist) {
1182                    var is_target = $.contains(that.$wrapper[0], event.target);
1183                    if (!is_target) {
1184                        toggleView(false);
1185                    }
1186                } else {
1187                    $(document).off("click", watcher);
1188                }
1189            }
1190
1191            function toggleView(show) {
1192                var active_class = "is-extended";
1193                if (show) {
1194                    that.$wrapper.addClass(active_class);
1195                } else {
1196                    var email_value = that.$emailField.val();
1197                    if (!email_value.length) {
1198                        that.$wrapper.removeClass(active_class);
1199                    } else {
1200
1201                    }
1202                }
1203            }
1204        };
1205
1206        SubscribeSection.prototype.initSubmit = function() {
1207            var that = this,
1208                $form = that.$form,
1209                $errorsPlace = that.$wrapper.find(".js-errors-place"),
1210                is_locked = false;
1211
1212            $form.on("submit", onSubmit);
1213
1214            function onSubmit(event) {
1215                event.preventDefault();
1216
1217                var formData = getData();
1218
1219                if (formData.errors.length) {
1220                    renderErrors(formData.errors);
1221                } else {
1222                    request(formData.data);
1223                }
1224            }
1225
1226            /**
1227             * @return {Object}
1228             * */
1229            function getData() {
1230                var result = {
1231                        data: [],
1232                        errors: []
1233                    },
1234                    data = $form.serializeArray();
1235
1236                $.each(data, function(index, item) {
1237                    if (item.value) {
1238                        result.data.push(item);
1239                    } else {
1240                        result.errors.push({
1241                            name: item.name
1242                        });
1243                    }
1244                });
1245
1246                return result;
1247            }
1248
1249            /**
1250             * @param {Array} data
1251             * */
1252            function request(data) {
1253                if (!is_locked) {
1254                    is_locked = true;
1255
1256                    var href = that.request_uri;
1257
1258                    $.post(href, data, "jsonp")
1259                        .always( function() {
1260                            is_locked = false;
1261                        })
1262                        .done( function(response) {
1263                            if (response.status === "ok") {
1264                                renderSuccess();
1265
1266                            } else if (response.errors) {
1267                                var errors = formatErrors(response.errors);
1268                                renderErrors(errors);
1269                            }
1270                        });
1271                }
1272
1273                /**
1274                 * @param {Object} errors
1275                 * @result {Array}
1276                 * */
1277                function formatErrors(errors) {
1278                    var result = [];
1279
1280                    $.each(errors, function(text, item) {
1281                        var name = item[0];
1282
1283                        if (name === "subscriber[email]") { name = "email"; }
1284
1285                        result.push({
1286                            name: name,
1287                            value: text
1288                        });
1289                    });
1290
1291                    return result;
1292                }
1293            }
1294
1295            /**
1296             * @param {Array} errors
1297             * */
1298            function renderErrors(errors) {
1299                var error_class = "error";
1300
1301                if (!errors || !errors[0]) {
1302                    errors = [];
1303                }
1304
1305                $.each(errors, function(index, item) {
1306                    var name = item.name,
1307                        text = item.value;
1308
1309                    var $field = that.$wrapper.find("[name=\"" + name + "\"]"),
1310                        $text = $("<span class='c-error' />").addClass("error");
1311
1312                    if ($field.length && !$field.hasClass(error_class)) {
1313                        if (text) {
1314                            $field.parent().append($text.text(text));
1315                        }
1316
1317                        $field
1318                            .addClass(error_class)
1319                            .one("focus click change", function() {
1320                                $field.removeClass(error_class);
1321                                $text.remove();
1322                            });
1323                    } else {
1324                        $errorsPlace.append($text);
1325
1326                        $form.one("submit", function() {
1327                            $text.remove();
1328                        });
1329                    }
1330                });
1331            }
1332
1333            function renderSuccess() {
1334                var $text = that.$wrapper.find(".js-success-message");
1335                $form.hide();
1336                $text.show();
1337            }
1338        };
1339
1340        return SubscribeSection;
1341
1342    })(jQuery);
1343
1344    var ScheduleSection = ( function($) {
1345
1346        ScheduleSection = function(options) {
1347            var that = this;
1348
1349            // DOM
1350            that.$wrapper = options["$wrapper"];
1351
1352            // VARS
1353
1354            // DYNAMIC VARS
1355
1356            // INIT
1357            that.initClass();
1358        };
1359
1360        ScheduleSection.prototype.initClass = function() {
1361            var that = this,
1362                $wrapper = that.$wrapper;
1363
1364            var open_class = "is-open";
1365
1366            $wrapper.on("click", ".js-show-schedule", function(event) {
1367                event.preventDefault();
1368                $wrapper.toggleClass(open_class);
1369            });
1370
1371            $wrapper.on("click", ".js-close-schedule", function(event) {
1372                event.preventDefault();
1373                $wrapper.removeClass(open_class);
1374            });
1375
1376            $(document).on("click", clickWatcher);
1377            function clickWatcher(event) {
1378                var is_exist = $.contains(document, $wrapper[0]);
1379                if (is_exist) {
1380                    var is_target = $.contains($wrapper[0], event.target);
1381                    if (!is_target) {
1382                        if ($wrapper.hasClass(open_class)) {
1383                            $wrapper.removeClass(open_class);
1384                        }
1385                    }
1386                } else {
1387                    $(document).off("click", clickWatcher);
1388                }
1389            }
1390
1391            $(document).on("keyup", keyWatcher);
1392            function keyWatcher(event) {
1393                var is_exist = $.contains(document, $wrapper[0]);
1394                if (is_exist) {
1395                    var is_escape = (event.keyCode === 27);
1396                    if (is_escape) {
1397                        if ($wrapper.hasClass(open_class)) {
1398                            $wrapper.removeClass(open_class);
1399                        }
1400                    }
1401                } else {
1402                    $(document).off("click", keyWatcher);
1403                }
1404            }
1405        };
1406
1407        return ScheduleSection;
1408
1409    })(jQuery);
1410
1411    // PAGES
1412
1413    var ProfilePage = ( function($) {
1414
1415        ProfilePage = function(options) {
1416            var that = this;
1417
1418            // DOM
1419            that.$wrapper = options["$wrapper"];
1420            that.locales = options["locales"];
1421
1422            // VARS
1423
1424            // DYNAMIC VARS
1425            that.is_locked = false;
1426            that.xhr = false;
1427
1428            // INIT
1429            that.initClass();
1430        };
1431
1432        ProfilePage.prototype.initClass = function() {
1433            var that = this;
1434
1435            that.initEditProfile();
1436        };
1437
1438        ProfilePage.prototype.initEditProfile = function() {
1439            var that = this,
1440                $wrapper = that.$wrapper.find(".js-form-wrapper");
1441
1442            if (!$wrapper.length) { return false; }
1443
1444            var ProfileSection = ( function($) {
1445
1446                ProfileSection = function(options) {
1447                    var that = this;
1448
1449                    // DOM
1450                    that.$wrapper = options["$wrapper"];
1451                    that.$editBlock = that.$wrapper.find(".js-edit-block");
1452                    that.$viewBlock = that.$wrapper.find(".js-view-block");
1453                    that.$passwordField = that.$editBlock.find(".wa-field-password");
1454                    that.$photoField = that.$editBlock.find(".wa-field-photo");
1455
1456                    // VARS
1457                    that.locales = options["locales"];
1458
1459                    // DYNAMIC VARS
1460
1461                    // INIT
1462                    that.initClass();
1463                };
1464
1465                ProfileSection.prototype.initClass = function() {
1466                    var that = this;
1467                    //
1468                    that.initBlockToggle();
1469                    //
1470                    if (that.$passwordField.length) {
1471                        that.initChangePassword();
1472                    }
1473                    //
1474                    if (that.$photoField.length) {
1475                        that.initPhotoSection();
1476                    }
1477                };
1478
1479                ProfileSection.prototype.initBlockToggle = function() {
1480                    var that = this;
1481
1482                    // show Edit Form
1483                    that.$wrapper.on("click", ".js-show-edit-form", function(event) {
1484                        event.preventDefault();
1485                        toggle(true);
1486                    });
1487
1488                    // hide edit Form
1489                    that.$wrapper.on("click", ".js-reset-form", function(event) {
1490                        event.preventDefault();
1491                        that.$wrapper.trigger("onReset");
1492                        toggle(false);
1493                    });
1494
1495                    /**
1496                     * @param {Boolean} show
1497                     * */
1498                    function toggle(show) {
1499                        if (show) {
1500                            that.$viewBlock.hide();
1501                            that.$editBlock.show();
1502
1503                        } else {
1504                            that.$editBlock.hide();
1505                            that.$viewBlock.show();
1506                        }
1507                    }
1508                };
1509
1510                ProfileSection.prototype.initChangePassword = function() {
1511                    var that = this,
1512                        $password = that.$passwordField,
1513                        $passwordBlock = $password.find("p"),
1514                        $changeLink = $("<a class=\"s-button s-change-password-button 
1514js-change-password\" href=\"javascript:void(0);\">" + that.locales["changePasswordText"] + "</a>").hide(),
1515                        hidden_class = "is-hidden",
1516                        is_changed = false;
1517
1518                    // Render
1519                    $password.find('.wa-value').prepend($changeLink);
1520
1521                    $changeLink.on("click", function(event) {
1522                        event.preventDefault();
1523                        toggle(true);
1524                    });
1525
1526                    var $viewChangePassword = that.$viewBlock.find(".js-change-password-force").show();
1527                    $viewChangePassword.on("click", function(event) {
1528                        event.preventDefault();
1529
1530                        that.$wrapper.find(".js-show-edit-form").trigger("click");
1531                        toggle(true);
1532                        setTimeout(function() {
1533                            $(window).scrollTop($password.offset().top);
1534                        }, 100)
1535                    });
1536
1537                    toggle(false);
1538
1539                    that.$wrapper.on("onReset", function() {
1540                        if (is_changed) {
1541                            toggle(false);
1542                        }
1543                    });
1544
1545                    /**
1546                     * @param {Boolean} show
1547                     * */
1548                    function toggle(show) {
1549                        if (show) {
1550                            $changeLink.hide();
1551                            $passwordBlock.removeClass(hidden_class);
1552
1553                        } else {
1554                            $changeLink.show();
1555                            $passwordBlock.addClass(hidden_class);
1556                        }
1557
1558                        is_changed = show;
1559                    }
1560                };
1561
1562                ProfileSection.prototype.initPhotoSection = function() {
1563                    var that = this,
1564                        $photo = that.$photoField,
1565                        $delete_photo_link = $("<a class=\"js-delete-photo\" href=\"javascript:void(0);\">" + that.locales["deletePhotoText"] + "</a>"),
1566                        $delete_link_wrapper = $("<p />").append($delete_photo_link),
1567                        $photo_input = $photo.find('[name="profile[photo]"]'),
1568                        $user_photo = $photo.find('img:first'),
1569                        $default_photo = $photo.find('img:last'),
1570                        photo_input_val = $photo_input.val(),
1571                        is_changed = false;
1572
1573                    if ($user_photo[0] !== $default_photo[0]) {
1574                        $default_photo.hide()
1575                            .after($delete_link_wrapper);
1576
1577                        $delete_photo_link.on("click", function(event) {
1578                            event.preventDefault();
1579                            toggle(true);
1580                        });
1581
1582                    } else {
1583                        $default_photo.show();
1584                    }
1585
1586                    that.$wrapper.on("onReset", function() {
1587                        if (is_changed) {
1588                            toggle(false);
1589                        }
1590                    });
1591
1592                    /**
1593                     * @param {Boolean} show
1594                     * */
1595                    function toggle(show) {
1596                        if (show) {
1597                            $user_photo.hide();
1598                            $default_photo.show();
1599                            $delete_photo_link.hide();
1600                            $photo_input.val('');
1601                        } else {
1602                            $user_photo.show();
1603                            $default_photo.hide();
1604                            $delete_photo_link.show();
1605                            $photo_input.val(photo_input_val);
1606                        }
1607
1608                        is_changed = show;
1609                    }
1610                };
1611
1612                return ProfileSection;
1613
1614            })($);
1615
1616            new ProfileSection({
1617                $wrapper: $wrapper,
1618                locales: that.locales
1619            });
1620        };
1621
1622        return ProfilePage;
1623
1624    })($);
1625
1626    //
1627
1628    waTheme.init.site.Layout = Layout;
1629    waTheme.init.site.Pane = Pane;
1630    waTheme.init.site.ProfilePage = ProfilePage;
1631    waTheme.init.site.FixedBlock = FixedBlock;
1632    waTheme.init.site.SubscribeSection = SubscribeSection;
1633    waTheme.init.site.ScheduleSection = ScheduleSection;
1634
1635    waTheme.init.shop.Compare = Compare;
1636    waTheme.init.shop.Cart = Cart;
1637    waTheme.init.shop.Catalog = Catalog;
1638
1639})(jQuery, window.waTheme);

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.