Ad

Add Delay To This Newsletter Popup Code - JQuery Modal Window Popup Code

My website is https://urbancitee.com , I'm using Ella theme, Shopify platform.

I'm using built-in popup code of this theme:

<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function() {    //
    var $modalParent        = jQuery('div.newsletterwrapper'),
        modalWindow         = jQuery('#email-modal'),
        emailModal          = jQuery('#email-modal'),
        modalPageURL        = window.location.pathname; 

    modalWindow = modalWindow.html();
    modalWindow = '<div id="email-modal">' + modalWindow + '</div>';
    $modalParent.css({'position':'relative'});
    jQuery('.wrapper #email-modal').remove();
    $modalParent.append(modalWindow);

    if (jQuery.cookie('emailSubcribeModal') != 'closed') {
        openEmailModalWindow();
    };

    jQuery('#email-modal .btn.close').click(function(e) {
        e.preventDefault();
        closeEmailModalWindow();
    });
    jQuery('body').keydown(function(e) {
        if( e.which == 27) {
            closeEmailModalWindow();
            jQuery('body').unbind('keydown');
        }
    });
    jQuery('#mc_embed_signup form').submit(function() {
        if (jQuery('#mc_embed_signup .email').val() != '') {
            closeEmailModalWindow();
        }
    });

    function closeEmailModalWindow () {
        jQuery('#email-modal .modal-window').fadeOut(600, function() {
            jQuery('#email-modal .modal-overlay').fadeOut(600, function() {
                jQuery('#email-modal').hide();
                jQuery.cookie('emailSubcribeModal', 'closed', {expires:1, path:'/'});
            });
        })
    }
    function openEmailModalWindow () {
        jQuery('#email-modal').fadeIn(600, function() {
           jQuery('#email-modal .modal-window').fadeIn(600);
        });
    }

});
// ]]
// ]]></script>

Please help me to add a delay to this popup windows, about 60s. Thank you very much!!!

Ad

Answer

You use setTimeout and include desired delay in number of milliseconds.

if (jQuery.cookie('emailSubcribeModal') != 'closed') {
    setTimeout(openEmailModalWindow, 60000);
};
Ad
source: stackoverflow.com
Ad