PageSourceSearch

https://www.emporiodellespezie.it/wp-content/plugins/woolentor-add…/quickview/assets/js/frontend.js?ver=3.5.1

js emporiodellespezie.it collected 2026-09-25 18:55:10 UTC 10,252 bytes, 280 lines download raw bytes

1;(function($){
2 "use strict";
3    
4    var WooLentorQuickView = {
5
6        body: $('body'),
7        modal: $('#woolentor-quickview-modal'),
8        modalbody: $('.woolentor-quickview-modal-body'),
9
10        /**
11         * [init]
12         * @return {[void]} Initial Function
13         */
14        init: function(){
15            this.wrapperHeight();
16            $( document )
17                .on( 'click.WooLentorQuickView', 'a.woolentor-quickview-btn,.woolentorquickview', this.openQuickView )
18                .on( 'click.WooLentorQuickView', '.woolentor-quickview-modal-close', this.closeQuickView )
19                .on( 'click.WooLentorQuickView', '.woolentor-quickview-overlay', this.closeQuickView );
20
21            $( document ).keyup( this.closeKeyUp );
22
23            if( woolentorQuickView.optionData['enableAjaxCart'] === 'on' ){
24                $( document ).on( 'click.WooLentorQuickView', '.woolentor-quickview-modal-content .woolentorquickview-content-template:not(.external) .single_add_to_cart_button:not(.disabled)', this.addToCart );
25            }
26
27        },
28
29        /**
30         * [openQuickView] Open quickview
31         * @param  event
32         * @return {[void]}
33         */
34        openQuickView: function( event ){
35            event.preventDefault();
36
37            var $this = $(this),
38                id = $this.data('product_id');
39
40            WooLentorQuickView.modalbody.html(''); /*clear content*/
41            WooLentorQuickView.body.addClass('woolentor-quickview-loader');
42
43            if( woolentorQuickView?.optionData?.spinnerImageUrl.length > 0 ){
44                 WooLentorQuickView.body.css('--woolentor-quick-view-spinner-image', 'url(' + woolentorQuickView?.optionData?.spinnerImageUrl + ')');
45            }
46
47            $this.addClass('loading');
48            WooLentorQuickView.modal.addClass('loading');
49
50            $.ajax({
51                url: woolentorQuickView.ajaxUrl,
52                data: {
53                    action: 'woolentor_quickview',
54                    id: id,
55                    nonce: woolentorQuickView.ajaxNonce,
56                },
57                method: 'POST',
58                success: function (response) {
59                    if ( response ) {
60                        WooLentorQuickView.body.removeClass('woolentor-quickview-loader');
61                        WooLentorQuickView.modal.removeClass('loading').addClass('woolentor-quickview-open');
62                        $this.removeClass('loading');
63
64                        WooLentorQuickView.modalbody.html( response );
65                        WooLentorQuickView.variation( WooLentorQuickView.modalbody );
66
67                        $(document).trigger('woolentor_quick_view_rendered');
68
69                        if( woolentorQuickView.optionData['thumbnailLayout'] === 'slider' ){
70                            WooLentorQuickView.imageSlider();
71                        }
72
73                    } else {
74                        console.log( 'Something wrong loading fetching product data' );
75                    }
76                },
77                error: function (response) {
78                    console.log('Something wrong with AJAX response.');
79                },
80                complete: function () {
81                    $this.removeClass('loading');
82                },
83            });
84
85        },
86
87        /**
88         * [variation] Product variation data manager
89         * @param  {[String]} $container
90         * @return {[void]} 
91         */
92        variation: function( $container ){
93
94            var $formvariation = $container.find('.variations_form');
95            $formvariation.each( function() {
96                $( this ).wc_variation_form();
97            });
98
99            $formvariation.trigger( 'check_variations' );
100            $formvariation.trigger( 'reset_image' );
101
102            if( typeof $.fn.wc_product_gallery !== 'undefined' ) {
103                $container.find('.woocommerce-product-gallery').each( function () {
104                    $(this).wc_product_gallery();
105                } );
106            }
107
108            if( woolentorQuickView.optionData['thumbnailLayout'] === 'slider' ){
109                WooLentorQuickView.variationData( $container );
110            }
111
112        },
113
114        /**
115         * [variationData] Manage varition data
116         * @param  {[String]} $product
117         * @return {[void]}
118         */
119        variationData: function( $product ){
120
121            $( '.single_variation_wrap' ).on( 'show_variation', function ( event, variation ) {
122                $product.find('.woolentor-quickview-main-image-slider').slick('slickGoTo', 0);
123            });
124
125        },
126
127        /**
128         * [closeQuickView] Close quickview
129         * @param  event
130         * @return {[void]}
131         */
132        closeQuickView: function( event ) {
133            event.preventDefault();
134            WooLentorQuickView.modal.removeClass('woolentor-quickview-open');
135        },
136
137        /**
138         * [closeKeyUp] Close quickview after press ESC Button
139         * @param  event
140         * @return {[void]}
141         */
142        closeKeyUp: function(event){
143            if( event.keyCode === 27 ){
144                WooLentorQuickView.modal.removeClass('woolentor-quickview-open');
145            }
146        },
147
148        /**
149         * [wrapperHeight] Manage Modal wrapper height
150         * @return {[void]}
151         */
152        wrapperHeight: function(){
153            var window_width = $(window).width(),
154                window_height = $(window).height();
155
156            $('.woolentor-quickview-modal-wrapper').css({"max-height": ( window_height-150 )+"px"});
157        },
158
159        /*
160        * Cuctom image slider
161        */
162        MainImageSlider: function(){
163            $('.woolentor-quickview-main-image-slider').slick({
164                slidesToShow: 1,
165                slidesToScroll: 1,
166                arrows: true,
167                fade: true,
168                asNavFor: '.woolentor-quickview-thumbnail-slider',
169                prevArrow: '<span class="woolentor-quickview-slick-prev">&#8592;</span>',
170                nextArrow: '<span class="woolentor-quickview-slick-next">&#8594;</span>',
171            });
172        },
173        ThumbnailSlider: function(){
174            $('.woolentor-quickview-thumbnail-slider').slick({
175                slidesToShow: 4,
176                slidesToScroll: 1,
177                asNavFor: '.woolentor-quickview-main-image-slider',
178                dots: false,
179                arrows: true,
180                focusOnSelect: true,
181                prevArrow: '<span class="woolentor-quickview-slick-prev">&#8592;</span>',
182                nextArrow: '<span class="woolentor-quickview-slick-next">&#8594;</span>',
183            });
184        },
185        imageSlider: function(){
186            this.MainImageSlider();
187            this.ThumbnailSlider();
188        },
189
190        /**
191         * [addToCart]
192         * @param event
193         */
194        addToCart: function( event ){
195            event.preventDefault();
196
197            var $this = $(this),
198                $form           = $this.closest('form.cart'),
199                all_data        = $form.serialize(),
200                product_qty     = $form.find('input[name=quantity]').val() || 1,
201                product_id      = $form.find('input[name=product_id]').val() || $this.val(),
202                variation_id    = $form.find('input[name=variation_id]').val() || 0;
203
204
205            /* For Variation product */    
206            var item = {},
207                variations = $form.find( 'select[name^=attribute]' );
208                if ( !variations.length) {
209                    variations = $form.find( '[name^=attribute]:checked' );
210                }
211                if ( !variations.length) {
212                    variations = $form.find( 'input[name^=attribute]' );
213                }
214
215                variations.each( function() {
216                    var $thisitem = $( this ),
217                        attributeName = $thisitem.attr( 'name' ),
218                        attributevalue = $thisitem.val(),
219                        index,
220                        attributeTaxName;
221                        $thisitem.removeClass( 'error' );
222                    if ( attributevalue.length === 0 ) {
223                        index = attributeName.lastIndexOf( '_' );
224                        attributeTaxName = attributeName.substring( index + 1 );
225                        $thisitem.addClass( 'required error' );
226                    } else {
227                        item[attributeName] = attributevalue;
228                    }
229                });
230
231            var data = {
232                product_id: product_id,
233                product_sku: '',
234                quantity: product_qty,
235                variation_id: variation_id,
236                variations: item,
237                all_data: all_data,
238            };
239
240            var alldata = data.all_data + '&product_id='+ data.product_id + '&product_sku='+ data.product_sku + '&quantity='+ data.quantity + '&variation_id='+ data.variation_id + '&variations='+ JSON.stringify( data.variations ) +'&action=woolentor_quickview_insert_to_cart' +'&nonce='+woolentorQuickView.ajaxNonce;
241
242            $( document.body ).trigger('adding_to_cart', [$this, data]);
243
244            $.ajax({
245                type: 'POST',
246                url: woolentorQuickView.ajaxUrl,
247                data: alldata,
248
249                beforeSend: function (response) {
250                    $this.removeClass('added').addClass('loading');
251                },
252
253                complete: function (response) {
254                    $this.addClass('added').removeClass('loading');
255                },
256
257                success: function (response) {
258
259                    if ( response.error & response.product_url ) {
260                        window.location = response.product_url;
261                        return;
262                    } else {
263                        $( document.body ).trigger( 'wc_fragment_refresh' );
264                        $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $this]);
265                    }
266
267                },
268
269            });
270
271        }
272
273    };
274
275    $( document ).ready( function() {
276        WooLentorQuickView.init();
277        $( window ).on( 'resize', WooLentorQuickView.wrapperHeight );
278    });
279    
280})(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.