PageSourceSearch

https://kgaleria.hu/wp-content/themes/kgaleria/nectar/woo/js/quick_view_actions.js?ver=1.1

js kgaleria.hu collected 2026-09-24 13:32:00 UTC 13,945 bytes, 440 lines download raw bytes

1jQuery(document).ready(function($){
2
3  var NectarQuickViewState = {
4    ajaxLoaded: false,
5    sizeSet: false
6  };
7
8  $('body').on('click','ul.products li.product a.nectar_quick_view',function(e){
9
10    e.preventDefault();
11
12    var $quickViewBox = $('.nectar-quick-view-box');
13    var $product_id = $(this).data('product-id');
14
15    //exit if no ID passed
16    if(typeof $product_id === 'undefined') { return; }
17
18    quickView($(this).parents('li.product'), 'open');
19
20    //empty old product info
21    $quickViewBox.find('.inner-content').empty();
22
23
24    //get product info
25    $.ajax({
26      type: 'POST',
27      url: nectarLove.ajaxurl,
28      data: {
29        'action': 'nectar_woo_get_product',
30        'product_id':  $product_id
31    },
32    success: function(response) {
33
34      NectarQuickViewState.ajaxLoaded = true;
35
36      $quickViewBox.find('.inner-content').html(response);
37
38      //store variation starting attr
39      $vari_startingImage = ($quickViewBox.find('.nectar-product-slider div.carousel-cell:first img').length > 0) ? $quickViewBox.find('.nectar-product-slider div.carousel-cell:first img').attr('src') : '';
40
41
42      //select2
43      if($('body[data-fancy-form-rcs="1"]').length > 0) {
44        select2Init();
45
46        //z index fix
47        $select2_css = '.select2-container { z-index: 99999; }';
48        var head = document.head || document.getElementsByTagName('head')[0];
49  			var style = document.createElement('style');
50
51  			style.type = 'text/css';
52  			if (style.styleSheet){
53  			  style.styleSheet.cssText = $select2_css;
54  			} else {
55  			  style.appendChild(document.createTextNode($select2_css));
56  			}
57  			$(style).attr('id','quickview-select-2-zindex');
58  			head.appendChild(style);
59
60      }
61
62      //slide BG Cover
63      if($('.nectar-quick-view-box[data-image-sizing="cropped"]').length > 0) {
64        flickitySlideCover();
65      }
66
67      //variations
68      if ( typeof wc_add_to_cart_variation_params !== 'undefined' ) {
69  			$( '.variations_form' ).each( function() {
70  				$( this ).wc_variation_form();
71  			});
72  		}
73
74      //quantity
75      quantityButtons();
76
77      var newWidthTimeout = ( NectarQuickViewState.sizeSet == true ) ? 0 : 200;
78
79      setTimeout(function(){
80
81        $('.nectar-quick-view-box').addClass('fully-open');
82
83        $('.nectar-quick-view-box-backdrop').addClass('visible');
84        $('.nectar-quick-view-box').addClass('animate-width').transition({
85             'left': productQV_Left+'px',
86             'width': productQV_Width+'px',
87          }, 550, 'cubic-bezier(.55,0,.1,1)' ,function(){
88
89          //init flickity
90          $pageDots = true;
91          if($('.nectar-quick-view-box .nectar-product-slider .carousel-cell').length == 1) {
92            $pageDots = false;
93          }
94          $carousel = $('.nectar-quick-view-box .nectar-product-slider').flickity({
95            contain: true,
96            lazyLoad: false,
97            imagesLoaded: true,
98            percentPosition: true,
99            prevNextButtons: false,
100            pageDots: $pageDots,
101            resize: true,
102            setGallerySize: true,
103            wrapAround: true,
104            accessibility: false
105          });
106
107          //show quick view content
108          $('.nectar-quick-view-box .preview_image').hide();
109          $('.nectar-quick-view-box').addClass('add-content');
110          $('.nectar-quick-view-box').addClass('fixedPos');
111
112        });
113
114        // Trigger for custom events.
115        $(window).trigger('nectar_quickview_init');
116
117      }, newWidthTimeout);
118
119
120    } // success
121
122
123  }); //ajax
124
125
126}); //quick view click
127
128
129
130$('body').on('click','.nectar-quick-view-box-backdrop, .nectar-quick-view-box .close',function(e){
131  e.preventDefault();
132  if( $('.nectar-quick-view-box.fully-open').length > 0 ) {
133     quickView($('.product.open-nectar-quick-view'),'close');
134  }
135});
136
137var $startingImage, $carousel, productQV_Width, productQV_Left, newHeight;
138
139function quickView(el,state) {
140
141    NectarQuickViewState.ajaxLoaded = false;
142    NectarQuickViewState.sizeSet = false;
143
144    var viewportWidth = window.innerWidth;
145    var viewportHeight = window.innerHeight;
146
147    if( el.find('.background-color-expand').length == 0 || 
148        state == 'close' || 
149        (el.find('.background-color-expand').length > 0 && el.find('.background-color-expand').css('display') == 'none') ) {
150        
151			var topSelected = el.offset().top - $(window).scrollTop(),
152			leftSelected = el.offset().left,
153			widthSelected = el.find('img').width(),
154			heightSelected = el.find('img').height();
155    } else {
156
157      var expansionAmt = 40;
158      if( nectarOptions && nectarOptions.woo_minimal_product_effect && nectarOptions.woo_minimal_product_effect === 'image_zoom' ) {
159        expansionAmt = 0;
160      }
161
162      var topSelected = el.offset().top - $(window).scrollTop() - (expansionAmt/2),
163			leftSelected = el.offset().left - (expansionAmt/2),
164			widthSelected = el.width() + expansionAmt,
165			heightSelected = el.height() + expansionAmt;
166
167    }
168
169    var aspectRatio = parseInt(el.find('.product-wrap img').height()) / parseInt(el.find('.product-wrap img').width());
170
171    var endingWidth = 425;
172
173    if(aspectRatio < 1.1) { endingWidth = 550; }
174    if(aspectRatio > 1.5) { endingWidth = 350; }
175
176    newHeight = Math.floor(aspectRatio*endingWidth);
177    var endingTop = (viewportHeight - newHeight)/2;
178		var endingLeft = (viewportWidth - endingWidth)/2;
179
180		productQV_Width = endingWidth + 475;
181		productQV_Left = (viewportWidth - productQV_Width)/2;
182
183
184    if(state == 'open') {
185
186      //copy image
187      var productImg = el.find('.product-wrap img:first').clone();
188      $('.nectar-quick-view-box .preview_image').show().html(productImg);
189
190
191      if( el.find('.background-color-expand').length > 0 && el.find('.background-color-expand').css('display') != 'none' ) {
192        
193        $('.nectar-quick-view-box .preview_image').css({
194          "top": expansionAmt/2 + 'px',
195          "left": expansionAmt/2 + 'px',
196          "width": el.find('.product-wrap img').width(),
197          "height": el.find('.product-wrap img').height()
198        });
199        
200        $('.nectar-quick-view-box .inner-wrap').css('background-color',el.find('.background-color-expand').css('background-color'));
201        
202
203      } else {
204        $('.nectar-quick-view-box').addClass('box-shadow-trans');
205      }
206
207
208      $('.nectar-quick-view-box').css({
209          "position": 'fixed',
210          "transform": '',
211          'opacity': '1',
212          "top": topSelected,
213          "left": leftSelected,
214          "width": widthSelected,
215          "height": heightSelected
216      });
217
218
219      //hide item and show the quick view
220      setTimeout(function(){
221        el.addClass('no-trans').addClass('open-nectar-quick-view');
222        el.trigger('mouseleave');
223        $('.nectar-quick-view-box').addClass('visible');
224        $('.nectar-quick-view-box-backdrop').css({'visibility': 'visible', 'z-index': '10000', 'pointer-events': 'all'});
225      },75);
226
227
228
229      //show loading
230      setTimeout(function(){
231        $('.nectar-quick-view-box').addClass('loading-vis');
232      },575);
233
234
235     setTimeout(function(){
236
237          if(el.find('.background-color-expand').length > 0 && el.find('.background-color-expand').css('display') != 'none' ) {
238
239            $('.nectar-quick-view-box .preview_image').transition({
240              "top": '-2px',
241              "left": '-2px',
242              "height": "calc(100% + 4px)"
243            }, 800, 'cubic-bezier(.55,0,.1,1)');
244          }
245
246          //animate size
247          $('.nectar-quick-view-box').transition({
248            'top': endingTop+ 'px',
249            'left': endingLeft+'px',
250            'width': (endingWidth - 1) + 'px',
251            'height': newHeight + 'px'
252          }, 750, 'cubic-bezier(.55,0,.1,1)');
253
254          NectarQuickViewState.sizeSet = true;
255
256      },125);
257
258
259  } else {
260
261     //close
262      $('.nectar-quick-view-box').removeClass('fully-open');
263      el.removeClass('no-trans');
264      $('.nectar-quick-view-box-backdrop').removeClass('visible');
265
266      if($('head #quickview-select-2-zindex').length > 0) {
267        $('head #quickview-select-2-zindex').remove();
268      }
269
270      $('.nectar-quick-view-box').transition({
271        'scale': '0.85',
272        'opacity': '0'
273      }, 300, 'cubic-bezier(.2,.75,.5,1)', function(){
274        el.removeClass('open-nectar-quick-view');
275        $startingImage = ($('.nectar-product-slider .flickity-slider .carousel-cell:first-child > img').length >
275 0) ? $('.nectar-product-slider .flickity-slider .carousel-cell:first-child > img').attr('src') : '';
276        $('.nectar-quick-view-box-backdrop').css({'visibility': 'hidden',  'z-index': '-1', 'pointer-events': 'none'});
277        $('.nectar-quick-view-box').removeClass('visible').removeClass('add-content').removeClass('loading-vis').removeClass('animate-width').removeClass('fixedPos');
278      });
279
280  }
281
282
283} //quickview function
284
285
286function resizePos() {
287  $('.nectar-quick-view-box.fixedPos').css({
288    'left': ($(window).width() - $('.nectar-quick-view-box').width())/2,
289    'top': ($(window).height() - $('.nectar-quick-view-box').height())/2
290  });
291}
292
293$(window).on('resize',resizePos);
294
295
296function flickitySlideCover() {
297
298  $('.nectar-quick-view-box div.images img').css({
299    'height': (parseInt($('.nectar-quick-view-box').height()) + 4) + 'px'
300  });
301
302  //set imgs as BGs
303  $('.nectar-quick-view-box .carousel-cell').each(function(){
304
305    var $storedImgSrc = $(this).find('img').css('visibility','hidden').attr('src');
306
307
308    if(typeof newHeight != 'undefined') {
309      $(this).find('img').css({
310        'height': newHeight + 4
311      });
312    }
313
314    $(this).css({
315      'background-image': 'url(' + $storedImgSrc + ')',
316      'background-size': 'cover',
317      'background-position': 'center'
318    });
319
320  });
321
322}
323
324
325//variation support
326var $vari_startingImage = '';
327
328$('body').on('blur','.nectar-quick-view-box select[name*="attribute_"]', function(){
329
330  var $that = $(this);
331  var attr_data = $('.variations_form').data('product_variations');
332  var $parent_quick_view = $(this).parents('.nectar-quick-view-box');
333
334  if($that.val().length > 0) {
335
336    //give woo time to update img
337    setTimeout(function(){
338
339      $(attr_data).each(function(i, el){
340
341        if(el.image && el.image.src) {
342
343
344          if(el.image.src == $parent_quick_view.find('.flickity-slider div.carousel-cell:first a > img').attr('src')){
345
346             if(el.image.url){
347
348                $parent_quick_view.find('.flickity-slider div.carousel-cell:first').css('background-image','url(' + el.image.src + ')');
349                $carousel.flickity( 'select', 0, true, false );
350
351              } // if found img url
352
353          } // if the sources match
354
355        } // if img source exists
356
357      });	//loop through attrs
358
359    },30);
360
361} else {
362
363  //reset to original
364  $parent_quick_view.find('.flickity-slider div.carousel-cell:first').css('background-image','url(' + $vari_startingImage + ')');
365
366}
367
368}); //blur variation
369
370
371
372
373
374$('body').on('change','.nectar-quick-view-box select[name*="attribute_"]', function(){
375
376
377     //keep classes from default hidden btn and full width btn the same
378     if($('.nectar-quick-view-box .product .product > .single_add_to_cart_button_wrap .single_add_to_cart_button').length > 0) {
379       setTimeout(function(){
380          var addToCartClasses = $('.nectar-quick-view-box .summary-content .single_add_to_cart_button').attr('class');
381          $('.nectar-quick-view-box .product .product > .single_add_to_cart_button_wrap .single_add_to_cart_button').attr('class',addToCartClasses);
382       },290);
383
384     }
385
386}); //blur variation 2
387
388
389
390function select2Init() {
391  $('.nectar-quick-view-box select' ).each( function() {
392
393    $( this ).select2({
394      minimumResultsForSearch: 7,
395      width: '100%'
396    });
397
398  });
399
400}
401
402
403
404
405// Quantity buttons
406function quantityButtons() {
407
408    if($('.nectar-quick-view-box .plus').length == 0) {
409
410      $('.nectar-quick-view-box div.quantity:not(.buttons_added), .nectar-quick-view-box td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<input type="button" value="+" class="plus" />' ).prepend( '<input type="button" value="-" class="minus" />' );
411
412    }
413
414    //also move add to cart button
415    setTimeout(function(){
416        var addToCartBtnText = $('.nectar-quick-view-box .summary-content .single_add_to_cart_button').text();
417        var addToCartBtnClasses = ($('.nectar-quick-view-box .summary-content .single_add_to_cart_button[class]').length >
417 0) ? $('.nectar-quick-view-box .summary-content .single_add_to_cart_button').attr('class') : '';
418        var productViewFullBtn = $('.nectar-quick-view-box .nectar-full-product-link').clone();
419
420        $('.nectar-quick-view-box .product .product').append('<div class="single_add_to_cart_button_wrap" />');
421
422        $('.nectar-quick-view-box .product .product .single_add_to_cart_button_wrap').append('<a class="single_add_to_cart_button button"><span>'+ addToCartBtnText +'</span></a>').append(productViewFullBtn);
423
424        //bind click to original button
425        $('.nectar-quick-view-box .product .product .single_add_to_cart_button_wrap > .single_add_to_cart_button').attr('class',addToCartBtnClasses).on('click',function(e){
426          e.preventDefault(e);
427          // ensure variations are set.
428          if( $('.nectar-quick-view-box .summary-content .single_add_to_cart_button.wc-variation-selection-needed').length == 0 ) {
429            $('.nectar-quick-view-box .summary-content .single_add_to_cart_button').trigger('click');
430          }
431        });
432
433    },150);
434}
435
436
437
438
439
440});

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.