PageSourceSearch

https://virginhairoutlet.co/wp-content/themes/betheme/js/woocommerce.js?ver=27.5.13

js virginhairoutlet.co collected 2026-09-26 08:19:58 UTC 50,063 bytes, 1,487 lines download raw bytes

1(function($) {
2$(document).ready(function() {
3
4   if( $('body').hasClass('shop-sidecart-active') ) {
5    woocart.refresh(); // prevent caching sidecart
6  }
7
8  mfnFakeSale.init();
9
10  // gallery grid
11  if(!$('body').hasClass('mfn-ui') && $('.mfn-product-gallery-grid').length){
12    // zoom
13    if( !$('body').hasClass('product-zoom-disabled') ){
14      $(' .mfn-product-gg-img a').zoom();
15    }
16    // lightbox
17    initPhotoSwipeFromDOM('.mfn-product-gallery-grid');
18  }
19
20  $( document ).on( 'click', '.mfn-quick-view', function(e) {
21    e.preventDefault();
22    var id = $(this).attr('data-id');
23    $(this).addClass('loading');
24    quickview.display(id);
25  });
26
27  if( $('body').hasClass('mfn-ajax-add-to-cart') ){
28    $( document ).on( 'click', '.single_add_to_cart_button:not(.disabled)', function(e) {
29
30      e.preventDefault();
31
32      var cc = $('#header_cart .header-cart-count').length ? $('#header_cart .header-cart-count').first().text() : 0;
33
34      var $thisbutton = $(this);
35      var $form = $thisbutton.closest('form.cart'),
36      c_form = $thisbutton.closest('form.cart').get(0);
37
38      var $qty = $form.find('input.qty');
39      var qty_max = $qty.attr('max');
40
41      if( typeof qty_max !== typeof undefined && qty_max != '' && parseInt($qty.val()) > parseInt(qty_max) ){
42        $qty.css({'background-color': '#77a464', 'transition': '0.8s'});
43        $qty.val(qty_max);
44
45        setTimeout(function() {
46            $qty.removeAttr('style');
47        }, 1000);
48
49        return;
50      }
51
52      var ajaxAct = {
53        url: wc_add_to_cart_params.ajax_url,
54        type: 'POST',
55        beforeSend: function (response) {
56            $(document.body).trigger('adding_to_cart');
57            $thisbutton.removeClass('added').addClass('loading');
58        },
59        success: function (response) {
60
61            if( typeof response.error !== 'undefined' ){
62                location.reload();
63                return;
64            }
65
66            $thisbutton.addClass('added').removeClass('loading');
67            $(document.body).trigger('added_to_cart');
68            $(document.body).trigger('wc_fragment_refresh');
69
70            $('.mfn-cart-holder').attr('aria-expanded', 'true');
71        }
72      };
73
74      // check if grouped product has any quantity selected
75      if( $form.hasClass('grouped_form') ){
76
77        var $inputs = $('input.qty', $form);
78        var hasQuantity = false;
79
80        $inputs.each(function(){
81          if( parseInt($(this).val()) > 0 ){
82            hasQuantity = true;
83          }
84        });
85
86        if( ! hasQuantity ){
87          alert( mfnwoovars.groupedQuantityErrori18n);
88          return false;
89        }
90
91      }
92
93      var formData = new FormData(c_form);
94      formData.append('action', 'woocommerce_add_to_cart');
95      formData.append('current_cart', cc);
96
97      if( $('.mnm_cart.mnm_data .mnm_add_to_cart_button').length ){
98        formData.delete('add-to-cart');
99      }
100
101      if ( !formData.has('product_id') && 'undefined' !== $thisbutton.val() ) {
102        formData.append( 'product_id', parseInt( $thisbutton.val() ) );
103      }
104
105      if ( formData.has('variation_id') ) {
106        formData.delete('product_id');
107      }
108
109      ajaxAct['data'] = formData;
110      ajaxAct['contentType'] = false;
111      ajaxAct['processData'] = false;
112
113      $(document.body).trigger('adding_to_cart', [$thisbutton, formData]);
114      $.ajax( ajaxAct );
115
116      return false;
117
118    });
119  }
120
121  // woo product category arrows
122  if( $('.wc-block-product-categories-list') ){
123    $('.wc-block-product-categories-list li.wc-block-product-categories-list-item').each(function() {
124      if($(this).children('ul').length){
125        $(this).append('<span class="cat-expander"></span>');
126      }
127    });
128
129    $('.wc-block-product-categories-list li > span.cat-expander').on('click', function(e) {
130      if($(this).siblings('ul').is(':visible')){
131        $(this).siblings('ul').slideUp(300);
132        $(this).parent('li').removeClass('li-expanded');
133      }else{
134        $(this).siblings('ul').slideDown(300);
135         $(this).parent('li').addClass('li-expanded');
136      }
137    });
138  }
139
140  // Append spans to additional info table
141  if($('.woocommerce-product-attributes').length){
142    spanToAdditionalInfo();
143  }
144
145  // product variations
146  if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){
147    productvariations.run();
148  }
149
150  $('.toggle-mfn-cart').on('click', function(e) {
151    if( $('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){
152        e.preventDefault();
153
154        if( $('body').hasClass('mfn-bebuilder-header') ) return;
155
156        if ( $('html').hasClass('mfn-cart-opened')) {
157          $('.mfn-cart-holder').attr('aria-expanded', 'false')
158        } else {
159          $('.mfn-cart-holder').attr('aria-expanded', 'true');
160        }
161
162        woocart.click();
163    }
164  });
165
166  $('.toggle-mfn-cart').on('keypress', function(e) {
167    e.preventDefault();
168    if ( e.originalEvent.key !== 'Enter' ) return;
169
170    if ( $('html').hasClass('mfn-cart-opened')) {
171      $('.mfn-cart-holder').attr('aria-expanded', 'false');
172
173      const domPrefix = $('body').hasClass('side-slide-is-open') ? '.extras-wrapper ' : '.top_bar_right ';
174      $(`${domPrefix} #header_cart`).trigger('focus');
175    } else {
176      $('.mfn-cart-holder').find('a').first().trigger('focus');
177      $('.mfn-cart-holder').attr('aria-expanded', 'true');
178    }
179
180    woocart.click();
181  });
182
183  $('.mfn-cart-overlay').on('click', function() {
184    woocart.click();
185  });
186
187  if($('body').hasClass('shop-sidecart-active')){
188      woocart.start();
189  }
190
191  $('.toggle-login-modal').on('click', function(e) {
192    e.preventDefault();
193    if( $('body').hasClass('mfn-ui') ) return;
194    modallogin.click($(this));
195  });
196
197  $(document).on('mouseup', function(e) {
198
199    // login form
200    if( $('body').hasClass('mfn-show-login-modal') ) {
201      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 ){
202        modallogin.click();
203      }
204    }
205
206  });
207
208  function alignListHeights(){
209    var i = 0;
210    $('.woocommerce .column_shop_products ul.products.list li.product').each(function() {
211        $(this).css({ 'min-height': '1px'});
212
213        var height= $(this).outerHeight();
214        var imgHeight = $(this).find('.product-loop-thumb').outerHeight();
215
216        if(imgHeight > height){
217            $(this).css({'min-height': imgHeight});
218        }
219    });
220  }
221
222  if( $('.woocommerce .column_shop_products ul.products.list').length ){
223    alignListHeights();
224    $(window).on('debouncedresize', alignListHeights);
225  }
226
227
228  $('.mfn-header-modal-login .woocommerce-form-login .form-row').on('click', function() {
229    if( !$(this).hasClass('active') ){
230      $(this).addClass('active');
231    }
232  });
233   // fix for safari
234  $('.mfn-header-modal-login .woocommerce-form-login .form-row input.input-text').on('focus keyup', function() {
235    if( !$(this).closest('.form-row').hasClass('active') ){
236      $(this).closest('.form-row').addClass('active');
237    }
238  });
239
240  $('.mfn-header-modal-login .woocommerce-form-login .form-row input').on('blur change', function() {
241    modallogin.check();
242  });
243
244  modallogin.check();
245
246  $('.mfn-cart-holder .mfn-ch-content').on('click', '.mfn-chp-remove', function(e) {
247    e.preventDefault();
248    if(!$('.mfn-cart-holder').hasClass('loading')){
249      $('.mfn-cart-holder').addClass('loading');
250      var pid = $(this).closest('.mfn-ch-product').attr('data-row-key');
251      woocart.delete(pid);
252    }
253  });
254
255  $('.mfn-woo-products').on('change', '.mfn-variations-wrapper-loop .mfn-vr-select', function() {
256    var link = $(this).find(':selected').attr('data-link');
257    if(link != '') {
258      window.location.href = link;
259    }
260  });
261
262  $('.mfn-cart-holder .mfn-ch-content').on('change', '.qty', function() {
263    var $el = $(this);
264    if(!$('.mfn-cart-holder').hasClass('loading')){
265        $('.mfn-cart-holder').addClass('loading');
266        var pid = $el.closest('.mfn-ch-product').attr('data-row-key');
267        var qty = $el.val();
268        woocart.updatequantity(pid, qty);
269    }
270  });
271
272
273  if( $('body').hasClass('woocommerce-checkout') ){
274
275    if( $('.woocommerce-form-login').length ){
276        $('.woocommerce-form-login').addClass('checkout-form-toggle');
277    }
278    if( $('.woocommerce-form-coupon').length ){
279        $('.woocommerce-form-coupon').addClass('checkout-form-toggle');
280    }
281
282    /*$(document).ajaxComplete(function() {
283      // checkoutpayment.start();
284    });*/
285
286    setTimeout(function(){
287      checkoutpayment.start();
288    },1500);
289  }
290
291  /*$( document.body ).on( 'adding_to_cart', function( e ) {
292    if(!$('.header-cart-count').length || !$('.header-cart-total').length){
293        $('.header-cart').append('<span class="header-cart-count"></span>');
294         $('#header_cart').append('<p class="header-cart-total"></p>');
295    }
296  });*/
297
298  //$( document.body ).on( 'wc_fragment_refresh added_to_cart', function( e ) {
299$( document.body ).on( 'added_to_cart', function( e ) {
300    if($('body').hasClass('shop-sidecart-active')) {
301      woocart.refresh();
302      if(!$('html').hasClass('mfn-cart-opened')) {
303        //woocart.click();
304        woocart.force_open = true;
305      }
306    }
307  } );
308
309  $( document.body ).on( 'updated_cart_totals removed_from_cart', function(){
310    if($('body').hasClass('shop-sidecart-active')){
311        woocart.refresh();
312    }
313  });
314
315  $(document).on('mouseup click', '.wc-block-cart__main .wc-block-cart-item__quantity .wc-block-components-quantity-selector__button', function() {
316    setTimeout( function() { $(document.body).trigger('wc_fragment_refresh')}, 2000 );
317  });
318
319  $(document).on('mouseup click', '.wc-block-cart__main .wc-block-cart-item__quantity .wc-block-cart-item__remove-link', function() {
320    setTimeout( function() { $(document.body).trigger('wc_fragment_refresh')}, 2000 );
321  });
322
323
324  // wishlist
325  wishlist.set();
326  $(document).on('click', '.mfn-wish-button', function(e) { e.preventDefault(); var id = $(this).attr('data-id'); wishlist.click(id); });
327
328  // attr ajjax filter
329  if( $('form.mfn_attr_filters').length ){
330
331    $(document).on('click', '.mfn-woo-list-active-filters li span', function() {
332        var id = $(this).attr('data-id');
333        $(this).closest('li').addClass('laoding');
334        if($('.widget.mfn_woo_attributes .mfn_attr_filters input.'+id).length){
335            if($('.mfn_woo_attributes .mfn_attr_filters input.'+id).is(':checked')) {
336                $('.mfn_woo_attributes .mfn_attr_filters input.'+id).prop('checked', false);
337                if( $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').hasClass('active') ) {
338                    $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').removeClass('active');
339                }
340            }
341            grabFiltersForms();
342        }
343    });
344
345    $(document).on('click', 'form.mfn_attr_filters ul li', function() {
346
347    var $li = $(this);
348    var $ul = $(this).closest('ul');
349    var $form = $(this).closest('form');
350    var input_class = $li.find('input').attr('class');
351
352    // on click active filters
353    if($form.hasClass('mfn-before-products-list-form')){
354
355        $li.find('input').is(':checked') ? $li.find('input').prop('checked', false) : $li.find('input').prop('checked', true);
356        $li.toggleClass('active');
357
358    }else if($form.hasClass('mfn_attr_filters')){
359        $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);
360        $('form.mfn_attr_filters ul li input.'+input_class).closest('li').toggleClass('active');
361    }
362
363    if( !$li.closest('form').hasClass('button-enabled') ){
364        $li.addClass('loading');
365        grabFiltersForms();
366    }
367
368    });
369  }
370
371  if( $('form.mfn_attr_filters.button-enabled').length ){
372    $('form.mfn_attr_filters.button-enabled').submit(function(e) {
373        e.preventDefault();
374        grabFiltersForms();
375    });
376  }
377
378  $.fn.extend({
379    /** formData:
380     * Most form submissions will require special formatting different from
381     * a normal get request (a=val1,val2&b=val3 vs. a=val1&a=val2&b=val3).
382     * Sample use: $.getJSON(url,$("myFormElement").formData(),callback);.
383     * @return {String} Serialized form data appropriate for GET requests.
384     * @author Joe Johnson
385     */
386    formData: function(){
387      var data = {};
388      $.each(this.serializeArray(),function(i,o){
389        if (data[o.name]) data[o.name] += ','+o.value;
390        else data[o.name] = o.value;
391      });
392      return $.param(data);
393    }
394  });
395
396  function removeQueryParameters(url, parametersToRemove) {
397    url = window.location.origin + url;
398    const urlObject = new URL(url);
399    parametersToRemove.forEach(param => {
400      urlObject.searchParams.delete(param);
401    });
402    return urlObject.toString();
403  }
404
405  function grabFiltersForms(){
406    let formsArr = [];
407    var path = getUrlWithoutPagination();
408
409    $('form.mfn_attr_filters').each(function() {
410      formsArr.push( $(this).formData() );
411      if( $(this).formData().includes('filter_') ) {
412        if( $(this).formData().includes('&') ){
413          var f_helper = $(this).formData().split('&');
414          f_helper.map( h => {
415            var q_helper = h.split('=');
416            formsArr.push( `query_type_${q_helper[0].replace('filter_', '')}=or` );
417          });
418        }else{
419          var q_helper = $(this).formData().split('=');
420          formsArr.push( `query_type_${q_helper[0].replace('filter_', '')}=or` );
421        }
422      }
423    });
424
425    if( $('form.woocommerce-ordering').length ){
426      if( $('form.woocommerce-ordering input[name="post_type"]').length ) formsArr.push('post_type='+$('form.woocommerce-ordering input[name="post_type"]').val());
427      if( $('form.woocommerce-ordering input[name="s"]').length ) formsArr.push('s='+$('form.woocommerce-ordering input[name="s"]').val());
428      if( $('form.woocommerce-ordering input[name="paged"]').length ) formsArr.push('paged='+$('form.woocommerce-ordering input[name="paged"]').val());
429      if( $('form.woocommerce-ordering select[name="orderby"]').length ) formsArr.push('orderby='+$('form.woocommerce-ordering select[name="orderby"]').val());
430    }
431
432    formUnique = formsArr.filter( function(a){if (!this[a]) {this[a] = 1; return a;}}, {} );
433
434    let formData = formUnique.join('&');
435    let url = path+'?'+formData;
436    load_products_ajax(url);
437  }
438
439  function load_products_ajax(url) {
440
441    var $products = $('.entry-content .mfn-woo-products');
442    $('.mfn_attr_filters button').addClass('loading disabled');
443
444    if($('body').hasClass('archive')){
445
446        $.get(url, function(responseText) {
447
448            $('.pager_wrapper').remove();
449            $('.woocommerce-info').remove();
450
451            if( $('.default-woo-list').length ){
452                $('.default-woo-list').replaceWith( $( $.parseHTML( responseText )).find('.default-woo-list').clone() );
453            }else if( $('.column_shop_products').length ){
454                $('.column_shop_products').each(function(i) {
455                  $(this).replaceWith( $( $.parseHTML( responseText )).find('.column_shop_products').eq(i).clone() );
456                });
457            }
458
459            $('.woocommerce-ordering select').on('change', function() {
460                $(this).closest('form').submit();
461            });
462
463            // remove unwanted attibutes
464            url = removeQueryParameters(url, ['layout', 'per_page']);
465            // replace %2C with coma
466            url = url.replace(/%2C/g,",");
467            // set browser url
468            history.replaceState(null, '', url);
469
470            if ($('.mcb-sidebar').length) {
471              var maxH = $('#Content .sections_group').outerHeight();
472              $('.mcb-sidebar').each(function() {
473                $(this).css('min-height', 0);
474                if ($(this).height() > maxH) {
475                  maxH = $(this).height();
476                }
477              });
478              $('.mcb-sidebar').css('min-height', maxH + 'px');
479            }
480
481            if( $('.woocommerce .column_shop_products ul.products.list').length ){
482                alignListHeights();
483                $(window).on('debouncedresize', alignListHeights);
484            }
485
486            if( $('.products li img').length ){
487                $('.products li img').each(function() {
488                    if( typeof $(this).attr('data-src') !== 'undefined' ){
489                        $(this).attr('src', $(this).attr('data-src'));
490                    }
491                })
492            }
493
494            if( $($.parseHTML( responseText )).find('.mfn-infinite-load-button').length ){
495              $(document).trigger('mfn:waypoints');
496            }
497
498            $('.mfn_attr_filters ul li').removeClass('loading');
499            $('.mfn_attr_filters button').removeClass('loading disabled');
500        });
501    }else{
502        window.location.href = url;
503    }
504
505  }
506
507  function getUrlWithoutPagination(){
508    var current_url = window.location.pathname;
509    var url = '';
510
511    // get url witout pagination
512    if(current_url.includes("/page/")){
513        url = current_url.split("/page/")[0];
514    }else{
515        url = current_url;
516    }
517
518    // if not listing page redirect
519    if( !$('body').hasClass('archive') ){
520        url = $('form.mfn_attr_filters').attr('action');
521    }
522
523    return url;
524  }
525
526  setTimeout(function() {
527    productgallery.start();
528  }, 300);
529
530});
531
532  // Append spans to additional info table
533
534  function spanToAdditionalInfo(){
535    $('.woocommerce-product-attributes td, .woocommerce-product-attributes th').each(function() {
536      $(this).html('<span>'+$(this).html()+'</span>');
537    });
538  }
539
540  var productvariations = {
541    run: function() {
542
543      $('.mfn-variations-wrapper .mfn-vr-options li a').on('click', function(e) {
544        e.preventDefault();
545        $(this).parent().siblings().removeClass('active');
546        $(this).parent().addClass('active');
547        var id = $(this).attr('data-id');
548        var atr = $(this).parent().parent().attr('data-atr');
549        $('.variations select#'+atr).val(id);
550        $('.variations select#'+atr).trigger('change');
551        if( $('form.variations_form').attr('data-product_variations') != 'false' ) {
552            setTimeout(function() { productvariations.triggerChange(); }, 100);
553        }
554      });
555
556      $('.mfn-variations-wrapper .mfn-vr-select').on('change', function() {
557        var id = $(this).val();
558        var atr = $(this).attr('data-atr');
559        $('.variations select#'+atr).val(id);
560        $('.variations select#'+atr).trigger('change');
561        if( $('form.variations_form').attr('data-product_variations') != 'false' ) {
562            setTimeout(function() { productvariations.triggerChange(); }, 100);
563        }
564      });
565
566      $('.woocommerce div.product form.cart .variations select').each(function() {
567        var val = $(this).val();
568        var atr = $(this).attr('id');
569        if( val.length ){
570          if($('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').length){
571            $('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').trigger('click');
572          }else if($('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').length){
573            $('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').val(val);
574          }
575        }
576      });
577
578      if( window.location.search ){
579        if( $('.mfn-variations-wrapper ul.mfn-vr-options').length ){
580          const urlParams = new URLSearchParams(window.location.search);
581          $('.mfn-variations-wrapper ul.mfn-vr-options').each(function() {
582            let attr = $(this).attr('data-atr');
583            if( urlParams.get(attr) && typeof attr !== 'undefined' ){
584              if( $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').length ) $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').trigger('click');
585            }
586          });
587        }
588      }
589
590      setTimeout(function() { productvariations.triggerChange(); }, 200);
591
592      //$('.variations').hide();
593
594    },
595
596    triggerChange: function() {
597
598        if( $('.mfn-vr-options li').length )
599            $('.mfn-vr-options li a').css('opacity', '0.3');
600
601        if( $('.mfn-vr-select option').length )
602            $('.mfn-vr-select option').attr('disabled', 'true');
603
604
605        $('.woocommerce form.variations_form.cart table.variations select option').each(function() {
606            var val = $(this).attr('value');
607            var attr_name = $(this).closest('select').attr('name');
608
609            if($('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name).length)
610                $('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name+' a[data-id="'+val+'"]').css('opacity', '1');
611
612            if($('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name).length)
613                $('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name+' option[value="'+val+'"]').removeAttr('disabled');
614        });
615
616    }
617  };
618
619  var wishlist = {
620
621    cookiename: 'mfn_wishlist',
622
623    click: function(id) {
624      wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = [];
625      if( arr.includes( id ) ){
626        arr = arr.filter( el => el != id);
627        $('.mfn-wish-button[data-id="'+id+'"]').removeClass('loved');
628        $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').slideUp(300);
629        setTimeout(function() {
630          $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').remove();
631        }, 400);
632        if($('.wishlist .wishlist-row').length == 1){
633          $('.wishlist .wishlist-info').show();
634        }
635      }else{
636        arr.push( id );
637        $('.mfn-wish-button[data-id="'+id+'"]').addClass('loved');
638      }
639      wishlist.createcookie(arr);
640      wishlist.updatecounter(arr.length);
641    },
642
643    set: function(){
644      wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = [];
645      if(arr.length){
646        $.each(arr, function(i, v) {
647          $('.mfn-wish-button[data-id="'+v+'"]').addClass('loved');
648        });
649      }
650        wishlist.updatecounter(arr.length);
651    },
652
653    readcookie: function(){
654      var nameEQ=wishlist.cookiename+"=";
655      var ca=document.cookie.split(';');
656      for(var i=0;i<ca.length;i++){
657        var c=ca[i];
658        while(c.charAt(0)==' ')c=c.substring(1,c.length);
659        if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length)
660      }
661
662      return null
663    },
664
665    createcookie: function(save){
666      var date=new Date();
667      date.setTime(date.getTime()+(365*24*60*60*1000));
668      var expires="; expires="+date.toGMTString();
669      document.cookie=wishlist.cookiename+"="+save+expires+"; path="+mfnwoovars.rooturl+'/'
670    },
671
672    updatecounter: function(count) {
673        $('.header-wishlist-count').text(count).attr('class', 'header-wishlist-count mfn-header-icon-'+count);
674    }
675
676  };
677
678  modallogin = {
679    check: function() {
680        $('.mfn-header-modal-login form.woocommerce-form-login').attr('action', mfnwoovars.myaccountpage);
681      $('.mfn-header-modal-login .woocommerce-form-login .form-row input').each(function() {
682        if( !$(this).val() ){
683          $(this).closest('.form-row').removeClass('active');
684        }else{
685          $(this).closest('.form-row').addClass('active');
686        }
687      });
688    },
689
690    // modallogin.click()
691
692    click: function($el) {
693
694      var rtl = $('body').hasClass('rtl');
695
696      if( $('.mfn-header-login').hasClass('disabled') ){
697        return true;
698      }
699
700      if( $('body').hasClass('mfn-show-login-modal') ){
701
702        $('.mfn-header-login').removeAttr('style').addClass('disabled');
703        setTimeout(function(){
704          $('.mfn-header-login').addClass('is-side').removeClass('disabled');
705        },300);
706
707        $('body').removeClass('mfn-show-login-modal no-overlay');
708
709      } else {
710
711        // check if we want modal to be boxed or slide from edge
712
713        if( $el.hasClass('is-boxed') ){
714
715          var bodyT = $('body').offset().top || 0,
716            top = $el.offset().top || 0,
717            left = $el.offset().left || 0,
718            windowW = window.innerWidth
719            modalW = 340;
720
721          top -= bodyT;
722
723          $('.mfn-header-login').removeClass('is-side');
724
725          $('.mfn-header-login').css('top', top + 'px');
726
727          if( rtl ){
728
729            if( left - modalW < 0 ){
730              $('.mfn-header-login').css('left', left + 'px');
731            } else {
732              $('.mfn-header-login').css('left', left - modalW + 37 + 'px');
733            }
734
735          } else {
736
737            if( left + modalW > windowW ){
738              $('.mfn-header-login').css('left', left - modalW + 37 + 'px');
739            } else {
740              $('.mfn-header-login').css('left', left + 'px');
741            }
742
743          }
744
745          $('body').addClass('no-overlay');
746
747        }
748
749        $('body').addClass('mfn-show-login-modal');
750
751      }
752
753    }
754
755  };
756
757  checkoutpayment = {
758
759    start: function( $once = false ) {
760        $('.wc_payment_methods .wc_payment_method').each(function() {
761            if( !$(this).find('.mfn-payment-check').length ){
762                $(this).append('<span class="mfn-payment-check"><i class="icon-check" aria-label="payment check icon"></i></span>');
763            }
764            if( $(this).find('.input-radio').is(':checked') ){
765              checkoutpayment.set( $(this), $once );
766            }
767        });
768        checkoutpayment.watch();
769    },
770
771    watch: function() {
772        $(document).on('click', '.wc_payment_methods .wc_payment_method', function() {
773            checkoutpayment.set( $(this) );
774        });
775    },
776
777    set: function( $li, $once = false ) {
778        $input = $li.find('.input-radio');
779        if(!$input.is(':checked')){
780
781            $('.wc_payment_methods .wc_payment_method .payment_box').slideUp(300);
782            $('.wc_payment_methods .wc_payment_method').removeClass('active-payment');
783
784            $input.trigger('click');
785            $li.addClass('active-payment');
786            $li.find('.payment_box').slideDown(300);
787
788        }else{
789            $li.addClass('active-payment');
790        }
791
792        // FIX | WooCommerce 7.6 no longer using ajax
793
794        if( ! $once ){
795          setTimeout(function(){
796            checkoutpayment.start( true );
797          },1500);
798        }
799
800    }
801
802  };
803
804  quickview = {
805    headerOffset: false,
806    display: function(id) {
807        $.ajax({
808            url: mfnwoovars.ajaxurl,
809            data: {
810                'mfn-woo-nonce': mfnwoovars.wpnonce,
811                action: 'mfnproductquickview',
812                id: id
813            },
814            type: 'POST',
815            success: function(response){
816
817
818                $('body').append(response);
819                $('.mfn-quick-view').removeClass('loading');
820                quickview.close();
821                if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){
822                    productvariations.run();
823                }
824
825                $('html').addClass('mfn-quick-view-opened');
826
827                $('.mfn-popup-quickview .mfn-quickview-slider').slick({
828                    slidesToShow: 1,
829                    slidesToScroll: 1,
830                    autoplay: true,
831                    autoplaySpeed: 3000,
832                    dots: false,
833                    arrows: true,
834                    prevArrow: '<a class="slick-prev mfn-popup-arrow slick-arrow" href="#"><i class="icon-left-open-big" aria-label="previous slide"></i></a>',
835                    nextArrow: '<a class="slick-next mfn-popup-arrow slick-arrow" href="#"><i class="icon-right-open-big" aria-label="next slide"></i></a>',
836                    focusOnChange: true,
837                });
838
839                if( $('.mfn-popup-quickview form.cart.variations_form').length ){
840                    $('.mfn-popup-quickview .variations_form').wc_variation_form();
841                }
842
843                $('.mfn-popup-quickview .mfn-quickview-slider').imagesLoaded( function() {
844                    quickview.setHeight();
845                });
846
847                wishlist.set();
848
849                $(window).on('debouncedresize', quickview.setHeight);
850
851                return;
852            }
853        });
854    },
855    setHeight: function() {
856        var popupH = $('.mfn-popup-quickview .mfn-popup-content').outerHeight();
857        var imgH = $('.mfn-popup-quickview .mfn-popup-content-photos .mfn-qs-one-first img').height();
858
859        if(imgH > popupH){
860            $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': popupH });
861        }else{
862            $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': imgH });
863        }
864
865        if( $('body').hasClass('mfn-header-scrolled') && $('.mfn-header-tmpl.mfn-hasSticky').length ){
866            $('html').addClass('mfn-disable-css-animations');
867            $('body').removeClass('mfn-header-scrolled');
868            quickview.headerOffset = $('.mfn-header-tmpl.mfn-hasSticky').outerHeight();
869            $('body').addClass('mfn-header-scrolled');
870            $('#Wrapper').css({'padding-top': quickview.headerOffset+"px"});
871        }
872
873    },
874    close: function() {
875        $('.mfn-close-popup').on('click', function() {
876            $('.mfn-popup').remove();
877            $('html').removeClass('mfn-quick-view-opened');
878            $('html').removeClass('mfn-disable-css-animations');
879        });
880
881        $('.mfn-popup').on('click', function(e) {
882            if(!$('.mfn-popup-content').is(e.target) && $('.mfn-popup-content').has(e.target).length === 0) {
883                $('.mfn-popup').remove();
884                $('html').removeClass('mfn-quick-view-opened');
885                $('html').removeClass('mfn-disable-css-animations');
886            }
887        });
888    }
889  },
890
891  woocart = {
892
893    force_open: false,
894
895    coupons: {
896
897      init: function() {
898        woocart.coupons.toggle();
899        woocart.coupons.apply();
900        woocart.coupons.remove();
901      },
902
903      back: function(e) {
904        if ( !$('.mfn-chft-apply-coupon-wrapper').is(e.target) && !$(e.target).closest('.mfn-chft-apply-coupon-wrapper').length ) {
905          $('.mfn-chft-apply-coupon-wrapper').removeClass('mfn-chft-apply-coupon-active');
906          $(document).unbind('click', woocart.coupons.back);
907        }
908      },
909
910      toggle: function() {
911        $(document).on('click', '.mfn-chft-apply-coupon-switcher', function(e) {
912          e.preventDefault();
913          $(this).closest('.mfn-chft-apply-coupon-wrapper').addClass('mfn-chft-apply-coupon-active');
914          $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').focus();
915          $(document).bind('click', woocart.coupons.back);
916        });
917      },
918
919      remove: function() {
920
921        $(document).on('click', '.mfn-chft-apply-coupon-wrapper .mfn-chft-coupons-list .mfn-sidecart-remove-coupon', function(e) {
922          e.preventDefault();
923          if( $(this).hasClass('loading') ) return;
924
925          $(this).addClass('loading');
926
927          let val = $(this).attr('data-code');
928
929          $.ajax({
930            url: mfnwoovars.ajaxurl,
931            data: {
932                'mfn-woo-nonce': mfnwoovars.wpnonce,
933                action: 'mfndeletecoupon',
934                code: val
935            },
936            type: 'POST',
937            cache: false,
938            success: function(response){
939
940              woocart.refresh();
941    
942
943            }
944          });
945
946        });
947
948      },
949
950      ajax: function() {
951
952        let button = $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon');
953        if( button.hasClass('loading') ) return;
954
955        $('.mfn-chft-apply-coupon-wrapper .mfn-sidecart-notice').remove();
956        $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').removeClass('mfn-error');
957
958        if( !$('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').val().length ){
959          $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').addClass('mfn-error');
960          return;
961        }
962
963        let val = $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').val();
964
965        button.addClass('loading');
966
967        $.ajax({
968          url: mfnwoovars.ajaxurl,
969          data: {
970              'mfn-woo-nonce': mfnwoovars.wpnonce,
971              action: 'mfnapplycoupon',
972              code: val
973          },
974          type: 'POST',
975          cache: false,
976          success: function(response){
977
978            if( response ){
979
980              let noticeHtml = '';
981
982              if( typeof response.notice.error === 'undefined' ) {
983
984                $('.mfn-cart-holder .mfn-ch-content').html(response.content);
985                $('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer);
986
987              }else{
988                $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').addClass('mfn-error');
989              }
990
991              for (const [key, value] of Object.entries(response.notice)) {
992                
993                noticeHtml += '<div class="mfn-sidecart-notice mfn-sidecart-notice-'+key+'">';
994                
995                if( value ){
996                  noticeHtml += value.map((x) => `<p>${x.notice}</p>`).join('');
997                }
998
999                noticeHtml += '</div>';
1000
1001                //$('.mfn-chft-apply-coupon').append();
1002              }
1003
1004              $('.mfn-chft-apply-coupon-wrapper').prepend(noticeHtml);
1005              woocart.coupons.removeNotices();
1006            }
1007            
1008            button.removeClass('loading');
1009
1010          }
1011        });
1012
1013      },
1014
1015      apply: function() {
1016
1017        $(document).on('click', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon', function(e) {
1018          e.preventDefault();
1019          woocart.coupons.ajax();
1020        });
1021
1022        $(document).on('keypress', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input', function(e) {
1023            if (e.which == 13) woocart.coupons.ajax();
1024        });
1025
1026      },
1027
1028      removeNotices: function() {
1029        setTimeout(function() {
1030          $('.mfn-chft-apply-coupon-wrapper .mfn-sidecart-notice').remove();
1031        }, 3000);
1032      }
1033    },
1034
1035    start: function() {
1036        /*if( $('a#header_cart .header-cart-count').length ){
1037            if( $('#Top_bar a#header_cart .header-cart-count').text() == '0' ){
1038                $('.mfn-ch-footer-buttons').hide();
1039            }
1040        }*/
1041
1042      return false;
1043    },
1044
1045    click: function() {
1046        if($('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){
1047            $('html').toggleClass('mfn-cart-opened');
1048            woocart.force_open = false;
1049        }
1050    },
1051
1052    refresh: function(){
1053      $.ajax({
1054        url: mfnwoovars.ajaxurl,
1055        data: {
1056            'mfn-woo-nonce': mfnwoovars.wpnonce,
1057            action: 'mfnrefreshcart'
1058        },
1059        type: 'POST',
1060        cache: false,
1061        success: function(response){
1062          $('.mfn-cart-holder .mfn-ch-content').html(response.content);
1063          $('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer);
1064          $('.mfn-cart-holder').removeClass('loading');
1065
1066          if( $('body').hasClass('woocommerce-cart') && $('.mfn-builder-content.mfn-cart-tmpl-builder').length ){
1067            $('.mfn-builder-content.mfn-cart-tmpl-builder').removeClass('mfn-cart-tmpl-not-empty mfn-cart-tmpl-empty');
1068            
1069            if( !response.total ){
1070              $('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-empty');
1071            }else{
1072              $('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-not-empty');
1073            }
1074          }
1075
1076          // side cart buttons
1077          if( response.total == 0 ){
1078            $('.mfn-ch-footer-buttons').hide();
1079          }else{
1080            $('.mfn-ch-footer-buttons').show();
1081          }
1082
1083          if( woocart.force_open ) woocart.click();
1084
1085          return;
1086        }
1087      });
1088    },
1089
1090    delete: function(id){
1091      $.ajax({
1092        url: mfnwoovars.ajaxurl,
1093        data: {
1094            'mfn-woo-nonce': mfnwoovars.wpnonce,
1095            action: 'mfnremovewooproduct',
1096            pid: id
1097        },
1098        type: 'POST',
1099        cache: false,
1100        success: function(response){
1101          $(document.body).trigger('wc_fragment_refresh');
1102          woocart.refresh();
1103          if($('body').hasClass('woocommerce-cart')){
1104            $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').trigger('click');
1105          }
1106        }
1107      });
1108    },
1109
1110    updatequantity: function(id, qty) {
1111      $.ajax({
1112        url: mfnwoovars.ajaxurl,
1113        data: {
1114            'mfn-woo-nonce': mfnwoovars.wpnonce,
1115            action: 'mfnchangeqtyproduct',
1116            pid: id,
1117            qty: qty
1118        },
1119        type: 'POST',
1120        cache: false,
1121        success: function(response){
1122          $(document.body).trigger('wc_fragment_refresh');
1123          woocart.refresh();
1124          if($('body').hasClass('woocommerce-cart')){
1125            $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').parent().siblings('.product-quantity').find('input.qty').val(qty).trigger('change');
1126            $('.woocommerce-cart-form .button[name="update_cart"]').trigger('click');
1127          }
1128
1129        }
1130      });
1131    }
1132
1133  };
1134
1135  woocart.coupons.init();
1136
1137  var mfnFakeSale = {
1138
1139    active: true,
1140
1141    time: function() {
1142      let arr = [20000, 25000, 30000, 35000, 40000, 50000];
1143      return arr[Math.floor(Math.random()*arr.length)];
1144    },
1145
1146    init: function() {
1147
1148      if( $('body').hasClass('mfn-ui') ) return;
1149
1150      if( mfnFakeSale.checkCookie("mfnFakeSale") ) mfnFakeSale.active = false;
1151
1152      if( typeof mfn_fake_sale === 'undefined' || !mfnFakeSale.active ) return;
1153
1154      let delay = typeof mfn_fake_sale.delay !== 'undefined' ? mfn_fake_sale.delay : 5;
1155
1156      delay = parseFloat(delay)*1000;
1157
1158      setTimeout(mfnFakeSale.show, delay);
1159
1160      $(document).on('click', '.mfn-fake-sale-noti .mfn-fake-sale-noti-close', function(e) {
1161        e.preventDefault();
1162        mfnFakeSale.active = false;
1163        mfnFakeSale.hide();
1164        mfnFakeSale.addCookie(1, "mfnFakeSale");
1165      });
1166
1167    },
1168
1169    show: function() {
1170      var item = mfn_fake_sale.items[Math.floor(Math.random() * mfn_fake_sale.items.length)];
1171
1172      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;
1172</span></a>' : ''}</div>`;
1173
1174      $('body').append(html);
1175
1176      setTimeout(mfnFakeSale.hide, 15000);
1177    },
1178
1179    hide: function() {
1180      if( $('.mfn-fake-sale-noti').length ) {
1181        $('.mfn-fake-sale-noti').addClass('mfn-fake-sale-noti-out');
1182        setTimeout(function() {$('.mfn-fake-sale-noti').remove(); }, 500);
1183        if( mfnFakeSale.active ) mfnFakeSale.reset();
1184      }
1185    },
1186
1187    reset: function() {
1188      setTimeout(mfnFakeSale.show, mfnFakeSale.time());
1189    },
1190
1191    addCookie(days, cookie_name){
1192      let date=new Date();
1193      date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
1194      let expires="; expires="+date.toGMTString();
1195      document.cookie=cookie_name+"=true"+expires+"; path=/";
1196    },
1197
1198    checkCookie(cookie_name){
1199      var nameEQ = cookie_name+"=";
1200      var ca = document.cookie.split(';');
1201      for(var i=0;i<ca.length;i++){
1202        var c = ca[i];
1203        while(c.charAt(0)==' ') c = c.substring(1,c.length);
1204        if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length)
1205      }
1206      return null
1207    }
1208
1209  };
1210
1211
1212  var productgallery = {
1213    start: function() {
1214
1215      if($('.flex-viewport').length){
1216        $loup = $('.woocommerce-product-gallery__trigger').clone(true).empty().appendTo('.flex-viewport');
1217        $('.woocommerce-product-gallery > .woocommerce-product-gallery__trigger').remove();
1218
1219        if($('.woocommerce-product-gallery .mfn-wish-button').length){
1220          $('.woocommerce-product-gallery .mfn-wish-button').clone(true).appendTo('.flex-viewport');
1221          $('.woocommerce-product-gallery > .mfn-wish-button').remove();
1222          $(document).trigger('resize');
1223        }
1224      }else if( $('.woocommerce-product-gallery__trigger').length ){
1225        $('.woocommerce-product-gallery__trigger').empty();
1226      }
1227
1228      if( $('.mfn-product-gallery').length ){
1229        if($('.flex-control-thumbs').length){
1230          $('.flex-control-thumbs').wrap('<div class="mfn-flex-control-thumbs-wrapper"></div>');
1231        }
1232        $('.woocommerce-product-gallery').imagesLoaded( function() {
1233          if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){
1234            productgallery.verticalThumbs();
1235          }else if( $('.mfn-thumbnails-bottom').length ){
1236            productgallery.horizontalThumbs();
1237          }
1238        });
1239      }
1240
1241    },
1242    horizontalThumbs: function() {
1243        var $container = $('.mfn-product-gallery');
1244        var containerW = $container.outerWidth();
1245        var $scroller = $container.find('.flex-control-thumbs');
1246        var scrollerW = 0;
1247
1248        $scroller.find('li').each(function() {
1249          $(this).addClass('swiper-slide');
1250          scrollerW += $(this).outerWidth();
1251        });
1252
1253        if( !$container.length || !$scroller.length ){
1254          return;
1255        }
1256
1257        if( scrollerW > containerW ){
1258          //return;
1259          $scroller.css({ 'justify-content': 'flex-start', 'width': '100%' });
1260          $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active');
1261        }
1262
1263        $scroller.addClass('swiper-wrapper');
1264
1265        var swiper_opts = {
1266          slidesPerView: 5,
1267          spaceBetween: parseInt(mfnwoovars.productthumbs),
1268        };
1269
1270
1271        $scroller.parent().addClass('mfn-arrows-absolute');
1272        $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>');
1273        swiper_opts['navigation'] = {
1274          nextEl: ".swiper-button-next",
1275          prevEl: ".swiper-button-prev",
1276        };
1277
1278        var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", swiper_opts);
1279    },
1280    verticalThumbs: function() {
1281        var $container = $('.mfn-product-gallery');
1282        var containerH = $container.find('.woocommerce-product-gallery__image').first().outerHeight();
1283        var $scroller = $container.find('.flex-control-thumbs');
1284        var scrollerH = 0;
1285        var mimgm = 0; // main image margin
1286        var overlay = mfnwoovars.productthumbsover ? mfnwoovars.productthumbsover : 0;
1287
1288        $scroller.find('li img').css({ 'height': 'auto' });
1289        $scroller.find('li').css({ 'height': 'auto' });
1290
1291        $scroller.find('li').each(function() {
1292          $(this).addClass('swiper-slide').css({ 'margin-bottom': parseInt(mfnwoovars.productthumbs) });
1293          scrollerH += $(this).outerHeight()+parseInt(mfnwoovars.productthumbs);
1294          $(this).css({ 'opacity': '1' });
1295        });
1296
1297        if(mfnwoovars.mainimgmargin == 'mfn-mim-2'){
1298          mimgm = 4;
1299        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-5'){
1300          mimgm = 10;
1301        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-10'){
1302          mimgm = 20;
1303        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-15'){
1304          mimgm = 30;
1305        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-20'){
1306          mimgm = 40;
1307        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-25'){
1308          mimgm = 50;
1309        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-30'){
1310          mimgm = 60;
1311        }
1312
1313        if( !$container.length || !$scroller.length ){
1314          return;
1315        }
1316
1317        $container.find('.flex-viewport').css({'height': 'auto'});
1318
1319        if( scrollerH > containerH ){
1320          if(overlay == 'mfn-thumbnails-overlay'){
1321            $('.mfn-flex-control-thumbs-wrapper').height( (containerH-mimgm) );
1322          }else{
1323            $('.mfn-flex-control-thumbs-wrapper').height(containerH);
1324          }
1325
1326          $scroller.css({ 'align-items': 'flex-start' });
1327          $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active');
1328
1329          $scroller.addClass('swiper-wrapper');
1330
1331          var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", {
1332            slidesPerView: 4,
1333            spaceBetween: parseInt(mfnwoovars.productthumbs),
1334            direction: "vertical",
1335            mousewheel: true,
1336          });
1337
1338          $scroller.find('li').each(function() {
1339            $(this).find('img').css({ 'height': $(this).outerHeight() });
1340            $(this).css({ 'opacity': '1' });
1341          });
1342
1343        }
1344
1345        $container.find('.flex-viewport').css('height', containerH);
1346
1347    }
1348  };
1349
1350  $(window).on('debouncedresize', function() {
1351    if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){
1352        setTimeout(productgallery.verticalThumbs(), 300);
1353    }
1354  });
1355
1356  var initPhotoSwipeFromDOM = function(gallerySelector) {
1357
1358    var parseThumbnailElements = function() {
1359        var items = [];
1360
1361    $(gallerySelector).find('div img').not('.zoomImg').each(function() {
1362        var img = $(this);
1363        var large_image_src   = img.attr( 'data-large_image' ),
1364              large_image_w   = img.attr( 'data-large_image_width' ),
1365              large_image_h   = img.attr( 'data-large_image_height' ),
1366              alt             = img.attr( 'alt' ),
1367              item            = {
1368                alt  : alt,
1369                src  : large_image_src,
1370                w    : large_image_w,
1371                h    : large_image_h,
1372                title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' )
1373              };
1374            items.push( item );
1375      });
1376
1377        return items;
1378    };
1379
1380    var openPhotoSwipe = function(index) {
1381        var pswpElement = document.querySelectorAll('.pswp')[0],
1382            items;
1383
1384        items = parseThumbnailElements();
1385
1386        var options = {
1387          index: parseInt(index, 10),
1388          //showAnimationDuration: 0,
1389          getThumbBoundsFn: function(index) {
1390                var thumbnail = $('.mfn-product-gallery-grid .mfn-product-gg-img[data-index="'+index+'"] div img:first-child'),
1391                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
1392                    rect = thumbnail.offset();
1393                return {x:rect.left, y:rect.top, w:thumbnail.width()};
1394            }
1395        };
1396
1397        if( isNaN(options.index) ) {
1398            return;
1399        }
1400
1401        gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
1402        gallery.init();
1403    };
1404
1405    $('.mfn-product-gallery-grid a.woocommerce-product-gallery__trigger').on('click', function(e) {
1406        e.preventDefault();
1407        var index = $(this).closest('.mfn-product-gg-img').attr('data-index');
1408        openPhotoSwipe( index );
1409    });
1410
1411
1412    $('.mfn-product-gallery-grid .woocommerce-product-gallery__image a').on('click', function(e) {
1413      e.preventDefault();
1414      if( !$(this).closest('.elementor-widget-container').length ){
1415        $(this).closest('.mfn-product-gg-img').find('.woocommerce-product-gallery__trigger').trigger('click');
1416      }
1417    });
1418
1419};
1420
1421
1422$(document).on('click', '.mfn-woocommerce-tabs .mfn-woocommerce-tabs-nav a', function(e) {
1423  e.preventDefault();
1424  if( $(this).parent('li').hasClass('active') ) return;
1425
1426  let wrapper = $(this).closest('.mfn-woocommerce-tabs');
1427  let selector = $(this).attr('href').replace('#', '.');
1428
1429  $(this).parent().siblings('li').removeClass('active');
1430  $(this).closest('.mfn-woocommerce-tabs').find('.mfn-woocommerce-tabs-content.active').removeClass('active');
1431
1432  $(this).parent('li').addClass('active');
1433  wrapper.find(selector).addClass('active');
1434
1435});
1436
1437
1438let mfnCurrencySwitcher = {
1439  selector: false,
1440  init: function() {
1441    if( !$('.column_header_currency_switcher .mfn-currency-switcher-wrapper:not(.initialized)').length ) return;
1442
1443    $('.column_header_currency_switcher .mfn-currency-switcher-wrapper:not(.initialized)').each(function() {
1444
1445      mfnCurrencySwitcher.selector = $(this);
1446      mfnCurrencySwitcher.selector.addClass('initialized');
1447
1448      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-flags') ) mfnCurrencySwitcher.attach_flags();
1449
1450      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-dropdown mfn-currency-switcher-dropdown-icon') ) mfnCurrencySwitcher.dropdown_icon();
1451
1452      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-dropdown') ) mfnCurrencySwitcher.dropdown();
1453
1454      mfnCurrencySwitcher.selector = false;
1455
1456    });
1457  },
1458  attach_flags: function() {
1459    let flag_path = mfnCurrencySwitcher.selector.attr('data-themepath');
1460    mfnCurrencySwitcher.selector.find('li a').each(function() {
1461      let code = $(this).attr('rel');
1462      let flag_uri = `${flag_path}/${code}.svg`;
1463      $(this).prepend('<img class="mfn-wcml-flag" src="'+flag_uri+'" alt="" width="20" height="15">');
1464    });
1465  },
1466  dropdown_icon: function() {
1467    let icon = mfnCurrencySwitcher.selector.attr('data-path');
1468    mfnCurrencySwitcher.selector.find('li.wcml-cs-active-currency > a').each(function() {
1469      $(this).append('<i class="mfn-arrow-icon '+icon+'"></i>')
1470    });
1471  },
1472  dropdown: function() {
1473    let clone = mfnCurrencySwitcher.selector.find('ul').clone();
1474    let active = mfnCurrencySwitcher.selector.find('ul li.wcml-cs-active-currency').clone();
1475
1476    mfnCurrencySwitcher.selector.find('ul').before('<ul class="mfn-wcml-dropdown-ready"></ul>');
1477    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready').append(active);
1478    mfnCurrencySwitcher.selector.find('ul:not(.mfn-wcml-dropdown-ready)').remove();
1479    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready li').append(clone);
1480    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready li ul li.wcml-cs-active-currency').remove();
1481  }
1482}
1483
1484mfnCurrencySwitcher.init();
1485
1486
1487})(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.