1

I am trying to load popup widget , admin specifies it will be unload on ready . Where can I specify it must pop unload or on ready ?

define([
'jquery',
'Magento_Ui/js/modal/modal',
'mage/cookies'
], function ($, modal) {
'use strict';

$.widget('devall.popupManager', {
    /**
     * creating popup
     */
    _create: function () {
        var self = this,
        popupOptions = {
            responsive: true,
            title: this.options.popupTitle,
            buttons: false,
            modalClass: 'popup-devnewsletter',
            autoOpen: true,

            /**
             * setting a cookie
             */
            closed: function () {
                self._setCookie();
            }
        };

        if (!$.cookie('popup_cookie')) {
            modal(popupOptions, this.element);
        }

        this.element.find('form').submit(function (e) {
            e.preventDefault();

            if ($(this).validation('isValid')) {
                $.ajax({
                    url: $(this).attr('action'),
                    data: $(this).serialize(),
                    dataType: 'json',
                    type: 'POST',
                    showLoader: true,

                    /**
                     * Just a function
                     */
                    success: function () {
                        self.element.modal('closeModal');
                        self._setCookie();
                    }
                });
            }
        });
    },

    /**
     * cookie function
     */
    _setCookie: function () {
        var expDate = new Date();

        expDate.setTime(expDate.getTime() + 3650000 * 60 * 1000);
        $.cookie('popup_cookie', 1, {
            expires: expDate
        });
    }
});

return $.devall.popupManager;
});
0

I added that code in _create function

   if (this.options.dataPopup.isExitIntent) { //show when Exit Intent
                $(document).mouseleave(function () {
                    bioEp.init(self.options.dataPopup.popupConfig);
                    self._fullScreen();
                    $(document).off('mouseleave');
                    self._setDefaultSize();
                });
            }

now trying to stop (trigger)popup,because popup is shown but user can leave anyway.

0
if (!$.cookie('popup_cookie')) {
                if (this.option.popupEvent === 2) {
                    $(document).mouseleave(function (e) {
                        var self = this;
                        e.preventDefault();
                        e.stopPropagation();
                        $(document).off('mouseleave');
                        modal(popupOptions, $('#popup-devnewsletter'));
                    });
                } else {
                    modal(popupOptions, $('#popup-devnewsletter'));
                }
            }

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.