1

Is there a way in magento to make a pop-up newsletter which will not close until there is an email supplied? How can I do this?

Example. http://www.peopleperhour.com/hourlies the grey area is not clickable and I don't want to put close button.

<script>
    function setCookie(cname,cvalue,exdays) {
        var d = new Date();
        d.setTime(d.getTime()+(exdays*24*60*60*1000));
        var expires = "expires="+d.toGMTString();
        document.cookie = cname+"="+cvalue+"; "+expires;
    }

    function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for (var i=0; i<ca.length; i++) {
            var c = ca[i].trim();
            if (c.indexOf(name)==0) return c.substring(name.length,c.length);
        }
        return "";
    }

     jQuery(document).ready(function() {
        if (getCookie("shownewsletter") != 1){
            jQuery('#newsletter_pop_up').bPopup({
                modalClose: false,
                position: ['auto', <?php if(Mage::getStoreConfig('newsletterpopup/general/top') != '') echo Mage::getStoreConfig('newsletterpopup/general/top'); else echo '120'; ?>],
                easing: 'easeOutBack', //uses jQuery easing plugin
                speed: <?php if(Mage::getStoreConfig('newsletterpopup/general/speed') != '') echo Mage::getStoreConfig('newsletterpopup/general/speed'); else echo '450' ?>,
                transition: 'slideDown',
                onClose: function() { setCookie("shownewsletter",'1',<?php if(Mage::getStoreConfig('newsletterpopup/general/cookietimeout')!='') echo Mage::getStoreConfig('newsletterpopup/general/cookietimeout');else echo '1' ?>);
                }
            });
        }

        jQuery( "#newsletter_pop_up form" ).submit(function( event ) {
            var email = jQuery('#newsletter_subscribe').val();
            var testEmail = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
            if (testEmail.test(email)) {
                setCookie("shownewsletter",'1',1);
                return true;
            } else{
                jQuery('#newsletter_subscribe').addClass('validation-failed');
                jQuery('#advice-required-entry-newsletter').show();
                return false;
            }
        });
     });
</script>
  • What code you are using for open this pop-up??? – Asish Hira Apr 4 '16 at 11:25
  • I am using the popup from this template demo.saharathemes.com/ma_sahara_fashion1415/index.php/… – KiD Cajes Apr 4 '16 at 11:44
  • That is not matter what you are using.. I need to know the code for edit it like you want. – Asish Hira Apr 4 '16 at 11:47
  • I actually don't have idea what to edit. What I want is that, they cannot click anywhere or skip the popup or close the popup until they supply email and click submit. After the submission, then they got to view the site. Like this one peopleperhour.com/hourlies but without closing button. – KiD Cajes Apr 4 '16 at 11:49
1

In case someone wants to know the answer for this. I bumped into the solution. Just right after the jQuery('#newsletter_pop_up').bPopup({ I added the code modalClose: false, And that answered my query. Thanks for the help everyone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.