0

It was working when I first installed it. Now I'm finally ready to try to use it it's not completely working. It Submits the form and it registers in magento backend in the newsletter subscribers but the popup form doesn't do anything to indicate that anything has happened. No javascript errors are reported in Chrome and no errors in system.log or exception.log.

I'm no javascript guy so I was wondering if someone could take a look and see if it's something obvious? Something I could try?

TY

<style type="text/css">
    .mr-nl-popup-container {
      position:fixed; 
      left:0; 
      top:0; 
      right:0; 
      bottom:0; 
      z-index:998; 
      max-width:100%;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      background-color:rgba(255,255,255,0.8);
    }
    .mr-nl-popup-container,
    .mr-nl-popup-container * {
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
    }
    .mr-nl-popup-frame {
      width:250px;
      max-width:90%;
      margin:5% auto;
    }
    .mr-nl-popup-frame .block-subscribe {
      position:relative;
      width:100%;
      background-color:#5e5e5e;
      padding:10px;
    }
    .mr-nl-popup-frame .block-content {
      background:transparent;
    }
    .mr-nl-popup-frame .block-subscribe p,
    .mr-nl-popup-frame .block-subscribe label,
    .mr-nl-popup-frame .block-subscribe .label {
      font-size:12px;
      font-weight:normal;
      color:#fefefe;
    }
    .mr-nl-popup-frame .block-subscribe .input-box {
      width:auto;
      position:relative;
    }
    .mr-nl-popup-frame .block-subscribe input,
    .mr-nl-popup-frame .block-subscribe select {
      width:100%;
    }
    .mr-nl-popup-frame .block-subscribe input[type="checkbox"] {
      width:auto;
    }
    .mr-nl-popup-frame .block-subscribe .close {
      float:right;
      width:18px;
      height:18px;
      line-height:17px;
      padding: 0;
    }
    .calendar {
      z-index:999;
    }
    #mr_nl_popup_dob_trig {
      position: absolute;
      padding:4px;
      -webkit-box-sizing: content-box;
      -moz-box-sizing: content-box;
      box-sizing: content-box;
      right: -1px;
      top: 50%;
      margin-top: -12px;
      cursor:pointer;
    }
    #mr_nl_messagesBlock .messages {
        margin-top:10px !important;
    }
    </style>
    <?php $helper = $this->helper('mediarocks_newsletterextended'); ?>

    <div id="mrNlPopupContainer" class="mr-nl-popup-container"<?php if ($helper->getPopupDelay() || $helper->isEmbedOnly()): ?> style="opacity:0; visibility: hidden;"<?php endif; ?>>
        <div class="mr-nl-popup-frame" id="mrNlPopupContainerInner">
            <div class="block block-subscribe">
                <div class="block-title">
                    <button type="button" id="mrNlPopupClose" class="close right" onclick="closeMrnlPopup('<?php echo !$helper->isEmbedOnly() ? 'dismiss' : ''; /* don't set mrnle_hide cookie when popup has been opened manually */ ?>');">&times;</button>
                    <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
                </div>
                <div id="mr_nl_messagesBlock"></div>
                <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail-popup">
                    <div class="block-content">

                        <p><?php echo $this->__('Sign Up for Our Newsletter:') ?></p>

                        <ul class="form-list" style="list-style:none;">
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_gender')): ?>

                            <li>
                                <label for="gender"><?php echo $this->__('Salutation') ?>:</label><br>
                                <div class="input-box">
                                    <select name="gender" id="gender">
                                        <option value=""><?php echo $this->__('choose') ?></option>
                                        <?php echo $helper->getGenderOptionsHtml(); ?>
                                    </select>
                                </div>
                            </li>
                            <?php endif; ?>
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_prefix')): ?>

                            <li>
                                <label for="prefix"><?php echo $this->__('Prefix') ?>:</label><br>
                                <div class="input-box">
                                    <input type="text" name="prefix" id="prefix" class="input-text" />
                                </div>
                            </li>
                            <?php endif; ?>
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_firstname')): ?>

                            <li>
                                <label for="firstname"><?php echo $this->__('First Name') ?>:</label><br>
                                <div class="input-box">
                                    <input type="text" name="firstname" id="firstname" class="input-text" />
                                </div>
                            </li>
                            <?php endif; ?>
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_lastname')): ?>

                            <li>
                                <label for="lastname"><?php echo $this->__('Last Name') ?>:</label><br>
                                 <div class="input-box">
                                    <input type="text" name="lastname" id="lastname" class="input-text" />
                                </div>
                            </li>
                            <?php endif; ?>
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_suffix')): ?>

                            <li>
                                <label for="suffix"><?php echo $this->__('Suffix') ?>:</label><br>
                                <div class="input-box">
                                    <input type="text" name="suffix" id="suffix" class="input-text" />
                                </div>
                            </li>
                            <?php endif; ?>
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_dob')): ?>

                            <li>
                                <label for="dob"><?php echo $this->__('Date of Birth') ?>:</label><br>
                                <div class="input-box">
                                    <input type="text" name="dob" id="mr_nl_popup_dob" class="input-text" placeholder="yyyy/mm/dd" />
                                    <img title="<?php echo $this->__('Select date') ?>" id="mr_nl_popup_dob_trig" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'adminhtml/default/default/images/grid-cal.gif'; ?>"  class="v-middle"/>
                                </div>
                                <script type="text/javascript">
                                    // <![CDATA[
                                    Calendar.setup({
                                        inputField : 'mr_nl_popup_dob',
                                        //ifFormat : '%m/%e/%y',
                                        button : 'mr_nl_popup_dob_trig',
                                        align : 'Br',
                                        singleClick : true
                                    });
                                    // ]]>
                                </script>
                            </li>
                            <?php endif; ?>
                            <?php if (Mage::getStoreConfig('newsletterextended/fields/show_channels')): ?>
                            <?php $channels = $helper->getChannels(); if (count($channels)): ?>

                            <li>
                                <label for="channels">Channels:</label>
                                <div class="input-box">
                                    <?php foreach($channels as $i => $channel): ?>
                                        <input type="checkbox" name="channels[]"<?php if ($i == count($channels)-1): ?> class="validate-one-required"<?php endif; ?> value="<?php echo $channel; ?>" /> <?php echo $helper->translateChannel($channel); ?><br />
                                    <?php endforeach; ?>
                                </div>
                            </li>
                            <?php endif; ?>
                            <?php endif; ?>

                            <li>
                                <label for="email" class="required"><em>*</em><?php echo $this->__('Email') ?>:</label><br>
                                 <div class="input-box">
                                    <?php echo $this->getChildHtml('html_calendar') ?>
                                    <input type="text" name="email" id="email" class="input-text required-entry validate-email" />
                                </div>
                            </li>
                        </ul>
                        <p class="required">* <?php echo $this->__('required fields') ?></p>
                        <div class="actions">
                            <button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        //<![CDATA[

        // init form validation
        var newsletterSubscriberFormDetailPopup = new VarienForm('newsletter-validate-detail-popup');

        function closeMrnlPopup(sAction) 
        {
            $('mrNlPopupContainer').fade({ duration: <?php echo $helper->getPopupFadeDuration(true); ?>, from: 1, to: 0 });
            if ('dismiss' === sAction) {
                // set cookie via ajax to not show the alert again
                new Ajax.Request( "<?php echo Mage::getUrl('newsletterextended/index/hidepopup', array('_forced_secure' => $this->getRequest()->isSecure())) ?>", {
                    method: "post",
                    onComplete: function() {
                        (isSubmit === true) && newsletterSubscriberFormDetailPopup.submit();
                    },
                });
            }
            else if ('reload' === sAction) {
                // fade out popup and reload page
                setTimeout(function()
                {
                    window.location.reload();
                }, <?php echo $helper->getPopupFadeDuration(); ?>);
            }
            else {
                // reset display state of popup container to make it possible to reopen the popup again
                setTimeout(function()
                {
                    $('mrNlPopupContainer').setStyle({opacity: 0, visibility: 'hidden', display: ''});
                }, <?php echo $helper->getPopupFadeDuration(); ?>);
            }
        }

        // function to use with "embed only", when popup should be opened manually
        function showMrnlePopup()
        {
            $('mrNlPopupContainer')
                .setStyle({opacity: 0, visibility: '', display:''})
                .fade({ duration: <?php echo $helper->getPopupFadeDuration(true); ?>, from: 0, to: 1 });
        }

        // prevent default submitting
        new Event.observe('newsletter-validate-detail-popup', 'submit', function(e){
            e.stop();
        });

        // listen to onFormValidate and submit form only if validation succeeds
        newsletterSubscriberFormDetailPopup.validator.options.onFormValidate = function(result, form) {

            if(result) {
                // submit via ajax and ger errors if no success
                new Ajax.Request( "<?php echo str_replace(array('https:', 'http:'), '', $this->getFormActionUrl()); ?>", {
                    parameters: $('newsletter-validate-detail-popup').serialize(true),
                    method: "post",
                    onComplete: function(transport) {
                        if (transport.responseJSON) {

                            // show error messages if no success and error messages given
                            if (!transport.responseJSON.success && transport.responseJSON.messages) {
                                $('mr_nl_messagesBlock').update(transport.responseJSON.messages);
                            }
                            // otherwise fade out popup and reload page to see messages
                            else {
                                closeMrnlPopup('reload');
                            } 
                        }
                    },
                });
            }
        };

        //  fade in after delay
        <?php if (!$helper->isEmbedOnly() && $helper->getPopupDelay()): ?>
        setTimeout(showMrnlePopup, <?php echo $helper->getPopupDelay(); ?>);
        <?php endif; ?>

        //  fade in after delay
        <?php if (!$helper->isEmbedOnly() && $helper->getPopupDelay()): ?>
        setTimeout(showMrnlePopup, <?php echo $helper->getPopupDelay(); ?>);
        <?php endif; ?>

        // close handler for background click
        function closeMrnlPopupHandler(e)
        {
            /* don't set mrnle_hide cookie when popup has been opened manually */
            closeMrnlPopup('<?php echo !$helper->isEmbedOnly() ? 'dismiss' : '';  ?>');
        }
        function preventCloseMrnlPopupHandler(e)
        {
            //stop the event propagating to the body element
            var evt = e ? e : window.event;

            if (evt.stopPropagation) {evt.stopPropagation();}
            else {evt.cancelBubble=true;}
        }

        // setup click handlers on button and body
        document.getElementById('mrNlPopupContainer').onclick = closeMrnlPopupHandler;
        document.getElementById('mrNlPopupContainerInner').onclick = preventCloseMrnlPopupHandler;

        //]]>
    </script>
0

Change window.location.reload(); /*line 216 to

window.location.reload(true);

and

<?php echo $helper->getPopupFadeDuration(); ?> 

with the time Duration that will take to reload the page

example

setTimeout(function()
{
   to window.location.reload(true);
}, 3000);

3000 = 3s

  • I added the code you gave above but no luck. I tried the extension on a fresh Magento install and it works perfect. So I know it works. No javascript errors in the console. Thanks. – Freejoy Jul 30 '17 at 18:18
  • Nice, good luck – M0ns1f Jul 30 '17 at 18:20
0

I found the problem. It was another extension that I installed called Activated NewsletterCoupon I had Mediarocks NewsletterExtended extension to depend on Activated NewsletterCoupon so I could give a discount for subscribing. Anyway, after removing the <depends> it worked.

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.