PageSourceSearch

https://techmkt.pro/wp-content/plugins/woo-smart-quick-view-premium/assets/js/frontend.js?ver=4.2.2

js techmkt.pro collected 2026-10-07 18:12:30 UTC 10,954 bytes, 329 lines download raw bytes

1'use strict';
2
3var woosq_ids = [], woosq_products = [];
4
5(function ($) {
6    $(function () {
7        $('.woosq-btn, .woosq-link').each(function () {
8            var id = $(this).attr('data-id');
9            var pid = $(this).attr('data-pid');
10            var product_id = $(this).attr('data-product_id');
11
12            if (typeof pid !== typeof undefined && pid !== false) {
13                id = pid;
14            }
15
16            if (typeof product_id !== typeof undefined && product_id !== false) {
17                id = product_id;
18            }
19
20            if (-1 === $.inArray(id, woosq_ids)) {
21                woosq_ids.push(id);
22                woosq_products.push({
23                    src: woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview') + '&product_id=' + id,
24                });
25            }
26        });
27
28        // quick view
29        if (woosq_vars.quick_view > 0) {
30            setTimeout(function () {
31                woosq_open(woosq_vars.quick_view);
32            }, 1000);
33        }
34    });
35
36    $(document).on('click touch', '[href*="#woosq-"]', function (e) {
37        var $this = $(this);
38        var href = $this.attr('href');
39        var reg = /#woosq-([0-9]+)/g;
40        var match = reg.exec(href);
41
42        if (match[1] !== undefined) {
43            var id = match[1];
44            var effect = $this.attr('data-effect');
45            var context = $this.attr('data-context');
46
47            woosq_open(id, effect, context);
48            e.preventDefault();
49        }
50    });
51
52    $(document).on('click touch', '.woosq-btn, .woosq-link', function (e) {
53        e.preventDefault();
54
55        var $this = $(this);
56        var id = $this.attr('data-id');
57        var pid = $this.attr('data-pid');
58        var product_id = $this.attr('data-product_id');
59        var effect = $this.attr('data-effect');
60        var context = $this.attr('data-context');
61
62        if (typeof pid !== typeof undefined && pid !== false) {
63            id = pid;
64        }
65
66        if (typeof product_id !== typeof undefined && product_id !== false) {
67            id = product_id;
68        }
69
70        woosq_open(id, effect, context);
71    });
72
73    $(document).on('added_to_cart', function () {
74        if (woosq_vars.auto_close === 'yes') {
75            if (woosq_vars.view === 'popup') {
76                $.magnificPopup.close();
77            }
78
79            woosq_close();
80        }
81    });
82
83    $(document).on('woosq_loaded', function () {
84        var form_variation = $('#woosq-popup').find('.variations_form');
85
86        form_variation.each(function () {
87            $(this).wc_variation_form();
88        });
89
90        woosq_init_content('loaded');
91
92        // add redirect
93        if (!$('#woosq-popup .woosq-redirect').length) {
94            if ((woosq_vars.cart_redirect === 'yes') &&
95                (woosq_vars.cart_url !== '')) {
96                $('#woosq-popup form').prepend(
97                    '<input class="woosq-redirect" name="woosq-redirect" type="hidden" value="' +
98                    woosq_vars.cart_url + '"/>');
99            } else {
100                $('#woosq-popup form').prepend(
101                    '<input class="woosq-redirect" name="woosq-redirect" type="hidden" value="' +
102                    window.location.href + '"/>');
103            }
104        }
105    });
106
107    $(window).on('resize', function () {
108        woosq_init_content('resize');
109    });
110
111    $(document).on('found_variation', function (e, t) {
112        if (!$(e['target']).closest('.woosb-product').length &&
113            !$(e['target']).closest('.woosg-product').length &&
114            !$(e['target']).closest('.woobt-product').length &&
115            !$(e['target']).closest('.woofs-product').length &&
116            $(e['target']).closest('#woosq-popup').length) {
117            if (t['image_id'] !== undefined) {
118                if ($('#woosq-popup .thumbnails .thumbnail').length > 1) {
119                    var $thumb = $(
120                        '.thumbnail:not(.slick-cloned)[data-id="' + t['image_id'] + '"]');
121
122                    if ($thumb.length) {
123                        var pos = $('#woosq-popup .thumbnails .thumbnail').index($thumb);
124                        var $images = $('#woosq-popup .thumbnails .images');
125
126                        if ((pos > 0) && $images.hasClass('slick-initialized')) {
127                            setTimeout(function () {
128                                $images.slick('slickGoTo', pos - 1);
129                            }, 100);
130                        }
131                    }
132                }
133            }
134        }
135    });
136
137    $(document).on('reset_data', function (e) {
138        if ($(e['target']).closest('#woosq-popup').length) {
139            if (($('#woosq-popup .thumbnails .thumbnail').length > 1) &&
140                $('#woosq-popup .thumbnails .images').hasClass('slick-initialized')) {
141                $('#woosq-popup .thumbnails .images').slick('slickGoTo', 0);
142            }
143        }
144    });
145
146    if (woosq_vars.hashchange === 'yes') {
147        $(window).on('hashchange', function () {
148            if (location.href.indexOf('#woosq') < 0) {
149                if (woosq_vars.view === 'popup') {
150                    $.magnificPopup.close();
151                }
152
153                woosq_close();
154            }
155        });
156    }
157
158    $(document).on('click touch', '.woosq-overlay, .woosq-close', function () {
159        woosq_close();
160    });
161})(jQuery);
162
163function woosq_open(id, effect, context) {
164    jQuery('body').addClass('woosq-open');
165
166    if (woosq_vars.view === 'sidebar') {
167        // sidebar
168        woosq_loading();
169
170        var data = {
171            action: 'woosq_quickview',
172            product_id: id,
173            context: context,
174            nonce: woosq_vars.nonce,
175        };
176
177        jQuery.post(woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview'), data, function (response) {
178            jQuery('.woosq-sidebar').html(response);
179            woosq_loaded();
180            jQuery(document.body).trigger('woosq_loaded', [id]);
181        });
182    } else {
183        // popup
184        if (-1 === jQuery.inArray(id, woosq_ids)) {
185            woosq_ids.push(id);
186            woosq_products.push({
187                src: woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview') + '&product_id=' + id,
188            });
189        }
190
191        var index = woosq_get_key(woosq_products, 'src',
192            woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview') + '&product_id=' + id);
193        var main_class = 'mfp-woosq';
194
195        if (typeof context !== typeof undefined && context !== false) {
196            main_class = main_class + ' mfp-woosq-' + context;
197        }
198
199        if (typeof effect !== typeof undefined && effect !== false) {
200            main_class = main_class + ' ' + effect;
201        } else {
202            main_class = main_class + ' ' + woosq_vars.effect;
203        }
204
205        jQuery.magnificPopup.open({
206            items: woosq_products,
207            type: 'ajax',
208            mainClass: main_class,
209            removalDelay: 160,
210            overflowY: 'scroll',
211            fixedContentPos: true,
212            tClose: woosq_vars.close,
213            gallery: {
214                tPrev: woosq_vars.prev,
215                tNext: woosq_vars.next,
216                enabled: woosq_vars.next_prev === 'yes',
217            },
218            ajax: {
219                settings: {
220                    type: 'GET', data: {
221                        nonce: woosq_vars.nonce,
222                    },
223                },
224            },
225            callbacks: {
226                open: function () {
227                    if (woosq_vars.hashchange === 'yes') {
228                        location.href = location.href.split('#')[0] + '#woosq';
229                    }
230                }, ajaxContentAdded: function () {
231                    jQuery(document.body).trigger('woosq_loaded', [id]);
232                }, close: function () {
233                    if (woosq_vars.hashchange === 'yes') {
234                        if (location.hash) history.go(-1);
235                    }
236                }, afterClose: function () {
237                    jQuery(document.body).trigger('woosq_close', [id]);
238                },
239            },
240        }, index);
241    }
242
243    jQuery(document.body).trigger('woosq_open', [id]);
244}
245
246function woosq_close() {
247    jQuery('body').removeClass('woosq-open');
248    jQuery(document.body).trigger('woosq_close');
249}
250
251function woosq_loading() {
252    jQuery('.woosq-sidebar').addClass('woosq-loading');
253}
254
255function woosq_loaded() {
256    jQuery('.woosq-sidebar').removeClass('woosq-loading');
257}
258
259function woosq_init_content(context) {
260    if (context === 'loaded') {
261        woosq_thumbnails_zoom();
262        woosq_thumbnails_slick();
263        woosq_related_slick();
264    }
265
266    if (woosq_vars.view === 'sidebar') {
267        if (woosq_vars.scrollbar === 'yes') {
268            jQuery('.woosq-product').perfectScrollbar('destroy').perfectScrollbar({theme: 'wpc'});
269        }
270    } else {
271        // fix for popup
272        if (woosq_vars.scrollbar === 'yes') {
273            if (jQuery(window).width() < 1024) {
274                jQuery('.woosq-product .summary-content').perfectScrollbar('destroy');
275                jQuery('.woosq-product').perfectScrollbar('destroy').perfectScrollbar({theme: 'wpc'});
276            } else {
277                jQuery('.woosq-product').perfectScrollbar('destroy');
278                jQuery('.woosq-product .summary-content').perfectScrollbar('destroy').perfectScrollbar({theme: 'wpc'});
279            }
280        }
281    }
282}
283
284function woosq_get_key(array, key, value) {
285    for (var i = 0; i < array.length; i++) {
286        if (array[i][key] === value) {
287            return i;
288        }
289    }
290
291    return -1;
292}
293
294function woosq_thumbnails_zoom() {
295    if (woosq_vars.thumbnails_effect === 'zoom') {
296        jQuery('#woosq-popup .thumbnails .images .thumbnail').each(function () {
297            var $this = jQuery(this);
298            var zoom_params = JSON.parse(woosq_vars.thumbnails_zoom_params);
299
300            zoom_params.url = $this.find('img').attr('data-src');
301
302            // destroy first
303            $this.trigger('zoom.destroy');
304            $this.zoom(zoom_params);
305        });
306    }
307}
308
309function woosq_thumbnails_slick() {
310    if (jQuery('#woosq-popup .thumbnails .images .thumbnail').length > 1) {
311        if (jQuery('#woosq-popup .thumbnails .images').hasClass('slick-initialized')) {
312            // unslick first
313            jQuery('#woosq-popup .thumbnails .images').slick('unslick');
314        }
315
316        jQuery('#woosq-popup .thumbnails .images').slick(JSON.parse(woosq_vars.thumbnails_slick_params));
317    }
318}
319
320function woosq_related_slick() {
321    if (jQuery('.woosq-related-products').hasClass('slick-initialized')) {
322        // unslick first
323        jQuery('.woosq-related-products').slick('unslick');
324    }
325
326    if (jQuery('.woosq-related-product').length > 1) {
327        jQuery('.woosq-related-products').slick(JSON.parse(woosq_vars.related_slick_params));
328    }
329}

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.