MDL-69166 core_payment: ES6-ifying modal_gateways
authorShamim Rezaie <shamim@moodle.com>
Wed, 15 Jan 2020 13:22:05 +0000 (00:22 +1100)
committerShamim Rezaie <shamim@moodle.com>
Tue, 27 Oct 2020 04:44:59 +0000 (15:44 +1100)
payment/amd/build/modal_gateways.min.js
payment/amd/build/modal_gateways.min.js.map
payment/amd/src/modal_gateways.js

index cf50a3a..54d199f 100644 (file)
Binary files a/payment/amd/build/modal_gateways.min.js and b/payment/amd/build/modal_gateways.min.js differ
index ad60518..7be1ed0 100644 (file)
Binary files a/payment/amd/build/modal_gateways.min.js.map and b/payment/amd/build/modal_gateways.min.js.map differ
index d7d6661..533a333 100644 (file)
  * @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;
+        });
     }
+}
+
+ModalGateways.TYPE = 'core_payment-modal_gateways';
 
-    return ModalGateways;
-});
+// 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;
+}