PageSourceSearch

https://www.metra.cz/wp-content/themes/betheme/js/woocommerce.js?ver=28.4.2

js metra.cz collected 2026-10-02 22:03:01 UTC 70,396 bytes, 2,033 lines download raw bytes

1(function($) {
2$(document).ready(function() {
3
4  mfnFakeSale.init();
5
6  // gallery grid
7  if(!$('body').hasClass('mfn-ui') && $('.mfn-product-gallery-grid').length){
8    // zoom
9    if( !$('body').hasClass('product-zoom-disabled') ){
10      $(' .mfn-product-gg-img a').zoom();
11    }
12    // lightbox
13    initPhotoSwipeFromDOM('.mfn-product-gallery-grid');
14  }
15
16  $( document ).on( 'click', '.mfn-quick-view', function(e) {
17    e.preventDefault();
18    var id = $(this).attr('data-id');
19    $(this).addClass('loading');
20    quickview.display(id);
21  });
22
23  if( $('body').hasClass('mfn-ajax-add-to-cart') ) {
24    $( document ).on( 'click', '.single_add_to_cart_button:not(.disabled)', function(e) {
25
26      e.preventDefault();
27
28      var cc = $('#header_cart .header-cart-count').length ? $('#header_cart .header-cart-count').first().text() : 0;
29
30      var $thisbutton = $(this);
31      var $form = $thisbutton.closest('form.cart'),
32      c_form = $thisbutton.closest('form.cart').get(0);
33
34      var $qty = $form.find('input.qty');
35      var qty_max = $qty.attr('max');
36
37      if( typeof qty_max !== typeof undefined && qty_max != '' && parseInt($qty.val()) > parseInt(qty_max) ){
38        $qty.css({'background-color': '#77a464', 'transition': '0.8s'});
39        $qty.val(qty_max);
40
41        setTimeout(function() {
42            $qty.removeAttr('style');
43        }, 1000);
44
45        return;
46      }
47
48      var ajaxAct = {
49        url: wc_add_to_cart_params.ajax_url,
50        type: 'POST',
51        beforeSend: function (response) {
52            $(document.body).trigger('adding_to_cart');
53            $thisbutton.removeClass('added').addClass('loading');
54        },
55        success: function (response) {
56
57            if( typeof response.error !== 'undefined' ){
58                location.reload();
59                return;
60            }
61
62            $thisbutton.addClass('added').removeClass('loading');
63            $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]);
64            $(document.body).trigger('wc_fragment_refresh');
65
66            $('.mfn-cart-holder').attr('aria-expanded', 'true');
67        }
68      };
69
70      // check if grouped product has any quantity selected
71      if( $form.hasClass('grouped_form') ){
72
73        var $inputs = $('input.qty', $form);
74        var hasQuantity = false;
75
76        $inputs.each(function(){
77          if( parseInt($(this).val()) > 0 ){
78            hasQuantity = true;
79          }
80        });
81
82        if( ! hasQuantity ){
83          alert( mfnwoovars.groupedQuantityErrori18n);
84          return false;
85        }
86
87      }
88
89      var formData = new FormData(c_form);
90      formData.append('action', 'woocommerce_add_to_cart');
91      formData.append('current_cart', cc);
92
93      if( $('.mnm_cart.mnm_data .mnm_add_to_cart_button').length ){
94        formData.delete('add-to-cart');
95      }
96
97      if ( !formData.has('product_id') && 'undefined' !== $thisbutton.val() ) {
98        formData.append( 'product_id', parseInt( $thisbutton.val() ) );
99      }
100
101      if ( formData.has('variation_id') ) {
102        formData.delete('product_id');
103      }
104
105      ajaxAct['data'] = formData;
106      ajaxAct['contentType'] = false;
107      ajaxAct['processData'] = false;
108
109      $(document.body).trigger('adding_to_cart', [$thisbutton, formData]);
110      $.ajax( ajaxAct );
111
112      return false;
113
114    });
115  }
116
117  // woo product category arrows
118  if( $('.wc-block-product-categories-list') ){
119    $('.wc-block-product-categories-list li.wc-block-product-categories-list-item').each(function() {
120      if($(this).children('ul').length){
121        $(this).append('<span class="cat-expander"></span>');
122      }
123    });
124
125    $('.wc-block-product-categories-list li > span.cat-expander').on('click', function(e) {
126      if($(this).siblings('ul').is(':visible')){
127        $(this).siblings('ul').slideUp(300);
128        $(this).parent('li').removeClass('li-expanded');
129      }else{
130        $(this).siblings('ul').slideDown(300);
131         $(this).parent('li').addClass('li-expanded');
132      }
133    });
134  }
135
136  // Append spans to additional info table
137  if($('.woocommerce-product-attributes').length){
138    spanToAdditionalInfo();
139  }
140
141  // product variations
142  if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){
143    productvariations.run();
144  }
145
146  $('.toggle-mfn-cart').on('click', function(e) {
147    if( $('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){
148        e.preventDefault();
149
150        if( $('body').hasClass('mfn-bebuilder-header') ) return;
151
152        if ( $('html').hasClass('mfn-cart-opened')) {
153          $('.mfn-cart-holder').attr('aria-expanded', 'false')
154        } else {
155          $('.mfn-cart-holder').attr('aria-expanded', 'true');
156        }
157
158        woocart.click();
159    }
160  });
161
162  $('.toggle-mfn-cart').on('keypress', function(e) {
163    e.preventDefault();
164    if ( e.originalEvent.key !== 'Enter' ) return;
165
166    if ( $('html').hasClass('mfn-cart-opened')) {
167      $('.mfn-cart-holder').attr('aria-expanded', 'false');
168
169      const domPrefix = $('body').hasClass('side-slide-is-open') ? '.extras-wrapper ' : '.top_bar_right ';
170      $(`${domPrefix} #header_cart`).trigger('focus');
171    } else {
172      $('.mfn-cart-holder').find('a').first().trigger('focus');
173      $('.mfn-cart-holder').attr('aria-expanded', 'true');
174    }
175
176    woocart.click();
177  });
178
179  $('.mfn-cart-overlay').on('click', function() {
180    woocart.click();
181  });
182
183  if($('body').hasClass('shop-sidecart-active')){
184      woocart.start();
185  }
186
187  $('.toggle-login-modal').on('click', function(e) {
188    e.preventDefault();
189    if( $('body').hasClass('mfn-ui') ) return;
190    modallogin.click($(this));
191  });
192
193  $(document).on('mouseup', function(e) {
194
195    // login form
196    if( $('body').hasClass('mfn-show-login-modal') ) {
197      if( ! $('.mfn-header-login').is(e.target) && $('.mfn-header-login').has(e.target).length === 0 && ! $('.toggle-login-modal').is(e.target) && $('.toggle-login-modal').has(e.target).length === 0 ){
198        modallogin.click();
199      }
200    }
201
202  });
203
204  if( $('.woocommerce .column_shop_products ul.products.list').length ){
205    alignListHeights();
206    $(window).on('debouncedresize', alignListHeights);
207  }
208
209
210  $('.mfn-header-modal-login .woocommerce-form-login .form-row').on('click', function() {
211    if( !$(this).hasClass('active') ){
212      $(this).addClass('active');
213    }
214  });
215   // fix for safari
216  $('.mfn-header-modal-login .woocommerce-form-login .form-row input.input-text').on('focus keyup', function() {
217    if( !$(this).closest('.form-row').hasClass('active') ){
218      $(this).closest('.form-row').addClass('active');
219    }
220  });
221
222  $('.mfn-header-modal-login .woocommerce-form-login .form-row input').on('blur change', function() {
223    modallogin.check();
224  });
225
226  modallogin.check();
227
228  $(document).on('click', '.mfn-cart-holder .mfn-ch-content .mfn-chp-remove', function(e) {
229    e.preventDefault();
230    if(!$('.mfn-cart-holder').hasClass('loading')){
231      $('.mfn-cart-holder').addClass('loading');
232      var pid = $(this).closest('.mfn-ch-product').attr('data-row-key');
233      woocart.delete(pid);
234    }
235  });
236
237  $('.mfn-woo-products').on('change', '.mfn-variations-wrapper-loop .mfn-vr-select', function() {
238    var link = $(this).find(':selected').attr('data-link');
239    if(link != '') {
240      window.location.href = link;
241    }
242  });
243
244  $(document).on('change', '.mfn-cart-holder .mfn-ch-content .qty', function() {
245    var $el = $(this);
246    if(!$('.mfn-cart-holder').hasClass('loading')){
247        $('.mfn-cart-holder').addClass('loading');
248        var pid = $el.closest('.mfn-ch-product').attr('data-row-key');
249        var qty = $el.val();
250        woocart.updatequantity(pid, qty);
251    }
252  });
253
254
255  if( $('body').hasClass('woocommerce-checkout') ){
256
257    if( $('.woocommerce-form-login').length ){
258        $('.woocommerce-form-login').addClass('checkout-form-toggle');
259    }
260    if( $('.woocommerce-form-coupon').length ){
261        $('.woocommerce-form-coupon').addClass('checkout-form-toggle');
262    }
263
264    /*$(document).ajaxComplete(function() {
265      // checkoutpayment.start();
266    });*/
267
268    setTimeout(function(){
269      checkoutpayment.start();
270    },1500);
271  }
272
273  /*$( document.body ).on( 'adding_to_cart', function( e ) {
274    if(!$('.header-cart-count').length || !$('.header-cart-total').length){
275        $('.header-cart').append('<span class="header-cart-count"></span>');
276         $('#header_cart').append('<p class="header-cart-total"></p>');
277    }
278  });*/
279
280  //$( document.body ).on( 'wc_fragment_refresh added_to_cart', function( e ) {
281  $( document.body ).on( 'added_to_cart', function( e ) {
282    if($('body').hasClass('shop-sidecart-active')) {
283      // woocart.refresh();
284      if(!$('html').hasClass('mfn-cart-opened')) {
285        //woocart.click();
286        woocart.force_open = true;
287      }
288    }
289  } );
290
291
292  $(document).on('mouseup click', '.wc-block-cart__main .wc-block-cart-item__quantity .wc-block-components-quantity-selector__button', function() {
293    setTimeout( function() { $(document.body).trigger('wc_fragment_refresh')}, 2000 );
294  });
295
296  $(document).on('mouseup click', '.wc-block-cart__main .wc-block-cart-item__quantity .wc-block-cart-item__remove-link', function() {
297    setTimeout( function() { $(document.body).trigger('wc_fragment_refresh')}, 2000 );
298  });
299
300  $(document).on('click', '.woocommerce-review-link, a.wc-rating-with-text', function(e) {
301
302    if( $('#tab-reviews').length && $('a[href="#tab-reviews"]').length ){
303      e.preventDefault();
304      $('a[href="#tab-reviews"]').trigger('click');
305
306      let offset_top = $('a[href="#tab-reviews"]').offset().top - $('.mfn-header-tmpl').outerHeight();
307
308      $('body, html').animate({scrollTop: offset_top}, 500);
309    }
310
311  });
312
313
314  // wishlist
315  wishlist.set();
316  $(document).on('click', '.mfn-wish-button', function(e) { e.preventDefault(); var id = $(this).attr('data-id'); wishlist.click(id); });
317
318
319
320
321
322
323
324
325
326
327
328let mfnShopListOptions = {
329  action: false,
330  params: '',
331  init: function() {
332
333    $(document).on('change', '.woocommerce-ordering select, .mfn-active-filters-sorting .mfn-archive-orderby-select', function() {
334      const value = $(this).val();
335      const url = new URL(window.location.href);
336      url.searchParams.set('orderby', value);
337      url.searchParams.delete('paged');
338      window.location.href = url.toString();
339    });
340
341    if( $('form.mfn_attr_filters').length ) {
342
343      // active filters
344      $(document).on('click', '.mfn-woo-list-active-filters li span', function() {
345          var id = $(this).attr('data-id');
346          $(this).closest('li').addClass('loading');
347          if($('.widget.mfn_woo_attributes .mfn_attr_filters input.'+id).length){
348              if($('.mfn_woo_attributes .mfn_attr_filters input.'+id).is(':checked')) {
349                  $('.mfn_woo_attributes .mfn_attr_filters input.'+id).prop('checked', false);
350                  if( $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').hasClass('active') ) {
351                      $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').removeClass('active');
352                  }
353              }
354              setTimeout(() => mfnShopListOptions.grab(), 1);
355          }
356      });
357
358      $(document).on('click', 'form.mfn_attr_filters ul li', function() {
359
360        var li = $(this);
361        var form = $(this).closest('form');
362        var input_class = li.find('input').attr('class');
363
364        li.siblings('li').removeClass('active');
365        li.siblings('li').find('input').prop('checked', false);
366
367        // on click active filters
368        if(form.hasClass('mfn-before-products-list-form')){
369
370            li.find('input').is(':checked') ? li.find('input').prop('checked', false) : li.find('input').prop('checked', true);
371            li.toggleClass('active');
372
373        }else if(form.hasClass('mfn_attr_filters')){
374            li.find('input').is(':checked') ? $('form.mfn_attr_filters ul li input.'+input_class).prop('checked', false) : $('form.mfn_attr_filters ul li input.'+input_class).prop('checked', true);
375            $('form.mfn_attr_filters ul li input.'+input_class).closest('li').toggleClass('active');
376        }
377
378        if( !li.closest('form').hasClass('button-enabled') ){
379            li.addClass('loading');
380            setTimeout(() => mfnShopListOptions.grab(), 1);
381        }
382
383      });
384
385    }
386
387    if( $('form.mfn_attr_filters.button-enabled').length ) {
388      $('form.mfn_attr_filters.button-enabled').submit(function(e) {
389          e.preventDefault();
390          mfnShopListOptions.grab();
391      });
392    }
393
394  },
395
396  grab: function() {
397
398    if( $('form.mfn-advanced-filters').length ) {
399      $('form.mfn-advanced-filters').trigger('submit');
400      return;
401    }
402
403    let formsArr = [];
404    var path = window.location.pathname.replace(/\/page\/\d+\/?$/, '/');
405
406
407
408    // Collect attribute filter forms
409    $('form.mfn_attr_filters').each(function () {
410      const fd = $(this).serialize();
411      if (!fd) return;
412
413      // Add full formData string
414      formsArr.push(fd);
415
416      // Add query_type_* params for each filter_*
417      fd.split('&').forEach(pair => {
418        if (!pair) return;
419        const [key, value] = pair.split('=');
420
421        if (key && key.indexOf('filter_') === 0) {
422          const taxonomy = key.slice('filter_'.length); // remove "filter_"
423          formsArr.push(`query_type_${taxonomy}=or`);
424        }
425      });
426    });
427
428    // Collect ordering form data (if present)
429    const $ordering = $('form.woocommerce-ordering');
430    if ($ordering.length) {
431      ['post_type', 's', 'paged', 'orderby'].forEach(name => {
432        const $field = $ordering.find(`[name="${name}"]`);
433        if ($field.length && $field.val() !== '') {
434          const val = encodeURIComponent($field.val());
435          const key = encodeURIComponent(name);
436          formsArr.push(`${key}=${val}`);
437        }
438      });
439    }
440
441    // Remove duplicates in a clear way
442    const formUnique = Array.from(new Set(formsArr));
443
444    // Build final URL
445    const formData = formUnique.join('&');
446    this.action = formData ? `${path}?${formData}` : path;
447
448    // Send ajax
449    this.ajax();
450
451  },
452
453  ajax: function() {
454
455    $('.mfn_attr_filters button').addClass('loading disabled');
456
457    if($('body').hasClass('archive')) {
458
459        $.get(mfnShopListOptions.action, function(responseText) {
460
461            $('.pager_wrapper').remove();
462            $('.woocommerce-info').remove();
463
464            if( $('.default-woo-list').length ){
465                $('.default-woo-list').replaceWith( $( $.parseHTML( responseText )).find('.default-woo-list').clone() );
466            }else if( $('.column_shop_products').length ){
467                $('.column_shop_products').each(function(i) {
468                  $(this).replaceWith( $( $.parseHTML( responseText )).find('.column_shop_products').eq(i).clone() );
469                });
470            }
471
472            if ($('.mcb-sidebar').length) {
473              var maxH = $('#Content .sections_group').outerHeight();
474              $('.mcb-sidebar').each(function() {
475                $(this).css('min-height', 0);
476                if ($(this).height() > maxH) {
477                  maxH = $(this).height();
478                }
479              });
480              $('.mcb-sidebar').css('min-height', maxH + 'px');
481            }
482
483            history.replaceState(null, '', mfnShopListOptions.action);
484
485            if( $($.parseHTML( responseText )).find('.mfn-infinite-load-button').length ) {
486              $(document).trigger('mfn:waypoints');
487            }
488
489            $(document).trigger('mfn:ajax:refresh');
490
491            $('.mfn_attr_filters ul li').removeClass('loading');
492            $('.mfn_attr_filters button').removeClass('loading disabled');
493        });
494    }else{
495        window.location.href = mfnShopListOptions.action;
496    }
497
498  }
499}
500
501
502mfnShopListOptions.init();
503
504setTimeout(function() {
505    productgallery.start();
506  }, 300);
507
508});
509
510
511
512
513
514
515
516
517
518/*
519
520  // attr ajjax filter
521  if( $('form.mfn_attr_filters').length ){
522
523    $(document).on('click', '.mfn-woo-list-active-filters li span', function() {
524        var id = $(this).attr('data-id');
525        $(this).closest('li').addClass('laoding');
526        if($('.widget.mfn_woo_attributes .mfn_attr_filters input.'+id).length){
527            if($('.mfn_woo_attributes .mfn_attr_filters input.'+id).is(':checked')) {
528                $('.mfn_woo_attributes .mfn_attr_filters input.'+id).prop('checked', false);
529                if( $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').hasClass('active') ) {
530                    $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').removeClass('active');
531                }
532            }
533            grabFiltersForms();
534        }
535    });
536
537    $(document).on('click', 'form.mfn_attr_filters ul li', function() {
538
539    var $li = $(this);
540    var $ul = $(this).closest('ul');
541    var $form = $(this).closest('form');
542    var input_class = $li.find('input').attr('class');
543
544    // on click active filters
545    if($form.hasClass('mfn-before-products-list-form')){
546
547        $li.find('input').is(':checked') ? $li.find('input').prop('checked', false) : $li.find('input').prop('checked', true);
548        $li.toggleClass('active');
549
550    }else if($form.hasClass('mfn_attr_filters')){
551        $li.find('input').is(':checked') ? $('form.mfn_attr_filters ul li input.'+input_class).prop('checked', false) : $('form.mfn_attr_filters ul li input.'+input_class).prop('checked', true);
552        $('form.mfn_attr_filters ul li input.'+input_class).closest('li').toggleClass('active');
553    }
554
555    if( !$li.closest('form').hasClass('button-enabled') ){
556        $li.addClass('loading');
557        grabFiltersForms();
558    }
559
560    });
561  }
562
563  if( $('form.mfn_attr_filters.button-enabled').length ){
564    $('form.mfn_attr_filters.button-enabled').submit(function(e) {
565        e.preventDefault();
566        grabFiltersForms();
567    });
568  }
569
570  $.fn.extend({
571    formData: function(){
572      var data = {};
573      $.each(this.serializeArray(),function(i,o){
574        if (data[o.name]) data[o.name] += ','+decodeURIComponent(o.value);
575        else data[o.name] = decodeURIComponent(o.value);
576      });
577      return $.param(data);
578    }
579  });
580
581  function removeQueryParameters(url, parametersToRemove) {
582    url = window.location.origin + url;
583    const urlObject = new URL(url);
584    parametersToRemove.forEach(param => {
585      urlObject.searchParams.delete(param);
586    });
587    return urlObject.toString();
588  }
589
590  function grabFiltersForms(){
591    let formsArr = [];
592    var path = getUrlWithoutPagination();
593
594    $('form.mfn_attr_filters').each(function() {
595      formsArr.push( $(this).formData() );
596      if( $(this).formData().includes('filter_') ) {
597        if( $(this).formData().includes('&') ) {
598          var f_helper = $(this).formData().split('&');
599          f_helper.map( h => {
600            var q_helper = h.split('=');
601            formsArr.push( `query_type_${q_helper[0].replace('filter_', '')}=or` );
602          });
603        }else{
604          var q_helper = $(this).formData().split('=');
605          formsArr.push( `query_type_${q_helper[0].replace('filter_', '')}=or` );
606        }
607      }
608    });
609
610    if( $('form.woocommerce-ordering').length ){
611      if( $('form.woocommerce-ordering input[name="post_type"]').length ) formsArr.push('post_type='+$('form.woocommerce-ordering input[name="post_type"]').val());
612      if( $('form.woocommerce-ordering input[name="s"]').length ) formsArr.push('s='+$('form.woocommerce-ordering input[name="s"]').val());
613      if( $('form.woocommerce-ordering input[name="paged"]').length ) formsArr.push('paged='+$('form.woocommerce-ordering input[name="paged"]').val());
614      if( $('form.woocommerce-ordering select[name="orderby"]').length ) formsArr.push('orderby='+$('form.woocommerce-ordering select[name="orderby"]').val());
615    }
616
617    formUnique = formsArr.filter( function(a){if (!this[a]) {this[a] = 1; return a;}}, {} );
618
619    let formData = formUnique.join('&');
620    let url = path+'?'+formData;
621    load_products_ajax(url);
622  }
623
624  function load_products_ajax(url) {
625
626    var $products = $('.entry-content .mfn-woo-products');
627    $('.mfn_attr_filters button').addClass('loading disabled');
628
629    if($('body').hasClass('archive')) {
630
631        $.get(url, function(responseText) {
632
633            $('.pager_wrapper').remove();
634            $('.woocommerce-info').remove();
635
636            if( $('.default-woo-list').length ){
637                $('.default-woo-list').replaceWith( $( $.parseHTML( responseText )).find('.default-woo-list').clone() );
638            }else if( $('.column_shop_products').length ){
639                $('.column_shop_products').each(function(i) {
640                  $(this).replaceWith( $( $.parseHTML( responseText )).find('.column_shop_products').eq(i).clone() );
641                });
642            }
643
644            $('.woocommerce-ordering select').on('change', function() {
645                $(this).closest('form').submit();
646            });
647
648            // remove unwanted attibutes
649            url = removeQueryParameters(url, ['layout', 'per_page']);
650            // replace %2C with coma
651            url = url.replace(/%2C/g,",");
652            // set browser url
653            history.replaceState(null, '', url);
654
655            if ($('.mcb-sidebar').length) {
656              var maxH = $('#Content .sections_group').outerHeight();
657              $('.mcb-sidebar').each(function() {
658                $(this).css('min-height', 0);
659                if ($(this).height() > maxH) {
660                  maxH = $(this).height();
661                }
662              });
663              $('.mcb-sidebar').css('min-height', maxH + 'px');
664            }
665
666            if( $('.woocommerce .column_shop_products ul.products.list').length ){
667                alignListHeights();
668                $(window).on('debouncedresize', alignListHeights);
669            }
670
671            if( $('.products li img').length ) {
672                $('.products li img').each(function() {
673                    if( typeof $(this).attr('data-src') !== 'undefined' ) {
674                        $(this).attr('src', $(this).attr('data-src'));
675                    }
676                })
677            }
678
679            if( $($.parseHTML( responseText )).find('.mfn-infinite-load-button').length ) {
680              $(document).trigger('mfn:waypoints');
681            }
682
683            $(document).trigger('mfn:ajax:refresh');
684
685            $('.mfn_attr_filters ul li').removeClass('loading');
686            $('.mfn_attr_filters button').removeClass('loading disabled');
687        });
688    }else{
689        window.location.href = url;
690    }
691
692  }
693
694  function getUrlWithoutPagination(){
695    var current_url = window.location.pathname;
696    var url = '';
697
698    // get url witout pagination
699    if(current_url.includes("/page/")){
700        url = current_url.split("/page/")[0];
701    }else{
702        url = current_url;
703    }
704
705    // if not listing page redirect
706    if( !$('body').hasClass('archive') ){
707        url = $('form.mfn_attr_filters').attr('action');
708    }
709
710    return url;
711  }
712
713  
714
715});
716
717
718
719
720*/
721
722
723
724
725function alignListHeights(){
726    var i = 0;
727    $('.woocommerce .column_shop_products ul.products.list li.product').each(function() {
728        $(this).css({ 'min-height': '1px'});
729
730        var height= $(this).outerHeight();
731        var imgHeight = $(this).find('.product-loop-thumb').outerHeight();
732
733        if(imgHeight > height){
734            $(this).css({'min-height': imgHeight});
735        }
736    });
737  }
738
739
740
741
742
743
744
745
746
747
748
749  // Append spans to additional info table
750
751  function spanToAdditionalInfo(){
752    $('.woocommerce-product-attributes td, .woocommerce-product-attributes th').each(function() {
753      $(this).html('<span>'+$(this).html()+'</span>');
754    });
755  }
756
757  var productvariations = {
758    run: function() {
759
760      $('.mfn-variations-wrapper .mfn-vr-options li a').on('click', function(e) {
761        e.preventDefault();
762        $(this).parent().siblings().removeClass('active');
763        $(this).parent().addClass('active');
764        var id = $(this).attr('data-id');
765        var atr = $(this).parent().parent().attr('data-atr');
766        $('.variations select#'+atr).val(id);
767        $('.variations select#'+atr).trigger('change');
768        if( $('form.variations_form').attr('data-product_variations') != 'false' ) {
769            setTimeout(function() { productvariations.triggerChange(); }, 100);
770        }
771      });
772
773      $('.mfn-variations-wrapper .mfn-vr-select').on('change', function() {
774        var id = $(this).val();
775        var atr = $(this).attr('data-atr');
776        $('.variations select#'+atr).val(id);
777        $('.variations select#'+atr).trigger('change');
778        if( $('form.variations_form').attr('data-product_variations') != 'false' ) {
779            setTimeout(function() { productvariations.triggerChange(); }, 100);
780        }
781      });
782
783      $('.woocommerce div.product form.cart .variations select').each(function() {
784        var val = $(this).val();
785        var atr = $(this).attr('id');
786        if( val.length ){
787          if($('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').length){
788            $('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').trigger('click');
789          }else if($('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').length){
790            $('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').val(val);
791          }
792        }
793      });
794
795      if( window.location.search ){
796        if( $('.mfn-variations-wrapper ul.mfn-vr-options').length ){
797          const urlParams = new URLSearchParams(window.location.search);
798          $('.mfn-variations-wrapper ul.mfn-vr-options').each(function() {
799            let attr = $(this).attr('data-atr');
800            if( urlParams.get(attr) && typeof attr !== 'undefined' ){
801              if( $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').length ) $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').trigger('click');
802            }
803          });
804        }
805      }
806
807      $(document).on('click', '.woocommerce .mfn-variations-wrapper .mfn-reset-variations', function(e) {
808        e.preventDefault();
809        $('.woocommerce .mfn-variations-wrapper .mfn-vr ul li').removeClass('active disabled');
810        $('.woocommerce .mfn-variations-wrapper .mfn-vr select').val('');
811        $('.mfn-variable-swatches .variations_form .variations select').val('').trigger('change');
812        $(this).hide();
813      });
814
815      setTimeout(function() { productvariations.triggerChange(); }, 200);
816
817      //$('.variations').hide();
818
819    },
820
821    triggerChange: function() {
822
823      if( $('.mfn-vr-options li').length ) {
824        $('.mfn-vr-options li').addClass('disabled');
825      }
826
827      if( $('.mfn-vr-select option').length ) {
828        $('.mfn-vr-select option').attr('disabled', 'true');
829      }
830
831
832      $('.woocommerce form.variations_form.cart table.variations select option').each(function() {
833
834          var val = $(this).attr('value');
835          var attr_name = $(this).closest('select').attr('name');
836
837          if($('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name).length){
838            $('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name+' a[data-id="'+val+'"]').parent('li').removeClass('disabled');
839          }
840
841          if($('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name).length){
842            $('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name+' option[value="'+val+'"]').removeAttr('disabled');
843          }
844
845      });
846
847      if( $('.woocommerce .mfn-variations-wrapper .mfn-vr ul li.active').length ) {
848        $('.woocommerce .mfn-variations-wrapper .mfn-reset-variations').show();
849      }else{
850        $('.woocommerce .mfn-variations-wrapper .mfn-reset-variations').hide();
851      }
852
853
854    }
855  };
856
857  var wishlist = {
858
859    cookiename: 'mfn_wishlist',
860
861    click: function(id) {
862      wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = [];
863      
864      if( arr.includes( id ) ){
865        arr = arr.filter( el => el != id);
866        $('.mfn-wish-button[data-id="'+id+'"]').removeClass('loved');
867        if( $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').length ) $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').slideUp(300);
868        if( $('body').hasClass('wishlist') && $('.mfn-wish-button[data-id="'+id+'"]').closest('.product').length ) $('.mfn-wish-button[data-id="'+id+'"]').closest('.product').slideUp(300);
869        setTimeout(function() {
870          if( $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').length ) $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').remove();
871          if( $('body').hasClass('wishlist') && $('.mfn-wish-button[data-id="'+id+'"]').closest('.product').length ) $('.mfn-wish-button[data-id="'+id+'"]').closest('.product').remove();
872        }, 400);
873        if($('.wishlist .wishlist-row').length == 1 || $('.wishlist .column_shop_products .product').length == 1){
874          $('.wishlist .wishlist-info').show();
875        }
876      }else{
877        arr.push( id );
878        $('.mfn-wish-button[data-id="'+id+'"]').addClass('loved');
879      }
880      wishlist.createcookie(arr);
881      wishlist.updatecounter(arr.length);
882    },
883
884    set: function() {
885      wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = [];
886      if(arr.length){
887        $.each(arr, function(i, v) {
888          $('.mfn-wish-button[data-id="'+v+'"]').addClass('loved');
889        });
890      }
891        wishlist.updatecounter(arr.length);
892    },
893
894    readcookie: function() {
895      var nameEQ=wishlist.cookiename+"=";
896      var ca=document.cookie.split(';');
897      for(var i=0;i<ca.length;i++){
898        var c=ca[i];
899        while(c.charAt(0)==' ')c=c.substring(1,c.length);
900        if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length)
901      }
902
903      return null
904    },
905
906    createcookie: function(save) {
907      var date=new Date();
908      date.setTime(date.getTime()+(365*24*60*60*1000));
909      var expires="; expires="+date.toGMTString();
910      document.cookie=wishlist.cookiename+"="+save+expires+"; path="+mfnwoovars.rooturl+'/'
911    },
912
913    updatecounter: function(count) {
914        $('.header-wishlist-count').text(count).attr('class', 'header-wishlist-count mfn-header-icon-'+count);
915    }
916
917  };
918
919  modallogin = {
920    check: function() {
921        $('.mfn-header-modal-login form.woocommerce-form-login').attr('action', mfnwoovars.myaccountpage);
922      $('.mfn-header-modal-login .woocommerce-form-login .form-row input').each(function() {
923        if( !$(this).val() ){
924          $(this).closest('.form-row').removeClass('active');
925        }else{
926          $(this).closest('.form-row').addClass('active');
927        }
928      });
929    },
930
931    // modallogin.click()
932
933    click: function($el) {
934
935      var rtl = $('body').hasClass('rtl');
936
937      if( $('.mfn-header-login').hasClass('disabled') ){
938        return true;
939      }
940
941      if( $('body').hasClass('mfn-show-login-modal') ){
942
943        $('.mfn-header-login').removeAttr('style').addClass('disabled');
944        setTimeout(function(){
945          $('.mfn-header-login').addClass('is-side').removeClass('disabled');
946        },300);
947
948        $('body').removeClass('mfn-show-login-modal no-overlay');
949
950      } else {
951
952        // check if we want modal to be boxed or slide from edge
953
954        if( $el.hasClass('is-boxed') ){
955
956          var bodyT = $('body').offset().top || 0,
957            top = $el.offset().top || 0,
958            left = $el.offset().left || 0,
959            windowW = window.innerWidth
960            modalW = 340;
961
962          top -= bodyT;
963
964          $('.mfn-header-login').removeClass('is-side');
965
966          $('.mfn-header-login').css('top', top + 'px');
967
968          if( rtl ){
969
970            if( left - modalW < 0 ){
971              $('.mfn-header-login').css('left', left + 'px');
972            } else {
973              $('.mfn-header-login').css('left', left - modalW + 37 + 'px');
974            }
975
976          } else {
977
978            if( left + modalW > windowW ){
979              $('.mfn-header-login').css('left', left - modalW + 37 + 'px');
980            } else {
981              $('.mfn-header-login').css('left', left + 'px');
982            }
983
984          }
985
986          $('body').addClass('no-overlay');
987
988        }
989
990        $('body').addClass('mfn-show-login-modal');
991
992      }
993
994    }
995
996  };
997
998  checkoutpayment = {
999
1000    start: function( $once = false ) {
1001        $('.wc_payment_methods .wc_payment_method').each(function() {
1002            if( !$(this).find('.mfn-payment-check').length ){
1003                $(this).append('<span class="mfn-payment-check"><i class="icon-check" aria-label="payment check icon"></i></span>');
1004            }
1005            if( $(this).find('.input-radio').is(':checked') ){
1006              checkoutpayment.set( $(this), $once );
1007            }
1008        });
1009        checkoutpayment.watch();
1010    },
1011
1012    watch: function() {
1013        $(document).on('click', '.wc_payment_methods .wc_payment_method', function() {
1014            checkoutpayment.set( $(this) );
1015        });
1016    },
1017
1018    set: function( $li, $once = false ) {
1019        $input = $li.find('.input-radio');
1020        if(!$input.is(':checked')){
1021
1022            $('.wc_payment_methods .wc_payment_method .payment_box').slideUp(300);
1023            $('.wc_payment_methods .wc_payment_method').removeClass('active-payment');
1024
1025            $input.trigger('click');
1026            $li.addClass('active-payment');
1027            $li.find('.payment_box').slideDown(300);
1028
1029        }else{
1030            $li.addClass('active-payment');
1031        }
1032
1033        // FIX | WooCommerce 7.6 no longer using ajax
1034
1035        if( ! $once ){
1036          setTimeout(function(){
1037            checkoutpayment.start( true );
1038          },1500);
1039        }
1040
1041    }
1042
1043  };
1044
1045  quickview = {
1046    headerOffset: false,
1047    display: function(id) {
1048        $.ajax({
1049            url: mfnwoovars.ajaxurl,
1050            data: {
1051                'mfn-woo-nonce': mfnwoovars.wpnonce,
1052                action: 'mfnproductquickview',
1053                id: id
1054            },
1055            type: 'POST',
1056            success: function(response){
1057
1058
1059                $('body').append(response);
1060                $('.mfn-quick-view').removeClass('loading');
1061                quickview.close();
1062                if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){
1063                    productvariations.run();
1064                }
1065
1066                $('html').addClass('mfn-quick-view-opened');
1067
1068                $('.mfn-popup-quickview .mfn-quickview-slider').slick({
1069                    slidesToShow: 1,
1070                    slidesToScroll: 1,
1071                    autoplay: true,
1072                    autoplaySpeed: 3000,
1073                    dots: false,
1074                    arrows: true,
1075                    prevArrow: '<a class="slick-prev mfn-popup-arrow slick-arrow" href="#"><i class="icon-left-open-big" aria-label="previous slide"></i></a>',
1076                    nextArrow: '<a class="slick-next mfn-popup-arrow slick-arrow" href="#"><i class="icon-right-open-big" aria-label="next slide"></i></a>',
1077                    focusOnChange: true,
1078                });
1079
1080                if( $('.mfn-popup-quickview form.cart.variations_form').length ){
1081                    $('.mfn-popup-quickview .variations_form').wc_variation_form();
1082                }
1083
1084                $('.mfn-popup-quickview .mfn-quickview-slider').imagesLoaded( function() {
1085                    quickview.setHeight();
1086                });
1087
1088                wishlist.set();
1089
1090                $(window).on('debouncedresize', quickview.setHeight);
1091
1092                return;
1093            }
1094        });
1095    },
1096    setHeight: function() {
1097        var popupH = $('.mfn-popup-quickview .mfn-popup-content').outerHeight();
1098        var imgH = $('.mfn-popup-quickview .mfn-popup-content-photos .mfn-qs-one-first img').height();
1099
1100        if(imgH > popupH){
1101            $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': popupH });
1102        }else{
1103            $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': imgH });
1104        }
1105
1106        if( $('body').hasClass('mfn-header-scrolled') && $('.mfn-header-tmpl.mfn-hasSticky').length ){
1107            $('html').addClass('mfn-disable-css-animations');
1108            $('body').removeClass('mfn-header-scrolled');
1109            quickview.headerOffset = $('.mfn-header-tmpl.mfn-hasSticky').outerHeight();
1110            $('body').addClass('mfn-header-scrolled');
1111            $('#Wrapper').css({'padding-top': quickview.headerOffset+"px"});
1112        }
1113
1114    },
1115    close: function() {
1116        $('.mfn-close-popup').on('click', function() {
1117            $('.mfn-popup').remove();
1118            $('html').removeClass('mfn-quick-view-opened');
1119            $('html').removeClass('mfn-disable-css-animations');
1120        });
1121
1122        $('.mfn-popup').on('click', function(e) {
1123            if(!$('.mfn-popup-content').is(e.target) && $('.mfn-popup-content').has(e.target).length === 0) {
1124                $('.mfn-popup').remove();
1125                $('html').removeClass('mfn-quick-view-opened');
1126                $('html').removeClass('mfn-disable-css-animations');
1127            }
1128        });
1129    }
1130  };
1131
1132  let woocart = {
1133
1134    force_open: false,
1135
1136    coupons: {
1137
1138      init: function() {
1139        woocart.coupons.toggle();
1140        woocart.coupons.apply();
1141        woocart.coupons.remove();
1142      },
1143
1144      back: function(e) {
1145        if ( !$('.mfn-chft-apply-coupon-wrapper').is(e.target) && !$(e.target).closest('.mfn-chft-apply-coupon-wrapper').length ) {
1146          $('.mfn-chft-apply-coupon-wrapper').removeClass('mfn-chft-apply-coupon-active');
1147          $(document).unbind('click', woocart.coupons.back);
1148        }
1149      },
1150
1151      toggle: function() {
1152        $(document).on('click', '.mfn-chft-apply-coupon-switcher', function(e) {
1153          e.preventDefault();
1154          $(this).closest('.mfn-chft-apply-coupon-wrapper').addClass('mfn-chft-apply-coupon-active');
1155          $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').focus();
1156          $(document).bind('click', woocart.coupons.back);
1157        });
1158      },
1159
1160      remove: function() {
1161
1162        $(document).on('click', '.mfn-chft-apply-coupon-wrapper .mfn-chft-coupons-list .mfn-sidecart-remove-coupon', function(e) {
1163          e.preventDefault();
1164          if( $(this).hasClass('loading') ) return;
1165
1166          $(this).addClass('loading');
1167
1168          let val = $(this).attr('data-code');
1169
1170          $.ajax({
1171            url: mfnwoovars.ajaxurl,
1172            data: {
1173                'mfn-woo-nonce': mfnwoovars.wpnonce,
1174                action: 'mfndeletecoupon',
1175                code: val
1176            },
1177            type: 'POST',
1178            cache: false,
1179            success: function(response){
1180
1181              $(document.body).trigger('wc_fragment_refresh');
1182
1183              // woocart.refresh();
1184
1185
1186            }
1187          });
1188
1189        });
1190
1191      },
1192
1193      apply: function() {
1194
1195        $(document).on('click', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon', function(e) {
1196          e.preventDefault();
1197          $(document.body).trigger('wc_fragment_refresh');
1198        });
1199
1200        $(document).on('keypress', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input', function(e) {
1201            if (e.which == 13) $(document.body).trigger('wc_fragment_refresh');
1202        });
1203
1204      },
1205
1206      removeNotices: function() {
1207        setTimeout(function() {
1208          $('.mfn-chft-apply-coupon-wrapper .mfn-sidecart-notice').remove();
1209        }, 3000);
1210      }
1211    },
1212
1213    start: function() {
1214        /*if( $('a#header_cart .header-cart-count').length ){
1215            if( $('#Top_bar a#header_cart .header-cart-count').text() == '0' ){
1216                $('.mfn-ch-footer-buttons').hide();
1217            }
1218        }*/
1219
1220      return false;
1221    },
1222
1223    click: function() {
1224        if($('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){
1225            $('html').toggleClass('mfn-cart-opened');
1226            woocart.force_open = false;
1227        }
1228    },
1229
1230    delete: function(id){
1231      $.ajax({
1232        url: mfnwoovars.ajaxurl,
1233        data: {
1234            'mfn-woo-nonce': mfnwoovars.wpnonce,
1235            action: 'mfnremovewooproduct',
1236            pid: id
1237        },
1238        type: 'POST',
1239        cache: false,
1240        success: function(response){
1241          $(document.body).trigger('wc_fragment_refresh');
1242          // woocart.refresh();
1243          if($('body').hasClass('woocommerce-cart')){
1244            $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').trigger('click');
1245          }
1246        }
1247      });
1248    },
1249
1250    updatequantity: function(id, qty) {
1251      $.ajax({
1252        url: mfnwoovars.ajaxurl,
1253        data: {
1254            'mfn-woo-nonce': mfnwoovars.wpnonce,
1255            action: 'mfnchangeqtyproduct',
1256            pid: id,
1257            qty: qty
1258        },
1259        type: 'POST',
1260        cache: false,
1261        success: function(response){
1262          $(document.body).trigger('wc_fragment_refresh');
1263          // woocart.refresh();
1264          if($('body').hasClass('woocommerce-cart')){
1265            $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').parent().siblings('.product-quantity').find('input.qty').val(qty).trigger('change');
1266            $('.woocommerce-cart-form .button[name="update_cart"]').trigger('click');
1267          }
1268
1269        }
1270      });
1271    }
1272
1273  };
1274
1275  woocart.coupons.init();
1276
1277  var mfnFakeSale = {
1278
1279    active: true,
1280
1281    time: function() {
1282      let arr = [20000, 25000, 30000, 35000, 40000, 50000];
1283      return arr[Math.floor(Math.random()*arr.length)];
1284    },
1285
1286    init: function() {
1287
1288      if( $('body').hasClass('mfn-ui') ) return;
1289
1290      if( mfnFakeSale.checkCookie("mfnFakeSale") ) mfnFakeSale.active = false;
1291
1292      if( typeof mfn_fake_sale === 'undefined' || !mfnFakeSale.active ) return;
1293
1294      let delay = typeof mfn_fake_sale.delay !== 'undefined' ? mfn_fake_sale.delay : 5;
1295
1296      delay = parseFloat(delay)*1000;
1297
1298      setTimeout(mfnFakeSale.show, delay);
1299
1300      $(document).on('click', '.mfn-fake-sale-noti .mfn-fake-sale-noti-close', function(e) {
1301        e.preventDefault();
1302        mfnFakeSale.active = false;
1303        mfnFakeSale.hide();
1304        mfnFakeSale.addCookie(1, "mfnFakeSale");
1305      });
1306
1307    },
1308
1309    show: function() {
1310      var item = mfn_fake_sale.items[Math.floor(Math.random() * mfn_fake_sale.items.length)];
1311
1312      var html = `<div class="mfn-fake-sale-noti mfn-fake-sale-noti-${mfn_fake_sale.position}">${item} ${mfn_fake_sale.closeable == '1' ? '<a href="/" class="mfn-fake-sale-noti-close"><span class="icon">&#10005;</span></a>' : ''}</div>`;
1313
1314      $('body').append(html);
1315
1316      setTimeout(mfnFakeSale.hide, 15000);
1317    },
1318
1319    hide: function() {
1320      if( $('.mfn-fake-sale-noti').length ) {
1321        $('.mfn-fake-sale-noti').addClass('mfn-fake-sale-noti-out');
1322        setTimeout(function() {$('.mfn-fake-sale-noti').remove(); }, 500);
1323        if( mfnFakeSale.active ) mfnFakeSale.reset();
1324      }
1325    },
1326
1327    reset: function() {
1328      setTimeout(mfnFakeSale.show, mfnFakeSale.time());
1329    },
1330
1331    addCookie(days, cookie_name){
1332      let date=new Date();
1333      date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
1334      let expires="; expires="+date.toGMTString();
1335      document.cookie=cookie_name+"=true"+expires+"; path=/";
1336    },
1337
1338    checkCookie(cookie_name){
1339      var nameEQ = cookie_name+"=";
1340      var ca = document.cookie.split(';');
1341      for(var i=0;i<ca.length;i++){
1342        var c = ca[i];
1343        while(c.charAt(0)==' ') c = c.substring(1,c.length);
1344        if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length)
1345      }
1346      return null
1347    }
1348
1349  };
1350
1351
1352  var productgallery = {
1353    start: function() {
1354
1355      if($('.flex-viewport').length){
1356        $loup = $('.woocommerce-product-gallery__trigger').clone(true).empty().appendTo('.flex-viewport');
1357        $('.woocommerce-product-gallery > .woocommerce-product-gallery__trigger').remove();
1358
1359        if($('.woocommerce-product-gallery .mfn-wish-button').length){
1360          $('.woocommerce-product-gallery .mfn-wish-button').clone(true).appendTo('.flex-viewport');
1361          $('.woocommerce-product-gallery > .mfn-wish-button').remove();
1362          $(document).trigger('resize');
1363        }
1364      }else if( $('.woocommerce-product-gallery__trigger').length ){
1365        $('.woocommerce-product-gallery__trigger').empty();
1366      }
1367
1368      if( $('.mfn-product-gallery').length ){
1369        if($('.flex-control-thumbs').length){
1370          $('.flex-control-thumbs').wrap('<div class="mfn-flex-control-thumbs-wrapper"></div>');
1371        }
1372        $('.woocommerce-product-gallery').imagesLoaded( function() {
1373          if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){
1374            productgallery.verticalThumbs();
1375          }else if( $('.mfn-thumbnails-bottom').length ){
1376            productgallery.horizontalThumbs();
1377          }
1378        });
1379      }
1380
1381    },
1382    horizontalThumbs: function() {
1383        var $container = $('.mfn-product-gallery');
1384        var containerW = $container.outerWidth();
1385        var $scroller = $container.find('.flex-control-thumbs');
1386        var scrollerW = 0;
1387
1388        $scroller.find('li').each(function() {
1389          $(this).addClass('swiper-slide');
1390          scrollerW += $(this).outerWidth();
1391        });
1392
1393        if( !$container.length || !$scroller.length ){
1394          return;
1395        }
1396
1397        if( scrollerW > containerW ){
1398          //return;
1399          $scroller.css({ 'justify-content': 'flex-start', 'width': '100%' });
1400          $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active');
1401        }
1402
1403        $scroller.addClass('swiper-wrapper');
1404
1405        var swiper_opts = {
1406          slidesPerView: 5,
1407          spaceBetween: parseInt(mfnwoovars.productthumbs),
1408        };
1409
1410
1411        $scroller.parent().addClass('mfn-arrows-absolute');
1412        $scroller.parent().append('<div class="swiper-button-next mfn-swiper-arrow"><i class="icon-right-open-big"></i></div><div class="swiper-button-prev mfn-swiper-arrow"><i class="icon-left-open-big"></i></div>');
1413        swiper_opts['navigation'] = {
1414          nextEl: ".swiper-button-next",
1415          prevEl: ".swiper-button-prev",
1416        };
1417
1418        var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", swiper_opts);
1419    },
1420    verticalThumbs: function() {
1421        var $container = $('.mfn-product-gallery');
1422        var containerH = $container.find('.woocommerce-product-gallery__image').first().outerHeight();
1423        var $scroller = $container.find('.flex-control-thumbs');
1424        var scrollerH = 0;
1425        var mimgm = 0; // main image margin
1426        var overlay = mfnwoovars.productthumbsover ? mfnwoovars.productthumbsover : 0;
1427
1428        $scroller.find('li img').css({ 'height': 'auto' });
1429        $scroller.find('li').css({ 'height': 'auto' });
1430
1431        $scroller.find('li').each(function() {
1432          $(this).addClass('swiper-slide').css({ 'margin-bottom': parseInt(mfnwoovars.productthumbs) });
1433          scrollerH += $(this).outerHeight()+parseInt(mfnwoovars.productthumbs);
1434          $(this).css({ 'opacity': '1' });
1435        });
1436
1437        if(mfnwoovars.mainimgmargin == 'mfn-mim-2'){
1438          mimgm = 4;
1439        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-5'){
1440          mimgm = 10;
1441        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-10'){
1442          mimgm = 20;
1443        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-15'){
1444          mimgm = 30;
1445        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-20'){
1446          mimgm = 40;
1447        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-25'){
1448          mimgm = 50;
1449        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-30'){
1450          mimgm = 60;
1451        }
1452
1453        if( !$container.length || !$scroller.length ){
1454          return;
1455        }
1456
1457        $container.find('.flex-viewport').css({'height': 'auto'});
1458
1459        if( scrollerH > containerH ){
1460          if(overlay == 'mfn-thumbnails-overlay'){
1461            $('.mfn-flex-control-thumbs-wrapper').height( (containerH-mimgm) );
1462          }else{
1463            $('.mfn-flex-control-thumbs-wrapper').height(containerH);
1464          }
1465
1466          $scroller.css({ 'align-items': 'flex-start' });
1467          $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active');
1468
1469          $scroller.addClass('swiper-wrapper');
1470
1471          var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", {
1472            slidesPerView: 4,
1473            spaceBetween: parseInt(mfnwoovars.productthumbs),
1474            direction: "vertical",
1475            mousewheel: true,
1476          });
1477
1478          $scroller.find('li').each(function() {
1479            $(this).find('img').css({ 'height': $(this).outerHeight() });
1480            $(this).css({ 'opacity': '1' });
1481          });
1482
1483        }
1484
1485        $container.find('.flex-viewport').css('height', containerH);
1486
1487    }
1488  };
1489
1490  $(window).on('debouncedresize', function() {
1491    if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){
1492        setTimeout(productgallery.verticalThumbs(), 300);
1493    }
1494    setTimeout(function() {shopGalleryListing.prepare();}, 100);
1495  });
1496
1497  var initPhotoSwipeFromDOM = function(gallerySelector) {
1498
1499    var parseThumbnailElements = function() {
1500        var items = [];
1501
1502    $(gallerySelector).find('div img').not('.zoomImg').each(function() {
1503        var img = $(this);
1504        var large_image_src   = img.attr( 'data-large_image' ),
1505              large_image_w   = img.attr( 'data-large_image_width' ),
1506              large_image_h   = img.attr( 'data-large_image_height' ),
1507              alt             = img.attr( 'alt' ),
1508              item            = {
1509                alt  : alt,
1510                src  : large_image_src,
1511                w    : large_image_w,
1512                h    : large_image_h,
1513                title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' )
1514              };
1515            items.push( item );
1516      });
1517
1518        return items;
1519    };
1520
1521    var openPhotoSwipe = function(index) {
1522        var pswpElement = document.querySelectorAll('.pswp')[0],
1523            items;
1524
1525        items = parseThumbnailElements();
1526
1527        var options = {
1528          index: parseInt(index, 10),
1529          //showAnimationDuration: 0,
1530          getThumbBoundsFn: function(index) {
1531                var thumbnail = $('.mfn-product-gallery-grid .mfn-product-gg-img[data-index="'+index+'"] div img:first-child'),
1532                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
1533                    rect = thumbnail.offset();
1534                return {x:rect.left, y:rect.top, w:thumbnail.width()};
1535            }
1536        };
1537
1538        if( isNaN(options.index) ) {
1539            return;
1540        }
1541
1542        gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
1543        gallery.init();
1544    };
1545
1546    $('.mfn-product-gallery-grid a.woocommerce-product-gallery__trigger').on('click', function(e) {
1547        e.preventDefault();
1548        var index = $(this).closest('.mfn-product-gg-img').attr('data-index');
1549        openPhotoSwipe( index );
1550    });
1551
1552
1553    $('.mfn-product-gallery-grid .woocommerce-product-gallery__image a').on('click', function(e) {
1554      e.preventDefault();
1555      if( !$(this).closest('.elementor-widget-container').length ){
1556        $(this).closest('.mfn-product-gg-img').find('.woocommerce-product-gallery__trigger').trigger('click');
1557      }
1558    });
1559
1560};
1561
1562
1563
1564
1565
1566
1567
1568$(document).on('click', '.mfn-woocommerce-tabs .mfn-woocommerce-tabs-nav a', function(e) {
1569  e.preventDefault();
1570  if( $(this).parent('li').hasClass('active') ) return;
1571
1572  let wrapper = $(this).closest('.mfn-woocommerce-tabs');
1573  let selector = $(this).attr('href').replace('#', '.');
1574
1575  $(this).parent().siblings('li').removeClass('active');
1576  $(this).closest('.mfn-woocommerce-tabs').find('.mfn-woocommerce-tabs-content.active').removeClass('active');
1577
1578  $(this).parent('li').addClass('active');
1579  wrapper.find(selector).addClass('active');
1580
1581});
1582
1583
1584/*let shopGalleryListing = {
1585  wrap: false,
1586  images: [],
1587  index: 0,
1588  touchStartX: 0,
1589  touchStartY: 0,
1590  touchThreshold: 30, // px
1591
1592  init: function () {
1593
1594    // NEXT
1595    $(document).on('click', '.mfn-product-list-gallery-slider .mfn-plgsn-next', function (e) {
1596      e.preventDefault();
1597      shopGalleryListing.setFromNav($(this));
1598      shopGalleryListing.next();
1599    });
1600
1601    // PREV
1602    $(document).on('click', '.mfn-product-list-gallery-slider .mfn-plgsn-prev', function (e) {
1603      e.preventDefault();
1604      shopGalleryListing.setFromNav($(this));
1605      shopGalleryListing.prev();
1606    });
1607
1608    // PAGINATION
1609    $(document).on('click', '.mfn-product-list-gallery-slider .mfn-product-list-gallery-slider-pagination a', function (e) {
1610      e.preventDefault();
1611      shopGalleryListing.setFromNav($(this));
1612      shopGalleryListing.show();
1613    });
1614
1615    // TOUCH START
1616    $(document).on('touchstart', '.mfn-product-list-gallery-slider a img', function (e) {
1617      const touch = e.originalEvent.touches[0];
1618
1619      shopGalleryListing.wrap   = $(this).closest('.mfn-product-list-gallery-slider');
1620      shopGalleryListing.images = JSON.parse(shopGalleryListing.wrap.attr('data-images')) || [];
1621      shopGalleryListing.index  = parseInt(shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-arrow').attr('data-index') || 0, 10);
1622
1623      shopGalleryListing.touchStartX = touch.clientX;
1624      shopGalleryListing.touchStartY = touch.clientY;
1625    });
1626
1627    // TOUCH END
1628    $(document).on('touchend', '.mfn-product-list-gallery-slider a img', function (e) {
1629      const touch = e.originalEvent.changedTouches[0];
1630      const dx = touch.clientX - shopGalleryListing.touchStartX;
1631      const dy = touch.clientY - shopGalleryListing.touchStartY;
1632
1633      // ignore mostly vertical swipes
1634      if (Math.abs(dy) > Math.abs(dx)) return;
1635
1636      if (dx < -shopGalleryListing.touchThreshold) {
1637        // swipe left -> next
1638        shopGalleryListing.next();
1639      } else if (dx > shopGalleryListing.touchThreshold) {
1640        // swipe right -> prev
1641        shopGalleryListing.prev();
1642      }
1643    });
1644  },
1645
1646  setFromNav: function ($el) {
1647    this.wrap   = $el.closest('.mfn-product-list-gallery-slider');
1648    this.images = JSON.parse(this.wrap.attr('data-images')) || [];
1649    this.index  = parseInt($el.attr('data-index') || 0, 10);
1650  },
1651
1652  show: function () {
1653    if (this.index < 0 || this.index >= this.images.length) return;
1654
1655    this.wrap.find('img.attachment-woocommerce_thumbnail')
1656      .attr('src', this.images[this.index]);
1657
1658    this.wrap.find('.mfn-product-list-gallery-slider-pagination a').removeClass('active');
1659    this.wrap.find('.mfn-product-list-gallery-slider-pagination a[data-index="' + this.index + '"]').addClass('active');
1660  },
1661
1662  next: function () {
1663    if (this.index >= this.images.length - 1) {
1664      this.index = 0;
1665    } else {
1666      this.index++;
1667    }
1668    this.wrap.find('.mfn-product-list-gallery-slider-arrow').attr('data-index', this.index);
1669    this.show();
1670  },
1671
1672  prev: function () {
1673    if (this.index <= 0) {
1674      this.index = this.images.length - 1;
1675    } else {
1676      this.index--;
1677    }
1678    this.wrap.find('.mfn-product-list-gallery-slider-arrow').attr('data-index', this.index);
1679    this.show();
1680  }
1681};*/
1682
1683
1684let shopGalleryListing = {
1685  wrap: false,
1686  offset: 0,
1687  slide_w: 0,
1688  index: 0,
1689  slides_count: 1,
1690  touchStartX: 0,
1691  touchStartY: 0,
1692  touchThreshold: 2, // px
1693  hasSwiped: false,
1694  timing: 300,
1695  dx: 0,
1696  dy: 0,
1697  abs_dx: 0,
1698  tolerance: 0,
1699  is_mobile: false,
1700  prepared: false,
1701  init: function () {
1702
1703    this.prepare();
1704
1705    // NEXT
1706    $(document).on('click', '.mfn-product-list-gallery-slider .mfn-plgsn-next', function (e) {
1707      e.preventDefault();
1708      if( $(this).hasClass('disabled') ) return;
1709      $(this).addClass('disabled');
1710      shopGalleryListing.wrap   = $(this).closest('.mfn-product-list-gallery-slider');
1711      shopGalleryListing.setFromNav();
1712
1713      if( !shopGalleryListing.wrap.find('.mfn-slide-current').next('.mfn-product-list-gallery-item').length ){
1714        shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').append(shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item:first-child'));
1715        shopGalleryListing.offset = shopGalleryListing.offset + shopGalleryListing.slide_w;
1716        shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({'transform': `translate3d(${shopGalleryListing.offset}px, 0, 0)`, 'transition-duration': `0s`});
1717        
1718        // shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({'left': shopGalleryListing.offset});
1719      }
1720
1721      setTimeout(shopGalleryListing.next, 50);
1722
1723    });
1724
1725    // PREV
1726    $(document).on('click', '.mfn-product-list-gallery-slider .mfn-plgsn-prev', function (e) {
1727      e.preventDefault();
1728      if( $(this).hasClass('disabled') ) return;
1729      $(this).addClass('disabled');
1730      
1731      shopGalleryListing.wrap   = $(this).closest('.mfn-product-list-gallery-slider');
1732      shopGalleryListing.setFromNav();
1733
1734      if( !shopGalleryListing.wrap.find('.mfn-slide-current').prev('.mfn-product-list-gallery-item').length ){
1735        shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').prepend(shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item:last-child'));
1736        shopGalleryListing.offset = shopGalleryListing.offset - shopGalleryListing.slide_w;
1737        shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({'transform': `translate3d(${shopGalleryListing.offset}px, 0, 0)`, 'transition-duration': `0s`});
1738        //shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({'left': shopGalleryListing.offset});
1739      }
1740
1741      setTimeout(shopGalleryListing.prev, 50);
1742    });
1743
1744    // PAGINATION
1745    $(document).on('click', '.mfn-product-list-gallery-slider .mfn-product-list-gallery-slider-pagination a', function (e) {
1746      e.preventDefault();
1747
1748      if( $(this).hasClass('active') ) return;
1749      if( $(this).closest('.mfn-product-list-gallery-slider-pagination').hasClass('disabled') ) return;
1750      $(this).closest('.mfn-product-list-gallery-slider-pagination').addClass('disabled');
1751
1752      shopGalleryListing.wrap = $(this).closest('.mfn-product-list-gallery-slider');
1753      shopGalleryListing.slide_w = shopGalleryListing.wrap.outerWidth();
1754      shopGalleryListing.index = $(this).attr('data-index');
1755      shopGalleryListing.wrap.find('.mfn-product-list-gallery-item[data-index="'+shopGalleryListing.index+'"]').addClass('mfn-slide-current').siblings().removeClass('mfn-slide-current');
1756      shopGalleryListing.offset = -shopGalleryListing.wrap.find('.mfn-product-list-gallery-item[data-index="'+shopGalleryListing.index+'"]').position().left;
1757
1758      shopGalleryListing.show();
1759    });
1760
1761    // TOUCH START
1762    $(document).on('touchstart', '.mfn-product-list-gallery-slider', function (e) {
1763
1764      if( shopGalleryListing.hasSwiped ) return;
1765
1766      const touch = e.originalEvent.touches[0];
1767
1768      shopGalleryListing.wrap    = $(this);
1769      shopGalleryListing.offset  = parseFloat(shopGalleryListing.wrap.attr('data-offset')) || 0;
1770      shopGalleryListing.slide_w = shopGalleryListing.wrap.outerWidth();
1771
1772      shopGalleryListing.touchStartX = touch.clientX;
1773      shopGalleryListing.touchStartY = touch.clientY;
1774
1775      shopGalleryListing.tolerance = shopGalleryListing.slide_w * 0.9;
1776
1777      shopGalleryListing.prepared = true;
1778
1779    });
1780
1781
1782    $(document).on('touchmove', '.mfn-product-list-gallery-slider', function (e) {
1783      const touch = e.originalEvent.touches[0];
1784
1785      shopGalleryListing.dx = touch.clientX - shopGalleryListing.touchStartX;
1786      shopGalleryListing.dy = touch.clientY - shopGalleryListing.touchStartY;
1787
1788      shopGalleryListing.abs_dx = Math.abs(shopGalleryListing.dx);
1789
1790      // ignore mostly vertical moves
1791      if (  Math.abs(shopGalleryListing.dy) < 100 ) {
1792        e.preventDefault();
1793      }else{
1794        shopGalleryListing.hasSwiped = true;
1795        return;
1796      }
1797
1798      if (shopGalleryListing.hasSwiped) return;
1799
1800      if (shopGalleryListing.dx < -shopGalleryListing.touchThreshold) {
1801        // swipe left -> next
1802
1803        if( !shopGalleryListing.wrap.find('.mfn-slide-current').next('.mfn-product-list-gallery-item').length ){
1804          shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').append(shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item:first-child'));
1805          shopGalleryListing.offset = shopGalleryListing.offset + shopGalleryListing.slide_w;
1806        }
1807
1808        if( shopGalleryListing.abs_dx >= shopGalleryListing.tolerance ) {
1809          shopGalleryListing.next();
1810          shopGalleryListing.hasSwiped = true;
1811          return;
1812        }
1813
1814        let tmp_offset = shopGalleryListing.offset-shopGalleryListing.abs_dx;
1815        // shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({left: tmp_offset});
1816        shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({transform: `translate3d(${tmp_offset}px, 0, 0)`, 'transition-duration': `0s`});
1817
1818      } else if (shopGalleryListing.dx >= shopGalleryListing.touchThreshold) {
1819        // swipe right -> prev
1820
1821        if( !shopGalleryListing.wrap.find('.mfn-slide-current').prev('.mfn-product-list-gallery-item').length ){
1822          shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').prepend(shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item:last-child'));
1823          shopGalleryListing.offset = shopGalleryListing.offset - shopGalleryListing.slide_w;
1824        }
1825
1826        if( shopGalleryListing.abs_dx >= shopGalleryListing.tolerance ){
1827          shopGalleryListing.prev();
1828          shopGalleryListing.hasSwiped = true;
1829          return;
1830        }
1831
1832        //shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({left: (shopGalleryListing.offset+shopGalleryListing.abs_dx)});
1833        let tmp_offset = shopGalleryListing.offset+shopGalleryListing.abs_dx;
1834        shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({transform: `translate3d(${tmp_offset}px, 0, 0)`, 'transition-duration': `0s`});
1835        //shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({left: tmp_offset});
1836        
1837      }
1838
1839    });
1840
1841    $(document).on('touchend', '.mfn-product-list-gallery-slider', function (e) {
1842
1843      const show_move = $('body').hasClass('mobile-row-2-products') && shopGalleryListing.is_mobile ? shopGalleryListing.tolerance / 2 : shopGalleryListing.tolerance / 4;
1844
1845        
1846        if ( !shopGalleryListing.hasSwiped && shopGalleryListing.dx > shopGalleryListing.touchThreshold ) {
1847          shopGalleryListing.prev();
1848          return;
1849        }else if( !shopGalleryListing.hasSwiped ) {
1850          shopGalleryListing.next();
1851          return;
1852        }
1853
1854        shopGalleryListing.show();
1855
1856
1857      /*shopGalleryListing.hasSwiped = false;
1858      shopGalleryListing.prepared = false;*/
1859      
1860    });
1861
1862  },
1863
1864  prepare: function() {
1865    // shopGalleryListing.prepeare
1866    if( !$('.mfn-product-list-gallery-slider').length ) return;
1867
1868    $('.mfn-product-list-gallery-slider .mfn-product-list-gallery-item').removeAttr('style');
1869
1870    setTimeout(function() {
1871      $('.mfn-product-list-gallery-slider').each(function() {
1872        let width = $(this).outerWidth();
1873        $(this).find('.mfn-product-list-gallery-item').css({'width': width});
1874      });
1875
1876    }, 1);
1877    
1878    if( $(window).width() < 767 ) { shopGalleryListing.is_mobile = true; }else{ shopGalleryListing.is_mobile = false; }
1879
1880  },
1881
1882  setFromNav: function () {
1883    shopGalleryListing.offset = parseFloat(shopGalleryListing.wrap.attr('data-offset')) || 0;
1884    shopGalleryListing.slide_w = shopGalleryListing.wrap.outerWidth();
1885    shopGalleryListing.slides_count = shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item').length;
1886  },
1887
1888  show: function() {
1889    // shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').animate({left: shopGalleryListing.offset}, shopGalleryListing.timing, 'swing', function() { shopGalleryListing.wrap.find('.disabled').removeClass('disabled'); shopGalleryListing.hasSwiped   = false; shopGalleryListing.prepared = false;});
1890    
1891    shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track').css({'transform': `translate3d(${shopGalleryListing.offset}px, 0, 0)`, 'transition-duration': `300ms`}); 
1892
1893    setTimeout(function() {
1894      shopGalleryListing.hasSwiped = false; 
1895      shopGalleryListing.prepared = false;
1896      shopGalleryListing.wrap.find('.disabled').removeClass('disabled');
1897    }, 290);
1898
1899    shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-pagination a[data-index="'+shopGalleryListing.index+'"]').addClass('active').siblings().removeClass('active');
1900    shopGalleryListing.wrap.attr('data-offset', shopGalleryListing.offset);
1901  },
1902
1903  next: function () {
1904
1905    if( shopGalleryListing.wrap.find('.mfn-slide-current').next('.mfn-product-list-gallery-item').length ){
1906      shopGalleryListing.offset = shopGalleryListing.offset - shopGalleryListing.slide_w;
1907      shopGalleryListing.index = shopGalleryListing.wrap.find('.mfn-slide-current').next('.mfn-product-list-gallery-item').attr('data-index');
1908      shopGalleryListing.wrap.find('.mfn-slide-current').next('.mfn-product-list-gallery-item').addClass('mfn-slide-current').siblings('.mfn-product-list-gallery-item').removeClass('mfn-slide-current');
1909    }else{
1910      shopGalleryListing.offset = 0;
1911      shopGalleryListing.index = 0;
1912      shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item:first-child').addClass('mfn-slide-current').siblings('.mfn-product-list-gallery-item').removeClass('mfn-slide-current');
1913    }
1914
1915    shopGalleryListing.show();
1916  },
1917
1918  prev: function () {
1919
1920    if( shopGalleryListing.wrap.find('.mfn-slide-current').prev('.mfn-product-list-gallery-item').length ){
1921      shopGalleryListing.offset = shopGalleryListing.offset + shopGalleryListing.slide_w;
1922      shopGalleryListing.index = shopGalleryListing.wrap.find('.mfn-slide-current').prev('.mfn-product-list-gallery-item').attr('data-index');
1923      shopGalleryListing.wrap.find('.mfn-slide-current').prev('.mfn-product-list-gallery-item').addClass('mfn-slide-current').siblings('.mfn-product-list-gallery-item').removeClass('mfn-slide-current');
1924    }else{
1925      shopGalleryListing.offset = -(shopGalleryListing.slide_w * shopGalleryListing.slides_count)+shopGalleryListing.slide_w;
1926      shopGalleryListing.index = shopGalleryListing.slides_count - 1;
1927      shopGalleryListing.wrap.find('.mfn-product-list-gallery-slider-track .mfn-product-list-gallery-item:last-child').addClass('mfn-slide-current').siblings('.mfn-product-list-gallery-item').removeClass('mfn-slide-current');
1928    }
1929
1930    shopGalleryListing.show();
1931  }
1932};
1933
1934shopGalleryListing.init();
1935
1936$(document).on('mfn:tabber:open', shopGalleryListing.prepare);
1937
1938$(document).on('mfn:ajax:refresh', function() {
1939  
1940  shopGalleryListing.prepare() 
1941
1942  if( $('.woocommerce .column_shop_products ul.products.list').length ){
1943      alignListHeights();
1944  }
1945
1946  if( $('.products li img').length ) {
1947      $('.products li img').each(function() {
1948          if( typeof $(this).attr('data-src') !== 'undefined' ) {
1949              $(this).attr('src', $(this).attr('data-src'));
1950          }
1951      })
1952  }
1953
1954});
1955
1956
1957let mfnCurrencySwitcher = {
1958  selector: false,
1959  init: function() {
1960    if( !$('.column_header_currency_switcher .mfn-currency-switcher-wrapper:not(.initialized)').length ) return;
1961
1962    $('.column_header_currency_switcher .mfn-currency-switcher-wrapper:not(.initialized)').each(function() {
1963
1964      mfnCurrencySwitcher.selector = $(this);
1965      mfnCurrencySwitcher.selector.addClass('initialized');
1966
1967      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-flags') ) mfnCurrencySwitcher.attach_flags();
1968
1969      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-dropdown mfn-currency-switcher-dropdown-icon') ) mfnCurrencySwitcher.dropdown_icon();
1970
1971      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-dropdown') ) mfnCurrencySwitcher.dropdown();
1972
1973      mfnCurrencySwitcher.selector = false;
1974
1975    });
1976  },
1977  attach_flags: function() {
1978    let flag_path = mfnCurrencySwitcher.selector.attr('data-themepath');
1979    mfnCurrencySwitcher.selector.find('li a').each(function() {
1980      let code = $(this).attr('rel');
1981      let flag_uri = `${flag_path}/${code}.svg`;
1982      $(this).prepend('<img class="mfn-wcml-flag" src="'+flag_uri+'" alt="" width="20" height="15">');
1983    });
1984  },
1985  dropdown_icon: function() {
1986    let icon = mfnCurrencySwitcher.selector.attr('data-path');
1987    mfnCurrencySwitcher.selector.find('li.wcml-cs-active-currency > a').each(function() {
1988      $(this).append('<i class="mfn-arrow-icon '+icon+'"></i>')
1989    });
1990  },
1991  dropdown: function() {
1992    let clone = mfnCurrencySwitcher.selector.find('ul').clone();
1993    let active = mfnCurrencySwitcher.selector.find('ul li.wcml-cs-active-currency').clone();
1994
1995    mfnCurrencySwitcher.selector.find('ul').before('<ul class="mfn-wcml-dropdown-ready"></ul>');
1996    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready').append(active);
1997    mfnCurrencySwitcher.selector.find('ul:not(.mfn-wcml-dropdown-ready)').remove();
1998    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready li').append(clone);
1999    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready li ul li.wcml-cs-active-currency').remove();
2000  }
2001}
2002
2003mfnCurrencySwitcher.init();
2004
2005
2006$(document.body).on('wc_fragments_refreshed', function () {
2007  $('.mfn-cart-holder').removeClass('loading');
2008
2009  let total = parseInt($('.header-cart-count').first().text(), 10) || 0;
2010
2011  if ( $('body').hasClass('woocommerce-cart') && $('.mfn-builder-content.mfn-cart-tmpl-builder').length ) {
2012    $('.mfn-builder-content.mfn-cart-tmpl-builder').removeClass('mfn-cart-tmpl-not-empty mfn-cart-tmpl-empty');
2013
2014    if ( ! total ) {
2015      $('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-empty');
2016    } else {
2017      $('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-not-empty');
2018    }
2019  }
2020
2021  if ( total === 0 ) {
2022    $('.mfn-ch-footer-buttons').hide();
2023  } else {
2024    $('.mfn-ch-footer-buttons').show();
2025  }
2026
2027  if ( woocart.force_open ) woocart.click();
2028  
2029});
2030
2031
2032
2033})(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.