![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Kaliop/AddToCartModal/view/frontend/web/js/ |
/** * Copyright (c) 2020 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * <[email protected]> */ define([ 'jquery', 'Magento_Ui/js/modal/modal' ], function ($, modal) { 'use strict'; $(function () { var addToCartModal = { modal: null, $document: $(document), init: function () { this._initListeners(); }, _initListeners: function () { this.$document.on('ajax:addToCart', $.proxy(function (event, data) { if (typeof data.response.modal_content !== 'undefined') { this.generateModal(data.response.modal_content); this.displayModal(); } }, this)); $('body').on('click', '[data-role=close-add-to-cart-modal]', $.proxy(function (event) { event.preventDefault(); this.closeModal(); }, this)); }, generateModal: function (content) { this.modal = jQuery('<div/>').html(content).modal({ title: '', type: 'popup', buttons: [], opened: $.proxy(function () { this.$document.trigger('ajax:addToCart:modal:opened', { 'content': content }); }, this), closed: $.proxy(function () { this.$document.trigger('ajax:addToCart:modal:closed', { 'content': content }); }, this) }); }, displayModal: function () { this.modal.modal('openModal'); }, closeModal: function () { this.modal.modal('closeModal'); } }; addToCartModal.init(); }); });