PageSourceSearch

https://saharov.help/wp-content/themes/betheme/js/woocommerce.js?ver=27.5.4

js saharov.help collected 2026-10-07 13:14:25 UTC 49,976 bytes, 1,485 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('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('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').replaceWith( $( $.parseHTML( responseText )).find('.column_shop_products').clone() );
455            }
456
457            $('.woocommerce-ordering select').on('change', function() {
458                $(this).closest('form').submit();
459            });
460
461            // remove unwanted attibutes
462            url = removeQueryParameters(url, ['layout', 'per_page']);
463            // replace %2C with coma
464            url = url.replace(/%2C/g,",");
465            // set browser url
466            history.replaceState(null, '', url);
467
468            if ($('.mcb-sidebar').length) {
469              var maxH = $('#Content .sections_group').outerHeight();
470              $('.mcb-sidebar').each(function() {
471                $(this).css('min-height', 0);
472                if ($(this).height() > maxH) {
473                  maxH = $(this).height();
474                }
475              });
476              $('.mcb-sidebar').css('min-height', maxH + 'px');
477            }
478
479            if( $('.woocommerce .column_shop_products ul.products.list').length ){
480                alignListHeights();
481                $(window).on('debouncedresize', alignListHeights);
482            }
483
484            if( $('.products li img').length ){
485                $('.products li img').each(function() {
486                    if( typeof $(this).attr('data-src') !== 'undefined' ){
487                        $(this).attr('src', $(this).attr('data-src'));
488                    }
489                })
490            }
491
492            if( $($.parseHTML( responseText )).find('.mfn-infinite-load-button').length ){
493              $(document).trigger('mfn:waypoints');
494            }
495
496            $('.mfn_attr_filters ul li').removeClass('loading');
497            $('.mfn_attr_filters button').removeClass('loading disabled');
498        });
499    }else{
500        window.location.href = url;
501    }
502
503  }
504
505  function getUrlWithoutPagination(){
506    var current_url = window.location.pathname;
507    var url = '';
508
509    // get url witout pagination
510    if(current_url.includes("/page/")){
511        url = current_url.split("/page/")[0];
512    }else{
513        url = current_url;
514    }
515
516    // if not listing page redirect
517    if( !$('body').hasClass('archive') ){
518        url = $('form.mfn_attr_filters').attr('action');
519    }
520
521    return url;
522  }
523
524  setTimeout(function() {
525    productgallery.start();
526  }, 300);
527
528});
529
530  // Append spans to additional info table
531
532  function spanToAdditionalInfo(){
533    $('.woocommerce-product-attributes td, .woocommerce-product-attributes th').each(function() {
534      $(this).html('<span>'+$(this).html()+'</span>');
535    });
536  }
537
538  var productvariations = {
539    run: function() {
540
541      $('.mfn-variations-wrapper .mfn-vr-options li a').on('click', function(e) {
542        e.preventDefault();
543        $(this).parent().siblings().removeClass('active');
544        $(this).parent().addClass('active');
545        var id = $(this).attr('data-id');
546        var atr = $(this).parent().parent().attr('data-atr');
547        $('.variations select#'+atr).val(id);
548        $('.variations select#'+atr).trigger('change');
549        if( $('form.variations_form').attr('data-product_variations') != 'false' ) {
550            setTimeout(function() { productvariations.triggerChange(); }, 100);
551        }
552      });
553
554      $('.mfn-variations-wrapper .mfn-vr-select').on('change', function() {
555        var id = $(this).val();
556        var atr = $(this).attr('data-atr');
557        $('.variations select#'+atr).val(id);
558        $('.variations select#'+atr).trigger('change');
559        if( $('form.variations_form').attr('data-product_variations') != 'false' ) {
560            setTimeout(function() { productvariations.triggerChange(); }, 100);
561        }
562      });
563
564      $('.woocommerce div.product form.cart .variations select').each(function() {
565        var val = $(this).val();
566        var atr = $(this).attr('id');
567        if( val.length ){
568          if($('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').length){
569            $('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').trigger('click');
570          }else if($('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').length){
571            $('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').val(val);
572          }
573        }
574      });
575
576      if( window.location.search ){
577        if( $('.mfn-variations-wrapper ul.mfn-vr-options').length ){
578          const urlParams = new URLSearchParams(window.location.search);
579          $('.mfn-variations-wrapper ul.mfn-vr-options').each(function() {
580            let attr = $(this).attr('data-atr');
581            if( urlParams.get(attr) && typeof attr !== 'undefined' ){
582              if( $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').length ) $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').trigger('click');
583            }
584          });
585        }
586      }
587
588      setTimeout(function() { productvariations.triggerChange(); }, 200);
589
590      //$('.variations').hide();
591
592    },
593
594    triggerChange: function() {
595
596        if( $('.mfn-vr-options li').length )
597            $('.mfn-vr-options li a').css('opacity', '0.3');
598
599        if( $('.mfn-vr-select option').length )
600            $('.mfn-vr-select option').attr('disabled', 'true');
601
602
603        $('.woocommerce form.variations_form.cart table.variations select option').each(function() {
604            var val = $(this).attr('value');
605            var attr_name = $(this).closest('select').attr('name');
606
607            if($('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name).length)
608                $('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name+' a[data-id="'+val+'"]').css('opacity', '1');
609
610            if($('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name).length)
611                $('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name+' option[value="'+val+'"]').removeAttr('disabled');
612        });
613
614    }
615  };
616
617  var wishlist = {
618
619    cookiename: 'mfn_wishlist',
620
621    click: function(id) {
622      wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = [];
623      if( arr.includes( id ) ){
624        arr = arr.filter( el => el != id);
625        $('.mfn-wish-button[data-id="'+id+'"]').removeClass('loved');
626        $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').slideUp(300);
627        setTimeout(function() {
628          $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').remove();
629        }, 400);
630        if($('.wishlist .wishlist-row').length == 1){
631          $('.wishlist .wishlist-info').show();
632        }
633      }else{
634        arr.push( id );
635        $('.mfn-wish-button[data-id="'+id+'"]').addClass('loved');
636      }
637      wishlist.createcookie(arr);
638      wishlist.updatecounter(arr.length);
639    },
640
641    set: function(){
642      wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = [];
643      if(arr.length){
644        $.each(arr, function(i, v) {
645          $('.mfn-wish-button[data-id="'+v+'"]').addClass('loved');
646        });
647      }
648        wishlist.updatecounter(arr.length);
649    },
650
651    readcookie: function(){
652      var nameEQ=wishlist.cookiename+"=";
653      var ca=document.cookie.split(';');
654      for(var i=0;i<ca.length;i++){
655        var c=ca[i];
656        while(c.charAt(0)==' ')c=c.substring(1,c.length);
657        if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length)
658      }
659
660      return null
661    },
662
663    createcookie: function(save){
664      var date=new Date();
665      date.setTime(date.getTime()+(365*24*60*60*1000));
666      var expires="; expires="+date.toGMTString();
667      document.cookie=wishlist.cookiename+"="+save+expires+"; path="+mfnwoovars.rooturl+'/'
668    },
669
670    updatecounter: function(count) {
671        $('.header-wishlist-count').text(count).attr('class', 'header-wishlist-count mfn-header-icon-'+count);
672    }
673
674  };
675
676  modallogin = {
677    check: function() {
678        $('.mfn-header-modal-login form.woocommerce-form-login').attr('action', mfnwoovars.myaccountpage);
679      $('.mfn-header-modal-login .woocommerce-form-login .form-row input').each(function() {
680        if( !$(this).val() ){
681          $(this).closest('.form-row').removeClass('active');
682        }else{
683          $(this).closest('.form-row').addClass('active');
684        }
685      });
686    },
687
688    // modallogin.click()
689
690    click: function($el) {
691
692      var rtl = $('body').hasClass('rtl');
693
694      if( $('.mfn-header-login').hasClass('disabled') ){
695        return true;
696      }
697
698      if( $('body').hasClass('mfn-show-login-modal') ){
699
700        $('.mfn-header-login').removeAttr('style').addClass('disabled');
701        setTimeout(function(){
702          $('.mfn-header-login').addClass('is-side').removeClass('disabled');
703        },300);
704
705        $('body').removeClass('mfn-show-login-modal no-overlay');
706
707      } else {
708
709        // check if we want modal to be boxed or slide from edge
710
711        if( $el.hasClass('is-boxed') ){
712
713          var bodyT = $('body').offset().top || 0,
714            top = $el.offset().top || 0,
715            left = $el.offset().left || 0,
716            windowW = window.innerWidth
717            modalW = 340;
718
719          top -= bodyT;
720
721          $('.mfn-header-login').removeClass('is-side');
722
723          $('.mfn-header-login').css('top', top + 'px');
724
725          if( rtl ){
726
727            if( left - modalW < 0 ){
728              $('.mfn-header-login').css('left', left + 'px');
729            } else {
730              $('.mfn-header-login').css('left', left - modalW + 37 + 'px');
731            }
732
733          } else {
734
735            if( left + modalW > windowW ){
736              $('.mfn-header-login').css('left', left - modalW + 37 + 'px');
737            } else {
738              $('.mfn-header-login').css('left', left + 'px');
739            }
740
741          }
742
743          $('body').addClass('no-overlay');
744
745        }
746
747        $('body').addClass('mfn-show-login-modal');
748
749      }
750
751    }
752
753  };
754
755  checkoutpayment = {
756
757    start: function( $once = false ) {
758        $('.wc_payment_methods .wc_payment_method').each(function() {
759            if( !$(this).find('.mfn-payment-check').length ){
760                $(this).append('<span class="mfn-payment-check"><i class="icon-check" aria-label="payment check icon"></i></span>');
761            }
762            if( $(this).find('.input-radio').is(':checked') ){
763              checkoutpayment.set( $(this), $once );
764            }
765        });
766        checkoutpayment.watch();
767    },
768
769    watch: function() {
770        $(document).on('click', '.wc_payment_methods .wc_payment_method', function() {
771            checkoutpayment.set( $(this) );
772        });
773    },
774
775    set: function( $li, $once = false ) {
776        $input = $li.find('.input-radio');
777        if(!$input.is(':checked')){
778
779            $('.wc_payment_methods .wc_payment_method .payment_box').slideUp(300);
780            $('.wc_payment_methods .wc_payment_method').removeClass('active-payment');
781
782            $input.trigger('click');
783            $li.addClass('active-payment');
784            $li.find('.payment_box').slideDown(300);
785
786        }else{
787            $li.addClass('active-payment');
788        }
789
790        // FIX | WooCommerce 7.6 no longer using ajax
791
792        if( ! $once ){
793          setTimeout(function(){
794            checkoutpayment.start( true );
795          },1500);
796        }
797
798    }
799
800  };
801
802  quickview = {
803    headerOffset: false,
804    display: function(id) {
805        $.ajax({
806            url: mfnwoovars.ajaxurl,
807            data: {
808                'mfn-woo-nonce': mfnwoovars.wpnonce,
809                action: 'mfnproductquickview',
810                id: id
811            },
812            type: 'POST',
813            success: function(response){
814
815
816                $('body').append(response);
817                $('.mfn-quick-view').removeClass('loading');
818                quickview.close();
819                if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){
820                    productvariations.run();
821                }
822
823                $('html').addClass('mfn-quick-view-opened');
824
825                $('.mfn-popup-quickview .mfn-quickview-slider').slick({
826                    slidesToShow: 1,
827                    slidesToScroll: 1,
828                    autoplay: true,
829                    autoplaySpeed: 3000,
830                    dots: false,
831                    arrows: true,
832                    prevArrow: '<a class="slick-prev mfn-popup-arrow slick-arrow" href="#"><i class="icon-left-open-big" aria-label="previous slide"></i></a>',
833                    nextArrow: '<a class="slick-next mfn-popup-arrow slick-arrow" href="#"><i class="icon-right-open-big" aria-label="next slide"></i></a>',
834                    focusOnChange: true,
835                });
836
837                if( $('.mfn-popup-quickview form.cart.variations_form').length ){
838                    $('.mfn-popup-quickview .variations_form').wc_variation_form();
839                }
840
841                $('.mfn-popup-quickview .mfn-quickview-slider').imagesLoaded( function() {
842                    quickview.setHeight();
843                });
844
845                wishlist.set();
846
847                $(window).on('debouncedresize', quickview.setHeight);
848
849                return;
850            }
851        });
852    },
853    setHeight: function() {
854        var popupH = $('.mfn-popup-quickview .mfn-popup-content').outerHeight();
855        var imgH = $('.mfn-popup-quickview .mfn-popup-content-photos .mfn-qs-one-first img').height();
856
857        if(imgH > popupH){
858            $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': popupH });
859        }else{
860            $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': imgH });
861        }
862
863        if( $('body').hasClass('mfn-header-scrolled') && $('.mfn-header-tmpl.mfn-hasSticky').length ){
864            $('html').addClass('mfn-disable-css-animations');
865            $('body').removeClass('mfn-header-scrolled');
866            quickview.headerOffset = $('.mfn-header-tmpl.mfn-hasSticky').outerHeight();
867            $('body').addClass('mfn-header-scrolled');
868            $('#Wrapper').css({'padding-top': quickview.headerOffset+"px"});
869        }
870
871    },
872    close: function() {
873        $('.mfn-close-popup').on('click', function() {
874            $('.mfn-popup').remove();
875            $('html').removeClass('mfn-quick-view-opened');
876            $('html').removeClass('mfn-disable-css-animations');
877        });
878
879        $('.mfn-popup').on('click', function(e) {
880            if(!$('.mfn-popup-content').is(e.target) && $('.mfn-popup-content').has(e.target).length === 0) {
881                $('.mfn-popup').remove();
882                $('html').removeClass('mfn-quick-view-opened');
883                $('html').removeClass('mfn-disable-css-animations');
884            }
885        });
886    }
887  },
888
889  woocart = {
890
891    force_open: false,
892
893    coupons: {
894
895      init: function() {
896        woocart.coupons.toggle();
897        woocart.coupons.apply();
898        woocart.coupons.remove();
899      },
900
901      back: function(e) {
902        if ( !$('.mfn-chft-apply-coupon-wrapper').is(e.target) && !$(e.target).closest('.mfn-chft-apply-coupon-wrapper').length ) {
903          $('.mfn-chft-apply-coupon-wrapper').removeClass('mfn-chft-apply-coupon-active');
904          $(document).unbind('click', woocart.coupons.back);
905        }
906      },
907
908      toggle: function() {
909        $(document).on('click', '.mfn-chft-apply-coupon-switcher', function(e) {
910          e.preventDefault();
911          $(this).closest('.mfn-chft-apply-coupon-wrapper').addClass('mfn-chft-apply-coupon-active');
912          $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').focus();
913          $(document).bind('click', woocart.coupons.back);
914        });
915      },
916
917      remove: function() {
918
919        $(document).on('click', '.mfn-chft-apply-coupon-wrapper .mfn-chft-coupons-list .mfn-sidecart-remove-coupon', function(e) {
920          e.preventDefault();
921          if( $(this).hasClass('loading') ) return;
922
923          $(this).addClass('loading');
924
925          let val = $(this).attr('data-code');
926
927          $.ajax({
928            url: mfnwoovars.ajaxurl,
929            data: {
930                'mfn-woo-nonce': mfnwoovars.wpnonce,
931                action: 'mfndeletecoupon',
932                code: val
933            },
934            type: 'POST',
935            cache: false,
936            success: function(response){
937
938              woocart.refresh();
939    
940
941            }
942          });
943
944        });
945
946      },
947
948      ajax: function() {
949
950        let button = $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon');
951        if( button.hasClass('loading') ) return;
952
953        $('.mfn-chft-apply-coupon-wrapper .mfn-sidecart-notice').remove();
954        $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').removeClass('mfn-error');
955
956        if( !$('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').val().length ){
957          $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').addClass('mfn-error');
958          return;
959        }
960
961        let val = $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').val();
962
963        button.addClass('loading');
964
965        $.ajax({
966          url: mfnwoovars.ajaxurl,
967          data: {
968              'mfn-woo-nonce': mfnwoovars.wpnonce,
969              action: 'mfnapplycoupon',
970              code: val
971          },
972          type: 'POST',
973          cache: false,
974          success: function(response){
975
976            if( response ){
977
978              let noticeHtml = '';
979
980              if( typeof response.notice.error === 'undefined' ) {
981
982                $('.mfn-cart-holder .mfn-ch-content').html(response.content);
983                $('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer);
984
985              }else{
986                $('.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input').addClass('mfn-error');
987              }
988
989              for (const [key, value] of Object.entries(response.notice)) {
990                
991                noticeHtml += '<div class="mfn-sidecart-notice mfn-sidecart-notice-'+key+'">';
992                
993                if( value ){
994                  noticeHtml += value.map((x) => `<p>${x.notice}</p>`).join('');
995                }
996
997                noticeHtml += '</div>';
998
999                //$('.mfn-chft-apply-coupon').append();
1000              }
1001
1002              $('.mfn-chft-apply-coupon-wrapper').prepend(noticeHtml);
1003              woocart.coupons.removeNotices();
1004            }
1005            
1006            button.removeClass('loading');
1007
1008          }
1009        });
1010
1011      },
1012
1013      apply: function() {
1014
1015        $(document).on('click', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon', function(e) {
1016          e.preventDefault();
1017          woocart.coupons.ajax();
1018        });
1019
1020        $(document).on('keypress', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input', function(e) {
1021            if (e.which == 13) woocart.coupons.ajax();
1022        });
1023
1024      },
1025
1026      removeNotices: function() {
1027        setTimeout(function() {
1028          $('.mfn-chft-apply-coupon-wrapper .mfn-sidecart-notice').remove();
1029        }, 3000);
1030      }
1031    },
1032
1033    start: function() {
1034        /*if( $('a#header_cart .header-cart-count').length ){
1035            if( $('#Top_bar a#header_cart .header-cart-count').text() == '0' ){
1036                $('.mfn-ch-footer-buttons').hide();
1037            }
1038        }*/
1039
1040      return false;
1041    },
1042
1043    click: function() {
1044        if($('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){
1045            $('html').toggleClass('mfn-cart-opened');
1046            woocart.force_open = false;
1047        }
1048    },
1049
1050    refresh: function(){
1051      $.ajax({
1052        url: mfnwoovars.ajaxurl,
1053        data: {
1054            'mfn-woo-nonce': mfnwoovars.wpnonce,
1055            action: 'mfnrefreshcart'
1056        },
1057        type: 'POST',
1058        cache: false,
1059        success: function(response){
1060          $('.mfn-cart-holder .mfn-ch-content').html(response.content);
1061          $('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer);
1062          $('.mfn-cart-holder').removeClass('loading');
1063
1064          if( $('body').hasClass('woocommerce-cart') && $('.mfn-builder-content.mfn-cart-tmpl-builder').length ){
1065            $('.mfn-builder-content.mfn-cart-tmpl-builder').removeClass('mfn-cart-tmpl-not-empty mfn-cart-tmpl-empty');
1066            
1067            if( !response.total ){
1068              $('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-empty');
1069            }else{
1070              $('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-not-empty');
1071            }
1072          }
1073
1074          // side cart buttons
1075          if( response.total == 0 ){
1076            $('.mfn-ch-footer-buttons').hide();
1077          }else{
1078            $('.mfn-ch-footer-buttons').show();
1079          }
1080
1081          if( woocart.force_open ) woocart.click();
1082
1083          return;
1084        }
1085      });
1086    },
1087
1088    delete: function(id){
1089      $.ajax({
1090        url: mfnwoovars.ajaxurl,
1091        data: {
1092            'mfn-woo-nonce': mfnwoovars.wpnonce,
1093            action: 'mfnremovewooproduct',
1094            pid: id
1095        },
1096        type: 'POST',
1097        cache: false,
1098        success: function(response){
1099          $(document.body).trigger('wc_fragment_refresh');
1100          woocart.refresh();
1101          if($('body').hasClass('woocommerce-cart')){
1102            $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').trigger('click');
1103          }
1104        }
1105      });
1106    },
1107
1108    updatequantity: function(id, qty) {
1109      $.ajax({
1110        url: mfnwoovars.ajaxurl,
1111        data: {
1112            'mfn-woo-nonce': mfnwoovars.wpnonce,
1113            action: 'mfnchangeqtyproduct',
1114            pid: id,
1115            qty: qty
1116        },
1117        type: 'POST',
1118        cache: false,
1119        success: function(response){
1120          $(document.body).trigger('wc_fragment_refresh');
1121          woocart.refresh();
1122          if($('body').hasClass('woocommerce-cart')){
1123            $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').parent().siblings('.product-quantity').find('input.qty').val(qty).trigger('change');
1124            $('.woocommerce-cart-form .button[name="update_cart"]').trigger('click');
1125          }
1126
1127        }
1128      });
1129    }
1130
1131  };
1132
1133  woocart.coupons.init();
1134
1135  var mfnFakeSale = {
1136
1137    active: true,
1138
1139    time: function() {
1140      let arr = [20000, 25000, 30000, 35000, 40000, 50000];
1141      return arr[Math.floor(Math.random()*arr.length)];
1142    },
1143
1144    init: function() {
1145
1146      if( $('body').hasClass('mfn-ui') ) return;
1147
1148      if( mfnFakeSale.checkCookie("mfnFakeSale") ) mfnFakeSale.active = false;
1149
1150      if( typeof mfn_fake_sale === 'undefined' || !mfnFakeSale.active ) return;
1151
1152      let delay = typeof mfn_fake_sale.delay !== 'undefined' ? mfn_fake_sale.delay : 5;
1153
1154      delay = parseFloat(delay)*1000;
1155
1156      setTimeout(mfnFakeSale.show, delay);
1157
1158      $(document).on('click', '.mfn-fake-sale-noti .mfn-fake-sale-noti-close', function(e) {
1159        e.preventDefault();
1160        mfnFakeSale.active = false;
1161        mfnFakeSale.hide();
1162        mfnFakeSale.addCookie(1, "mfnFakeSale");
1163      });
1164
1165    },
1166
1167    show: function() {
1168      var item = mfn_fake_sale.items[Math.floor(Math.random() * mfn_fake_sale.items.length)];
1169
1170      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;
1170</span></a>' : ''}</div>`;
1171
1172      $('body').append(html);
1173
1174      setTimeout(mfnFakeSale.hide, 15000);
1175    },
1176
1177    hide: function() {
1178      if( $('.mfn-fake-sale-noti').length ) {
1179        $('.mfn-fake-sale-noti').addClass('mfn-fake-sale-noti-out');
1180        setTimeout(function() {$('.mfn-fake-sale-noti').remove(); }, 500);
1181        if( mfnFakeSale.active ) mfnFakeSale.reset();
1182      }
1183    },
1184
1185    reset: function() {
1186      setTimeout(mfnFakeSale.show, mfnFakeSale.time());
1187    },
1188
1189    addCookie(days, cookie_name){
1190      let date=new Date();
1191      date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
1192      let expires="; expires="+date.toGMTString();
1193      document.cookie=cookie_name+"=true"+expires+"; path=/";
1194    },
1195
1196    checkCookie(cookie_name){
1197      var nameEQ = cookie_name+"=";
1198      var ca = document.cookie.split(';');
1199      for(var i=0;i<ca.length;i++){
1200        var c = ca[i];
1201        while(c.charAt(0)==' ') c = c.substring(1,c.length);
1202        if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length)
1203      }
1204      return null
1205    }
1206
1207  };
1208
1209
1210  var productgallery = {
1211    start: function() {
1212
1213      if($('.flex-viewport').length){
1214        $loup = $('.woocommerce-product-gallery__trigger').clone(true).empty().appendTo('.flex-viewport');
1215        $('.woocommerce-product-gallery > .woocommerce-product-gallery__trigger').remove();
1216
1217        if($('.woocommerce-product-gallery .mfn-wish-button').length){
1218          $('.woocommerce-product-gallery .mfn-wish-button').clone(true).appendTo('.flex-viewport');
1219          $('.woocommerce-product-gallery > .mfn-wish-button').remove();
1220          $(document).trigger('resize');
1221        }
1222      }else if( $('.woocommerce-product-gallery__trigger').length ){
1223        $('.woocommerce-product-gallery__trigger').empty();
1224      }
1225
1226      if( $('.mfn-product-gallery').length ){
1227        if($('.flex-control-thumbs').length){
1228          $('.flex-control-thumbs').wrap('<div class="mfn-flex-control-thumbs-wrapper"></div>');
1229        }
1230        $('.woocommerce-product-gallery').imagesLoaded( function() {
1231          if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){
1232            productgallery.verticalThumbs();
1233          }else if( $('.mfn-thumbnails-bottom').length ){
1234            productgallery.horizontalThumbs();
1235          }
1236        });
1237      }
1238
1239    },
1240    horizontalThumbs: function() {
1241        var $container = $('.mfn-product-gallery');
1242        var containerW = $container.outerWidth();
1243        var $scroller = $container.find('.flex-control-thumbs');
1244        var scrollerW = 0;
1245
1246        $scroller.find('li').each(function() {
1247          $(this).addClass('swiper-slide');
1248          scrollerW += $(this).outerWidth();
1249        });
1250
1251        if( !$container.length || !$scroller.length ){
1252          return;
1253        }
1254
1255        if( scrollerW > containerW ){
1256          //return;
1257          $scroller.css({ 'justify-content': 'flex-start', 'width': '100%' });
1258          $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active');
1259        }
1260
1261        $scroller.addClass('swiper-wrapper');
1262
1263        var swiper_opts = {
1264          slidesPerView: 5,
1265          spaceBetween: parseInt(mfnwoovars.productthumbs),
1266        };
1267
1268
1269        $scroller.parent().addClass('mfn-arrows-absolute');
1270        $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>');
1271        swiper_opts['navigation'] = {
1272          nextEl: ".swiper-button-next",
1273          prevEl: ".swiper-button-prev",
1274        };
1275
1276        var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", swiper_opts);
1277    },
1278    verticalThumbs: function() {
1279        var $container = $('.mfn-product-gallery');
1280        var containerH = $container.find('.woocommerce-product-gallery__image').first().outerHeight();
1281        var $scroller = $container.find('.flex-control-thumbs');
1282        var scrollerH = 0;
1283        var mimgm = 0; // main image margin
1284        var overlay = mfnwoovars.productthumbsover ? mfnwoovars.productthumbsover : 0;
1285
1286        $scroller.find('li img').css({ 'height': 'auto' });
1287        $scroller.find('li').css({ 'height': 'auto' });
1288
1289        $scroller.find('li').each(function() {
1290          $(this).addClass('swiper-slide').css({ 'margin-bottom': parseInt(mfnwoovars.productthumbs) });
1291          scrollerH += $(this).outerHeight()+parseInt(mfnwoovars.productthumbs);
1292          $(this).css({ 'opacity': '1' });
1293        });
1294
1295        if(mfnwoovars.mainimgmargin == 'mfn-mim-2'){
1296          mimgm = 4;
1297        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-5'){
1298          mimgm = 10;
1299        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-10'){
1300          mimgm = 20;
1301        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-15'){
1302          mimgm = 30;
1303        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-20'){
1304          mimgm = 40;
1305        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-25'){
1306          mimgm = 50;
1307        }else if(mfnwoovars.mainimgmargin == 'mfn-mim-30'){
1308          mimgm = 60;
1309        }
1310
1311        if( !$container.length || !$scroller.length ){
1312          return;
1313        }
1314
1315        $container.find('.flex-viewport').css({'height': 'auto'});
1316
1317        if( scrollerH > containerH ){
1318          if(overlay == 'mfn-thumbnails-overlay'){
1319            $('.mfn-flex-control-thumbs-wrapper').height( (containerH-mimgm) );
1320          }else{
1321            $('.mfn-flex-control-thumbs-wrapper').height(containerH);
1322          }
1323
1324          $scroller.css({ 'align-items': 'flex-start' });
1325          $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active');
1326
1327          $scroller.addClass('swiper-wrapper');
1328
1329          var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", {
1330            slidesPerView: 4,
1331            spaceBetween: parseInt(mfnwoovars.productthumbs),
1332            direction: "vertical",
1333            mousewheel: true,
1334          });
1335
1336          $scroller.find('li').each(function() {
1337            $(this).find('img').css({ 'height': $(this).outerHeight() });
1338            $(this).css({ 'opacity': '1' });
1339          });
1340
1341        }
1342
1343        $container.find('.flex-viewport').css('height', containerH);
1344
1345    }
1346  };
1347
1348  $(window).on('debouncedresize', function() {
1349    if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){
1350        setTimeout(productgallery.verticalThumbs(), 300);
1351    }
1352  });
1353
1354  var initPhotoSwipeFromDOM = function(gallerySelector) {
1355
1356    var parseThumbnailElements = function() {
1357        var items = [];
1358
1359    $(gallerySelector).find('div img').not('.zoomImg').each(function() {
1360        var img = $(this);
1361        var large_image_src   = img.attr( 'data-large_image' ),
1362              large_image_w   = img.attr( 'data-large_image_width' ),
1363              large_image_h   = img.attr( 'data-large_image_height' ),
1364              alt             = img.attr( 'alt' ),
1365              item            = {
1366                alt  : alt,
1367                src  : large_image_src,
1368                w    : large_image_w,
1369                h    : large_image_h,
1370                title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' )
1371              };
1372            items.push( item );
1373      });
1374
1375        return items;
1376    };
1377
1378    var openPhotoSwipe = function(index) {
1379        var pswpElement = document.querySelectorAll('.pswp')[0],
1380            items;
1381
1382        items = parseThumbnailElements();
1383
1384        var options = {
1385          index: parseInt(index, 10),
1386          //showAnimationDuration: 0,
1387          getThumbBoundsFn: function(index) {
1388                var thumbnail = $('.mfn-product-gallery-grid .mfn-product-gg-img[data-index="'+index+'"] div img:first-child'),
1389                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
1390                    rect = thumbnail.offset();
1391                return {x:rect.left, y:rect.top, w:thumbnail.width()};
1392            }
1393        };
1394
1395        if( isNaN(options.index) ) {
1396            return;
1397        }
1398
1399        gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
1400        gallery.init();
1401    };
1402
1403    $('.mfn-product-gallery-grid a.woocommerce-product-gallery__trigger').on('click', function(e) {
1404        e.preventDefault();
1405        var index = $(this).closest('.mfn-product-gg-img').attr('data-index');
1406        openPhotoSwipe( index );
1407    });
1408
1409
1410    $('.mfn-product-gallery-grid .woocommerce-product-gallery__image a').on('click', function(e) {
1411      e.preventDefault();
1412      if( !$(this).closest('.elementor-widget-container').length ){
1413        $(this).closest('.mfn-product-gg-img').find('.woocommerce-product-gallery__trigger').trigger('click');
1414      }
1415    });
1416
1417};
1418
1419
1420$(document).on('click', '.mfn-woocommerce-tabs .mfn-woocommerce-tabs-nav a', function(e) {
1421  e.preventDefault();
1422  if( $(this).parent('li').hasClass('active') ) return;
1423
1424  let wrapper = $(this).closest('.mfn-woocommerce-tabs');
1425  let selector = $(this).attr('href').replace('#', '.');
1426
1427  $(this).parent().siblings('li').removeClass('active');
1428  $(this).closest('.mfn-woocommerce-tabs').find('.mfn-woocommerce-tabs-content.active').removeClass('active');
1429
1430  $(this).parent('li').addClass('active');
1431  wrapper.find(selector).addClass('active');
1432
1433});
1434
1435
1436let mfnCurrencySwitcher = {
1437  selector: false,
1438  init: function() {
1439    if( !$('.column_header_currency_switcher .mfn-currency-switcher-wrapper:not(.initialized)').length ) return;
1440
1441    $('.column_header_currency_switcher .mfn-currency-switcher-wrapper:not(.initialized)').each(function() {
1442
1443      mfnCurrencySwitcher.selector = $(this);
1444      mfnCurrencySwitcher.selector.addClass('initialized');
1445
1446      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-flags') ) mfnCurrencySwitcher.attach_flags();
1447
1448      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-dropdown mfn-currency-switcher-dropdown-icon') ) mfnCurrencySwitcher.dropdown_icon();
1449
1450      if( mfnCurrencySwitcher.selector.hasClass('mfn-currency-switcher-dropdown') ) mfnCurrencySwitcher.dropdown();
1451
1452      mfnCurrencySwitcher.selector = false;
1453
1454    });
1455  },
1456  attach_flags: function() {
1457    let flag_path = mfnCurrencySwitcher.selector.attr('data-themepath');
1458    mfnCurrencySwitcher.selector.find('li a').each(function() {
1459      let code = $(this).attr('rel');
1460      let flag_uri = `${flag_path}/${code}.svg`;
1461      $(this).prepend('<img class="mfn-wcml-flag" src="'+flag_uri+'" alt="" width="20" height="15">');
1462    });
1463  },
1464  dropdown_icon: function() {
1465    let icon = mfnCurrencySwitcher.selector.attr('data-path');
1466    mfnCurrencySwitcher.selector.find('li.wcml-cs-active-currency > a').each(function() {
1467      $(this).append('<i class="mfn-arrow-icon '+icon+'"></i>')
1468    });
1469  },
1470  dropdown: function() {
1471    let clone = mfnCurrencySwitcher.selector.find('ul').clone();
1472    let active = mfnCurrencySwitcher.selector.find('ul li.wcml-cs-active-currency').clone();
1473
1474    mfnCurrencySwitcher.selector.find('ul').before('<ul class="mfn-wcml-dropdown-ready"></ul>');
1475    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready').append(active);
1476    mfnCurrencySwitcher.selector.find('ul:not(.mfn-wcml-dropdown-ready)').remove();
1477    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready li').append(clone);
1478    mfnCurrencySwitcher.selector.find('ul.mfn-wcml-dropdown-ready li ul li.wcml-cs-active-currency').remove();
1479  }
1480}
1481
1482mfnCurrencySwitcher.init();
1483
1484
1485})(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.