PageSourceSearch

https://cholita.gal/wp-content/plugins/clever-swatches/assets/js/single-product-page-swatch.js

js cholita.gal collected 2026-10-08 07:25:06 UTC 37,543 bytes, 625 lines download raw bytes

1(function ($) {
2    'use strict';
3    $(document).ready(function () {
4        /*Clever Swatches gallery*/
5        cw_product_gallery();
6
7        function cw_product_gallery() {
8            var icon_up = '<svg height="40px" tyle="enable-background:new 0 0 40 40;" version="1.1" viewBox="0 0 512 512" width="40px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><polygon points="396.6,352 416,331.3 256,160 96,331.3 115.3,352 256,201.5 "/></svg>';
9            var icon_down = '<svg height="40px" tyle="enable-background:new 0 0 40 40;" version="1.1" viewBox="0 0 512 512" width="40px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><polygon points="396.6,160 416,180.7 256,352 96,180.7 115.3,160 256,310.5 "/></svg>';
10            var icon_prev = '<svg height="40px" tyle="enable-background:new 0 0 40 40;" version="1.1" viewBox="0 0 512 512" width="40px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><polygon points="352,115.4 331.3,96 160,256 331.3,416 352,396.7 201.5,256 "/></svg>';
11            var icon_next = '<svg height="40px" tyle="enable-background:new 0 0 40 40;" version="1.1" viewBox="0 0 512 512" width="40px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><polygon points="160,115.4 180.7,96 352,256 180.7,416 160,396.7 310.5,256 "/></svg>';
12            if ($('.cw-product-gallery')[0]) {
13                $('.cw-product-gallery .cw-product-gallery-main').slick({
14                    slidesToShow: 1,
15                    slidesToScroll: 1,
16                    rtl: $('body.rtl')[0] ? true : false,
17                    rows: 0,
18                    swipe: true,
19                    asNavFor: '.cw-product-gallery .cw-product-gallery-thumbs',
20                    prevArrow: '<span class="cw-product-gallery-btn prev-item">' + icon_prev + '</span>',
21                    nextArrow: '<span class="cw-product-gallery-btn next-item ">' + icon_next + '</span>',
22                });
23                var columns = $('.cw-product-gallery .cw-product-gallery-thumbs').data('thumb-columns');
24                var vertical = $('.cw-product-gallery.vertical')[0] ? true : false;
25                let next = !vertical ? icon_prev : icon_up;
26                let prev = !vertical ? icon_next : icon_down;
27                $('.cw-product-gallery .cw-product-gallery-thumbs').slick({
28                    slidesToShow: columns,
29                    slidesToScroll: 1,
30                    rtl: $('body.rtl')[0] ? true : false,
31                    rows: 0,
32                    focusOnSelect: true,
33                    vertical: vertical,
34                    verticalSwiping: vertical,
35                    asNavFor: '.cw-product-gallery .cw-product-gallery-main',
36                    prevArrow: '<span class="cw-product-gallery-btn prev-item">' + next + '</span>',
37                    nextArrow: '<span class="cw-product-gallery-btn next-item ">' + prev + '</span>',
38                });
39                //Gallery Zoom
40                var w_width = '';
41                $(window).resize(function () {
42                    if (w_width != $(window).width()) {
43                        if (typeof  $.fn.zoom != 'undefined') {
44                            $('.cw-product-gallery .cw-product-gallery-main .woocommerce-product-gallery__image a').trigger('zoom.destroy');
45                            if ($(window).width() > 768) {
46                                $('.cw-product-gallery .cw-product-gallery-main .woocommerce-product-gallery__image a').zoom();
47                            }
48                        }
49                        w_width = $(window).width();
50                    }
51                }).resize();
52            }
53        }
54        /*End Clever Swatches gallery*/
55        function cw_findMatchVariation(product_variations, check_options) {
56            var match_variation = false;
57            $.each(product_variations, function (key, value) {
58                var product_variation = value;
59                var attribute_case = product_variation.attributes;
60                var count_check = Object.keys(check_options).length;
61
62                $.each(check_options, function (key, value) {
63                    if ((attribute_case[key] == "") || (value == attribute_case[key])) {
64                        count_check--;
65                    }
66                });
67                if (count_check <= 0) {
68                    match_variation = value;
69                    // break jquery each loop
70                    return false;
71                }
72                //}
73            });
74            return match_variation;
75        }
76
77        function cw_runFilter(product_variations, selected_options, attribute_rows, disable_class, enable_class) {
78            attribute_rows.each(function () {
79                var current_attribute_row = $(this);
80                var attribute_name = current_attribute_row.data('group-attribute');
81                var check_options = {};
82                check_options = $.extend({}, selected_options);
83                var attribute_display_type = $(this).data('attribute-display-type');
84                if (attribute_display_type == 'default') {
85                    if (disable_class == 'unavailable') { //only run filter on click event
86                        //this for select type option
87                        $(this).find('select.zoo-cw-attribute-select option').each(function () {
88                            var option_value = $(this).val();
89                            if (option_value != '') {
90                                var option_text = $(this).text();
91                                var new_text = option_text.replace(' * (Not suitable)', '');
92                                check_options[attribute_name] = option_value;
93                                if (cw_findMatchVariation(product_variations, check_options, true)) {
94                                    $(this).text(new_text);
95                                } else {
96                                    $(this).text(new_text + ' * (Not suitable)');
97                                }
98                            }
99                        });
100                    }
101                } else {
102                    //this for other type option
103                    var options = $(this).find('.zoo-cw-attribute-option');
104                    options.each(function () {
105                        var option = $(this);
106                        var option_value = $(this).data('attribute-option');
107                        check_options[attribute_name] = option_value;
108                        if (cw_findMatchVariation(product_variations, check_options, true)) {
109                            option.addClass(enable_class).removeClass(disable_class);
110                        } else {
111                            option.addClass(disable_class).removeClass(enable_class);
112                        }
113                    });
114                }
115            });
116        }
117
118        function cw_processSelectedOption(product_variations, selected_options, form_add_to_cart) {
119            var old_variation_id = form_add_to_cart.find('input[name=old_variation_id]').val();
120            var gallery_enabled = form_add_to_cart.data('gallery_enabled');
121            var add_to_cart_button = form_add_to_cart.find('.single_add_to_cart_button:not(.zoo-buy-now)');
122            var variation_id = 0;
123
124            var match_variation = cw_findMatchVariation(product_variations, selected_options);
125            if (match_variation) {
126                variation_id = match_variation.variation_id;
127            }
128            //trigger default function of woocommerce
129            if (gallery_enabled) {
130                if (variation_id != old_variation_id) {
131                    form_add_to_cart.find('input[name=variation_id]').val(variation_id);
132                    form_add_to_cart.find('input[name=old_variation_id]').val(variation_id);
133
134                    if (variation_id != 0) {
135                        if (match_variation.is_in_stock && match_variation.is_purchasable) {
136                            $(document).trigger('cleverswatch_button_add_cart', {
137                                "selector": add_to_cart_button
138                            });
139                        } else {
140                            $(document).trigger('cleverswatch_button_out_stock', {
141                                "selector": add_to_cart_button
142                            });
143                        }
144                        var template = wp.template('variation-template');
145                        var template_html = template({
146                            variation: match_variation
147                        });
148                        form_add_to_cart.find('.woocommerce-variation.single_variation').html(template_html).show();
149
150                        var product_id = form_add_to_cart.data('product_id');
151                        $('.product_meta .sku').html(match_variation.sku);
152
153                        cw_updateGallery(form_add_to_cart, product_id, selected_options, variation_id);
154                    } else {
155                        add_to_cart_button.html(wp.template('add-to-cart-button-out-stock')).addClass('disabled 
155wc-variation-selection-needed');
156                        var template_html = wp.template('unavailable-variation-template');
157                        form_add_to_cart.find('.woocommerce-variation.single_variation').html(template_html).show();
158                    }
159                }
160            } else {
161                $('.variations_form').trigger('found_variation', [match_variation]);
162            }
163        }
164
165        function cw_ResetOptions(form_add_to_cart) {
166            var product_id = form_add_to_cart.data('product_id');
167            var gallery_enabled = form_add_to_cart.data('gallery_enabled');
168            $(document).trigger('.reset_variations');
169            //trigger default function of woocommerce
170            if (gallery_enabled) {
171                if (product_id != '') {
172                    cw_updateGallery(form_add_to_cart, product_id, '', '');
173                }
174            }
175        }
176
177        var wrap_class = !!zoo_cw_params.product_image_custom_class ? zoo_cw_params.product_image_custom_class : 'div.woocommerce-product-gallery,div.images';
178
179        function cw_updateGallery(form_add_to_cart, product_id, selected_options, variation_id) {
180            $(document).trigger('cleverswatch_before_update_gallery', {
181                "product_id": product_id,
182                "selected_options": selected_options
183            });
184            var ajax_url = zoo_cw_params.ajax_url;
185            var $gallery = $('#product-' + product_id).find(wrap_class).parent();
186            if ($('.elementor-type-product.post-' + product_id + ' ' + wrap_class)[0]) {
187                $gallery = $('.elementor-type-product.post-' + product_id + ' ' + wrap_class).parent();
188            } else if ($('.elementor.product.post-' + product_id + ' ' + wrap_class)[0]) {
189                $gallery = $('.elementor.product.post-' + product_id + ' ' + wrap_class).parent();
190            }
191            if ($('.cw-product-gallery')[0]) {
192                $gallery = $('#product-' + product_id).find('.cw-product-gallery').parent();
193                if ($('.elementor-type-product.post-' + product_id + ' .cw-product-gallery')[0]) {
194                    $gallery = $('.elementor-type-product.post-' + product_id + ' .cw-product-gallery').parent();
195                }
196                else if ($('.elementor.product.post-' + product_id + ' .cw-product-gallery')[0]) {
197                    $gallery = $('.elementor.product.post-' + product_id + ' .cw-product-gallery').parent();
198                }
199            }
200            $gallery.addClass('zoo-cw-gallery-loading');
201
202            $.ajax({
203                url: ajax_url,
204                cache: false,
205                type: "POST",
206                data: {
207                    'action': 'clever_swatch_action',
208                    'product_id': product_id,
209                    'selected_options': selected_options,
210                    'variation_id': variation_id
211                }, success: function (response) {
212                    if (!!response) {
213                        if (response.cw_gallery_enabled) {
214                            //trigger for update CW gallery
215                            $(document).trigger('cleverswatch_update_cw_gallery', {
216                                "content": response.html_content,
217                                "product_id": product_id,
218                                "form_add_to_cart": form_add_to_cart,
219                                "variation_id": response.variation_id,
220                                "variation_data": response.variation_data,
221                            });
222                        } else {
223                            //trigger for update integrated gallery
224                            $(document).trigger('cleverswatch_update_gallery', {
225                                "content": response.html_content,
226                                "product_id": product_id,
227                                "form_add_to_cart": form_add_to_cart,
228                                "variation_id": response.variation_id,
229                                "variation_data": response.variation_data,
230                            });
231                        }
232                    }
233                }, error: function (jqXHR, textStatus) {
234                    console.log(jqXHR);
235                }
236            });
237        }
238
239        function iOS() {
240
241            var iDevices = [
242                'iPad Simulator',
243                'iPhone Simulator',
244                'iPod Simulator',
245                'iPad',
246                'iPhone',
247                'iPod'
248            ];
249
250            if (!!navigator.platform) {
251                while (iDevices.length) {
252                    if (navigator.platform === iDevices.pop()){ return true; }
253                }
254            }
255
256            return false;
257        }
258
259        if (!$('.variations_form.no-cw-data')[0]) {
260            //click function for image/text/color types option
261            $(document).on('click', '.variations_form .zoo-cw-attribute-option', function () {
262                var form_add_to_cart = $(this).parents('.variations_form');
263                var attribute_rows = form_add_to_cart.find('.zoo-cw-group-attribute');
264                var current_attribute_row = $(this).parents('.zoo-cw-group-attribute');
265                var attribute_name = current_attribute_row.data('group-attribute');
266                var product_variations = form_add_to_cart.data('product_variations');
267                var selected_option_name = $(this).data('attribute-name');
268                var option_value = $(this).data('attribute-option');
269                var selected_options = form_add_to_cart.data('selected_options');
270                if (selected_options === undefined) {
271                    selected_options = {};
272                }
273                if ($(this).hasClass('zoo-cw-active')) {
274                    //visual
275                    $(this).removeClass('zoo-cw-active');
276                    current_attribute_row.parents('.zoo-cw-attr-row').find('.zoo-cw-name').text('');
277                    //process
278                    current_attribute_row.find('input[name="' + attribute_name + '"]').val('');
279                    delete selected_options[attribute_name];
280                    form_add_to_cart.data('selected_options', selected_options);
281                    cw_runFilter(product_variations, selected_options, attribute_rows, 'unavailable', "");
282                    //disable add to cart button
283                    form_add_to_cart.find('input[name=variation_id]').val('');
284                    form_add_to_cart.find('button.single_add_to_cart_button').addClass('disabled wc-variation-selection-needed');
285                    form_add_to_cart.find('.woocommerce-variation.single_variation').hide();
286                    current_attribute_row.find('select').val('');
287                    if (!form_add_to_cart.find('.zoo-cw-attribute-option.zoo-cw-active')[0]) {
288                        cw_ResetOptions(form_add_to_cart);
289                    }
290                } else {
291                    var options = current_attribute_row.find('.zoo-cw-attribute-option');
292                    //visual
293                    options.removeClass('zoo-cw-active');
294                    $(this).addClass('zoo-cw-active');
295                    current_attribute_row.parents('.zoo-cw-attr-row').find('.zoo-cw-name').text(selected_option_name);
296                    //process
297                    current_attribute_row.find('input[name="' + attribute_name + '"]').val(option_value);
298                    current_attribute_row.find('select option:selected').attr('selected', '');
299                    current_attribute_row.find("select option[value='" + option_value + "']").attr('selected', 'selected');
300
301                    selected_options[attribute_name] = option_value;
302                    form_add_to_cart.data('selected_options', selected_options);
303                    cw_runFilter(product_variations, selected_options, attribute_rows, 'unavailable', "");
304                    //apply to cart
305                    var attributes_count = form_add_to_cart.data('attributes_count');
306                    if (Object.keys(selected_options).length == attributes_count) {
307                        cw_processSelectedOption(product_variations, selected_options, form_add_to_cart);
308                    } else {
309                        form_add_to_cart.find('button.single_add_to_cart_button').addClass('disabled wc-variation-selection-needed');
310                        form_add_to_cart.find('.woocommerce-variation.single_variation').hide();
311                    }
312                }
313                current_attribute_row.find('select').trigger('change');
314                $(".variations_form").trigger("woocommerce_variation_select_change");
315            });
316
317            //hover function for image/text/color types option
318
319            var temp_option_value = '';
320            $(window).resize(function () {
321                if(!iOS()) {
322                    if ($(window).width() > 769 && $('.zoo-cw-is-desktop')[0]) {
323                        $(document).on({
324                            mouseenter: function () {
325                                var form_add_to_cart = $(this).parents('.variations_form');
326                                var attribute_rows = form_add_to_cart.find('.zoo-cw-group-attribute');
327                                var current_attribute_row = $(this).parents('.zoo-cw-group-attribute');
328                                var attribute_name = current_attribute_row.data('group-attribute');
329                                var product_variations = form_add_to_cart.data('product_variations');
330                                var option_value = $(this).data('attribute-option');
331                                if (option_value != temp_option_value) {
332                                    temp_option_value = option_value;
333                                    var selected_options = form_add_to_cart.data('selected_options');
334                                    if (selected_options === undefined) {
335                                        selected_options = {};
336                                    }
337                                    //visual
338                                    var new_option_name = $(this).data('attribute-name');
339                                    current_attribute_row.parents('.zoo-cw-attr-row').find('.zoo-cw-name').text(new_option_name);
340                                    //process
341                                    var check_options = $.extend({}, selected_options);
342                                    check_options[attribute_name] = option_value;
343                                    cw_runFilter(product_variations, check_options, attribute_rows, 'temp-unavailable', 'temp-available');
344
345                                    //add to cart button effect
346                                    var add_to_cart_button = form_add_to_cart.find('.single_add_to_cart_button:not(.zoo-buy-now)');
347                                    var attributes_count = form_add_to_cart.data('attributes_count');
348                                    if (Object.keys(check_options).length == attributes_count) {
349                                        var match_variation = cw_findMatchVariation(product_variations, check_options);
350                                        if (match_variation) {
351                                            if (match_variation.is_in_stock && match_variation.is_purchasable) {
352                                                $(document).trigger('cleverswatch_button_add_cart', {
353                                                    "selector": add_to_cart_button
354                                                });
355                                            } else {
356                                                $(document).trigger('cleverswatch_button_out_stock', {
357                                                    "selector": add_to_cart_button
358                                                });
359                                            }
360
361                                            var template = wp.template('variation-template');
362                                            var template_html = template({
363                                                variation: match_variation
364                                            });
365                                            form_add_to_cart.find('.woocommerce-variation.single_variation').html(template_html);
366                                            if ($('.single_variation_wrap .single_variation').css('display') == 'none') {
367                                                form_add_to_cart.find('.woocommerce-variation.single_variation').slideDown()
368                                            }
369                                        } else {
370                                            $(document).trigger('cleverswatch_button_out_stock', {
371                                                "selector": add_to_cart_button
372                                            });
373                                            var template = wp.template('unavailable-variation-template');
374                                            form_add_to_cart.find('.woocommerce-variation.single_variation').html(template);
375                                            if ($('.single_variation_wrap .single_variation').css('display') == 'none') {
376                                                form_add_to_cart.find('.woocommerce-variation.single_variation').slideDown()
377                                            }
378                                        }
379
380                                    } else {
381                                        $(document).trigger('cleverswatch_button_select_option', {
382                                            "selector": add_to_cart_button
383                                        });
384                                        form_add_to_cart.find('.woocommerce-variation.single_variation').slide
384Up();
385                                    }
386                                }
387                            },
388                            mouseleave: function () {
389                                if (temp_option_value != '') {
390                                    temp_option_value = '';
391                                    var form_add_to_cart = $(this).parents('.variations_form');
392                                    var attribute_rows = form_add_to_cart.find('.zoo-cw-group-attribute');
393                                    var current_attribute_row = $(this).parents('.zoo-cw-group-attribute');
394                                    //visual
395                                    attribute_rows.find('.zoo-cw-attribute-option').removeClass('temp-unavailable').removeClass('temp-available');
396                                    var selected_option_name = current_attribute_row.find('.zoo-cw-attribute-option.zoo-cw-active').data('attribute-name');
397                                    if (selected_option_name === undefined) {
398                                        selected_option_name = '';
399                                    }
400                                    current_attribute_row.parents('.zoo-cw-attr-row').find('.zoo-cw-name').text(selected_option_name);
401
402                                    //add to cart button effect
403                                    var add_to_cart_button = form_add_to_cart.find('.single_add_to_cart_button:not(.zoo-buy-now)');
404                                    var product_variations = form_add_to_cart.data('product_variations');
405
406
407                                    var selected_options = form_add_to_cart.data('selected_options');
408                                    if (selected_options === undefined) {
409                                        selected_options = {};
410                                    }
411                                    var attributes_count = form_add_to_cart.data('attributes_count');
412                                    if (Object.keys(selected_options).length == attributes_count) {
413                                        var match_variation = cw_findMatchVariation(product_variations, selected_options);
414                                        if (match_variation) {
415                                            if (match_variation.is_in_stock && match_variation.is_purchasable) {
416                                                $(document).trigger('cleverswatch_button_add_cart', {
417                                                    "selector": add_to_cart_button
418                                                });
419                                            } else {
420                                                $(document).trigger('cleverswatch_button_out_stock', {
421                                                    "selector": add_to_cart_button
422                                                });
423                                            }
424                                            var template = wp.template('variation-template');
425                                            var template_html = template({
426                                                variation: match_variation
427                                            });
428                                            form_add_to_cart.find('.woocommerce-variation.single_variation').html(template_html);
429                                            if ($('.single_variation_wrap .single_variation').css('display') == 'none') {
430                                                form_add_to_cart.find('.woocommerce-variation.single_variation').slideDown()
431                                            }
432                                        } else {
433                                            $(document).trigger('cleverswatch_button_out_stock', {
434                                                "selector": add_to_cart_button
435                                            });
436                                            var template = wp.template('unavailable-variation-template');
437                                            form_add_to_cart.find('.woocommerce-variation.single_variation').html(template);
438                                            if ($('.single_variation_wrap .single_variation').css('display') == 'none') {
439                                                form_add_to_cart.find('.woocommerce-variation.single_variation').slideDown()
440                                            }
441                                        }
442                                    } else {
443                                        $(document).trigger('cleverswatch_button_select_option', {
444                                            "selector": add_to_cart_button
445                                        });
446                                    }
447                                }
448                            }
449                        }, '.variations_form .zoo-cw-attribute-option');
450                        $(document).on({
451                            mouseleave: function () {
452                                if (!$(this).find('.zoo-cw-active')[0]) {
453                                    $(this).parents('.variations_form').find('.woocommerce-variation.single_variation').slide
453Up();
454                                }
455                            }
456                        }, '.variations_form .zoo-cw-group-attribute:not(.zoo-cw-type-default)');
457                    }
458                }
459            }).resize();
460            //pass the element as an argument to .on
461            //change function for select type option
462            $(document).on('change', '.variations_form .zoo-cw-group-attribute select.zoo-cw-attribute-select', function () {
463                var form_add_to_cart = $(this).parents('.variations_form');
464                var attribute_rows = form_add_to_cart.find('.zoo-cw-group-attribute');
465                var current_attribute_row = $(this).parents('.zoo-cw-group-attribute');
466                var attribute_name = current_attribute_row.data('group-attribute');
467                var product_variations = form_add_to_cart.data('product_variations');
468                var selected_options = form_add_to_cart.data('selected_options');
469                if (selected_options === undefined) {
470                    selected_options = {};
471                }
472                var selected_option_name = '';
473                var option_value = $(this).val();
474                var single_variation = $(this).parents('.variations_form').find('.woocommerce-variation.single_variation');
475                if (option_value == "") {
476                    selected_option_name = "";
477                    single_variation.slideUp();
478                } else {
479                    selected_option_name = $(this).find('option:selected').text();
480                    single_variation.slideDown();
481                }
482                //visual
483                current_attribute_row.parents('.zoo-cw-attr-row').find('.zoo-cw-name').text(selected_option_name);
484                //process
485                current_attribute_row.find('input[name="' + attribute_name + '"]').val(option_value);
486                selected_options[attribute_name] = option_value;
487                form_add_to_cart.data('selected_options', selected_options);
488                cw_runFilter(product_variations, selected_options, attribute_rows, 'unavailable', "");
489                //apply to cart
490                var attributes_count = form_add_to_cart.data('attributes_count');
491                if (Object.keys(selected_options).length == attributes_count) {
492                    cw_processSelectedOption(product_variations, selected_options, form_add_to_cart);
493                } else {
494                    form_add_to_cart.find('button.single_add_to_cart_button').addClass('disabled wc-variation-selection-needed');
495                }
496                if (option_value == '') {
497                    form_add_to_cart.find('button.single_add_to_cart_button').addClass('disabled wc-variation-selection-needed');
498                }
499                $(".variations_form").trigger("woocommerce_variation_select_change");
500            });
501        }
502
503        //binding update cw gallery
504        $(document).bind('cleverswatch_update_cw_gallery', function (event, response) {
505            var cw_gallery = $('#product-' + response.product_id).find('.cw-product-gallery');
506            if ($('.elementor-type-product.post-' + response.product_id + ' .cw-product-gallery')[0]) {
507                cw_gallery = $('.elementor-type-product.post-' + response.product_id + ' .cw-product-gallery');
508            }
509            if ($('.elementor.product.post-' + response.product_id + ' .cw-product-gallery')[0]) {
510                cw_gallery = $('.elementor.product.post-' + response.product_id + ' .cw-product-gallery');
511            }
512            if (cw_gallery.length) {
513                cw_gallery.replaceWith(response.content);
514                setTimeout(function () {
515                    cw_product_gallery();
516                    cw_gallery.wc_product_gallery();
517                }, 300);
518            }
519            setTimeout(function () {
520                $('.zoo-cw-gallery-loading').removeClass('zoo-cw-gallery-loading');
521            }, 300);
522        });
523        //binding update gallery
524        $(document).bind('cleverswatch_update_gallery', function (event, response) {
525            var imagesDiv = $('#product-' + response.product_id).find(wrap_class);
526            if ($('.elementor-type-product.post-' + response.product_id + ' ' + wrap_class)[0]) {
527                imagesDiv = $('.elementor-type-product.post-' + response.product_id + ' ' + wrap_class);
528            }
529            if ($('.elementor.product.post-' + response.product_id + ' ' + wrap_class)[0]) {
530                imagesDiv = $('.elementor.product.post-' + response.product_id + ' ' + wrap_class);
531            }
532            if (jQuery(imagesDiv).length) {
533                imagesDiv.replaceWith(response.content);
534                setTimeout(function () {
535                    if (!!zoo_cw_params.slider_support && typeof $.fn.wc_product_gallery !== "undefined") {
536                        imagesDiv.wc_product_gallery();
537                    }
538                }, 100)
539            }
540            setTimeout(function () {
541                $('.zoo-cw-gallery-loading').removeClass('zoo-cw-gallery-loading');
542            }, 100)
543        });
544        //Bind for button if button is select option
545        $(document).bind('cleverswatch_button_select_option', function (event, response) {
546            var add_to_cart_button = response.selector;
547            var icon = add_to_cart_button.find('i').clone();
548            add_to_cart_button.html(wp.template('add-to-cart-button-select-option')).addClass('disabled 
548wc-variation-selection-needed');
549            add_to_cart_button.prepend(icon);
550        });
551        //Bind for button if button is Add to Cart
552        $(document).bind('cleverswatch_button_add_cart', function (event, response) {
553            var add_to_cart_button = response.selector;
554            var icon = add_to_cart_button.find('i').clone();
555            add_to_cart_button.html(wp.template('add-to-cart-button')).removeClass('disabled wc-variation-selection-needed wc-variation-is-unavailable');
556            add_to_cart_button.prepend(icon);
557        });
558        //Bind for button if button is Out of stock
559        $(document).bind('cleverswatch_button_out_stock', function (event, response) {
560            var add_to_cart_button = response.selector;
561            var icon = add_to_cart_button.find('i').clone();
562            add_to_cart_button.html(wp.template('add-to-cart-button-out-stock')).addClass('disabled wc-variation-is-unavailable');
563            add_to_cart_button.prepend(icon);
564        });
565
566        //product lightbox
567        $(document).on('click', '.cw-product-gallery-main a', function (e) {
568            e.preventDefault();
569            if (!$('.pswp--visible')[0] && typeof PhotoSwipe !== 'undefined') {
570                var pswpElement = $('.pswp')[0],
571                    items = $(this).cwgetGalleryItems(),
572                    c_index = $(this).parent().index();
573                if ($(this).parent().hasClass('slick-slide')) {
574                    if ($('.cw-product-gallery-main')[0]) {
575                        var total_sl_active = $('.cw-product-gallery-main .slick-active').length;
576                        if (total_sl_active == 0) {
577                            c_index = $(this).parent().index();
578                        }
579                        else {
580                            c_index = $(this).parent().index() - total_sl_active - 1;
581                        }
582                    }
583                    else {
584                        c_index = $(this).parent().index() - 1;
585                    }
586
587                }
588                var options = {
589                    index: c_index,
590                    shareEl: false,
591                    closeOnScroll: false,
592                    history: false,
593                    hideAnimationDuration: 0,
594                    showAnimationDuration: 0
595                };
596                // Initializes and opens PhotoSwipe.
597                var photoswipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
598                photoswipe.init();
599            }
600        });
601        jQuery.fn.extend({
602            //Push product images to list
603            cwgetGalleryItems: function () {
604                var $slides = this.parents('.cw-product-gallery-main').find('.cw-product-gallery-item:not(.slick-cloned)'),
605                    items = [];
606                if ($slides.length > 0) {
607                    $slides.each(function (i, el) {
608                        var img = $(el).find('img'),
609                            large_image_src = img.attr('data-large_image'),
610                            large_image_w = img.attr('data-large_image_width'),
611                            large_image_h = img.attr('data-large_image_height'),
612                            item = {
613                                src: large_image_src,
614                                w: large_image_w,
615                                h: large_image_h,
616                                title: img.attr('title')
617                            };
618                        items.push(item);
619                    });
620                }
621                return items;
622            }
623        });
624    });
625})(jQuery);

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.