PageSourceSearch

https://ritualpom.ru/g/templates/shop2/2.27.2/js/product.quick.view.js

js ritualpom.ru collected 2026-10-07 18:01:48 UTC 4,894 bytes, 131 lines download raw bytes

1$(function(){
2
3    var quick_view_class = "product-quick-view";
4    var $quick_view_trigger;
5    var ind;
6
7    $(document).on("click", ".quick-view-trigger", function (e) {
8        e.preventDefault();
9        if (!$quick_view_trigger) {
10            $quick_view_trigger = $(".quick-view-trigger");
11        };
12        var $this = $(this);
13        var url = $this.attr("data-url") || $this.attr("href");
14        ind = $quick_view_trigger.index($this);
15        loadProduct(url, function (){
16            checkQuickViews(ind);
17        });
18    });
19
20    $(document).on("click", ".quick-view-trigger-modification", function (e) {
21        e.preventDefault();
22        var $this = $(this);
23        var url = $this.attr("data-url") || $this.attr("href");
24        loadProduct(url, function (){
25            checkQuickViews(ind);
26        });
27    });
28
29    if (shop2 && shop2.product && shop2.product._reload) {
30        var reload = shop2.product._reload;
31        //console.log(reload);
32
33        shop2.product._reload = function(node) {
34            var args = Array.prototype.slice.call(arguments, 0);
35            var popoverDiv = $(node).closest("." + quick_view_class);
36            if (popoverDiv.length) {
37                reloadProduct(node);
38            } else {
39                reload.apply(this, args);
40            }
41        }
42    }
43
44    function loadProduct (url, callback) {
45        if (!myo) return false;
46        if (myo.stack.length && myo.stack[myo.stack.length-1].wrapDiv.hasClass(quick_view_class)) {
47            myo.close();
48        };       
49        myo.open({
50            ajax: url,
51            ajaxData: {"products_only": 1, "shop2_mode": shop2.mode},
52            wrapClass: quick_view_class,
53            onContentLoad: function () {
54                var win = myo.stack[myo.stack.length-1];
55                win.bodyDiv.find("img").load(function () {
56                    win.setPosition();
57                });
58                var thumbs = win.bodyDiv.find(".gal-thumb");
59                if (thumbs.length) {
60                    thumbs.scrollerM({
61                        liquid: false,
62                        infinite: false,
63                        autoScroll: false,
64                        stopOnHover: false,
65                        waitLoad: true,
66                        movecount: 1,
67                        vertical: !(thumbs.closest(".product-left").hasClass("horizontal"))
68                    });
69                };
70                if ($.isFunction(callback)) {
71                    callback();
72                };
73            }
74        });
75    }
76
77    function reloadProduct(node) {
78        var $node = $(node),
79            kinds = shop2.product.getNodeData(node, 'kinds', true),
80            paramName = shop2.product.getNodeData(node, 'name'),
81            paramValue = shop2.product.getNodeData(node, 'value'),
82            $form = $node.closest('form'),
83            form = $form.get(0),
84            meta, kind_id, product_id;
85
86        if (kinds && $.type(paramName) !== 'undefined' && $.type(paramValue) !== 'undefined' && form) {
87
88            if (form.elements.meta) {
89                meta = $.parseJSON(form.elements.meta.value);
90            }
91
92            product_id = form.elements.product_id.value;
93
94            $form.find('[name=submit]').prop('disabled', true);
95
96            kind_id = shop2.product.findKindId(product_id, kinds, paramName, paramValue, meta);
97
98            if (kind_id === 0) return false;
99
100            // url = document.location.href.replace(/\/folder\/(.+)/i, '/product/' + kind_id);
101
102            var url = window.location.protocol + "//" + window.location.host + shop2.uri + "/product/" + kind_id + "?product_preview";
103
104            loadProduct(url, function () {
105                checkQuickViews(ind);
106            });
107        }
108    }
109
110    function checkQuickViews (ind) {
111        var prev_product = ind-1 >= 0 ? $quick_view_trigger.eq(ind-1) : null,
112            next_product = ind+1 < $quick_view_trigger.length ? $quick_view_trigger.eq(ind+1) : null,
113            prev_product_caller,
114            next_product_caller;
115
116        myo.stack[myo.stack.length-1].bodyDiv.append('<div class="prev_product_caller hide"></div><div class="next_product_caller hide"></div>');
117        prev_product_caller = myo.stack[myo.stack.length-1].bodyDiv.find(".prev_product_caller");
118        next_product_caller = myo.stack[myo.stack.length-1].bodyDiv.find(".next_product_caller");
119
120        if (prev_product) {
121            prev_product_caller.removeClass("hide").on("click", function () {
122                prev_product.trigger("click");
123            });
124        };
125        if (next_product) {
126            next_product_caller.removeClass("hide").on("click", function () {
127                next_product.trigger("click");
128            });
129        };
130    }
131});

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.