Created
November 21, 2022 14:35
-
-
Save dislokacia/3fe59eef35b7414eb9297dedfef84138 to your computer and use it in GitHub Desktop.
Custom Loader for JSF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*For Elementor Pro User - in Custom CSS tab*/ | |
/*In the custom spinner container widget Custom CSS field */ | |
selector { | |
display:none; | |
} | |
selector i { | |
-webkit-animation: fa-spin 2s infinite linear; | |
animation: fa-spin 2s infinite linear; | |
} | |
/*Others*/ | |
#itchy-loader { | |
display:none; | |
} | |
#itchy-loader i { | |
-webkit-animation: fa-spin 2s infinite linear; | |
animation: fa-spin 2s infinite linear; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_footer', 'itchycode_enhance_jetsmartfilters_loading_spinner' ); | |
function itchycode_enhance_jetsmartfilters_loading_spinner() { | |
//Only target on one of my page, jetsmartfilter-jetlisting-custom-spinner is my page slug | |
if( ! is_page('jetsmartfilter-jetlisting-custom-spinner') ) return; | |
?> | |
<script> | |
document.addEventListener('DOMContentLoaded', function() { | |
(($)=>{ | |
//We must wait for the jQuery ready event because JetSmartFilters is not initialized yet | |
$(document).ready(function(){ | |
//Get the spinner container | |
const spinnerContainer = document.getElementById('itchy-loader'); | |
//Get the listing container | |
const listingContainer = document.getElementById('my-product-listing'); | |
if(spinnerContainer && listingContainer) { | |
//Subscribe start loading event bus by JetSmartFilters | |
window.JetSmartFilters.events.subscribe('ajaxFilters/start-loading', ()=>{ | |
spinnerContainer.style.display = 'flex'; | |
listingContainer.style.display = 'none'; | |
}) | |
//Subscribe end loading event bus by JetSmartFilters | |
window.JetSmartFilters.events.subscribe('ajaxFilters/end-loading', ()=>{ | |
spinnerContainer.style.display = 'none'; | |
listingContainer.style.display = 'flex'; | |
}) | |
} | |
}) | |
})(jQuery) | |
}); | |
</script> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment