/*! impleCode Product AJAX Scripts Manages product ajax related scripts (c) 2017 impleCode - https://implecode.com */ var ic_popstate = !1; function ic_ajax_update_product_listing( t, e ){!1 === ( e = ic_defaultFor( e, !1 ) ) && ( e = "?" + t ), "none" !== e && ( window.history.pushState( {form_data:t}, document.title, e ), 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:t, query_vars:r, request_url:ic_ajax.request_url, ajax_elements:{}, ic_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 t = jQuery( this ).data( "ic_ajax" ), e = jQuery( this ).data( "ic_ajax_data" ); e || ( e = 1 ), void 0 === i.ajax_elements[t] && ( void 0 === i.ajax_elements["product-sort-bar"]?i.ajax_elements[t] = e:jQuery( this ).closest( ".product-sort-bar" ).length || ( i.ajax_elements[t] = e ) )}} ), jQuery( ".product-list" ).css( "opacity", "0.5" ), jQuery.post( product_object.ajaxurl, i, function( t ){jQuery( ".reset-filters" ).remove( ), t = jQuery.parseJSON( t ); var r = jQuery( t["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 ), is_element_visible( jQuery( ".product-list div:first-child" ) ) || jQuery( ".product-list div" ).length && jQuery( "html, body" ).animate( {scrollTop:jQuery( ".product-list div" ).offset( ).top - 100}, "slow" )} ), jQuery( "#product_archive_nav" ).length?jQuery( "#product_archive_nav" ).replaceWith( t["product-pagination"] ):jQuery( "div#product_sidebar" ).length?jQuery( t["product-pagination"] ).insertAfter( "div#product_sidebar" ):jQuery( "article#product_listing" ).length?jQuery( t["product-pagination"] ).insertAfter( "article#product_listing" ):jQuery( ".product-list" ).after( t["product-pagination"] ), jQuery.each( i.ajax_elements, function( e, r ){if ( jQuery( "." + e ).length && void 0 !== t[e] && t[e].length ){var a = jQuery( t[e] ); a.hasClass( e ) || ( a = a.find( "." + e ) ), jQuery( "." + e ).replaceWith( a ), jQuery( "." + e ).trigger( "reload" )}} ), t.remove_pagination ){var a = ic_ajax.request_url; - 1 !== a.indexOf( "?" ) && ( a = a.substr( 0, a.indexOf( "?" ) ) ); var u = ""; if ( - 1 !== e.indexOf( "?" ) )u = e.substr( e.indexOf( "?" ) + 1 ); "" !== u && ( u = "?" + u ); var o = a + u; window.history.replaceState( {}, document.title, o )}jQuery.ic.doAction( "ic_self_submit" )} )}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( t ){var e = t.originalEvent.state; if ( null !== e ){if ( void 0 !== e.form_data ){var r = e.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}jQuery( document ).ready( function( ){if ( jQuery( ".product-entry" ).length || 1 !== jQuery( ".product-list" ).length )return!0; var t = 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 t = jQuery( this ).val( ); jQuery( ".ic-search-keyword" ).text( t ), jQuery( ".product-search-box" ).val( t )} ), jQuery( "body" ).on( "submit", t, function( t ){if ( !ic_ajax_product_list_on_screen( ) )return!0; t.preventDefault( ); var e = jQuery( this ), r = jQuery( "[name!=page]", this ), a = e.serialize( ), i = r.serialize( ), u = e.attr( "action" ); ic_ajax_update_product_listing( a, i = "" !== i?u + "?" + i:u )} ); var e = "a.filter-url, .product-archive-nav li:not(.active) a"; jQuery( "body" ).on( "click", e, function( t ){if ( !ic_ajax_product_list_on_screen( ) )return!0; t.preventDefault( ); var e = jQuery( this ).attr( "href" ); if ( - 1 !== e.indexOf( "?" ) )var r = e.substr( e.indexOf( "?" ) + 1 ); else 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( t ).length || jQuery( e ).length ) && ic_ajax_back_button_filters( )} );