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( response == 'error' ){ 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 ( 'undefined' !== $thisbutton.val() ) { 102 formData.append( 'product_id', parseInt( $thisbutton.val() ) ); 103 } 104 105 ajaxAct['data'] = formData; 106 ajaxAct['contentType'] = false; 107 ajaxAct['processData'] = false; 108 109 $(document.body).trigger('adding_to_cart', [$thisbutton, formData]); 110 $.ajax( ajaxAct ); 111 112 return false; 113 114 }); 115 } 116 117 // woo product category arrows 118 if( $('.wc-block-product-categories-list') ){ 119 $('.wc-block-product-categories-list li.wc-block-product-categories-list-item').each(function() { 120 if($(this).children('ul').length){ 121 $(this).append('<span class="cat-expander"></span>'); 122 } 123 }); 124 125 $('.wc-block-product-categories-list li > span.cat-expander').on('click', function(e) { 126 if($(this).siblings('ul').is(':visible')){ 127 $(this).siblings('ul').slideUp(300); 128 $(this).parent('li').removeClass('li-expanded'); 129 }else{ 130 $(this).siblings('ul').slideDown(300); 131 $(this).parent('li').addClass('li-expanded'); 132 } 133 }); 134 } 135 136 // Append spans to additional info table 137 if($('.woocommerce-product-attributes').length){ 138 spanToAdditionalInfo(); 139 } 140 141 // product variations 142 if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){ 143 productvariations.run(); 144 } 145 146 $('.toggle-mfn-cart').on('click', function(e) { 147 if( $('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){ 148 e.preventDefault(); 149 150 if( $('body').hasClass('mfn-bebuilder-header') ) return; 151 152 if ( $('html').hasClass('mfn-cart-opened')) { 153 $('.mfn-cart-holder').attr('aria-expanded', 'false') 154 } else { 155 $('.mfn-cart-holder').attr('aria-expanded', 'true'); 156 } 157 158 woocart.click(); 159 } 160 }); 161 162 $('.toggle-mfn-cart').on('keypress', function(e) { 163 e.preventDefault(); 164 if ( e.originalEvent.key !== 'Enter' ) return; 165 166 if ( $('html').hasClass('mfn-cart-opened')) { 167 $('.mfn-cart-holder').attr('aria-expanded', 'false'); 168 169 const domPrefix = $('body').hasClass('side-slide-is-open') ? '.extras-wrapper ' : '.top_bar_right '; 170 $(`${domPrefix} #header_cart`).trigger('focus'); 171 } else { 172 $('.mfn-cart-holder').find('a').first().trigger('focus'); 173 $('.mfn-cart-holder').attr('aria-expanded', 'true'); 174 } 175 176 woocart.click(); 177 }); 178 179 $('.mfn-cart-overlay').on('click', function() { 180 woocart.click(); 181 }); 182 183 if($('body').hasClass('shop-sidecart-active')){ 184 woocart.start(); 185 } 186 187 $('.toggle-login-modal').on('click', function(e) { 188 e.preventDefault(); 189 modallogin.click($(this)); 190 }); 191 192 $(document).on('mouseup', function(e) { 193 194 // login form 195 if( $('body').hasClass('mfn-show-login-modal') ){ 196 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 ){ 197 modallogin.click(); 198 } 199 } 200 201 }); 202 203 function alignListHeights(){ 204 var i = 0; 205 $('.woocommerce .column_shop_products ul.products.list li.product').each(function() { 206 $(this).css({ 'min-height': '1px'}); 207 208 var height= $(this).outerHeight(); 209 var imgHeight = $(this).find('.product-loop-thumb').outerHeight(); 210 211 if(imgHeight > height){ 212 $(this).css({'min-height': imgHeight}); 213 } 214 }); 215 } 216 217 if( $('.woocommerce .column_shop_products ul.products.list').length ){ 218 alignListHeights(); 219 $(window).on('debouncedresize', alignListHeights); 220 } 221 222 223 $('.mfn-header-modal-login .woocommerce-form-login .form-row').on('click', function() { 224 if( !$(this).hasClass('active') ){ 225 $(this).addClass('active'); 226 } 227 }); 228 229 $('.mfn-header-modal-login .woocommerce-form-login .form-row input').on('blur change', function() { 230 modallogin.check(); 231 }); 232 233 modallogin.check(); 234 235 $('.mfn-cart-holder .mfn-ch-content').on('click', '.mfn-chp-remove', function(e) { 236 e.preventDefault(); 237 if(!$('.mfn-cart-holder').hasClass('loading')){ 238 $('.mfn-cart-holder').addClass('loading'); 239 var pid = $(this).closest('.mfn-ch-product').attr('data-row-key'); 240 woocart.delete(pid); 241 } 242 }); 243 244 $('.mfn-woo-products').on('change', '.mfn-variations-wrapper-loop .mfn-vr-select', function() { 245 var link = $(this).find(':selected').attr('data-link'); 246 if(link != ''){ 247 window.location.href = link; 248 } 249 }); 250 251 $('.mfn-cart-holder .mfn-ch-content').on('change', '.qty', function() { 252 var $el = $(this); 253 if(!$('.mfn-cart-holder').hasClass('loading')){ 254 $('.mfn-cart-holder').addClass('loading'); 255 var pid = $el.closest('.mfn-ch-product').attr('data-row-key'); 256 var qty = $el.val(); 257 woocart.updatequantity(pid, qty); 258 } 259 }); 260 261 262 if( $('body').hasClass('woocommerce-checkout') ){ 263 264 if( $('.woocommerce-form-login').length ){ 265 $('.woocommerce-form-login').addClass('checkout-form-toggle'); 266 } 267 if( $('.woocommerce-form-coupon').length ){ 268 $('.woocommerce-form-coupon').addClass('checkout-form-toggle'); 269 } 270 271 $(document).ajaxComplete(function() { 272 // checkoutpayment.start(); 273 }); 274 275 setTimeout(function(){ 276 checkoutpayment.start(); 277 },1500); 278 } 279 280 /*$( document.body ).on( 'adding_to_cart', function( e ) { 281 if(!$('.header-cart-count').length || !$('.header-cart-total').length){ 282 $('.header-cart').append('<span class="header-cart-count"></span>'); 283 $('#header_cart').append('<p class="header-cart-total"></p>'); 284 } 285 });*/ 286 287 //$( document.body ).on( 'wc_fragment_refresh added_to_cart', function( e ) { 288$( document.body ).on( 'added_to_cart', function( e ) { 289 if($('body').hasClass('shop-sidecart-active')){ 290 woocart.refresh(); 291 if(!$('html').hasClass('mfn-cart-opened')){ 292 woocart.click(); 293 } 294 } 295 } ); 296 297 $( document.body ).on( 'updated_cart_totals removed_from_cart', function(){ 298 if($('body').hasClass('shop-sidecart-active')){ 299 woocart.refresh(); 300 } 301 }); 302 303 // wishlist 304 wishlist.set(); 305 $(document).on('click', '.mfn-wish-button', function(e) { e.preventDefault(); var id = $(this).attr('data-id'); wishlist.click(id); }); 306 307 // attr ajjax filter 308 if( $('form.mfn_attr_filters').length ){ 309 310 $(document).on('click', '.mfn-woo-list-active-filters li span', function() { 311 var id = $(this).attr('data-id'); 312 $(this).closest('li').addClass('laoding'); 313 if($('.widget.mfn_woo_attributes .mfn_attr_filters input.'+id).length){ 314 if($('.mfn_woo_attributes .mfn_attr_filters input.'+id).is(':checked')) { 315 $('.mfn_woo_attributes .mfn_attr_filters input.'+id).prop('checked', false); 316 if( $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').hasClass('active') ){ 317 $('.mfn_woo_attributes .mfn_attr_filters input.'+id).closest('li').removeClass('active'); 318 } 319 } 320 grabFiltersForms(); 321 } 322 }); 323 324 $(document).on('click', 'form.mfn_attr_filters ul li', function() { 325 326 var $li = $(this); 327 var $ul = $(this).closest('ul'); 328 var $form = $(this).closest('form'); 329 var input_class = $li.find('input').attr('class'); 330 331 // on click active filters 332 if($form.hasClass('mfn-before-products-list-form')){ 333 334 $li.find('input').is(':checked') ? $li.find('input').prop('checked', false) : $li.find('input').prop('checked', true); 335 $li.toggleClass('active'); 336 337 }else if($form.hasClass('mfn_attr_filters')){ 338 $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); 339 $('form.mfn_attr_filters ul li input.'+input_class).closest('li').toggleClass('active'); 340 } 341 342 if( !$li.closest('form').hasClass('button-enabled') ){ 343 $li.addClass('loading'); 344 grabFiltersForms(); 345 } 346 347 }); 348 } 349 350 if( $('form.mfn_attr_filters.button-enabled').length ){ 351 $('form.mfn_attr_filters.button-enabled').submit(function(e) { 352 e.preventDefault(); 353 grabFiltersForms(); 354 }); 355 } 356 357 $.fn.extend({ 358 /** formData: 359 * Most form submissions will require special formatting different from 360 * a normal get request (a=val1,val2&b=val3 vs. a=val1&a=val2&b=val3). 361 * Sample use: $.getJSON(url,$("myFormElement").formData(),callback);. 362 * @return {String} Serialized form data appropriate for GET requests. 363 * @author Joe Johnson 364 */ 365 formData: function(){ 366 var data = {}; 367 $.each(this.serializeArray(),function(i,o){ 368 if (data[o.name]) data[o.name] += ','+o.value; 369 else data[o.name] = o.value; 370 }); 371 return $.param(data); 372 } 373 }); 374 375 function removeQueryParameters(url, parametersToRemove) { 376 url = window.location.origin + url; 377 const urlObject = new URL(url); 378 parametersToRemove.forEach(param => { 379 urlObject.searchParams.delete(param); 380 }); 381 return urlObject.toString(); 382 } 383 384 function grabFiltersForms(){ 385 let formsArr = []; 386 var path = getUrlWithoutPagination(); 387 388 $('form.mfn_attr_filters').each(function() { 389 formsArr.push( $(this).formData() ); 390 }); 391 392 formUnique = formsArr.filter( function(a){if (!this[a]) {this[a] = 1; return a;}}, {} ); 393 394 let formData = formUnique.join('&'); 395 let url = path+'?'+formData; 396 load_products_ajax(url); 397 } 398 399 function load_products_ajax(url) { 400 401 var $products = $('.entry-content .mfn-woo-products'); 402 $('.mfn_attr_filters button').addClass('loading disabled'); 403 404 if($('body').hasClass('archive')){ 405 406 $.get(url, function(responseText) { 407 408 $('.pager_wrapper').remove(); 409 $('.woocommerce-info').remove(); 410
411 if( $('.default-woo-list').length ){ 412 $('.default-woo-list').replaceWith( $( $.parseHTML( responseText )).find('.default-woo-list').clone() ); 413 }else if( $('.column_shop_products').length ){ 414 $('.column_shop_products').replaceWith( $( $.parseHTML( responseText )).find('.column_shop_products').clone() ); 415 } 416 417 $('.woocommerce-ordering select').on('change', function() { 418 $(this).closest('form').submit(); 419 }); 420 421 // remove unwanted attibutes 422 url = removeQueryParameters(url, ['layout', 'per_page']); 423 // replace %2C with coma 424 url = url.replace(/%2C/g,","); 425 // set browser url 426 history.replaceState(null, '', url); 427 428 if ($('.mcb-sidebar').length) { 429 var maxH = $('#Content .sections_group').outerHeight(); 430 $('.mcb-sidebar').each(function() { 431 $(this).css('min-height', 0); 432 if ($(this).height() > maxH) { 433 maxH = $(this).height(); 434 } 435 }); 436 $('.mcb-sidebar').css('min-height', maxH + 'px'); 437 } 438 439 if( $('.woocommerce .column_shop_products ul.products.list').length ){ 440 alignListHeights(); 441 $(window).on('debouncedresize', alignListHeights); 442 } 443 444 if( $('.products li img').length ){ 445 $('.products li img').each(function() { 446 if( typeof $(this).attr('data-src') !== 'undefined' ){ 447 $(this).attr('src', $(this).attr('data-src')); 448 } 449 }) 450 } 451 452 $('.mfn_attr_filters ul li').removeClass('loading'); 453 $('.mfn_attr_filters button').removeClass('loading disabled'); 454 }); 455 }else{ 456 window.location.href = url; 457 } 458 459 } 460 461 function getUrlWithoutPagination(){ 462 var current_url = window.location.pathname; 463 var url = ''; 464 465 // get url witout pagination 466 if(current_url.includes("/page/")){ 467 url = current_url.split("/page/")[0]; 468 }else{ 469 url = current_url; 470 } 471 472 // if not listing page redirect 473 if( !$('body').hasClass('archive') ){ 474 url = $('form.mfn_attr_filters').attr('action'); 475 } 476 477 return url; 478 } 479 480 setTimeout(function() { 481 productgallery.start(); 482 }, 300); 483 484}); 485 486 // Append spans to additional info table 487 488 function spanToAdditionalInfo(){ 489 $('.woocommerce-product-attributes td, .woocommerce-product-attributes th').each(function() { 490 $(this).html('<span>'+$(this).html()+'</span>'); 491 }); 492 } 493 494 var productvariations = { 495 run: function() { 496 497 $('.mfn-variations-wrapper .mfn-vr-options li a').on('click', function(e) { 498 e.preventDefault(); 499 $(this).parent().siblings().removeClass('active'); 500 $(this).parent().addClass('active'); 501 var id = $(this).attr('data-id'); 502 var atr = $(this).parent().parent().attr('data-atr'); 503 $('.variations select#'+atr).val(id); 504 $('.variations select#'+atr).trigger('change'); 505 if( $('form.variations_form').attr('data-product_variations') != 'false' ) { 506 setTimeout(function() { productvariations.triggerChange(atr, id); }, 100); 507 } 508 }); 509 510 $('.mfn-variations-wrapper .mfn-vr-select').on('change', function() { 511 var id = $(this).val(); 512 var atr = $(this).attr('data-atr'); 513 $('.variations select#'+atr).val(id); 514 $('.variations select#'+atr).trigger('change'); 515 if( $('form.variations_form').attr('data-product_variations') != 'false' ) { 516 setTimeout(function() { productvariations.triggerChange(atr, id); }, 100); 517 } 518 }); 519 520 $('.woocommerce div.product form.cart .variations select').each(function() { 521 var val = $(this).val(); 522 var atr = $(this).attr('id'); 523 if( val.length ){ 524 if($('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').length){ 525 $('.mfn-variations-wrapper .mfn-vr-options[data-atr="'+atr+'"] li a[data-id="'+val+'"]').trigger('click'); 526 }else if($('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').length){ 527 $('.mfn-variations-wrapper .mfn-vr-select[data-atr="'+atr+'"]').val(val); 528 } 529 } 530 }); 531 532 if( window.location.search ){ 533 if( $('.mfn-variations-wrapper ul.mfn-vr-options').length ){
534 const urlParams = new URLSearchParams(window.location.search); 535 $('.mfn-variations-wrapper ul.mfn-vr-options').each(function() { 536 let attr = $(this).attr('data-atr'); 537 if( urlParams.get(attr) && typeof attr !== 'undefined' ){ 538 if( $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').length ) $(this).find('li a[data-id="'+urlParams.get(attr)+'"]').trigger('click'); 539 } 540 }); 541 } 542 } 543 544 //$('.variations').hide(); 545 546 }, 547 548 triggerChange: function(atr, nval) { 549 550 if( $('.mfn-vr-options li').length ) 551 $('.mfn-vr-options li a').css('opacity', '0.3'); 552 553 if( $('.mfn-vr-select option').length ) 554 $('.mfn-vr-select option').attr('disabled', 'true'); 555 556 557 $('.woocommerce form.variations_form.cart table.variations select option').each(function() { 558 var val = $(this).attr('value'); 559 var attr_name = $(this).closest('select').attr('name'); 560 561 if($('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name).length) 562 $('.woocommerce .mfn-variations-wrapper .mfn-vr ul.'+attr_name+' a[data-id="'+val+'"]').css('opacity', '1'); 563 564 if($('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name).length) 565 $('.woocommerce .mfn-variations-wrapper .mfn-vr select.'+attr_name+' option[value="'+val+'"]').removeAttr('disabled'); 566 }); 567 568 } 569 }; 570 571 var wishlist = { 572 573 cookiename: 'mfn_wishlist', 574 575 click: function(id) { 576 wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = []; 577 if( arr.includes( id ) ){ 578 arr = arr.filter( el => el != id); 579 $('.mfn-wish-button[data-id="'+id+'"]').removeClass('loved'); 580 $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').slideUp(300); 581 setTimeout(function() { 582 $('.mfn-wish-button[data-id="'+id+'"]').closest('.wishlist-row').remove(); 583 }, 400); 584 if($('.wishlist .wishlist-row').length == 1){ 585 $('.wishlist .wishlist-info').show(); 586 } 587 }else{ 588 arr.push( id ); 589 $('.mfn-wish-button[data-id="'+id+'"]').addClass('loved'); 590 } 591 wishlist.createcookie(arr); 592 wishlist.updatecounter(arr.length); 593 }, 594 595 set: function(){ 596 wishlist.readcookie() ? arr = wishlist.readcookie().split(',') : arr = []; 597 if(arr.length){ 598 $.each(arr, function(i, v) { 599 $('.mfn-wish-button[data-id="'+v+'"]').addClass('loved'); 600 }); 601 } 602 wishlist.updatecounter(arr.length); 603 }, 604 605 readcookie: function(){ 606 var nameEQ=wishlist.cookiename+"="; 607 var ca=document.cookie.split(';'); 608 for(var i=0;i<ca.length;i++){ 609 var c=ca[i]; 610 while(c.charAt(0)==' ')c=c.substring(1,c.length); 611 if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length) 612 } 613 614 return null 615 }, 616 617 createcookie: function(save){ 618 var date=new Date(); 619 date.setTime(date.getTime()+(365*24*60*60*1000)); 620 var expires="; expires="+date.toGMTString(); 621 document.cookie=wishlist.cookiename+"="+save+expires+"; path="+mfnwoovars.rooturl+'/' 622 }, 623 624 updatecounter: function(count) { 625 $('.header-wishlist-count').text(count).attr('class', 'header-wishlist-count mfn-header-icon-'+count); 626 } 627 628 }; 629 630 modallogin = { 631 check: function() { 632 $('.mfn-header-modal-login form.woocommerce-form-login').attr('action', mfnwoovars.myaccountpage); 633 $('.mfn-header-modal-login .woocommerce-form-login .form-row input').each(function() { 634 if( !$(this).val() ){ 635 $(this).closest('.form-row').removeClass('active'); 636 }else{ 637 $(this).closest('.form-row').addClass('active'); 638 } 639 }); 640 }, 641 642 // modallogin.click() 643 644 click: function($el) { 645 646 var rtl = $('body').hasClass('rtl'); 647 648 if( $('.mfn-header-login').hasClass('disabled') ){ 649 return true; 650 } 651 652 if( $('body').hasClass('mfn-show-login-modal') ){ 653 654 $('.mfn-header-login').removeAttr('style').addClass('disabled'); 655 setTimeout(function(){ 656 $('.mfn-header-login').addClass('is-side').removeClass('disabled'); 657 },300); 658 659 $('body').removeClass('mfn-show-login-modal no-overlay'); 660 661 } else { 662 663 // check if we want modal to be boxed or slide from edge 664 665 if( $el.hasClass('is-boxed') ){ 666 667 var bodyT = $('body').offset().top || 0, 668 top = $el.offset().top || 0, 669 left = $el.offset().left || 0, 670 windowW = window.innerWidth 671 modalW = 340; 672 673 top -= bodyT; 674 675 $('.mfn-header-login').removeClass('is-side'); 676 677 $('.mfn-header-login').css('top', top + 'px'); 678 679 if( rtl ){ 680 681 if( left - modalW < 0 ){ 682 $('.mfn-header-login').css('left', left + 'px'); 683 } else { 684 $('.mfn-header-login').css('left', left - modalW + 37 + 'px'); 685 } 686 687 } else { 688 689 if( left + modalW > windowW ){ 690 $('.mfn-header-login').css('left', left - modalW + 37 + 'px'); 691 } else { 692 $('.mfn-header-login').css('left', left + 'px'); 693 } 694 695 } 696 697 $('body').addClass('no-overlay'); 698 699 } 700 701 $('body').addClass('mfn-show-login-modal'); 702 703 } 704 705 } 706 707 }; 708 709 checkoutpayment = { 710 711 start: function( $once = false ) { 712 $('.wc_payment_methods .wc_payment_method').each(function() { 713 if( !$(this).find('.mfn-payment-check').length ){ 714 $(this).append('<span class="mfn-payment-check"><i class="icon-check" aria-label="payment check icon"></i></span>'); 715 } 716 if( $(this).find('.input-radio').is(':checked') ){ 717 checkoutpayment.set( $(this), $once ); 718 } 719 });
720 checkoutpayment.watch(); 721 }, 722 723 watch: function() { 724 $(document).on('click', '.wc_payment_methods .wc_payment_method', function() { 725 checkoutpayment.set( $(this) ); 726 }); 727 }, 728 729 set: function( $li, $once = false ) { 730 $input = $li.find('.input-radio'); 731 if(!$input.is(':checked')){ 732 733 $('.wc_payment_methods .wc_payment_method .payment_box').slideUp(300); 734 $('.wc_payment_methods .wc_payment_method').removeClass('active-payment'); 735 736 $input.trigger('click'); 737 $li.addClass('active-payment'); 738 $li.find('.payment_box').slideDown(300); 739 740 }else{ 741 $li.addClass('active-payment'); 742 } 743 744 // FIX | WooCommerce 7.6 no longer using ajax 745 746 if( ! $once ){ 747 setTimeout(function(){ 748 checkoutpayment.start( true ); 749 },1500); 750 } 751 752 } 753 754 }; 755 756 quickview = { 757 headerOffset: false, 758 display: function(id) { 759 $.ajax({ 760 url: mfnwoovars.ajaxurl, 761 data: { 762 'mfn-woo-nonce': mfnwoovars.wpnonce, 763 action: 'mfnproductquickview', 764 id: id 765 }, 766 type: 'POST', 767 success: function(response){ 768 769 770 $('body').append(response); 771 $('.mfn-quick-view').removeClass('loading'); 772 quickview.close(); 773 if( $('.mfn-variations-wrapper').length && $('body').hasClass('mfn-variable-swatches') ){ 774 productvariations.run(); 775 } 776 777 $('html').addClass('mfn-quick-view-opened'); 778 779 $('.mfn-popup-quickview .mfn-quickview-slider').slick({ 780 slidesToShow: 1, 781 slidesToScroll: 1, 782 autoplay: true, 783 autoplaySpeed: 3000, 784 dots: false, 785 arrows: true, 786 prevArrow: '<a class="slick-prev mfn-popup-arrow slick-arrow" href="#"><i class="icon-left-open-big" aria-label="previous slide"></i></a>', 787 nextArrow: '<a class="slick-next mfn-popup-arrow slick-arrow" href="#"><i class="icon-right-open-big" aria-label="next slide"></i></a>', 788 focusOnChange: true, 789 }); 790 791 if( $('.mfn-popup-quickview form.cart.variations_form').length ){ 792 $('.mfn-popup-quickview .variations_form').wc_variation_form(); 793 } 794 795 $('.mfn-popup-quickview .mfn-quickview-slider').imagesLoaded( function() { 796 quickview.setHeight(); 797 }); 798 799 wishlist.set(); 800 801 $(window).on('debouncedresize', quickview.setHeight); 802 803 return; 804 } 805 }); 806 }, 807 setHeight: function() { 808 var popupH = $('.mfn-popup-quickview .mfn-popup-content').outerHeight(); 809 var imgH = $('.mfn-popup-quickview .mfn-popup-content-photos .mfn-qs-one-first img').height(); 810 811 if(imgH > popupH){ 812 $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': popupH }); 813 }else{ 814 $('.mfn-popup-quickview .mfn-popup-content-text').css({ 'height': imgH }); 815 } 816 817 if( $('body').hasClass('mfn-header-scrolled') && $('.mfn-header-tmpl.mfn-hasSticky').length ){ 818 $('html').addClass('mfn-disable-css-animations'); 819 $('body').removeClass('mfn-header-scrolled'); 820 quickview.headerOffset = $('.mfn-header-tmpl.mfn-hasSticky').outerHeight(); 821 $('body').addClass('mfn-header-scrolled'); 822 $('#Wrapper').css({'padding-top': quickview.headerOffset+"px"}); 823 } 824 825 }, 826 close: function() { 827 $('.mfn-close-popup').on('click', function() { 828 $('.mfn-popup').remove(); 829 $('html').removeClass('mfn-quick-view-opened'); 830 $('html').removeClass('mfn-disable-css-animations'); 831 }); 832 833 $('.mfn-popup').on('click', function(e) { 834 if(!$('.mfn-popup-content').is(e.target) && $('.mfn-popup-content').has(e.target).length === 0) { 835 $('.mfn-popup').remove(); 836 $('html').removeClass('mfn-quick-view-opened'); 837 $('html').removeClass('mfn-disable-css-animations'); 838 } 839 }); 840 } 841 }, 842 843 woocart = { 844 845 start: function() { 846 /*if( $('a#header_cart .header-cart-count').length ){ 847 if( $('#Top_bar a#header_cart .header-cart-count').text() == '0' ){ 848 $('.mfn-ch-footer-buttons').hide(); 849 } 850 }*/ 851 852 return false;
853 }, 854 855 click: function() { 856 if($('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){ 857 $('html').toggleClass('mfn-cart-opened'); 858 } 859 }, 860 861 refresh: function(){ 862 $.ajax({ 863 url: mfnwoovars.ajaxurl, 864 data: { 865 'mfn-woo-nonce': mfnwoovars.wpnonce, 866 action: 'mfnrefreshcart' 867 }, 868 type: 'POST', 869 cache: false, 870 success: function(response){ 871 $('.mfn-cart-holder .mfn-ch-content').html(response.content); 872 $('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer); 873 $('.mfn-cart-holder').removeClass('loading'); 874 875 // side cart buttons 876 if( response.total == 0 ){ 877 $('.mfn-ch-footer-buttons').hide(); 878 }else{ 879 $('.mfn-ch-footer-buttons').show(); 880 } 881 882 return; 883 } 884 }); 885 }, 886 887 delete: function(id){ 888 $.ajax({ 889 url: mfnwoovars.ajaxurl, 890 data: { 891 'mfn-woo-nonce': mfnwoovars.wpnonce, 892 action: 'mfnremovewooproduct', 893 pid: id 894 }, 895 type: 'POST', 896 cache: false, 897 success: function(response){ 898 $(document.body).trigger('wc_fragment_refresh'); 899 woocart.refresh(); 900 if($('body').hasClass('woocommerce-cart')){ 901 $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').trigger('click'); 902 } 903 } 904 }); 905 }, 906 907 updatequantity: function(id, qty) { 908 $.ajax({ 909 url: mfnwoovars.ajaxurl, 910 data: { 911 'mfn-woo-nonce': mfnwoovars.wpnonce, 912 action: 'mfnchangeqtyproduct', 913 pid: id, 914 qty: qty 915 }, 916 type: 'POST', 917 cache: false, 918 success: function(response){ 919 $(document.body).trigger('wc_fragment_refresh'); 920 woocart.refresh(); 921 if($('body').hasClass('woocommerce-cart')){ 922 $('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').parent().siblings('.product-quantity').find('input.qty').val(qty).trigger('change'); 923 $('.woocommerce-cart-form .button[name="update_cart"]').trigger('click'); 924 } 925 926 } 927 }); 928 } 929 930 }; 931 932 var mfnFakeSale = { 933 934 active: true, 935 936 time: function() { 937 let arr = [20000, 25000, 30000, 35000, 40000, 50000]; 938 return arr[Math.floor(Math.random()*arr.length)]; 939 }, 940 941 init: function() { 942 943 if( $('body').hasClass('mfn-ui') ) return; 944 945 if( mfnFakeSale.checkCookie("mfnFakeSale") ) mfnFakeSale.active = false; 946 947 if( typeof mfn_fake_sale === 'undefined' || !mfnFakeSale.active ) return; 948 949 let delay = typeof mfn_fake_sale.delay !== 'undefined' ? mfn_fake_sale.delay : 5; 950 951 delay = parseFloat(delay)*1000; 952 953 setTimeout(mfnFakeSale.show, delay); 954 955 $(document).on('click', '.mfn-fake-sale-noti .mfn-fake-sale-noti-close', function(e) { 956 e.preventDefault(); 957 mfnFakeSale.active = false; 958 mfnFakeSale.hide(); 959 mfnFakeSale.addCookie(1, "mfnFakeSale"); 960 }); 961 962 }, 963 964 show: function() { 965 var item = mfn_fake_sale.items[Math.floor(Math.random() * mfn_fake_sale.items.length)]; 966 967 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">✕</span></a>' : ''}</div>`; 968 969 $('body').append(html); 970 971 setTimeout(mfnFakeSale.hide, 15000); 972 }, 973 974 hide: function() { 975 if( $('.mfn-fake-sale-noti').length ) { 976 $('.mfn-fake-sale-noti').addClass('mfn-fake-sale-noti-out'); 977 setTimeout(function() {$('.mfn-fake-sale-noti').remove(); }, 500); 978 if( mfnFakeSale.active ) mfnFakeSale.reset(); 979 } 980 }, 981 982 reset: function() { 983 setTimeout(mfnFakeSale.show, mfnFakeSale.time()); 984 }, 985 986 addCookie(days, cookie_name){ 987 let date=new Date(); 988 date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000)); 989 let expires="; expires="+date.toGMTString(); 990 document.cookie=cookie_name+"=true"+expires+"; path=/"; 991 }, 992 993 checkCookie(cookie_name){ 994 var nameEQ = cookie_name+"="; 995 var ca = document.cookie.split(';'); 996 for(var i=0;i<ca.length;i++){ 997 var c = ca[i]; 998 while(c.charAt(0)==' ') c = c.substring(1,c.length); 999 if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length) 1000 } 1001 return null 1002 } 1003 1004 }; 1005 1006 1007 var productgallery = { 1008 start: function() { 1009 1010 if($('.flex-viewport').length){ 1011 $loup = $('.woocommerce-product-gallery__trigger').clone(true).empty().appendTo('.flex-viewport'); 1012 $('.woocommerce-product-gallery > .woocommerce-product-gallery__trigger').remove(); 1013 1014 if($('.woocommerce-product-gallery .mfn-wish-button').length){ 1015 $('.woocommerce-product-gallery .mfn-wish-button').clone(true).appendTo('.flex-viewport'); 1016 $('.woocommerce-product-gallery > .mfn-wish-button').remove(); 1017 $(document).trigger('resize'); 1018 } 1019 }else if( $('.woocommerce-product-gallery__trigger').length ){ 1020 $('.woocommerce-product-gallery__trigger').empty(); 1021 } 1022 1023 if( $('.mfn-product-gallery').length ){ 1024 if($('.flex-control-thumbs').length){ 1025 $('.flex-control-thumbs').wrap('<div class="mfn-flex-control-thumbs-wrapper"></div>'); 1026 } 1027 $('.woocommerce-product-gallery').imagesLoaded( function() {
1028 if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){ 1029 productgallery.verticalThumbs(); 1030 }else if( $('.mfn-thumbnails-bottom').length ){ 1031 productgallery.horizontalThumbs(); 1032 } 1033 }); 1034 } 1035 1036 }, 1037 horizontalThumbs: function() { 1038 var $container = $('.mfn-product-gallery'); 1039 var containerW = $container.outerWidth(); 1040 var $scroller = $container.find('.flex-control-thumbs'); 1041 var scrollerW = 0; 1042 1043 $scroller.find('li').each(function() { 1044 $(this).addClass('swiper-slide'); 1045 scrollerW += $(this).outerWidth(); 1046 }); 1047 1048 if( !$container.length || !$scroller.length ){ 1049 return; 1050 } 1051 1052 if( scrollerW > containerW ){ 1053 //return; 1054 $scroller.css({ 'justify-content': 'flex-start', 'width': '100%' }); 1055 $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active'); 1056 } 1057 1058 $scroller.addClass('swiper-wrapper'); 1059 1060 var swiper_opts = { 1061 slidesPerView: 5, 1062 spaceBetween: parseInt(mfnwoovars.productthumbs), 1063 }; 1064 1065 1066 $scroller.parent().addClass('mfn-arrows-absolute'); 1067 $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>'); 1068 swiper_opts['navigation'] = { 1069 nextEl: ".swiper-button-next", 1070 prevEl: ".swiper-button-prev", 1071 }; 1072 1073 var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", swiper_opts); 1074 }, 1075 verticalThumbs: function() { 1076 var $container = $('.mfn-product-gallery'); 1077 var containerH = $container.find('.woocommerce-product-gallery__image').first().outerHeight(); 1078 var $scroller = $container.find('.flex-control-thumbs'); 1079 var scrollerH = 0; 1080 var mimgm = 0; // main image margin 1081 var overlay = mfnwoovars.productthumbsover ? mfnwoovars.productthumbsover : 0; 1082 1083 $scroller.find('li img').css({ 'height': 'auto' }); 1084 $scroller.find('li').css({ 'height': 'auto' }); 1085 1086 $scroller.find('li').each(function() { 1087 $(this).addClass('swiper-slide').css({ 'margin-bottom': parseInt(mfnwoovars.productthumbs) }); 1088 scrollerH += $(this).outerHeight()+parseInt(mfnwoovars.productthumbs); 1089 $(this).css({ 'opacity': '1' }); 1090 }); 1091 1092 if(mfnwoovars.mainimgmargin == 'mfn-mim-2'){ 1093 mimgm = 4; 1094 }else if(mfnwoovars.mainimgmargin == 'mfn-mim-5'){ 1095 mimgm = 10; 1096 }else if(mfnwoovars.mainimgmargin == 'mfn-mim-10'){ 1097 mimgm = 20; 1098 }else if(mfnwoovars.mainimgmargin == 'mfn-mim-15'){ 1099 mimgm = 30; 1100 }else if(mfnwoovars.mainimgmargin == 'mfn-mim-20'){ 1101 mimgm = 40; 1102 }else if(mfnwoovars.mainimgmargin == 'mfn-mim-25'){ 1103 mimgm = 50; 1104 }else if(mfnwoovars.mainimgmargin == 'mfn-mim-30'){ 1105 mimgm = 60; 1106 } 1107 1108 if( !$container.length || !$scroller.length ){ 1109 return; 1110 } 1111 1112 $container.find('.flex-viewport').css({'height': 'auto'}); 1113 1114 if( scrollerH > containerH ){ 1115 if(overlay == 'mfn-thumbnails-overlay'){ 1116 $('.mfn-flex-control-thumbs-wrapper').height( (containerH-mimgm) ); 1117 }else{ 1118 $('.mfn-flex-control-thumbs-wrapper').height(containerH); 1119 } 1120 1121 $scroller.css({ 'align-items': 'flex-start' }); 1122 $('.mfn-flex-control-thumbs-wrapper').addClass('mfn-scroller-active'); 1123 1124 $scroller.addClass('swiper-wrapper'); 1125 1126 var swiper = new Swiper(".mfn-flex-control-thumbs-wrapper", { 1127 slidesPerView: 4, 1128 spaceBetween: parseInt(mfnwoovars.productthumbs), 1129 direction: "vertical", 1130 mousewheel: true, 1131 }); 1132 1133 $scroller.find('li').each(function() { 1134 $(this).find('img').css({ 'height': $(this).outerHeight() }); 1135 $(this).css({ 'opacity': '1' }); 1136 }); 1137 1138 } 1139 1140 $container.find('.flex-viewport').css('height', containerH); 1141 1142 } 1143 }; 1144 1145 $(window).on('debouncedresize', function() {
1146 if( $('.mfn-thumbnails-left').length || $('.mfn-thumbnails-right').length ){ 1147 setTimeout(productgallery.verticalThumbs(), 300); 1148 } 1149 }); 1150 1151 var initPhotoSwipeFromDOM = function(gallerySelector) { 1152 1153 var parseThumbnailElements = function() { 1154 var items = []; 1155 1156 $(gallerySelector).find('div img').not('.zoomImg').each(function() { 1157 var img = $(this); 1158 var large_image_src = img.attr( 'data-large_image' ), 1159 large_image_w = img.attr( 'data-large_image_width' ), 1160 large_image_h = img.attr( 'data-large_image_height' ), 1161 alt = img.attr( 'alt' ), 1162 item = { 1163 alt : alt, 1164 src : large_image_src, 1165 w : large_image_w, 1166 h : large_image_h, 1167 title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' ) 1168 }; 1169 items.push( item ); 1170 }); 1171 1172 return items; 1173 }; 1174 1175 var openPhotoSwipe = function(index) { 1176 var pswpElement = document.querySelectorAll('.pswp')[0], 1177 items; 1178 1179 items = parseThumbnailElements(); 1180 1181 var options = { 1182 index: parseInt(index, 10), 1183 //showAnimationDuration: 0, 1184 getThumbBoundsFn: function(index) { 1185 var thumbnail = $('.mfn-product-gallery-grid .mfn-product-gg-img[data-index="'+index+'"] div img:first-child'), 1186 pageYScroll = window.pageYOffset || document.documentElement.scrollTop, 1187 rect = thumbnail.offset(); 1188 return {x:rect.left, y:rect.top, w:thumbnail.width()}; 1189 } 1190 }; 1191 1192 if( isNaN(options.index) ) { 1193 return; 1194 } 1195 1196 gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); 1197 gallery.init(); 1198 }; 1199 1200 $('.mfn-product-gallery-grid a.woocommerce-product-gallery__trigger').on('click', function(e) { 1201 e.preventDefault(); 1202 var index = $(this).closest('.mfn-product-gg-img').attr('data-index'); 1203 openPhotoSwipe( index ); 1204 }); 1205 1206 1207 $('.mfn-product-gallery-grid .woocommerce-product-gallery__image a').on('click', function(e) { 1208 e.preventDefault(); 1209 if( !$(this).closest('.elementor-widget-container').length ){ 1210 $(this).closest('.mfn-product-gg-img').find('.woocommerce-product-gallery__trigger').trigger('click'); 1211 } 1212 }); 1213 1214}; 1215 1216 1217$(document).on('click', '.mfn-woocommerce-tabs .mfn-woocommerce-tabs-nav a', function(e) { 1218 e.preventDefault(); 1219 if( $(this).parent('li').hasClass('active') ) return; 1220 1221 $(this).parent().siblings('li').removeClass('active'); 1222 $(this).closest('.mfn-woocommerce-tabs').find('.mfn-woocommerce-tabs-content.active').removeClass('active'); 1223 1224 $(this).parent('li').addClass('active'); 1225 $($(this).attr('href')).addClass('active'); 1226 1227}); 1228 1229})(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.