/*! impleCode Product AJAX Scripts Manages product ajax related scripts (c) 2017 impleCode - https://implecode.com */ function ic_ajax_update_product_listing( e, t ){!1 === ( t = ic_defaultFor( t, !1 ) ) && ( t = "?" + e ), "none" !== t && ( window.history.pushState( {form_data:e}, document.title, t ), ic_popstate = !0 ); var r = ic_ajax.query_vars, a = 0; jQuery( ".product-list" ).data( "ic_ajax_query" ) && ( r = JSON.stringify( jQuery( ".product-list" ).data( "ic_ajax_query" ) ), a = 1 ); var i = {action:"ic_self_submit", self_submit_data:e, query_vars:r, request_url:ic_ajax.request_url, ajax_elements:{}, shortcode:a, is_search:ic_ajax.is_search, security:ic_ajax.nonce}; jQuery( ".product-sort-bar" ).length && ( i.ajax_elements["product-sort-bar"] = 1 ), jQuery( ".ic_ajax" ).length && jQuery( ".ic_ajax" ).each( function( ){if ( jQuery( this ).data( "ic_ajax" ).length ){var e = jQuery( this ).data( "ic_ajax" ); void 0 === i.ajax_elements[e] && ( void 0 === i.ajax_elements["product-sort-bar"]?i.ajax_elements[e] = 1:jQuery( this ).closest( ".product-sort-bar" ).length || ( i.ajax_elements[e] = 1 ) )}} ), jQuery( ".product-list" ).css( "opacity", "0.5" ), jQuery.post( product_object.ajaxurl + "?" + e, i, function( e ){jQuery( ".reset-filters" ).remove( ), e = jQuery.parseJSON( e ); var r = jQuery( e["product-listing"] ).not( "form, div.product-sort-bar, .reset-filters" ); if ( jQuery( ".product-list" ).animate( {opacity:0}, "fast", function( ){r = r.hide( ), jQuery( ".product-list" ).replaceWith( r ), jQuery( ".product-list" ).fadeIn( "fast" ), setTimeout( "modern_grid_font_size()", 0 )} ), jQuery( "#product_archive_nav" ).length?jQuery( "#product_archive_nav" ).replaceWith( e["product-pagination"] ):jQuery( "article#product_listing" ).length?jQuery( e["product-pagination"] ).insertAfter( "article#product_listing" ):jQuery( ".product-list" ).append( e["product-pagination"] ), jQuery.each( i.ajax_elements, function( t, r ){if ( jQuery( "." + t ).length && void 0 !== e[t] && e[t].length ){var a = jQuery( e[t] ); a.hasClass( t ) || ( a = a.find( "." + t ) ), jQuery( "." + t ).replaceWith( a )}} ), e.remove_pagination ){var a = ic_ajax.request_url; - 1 !== a.indexOf( "?" ) && ( a = a.substr( 0, a.indexOf( "?" ) ) ); u = ""; if ( - 1 !== t.indexOf( "?" ) )var u = t.substr( t.indexOf( "?" ) + 1 ); "" !== u && ( u = "?" + u ); var o = a + u; window.history.replaceState( {}, document.title, o )}} )}function ic_ajax_back_button_filters( ){jQuery( window ).unbind( "popstate", ic_ajax_run_filters ), jQuery( window ).on( "popstate", ic_ajax_run_filters )}function ic_ajax_run_filters( e ){var t = e.originalEvent.state; if ( null !== t ){if ( void 0 !== t.form_data ){var r = t.form_data; r.length?ic_ajax_update_product_listing( r, "none" ):window.location.reload( )}} else ic_popstate && location.reload( )}function ic_ajax_product_list_on_screen( ){return jQuery( window ).scrollTop( ) + jQuery( window ).height( ) > jQuery( ".product-list" ).offset( ).top}var ic_popstate = !1; jQuery( document ).ready( function( ){if ( jQuery( ".product-entry" ).length || 1 !== jQuery( ".product-list" ).length )return!0; var e = jQuery.ic.applyFilters( "ic_ajax_submit_elements", "form.ic_ajax, form.product_order, form#product_search_form, form.price-filter-form" ); jQuery( "body" ).on( "change", ".product-search-box", function( ){var e = jQuery( this ).val( ); jQuery( ".ic-search-keyword" ).text( e ), jQuery( ".product-search-box" ).val( e )} ), jQuery( "body" ).on( "submit", e, function( e ){if ( !ic_ajax_product_list_on_screen( ) )return!0; e.preventDefault( ); var t = jQuery( this ), r = jQuery( "[name!=page]", this ), a = t.serialize( ), i = r.serialize( ); "" !== i && ( i = t.attr( "action" ) + "?" + i ), ic_ajax_update_product_listing( a, i )} ); jQuery( "body" ).on( "click", "a.filter-url, .product-archive-nav a", function( e ){if ( !ic_ajax_product_list_on_screen( ) )return!0; e.preventDefault( ); var t = jQuery( this ).attr( "href" ); if ( - 1 !== t.indexOf( "?" ) )r = t.substr( t.indexOf( "?" ) + 1 ); else var r = ""; var a = !1, i = ""; void 0 !== jQuery( this ).closest( "li" ).data( "page" )?i = jQuery( this ).closest( "li" ).data( "page" ):void 0 !== jQuery( this ).data( "page" ) && ( i = jQuery( this ).data( "page" ) ), "" !== i && ( r = "" !== r?r + "&page=" + i:r + "page=" + i, a = jQuery( this ).attr( "href" ) ), ic_ajax_update_product_listing( r, a )} ), ( jQuery( e ).length || jQuery( "a.filter-url, .product-archive-nav a" ).length ) && ic_ajax_back_button_filters( )} );