MDL-69166 core_payment: ES6-ifying modal_gateways

This commit is contained in:
Shamim Rezaie 2020-01-16 00:22:05 +11:00
parent b23dcc37f2
commit fd187060ad
3 changed files with 33 additions and 47 deletions

View File

@ -1,2 +1,2 @@
define ("core_payment/modal_gateways",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_events","core_payment/events","core/modal_registry"],function(a,b,c,d,f,g,h){var i=!1,j={PROCEED_BUTTON:"[data-action=\"proceed\"]",CANCEL_BUTTON:"[data-action=\"cancel\"]"},k=function(a){d.call(this,a)};k.TYPE="core_payment-modal_gateways";k.prototype=Object.create(d.prototype);k.prototype.constructor=k;k.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.getModal().on(c.events.activate,j.PROCEED_BUTTON,function(b,c){var d=a.Event(g.proceed);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this));this.getModal().on(c.events.activate,j.CANCEL_BUTTON,function(b,c){var d=a.Event(f.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this))};if(!i){h.register(k.TYPE,k,"core_payment/modal_gateways");i=!0}return k});
define ("core_payment/modal_gateways",["exports","jquery","core/custom_interaction_events","core/modal","core/modal_events","core_payment/events","core/modal_registry"],function(a,b,c,d,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=i(b);c=i(c);d=i(d);f=i(f);g=i(g);h=i(h);function i(a){return a&&a.__esModule?a:{default:a}}function j(a){if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){j=function(a){return typeof a}}else{j=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return j(a)}function k(a,b){if(!(a instanceof b)){throw new TypeError("Cannot call a class as a function")}}function l(a,b){for(var c=0,d;c<b.length;c++){d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;if("value"in d)d.writable=!0;Object.defineProperty(a,d.key,d)}}function m(a,b,c){if(b)l(a.prototype,b);if(c)l(a,c);return a}function n(a,b){if(b&&("object"===j(b)||"function"==typeof b)){return b}return o(a)}function o(a){if(void 0===a){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return a}function p(a,b,c){if("undefined"!=typeof Reflect&&Reflect.get){p=Reflect.get}else{p=function(a,b,c){var d=q(a,b);if(!d)return;var e=Object.getOwnPropertyDescriptor(d,b);if(e.get){return e.get.call(c)}return e.value}}return p(a,b,c||a)}function q(a,b){while(!Object.prototype.hasOwnProperty.call(a,b)){a=r(a);if(null===a)break}return a}function r(a){r=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)};return r(a)}function s(a,b){if("function"!=typeof b&&null!==b){throw new TypeError("Super expression must either be null or a function")}a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}});if(b)t(a,b)}function t(a,b){t=Object.setPrototypeOf||function(a,b){a.__proto__=b;return a};return t(a,b)}var u=!1,v={PROCEED_BUTTON:"[data-action=\"proceed\"]",CANCEL_BUTTON:"[data-action=\"cancel\"]"},w=function(a){s(d,a);function d(a){k(this,d);return n(this,r(d).call(this,a))}m(d,[{key:"registerEventListeners",value:function registerEventListeners(){var a=this;p(r(d.prototype),"registerEventListeners",this).call(this);this.getModal().on(c.default.events.activate,v.PROCEED_BUTTON,function(c,d){var e=b.default.Event(g.default.proceed);a.getRoot().trigger(e,a);if(!e.isDefaultPrevented()){a.hide();d.originalEvent.preventDefault()}});this.getModal().on(c.default.events.activate,v.CANCEL_BUTTON,function(c,d){var e=b.default.Event(f.default.cancel);a.getRoot().trigger(e,a);if(!e.isDefaultPrevented()){a.hide();d.originalEvent.preventDefault()}})}}]);return d}(d.default);a.default=w;w.TYPE="core_payment-modal_gateways";if(!u){h.default.register(w.TYPE,w,"core_payment/modal_gateways");u=!0}return a.default});
//# sourceMappingURL=modal_gateways.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -22,54 +22,40 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define([
'jquery',
'core/notification',
'core/custom_interaction_events',
'core/modal',
'core/modal_events',
'core_payment/events',
'core/modal_registry'
],
function(
$,
Notification,
CustomEvents,
Modal,
ModalEvents,
PaymentEvents,
ModalRegistry
) {
import $ from 'jquery';
import CustomEvents from 'core/custom_interaction_events';
import Modal from 'core/modal';
import ModalEvents from 'core/modal_events';
import PaymentEvents from 'core_payment/events';
import ModalRegistry from 'core/modal_registry';
var registered = false;
var SELECTORS = {
PROCEED_BUTTON: '[data-action="proceed"]',
CANCEL_BUTTON: '[data-action="cancel"]',
};
let registered = false;
const SELECTORS = {
PROCEED_BUTTON: '[data-action="proceed"]',
CANCEL_BUTTON: '[data-action="cancel"]',
};
export default class ModalGateways extends Modal {
/**
* Constructor for the Modal.
*
* @param {object} root The root jQuery element for the modal
*/
var ModalGateways = function(root) {
Modal.call(this, root);
};
ModalGateways.TYPE = 'core_payment-modal_gateways';
ModalGateways.prototype = Object.create(Modal.prototype);
ModalGateways.prototype.constructor = ModalGateways;
constructor(root) {
super(root);
}
/**
* Set up all of the event handling for the modal.
*
* @method registerEventListeners
*/
ModalGateways.prototype.registerEventListeners = function() {
registerEventListeners() {
// Apply parent event listeners.
Modal.prototype.registerEventListeners.call(this);
super.registerEventListeners();
this.getModal().on(CustomEvents.events.activate, SELECTORS.PROCEED_BUTTON, function(e, data) {
this.getModal().on(CustomEvents.events.activate, SELECTORS.PROCEED_BUTTON, (e, data) => {
var proceedEvent = $.Event(PaymentEvents.proceed);
this.getRoot().trigger(proceedEvent, this);
@ -77,9 +63,9 @@ function(
this.hide();
data.originalEvent.preventDefault();
}
}.bind(this));
});
this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {
this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, (e, data) => {
var cancelEvent = $.Event(ModalEvents.cancel);
this.getRoot().trigger(cancelEvent, this);
@ -87,15 +73,15 @@ function(
this.hide();
data.originalEvent.preventDefault();
}
}.bind(this));
};
// Automatically register with the modal registry the first time this module is imported so that you can create modals
// of this type using the modal factory.
if (!registered) {
ModalRegistry.register(ModalGateways.TYPE, ModalGateways, 'core_payment/modal_gateways');
registered = true;
});
}
}
return ModalGateways;
});
ModalGateways.TYPE = 'core_payment-modal_gateways';
// Automatically register with the modal registry the first time this module is imported so that you can create modals
// of this type using the modal factory.
if (!registered) {
ModalRegistry.register(ModalGateways.TYPE, ModalGateways, 'core_payment/modal_gateways');
registered = true;
}