Skip to content

Instantly share code, notes, and snippets.

@wpstudio
Created July 1, 2021 12:22
Show Gist options
  • Save wpstudio/2082c7f76ee9438a13162461f77433d4 to your computer and use it in GitHub Desktop.
Save wpstudio/2082c7f76ee9438a13162461f77433d4 to your computer and use it in GitHub Desktop.
Javascript for Modal Gravity Forms Webinar
<script type="text/javascript">
jQuery(document).ready(function($){
var delayInSeconds = 10;//Update to change the modal open delay (in seconds)
var modalUID = 'wpsabc';//Update to force modal to show again for anyone that closed it
var $modal = $('.wps-modal_wrapper');
var $form = $modal.find('form');
var modalRef = $form.attr('id') + '_modal_' + modalUID;
var hasClosed = localStorage.getItem(modalRef);
$modal.prepend('<button type="button" id="wps-button-close" title="Close"><span>Close</span></button>');
if ( hasClosed === null ) {
$('#wps-button-close').on('click', function(){
$modal.removeClass('active');
localStorage.setItem(modalRef, true);
});
setTimeout(function() {
$modal.addClass('active');
}, delayInSeconds * 1000);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment