diff --git a/.eslintrc b/.eslintrc
index 754c8be4f5a..14f4397ffbe 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -185,7 +185,7 @@
'promise/always-return': 'warn',
'promise/no-return-wrap': 'warn',
'promise/param-names': 'warn',
- 'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail']}],
+ 'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail', 'always'], allowFinally: true}],
'promise/no-native': 'warn',
'promise/no-promise-in-callback': 'warn',
'promise/no-callback-in-promise': 'warn',
diff --git a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js
index bb9b4c44ef3..02d832965b4 100644
--- a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js
+++ b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js
@@ -1,10 +1,3 @@
-/**
- * Request actions.
- *
- * @module tool_dataprivacy/data_request_modal
- * @copyright 2018 Jun Pataleta
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("tool_dataprivacy/data_request_modal",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","tool_dataprivacy/events"],(function($,Notification,CustomEvents,Modal,ModalRegistry,DataPrivacyEvents){var registered=!1,SELECTORS_APPROVE_BUTTON='[data-action="approve"]',SELECTORS_DENY_BUTTON='[data-action="deny"]',SELECTORS_COMPLETE_BUTTON='[data-action="complete"]',ModalDataRequest=function(root){Modal.call(this,root)};return ModalDataRequest.TYPE="tool_dataprivacy-data_request",(ModalDataRequest.prototype=Object.create(Modal.prototype)).constructor=ModalDataRequest,ModalDataRequest.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_APPROVE_BUTTON,function(e,data){var approveEvent=$.Event(DataPrivacyEvents.approve);this.getRoot().trigger(approveEvent,this),approveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_DENY_BUTTON,function(e,data){var denyEvent=$.Event(DataPrivacyEvents.deny);this.getRoot().trigger(denyEvent,this),denyEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_COMPLETE_BUTTON,function(e,data){var completeEvent=$.Event(DataPrivacyEvents.complete);this.getRoot().trigger(completeEvent,this),completeEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this))},registered||(ModalRegistry.register(ModalDataRequest.TYPE,ModalDataRequest,"tool_dataprivacy/data_request_modal"),registered=!0),ModalDataRequest}));
+define("tool_dataprivacy/data_request_modal",["exports","jquery","core/custom_interaction_events","core/modal","./events"],(function(_exports,_jquery,CustomEvents,_modal,_events){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),CustomEvents=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(CustomEvents),_modal=_interopRequireDefault(_modal),_events=_interopRequireDefault(_events);const SELECTORS_APPROVE_BUTTON='[data-action="approve"]',SELECTORS_DENY_BUTTON='[data-action="deny"]',SELECTORS_COMPLETE_BUTTON='[data-action="complete"]';class ModalDataRequest extends _modal.default{registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_APPROVE_BUTTON,((e,data)=>{const approveEvent=_jquery.default.Event(_events.default.approve);this.getRoot().trigger(approveEvent,this),approveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())})),this.getModal().on(CustomEvents.events.activate,SELECTORS_DENY_BUTTON,((e,data)=>{const denyEvent=_jquery.default.Event(_events.default.deny);this.getRoot().trigger(denyEvent,this),denyEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())})),this.getModal().on(CustomEvents.events.activate,SELECTORS_COMPLETE_BUTTON,((e,data)=>{const completeEvent=_jquery.default.Event(_events.default.complete);this.getRoot().trigger(completeEvent,this),completeEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}))}}return _exports.default=ModalDataRequest,_defineProperty(ModalDataRequest,"TYPE","tool_dataprivacy-data_request"),_defineProperty(ModalDataRequest,"TEMPLATE","tool_dataprivacy/data_request_modal"),ModalDataRequest.registerModalType(),_exports.default}));
//# sourceMappingURL=data_request_modal.min.js.map
\ No newline at end of file
diff --git a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map
index ef4fbb7deda..09fe9e72b5a 100644
--- a/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map
+++ b/admin/tool/dataprivacy/amd/build/data_request_modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"data_request_modal.min.js","sources":["../src/data_request_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_request_modal\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_registry',\n 'tool_dataprivacy/events'],\n function($, Notification, CustomEvents, Modal, ModalRegistry, DataPrivacyEvents) {\n\n var registered = false;\n var SELECTORS = {\n APPROVE_BUTTON: '[data-action=\"approve\"]',\n DENY_BUTTON: '[data-action=\"deny\"]',\n COMPLETE_BUTTON: '[data-action=\"complete\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDataRequest = function(root) {\n Modal.call(this, root);\n };\n\n ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';\n ModalDataRequest.prototype = Object.create(Modal.prototype);\n ModalDataRequest.prototype.constructor = ModalDataRequest;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDataRequest.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, function(e, data) {\n var approveEvent = $.Event(DataPrivacyEvents.approve);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, function(e, data) {\n var denyEvent = $.Event(DataPrivacyEvents.deny);\n this.getRoot().trigger(denyEvent, this);\n\n if (!denyEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {\n var completeEvent = $.Event(DataPrivacyEvents.complete);\n this.getRoot().trigger(completeEvent, this);\n\n if (!completeEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDataRequest.TYPE, ModalDataRequest, 'tool_dataprivacy/data_request_modal');\n registered = true;\n }\n\n return ModalDataRequest;\n });"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","DataPrivacyEvents","registered","SELECTORS","ModalDataRequest","root","call","this","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","approveEvent","Event","approve","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","denyEvent","deny","completeEvent","complete","register"],"mappings":";;;;;;;AAsBAA,6CAAO,CAAC,SAAU,oBAAqB,iCAAkC,aAAc,sBAC/E,4BACJ,SAASC,EAAGC,aAAcC,aAAcC,MAAOC,cAAeC,uBAEtDC,YAAa,EACbC,yBACgB,0BADhBA,sBAEa,uBAFbA,0BAGiB,2BAQjBC,iBAAmB,SAASC,MAC5BN,MAAMO,KAAKC,KAAMF,cAGrBD,iBAAiBI,KAAO,iCACxBJ,iBAAiBK,UAAYC,OAAOC,OAAOZ,MAAMU,YACtBG,YAAcR,iBAOzCA,iBAAiBK,UAAUI,uBAAyB,WAEhDd,MAAMU,UAAUI,uBAAuBP,KAAKC,WAEvCO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,yBAA0B,SAASe,EAAGC,UAC/EC,aAAexB,EAAEyB,MAAMpB,kBAAkBqB,cACxCC,UAAUC,QAAQJ,aAAcb,MAEhCa,aAAaK,4BACTC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,YAEFO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,sBAAuB,SAASe,EAAGC,UAC5EW,UAAYlC,EAAEyB,MAAMpB,kBAAkB8B,WACrCR,UAAUC,QAAQM,UAAWvB,MAE7BuB,UAAUL,4BACNC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,YAEFO,WAAWC,GAAGjB,aAAakB,OAAOC,SAAUd,0BAA2B,SAASe,EAAGC,UAChFa,cAAgBpC,EAAEyB,MAAMpB,kBAAkBgC,eACzCV,UAAUC,QAAQQ,cAAezB,MAEjCyB,cAAcP,4BACVC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKtB,QAKNL,aACDF,cAAckC,SAAS9B,iBAAiBI,KAAMJ,iBAAkB,uCAChEF,YAAa,GAGVE"}
\ No newline at end of file
+{"version":3,"file":"data_request_modal.min.js","sources":["../src/data_request_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Request actions.\n *\n * @module tool_dataprivacy/data_request_modal\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport DataPrivacyEvents from './events';\n\nconst SELECTORS = {\n APPROVE_BUTTON: '[data-action=\"approve\"]',\n DENY_BUTTON: '[data-action=\"deny\"]',\n COMPLETE_BUTTON: '[data-action=\"complete\"]',\n};\n\nexport default class ModalDataRequest extends Modal {\n static TYPE = 'tool_dataprivacy-data_request';\n static TEMPLATE = 'tool_dataprivacy/data_request_modal';\n\n /**\n * Set up all of the event handling for the modal.\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, (e, data) => {\n const approveEvent = $.Event(DataPrivacyEvents.approve);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, (e, data) => {\n const denyEvent = $.Event(DataPrivacyEvents.deny);\n this.getRoot().trigger(denyEvent, this);\n\n if (!denyEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, (e, data) => {\n const completeEvent = $.Event(DataPrivacyEvents.complete);\n this.getRoot().trigger(completeEvent, this);\n\n if (!completeEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n }\n}\n\nModalDataRequest.registerModalType();\n"],"names":["SELECTORS","ModalDataRequest","Modal","registerEventListeners","this","getModal","on","CustomEvents","events","activate","e","data","approveEvent","$","Event","DataPrivacyEvents","approve","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","denyEvent","deny","completeEvent","complete","registerModalType"],"mappings":"gjDA4BMA,yBACc,0BADdA,sBAEW,uBAFXA,0BAGe,iCAGAC,yBAAyBC,eAO1CC,+BAEUA,uBAAuBC,WAExBC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,0BAA0B,CAACU,EAAGC,cACrEC,aAAeC,gBAAEC,MAAMC,gBAAkBC,cAC1CC,UAAUC,QAAQN,aAAcR,MAEhCQ,aAAaO,4BACTC,OACLT,KAAKU,cAAcC,0BAItBjB,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,uBAAuB,CAACU,EAAGC,cAClEY,UAAYV,gBAAEC,MAAMC,gBAAkBS,WACvCP,UAAUC,QAAQK,UAAWnB,MAE7BmB,UAAUJ,4BACNC,OACLT,KAAKU,cAAcC,0BAItBjB,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,2BAA2B,CAACU,EAAGC,cACtEc,cAAgBZ,gBAAEC,MAAMC,gBAAkBW,eAC3CT,UAAUC,QAAQO,cAAerB,MAEjCqB,cAAcN,4BACVC,OACLT,KAAKU,cAAcC,+EArCdrB,wBACH,iDADGA,4BAEC,uCAyCtBA,iBAAiB0B"}
\ No newline at end of file
diff --git a/admin/tool/dataprivacy/amd/build/events.min.js b/admin/tool/dataprivacy/amd/build/events.min.js
index f5ee42396d0..c9ffd6cd48e 100644
--- a/admin/tool/dataprivacy/amd/build/events.min.js
+++ b/admin/tool/dataprivacy/amd/build/events.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the events the data privacy tool can fire.
- *
- * @module tool_dataprivacy/events
- * @copyright 2018 Jun Pataleta
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("tool_dataprivacy/events",[],(function(){return{approve:"tool_dataprivacy-data_request:approve",bulkApprove:"tool_dataprivacy-data_request:bulk_approve",deny:"tool_dataprivacy-data_request:deny",bulkDeny:"tool_dataprivacy-data_request:bulk_deny",complete:"tool_dataprivacy-data_request:complete"}}));
+define("tool_dataprivacy/events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={approve:"tool_dataprivacy-data_request:approve",bulkApprove:"tool_dataprivacy-data_request:bulk_approve",deny:"tool_dataprivacy-data_request:deny",bulkDeny:"tool_dataprivacy-data_request:bulk_deny",complete:"tool_dataprivacy-data_request:complete"},_exports.default}));
//# sourceMappingURL=events.min.js.map
\ No newline at end of file
diff --git a/admin/tool/dataprivacy/amd/build/events.min.js.map b/admin/tool/dataprivacy/amd/build/events.min.js.map
index 287e52800b6..b0202d8f871 100644
--- a/admin/tool/dataprivacy/amd/build/events.min.js.map
+++ b/admin/tool/dataprivacy/amd/build/events.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"events.min.js","sources":["../src/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events the data privacy tool can fire.\n *\n * @module tool_dataprivacy/events\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n approve: 'tool_dataprivacy-data_request:approve',\n bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',\n deny: 'tool_dataprivacy-data_request:deny',\n bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',\n complete: 'tool_dataprivacy-data_request:complete'\n };\n});\n"],"names":["define","approve","bulkApprove","deny","bulkDeny","complete"],"mappings":";;;;;;;AAsBAA,iCAAO,IAAI,iBACA,CACHC,QAAS,wCACTC,YAAa,6CACbC,KAAM,qCACNC,SAAU,0CACVC,SAAU"}
\ No newline at end of file
+{"version":3,"file":"events.min.js","sources":["../src/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events the data privacy tool can fire.\n *\n * @module tool_dataprivacy/events\n * @copyright 2018 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n approve: 'tool_dataprivacy-data_request:approve',\n bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',\n deny: 'tool_dataprivacy-data_request:deny',\n bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',\n complete: 'tool_dataprivacy-data_request:complete',\n};\n"],"names":["approve","bulkApprove","deny","bulkDeny","complete"],"mappings":"yKAsBe,CACXA,QAAS,wCACTC,YAAa,6CACbC,KAAM,qCACNC,SAAU,0CACVC,SAAU"}
\ No newline at end of file
diff --git a/admin/tool/dataprivacy/amd/src/data_request_modal.js b/admin/tool/dataprivacy/amd/src/data_request_modal.js
index 8b23c88336b..192b5c24c2a 100644
--- a/admin/tool/dataprivacy/amd/src/data_request_modal.js
+++ b/admin/tool/dataprivacy/amd/src/data_request_modal.js
@@ -20,76 +20,59 @@
* @copyright 2018 Jun Pataleta
* @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_registry',
- 'tool_dataprivacy/events'],
- function($, Notification, CustomEvents, Modal, ModalRegistry, DataPrivacyEvents) {
- var registered = false;
- var SELECTORS = {
- APPROVE_BUTTON: '[data-action="approve"]',
- DENY_BUTTON: '[data-action="deny"]',
- COMPLETE_BUTTON: '[data-action="complete"]'
- };
+import $ from 'jquery';
+import * as CustomEvents from 'core/custom_interaction_events';
+import Modal from 'core/modal';
+import DataPrivacyEvents from './events';
- /**
- * Constructor for the Modal.
- *
- * @param {object} root The root jQuery element for the modal
- */
- var ModalDataRequest = function(root) {
- Modal.call(this, root);
- };
+const SELECTORS = {
+ APPROVE_BUTTON: '[data-action="approve"]',
+ DENY_BUTTON: '[data-action="deny"]',
+ COMPLETE_BUTTON: '[data-action="complete"]',
+};
- ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';
- ModalDataRequest.prototype = Object.create(Modal.prototype);
- ModalDataRequest.prototype.constructor = ModalDataRequest;
+export default class ModalDataRequest extends Modal {
+ static TYPE = 'tool_dataprivacy-data_request';
+ static TEMPLATE = 'tool_dataprivacy/data_request_modal';
- /**
- * Set up all of the event handling for the modal.
- *
- * @method registerEventListeners
- */
- ModalDataRequest.prototype.registerEventListeners = function() {
- // Apply parent event listeners.
- Modal.prototype.registerEventListeners.call(this);
+ /**
+ * Set up all of the event handling for the modal.
+ */
+ registerEventListeners() {
+ // Apply parent event listeners.
+ super.registerEventListeners(this);
- this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, function(e, data) {
- var approveEvent = $.Event(DataPrivacyEvents.approve);
- this.getRoot().trigger(approveEvent, this);
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.APPROVE_BUTTON, (e, data) => {
+ const approveEvent = $.Event(DataPrivacyEvents.approve);
+ this.getRoot().trigger(approveEvent, this);
- if (!approveEvent.isDefaultPrevented()) {
- this.hide();
- data.originalEvent.preventDefault();
- }
- }.bind(this));
+ if (!approveEvent.isDefaultPrevented()) {
+ this.hide();
+ data.originalEvent.preventDefault();
+ }
+ });
- this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, function(e, data) {
- var denyEvent = $.Event(DataPrivacyEvents.deny);
- this.getRoot().trigger(denyEvent, this);
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.DENY_BUTTON, (e, data) => {
+ const denyEvent = $.Event(DataPrivacyEvents.deny);
+ this.getRoot().trigger(denyEvent, this);
- if (!denyEvent.isDefaultPrevented()) {
- this.hide();
- data.originalEvent.preventDefault();
- }
- }.bind(this));
+ if (!denyEvent.isDefaultPrevented()) {
+ this.hide();
+ data.originalEvent.preventDefault();
+ }
+ });
- this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {
- var completeEvent = $.Event(DataPrivacyEvents.complete);
- this.getRoot().trigger(completeEvent, this);
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, (e, data) => {
+ const completeEvent = $.Event(DataPrivacyEvents.complete);
+ this.getRoot().trigger(completeEvent, this);
- if (!completeEvent.isDefaultPrevented()) {
- this.hide();
- data.originalEvent.preventDefault();
- }
- }.bind(this));
- };
+ if (!completeEvent.isDefaultPrevented()) {
+ this.hide();
+ data.originalEvent.preventDefault();
+ }
+ });
+ }
+}
- // 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(ModalDataRequest.TYPE, ModalDataRequest, 'tool_dataprivacy/data_request_modal');
- registered = true;
- }
-
- return ModalDataRequest;
- });
\ No newline at end of file
+ModalDataRequest.registerModalType();
diff --git a/admin/tool/dataprivacy/amd/src/events.js b/admin/tool/dataprivacy/amd/src/events.js
index 75de61dbb71..dd2a5f3a83b 100644
--- a/admin/tool/dataprivacy/amd/src/events.js
+++ b/admin/tool/dataprivacy/amd/src/events.js
@@ -20,12 +20,10 @@
* @copyright 2018 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([], function() {
- return {
- approve: 'tool_dataprivacy-data_request:approve',
- bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',
- deny: 'tool_dataprivacy-data_request:deny',
- bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',
- complete: 'tool_dataprivacy-data_request:complete'
- };
-});
+export default {
+ approve: 'tool_dataprivacy-data_request:approve',
+ bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',
+ deny: 'tool_dataprivacy-data_request:deny',
+ bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',
+ complete: 'tool_dataprivacy-data_request:complete',
+};
diff --git a/calendar/amd/build/crud.min.js b/calendar/amd/build/crud.min.js
index d3818aa2cc9..30b5bea95b8 100644
--- a/calendar/amd/build/crud.min.js
+++ b/calendar/amd/build/crud.min.js
@@ -5,6 +5,6 @@
* @copyright 2017 Andrew Nicols
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define("core_calendar/crud",["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/modal_event_form","core_calendar/repository","core_calendar/events","core_calendar/modal_delete","core_calendar/selectors","core/pending"],(function($,Str,Notification,CustomEvents,Modal,ModalRegistry,ModalFactory,ModalEvents,ModalEventForm,CalendarRepository,CalendarEvents,ModalDelete,CalendarSelectors,Pending){return{registerRemove:function(root){root.on("click",CalendarSelectors.actions.remove,(function(e){var eventSource=$(this).closest(CalendarSelectors.eventItem);!function(eventId,eventTitle,eventCount){var deletePromise,pendingPromise=new Pending("core_calendar/crud:confirmDeletion"),deleteStrings=[{key:"deleteevent",component:"calendar"}],isRepeatedEvent=(eventCount=parseInt(eventCount,10))>1;isRepeatedEvent?(deleteStrings.push({key:"confirmeventseriesdelete",component:"calendar",param:{name:eventTitle,count:eventCount}}),deletePromise=ModalFactory.create({type:ModalDelete.TYPE})):(deleteStrings.push({key:"confirmeventdelete",component:"calendar",param:eventTitle}),deletePromise=ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL}));var stringsPromise=Str.get_strings(deleteStrings);$.when(stringsPromise,deletePromise).then((function(strings,deleteModal){return deleteModal.setRemoveOnClose(!0),deleteModal.setTitle(strings[0]),deleteModal.setBody(strings[1]),isRepeatedEvent||deleteModal.setSaveButtonText(strings[0]),deleteModal.show(),deleteModal.getRoot().on(ModalEvents.save,(function(){var pendingPromise=new Pending("calendar/crud:initModal:deletedevent");CalendarRepository.deleteEvent(eventId,!1).then((function(){$("body").trigger(CalendarEvents.deleted,[eventId,!1])})).then(pendingPromise.resolve).catch(Notification.exception)})),deleteModal.getRoot().on(CalendarEvents.deleteAll,(function(){var pendingPromise=new Pending("calendar/crud:initModal:deletedallevent");CalendarRepository.deleteEvent(eventId,!0).then((function(){$("body").trigger(CalendarEvents.deleted,[eventId,!0])})).then(pendingPromise.resolve).catch(Notification.exception)})),deleteModal})).then((function(modal){return pendingPromise.resolve(),modal})).catch(Notification.exception)}(eventSource.data("eventId"),eventSource.data("eventTitle"),eventSource.data("eventCount")),e.preventDefault()}))},registerEditListeners:function(root,eventFormModalPromise){var pendingPromise=new Pending("core_calendar/crud:registerEditListeners");return eventFormModalPromise.then((function(modal){return $("body").on(CalendarEvents.editEvent,(function(e,eventId){var target=root.find("[data-event-id=".concat(eventId,"]")),calendarWrapper=root.find(CalendarSelectors.wrapper);modal.setEventId(eventId),modal.setContextId(calendarWrapper.data("contextId")),modal.setReturnElement(target),modal.show(),e.stopImmediatePropagation()})),modal})).then((function(modal){return pendingPromise.resolve(),modal})).catch(Notification.exception)},registerEventFormModal:function(root){var eventFormPromise=ModalFactory.create({type:ModalEventForm.TYPE,large:!0});return root.on("click",CalendarSelectors.actions.create,(function(e){eventFormPromise.then((function(modal){var wrapper=root.find(CalendarSelectors.wrapper),categoryId=wrapper.data("categoryid");void 0!==categoryId&&modal.setCategoryId(categoryId);var today=root.find(CalendarSelectors.today),firstDay=root.find(CalendarSelectors.day);!today.length&&firstDay.length&&modal.setStartTime(firstDay.data("newEventTimestamp")),modal.setContextId(wrapper.data("contextId")),modal.setCourseId(wrapper.data("courseid")),modal.show()})).fail(Notification.exception),e.preventDefault()})),root.on("click",CalendarSelectors.actions.edit,(function(e){e.preventDefault();var target=$(e.currentTarget),calendarWrapper=target.closest(CalendarSelectors.wrapper),eventWrapper=target.closest(CalendarSelectors.eventItem);eventFormPromise.then((function(modal){modal.setEventId(eventWrapper.data("eventId")),modal.setContextId(calendarWrapper.data("contextId")),modal.setCourseId(eventWrapper.data("courseId")),modal.show(),e.stopImmediatePropagation()})).fail(Notification.exception)})),eventFormPromise}}}));
+define("core_calendar/crud",["jquery","core/str","core/notification","core/modal_factory","core/modal_events","core_calendar/modal_event_form","core_calendar/repository","core_calendar/events","core_calendar/modal_delete","core_calendar/selectors","core/pending"],(function($,Str,Notification,ModalFactory,ModalEvents,ModalEventForm,CalendarRepository,CalendarEvents,ModalDelete,CalendarSelectors,Pending){return{registerRemove:function(root){root.on("click",CalendarSelectors.actions.remove,(function(e){var eventSource=$(this).closest(CalendarSelectors.eventItem);!function(eventId,eventTitle,eventCount){var deletePromise,pendingPromise=new Pending("core_calendar/crud:confirmDeletion"),deleteStrings=[{key:"deleteevent",component:"calendar"}],isRepeatedEvent=(eventCount=parseInt(eventCount,10))>1;isRepeatedEvent?(deleteStrings.push({key:"confirmeventseriesdelete",component:"calendar",param:{name:eventTitle,count:eventCount}}),deletePromise=ModalFactory.create({type:ModalDelete.TYPE})):(deleteStrings.push({key:"confirmeventdelete",component:"calendar",param:eventTitle}),deletePromise=ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL}));var stringsPromise=Str.get_strings(deleteStrings);$.when(stringsPromise,deletePromise).then((function(strings,deleteModal){return deleteModal.setRemoveOnClose(!0),deleteModal.setTitle(strings[0]),deleteModal.setBody(strings[1]),isRepeatedEvent||deleteModal.setSaveButtonText(strings[0]),deleteModal.show(),deleteModal.getRoot().on(ModalEvents.save,(function(){var pendingPromise=new Pending("calendar/crud:initModal:deletedevent");CalendarRepository.deleteEvent(eventId,!1).then((function(){$("body").trigger(CalendarEvents.deleted,[eventId,!1])})).then(pendingPromise.resolve).catch(Notification.exception)})),deleteModal.getRoot().on(CalendarEvents.deleteAll,(function(){var pendingPromise=new Pending("calendar/crud:initModal:deletedallevent");CalendarRepository.deleteEvent(eventId,!0).then((function(){$("body").trigger(CalendarEvents.deleted,[eventId,!0])})).then(pendingPromise.resolve).catch(Notification.exception)})),deleteModal})).then((function(modal){return pendingPromise.resolve(),modal})).catch(Notification.exception)}(eventSource.data("eventId"),eventSource.data("eventTitle"),eventSource.data("eventCount")),e.preventDefault()}))},registerEditListeners:function(root,eventFormModalPromise){var pendingPromise=new Pending("core_calendar/crud:registerEditListeners");return eventFormModalPromise.then((function(modal){return $("body").on(CalendarEvents.editEvent,(function(e,eventId){var target=root.find("[data-event-id=".concat(eventId,"]")),calendarWrapper=root.find(CalendarSelectors.wrapper);modal.setEventId(eventId),modal.setContextId(calendarWrapper.data("contextId")),modal.setReturnElement(target),modal.show(),e.stopImmediatePropagation()})),modal})).then((function(modal){return pendingPromise.resolve(),modal})).catch(Notification.exception)},registerEventFormModal:function(root){var eventFormPromise=ModalFactory.create({type:ModalEventForm.TYPE,large:!0});return root.on("click",CalendarSelectors.actions.create,(function(e){eventFormPromise.then((function(modal){var wrapper=root.find(CalendarSelectors.wrapper),categoryId=wrapper.data("categoryid");void 0!==categoryId&&modal.setCategoryId(categoryId);var today=root.find(CalendarSelectors.today),firstDay=root.find(CalendarSelectors.day);!today.length&&firstDay.length&&modal.setStartTime(firstDay.data("newEventTimestamp")),modal.setContextId(wrapper.data("contextId")),modal.setCourseId(wrapper.data("courseid")),modal.show()})).fail(Notification.exception),e.preventDefault()})),root.on("click",CalendarSelectors.actions.edit,(function(e){e.preventDefault();var target=$(e.currentTarget),calendarWrapper=target.closest(CalendarSelectors.wrapper),eventWrapper=target.closest(CalendarSelectors.eventItem);eventFormPromise.then((function(modal){modal.setEventId(eventWrapper.data("eventId")),modal.setContextId(calendarWrapper.data("contextId")),modal.setCourseId(eventWrapper.data("courseId")),modal.show(),e.stopImmediatePropagation()})).fail(Notification.exception)})),eventFormPromise}}}));
//# sourceMappingURL=crud.min.js.map
\ No newline at end of file
diff --git a/calendar/amd/build/crud.min.js.map b/calendar/amd/build/crud.min.js.map
index 707dd194a41..de481ef9645 100644
--- a/calendar/amd/build/crud.min.js.map
+++ b/calendar/amd/build/crud.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"crud.min.js","sources":["../src/crud.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A module to handle CRUD operations within the UI.\n *\n * @module core_calendar/crud\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/modal_factory',\n 'core/modal_events',\n 'core_calendar/modal_event_form',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/modal_delete',\n 'core_calendar/selectors',\n 'core/pending',\n],\nfunction(\n $,\n Str,\n Notification,\n CustomEvents,\n Modal,\n ModalRegistry,\n ModalFactory,\n ModalEvents,\n ModalEventForm,\n CalendarRepository,\n CalendarEvents,\n ModalDelete,\n CalendarSelectors,\n Pending\n) {\n\n /**\n * Prepares the action for the summary modal's delete action.\n *\n * @param {Number} eventId The ID of the event.\n * @param {string} eventTitle The event title.\n * @param {Number} eventCount The number of events in the series.\n * @return {Promise}\n */\n function confirmDeletion(eventId, eventTitle, eventCount) {\n var pendingPromise = new Pending('core_calendar/crud:confirmDeletion');\n var deleteStrings = [\n {\n key: 'deleteevent',\n component: 'calendar'\n },\n ];\n\n eventCount = parseInt(eventCount, 10);\n var deletePromise;\n var isRepeatedEvent = eventCount > 1;\n if (isRepeatedEvent) {\n deleteStrings.push({\n key: 'confirmeventseriesdelete',\n component: 'calendar',\n param: {\n name: eventTitle,\n count: eventCount,\n },\n });\n\n deletePromise = ModalFactory.create(\n {\n type: ModalDelete.TYPE\n }\n );\n } else {\n deleteStrings.push({\n key: 'confirmeventdelete',\n component: 'calendar',\n param: eventTitle\n });\n\n\n deletePromise = ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n });\n }\n\n var stringsPromise = Str.get_strings(deleteStrings);\n\n var finalPromise = $.when(stringsPromise, deletePromise)\n .then(function(strings, deleteModal) {\n deleteModal.setRemoveOnClose(true);\n deleteModal.setTitle(strings[0]);\n deleteModal.setBody(strings[1]);\n if (!isRepeatedEvent) {\n deleteModal.setSaveButtonText(strings[0]);\n }\n\n deleteModal.show();\n\n deleteModal.getRoot().on(ModalEvents.save, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedevent');\n CalendarRepository.deleteEvent(eventId, false)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, false]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n deleteModal.getRoot().on(CalendarEvents.deleteAll, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedallevent');\n CalendarRepository.deleteEvent(eventId, true)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, true]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n return deleteModal;\n })\n .then(function(modal) {\n pendingPromise.resolve();\n\n return modal;\n })\n .catch(Notification.exception);\n\n return finalPromise;\n }\n\n /**\n * Create the event form modal for creating new events and\n * editing existing events.\n *\n * @method registerEventFormModal\n * @param {object} root The calendar root element\n * @return {object} The create modal promise\n */\n var registerEventFormModal = function(root) {\n var eventFormPromise = ModalFactory.create({\n type: ModalEventForm.TYPE,\n large: true\n });\n\n // Bind click event on the new event button.\n root.on('click', CalendarSelectors.actions.create, function(e) {\n eventFormPromise.then(function(modal) {\n var wrapper = root.find(CalendarSelectors.wrapper);\n\n var categoryId = wrapper.data('categoryid');\n if (typeof categoryId !== 'undefined') {\n modal.setCategoryId(categoryId);\n }\n\n // Attempt to find the cell for today.\n // If it can't be found, then use the start time of the first day on the calendar.\n var today = root.find(CalendarSelectors.today);\n var firstDay = root.find(CalendarSelectors.day);\n if (!today.length && firstDay.length) {\n modal.setStartTime(firstDay.data('newEventTimestamp'));\n }\n\n modal.setContextId(wrapper.data('contextId'));\n modal.setCourseId(wrapper.data('courseid'));\n modal.show();\n return;\n })\n .fail(Notification.exception);\n\n e.preventDefault();\n });\n\n root.on('click', CalendarSelectors.actions.edit, function(e) {\n e.preventDefault();\n var target = $(e.currentTarget),\n calendarWrapper = target.closest(CalendarSelectors.wrapper),\n eventWrapper = target.closest(CalendarSelectors.eventItem);\n\n eventFormPromise.then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n modal.setEventId(eventWrapper.data('eventId'));\n\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.setCourseId(eventWrapper.data('courseId'));\n modal.show();\n\n e.stopImmediatePropagation();\n return;\n }).fail(Notification.exception);\n });\n\n\n return eventFormPromise;\n };\n /**\n * Register the listeners required to remove the event.\n *\n * @param {jQuery} root\n */\n function registerRemove(root) {\n root.on('click', CalendarSelectors.actions.remove, function(e) {\n // Fetch the event title, count, and pass them into the new dialogue.\n var eventSource = $(this).closest(CalendarSelectors.eventItem);\n var eventId = eventSource.data('eventId'),\n eventTitle = eventSource.data('eventTitle'),\n eventCount = eventSource.data('eventCount');\n confirmDeletion(eventId, eventTitle, eventCount);\n\n e.preventDefault();\n });\n }\n\n /**\n * Register the listeners required to edit the event.\n *\n * @param {jQuery} root\n * @param {Promise} eventFormModalPromise\n * @returns {Promise}\n */\n function registerEditListeners(root, eventFormModalPromise) {\n var pendingPromise = new Pending('core_calendar/crud:registerEditListeners');\n\n return eventFormModalPromise\n .then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n $('body').on(CalendarEvents.editEvent, function(e, eventId) {\n var target = root.find(`[data-event-id=${eventId}]`),\n calendarWrapper = root.find(CalendarSelectors.wrapper);\n\n modal.setEventId(eventId);\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.setReturnElement(target);\n modal.show();\n\n e.stopImmediatePropagation();\n });\n return modal;\n })\n .then(function(modal) {\n pendingPromise.resolve();\n\n return modal;\n })\n .catch(Notification.exception);\n }\n\n return {\n registerRemove: registerRemove,\n registerEditListeners: registerEditListeners,\n registerEventFormModal: registerEventFormModal\n };\n});\n"],"names":["define","$","Str","Notification","CustomEvents","Modal","ModalRegistry","ModalFactory","ModalEvents","ModalEventForm","CalendarRepository","CalendarEvents","ModalDelete","CalendarSelectors","Pending","registerRemove","root","on","actions","remove","e","eventSource","this","closest","eventItem","eventId","eventTitle","eventCount","deletePromise","pendingPromise","deleteStrings","key","component","isRepeatedEvent","parseInt","push","param","name","count","create","type","TYPE","types","SAVE_CANCEL","stringsPromise","get_strings","when","then","strings","deleteModal","setRemoveOnClose","setTitle","setBody","setSaveButtonText","show","getRoot","save","deleteEvent","trigger","deleted","resolve","catch","exception","deleteAll","modal","confirmDeletion","data","preventDefault","registerEditListeners","eventFormModalPromise","editEvent","target","find","calendarWrapper","wrapper","setEventId","setContextId","setReturnElement","stopImmediatePropagation","registerEventFormModal","eventFormPromise","large","categoryId","setCategoryId","today","firstDay","day","length","setStartTime","setCourseId","fail","edit","currentTarget","eventWrapper"],"mappings":"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"}
\ No newline at end of file
+{"version":3,"file":"crud.min.js","sources":["../src/crud.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A module to handle CRUD operations within the UI.\n *\n * @module core_calendar/crud\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/notification',\n 'core/modal_factory',\n 'core/modal_events',\n 'core_calendar/modal_event_form',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/modal_delete',\n 'core_calendar/selectors',\n 'core/pending',\n],\nfunction(\n $,\n Str,\n Notification,\n ModalFactory,\n ModalEvents,\n ModalEventForm,\n CalendarRepository,\n CalendarEvents,\n ModalDelete,\n CalendarSelectors,\n Pending\n) {\n\n /**\n * Prepares the action for the summary modal's delete action.\n *\n * @param {Number} eventId The ID of the event.\n * @param {string} eventTitle The event title.\n * @param {Number} eventCount The number of events in the series.\n * @return {Promise}\n */\n function confirmDeletion(eventId, eventTitle, eventCount) {\n var pendingPromise = new Pending('core_calendar/crud:confirmDeletion');\n var deleteStrings = [\n {\n key: 'deleteevent',\n component: 'calendar'\n },\n ];\n\n eventCount = parseInt(eventCount, 10);\n var deletePromise;\n var isRepeatedEvent = eventCount > 1;\n if (isRepeatedEvent) {\n deleteStrings.push({\n key: 'confirmeventseriesdelete',\n component: 'calendar',\n param: {\n name: eventTitle,\n count: eventCount,\n },\n });\n\n deletePromise = ModalFactory.create(\n {\n type: ModalDelete.TYPE\n }\n );\n } else {\n deleteStrings.push({\n key: 'confirmeventdelete',\n component: 'calendar',\n param: eventTitle\n });\n\n\n deletePromise = ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n });\n }\n\n var stringsPromise = Str.get_strings(deleteStrings);\n\n var finalPromise = $.when(stringsPromise, deletePromise)\n .then(function(strings, deleteModal) {\n deleteModal.setRemoveOnClose(true);\n deleteModal.setTitle(strings[0]);\n deleteModal.setBody(strings[1]);\n if (!isRepeatedEvent) {\n deleteModal.setSaveButtonText(strings[0]);\n }\n\n deleteModal.show();\n\n deleteModal.getRoot().on(ModalEvents.save, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedevent');\n CalendarRepository.deleteEvent(eventId, false)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, false]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n deleteModal.getRoot().on(CalendarEvents.deleteAll, function() {\n var pendingPromise = new Pending('calendar/crud:initModal:deletedallevent');\n CalendarRepository.deleteEvent(eventId, true)\n .then(function() {\n $('body').trigger(CalendarEvents.deleted, [eventId, true]);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(Notification.exception);\n });\n\n return deleteModal;\n })\n .then(function(modal) {\n pendingPromise.resolve();\n\n return modal;\n })\n .catch(Notification.exception);\n\n return finalPromise;\n }\n\n /**\n * Create the event form modal for creating new events and\n * editing existing events.\n *\n * @method registerEventFormModal\n * @param {object} root The calendar root element\n * @return {object} The create modal promise\n */\n var registerEventFormModal = function(root) {\n var eventFormPromise = ModalFactory.create({\n type: ModalEventForm.TYPE,\n large: true\n });\n\n // Bind click event on the new event button.\n root.on('click', CalendarSelectors.actions.create, function(e) {\n eventFormPromise.then(function(modal) {\n var wrapper = root.find(CalendarSelectors.wrapper);\n\n var categoryId = wrapper.data('categoryid');\n if (typeof categoryId !== 'undefined') {\n modal.setCategoryId(categoryId);\n }\n\n // Attempt to find the cell for today.\n // If it can't be found, then use the start time of the first day on the calendar.\n var today = root.find(CalendarSelectors.today);\n var firstDay = root.find(CalendarSelectors.day);\n if (!today.length && firstDay.length) {\n modal.setStartTime(firstDay.data('newEventTimestamp'));\n }\n\n modal.setContextId(wrapper.data('contextId'));\n modal.setCourseId(wrapper.data('courseid'));\n modal.show();\n return;\n })\n .fail(Notification.exception);\n\n e.preventDefault();\n });\n\n root.on('click', CalendarSelectors.actions.edit, function(e) {\n e.preventDefault();\n var target = $(e.currentTarget),\n calendarWrapper = target.closest(CalendarSelectors.wrapper),\n eventWrapper = target.closest(CalendarSelectors.eventItem);\n\n eventFormPromise.then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n modal.setEventId(eventWrapper.data('eventId'));\n\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.setCourseId(eventWrapper.data('courseId'));\n modal.show();\n\n e.stopImmediatePropagation();\n return;\n }).fail(Notification.exception);\n });\n\n\n return eventFormPromise;\n };\n /**\n * Register the listeners required to remove the event.\n *\n * @param {jQuery} root\n */\n function registerRemove(root) {\n root.on('click', CalendarSelectors.actions.remove, function(e) {\n // Fetch the event title, count, and pass them into the new dialogue.\n var eventSource = $(this).closest(CalendarSelectors.eventItem);\n var eventId = eventSource.data('eventId'),\n eventTitle = eventSource.data('eventTitle'),\n eventCount = eventSource.data('eventCount');\n confirmDeletion(eventId, eventTitle, eventCount);\n\n e.preventDefault();\n });\n }\n\n /**\n * Register the listeners required to edit the event.\n *\n * @param {jQuery} root\n * @param {Promise} eventFormModalPromise\n * @returns {Promise}\n */\n function registerEditListeners(root, eventFormModalPromise) {\n var pendingPromise = new Pending('core_calendar/crud:registerEditListeners');\n\n return eventFormModalPromise\n .then(function(modal) {\n // When something within the calendar tells us the user wants\n // to edit an event then show the event form modal.\n $('body').on(CalendarEvents.editEvent, function(e, eventId) {\n var target = root.find(`[data-event-id=${eventId}]`),\n calendarWrapper = root.find(CalendarSelectors.wrapper);\n\n modal.setEventId(eventId);\n modal.setContextId(calendarWrapper.data('contextId'));\n modal.setReturnElement(target);\n modal.show();\n\n e.stopImmediatePropagation();\n });\n return modal;\n })\n .then(function(modal) {\n pendingPromise.resolve();\n\n return modal;\n })\n .catch(Notification.exception);\n }\n\n return {\n registerRemove: registerRemove,\n registerEditListeners: registerEditListeners,\n registerEventFormModal: registerEventFormModal\n };\n});\n"],"names":["define","$","Str","Notification","ModalFactory","ModalEvents","ModalEventForm","CalendarRepository","CalendarEvents","ModalDelete","CalendarSelectors","Pending","registerRemove","root","on","actions","remove","e","eventSource","this","closest","eventItem","eventId","eventTitle","eventCount","deletePromise","pendingPromise","deleteStrings","key","component","isRepeatedEvent","parseInt","push","param","name","count","create","type","TYPE","types","SAVE_CANCEL","stringsPromise","get_strings","when","then","strings","deleteModal","setRemoveOnClose","setTitle","setBody","setSaveButtonText","show","getRoot","save","deleteEvent","trigger","deleted","resolve","catch","exception","deleteAll","modal","confirmDeletion","data","preventDefault","registerEditListeners","eventFormModalPromise","editEvent","target","find","calendarWrapper","wrapper","setEventId","setContextId","setReturnElement","stopImmediatePropagation","registerEventFormModal","eventFormPromise","large","categoryId","setCategoryId","today","firstDay","day","length","setStartTime","setCourseId","fail","edit","currentTarget","eventWrapper"],"mappings":"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"}
\ No newline at end of file
diff --git a/calendar/amd/build/events.min.js b/calendar/amd/build/events.min.js
index f1e4bd89da6..92b38877935 100644
--- a/calendar/amd/build/events.min.js
+++ b/calendar/amd/build/events.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the events the calendar component can fire.
- *
- * @module core_calendar/events
- * @copyright 2017 Simey Lameze
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core_calendar/events",[],(function(){return{created:"calendar-events:created",deleted:"calendar-events:deleted",deleteAll:"calendar-events:delete_all",updated:"calendar-events:updated",editEvent:"calendar-events:edit_event",editActionEvent:"calendar-events:edit_action_event",eventMoved:"calendar-events:event_moved",dayChanged:"calendar-events:day_changed",monthChanged:"calendar-events:month_changed",moveEvent:"calendar-events:move_event",filterChanged:"calendar-events:filter_changed",courseChanged:"calendar-events:course_changed",viewUpdated:"calendar-events:view_updated"}}));
+define("core_calendar/events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={created:"calendar-events:created",deleted:"calendar-events:deleted",deleteAll:"calendar-events:delete_all",updated:"calendar-events:updated",editEvent:"calendar-events:edit_event",editActionEvent:"calendar-events:edit_action_event",eventMoved:"calendar-events:event_moved",dayChanged:"calendar-events:day_changed",monthChanged:"calendar-events:month_changed",moveEvent:"calendar-events:move_event",filterChanged:"calendar-events:filter_changed",courseChanged:"calendar-events:course_changed",viewUpdated:"calendar-events:view_updated"},_exports.default}));
//# sourceMappingURL=events.min.js.map
\ No newline at end of file
diff --git a/calendar/amd/build/events.min.js.map b/calendar/amd/build/events.min.js.map
index 9f0441077e5..113d70ad731 100644
--- a/calendar/amd/build/events.min.js.map
+++ b/calendar/amd/build/events.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"events.min.js","sources":["../src/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events the calendar component can fire.\n *\n * @module core_calendar/events\n * @copyright 2017 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n created: 'calendar-events:created',\n deleted: 'calendar-events:deleted',\n deleteAll: 'calendar-events:delete_all',\n updated: 'calendar-events:updated',\n editEvent: 'calendar-events:edit_event',\n editActionEvent: 'calendar-events:edit_action_event',\n eventMoved: 'calendar-events:event_moved',\n dayChanged: 'calendar-events:day_changed',\n monthChanged: 'calendar-events:month_changed',\n moveEvent: 'calendar-events:move_event',\n filterChanged: 'calendar-events:filter_changed',\n courseChanged: 'calendar-events:course_changed',\n viewUpdated: 'calendar-events:view_updated',\n };\n});\n"],"names":["define","created","deleted","deleteAll","updated","editEvent","editActionEvent","eventMoved","dayChanged","monthChanged","moveEvent","filterChanged","courseChanged","viewUpdated"],"mappings":";;;;;;;AAsBAA,8BAAO,IAAI,iBACA,CACHC,QAAS,0BACTC,QAAS,0BACTC,UAAW,6BACXC,QAAS,0BACTC,UAAW,6BACXC,gBAAiB,oCACjBC,WAAY,8BACZC,WAAY,8BACZC,aAAc,gCACdC,UAAW,6BACXC,cAAe,iCACfC,cAAe,iCACfC,YAAa"}
\ No newline at end of file
+{"version":3,"file":"events.min.js","sources":["../src/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events the calendar component can fire.\n *\n * @module core_calendar/events\n * @copyright 2017 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n created: 'calendar-events:created',\n deleted: 'calendar-events:deleted',\n deleteAll: 'calendar-events:delete_all',\n updated: 'calendar-events:updated',\n editEvent: 'calendar-events:edit_event',\n editActionEvent: 'calendar-events:edit_action_event',\n eventMoved: 'calendar-events:event_moved',\n dayChanged: 'calendar-events:day_changed',\n monthChanged: 'calendar-events:month_changed',\n moveEvent: 'calendar-events:move_event',\n filterChanged: 'calendar-events:filter_changed',\n courseChanged: 'calendar-events:course_changed',\n viewUpdated: 'calendar-events:view_updated',\n};\n"],"names":["created","deleted","deleteAll","updated","editEvent","editActionEvent","eventMoved","dayChanged","monthChanged","moveEvent","filterChanged","courseChanged","viewUpdated"],"mappings":"sKAsBe,CACXA,QAAS,0BACTC,QAAS,0BACTC,UAAW,6BACXC,QAAS,0BACTC,UAAW,6BACXC,gBAAiB,oCACjBC,WAAY,8BACZC,WAAY,8BACZC,aAAc,gCACdC,UAAW,6BACXC,cAAe,iCACfC,cAAe,iCACfC,YAAa"}
\ No newline at end of file
diff --git a/calendar/amd/build/modal_delete.min.js b/calendar/amd/build/modal_delete.min.js
index 6fc0e83a839..f0080a8f3a4 100644
--- a/calendar/amd/build/modal_delete.min.js
+++ b/calendar/amd/build/modal_delete.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the logic for the delete modal.
- *
- * @module core_calendar/modal_delete
- * @copyright 2017 Andrew Nicols
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core_calendar/modal_delete",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_events","core/modal_registry","core_calendar/events"],(function($,Notification,CustomEvents,Modal,ModalEvents,ModalRegistry,CalendarEvents){var registered=!1,SELECTORS_DELETE_ONE_BUTTON='[data-action="deleteone"]',SELECTORS_DELETE_ALL_BUTTON='[data-action="deleteall"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]',ModalDelete=function(root){Modal.call(this,root),this.setRemoveOnClose(!0)};return ModalDelete.TYPE="core_calendar-modal_delete",(ModalDelete.prototype=Object.create(Modal.prototype)).constructor=ModalDelete,ModalDelete.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_DELETE_ONE_BUTTON,function(e,data){var saveEvent=$.Event(ModalEvents.save);this.getRoot().trigger(saveEvent,this),saveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_DELETE_ALL_BUTTON,function(e,data){var saveEvent=$.Event(CalendarEvents.deleteAll);this.getRoot().trigger(saveEvent,this),saveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this),cancelEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}.bind(this))},registered||(ModalRegistry.register(ModalDelete.TYPE,ModalDelete,"calendar/event_delete_modal"),registered=!0),ModalDelete}));
+define("core_calendar/modal_delete",["exports","jquery","core/custom_interaction_events","core/modal","core/modal_events","./events"],(function(_exports,_jquery,CustomEvents,_modal,_modal_events,_events){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),CustomEvents=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(CustomEvents),_modal=_interopRequireDefault(_modal),_modal_events=_interopRequireDefault(_modal_events),_events=_interopRequireDefault(_events);const SELECTORS_DELETE_ONE_BUTTON='[data-action="deleteone"]',SELECTORS_DELETE_ALL_BUTTON='[data-action="deleteall"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]';class ModalDelete extends _modal.default{constructor(root){super(root),this.setRemoveOnClose(!0)}registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_DELETE_ONE_BUTTON,((e,data)=>{const saveEvent=_jquery.default.Event(_modal_events.default.save);this.getRoot().trigger(saveEvent,this),saveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())})),this.getModal().on(CustomEvents.events.activate,SELECTORS_DELETE_ALL_BUTTON,((e,data)=>{const saveEvent=_jquery.default.Event(_events.default.deleteAll);this.getRoot().trigger(saveEvent,this),saveEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())})),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,((e,data)=>{const cancelEvent=_jquery.default.Event(_modal_events.default.cancel);this.getRoot().trigger(cancelEvent,this),cancelEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}))}}return _exports.default=ModalDelete,_defineProperty(ModalDelete,"TYPE","core_calendar-modal_delete"),_defineProperty(ModalDelete,"TEMPLATE","calendar/event_delete_modal"),ModalDelete.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_delete.min.js.map
\ No newline at end of file
diff --git a/calendar/amd/build/modal_delete.min.js.map b/calendar/amd/build/modal_delete.min.js.map
index 8aee0d38d16..ce78bf377fb 100644
--- a/calendar/amd/build/modal_delete.min.js.map
+++ b/calendar/amd/build/modal_delete.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_delete.min.js","sources":["../src/modal_delete.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the delete modal.\n *\n * @module core_calendar/modal_delete\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_events',\n 'core/modal_registry',\n 'core_calendar/events',\n],\nfunction(\n $,\n Notification,\n CustomEvents,\n Modal,\n ModalEvents,\n ModalRegistry,\n CalendarEvents\n) {\n\n var registered = false;\n var SELECTORS = {\n DELETE_ONE_BUTTON: '[data-action=\"deleteone\"]',\n DELETE_ALL_BUTTON: '[data-action=\"deleteall\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @class\n * @param {object} root The root jQuery element for the modal\n */\n var ModalDelete = function(root) {\n Modal.call(this, root);\n\n this.setRemoveOnClose(true);\n };\n\n ModalDelete.TYPE = 'core_calendar-modal_delete';\n ModalDelete.prototype = Object.create(Modal.prototype);\n ModalDelete.prototype.constructor = ModalDelete;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalDelete.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ONE_BUTTON, function(e, data) {\n var saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ALL_BUTTON, function(e, data) {\n var saveEvent = $.Event(CalendarEvents.deleteAll);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalDelete.TYPE, ModalDelete, 'calendar/event_delete_modal');\n registered = true;\n }\n\n return ModalDelete;\n});\n"],"names":["define","$","Notification","CustomEvents","Modal","ModalEvents","ModalRegistry","CalendarEvents","registered","SELECTORS","ModalDelete","root","call","this","setRemoveOnClose","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","data","saveEvent","Event","save","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","bind","deleteAll","cancelEvent","cancel","register"],"mappings":";;;;;;;AAsBAA,oCAAO,CACH,SACA,oBACA,iCACA,aACA,oBACA,sBACA,yBAEJ,SACIC,EACAC,aACAC,aACAC,MACAC,YACAC,cACAC,oBAGIC,YAAa,EACbC,4BACmB,4BADnBA,4BAEmB,4BAFnBA,wBAGe,yBASfC,YAAc,SAASC,MACvBP,MAAMQ,KAAKC,KAAMF,WAEZG,kBAAiB,WAG1BJ,YAAYK,KAAO,8BACnBL,YAAYM,UAAYC,OAAOC,OAAOd,MAAMY,YACtBG,YAAcT,YAOpCA,YAAYM,UAAUI,uBAAyB,WAE3ChB,MAAMY,UAAUI,uBAAuBR,KAAKC,WAEvCQ,WAAWC,GAAGnB,aAAaoB,OAAOC,SAAUf,4BAA6B,SAASgB,EAAGC,UAClFC,UAAY1B,EAAE2B,MAAMvB,YAAYwB,WAC/BC,UAAUC,QAAQJ,UAAWd,MAE7Bc,UAAUK,4BACNC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKvB,YAEFQ,WAAWC,GAAGnB,aAAaoB,OAAOC,SAAUf,4BAA6B,SAASgB,EAAGC,UAClFC,UAAY1B,EAAE2B,MAAMrB,eAAe8B,gBAClCP,UAAUC,QAAQJ,UAAWd,MAE7Bc,UAAUK,4BACNC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKvB,YAEFQ,WAAWC,GAAGnB,aAAaoB,OAAOC,SAAUf,wBAAyB,SAASgB,EAAGC,UAC9EY,YAAcrC,EAAE2B,MAAMvB,YAAYkC,aACjCT,UAAUC,QAAQO,YAAazB,MAE/ByB,YAAYN,4BACRC,OACLP,KAAKQ,cAAcC,mBAEzBC,KAAKvB,QAKNL,aACDF,cAAckC,SAAS9B,YAAYK,KAAML,YAAa,+BACtDF,YAAa,GAGVE"}
\ No newline at end of file
+{"version":3,"file":"modal_delete.min.js","sources":["../src/modal_delete.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the delete modal.\n *\n * @module core_calendar/modal_delete\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport ModalEvents from 'core/modal_events';\nimport CalendarEvents from './events';\n\nconst SELECTORS = {\n DELETE_ONE_BUTTON: '[data-action=\"deleteone\"]',\n DELETE_ALL_BUTTON: '[data-action=\"deleteall\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n};\n\n/**\n * Constructor for the Modal.\n *\n * @class\n * @param {object} root The root jQuery element for the modal\n */\nexport default class ModalDelete extends Modal {\n static TYPE = 'core_calendar-modal_delete';\n static TEMPLATE = 'calendar/event_delete_modal';\n\n constructor(root) {\n super(root);\n this.setRemoveOnClose(true);\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ONE_BUTTON, (e, data) => {\n const saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ALL_BUTTON, (e, data) => {\n const saveEvent = $.Event(CalendarEvents.deleteAll);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, (e, data) => {\n const cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n }\n}\n\nModalDelete.registerModalType();\n"],"names":["SELECTORS","ModalDelete","Modal","constructor","root","setRemoveOnClose","registerEventListeners","this","getModal","on","CustomEvents","events","activate","e","data","saveEvent","$","Event","ModalEvents","save","getRoot","trigger","isDefaultPrevented","hide","originalEvent","preventDefault","CalendarEvents","deleteAll","cancelEvent","cancel","registerModalType"],"mappings":"6nDA6BMA,4BACiB,4BADjBA,4BAEiB,4BAFjBA,wBAGa,+BASEC,oBAAoBC,eAIrCC,YAAYC,YACFA,WACDC,kBAAiB,GAQ1BC,+BAEUA,uBAAuBC,WAExBC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUZ,6BAA6B,CAACa,EAAGC,cACxEC,UAAYC,gBAAEC,MAAMC,sBAAYC,WACjCC,UAAUC,QAAQN,UAAWR,MAE7BQ,UAAUO,4BACNC,OACLT,KAAKU,cAAcC,0BAItBjB,WAAWC,GAAGC,aAAaC,OAAOC,SAAUZ,6BAA6B,CAACa,EAAGC,cACxEC,UAAYC,gBAAEC,MAAMS,gBAAeC,gBACpCP,UAAUC,QAAQN,UAAWR,MAE7BQ,UAAUO,4BACNC,OACLT,KAAKU,cAAcC,0BAItBjB,WAAWC,GAAGC,aAAaC,OAAOC,SAAUZ,yBAAyB,CAACa,EAAGC,cACpEc,YAAcZ,gBAAEC,MAAMC,sBAAYW,aACnCT,UAAUC,QAAQO,YAAarB,MAE/BqB,YAAYN,4BACRC,OACLT,KAAKU,cAAcC,0EA5CdxB,mBACH,8CADGA,uBAEC,+BAgDtBA,YAAY6B"}
\ No newline at end of file
diff --git a/calendar/amd/build/modal_event_form.min.js b/calendar/amd/build/modal_event_form.min.js
index be14640dd4b..8086b436ab6 100644
--- a/calendar/amd/build/modal_event_form.min.js
+++ b/calendar/amd/build/modal_event_form.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the logic for the quick add or update event modal.
- *
- * @module core_calendar/modal_event_form
- * @copyright 2017 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core_calendar/modal_event_form",["jquery","core_form/events","core/str","core/notification","core/templates","core/custom_interaction_events","core/modal","core/modal_registry","core/fragment","core_calendar/events","core_calendar/repository"],(function($,FormEvents,Str,Notification,Templates,CustomEvents,Modal,ModalRegistry,Fragment,CalendarEvents,Repository){var registered=!1,SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_LOADING_ICON_CONTAINER='[data-region="loading-icon-container"]',ModalEventForm=function(root){Modal.call(this,root),this.eventId=null,this.startTime=null,this.courseId=null,this.categoryId=null,this.contextId=null,this.reloadingBody=!1,this.reloadingTitle=!1,this.saveButton=this.getFooter().find(SELECTORS_SAVE_BUTTON)};return ModalEventForm.TYPE="core_calendar-modal_event_form",(ModalEventForm.prototype=Object.create(Modal.prototype)).constructor=ModalEventForm,ModalEventForm.prototype.setContextId=function(id){this.contextId=id},ModalEventForm.prototype.getContextId=function(){return this.contextId},ModalEventForm.prototype.setCourseId=function(id){this.courseId=id},ModalEventForm.prototype.getCourseId=function(){return this.courseId},ModalEventForm.prototype.setCategoryId=function(id){this.categoryId=id},ModalEventForm.prototype.getCategoryId=function(){return this.categoryId},ModalEventForm.prototype.hasCourseId=function(){return null!==this.courseId},ModalEventForm.prototype.hasCategoryId=function(){return null!==this.categoryId},ModalEventForm.prototype.setEventId=function(id){this.eventId=id},ModalEventForm.prototype.getEventId=function(){return this.eventId},ModalEventForm.prototype.hasEventId=function(){return null!==this.eventId},ModalEventForm.prototype.setStartTime=function(time){this.startTime=time},ModalEventForm.prototype.getStartTime=function(){return this.startTime},ModalEventForm.prototype.hasStartTime=function(){return null!==this.startTime},ModalEventForm.prototype.getForm=function(){return this.getBody().find("form")},ModalEventForm.prototype.disableButtons=function(){this.saveButton.prop("disabled",!0)},ModalEventForm.prototype.enableButtons=function(){this.saveButton.prop("disabled",!1)},ModalEventForm.prototype.reloadTitleContent=function(){return this.reloadingTitle||(this.reloadingTitle=!0,this.hasEventId()?this.titlePromise=Str.get_string("editevent","calendar"):this.titlePromise=Str.get_string("newevent","calendar"),this.titlePromise.then(function(string){return this.setTitle(string),string}.bind(this)).always(function(){this.reloadingTitle=!1}.bind(this)).fail(Notification.exception)),this.titlePromise},ModalEventForm.prototype.reloadBodyContent=function(formData){if(this.reloadingBody)return this.bodyPromise;this.reloadingBody=!0,this.disableButtons();var args={};return this.hasEventId()&&(args.eventid=this.getEventId()),this.hasStartTime()&&(args.starttime=this.getStartTime()),this.hasCourseId()&&(args.courseid=this.getCourseId()),this.hasCategoryId()&&(args.categoryid=this.getCategoryId()),void 0!==formData&&(args.formdata=formData),this.bodyPromise=Fragment.loadFragment("calendar","event_form",this.getContextId(),args),this.setBody(this.bodyPromise),this.bodyPromise.then(function(){this.enableButtons()}.bind(this)).fail(Notification.exception).always(function(){this.reloadingBody=!1}.bind(this)).fail(Notification.exception),this.bodyPromise},ModalEventForm.prototype.reloadAllContent=function(){return $.when(this.reloadTitleContent(),this.reloadBodyContent())},ModalEventForm.prototype.show=function(){this.reloadAllContent(),Modal.prototype.show.call(this)},ModalEventForm.prototype.hide=function(){Modal.prototype.hide.call(this),this.setEventId(null),this.setStartTime(null),this.setCourseId(null),this.setCategoryId(null)},ModalEventForm.prototype.getFormData=function(){return this.getForm().serialize()},ModalEventForm.prototype.save=function(){var invalid,loadingContainer=this.saveButton.find(SELECTORS_LOADING_ICON_CONTAINER);if((invalid=this.getForm().find('[aria-invalid="true"]')).length)return invalid.first().focus(),Promise.resolve();loadingContainer.removeClass("hidden"),this.disableButtons();var formData=this.getFormData();return Repository.submitCreateUpdateForm(formData).then(function(response){if(response.validationerror)this.reloadBodyContent(formData);else{var isExisting=this.hasEventId();this.hide(),isExisting?$("body").trigger(CalendarEvents.updated,[response.event]):$("body").trigger(CalendarEvents.created,[response.event])}}.bind(this)).always(function(){loadingContainer.addClass("hidden"),this.enableButtons()}.bind(this)).fail(Notification.exception)},ModalEventForm.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,function(e,data){this.getForm().submit(),data.originalEvent.preventDefault(),e.stopPropagation()}.bind(this)),this.getModal().on("submit",function(e){FormEvents.notifyFormSubmittedByJavascript(this.getForm()[0]),this.save(),e.preventDefault(),e.stopPropagation()}.bind(this))},registered||(ModalRegistry.register(ModalEventForm.TYPE,ModalEventForm,"calendar/modal_event_form"),registered=!0),ModalEventForm}));
+define("core_calendar/modal_event_form",["exports","jquery","core/custom_interaction_events","core/modal","core_form/events","./events","core/str","core/notification","core/fragment","core_calendar/repository"],(function(_exports,_jquery,CustomEvents,_modal,FormEvents,_events2,Str,Notification,Fragment,Repository){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),CustomEvents=_interopRequireWildcard(CustomEvents),_modal=_interopRequireDefault(_modal),FormEvents=_interopRequireWildcard(FormEvents),_events2=_interopRequireDefault(_events2),Str=_interopRequireWildcard(Str),Notification=_interopRequireWildcard(Notification),Fragment=_interopRequireWildcard(Fragment),Repository=_interopRequireWildcard(Repository);const SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_LOADING_ICON_CONTAINER='[data-region="loading-icon-container"]';class ModalEventForm extends _modal.default{constructor(root){super(root),this.eventId=null,this.startTime=null,this.courseId=null,this.categoryId=null,this.contextId=null,this.reloadingBody=!1,this.reloadingTitle=!1,this.saveButton=this.getFooter().find(SELECTORS_SAVE_BUTTON)}setContextId(id){this.contextId=id}getContextId(){return this.contextId}setCourseId(id){this.courseId=id}getCourseId(){return this.courseId}setCategoryId(id){this.categoryId=id}getCategoryId(){return this.categoryId}hasCourseId(){return null!==this.courseId}hasCategoryId(){return null!==this.categoryId}setEventId(id){this.eventId=id}getEventId(){return this.eventId}hasEventId(){return null!==this.eventId}setStartTime(time){this.startTime=time}getStartTime(){return this.startTime}hasStartTime(){return null!==this.startTime}getForm(){return this.getBody().find("form")}disableButtons(){this.saveButton.prop("disabled",!0)}enableButtons(){this.saveButton.prop("disabled",!1)}reloadTitleContent(){return this.reloadingTitle||(this.reloadingTitle=!0,this.hasEventId()?this.titlePromise=Str.get_string("editevent","calendar"):this.titlePromise=Str.get_string("newevent","calendar"),this.titlePromise.then((string=>(this.setTitle(string),string))).catch(Notification.exception).always((()=>{this.reloadingTitle=!1}))),this.titlePromise}reloadBodyContent(formData){if(this.reloadingBody)return this.bodyPromise;this.reloadingBody=!0,this.disableButtons();const args={};return this.hasEventId()&&(args.eventid=this.getEventId()),this.hasStartTime()&&(args.starttime=this.getStartTime()),this.hasCourseId()&&(args.courseid=this.getCourseId()),this.hasCategoryId()&&(args.categoryid=this.getCategoryId()),void 0!==formData&&(args.formdata=formData),this.bodyPromise=Fragment.loadFragment("calendar","event_form",this.getContextId(),args),this.setBody(this.bodyPromise),this.bodyPromise.then((()=>{this.enableButtons()})).catch(Notification.exception).always((()=>{this.reloadingBody=!1})),this.bodyPromise}reloadAllContent(){return _jquery.default.when(this.reloadTitleContent(),this.reloadBodyContent())}show(){this.reloadAllContent(),super.show(this)}hide(){super.hide(this),this.setEventId(null),this.setStartTime(null),this.setCourseId(null),this.setCategoryId(null)}getFormData(){return this.getForm().serialize()}save(){const loadingContainer=this.saveButton.find(SELECTORS_LOADING_ICON_CONTAINER),invalid=this.getForm().find('[aria-invalid="true"]');if(invalid.length)return invalid.first().focus(),Promise.resolve();loadingContainer.removeClass("hidden"),this.disableButtons();const formData=this.getFormData();return Repository.submitCreateUpdateForm(formData).then((response=>{if(response.validationerror)this.reloadBodyContent(formData);else{const isExisting=this.hasEventId();this.hide(),isExisting?(0,_jquery.default)("body").trigger(_events2.default.updated,[response.event]):(0,_jquery.default)("body").trigger(_events2.default.created,[response.event])}})).catch(Notification.exception).always((()=>{loadingContainer.addClass("hidden"),this.enableButtons()}))}registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,((e,data)=>{this.getForm().submit(),data.originalEvent.preventDefault(),e.stopPropagation()})),this.getModal().on("submit",(e=>{FormEvents.notifyFormSubmittedByJavascript(this.getForm()[0]),this.save(),e.preventDefault(),e.stopPropagation()}))}}return _exports.default=ModalEventForm,_defineProperty(ModalEventForm,"TYPE","core_calendar-modal_event_form"),_defineProperty(ModalEventForm,"TEMPLATE","calendar/modal_event_form"),ModalEventForm.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_event_form.min.js.map
\ No newline at end of file
diff --git a/calendar/amd/build/modal_event_form.min.js.map b/calendar/amd/build/modal_event_form.min.js.map
index 20ec5c3603a..79790b47882 100644
--- a/calendar/amd/build/modal_event_form.min.js.map
+++ b/calendar/amd/build/modal_event_form.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_event_form.min.js","sources":["../src/modal_event_form.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the quick add or update event modal.\n *\n * @module core_calendar/modal_event_form\n * @copyright 2017 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core_form/events',\n 'core/str',\n 'core/notification',\n 'core/templates',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/fragment',\n 'core_calendar/events',\n 'core_calendar/repository'\n],\nfunction(\n $,\n FormEvents,\n Str,\n Notification,\n Templates,\n CustomEvents,\n Modal,\n ModalRegistry,\n Fragment,\n CalendarEvents,\n Repository\n) {\n var registered = false;\n var SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n LOADING_ICON_CONTAINER: '[data-region=\"loading-icon-container\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalEventForm = function(root) {\n Modal.call(this, root);\n this.eventId = null;\n this.startTime = null;\n this.courseId = null;\n this.categoryId = null;\n this.contextId = null;\n this.reloadingBody = false;\n this.reloadingTitle = false;\n this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);\n };\n\n ModalEventForm.TYPE = 'core_calendar-modal_event_form';\n ModalEventForm.prototype = Object.create(Modal.prototype);\n ModalEventForm.prototype.constructor = ModalEventForm;\n\n /**\n * Set the context id to the given value.\n *\n * @method setContextId\n * @param {Number} id The event id\n */\n ModalEventForm.prototype.setContextId = function(id) {\n this.contextId = id;\n };\n\n /**\n * Retrieve the current context id, if any.\n *\n * @method getContextId\n * @return {Number|null} The event id\n */\n ModalEventForm.prototype.getContextId = function() {\n return this.contextId;\n };\n\n /**\n * Set the course id to the given value.\n *\n * @method setCourseId\n * @param {int} id The event id\n */\n ModalEventForm.prototype.setCourseId = function(id) {\n this.courseId = id;\n };\n\n /**\n * Retrieve the current course id, if any.\n *\n * @method getCourseId\n * @return {int|null} The event id\n */\n ModalEventForm.prototype.getCourseId = function() {\n return this.courseId;\n };\n\n /**\n * Set the category id to the given value.\n *\n * @method setCategoryId\n * @param {int} id The event id\n */\n ModalEventForm.prototype.setCategoryId = function(id) {\n this.categoryId = id;\n };\n\n /**\n * Retrieve the current category id, if any.\n *\n * @method getCategoryId\n * @return {int|null} The event id\n */\n ModalEventForm.prototype.getCategoryId = function() {\n return this.categoryId;\n };\n\n /**\n * Check if the modal has an course id.\n *\n * @method hasCourseId\n * @return {bool}\n */\n ModalEventForm.prototype.hasCourseId = function() {\n return this.courseId !== null;\n };\n\n /**\n * Check if the modal has an category id.\n *\n * @method hasCategoryId\n * @return {bool}\n */\n ModalEventForm.prototype.hasCategoryId = function() {\n return this.categoryId !== null;\n };\n\n /**\n * Set the event id to the given value.\n *\n * @method setEventId\n * @param {int} id The event id\n */\n ModalEventForm.prototype.setEventId = function(id) {\n this.eventId = id;\n };\n\n /**\n * Retrieve the current event id, if any.\n *\n * @method getEventId\n * @return {int|null} The event id\n */\n ModalEventForm.prototype.getEventId = function() {\n return this.eventId;\n };\n\n /**\n * Check if the modal has an event id.\n *\n * @method hasEventId\n * @return {bool}\n */\n ModalEventForm.prototype.hasEventId = function() {\n return this.eventId !== null;\n };\n\n /**\n * Set the start time to the given value.\n *\n * @method setStartTime\n * @param {int} time The start time\n */\n ModalEventForm.prototype.setStartTime = function(time) {\n this.startTime = time;\n };\n\n /**\n * Retrieve the current start time, if any.\n *\n * @method getStartTime\n * @return {int|null} The start time\n */\n ModalEventForm.prototype.getStartTime = function() {\n return this.startTime;\n };\n\n /**\n * Check if the modal has start time.\n *\n * @method hasStartTime\n * @return {bool}\n */\n ModalEventForm.prototype.hasStartTime = function() {\n return this.startTime !== null;\n };\n\n /**\n * Get the form element from the modal.\n *\n * @method getForm\n * @return {object}\n */\n ModalEventForm.prototype.getForm = function() {\n return this.getBody().find('form');\n };\n\n /**\n * Disable the buttons in the footer.\n *\n * @method disableButtons\n */\n ModalEventForm.prototype.disableButtons = function() {\n this.saveButton.prop('disabled', true);\n };\n\n /**\n * Enable the buttons in the footer.\n *\n * @method enableButtons\n */\n ModalEventForm.prototype.enableButtons = function() {\n this.saveButton.prop('disabled', false);\n };\n\n /**\n * Reload the title for the modal to the appropriate value\n * depending on whether we are creating a new event or\n * editing an existing event.\n *\n * @method reloadTitleContent\n * @return {object} A promise resolved with the new title text\n */\n ModalEventForm.prototype.reloadTitleContent = function() {\n if (this.reloadingTitle) {\n return this.titlePromise;\n }\n\n this.reloadingTitle = true;\n\n if (this.hasEventId()) {\n this.titlePromise = Str.get_string('editevent', 'calendar');\n } else {\n this.titlePromise = Str.get_string('newevent', 'calendar');\n }\n\n this.titlePromise.then(function(string) {\n this.setTitle(string);\n return string;\n }.bind(this))\n .always(function() {\n this.reloadingTitle = false;\n return;\n }.bind(this))\n .fail(Notification.exception);\n\n return this.titlePromise;\n };\n\n /**\n * Send a request to the server to get the event_form in a fragment\n * and render the result in the body of the modal.\n *\n * If serialised form data is provided then it will be sent in the\n * request to the server to have the form rendered with the data. This\n * is used when the form had a server side error and we need the server\n * to re-render it for us to display the error to the user.\n *\n * @method reloadBodyContent\n * @param {string} formData The serialised form data\n * @return {object} A promise resolved with the fragment html and js from\n */\n ModalEventForm.prototype.reloadBodyContent = function(formData) {\n if (this.reloadingBody) {\n return this.bodyPromise;\n }\n\n this.reloadingBody = true;\n this.disableButtons();\n\n var args = {};\n\n if (this.hasEventId()) {\n args.eventid = this.getEventId();\n }\n\n if (this.hasStartTime()) {\n args.starttime = this.getStartTime();\n }\n\n if (this.hasCourseId()) {\n args.courseid = this.getCourseId();\n }\n\n if (this.hasCategoryId()) {\n args.categoryid = this.getCategoryId();\n }\n\n if (typeof formData !== 'undefined') {\n args.formdata = formData;\n }\n\n this.bodyPromise = Fragment.loadFragment('calendar', 'event_form', this.getContextId(), args);\n\n this.setBody(this.bodyPromise);\n\n this.bodyPromise.then(function() {\n this.enableButtons();\n return;\n }.bind(this))\n .fail(Notification.exception)\n .always(function() {\n this.reloadingBody = false;\n return;\n }.bind(this))\n .fail(Notification.exception);\n\n return this.bodyPromise;\n };\n\n /**\n * Reload both the title and body content.\n *\n * @method reloadAllContent\n * @return {object} promise\n */\n ModalEventForm.prototype.reloadAllContent = function() {\n return $.when(this.reloadTitleContent(), this.reloadBodyContent());\n };\n\n /**\n * Kick off a reload the modal content before showing it. This\n * is to allow us to re-use the same modal for creating and\n * editing different events within the page.\n *\n * We do the reload when showing the modal rather than hiding it\n * to save a request to the server if the user closes the modal\n * and never re-opens it.\n *\n * @method show\n */\n ModalEventForm.prototype.show = function() {\n this.reloadAllContent();\n Modal.prototype.show.call(this);\n };\n\n /**\n * Clear the event id from the modal when it's closed so\n * that it is loaded fresh next time it's displayed.\n *\n * The event id will be set by the calling code if it wants\n * to edit a specific event.\n *\n * @method hide\n */\n ModalEventForm.prototype.hide = function() {\n Modal.prototype.hide.call(this);\n this.setEventId(null);\n this.setStartTime(null);\n this.setCourseId(null);\n this.setCategoryId(null);\n };\n\n /**\n * Get the serialised form data.\n *\n * @method getFormData\n * @return {string} serialised form data\n */\n ModalEventForm.prototype.getFormData = function() {\n return this.getForm().serialize();\n };\n\n /**\n * Send the form data to the server to create or update\n * an event.\n *\n * If there is a server side validation error then we re-request the\n * rendered form (with the data) from the server in order to get the\n * server side errors to display.\n *\n * On success the modal is hidden and the page is reloaded so that the\n * new event will display.\n *\n * @method save\n * @return {object} A promise\n */\n ModalEventForm.prototype.save = function() {\n var invalid,\n loadingContainer = this.saveButton.find(SELECTORS.LOADING_ICON_CONTAINER);\n\n // Now the change events have run, see if there are any \"invalid\" form fields.\n invalid = this.getForm().find('[aria-invalid=\"true\"]');\n\n // If we found invalid fields, focus on the first one and do not submit via ajax.\n if (invalid.length) {\n invalid.first().focus();\n return Promise.resolve();\n }\n\n loadingContainer.removeClass('hidden');\n this.disableButtons();\n\n var formData = this.getFormData();\n // Send the form data to the server for processing.\n return Repository.submitCreateUpdateForm(formData)\n .then(function(response) {\n if (response.validationerror) {\n // If there was a server side validation error then\n // we need to re-request the rendered form from the server\n // in order to display the error for the user.\n this.reloadBodyContent(formData);\n return;\n } else {\n // Check whether this was a new event or not.\n // The hide function unsets the form data so grab this before the hide.\n var isExisting = this.hasEventId();\n\n // No problemo! Our work here is done.\n this.hide();\n\n // Trigger the appropriate calendar event so that the view can be updated.\n if (isExisting) {\n $('body').trigger(CalendarEvents.updated, [response.event]);\n } else {\n $('body').trigger(CalendarEvents.created, [response.event]);\n }\n }\n\n return;\n }.bind(this))\n .always(function() {\n // Regardless of success or error we should always stop\n // the loading icon and re-enable the buttons.\n loadingContainer.addClass('hidden');\n this.enableButtons();\n\n return;\n }.bind(this))\n .fail(Notification.exception);\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n * @fires event:uploadStarted\n * @fires event:formSubmittedByJavascript\n */\n ModalEventForm.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // When the user clicks the save button we trigger the form submission. We need to\n // trigger an actual submission because there is some JS code in the form that is\n // listening for this event and doing some stuff (e.g. saving draft areas etc).\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(e, data) {\n this.getForm().submit();\n data.originalEvent.preventDefault();\n e.stopPropagation();\n }.bind(this));\n\n // Catch the submit event before it is actually processed by the browser and\n // prevent the submission. We'll take it from here.\n this.getModal().on('submit', function(e) {\n FormEvents.notifyFormSubmittedByJavascript(this.getForm()[0]);\n\n this.save();\n\n // Stop the form from actually submitting and prevent it's\n // propagation because we have already handled the event.\n e.preventDefault();\n e.stopPropagation();\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalEventForm.TYPE, ModalEventForm, 'calendar/modal_event_form');\n registered = true;\n }\n\n return ModalEventForm;\n});\n"],"names":["define","$","FormEvents","Str","Notification","Templates","CustomEvents","Modal","ModalRegistry","Fragment","CalendarEvents","Repository","registered","SELECTORS","ModalEventForm","root","call","this","eventId","startTime","courseId","categoryId","contextId","reloadingBody","reloadingTitle","saveButton","getFooter","find","TYPE","prototype","Object","create","constructor","setContextId","id","getContextId","setCourseId","getCourseId","setCategoryId","getCategoryId","hasCourseId","hasCategoryId","setEventId","getEventId","hasEventId","setStartTime","time","getStartTime","hasStartTime","getForm","getBody","disableButtons","prop","enableButtons","reloadTitleContent","titlePromise","get_string","then","string","setTitle","bind","always","fail","exception","reloadBodyContent","formData","bodyPromise","args","eventid","starttime","courseid","categoryid","formdata","loadFragment","setBody","reloadAllContent","when","show","hide","getFormData","serialize","save","invalid","loadingContainer","length","first","focus","Promise","resolve","removeClass","submitCreateUpdateForm","response","validationerror","isExisting","trigger","updated","event","created","addClass","registerEventListeners","getModal","on","events","activate","e","data","submit","originalEvent","preventDefault","stopPropagation","notifyFormSubmittedByJavascript","register"],"mappings":";;;;;;;AAsBAA,wCAAO,CACH,SACA,mBACA,WACA,oBACA,iBACA,iCACA,aACA,sBACA,gBACA,uBACA,6BAEJ,SACIC,EACAC,WACAC,IACAC,aACAC,UACAC,aACAC,MACAC,cACAC,SACAC,eACAC,gBAEIC,YAAa,EACbC,sBACa,uBADbA,iCAEwB,yCAQxBC,eAAiB,SAASC,MAC1BR,MAAMS,KAAKC,KAAMF,WACZG,QAAU,UACVC,UAAY,UACZC,SAAW,UACXC,WAAa,UACbC,UAAY,UACZC,eAAgB,OAChBC,gBAAiB,OACjBC,WAAaR,KAAKS,YAAYC,KAAKd,+BAG5CC,eAAec,KAAO,kCACtBd,eAAee,UAAYC,OAAOC,OAAOxB,MAAMsB,YACtBG,YAAclB,eAQvCA,eAAee,UAAUI,aAAe,SAASC,SACxCZ,UAAYY,IASrBpB,eAAee,UAAUM,aAAe,kBAC7BlB,KAAKK,WAShBR,eAAee,UAAUO,YAAc,SAASF,SACvCd,SAAWc,IASpBpB,eAAee,UAAUQ,YAAc,kBAC5BpB,KAAKG,UAShBN,eAAee,UAAUS,cAAgB,SAASJ,SACzCb,WAAaa,IAStBpB,eAAee,UAAUU,cAAgB,kBAC9BtB,KAAKI,YAShBP,eAAee,UAAUW,YAAc,kBACV,OAAlBvB,KAAKG,UAShBN,eAAee,UAAUY,cAAgB,kBACV,OAApBxB,KAAKI,YAShBP,eAAee,UAAUa,WAAa,SAASR,SACtChB,QAAUgB,IASnBpB,eAAee,UAAUc,WAAa,kBAC3B1B,KAAKC,SAShBJ,eAAee,UAAUe,WAAa,kBACV,OAAjB3B,KAAKC,SAShBJ,eAAee,UAAUgB,aAAe,SAASC,WACxC3B,UAAY2B,MASrBhC,eAAee,UAAUkB,aAAe,kBAC7B9B,KAAKE,WAShBL,eAAee,UAAUmB,aAAe,kBACV,OAAnB/B,KAAKE,WAShBL,eAAee,UAAUoB,QAAU,kBACxBhC,KAAKiC,UAAUvB,KAAK,SAQ/Bb,eAAee,UAAUsB,eAAiB,gBACjC1B,WAAW2B,KAAK,YAAY,IAQrCtC,eAAee,UAAUwB,cAAgB,gBAChC5B,WAAW2B,KAAK,YAAY,IAWrCtC,eAAee,UAAUyB,mBAAqB,kBACtCrC,KAAKO,sBAIJA,gBAAiB,EAElBP,KAAK2B,kBACAW,aAAepD,IAAIqD,WAAW,YAAa,iBAE3CD,aAAepD,IAAIqD,WAAW,WAAY,iBAG9CD,aAAaE,KAAK,SAASC,oBACvBC,SAASD,QACPA,QACTE,KAAK3C,OACN4C,OAAO,gBACCrC,gBAAiB,GAExBoC,KAAK3C,OACN6C,KAAK1D,aAAa2D,YAnBR9C,KAAKsC,cAqCpBzC,eAAee,UAAUmC,kBAAoB,SAASC,aAC9ChD,KAAKM,qBACEN,KAAKiD,iBAGX3C,eAAgB,OAChB4B,qBAEDgB,KAAO,UAEPlD,KAAK2B,eACLuB,KAAKC,QAAUnD,KAAK0B,cAGpB1B,KAAK+B,iBACLmB,KAAKE,UAAYpD,KAAK8B,gBAGtB9B,KAAKuB,gBACL2B,KAAKG,SAAWrD,KAAKoB,eAGrBpB,KAAKwB,kBACL0B,KAAKI,WAAatD,KAAKsB,sBAGH,IAAb0B,WACPE,KAAKK,SAAWP,eAGfC,YAAczD,SAASgE,aAAa,WAAY,aAAcxD,KAAKkB,eAAgBgC,WAEnFO,QAAQzD,KAAKiD,kBAEbA,YAAYT,KAAK,gBACbJ,iBAEPO,KAAK3C,OACN6C,KAAK1D,aAAa2D,WAClBF,OAAO,gBACCtC,eAAgB,GAEvBqC,KAAK3C,OACN6C,KAAK1D,aAAa2D,WAEZ9C,KAAKiD,aAShBpD,eAAee,UAAU8C,iBAAmB,kBACjC1E,EAAE2E,KAAK3D,KAAKqC,qBAAsBrC,KAAK+C,sBAclDlD,eAAee,UAAUgD,KAAO,gBACvBF,mBACLpE,MAAMsB,UAAUgD,KAAK7D,KAAKC,OAY9BH,eAAee,UAAUiD,KAAO,WAC5BvE,MAAMsB,UAAUiD,KAAK9D,KAAKC,WACrByB,WAAW,WACXG,aAAa,WACbT,YAAY,WACZE,cAAc,OASvBxB,eAAee,UAAUkD,YAAc,kBAC5B9D,KAAKgC,UAAU+B,aAiB1BlE,eAAee,UAAUoD,KAAO,eACxBC,QACAC,iBAAmBlE,KAAKQ,WAAWE,KAAKd,sCAG5CqE,QAAUjE,KAAKgC,UAAUtB,KAAK,0BAGlByD,cACRF,QAAQG,QAAQC,QACTC,QAAQC,UAGnBL,iBAAiBM,YAAY,eACxBtC,qBAEDc,SAAWhD,KAAK8D,qBAEbpE,WAAW+E,uBAAuBzB,UACpCR,KAAK,SAASkC,aACPA,SAASC,qBAIJ5B,kBAAkBC,mBAKnB4B,WAAa5E,KAAK2B,kBAGjBkC,OAGDe,WACA5F,EAAE,QAAQ6F,QAAQpF,eAAeqF,QAAS,CAACJ,SAASK,QAEpD/F,EAAE,QAAQ6F,QAAQpF,eAAeuF,QAAS,CAACN,SAASK,UAK9DpC,KAAK3C,OACN4C,OAAO,WAGJsB,iBAAiBe,SAAS,eACrB7C,iBAGPO,KAAK3C,OACN6C,KAAK1D,aAAa2D,YAU3BjD,eAAee,UAAUsE,uBAAyB,WAE9C5F,MAAMsB,UAAUsE,uBAAuBnF,KAAKC,WAKvCmF,WAAWC,GAAG/F,aAAagG,OAAOC,SAAU1F,sBAAuB,SAAS2F,EAAGC,WAC3ExD,UAAUyD,SACfD,KAAKE,cAAcC,iBACnBJ,EAAEK,mBACJjD,KAAK3C,YAIFmF,WAAWC,GAAG,SAAU,SAASG,GAClCtG,WAAW4G,gCAAgC7F,KAAKgC,UAAU,SAErDgC,OAILuB,EAAEI,iBACFJ,EAAEK,mBACJjD,KAAK3C,QAKNL,aACDJ,cAAcuG,SAASjG,eAAec,KAAMd,eAAgB,6BAC5DF,YAAa,GAGVE"}
\ No newline at end of file
+{"version":3,"file":"modal_event_form.min.js","sources":["../src/modal_event_form.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the quick add or update event modal.\n *\n * @module core_calendar/modal_event_form\n * @copyright 2017 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport * as FormEvents from 'core_form/events';\nimport CalendarEvents from './events';\nimport * as Str from 'core/str';\nimport * as Notification from 'core/notification';\nimport * as Fragment from 'core/fragment';\nimport * as Repository from 'core_calendar/repository';\n\nconst SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n LOADING_ICON_CONTAINER: '[data-region=\"loading-icon-container\"]',\n};\n\nexport default class ModalEventForm extends Modal {\n static TYPE = 'core_calendar-modal_event_form';\n static TEMPLATE = 'calendar/modal_event_form';\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n constructor(root) {\n super(root);\n\n this.eventId = null;\n this.startTime = null;\n this.courseId = null;\n this.categoryId = null;\n this.contextId = null;\n this.reloadingBody = false;\n this.reloadingTitle = false;\n this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);\n }\n\n /**\n * Set the context id to the given value.\n *\n * @method setContextId\n * @param {Number} id The event id\n */\n setContextId(id) {\n this.contextId = id;\n }\n\n /**\n * Retrieve the current context id, if any.\n *\n * @method getContextId\n * @return {Number|null} The event id\n */\n getContextId() {\n return this.contextId;\n }\n\n /**\n * Set the course id to the given value.\n *\n * @method setCourseId\n * @param {Number} id The event id\n */\n setCourseId(id) {\n this.courseId = id;\n }\n\n /**\n * Retrieve the current course id, if any.\n *\n * @method getCourseId\n * @return {Number|null} The event id\n */\n getCourseId() {\n return this.courseId;\n }\n\n /**\n * Set the category id to the given value.\n *\n * @method setCategoryId\n * @param {Number} id The event id\n */\n setCategoryId(id) {\n this.categoryId = id;\n }\n\n /**\n * Retrieve the current category id, if any.\n *\n * @method getCategoryId\n * @return {Number|null} The event id\n */\n getCategoryId() {\n return this.categoryId;\n }\n\n /**\n * Check if the modal has an course id.\n *\n * @method hasCourseId\n * @return {bool}\n */\n hasCourseId() {\n return this.courseId !== null;\n }\n\n /**\n * Check if the modal has an category id.\n *\n * @method hasCategoryId\n * @return {bool}\n */\n hasCategoryId() {\n return this.categoryId !== null;\n }\n\n /**\n * Set the event id to the given value.\n *\n * @method setEventId\n * @param {Number} id The event id\n */\n setEventId(id) {\n this.eventId = id;\n }\n\n /**\n * Retrieve the current event id, if any.\n *\n * @method getEventId\n * @return {Number|null} The event id\n */\n getEventId() {\n return this.eventId;\n }\n\n /**\n * Check if the modal has an event id.\n *\n * @method hasEventId\n * @return {bool}\n */\n hasEventId() {\n return this.eventId !== null;\n }\n\n /**\n * Set the start time to the given value.\n *\n * @method setStartTime\n * @param {Number} time The start time\n */\n setStartTime(time) {\n this.startTime = time;\n }\n\n /**\n * Retrieve the current start time, if any.\n *\n * @method getStartTime\n * @return {Number|null} The start time\n */\n getStartTime() {\n return this.startTime;\n }\n\n /**\n * Check if the modal has start time.\n *\n * @method hasStartTime\n * @return {bool}\n */\n hasStartTime() {\n return this.startTime !== null;\n }\n\n /**\n * Get the form element from the modal.\n *\n * @method getForm\n * @return {object}\n */\n getForm() {\n return this.getBody().find('form');\n }\n\n /**\n * Disable the buttons in the footer.\n *\n * @method disableButtons\n */\n disableButtons() {\n this.saveButton.prop('disabled', true);\n }\n\n /**\n * Enable the buttons in the footer.\n *\n * @method enableButtons\n */\n enableButtons() {\n this.saveButton.prop('disabled', false);\n }\n\n /**\n * Reload the title for the modal to the appropriate value\n * depending on whether we are creating a new event or\n * editing an existing event.\n *\n * @method reloadTitleContent\n * @return {object} A promise resolved with the new title text\n */\n reloadTitleContent() {\n if (this.reloadingTitle) {\n return this.titlePromise;\n }\n\n this.reloadingTitle = true;\n\n if (this.hasEventId()) {\n this.titlePromise = Str.get_string('editevent', 'calendar');\n } else {\n this.titlePromise = Str.get_string('newevent', 'calendar');\n }\n\n this.titlePromise.then((string) => {\n this.setTitle(string);\n return string;\n })\n .catch(Notification.exception)\n .always(() => {\n this.reloadingTitle = false;\n return;\n });\n\n return this.titlePromise;\n }\n\n /**\n * Send a request to the server to get the event_form in a fragment\n * and render the result in the body of the modal.\n *\n * If serialised form data is provided then it will be sent in the\n * request to the server to have the form rendered with the data. This\n * is used when the form had a server side error and we need the server\n * to re-render it for us to display the error to the user.\n *\n * @method reloadBodyContent\n * @param {string} formData The serialised form data\n * @return {object} A promise resolved with the fragment html and js from\n */\n reloadBodyContent(formData) {\n if (this.reloadingBody) {\n return this.bodyPromise;\n }\n\n this.reloadingBody = true;\n this.disableButtons();\n\n const args = {};\n\n if (this.hasEventId()) {\n args.eventid = this.getEventId();\n }\n\n if (this.hasStartTime()) {\n args.starttime = this.getStartTime();\n }\n\n if (this.hasCourseId()) {\n args.courseid = this.getCourseId();\n }\n\n if (this.hasCategoryId()) {\n args.categoryid = this.getCategoryId();\n }\n\n if (typeof formData !== 'undefined') {\n args.formdata = formData;\n }\n\n this.bodyPromise = Fragment.loadFragment('calendar', 'event_form', this.getContextId(), args);\n\n this.setBody(this.bodyPromise);\n\n this.bodyPromise.then(() => {\n this.enableButtons();\n return;\n })\n .catch(Notification.exception)\n .always(() => {\n this.reloadingBody = false;\n return;\n });\n\n return this.bodyPromise;\n }\n\n /**\n * Reload both the title and body content.\n *\n * @method reloadAllContent\n * @return {object} promise\n */\n reloadAllContent() {\n return $.when(this.reloadTitleContent(), this.reloadBodyContent());\n }\n\n /**\n * Kick off a reload the modal content before showing it. This\n * is to allow us to re-use the same modal for creating and\n * editing different events within the page.\n *\n * We do the reload when showing the modal rather than hiding it\n * to save a request to the server if the user closes the modal\n * and never re-opens it.\n *\n * @method show\n */\n show() {\n this.reloadAllContent();\n super.show(this);\n }\n\n /**\n * Clear the event id from the modal when it's closed so\n * that it is loaded fresh next time it's displayed.\n *\n * The event id will be set by the calling code if it wants\n * to edit a specific event.\n *\n * @method hide\n */\n hide() {\n super.hide(this);\n this.setEventId(null);\n this.setStartTime(null);\n this.setCourseId(null);\n this.setCategoryId(null);\n }\n\n /**\n * Get the serialised form data.\n *\n * @method getFormData\n * @return {string} serialised form data\n */\n getFormData() {\n return this.getForm().serialize();\n }\n\n /**\n * Send the form data to the server to create or update\n * an event.\n *\n * If there is a server side validation error then we re-request the\n * rendered form (with the data) from the server in order to get the\n * server side errors to display.\n *\n * On success the modal is hidden and the page is reloaded so that the\n * new event will display.\n *\n * @method save\n * @return {object} A promise\n */\n save() {\n const loadingContainer = this.saveButton.find(SELECTORS.LOADING_ICON_CONTAINER);\n\n // Now the change events have run, see if there are any \"invalid\" form fields.\n const invalid = this.getForm().find('[aria-invalid=\"true\"]');\n\n // If we found invalid fields, focus on the first one and do not submit via ajax.\n if (invalid.length) {\n invalid.first().focus();\n return Promise.resolve();\n }\n\n loadingContainer.removeClass('hidden');\n this.disableButtons();\n\n const formData = this.getFormData();\n // Send the form data to the server for processing.\n return Repository.submitCreateUpdateForm(formData)\n .then((response) => {\n if (response.validationerror) {\n // If there was a server side validation error then\n // we need to re-request the rendered form from the server\n // in order to display the error for the user.\n this.reloadBodyContent(formData);\n return;\n } else {\n // Check whether this was a new event or not.\n // The hide function unsets the form data so grab this before the hide.\n const isExisting = this.hasEventId();\n\n // No problemo! Our work here is done.\n this.hide();\n\n // Trigger the appropriate calendar event so that the view can be updated.\n if (isExisting) {\n $('body').trigger(CalendarEvents.updated, [response.event]);\n } else {\n $('body').trigger(CalendarEvents.created, [response.event]);\n }\n }\n\n return;\n })\n .catch(Notification.exception)\n .always(() => {\n // Regardless of success or error we should always stop\n // the loading icon and re-enable the buttons.\n loadingContainer.addClass('hidden');\n this.enableButtons();\n\n return;\n });\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n * @fires event:uploadStarted\n * @fires event:formSubmittedByJavascript\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n // When the user clicks the save button we trigger the form submission. We need to\n // trigger an actual submission because there is some JS code in the form that is\n // listening for this event and doing some stuff (e.g. saving draft areas etc).\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, (e, data) => {\n this.getForm().submit();\n data.originalEvent.preventDefault();\n e.stopPropagation();\n });\n\n // Catch the submit event before it is actually processed by the browser and\n // prevent the submission. We'll take it from here.\n this.getModal().on('submit', (e) => {\n FormEvents.notifyFormSubmittedByJavascript(this.getForm()[0]);\n\n this.save();\n\n // Stop the form from actually submitting and prevent it's\n // propagation because we have already handled the event.\n e.preventDefault();\n e.stopPropagation();\n });\n }\n}\n\nModalEventForm.registerModalType();\n"],"names":["SELECTORS","ModalEventForm","Modal","constructor","root","eventId","startTime","courseId","categoryId","contextId","reloadingBody","reloadingTitle","saveButton","this","getFooter","find","setContextId","id","getContextId","setCourseId","getCourseId","setCategoryId","getCategoryId","hasCourseId","hasCategoryId","setEventId","getEventId","hasEventId","setStartTime","time","getStartTime","hasStartTime","getForm","getBody","disableButtons","prop","enableButtons","reloadTitleContent","titlePromise","Str","get_string","then","string","setTitle","catch","Notification","exception","always","reloadBodyContent","formData","bodyPromise","args","eventid","starttime","courseid","categoryid","formdata","Fragment","loadFragment","setBody","reloadAllContent","$","when","show","hide","getFormData","serialize","save","loadingContainer","invalid","length","first","focus","Promise","resolve","removeClass","Repository","submitCreateUpdateForm","response","validationerror","isExisting","trigger","CalendarEvents","updated","event","created","addClass","registerEventListeners","getModal","on","CustomEvents","events","activate","e","data","submit","originalEvent","preventDefault","stopPropagation","FormEvents","notifyFormSubmittedByJavascript","registerModalType"],"mappings":"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"}
\ No newline at end of file
diff --git a/calendar/amd/build/summary_modal.min.js b/calendar/amd/build/summary_modal.min.js
index 8d8df71f258..b7750d06e08 100644
--- a/calendar/amd/build/summary_modal.min.js
+++ b/calendar/amd/build/summary_modal.min.js
@@ -1,10 +1,3 @@
-/**
- * A javascript module to handle summary modal.
- *
- * @module core_calendar/summary_modal
- * @copyright 2017 Simey Lameze
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core_calendar/summary_modal",["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/repository","core_calendar/events","core_calendar/crud"],(function($,Str,Notification,CustomEvents,Modal,ModalRegistry,ModalFactory,ModalEvents,CalendarRepository,CalendarEvents,CalendarCrud){var registered=!1,SELECTORS_ROOT="[data-region='summary-modal-container']",SELECTORS_EDIT_BUTTON='[data-action="edit"]',SELECTORS_DELETE_BUTTON='[data-action="delete"]',ModalEventSummary=function(root){Modal.call(this,root)};return ModalEventSummary.TYPE="core_calendar-event_summary",(ModalEventSummary.prototype=Object.create(Modal.prototype)).constructor=ModalEventSummary,ModalEventSummary.prototype.getEditButton=function(){return void 0===this.editButton&&(this.editButton=this.getFooter().find(SELECTORS_EDIT_BUTTON)),this.editButton},ModalEventSummary.prototype.getDeleteButton=function(){return void 0===this.deleteButton&&(this.deleteButton=this.getFooter().find(SELECTORS_DELETE_BUTTON)),this.deleteButton},ModalEventSummary.prototype.getEventId=function(){return this.getBody().find(SELECTORS_ROOT).attr("data-event-id")},ModalEventSummary.prototype.getEventTitle=function(){return this.getBody().find(SELECTORS_ROOT).attr("data-event-title")},ModalEventSummary.prototype.getEventCount=function(){return this.getBody().find(SELECTORS_ROOT).attr("data-event-count")},ModalEventSummary.prototype.getEditUrl=function(){return this.getBody().find(SELECTORS_ROOT).attr("data-edit-url")},ModalEventSummary.prototype.isActionEvent=function(){return"true"==this.getBody().find(SELECTORS_ROOT).attr("data-action-event")},ModalEventSummary.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),M.util.js_pending("core_calendar/summary_modal:registerEventListeners:bodyRendered"),this.getRoot().on(ModalEvents.bodyRendered,function(){this.getModal().data({eventTitle:this.getEventTitle(),eventId:this.getEventId(),eventCount:this.getEventCount()}).attr("data-type","event"),CalendarCrud.registerRemove(this.getModal()),M.util.js_complete("core_calendar/summary_modal:registerEventListeners:bodyRendered")}.bind(this)),$("body").on(CalendarEvents.deleted,function(){this.hide()}.bind(this)),CustomEvents.define(this.getEditButton(),[CustomEvents.events.activate]),this.getEditButton().on(CustomEvents.events.activate,function(e,data){this.isActionEvent()?$("body").trigger(CalendarEvents.editActionEvent,[this.getEditUrl()]):$("body").trigger(CalendarEvents.editEvent,[this.getEventId()]),this.hide(),e.preventDefault(),e.stopPropagation(),data.originalEvent.preventDefault(),data.originalEvent.stopPropagation()}.bind(this))},registered||(ModalRegistry.register(ModalEventSummary.TYPE,ModalEventSummary,"core_calendar/event_summary_modal"),registered=!0),ModalEventSummary}));
+define("core_calendar/summary_modal",["exports","jquery","core/custom_interaction_events","core/modal","./events","core_calendar/crud","core/modal_events"],(function(_exports,_jquery,CustomEvents,_modal,_events,CalendarCrud,ModalEvents){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),CustomEvents=_interopRequireWildcard(CustomEvents),_modal=_interopRequireDefault(_modal),_events=_interopRequireDefault(_events),CalendarCrud=_interopRequireWildcard(CalendarCrud),ModalEvents=_interopRequireWildcard(ModalEvents);const SELECTORS_ROOT="[data-region='summary-modal-container']",SELECTORS_EDIT_BUTTON='[data-action="edit"]',SELECTORS_DELETE_BUTTON='[data-action="delete"]';class ModalEventSummary extends _modal.default{getEditButton(){return void 0===this.editButton&&(this.editButton=this.getFooter().find(SELECTORS_EDIT_BUTTON)),this.editButton}getDeleteButton(){return void 0===this.deleteButton&&(this.deleteButton=this.getFooter().find(SELECTORS_DELETE_BUTTON)),this.deleteButton}getEventId(){return this.getBody().find(SELECTORS_ROOT).attr("data-event-id")}getEventTitle(){return this.getBody().find(SELECTORS_ROOT).attr("data-event-title")}getEventCount(){return this.getBody().find(SELECTORS_ROOT).attr("data-event-count")}getEditUrl(){return this.getBody().find(SELECTORS_ROOT).attr("data-edit-url")}isActionEvent(){return"true"==this.getBody().find(SELECTORS_ROOT).attr("data-action-event")}registerEventListeners(){super.registerEventListeners(this),M.util.js_pending("core_calendar/summary_modal:registerEventListeners:bodyRendered"),this.getRoot().on(ModalEvents.bodyRendered,function(){this.getModal().data({eventTitle:this.getEventTitle(),eventId:this.getEventId(),eventCount:this.getEventCount()}).attr("data-type","event"),CalendarCrud.registerRemove(this.getModal()),M.util.js_complete("core_calendar/summary_modal:registerEventListeners:bodyRendered")}.bind(this)),(0,_jquery.default)("body").on(_events.default.deleted,function(){this.hide()}.bind(this)),CustomEvents.define(this.getEditButton(),[CustomEvents.events.activate]),this.getEditButton().on(CustomEvents.events.activate,function(e,data){this.isActionEvent()?(0,_jquery.default)("body").trigger(_events.default.editActionEvent,[this.getEditUrl()]):(0,_jquery.default)("body").trigger(_events.default.editEvent,[this.getEventId()]),this.hide(),e.preventDefault(),e.stopPropagation(),data.originalEvent.preventDefault(),data.originalEvent.stopPropagation()}.bind(this))}}return _exports.default=ModalEventSummary,_defineProperty(ModalEventSummary,"TEMPLATE","core_calendar/event_summary_modal"),_defineProperty(ModalEventSummary,"TYPE","core_calendar-event_summary"),ModalEventSummary.registerModalType(),_exports.default}));
//# sourceMappingURL=summary_modal.min.js.map
\ No newline at end of file
diff --git a/calendar/amd/build/summary_modal.min.js.map b/calendar/amd/build/summary_modal.min.js.map
index 423c4ada941..24b4e852ad7 100644
--- a/calendar/amd/build/summary_modal.min.js.map
+++ b/calendar/amd/build/summary_modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"summary_modal.min.js","sources":["../src/summary_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A javascript module to handle summary modal.\n *\n * @module core_calendar/summary_modal\n * @copyright 2017 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/str',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/modal_factory',\n 'core/modal_events',\n 'core_calendar/repository',\n 'core_calendar/events',\n 'core_calendar/crud',\n],\nfunction(\n $,\n Str,\n Notification,\n CustomEvents,\n Modal,\n ModalRegistry,\n ModalFactory,\n ModalEvents,\n CalendarRepository,\n CalendarEvents,\n CalendarCrud\n) {\n\n var registered = false;\n var SELECTORS = {\n ROOT: \"[data-region='summary-modal-container']\",\n EDIT_BUTTON: '[data-action=\"edit\"]',\n DELETE_BUTTON: '[data-action=\"delete\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalEventSummary = function(root) {\n Modal.call(this, root);\n };\n\n ModalEventSummary.TYPE = 'core_calendar-event_summary';\n ModalEventSummary.prototype = Object.create(Modal.prototype);\n ModalEventSummary.prototype.constructor = ModalEventSummary;\n\n /**\n * Get the edit button element from the footer. The button is cached\n * as it's not expected to change.\n *\n * @method getEditButton\n * @return {object} button element\n */\n ModalEventSummary.prototype.getEditButton = function() {\n if (typeof this.editButton == 'undefined') {\n this.editButton = this.getFooter().find(SELECTORS.EDIT_BUTTON);\n }\n\n return this.editButton;\n };\n\n /**\n * Get the delete button element from the footer. The button is cached\n * as it's not expected to change.\n *\n * @method getDeleteButton\n * @return {object} button element\n */\n ModalEventSummary.prototype.getDeleteButton = function() {\n if (typeof this.deleteButton == 'undefined') {\n this.deleteButton = this.getFooter().find(SELECTORS.DELETE_BUTTON);\n }\n\n return this.deleteButton;\n };\n\n /**\n * Get the id for the event being shown in this modal. This value is\n * not cached because it will change depending on which event is\n * being displayed.\n *\n * @method getEventId\n * @return {int}\n */\n ModalEventSummary.prototype.getEventId = function() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-id');\n };\n\n /**\n * Get the title for the event being shown in this modal. This value is\n * not cached because it will change depending on which event is\n * being displayed.\n *\n * @method getEventTitle\n * @return {String}\n */\n ModalEventSummary.prototype.getEventTitle = function() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-title');\n };\n\n /**\n * Get the number of events in the series for the event being shown in\n * this modal. This value is not cached because it will change\n * depending on which event is being displayed.\n *\n * @method getEventCount\n * @return {int}\n */\n ModalEventSummary.prototype.getEventCount = function() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-count');\n };\n\n /**\n * Get the url for the event being shown in this modal.\n *\n * @method getEventUrl\n * @return {String}\n */\n ModalEventSummary.prototype.getEditUrl = function() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-edit-url');\n };\n\n /**\n * Is this an action event.\n *\n * @method getEventUrl\n * @return {String}\n */\n ModalEventSummary.prototype.isActionEvent = function() {\n return (this.getBody().find(SELECTORS.ROOT).attr('data-action-event') == 'true');\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalEventSummary.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // We have to wait for the modal to finish rendering in order to ensure that\n // the data-event-title property is available to use as the modal title.\n M.util.js_pending('core_calendar/summary_modal:registerEventListeners:bodyRendered');\n this.getRoot().on(ModalEvents.bodyRendered, function() {\n this.getModal().data({\n eventTitle: this.getEventTitle(),\n eventId: this.getEventId(),\n eventCount: this.getEventCount(),\n })\n .attr('data-type', 'event');\n CalendarCrud.registerRemove(this.getModal());\n M.util.js_complete('core_calendar/summary_modal:registerEventListeners:bodyRendered');\n }.bind(this));\n\n $('body').on(CalendarEvents.deleted, function() {\n // Close the dialogue on delete.\n this.hide();\n }.bind(this));\n\n CustomEvents.define(this.getEditButton(), [\n CustomEvents.events.activate\n ]);\n\n this.getEditButton().on(CustomEvents.events.activate, function(e, data) {\n if (this.isActionEvent()) {\n // Action events cannot be edited on the event form and must be redirected to the module UI.\n $('body').trigger(CalendarEvents.editActionEvent, [this.getEditUrl()]);\n } else {\n // When the edit button is clicked we fire an event for the calendar UI to handle.\n // We don't care how the UI chooses to handle it.\n $('body').trigger(CalendarEvents.editEvent, [this.getEventId()]);\n }\n\n // There is nothing else for us to do so let's hide.\n this.hide();\n\n // We've handled this event so no need to propagate it.\n e.preventDefault();\n e.stopPropagation();\n data.originalEvent.preventDefault();\n data.originalEvent.stopPropagation();\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalEventSummary.TYPE, ModalEventSummary, 'core_calendar/event_summary_modal');\n registered = true;\n }\n\n return ModalEventSummary;\n});\n"],"names":["define","$","Str","Notification","CustomEvents","Modal","ModalRegistry","ModalFactory","ModalEvents","CalendarRepository","CalendarEvents","CalendarCrud","registered","SELECTORS","ModalEventSummary","root","call","this","TYPE","prototype","Object","create","constructor","getEditButton","editButton","getFooter","find","getDeleteButton","deleteButton","getEventId","getBody","attr","getEventTitle","getEventCount","getEditUrl","isActionEvent","registerEventListeners","M","util","js_pending","getRoot","on","bodyRendered","getModal","data","eventTitle","eventId","eventCount","registerRemove","js_complete","bind","deleted","hide","events","activate","e","trigger","editActionEvent","editEvent","preventDefault","stopPropagation","originalEvent","register"],"mappings":";;;;;;;AAsBAA,qCAAO,CACH,SACA,WACA,oBACA,iCACA,aACA,sBACA,qBACA,oBACA,2BACA,uBACA,uBAEJ,SACIC,EACAC,IACAC,aACAC,aACAC,MACAC,cACAC,aACAC,YACAC,mBACAC,eACAC,kBAGIC,YAAa,EACbC,eACM,0CADNA,sBAEa,uBAFbA,wBAGe,yBAQfC,kBAAoB,SAASC,MAC7BV,MAAMW,KAAKC,KAAMF,cAGrBD,kBAAkBI,KAAO,+BACzBJ,kBAAkBK,UAAYC,OAAOC,OAAOhB,MAAMc,YACtBG,YAAcR,kBAS1CA,kBAAkBK,UAAUI,cAAgB,uBACV,IAAnBN,KAAKO,kBACPA,WAAaP,KAAKQ,YAAYC,KAAKb,wBAGrCI,KAAKO,YAUhBV,kBAAkBK,UAAUQ,gBAAkB,uBACV,IAArBV,KAAKW,oBACPA,aAAeX,KAAKQ,YAAYC,KAAKb,0BAGvCI,KAAKW,cAWhBd,kBAAkBK,UAAUU,WAAa,kBAC9BZ,KAAKa,UAAUJ,KAAKb,gBAAgBkB,KAAK,kBAWpDjB,kBAAkBK,UAAUa,cAAgB,kBACjCf,KAAKa,UAAUJ,KAAKb,gBAAgBkB,KAAK,qBAWpDjB,kBAAkBK,UAAUc,cAAgB,kBACjChB,KAAKa,UAAUJ,KAAKb,gBAAgBkB,KAAK,qBASpDjB,kBAAkBK,UAAUe,WAAa,kBAC9BjB,KAAKa,UAAUJ,KAAKb,gBAAgBkB,KAAK,kBASpDjB,kBAAkBK,UAAUgB,cAAgB,iBACiC,QAAjElB,KAAKa,UAAUJ,KAAKb,gBAAgBkB,KAAK,sBAQrDjB,kBAAkBK,UAAUiB,uBAAyB,WAEjD/B,MAAMc,UAAUiB,uBAAuBpB,KAAKC,MAI5CoB,EAAEC,KAAKC,WAAW,wEACbC,UAAUC,GAAGjC,YAAYkC,aAAc,gBACnCC,WAAWC,KAAK,CACjBC,WAAY5B,KAAKe,gBACjBc,QAAS7B,KAAKY,aACdkB,WAAY9B,KAAKgB,kBAEpBF,KAAK,YAAa,SACnBpB,aAAaqC,eAAe/B,KAAK0B,YACjCN,EAAEC,KAAKW,YAAY,oEACrBC,KAAKjC,OAEPhB,EAAE,QAAQwC,GAAG/B,eAAeyC,QAAS,gBAE5BC,QACPF,KAAKjC,OAEPb,aAAaJ,OAAOiB,KAAKM,gBAAiB,CACtCnB,aAAaiD,OAAOC,gBAGnB/B,gBAAgBkB,GAAGrC,aAAaiD,OAAOC,SAAU,SAASC,EAAGX,MAC1D3B,KAAKkB,gBAELlC,EAAE,QAAQuD,QAAQ9C,eAAe+C,gBAAiB,CAACxC,KAAKiB,eAIxDjC,EAAE,QAAQuD,QAAQ9C,eAAegD,UAAW,CAACzC,KAAKY,oBAIjDuB,OAGLG,EAAEI,iBACFJ,EAAEK,kBACFhB,KAAKiB,cAAcF,iBACnBf,KAAKiB,cAAcD,mBACrBV,KAAKjC,QAKNL,aACDN,cAAcwD,SAAShD,kBAAkBI,KAAMJ,kBAAmB,qCAClEF,YAAa,GAGVE"}
\ No newline at end of file
+{"version":3,"file":"summary_modal.min.js","sources":["../src/summary_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A javascript module to handle summary modal.\n *\n * @module core_calendar/summary_modal\n * @copyright 2017 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport CalendarEvents from './events';\nimport * as CalendarCrud from 'core_calendar/crud';\nimport * as ModalEvents from 'core/modal_events';\n\nconst SELECTORS = {\n ROOT: \"[data-region='summary-modal-container']\",\n EDIT_BUTTON: '[data-action=\"edit\"]',\n DELETE_BUTTON: '[data-action=\"delete\"]',\n};\n\nexport default class ModalEventSummary extends Modal {\n static TEMPLATE = 'core_calendar/event_summary_modal';\n static TYPE = 'core_calendar-event_summary';\n\n /**\n * Get the edit button element from the footer. The button is cached\n * as it's not expected to change.\n *\n * @method getEditButton\n * @return {object} button element\n */\n getEditButton() {\n if (typeof this.editButton == 'undefined') {\n this.editButton = this.getFooter().find(SELECTORS.EDIT_BUTTON);\n }\n\n return this.editButton;\n }\n\n /**\n * Get the delete button element from the footer. The button is cached\n * as it's not expected to change.\n *\n * @method getDeleteButton\n * @return {object} button element\n */\n getDeleteButton() {\n if (typeof this.deleteButton == 'undefined') {\n this.deleteButton = this.getFooter().find(SELECTORS.DELETE_BUTTON);\n }\n\n return this.deleteButton;\n }\n\n /**\n * Get the id for the event being shown in this modal. This value is\n * not cached because it will change depending on which event is\n * being displayed.\n *\n * @method getEventId\n * @return {int}\n */\n getEventId() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-id');\n }\n\n /**\n * Get the title for the event being shown in this modal. This value is\n * not cached because it will change depending on which event is\n * being displayed.\n *\n * @method getEventTitle\n * @return {String}\n */\n getEventTitle() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-title');\n }\n\n /**\n * Get the number of events in the series for the event being shown in\n * this modal. This value is not cached because it will change\n * depending on which event is being displayed.\n *\n * @method getEventCount\n * @return {int}\n */\n getEventCount() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-count');\n }\n\n /**\n * Get the url for the event being shown in this modal.\n *\n * @method getEventUrl\n * @return {String}\n */\n getEditUrl() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-edit-url');\n }\n\n /**\n * Is this an action event.\n *\n * @method getEventUrl\n * @return {String}\n */\n isActionEvent() {\n return (this.getBody().find(SELECTORS.ROOT).attr('data-action-event') == 'true');\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n // We have to wait for the modal to finish rendering in order to ensure that\n // the data-event-title property is available to use as the modal title.\n M.util.js_pending('core_calendar/summary_modal:registerEventListeners:bodyRendered');\n this.getRoot().on(ModalEvents.bodyRendered, function() {\n this.getModal().data({\n eventTitle: this.getEventTitle(),\n eventId: this.getEventId(),\n eventCount: this.getEventCount(),\n })\n .attr('data-type', 'event');\n CalendarCrud.registerRemove(this.getModal());\n M.util.js_complete('core_calendar/summary_modal:registerEventListeners:bodyRendered');\n }.bind(this));\n\n $('body').on(CalendarEvents.deleted, function() {\n // Close the dialogue on delete.\n this.hide();\n }.bind(this));\n\n CustomEvents.define(this.getEditButton(), [\n CustomEvents.events.activate\n ]);\n\n this.getEditButton().on(CustomEvents.events.activate, function(e, data) {\n if (this.isActionEvent()) {\n // Action events cannot be edited on the event form and must be redirected to the module UI.\n $('body').trigger(CalendarEvents.editActionEvent, [this.getEditUrl()]);\n } else {\n // When the edit button is clicked we fire an event for the calendar UI to handle.\n // We don't care how the UI chooses to handle it.\n $('body').trigger(CalendarEvents.editEvent, [this.getEventId()]);\n }\n\n // There is nothing else for us to do so let's hide.\n this.hide();\n\n // We've handled this event so no need to propagate it.\n e.preventDefault();\n e.stopPropagation();\n data.originalEvent.preventDefault();\n data.originalEvent.stopPropagation();\n }.bind(this));\n }\n}\n\nModalEventSummary.registerModalType();\n"],"names":["SELECTORS","ModalEventSummary","Modal","getEditButton","this","editButton","getFooter","find","getDeleteButton","deleteButton","getEventId","getBody","attr","getEventTitle","getEventCount","getEditUrl","isActionEvent","registerEventListeners","M","util","js_pending","getRoot","on","ModalEvents","bodyRendered","getModal","data","eventTitle","eventId","eventCount","CalendarCrud","registerRemove","js_complete","bind","CalendarEvents","deleted","hide","CustomEvents","define","events","activate","e","trigger","editActionEvent","editEvent","preventDefault","stopPropagation","originalEvent","registerModalType"],"mappings":"6vDA8BMA,eACI,0CADJA,sBAEW,uBAFXA,wBAGa,+BAGEC,0BAA0BC,eAW3CC,4BACkC,IAAnBC,KAAKC,kBACPA,WAAaD,KAAKE,YAAYC,KAAKP,wBAGrCI,KAAKC,WAUhBG,8BACoC,IAArBJ,KAAKK,oBACPA,aAAeL,KAAKE,YAAYC,KAAKP,0BAGvCI,KAAKK,aAWhBC,oBACWN,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,iBAWpDC,uBACWT,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,oBAWpDE,uBACWV,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,oBASpDG,oBACWX,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,iBASpDI,sBAC6E,QAAjEZ,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,qBAQrDK,+BAEUA,uBAAuBb,MAI7Bc,EAAEC,KAAKC,WAAW,wEACbC,UAAUC,GAAGC,YAAYC,aAAc,gBACnCC,WAAWC,KAAK,CACjBC,WAAYvB,KAAKS,gBACjBe,QAASxB,KAAKM,aACdmB,WAAYzB,KAAKU,kBAEpBF,KAAK,YAAa,SACnBkB,aAAaC,eAAe3B,KAAKqB,YACjCP,EAAEC,KAAKa,YAAY,oEACrBC,KAAK7B,2BAEL,QAAQkB,GAAGY,gBAAeC,QAAS,gBAE5BC,QACPH,KAAK7B,OAEPiC,aAAaC,OAAOlC,KAAKD,gBAAiB,CACtCkC,aAAaE,OAAOC,gBAGnBrC,gBAAgBmB,GAAGe,aAAaE,OAAOC,SAAU,SAASC,EAAGf,MAC1DtB,KAAKY,oCAEH,QAAQ0B,QAAQR,gBAAeS,gBAAiB,CAACvC,KAAKW,mCAItD,QAAQ2B,QAAQR,gBAAeU,UAAW,CAACxC,KAAKM,oBAIjD0B,OAGLK,EAAEI,iBACFJ,EAAEK,kBACFpB,KAAKqB,cAAcF,iBACnBnB,KAAKqB,cAAcD,mBACrBb,KAAK7B,kEA5IMH,6BACC,qDADDA,yBAEH,+BA8IlBA,kBAAkB+C"}
\ No newline at end of file
diff --git a/calendar/amd/src/crud.js b/calendar/amd/src/crud.js
index 1621ea1185c..d2f77411df7 100644
--- a/calendar/amd/src/crud.js
+++ b/calendar/amd/src/crud.js
@@ -24,9 +24,6 @@ define([
'jquery',
'core/str',
'core/notification',
- 'core/custom_interaction_events',
- 'core/modal',
- 'core/modal_registry',
'core/modal_factory',
'core/modal_events',
'core_calendar/modal_event_form',
@@ -40,9 +37,6 @@ function(
$,
Str,
Notification,
- CustomEvents,
- Modal,
- ModalRegistry,
ModalFactory,
ModalEvents,
ModalEventForm,
diff --git a/calendar/amd/src/events.js b/calendar/amd/src/events.js
index 3c839f654ec..4280f59283c 100644
--- a/calendar/amd/src/events.js
+++ b/calendar/amd/src/events.js
@@ -20,20 +20,18 @@
* @copyright 2017 Simey Lameze
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([], function() {
- return {
- created: 'calendar-events:created',
- deleted: 'calendar-events:deleted',
- deleteAll: 'calendar-events:delete_all',
- updated: 'calendar-events:updated',
- editEvent: 'calendar-events:edit_event',
- editActionEvent: 'calendar-events:edit_action_event',
- eventMoved: 'calendar-events:event_moved',
- dayChanged: 'calendar-events:day_changed',
- monthChanged: 'calendar-events:month_changed',
- moveEvent: 'calendar-events:move_event',
- filterChanged: 'calendar-events:filter_changed',
- courseChanged: 'calendar-events:course_changed',
- viewUpdated: 'calendar-events:view_updated',
- };
-});
+export default {
+ created: 'calendar-events:created',
+ deleted: 'calendar-events:deleted',
+ deleteAll: 'calendar-events:delete_all',
+ updated: 'calendar-events:updated',
+ editEvent: 'calendar-events:edit_event',
+ editActionEvent: 'calendar-events:edit_action_event',
+ eventMoved: 'calendar-events:event_moved',
+ dayChanged: 'calendar-events:day_changed',
+ monthChanged: 'calendar-events:month_changed',
+ moveEvent: 'calendar-events:move_event',
+ filterChanged: 'calendar-events:filter_changed',
+ courseChanged: 'calendar-events:course_changed',
+ viewUpdated: 'calendar-events:view_updated',
+};
diff --git a/calendar/amd/src/modal_delete.js b/calendar/amd/src/modal_delete.js
index f1320b29bf8..1b81ca920e9 100644
--- a/calendar/amd/src/modal_delete.js
+++ b/calendar/amd/src/modal_delete.js
@@ -20,94 +20,73 @@
* @copyright 2017 Andrew Nicols
* @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/modal_registry',
- 'core_calendar/events',
-],
-function(
- $,
- Notification,
- CustomEvents,
- Modal,
- ModalEvents,
- ModalRegistry,
- CalendarEvents
-) {
- var registered = false;
- var SELECTORS = {
- DELETE_ONE_BUTTON: '[data-action="deleteone"]',
- DELETE_ALL_BUTTON: '[data-action="deleteall"]',
- CANCEL_BUTTON: '[data-action="cancel"]',
- };
+import $ from 'jquery';
+import * as CustomEvents from 'core/custom_interaction_events';
+import Modal from 'core/modal';
+import ModalEvents from 'core/modal_events';
+import CalendarEvents from './events';
- /**
- * Constructor for the Modal.
- *
- * @class
- * @param {object} root The root jQuery element for the modal
- */
- var ModalDelete = function(root) {
- Modal.call(this, root);
+const SELECTORS = {
+ DELETE_ONE_BUTTON: '[data-action="deleteone"]',
+ DELETE_ALL_BUTTON: '[data-action="deleteall"]',
+ CANCEL_BUTTON: '[data-action="cancel"]',
+};
+/**
+ * Constructor for the Modal.
+ *
+ * @class
+ * @param {object} root The root jQuery element for the modal
+ */
+export default class ModalDelete extends Modal {
+ static TYPE = 'core_calendar-modal_delete';
+ static TEMPLATE = 'calendar/event_delete_modal';
+
+ constructor(root) {
+ super(root);
this.setRemoveOnClose(true);
- };
-
- ModalDelete.TYPE = 'core_calendar-modal_delete';
- ModalDelete.prototype = Object.create(Modal.prototype);
- ModalDelete.prototype.constructor = ModalDelete;
+ }
/**
* Set up all of the event handling for the modal.
*
* @method registerEventListeners
*/
- ModalDelete.prototype.registerEventListeners = function() {
+ registerEventListeners() {
// Apply parent event listeners.
- Modal.prototype.registerEventListeners.call(this);
+ super.registerEventListeners(this);
- this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ONE_BUTTON, function(e, data) {
- var saveEvent = $.Event(ModalEvents.save);
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ONE_BUTTON, (e, data) => {
+ const saveEvent = $.Event(ModalEvents.save);
this.getRoot().trigger(saveEvent, this);
if (!saveEvent.isDefaultPrevented()) {
this.hide();
data.originalEvent.preventDefault();
}
- }.bind(this));
+ });
- this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ALL_BUTTON, function(e, data) {
- var saveEvent = $.Event(CalendarEvents.deleteAll);
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.DELETE_ALL_BUTTON, (e, data) => {
+ const saveEvent = $.Event(CalendarEvents.deleteAll);
this.getRoot().trigger(saveEvent, this);
if (!saveEvent.isDefaultPrevented()) {
this.hide();
data.originalEvent.preventDefault();
}
- }.bind(this));
+ });
- this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {
- var cancelEvent = $.Event(ModalEvents.cancel);
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, (e, data) => {
+ const cancelEvent = $.Event(ModalEvents.cancel);
this.getRoot().trigger(cancelEvent, this);
if (!cancelEvent.isDefaultPrevented()) {
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(ModalDelete.TYPE, ModalDelete, 'calendar/event_delete_modal');
- registered = true;
+ });
}
+}
- return ModalDelete;
-});
+ModalDelete.registerModalType();
diff --git a/calendar/amd/src/modal_event_form.js b/calendar/amd/src/modal_event_form.js
index b7d94a49497..c7e6f2a56bd 100644
--- a/calendar/amd/src/modal_event_form.js
+++ b/calendar/amd/src/modal_event_form.js
@@ -20,45 +20,34 @@
* @copyright 2017 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([
- 'jquery',
- 'core_form/events',
- 'core/str',
- 'core/notification',
- 'core/templates',
- 'core/custom_interaction_events',
- 'core/modal',
- 'core/modal_registry',
- 'core/fragment',
- 'core_calendar/events',
- 'core_calendar/repository'
-],
-function(
- $,
- FormEvents,
- Str,
- Notification,
- Templates,
- CustomEvents,
- Modal,
- ModalRegistry,
- Fragment,
- CalendarEvents,
- Repository
-) {
- var registered = false;
- var SELECTORS = {
- SAVE_BUTTON: '[data-action="save"]',
- LOADING_ICON_CONTAINER: '[data-region="loading-icon-container"]',
- };
+
+import $ from 'jquery';
+import * as CustomEvents from 'core/custom_interaction_events';
+import Modal from 'core/modal';
+import * as FormEvents from 'core_form/events';
+import CalendarEvents from './events';
+import * as Str from 'core/str';
+import * as Notification from 'core/notification';
+import * as Fragment from 'core/fragment';
+import * as Repository from 'core_calendar/repository';
+
+const SELECTORS = {
+ SAVE_BUTTON: '[data-action="save"]',
+ LOADING_ICON_CONTAINER: '[data-region="loading-icon-container"]',
+};
+
+export default class ModalEventForm extends Modal {
+ static TYPE = 'core_calendar-modal_event_form';
+ static TEMPLATE = 'calendar/modal_event_form';
/**
* Constructor for the Modal.
*
* @param {object} root The root jQuery element for the modal
*/
- var ModalEventForm = function(root) {
- Modal.call(this, root);
+ constructor(root) {
+ super(root);
+
this.eventId = null;
this.startTime = null;
this.courseId = null;
@@ -67,11 +56,7 @@ function(
this.reloadingBody = false;
this.reloadingTitle = false;
this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);
- };
-
- ModalEventForm.TYPE = 'core_calendar-modal_event_form';
- ModalEventForm.prototype = Object.create(Modal.prototype);
- ModalEventForm.prototype.constructor = ModalEventForm;
+ }
/**
* Set the context id to the given value.
@@ -79,9 +64,9 @@ function(
* @method setContextId
* @param {Number} id The event id
*/
- ModalEventForm.prototype.setContextId = function(id) {
+ setContextId(id) {
this.contextId = id;
- };
+ }
/**
* Retrieve the current context id, if any.
@@ -89,49 +74,49 @@ function(
* @method getContextId
* @return {Number|null} The event id
*/
- ModalEventForm.prototype.getContextId = function() {
+ getContextId() {
return this.contextId;
- };
+ }
/**
* Set the course id to the given value.
*
* @method setCourseId
- * @param {int} id The event id
+ * @param {Number} id The event id
*/
- ModalEventForm.prototype.setCourseId = function(id) {
+ setCourseId(id) {
this.courseId = id;
- };
+ }
/**
* Retrieve the current course id, if any.
*
* @method getCourseId
- * @return {int|null} The event id
+ * @return {Number|null} The event id
*/
- ModalEventForm.prototype.getCourseId = function() {
+ getCourseId() {
return this.courseId;
- };
+ }
/**
* Set the category id to the given value.
*
* @method setCategoryId
- * @param {int} id The event id
+ * @param {Number} id The event id
*/
- ModalEventForm.prototype.setCategoryId = function(id) {
+ setCategoryId(id) {
this.categoryId = id;
- };
+ }
/**
* Retrieve the current category id, if any.
*
* @method getCategoryId
- * @return {int|null} The event id
+ * @return {Number|null} The event id
*/
- ModalEventForm.prototype.getCategoryId = function() {
+ getCategoryId() {
return this.categoryId;
- };
+ }
/**
* Check if the modal has an course id.
@@ -139,9 +124,9 @@ function(
* @method hasCourseId
* @return {bool}
*/
- ModalEventForm.prototype.hasCourseId = function() {
+ hasCourseId() {
return this.courseId !== null;
- };
+ }
/**
* Check if the modal has an category id.
@@ -149,29 +134,29 @@ function(
* @method hasCategoryId
* @return {bool}
*/
- ModalEventForm.prototype.hasCategoryId = function() {
+ hasCategoryId() {
return this.categoryId !== null;
- };
+ }
/**
* Set the event id to the given value.
*
* @method setEventId
- * @param {int} id The event id
+ * @param {Number} id The event id
*/
- ModalEventForm.prototype.setEventId = function(id) {
+ setEventId(id) {
this.eventId = id;
- };
+ }
/**
* Retrieve the current event id, if any.
*
* @method getEventId
- * @return {int|null} The event id
+ * @return {Number|null} The event id
*/
- ModalEventForm.prototype.getEventId = function() {
+ getEventId() {
return this.eventId;
- };
+ }
/**
* Check if the modal has an event id.
@@ -179,29 +164,29 @@ function(
* @method hasEventId
* @return {bool}
*/
- ModalEventForm.prototype.hasEventId = function() {
+ hasEventId() {
return this.eventId !== null;
- };
+ }
/**
* Set the start time to the given value.
*
* @method setStartTime
- * @param {int} time The start time
+ * @param {Number} time The start time
*/
- ModalEventForm.prototype.setStartTime = function(time) {
+ setStartTime(time) {
this.startTime = time;
- };
+ }
/**
* Retrieve the current start time, if any.
*
* @method getStartTime
- * @return {int|null} The start time
+ * @return {Number|null} The start time
*/
- ModalEventForm.prototype.getStartTime = function() {
+ getStartTime() {
return this.startTime;
- };
+ }
/**
* Check if the modal has start time.
@@ -209,9 +194,9 @@ function(
* @method hasStartTime
* @return {bool}
*/
- ModalEventForm.prototype.hasStartTime = function() {
+ hasStartTime() {
return this.startTime !== null;
- };
+ }
/**
* Get the form element from the modal.
@@ -219,27 +204,27 @@ function(
* @method getForm
* @return {object}
*/
- ModalEventForm.prototype.getForm = function() {
+ getForm() {
return this.getBody().find('form');
- };
+ }
/**
* Disable the buttons in the footer.
*
* @method disableButtons
*/
- ModalEventForm.prototype.disableButtons = function() {
+ disableButtons() {
this.saveButton.prop('disabled', true);
- };
+ }
/**
* Enable the buttons in the footer.
*
* @method enableButtons
*/
- ModalEventForm.prototype.enableButtons = function() {
+ enableButtons() {
this.saveButton.prop('disabled', false);
- };
+ }
/**
* Reload the title for the modal to the appropriate value
@@ -249,7 +234,7 @@ function(
* @method reloadTitleContent
* @return {object} A promise resolved with the new title text
*/
- ModalEventForm.prototype.reloadTitleContent = function() {
+ reloadTitleContent() {
if (this.reloadingTitle) {
return this.titlePromise;
}
@@ -262,18 +247,18 @@ function(
this.titlePromise = Str.get_string('newevent', 'calendar');
}
- this.titlePromise.then(function(string) {
+ this.titlePromise.then((string) => {
this.setTitle(string);
return string;
- }.bind(this))
- .always(function() {
+ })
+ .catch(Notification.exception)
+ .always(() => {
this.reloadingTitle = false;
return;
- }.bind(this))
- .fail(Notification.exception);
+ });
return this.titlePromise;
- };
+ }
/**
* Send a request to the server to get the event_form in a fragment
@@ -288,7 +273,7 @@ function(
* @param {string} formData The serialised form data
* @return {object} A promise resolved with the fragment html and js from
*/
- ModalEventForm.prototype.reloadBodyContent = function(formData) {
+ reloadBodyContent(formData) {
if (this.reloadingBody) {
return this.bodyPromise;
}
@@ -296,7 +281,7 @@ function(
this.reloadingBody = true;
this.disableButtons();
- var args = {};
+ const args = {};
if (this.hasEventId()) {
args.eventid = this.getEventId();
@@ -322,19 +307,18 @@ function(
this.setBody(this.bodyPromise);
- this.bodyPromise.then(function() {
+ this.bodyPromise.then(() => {
this.enableButtons();
return;
- }.bind(this))
- .fail(Notification.exception)
- .always(function() {
+ })
+ .catch(Notification.exception)
+ .always(() => {
this.reloadingBody = false;
return;
- }.bind(this))
- .fail(Notification.exception);
+ });
return this.bodyPromise;
- };
+ }
/**
* Reload both the title and body content.
@@ -342,9 +326,9 @@ function(
* @method reloadAllContent
* @return {object} promise
*/
- ModalEventForm.prototype.reloadAllContent = function() {
+ reloadAllContent() {
return $.when(this.reloadTitleContent(), this.reloadBodyContent());
- };
+ }
/**
* Kick off a reload the modal content before showing it. This
@@ -357,10 +341,10 @@ function(
*
* @method show
*/
- ModalEventForm.prototype.show = function() {
+ show() {
this.reloadAllContent();
- Modal.prototype.show.call(this);
- };
+ super.show(this);
+ }
/**
* Clear the event id from the modal when it's closed so
@@ -371,13 +355,13 @@ function(
*
* @method hide
*/
- ModalEventForm.prototype.hide = function() {
- Modal.prototype.hide.call(this);
+ hide() {
+ super.hide(this);
this.setEventId(null);
this.setStartTime(null);
this.setCourseId(null);
this.setCategoryId(null);
- };
+ }
/**
* Get the serialised form data.
@@ -385,9 +369,9 @@ function(
* @method getFormData
* @return {string} serialised form data
*/
- ModalEventForm.prototype.getFormData = function() {
+ getFormData() {
return this.getForm().serialize();
- };
+ }
/**
* Send the form data to the server to create or update
@@ -403,12 +387,11 @@ function(
* @method save
* @return {object} A promise
*/
- ModalEventForm.prototype.save = function() {
- var invalid,
- loadingContainer = this.saveButton.find(SELECTORS.LOADING_ICON_CONTAINER);
+ save() {
+ const loadingContainer = this.saveButton.find(SELECTORS.LOADING_ICON_CONTAINER);
// Now the change events have run, see if there are any "invalid" form fields.
- invalid = this.getForm().find('[aria-invalid="true"]');
+ const invalid = this.getForm().find('[aria-invalid="true"]');
// If we found invalid fields, focus on the first one and do not submit via ajax.
if (invalid.length) {
@@ -419,10 +402,10 @@ function(
loadingContainer.removeClass('hidden');
this.disableButtons();
- var formData = this.getFormData();
+ const formData = this.getFormData();
// Send the form data to the server for processing.
return Repository.submitCreateUpdateForm(formData)
- .then(function(response) {
+ .then((response) => {
if (response.validationerror) {
// If there was a server side validation error then
// we need to re-request the rendered form from the server
@@ -432,7 +415,7 @@ function(
} else {
// Check whether this was a new event or not.
// The hide function unsets the form data so grab this before the hide.
- var isExisting = this.hasEventId();
+ const isExisting = this.hasEventId();
// No problemo! Our work here is done.
this.hide();
@@ -446,17 +429,17 @@ function(
}
return;
- }.bind(this))
- .always(function() {
+ })
+ .catch(Notification.exception)
+ .always(() => {
// Regardless of success or error we should always stop
// the loading icon and re-enable the buttons.
loadingContainer.addClass('hidden');
this.enableButtons();
return;
- }.bind(this))
- .fail(Notification.exception);
- };
+ });
+ }
/**
* Set up all of the event handling for the modal.
@@ -465,22 +448,22 @@ function(
* @fires event:uploadStarted
* @fires event:formSubmittedByJavascript
*/
- ModalEventForm.prototype.registerEventListeners = function() {
+ registerEventListeners() {
// Apply parent event listeners.
- Modal.prototype.registerEventListeners.call(this);
+ super.registerEventListeners(this);
// When the user clicks the save button we trigger the form submission. We need to
// trigger an actual submission because there is some JS code in the form that is
// listening for this event and doing some stuff (e.g. saving draft areas etc).
- this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(e, data) {
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, (e, data) => {
this.getForm().submit();
data.originalEvent.preventDefault();
e.stopPropagation();
- }.bind(this));
+ });
// Catch the submit event before it is actually processed by the browser and
// prevent the submission. We'll take it from here.
- this.getModal().on('submit', function(e) {
+ this.getModal().on('submit', (e) => {
FormEvents.notifyFormSubmittedByJavascript(this.getForm()[0]);
this.save();
@@ -489,15 +472,8 @@ function(
// propagation because we have already handled the event.
e.preventDefault();
e.stopPropagation();
- }.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(ModalEventForm.TYPE, ModalEventForm, 'calendar/modal_event_form');
- registered = true;
+ });
}
+}
- return ModalEventForm;
-});
+ModalEventForm.registerModalType();
diff --git a/calendar/amd/src/summary_modal.js b/calendar/amd/src/summary_modal.js
index 744f4edcbb7..4ec2e01bc9e 100644
--- a/calendar/amd/src/summary_modal.js
+++ b/calendar/amd/src/summary_modal.js
@@ -20,52 +20,23 @@
* @copyright 2017 Simey Lameze
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([
- 'jquery',
- 'core/str',
- 'core/notification',
- 'core/custom_interaction_events',
- 'core/modal',
- 'core/modal_registry',
- 'core/modal_factory',
- 'core/modal_events',
- 'core_calendar/repository',
- 'core_calendar/events',
- 'core_calendar/crud',
-],
-function(
- $,
- Str,
- Notification,
- CustomEvents,
- Modal,
- ModalRegistry,
- ModalFactory,
- ModalEvents,
- CalendarRepository,
- CalendarEvents,
- CalendarCrud
-) {
- var registered = false;
- var SELECTORS = {
- ROOT: "[data-region='summary-modal-container']",
- EDIT_BUTTON: '[data-action="edit"]',
- DELETE_BUTTON: '[data-action="delete"]',
- };
+import $ from 'jquery';
+import * as CustomEvents from 'core/custom_interaction_events';
+import Modal from 'core/modal';
+import CalendarEvents from './events';
+import * as CalendarCrud from 'core_calendar/crud';
+import * as ModalEvents from 'core/modal_events';
- /**
- * Constructor for the Modal.
- *
- * @param {object} root The root jQuery element for the modal
- */
- var ModalEventSummary = function(root) {
- Modal.call(this, root);
- };
+const SELECTORS = {
+ ROOT: "[data-region='summary-modal-container']",
+ EDIT_BUTTON: '[data-action="edit"]',
+ DELETE_BUTTON: '[data-action="delete"]',
+};
- ModalEventSummary.TYPE = 'core_calendar-event_summary';
- ModalEventSummary.prototype = Object.create(Modal.prototype);
- ModalEventSummary.prototype.constructor = ModalEventSummary;
+export default class ModalEventSummary extends Modal {
+ static TEMPLATE = 'core_calendar/event_summary_modal';
+ static TYPE = 'core_calendar-event_summary';
/**
* Get the edit button element from the footer. The button is cached
@@ -74,13 +45,13 @@ function(
* @method getEditButton
* @return {object} button element
*/
- ModalEventSummary.prototype.getEditButton = function() {
+ getEditButton() {
if (typeof this.editButton == 'undefined') {
this.editButton = this.getFooter().find(SELECTORS.EDIT_BUTTON);
}
return this.editButton;
- };
+ }
/**
* Get the delete button element from the footer. The button is cached
@@ -89,13 +60,13 @@ function(
* @method getDeleteButton
* @return {object} button element
*/
- ModalEventSummary.prototype.getDeleteButton = function() {
+ getDeleteButton() {
if (typeof this.deleteButton == 'undefined') {
this.deleteButton = this.getFooter().find(SELECTORS.DELETE_BUTTON);
}
return this.deleteButton;
- };
+ }
/**
* Get the id for the event being shown in this modal. This value is
@@ -105,9 +76,9 @@ function(
* @method getEventId
* @return {int}
*/
- ModalEventSummary.prototype.getEventId = function() {
+ getEventId() {
return this.getBody().find(SELECTORS.ROOT).attr('data-event-id');
- };
+ }
/**
* Get the title for the event being shown in this modal. This value is
@@ -117,9 +88,9 @@ function(
* @method getEventTitle
* @return {String}
*/
- ModalEventSummary.prototype.getEventTitle = function() {
+ getEventTitle() {
return this.getBody().find(SELECTORS.ROOT).attr('data-event-title');
- };
+ }
/**
* Get the number of events in the series for the event being shown in
@@ -129,9 +100,9 @@ function(
* @method getEventCount
* @return {int}
*/
- ModalEventSummary.prototype.getEventCount = function() {
+ getEventCount() {
return this.getBody().find(SELECTORS.ROOT).attr('data-event-count');
- };
+ }
/**
* Get the url for the event being shown in this modal.
@@ -139,9 +110,9 @@ function(
* @method getEventUrl
* @return {String}
*/
- ModalEventSummary.prototype.getEditUrl = function() {
+ getEditUrl() {
return this.getBody().find(SELECTORS.ROOT).attr('data-edit-url');
- };
+ }
/**
* Is this an action event.
@@ -149,18 +120,18 @@ function(
* @method getEventUrl
* @return {String}
*/
- ModalEventSummary.prototype.isActionEvent = function() {
+ isActionEvent() {
return (this.getBody().find(SELECTORS.ROOT).attr('data-action-event') == 'true');
- };
+ }
/**
* Set up all of the event handling for the modal.
*
* @method registerEventListeners
*/
- ModalEventSummary.prototype.registerEventListeners = function() {
+ registerEventListeners() {
// Apply parent event listeners.
- Modal.prototype.registerEventListeners.call(this);
+ super.registerEventListeners(this);
// We have to wait for the modal to finish rendering in order to ensure that
// the data-event-title property is available to use as the modal title.
@@ -204,14 +175,7 @@ function(
data.originalEvent.preventDefault();
data.originalEvent.stopPropagation();
}.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(ModalEventSummary.TYPE, ModalEventSummary, 'core_calendar/event_summary_modal');
- registered = true;
}
+}
- return ModalEventSummary;
-});
+ModalEventSummary.registerModalType();
diff --git a/lib/amd/build/config.min.js b/lib/amd/build/config.min.js
index d69d734840a..fae681c11a7 100644
--- a/lib/amd/build/config.min.js
+++ b/lib/amd/build/config.min.js
@@ -1,11 +1,12 @@
+define("core/config",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;
/**
- * Expose the M.cfg global variable.
- *
- * @module core/config
- * @copyright 2015 Damyon Wiese
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since 2.9
- */
-define("core/config",(function(){return M.cfg}));
+ * Expose the M.cfg global variable.
+ *
+ * @module core/config
+ * @copyright 2015 Damyon Wiese
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since 2.9
+ */
+var _default=M.cfg;return _exports.default=_default,_exports.default}));
//# sourceMappingURL=config.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/config.min.js.map b/lib/amd/build/config.min.js.map
index 390761a9d43..6159b5b5e5e 100644
--- a/lib/amd/build/config.min.js.map
+++ b/lib/amd/build/config.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"config.min.js","sources":["../src/config.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Expose the M.cfg global variable.\n *\n * @module core/config\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\ndefine(function() {\n // This module exposes only the raw data from M.cfg;\n return M.cfg;\n});\n"],"names":["define","M","cfg"],"mappings":";;;;;;;;AAuBAA,sBAAO,kBAEIC,EAAEC"}
\ No newline at end of file
+{"version":3,"file":"config.min.js","sources":["../src/config.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Expose the M.cfg global variable.\n *\n * @module core/config\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\n// This module exposes only the raw data from M.cfg;\nexport default M.cfg;\n"],"names":["M","cfg"],"mappings":";;;;;;;;;aAwBeA,EAAEC"}
\ No newline at end of file
diff --git a/lib/amd/build/first.min.js b/lib/amd/build/first.min.js
index 0ea58150d29..159471424a8 100644
--- a/lib/amd/build/first.min.js
+++ b/lib/amd/build/first.min.js
@@ -1,16 +1,16 @@
+define("core/first",["jquery"],(function(_jquery){var obj;
/**
- * This is an empty module, that is required before all other modules.
- * Because every module is returned from a request for any other module, this
- * forces the loading of all modules with a single request.
- *
- * This function also sets up the listeners for ajax requests so we can tell
- * if any requests are still in progress.
- *
- * @module core/first
- * @copyright 2015 Damyon Wiese
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since 2.9
- */
-define("core/first",["jquery"],(function($){$(document).bind("ajaxStart",(function(){M.util.js_pending("jq")})).bind("ajaxStop",(function(){M.util.js_complete("jq")}))}));
+ * This is an empty module, that is required before all other modules.
+ * Because every module is returned from a request for any other module, this
+ * forces the loading of all modules with a single request.
+ *
+ * This function also sets up the listeners for ajax requests so we can tell
+ * if any requests are still in progress.
+ *
+ * @module core/first
+ * @copyright 2015 Damyon Wiese
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since 2.9
+ */(0,(_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj}).default)(document).bind("ajaxStart",(function(){M.util.js_pending("jq")})).bind("ajaxStop",(function(){M.util.js_complete("jq")}))}));
//# sourceMappingURL=first.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/first.min.js.map b/lib/amd/build/first.min.js.map
index 7cd1860203b..3c44137db98 100644
--- a/lib/amd/build/first.min.js.map
+++ b/lib/amd/build/first.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"first.min.js","sources":["../src/first.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This is an empty module, that is required before all other modules.\n * Because every module is returned from a request for any other module, this\n * forces the loading of all modules with a single request.\n *\n * This function also sets up the listeners for ajax requests so we can tell\n * if any requests are still in progress.\n *\n * @module core/first\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\ndefine(['jquery'], function($) {\n $(document).bind(\"ajaxStart\", function() {\n M.util.js_pending('jq');\n }).bind(\"ajaxStop\", function() {\n M.util.js_complete('jq');\n });\n});\n"],"names":["define","$","document","bind","M","util","js_pending","js_complete"],"mappings":";;;;;;;;;;;;;AA4BAA,oBAAO,CAAC,WAAW,SAASC,GACxBA,EAAEC,UAAUC,KAAK,aAAa,WAC1BC,EAAEC,KAAKC,WAAW,SACnBH,KAAK,YAAY,WAChBC,EAAEC,KAAKE,YAAY"}
\ No newline at end of file
+{"version":3,"file":"first.min.js","sources":["../src/first.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * This is an empty module, that is required before all other modules.\n * Because every module is returned from a request for any other module, this\n * forces the loading of all modules with a single request.\n *\n * This function also sets up the listeners for ajax requests so we can tell\n * if any requests are still in progress.\n *\n * @module core/first\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\n\nimport $ from 'jquery';\n\n$(document)\n.bind(\"ajaxStart\", function() {\n M.util.js_pending('jq');\n})\n.bind(\"ajaxStop\", function() {\n M.util.js_complete('jq');\n});\n"],"names":["document","bind","M","util","js_pending","js_complete"],"mappings":";;;;;;;;;;;;;2EA+BEA,UACDC,KAAK,aAAa,WACfC,EAAEC,KAAKC,WAAW,SAErBH,KAAK,YAAY,WACdC,EAAEC,KAAKE,YAAY"}
\ No newline at end of file
diff --git a/lib/amd/build/local/modal/alert.min.js b/lib/amd/build/local/modal/alert.min.js
index 1876e740dd3..180291edf37 100644
--- a/lib/amd/build/local/modal/alert.min.js
+++ b/lib/amd/build/local/modal/alert.min.js
@@ -1,10 +1,3 @@
-define("core/local/modal/alert",["exports","core/modal"],(function(_exports,_modal){var obj;
-/**
- * Alert modal.
- *
- * @module core/local/modal/alert
- * @copyright 2020 Andrew Nicols
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class _default extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnCancel()}}return _exports.default=_default,_exports.default}));
+define("core/local/modal/alert",["exports","core/modal"],(function(_exports,_modal){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class ModalAlert extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnCancel()}}return _exports.default=ModalAlert,_defineProperty(ModalAlert,"TYPE","ALERT"),_defineProperty(ModalAlert,"TEMPLATE","core/local/modal/alert"),ModalAlert.registerModalType(),_exports.default}));
//# sourceMappingURL=alert.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/local/modal/alert.min.js.map b/lib/amd/build/local/modal/alert.min.js.map
index 1227a766902..b509e60b5c8 100644
--- a/lib/amd/build/local/modal/alert.min.js.map
+++ b/lib/amd/build/local/modal/alert.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"alert.min.js","sources":["../../../src/local/modal/alert.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Alert modal.\n *\n * @module core/local/modal/alert\n * @copyright 2020 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\n/**\n * The Alert Modal\n *\n * @class\n * @extends Modal\n */\nexport default class extends Modal {\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on cancel.\n this.registerCloseOnCancel();\n }\n}\n"],"names":["Modal","registerEventListeners","registerCloseOnCancel"],"mappings":";;;;;;;kKA+B6BA,eAIzBC,+BAEUA,8BAGDC"}
\ No newline at end of file
+{"version":3,"file":"alert.min.js","sources":["../../../src/local/modal/alert.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Alert modal.\n *\n * @module core/local/modal/alert\n * @copyright 2020 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\n/**\n * The Alert Modal\n *\n * @class\n * @extends Modal\n */\nexport default class ModalAlert extends Modal {\n static TYPE = 'ALERT';\n static TEMPLATE = 'core/local/modal/alert';\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on cancel.\n this.registerCloseOnCancel();\n }\n}\n\nModalAlert.registerModalType();\n"],"names":["ModalAlert","Modal","registerEventListeners","registerCloseOnCancel","registerModalType"],"mappings":"4YA+BqBA,mBAAmBC,eAOpCC,+BAEUA,8BAGDC,4EAZQH,kBACH,yBADGA,sBAEC,0BActBA,WAAWI"}
\ No newline at end of file
diff --git a/lib/amd/build/modal.min.js b/lib/amd/build/modal.min.js
index ae27c3efa97..4866f0dcb09 100644
--- a/lib/amd/build/modal.min.js
+++ b/lib/amd/build/modal.min.js
@@ -1,11 +1,3 @@
-/**
- * Contain the logic for modals.
- *
- * @module core/modal
- * @class core/modal
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core/modal",["jquery","core/templates","core/notification","core/key_codes","core/custom_interaction_events","core/modal_backdrop","core_filters/events","core/modal_events","core/local/aria/focuslock","core/pending","core/aria","core/fullscreen"],(function($,Templates,Notification,KeyCodes,CustomEvents,ModalBackdrop,FilterEvents,ModalEvents,FocusLock,Pending,Aria,Fullscreen){var backdropPromise,SELECTORS_CONTAINER='[data-region="modal-container"]',SELECTORS_MODAL='[data-region="modal"]',SELECTORS_HEADER='[data-region="header"]',SELECTORS_TITLE='[data-region="title"]',SELECTORS_BODY='[data-region="body"]',SELECTORS_FOOTER='[data-region="footer"]',SELECTORS_HIDE='[data-action="hide"]',SELECTORS_DIALOG="[role=dialog]",SELECTORS_FORM="form",SELECTORS_MENU_BAR="[role=menubar]",SELECTORS_HAS_Z_INDEX=".moodle-has-zindex",TEMPLATES_LOADING="core/loading",TEMPLATES_BACKDROP="core/modal_backdrop",modalCounter=0,Modal=function(root){this.root=$(root),this.modal=this.root.find(SELECTORS_MODAL),this.header=this.modal.find(SELECTORS_HEADER),this.headerPromise=$.Deferred(),this.title=this.header.find(SELECTORS_TITLE),this.titlePromise=$.Deferred(),this.body=this.modal.find(SELECTORS_BODY),this.bodyPromise=$.Deferred(),this.footer=this.modal.find(SELECTORS_FOOTER),this.footerPromise=$.Deferred(),this.hiddenSiblings=[],this.isAttached=!1,this.bodyJS=null,this.footerJS=null,this.modalCount=modalCounter++,this.attachmentPoint=document.createElement("div"),document.body.append(this.attachmentPoint),this.focusOnClose=null,this.root.is(SELECTORS_CONTAINER)||Notification.exception({message:"Element is not a modal container"}),this.modal.length||Notification.exception({message:"Container does not contain a modal"}),this.header.length||Notification.exception({message:"Modal is missing a header region"}),this.title.length||Notification.exception({message:"Modal header is missing a title region"}),this.body.length||Notification.exception({message:"Modal is missing a body region"}),this.footer.length||Notification.exception({message:"Modal is missing a footer region"}),this.registerEventListeners()};return Modal.prototype.attachToDOM=function(){this.getAttachmentPoint().append(this.root),this.isAttached||(FocusLock.trapFocus(this.root[0]),this.bodyJS&&(Templates.runTemplateJS(this.bodyJS),this.bodyJS=null),this.footerJS&&(Templates.runTemplateJS(this.footerJS),this.footerJS=null),this.isAttached=!0)},Modal.prototype.countOtherVisibleModals=function(){var count=0;return $("body").find(SELECTORS_CONTAINER).each(function(index,element){element=$(element),!this.root.is(element)&&element.hasClass("show")&&count++}.bind(this)),count},Modal.prototype.getBackdrop=function(){return backdropPromise||(backdropPromise=Templates.render(TEMPLATES_BACKDROP,{}).then((function(html){var element=$(html);return new ModalBackdrop(element)})).fail(Notification.exception)),backdropPromise},Modal.prototype.getRoot=function(){return this.root},Modal.prototype.getModal=function(){return this.modal},Modal.prototype.getTitle=function(){return this.title},Modal.prototype.getBody=function(){return this.body},Modal.prototype.getFooter=function(){return this.footer},Modal.prototype.getTitlePromise=function(){return this.titlePromise},Modal.prototype.getBodyPromise=function(){return this.bodyPromise},Modal.prototype.getFooterPromise=function(){return this.footerPromise},Modal.prototype.getModalCount=function(){return this.modalCount},Modal.prototype.setTitle=function(value){var title=this.getTitle();this.titlePromise=$.Deferred(),this.asyncSet(value,title.html.bind(title)).then(function(){this.titlePromise.resolve(title)}.bind(this)).catch(Notification.exception)},Modal.prototype.setBody=function(value){this.bodyPromise=$.Deferred();var body=this.getBody();if("string"==typeof value)body.html(value),FilterEvents.notifyFilterContentUpdated(body),this.getRoot().trigger(ModalEvents.bodyRendered,this),this.bodyPromise.resolve(body);else{var jsPendingId="amd-modal-js-pending-id-"+this.getModalCount();M.util.js_pending(jsPendingId);var contentPromise=null;if(body.css("overflow","hidden"),"pending"==(value=$.when(value)).state()){var height=body.innerHeight();height<100&&(height=100),body.animate({height:height+"px"},150),body.html(""),contentPromise=Templates.render(TEMPLATES_LOADING,{}).then((function(html){var loadingIcon=$(html).hide();return body.html(loadingIcon),loadingIcon.fadeIn(150),$.when(loadingIcon.promise(),value)})).then((function(loadingIcon){return loadingIcon.fadeOut(100).promise()})).then((function(){return value}))}else contentPromise=value;contentPromise.then(function(html,js){var result=null;if(this.isVisible()){body.css("opacity",0);var currentHeight=body.innerHeight();body.html(html),body.css("height","");var newHeight=body.innerHeight();body.css("height",currentHeight+"px"),result=body.animate({height:newHeight+"px",opacity:1},{duration:150,queue:!1}).promise()}else body.html(html);return js&&(this.isAttached?Templates.runTemplateJS(js):this.bodyJS=js),result}.bind(this)).then(function(result){return FilterEvents.notifyFilterContentUpdated(body),this.getRoot().trigger(ModalEvents.bodyRendered,this),result}.bind(this)).then(function(){this.bodyPromise.resolve(body)}.bind(this)).fail(Notification.exception).always((function(){body.css("height",""),body.css("overflow",""),body.css("opacity",""),M.util.js_complete(jsPendingId)})).fail(Notification.exception)}},Modal.prototype.setBodyContent=function(promise){return promise.then((_ref=>{let{html:html,js:js}=_ref;return this.setBody($.when(html,js))})).catch((exception=>{throw this.hide(),exception}))},Modal.prototype.setFooter=function(value){this.showFooter(),this.footerPromise=$.Deferred();var footer=this.getFooter();"string"==typeof value?(footer.html(value),this.footerPromise.resolve(footer)):Templates.render(TEMPLATES_LOADING,{}).then((function(html){return footer.html(html),value})).then(function(html,js){return footer.html(html),js&&(this.isAttached?Templates.runTemplateJS(js):this.footerJS=js),footer}.bind(this)).then(function(footer){this.footerPromise.resolve(footer)}.bind(this)).catch(Notification.exception)},Modal.prototype.hasFooterContent=function(){return!!this.getFooter().children().length},Modal.prototype.hideFooter=function(){this.getFooter().addClass("hidden")},Modal.prototype.showFooter=function(){this.getFooter().removeClass("hidden")},Modal.prototype.setLarge=function(){this.isLarge()||this.getModal().addClass("modal-lg")},Modal.prototype.isLarge=function(){return this.getModal().hasClass("modal-lg")},Modal.prototype.setSmall=function(){this.isSmall()||this.getModal().removeClass("modal-lg")},Modal.prototype.isSmall=function(){return!this.getModal().hasClass("modal-lg")},Modal.prototype.setScrollable=function(value){value?this.getModal()[0].classList.add("modal-dialog-scrollable"):this.getModal()[0].classList.remove("modal-dialog-scrollable")},Modal.prototype.calculateZIndex=function(){var items=$(SELECTORS_DIALOG+", "+SELECTORS_MENU_BAR+", "+SELECTORS_HAS_Z_INDEX),zIndex=parseInt(this.root.css("z-index"));return items.each((function(index,item){var itemZIndex=(item=$(item)).css("z-index")?parseInt(item.css("z-index")):0;itemZIndex>zIndex&&(zIndex=itemZIndex)})),zIndex},Modal.prototype.isVisible=function(){return this.root.hasClass("show")},Modal.prototype.hasFocus=function(){var target=$(document.activeElement);return this.root.is(target)||this.root.has(target).length},Modal.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")},Modal.prototype.getAttachmentPoint=function(){return $(Fullscreen.getElement()||this.attachmentPoint)},Modal.prototype.show=function(){if(this.isVisible())return $.Deferred().resolve();var pendingPromise=new Pending("core/modal:show");return this.hasFooterContent()?this.showFooter():this.hideFooter(),this.attachToDOM(),!this.focusOnClose&&document.activeElement&&(this.focusOnClose=document.activeElement),this.getBackdrop().then(function(backdrop){var newIndex=this.calculateZIndex()+2,newBackdropIndex=newIndex-1;this.root.css("z-index",newIndex),backdrop.setZIndex(newBackdropIndex),backdrop.show(),this.root.removeClass("hide").addClass("show"),this.accessibilityShow(),this.getModal().focus(),$("body").addClass("modal-open"),this.root.trigger(ModalEvents.shown,this)}.bind(this)).then(pendingPromise.resolve)},Modal.prototype.hideIfNotForm=function(){0==this.modal.find(SELECTORS_FORM).length&&this.hide()},Modal.prototype.hide=function(){this.getBackdrop().done(function(backdrop){FocusLock.untrapFocus(),this.countOtherVisibleModals()||(backdrop.hide(),$("body").removeClass("modal-open"));var currentIndex=parseInt(this.root.css("z-index"));this.root.css("z-index",""),backdrop.setZIndex(currentIndex-3),this.accessibilityHide(),this.hasTransitions()?this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this)):this.getRoot().removeClass("show").addClass("hide"),$(document.body).find(this.getRoot()).length&&$(document.body).append(this.getRoot()),this.root.trigger(ModalEvents.hidden,this)}.bind(this))},Modal.prototype.destroy=function(){this.hide(),this.root.remove(),this.root.trigger(ModalEvents.destroyed,this),this.attachmentPoint.remove()},Modal.prototype.accessibilityShow=function(){Aria.unhide(this.root.get()),Aria.hideSiblings(this.root.get()[0])},Modal.prototype.accessibilityHide=function(){Aria.unhideSiblings(this.root.get()[0]),Aria.hide(this.root.get())},Modal.prototype.registerEventListeners=function(){this.getRoot().on("keydown",function(e){this.isVisible()&&e.keyCode==KeyCodes.escape&&(this.removeOnClose?this.destroy():this.hide())}.bind(this)),this.getRoot().click(function(e){if(!$(e.target).closest(SELECTORS_MODAL).length&&$(e.target).closest(SELECTORS_CONTAINER).length){var outsideClickEvent=$.Event(ModalEvents.outsideClick);this.getRoot().trigger(outsideClickEvent,this),outsideClickEvent.isDefaultPrevented()||this.hideIfNotForm()}}.bind(this)),CustomEvents.define(this.getModal(),[CustomEvents.events.activate]),this.getModal().on(CustomEvents.events.activate,SELECTORS_HIDE,function(e,data){this.removeOnClose?this.destroy():this.hide(),data.originalEvent.preventDefault()}.bind(this)),this.getRoot().on(ModalEvents.hidden,(()=>{this.focusOnClose&&this.focusOnClose.focus()}))},Modal.prototype.registerCloseOnCancel=function(){this.getModal().on(CustomEvents.events.activate,this.getActionSelector("cancel"),function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this),cancelEvent.isDefaultPrevented()||(data.originalEvent.preventDefault(),this.removeOnClose?this.destroy():this.hide())}.bind(this))},Modal.prototype.registerCloseOnSave=function(){this.getModal().on(CustomEvents.events.activate,this.getActionSelector("save"),function(e,data){var saveEvent=$.Event(ModalEvents.save);this.getRoot().trigger(saveEvent,this),saveEvent.isDefaultPrevented()||(data.originalEvent.preventDefault(),this.removeOnClose?this.destroy():this.hide())}.bind(this))},Modal.prototype.registerCloseOnDelete=function(){this.getModal().on(CustomEvents.events.activate,this.getActionSelector("delete"),function(e,data){var deleteEvent=$.Event(ModalEvents.delete);this.getRoot().trigger(deleteEvent,this),deleteEvent.isDefaultPrevented()||(data.originalEvent.preventDefault(),this.removeOnClose?this.destroy():this.hide())}.bind(this))},Modal.prototype.asyncSet=function(value,setFunction){var p=value;return"object"==typeof value&&value.hasOwnProperty("then")||(p=$.Deferred()).resolve(value),p.then((function(content){setFunction(content)})).fail(Notification.exception),p},Modal.prototype.setButtonText=function(action,value){const button=this.getFooter().find(this.getActionSelector(action));if(!button)throw new Error("Unable to find the '"+action+"' button");return this.asyncSet(value,button.text.bind(button))},Modal.prototype.getActionSelector=function(action){return"[data-action='"+action+"']"},Modal.prototype.setRemoveOnClose=function(remove){this.removeOnClose=remove},Modal.prototype.setReturnElement=function(element){this.focusOnClose=element},Modal.prototype.setButtonDisabled=function(action,disabled){const button=this.getFooter().find(this.getActionSelector(action));if(!button)throw new Error("Unable to find the '"+action+"' button");disabled?button.attr("disabled",""):button.removeAttr("disabled")},Modal}));
+define("core/modal",["exports","jquery","core/templates","core/notification","core/key_codes","core/modal_backdrop","core/modal_events","core/modal_registry","core/pending","core/custom_interaction_events","core_filters/events","core/local/aria/focuslock","core/aria","core/fullscreen"],(function(_exports,_jquery,Templates,Notification,KeyCodes,_modal_backdrop,_modal_events,ModalRegistry,_pending,CustomEvents,FilterEvents,FocusLock,Aria,Fullscreen){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),Templates=_interopRequireWildcard(Templates),Notification=_interopRequireWildcard(Notification),KeyCodes=_interopRequireWildcard(KeyCodes),_modal_backdrop=_interopRequireDefault(_modal_backdrop),_modal_events=_interopRequireDefault(_modal_events),ModalRegistry=_interopRequireWildcard(ModalRegistry),_pending=_interopRequireDefault(_pending),CustomEvents=_interopRequireWildcard(CustomEvents),FilterEvents=_interopRequireWildcard(FilterEvents),FocusLock=_interopRequireWildcard(FocusLock),Aria=_interopRequireWildcard(Aria),Fullscreen=_interopRequireWildcard(Fullscreen);const SELECTORS_CONTAINER='[data-region="modal-container"]',SELECTORS_MODAL='[data-region="modal"]',SELECTORS_HEADER='[data-region="header"]',SELECTORS_TITLE='[data-region="title"]',SELECTORS_BODY='[data-region="body"]',SELECTORS_FOOTER='[data-region="footer"]',SELECTORS_HIDE='[data-action="hide"]',SELECTORS_DIALOG="[role=dialog]",SELECTORS_FORM="form",SELECTORS_MENU_BAR="[role=menubar]",SELECTORS_HAS_Z_INDEX=".moodle-has-zindex",TEMPLATES_LOADING="core/loading",TEMPLATES_BACKDROP="core/modal_backdrop";class Modal{constructor(root){this.root=(0,_jquery.default)(root),this.modal=this.root.find(SELECTORS_MODAL),this.header=this.modal.find(SELECTORS_HEADER),this.headerPromise=_jquery.default.Deferred(),this.title=this.header.find(SELECTORS_TITLE),this.titlePromise=_jquery.default.Deferred(),this.body=this.modal.find(SELECTORS_BODY),this.bodyPromise=_jquery.default.Deferred(),this.footer=this.modal.find(SELECTORS_FOOTER),this.footerPromise=_jquery.default.Deferred(),this.hiddenSiblings=[],this.isAttached=!1,this.bodyJS=null,this.footerJS=null,this.modalCount=this.modalCounter++,this.attachmentPoint=document.createElement("div"),document.body.append(this.attachmentPoint),this.focusOnClose=null,this.root.is(SELECTORS_CONTAINER)||Notification.exception({message:"Element is not a modal container"}),this.modal.length||Notification.exception({message:"Container does not contain a modal"}),this.header.length||Notification.exception({message:"Modal is missing a header region"}),this.title.length||Notification.exception({message:"Modal header is missing a title region"}),this.body.length||Notification.exception({message:"Modal is missing a body region"}),this.footer.length||Notification.exception({message:"Modal is missing a footer region"}),this.registerEventListeners()}static registerModalType(){if(!this.TYPE)throw new Error("Unknown modal type",this);if(!this.TEMPLATE)throw new Error("Unknown modal template",this);ModalRegistry.register(this.TYPE,this,this.TEMPLATE)}attachToDOM(){this.getAttachmentPoint().append(this.root),this.isAttached||(FocusLock.trapFocus(this.root[0]),this.bodyJS&&(Templates.runTemplateJS(this.bodyJS),this.bodyJS=null),this.footerJS&&(Templates.runTemplateJS(this.footerJS),this.footerJS=null),this.isAttached=!0)}countOtherVisibleModals(){let count=0;return(0,_jquery.default)("body").find(SELECTORS_CONTAINER).each(((index,element)=>{element=(0,_jquery.default)(element),!this.root.is(element)&&element.hasClass("show")&&count++})),count}getBackdrop(){return Modal.backdropPromise||(Modal.backdropPromise=Templates.render(TEMPLATES_BACKDROP,{}).then((html=>new _modal_backdrop.default((0,_jquery.default)(html)))).catch(Notification.exception)),Modal.backdropPromise}getRoot(){return this.root}getModal(){return this.modal}getTitle(){return this.title}getBody(){return this.body}getFooter(){return this.footer}getTitlePromise(){return this.titlePromise}getBodyPromise(){return this.bodyPromise}getFooterPromise(){return this.footerPromise}getModalCount(){return this.modalCount}setTitle(value){const title=this.getTitle();this.titlePromise=_jquery.default.Deferred(),this.asyncSet(value,title.html.bind(title)).then((()=>{this.titlePromise.resolve(title)})).catch(Notification.exception)}setBody(value){this.bodyPromise=_jquery.default.Deferred();const body=this.getBody();if("string"==typeof value)body.html(value),FilterEvents.notifyFilterContentUpdated(body),this.getRoot().trigger(_modal_events.default.bodyRendered,this),this.bodyPromise.resolve(body);else{const modalPromise=new _pending.default("amd-modal-js-pending-id-".concat(this.getModalCount()));let contentPromise=null;if(body.css("overflow","hidden"),"pending"==(value=_jquery.default.when(value)).state()){let height=body.innerHeight();height<100&&(height=100),body.animate({height:"".concat(height,"px")},150),body.html(""),contentPromise=Templates.render(TEMPLATES_LOADING,{}).then((html=>{const loadingIcon=(0,_jquery.default)(html).hide();return body.html(loadingIcon),loadingIcon.fadeIn(150),_jquery.default.when(loadingIcon.promise(),value)})).then((loadingIcon=>loadingIcon.fadeOut(100).promise())).then((()=>value))}else contentPromise=value;contentPromise.then(((html,js)=>{let result=null;if(this.isVisible()){body.css("opacity",0);const currentHeight=body.innerHeight();body.html(html),body.css("height","");const newHeight=body.innerHeight();body.css("height","".concat(currentHeight,"px")),result=body.animate({height:"".concat(newHeight,"px"),opacity:1},{duration:150,queue:!1}).promise()}else body.html(html);return js&&(this.isAttached?Templates.runTemplateJS(js):this.bodyJS=js),result})).then((result=>(FilterEvents.notifyFilterContentUpdated(body),this.getRoot().trigger(_modal_events.default.bodyRendered,this),result))).then((()=>{this.bodyPromise.resolve(body)})).catch(Notification.exception).always((()=>{body.css("height",""),body.css("overflow",""),body.css("opacity",""),modalPromise.resolve()}))}}setBodyContent(promise){return promise.then((_ref=>{let{html:html,js:js}=_ref;return this.setBody(_jquery.default.when(html,js))})).catch((exception=>{throw this.hide(),exception}))}setFooter(value){this.showFooter(),this.footerPromise=_jquery.default.Deferred();const footer=this.getFooter();"string"==typeof value?(footer.html(value),this.footerPromise.resolve(footer)):Templates.render(TEMPLATES_LOADING,{}).then((html=>(footer.html(html),value))).then(((html,js)=>(footer.html(html),js&&(this.isAttached?Templates.runTemplateJS(js):this.footerJS=js),footer))).then((footer=>{this.footerPromise.resolve(footer)})).catch(Notification.exception)}hasFooterContent(){return!!this.getFooter().children().length}hideFooter(){this.getFooter().addClass("hidden")}showFooter(){this.getFooter().removeClass("hidden")}setLarge(){this.isLarge()||this.getModal().addClass("modal-lg")}isLarge(){return this.getModal().hasClass("modal-lg")}setSmall(){this.isSmall()||this.getModal().removeClass("modal-lg")}isSmall(){return!this.getModal().hasClass("modal-lg")}setScrollable(value){value?this.getModal()[0].classList.add("modal-dialog-scrollable"):this.getModal()[0].classList.remove("modal-dialog-scrollable")}calculateZIndex(){const items=(0,_jquery.default)("".concat(SELECTORS_DIALOG,", ").concat(SELECTORS_MENU_BAR,", ").concat(SELECTORS_HAS_Z_INDEX));let zIndex=parseInt(this.root.css("z-index"));return items.each(((index,item)=>{const itemZIndex=(item=(0,_jquery.default)(item)).css("z-index")?parseInt(item.css("z-index")):0;itemZIndex>zIndex&&(zIndex=itemZIndex)})),zIndex}isVisible(){return this.root.hasClass("show")}hasFocus(){const target=(0,_jquery.default)(document.activeElement);return this.root.is(target)||this.root.has(target).length}hasTransitions(){return this.getRoot().hasClass("fade")}getAttachmentPoint(){return(0,_jquery.default)(Fullscreen.getElement()||this.attachmentPoint)}show(){if(this.isVisible())return _jquery.default.Deferred().resolve();const pendingPromise=new _pending.default("core/modal:show");return this.hasFooterContent()?this.showFooter():this.hideFooter(),this.attachToDOM(),!this.focusOnClose&&document.activeElement&&(this.focusOnClose=document.activeElement),this.getBackdrop().then((backdrop=>{const newIndex=this.calculateZIndex()+2,newBackdropIndex=newIndex-1;this.root.css("z-index",newIndex),backdrop.setZIndex(newBackdropIndex),backdrop.show(),this.root.removeClass("hide").addClass("show"),this.accessibilityShow(),this.getModal().focus(),(0,_jquery.default)("body").addClass("modal-open"),this.root.trigger(_modal_events.default.shown,this)})).then(pendingPromise.resolve)}hideIfNotForm(){0==this.modal.find(SELECTORS_FORM).length&&this.hide()}hide(){this.getBackdrop().done((backdrop=>{FocusLock.untrapFocus(),this.countOtherVisibleModals()||(backdrop.hide(),(0,_jquery.default)("body").removeClass("modal-open"));const currentIndex=parseInt(this.root.css("z-index"));this.root.css("z-index",""),backdrop.setZIndex(currentIndex-3),this.accessibilityHide(),this.hasTransitions()?this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",(()=>{this.getRoot().removeClass("show").addClass("hide")})):this.getRoot().removeClass("show").addClass("hide"),(0,_jquery.default)(document.body).find(this.getRoot()).length&&(0,_jquery.default)(document.body).append(this.getRoot()),this.root.trigger(_modal_events.default.hidden,this)}))}destroy(){this.hide(),this.root.remove(),this.root.trigger(_modal_events.default.destroyed,this),this.attachmentPoint.remove()}accessibilityShow(){Aria.unhide(this.root.get()),Aria.hideSiblings(this.root.get()[0])}accessibilityHide(){Aria.unhideSiblings(this.root.get()[0]),Aria.hide(this.root.get())}registerEventListeners(){this.getRoot().on("keydown",(e=>{this.isVisible()&&e.keyCode==KeyCodes.escape&&(this.removeOnClose?this.destroy():this.hide())})),this.getRoot().click((e=>{if(!(0,_jquery.default)(e.target).closest(SELECTORS_MODAL).length&&(0,_jquery.default)(e.target).closest(SELECTORS_CONTAINER).length){const outsideClickEvent=_jquery.default.Event(_modal_events.default.outsideClick);this.getRoot().trigger(outsideClickEvent,this),outsideClickEvent.isDefaultPrevented()||this.hideIfNotForm()}})),CustomEvents.define(this.getModal(),[CustomEvents.events.activate]),this.getModal().on(CustomEvents.events.activate,SELECTORS_HIDE,((e,data)=>{this.removeOnClose?this.destroy():this.hide(),data.originalEvent.preventDefault()})),this.getRoot().on(_modal_events.default.hidden,(()=>{this.focusOnClose&&this.focusOnClose.focus()}))}registerCloseOnCancel(){this.getModal().on(CustomEvents.events.activate,this.getActionSelector("cancel"),((e,data)=>{const cancelEvent=_jquery.default.Event(_modal_events.default.cancel);this.getRoot().trigger(cancelEvent,this),cancelEvent.isDefaultPrevented()||(data.originalEvent.preventDefault(),this.removeOnClose?this.destroy():this.hide())}))}registerCloseOnSave(){this.getModal().on(CustomEvents.events.activate,this.getActionSelector("save"),((e,data)=>{const saveEvent=_jquery.default.Event(_modal_events.default.save);this.getRoot().trigger(saveEvent,this),saveEvent.isDefaultPrevented()||(data.originalEvent.preventDefault(),this.removeOnClose?this.destroy():this.hide())}))}registerCloseOnDelete(){this.getModal().on(CustomEvents.events.activate,this.getActionSelector("delete"),((e,data)=>{const deleteEvent=_jquery.default.Event(_modal_events.default.delete);this.getRoot().trigger(deleteEvent,this),deleteEvent.isDefaultPrevented()||(data.originalEvent.preventDefault(),this.removeOnClose?this.destroy():this.hide())}))}asyncSet(value,setFunction){var p=value;return"object"==typeof value&&value.hasOwnProperty("then")||(p=_jquery.default.Deferred()).resolve(value),p.then((content=>{setFunction(content)})).catch(Notification.exception),p}setButtonText(action,value){const button=this.getFooter().find(this.getActionSelector(action));if(!button)throw new Error("Unable to find the '"+action+"' button");return this.asyncSet(value,button.text.bind(button))}getActionSelector(action){return"[data-action='"+action+"']"}setRemoveOnClose(remove){this.removeOnClose=remove}setReturnElement(element){this.focusOnClose=element}setButtonDisabled(action,disabled){const button=this.getFooter().find(this.getActionSelector(action));if(!button)throw new Error("Unable to find the '"+action+"' button");disabled?button.attr("disabled",""):button.removeAttr("disabled")}}return _exports.default=Modal,_defineProperty(Modal,"TEMPLATE","core/modal"),_defineProperty(Modal,"backdropPromise",null),_defineProperty(Modal,"modalCounter",0),_exports.default}));
//# sourceMappingURL=modal.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal.min.js.map b/lib/amd/build/modal.min.js.map
index 498eecf481d..a1d4f0145b3 100644
--- a/lib/amd/build/modal.min.js.map
+++ b/lib/amd/build/modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for modals.\n *\n * @module core/modal\n * @class core/modal\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'core/key_codes',\n 'core/custom_interaction_events',\n 'core/modal_backdrop',\n 'core_filters/events',\n 'core/modal_events',\n 'core/local/aria/focuslock',\n 'core/pending',\n 'core/aria',\n 'core/fullscreen'\n], function(\n $,\n Templates,\n Notification,\n KeyCodes,\n CustomEvents,\n ModalBackdrop,\n FilterEvents,\n ModalEvents,\n FocusLock,\n Pending,\n Aria,\n Fullscreen\n) {\n\n var SELECTORS = {\n CONTAINER: '[data-region=\"modal-container\"]',\n MODAL: '[data-region=\"modal\"]',\n HEADER: '[data-region=\"header\"]',\n TITLE: '[data-region=\"title\"]',\n BODY: '[data-region=\"body\"]',\n FOOTER: '[data-region=\"footer\"]',\n HIDE: '[data-action=\"hide\"]',\n DIALOG: '[role=dialog]',\n FORM: 'form',\n MENU_BAR: '[role=menubar]',\n HAS_Z_INDEX: '.moodle-has-zindex',\n CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n };\n\n var TEMPLATES = {\n LOADING: 'core/loading',\n BACKDROP: 'core/modal_backdrop',\n };\n\n /**\n * Module singleton for the backdrop to be reused by all Modal instances.\n */\n var backdropPromise;\n\n /**\n * A counter that gets incremented for each modal created. This can be\n * used to generate unique values for the modals.\n */\n var modalCounter = 0;\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var Modal = function(root) {\n this.root = $(root);\n this.modal = this.root.find(SELECTORS.MODAL);\n this.header = this.modal.find(SELECTORS.HEADER);\n this.headerPromise = $.Deferred();\n this.title = this.header.find(SELECTORS.TITLE);\n this.titlePromise = $.Deferred();\n this.body = this.modal.find(SELECTORS.BODY);\n this.bodyPromise = $.Deferred();\n this.footer = this.modal.find(SELECTORS.FOOTER);\n this.footerPromise = $.Deferred();\n this.hiddenSiblings = [];\n this.isAttached = false;\n this.bodyJS = null;\n this.footerJS = null;\n this.modalCount = modalCounter++;\n this.attachmentPoint = document.createElement('div');\n document.body.append(this.attachmentPoint);\n this.focusOnClose = null;\n\n if (!this.root.is(SELECTORS.CONTAINER)) {\n Notification.exception({message: 'Element is not a modal container'});\n }\n\n if (!this.modal.length) {\n Notification.exception({message: 'Container does not contain a modal'});\n }\n\n if (!this.header.length) {\n Notification.exception({message: 'Modal is missing a header region'});\n }\n\n if (!this.title.length) {\n Notification.exception({message: 'Modal header is missing a title region'});\n }\n\n if (!this.body.length) {\n Notification.exception({message: 'Modal is missing a body region'});\n }\n\n if (!this.footer.length) {\n Notification.exception({message: 'Modal is missing a footer region'});\n }\n\n this.registerEventListeners();\n };\n\n /**\n * Attach the modal to the correct part of the page.\n *\n * If it hasn't already been added it runs any\n * javascript that has been cached until now.\n *\n * @method attachToDOM\n */\n Modal.prototype.attachToDOM = function() {\n this.getAttachmentPoint().append(this.root);\n\n if (this.isAttached) {\n return;\n }\n\n FocusLock.trapFocus(this.root[0]);\n\n // If we'd cached any JS then we can run it how that the modal is\n // attached to the DOM.\n if (this.bodyJS) {\n Templates.runTemplateJS(this.bodyJS);\n this.bodyJS = null;\n }\n\n if (this.footerJS) {\n Templates.runTemplateJS(this.footerJS);\n this.footerJS = null;\n }\n\n this.isAttached = true;\n };\n\n /**\n * Count the number of other visible modals (not including this one).\n *\n * @method countOtherVisibleModals\n * @return {int}\n */\n Modal.prototype.countOtherVisibleModals = function() {\n var count = 0;\n $('body').find(SELECTORS.CONTAINER).each(function(index, element) {\n element = $(element);\n\n // If we haven't found ourself and the element is visible.\n if (!this.root.is(element) && element.hasClass('show')) {\n count++;\n }\n }.bind(this));\n\n return count;\n };\n\n /**\n * Get the modal backdrop.\n *\n * @method getBackdrop\n * @return {object} jQuery promise\n */\n Modal.prototype.getBackdrop = function() {\n if (!backdropPromise) {\n backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})\n .then(function(html) {\n var element = $(html);\n\n return new ModalBackdrop(element);\n })\n .fail(Notification.exception);\n }\n\n return backdropPromise;\n };\n\n /**\n * Get the root element of this modal.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n Modal.prototype.getRoot = function() {\n return this.root;\n };\n\n /**\n * Get the modal element of this modal.\n *\n * @method getModal\n * @return {object} jQuery object\n */\n Modal.prototype.getModal = function() {\n return this.modal;\n };\n\n /**\n * Get the modal title element.\n *\n * @method getTitle\n * @return {object} jQuery object\n */\n Modal.prototype.getTitle = function() {\n return this.title;\n };\n\n /**\n * Get the modal body element.\n *\n * @method getBody\n * @return {object} jQuery object\n */\n Modal.prototype.getBody = function() {\n return this.body;\n };\n\n /**\n * Get the modal footer element.\n *\n * @method getFooter\n * @return {object} jQuery object\n */\n Modal.prototype.getFooter = function() {\n return this.footer;\n };\n\n /**\n * Get a promise resolving to the title region.\n *\n * @method getTitlePromise\n * @return {Promise}\n */\n Modal.prototype.getTitlePromise = function() {\n return this.titlePromise;\n };\n\n /**\n * Get a promise resolving to the body region.\n *\n * @method getBodyPromise\n * @return {object} jQuery object\n */\n Modal.prototype.getBodyPromise = function() {\n return this.bodyPromise;\n };\n\n /**\n * Get a promise resolving to the footer region.\n *\n * @method getFooterPromise\n * @return {object} jQuery object\n */\n Modal.prototype.getFooterPromise = function() {\n return this.footerPromise;\n };\n\n /**\n * Get the unique modal count.\n *\n * @method getModalCount\n * @return {int}\n */\n Modal.prototype.getModalCount = function() {\n return this.modalCount;\n };\n\n /**\n * Set the modal title element.\n *\n * This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with\n * HTML most commonly from a Str.get_string call.\n *\n * @method setTitle\n * @param {(string|object)} value The title string or jQuery promise which resolves to the title.\n */\n Modal.prototype.setTitle = function(value) {\n var title = this.getTitle();\n this.titlePromise = $.Deferred();\n\n this.asyncSet(value, title.html.bind(title))\n .then(function() {\n this.titlePromise.resolve(title);\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Set the modal body element.\n *\n * This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with\n * HTML and Javascript most commonly from a Templates.render call.\n *\n * @method setBody\n * @param {(string|object)} value The body string or jQuery promise which resolves to the body.\n * @fires event:filterContentUpdated\n */\n Modal.prototype.setBody = function(value) {\n this.bodyPromise = $.Deferred();\n\n var body = this.getBody();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n body.html(value);\n FilterEvents.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n this.bodyPromise.resolve(body);\n } else {\n var jsPendingId = 'amd-modal-js-pending-id-' + this.getModalCount();\n M.util.js_pending(jsPendingId);\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n var contentPromise = null;\n body.css('overflow', 'hidden');\n\n // Ensure that the `value` is a jQuery Promise.\n value = $.when(value);\n\n if (value.state() == 'pending') {\n // We're still waiting for the body promise to resolve so\n // let's show a loading icon.\n var height = body.innerHeight();\n if (height < 100) {\n height = 100;\n }\n\n body.animate({height: height + 'px'}, 150);\n\n body.html('');\n contentPromise = Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n var loadingIcon = $(html).hide();\n body.html(loadingIcon);\n loadingIcon.fadeIn(150);\n\n // We only want the loading icon to fade out\n // when the content for the body has finished\n // loading.\n return $.when(loadingIcon.promise(), value);\n })\n .then(function(loadingIcon) {\n // Once the content has finished loading and\n // the loading icon has been shown then we can\n // fade the icon away to reveal the content.\n return loadingIcon.fadeOut(100).promise();\n })\n .then(function() {\n return value;\n });\n } else {\n // The content is already loaded so let's just display\n // it to the user. No need for a loading icon.\n contentPromise = value;\n }\n\n // Now we can actually display the content.\n contentPromise.then(function(html, js) {\n var result = null;\n\n if (this.isVisible()) {\n // If the modal is visible then we should display\n // the content gracefully for the user.\n body.css('opacity', 0);\n var currentHeight = body.innerHeight();\n body.html(html);\n // We need to clear any height values we've set here\n // in order to measure the height of the content being\n // added. This then allows us to animate the height\n // transition.\n body.css('height', '');\n var newHeight = body.innerHeight();\n body.css('height', currentHeight + 'px');\n result = body.animate(\n {height: newHeight + 'px', opacity: 1},\n {duration: 150, queue: false}\n ).promise();\n } else {\n // Since the modal isn't visible we can just immediately\n // set the content. No need to animate it.\n body.html(html);\n }\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.bodyJS = js;\n }\n }\n\n return result;\n }.bind(this))\n .then(function(result) {\n FilterEvents.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n return result;\n }.bind(this))\n .then(function() {\n this.bodyPromise.resolve(body);\n return;\n }.bind(this))\n .fail(Notification.exception)\n .always(function() {\n // When we're done displaying all of the content we need\n // to clear the custom values we've set here.\n body.css('height', '');\n body.css('overflow', '');\n body.css('opacity', '');\n M.util.js_complete(jsPendingId);\n\n return;\n })\n .fail(Notification.exception);\n }\n };\n\n /**\n * Alternative to setBody() that can be used from non-Jquery modules\n *\n * @param {Promise} promise promise that returns {html, js} object\n * @return {Promise}\n */\n Modal.prototype.setBodyContent = function(promise) {\n // Call the leegacy API for now and pass it a jQuery Promise.\n // This is a non-spec feature of jQuery and cannot be produced with spec promises.\n // We can encourage people to migrate to this approach, and in future we can swap\n // it so that setBody() calls setBodyPromise().\n return promise.then(({html, js}) => this.setBody($.when(html, js)))\n .catch(exception => {\n this.hide();\n throw exception;\n });\n };\n\n /**\n * Set the modal footer element. The footer element is made visible, if it\n * isn't already.\n *\n * This method is overloaded to take either a string\n * value for the body or a jQuery promise that is resolved with HTML and Javascript\n * most commonly from a Templates.render call.\n *\n * @method setFooter\n * @param {(string|object)} value The footer string or jQuery promise\n */\n Modal.prototype.setFooter = function(value) {\n // Make sure the footer is visible.\n this.showFooter();\n this.footerPromise = $.Deferred();\n\n var footer = this.getFooter();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n footer.html(value);\n this.footerPromise.resolve(footer);\n } else {\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n footer.html(html);\n\n return value;\n })\n .then(function(html, js) {\n footer.html(html);\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.footerJS = js;\n }\n }\n\n return footer;\n }.bind(this))\n .then(function(footer) {\n this.footerPromise.resolve(footer);\n return;\n }.bind(this))\n .catch(Notification.exception);\n }\n };\n\n /**\n * Check if the footer has any content in it.\n *\n * @method hasFooterContent\n * @return {bool}\n */\n Modal.prototype.hasFooterContent = function() {\n return this.getFooter().children().length ? true : false;\n };\n\n /**\n * Hide the footer element.\n *\n * @method hideFooter\n */\n Modal.prototype.hideFooter = function() {\n this.getFooter().addClass('hidden');\n };\n\n /**\n * Show the footer element.\n *\n * @method showFooter\n */\n Modal.prototype.showFooter = function() {\n this.getFooter().removeClass('hidden');\n };\n\n /**\n * Mark the modal as a large modal.\n *\n * @method setLarge\n */\n Modal.prototype.setLarge = function() {\n if (this.isLarge()) {\n return;\n }\n\n this.getModal().addClass('modal-lg');\n };\n\n /**\n * Check if the modal is a large modal.\n *\n * @method isLarge\n * @return {bool}\n */\n Modal.prototype.isLarge = function() {\n return this.getModal().hasClass('modal-lg');\n };\n\n /**\n * Mark the modal as a small modal.\n *\n * @method setSmall\n */\n Modal.prototype.setSmall = function() {\n if (this.isSmall()) {\n return;\n }\n\n this.getModal().removeClass('modal-lg');\n };\n\n /**\n * Check if the modal is a small modal.\n *\n * @method isSmall\n * @return {bool}\n */\n Modal.prototype.isSmall = function() {\n return !this.getModal().hasClass('modal-lg');\n };\n\n /**\n * Set this modal to be scrollable or not.\n *\n * @method setScrollable\n * @param {bool} value Whether the modal is scrollable or not\n */\n Modal.prototype.setScrollable = function(value) {\n if (!value) {\n this.getModal()[0].classList.remove('modal-dialog-scrollable');\n return;\n }\n\n this.getModal()[0].classList.add('modal-dialog-scrollable');\n };\n\n\n /**\n * Determine the highest z-index value currently on the page.\n *\n * @method calculateZIndex\n * @return {int}\n */\n Modal.prototype.calculateZIndex = function() {\n var items = $(SELECTORS.DIALOG + ', ' + SELECTORS.MENU_BAR + ', ' + SELECTORS.HAS_Z_INDEX);\n var zIndex = parseInt(this.root.css('z-index'));\n\n items.each(function(index, item) {\n item = $(item);\n // Note that webkit browsers won't return the z-index value from the CSS stylesheet\n // if the element doesn't have a position specified. Instead it'll return \"auto\".\n var itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;\n\n if (itemZIndex > zIndex) {\n zIndex = itemZIndex;\n }\n });\n\n return zIndex;\n };\n\n /**\n * Check if this modal is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n Modal.prototype.isVisible = function() {\n return this.root.hasClass('show');\n };\n\n /**\n * Check if this modal has focus.\n *\n * @method hasFocus\n * @return {bool}\n */\n Modal.prototype.hasFocus = function() {\n var target = $(document.activeElement);\n return this.root.is(target) || this.root.has(target).length;\n };\n\n /**\n * Check if this modal has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n Modal.prototype.hasTransitions = function() {\n return this.getRoot().hasClass('fade');\n };\n\n /**\n * Gets the jQuery wrapped node that the Modal should be attached to.\n *\n * @returns {jQuery}\n */\n Modal.prototype.getAttachmentPoint = function() {\n return $(Fullscreen.getElement() || this.attachmentPoint);\n };\n\n /**\n * Display this modal. The modal will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n * @returns {Promise}\n */\n Modal.prototype.show = function() {\n if (this.isVisible()) {\n return $.Deferred().resolve();\n }\n\n var pendingPromise = new Pending('core/modal:show');\n\n if (this.hasFooterContent()) {\n this.showFooter();\n } else {\n this.hideFooter();\n }\n\n this.attachToDOM();\n\n // If the focusOnClose was not set. Set the focus back to triggered element.\n if (!this.focusOnClose && document.activeElement) {\n this.focusOnClose = document.activeElement;\n }\n\n return this.getBackdrop()\n .then(function(backdrop) {\n var currentIndex = this.calculateZIndex();\n var newIndex = currentIndex + 2;\n var newBackdropIndex = newIndex - 1;\n this.root.css('z-index', newIndex);\n backdrop.setZIndex(newBackdropIndex);\n backdrop.show();\n\n this.root.removeClass('hide').addClass('show');\n this.accessibilityShow();\n this.getModal().focus();\n $('body').addClass('modal-open');\n this.root.trigger(ModalEvents.shown, this);\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve);\n };\n\n /**\n * Hide this modal if it does not contain a form.\n *\n * @method hideIfNotForm\n */\n Modal.prototype.hideIfNotForm = function() {\n var formElement = this.modal.find(SELECTORS.FORM);\n if (formElement.length == 0) {\n this.hide();\n }\n };\n\n /**\n * Hide this modal.\n *\n * @method hide\n */\n Modal.prototype.hide = function() {\n this.getBackdrop().done(function(backdrop) {\n FocusLock.untrapFocus();\n\n if (!this.countOtherVisibleModals()) {\n // Hide the backdrop if we're the last open modal.\n backdrop.hide();\n $('body').removeClass('modal-open');\n }\n\n var currentIndex = parseInt(this.root.css('z-index'));\n this.root.css('z-index', '');\n backdrop.setZIndex(currentIndex - 3);\n\n this.accessibilityHide();\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {\n this.getRoot().removeClass('show').addClass('hide');\n }.bind(this));\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n // Ensure the modal is moved onto the body node if it is still attached to the DOM.\n if ($(document.body).find(this.getRoot()).length) {\n $(document.body).append(this.getRoot());\n }\n\n this.root.trigger(ModalEvents.hidden, this);\n }.bind(this));\n };\n\n /**\n * Remove this modal from the DOM.\n *\n * @method destroy\n */\n Modal.prototype.destroy = function() {\n this.hide();\n this.root.remove();\n this.root.trigger(ModalEvents.destroyed, this);\n this.attachmentPoint.remove();\n };\n\n /**\n * Sets the appropriate aria attributes on this dialogue and the other\n * elements in the DOM to ensure that screen readers are able to navigate\n * the dialogue popup correctly.\n *\n * @method accessibilityShow\n */\n Modal.prototype.accessibilityShow = function() {\n // Make us visible to screen readers.\n Aria.unhide(this.root.get());\n\n // Hide siblings.\n Aria.hideSiblings(this.root.get()[0]);\n };\n\n /**\n * Restores the aria visibility on the DOM elements changed when displaying\n * the dialogue popup and makes the dialogue aria hidden to allow screen\n * readers to navigate the main page correctly when the dialogue is closed.\n *\n * @method accessibilityHide\n */\n Modal.prototype.accessibilityHide = function() {\n // Unhide siblings.\n Aria.unhideSiblings(this.root.get()[0]);\n\n // Hide this modal.\n Aria.hide(this.root.get());\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n Modal.prototype.registerEventListeners = function() {\n this.getRoot().on('keydown', function(e) {\n if (!this.isVisible()) {\n return;\n }\n\n if (e.keyCode == KeyCodes.escape) {\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n\n // Listen for clicks on the modal container.\n this.getRoot().click(function(e) {\n // If the click wasn't inside the modal element then we should\n // hide the modal.\n if (!$(e.target).closest(SELECTORS.MODAL).length) {\n // The check above fails to detect the click was inside the modal when the DOM tree is already changed.\n // So, we check if we can still find the container element or not. If not, then the DOM tree is changed.\n // It's best not to hide the modal in that case.\n if ($(e.target).closest(SELECTORS.CONTAINER).length) {\n var outsideClickEvent = $.Event(ModalEvents.outsideClick);\n this.getRoot().trigger(outsideClickEvent, this);\n\n if (!outsideClickEvent.isDefaultPrevented()) {\n this.hideIfNotForm();\n }\n }\n }\n }.bind(this));\n\n CustomEvents.define(this.getModal(), [CustomEvents.events.activate]);\n this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, function(e, data) {\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n data.originalEvent.preventDefault();\n }.bind(this));\n\n this.getRoot().on(ModalEvents.hidden, () => {\n if (this.focusOnClose) {\n // Focus on the element that actually triggers the modal.\n this.focusOnClose.focus();\n }\n });\n };\n\n /**\n * Register a listener to close the dialogue when the cancel button is pressed.\n *\n * @method registerCloseOnCancel\n */\n Modal.prototype.registerCloseOnCancel = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('cancel'), function(e, data) {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n /**\n * Register a listener to close the dialogue when the save button is pressed.\n *\n * @method registerCloseOnSave\n */\n Modal.prototype.registerCloseOnSave = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), function(e, data) {\n var saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n\n /**\n * Register a listener to close the dialogue when the delete button is pressed.\n *\n * @method registerCloseOnDelete\n */\n Modal.prototype.registerCloseOnDelete = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('delete'), function(e, data) {\n var deleteEvent = $.Event(ModalEvents.delete);\n this.getRoot().trigger(deleteEvent, this);\n\n if (!deleteEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n /**\n * Set or resolve and set the value using the function.\n *\n * @method asyncSet\n * @param {(string|object)} value The string or jQuery promise.\n * @param {function} setFunction The setter\n * @return {Promise}\n */\n Modal.prototype.asyncSet = function(value, setFunction) {\n var p = value;\n if (typeof value !== 'object' || !value.hasOwnProperty('then')) {\n p = $.Deferred();\n p.resolve(value);\n }\n\n p.then(function(content) {\n setFunction(content);\n\n return;\n })\n .fail(Notification.exception);\n\n return p;\n };\n\n /**\n * Set the title text of a button.\n *\n * This method is overloaded to take either a string value for the button title or a jQuery promise that is resolved with\n * text most commonly from a Str.get_string call.\n *\n * @param {DOMString} action The action of the button\n * @param {(String|object)} value The button text, or a promise which will resolve to it\n * @returns {Promise}\n */\n Modal.prototype.setButtonText = function(action, value) {\n const button = this.getFooter().find(this.getActionSelector(action));\n\n if (!button) {\n throw new Error(\"Unable to find the '\" + action + \"' button\");\n }\n\n return this.asyncSet(value, button.text.bind(button));\n };\n\n /**\n * Get the Selector for an action.\n *\n * @param {String} action\n * @returns {DOMString}\n */\n Modal.prototype.getActionSelector = function(action) {\n return \"[data-action='\" + action + \"']\";\n };\n\n /**\n * Set the flag to remove the modal from the DOM on close.\n *\n * @param {Boolean} remove\n */\n Modal.prototype.setRemoveOnClose = function(remove) {\n this.removeOnClose = remove;\n };\n\n /**\n * Set the return element for the modal.\n *\n * @param {Element|jQuery} element Element to focus when the modal is closed\n */\n Modal.prototype.setReturnElement = function(element) {\n this.focusOnClose = element;\n };\n\n /**\n * Set the a button enabled or disabled.\n *\n * @param {DOMString} action The action of the button\n * @param {Boolean} disabled the new disabled value\n */\n Modal.prototype.setButtonDisabled = function(action, disabled) {\n const button = this.getFooter().find(this.getActionSelector(action));\n\n if (!button) {\n throw new Error(\"Unable to find the '\" + action + \"' button\");\n }\n if (disabled) {\n button.attr('disabled', '');\n } else {\n button.removeAttr('disabled');\n }\n };\n\n return Modal;\n});\n"],"names":["define","$","Templates","Notification","KeyCodes","CustomEvents","ModalBackdrop","FilterEvents","ModalEvents","FocusLock","Pending","Aria","Fullscreen","backdropPromise","SELECTORS","TEMPLATES","modalCounter","Modal","root","modal","this","find","header","headerPromise","Deferred","title","titlePromise","body","bodyPromise","footer","footerPromise","hiddenSiblings","isAttached","bodyJS","footerJS","modalCount","attachmentPoint","document","createElement","append","focusOnClose","is","exception","message","length","registerEventListeners","prototype","attachToDOM","getAttachmentPoint","trapFocus","runTemplateJS","countOtherVisibleModals","count","each","index","element","hasClass","bind","getBackdrop","render","then","html","fail","getRoot","getModal","getTitle","getBody","getFooter","getTitlePromise","getBodyPromise","getFooterPromise","getModalCount","setTitle","value","asyncSet","resolve","catch","setBody","notifyFilterContentUpdated","trigger","bodyRendered","jsPendingId","M","util","js_pending","contentPromise","css","when","state","height","innerHeight","animate","loadingIcon","hide","fadeIn","promise","fadeOut","js","result","isVisible","currentHeight","newHeight","opacity","duration","queue","always","js_complete","setBodyContent","_ref","setFooter","showFooter","hasFooterContent","children","hideFooter","addClass","removeClass","setLarge","isLarge","setSmall","isSmall","setScrollable","classList","add","remove","calculateZIndex","items","zIndex","parseInt","item","itemZIndex","hasFocus","target","activeElement","has","hasTransitions","getElement","show","pendingPromise","backdrop","newIndex","newBackdropIndex","setZIndex","accessibilityShow","focus","shown","hideIfNotForm","done","untrapFocus","currentIndex","accessibilityHide","one","hidden","destroy","destroyed","unhide","get","hideSiblings","unhideSiblings","on","e","keyCode","escape","removeOnClose","click","closest","outsideClickEvent","Event","outsideClick","isDefaultPrevented","events","activate","data","originalEvent","preventDefault","registerCloseOnCancel","getActionSelector","cancelEvent","cancel","registerCloseOnSave","saveEvent","save","registerCloseOnDelete","deleteEvent","delete","setFunction","p","hasOwnProperty","content","setButtonText","action","button","Error","text","setRemoveOnClose","setReturnElement","setButtonDisabled","disabled","attr","removeAttr"],"mappings":";;;;;;;;AAuBAA,oBAAO,CACH,SACA,iBACA,oBACA,iBACA,iCACA,sBACA,sBACA,oBACA,4BACA,eACA,YACA,oBACD,SACCC,EACAC,UACAC,aACAC,SACAC,aACAC,cACAC,aACAC,YACAC,UACAC,QACAC,KACAC,gBA0BIC,gBAvBAC,oBACW,kCADXA,gBAEO,wBAFPA,iBAGQ,yBAHRA,gBAIO,wBAJPA,eAKM,uBALNA,iBAMQ,yBANRA,eAOM,uBAPNA,iBAQQ,gBARRA,eASM,OATNA,mBAUU,iBAVVA,sBAWa,qBAIbC,kBACS,eADTA,mBAEU,sBAYVC,aAAe,EAOfC,MAAQ,SAASC,WACZA,KAAOjB,EAAEiB,WACTC,MAAQC,KAAKF,KAAKG,KAAKP,sBACvBQ,OAASF,KAAKD,MAAME,KAAKP,uBACzBS,cAAgBtB,EAAEuB,gBAClBC,MAAQL,KAAKE,OAAOD,KAAKP,sBACzBY,aAAezB,EAAEuB,gBACjBG,KAAOP,KAAKD,MAAME,KAAKP,qBACvBc,YAAc3B,EAAEuB,gBAChBK,OAAST,KAAKD,MAAME,KAAKP,uBACzBgB,cAAgB7B,EAAEuB,gBAClBO,eAAiB,QACjBC,YAAa,OACbC,OAAS,UACTC,SAAW,UACXC,WAAanB,oBACboB,gBAAkBC,SAASC,cAAc,OAC9CD,SAASV,KAAKY,OAAOnB,KAAKgB,sBACrBI,aAAe,KAEfpB,KAAKF,KAAKuB,GAAG3B,sBACdX,aAAauC,UAAU,CAACC,QAAS,qCAGhCvB,KAAKD,MAAMyB,QACZzC,aAAauC,UAAU,CAACC,QAAS,uCAGhCvB,KAAKE,OAAOsB,QACbzC,aAAauC,UAAU,CAACC,QAAS,qCAGhCvB,KAAKK,MAAMmB,QACZzC,aAAauC,UAAU,CAACC,QAAS,2CAGhCvB,KAAKO,KAAKiB,QACXzC,aAAauC,UAAU,CAACC,QAAS,mCAGhCvB,KAAKS,OAAOe,QACbzC,aAAauC,UAAU,CAACC,QAAS,0CAGhCE,iCAWT5B,MAAM6B,UAAUC,YAAc,gBACrBC,qBAAqBT,OAAOnB,KAAKF,MAElCE,KAAKY,aAITvB,UAAUwC,UAAU7B,KAAKF,KAAK,IAI1BE,KAAKa,SACL/B,UAAUgD,cAAc9B,KAAKa,aACxBA,OAAS,MAGdb,KAAKc,WACLhC,UAAUgD,cAAc9B,KAAKc,eACxBA,SAAW,WAGfF,YAAa,IAStBf,MAAM6B,UAAUK,wBAA0B,eAClCC,MAAQ,SACZnD,EAAE,QAAQoB,KAAKP,qBAAqBuC,KAAK,SAASC,MAAOC,SACrDA,QAAUtD,EAAEsD,UAGPnC,KAAKF,KAAKuB,GAAGc,UAAYA,QAAQC,SAAS,SAC3CJ,SAENK,KAAKrC,OAEAgC,OASXnC,MAAM6B,UAAUY,YAAc,kBACrB7C,kBACDA,gBAAkBX,UAAUyD,OAAO5C,mBAAoB,IAClD6C,MAAK,SAASC,UACPN,QAAUtD,EAAE4D,aAET,IAAIvD,cAAciD,YAE5BO,KAAK3D,aAAauC,YAGpB7B,iBASXI,MAAM6B,UAAUiB,QAAU,kBACf3C,KAAKF,MAShBD,MAAM6B,UAAUkB,SAAW,kBAChB5C,KAAKD,OAShBF,MAAM6B,UAAUmB,SAAW,kBAChB7C,KAAKK,OAShBR,MAAM6B,UAAUoB,QAAU,kBACf9C,KAAKO,MAShBV,MAAM6B,UAAUqB,UAAY,kBACjB/C,KAAKS,QAShBZ,MAAM6B,UAAUsB,gBAAkB,kBACvBhD,KAAKM,cAShBT,MAAM6B,UAAUuB,eAAiB,kBACtBjD,KAAKQ,aAShBX,MAAM6B,UAAUwB,iBAAmB,kBACxBlD,KAAKU,eAShBb,MAAM6B,UAAUyB,cAAgB,kBACrBnD,KAAKe,YAYhBlB,MAAM6B,UAAU0B,SAAW,SAASC,WAC5BhD,MAAQL,KAAK6C,gBACZvC,aAAezB,EAAEuB,gBAEjBkD,SAASD,MAAOhD,MAAMoC,KAAKJ,KAAKhC,QACpCmC,KAAK,gBACGlC,aAAaiD,QAAQlD,QAC5BgC,KAAKrC,OACNwD,MAAMzE,aAAauC,YAaxBzB,MAAM6B,UAAU+B,QAAU,SAASJ,YAC1B7C,YAAc3B,EAAEuB,eAEjBG,KAAOP,KAAK8C,aAEK,iBAAVO,MAEP9C,KAAKkC,KAAKY,OACVlE,aAAauE,2BAA2BnD,WACnCoC,UAAUgB,QAAQvE,YAAYwE,aAAc5D,WAC5CQ,YAAY+C,QAAQhD,UACtB,KACCsD,YAAc,2BAA6B7D,KAAKmD,gBACpDW,EAAEC,KAAKC,WAAWH,iBAGdI,eAAiB,QACrB1D,KAAK2D,IAAI,WAAY,UAKA,YAFrBb,MAAQxE,EAAEsF,KAAKd,QAELe,QAAsB,KAGxBC,OAAS9D,KAAK+D,cACdD,OAAS,MACTA,OAAS,KAGb9D,KAAKgE,QAAQ,CAACF,OAAQA,OAAS,MAAO,KAEtC9D,KAAKkC,KAAK,IACVwB,eAAiBnF,UAAUyD,OAAO5C,kBAAmB,IAChD6C,MAAK,SAASC,UACP+B,YAAc3F,EAAE4D,MAAMgC,cAC1BlE,KAAKkC,KAAK+B,aACVA,YAAYE,OAAO,KAKZ7F,EAAEsF,KAAKK,YAAYG,UAAWtB,UAExCb,MAAK,SAASgC,oBAIJA,YAAYI,QAAQ,KAAKD,aAEnCnC,MAAK,kBACKa,cAKfY,eAAiBZ,MAIrBY,eAAezB,KAAK,SAASC,KAAMoC,QAC3BC,OAAS,QAET9E,KAAK+E,YAAa,CAGlBxE,KAAK2D,IAAI,UAAW,OAChBc,cAAgBzE,KAAK+D,cACzB/D,KAAKkC,KAAKA,MAKVlC,KAAK2D,IAAI,SAAU,QACfe,UAAY1E,KAAK+D,cACrB/D,KAAK2D,IAAI,SAAUc,cAAgB,MACnCF,OAASvE,KAAKgE,QACV,CAACF,OAAQY,UAAY,KAAMC,QAAS,GACpC,CAACC,SAAU,IAAKC,OAAO,IACzBT,eAIFpE,KAAKkC,KAAKA,aAGVoC,KACI7E,KAAKY,WAEL9B,UAAUgD,cAAc+C,SAGnBhE,OAASgE,IAIfC,QACTzC,KAAKrC,OACNwC,KAAK,SAASsC,eACX3F,aAAauE,2BAA2BnD,WACnCoC,UAAUgB,QAAQvE,YAAYwE,aAAc5D,MAC1C8E,QACTzC,KAAKrC,OACNwC,KAAK,gBACGhC,YAAY+C,QAAQhD,OAE3B8B,KAAKrC,OACN0C,KAAK3D,aAAauC,WAClB+D,QAAO,WAGJ9E,KAAK2D,IAAI,SAAU,IACnB3D,KAAK2D,IAAI,WAAY,IACrB3D,KAAK2D,IAAI,UAAW,IACpBJ,EAAEC,KAAKuB,YAAYzB,gBAItBnB,KAAK3D,aAAauC,aAU3BzB,MAAM6B,UAAU6D,eAAiB,SAASZ,gBAK/BA,QAAQnC,MAAKgD,WAAC/C,KAACA,KAADoC,GAAOA,gBAAQ7E,KAAKyD,QAAQ5E,EAAEsF,KAAK1B,KAAMoC,QACzDrB,OAAMlC,uBACEmD,OACCnD,cAelBzB,MAAM6B,UAAU+D,UAAY,SAASpC,YAE5BqC,kBACAhF,cAAgB7B,EAAEuB,eAEnBK,OAAST,KAAK+C,YAEG,iBAAVM,OAEP5C,OAAOgC,KAAKY,YACP3C,cAAc6C,QAAQ9C,SAI3B3B,UAAUyD,OAAO5C,kBAAmB,IACnC6C,MAAK,SAASC,aACXhC,OAAOgC,KAAKA,MAELY,SAEVb,KAAK,SAASC,KAAMoC,WACjBpE,OAAOgC,KAAKA,MAERoC,KACI7E,KAAKY,WAEL9B,UAAUgD,cAAc+C,SAGnB/D,SAAW+D,IAIjBpE,QACT4B,KAAKrC,OACNwC,KAAK,SAAS/B,aACNC,cAAc6C,QAAQ9C,SAE7B4B,KAAKrC,OACNwD,MAAMzE,aAAauC,YAU5BzB,MAAM6B,UAAUiE,iBAAmB,mBACxB3F,KAAK+C,YAAY6C,WAAWpE,QAQvC3B,MAAM6B,UAAUmE,WAAa,gBACpB9C,YAAY+C,SAAS,WAQ9BjG,MAAM6B,UAAUgE,WAAa,gBACpB3C,YAAYgD,YAAY,WAQjClG,MAAM6B,UAAUsE,SAAW,WACnBhG,KAAKiG,gBAIJrD,WAAWkD,SAAS,aAS7BjG,MAAM6B,UAAUuE,QAAU,kBACfjG,KAAK4C,WAAWR,SAAS,aAQpCvC,MAAM6B,UAAUwE,SAAW,WACnBlG,KAAKmG,gBAIJvD,WAAWmD,YAAY,aAShClG,MAAM6B,UAAUyE,QAAU,kBACdnG,KAAK4C,WAAWR,SAAS,aASrCvC,MAAM6B,UAAU0E,cAAgB,SAAS/C,OAChCA,WAKAT,WAAW,GAAGyD,UAAUC,IAAI,gCAJxB1D,WAAW,GAAGyD,UAAUE,OAAO,4BAc5C1G,MAAM6B,UAAU8E,gBAAkB,eAC1BC,MAAQ5H,EAAEa,iBAAmB,KAAOA,mBAAqB,KAAOA,uBAChEgH,OAASC,SAAS3G,KAAKF,KAAKoE,IAAI,mBAEpCuC,MAAMxE,MAAK,SAASC,MAAO0E,UAInBC,YAHJD,KAAO/H,EAAE+H,OAGa1C,IAAI,WAAayC,SAASC,KAAK1C,IAAI,YAAc,EAEnE2C,WAAaH,SACbA,OAASG,eAIVH,QASX7G,MAAM6B,UAAUqD,UAAY,kBACjB/E,KAAKF,KAAKsC,SAAS,SAS9BvC,MAAM6B,UAAUoF,SAAW,eACnBC,OAASlI,EAAEoC,SAAS+F,sBACjBhH,KAAKF,KAAKuB,GAAG0F,SAAW/G,KAAKF,KAAKmH,IAAIF,QAAQvF,QASzD3B,MAAM6B,UAAUwF,eAAiB,kBACtBlH,KAAK2C,UAAUP,SAAS,SAQnCvC,MAAM6B,UAAUE,mBAAqB,kBAC1B/C,EAAEW,WAAW2H,cAAgBnH,KAAKgB,kBAU7CnB,MAAM6B,UAAU0F,KAAO,cACfpH,KAAK+E,mBACElG,EAAEuB,WAAWmD,cAGpB8D,eAAiB,IAAI/H,QAAQ,0BAE7BU,KAAK2F,wBACAD,kBAEAG,kBAGJlE,eAGA3B,KAAKoB,cAAgBH,SAAS+F,qBAC1B5F,aAAeH,SAAS+F,eAG1BhH,KAAKsC,cACXE,KAAK,SAAS8E,cAEPC,SADevH,KAAKwG,kBACM,EAC1BgB,iBAAmBD,SAAW,OAC7BzH,KAAKoE,IAAI,UAAWqD,UACzBD,SAASG,UAAUD,kBACnBF,SAASF,YAEJtH,KAAKiG,YAAY,QAAQD,SAAS,aAClC4B,yBACA9E,WAAW+E,QAChB9I,EAAE,QAAQiH,SAAS,mBACdhG,KAAK6D,QAAQvE,YAAYwI,MAAO5H,OAGvCqC,KAAKrC,OACNwC,KAAK6E,eAAe9D,UAQzB1D,MAAM6B,UAAUmG,cAAgB,WAEF,GADR7H,KAAKD,MAAME,KAAKP,gBAClB8B,aACPiD,QASb5E,MAAM6B,UAAU+C,KAAO,gBACdnC,cAAcwF,KAAK,SAASR,UAC7BjI,UAAU0I,cAEL/H,KAAK+B,4BAENuF,SAAS7C,OACT5F,EAAE,QAAQkH,YAAY,mBAGtBiC,aAAerB,SAAS3G,KAAKF,KAAKoE,IAAI,iBACrCpE,KAAKoE,IAAI,UAAW,IACzBoD,SAASG,UAAUO,aAAe,QAE7BC,oBAEDjI,KAAKkH,sBAEAvE,UAAUuF,IAAI,mDAAoD,gBAC9DvF,UAAUoD,YAAY,QAAQD,SAAS,SAC9CzD,KAAKrC,YAEF2C,UAAUoD,YAAY,QAAQD,SAAS,QAI5CjH,EAAEoC,SAASV,MAAMN,KAAKD,KAAK2C,WAAWnB,QACtC3C,EAAEoC,SAASV,MAAMY,OAAOnB,KAAK2C,gBAG5B7C,KAAK6D,QAAQvE,YAAY+I,OAAQnI,OACxCqC,KAAKrC,QAQXH,MAAM6B,UAAU0G,QAAU,gBACjB3D,YACA3E,KAAKyG,cACLzG,KAAK6D,QAAQvE,YAAYiJ,UAAWrI,WACpCgB,gBAAgBuF,UAUzB1G,MAAM6B,UAAUgG,kBAAoB,WAEhCnI,KAAK+I,OAAOtI,KAAKF,KAAKyI,OAGtBhJ,KAAKiJ,aAAaxI,KAAKF,KAAKyI,MAAM,KAUtC1I,MAAM6B,UAAUuG,kBAAoB,WAEhC1I,KAAKkJ,eAAezI,KAAKF,KAAKyI,MAAM,IAGpChJ,KAAKkF,KAAKzE,KAAKF,KAAKyI,QAQxB1I,MAAM6B,UAAUD,uBAAyB,gBAChCkB,UAAU+F,GAAG,UAAW,SAASC,GAC7B3I,KAAK+E,aAIN4D,EAAEC,SAAW5J,SAAS6J,SAClB7I,KAAK8I,mBACAV,eAEA3D,SAGfpC,KAAKrC,YAGF2C,UAAUoG,MAAM,SAASJ,OAGrB9J,EAAE8J,EAAE5B,QAAQiC,QAAQtJ,iBAAiB8B,QAIlC3C,EAAE8J,EAAE5B,QAAQiC,QAAQtJ,qBAAqB8B,OAAQ,KAC7CyH,kBAAoBpK,EAAEqK,MAAM9J,YAAY+J,mBACvCxG,UAAUgB,QAAQsF,kBAAmBjJ,MAErCiJ,kBAAkBG,2BACdvB,kBAInBxF,KAAKrC,OAEPf,aAAaL,OAAOoB,KAAK4C,WAAY,CAAC3D,aAAaoK,OAAOC,gBACrD1G,WAAW8F,GAAGzJ,aAAaoK,OAAOC,SAAU5J,eAAgB,SAASiJ,EAAGY,MACrEvJ,KAAK8I,mBACAV,eAEA3D,OAET8E,KAAKC,cAAcC,kBACrBpH,KAAKrC,YAEF2C,UAAU+F,GAAGtJ,YAAY+I,QAAQ,KAC9BnI,KAAKoB,mBAEAA,aAAauG,YAU9B9H,MAAM6B,UAAUgI,sBAAwB,gBAE/B9G,WAAW8F,GAAGzJ,aAAaoK,OAAOC,SAAUtJ,KAAK2J,kBAAkB,UAAW,SAAShB,EAAGY,UACvFK,YAAc/K,EAAEqK,MAAM9J,YAAYyK,aACjClH,UAAUgB,QAAQiG,YAAa5J,MAE/B4J,YAAYR,uBACbG,KAAKC,cAAcC,iBAEfzJ,KAAK8I,mBACAV,eAEA3D,SAGfpC,KAAKrC,QAQXH,MAAM6B,UAAUoI,oBAAsB,gBAE7BlH,WAAW8F,GAAGzJ,aAAaoK,OAAOC,SAAUtJ,KAAK2J,kBAAkB,QAAS,SAAShB,EAAGY,UACrFQ,UAAYlL,EAAEqK,MAAM9J,YAAY4K,WAC/BrH,UAAUgB,QAAQoG,UAAW/J,MAE7B+J,UAAUX,uBACXG,KAAKC,cAAcC,iBAEfzJ,KAAK8I,mBACAV,eAEA3D,SAGfpC,KAAKrC,QASXH,MAAM6B,UAAUuI,sBAAwB,gBAE/BrH,WAAW8F,GAAGzJ,aAAaoK,OAAOC,SAAUtJ,KAAK2J,kBAAkB,UAAW,SAAShB,EAAGY,UACvFW,YAAcrL,EAAEqK,MAAM9J,YAAY+K,aACjCxH,UAAUgB,QAAQuG,YAAalK,MAE/BkK,YAAYd,uBACbG,KAAKC,cAAcC,iBAEfzJ,KAAK8I,mBACAV,eAEA3D,SAGfpC,KAAKrC,QAWXH,MAAM6B,UAAU4B,SAAW,SAASD,MAAO+G,iBACnCC,EAAIhH,YACa,iBAAVA,OAAuBA,MAAMiH,eAAe,UACnDD,EAAIxL,EAAEuB,YACJmD,QAAQF,OAGdgH,EAAE7H,MAAK,SAAS+H,SACZH,YAAYG,YAIf7H,KAAK3D,aAAauC,WAEZ+I,GAaXxK,MAAM6B,UAAU8I,cAAgB,SAASC,OAAQpH,aACvCqH,OAAS1K,KAAK+C,YAAY9C,KAAKD,KAAK2J,kBAAkBc,aAEvDC,aACK,IAAIC,MAAM,uBAAyBF,OAAS,mBAG/CzK,KAAKsD,SAASD,MAAOqH,OAAOE,KAAKvI,KAAKqI,UASjD7K,MAAM6B,UAAUiI,kBAAoB,SAASc,cAClC,iBAAmBA,OAAS,MAQvC5K,MAAM6B,UAAUmJ,iBAAmB,SAAStE,aACnCuC,cAAgBvC,QAQzB1G,MAAM6B,UAAUoJ,iBAAmB,SAAS3I,cACnCf,aAAee,SASxBtC,MAAM6B,UAAUqJ,kBAAoB,SAASN,OAAQO,gBAC3CN,OAAS1K,KAAK+C,YAAY9C,KAAKD,KAAK2J,kBAAkBc,aAEvDC,aACK,IAAIC,MAAM,uBAAyBF,OAAS,YAElDO,SACAN,OAAOO,KAAK,WAAY,IAExBP,OAAOQ,WAAW,aAInBrL"}
\ No newline at end of file
+{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for modals.\n *\n * @module core/modal\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as Templates from 'core/templates';\nimport * as Notification from 'core/notification';\nimport * as KeyCodes from 'core/key_codes';\nimport ModalBackdrop from 'core/modal_backdrop';\nimport ModalEvents from 'core/modal_events';\nimport * as ModalRegistry from 'core/modal_registry';\nimport Pending from 'core/pending';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport * as FilterEvents from 'core_filters/events';\nimport * as FocusLock from 'core/local/aria/focuslock';\nimport * as Aria from 'core/aria';\nimport * as Fullscreen from 'core/fullscreen';\n\nconst SELECTORS = {\n CONTAINER: '[data-region=\"modal-container\"]',\n MODAL: '[data-region=\"modal\"]',\n HEADER: '[data-region=\"header\"]',\n TITLE: '[data-region=\"title\"]',\n BODY: '[data-region=\"body\"]',\n FOOTER: '[data-region=\"footer\"]',\n HIDE: '[data-action=\"hide\"]',\n DIALOG: '[role=dialog]',\n FORM: 'form',\n MENU_BAR: '[role=menubar]',\n HAS_Z_INDEX: '.moodle-has-zindex',\n CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n};\n\nconst TEMPLATES = {\n LOADING: 'core/loading',\n BACKDROP: 'core/modal_backdrop',\n};\n\nexport default class Modal {\n /** @var {string} The template to use for this modal */\n static TEMPLATE = 'core/modal';\n\n /** @var {Promise} Module singleton for the backdrop to be reused by all Modal instances */\n static backdropPromise = null;\n\n /**\n * @var {Number} A counter that gets incremented for each modal created.\n * This can be used to generate unique values for the modals.\n */\n static modalCounter = 0;\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n constructor(root) {\n this.root = $(root);\n\n this.modal = this.root.find(SELECTORS.MODAL);\n this.header = this.modal.find(SELECTORS.HEADER);\n this.headerPromise = $.Deferred();\n this.title = this.header.find(SELECTORS.TITLE);\n this.titlePromise = $.Deferred();\n this.body = this.modal.find(SELECTORS.BODY);\n this.bodyPromise = $.Deferred();\n this.footer = this.modal.find(SELECTORS.FOOTER);\n this.footerPromise = $.Deferred();\n this.hiddenSiblings = [];\n this.isAttached = false;\n this.bodyJS = null;\n this.footerJS = null;\n this.modalCount = this.modalCounter++;\n this.attachmentPoint = document.createElement('div');\n document.body.append(this.attachmentPoint);\n this.focusOnClose = null;\n\n if (!this.root.is(SELECTORS.CONTAINER)) {\n Notification.exception({message: 'Element is not a modal container'});\n }\n\n if (!this.modal.length) {\n Notification.exception({message: 'Container does not contain a modal'});\n }\n\n if (!this.header.length) {\n Notification.exception({message: 'Modal is missing a header region'});\n }\n\n if (!this.title.length) {\n Notification.exception({message: 'Modal header is missing a title region'});\n }\n\n if (!this.body.length) {\n Notification.exception({message: 'Modal is missing a body region'});\n }\n\n if (!this.footer.length) {\n Notification.exception({message: 'Modal is missing a footer region'});\n }\n\n this.registerEventListeners();\n }\n\n /**\n * Register a modal with the modal registry.\n */\n static registerModalType() {\n if (!this.TYPE) {\n throw new Error(`Unknown modal type`, this);\n }\n\n if (!this.TEMPLATE) {\n throw new Error(`Unknown modal template`, this);\n }\n ModalRegistry.register(\n this.TYPE,\n this,\n this.TEMPLATE,\n );\n }\n\n /**\n * Attach the modal to the correct part of the page.\n *\n * If it hasn't already been added it runs any\n * javascript that has been cached until now.\n *\n * @method attachToDOM\n */\n attachToDOM() {\n this.getAttachmentPoint().append(this.root);\n\n if (this.isAttached) {\n return;\n }\n\n FocusLock.trapFocus(this.root[0]);\n\n // If we'd cached any JS then we can run it how that the modal is\n // attached to the DOM.\n if (this.bodyJS) {\n Templates.runTemplateJS(this.bodyJS);\n this.bodyJS = null;\n }\n\n if (this.footerJS) {\n Templates.runTemplateJS(this.footerJS);\n this.footerJS = null;\n }\n\n this.isAttached = true;\n }\n\n /**\n * Count the number of other visible modals (not including this one).\n *\n * @method countOtherVisibleModals\n * @return {int}\n */\n countOtherVisibleModals() {\n let count = 0;\n $('body').find(SELECTORS.CONTAINER).each((index, element) => {\n element = $(element);\n\n // If we haven't found ourself and the element is visible.\n if (!this.root.is(element) && element.hasClass('show')) {\n count++;\n }\n });\n\n return count;\n }\n\n /**\n * Get the modal backdrop.\n *\n * @method getBackdrop\n * @return {object} jQuery promise\n */\n getBackdrop() {\n if (!Modal.backdropPromise) {\n Modal.backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})\n .then((html) => new ModalBackdrop($(html)))\n .catch(Notification.exception);\n }\n\n return Modal.backdropPromise;\n }\n\n /**\n * Get the root element of this modal.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n getRoot() {\n return this.root;\n }\n\n /**\n * Get the modal element of this modal.\n *\n * @method getModal\n * @return {object} jQuery object\n */\n getModal() {\n return this.modal;\n }\n\n /**\n * Get the modal title element.\n *\n * @method getTitle\n * @return {object} jQuery object\n */\n getTitle() {\n return this.title;\n }\n\n /**\n * Get the modal body element.\n *\n * @method getBody\n * @return {object} jQuery object\n */\n getBody() {\n return this.body;\n }\n\n /**\n * Get the modal footer element.\n *\n * @method getFooter\n * @return {object} jQuery object\n */\n getFooter() {\n return this.footer;\n }\n\n /**\n * Get a promise resolving to the title region.\n *\n * @method getTitlePromise\n * @return {Promise}\n */\n getTitlePromise() {\n return this.titlePromise;\n }\n\n /**\n * Get a promise resolving to the body region.\n *\n * @method getBodyPromise\n * @return {object} jQuery object\n */\n getBodyPromise() {\n return this.bodyPromise;\n }\n\n /**\n * Get a promise resolving to the footer region.\n *\n * @method getFooterPromise\n * @return {object} jQuery object\n */\n getFooterPromise() {\n return this.footerPromise;\n }\n\n /**\n * Get the unique modal count.\n *\n * @method getModalCount\n * @return {int}\n */\n getModalCount() {\n return this.modalCount;\n }\n\n /**\n * Set the modal title element.\n *\n * This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with\n * HTML most commonly from a Str.get_string call.\n *\n * @method setTitle\n * @param {(string|object)} value The title string or jQuery promise which resolves to the title.\n */\n setTitle(value) {\n const title = this.getTitle();\n this.titlePromise = $.Deferred();\n\n this.asyncSet(value, title.html.bind(title))\n .then(() => {\n this.titlePromise.resolve(title);\n return;\n })\n .catch(Notification.exception);\n }\n\n /**\n * Set the modal body element.\n *\n * This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with\n * HTML and Javascript most commonly from a Templates.render call.\n *\n * @method setBody\n * @param {(string|object)} value The body string or jQuery promise which resolves to the body.\n * @fires event:filterContentUpdated\n */\n setBody(value) {\n this.bodyPromise = $.Deferred();\n\n const body = this.getBody();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n body.html(value);\n FilterEvents.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n this.bodyPromise.resolve(body);\n } else {\n const modalPromise = new Pending(`amd-modal-js-pending-id-${this.getModalCount()}`);\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n let contentPromise = null;\n body.css('overflow', 'hidden');\n\n // Ensure that the `value` is a jQuery Promise.\n value = $.when(value);\n\n if (value.state() == 'pending') {\n // We're still waiting for the body promise to resolve so\n // let's show a loading icon.\n let height = body.innerHeight();\n if (height < 100) {\n height = 100;\n }\n\n body.animate({height: `${height}px`}, 150);\n\n body.html('');\n contentPromise = Templates.render(TEMPLATES.LOADING, {})\n .then((html) => {\n const loadingIcon = $(html).hide();\n body.html(loadingIcon);\n loadingIcon.fadeIn(150);\n\n // We only want the loading icon to fade out\n // when the content for the body has finished\n // loading.\n return $.when(loadingIcon.promise(), value);\n })\n .then((loadingIcon) => {\n // Once the content has finished loading and\n // the loading icon has been shown then we can\n // fade the icon away to reveal the content.\n return loadingIcon.fadeOut(100).promise();\n })\n .then(() => {\n return value;\n });\n } else {\n // The content is already loaded so let's just display\n // it to the user. No need for a loading icon.\n contentPromise = value;\n }\n\n // Now we can actually display the content.\n contentPromise.then((html, js) => {\n let result = null;\n\n if (this.isVisible()) {\n // If the modal is visible then we should display\n // the content gracefully for the user.\n body.css('opacity', 0);\n const currentHeight = body.innerHeight();\n body.html(html);\n // We need to clear any height values we've set here\n // in order to measure the height of the content being\n // added. This then allows us to animate the height\n // transition.\n body.css('height', '');\n const newHeight = body.innerHeight();\n body.css('height', `${currentHeight}px`);\n result = body.animate(\n {height: `${newHeight}px`, opacity: 1},\n {duration: 150, queue: false}\n ).promise();\n } else {\n // Since the modal isn't visible we can just immediately\n // set the content. No need to animate it.\n body.html(html);\n }\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.bodyJS = js;\n }\n }\n\n return result;\n })\n .then((result) => {\n FilterEvents.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n return result;\n })\n .then(() => {\n this.bodyPromise.resolve(body);\n return;\n })\n .catch(Notification.exception)\n .always(() => {\n // When we're done displaying all of the content we need\n // to clear the custom values we've set here.\n body.css('height', '');\n body.css('overflow', '');\n body.css('opacity', '');\n modalPromise.resolve();\n\n return;\n });\n }\n }\n\n /**\n * Alternative to setBody() that can be used from non-Jquery modules\n *\n * @param {Promise} promise promise that returns {html, js} object\n * @return {Promise}\n */\n setBodyContent(promise) {\n // Call the leegacy API for now and pass it a jQuery Promise.\n // This is a non-spec feature of jQuery and cannot be produced with spec promises.\n // We can encourage people to migrate to this approach, and in future we can swap\n // it so that setBody() calls setBodyPromise().\n return promise.then(({html, js}) => this.setBody($.when(html, js)))\n .catch(exception => {\n this.hide();\n throw exception;\n });\n }\n\n /**\n * Set the modal footer element. The footer element is made visible, if it\n * isn't already.\n *\n * This method is overloaded to take either a string\n * value for the body or a jQuery promise that is resolved with HTML and Javascript\n * most commonly from a Templates.render call.\n *\n * @method setFooter\n * @param {(string|object)} value The footer string or jQuery promise\n */\n setFooter(value) {\n // Make sure the footer is visible.\n this.showFooter();\n this.footerPromise = $.Deferred();\n\n const footer = this.getFooter();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n footer.html(value);\n this.footerPromise.resolve(footer);\n } else {\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n Templates.render(TEMPLATES.LOADING, {})\n .then((html) => {\n footer.html(html);\n\n return value;\n })\n .then((html, js) => {\n footer.html(html);\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.footerJS = js;\n }\n }\n\n return footer;\n })\n .then((footer) => {\n this.footerPromise.resolve(footer);\n return;\n })\n .catch(Notification.exception);\n }\n }\n\n /**\n * Check if the footer has any content in it.\n *\n * @method hasFooterContent\n * @return {bool}\n */\n hasFooterContent() {\n return this.getFooter().children().length ? true : false;\n }\n\n /**\n * Hide the footer element.\n *\n * @method hideFooter\n */\n hideFooter() {\n this.getFooter().addClass('hidden');\n }\n\n /**\n * Show the footer element.\n *\n * @method showFooter\n */\n showFooter() {\n this.getFooter().removeClass('hidden');\n }\n\n /**\n * Mark the modal as a large modal.\n *\n * @method setLarge\n */\n setLarge() {\n if (this.isLarge()) {\n return;\n }\n\n this.getModal().addClass('modal-lg');\n }\n\n /**\n * Check if the modal is a large modal.\n *\n * @method isLarge\n * @return {bool}\n */\n isLarge() {\n return this.getModal().hasClass('modal-lg');\n }\n\n /**\n * Mark the modal as a small modal.\n *\n * @method setSmall\n */\n setSmall() {\n if (this.isSmall()) {\n return;\n }\n\n this.getModal().removeClass('modal-lg');\n }\n\n /**\n * Check if the modal is a small modal.\n *\n * @method isSmall\n * @return {bool}\n */\n isSmall() {\n return !this.getModal().hasClass('modal-lg');\n }\n\n /**\n * Set this modal to be scrollable or not.\n *\n * @method setScrollable\n * @param {bool} value Whether the modal is scrollable or not\n */\n setScrollable(value) {\n if (!value) {\n this.getModal()[0].classList.remove('modal-dialog-scrollable');\n return;\n }\n\n this.getModal()[0].classList.add('modal-dialog-scrollable');\n }\n\n\n /**\n * Determine the highest z-index value currently on the page.\n *\n * @method calculateZIndex\n * @return {int}\n */\n calculateZIndex() {\n const items = $(`${SELECTORS.DIALOG}, ${SELECTORS.MENU_BAR}, ${SELECTORS.HAS_Z_INDEX}`);\n let zIndex = parseInt(this.root.css('z-index'));\n\n items.each((index, item) => {\n item = $(item);\n // Note that webkit browsers won't return the z-index value from the CSS stylesheet\n // if the element doesn't have a position specified. Instead it'll return \"auto\".\n const itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;\n\n if (itemZIndex > zIndex) {\n zIndex = itemZIndex;\n }\n });\n\n return zIndex;\n }\n\n /**\n * Check if this modal is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n isVisible() {\n return this.root.hasClass('show');\n }\n\n /**\n * Check if this modal has focus.\n *\n * @method hasFocus\n * @return {bool}\n */\n hasFocus() {\n const target = $(document.activeElement);\n return this.root.is(target) || this.root.has(target).length;\n }\n\n /**\n * Check if this modal has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n hasTransitions() {\n return this.getRoot().hasClass('fade');\n }\n\n /**\n * Gets the jQuery wrapped node that the Modal should be attached to.\n *\n * @returns {jQuery}\n */\n getAttachmentPoint() {\n return $(Fullscreen.getElement() || this.attachmentPoint);\n }\n\n /**\n * Display this modal. The modal will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n * @returns {Promise}\n */\n show() {\n if (this.isVisible()) {\n return $.Deferred().resolve();\n }\n\n const pendingPromise = new Pending('core/modal:show');\n\n if (this.hasFooterContent()) {\n this.showFooter();\n } else {\n this.hideFooter();\n }\n\n this.attachToDOM();\n\n // If the focusOnClose was not set. Set the focus back to triggered element.\n if (!this.focusOnClose && document.activeElement) {\n this.focusOnClose = document.activeElement;\n }\n\n return this.getBackdrop()\n .then((backdrop) => {\n const currentIndex = this.calculateZIndex();\n const newIndex = currentIndex + 2;\n const newBackdropIndex = newIndex - 1;\n this.root.css('z-index', newIndex);\n backdrop.setZIndex(newBackdropIndex);\n backdrop.show();\n\n this.root.removeClass('hide').addClass('show');\n this.accessibilityShow();\n this.getModal().focus();\n $('body').addClass('modal-open');\n this.root.trigger(ModalEvents.shown, this);\n\n return;\n })\n .then(pendingPromise.resolve);\n }\n\n /**\n * Hide this modal if it does not contain a form.\n *\n * @method hideIfNotForm\n */\n hideIfNotForm() {\n const formElement = this.modal.find(SELECTORS.FORM);\n if (formElement.length == 0) {\n this.hide();\n }\n }\n\n /**\n * Hide this modal.\n *\n * @method hide\n */\n hide() {\n this.getBackdrop().done((backdrop) => {\n FocusLock.untrapFocus();\n\n if (!this.countOtherVisibleModals()) {\n // Hide the backdrop if we're the last open modal.\n backdrop.hide();\n $('body').removeClass('modal-open');\n }\n\n const currentIndex = parseInt(this.root.css('z-index'));\n this.root.css('z-index', '');\n backdrop.setZIndex(currentIndex - 3);\n\n this.accessibilityHide();\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', () => {\n this.getRoot().removeClass('show').addClass('hide');\n });\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n // Ensure the modal is moved onto the body node if it is still attached to the DOM.\n if ($(document.body).find(this.getRoot()).length) {\n $(document.body).append(this.getRoot());\n }\n\n this.root.trigger(ModalEvents.hidden, this);\n });\n }\n\n /**\n * Remove this modal from the DOM.\n *\n * @method destroy\n */\n destroy() {\n this.hide();\n this.root.remove();\n this.root.trigger(ModalEvents.destroyed, this);\n this.attachmentPoint.remove();\n }\n\n /**\n * Sets the appropriate aria attributes on this dialogue and the other\n * elements in the DOM to ensure that screen readers are able to navigate\n * the dialogue popup correctly.\n *\n * @method accessibilityShow\n */\n accessibilityShow() {\n // Make us visible to screen readers.\n Aria.unhide(this.root.get());\n\n // Hide siblings.\n Aria.hideSiblings(this.root.get()[0]);\n }\n\n /**\n * Restores the aria visibility on the DOM elements changed when displaying\n * the dialogue popup and makes the dialogue aria hidden to allow screen\n * readers to navigate the main page correctly when the dialogue is closed.\n *\n * @method accessibilityHide\n */\n accessibilityHide() {\n // Unhide siblings.\n Aria.unhideSiblings(this.root.get()[0]);\n\n // Hide this modal.\n Aria.hide(this.root.get());\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n this.getRoot().on('keydown', (e) => {\n if (!this.isVisible()) {\n return;\n }\n\n if (e.keyCode == KeyCodes.escape) {\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n });\n\n // Listen for clicks on the modal container.\n this.getRoot().click((e) => {\n // If the click wasn't inside the modal element then we should\n // hide the modal.\n if (!$(e.target).closest(SELECTORS.MODAL).length) {\n // The check above fails to detect the click was inside the modal when the DOM tree is already changed.\n // So, we check if we can still find the container element or not. If not, then the DOM tree is changed.\n // It's best not to hide the modal in that case.\n if ($(e.target).closest(SELECTORS.CONTAINER).length) {\n const outsideClickEvent = $.Event(ModalEvents.outsideClick);\n this.getRoot().trigger(outsideClickEvent, this);\n\n if (!outsideClickEvent.isDefaultPrevented()) {\n this.hideIfNotForm();\n }\n }\n }\n });\n\n CustomEvents.define(this.getModal(), [CustomEvents.events.activate]);\n this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, (e, data) => {\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n data.originalEvent.preventDefault();\n });\n\n this.getRoot().on(ModalEvents.hidden, () => {\n if (this.focusOnClose) {\n // Focus on the element that actually triggers the modal.\n this.focusOnClose.focus();\n }\n });\n }\n\n /**\n * Register a listener to close the dialogue when the cancel button is pressed.\n *\n * @method registerCloseOnCancel\n */\n registerCloseOnCancel() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('cancel'), (e, data) => {\n const cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n });\n }\n\n /**\n * Register a listener to close the dialogue when the save button is pressed.\n *\n * @method registerCloseOnSave\n */\n registerCloseOnSave() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), (e, data) => {\n const saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n });\n }\n\n\n /**\n * Register a listener to close the dialogue when the delete button is pressed.\n *\n * @method registerCloseOnDelete\n */\n registerCloseOnDelete() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('delete'), (e, data) => {\n const deleteEvent = $.Event(ModalEvents.delete);\n this.getRoot().trigger(deleteEvent, this);\n\n if (!deleteEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n });\n }\n\n /**\n * Set or resolve and set the value using the function.\n *\n * @method asyncSet\n * @param {(string|object)} value The string or jQuery promise.\n * @param {function} setFunction The setter\n * @return {Promise}\n */\n asyncSet(value, setFunction) {\n var p = value;\n if (typeof value !== 'object' || !value.hasOwnProperty('then')) {\n p = $.Deferred();\n p.resolve(value);\n }\n\n p.then((content) => {\n setFunction(content);\n\n return;\n })\n .catch(Notification.exception);\n\n return p;\n }\n\n /**\n * Set the title text of a button.\n *\n * This method is overloaded to take either a string value for the button title or a jQuery promise that is resolved with\n * text most commonly from a Str.get_string call.\n *\n * @param {DOMString} action The action of the button\n * @param {(String|object)} value The button text, or a promise which will resolve to it\n * @returns {Promise}\n */\n setButtonText(action, value) {\n const button = this.getFooter().find(this.getActionSelector(action));\n\n if (!button) {\n throw new Error(\"Unable to find the '\" + action + \"' button\");\n }\n\n return this.asyncSet(value, button.text.bind(button));\n }\n\n /**\n * Get the Selector for an action.\n *\n * @param {String} action\n * @returns {DOMString}\n */\n getActionSelector(action) {\n return \"[data-action='\" + action + \"']\";\n }\n\n /**\n * Set the flag to remove the modal from the DOM on close.\n *\n * @param {Boolean} remove\n */\n setRemoveOnClose(remove) {\n this.removeOnClose = remove;\n }\n\n /**\n * Set the return element for the modal.\n *\n * @param {Element|jQuery} element Element to focus when the modal is closed\n */\n setReturnElement(element) {\n this.focusOnClose = element;\n }\n\n /**\n * Set the a button enabled or disabled.\n *\n * @param {DOMString} action The action of the button\n * @param {Boolean} disabled the new disabled value\n */\n setButtonDisabled(action, disabled) {\n const button = this.getFooter().find(this.getActionSelector(action));\n\n if (!button) {\n throw new Error(\"Unable to find the '\" + action + \"' button\");\n }\n if (disabled) {\n button.attr('disabled', '');\n } else {\n button.removeAttr('disabled');\n }\n }\n}\n"],"names":["SELECTORS","TEMPLATES","Modal","constructor","root","modal","this","find","header","headerPromise","$","Deferred","title","titlePromise","body","bodyPromise","footer","footerPromise","hiddenSiblings","isAttached","bodyJS","footerJS","modalCount","modalCounter","attachmentPoint","document","createElement","append","focusOnClose","is","Notification","exception","message","length","registerEventListeners","TYPE","Error","TEMPLATE","ModalRegistry","register","attachToDOM","getAttachmentPoint","FocusLock","trapFocus","Templates","runTemplateJS","countOtherVisibleModals","count","each","index","element","hasClass","getBackdrop","backdropPromise","render","then","html","ModalBackdrop","catch","getRoot","getModal","getTitle","getBody","getFooter","getTitlePromise","getBodyPromise","getFooterPromise","getModalCount","setTitle","value","asyncSet","bind","resolve","setBody","FilterEvents","notifyFilterContentUpdated","trigger","ModalEvents","bodyRendered","modalPromise","Pending","contentPromise","css","when","state","height","innerHeight","animate","loadingIcon","hide","fadeIn","promise","fadeOut","js","result","isVisible","currentHeight","newHeight","opacity","duration","queue","always","setBodyContent","_ref","setFooter","showFooter","hasFooterContent","children","hideFooter","addClass","removeClass","setLarge","isLarge","setSmall","isSmall","setScrollable","classList","add","remove","calculateZIndex","items","zIndex","parseInt","item","itemZIndex","hasFocus","target","activeElement","has","hasTransitions","Fullscreen","getElement","show","pendingPromise","backdrop","newIndex","newBackdropIndex","setZIndex","accessibilityShow","focus","shown","hideIfNotForm","done","untrapFocus","currentIndex","accessibilityHide","one","hidden","destroy","destroyed","Aria","unhide","get","hideSiblings","unhideSiblings","on","e","keyCode","KeyCodes","escape","removeOnClose","click","closest","outsideClickEvent","Event","outsideClick","isDefaultPrevented","CustomEvents","define","events","activate","data","originalEvent","preventDefault","registerCloseOnCancel","getActionSelector","cancelEvent","cancel","registerCloseOnSave","saveEvent","save","registerCloseOnDelete","deleteEvent","delete","setFunction","p","hasOwnProperty","content","setButtonText","action","button","text","setRemoveOnClose","setReturnElement","setButtonDisabled","disabled","attr","removeAttr"],"mappings":"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"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_backdrop.min.js b/lib/amd/build/modal_backdrop.min.js
index e8f2f2905e1..7322a23bd57 100644
--- a/lib/amd/build/modal_backdrop.min.js
+++ b/lib/amd/build/modal_backdrop.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the logic for modal backdrops.
- *
- * @module core/modal_backdrop
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core/modal_backdrop",["jquery","core/templates","core/notification","core/fullscreen"],(function($,Templates,Notification,Fullscreen){var SELECTORS_ROOT='[data-region="modal-backdrop"]',ModalBackdrop=function(root){this.root=$(root),this.isAttached=!1,this.attachmentPoint=document.createElement("div"),document.body.append(this.attachmentPoint),this.root.is(SELECTORS_ROOT)||Notification.exception({message:"Element is not a modal backdrop"})};return ModalBackdrop.prototype.getRoot=function(){return this.root},ModalBackdrop.prototype.getAttachmentPoint=function(){return $(Fullscreen.getElement()||this.attachmentPoint)},ModalBackdrop.prototype.attachToDOM=function(){this.getAttachmentPoint().append(this.root),this.isAttached||(this.isAttached=!0)},ModalBackdrop.prototype.setZIndex=function(value){this.root.css("z-index",value)},ModalBackdrop.prototype.isVisible=function(){return this.root.hasClass("show")},ModalBackdrop.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")},ModalBackdrop.prototype.show=function(){this.isVisible()||(this.attachToDOM(),this.root.removeClass("hide").addClass("show"))},ModalBackdrop.prototype.hide=function(){this.isVisible()&&(this.hasTransitions()?this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this)):this.getRoot().removeClass("show").addClass("hide"),$(document.body).find(this.getRoot()).length&&$(document.body).append(this.getRoot()))},ModalBackdrop.prototype.destroy=function(){this.root.remove(),this.attachmentPoint.remove()},ModalBackdrop}));
+define("core/modal_backdrop",["exports","jquery","./notification","./fullscreen"],(function(_exports,_jquery,Notification,Fullscreen){var obj;function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj},Notification=_interopRequireWildcard(Notification),Fullscreen=_interopRequireWildcard(Fullscreen);const SELECTORS_ROOT='[data-region="modal-backdrop"]';return _exports.default=class{constructor(root){_defineProperty(this,"root",null),_defineProperty(this,"isAttached",!1),_defineProperty(this,"attachmentPoint",null),this.root=(0,_jquery.default)(root),this.isAttached=!1,this.attachmentPoint=document.createElement("div"),document.body.append(this.attachmentPoint),this.root.is(SELECTORS_ROOT)||Notification.exception({message:"Element is not a modal backdrop"})}getRoot(){return this.root}getAttachmentPoint(){return(0,_jquery.default)(Fullscreen.getElement()||this.attachmentPoint)}attachToDOM(){this.getAttachmentPoint().append(this.root),this.isAttached||(this.isAttached=!0)}setZIndex(value){this.root.css("z-index",value)}isVisible(){return this.root.hasClass("show")}hasTransitions(){return this.getRoot().hasClass("fade")}show(){this.isVisible()||(this.attachToDOM(),this.root.removeClass("hide").addClass("show"))}hide(){this.isVisible()&&(this.hasTransitions()?this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",(()=>{this.getRoot().removeClass("show").addClass("hide")})):this.getRoot().removeClass("show").addClass("hide"),(0,_jquery.default)(document.body).find(this.getRoot()).length&&(0,_jquery.default)(document.body).append(this.getRoot()))}destroy(){this.root.remove(),this.attachmentPoint.remove()}},_exports.default}));
//# sourceMappingURL=modal_backdrop.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_backdrop.min.js.map b/lib/amd/build/modal_backdrop.min.js.map
index 681dbec7532..fc509670840 100644
--- a/lib/amd/build/modal_backdrop.min.js.map
+++ b/lib/amd/build/modal_backdrop.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_backdrop.min.js","sources":["../src/modal_backdrop.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for modal backdrops.\n *\n * @module core/modal_backdrop\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],\n function($, Templates, Notification, Fullscreen) {\n\n var SELECTORS = {\n ROOT: '[data-region=\"modal-backdrop\"]',\n };\n\n /**\n * Constructor for ModalBackdrop.\n *\n * @class core/modal_backdrop\n * @param {object} root The root element for the modal backdrop\n */\n var ModalBackdrop = function(root) {\n this.root = $(root);\n this.isAttached = false;\n this.attachmentPoint = document.createElement('div');\n document.body.append(this.attachmentPoint);\n\n if (!this.root.is(SELECTORS.ROOT)) {\n Notification.exception({message: 'Element is not a modal backdrop'});\n }\n };\n\n /**\n * Get the root element of this modal backdrop.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n ModalBackdrop.prototype.getRoot = function() {\n return this.root;\n };\n\n /**\n * Gets the jQuery wrapped node that the Modal should be attached to.\n *\n * @returns {jQuery}\n */\n ModalBackdrop.prototype.getAttachmentPoint = function() {\n return $(Fullscreen.getElement() || this.attachmentPoint);\n };\n\n /**\n * Add the modal backdrop to the page, if it hasn't already been added.\n *\n * @method attachToDOM\n */\n ModalBackdrop.prototype.attachToDOM = function() {\n this.getAttachmentPoint().append(this.root);\n\n if (this.isAttached) {\n return;\n }\n\n this.isAttached = true;\n };\n\n /**\n * Set the z-index value for this backdrop.\n *\n * @method setZIndex\n * @param {int} value The z-index value\n */\n ModalBackdrop.prototype.setZIndex = function(value) {\n this.root.css('z-index', value);\n };\n\n /**\n * Check if this backdrop is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n ModalBackdrop.prototype.isVisible = function() {\n return this.root.hasClass('show');\n };\n\n /**\n * Check if this backdrop has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n ModalBackdrop.prototype.hasTransitions = function() {\n return this.getRoot().hasClass('fade');\n };\n\n /**\n * Display this backdrop. The backdrop will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n */\n ModalBackdrop.prototype.show = function() {\n if (this.isVisible()) {\n return;\n }\n\n this.attachToDOM();\n\n this.root.removeClass('hide').addClass('show');\n };\n\n /**\n * Hide this backdrop.\n *\n * @method hide\n */\n ModalBackdrop.prototype.hide = function() {\n if (!this.isVisible()) {\n return;\n }\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {\n this.getRoot().removeClass('show').addClass('hide');\n }.bind(this));\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n // Ensure the modal is moved onto the body node if it is still attached to the DOM.\n if ($(document.body).find(this.getRoot()).length) {\n $(document.body).append(this.getRoot());\n }\n };\n\n /**\n * Remove this backdrop from the DOM.\n *\n * @method destroy\n */\n ModalBackdrop.prototype.destroy = function() {\n this.root.remove();\n this.attachmentPoint.remove();\n };\n\n return ModalBackdrop;\n});\n"],"names":["define","$","Templates","Notification","Fullscreen","SELECTORS","ModalBackdrop","root","isAttached","attachmentPoint","document","createElement","body","append","this","is","exception","message","prototype","getRoot","getAttachmentPoint","getElement","attachToDOM","setZIndex","value","css","isVisible","hasClass","hasTransitions","show","removeClass","addClass","hide","one","bind","find","length","destroy","remove"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SAAU,iBAAkB,oBAAqB,oBACpD,SAASC,EAAGC,UAAWC,aAAcC,gBAElCC,eACM,iCASNC,cAAgB,SAASC,WACpBA,KAAON,EAAEM,WACTC,YAAa,OACbC,gBAAkBC,SAASC,cAAc,OAC9CD,SAASE,KAAKC,OAAOC,KAAKL,iBAErBK,KAAKP,KAAKQ,GAAGV,iBACdF,aAAaa,UAAU,CAACC,QAAS,4CAUzCX,cAAcY,UAAUC,QAAU,kBACvBL,KAAKP,MAQfD,cAAcY,UAAUE,mBAAqB,kBAClCnB,EAAEG,WAAWiB,cAAgBP,KAAKL,kBAQ9CH,cAAcY,UAAUI,YAAc,gBAC7BF,qBAAqBP,OAAOC,KAAKP,MAElCO,KAAKN,kBAIJA,YAAa,IAStBF,cAAcY,UAAUK,UAAY,SAASC,YACpCjB,KAAKkB,IAAI,UAAWD,QAS7BlB,cAAcY,UAAUQ,UAAY,kBACzBZ,KAAKP,KAAKoB,SAAS,SAS9BrB,cAAcY,UAAUU,eAAiB,kBAC9Bd,KAAKK,UAAUQ,SAAS,SASnCrB,cAAcY,UAAUW,KAAO,WACvBf,KAAKY,mBAIJJ,mBAEAf,KAAKuB,YAAY,QAAQC,SAAS,UAQ3CzB,cAAcY,UAAUc,KAAO,WACtBlB,KAAKY,cAINZ,KAAKc,sBAEAT,UAAUc,IAAI,mDAAoD,gBAC9Dd,UAAUW,YAAY,QAAQC,SAAS,SAC9CG,KAAKpB,YAEFK,UAAUW,YAAY,QAAQC,SAAS,QAI5C9B,EAAES,SAASE,MAAMuB,KAAKrB,KAAKK,WAAWiB,QACtCnC,EAAES,SAASE,MAAMC,OAAOC,KAAKK,aASrCb,cAAcY,UAAUmB,QAAU,gBACzB9B,KAAK+B,cACL7B,gBAAgB6B,UAGlBhC"}
\ No newline at end of file
+{"version":3,"file":"modal_backdrop.min.js","sources":["../src/modal_backdrop.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for modal backdrops.\n *\n * @module core/modal_backdrop\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport $ from 'jquery';\nimport * as Notification from './notification';\nimport * as Fullscreen from './fullscreen';\n\nconst SELECTORS = {\n ROOT: '[data-region=\"modal-backdrop\"]',\n};\n\nexport default class ModalBackdrop {\n root = null;\n isAttached = false;\n attachmentPoint = null;\n\n /**\n * Constructor for ModalBackdrop.\n *\n * @class core/modal_backdrop\n * @param {HTMLElement|jQuery} root The root element for the modal backdrop\n */\n constructor(root) {\n this.root = $(root);\n this.isAttached = false;\n this.attachmentPoint = document.createElement('div');\n document.body.append(this.attachmentPoint);\n\n if (!this.root.is(SELECTORS.ROOT)) {\n Notification.exception({message: 'Element is not a modal backdrop'});\n }\n }\n\n /**\n * Get the root element of this modal backdrop.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n getRoot() {\n return this.root;\n }\n\n /**\n * Gets the jQuery wrapped node that the Modal should be attached to.\n *\n * @returns {jQuery}\n */\n getAttachmentPoint() {\n return $(Fullscreen.getElement() || this.attachmentPoint);\n }\n\n /**\n * Add the modal backdrop to the page, if it hasn't already been added.\n *\n * @method attachToDOM\n */\n attachToDOM() {\n this.getAttachmentPoint().append(this.root);\n\n if (this.isAttached) {\n return;\n }\n\n this.isAttached = true;\n }\n\n /**\n * Set the z-index value for this backdrop.\n *\n * @method setZIndex\n * @param {int} value The z-index value\n */\n setZIndex(value) {\n this.root.css('z-index', value);\n }\n\n /**\n * Check if this backdrop is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n isVisible() {\n return this.root.hasClass('show');\n }\n\n /**\n * Check if this backdrop has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n hasTransitions() {\n return this.getRoot().hasClass('fade');\n }\n\n /**\n * Display this backdrop. The backdrop will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n */\n show() {\n if (this.isVisible()) {\n return;\n }\n\n this.attachToDOM();\n this.root.removeClass('hide').addClass('show');\n }\n\n /**\n * Hide this backdrop.\n *\n * @method hide\n */\n hide() {\n if (!this.isVisible()) {\n return;\n }\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', () => {\n this.getRoot().removeClass('show').addClass('hide');\n });\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n // Ensure the modal is moved onto the body node if it is still attached to the DOM.\n if ($(document.body).find(this.getRoot()).length) {\n $(document.body).append(this.getRoot());\n }\n }\n\n /**\n * Remove this backdrop from the DOM.\n *\n * @method destroy\n */\n destroy() {\n this.root.remove();\n this.attachmentPoint.remove();\n }\n}\n"],"names":["SELECTORS","constructor","root","isAttached","attachmentPoint","document","createElement","body","append","this","is","Notification","exception","message","getRoot","getAttachmentPoint","Fullscreen","getElement","attachToDOM","setZIndex","value","css","isVisible","hasClass","hasTransitions","show","removeClass","addClass","hide","one","find","length","destroy","remove"],"mappings":"y9CA0BMA,eACI,+DAcNC,YAAYC,kCAVL,yCACM,0CACK,WASTA,MAAO,mBAAEA,WACTC,YAAa,OACbC,gBAAkBC,SAASC,cAAc,OAC9CD,SAASE,KAAKC,OAAOC,KAAKL,iBAErBK,KAAKP,KAAKQ,GAAGV,iBACdW,aAAaC,UAAU,CAACC,QAAS,oCAUzCC,iBACWL,KAAKP,KAQhBa,4BACW,mBAAEC,WAAWC,cAAgBR,KAAKL,iBAQ7Cc,mBACSH,qBAAqBP,OAAOC,KAAKP,MAElCO,KAAKN,kBAIJA,YAAa,GAStBgB,UAAUC,YACDlB,KAAKmB,IAAI,UAAWD,OAS7BE,mBACWb,KAAKP,KAAKqB,SAAS,QAS9BC,wBACWf,KAAKK,UAAUS,SAAS,QASnCE,OACQhB,KAAKa,mBAIJJ,mBACAhB,KAAKwB,YAAY,QAAQC,SAAS,SAQ3CC,OACSnB,KAAKa,cAINb,KAAKe,sBAEAV,UAAUe,IAAI,oDAAoD,UAC9Df,UAAUY,YAAY,QAAQC,SAAS,gBAG3Cb,UAAUY,YAAY,QAAQC,SAAS,SAI5C,mBAAEtB,SAASE,MAAMuB,KAAKrB,KAAKK,WAAWiB,4BACpC1B,SAASE,MAAMC,OAAOC,KAAKK,YASrCkB,eACS9B,KAAK+B,cACL7B,gBAAgB6B"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_cancel.min.js b/lib/amd/build/modal_cancel.min.js
index 3ce72b2fe32..98c09264bda 100644
--- a/lib/amd/build/modal_cancel.min.js
+++ b/lib/amd/build/modal_cancel.min.js
@@ -1,10 +1,3 @@
-define("core/modal_cancel",["exports","core/modal","core/notification"],(function(_exports,_modal,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
-/**
- * Contain the logic for the cancel modal.
- *
- * @module core/modal_cancel
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_notification=_interopRequireDefault(_notification);class _default extends _modal.default{constructor(root){super(root),this.getFooter().find(this.getActionSelector("cancel")).length||_notification.default.exception({message:"No cancel button found"})}registerEventListeners(){super.registerEventListeners(),this.registerCloseOnCancel()}}return _exports.default=_default,_exports.default}));
+define("core/modal_cancel",["exports","core/modal","core/notification"],(function(_exports,_modal,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_notification=_interopRequireDefault(_notification);class ModalCancel extends _modal.default{constructor(root){super(root),this.getFooter().find(this.getActionSelector("cancel")).length||_notification.default.exception({message:"No cancel button found"})}registerEventListeners(){super.registerEventListeners(),this.registerCloseOnCancel()}}return _exports.default=ModalCancel,_defineProperty(ModalCancel,"TYPE","CANCEL"),_defineProperty(ModalCancel,"TEMPLATE","core/modal_cancel"),ModalCancel.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_cancel.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_cancel.min.js.map b/lib/amd/build/modal_cancel.min.js.map
index 652a2c8c690..6f4a8c4e3a0 100644
--- a/lib/amd/build/modal_cancel.min.js.map
+++ b/lib/amd/build/modal_cancel.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_cancel.min.js","sources":["../src/modal_cancel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the cancel modal.\n *\n * @module core/modal_cancel\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport Notification from 'core/notification';\n\n/**\n * @class\n * @extends module:core/modal\n */\nexport default class extends Modal {\n constructor(root) {\n super(root);\n\n if (!this.getFooter().find(this.getActionSelector('cancel')).length) {\n Notification.exception({message: 'No cancel button found'});\n }\n }\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on cancel.\n this.registerCloseOnCancel();\n }\n}\n"],"names":["Modal","constructor","root","this","getFooter","find","getActionSelector","length","exception","message","registerEventListeners","registerCloseOnCancel"],"mappings":";;;;;;;sMA8B6BA,eACzBC,YAAYC,YACFA,MAEDC,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAOzCC,+BAEUA,8BAGDC"}
\ No newline at end of file
+{"version":3,"file":"modal_cancel.min.js","sources":["../src/modal_cancel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the cancel modal.\n *\n * @module core/modal_cancel\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport Notification from 'core/notification';\n\n/**\n * @class\n * @extends module:core/modal\n */\nexport default class ModalCancel extends Modal {\n static TYPE = 'CANCEL';\n static TEMPLATE = 'core/modal_cancel';\n\n constructor(root) {\n super(root);\n\n if (!this.getFooter().find(this.getActionSelector('cancel')).length) {\n Notification.exception({message: 'No cancel button found'});\n }\n }\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on cancel.\n this.registerCloseOnCancel();\n }\n}\n\nModalCancel.registerModalType();\n"],"names":["ModalCancel","Modal","constructor","root","this","getFooter","find","getActionSelector","length","exception","message","registerEventListeners","registerCloseOnCancel","registerModalType"],"mappings":"uhBA8BqBA,oBAAoBC,eAIrCC,YAAYC,YACFA,MAEDC,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAOzCC,+BAEUA,8BAGDC,6EApBQZ,mBACH,0BADGA,uBAEC,qBAsBtBA,YAAYa"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_copy_to_clipboard.min.js b/lib/amd/build/modal_copy_to_clipboard.min.js
index 54d26bf9737..509826926bd 100644
--- a/lib/amd/build/modal_copy_to_clipboard.min.js
+++ b/lib/amd/build/modal_copy_to_clipboard.min.js
@@ -1,3 +1,3 @@
-define("core/modal_copy_to_clipboard",["exports","core/modal","core/modal_registry","core/modal_factory","core/copy_to_clipboard"],(function(_exports,_modal,_modal_registry,_modal_factory,_copy_to_clipboard){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry),_modal_factory=_interopRequireDefault(_modal_factory);class CopyToClipboardModal extends _modal.default{constructor(){super(...arguments),this.setRemoveOnClose(!0)}registerEventListeners(){super.registerEventListeners(...arguments),this.getRoot().get(0).addEventListener("click",(e=>{e.target.closest('[data-action="copytoclipboard"]')&&this.getRoot().get(0).contains(e.target)&&setTimeout(this.destroy.bind(this))}))}static async create(){let{text:text,useTextArea:useTextArea=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},title=arguments.length>1?arguments[1]:void 0;_modal_registry.default.get(this.TYPE)||_modal_registry.default.register(this.TYPE,this,this.TEMPLATE);const modal=await _modal_factory.default.create({type:this.TYPE,templateContext:{text:text,useTextArea:useTextArea}});title&&modal.setTitle(title),modal.show()}}return _exports.default=CopyToClipboardModal,_defineProperty(CopyToClipboardModal,"TYPE","core/copytoclipboard"),_defineProperty(CopyToClipboardModal,"TEMPLATE","core/modal_copytoclipboard"),_exports.default}));
+define("core/modal_copy_to_clipboard",["exports","core/modal","core/modal_factory","core/copy_to_clipboard"],(function(_exports,_modal,_modal_factory,_copy_to_clipboard){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_factory=_interopRequireDefault(_modal_factory);class CopyToClipboardModal extends _modal.default{constructor(){super(...arguments),this.setRemoveOnClose(!0)}registerEventListeners(){super.registerEventListeners(...arguments),this.getRoot().get(0).addEventListener("click",(e=>{e.target.closest('[data-action="copytoclipboard"]')&&this.getRoot().get(0).contains(e.target)&&setTimeout(this.destroy.bind(this))}))}static async create(){let{text:text,useTextArea:useTextArea=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},title=arguments.length>1?arguments[1]:void 0;this.registerModalType();const modal=await _modal_factory.default.create({type:this.TYPE,templateContext:{text:text,useTextArea:useTextArea}});title&&modal.setTitle(title),modal.show()}}return _exports.default=CopyToClipboardModal,_defineProperty(CopyToClipboardModal,"TYPE","core/copytoclipboard"),_defineProperty(CopyToClipboardModal,"TEMPLATE","core/modal_copytoclipboard"),_exports.default}));
//# sourceMappingURL=modal_copy_to_clipboard.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_copy_to_clipboard.min.js.map b/lib/amd/build/modal_copy_to_clipboard.min.js.map
index 35550c5d52d..1bc2627567a 100644
--- a/lib/amd/build/modal_copy_to_clipboard.min.js.map
+++ b/lib/amd/build/modal_copy_to_clipboard.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_copy_to_clipboard.min.js","sources":["../src/modal_copy_to_clipboard.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the copy to clipboard modal, i.e. the modal contains a\n * readonly input text field, that contains a value. Clicking on the single\n * button \"Copy to clipboard\" in the footer, puts the content of the input\n * text field into the clipboard and closes the modal.\n *\n * Usage:\n * ModalCopyToClipboard.create(string:, string:|null);\n *\n * @module core/modal_copy_to_clipboard\n * @copyright 2023 Stephan Robotta \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\nimport ModalFactory from 'core/modal_factory';\nimport 'core/copy_to_clipboard';\n\nexport default class CopyToClipboardModal extends Modal {\n static TYPE = 'core/copytoclipboard';\n static TEMPLATE = 'core/modal_copytoclipboard';\n\n constructor(...config) {\n // Override the constructor to set the removeOnClose property, and show the modal.\n super(...config);\n this.setRemoveOnClose(true);\n }\n\n /**\n * Set up all the event handling for the modal.\n * This is an override of the parent method, adding an event listener to close upon the action.\n *\n * @param {array} args\n */\n registerEventListeners(...args) {\n super.registerEventListeners(...args);\n\n this.getRoot().get(0).addEventListener('click', (e) => {\n if (!e.target.closest('[data-action=\"copytoclipboard\"]')) {\n return;\n }\n\n if (!this.getRoot().get(0).contains(e.target)) {\n return;\n }\n\n // Note: We must call destroy() here, because the copy-to-clipboard action listens on the document,\n // which will be processed after this event listener has been processed.\n // By placing this in a setTimeout we move its processing to after the event loop has finished.\n setTimeout(this.destroy.bind(this));\n });\n }\n\n /**\n * Create a new instance of the Modal. Set the text that is being copied. By default, the text is put into the\n * value of an input readonly field. If useTextArea is set to true, the text is rendered in a textarea element.\n * The optional title argument is for the modal title. If not set, the generic string \"copy to clipboard\" is used.\n *\n * @param {Object} data used in the template\n * @param {string} data.text the text to copy to the clipboard\n * @param {boolean} data.useTextArea when the text to copy is displayed in a textarea, default is input\n * @param {string|null} title\n * @returns {Promise}\n */\n static async create(\n {\n text,\n useTextArea = false,\n } = {},\n title\n ) {\n if (!ModalRegistry.get(this.TYPE)) {\n ModalRegistry.register(this.TYPE, this, this.TEMPLATE);\n }\n\n const modal = await ModalFactory.create({\n type: this.TYPE,\n templateContext: {\n text: text,\n useTextArea: useTextArea,\n },\n });\n if (title) {\n modal.setTitle(title);\n }\n modal.show();\n }\n}"],"names":["CopyToClipboardModal","Modal","constructor","setRemoveOnClose","registerEventListeners","getRoot","get","addEventListener","e","target","closest","this","contains","setTimeout","destroy","bind","text","useTextArea","title","ModalRegistry","TYPE","register","TEMPLATE","modal","ModalFactory","create","type","templateContext","setTitle","show"],"mappings":"grBAkCqBA,6BAA6BC,eAI9CC,uCAGSC,kBAAiB,GAS1BC,+BACUA,0CAEDC,UAAUC,IAAI,GAAGC,iBAAiB,SAAUC,IACxCA,EAAEC,OAAOC,QAAQ,oCAIjBC,KAAKN,UAAUC,IAAI,GAAGM,SAASJ,EAAEC,SAOtCI,WAAWF,KAAKG,QAAQC,KAAKJ,oCAgBjCK,KACIA,KADJC,YAEIA,aAAc,0DACd,GACJC,6CAEKC,wBAAcb,IAAIK,KAAKS,+BACVC,SAASV,KAAKS,KAAMT,KAAMA,KAAKW,gBAG3CC,YAAcC,uBAAaC,OAAO,CACpCC,KAAMf,KAAKS,KACXO,gBAAiB,CACbX,KAAMA,KACNC,YAAaA,eAGjBC,OACAK,MAAMK,SAASV,OAEnBK,MAAMM,qEAnEO7B,4BACH,wCADGA,gCAEC"}
\ No newline at end of file
+{"version":3,"file":"modal_copy_to_clipboard.min.js","sources":["../src/modal_copy_to_clipboard.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the copy to clipboard modal, i.e. the modal contains a\n * readonly input text field, that contains a value. Clicking on the single\n * button \"Copy to clipboard\" in the footer, puts the content of the input\n * text field into the clipboard and closes the modal.\n *\n * Usage:\n * ModalCopyToClipboard.create(string:, string:|null);\n *\n * @module core/modal_copy_to_clipboard\n * @copyright 2023 Stephan Robotta \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalFactory from 'core/modal_factory';\nimport 'core/copy_to_clipboard';\n\nexport default class CopyToClipboardModal extends Modal {\n static TYPE = 'core/copytoclipboard';\n static TEMPLATE = 'core/modal_copytoclipboard';\n\n constructor(...config) {\n // Override the constructor to set the removeOnClose property, and show the modal.\n super(...config);\n this.setRemoveOnClose(true);\n }\n\n /**\n * Set up all the event handling for the modal.\n * This is an override of the parent method, adding an event listener to close upon the action.\n *\n * @param {array} args\n */\n registerEventListeners(...args) {\n super.registerEventListeners(...args);\n\n this.getRoot().get(0).addEventListener('click', (e) => {\n if (!e.target.closest('[data-action=\"copytoclipboard\"]')) {\n return;\n }\n\n if (!this.getRoot().get(0).contains(e.target)) {\n return;\n }\n\n // Note: We must call destroy() here, because the copy-to-clipboard action listens on the document,\n // which will be processed after this event listener has been processed.\n // By placing this in a setTimeout we move its processing to after the event loop has finished.\n setTimeout(this.destroy.bind(this));\n });\n }\n\n /**\n * Create a new instance of the Modal. Set the text that is being copied. By default, the text is put into the\n * value of an input readonly field. If useTextArea is set to true, the text is rendered in a textarea element.\n * The optional title argument is for the modal title. If not set, the generic string \"copy to clipboard\" is used.\n *\n * @param {Object} data used in the template\n * @param {string} data.text the text to copy to the clipboard\n * @param {boolean} data.useTextArea when the text to copy is displayed in a textarea, default is input\n * @param {string|null} title\n * @returns {Promise}\n */\n static async create(\n {\n text,\n useTextArea = false,\n } = {},\n title\n ) {\n this.registerModalType();\n\n const modal = await ModalFactory.create({\n type: this.TYPE,\n templateContext: {\n text: text,\n useTextArea: useTextArea,\n },\n });\n if (title) {\n modal.setTitle(title);\n }\n modal.show();\n }\n}\n"],"names":["CopyToClipboardModal","Modal","constructor","setRemoveOnClose","registerEventListeners","getRoot","get","addEventListener","e","target","closest","this","contains","setTimeout","destroy","bind","text","useTextArea","title","registerModalType","modal","ModalFactory","create","type","TYPE","templateContext","setTitle","show"],"mappings":"klBAiCqBA,6BAA6BC,eAI9CC,uCAGSC,kBAAiB,GAS1BC,+BACUA,0CAEDC,UAAUC,IAAI,GAAGC,iBAAiB,SAAUC,IACxCA,EAAEC,OAAOC,QAAQ,oCAIjBC,KAAKN,UAAUC,IAAI,GAAGM,SAASJ,EAAEC,SAOtCI,WAAWF,KAAKG,QAAQC,KAAKJ,oCAgBjCK,KACIA,KADJC,YAEIA,aAAc,0DACd,GACJC,kDAEKC,0BAECC,YAAcC,uBAAaC,OAAO,CACpCC,KAAMZ,KAAKa,KACXC,gBAAiB,CACbT,KAAMA,KACNC,YAAaA,eAGjBC,OACAE,MAAMM,SAASR,OAEnBE,MAAMO,qEAjEO3B,4BACH,wCADGA,gCAEC"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_delete_cancel.min.js b/lib/amd/build/modal_delete_cancel.min.js
index 0e8c1e350ab..2985c980c1e 100644
--- a/lib/amd/build/modal_delete_cancel.min.js
+++ b/lib/amd/build/modal_delete_cancel.min.js
@@ -1,10 +1,3 @@
-define("core/modal_delete_cancel",["exports","core/modal","core/notification"],(function(_exports,_modal,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
-/**
- * Contain the logic for the delete/cancel modal.
- *
- * @module core/modal_delete_cancel
- * @copyright 2022 Laurent David
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_notification=_interopRequireDefault(_notification);class _default extends _modal.default{constructor(root){super(root),this.getFooter().find(this.getActionSelector("delete")).length||_notification.default.exception({message:"No delete button found"}),this.getFooter().find(this.getActionSelector("cancel")).length||_notification.default.exception({message:"No cancel button found"})}registerEventListeners(){super.registerEventListeners(),this.registerCloseOnDelete(),this.registerCloseOnCancel()}setFooter(){_notification.default.exception({message:"Can not change the footer of a delete cancel modal"})}setDeleteButtonText(value){return this.setButtonText("delete",value)}}return _exports.default=_default,_exports.default}));
+define("core/modal_delete_cancel",["exports","core/modal","core/notification"],(function(_exports,_modal,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_notification=_interopRequireDefault(_notification);class ModalDeleteCancel extends _modal.default{constructor(root){super(root),this.getFooter().find(this.getActionSelector("delete")).length||_notification.default.exception({message:"No delete button found"}),this.getFooter().find(this.getActionSelector("cancel")).length||_notification.default.exception({message:"No cancel button found"})}registerEventListeners(){super.registerEventListeners(),this.registerCloseOnDelete(),this.registerCloseOnCancel()}setFooter(){_notification.default.exception({message:"Can not change the footer of a delete cancel modal"})}setDeleteButtonText(value){return this.setButtonText("delete",value)}}return _exports.default=ModalDeleteCancel,_defineProperty(ModalDeleteCancel,"TYPE","DELETE_CANCEL"),_defineProperty(ModalDeleteCancel,"TEMPLATE","core/modal_delete_cancel"),ModalDeleteCancel.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_delete_cancel.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_delete_cancel.min.js.map b/lib/amd/build/modal_delete_cancel.min.js.map
index ea1e045867c..4d18c4dc54b 100644
--- a/lib/amd/build/modal_delete_cancel.min.js.map
+++ b/lib/amd/build/modal_delete_cancel.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_delete_cancel.min.js","sources":["../src/modal_delete_cancel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the delete/cancel modal.\n *\n * @module core/modal_delete_cancel\n * @copyright 2022 Laurent David \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport Modal from 'core/modal';\nimport Notification from 'core/notification';\n\n/**\n * The Delete/Cancel Modal.\n *\n * @class\n * @extends module:core/modal\n */\nexport default class extends Modal {\n constructor(root) {\n super(root);\n\n if (!this.getFooter().find(this.getActionSelector('delete')).length) {\n Notification.exception({message: 'No delete button found'});\n }\n\n if (!this.getFooter().find(this.getActionSelector('cancel')).length) {\n Notification.exception({message: 'No cancel button found'});\n }\n }\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on delete/cancel.\n this.registerCloseOnDelete();\n this.registerCloseOnCancel();\n }\n\n /**\n * Override parent implementation to prevent changing the footer content.\n */\n setFooter() {\n Notification.exception({message: 'Can not change the footer of a delete cancel modal'});\n }\n\n /**\n * Set the title of the delete button.\n *\n * @param {String|Promise} value The button text, or a Promise which will resolve it\n * @returns{Promise}\n */\n setDeleteButtonText(value) {\n return this.setButtonText('delete', value);\n }\n}\n"],"names":["Modal","constructor","root","this","getFooter","find","getActionSelector","length","exception","message","registerEventListeners","registerCloseOnDelete","registerCloseOnCancel","setFooter","setDeleteButtonText","value","setButtonText"],"mappings":";;;;;;;sMA+B6BA,eACzBC,YAAYC,YACFA,MAEDC,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAGhCN,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAOzCC,+BAEUA,8BAGDC,6BACAC,wBAMTC,kCACiBL,UAAU,CAACC,QAAS,uDASrCK,oBAAoBC,cACTZ,KAAKa,cAAc,SAAUD"}
\ No newline at end of file
+{"version":3,"file":"modal_delete_cancel.min.js","sources":["../src/modal_delete_cancel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the delete/cancel modal.\n *\n * @module core/modal_delete_cancel\n * @copyright 2022 Laurent David \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport Modal from 'core/modal';\nimport Notification from 'core/notification';\n\n/**\n * The Delete/Cancel Modal.\n *\n * @class\n * @extends module:core/modal\n */\nexport default class ModalDeleteCancel extends Modal {\n static TYPE = 'DELETE_CANCEL';\n static TEMPLATE = 'core/modal_delete_cancel';\n\n constructor(root) {\n super(root);\n\n if (!this.getFooter().find(this.getActionSelector('delete')).length) {\n Notification.exception({message: 'No delete button found'});\n }\n\n if (!this.getFooter().find(this.getActionSelector('cancel')).length) {\n Notification.exception({message: 'No cancel button found'});\n }\n }\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on delete/cancel.\n this.registerCloseOnDelete();\n this.registerCloseOnCancel();\n }\n\n /**\n * Override parent implementation to prevent changing the footer content.\n */\n setFooter() {\n Notification.exception({message: 'Can not change the footer of a delete cancel modal'});\n }\n\n /**\n * Set the title of the delete button.\n *\n * @param {String|Promise} value The button text, or a Promise which will resolve it\n * @returns{Promise}\n */\n setDeleteButtonText(value) {\n return this.setButtonText('delete', value);\n }\n}\n\nModalDeleteCancel.registerModalType();\n"],"names":["ModalDeleteCancel","Modal","constructor","root","this","getFooter","find","getActionSelector","length","exception","message","registerEventListeners","registerCloseOnDelete","registerCloseOnCancel","setFooter","setDeleteButtonText","value","setButtonText","registerModalType"],"mappings":"8hBA+BqBA,0BAA0BC,eAI3CC,YAAYC,YACFA,MAEDC,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAGhCN,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAOzCC,+BAEUA,8BAGDC,6BACAC,wBAMTC,kCACiBL,UAAU,CAACC,QAAS,uDASrCK,oBAAoBC,cACTZ,KAAKa,cAAc,SAAUD,kEA1CvBhB,yBACH,iCADGA,6BAEC,4BA4CtBA,kBAAkBkB"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_events.min.js b/lib/amd/build/modal_events.min.js
index 738b6249f98..c9413e9c837 100644
--- a/lib/amd/build/modal_events.min.js
+++ b/lib/amd/build/modal_events.min.js
@@ -1,11 +1,3 @@
-/**
- * Contain the events a modal can fire.
- *
- * @module core/modal_events
- * @class modal_events
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core/modal_events",[],(function(){return{shown:"modal:shown",hidden:"modal:hidden",destroyed:"modal:destroyed",bodyRendered:"modal:bodyRendered",outsideClick:"modal:outsideClick",save:"modal-save-cancel:save",delete:"modal-delete-cancel:delete",cancel:"modal-save-cancel:cancel"}}));
+define("core/modal_events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={shown:"modal:shown",hidden:"modal:hidden",destroyed:"modal:destroyed",bodyRendered:"modal:bodyRendered",outsideClick:"modal:outsideClick",save:"modal-save-cancel:save",delete:"modal-delete-cancel:delete",cancel:"modal-save-cancel:cancel"},_exports.default}));
//# sourceMappingURL=modal_events.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_events.min.js.map b/lib/amd/build/modal_events.min.js.map
index f1e8c99e7dd..29bc9849185 100644
--- a/lib/amd/build/modal_events.min.js.map
+++ b/lib/amd/build/modal_events.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_events.min.js","sources":["../src/modal_events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events a modal can fire.\n *\n * @module core/modal_events\n * @class modal_events\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n // Default events.\n shown: 'modal:shown',\n hidden: 'modal:hidden',\n destroyed: 'modal:destroyed',\n bodyRendered: 'modal:bodyRendered',\n outsideClick: 'modal:outsideClick',\n // ModalSaveCancel events.\n save: 'modal-save-cancel:save',\n 'delete': 'modal-delete-cancel:delete', // Delete is a reserved word.\n cancel: 'modal-save-cancel:cancel',\n };\n});\n"],"names":["define","shown","hidden","destroyed","bodyRendered","outsideClick","save","cancel"],"mappings":";;;;;;;;AAuBAA,2BAAO,IAAI,iBACA,CAEHC,MAAO,cACPC,OAAQ,eACRC,UAAW,kBACXC,aAAc,qBACdC,aAAc,qBAEdC,KAAM,gCACI,6BACVC,OAAQ"}
\ No newline at end of file
+{"version":3,"file":"modal_events.min.js","sources":["../src/modal_events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the events a modal can fire.\n *\n * @module core/modal_events\n * @class modal_events\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n // Default events.\n shown: 'modal:shown',\n hidden: 'modal:hidden',\n destroyed: 'modal:destroyed',\n bodyRendered: 'modal:bodyRendered',\n outsideClick: 'modal:outsideClick',\n // ModalSaveCancel events.\n save: 'modal-save-cancel:save',\n 'delete': 'modal-delete-cancel:delete', // Delete is a reserved word.\n cancel: 'modal-save-cancel:cancel',\n};\n"],"names":["shown","hidden","destroyed","bodyRendered","outsideClick","save","cancel"],"mappings":"mKAuBe,CAEXA,MAAO,cACPC,OAAQ,eACRC,UAAW,kBACXC,aAAc,qBACdC,aAAc,qBAEdC,KAAM,gCACI,6BACVC,OAAQ"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_factory.min.js b/lib/amd/build/modal_factory.min.js
index 7ead5a15b48..a3dcc61e6dd 100644
--- a/lib/amd/build/modal_factory.min.js
+++ b/lib/amd/build/modal_factory.min.js
@@ -1,10 +1,10 @@
+define("core/modal_factory",["exports","jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_delete_cancel","core/modal_cancel","core/local/modal/alert","core/templates","core/notification","core/custom_interaction_events","core/pending"],(function(_exports,_jquery,_modal_events,ModalRegistry,_modal,_modal_save_cancel,_modal_delete_cancel,_modal_cancel,_alert,Templates,Notification,CustomEvents,_pending){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
/**
- * Create a modal.
- *
- * @module core/modal_factory
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core/modal_factory",["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_delete_cancel","core/modal_cancel","core/local/modal/alert","core/templates","core/notification","core/custom_interaction_events","core/pending"],(function($,ModalEvents,ModalRegistry,Modal,ModalSaveCancel,ModalDeleteCancel,ModalCancel,ModalAlert,Templates,Notification,CustomEvents,Pending){var TEMPLATES_DEFAULT="core/modal",TEMPLATES_SAVE_CANCEL="core/modal_save_cancel",TEMPLATES_DELETE_CANCEL="core/modal_delete_cancel",TEMPLATES_CANCEL="core/modal_cancel",TEMPLATES_ALERT="core/local/modal/alert",TYPES={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",DELETE_CANCEL:"DELETE_CANCEL",CANCEL:"CANCEL",ALERT:"ALERT"};ModalRegistry.register(TYPES.DEFAULT,Modal,TEMPLATES_DEFAULT),ModalRegistry.register(TYPES.SAVE_CANCEL,ModalSaveCancel,TEMPLATES_SAVE_CANCEL),ModalRegistry.register(TYPES.DELETE_CANCEL,ModalDeleteCancel,TEMPLATES_DELETE_CANCEL),ModalRegistry.register(TYPES.CANCEL,ModalCancel,TEMPLATES_CANCEL),ModalRegistry.register(TYPES.ALERT,ModalAlert,TEMPLATES_ALERT);var createFromType=function(registryConf,templateContext){var templateName=registryConf.template,modalPromise=Templates.render(templateName,templateContext).then((function(html){var modalElement=$(html);return function(registryConf,modalElement){return modalElement=$(modalElement),new(0,registryConf.module)(modalElement)}(registryConf,modalElement)})).fail(Notification.exception);return modalPromise};return{create:function(modalConfig,triggerElement){var registryConf,type=modalConfig.type||TYPES.DEFAULT,isLarge=!!modalConfig.large,isScrollable=!modalConfig.hasOwnProperty("scrollable")||modalConfig.scrollable,templateContext={};(registryConf=ModalRegistry.get(type))||Notification.exception({message:"Unable to find modal of type: "+type}),void 0!==modalConfig.templateContext&&(templateContext=modalConfig.templateContext);var modalPromise=createFromType(registryConf,templateContext).then((function(modal){return void 0!==modalConfig.title&&modal.setTitle(modalConfig.title),void 0!==modalConfig.body&&modal.setBody(modalConfig.body),void 0!==modalConfig.footer&&modal.setFooter(modalConfig.footer),modalConfig.buttons&&Object.entries(modalConfig.buttons).forEach((function(_ref){let[key,value]=_ref;modal.setButtonText(key,value)})),isLarge&&modal.setLarge(),void 0!==modalConfig.removeOnClose&&modal.setRemoveOnClose(modalConfig.removeOnClose),modal.setScrollable(isScrollable),modal}));return void 0!==triggerElement&&function(modalPromise,triggerElement,modalConfig){var actualTriggerElement=null,hasPreShowCallback="function"==typeof modalConfig.preShowCallback,triggeredCallback=function(e,data){var pendingPromise=new Pending("core/modal_factory:setUpTrigger:triggeredCallback");actualTriggerElement=$(e.currentTarget),modalPromise.then((function(modal){return hasPreShowCallback&&modalConfig.preShowCallback(actualTriggerElement,modal),modal.show(),modal})).then(pendingPromise.resolve),data.originalEvent.preventDefault()};if(Array.isArray(triggerElement)){var selector=triggerElement[1];triggerElement=triggerElement[0],CustomEvents.define(triggerElement,[CustomEvents.events.activate]),triggerElement.on(CustomEvents.events.activate,selector,triggeredCallback)}else CustomEvents.define(triggerElement,[CustomEvents.events.activate]),triggerElement.on(CustomEvents.events.activate,triggeredCallback);modalPromise.then((function(modal){return modal.getRoot().on(ModalEvents.hidden,(function(){null!==actualTriggerElement&&actualTriggerElement.focus()})),modal}))}(modalPromise,triggerElement,modalConfig),modalPromise},types:TYPES}}));
+ * Create a modal.
+ *
+ * @module core/modal_factory
+ * @copyright 2016 Ryan Wyllie
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.types=_exports.default=_exports.create=void 0,_jquery=_interopRequireDefault(_jquery),_modal_events=_interopRequireDefault(_modal_events),ModalRegistry=_interopRequireWildcard(ModalRegistry),_modal=_interopRequireDefault(_modal),_modal_save_cancel=_interopRequireDefault(_modal_save_cancel),_modal_delete_cancel=_interopRequireDefault(_modal_delete_cancel),_modal_cancel=_interopRequireDefault(_modal_cancel),_alert=_interopRequireDefault(_alert),Templates=_interopRequireWildcard(Templates),Notification=_interopRequireWildcard(Notification),CustomEvents=_interopRequireWildcard(CustomEvents),_pending=_interopRequireDefault(_pending);const types={DEFAULT:"DEFAULT",SAVE_CANCEL:_modal_save_cancel.default.TYPE,DELETE_CANCEL:_modal_delete_cancel.default.TYPE,CANCEL:_modal_cancel.default.TYPE,ALERT:_alert.default.TYPE};_exports.types=types,ModalRegistry.register(types.DEFAULT,_modal.default,_modal.default.TEMPLATE);const createFromType=(registryConf,templateContext)=>{const templateName=registryConf.template;return Templates.render(templateName,templateContext).then((html=>((registryConf,modalElement)=>(modalElement=(0,_jquery.default)(modalElement),new(0,registryConf.module)(modalElement)))(registryConf,(0,_jquery.default)(html))))},create=(modalConfig,triggerElement)=>{const type=modalConfig.type||types.DEFAULT,isLarge=!!modalConfig.large,isScrollable=!modalConfig.hasOwnProperty("scrollable")||modalConfig.scrollable,registryConf=ModalRegistry.get(type);registryConf||Notification.exception({message:"Unable to find modal of type: "+type});const templateContext=modalConfig.templateContext||{},modalPromise=createFromType(registryConf,templateContext).then((modal=>(void 0!==modalConfig.title&&modal.setTitle(modalConfig.title),void 0!==modalConfig.body&&modal.setBody(modalConfig.body),void 0!==modalConfig.footer&&modal.setFooter(modalConfig.footer),modalConfig.buttons&&Object.entries(modalConfig.buttons).forEach((function(_ref){let[key,value]=_ref;modal.setButtonText(key,value)})),isLarge&&modal.setLarge(),void 0!==modalConfig.removeOnClose&&modal.setRemoveOnClose(modalConfig.removeOnClose),modal.setScrollable(isScrollable),modal)));return void 0!==triggerElement&&((modalPromise,triggerElement,modalConfig)=>{let actualTriggerElement=null;const hasPreShowCallback="function"==typeof modalConfig.preShowCallback,triggeredCallback=(e,data)=>{const pendingPromise=new _pending.default("core/modal_factory:setUpTrigger:triggeredCallback");actualTriggerElement=(0,_jquery.default)(e.currentTarget),modalPromise.then((function(modal){return hasPreShowCallback&&modalConfig.preShowCallback(actualTriggerElement,modal),modal.show(),modal})).then(pendingPromise.resolve),data.originalEvent.preventDefault()};if(Array.isArray(triggerElement)){const selector=triggerElement[1];triggerElement=triggerElement[0],CustomEvents.define(triggerElement,[CustomEvents.events.activate]),triggerElement.on(CustomEvents.events.activate,selector,triggeredCallback)}else CustomEvents.define(triggerElement,[CustomEvents.events.activate]),triggerElement.on(CustomEvents.events.activate,triggeredCallback);modalPromise.then((function(modal){return modal.getRoot().on(_modal_events.default.hidden,(function(){null!==actualTriggerElement&&actualTriggerElement.focus()})),modal}))})(modalPromise,triggerElement,modalConfig),modalPromise};_exports.create=create;var _default={create:create,types:types};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=modal_factory.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_factory.min.js.map b/lib/amd/build/modal_factory.min.js.map
index e9bf1c4121b..e00ca956082 100644
--- a/lib/amd/build/modal_factory.min.js.map
+++ b/lib/amd/build/modal_factory.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_factory.min.js","sources":["../src/modal_factory.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Create a modal.\n *\n * @module core/modal_factory\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',\n 'core/modal_save_cancel', 'core/modal_delete_cancel', 'core/modal_cancel', 'core/local/modal/alert',\n 'core/templates', 'core/notification', 'core/custom_interaction_events',\n 'core/pending'],\n function($, ModalEvents, ModalRegistry, Modal, ModalSaveCancel, ModalDeleteCancel,\n ModalCancel, ModalAlert, Templates, Notification, CustomEvents, Pending) {\n\n // The templates for each type of modal.\n var TEMPLATES = {\n DEFAULT: 'core/modal',\n SAVE_CANCEL: 'core/modal_save_cancel',\n DELETE_CANCEL: 'core/modal_delete_cancel',\n CANCEL: 'core/modal_cancel',\n ALERT: 'core/local/modal/alert',\n };\n\n /**\n * The available types of modals.\n *\n * @constant\n * @static\n * @public\n * @property {String} DEFAULT The default modal\n * @property {String} SAVE_CANCEL A modal which can be used to either save, or cancel.\n * @property {String} DELETE_CANCEL A modal which can be used to either delete, or cancel.\n * @property {String} CANCEL A modal which displayed a cancel button\n * @property {String} ALERT An information modal which only displays information.\n */\n var TYPES = {\n DEFAULT: 'DEFAULT',\n SAVE_CANCEL: 'SAVE_CANCEL',\n DELETE_CANCEL: 'DELETE_CANCEL',\n CANCEL: 'CANCEL',\n ALERT: 'ALERT',\n };\n\n // Register the common set of modals.\n ModalRegistry.register(TYPES.DEFAULT, Modal, TEMPLATES.DEFAULT);\n ModalRegistry.register(TYPES.SAVE_CANCEL, ModalSaveCancel, TEMPLATES.SAVE_CANCEL);\n ModalRegistry.register(TYPES.DELETE_CANCEL, ModalDeleteCancel, TEMPLATES.DELETE_CANCEL);\n ModalRegistry.register(TYPES.CANCEL, ModalCancel, TEMPLATES.CANCEL);\n ModalRegistry.register(TYPES.ALERT, ModalAlert, TEMPLATES.ALERT);\n\n /**\n * Set up the events required to show the modal and return focus when the modal\n * is closed.\n *\n * @method setUpTrigger\n * @private\n * @param {Promise} modalPromise The modal instance\n * @param {object} triggerElement The jQuery element to open the modal\n * @param {object} modalConfig The modal configuration given to the factory\n */\n var setUpTrigger = function(modalPromise, triggerElement, modalConfig) {\n // The element that actually shows the modal.\n var actualTriggerElement = null;\n // Check if the client has provided a callback function to be called\n // before the modal is displayed.\n var hasPreShowCallback = (typeof modalConfig.preShowCallback == 'function');\n // Function to handle the trigger element being activated.\n var triggeredCallback = function(e, data) {\n var pendingPromise = new Pending('core/modal_factory:setUpTrigger:triggeredCallback');\n actualTriggerElement = $(e.currentTarget);\n modalPromise.then(function(modal) {\n if (hasPreShowCallback) {\n // If the client provided a pre-show callback then execute\n // it now before showing the modal.\n modalConfig.preShowCallback(actualTriggerElement, modal);\n }\n\n modal.show();\n\n return modal;\n })\n .then(pendingPromise.resolve);\n data.originalEvent.preventDefault();\n };\n\n // The trigger element can either be a single element or it can be an\n // element + selector pair to create a delegated event handler to trigger\n // the modal.\n if (Array.isArray(triggerElement)) {\n var selector = triggerElement[1];\n triggerElement = triggerElement[0];\n\n CustomEvents.define(triggerElement, [CustomEvents.events.activate]);\n triggerElement.on(CustomEvents.events.activate, selector, triggeredCallback);\n } else {\n CustomEvents.define(triggerElement, [CustomEvents.events.activate]);\n triggerElement.on(CustomEvents.events.activate, triggeredCallback);\n }\n\n modalPromise.then(function(modal) {\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Focus on the trigger element that actually launched the modal.\n if (actualTriggerElement !== null) {\n actualTriggerElement.focus();\n }\n });\n\n return modal;\n });\n };\n\n /**\n * Create the correct instance of a modal based on the givem type. Sets up\n * the trigger between the modal and the trigger element.\n *\n * @method createFromElement\n * @private\n * @param {object} registryConf A config from the ModalRegistry\n * @param {object} modalElement The modal HTML jQuery object\n * @return {object} Modal instance\n */\n var createFromElement = function(registryConf, modalElement) {\n modalElement = $(modalElement);\n var Module = registryConf.module;\n var modal = new Module(modalElement);\n\n return modal;\n };\n\n /**\n * Create the correct modal instance for the given type, including loading\n * the correct template.\n *\n * @method createFromType\n * @private\n * @param {object} registryConf A config from the ModalRegistry\n * @param {object} templateContext The context to render the template with\n * @returns {promise} Resolved with a Modal instance\n */\n var createFromType = function(registryConf, templateContext) {\n var templateName = registryConf.template;\n\n var modalPromise = Templates.render(templateName, templateContext)\n .then(function(html) {\n var modalElement = $(html);\n return createFromElement(registryConf, modalElement);\n })\n .fail(Notification.exception);\n\n return modalPromise;\n };\n\n /**\n * Create a Modal instance.\n *\n * @method create\n * @param {object} modalConfig The configuration to create the modal instance\n * @param {object} triggerElement The trigger HTML jQuery object\n * @return {promise} Resolved with a Modal instance\n */\n var create = function(modalConfig, triggerElement) {\n var type = modalConfig.type || TYPES.DEFAULT;\n var isLarge = modalConfig.large ? true : false;\n // If 'scrollable' is not configured, set the modal to be scrollable by default.\n var isScrollable = modalConfig.hasOwnProperty('scrollable') ? modalConfig.scrollable : true;\n var registryConf = null;\n var templateContext = {};\n\n registryConf = ModalRegistry.get(type);\n\n if (!registryConf) {\n Notification.exception({message: 'Unable to find modal of type: ' + type});\n }\n\n if (typeof modalConfig.templateContext != 'undefined') {\n templateContext = modalConfig.templateContext;\n }\n\n var modalPromise = createFromType(registryConf, templateContext)\n .then(function(modal) {\n if (typeof modalConfig.title != 'undefined') {\n modal.setTitle(modalConfig.title);\n }\n\n if (typeof modalConfig.body != 'undefined') {\n modal.setBody(modalConfig.body);\n }\n\n if (typeof modalConfig.footer != 'undefined') {\n modal.setFooter(modalConfig.footer);\n }\n\n if (modalConfig.buttons) {\n Object.entries(modalConfig.buttons).forEach(function([key, value]) {\n modal.setButtonText(key, value);\n });\n }\n\n if (isLarge) {\n modal.setLarge();\n }\n\n if (typeof modalConfig.removeOnClose !== 'undefined') {\n // If configured remove the modal when hiding it.\n modal.setRemoveOnClose(modalConfig.removeOnClose);\n }\n\n modal.setScrollable(isScrollable);\n\n return modal;\n });\n\n if (typeof triggerElement != 'undefined') {\n setUpTrigger(modalPromise, triggerElement, modalConfig);\n }\n\n return modalPromise;\n };\n\n return {\n create: create,\n types: TYPES,\n };\n});\n"],"names":["define","$","ModalEvents","ModalRegistry","Modal","ModalSaveCancel","ModalDeleteCancel","ModalCancel","ModalAlert","Templates","Notification","CustomEvents","Pending","TEMPLATES","TYPES","DEFAULT","SAVE_CANCEL","DELETE_CANCEL","CANCEL","ALERT","register","createFromType","registryConf","templateContext","templateName","template","modalPromise","render","then","html","modalElement","Module","module","createFromElement","fail","exception","create","modalConfig","triggerElement","type","isLarge","large","isScrollable","hasOwnProperty","scrollable","get","message","modal","title","setTitle","body","setBody","footer","setFooter","buttons","Object","entries","forEach","key","value","setButtonText","setLarge","removeOnClose","setRemoveOnClose","setScrollable","actualTriggerElement","hasPreShowCallback","preShowCallback","triggeredCallback","e","data","pendingPromise","currentTarget","show","resolve","originalEvent","preventDefault","Array","isArray","selector","events","activate","on","getRoot","hidden","focus","setUpTrigger","types"],"mappings":"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"}
\ No newline at end of file
+{"version":3,"file":"modal_factory.min.js","sources":["../src/modal_factory.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Create a modal.\n *\n * @module core/modal_factory\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport ModalEvents from 'core/modal_events';\nimport * as ModalRegistry from 'core/modal_registry';\nimport Modal from 'core/modal';\nimport ModalSaveCancel from 'core/modal_save_cancel';\nimport ModalDeleteCancel from 'core/modal_delete_cancel';\nimport ModalCancel from 'core/modal_cancel';\nimport ModalAlert from 'core/local/modal/alert';\nimport * as Templates from 'core/templates';\nimport * as Notification from 'core/notification';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Pending from 'core/pending';\n\n/**\n * The available standard modals.\n *\n * @property {String} DEFAULT The default modal\n * @property {String} SAVE_CANCEL A modal which can be used to either save, or cancel.\n * @property {String} DELETE_CANCEL A modal which can be used to either delete, or cancel.\n * @property {String} CANCEL A modal which displayed a cancel button\n * @property {String} ALERT An information modal which only displays information.\n */\nexport const types = {\n DEFAULT: 'DEFAULT',\n SAVE_CANCEL: ModalSaveCancel.TYPE,\n DELETE_CANCEL: ModalDeleteCancel.TYPE,\n CANCEL: ModalCancel.TYPE,\n ALERT: ModalAlert.TYPE,\n};\n\n// Most modals are self-registering.\n// We do not self-register the base Modal because we do not want to define a default TYPE\n// on the class that every other modal extends.\nModalRegistry.register(types.DEFAULT, Modal, Modal.TEMPLATE);\n\n/**\n * Set up the events required to show the modal and return focus when the modal\n * is closed.\n *\n * @method setUpTrigger\n * @private\n * @param {Promise} modalPromise The modal instance\n * @param {object} triggerElement The jQuery element to open the modal\n * @param {object} modalConfig The modal configuration given to the factory\n */\nconst setUpTrigger = (modalPromise, triggerElement, modalConfig) => {\n // The element that actually shows the modal.\n let actualTriggerElement = null;\n // Check if the client has provided a callback function to be called\n // before the modal is displayed.\n const hasPreShowCallback = (typeof modalConfig.preShowCallback == 'function');\n // Function to handle the trigger element being activated.\n const triggeredCallback = (e, data) => {\n const pendingPromise = new Pending('core/modal_factory:setUpTrigger:triggeredCallback');\n actualTriggerElement = $(e.currentTarget);\n\n // eslint-disable-next-line promise/catch-or-return\n modalPromise.then(function(modal) {\n if (hasPreShowCallback) {\n // If the client provided a pre-show callback then execute\n // it now before showing the modal.\n modalConfig.preShowCallback(actualTriggerElement, modal);\n }\n\n modal.show();\n\n return modal;\n })\n .then(pendingPromise.resolve);\n data.originalEvent.preventDefault();\n };\n\n // The trigger element can either be a single element or it can be an\n // element + selector pair to create a delegated event handler to trigger\n // the modal.\n if (Array.isArray(triggerElement)) {\n const selector = triggerElement[1];\n triggerElement = triggerElement[0];\n\n CustomEvents.define(triggerElement, [CustomEvents.events.activate]);\n triggerElement.on(CustomEvents.events.activate, selector, triggeredCallback);\n } else {\n CustomEvents.define(triggerElement, [CustomEvents.events.activate]);\n triggerElement.on(CustomEvents.events.activate, triggeredCallback);\n }\n\n // eslint-disable-next-line promise/catch-or-return\n modalPromise.then(function(modal) {\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Focus on the trigger element that actually launched the modal.\n if (actualTriggerElement !== null) {\n actualTriggerElement.focus();\n }\n });\n\n return modal;\n });\n};\n\n/**\n * Create the correct instance of a modal based on the givem type. Sets up\n * the trigger between the modal and the trigger element.\n *\n * @method createFromElement\n * @private\n * @param {object} registryConf A config from the ModalRegistry\n * @param {object} modalElement The modal HTML jQuery object\n * @return {object} Modal instance\n */\nconst createFromElement = (registryConf, modalElement) => {\n modalElement = $(modalElement);\n const Module = registryConf.module;\n const modal = new Module(modalElement);\n\n return modal;\n};\n\n/**\n * Create the correct modal instance for the given type, including loading\n * the correct template.\n *\n * @method createFromType\n * @private\n * @param {object} registryConf A config from the ModalRegistry\n * @param {object} templateContext The context to render the template with\n * @returns {promise} Resolved with a Modal instance\n */\nconst createFromType = (registryConf, templateContext) => {\n const templateName = registryConf.template;\n return Templates.render(templateName, templateContext)\n .then((html) => createFromElement(registryConf, $(html)));\n};\n\n/**\n * Create a Modal instance.\n *\n * @method create\n * @param {object} modalConfig The configuration to create the modal instance\n * @param {object} triggerElement The trigger HTML jQuery object\n * @return {promise} Resolved with a Modal instance\n */\nexport const create = (modalConfig, triggerElement) => {\n const type = modalConfig.type || types.DEFAULT;\n const isLarge = modalConfig.large ? true : false;\n // If 'scrollable' is not configured, set the modal to be scrollable by default.\n const isScrollable = modalConfig.hasOwnProperty('scrollable') ? modalConfig.scrollable : true;\n\n const registryConf = ModalRegistry.get(type);\n if (!registryConf) {\n Notification.exception({message: 'Unable to find modal of type: ' + type});\n }\n\n const templateContext = modalConfig.templateContext || {};\n\n const modalPromise = createFromType(registryConf, templateContext)\n .then((modal) => {\n if (typeof modalConfig.title !== 'undefined') {\n modal.setTitle(modalConfig.title);\n }\n\n if (typeof modalConfig.body !== 'undefined') {\n modal.setBody(modalConfig.body);\n }\n\n if (typeof modalConfig.footer !== 'undefined') {\n modal.setFooter(modalConfig.footer);\n }\n\n if (modalConfig.buttons) {\n Object.entries(modalConfig.buttons).forEach(function([key, value]) {\n modal.setButtonText(key, value);\n });\n }\n\n if (isLarge) {\n modal.setLarge();\n }\n\n if (typeof modalConfig.removeOnClose !== 'undefined') {\n // If configured remove the modal when hiding it.\n modal.setRemoveOnClose(modalConfig.removeOnClose);\n }\n\n modal.setScrollable(isScrollable);\n\n return modal;\n });\n\n if (typeof triggerElement !== 'undefined') {\n setUpTrigger(modalPromise, triggerElement, modalConfig);\n }\n\n return modalPromise;\n};\n\nexport default {\n create,\n types,\n};\n"],"names":["types","DEFAULT","SAVE_CANCEL","ModalSaveCancel","TYPE","DELETE_CANCEL","ModalDeleteCancel","CANCEL","ModalCancel","ALERT","ModalAlert","ModalRegistry","register","Modal","TEMPLATE","createFromType","registryConf","templateContext","templateName","template","Templates","render","then","html","modalElement","Module","module","createFromElement","create","modalConfig","triggerElement","type","isLarge","large","isScrollable","hasOwnProperty","scrollable","get","Notification","exception","message","modalPromise","modal","title","setTitle","body","setBody","footer","setFooter","buttons","Object","entries","forEach","key","value","setButtonText","setLarge","removeOnClose","setRemoveOnClose","setScrollable","actualTriggerElement","hasPreShowCallback","preShowCallback","triggeredCallback","e","data","pendingPromise","Pending","currentTarget","show","resolve","originalEvent","preventDefault","Array","isArray","selector","CustomEvents","define","events","activate","on","getRoot","ModalEvents","hidden","focus","setUpTrigger"],"mappings":";;;;;;;wsBA6CaA,MAAQ,CACjBC,QAAS,UACTC,YAAaC,2BAAgBC,KAC7BC,cAAeC,6BAAkBF,KACjCG,OAAQC,sBAAYJ,KACpBK,MAAOC,eAAWN,2BAMtBO,cAAcC,SAASZ,MAAMC,QAASY,eAAOA,eAAMC,gBA8F7CC,eAAiB,CAACC,aAAcC,yBAC5BC,aAAeF,aAAaG,gBAC3BC,UAAUC,OAAOH,aAAcD,iBACjCK,MAAMC,MArBW,EAACP,aAAcQ,gBACrCA,cAAe,mBAAEA,cAEH,IAAIC,EADHT,aAAaU,QACHF,eAkBLG,CAAkBX,cAAc,mBAAEO,UAW7CK,OAAS,CAACC,YAAaC,wBAC1BC,KAAOF,YAAYE,MAAQ/B,MAAMC,QACjC+B,UAAUH,YAAYI,MAEtBC,cAAeL,YAAYM,eAAe,eAAgBN,YAAYO,WAEtEpB,aAAeL,cAAc0B,IAAIN,MAClCf,cACDsB,aAAaC,UAAU,CAACC,QAAS,iCAAmCT,aAGlEd,gBAAkBY,YAAYZ,iBAAmB,GAEjDwB,aAAe1B,eAAeC,aAAcC,iBAC7CK,MAAMoB,aAC8B,IAAtBb,YAAYc,OACnBD,MAAME,SAASf,YAAYc,YAGC,IAArBd,YAAYgB,MACnBH,MAAMI,QAAQjB,YAAYgB,WAGI,IAAvBhB,YAAYkB,QACnBL,MAAMM,UAAUnB,YAAYkB,QAG5BlB,YAAYoB,SACZC,OAAOC,QAAQtB,YAAYoB,SAASG,SAAQ,mBAAUC,IAAKC,YACvDZ,MAAMa,cAAcF,IAAKC,UAI7BtB,SACAU,MAAMc,gBAG+B,IAA9B3B,YAAY4B,eAEnBf,MAAMgB,iBAAiB7B,YAAY4B,eAGvCf,MAAMiB,cAAczB,cAEbQ,qBAGe,IAAnBZ,gBA/IM,EAACW,aAAcX,eAAgBD,mBAE5C+B,qBAAuB,WAGrBC,mBAA4D,mBAA/BhC,YAAYiC,gBAEzCC,kBAAoB,CAACC,EAAGC,cACpBC,eAAiB,IAAIC,iBAAQ,qDACnCP,sBAAuB,mBAAEI,EAAEI,eAG3B3B,aAAanB,MAAK,SAASoB,cACnBmB,oBAGAhC,YAAYiC,gBAAgBF,qBAAsBlB,OAGtDA,MAAM2B,OAEC3B,SAEVpB,KAAK4C,eAAeI,SACrBL,KAAKM,cAAcC,qBAMnBC,MAAMC,QAAQ5C,gBAAiB,OACzB6C,SAAW7C,eAAe,GAChCA,eAAiBA,eAAe,GAEhC8C,aAAaC,OAAO/C,eAAgB,CAAC8C,aAAaE,OAAOC,WACzDjD,eAAekD,GAAGJ,aAAaE,OAAOC,SAAUJ,SAAUZ,wBAE1Da,aAAaC,OAAO/C,eAAgB,CAAC8C,aAAaE,OAAOC,WACzDjD,eAAekD,GAAGJ,aAAaE,OAAOC,SAAUhB,mBAIpDtB,aAAanB,MAAK,SAASoB,cACvBA,MAAMuC,UAAUD,GAAGE,sBAAYC,QAAQ,WAEN,OAAzBvB,sBACAA,qBAAqBwB,WAItB1C,UA8FP2C,CAAa5C,aAAcX,eAAgBD,aAGxCY,kDAGI,CACXb,OAAAA,OACA5B,MAAAA"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_registry.min.js b/lib/amd/build/modal_registry.min.js
index 4f3d278865f..ace36ba2edd 100644
--- a/lib/amd/build/modal_registry.min.js
+++ b/lib/amd/build/modal_registry.min.js
@@ -1,11 +1,11 @@
+define("core/modal_registry",["exports","core/notification","core/prefetch"],(function(_exports,Notification,Prefetch){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
/**
- * A registry for the different types of modal.
- *
- * @module core/modal_registry
- * @class modal_registry
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core/modal_registry",["core/notification","core/prefetch"],(function(Notification,Prefetch){var registry={},get=function(type){return registry[type]};return{register:function(type,module,template){get(type)&&Notification.exception({message:"Modal of type '"+type+"' is already registered"}),module&&"function"==typeof module||Notification.exception({message:"You must provide a modal module"}),template||Notification.exception({message:"You must provide a modal template"}),registry[type]={module:module,template:template},Prefetch.prefetchTemplate(template)},get:get}}));
+ * A registry for the different types of modal.
+ *
+ * @module core/modal_registry
+ * @class modal_registry
+ * @copyright 2016 Ryan Wyllie
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.register=_exports.get=_exports.default=void 0,Notification=_interopRequireWildcard(Notification),Prefetch=_interopRequireWildcard(Prefetch);const registry=new Map,get=type=>registry.get(type);_exports.get=get;const register=(type,module,template)=>{const existing=get(type);existing&&existing.module!==module&&Notification.exception({message:"Modal of type '".concat(type,"' is already registered")}),module&&"function"==typeof module||Notification.exception({message:"You must provide a modal module"}),template||Notification.exception({message:"You must provide a modal template"}),registry.set(type,{module:module,template:template}),Prefetch.prefetchTemplate(template)};_exports.register=register;var _default={register:register,get:get};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=modal_registry.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_registry.min.js.map b/lib/amd/build/modal_registry.min.js.map
index bef4b3b4c50..ea733aba80a 100644
--- a/lib/amd/build/modal_registry.min.js.map
+++ b/lib/amd/build/modal_registry.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_registry.min.js","sources":["../src/modal_registry.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A registry for the different types of modal.\n *\n * @module core/modal_registry\n * @class modal_registry\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/notification', 'core/prefetch'], function(Notification, Prefetch) {\n\n // A singleton registry for all modules to access. Allows types to be\n // added at runtime.\n var registry = {};\n\n /**\n * Get a registered type of modal.\n *\n * @method get\n * @param {string} type The type of modal to get\n * @return {object} The registered config for the modal\n */\n var get = function(type) {\n return registry[type];\n };\n\n /**\n * Register a modal with the registry.\n *\n * @method register\n * @param {string} type The type of modal (must be unique)\n * @param {function} module The modal module (must be a constructor function of type core/modal)\n * @param {string} template The template name of the modal\n */\n var register = function(type, module, template) {\n if (get(type)) {\n Notification.exception({message: \"Modal of type '\" + type + \"' is already registered\"});\n }\n\n if (!module || typeof module !== 'function') {\n Notification.exception({message: \"You must provide a modal module\"});\n }\n\n if (!template) {\n Notification.exception({message: \"You must provide a modal template\"});\n }\n\n registry[type] = {\n module: module,\n template: template,\n };\n\n // Prefetch the template.\n Prefetch.prefetchTemplate(template);\n };\n\n return {\n register: register,\n get: get,\n };\n});\n"],"names":["define","Notification","Prefetch","registry","get","type","register","module","template","exception","message","prefetchTemplate"],"mappings":";;;;;;;;AAuBAA,6BAAO,CAAC,oBAAqB,kBAAkB,SAASC,aAAcC,cAI9DC,SAAW,GASXC,IAAM,SAASC,aACRF,SAASE,aAiCb,CACHC,SAvBW,SAASD,KAAME,OAAQC,UAC9BJ,IAAIC,OACJJ,aAAaQ,UAAU,CAACC,QAAS,mBAAqBL,KAAO,4BAG5DE,QAA4B,mBAAXA,QAClBN,aAAaQ,UAAU,CAACC,QAAS,oCAGhCF,UACDP,aAAaQ,UAAU,CAACC,QAAS,sCAGrCP,SAASE,MAAQ,CACbE,OAAQA,OACRC,SAAUA,UAIdN,SAASS,iBAAiBH,WAK1BJ,IAAKA"}
\ No newline at end of file
+{"version":3,"file":"modal_registry.min.js","sources":["../src/modal_registry.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A registry for the different types of modal.\n *\n * @module core/modal_registry\n * @class modal_registry\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport * as Notification from 'core/notification';\nimport * as Prefetch from 'core/prefetch';\n\n// A singleton registry for all modules to access. Allows types to be\n// added at runtime.\nconst registry = new Map();\n\n/**\n * Get a registered type of modal.\n *\n * @method get\n * @param {string} type The type of modal to get\n * @return {object} The registered config for the modal\n */\nexport const get = (type) => registry.get(type);\n\n/**\n * Register a modal with the registry.\n *\n * @method register\n * @param {string} type The type of modal (must be unique)\n * @param {function} module The modal module (must be a constructor function of type core/modal)\n * @param {string} template The template name of the modal\n */\nexport const register = (type, module, template) => {\n const existing = get(type);\n if (existing && existing.module !== module) {\n Notification.exception({\n message: `Modal of type '${type}' is already registered`,\n });\n }\n\n if (!module || typeof module !== 'function') {\n Notification.exception({message: \"You must provide a modal module\"});\n }\n\n if (!template) {\n Notification.exception({message: \"You must provide a modal template\"});\n }\n\n registry.set(type, {module, template});\n\n // Prefetch the template.\n Prefetch.prefetchTemplate(template);\n};\n\nexport default {\n register,\n get,\n};\n"],"names":["registry","Map","get","type","register","module","template","existing","Notification","exception","message","set","Prefetch","prefetchTemplate"],"mappings":";;;;;;;;wNA4BMA,SAAW,IAAIC,IASRC,IAAOC,MAASH,SAASE,IAAIC,6BAU7BC,SAAW,CAACD,KAAME,OAAQC,kBAC7BC,SAAWL,IAAIC,MACjBI,UAAYA,SAASF,SAAWA,QAChCG,aAAaC,UAAU,CACnBC,kCAA4BP,kCAI/BE,QAA4B,mBAAXA,QAClBG,aAAaC,UAAU,CAACC,QAAS,oCAGhCJ,UACDE,aAAaC,UAAU,CAACC,QAAS,sCAGrCV,SAASW,IAAIR,KAAM,CAACE,OAAAA,OAAQC,SAAAA,WAG5BM,SAASC,iBAAiBP,mDAGf,CACXF,SAAAA,SACAF,IAAAA"}
\ No newline at end of file
diff --git a/lib/amd/build/modal_save_cancel.min.js b/lib/amd/build/modal_save_cancel.min.js
index 3bf04119ba8..28fd66228b4 100644
--- a/lib/amd/build/modal_save_cancel.min.js
+++ b/lib/amd/build/modal_save_cancel.min.js
@@ -1,10 +1,3 @@
-define("core/modal_save_cancel",["exports","core/modal","core/notification"],(function(_exports,_modal,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
-/**
- * Contain the logic for the save/cancel modal.
- *
- * @module core/modal_save_cancel
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_notification=_interopRequireDefault(_notification);class _default extends _modal.default{constructor(root){super(root),this.getFooter().find(this.getActionSelector("save")).length||_notification.default.exception({message:"No save button found"}),this.getFooter().find(this.getActionSelector("cancel")).length||_notification.default.exception({message:"No cancel button found"})}registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}setFooter(){_notification.default.exception({message:"Can not change the footer of a save cancel modal"})}setSaveButtonText(value){return this.setButtonText("save",value)}}return _exports.default=_default,_exports.default}));
+define("core/modal_save_cancel",["exports","core/modal","core/notification"],(function(_exports,_modal,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_notification=_interopRequireDefault(_notification);class ModalSaveCancel extends _modal.default{constructor(root){super(root),this.getFooter().find(this.getActionSelector("save")).length||_notification.default.exception({message:"No save button found"}),this.getFooter().find(this.getActionSelector("cancel")).length||_notification.default.exception({message:"No cancel button found"})}registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}setFooter(){_notification.default.exception({message:"Can not change the footer of a save cancel modal"})}setSaveButtonText(value){return this.setButtonText("save",value)}}return _exports.default=ModalSaveCancel,_defineProperty(ModalSaveCancel,"TYPE","SAVE_CANCEL"),_defineProperty(ModalSaveCancel,"TEMPLATE","core/modal_save_cancel"),ModalSaveCancel.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_save_cancel.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/modal_save_cancel.min.js.map b/lib/amd/build/modal_save_cancel.min.js.map
index 5b65836080d..515c187e842 100644
--- a/lib/amd/build/modal_save_cancel.min.js.map
+++ b/lib/amd/build/modal_save_cancel.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_save_cancel.min.js","sources":["../src/modal_save_cancel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the save/cancel modal.\n *\n * @module core/modal_save_cancel\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport Notification from 'core/notification';\n\n/**\n * The Save/Cancel Modal.\n *\n * @class\n * @extends module:core/modal\n */\nexport default class extends Modal {\n constructor(root) {\n super(root);\n\n if (!this.getFooter().find(this.getActionSelector('save')).length) {\n Notification.exception({message: 'No save button found'});\n }\n\n if (!this.getFooter().find(this.getActionSelector('cancel')).length) {\n Notification.exception({message: 'No cancel button found'});\n }\n }\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n\n /**\n * Override parent implementation to prevent changing the footer content.\n */\n setFooter() {\n Notification.exception({message: 'Can not change the footer of a save cancel modal'});\n return;\n }\n\n /**\n * Set the title of the save button.\n *\n * @param {String|Promise} value The button text, or a Promise which will resolve it\n * @returns{Promise}\n */\n setSaveButtonText(value) {\n return this.setButtonText('save', value);\n }\n}\n"],"names":["Modal","constructor","root","this","getFooter","find","getActionSelector","length","exception","message","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","setFooter","setSaveButtonText","value","setButtonText"],"mappings":";;;;;;;sMAgC6BA,eACzBC,YAAYC,YACFA,MAEDC,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,SAASC,8BAC1CC,UAAU,CAACC,QAAS,yBAGhCN,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAOzCC,+BAEUA,8BAGDC,2BACAC,wBAMTC,kCACiBL,UAAU,CAACC,QAAS,qDAUrCK,kBAAkBC,cACPZ,KAAKa,cAAc,OAAQD"}
\ No newline at end of file
+{"version":3,"file":"modal_save_cancel.min.js","sources":["../src/modal_save_cancel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the save/cancel modal.\n *\n * @module core/modal_save_cancel\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport Notification from 'core/notification';\n\n/**\n * The Save/Cancel Modal.\n *\n * @class\n * @extends module:core/modal\n */\nexport default class ModalSaveCancel extends Modal {\n static TYPE = 'SAVE_CANCEL';\n static TEMPLATE = 'core/modal_save_cancel';\n\n constructor(root) {\n super(root);\n\n if (!this.getFooter().find(this.getActionSelector('save')).length) {\n Notification.exception({message: 'No save button found'});\n }\n\n if (!this.getFooter().find(this.getActionSelector('cancel')).length) {\n Notification.exception({message: 'No cancel button found'});\n }\n }\n\n /**\n * Register all event listeners.\n */\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n\n /**\n * Override parent implementation to prevent changing the footer content.\n */\n setFooter() {\n Notification.exception({message: 'Can not change the footer of a save cancel modal'});\n return;\n }\n\n /**\n * Set the title of the save button.\n *\n * @param {String|Promise} value The button text, or a Promise which will resolve it\n * @returns{Promise}\n */\n setSaveButtonText(value) {\n return this.setButtonText('save', value);\n }\n}\n\nModalSaveCancel.registerModalType();\n"],"names":["ModalSaveCancel","Modal","constructor","root","this","getFooter","find","getActionSelector","length","exception","message","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","setFooter","setSaveButtonText","value","setButtonText","registerModalType"],"mappings":"4hBAgCqBA,wBAAwBC,eAIzCC,YAAYC,YACFA,MAEDC,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,SAASC,8BAC1CC,UAAU,CAACC,QAAS,yBAGhCN,KAAKC,YAAYC,KAAKF,KAAKG,kBAAkB,WAAWC,8BAC5CC,UAAU,CAACC,QAAS,2BAOzCC,+BAEUA,8BAGDC,2BACAC,wBAMTC,kCACiBL,UAAU,CAACC,QAAS,qDAUrCK,kBAAkBC,cACPZ,KAAKa,cAAc,OAAQD,gEA3CrBhB,uBACH,+BADGA,2BAEC,0BA6CtBA,gBAAgBkB"}
\ No newline at end of file
diff --git a/lib/amd/build/moodlenet/send_activity_modal.min.js b/lib/amd/build/moodlenet/send_activity_modal.min.js
index fcab79d0be5..9a20ed8706a 100644
--- a/lib/amd/build/moodlenet/send_activity_modal.min.js
+++ b/lib/amd/build/moodlenet/send_activity_modal.min.js
@@ -1,3 +1,3 @@
-define("core/moodlenet/send_activity_modal",["exports","core/modal","core/modal_registry"],(function(_exports,_modal,_modal_registry){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const SendActivityModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","core/moodlenet/send_activity_modal"),_defineProperty(_class,"TEMPLATE","core/moodlenet/send_activity_modal_base"),_class);_modal_registry.default.register(SendActivityModal.TYPE,SendActivityModal,SendActivityModal.TEMPLATE);var _default=SendActivityModal;return _exports.default=_default,_exports.default}));
+define("core/moodlenet/send_activity_modal",["exports","core/modal"],(function(_exports,_modal){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class SendActivityModal extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}}return _exports.default=SendActivityModal,_defineProperty(SendActivityModal,"TYPE","core/moodlenet/send_activity_modal"),_defineProperty(SendActivityModal,"TEMPLATE","core/moodlenet/send_activity_modal_base"),SendActivityModal.registerModalType(),_exports.default}));
//# sourceMappingURL=send_activity_modal.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/moodlenet/send_activity_modal.min.js.map b/lib/amd/build/moodlenet/send_activity_modal.min.js.map
index 9dc04ef26e2..ded0340ee51 100644
--- a/lib/amd/build/moodlenet/send_activity_modal.min.js.map
+++ b/lib/amd/build/moodlenet/send_activity_modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"send_activity_modal.min.js","sources":["../../src/moodlenet/send_activity_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Send activity modal for MoodleNet.\n *\n * @module core/moodlenet/send_activity_modal\n * @copyright 2023 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.2\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\n\nconst SendActivityModal = class extends Modal {\n static TYPE = 'core/moodlenet/send_activity_modal';\n static TEMPLATE = 'core/moodlenet/send_activity_modal_base';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(SendActivityModal.TYPE, SendActivityModal, SendActivityModal.TEMPLATE);\n\nexport default SendActivityModal;\n"],"names":["SendActivityModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","register","TYPE","TEMPLATE"],"mappings":"2jBA2BMA,0CAAoB,cAAcC,eAIpCC,+BAEUA,8BAGDC,2BACAC,iCATK,wEACI,2EAYRC,SAASL,kBAAkBM,KAAMN,kBAAmBA,kBAAkBO,uBAErEP"}
\ No newline at end of file
+{"version":3,"file":"send_activity_modal.min.js","sources":["../../src/moodlenet/send_activity_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Send activity modal for MoodleNet.\n *\n * @module core/moodlenet/send_activity_modal\n * @copyright 2023 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.2\n */\n\nimport Modal from 'core/modal';\n\nexport default class SendActivityModal extends Modal {\n static TYPE = 'core/moodlenet/send_activity_modal';\n static TEMPLATE = 'core/moodlenet/send_activity_modal_base';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n}\n\nSendActivityModal.registerModalType();\n"],"names":["SendActivityModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","registerModalType"],"mappings":"wZA0BqBA,0BAA0BC,eAI3CC,+BAEUA,8BAGDC,2BACAC,mFAVQJ,yBACH,sDADGA,6BAEC,2CAYtBA,kBAAkBK"}
\ No newline at end of file
diff --git a/lib/amd/src/config.js b/lib/amd/src/config.js
index 82084bfcab0..a5540376f53 100644
--- a/lib/amd/src/config.js
+++ b/lib/amd/src/config.js
@@ -21,7 +21,5 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/
-define(function() {
- // This module exposes only the raw data from M.cfg;
- return M.cfg;
-});
+// This module exposes only the raw data from M.cfg;
+export default M.cfg;
diff --git a/lib/amd/src/first.js b/lib/amd/src/first.js
index 10eb230575f..1b35e752ed1 100644
--- a/lib/amd/src/first.js
+++ b/lib/amd/src/first.js
@@ -26,10 +26,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/
-define(['jquery'], function($) {
- $(document).bind("ajaxStart", function() {
- M.util.js_pending('jq');
- }).bind("ajaxStop", function() {
- M.util.js_complete('jq');
- });
+
+import $ from 'jquery';
+
+$(document)
+.bind("ajaxStart", function() {
+ M.util.js_pending('jq');
+})
+.bind("ajaxStop", function() {
+ M.util.js_complete('jq');
});
diff --git a/lib/amd/src/local/modal/alert.js b/lib/amd/src/local/modal/alert.js
index 6cf62f100f6..0303f372090 100644
--- a/lib/amd/src/local/modal/alert.js
+++ b/lib/amd/src/local/modal/alert.js
@@ -29,7 +29,10 @@ import Modal from 'core/modal';
* @class
* @extends Modal
*/
-export default class extends Modal {
+export default class ModalAlert extends Modal {
+ static TYPE = 'ALERT';
+ static TEMPLATE = 'core/local/modal/alert';
+
/**
* Register all event listeners.
*/
@@ -41,3 +44,5 @@ export default class extends Modal {
this.registerCloseOnCancel();
}
}
+
+ModalAlert.registerModalType();
diff --git a/lib/amd/src/modal.js b/lib/amd/src/modal.js
index 79f861b3ea2..80878a8faeb 100644
--- a/lib/amd/src/modal.js
+++ b/lib/amd/src/modal.js
@@ -17,76 +17,65 @@
* Contain the logic for modals.
*
* @module core/modal
- * @class core/modal
* @copyright 2016 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([
- 'jquery',
- 'core/templates',
- 'core/notification',
- 'core/key_codes',
- 'core/custom_interaction_events',
- 'core/modal_backdrop',
- 'core_filters/events',
- 'core/modal_events',
- 'core/local/aria/focuslock',
- 'core/pending',
- 'core/aria',
- 'core/fullscreen'
-], function(
- $,
- Templates,
- Notification,
- KeyCodes,
- CustomEvents,
- ModalBackdrop,
- FilterEvents,
- ModalEvents,
- FocusLock,
- Pending,
- Aria,
- Fullscreen
-) {
- var SELECTORS = {
- CONTAINER: '[data-region="modal-container"]',
- MODAL: '[data-region="modal"]',
- HEADER: '[data-region="header"]',
- TITLE: '[data-region="title"]',
- BODY: '[data-region="body"]',
- FOOTER: '[data-region="footer"]',
- HIDE: '[data-action="hide"]',
- DIALOG: '[role=dialog]',
- FORM: 'form',
- MENU_BAR: '[role=menubar]',
- HAS_Z_INDEX: '.moodle-has-zindex',
- CAN_RECEIVE_FOCUS: 'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',
- };
+import $ from 'jquery';
+import * as Templates from 'core/templates';
+import * as Notification from 'core/notification';
+import * as KeyCodes from 'core/key_codes';
+import ModalBackdrop from 'core/modal_backdrop';
+import ModalEvents from 'core/modal_events';
+import * as ModalRegistry from 'core/modal_registry';
+import Pending from 'core/pending';
+import * as CustomEvents from 'core/custom_interaction_events';
+import * as FilterEvents from 'core_filters/events';
+import * as FocusLock from 'core/local/aria/focuslock';
+import * as Aria from 'core/aria';
+import * as Fullscreen from 'core/fullscreen';
- var TEMPLATES = {
- LOADING: 'core/loading',
- BACKDROP: 'core/modal_backdrop',
- };
+const SELECTORS = {
+ CONTAINER: '[data-region="modal-container"]',
+ MODAL: '[data-region="modal"]',
+ HEADER: '[data-region="header"]',
+ TITLE: '[data-region="title"]',
+ BODY: '[data-region="body"]',
+ FOOTER: '[data-region="footer"]',
+ HIDE: '[data-action="hide"]',
+ DIALOG: '[role=dialog]',
+ FORM: 'form',
+ MENU_BAR: '[role=menubar]',
+ HAS_Z_INDEX: '.moodle-has-zindex',
+ CAN_RECEIVE_FOCUS: 'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',
+};
+
+const TEMPLATES = {
+ LOADING: 'core/loading',
+ BACKDROP: 'core/modal_backdrop',
+};
+
+export default class Modal {
+ /** @var {string} The template to use for this modal */
+ static TEMPLATE = 'core/modal';
+
+ /** @var {Promise} Module singleton for the backdrop to be reused by all Modal instances */
+ static backdropPromise = null;
/**
- * Module singleton for the backdrop to be reused by all Modal instances.
+ * @var {Number} A counter that gets incremented for each modal created.
+ * This can be used to generate unique values for the modals.
*/
- var backdropPromise;
-
- /**
- * A counter that gets incremented for each modal created. This can be
- * used to generate unique values for the modals.
- */
- var modalCounter = 0;
+ static modalCounter = 0;
/**
* Constructor for the Modal.
*
* @param {object} root The root jQuery element for the modal
*/
- var Modal = function(root) {
+ constructor(root) {
this.root = $(root);
+
this.modal = this.root.find(SELECTORS.MODAL);
this.header = this.modal.find(SELECTORS.HEADER);
this.headerPromise = $.Deferred();
@@ -100,7 +89,7 @@ define([
this.isAttached = false;
this.bodyJS = null;
this.footerJS = null;
- this.modalCount = modalCounter++;
+ this.modalCount = this.modalCounter++;
this.attachmentPoint = document.createElement('div');
document.body.append(this.attachmentPoint);
this.focusOnClose = null;
@@ -130,7 +119,25 @@ define([
}
this.registerEventListeners();
- };
+ }
+
+ /**
+ * Register a modal with the modal registry.
+ */
+ static registerModalType() {
+ if (!this.TYPE) {
+ throw new Error(`Unknown modal type`, this);
+ }
+
+ if (!this.TEMPLATE) {
+ throw new Error(`Unknown modal template`, this);
+ }
+ ModalRegistry.register(
+ this.TYPE,
+ this,
+ this.TEMPLATE,
+ );
+ }
/**
* Attach the modal to the correct part of the page.
@@ -140,7 +147,7 @@ define([
*
* @method attachToDOM
*/
- Modal.prototype.attachToDOM = function() {
+ attachToDOM() {
this.getAttachmentPoint().append(this.root);
if (this.isAttached) {
@@ -162,7 +169,7 @@ define([
}
this.isAttached = true;
- };
+ }
/**
* Count the number of other visible modals (not including this one).
@@ -170,19 +177,19 @@ define([
* @method countOtherVisibleModals
* @return {int}
*/
- Modal.prototype.countOtherVisibleModals = function() {
- var count = 0;
- $('body').find(SELECTORS.CONTAINER).each(function(index, element) {
+ countOtherVisibleModals() {
+ let count = 0;
+ $('body').find(SELECTORS.CONTAINER).each((index, element) => {
element = $(element);
// If we haven't found ourself and the element is visible.
if (!this.root.is(element) && element.hasClass('show')) {
count++;
}
- }.bind(this));
+ });
return count;
- };
+ }
/**
* Get the modal backdrop.
@@ -190,19 +197,15 @@ define([
* @method getBackdrop
* @return {object} jQuery promise
*/
- Modal.prototype.getBackdrop = function() {
- if (!backdropPromise) {
- backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})
- .then(function(html) {
- var element = $(html);
-
- return new ModalBackdrop(element);
- })
- .fail(Notification.exception);
+ getBackdrop() {
+ if (!Modal.backdropPromise) {
+ Modal.backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})
+ .then((html) => new ModalBackdrop($(html)))
+ .catch(Notification.exception);
}
- return backdropPromise;
- };
+ return Modal.backdropPromise;
+ }
/**
* Get the root element of this modal.
@@ -210,9 +213,9 @@ define([
* @method getRoot
* @return {object} jQuery object
*/
- Modal.prototype.getRoot = function() {
+ getRoot() {
return this.root;
- };
+ }
/**
* Get the modal element of this modal.
@@ -220,9 +223,9 @@ define([
* @method getModal
* @return {object} jQuery object
*/
- Modal.prototype.getModal = function() {
+ getModal() {
return this.modal;
- };
+ }
/**
* Get the modal title element.
@@ -230,9 +233,9 @@ define([
* @method getTitle
* @return {object} jQuery object
*/
- Modal.prototype.getTitle = function() {
+ getTitle() {
return this.title;
- };
+ }
/**
* Get the modal body element.
@@ -240,9 +243,9 @@ define([
* @method getBody
* @return {object} jQuery object
*/
- Modal.prototype.getBody = function() {
+ getBody() {
return this.body;
- };
+ }
/**
* Get the modal footer element.
@@ -250,9 +253,9 @@ define([
* @method getFooter
* @return {object} jQuery object
*/
- Modal.prototype.getFooter = function() {
+ getFooter() {
return this.footer;
- };
+ }
/**
* Get a promise resolving to the title region.
@@ -260,9 +263,9 @@ define([
* @method getTitlePromise
* @return {Promise}
*/
- Modal.prototype.getTitlePromise = function() {
+ getTitlePromise() {
return this.titlePromise;
- };
+ }
/**
* Get a promise resolving to the body region.
@@ -270,9 +273,9 @@ define([
* @method getBodyPromise
* @return {object} jQuery object
*/
- Modal.prototype.getBodyPromise = function() {
+ getBodyPromise() {
return this.bodyPromise;
- };
+ }
/**
* Get a promise resolving to the footer region.
@@ -280,9 +283,9 @@ define([
* @method getFooterPromise
* @return {object} jQuery object
*/
- Modal.prototype.getFooterPromise = function() {
+ getFooterPromise() {
return this.footerPromise;
- };
+ }
/**
* Get the unique modal count.
@@ -290,9 +293,9 @@ define([
* @method getModalCount
* @return {int}
*/
- Modal.prototype.getModalCount = function() {
+ getModalCount() {
return this.modalCount;
- };
+ }
/**
* Set the modal title element.
@@ -303,16 +306,17 @@ define([
* @method setTitle
* @param {(string|object)} value The title string or jQuery promise which resolves to the title.
*/
- Modal.prototype.setTitle = function(value) {
- var title = this.getTitle();
+ setTitle(value) {
+ const title = this.getTitle();
this.titlePromise = $.Deferred();
this.asyncSet(value, title.html.bind(title))
- .then(function() {
+ .then(() => {
this.titlePromise.resolve(title);
- }.bind(this))
+ return;
+ })
.catch(Notification.exception);
- };
+ }
/**
* Set the modal body element.
@@ -324,10 +328,10 @@ define([
* @param {(string|object)} value The body string or jQuery promise which resolves to the body.
* @fires event:filterContentUpdated
*/
- Modal.prototype.setBody = function(value) {
+ setBody(value) {
this.bodyPromise = $.Deferred();
- var body = this.getBody();
+ const body = this.getBody();
if (typeof value === 'string') {
// Just set the value if it's a string.
@@ -336,11 +340,10 @@ define([
this.getRoot().trigger(ModalEvents.bodyRendered, this);
this.bodyPromise.resolve(body);
} else {
- var jsPendingId = 'amd-modal-js-pending-id-' + this.getModalCount();
- M.util.js_pending(jsPendingId);
+ const modalPromise = new Pending(`amd-modal-js-pending-id-${this.getModalCount()}`);
// Otherwise we assume it's a promise to be resolved with
// html and javascript.
- var contentPromise = null;
+ let contentPromise = null;
body.css('overflow', 'hidden');
// Ensure that the `value` is a jQuery Promise.
@@ -349,17 +352,17 @@ define([
if (value.state() == 'pending') {
// We're still waiting for the body promise to resolve so
// let's show a loading icon.
- var height = body.innerHeight();
+ let height = body.innerHeight();
if (height < 100) {
height = 100;
}
- body.animate({height: height + 'px'}, 150);
+ body.animate({height: `${height}px`}, 150);
body.html('');
contentPromise = Templates.render(TEMPLATES.LOADING, {})
- .then(function(html) {
- var loadingIcon = $(html).hide();
+ .then((html) => {
+ const loadingIcon = $(html).hide();
body.html(loadingIcon);
loadingIcon.fadeIn(150);
@@ -368,13 +371,13 @@ define([
// loading.
return $.when(loadingIcon.promise(), value);
})
- .then(function(loadingIcon) {
+ .then((loadingIcon) => {
// Once the content has finished loading and
// the loading icon has been shown then we can
// fade the icon away to reveal the content.
return loadingIcon.fadeOut(100).promise();
})
- .then(function() {
+ .then(() => {
return value;
});
} else {
@@ -384,24 +387,24 @@ define([
}
// Now we can actually display the content.
- contentPromise.then(function(html, js) {
- var result = null;
+ contentPromise.then((html, js) => {
+ let result = null;
if (this.isVisible()) {
// If the modal is visible then we should display
// the content gracefully for the user.
body.css('opacity', 0);
- var currentHeight = body.innerHeight();
+ const currentHeight = body.innerHeight();
body.html(html);
// We need to clear any height values we've set here
// in order to measure the height of the content being
// added. This then allows us to animate the height
// transition.
body.css('height', '');
- var newHeight = body.innerHeight();
- body.css('height', currentHeight + 'px');
+ const newHeight = body.innerHeight();
+ body.css('height', `${currentHeight}px`);
result = body.animate(
- {height: newHeight + 'px', opacity: 1},
+ {height: `${newHeight}px`, opacity: 1},
{duration: 150, queue: false}
).promise();
} else {
@@ -421,30 +424,29 @@ define([
}
return result;
- }.bind(this))
- .then(function(result) {
+ })
+ .then((result) => {
FilterEvents.notifyFilterContentUpdated(body);
this.getRoot().trigger(ModalEvents.bodyRendered, this);
return result;
- }.bind(this))
- .then(function() {
+ })
+ .then(() => {
this.bodyPromise.resolve(body);
return;
- }.bind(this))
- .fail(Notification.exception)
- .always(function() {
+ })
+ .catch(Notification.exception)
+ .always(() => {
// When we're done displaying all of the content we need
// to clear the custom values we've set here.
body.css('height', '');
body.css('overflow', '');
body.css('opacity', '');
- M.util.js_complete(jsPendingId);
+ modalPromise.resolve();
return;
- })
- .fail(Notification.exception);
+ });
}
- };
+ }
/**
* Alternative to setBody() that can be used from non-Jquery modules
@@ -452,7 +454,7 @@ define([
* @param {Promise} promise promise that returns {html, js} object
* @return {Promise}
*/
- Modal.prototype.setBodyContent = function(promise) {
+ setBodyContent(promise) {
// Call the leegacy API for now and pass it a jQuery Promise.
// This is a non-spec feature of jQuery and cannot be produced with spec promises.
// We can encourage people to migrate to this approach, and in future we can swap
@@ -462,7 +464,7 @@ define([
this.hide();
throw exception;
});
- };
+ }
/**
* Set the modal footer element. The footer element is made visible, if it
@@ -475,12 +477,12 @@ define([
* @method setFooter
* @param {(string|object)} value The footer string or jQuery promise
*/
- Modal.prototype.setFooter = function(value) {
+ setFooter(value) {
// Make sure the footer is visible.
this.showFooter();
this.footerPromise = $.Deferred();
- var footer = this.getFooter();
+ const footer = this.getFooter();
if (typeof value === 'string') {
// Just set the value if it's a string.
@@ -490,12 +492,12 @@ define([
// Otherwise we assume it's a promise to be resolved with
// html and javascript.
Templates.render(TEMPLATES.LOADING, {})
- .then(function(html) {
+ .then((html) => {
footer.html(html);
return value;
})
- .then(function(html, js) {
+ .then((html, js) => {
footer.html(html);
if (js) {
@@ -509,14 +511,14 @@ define([
}
return footer;
- }.bind(this))
- .then(function(footer) {
+ })
+ .then((footer) => {
this.footerPromise.resolve(footer);
return;
- }.bind(this))
+ })
.catch(Notification.exception);
}
- };
+ }
/**
* Check if the footer has any content in it.
@@ -524,40 +526,40 @@ define([
* @method hasFooterContent
* @return {bool}
*/
- Modal.prototype.hasFooterContent = function() {
+ hasFooterContent() {
return this.getFooter().children().length ? true : false;
- };
+ }
/**
* Hide the footer element.
*
* @method hideFooter
*/
- Modal.prototype.hideFooter = function() {
+ hideFooter() {
this.getFooter().addClass('hidden');
- };
+ }
/**
* Show the footer element.
*
* @method showFooter
*/
- Modal.prototype.showFooter = function() {
+ showFooter() {
this.getFooter().removeClass('hidden');
- };
+ }
/**
* Mark the modal as a large modal.
*
* @method setLarge
*/
- Modal.prototype.setLarge = function() {
+ setLarge() {
if (this.isLarge()) {
return;
}
this.getModal().addClass('modal-lg');
- };
+ }
/**
* Check if the modal is a large modal.
@@ -565,22 +567,22 @@ define([
* @method isLarge
* @return {bool}
*/
- Modal.prototype.isLarge = function() {
+ isLarge() {
return this.getModal().hasClass('modal-lg');
- };
+ }
/**
* Mark the modal as a small modal.
*
* @method setSmall
*/
- Modal.prototype.setSmall = function() {
+ setSmall() {
if (this.isSmall()) {
return;
}
this.getModal().removeClass('modal-lg');
- };
+ }
/**
* Check if the modal is a small modal.
@@ -588,9 +590,9 @@ define([
* @method isSmall
* @return {bool}
*/
- Modal.prototype.isSmall = function() {
+ isSmall() {
return !this.getModal().hasClass('modal-lg');
- };
+ }
/**
* Set this modal to be scrollable or not.
@@ -598,14 +600,14 @@ define([
* @method setScrollable
* @param {bool} value Whether the modal is scrollable or not
*/
- Modal.prototype.setScrollable = function(value) {
+ setScrollable(value) {
if (!value) {
this.getModal()[0].classList.remove('modal-dialog-scrollable');
return;
}
this.getModal()[0].classList.add('modal-dialog-scrollable');
- };
+ }
/**
@@ -614,15 +616,15 @@ define([
* @method calculateZIndex
* @return {int}
*/
- Modal.prototype.calculateZIndex = function() {
- var items = $(SELECTORS.DIALOG + ', ' + SELECTORS.MENU_BAR + ', ' + SELECTORS.HAS_Z_INDEX);
- var zIndex = parseInt(this.root.css('z-index'));
+ calculateZIndex() {
+ const items = $(`${SELECTORS.DIALOG}, ${SELECTORS.MENU_BAR}, ${SELECTORS.HAS_Z_INDEX}`);
+ let zIndex = parseInt(this.root.css('z-index'));
- items.each(function(index, item) {
+ items.each((index, item) => {
item = $(item);
// Note that webkit browsers won't return the z-index value from the CSS stylesheet
// if the element doesn't have a position specified. Instead it'll return "auto".
- var itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;
+ const itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;
if (itemZIndex > zIndex) {
zIndex = itemZIndex;
@@ -630,7 +632,7 @@ define([
});
return zIndex;
- };
+ }
/**
* Check if this modal is visible.
@@ -638,9 +640,9 @@ define([
* @method isVisible
* @return {bool}
*/
- Modal.prototype.isVisible = function() {
+ isVisible() {
return this.root.hasClass('show');
- };
+ }
/**
* Check if this modal has focus.
@@ -648,10 +650,10 @@ define([
* @method hasFocus
* @return {bool}
*/
- Modal.prototype.hasFocus = function() {
- var target = $(document.activeElement);
+ hasFocus() {
+ const target = $(document.activeElement);
return this.root.is(target) || this.root.has(target).length;
- };
+ }
/**
* Check if this modal has CSS transitions applied.
@@ -659,18 +661,18 @@ define([
* @method hasTransitions
* @return {bool}
*/
- Modal.prototype.hasTransitions = function() {
+ hasTransitions() {
return this.getRoot().hasClass('fade');
- };
+ }
/**
* Gets the jQuery wrapped node that the Modal should be attached to.
*
* @returns {jQuery}
*/
- Modal.prototype.getAttachmentPoint = function() {
+ getAttachmentPoint() {
return $(Fullscreen.getElement() || this.attachmentPoint);
- };
+ }
/**
* Display this modal. The modal will be attached to the DOM if it hasn't
@@ -679,12 +681,12 @@ define([
* @method show
* @returns {Promise}
*/
- Modal.prototype.show = function() {
+ show() {
if (this.isVisible()) {
return $.Deferred().resolve();
}
- var pendingPromise = new Pending('core/modal:show');
+ const pendingPromise = new Pending('core/modal:show');
if (this.hasFooterContent()) {
this.showFooter();
@@ -700,10 +702,10 @@ define([
}
return this.getBackdrop()
- .then(function(backdrop) {
- var currentIndex = this.calculateZIndex();
- var newIndex = currentIndex + 2;
- var newBackdropIndex = newIndex - 1;
+ .then((backdrop) => {
+ const currentIndex = this.calculateZIndex();
+ const newIndex = currentIndex + 2;
+ const newBackdropIndex = newIndex - 1;
this.root.css('z-index', newIndex);
backdrop.setZIndex(newBackdropIndex);
backdrop.show();
@@ -715,29 +717,29 @@ define([
this.root.trigger(ModalEvents.shown, this);
return;
- }.bind(this))
+ })
.then(pendingPromise.resolve);
- };
+ }
/**
* Hide this modal if it does not contain a form.
*
* @method hideIfNotForm
*/
- Modal.prototype.hideIfNotForm = function() {
- var formElement = this.modal.find(SELECTORS.FORM);
+ hideIfNotForm() {
+ const formElement = this.modal.find(SELECTORS.FORM);
if (formElement.length == 0) {
this.hide();
}
- };
+ }
/**
* Hide this modal.
*
* @method hide
*/
- Modal.prototype.hide = function() {
- this.getBackdrop().done(function(backdrop) {
+ hide() {
+ this.getBackdrop().done((backdrop) => {
FocusLock.untrapFocus();
if (!this.countOtherVisibleModals()) {
@@ -746,7 +748,7 @@ define([
$('body').removeClass('modal-open');
}
- var currentIndex = parseInt(this.root.css('z-index'));
+ const currentIndex = parseInt(this.root.css('z-index'));
this.root.css('z-index', '');
backdrop.setZIndex(currentIndex - 3);
@@ -754,9 +756,9 @@ define([
if (this.hasTransitions()) {
// Wait for CSS transitions to complete before hiding the element.
- this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {
+ this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', () => {
this.getRoot().removeClass('show').addClass('hide');
- }.bind(this));
+ });
} else {
this.getRoot().removeClass('show').addClass('hide');
}
@@ -767,20 +769,20 @@ define([
}
this.root.trigger(ModalEvents.hidden, this);
- }.bind(this));
- };
+ });
+ }
/**
* Remove this modal from the DOM.
*
* @method destroy
*/
- Modal.prototype.destroy = function() {
+ destroy() {
this.hide();
this.root.remove();
this.root.trigger(ModalEvents.destroyed, this);
this.attachmentPoint.remove();
- };
+ }
/**
* Sets the appropriate aria attributes on this dialogue and the other
@@ -789,13 +791,13 @@ define([
*
* @method accessibilityShow
*/
- Modal.prototype.accessibilityShow = function() {
+ accessibilityShow() {
// Make us visible to screen readers.
Aria.unhide(this.root.get());
// Hide siblings.
Aria.hideSiblings(this.root.get()[0]);
- };
+ }
/**
* Restores the aria visibility on the DOM elements changed when displaying
@@ -804,21 +806,21 @@ define([
*
* @method accessibilityHide
*/
- Modal.prototype.accessibilityHide = function() {
+ accessibilityHide() {
// Unhide siblings.
Aria.unhideSiblings(this.root.get()[0]);
// Hide this modal.
Aria.hide(this.root.get());
- };
+ }
/**
* Set up all of the event handling for the modal.
*
* @method registerEventListeners
*/
- Modal.prototype.registerEventListeners = function() {
- this.getRoot().on('keydown', function(e) {
+ registerEventListeners() {
+ this.getRoot().on('keydown', (e) => {
if (!this.isVisible()) {
return;
}
@@ -830,10 +832,10 @@ define([
this.hide();
}
}
- }.bind(this));
+ });
// Listen for clicks on the modal container.
- this.getRoot().click(function(e) {
+ this.getRoot().click((e) => {
// If the click wasn't inside the modal element then we should
// hide the modal.
if (!$(e.target).closest(SELECTORS.MODAL).length) {
@@ -841,7 +843,7 @@ define([
// So, we check if we can still find the container element or not. If not, then the DOM tree is changed.
// It's best not to hide the modal in that case.
if ($(e.target).closest(SELECTORS.CONTAINER).length) {
- var outsideClickEvent = $.Event(ModalEvents.outsideClick);
+ const outsideClickEvent = $.Event(ModalEvents.outsideClick);
this.getRoot().trigger(outsideClickEvent, this);
if (!outsideClickEvent.isDefaultPrevented()) {
@@ -849,17 +851,17 @@ define([
}
}
}
- }.bind(this));
+ });
CustomEvents.define(this.getModal(), [CustomEvents.events.activate]);
- this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, function(e, data) {
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, (e, data) => {
if (this.removeOnClose) {
this.destroy();
} else {
this.hide();
}
data.originalEvent.preventDefault();
- }.bind(this));
+ });
this.getRoot().on(ModalEvents.hidden, () => {
if (this.focusOnClose) {
@@ -867,17 +869,17 @@ define([
this.focusOnClose.focus();
}
});
- };
+ }
/**
* Register a listener to close the dialogue when the cancel button is pressed.
*
* @method registerCloseOnCancel
*/
- Modal.prototype.registerCloseOnCancel = function() {
+ registerCloseOnCancel() {
// Handle the clicking of the Cancel button.
- this.getModal().on(CustomEvents.events.activate, this.getActionSelector('cancel'), function(e, data) {
- var cancelEvent = $.Event(ModalEvents.cancel);
+ this.getModal().on(CustomEvents.events.activate, this.getActionSelector('cancel'), (e, data) => {
+ const cancelEvent = $.Event(ModalEvents.cancel);
this.getRoot().trigger(cancelEvent, this);
if (!cancelEvent.isDefaultPrevented()) {
@@ -889,18 +891,18 @@ define([
this.hide();
}
}
- }.bind(this));
- };
+ });
+ }
/**
* Register a listener to close the dialogue when the save button is pressed.
*
* @method registerCloseOnSave
*/
- Modal.prototype.registerCloseOnSave = function() {
+ registerCloseOnSave() {
// Handle the clicking of the Cancel button.
- this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), function(e, data) {
- var saveEvent = $.Event(ModalEvents.save);
+ this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), (e, data) => {
+ const saveEvent = $.Event(ModalEvents.save);
this.getRoot().trigger(saveEvent, this);
if (!saveEvent.isDefaultPrevented()) {
@@ -912,8 +914,8 @@ define([
this.hide();
}
}
- }.bind(this));
- };
+ });
+ }
/**
@@ -921,10 +923,10 @@ define([
*
* @method registerCloseOnDelete
*/
- Modal.prototype.registerCloseOnDelete = function() {
+ registerCloseOnDelete() {
// Handle the clicking of the Cancel button.
- this.getModal().on(CustomEvents.events.activate, this.getActionSelector('delete'), function(e, data) {
- var deleteEvent = $.Event(ModalEvents.delete);
+ this.getModal().on(CustomEvents.events.activate, this.getActionSelector('delete'), (e, data) => {
+ const deleteEvent = $.Event(ModalEvents.delete);
this.getRoot().trigger(deleteEvent, this);
if (!deleteEvent.isDefaultPrevented()) {
@@ -936,8 +938,8 @@ define([
this.hide();
}
}
- }.bind(this));
- };
+ });
+ }
/**
* Set or resolve and set the value using the function.
@@ -947,22 +949,22 @@ define([
* @param {function} setFunction The setter
* @return {Promise}
*/
- Modal.prototype.asyncSet = function(value, setFunction) {
+ asyncSet(value, setFunction) {
var p = value;
if (typeof value !== 'object' || !value.hasOwnProperty('then')) {
p = $.Deferred();
p.resolve(value);
}
- p.then(function(content) {
+ p.then((content) => {
setFunction(content);
return;
})
- .fail(Notification.exception);
+ .catch(Notification.exception);
return p;
- };
+ }
/**
* Set the title text of a button.
@@ -974,7 +976,7 @@ define([
* @param {(String|object)} value The button text, or a promise which will resolve to it
* @returns {Promise}
*/
- Modal.prototype.setButtonText = function(action, value) {
+ setButtonText(action, value) {
const button = this.getFooter().find(this.getActionSelector(action));
if (!button) {
@@ -982,7 +984,7 @@ define([
}
return this.asyncSet(value, button.text.bind(button));
- };
+ }
/**
* Get the Selector for an action.
@@ -990,27 +992,27 @@ define([
* @param {String} action
* @returns {DOMString}
*/
- Modal.prototype.getActionSelector = function(action) {
+ getActionSelector(action) {
return "[data-action='" + action + "']";
- };
+ }
/**
* Set the flag to remove the modal from the DOM on close.
*
* @param {Boolean} remove
*/
- Modal.prototype.setRemoveOnClose = function(remove) {
+ setRemoveOnClose(remove) {
this.removeOnClose = remove;
- };
+ }
/**
* Set the return element for the modal.
*
* @param {Element|jQuery} element Element to focus when the modal is closed
*/
- Modal.prototype.setReturnElement = function(element) {
+ setReturnElement(element) {
this.focusOnClose = element;
- };
+ }
/**
* Set the a button enabled or disabled.
@@ -1018,7 +1020,7 @@ define([
* @param {DOMString} action The action of the button
* @param {Boolean} disabled the new disabled value
*/
- Modal.prototype.setButtonDisabled = function(action, disabled) {
+ setButtonDisabled(action, disabled) {
const button = this.getFooter().find(this.getActionSelector(action));
if (!button) {
@@ -1029,7 +1031,5 @@ define([
} else {
button.removeAttr('disabled');
}
- };
-
- return Modal;
-});
+ }
+}
diff --git a/lib/amd/src/modal_backdrop.js b/lib/amd/src/modal_backdrop.js
index 6da66ca5615..219040a6ba0 100644
--- a/lib/amd/src/modal_backdrop.js
+++ b/lib/amd/src/modal_backdrop.js
@@ -20,20 +20,26 @@
* @copyright 2016 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
- function($, Templates, Notification, Fullscreen) {
+import $ from 'jquery';
+import * as Notification from './notification';
+import * as Fullscreen from './fullscreen';
- var SELECTORS = {
- ROOT: '[data-region="modal-backdrop"]',
- };
+const SELECTORS = {
+ ROOT: '[data-region="modal-backdrop"]',
+};
+
+export default class ModalBackdrop {
+ root = null;
+ isAttached = false;
+ attachmentPoint = null;
/**
* Constructor for ModalBackdrop.
*
* @class core/modal_backdrop
- * @param {object} root The root element for the modal backdrop
+ * @param {HTMLElement|jQuery} root The root element for the modal backdrop
*/
- var ModalBackdrop = function(root) {
+ constructor(root) {
this.root = $(root);
this.isAttached = false;
this.attachmentPoint = document.createElement('div');
@@ -42,7 +48,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
if (!this.root.is(SELECTORS.ROOT)) {
Notification.exception({message: 'Element is not a modal backdrop'});
}
- };
+ }
/**
* Get the root element of this modal backdrop.
@@ -50,25 +56,25 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
* @method getRoot
* @return {object} jQuery object
*/
- ModalBackdrop.prototype.getRoot = function() {
+ getRoot() {
return this.root;
- };
+ }
- /**
- * Gets the jQuery wrapped node that the Modal should be attached to.
- *
- * @returns {jQuery}
- */
- ModalBackdrop.prototype.getAttachmentPoint = function() {
- return $(Fullscreen.getElement() || this.attachmentPoint);
- };
+ /**
+ * Gets the jQuery wrapped node that the Modal should be attached to.
+ *
+ * @returns {jQuery}
+ */
+ getAttachmentPoint() {
+ return $(Fullscreen.getElement() || this.attachmentPoint);
+ }
/**
* Add the modal backdrop to the page, if it hasn't already been added.
*
* @method attachToDOM
*/
- ModalBackdrop.prototype.attachToDOM = function() {
+ attachToDOM() {
this.getAttachmentPoint().append(this.root);
if (this.isAttached) {
@@ -76,7 +82,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
}
this.isAttached = true;
- };
+ }
/**
* Set the z-index value for this backdrop.
@@ -84,9 +90,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
* @method setZIndex
* @param {int} value The z-index value
*/
- ModalBackdrop.prototype.setZIndex = function(value) {
+ setZIndex(value) {
this.root.css('z-index', value);
- };
+ }
/**
* Check if this backdrop is visible.
@@ -94,9 +100,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
* @method isVisible
* @return {bool}
*/
- ModalBackdrop.prototype.isVisible = function() {
+ isVisible() {
return this.root.hasClass('show');
- };
+ }
/**
* Check if this backdrop has CSS transitions applied.
@@ -104,9 +110,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
* @method hasTransitions
* @return {bool}
*/
- ModalBackdrop.prototype.hasTransitions = function() {
+ hasTransitions() {
return this.getRoot().hasClass('fade');
- };
+ }
/**
* Display this backdrop. The backdrop will be attached to the DOM if it hasn't
@@ -114,31 +120,30 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
*
* @method show
*/
- ModalBackdrop.prototype.show = function() {
+ show() {
if (this.isVisible()) {
return;
}
this.attachToDOM();
-
this.root.removeClass('hide').addClass('show');
- };
+ }
/**
* Hide this backdrop.
*
* @method hide
*/
- ModalBackdrop.prototype.hide = function() {
+ hide() {
if (!this.isVisible()) {
return;
}
if (this.hasTransitions()) {
// Wait for CSS transitions to complete before hiding the element.
- this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {
+ this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', () => {
this.getRoot().removeClass('show').addClass('hide');
- }.bind(this));
+ });
} else {
this.getRoot().removeClass('show').addClass('hide');
}
@@ -147,17 +152,15 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
if ($(document.body).find(this.getRoot()).length) {
$(document.body).append(this.getRoot());
}
- };
+ }
/**
* Remove this backdrop from the DOM.
*
* @method destroy
*/
- ModalBackdrop.prototype.destroy = function() {
+ destroy() {
this.root.remove();
this.attachmentPoint.remove();
- };
-
- return ModalBackdrop;
-});
+ }
+}
diff --git a/lib/amd/src/modal_cancel.js b/lib/amd/src/modal_cancel.js
index 56f4caf4424..9bcf8d0429d 100644
--- a/lib/amd/src/modal_cancel.js
+++ b/lib/amd/src/modal_cancel.js
@@ -28,7 +28,10 @@ import Notification from 'core/notification';
* @class
* @extends module:core/modal
*/
-export default class extends Modal {
+export default class ModalCancel extends Modal {
+ static TYPE = 'CANCEL';
+ static TEMPLATE = 'core/modal_cancel';
+
constructor(root) {
super(root);
@@ -48,3 +51,5 @@ export default class extends Modal {
this.registerCloseOnCancel();
}
}
+
+ModalCancel.registerModalType();
diff --git a/lib/amd/src/modal_copy_to_clipboard.js b/lib/amd/src/modal_copy_to_clipboard.js
index e1f0915f85b..050ff473b25 100644
--- a/lib/amd/src/modal_copy_to_clipboard.js
+++ b/lib/amd/src/modal_copy_to_clipboard.js
@@ -28,7 +28,6 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
import ModalFactory from 'core/modal_factory';
import 'core/copy_to_clipboard';
@@ -85,9 +84,7 @@ export default class CopyToClipboardModal extends Modal {
} = {},
title
) {
- if (!ModalRegistry.get(this.TYPE)) {
- ModalRegistry.register(this.TYPE, this, this.TEMPLATE);
- }
+ this.registerModalType();
const modal = await ModalFactory.create({
type: this.TYPE,
@@ -101,4 +98,4 @@ export default class CopyToClipboardModal extends Modal {
}
modal.show();
}
-}
\ No newline at end of file
+}
diff --git a/lib/amd/src/modal_delete_cancel.js b/lib/amd/src/modal_delete_cancel.js
index 611a87f0f69..5683ae31b1c 100644
--- a/lib/amd/src/modal_delete_cancel.js
+++ b/lib/amd/src/modal_delete_cancel.js
@@ -29,7 +29,10 @@ import Notification from 'core/notification';
* @class
* @extends module:core/modal
*/
-export default class extends Modal {
+export default class ModalDeleteCancel extends Modal {
+ static TYPE = 'DELETE_CANCEL';
+ static TEMPLATE = 'core/modal_delete_cancel';
+
constructor(root) {
super(root);
@@ -71,3 +74,5 @@ export default class extends Modal {
return this.setButtonText('delete', value);
}
}
+
+ModalDeleteCancel.registerModalType();
diff --git a/lib/amd/src/modal_events.js b/lib/amd/src/modal_events.js
index af2fc60570a..a85f1cd969a 100644
--- a/lib/amd/src/modal_events.js
+++ b/lib/amd/src/modal_events.js
@@ -21,17 +21,15 @@
* @copyright 2016 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([], function() {
- return {
- // Default events.
- shown: 'modal:shown',
- hidden: 'modal:hidden',
- destroyed: 'modal:destroyed',
- bodyRendered: 'modal:bodyRendered',
- outsideClick: 'modal:outsideClick',
- // ModalSaveCancel events.
- save: 'modal-save-cancel:save',
- 'delete': 'modal-delete-cancel:delete', // Delete is a reserved word.
- cancel: 'modal-save-cancel:cancel',
- };
-});
+export default {
+ // Default events.
+ shown: 'modal:shown',
+ hidden: 'modal:hidden',
+ destroyed: 'modal:destroyed',
+ bodyRendered: 'modal:bodyRendered',
+ outsideClick: 'modal:outsideClick',
+ // ModalSaveCancel events.
+ save: 'modal-save-cancel:save',
+ 'delete': 'modal-delete-cancel:delete', // Delete is a reserved word.
+ cancel: 'modal-save-cancel:cancel',
+};
diff --git a/lib/amd/src/modal_factory.js b/lib/amd/src/modal_factory.js
index 3295da4e489..ca1a2b79207 100644
--- a/lib/amd/src/modal_factory.js
+++ b/lib/amd/src/modal_factory.js
@@ -20,220 +20,203 @@
* @copyright 2016 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
- 'core/modal_save_cancel', 'core/modal_delete_cancel', 'core/modal_cancel', 'core/local/modal/alert',
- 'core/templates', 'core/notification', 'core/custom_interaction_events',
- 'core/pending'],
- function($, ModalEvents, ModalRegistry, Modal, ModalSaveCancel, ModalDeleteCancel,
- ModalCancel, ModalAlert, Templates, Notification, CustomEvents, Pending) {
- // The templates for each type of modal.
- var TEMPLATES = {
- DEFAULT: 'core/modal',
- SAVE_CANCEL: 'core/modal_save_cancel',
- DELETE_CANCEL: 'core/modal_delete_cancel',
- CANCEL: 'core/modal_cancel',
- ALERT: 'core/local/modal/alert',
- };
+import $ from 'jquery';
+import ModalEvents from 'core/modal_events';
+import * as ModalRegistry from 'core/modal_registry';
+import Modal from 'core/modal';
+import ModalSaveCancel from 'core/modal_save_cancel';
+import ModalDeleteCancel from 'core/modal_delete_cancel';
+import ModalCancel from 'core/modal_cancel';
+import ModalAlert from 'core/local/modal/alert';
+import * as Templates from 'core/templates';
+import * as Notification from 'core/notification';
+import * as CustomEvents from 'core/custom_interaction_events';
+import Pending from 'core/pending';
- /**
- * The available types of modals.
- *
- * @constant
- * @static
- * @public
- * @property {String} DEFAULT The default modal
- * @property {String} SAVE_CANCEL A modal which can be used to either save, or cancel.
- * @property {String} DELETE_CANCEL A modal which can be used to either delete, or cancel.
- * @property {String} CANCEL A modal which displayed a cancel button
- * @property {String} ALERT An information modal which only displays information.
- */
- var TYPES = {
- DEFAULT: 'DEFAULT',
- SAVE_CANCEL: 'SAVE_CANCEL',
- DELETE_CANCEL: 'DELETE_CANCEL',
- CANCEL: 'CANCEL',
- ALERT: 'ALERT',
- };
+/**
+ * The available standard modals.
+ *
+ * @property {String} DEFAULT The default modal
+ * @property {String} SAVE_CANCEL A modal which can be used to either save, or cancel.
+ * @property {String} DELETE_CANCEL A modal which can be used to either delete, or cancel.
+ * @property {String} CANCEL A modal which displayed a cancel button
+ * @property {String} ALERT An information modal which only displays information.
+ */
+export const types = {
+ DEFAULT: 'DEFAULT',
+ SAVE_CANCEL: ModalSaveCancel.TYPE,
+ DELETE_CANCEL: ModalDeleteCancel.TYPE,
+ CANCEL: ModalCancel.TYPE,
+ ALERT: ModalAlert.TYPE,
+};
- // Register the common set of modals.
- ModalRegistry.register(TYPES.DEFAULT, Modal, TEMPLATES.DEFAULT);
- ModalRegistry.register(TYPES.SAVE_CANCEL, ModalSaveCancel, TEMPLATES.SAVE_CANCEL);
- ModalRegistry.register(TYPES.DELETE_CANCEL, ModalDeleteCancel, TEMPLATES.DELETE_CANCEL);
- ModalRegistry.register(TYPES.CANCEL, ModalCancel, TEMPLATES.CANCEL);
- ModalRegistry.register(TYPES.ALERT, ModalAlert, TEMPLATES.ALERT);
+// Most modals are self-registering.
+// We do not self-register the base Modal because we do not want to define a default TYPE
+// on the class that every other modal extends.
+ModalRegistry.register(types.DEFAULT, Modal, Modal.TEMPLATE);
- /**
- * Set up the events required to show the modal and return focus when the modal
- * is closed.
- *
- * @method setUpTrigger
- * @private
- * @param {Promise} modalPromise The modal instance
- * @param {object} triggerElement The jQuery element to open the modal
- * @param {object} modalConfig The modal configuration given to the factory
- */
- var setUpTrigger = function(modalPromise, triggerElement, modalConfig) {
- // The element that actually shows the modal.
- var actualTriggerElement = null;
- // Check if the client has provided a callback function to be called
- // before the modal is displayed.
- var hasPreShowCallback = (typeof modalConfig.preShowCallback == 'function');
- // Function to handle the trigger element being activated.
- var triggeredCallback = function(e, data) {
- var pendingPromise = new Pending('core/modal_factory:setUpTrigger:triggeredCallback');
- actualTriggerElement = $(e.currentTarget);
- modalPromise.then(function(modal) {
- if (hasPreShowCallback) {
- // If the client provided a pre-show callback then execute
- // it now before showing the modal.
- modalConfig.preShowCallback(actualTriggerElement, modal);
- }
-
- modal.show();
-
- return modal;
- })
- .then(pendingPromise.resolve);
- data.originalEvent.preventDefault();
- };
-
- // The trigger element can either be a single element or it can be an
- // element + selector pair to create a delegated event handler to trigger
- // the modal.
- if (Array.isArray(triggerElement)) {
- var selector = triggerElement[1];
- triggerElement = triggerElement[0];
-
- CustomEvents.define(triggerElement, [CustomEvents.events.activate]);
- triggerElement.on(CustomEvents.events.activate, selector, triggeredCallback);
- } else {
- CustomEvents.define(triggerElement, [CustomEvents.events.activate]);
- triggerElement.on(CustomEvents.events.activate, triggeredCallback);
- }
+/**
+ * Set up the events required to show the modal and return focus when the modal
+ * is closed.
+ *
+ * @method setUpTrigger
+ * @private
+ * @param {Promise} modalPromise The modal instance
+ * @param {object} triggerElement The jQuery element to open the modal
+ * @param {object} modalConfig The modal configuration given to the factory
+ */
+const setUpTrigger = (modalPromise, triggerElement, modalConfig) => {
+ // The element that actually shows the modal.
+ let actualTriggerElement = null;
+ // Check if the client has provided a callback function to be called
+ // before the modal is displayed.
+ const hasPreShowCallback = (typeof modalConfig.preShowCallback == 'function');
+ // Function to handle the trigger element being activated.
+ const triggeredCallback = (e, data) => {
+ const pendingPromise = new Pending('core/modal_factory:setUpTrigger:triggeredCallback');
+ actualTriggerElement = $(e.currentTarget);
+ // eslint-disable-next-line promise/catch-or-return
modalPromise.then(function(modal) {
- modal.getRoot().on(ModalEvents.hidden, function() {
- // Focus on the trigger element that actually launched the modal.
- if (actualTriggerElement !== null) {
- actualTriggerElement.focus();
- }
- });
+ if (hasPreShowCallback) {
+ // If the client provided a pre-show callback then execute
+ // it now before showing the modal.
+ modalConfig.preShowCallback(actualTriggerElement, modal);
+ }
+
+ modal.show();
+
+ return modal;
+ })
+ .then(pendingPromise.resolve);
+ data.originalEvent.preventDefault();
+ };
+
+ // The trigger element can either be a single element or it can be an
+ // element + selector pair to create a delegated event handler to trigger
+ // the modal.
+ if (Array.isArray(triggerElement)) {
+ const selector = triggerElement[1];
+ triggerElement = triggerElement[0];
+
+ CustomEvents.define(triggerElement, [CustomEvents.events.activate]);
+ triggerElement.on(CustomEvents.events.activate, selector, triggeredCallback);
+ } else {
+ CustomEvents.define(triggerElement, [CustomEvents.events.activate]);
+ triggerElement.on(CustomEvents.events.activate, triggeredCallback);
+ }
+
+ // eslint-disable-next-line promise/catch-or-return
+ modalPromise.then(function(modal) {
+ modal.getRoot().on(ModalEvents.hidden, function() {
+ // Focus on the trigger element that actually launched the modal.
+ if (actualTriggerElement !== null) {
+ actualTriggerElement.focus();
+ }
+ });
+
+ return modal;
+ });
+};
+
+/**
+ * Create the correct instance of a modal based on the givem type. Sets up
+ * the trigger between the modal and the trigger element.
+ *
+ * @method createFromElement
+ * @private
+ * @param {object} registryConf A config from the ModalRegistry
+ * @param {object} modalElement The modal HTML jQuery object
+ * @return {object} Modal instance
+ */
+const createFromElement = (registryConf, modalElement) => {
+ modalElement = $(modalElement);
+ const Module = registryConf.module;
+ const modal = new Module(modalElement);
+
+ return modal;
+};
+
+/**
+ * Create the correct modal instance for the given type, including loading
+ * the correct template.
+ *
+ * @method createFromType
+ * @private
+ * @param {object} registryConf A config from the ModalRegistry
+ * @param {object} templateContext The context to render the template with
+ * @returns {promise} Resolved with a Modal instance
+ */
+const createFromType = (registryConf, templateContext) => {
+ const templateName = registryConf.template;
+ return Templates.render(templateName, templateContext)
+ .then((html) => createFromElement(registryConf, $(html)));
+};
+
+/**
+ * Create a Modal instance.
+ *
+ * @method create
+ * @param {object} modalConfig The configuration to create the modal instance
+ * @param {object} triggerElement The trigger HTML jQuery object
+ * @return {promise} Resolved with a Modal instance
+ */
+export const create = (modalConfig, triggerElement) => {
+ const type = modalConfig.type || types.DEFAULT;
+ const isLarge = modalConfig.large ? true : false;
+ // If 'scrollable' is not configured, set the modal to be scrollable by default.
+ const isScrollable = modalConfig.hasOwnProperty('scrollable') ? modalConfig.scrollable : true;
+
+ const registryConf = ModalRegistry.get(type);
+ if (!registryConf) {
+ Notification.exception({message: 'Unable to find modal of type: ' + type});
+ }
+
+ const templateContext = modalConfig.templateContext || {};
+
+ const modalPromise = createFromType(registryConf, templateContext)
+ .then((modal) => {
+ if (typeof modalConfig.title !== 'undefined') {
+ modal.setTitle(modalConfig.title);
+ }
+
+ if (typeof modalConfig.body !== 'undefined') {
+ modal.setBody(modalConfig.body);
+ }
+
+ if (typeof modalConfig.footer !== 'undefined') {
+ modal.setFooter(modalConfig.footer);
+ }
+
+ if (modalConfig.buttons) {
+ Object.entries(modalConfig.buttons).forEach(function([key, value]) {
+ modal.setButtonText(key, value);
+ });
+ }
+
+ if (isLarge) {
+ modal.setLarge();
+ }
+
+ if (typeof modalConfig.removeOnClose !== 'undefined') {
+ // If configured remove the modal when hiding it.
+ modal.setRemoveOnClose(modalConfig.removeOnClose);
+ }
+
+ modal.setScrollable(isScrollable);
return modal;
});
- };
- /**
- * Create the correct instance of a modal based on the givem type. Sets up
- * the trigger between the modal and the trigger element.
- *
- * @method createFromElement
- * @private
- * @param {object} registryConf A config from the ModalRegistry
- * @param {object} modalElement The modal HTML jQuery object
- * @return {object} Modal instance
- */
- var createFromElement = function(registryConf, modalElement) {
- modalElement = $(modalElement);
- var Module = registryConf.module;
- var modal = new Module(modalElement);
+ if (typeof triggerElement !== 'undefined') {
+ setUpTrigger(modalPromise, triggerElement, modalConfig);
+ }
- return modal;
- };
+ return modalPromise;
+};
- /**
- * Create the correct modal instance for the given type, including loading
- * the correct template.
- *
- * @method createFromType
- * @private
- * @param {object} registryConf A config from the ModalRegistry
- * @param {object} templateContext The context to render the template with
- * @returns {promise} Resolved with a Modal instance
- */
- var createFromType = function(registryConf, templateContext) {
- var templateName = registryConf.template;
-
- var modalPromise = Templates.render(templateName, templateContext)
- .then(function(html) {
- var modalElement = $(html);
- return createFromElement(registryConf, modalElement);
- })
- .fail(Notification.exception);
-
- return modalPromise;
- };
-
- /**
- * Create a Modal instance.
- *
- * @method create
- * @param {object} modalConfig The configuration to create the modal instance
- * @param {object} triggerElement The trigger HTML jQuery object
- * @return {promise} Resolved with a Modal instance
- */
- var create = function(modalConfig, triggerElement) {
- var type = modalConfig.type || TYPES.DEFAULT;
- var isLarge = modalConfig.large ? true : false;
- // If 'scrollable' is not configured, set the modal to be scrollable by default.
- var isScrollable = modalConfig.hasOwnProperty('scrollable') ? modalConfig.scrollable : true;
- var registryConf = null;
- var templateContext = {};
-
- registryConf = ModalRegistry.get(type);
-
- if (!registryConf) {
- Notification.exception({message: 'Unable to find modal of type: ' + type});
- }
-
- if (typeof modalConfig.templateContext != 'undefined') {
- templateContext = modalConfig.templateContext;
- }
-
- var modalPromise = createFromType(registryConf, templateContext)
- .then(function(modal) {
- if (typeof modalConfig.title != 'undefined') {
- modal.setTitle(modalConfig.title);
- }
-
- if (typeof modalConfig.body != 'undefined') {
- modal.setBody(modalConfig.body);
- }
-
- if (typeof modalConfig.footer != 'undefined') {
- modal.setFooter(modalConfig.footer);
- }
-
- if (modalConfig.buttons) {
- Object.entries(modalConfig.buttons).forEach(function([key, value]) {
- modal.setButtonText(key, value);
- });
- }
-
- if (isLarge) {
- modal.setLarge();
- }
-
- if (typeof modalConfig.removeOnClose !== 'undefined') {
- // If configured remove the modal when hiding it.
- modal.setRemoveOnClose(modalConfig.removeOnClose);
- }
-
- modal.setScrollable(isScrollable);
-
- return modal;
- });
-
- if (typeof triggerElement != 'undefined') {
- setUpTrigger(modalPromise, triggerElement, modalConfig);
- }
-
- return modalPromise;
- };
-
- return {
- create: create,
- types: TYPES,
- };
-});
+export default {
+ create,
+ types,
+};
diff --git a/lib/amd/src/modal_registry.js b/lib/amd/src/modal_registry.js
index 03b6441ce73..4814eab51a8 100644
--- a/lib/amd/src/modal_registry.js
+++ b/lib/amd/src/modal_registry.js
@@ -21,55 +21,53 @@
* @copyright 2016 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define(['core/notification', 'core/prefetch'], function(Notification, Prefetch) {
+import * as Notification from 'core/notification';
+import * as Prefetch from 'core/prefetch';
- // A singleton registry for all modules to access. Allows types to be
- // added at runtime.
- var registry = {};
+// A singleton registry for all modules to access. Allows types to be
+// added at runtime.
+const registry = new Map();
- /**
- * Get a registered type of modal.
- *
- * @method get
- * @param {string} type The type of modal to get
- * @return {object} The registered config for the modal
- */
- var get = function(type) {
- return registry[type];
- };
+/**
+ * Get a registered type of modal.
+ *
+ * @method get
+ * @param {string} type The type of modal to get
+ * @return {object} The registered config for the modal
+ */
+export const get = (type) => registry.get(type);
- /**
- * Register a modal with the registry.
- *
- * @method register
- * @param {string} type The type of modal (must be unique)
- * @param {function} module The modal module (must be a constructor function of type core/modal)
- * @param {string} template The template name of the modal
- */
- var register = function(type, module, template) {
- if (get(type)) {
- Notification.exception({message: "Modal of type '" + type + "' is already registered"});
- }
+/**
+ * Register a modal with the registry.
+ *
+ * @method register
+ * @param {string} type The type of modal (must be unique)
+ * @param {function} module The modal module (must be a constructor function of type core/modal)
+ * @param {string} template The template name of the modal
+ */
+export const register = (type, module, template) => {
+ const existing = get(type);
+ if (existing && existing.module !== module) {
+ Notification.exception({
+ message: `Modal of type '${type}' is already registered`,
+ });
+ }
- if (!module || typeof module !== 'function') {
- Notification.exception({message: "You must provide a modal module"});
- }
+ if (!module || typeof module !== 'function') {
+ Notification.exception({message: "You must provide a modal module"});
+ }
- if (!template) {
- Notification.exception({message: "You must provide a modal template"});
- }
+ if (!template) {
+ Notification.exception({message: "You must provide a modal template"});
+ }
- registry[type] = {
- module: module,
- template: template,
- };
+ registry.set(type, {module, template});
- // Prefetch the template.
- Prefetch.prefetchTemplate(template);
- };
+ // Prefetch the template.
+ Prefetch.prefetchTemplate(template);
+};
- return {
- register: register,
- get: get,
- };
-});
+export default {
+ register,
+ get,
+};
diff --git a/lib/amd/src/modal_save_cancel.js b/lib/amd/src/modal_save_cancel.js
index 99e3c7f67a9..844b6c63600 100644
--- a/lib/amd/src/modal_save_cancel.js
+++ b/lib/amd/src/modal_save_cancel.js
@@ -30,7 +30,10 @@ import Notification from 'core/notification';
* @class
* @extends module:core/modal
*/
-export default class extends Modal {
+export default class ModalSaveCancel extends Modal {
+ static TYPE = 'SAVE_CANCEL';
+ static TEMPLATE = 'core/modal_save_cancel';
+
constructor(root) {
super(root);
@@ -73,3 +76,5 @@ export default class extends Modal {
return this.setButtonText('save', value);
}
}
+
+ModalSaveCancel.registerModalType();
diff --git a/lib/amd/src/moodlenet/send_activity_modal.js b/lib/amd/src/moodlenet/send_activity_modal.js
index 4846ad6869b..560fdfaa3eb 100644
--- a/lib/amd/src/moodlenet/send_activity_modal.js
+++ b/lib/amd/src/moodlenet/send_activity_modal.js
@@ -23,9 +23,8 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
-const SendActivityModal = class extends Modal {
+export default class SendActivityModal extends Modal {
static TYPE = 'core/moodlenet/send_activity_modal';
static TEMPLATE = 'core/moodlenet/send_activity_modal_base';
@@ -37,8 +36,6 @@ const SendActivityModal = class extends Modal {
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
-};
+}
-ModalRegistry.register(SendActivityModal.TYPE, SendActivityModal, SendActivityModal.TEMPLATE);
-
-export default SendActivityModal;
+SendActivityModal.registerModalType();
diff --git a/lib/editor/tiny/plugins/equation/amd/build/modal.min.js b/lib/editor/tiny/plugins/equation/amd/build/modal.min.js
index c9aa6732bc6..3bbc8ac1e91 100644
--- a/lib/editor/tiny/plugins/equation/amd/build/modal.min.js
+++ b/lib/editor/tiny/plugins/equation/amd/build/modal.min.js
@@ -1,3 +1,3 @@
-define("tiny_equation/modal",["exports","core/modal","core/modal_registry"],(function(_exports,_modal,_modal_registry){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const EquationModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","tiny_equation/modal"),_defineProperty(_class,"TEMPLATE","tiny_equation/modal"),_class);_modal_registry.default.register(EquationModal.TYPE,EquationModal,EquationModal.TEMPLATE);var _default=EquationModal;return _exports.default=_default,_exports.default}));
+define("tiny_equation/modal",["exports","core/modal"],(function(_exports,_modal){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class EquationModal extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}}return _exports.default=EquationModal,_defineProperty(EquationModal,"TYPE","tiny_equation/modal"),_defineProperty(EquationModal,"TEMPLATE","tiny_equation/modal"),EquationModal.registerModalType(),_exports.default}));
//# sourceMappingURL=modal.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/equation/amd/build/modal.min.js.map b/lib/editor/tiny/plugins/equation/amd/build/modal.min.js.map
index 827c7f75b20..c7443cdcba3 100644
--- a/lib/editor/tiny/plugins/equation/amd/build/modal.min.js.map
+++ b/lib/editor/tiny/plugins/equation/amd/build/modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Equation Modal for Tiny.\n *\n * @module tiny_equation/modal\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\n\nconst EquationModal = class extends Modal {\n static TYPE = 'tiny_equation/modal';\n static TEMPLATE = 'tiny_equation/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(EquationModal.TYPE, EquationModal, EquationModal.TEMPLATE);\n\nexport default EquationModal;\n"],"names":["EquationModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","register","TYPE","TEMPLATE"],"mappings":"4iBA0BMA,sCAAgB,cAAcC,eAIhCC,+BAEUA,8BAGDC,2BACAC,iCATK,yDACI,uDAYRC,SAASL,cAAcM,KAAMN,cAAeA,cAAcO,uBAEzDP"}
\ No newline at end of file
+{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Equation Modal for Tiny.\n *\n * @module tiny_equation/modal\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\nexport default class EquationModal extends Modal {\n static TYPE = 'tiny_equation/modal';\n static TEMPLATE = 'tiny_equation/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n}\n\nEquationModal.registerModalType();\n"],"names":["EquationModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","registerModalType"],"mappings":"yYAyBqBA,sBAAsBC,eAIvCC,+BAEUA,8BAGDC,2BACAC,+EAVQJ,qBACH,uCADGA,yBAEC,uBAYtBA,cAAcK"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/equation/amd/src/modal.js b/lib/editor/tiny/plugins/equation/amd/src/modal.js
index 5a3669c30ce..0144e81dae4 100644
--- a/lib/editor/tiny/plugins/equation/amd/src/modal.js
+++ b/lib/editor/tiny/plugins/equation/amd/src/modal.js
@@ -22,9 +22,8 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
-const EquationModal = class extends Modal {
+export default class EquationModal extends Modal {
static TYPE = 'tiny_equation/modal';
static TEMPLATE = 'tiny_equation/modal';
@@ -36,8 +35,6 @@ const EquationModal = class extends Modal {
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
-};
+}
-ModalRegistry.register(EquationModal.TYPE, EquationModal, EquationModal.TEMPLATE);
-
-export default EquationModal;
+EquationModal.registerModalType();
diff --git a/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js b/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js
index cc5ef830e94..20edfd5a59d 100644
--- a/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js
+++ b/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js
@@ -1,3 +1,3 @@
-define("tiny_h5p/modal",["exports","core/modal","core/modal_registry"],(function(_exports,_modal,_modal_registry){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const H5PModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","tiny_h5p/modal"),_defineProperty(_class,"TEMPLATE","tiny_h5p/modal"),_class);_modal_registry.default.register(H5PModal.TYPE,H5PModal,H5PModal.TEMPLATE);var _default=H5PModal;return _exports.default=_default,_exports.default}));
+define("tiny_h5p/modal",["exports","core/modal"],(function(_exports,_modal){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class H5PModal extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}}return _exports.default=H5PModal,_defineProperty(H5PModal,"TYPE","tiny_h5p/modal"),_defineProperty(H5PModal,"TEMPLATE","tiny_h5p/modal"),H5PModal.registerModalType(),_exports.default}));
//# sourceMappingURL=modal.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js.map b/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js.map
index 0a082c4bb03..66c63c71d35 100644
--- a/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js.map
+++ b/lib/editor/tiny/plugins/h5p/amd/build/modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * H5P Management Modal for Tiny.\n *\n * @module tiny_h5p/modal\n * @copyright 2022 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\n\nconst H5PModal = class extends Modal {\n static TYPE = 'tiny_h5p/modal';\n\n static TEMPLATE = 'tiny_h5p/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(H5PModal.TYPE, H5PModal, H5PModal.TEMPLATE);\n\nexport default H5PModal;\n"],"names":["H5PModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","register","TYPE","TEMPLATE"],"mappings":"uiBA0BMA,iCAAW,cAAcC,eAK3BC,+BAEUA,8BAGDC,2BACAC,iCAVK,oDAEI,kDAYRC,SAASL,SAASM,KAAMN,SAAUA,SAASO,uBAE1CP"}
\ No newline at end of file
+{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * H5P Management Modal for Tiny.\n *\n * @module tiny_h5p/modal\n * @copyright 2022 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\nexport default class H5PModal extends Modal {\n static TYPE = 'tiny_h5p/modal';\n static TEMPLATE = 'tiny_h5p/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n}\n\nH5PModal.registerModalType();\n"],"names":["H5PModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","registerModalType"],"mappings":"oYAyBqBA,iBAAiBC,eAIlCC,+BAEUA,8BAGDC,2BACAC,0EAVQJ,gBACH,kCADGA,oBAEC,kBAYtBA,SAASK"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/h5p/amd/src/modal.js b/lib/editor/tiny/plugins/h5p/amd/src/modal.js
index e3798a5bdf8..89acd141e91 100644
--- a/lib/editor/tiny/plugins/h5p/amd/src/modal.js
+++ b/lib/editor/tiny/plugins/h5p/amd/src/modal.js
@@ -22,11 +22,9 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
-const H5PModal = class extends Modal {
+export default class H5PModal extends Modal {
static TYPE = 'tiny_h5p/modal';
-
static TEMPLATE = 'tiny_h5p/modal';
registerEventListeners() {
@@ -37,8 +35,6 @@ const H5PModal = class extends Modal {
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
-};
+}
-ModalRegistry.register(H5PModal.TYPE, H5PModal, H5PModal.TEMPLATE);
-
-export default H5PModal;
+H5PModal.registerModalType();
diff --git a/lib/editor/tiny/plugins/link/amd/build/modal.min.js b/lib/editor/tiny/plugins/link/amd/build/modal.min.js
index 0ad22fde30b..487a5156325 100644
--- a/lib/editor/tiny/plugins/link/amd/build/modal.min.js
+++ b/lib/editor/tiny/plugins/link/amd/build/modal.min.js
@@ -1,3 +1,3 @@
-define("tiny_link/modal",["exports","core/modal","core/modal_registry"],(function(_exports,_modal,_modal_registry){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const LinkModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","tiny_link/modal"),_defineProperty(_class,"TEMPLATE","tiny_link/modal"),_class);_modal_registry.default.register(LinkModal.TYPE,LinkModal,LinkModal.TEMPLATE);var _default=LinkModal;return _exports.default=_default,_exports.default}));
+define("tiny_link/modal",["exports","core/modal"],(function(_exports,_modal){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class LinkModal extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}}return _exports.default=LinkModal,_defineProperty(LinkModal,"TYPE","tiny_link/modal"),_defineProperty(LinkModal,"TEMPLATE","tiny_link/modal"),LinkModal.registerModalType(),_exports.default}));
//# sourceMappingURL=modal.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/link/amd/build/modal.min.js.map b/lib/editor/tiny/plugins/link/amd/build/modal.min.js.map
index 61bea15a291..2d4ff128819 100644
--- a/lib/editor/tiny/plugins/link/amd/build/modal.min.js.map
+++ b/lib/editor/tiny/plugins/link/amd/build/modal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Link Modal for Tiny.\n *\n * @module tiny_link/modal\n * @copyright 2023 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\n\nconst LinkModal = class extends Modal {\n static TYPE = 'tiny_link/modal';\n static TEMPLATE = 'tiny_link/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(LinkModal.TYPE, LinkModal, LinkModal.TEMPLATE);\n\nexport default LinkModal;\n"],"names":["LinkModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","register","TYPE","TEMPLATE"],"mappings":"wiBA0BMA,kCAAY,cAAcC,eAI5BC,+BAEUA,8BAGDC,2BACAC,iCATK,qDACI,mDAYRC,SAASL,UAAUM,KAAMN,UAAWA,UAAUO,uBAE7CP"}
\ No newline at end of file
+{"version":3,"file":"modal.min.js","sources":["../src/modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Link Modal for Tiny.\n *\n * @module tiny_link/modal\n * @copyright 2023 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\nexport default class LinkModal extends Modal {\n static TYPE = 'tiny_link/modal';\n static TEMPLATE = 'tiny_link/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n}\n\nLinkModal.registerModalType();\n"],"names":["LinkModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","registerModalType"],"mappings":"qYAyBqBA,kBAAkBC,eAInCC,+BAEUA,8BAGDC,2BACAC,2EAVQJ,iBACH,mCADGA,qBAEC,mBAYtBA,UAAUK"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/link/amd/src/modal.js b/lib/editor/tiny/plugins/link/amd/src/modal.js
index d09cbacce57..58f6bc97849 100644
--- a/lib/editor/tiny/plugins/link/amd/src/modal.js
+++ b/lib/editor/tiny/plugins/link/amd/src/modal.js
@@ -22,9 +22,8 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
-const LinkModal = class extends Modal {
+export default class LinkModal extends Modal {
static TYPE = 'tiny_link/modal';
static TEMPLATE = 'tiny_link/modal';
@@ -36,8 +35,6 @@ const LinkModal = class extends Modal {
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
-};
+}
-ModalRegistry.register(LinkModal.TYPE, LinkModal, LinkModal.TEMPLATE);
-
-export default LinkModal;
+LinkModal.registerModalType();
diff --git a/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js b/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js
index 8135508d418..f9d1185ac2b 100644
--- a/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js
+++ b/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js
@@ -1,3 +1,3 @@
-define("tiny_media/embedmodal",["exports","core/modal","core/modal_registry","./common"],(function(_exports,_modal,_modal_registry,_common){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const EmbedModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","".concat(_common.component,"/modal")),_defineProperty(_class,"TEMPLATE","".concat(_common.component,"/embed_media_modal")),_class);_modal_registry.default.register(EmbedModal.TYPE,EmbedModal,EmbedModal.TEMPLATE);var _default=EmbedModal;return _exports.default=_default,_exports.default}));
+define("tiny_media/embedmodal",["exports","core/modal","./common"],(function(_exports,_modal,_common){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class EmbedModal extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}}return _exports.default=EmbedModal,_defineProperty(EmbedModal,"TYPE","".concat(_common.component,"/modal")),_defineProperty(EmbedModal,"TEMPLATE","".concat(_common.component,"/embed_media_modal")),EmbedModal.registerModalType(),_exports.default}));
//# sourceMappingURL=embedmodal.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js.map b/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js.map
index 0c178b7a2ed..2a73ab99453 100644
--- a/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js.map
+++ b/lib/editor/tiny/plugins/media/amd/build/embedmodal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"embedmodal.min.js","sources":["../src/embedmodal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Embedded Media Management Modal for Tiny.\n *\n * @module tiny_media/embedmodal\n * @copyright 2022 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\nimport {component} from './common';\n\nconst EmbedModal = class extends Modal {\n static TYPE = `${component}/modal`;\n\n static TEMPLATE = `${component}/embed_media_modal`;\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(EmbedModal.TYPE, EmbedModal, EmbedModal.TEMPLATE);\n\nexport default EmbedModal;\n"],"names":["EmbedModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","component","register","TYPE","TEMPLATE"],"mappings":"ikBA2BMA,mCAAa,cAAcC,eAK7BC,+BAEUA,8BAGDC,2BACAC,2CAVQC,yEAEIA,yEAYXC,SAASN,WAAWO,KAAMP,WAAYA,WAAWQ,uBAEhDR"}
\ No newline at end of file
+{"version":3,"file":"embedmodal.min.js","sources":["../src/embedmodal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Embedded Media Management Modal for Tiny.\n *\n * @module tiny_media/embedmodal\n * @copyright 2022 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport {component} from './common';\n\nexport default class EmbedModal extends Modal {\n static TYPE = `${component}/modal`;\n static TEMPLATE = `${component}/embed_media_modal`;\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n}\n\nEmbedModal.registerModalType();\n"],"names":["EmbedModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","component","registerModalType"],"mappings":"8ZA0BqBA,mBAAmBC,eAIpCC,+BAEUA,8BAGDC,2BACAC,4EAVQJ,4BACAK,6CADAL,gCAEIK,yCAYzBL,WAAWM"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js b/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js
index 295846e5311..39e264859f8 100644
--- a/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js
+++ b/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js
@@ -1,3 +1,3 @@
-define("tiny_media/imagemodal",["exports","core/modal","core/modal_registry","./common"],(function(_exports,_modal,_modal_registry,_common){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const ImageModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","".concat(_common.component,"/imagemodal")),_defineProperty(_class,"TEMPLATE","".concat(_common.component,"/insert_image_modal")),_class);_modal_registry.default.register(ImageModal.TYPE,ImageModal,ImageModal.TEMPLATE);var _default=ImageModal;return _exports.default=_default,_exports.default}));
+define("tiny_media/imagemodal",["exports","core/modal","./common"],(function(_exports,_modal,_common){var obj;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class ImageModal extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}}return _exports.default=ImageModal,_defineProperty(ImageModal,"TYPE","".concat(_common.component,"/imagemodal")),_defineProperty(ImageModal,"TEMPLATE","".concat(_common.component,"/insert_image_modal")),ImageModal.registerModalType(),_exports.default}));
//# sourceMappingURL=imagemodal.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js.map b/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js.map
index 0e35106a586..d702d762b40 100644
--- a/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js.map
+++ b/lib/editor/tiny/plugins/media/amd/build/imagemodal.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"imagemodal.min.js","sources":["../src/imagemodal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Image Modal for Tiny.\n *\n * @module tiny_media/imagemodal\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\nimport {component} from './common';\n\nconst ImageModal = class extends Modal {\n static TYPE = `${component}/imagemodal`;\n\n static TEMPLATE = `${component}/insert_image_modal`;\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(ImageModal.TYPE, ImageModal, ImageModal.TEMPLATE);\n\nexport default ImageModal;\n"],"names":["ImageModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","component","register","TYPE","TEMPLATE"],"mappings":"ikBA2BMA,mCAAa,cAAcC,eAK7BC,+BAEUA,8BAGDC,2BACAC,2CAVQC,8EAEIA,0EAYXC,SAASN,WAAWO,KAAMP,WAAYA,WAAWQ,uBAEhDR"}
\ No newline at end of file
+{"version":3,"file":"imagemodal.min.js","sources":["../src/imagemodal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Image Modal for Tiny.\n *\n * @module tiny_media/imagemodal\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport {component} from './common';\n\nexport default class ImageModal extends Modal {\n static TYPE = `${component}/imagemodal`;\n static TEMPLATE = `${component}/insert_image_modal`;\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n}\n\nImageModal.registerModalType();\n"],"names":["ImageModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","component","registerModalType"],"mappings":"8ZA0BqBA,mBAAmBC,eAIpCC,+BAEUA,8BAGDC,2BACAC,4EAVQJ,4BACAK,kDADAL,gCAEIK,0CAYzBL,WAAWM"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/media/amd/src/embedmodal.js b/lib/editor/tiny/plugins/media/amd/src/embedmodal.js
index eac32bd4bb2..2ecbb7c9cd4 100644
--- a/lib/editor/tiny/plugins/media/amd/src/embedmodal.js
+++ b/lib/editor/tiny/plugins/media/amd/src/embedmodal.js
@@ -22,12 +22,10 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
import {component} from './common';
-const EmbedModal = class extends Modal {
+export default class EmbedModal extends Modal {
static TYPE = `${component}/modal`;
-
static TEMPLATE = `${component}/embed_media_modal`;
registerEventListeners() {
@@ -38,8 +36,6 @@ const EmbedModal = class extends Modal {
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
-};
+}
-ModalRegistry.register(EmbedModal.TYPE, EmbedModal, EmbedModal.TEMPLATE);
-
-export default EmbedModal;
+EmbedModal.registerModalType();
diff --git a/lib/editor/tiny/plugins/media/amd/src/imagemodal.js b/lib/editor/tiny/plugins/media/amd/src/imagemodal.js
index 28a9b6b298d..aca4bdcfd73 100644
--- a/lib/editor/tiny/plugins/media/amd/src/imagemodal.js
+++ b/lib/editor/tiny/plugins/media/amd/src/imagemodal.js
@@ -22,12 +22,10 @@
*/
import Modal from 'core/modal';
-import ModalRegistry from 'core/modal_registry';
import {component} from './common';
-const ImageModal = class extends Modal {
+export default class ImageModal extends Modal {
static TYPE = `${component}/imagemodal`;
-
static TEMPLATE = `${component}/insert_image_modal`;
registerEventListeners() {
@@ -38,8 +36,6 @@ const ImageModal = class extends Modal {
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
-};
+}
-ModalRegistry.register(ImageModal.TYPE, ImageModal, ImageModal.TEMPLATE);
-
-export default ImageModal;
+ImageModal.registerModalType();
diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js b/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js
index 914faba5ac5..f441293c86c 100644
--- a/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js
+++ b/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js
@@ -1,3 +1,3 @@
-define("tiny_recordrtc/audio_recorder",["exports","./base_recorder","./modal","core/modal_registry","tiny_recordrtc/common"],(function(_exports,_base_recorder,_modal,_modal_registry,_common){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_base_recorder=_interopRequireDefault(_base_recorder),_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);class Audio extends _base_recorder.default{configurePlayer(){return this.modalRoot.querySelector("audio")}getSupportedTypes(){return["audio/webm;codecs=opus","audio/ogg;codecs=opus"]}getParsedRecordingOptions(){return{audioBitsPerSecond:parseInt(this.config.audiobitrate)}}getMediaConstraints(){return{audio:!0}}getRecordingType(){return"audio"}getTimeLimit(){return this.config.audiotimelimit}getEmbedTemplateName(){return"tiny_recordrtc/embed_audio"}getFileName(prefix){return"".concat(prefix,"-audio.ogg")}static getModalClass(){var _class;const modalType="".concat(_common.component,"/audio_recorder"),registration=_modal_registry.default.get(modalType);if(registration)return registration.module;const AudioModal=(_defineProperty(_class=class extends _modal.default{},"TYPE",modalType),_defineProperty(_class,"TEMPLATE","".concat(_common.component,"/audio_recorder")),_class);return _modal_registry.default.register(AudioModal.TYPE,AudioModal,AudioModal.TEMPLATE),AudioModal}}return _exports.default=Audio,_exports.default}));
+define("tiny_recordrtc/audio_recorder",["exports","./base_recorder","./modal","tiny_recordrtc/common"],(function(_exports,_base_recorder,_modal,_common){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_base_recorder=_interopRequireDefault(_base_recorder),_modal=_interopRequireDefault(_modal);class Audio extends _base_recorder.default{configurePlayer(){return this.modalRoot.querySelector("audio")}getSupportedTypes(){return["audio/webm;codecs=opus","audio/ogg;codecs=opus"]}getParsedRecordingOptions(){return{audioBitsPerSecond:parseInt(this.config.audiobitrate)}}getMediaConstraints(){return{audio:!0}}getRecordingType(){return"audio"}getTimeLimit(){return this.config.audiotimelimit}getEmbedTemplateName(){return"tiny_recordrtc/embed_audio"}getFileName(prefix){return"".concat(prefix,"-audio.ogg")}static getModalClass(){var _class;const AudioModal=(_defineProperty(_class=class extends _modal.default{},"TYPE","".concat(_common.component,"/audio_recorder")),_defineProperty(_class,"TEMPLATE","".concat(_common.component,"/audio_recorder")),_class);return AudioModal.registerModalType(),AudioModal}}return _exports.default=Audio,_exports.default}));
//# sourceMappingURL=audio_recorder.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js.map b/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js.map
index a3474ec0f1a..ba4ddac8e9f 100644
--- a/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js.map
+++ b/lib/editor/tiny/plugins/recordrtc/amd/build/audio_recorder.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"audio_recorder.min.js","sources":["../src/audio_recorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - audio recorder configuration.\n *\n * @module tiny_recordrtc/audio_recorder\n * @copyright 2022 Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport BaseClass from './base_recorder';\nimport Modal from './modal';\nimport ModalRegistry from 'core/modal_registry';\nimport {component} from 'tiny_recordrtc/common';\n\nexport default class Audio extends BaseClass {\n configurePlayer() {\n return this.modalRoot.querySelector('audio');\n }\n\n getSupportedTypes() {\n return [\n 'audio/webm;codecs=opus',\n 'audio/ogg;codecs=opus',\n ];\n }\n\n getParsedRecordingOptions() {\n return {\n audioBitsPerSecond: parseInt(this.config.audiobitrate),\n };\n }\n\n getMediaConstraints() {\n return {\n audio: true,\n };\n }\n\n getRecordingType() {\n return 'audio';\n }\n\n getTimeLimit() {\n return this.config.audiotimelimit;\n }\n\n getEmbedTemplateName() {\n return 'tiny_recordrtc/embed_audio';\n }\n\n getFileName(prefix) {\n return `${prefix}-audio.ogg`;\n }\n\n static getModalClass() {\n const modalType = `${component}/audio_recorder`;\n const registration = ModalRegistry.get(modalType);\n if (registration) {\n return registration.module;\n }\n\n const AudioModal = class extends Modal {\n static TYPE = modalType;\n static TEMPLATE = `${component}/audio_recorder`;\n };\n\n ModalRegistry.register(AudioModal.TYPE, AudioModal, AudioModal.TEMPLATE);\n return AudioModal;\n }\n}\n"],"names":["Audio","BaseClass","configurePlayer","this","modalRoot","querySelector","getSupportedTypes","getParsedRecordingOptions","audioBitsPerSecond","parseInt","config","audiobitrate","getMediaConstraints","audio","getRecordingType","getTimeLimit","audiotimelimit","getEmbedTemplateName","getFileName","prefix","modalType","component","registration","ModalRegistry","get","module","AudioModal","Modal","register","TYPE","TEMPLATE"],"mappings":"+pBA4BqBA,cAAcC,uBAC/BC,yBACWC,KAAKC,UAAUC,cAAc,SAGxCC,0BACW,CACH,yBACA,yBAIRC,kCACW,CACHC,mBAAoBC,SAASN,KAAKO,OAAOC,eAIjDC,4BACW,CACHC,OAAO,GAIfC,yBACW,QAGXC,sBACWZ,KAAKO,OAAOM,eAGvBC,6BACW,6BAGXC,YAAYC,wBACEA,6DAIJC,oBAAeC,qCACfC,aAAeC,wBAAcC,IAAIJ,cACnCE,oBACOA,aAAaG,aAGlBC,mCAAa,cAAcC,wBACfP,uDACOC,6EAGXO,SAASF,WAAWG,KAAMH,WAAYA,WAAWI,UACxDJ"}
\ No newline at end of file
+{"version":3,"file":"audio_recorder.min.js","sources":["../src/audio_recorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - audio recorder configuration.\n *\n * @module tiny_recordrtc/audio_recorder\n * @copyright 2022 Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport BaseClass from './base_recorder';\nimport Modal from './modal';\nimport {component} from 'tiny_recordrtc/common';\n\nexport default class Audio extends BaseClass {\n configurePlayer() {\n return this.modalRoot.querySelector('audio');\n }\n\n getSupportedTypes() {\n return [\n 'audio/webm;codecs=opus',\n 'audio/ogg;codecs=opus',\n ];\n }\n\n getParsedRecordingOptions() {\n return {\n audioBitsPerSecond: parseInt(this.config.audiobitrate),\n };\n }\n\n getMediaConstraints() {\n return {\n audio: true,\n };\n }\n\n getRecordingType() {\n return 'audio';\n }\n\n getTimeLimit() {\n return this.config.audiotimelimit;\n }\n\n getEmbedTemplateName() {\n return 'tiny_recordrtc/embed_audio';\n }\n\n getFileName(prefix) {\n return `${prefix}-audio.ogg`;\n }\n\n static getModalClass() {\n const AudioModal = class extends Modal {\n static TYPE = `${component}/audio_recorder`;\n static TEMPLATE = `${component}/audio_recorder`;\n };\n\n AudioModal.registerModalType();\n return AudioModal;\n }\n}\n"],"names":["Audio","BaseClass","configurePlayer","this","modalRoot","querySelector","getSupportedTypes","getParsedRecordingOptions","audioBitsPerSecond","parseInt","config","audiobitrate","getMediaConstraints","audio","getRecordingType","getTimeLimit","audiotimelimit","getEmbedTemplateName","getFileName","prefix","AudioModal","Modal","component","registerModalType"],"mappings":"ikBA2BqBA,cAAcC,uBAC/BC,yBACWC,KAAKC,UAAUC,cAAc,SAGxCC,0BACW,CACH,yBACA,yBAIRC,kCACW,CACHC,mBAAoBC,SAASN,KAAKO,OAAOC,eAIjDC,4BACW,CACHC,OAAO,GAIfC,yBACW,QAGXC,sBACWZ,KAAKO,OAAOM,eAGvBC,6BACW,6BAGXC,YAAYC,wBACEA,6DAIJC,mCAAa,cAAcC,kCACZC,kFACIA,qDAGzBF,WAAWG,oBACJH"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js b/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js
index 692c207a646..9e771bbeb3f 100644
--- a/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js
+++ b/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js
@@ -1,3 +1,3 @@
-define("tiny_recordrtc/video_recorder",["exports","./base_recorder","tiny_recordrtc/modal","core/modal_registry","tiny_recordrtc/common"],(function(_exports,_base_recorder,_modal,_modal_registry,_common){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_base_recorder=_interopRequireDefault(_base_recorder),_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);class Video extends _base_recorder.default{configurePlayer(){return this.modalRoot.querySelector("video")}getSupportedTypes(){return["video/webm;codecs=vp9,opus","video/webm;codecs=h264,opus","video/webm;codecs=vp8,opus"]}getParsedRecordingOptions(){return{audioBitsPerSecond:parseInt(this.config.audiobitrate),videoBitsPerSecond:parseInt(this.config.videobitrate)}}getMediaConstraints(){return{audio:!0,video:{width:{ideal:640},height:{ideal:480}}}}playOnCapture(){return!0}getRecordingType(){return"video"}getTimeLimit(){return this.config.videotimelimit}getEmbedTemplateName(){return"tiny_recordrtc/embed_video"}getFileName(prefix){return"".concat(prefix,"-video.webm")}static getModalClass(){var _class;const modalType="".concat(_common.component,"/video_recorder"),registration=_modal_registry.default.get(modalType);if(registration)return registration.module;const VideoModal=(_defineProperty(_class=class extends _modal.default{},"TYPE",modalType),_defineProperty(_class,"TEMPLATE","".concat(_common.component,"/video_recorder")),_class);return _modal_registry.default.register(VideoModal.TYPE,VideoModal,VideoModal.TEMPLATE),VideoModal}}return _exports.default=Video,_exports.default}));
+define("tiny_recordrtc/video_recorder",["exports","./base_recorder","tiny_recordrtc/modal","tiny_recordrtc/common"],(function(_exports,_base_recorder,_modal,_common){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_base_recorder=_interopRequireDefault(_base_recorder),_modal=_interopRequireDefault(_modal);class Video extends _base_recorder.default{configurePlayer(){return this.modalRoot.querySelector("video")}getSupportedTypes(){return["video/webm;codecs=vp9,opus","video/webm;codecs=h264,opus","video/webm;codecs=vp8,opus"]}getParsedRecordingOptions(){return{audioBitsPerSecond:parseInt(this.config.audiobitrate),videoBitsPerSecond:parseInt(this.config.videobitrate)}}getMediaConstraints(){return{audio:!0,video:{width:{ideal:640},height:{ideal:480}}}}playOnCapture(){return!0}getRecordingType(){return"video"}getTimeLimit(){return this.config.videotimelimit}getEmbedTemplateName(){return"tiny_recordrtc/embed_video"}getFileName(prefix){return"".concat(prefix,"-video.webm")}static getModalClass(){var _class;const VideoModal=(_defineProperty(_class=class extends _modal.default{},"TYPE","".concat(_common.component,"/video_recorder")),_defineProperty(_class,"TEMPLATE","".concat(_common.component,"/video_recorder")),_class);return VideoModal.registerModalType(),VideoModal}}return _exports.default=Video,_exports.default}));
//# sourceMappingURL=video_recorder.min.js.map
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js.map b/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js.map
index 1d9cc48d94b..ae24a70eb10 100644
--- a/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js.map
+++ b/lib/editor/tiny/plugins/recordrtc/amd/build/video_recorder.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"video_recorder.min.js","sources":["../src/video_recorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - Video recorder configuration.\n *\n * @module tiny_recordrtc/video_recorder\n * @copyright 2022 Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport BaseClass from './base_recorder';\nimport Modal from 'tiny_recordrtc/modal';\nimport ModalRegistry from 'core/modal_registry';\nimport {component} from 'tiny_recordrtc/common';\n\nexport default class Video extends BaseClass {\n configurePlayer() {\n return this.modalRoot.querySelector('video');\n }\n\n getSupportedTypes() {\n return [\n 'video/webm;codecs=vp9,opus',\n 'video/webm;codecs=h264,opus',\n 'video/webm;codecs=vp8,opus',\n ];\n\n }\n\n getParsedRecordingOptions() {\n return {\n audioBitsPerSecond: parseInt(this.config.audiobitrate),\n videoBitsPerSecond: parseInt(this.config.videobitrate)\n };\n }\n\n getMediaConstraints() {\n return {\n audio: true,\n video: {\n width: {\n ideal: 640,\n },\n height: {\n ideal: 480,\n },\n },\n };\n }\n\n playOnCapture() {\n // Play the recording back on capture.\n return true;\n }\n\n getRecordingType() {\n return 'video';\n }\n\n getTimeLimit() {\n return this.config.videotimelimit;\n }\n\n getEmbedTemplateName() {\n return 'tiny_recordrtc/embed_video';\n }\n\n getFileName(prefix) {\n return `${prefix}-video.webm`;\n }\n\n static getModalClass() {\n const modalType = `${component}/video_recorder`;\n const registration = ModalRegistry.get(modalType);\n if (registration) {\n return registration.module;\n }\n\n const VideoModal = class extends Modal {\n static TYPE = modalType;\n static TEMPLATE = `${component}/video_recorder`;\n };\n\n ModalRegistry.register(VideoModal.TYPE, VideoModal, VideoModal.TEMPLATE);\n return VideoModal;\n }\n}\n"],"names":["Video","BaseClass","configurePlayer","this","modalRoot","querySelector","getSupportedTypes","getParsedRecordingOptions","audioBitsPerSecond","parseInt","config","audiobitrate","videoBitsPerSecond","videobitrate","getMediaConstraints","audio","video","width","ideal","height","playOnCapture","getRecordingType","getTimeLimit","videotimelimit","getEmbedTemplateName","getFileName","prefix","modalType","component","registration","ModalRegistry","get","module","VideoModal","Modal","register","TYPE","TEMPLATE"],"mappings":"4qBA4BqBA,cAAcC,uBAC/BC,yBACWC,KAAKC,UAAUC,cAAc,SAGxCC,0BACW,CACH,6BACA,8BACA,8BAKRC,kCACW,CACHC,mBAAoBC,SAASN,KAAKO,OAAOC,cACzCC,mBAAoBH,SAASN,KAAKO,OAAOG,eAIjDC,4BACW,CACHC,OAAO,EACPC,MAAO,CACHC,MAAO,CACHC,MAAO,KAEXC,OAAQ,CACJD,MAAO,OAMvBE,uBAEW,EAGXC,yBACW,QAGXC,sBACWnB,KAAKO,OAAOa,eAGvBC,6BACW,6BAGXC,YAAYC,wBACEA,8DAIJC,oBAAeC,qCACfC,aAAeC,wBAAcC,IAAIJ,cACnCE,oBACOA,aAAaG,aAGlBC,mCAAa,cAAcC,wBACfP,uDACOC,6EAGXO,SAASF,WAAWG,KAAMH,WAAYA,WAAWI,UACxDJ"}
\ No newline at end of file
+{"version":3,"file":"video_recorder.min.js","sources":["../src/video_recorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - Video recorder configuration.\n *\n * @module tiny_recordrtc/video_recorder\n * @copyright 2022 Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport BaseClass from './base_recorder';\nimport Modal from 'tiny_recordrtc/modal';\nimport {component} from 'tiny_recordrtc/common';\n\nexport default class Video extends BaseClass {\n configurePlayer() {\n return this.modalRoot.querySelector('video');\n }\n\n getSupportedTypes() {\n return [\n 'video/webm;codecs=vp9,opus',\n 'video/webm;codecs=h264,opus',\n 'video/webm;codecs=vp8,opus',\n ];\n\n }\n\n getParsedRecordingOptions() {\n return {\n audioBitsPerSecond: parseInt(this.config.audiobitrate),\n videoBitsPerSecond: parseInt(this.config.videobitrate)\n };\n }\n\n getMediaConstraints() {\n return {\n audio: true,\n video: {\n width: {\n ideal: 640,\n },\n height: {\n ideal: 480,\n },\n },\n };\n }\n\n playOnCapture() {\n // Play the recording back on capture.\n return true;\n }\n\n getRecordingType() {\n return 'video';\n }\n\n getTimeLimit() {\n return this.config.videotimelimit;\n }\n\n getEmbedTemplateName() {\n return 'tiny_recordrtc/embed_video';\n }\n\n getFileName(prefix) {\n return `${prefix}-video.webm`;\n }\n\n static getModalClass() {\n const VideoModal = class extends Modal {\n static TYPE = `${component}/video_recorder`;\n static TEMPLATE = `${component}/video_recorder`;\n };\n\n VideoModal.registerModalType();\n return VideoModal;\n }\n}\n"],"names":["Video","BaseClass","configurePlayer","this","modalRoot","querySelector","getSupportedTypes","getParsedRecordingOptions","audioBitsPerSecond","parseInt","config","audiobitrate","videoBitsPerSecond","videobitrate","getMediaConstraints","audio","video","width","ideal","height","playOnCapture","getRecordingType","getTimeLimit","videotimelimit","getEmbedTemplateName","getFileName","prefix","VideoModal","Modal","component","registerModalType"],"mappings":"8kBA2BqBA,cAAcC,uBAC/BC,yBACWC,KAAKC,UAAUC,cAAc,SAGxCC,0BACW,CACH,6BACA,8BACA,8BAKRC,kCACW,CACHC,mBAAoBC,SAASN,KAAKO,OAAOC,cACzCC,mBAAoBH,SAASN,KAAKO,OAAOG,eAIjDC,4BACW,CACHC,OAAO,EACPC,MAAO,CACHC,MAAO,CACHC,MAAO,KAEXC,OAAQ,CACJD,MAAO,OAMvBE,uBAEW,EAGXC,yBACW,QAGXC,sBACWnB,KAAKO,OAAOa,eAGvBC,6BACW,6BAGXC,YAAYC,wBACEA,8DAIJC,mCAAa,cAAcC,kCACZC,kFACIA,qDAGzBF,WAAWG,oBACJH"}
\ No newline at end of file
diff --git a/lib/editor/tiny/plugins/recordrtc/amd/src/audio_recorder.js b/lib/editor/tiny/plugins/recordrtc/amd/src/audio_recorder.js
index 346ec697e4e..17fd1cc4f56 100644
--- a/lib/editor/tiny/plugins/recordrtc/amd/src/audio_recorder.js
+++ b/lib/editor/tiny/plugins/recordrtc/amd/src/audio_recorder.js
@@ -23,7 +23,6 @@
import BaseClass from './base_recorder';
import Modal from './modal';
-import ModalRegistry from 'core/modal_registry';
import {component} from 'tiny_recordrtc/common';
export default class Audio extends BaseClass {
@@ -67,18 +66,12 @@ export default class Audio extends BaseClass {
}
static getModalClass() {
- const modalType = `${component}/audio_recorder`;
- const registration = ModalRegistry.get(modalType);
- if (registration) {
- return registration.module;
- }
-
const AudioModal = class extends Modal {
- static TYPE = modalType;
+ static TYPE = `${component}/audio_recorder`;
static TEMPLATE = `${component}/audio_recorder`;
};
- ModalRegistry.register(AudioModal.TYPE, AudioModal, AudioModal.TEMPLATE);
+ AudioModal.registerModalType();
return AudioModal;
}
}
diff --git a/lib/editor/tiny/plugins/recordrtc/amd/src/video_recorder.js b/lib/editor/tiny/plugins/recordrtc/amd/src/video_recorder.js
index 28c3246747b..799e5f7d298 100644
--- a/lib/editor/tiny/plugins/recordrtc/amd/src/video_recorder.js
+++ b/lib/editor/tiny/plugins/recordrtc/amd/src/video_recorder.js
@@ -23,7 +23,6 @@
import BaseClass from './base_recorder';
import Modal from 'tiny_recordrtc/modal';
-import ModalRegistry from 'core/modal_registry';
import {component} from 'tiny_recordrtc/common';
export default class Video extends BaseClass {
@@ -83,18 +82,12 @@ export default class Video extends BaseClass {
}
static getModalClass() {
- const modalType = `${component}/video_recorder`;
- const registration = ModalRegistry.get(modalType);
- if (registration) {
- return registration.module;
- }
-
const VideoModal = class extends Modal {
- static TYPE = modalType;
+ static TYPE = `${component}/video_recorder`;
static TEMPLATE = `${component}/video_recorder`;
};
- ModalRegistry.register(VideoModal.TYPE, VideoModal, VideoModal.TEMPLATE);
+ VideoModal.registerModalType();
return VideoModal;
}
}
diff --git a/message/amd/build/notification_processor_settings.min.js b/message/amd/build/notification_processor_settings.min.js
index 16feff62b5f..0a4bf49c62d 100644
--- a/message/amd/build/notification_processor_settings.min.js
+++ b/message/amd/build/notification_processor_settings.min.js
@@ -1,10 +1,3 @@
-/**
- * Load the settings for a message processor.
- *
- * @module core_message/notification_processor_settings
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("core_message/notification_processor_settings",["jquery","core/ajax","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/fragment"],(function($,Ajax,Str,Notification,CustomEvents,Modal,ModalRegistry,Fragment){var registered=!1,SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]',SELECTORS_PROCESSOR="[data-processor-name]",SELECTORS_PREFERENCE_ROW='[data-region="preference-row"]',NotificationProcessorSettings=function(root){Modal.call(this,root),this.name=null,this.userId=null,this.contextId=null,this.element=null,this.saveButton=this.getFooter().find(SELECTORS_SAVE_BUTTON),this.cancelButton=this.getFooter().find(SELECTORS_CANCEL_BUTTON)};return NotificationProcessorSettings.TYPE="core_message-notification_processor_settings",(NotificationProcessorSettings.prototype=Object.create(Modal.prototype)).constructor=NotificationProcessorSettings,NotificationProcessorSettings.prototype.setUserId=function(id){this.userId=id},NotificationProcessorSettings.prototype.getUserId=function(){return this.userId},NotificationProcessorSettings.prototype.setElement=function(element){this.element=element},NotificationProcessorSettings.prototype.getElement=function(){return this.element},NotificationProcessorSettings.prototype.setName=function(name){this.name=name},NotificationProcessorSettings.prototype.getName=function(){return this.name},NotificationProcessorSettings.prototype.setContextId=function(id){this.contextId=id},NotificationProcessorSettings.prototype.getContextId=function(){return this.contextId},NotificationProcessorSettings.prototype.getForm=function(){return this.getBody().find("form")},NotificationProcessorSettings.prototype.disableButtons=function(){this.saveButton.prop("disabled",!0),this.cancelButton.prop("disabled",!0)},NotificationProcessorSettings.prototype.enableButtons=function(){this.saveButton.prop("disabled",!1),this.cancelButton.prop("disabled",!1)},NotificationProcessorSettings.prototype.loadTitleContent=function(){return this.titlePromise=Str.get_string("processorsettings","message"),this.setTitle(this.titlePromise),this.titlePromise},NotificationProcessorSettings.prototype.loadBodyContent=function(){this.disableButtons();var args={userid:this.getUserId(),type:this.getName()};return this.bodyPromise=Fragment.loadFragment("message","processor_settings",this.getContextId(),args),this.setBody(this.bodyPromise),this.bodyPromise.then(function(){this.enableButtons()}.bind(this)).fail(Notification.exception),this.bodyPromise},NotificationProcessorSettings.prototype.loadAllContent=function(){return $.when(this.loadTitleContent(),this.loadBodyContent())},NotificationProcessorSettings.prototype.show=function(){this.loadAllContent(),Modal.prototype.show.call(this)},NotificationProcessorSettings.prototype.hide=function(){Modal.prototype.hide.call(this),this.setContextId(null),this.setName(null),this.setUserId(null)},NotificationProcessorSettings.prototype.updateConfiguredStatus=function(){var processorHeader=$(this.getElement()).closest(SELECTORS_PROCESSOR);if(!processorHeader.hasClass("unconfigured"))return!1;var processorName=processorHeader.attr("data-processor-name"),request={methodname:"core_message_get_message_processor",args:{name:processorName,userid:this.userId}};return Ajax.call([request])[0].fail(Notification.exception).done((function(result){if(result.userconfigured){var notifications=$(SELECTORS_PREFERENCE_ROW+' [data-processor-name="'+processorName+'"]');processorHeader.removeClass("unconfigured"),notifications.removeClass("disabled")}}))},NotificationProcessorSettings.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,function(e,data){this.getForm().submit(),data.originalEvent.preventDefault()}.bind(this)),this.getModal().on("mpp:formsubmitted",function(e){this.hide(),this.updateConfiguredStatus(),e.stopPropagation()}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,function(e,data){this.hide(),data.originalEvent.preventDefault(),e.stopPropagation()}.bind(this))},registered||(ModalRegistry.register(NotificationProcessorSettings.TYPE,NotificationProcessorSettings,"core/modal_save_cancel"),registered=!0),NotificationProcessorSettings}));
+define("core_message/notification_processor_settings",["exports","jquery","core/ajax","core/str","core/notification","core/custom_interaction_events","core/modal","core/fragment"],(function(_exports,_jquery,Ajax,Str,Notification,CustomEvents,_modal,Fragment){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),Ajax=_interopRequireWildcard(Ajax),Str=_interopRequireWildcard(Str),Notification=_interopRequireWildcard(Notification),CustomEvents=_interopRequireWildcard(CustomEvents),_modal=_interopRequireDefault(_modal),Fragment=_interopRequireWildcard(Fragment);const SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]',SELECTORS_PROCESSOR="[data-processor-name]",SELECTORS_PREFERENCE_ROW='[data-region="preference-row"]';class NotificationProcessorSettings extends _modal.default{constructor(root){super(root),this.name=null,this.userId=null,this.contextId=null,this.element=null,this.saveButton=this.getFooter().find(SELECTORS_SAVE_BUTTON),this.cancelButton=this.getFooter().find(SELECTORS_CANCEL_BUTTON)}setUserId(id){this.userId=id}getUserId(){return this.userId}setElement(element){this.element=element}getElement(){return this.element}setName(name){this.name=name}getName(){return this.name}setContextId(id){this.contextId=id}getContextId(){return this.contextId}getForm(){return this.getBody().find("form")}disableButtons(){this.saveButton.prop("disabled",!0),this.cancelButton.prop("disabled",!0)}enableButtons(){this.saveButton.prop("disabled",!1),this.cancelButton.prop("disabled",!1)}loadTitleContent(){return this.titlePromise=Str.get_string("processorsettings","message"),this.setTitle(this.titlePromise),this.titlePromise}loadBodyContent(){this.disableButtons();const args={userid:this.getUserId(),type:this.getName()};return this.bodyPromise=Fragment.loadFragment("message","processor_settings",this.getContextId(),args),this.setBody(this.bodyPromise),this.bodyPromise.then((()=>{this.enableButtons()})).catch(Notification.exception),this.bodyPromise}loadAllContent(){return _jquery.default.when(this.loadTitleContent(),this.loadBodyContent())}show(){this.loadAllContent(),super.show(this)}hide(){super.hide(this),this.setContextId(null),this.setName(null),this.setUserId(null)}updateConfiguredStatus(){const processorHeader=(0,_jquery.default)(this.getElement()).closest(SELECTORS_PROCESSOR);if(!processorHeader.hasClass("unconfigured"))return!1;const processorName=processorHeader.attr("data-processor-name"),request={methodname:"core_message_get_message_processor",args:{name:processorName,userid:this.userId}};return Ajax.call([request])[0].then((result=>{if(result.userconfigured){const notifications=(0,_jquery.default)(SELECTORS_PREFERENCE_ROW+' [data-processor-name="'+processorName+'"]');processorHeader.removeClass("unconfigured"),notifications.removeClass("disabled")}return result}))}registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,((e,data)=>{this.getForm().submit(),data.originalEvent.preventDefault()})),this.getModal().on("mpp:formsubmitted",(e=>{this.hide(),this.updateConfiguredStatus(),e.stopPropagation()})),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,((e,data)=>{this.hide(),data.originalEvent.preventDefault(),e.stopPropagation()}))}}return _exports.default=NotificationProcessorSettings,_defineProperty(NotificationProcessorSettings,"TYPE","core_message-notification_processor_settings"),_defineProperty(NotificationProcessorSettings,"TEMPLATE","core/modal_save_cancel"),NotificationProcessorSettings.registerModalType(),_exports.default}));
//# sourceMappingURL=notification_processor_settings.min.js.map
\ No newline at end of file
diff --git a/message/amd/build/notification_processor_settings.min.js.map b/message/amd/build/notification_processor_settings.min.js.map
index 979322abe32..47d3ef84cce 100644
--- a/message/amd/build/notification_processor_settings.min.js.map
+++ b/message/amd/build/notification_processor_settings.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"notification_processor_settings.min.js","sources":["../src/notification_processor_settings.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Load the settings for a message processor.\n *\n * @module core_message/notification_processor_settings\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/str',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/fragment',\n ],\n function(\n $,\n Ajax,\n Str,\n Notification,\n CustomEvents,\n Modal,\n ModalRegistry,\n Fragment\n ) {\n\n var registered = false;\n var SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n PROCESSOR: '[data-processor-name]',\n PREFERENCE_ROW: '[data-region=\"preference-row\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @class\n * @param {object} root The root jQuery element for the modal.\n */\n var NotificationProcessorSettings = function(root) {\n Modal.call(this, root);\n this.name = null;\n this.userId = null;\n this.contextId = null;\n this.element = null;\n this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);\n this.cancelButton = this.getFooter().find(SELECTORS.CANCEL_BUTTON);\n };\n\n NotificationProcessorSettings.TYPE = 'core_message-notification_processor_settings';\n NotificationProcessorSettings.prototype = Object.create(Modal.prototype);\n NotificationProcessorSettings.prototype.constructor = NotificationProcessorSettings;\n\n /**\n * Set the userid to the given value.\n *\n * @method setUserId\n * @param {int} id The notification userid\n */\n NotificationProcessorSettings.prototype.setUserId = function(id) {\n this.userId = id;\n };\n\n /**\n * Retrieve the current userid, if any.\n *\n * @method getUserId\n * @return {int|null} The notification userid\n */\n NotificationProcessorSettings.prototype.getUserId = function() {\n return this.userId;\n };\n\n /**\n * Set the object to the given value.\n *\n * @method setElement\n * @param {object} element The notification node element.\n */\n NotificationProcessorSettings.prototype.setElement = function(element) {\n this.element = element;\n };\n\n /**\n * Retrieve the current element, if any.\n *\n * @method getElement\n * @return {object|null} The notification node element.\n */\n NotificationProcessorSettings.prototype.getElement = function() {\n return this.element;\n };\n\n /**\n * Set the name to the given value.\n *\n * @method setName\n * @param {string} name The notification name.\n */\n NotificationProcessorSettings.prototype.setName = function(name) {\n this.name = name;\n };\n\n /**\n * Retrieve the current name, if any.\n *\n * @method getName\n * @return {string|null} The notification name.\n */\n NotificationProcessorSettings.prototype.getName = function() {\n return this.name;\n };\n /**\n * Set the context id to the given value.\n *\n * @method setContextId\n * @param {Number} id The notification context id\n */\n NotificationProcessorSettings.prototype.setContextId = function(id) {\n this.contextId = id;\n };\n\n /**\n * Retrieve the current context id, if any.\n *\n * @method getContextId\n * @return {Number|null} The notification context id\n */\n NotificationProcessorSettings.prototype.getContextId = function() {\n return this.contextId;\n };\n\n /**\n * Get the form element from the modal.\n *\n * @method getForm\n * @return {object}\n */\n NotificationProcessorSettings.prototype.getForm = function() {\n return this.getBody().find('form');\n };\n\n /**\n * Disable the buttons in the footer.\n *\n * @method disableButtons\n */\n NotificationProcessorSettings.prototype.disableButtons = function() {\n this.saveButton.prop('disabled', true);\n this.cancelButton.prop('disabled', true);\n };\n\n /**\n * Enable the buttons in the footer.\n *\n * @method enableButtons\n */\n NotificationProcessorSettings.prototype.enableButtons = function() {\n this.saveButton.prop('disabled', false);\n this.cancelButton.prop('disabled', false);\n };\n\n /**\n * Load the title for the modal to the appropriate value\n * depending on message outputs.\n *\n * @method loadTitleContent\n * @return {object} A promise resolved with the new title text.\n */\n NotificationProcessorSettings.prototype.loadTitleContent = function() {\n this.titlePromise = Str.get_string('processorsettings', 'message');\n this.setTitle(this.titlePromise);\n\n return this.titlePromise;\n };\n\n /**\n * Load the body for the modal to the appropriate value\n * depending on message outputs.\n *\n * @method loadBodyContent\n * @return {object} A promise resolved with the fragment html and js from\n */\n NotificationProcessorSettings.prototype.loadBodyContent = function() {\n this.disableButtons();\n\n var args = {\n userid: this.getUserId(),\n type: this.getName(),\n };\n\n this.bodyPromise = Fragment.loadFragment('message', 'processor_settings', this.getContextId(), args);\n this.setBody(this.bodyPromise);\n\n this.bodyPromise.then(function() {\n this.enableButtons();\n return;\n }.bind(this))\n .fail(Notification.exception);\n\n return this.bodyPromise;\n };\n\n /**\n * Load both the title and body content.\n *\n * @method loadAllContent\n * @return {object} promise\n */\n NotificationProcessorSettings.prototype.loadAllContent = function() {\n return $.when(this.loadTitleContent(), this.loadBodyContent());\n };\n\n /**\n * Load the modal content before showing it. This\n * is to allow us to re-use the same modal for creating and\n * editing different message outputs within the page.\n *\n * @method show\n */\n NotificationProcessorSettings.prototype.show = function() {\n this.loadAllContent();\n Modal.prototype.show.call(this);\n };\n\n /**\n * Clear the notification from the modal when it's closed so\n * that it is loaded fresh next time it's displayed.\n *\n * @method hide\n */\n NotificationProcessorSettings.prototype.hide = function() {\n Modal.prototype.hide.call(this);\n this.setContextId(null);\n this.setName(null);\n this.setUserId(null);\n };\n\n /**\n * Checks if the processor has been configured. If so then remove the unconfigured\n * status from the interface.\n *\n * @method updateConfiguredStatus\n * @return {Promise|boolean}\n */\n NotificationProcessorSettings.prototype.updateConfiguredStatus = function() {\n var processorHeader = $(this.getElement()).closest(SELECTORS.PROCESSOR);\n\n if (!processorHeader.hasClass('unconfigured')) {\n return false;\n }\n\n var processorName = processorHeader.attr('data-processor-name');\n var request = {\n methodname: 'core_message_get_message_processor',\n args: {\n name: processorName,\n userid: this.userId,\n },\n };\n\n return Ajax.call([request])[0]\n .fail(Notification.exception)\n .done(function(result) {\n // Check if the user has figured configuring the processor.\n if (result.userconfigured) {\n // If they have then we can enable the settings.\n var notifications = $(SELECTORS.PREFERENCE_ROW + ' [data-processor-name=\"' + processorName + '\"]');\n processorHeader.removeClass('unconfigured');\n notifications.removeClass('disabled');\n }\n });\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n NotificationProcessorSettings.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // When the user clicks the save button we trigger the form submission.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(e, data) {\n this.getForm().submit();\n data.originalEvent.preventDefault();\n }.bind(this));\n\n this.getModal().on('mpp:formsubmitted', function(e) {\n this.hide();\n this.updateConfiguredStatus();\n e.stopPropagation();\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n this.hide();\n data.originalEvent.preventDefault();\n e.stopPropagation();\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported\n // so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(\n NotificationProcessorSettings.TYPE,\n NotificationProcessorSettings,\n 'core/modal_save_cancel');\n registered = true;\n }\n\n return NotificationProcessorSettings;\n});\n"],"names":["define","$","Ajax","Str","Notification","CustomEvents","Modal","ModalRegistry","Fragment","registered","SELECTORS","NotificationProcessorSettings","root","call","this","name","userId","contextId","element","saveButton","getFooter","find","cancelButton","TYPE","prototype","Object","create","constructor","setUserId","id","getUserId","setElement","getElement","setName","getName","setContextId","getContextId","getForm","getBody","disableButtons","prop","enableButtons","loadTitleContent","titlePromise","get_string","setTitle","loadBodyContent","args","userid","type","bodyPromise","loadFragment","setBody","then","bind","fail","exception","loadAllContent","when","show","hide","updateConfiguredStatus","processorHeader","closest","hasClass","processorName","attr","request","methodname","done","result","userconfigured","notifications","removeClass","registerEventListeners","getModal","on","events","activate","e","data","submit","originalEvent","preventDefault","stopPropagation","register"],"mappings":"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"}
\ No newline at end of file
+{"version":3,"file":"notification_processor_settings.min.js","sources":["../src/notification_processor_settings.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Load the settings for a message processor.\n *\n * @module core_message/notification_processor_settings\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n\nimport $ from 'jquery';\nimport * as Ajax from 'core/ajax';\nimport * as Str from 'core/str';\nimport * as Notification from 'core/notification';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport * as Fragment from 'core/fragment';\n\nconst SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n PROCESSOR: '[data-processor-name]',\n PREFERENCE_ROW: '[data-region=\"preference-row\"]',\n};\n\nexport default class NotificationProcessorSettings extends Modal {\n static TYPE = 'core_message-notification_processor_settings';\n static TEMPLATE = 'core/modal_save_cancel';\n\n /**\n * Constructor for the Modal.\n *\n * @class\n * @param {object} root The root jQuery element for the modal.\n */\n constructor(root) {\n super(root);\n this.name = null;\n this.userId = null;\n this.contextId = null;\n this.element = null;\n this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);\n this.cancelButton = this.getFooter().find(SELECTORS.CANCEL_BUTTON);\n }\n\n /**\n * Set the userid to the given value.\n *\n * @method setUserId\n * @param {int} id The notification userid\n */\n setUserId(id) {\n this.userId = id;\n }\n\n /**\n * Retrieve the current userid, if any.\n *\n * @method getUserId\n * @return {int|null} The notification userid\n */\n getUserId() {\n return this.userId;\n }\n\n /**\n * Set the object to the given value.\n *\n * @method setElement\n * @param {object} element The notification node element.\n */\n setElement(element) {\n this.element = element;\n }\n\n /**\n * Retrieve the current element, if any.\n *\n * @method getElement\n * @return {object|null} The notification node element.\n */\n getElement() {\n return this.element;\n }\n\n /**\n * Set the name to the given value.\n *\n * @method setName\n * @param {string} name The notification name.\n */\n setName(name) {\n this.name = name;\n }\n\n /**\n * Retrieve the current name, if any.\n *\n * @method getName\n * @return {string|null} The notification name.\n */\n getName() {\n return this.name;\n }\n /**\n * Set the context id to the given value.\n *\n * @method setContextId\n * @param {Number} id The notification context id\n */\n setContextId(id) {\n this.contextId = id;\n }\n\n /**\n * Retrieve the current context id, if any.\n *\n * @method getContextId\n * @return {Number|null} The notification context id\n */\n getContextId() {\n return this.contextId;\n }\n\n /**\n * Get the form element from the modal.\n *\n * @method getForm\n * @return {object}\n */\n getForm() {\n return this.getBody().find('form');\n }\n\n /**\n * Disable the buttons in the footer.\n *\n * @method disableButtons\n */\n disableButtons() {\n this.saveButton.prop('disabled', true);\n this.cancelButton.prop('disabled', true);\n }\n\n /**\n * Enable the buttons in the footer.\n *\n * @method enableButtons\n */\n enableButtons() {\n this.saveButton.prop('disabled', false);\n this.cancelButton.prop('disabled', false);\n }\n\n /**\n * Load the title for the modal to the appropriate value\n * depending on message outputs.\n *\n * @method loadTitleContent\n * @return {object} A promise resolved with the new title text.\n */\n loadTitleContent() {\n this.titlePromise = Str.get_string('processorsettings', 'message');\n this.setTitle(this.titlePromise);\n\n return this.titlePromise;\n }\n\n /**\n * Load the body for the modal to the appropriate value\n * depending on message outputs.\n *\n * @method loadBodyContent\n * @return {object} A promise resolved with the fragment html and js from\n */\n loadBodyContent() {\n this.disableButtons();\n\n const args = {\n userid: this.getUserId(),\n type: this.getName(),\n };\n\n this.bodyPromise = Fragment.loadFragment('message', 'processor_settings', this.getContextId(), args);\n this.setBody(this.bodyPromise);\n\n this.bodyPromise.then(() => {\n this.enableButtons();\n return;\n })\n .catch(Notification.exception);\n\n return this.bodyPromise;\n }\n\n /**\n * Load both the title and body content.\n *\n * @method loadAllContent\n * @return {object} promise\n */\n loadAllContent() {\n return $.when(this.loadTitleContent(), this.loadBodyContent());\n }\n\n /**\n * Load the modal content before showing it. This\n * is to allow us to re-use the same modal for creating and\n * editing different message outputs within the page.\n *\n * @method show\n */\n show() {\n this.loadAllContent();\n super.show(this);\n }\n\n /**\n * Clear the notification from the modal when it's closed so\n * that it is loaded fresh next time it's displayed.\n *\n * @method hide\n */\n hide() {\n super.hide(this);\n this.setContextId(null);\n this.setName(null);\n this.setUserId(null);\n }\n\n /**\n * Checks if the processor has been configured. If so then remove the unconfigured\n * status from the interface.\n *\n * @method updateConfiguredStatus\n * @return {Promise|boolean}\n */\n updateConfiguredStatus() {\n const processorHeader = $(this.getElement()).closest(SELECTORS.PROCESSOR);\n\n if (!processorHeader.hasClass('unconfigured')) {\n return false;\n }\n\n const processorName = processorHeader.attr('data-processor-name');\n const request = {\n methodname: 'core_message_get_message_processor',\n args: {\n name: processorName,\n userid: this.userId,\n },\n };\n\n return Ajax.call([request])[0]\n .then((result) => {\n // Check if the user has figured configuring the processor.\n if (result.userconfigured) {\n // If they have then we can enable the settings.\n const notifications = $(SELECTORS.PREFERENCE_ROW + ' [data-processor-name=\"' + processorName + '\"]');\n processorHeader.removeClass('unconfigured');\n notifications.removeClass('disabled');\n }\n return result;\n });\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n // When the user clicks the save button we trigger the form submission.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, (e, data) => {\n this.getForm().submit();\n data.originalEvent.preventDefault();\n });\n\n this.getModal().on('mpp:formsubmitted', (e) => {\n this.hide();\n this.updateConfiguredStatus();\n e.stopPropagation();\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, (e, data) => {\n this.hide();\n data.originalEvent.preventDefault();\n e.stopPropagation();\n });\n }\n}\n\nNotificationProcessorSettings.registerModalType();\n"],"names":["SELECTORS","NotificationProcessorSettings","Modal","constructor","root","name","userId","contextId","element","saveButton","this","getFooter","find","cancelButton","setUserId","id","getUserId","setElement","getElement","setName","getName","setContextId","getContextId","getForm","getBody","disableButtons","prop","enableButtons","loadTitleContent","titlePromise","Str","get_string","setTitle","loadBodyContent","args","userid","type","bodyPromise","Fragment","loadFragment","setBody","then","catch","Notification","exception","loadAllContent","$","when","show","hide","updateConfiguredStatus","processorHeader","closest","hasClass","processorName","attr","request","methodname","Ajax","call","result","userconfigured","notifications","removeClass","registerEventListeners","getModal","on","CustomEvents","events","activate","e","data","submit","originalEvent","preventDefault","stopPropagation","registerModalType"],"mappings":"yyDAgCMA,sBACW,uBADXA,wBAEa,yBAFbA,oBAGS,wBAHTA,yBAIc,uCAGCC,sCAAsCC,eAUvDC,YAAYC,YACFA,WACDC,KAAO,UACPC,OAAS,UACTC,UAAY,UACZC,QAAU,UACVC,WAAaC,KAAKC,YAAYC,KAAKZ,4BACnCa,aAAeH,KAAKC,YAAYC,KAAKZ,yBAS9Cc,UAAUC,SACDT,OAASS,GASlBC,mBACWN,KAAKJ,OAShBW,WAAWT,cACFA,QAAUA,QASnBU,oBACWR,KAAKF,QAShBW,QAAQd,WACCA,KAAOA,KAShBe,iBACWV,KAAKL,KAQhBgB,aAAaN,SACJR,UAAYQ,GASrBO,sBACWZ,KAAKH,UAShBgB,iBACWb,KAAKc,UAAUZ,KAAK,QAQ/Ba,sBACShB,WAAWiB,KAAK,YAAY,QAC5Bb,aAAaa,KAAK,YAAY,GAQvCC,qBACSlB,WAAWiB,KAAK,YAAY,QAC5Bb,aAAaa,KAAK,YAAY,GAUvCE,+BACSC,aAAeC,IAAIC,WAAW,oBAAqB,gBACnDC,SAAStB,KAAKmB,cAEZnB,KAAKmB,aAUhBI,uBACSR,uBAECS,KAAO,CACTC,OAAQzB,KAAKM,YACboB,KAAM1B,KAAKU,uBAGViB,YAAcC,SAASC,aAAa,UAAW,qBAAsB7B,KAAKY,eAAgBY,WAC1FM,QAAQ9B,KAAK2B,kBAEbA,YAAYI,MAAK,UACbd,mBAGRe,MAAMC,aAAaC,WAEblC,KAAK2B,YAShBQ,wBACWC,gBAAEC,KAAKrC,KAAKkB,mBAAoBlB,KAAKuB,mBAUhDe,YACSH,uBACCG,KAAKtC,MASfuC,aACUA,KAAKvC,WACNW,aAAa,WACbF,QAAQ,WACRL,UAAU,MAUnBoC,+BACUC,iBAAkB,mBAAEzC,KAAKQ,cAAckC,QAAQpD,yBAEhDmD,gBAAgBE,SAAS,uBACnB,QAGLC,cAAgBH,gBAAgBI,KAAK,uBACrCC,QAAU,CACZC,WAAY,qCACZvB,KAAM,CACF7B,KAAMiD,cACNnB,OAAQzB,KAAKJ,gBAIdoD,KAAKC,KAAK,CAACH,UAAU,GACvBf,MAAMmB,YAECA,OAAOC,eAAgB,OAEjBC,eAAgB,mBAAE9D,yBAA2B,0BAA4BsD,cAAgB,MAC/FH,gBAAgBY,YAAY,gBAC5BD,cAAcC,YAAY,mBAEvBH,UASnBI,+BAEUA,uBAAuBtD,WAGxBuD,WAAWC,GAAGC,aAAaC,OAAOC,SAAUrE,uBAAuB,CAACsE,EAAGC,aACnEhD,UAAUiD,SACfD,KAAKE,cAAcC,yBAGlBT,WAAWC,GAAG,qBAAsBI,SAChCrB,YACAC,yBACLoB,EAAEK,0BAGDV,WAAWC,GAAGC,aAAaC,OAAOC,SAAUrE,yBAAyB,CAACsE,EAAGC,aACrEtB,OACLsB,KAAKE,cAAcC,iBACnBJ,EAAEK,4FAzQO1E,qCACH,gEADGA,yCAEC,0BA4QtBA,8BAA8B2E"}
\ No newline at end of file
diff --git a/message/amd/src/notification_processor_settings.js b/message/amd/src/notification_processor_settings.js
index 4295750591f..5e57538804e 100644
--- a/message/amd/src/notification_processor_settings.js
+++ b/message/amd/src/notification_processor_settings.js
@@ -20,34 +20,26 @@
* @copyright 2016 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([
- 'jquery',
- 'core/ajax',
- 'core/str',
- 'core/notification',
- 'core/custom_interaction_events',
- 'core/modal',
- 'core/modal_registry',
- 'core/fragment',
- ],
- function(
- $,
- Ajax,
- Str,
- Notification,
- CustomEvents,
- Modal,
- ModalRegistry,
- Fragment
- ) {
- var registered = false;
- var SELECTORS = {
- SAVE_BUTTON: '[data-action="save"]',
- CANCEL_BUTTON: '[data-action="cancel"]',
- PROCESSOR: '[data-processor-name]',
- PREFERENCE_ROW: '[data-region="preference-row"]',
- };
+
+import $ from 'jquery';
+import * as Ajax from 'core/ajax';
+import * as Str from 'core/str';
+import * as Notification from 'core/notification';
+import * as CustomEvents from 'core/custom_interaction_events';
+import Modal from 'core/modal';
+import * as Fragment from 'core/fragment';
+
+const SELECTORS = {
+ SAVE_BUTTON: '[data-action="save"]',
+ CANCEL_BUTTON: '[data-action="cancel"]',
+ PROCESSOR: '[data-processor-name]',
+ PREFERENCE_ROW: '[data-region="preference-row"]',
+};
+
+export default class NotificationProcessorSettings extends Modal {
+ static TYPE = 'core_message-notification_processor_settings';
+ static TEMPLATE = 'core/modal_save_cancel';
/**
* Constructor for the Modal.
@@ -55,19 +47,15 @@ define([
* @class
* @param {object} root The root jQuery element for the modal.
*/
- var NotificationProcessorSettings = function(root) {
- Modal.call(this, root);
+ constructor(root) {
+ super(root);
this.name = null;
this.userId = null;
this.contextId = null;
this.element = null;
this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);
this.cancelButton = this.getFooter().find(SELECTORS.CANCEL_BUTTON);
- };
-
- NotificationProcessorSettings.TYPE = 'core_message-notification_processor_settings';
- NotificationProcessorSettings.prototype = Object.create(Modal.prototype);
- NotificationProcessorSettings.prototype.constructor = NotificationProcessorSettings;
+ }
/**
* Set the userid to the given value.
@@ -75,9 +63,9 @@ define([
* @method setUserId
* @param {int} id The notification userid
*/
- NotificationProcessorSettings.prototype.setUserId = function(id) {
+ setUserId(id) {
this.userId = id;
- };
+ }
/**
* Retrieve the current userid, if any.
@@ -85,9 +73,9 @@ define([
* @method getUserId
* @return {int|null} The notification userid
*/
- NotificationProcessorSettings.prototype.getUserId = function() {
+ getUserId() {
return this.userId;
- };
+ }
/**
* Set the object to the given value.
@@ -95,9 +83,9 @@ define([
* @method setElement
* @param {object} element The notification node element.
*/
- NotificationProcessorSettings.prototype.setElement = function(element) {
+ setElement(element) {
this.element = element;
- };
+ }
/**
* Retrieve the current element, if any.
@@ -105,9 +93,9 @@ define([
* @method getElement
* @return {object|null} The notification node element.
*/
- NotificationProcessorSettings.prototype.getElement = function() {
+ getElement() {
return this.element;
- };
+ }
/**
* Set the name to the given value.
@@ -115,9 +103,9 @@ define([
* @method setName
* @param {string} name The notification name.
*/
- NotificationProcessorSettings.prototype.setName = function(name) {
+ setName(name) {
this.name = name;
- };
+ }
/**
* Retrieve the current name, if any.
@@ -125,18 +113,18 @@ define([
* @method getName
* @return {string|null} The notification name.
*/
- NotificationProcessorSettings.prototype.getName = function() {
+ getName() {
return this.name;
- };
+ }
/**
* Set the context id to the given value.
*
* @method setContextId
* @param {Number} id The notification context id
*/
- NotificationProcessorSettings.prototype.setContextId = function(id) {
+ setContextId(id) {
this.contextId = id;
- };
+ }
/**
* Retrieve the current context id, if any.
@@ -144,9 +132,9 @@ define([
* @method getContextId
* @return {Number|null} The notification context id
*/
- NotificationProcessorSettings.prototype.getContextId = function() {
+ getContextId() {
return this.contextId;
- };
+ }
/**
* Get the form element from the modal.
@@ -154,29 +142,29 @@ define([
* @method getForm
* @return {object}
*/
- NotificationProcessorSettings.prototype.getForm = function() {
+ getForm() {
return this.getBody().find('form');
- };
+ }
/**
* Disable the buttons in the footer.
*
* @method disableButtons
*/
- NotificationProcessorSettings.prototype.disableButtons = function() {
+ disableButtons() {
this.saveButton.prop('disabled', true);
this.cancelButton.prop('disabled', true);
- };
+ }
/**
* Enable the buttons in the footer.
*
* @method enableButtons
*/
- NotificationProcessorSettings.prototype.enableButtons = function() {
+ enableButtons() {
this.saveButton.prop('disabled', false);
this.cancelButton.prop('disabled', false);
- };
+ }
/**
* Load the title for the modal to the appropriate value
@@ -185,12 +173,12 @@ define([
* @method loadTitleContent
* @return {object} A promise resolved with the new title text.
*/
- NotificationProcessorSettings.prototype.loadTitleContent = function() {
+ loadTitleContent() {
this.titlePromise = Str.get_string('processorsettings', 'message');
this.setTitle(this.titlePromise);
return this.titlePromise;
- };
+ }
/**
* Load the body for the modal to the appropriate value
@@ -199,10 +187,10 @@ define([
* @method loadBodyContent
* @return {object} A promise resolved with the fragment html and js from
*/
- NotificationProcessorSettings.prototype.loadBodyContent = function() {
+ loadBodyContent() {
this.disableButtons();
- var args = {
+ const args = {
userid: this.getUserId(),
type: this.getName(),
};
@@ -210,14 +198,14 @@ define([
this.bodyPromise = Fragment.loadFragment('message', 'processor_settings', this.getContextId(), args);
this.setBody(this.bodyPromise);
- this.bodyPromise.then(function() {
+ this.bodyPromise.then(() => {
this.enableButtons();
return;
- }.bind(this))
- .fail(Notification.exception);
+ })
+ .catch(Notification.exception);
return this.bodyPromise;
- };
+ }
/**
* Load both the title and body content.
@@ -225,9 +213,9 @@ define([
* @method loadAllContent
* @return {object} promise
*/
- NotificationProcessorSettings.prototype.loadAllContent = function() {
+ loadAllContent() {
return $.when(this.loadTitleContent(), this.loadBodyContent());
- };
+ }
/**
* Load the modal content before showing it. This
@@ -236,10 +224,10 @@ define([
*
* @method show
*/
- NotificationProcessorSettings.prototype.show = function() {
+ show() {
this.loadAllContent();
- Modal.prototype.show.call(this);
- };
+ super.show(this);
+ }
/**
* Clear the notification from the modal when it's closed so
@@ -247,12 +235,12 @@ define([
*
* @method hide
*/
- NotificationProcessorSettings.prototype.hide = function() {
- Modal.prototype.hide.call(this);
+ hide() {
+ super.hide(this);
this.setContextId(null);
this.setName(null);
this.setUserId(null);
- };
+ }
/**
* Checks if the processor has been configured. If so then remove the unconfigured
@@ -261,15 +249,15 @@ define([
* @method updateConfiguredStatus
* @return {Promise|boolean}
*/
- NotificationProcessorSettings.prototype.updateConfiguredStatus = function() {
- var processorHeader = $(this.getElement()).closest(SELECTORS.PROCESSOR);
+ updateConfiguredStatus() {
+ const processorHeader = $(this.getElement()).closest(SELECTORS.PROCESSOR);
if (!processorHeader.hasClass('unconfigured')) {
return false;
}
- var processorName = processorHeader.attr('data-processor-name');
- var request = {
+ const processorName = processorHeader.attr('data-processor-name');
+ const request = {
methodname: 'core_message_get_message_processor',
args: {
name: processorName,
@@ -278,56 +266,45 @@ define([
};
return Ajax.call([request])[0]
- .fail(Notification.exception)
- .done(function(result) {
+ .then((result) => {
// Check if the user has figured configuring the processor.
if (result.userconfigured) {
// If they have then we can enable the settings.
- var notifications = $(SELECTORS.PREFERENCE_ROW + ' [data-processor-name="' + processorName + '"]');
+ const notifications = $(SELECTORS.PREFERENCE_ROW + ' [data-processor-name="' + processorName + '"]');
processorHeader.removeClass('unconfigured');
notifications.removeClass('disabled');
}
+ return result;
});
- };
+ }
/**
* Set up all of the event handling for the modal.
*
* @method registerEventListeners
*/
- NotificationProcessorSettings.prototype.registerEventListeners = function() {
+ registerEventListeners() {
// Apply parent event listeners.
- Modal.prototype.registerEventListeners.call(this);
+ super.registerEventListeners(this);
// When the user clicks the save button we trigger the form submission.
- this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(e, data) {
+ this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, (e, data) => {
this.getForm().submit();
data.originalEvent.preventDefault();
- }.bind(this));
+ });
- this.getModal().on('mpp:formsubmitted', function(e) {
+ this.getModal().on('mpp:formsubmitted', (e) => {
this.hide();
this.updateConfiguredStatus();
e.stopPropagation();
- }.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) => {
this.hide();
data.originalEvent.preventDefault();
e.stopPropagation();
- }.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(
- NotificationProcessorSettings.TYPE,
- NotificationProcessorSettings,
- 'core/modal_save_cancel');
- registered = true;
+ });
}
+}
- return NotificationProcessorSettings;
-});
+NotificationProcessorSettings.registerModalType();
diff --git a/mod/quiz/amd/build/modal_add_random_question.min.js b/mod/quiz/amd/build/modal_add_random_question.min.js
index e9a7429c40d..a33960fe2e9 100644
--- a/mod/quiz/amd/build/modal_add_random_question.min.js
+++ b/mod/quiz/amd/build/modal_add_random_question.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the logic for the add random question modal.
- *
- * @module mod_quiz/modal_add_random_question
- * @copyright 2018 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("mod_quiz/modal_add_random_question",["jquery","core/notification","core/modal","core/modal_events","core/modal_registry","core/fragment","core/templates","core_form/changechecker"],(function($,Notification,Modal,ModalEvents,ModalRegistry,Fragment,Templates,FormChangeChecker){var registered=!1,SELECTORS_EXISTING_CATEGORY_CONTAINER='[data-region="existing-category-container"]',SELECTORS_EXISTING_CATEGORY_FORM_ELEMENT="#id_existingcategoryheader",SELECTORS_NEW_CATEGORY_CONTAINER='[data-region="new-category-container"]',SELECTORS_NEW_CATEGORY_FORM_ELEMENT="#id_newcategoryheader",SELECTORS_TAB_CONTENT='[data-region="tab-content"]',SELECTORS_ADD_ON_PAGE_FORM_ELEMENT='[name="addonpage"]',SELECTORS_SUBMIT_BUTTON_ELEMENT='input[type="submit"]',SELECTORS_CANCEL_BUTTON_ELEMENT='input[type="submit"][name="cancel"]',SELECTORS_FORM_HEADER="legend",SELECTORS_BUTTON_CONTAINER=".fitem",ModalAddRandomQuestion=function(root){Modal.call(this,root),this.contextId=null,this.addOnPageId=null,this.category=null,this.returnUrl=null,this.cmid=null,this.loadedForm=!1};return ModalAddRandomQuestion.TYPE="mod_quiz-quiz-add-random-question",(ModalAddRandomQuestion.prototype=Object.create(Modal.prototype)).constructor=ModalAddRandomQuestion,ModalAddRandomQuestion.prototype.setContextId=function(id){this.contextId=id},ModalAddRandomQuestion.prototype.getContextId=function(){return this.contextId},ModalAddRandomQuestion.prototype.setAddOnPageId=function(id){this.addOnPageId=id,this.getBody().find(SELECTORS_ADD_ON_PAGE_FORM_ELEMENT).val(id)},ModalAddRandomQuestion.prototype.getAddOnPageId=function(){return this.addOnPageId},ModalAddRandomQuestion.prototype.setCategory=function(category){this.category=category},ModalAddRandomQuestion.prototype.getCategory=function(){return this.category},ModalAddRandomQuestion.prototype.setReturnUrl=function(url){this.returnUrl=url},ModalAddRandomQuestion.prototype.getReturnUrl=function(){return this.returnUrl},ModalAddRandomQuestion.prototype.setCMID=function(id){this.cmid=id},ModalAddRandomQuestion.prototype.getCMID=function(){return this.cmid},ModalAddRandomQuestion.prototype.moveFormElementIntoTab=function(formElement,tabElement){var submitButtons=formElement.find(SELECTORS_SUBMIT_BUTTON_ELEMENT),footer=$('');formElement.find(SELECTORS_FORM_HEADER).addClass("hidden"),formElement.wrap(tabElement),submitButtons.closest(SELECTORS_BUTTON_CONTAINER).remove(),submitButtons.appendTo(footer),footer.appendTo(formElement)},ModalAddRandomQuestion.prototype.moveTabsIntoTabContent=function(form){var tabContent=this.getBody().find(SELECTORS_TAB_CONTENT).empty();form.find('[role="tabpanel"]').wrapAll(tabContent)},ModalAddRandomQuestion.prototype.moveCancelButtonToTabs=function(form){var cancelButton=form.find(SELECTORS_CANCEL_BUTTON_ELEMENT).addClass("ml-1"),tabFooters=form.find('[data-region="footer"]');cancelButton.closest(SELECTORS_BUTTON_CONTAINER).remove(),cancelButton.clone().appendTo(tabFooters)},ModalAddRandomQuestion.prototype.loadForm=function(){return Fragment.loadFragment("mod_quiz","add_random_question_form",this.getContextId(),{addonpage:this.getAddOnPageId(),cat:this.getCategory(),returnurl:this.getReturnUrl(),cmid:this.getCMID()}).then(function(html,js){var form=$(html),existingCategoryFormElement=form.find(SELECTORS_EXISTING_CATEGORY_FORM_ELEMENT),existingCategoryTab=this.getBody().find(SELECTORS_EXISTING_CATEGORY_CONTAINER),newCategoryFormElement=form.find(SELECTORS_NEW_CATEGORY_FORM_ELEMENT),newCategoryTab=this.getBody().find(SELECTORS_NEW_CATEGORY_CONTAINER);this.moveFormElementIntoTab(existingCategoryFormElement,existingCategoryTab),this.moveFormElementIntoTab(newCategoryFormElement,newCategoryTab),this.moveTabsIntoTabContent(form),this.moveCancelButtonToTabs(form),Templates.replaceNode(this.getBody().find(SELECTORS_TAB_CONTENT),form,js)}.bind(this)).then((function(){FormChangeChecker.disableAllChecks()})).fail(Notification.exception)},ModalAddRandomQuestion.prototype.show=function(){Modal.prototype.show.call(this),this.loadedForm||(this.loadForm(),this.loadedForm=!0)},registered||(ModalRegistry.register(ModalAddRandomQuestion.TYPE,ModalAddRandomQuestion,"mod_quiz/modal_add_random_question"),registered=!0),ModalAddRandomQuestion}));
+define("mod_quiz/modal_add_random_question",["exports","jquery","core/modal","core/notification","core/fragment","core/templates","core_form/changechecker"],(function(_exports,_jquery,_modal,Notification,Fragment,Templates,FormChangeChecker){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),_modal=_interopRequireDefault(_modal),Notification=_interopRequireWildcard(Notification),Fragment=_interopRequireWildcard(Fragment),Templates=_interopRequireWildcard(Templates),FormChangeChecker=_interopRequireWildcard(FormChangeChecker);const SELECTORS_EXISTING_CATEGORY_CONTAINER='[data-region="existing-category-container"]',SELECTORS_EXISTING_CATEGORY_FORM_ELEMENT="#id_existingcategoryheader",SELECTORS_NEW_CATEGORY_CONTAINER='[data-region="new-category-container"]',SELECTORS_NEW_CATEGORY_FORM_ELEMENT="#id_newcategoryheader",SELECTORS_TAB_CONTENT='[data-region="tab-content"]',SELECTORS_ADD_ON_PAGE_FORM_ELEMENT='[name="addonpage"]',SELECTORS_SUBMIT_BUTTON_ELEMENT='input[type="submit"]',SELECTORS_CANCEL_BUTTON_ELEMENT='input[type="submit"][name="cancel"]',SELECTORS_FORM_HEADER="legend",SELECTORS_BUTTON_CONTAINER=".fitem";class ModalAddRandomQuestion extends _modal.default{constructor(root){super(root),this.contextId=null,this.addOnPageId=null,this.category=null,this.returnUrl=null,this.cmid=null,this.loadedForm=!1}setContextId(id){this.contextId=id}getContextId(){return this.contextId}setAddOnPageId(id){this.addOnPageId=id,this.getBody().find(SELECTORS_ADD_ON_PAGE_FORM_ELEMENT).val(id)}getAddOnPageId(){return this.addOnPageId}setCategory(category){this.category=category}getCategory(){return this.category}setReturnUrl(url){this.returnUrl=url}getReturnUrl(){return this.returnUrl}setCMID(id){this.cmid=id}getCMID(){return this.cmid}moveFormElementIntoTab(formElement,tabElement){const submitButtons=formElement.find(SELECTORS_SUBMIT_BUTTON_ELEMENT),footer=(0,_jquery.default)('');formElement.find(SELECTORS_FORM_HEADER).addClass("hidden"),formElement.wrap(tabElement),submitButtons.closest(SELECTORS_BUTTON_CONTAINER).remove(),submitButtons.appendTo(footer),footer.appendTo(formElement)}moveTabsIntoTabContent(form){const tabContent=this.getBody().find(SELECTORS_TAB_CONTENT).empty();form.find('[role="tabpanel"]').wrapAll(tabContent)}moveCancelButtonToTabs(form){const cancelButton=form.find(SELECTORS_CANCEL_BUTTON_ELEMENT).addClass("ml-1"),tabFooters=form.find('[data-region="footer"]');cancelButton.closest(SELECTORS_BUTTON_CONTAINER).remove(),cancelButton.clone().appendTo(tabFooters)}loadForm(){return Fragment.loadFragment("mod_quiz","add_random_question_form",this.getContextId(),{addonpage:this.getAddOnPageId(),cat:this.getCategory(),returnurl:this.getReturnUrl(),cmid:this.getCMID()}).then(((html,js)=>{const form=(0,_jquery.default)(html),existingCategoryFormElement=form.find(SELECTORS_EXISTING_CATEGORY_FORM_ELEMENT),existingCategoryTab=this.getBody().find(SELECTORS_EXISTING_CATEGORY_CONTAINER),newCategoryFormElement=form.find(SELECTORS_NEW_CATEGORY_FORM_ELEMENT),newCategoryTab=this.getBody().find(SELECTORS_NEW_CATEGORY_CONTAINER);this.moveFormElementIntoTab(existingCategoryFormElement,existingCategoryTab),this.moveFormElementIntoTab(newCategoryFormElement,newCategoryTab),this.moveTabsIntoTabContent(form),this.moveCancelButtonToTabs(form),Templates.replaceNode(this.getBody().find(SELECTORS_TAB_CONTENT),form,js)})).then((()=>{FormChangeChecker.disableAllChecks()})).catch(Notification.exception)}show(){super.show(this),this.loadedForm||(this.loadForm(),this.loadedForm=!0)}}return _exports.default=ModalAddRandomQuestion,_defineProperty(ModalAddRandomQuestion,"TYPE","mod_quiz-quiz-add-random-question"),_defineProperty(ModalAddRandomQuestion,"TEMPLATE","mod_quiz/modal_add_random_question"),ModalAddRandomQuestion.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_add_random_question.min.js.map
\ No newline at end of file
diff --git a/mod/quiz/amd/build/modal_add_random_question.min.js.map b/mod/quiz/amd/build/modal_add_random_question.min.js.map
index 76cd49582e7..728f80bcca9 100644
--- a/mod/quiz/amd/build/modal_add_random_question.min.js.map
+++ b/mod/quiz/amd/build/modal_add_random_question.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_add_random_question.min.js","sources":["../src/modal_add_random_question.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the add random question modal.\n *\n * @module mod_quiz/modal_add_random_question\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/notification',\n 'core/modal',\n 'core/modal_events',\n 'core/modal_registry',\n 'core/fragment',\n 'core/templates',\n 'core_form/changechecker',\n],\nfunction(\n $,\n Notification,\n Modal,\n ModalEvents,\n ModalRegistry,\n Fragment,\n Templates,\n FormChangeChecker,\n) {\n\n var registered = false;\n var SELECTORS = {\n EXISTING_CATEGORY_CONTAINER: '[data-region=\"existing-category-container\"]',\n EXISTING_CATEGORY_FORM_ELEMENT: '#id_existingcategoryheader',\n NEW_CATEGORY_CONTAINER: '[data-region=\"new-category-container\"]',\n NEW_CATEGORY_FORM_ELEMENT: '#id_newcategoryheader',\n TAB_CONTENT: '[data-region=\"tab-content\"]',\n ADD_ON_PAGE_FORM_ELEMENT: '[name=\"addonpage\"]',\n SUBMIT_BUTTON_ELEMENT: 'input[type=\"submit\"]',\n CANCEL_BUTTON_ELEMENT: 'input[type=\"submit\"][name=\"cancel\"]',\n FORM_HEADER: 'legend',\n BUTTON_CONTAINER: '.fitem'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalAddRandomQuestion = function(root) {\n Modal.call(this, root);\n this.contextId = null;\n this.addOnPageId = null;\n this.category = null;\n this.returnUrl = null;\n this.cmid = null;\n this.loadedForm = false;\n };\n\n ModalAddRandomQuestion.TYPE = 'mod_quiz-quiz-add-random-question';\n ModalAddRandomQuestion.prototype = Object.create(Modal.prototype);\n ModalAddRandomQuestion.prototype.constructor = ModalAddRandomQuestion;\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {int} id\n */\n ModalAddRandomQuestion.prototype.setContextId = function(id) {\n this.contextId = id;\n };\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {int}\n */\n ModalAddRandomQuestion.prototype.getContextId = function() {\n return this.contextId;\n };\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {int} id\n */\n ModalAddRandomQuestion.prototype.setAddOnPageId = function(id) {\n this.addOnPageId = id;\n this.getBody().find(SELECTORS.ADD_ON_PAGE_FORM_ELEMENT).val(id);\n };\n\n /**\n * Returns the saved page id for the question to be added to.\n *\n * @method getAddOnPageId\n * @return {int}\n */\n ModalAddRandomQuestion.prototype.getAddOnPageId = function() {\n return this.addOnPageId;\n };\n\n /**\n * Set the category for this form. The category is a comma separated\n * category id and category context id.\n *\n * @method setCategory\n * @param {string} category\n */\n ModalAddRandomQuestion.prototype.setCategory = function(category) {\n this.category = category;\n };\n\n /**\n * Returns the saved category.\n *\n * @method getCategory\n * @return {string}\n */\n ModalAddRandomQuestion.prototype.getCategory = function() {\n return this.category;\n };\n\n /**\n * Set the return URL for the form.\n *\n * @method setReturnUrl\n * @param {string} url\n */\n ModalAddRandomQuestion.prototype.setReturnUrl = function(url) {\n this.returnUrl = url;\n };\n\n /**\n * Returns the return URL for the form.\n *\n * @method getReturnUrl\n * @return {string}\n */\n ModalAddRandomQuestion.prototype.getReturnUrl = function() {\n return this.returnUrl;\n };\n\n /**\n * Set the course module id for the form.\n *\n * @method setCMID\n * @param {int} id\n */\n ModalAddRandomQuestion.prototype.setCMID = function(id) {\n this.cmid = id;\n };\n\n /**\n * Returns the course module id for the form.\n *\n * @method getCMID\n * @return {int}\n */\n ModalAddRandomQuestion.prototype.getCMID = function() {\n return this.cmid;\n };\n\n /**\n * Moves a given form element inside (a child of) a given tab element.\n *\n * Hides the 'legend' (e.g. header) element of the form element because the\n * tab has the name.\n *\n * Moves the submit button into a footer element at the bottom of the form\n * element for styling purposes.\n *\n * @method moveFormElementIntoTab\n * @param {jquery} formElement The form element to move into the tab.\n * @param {jquey} tabElement The tab element for the form element to move into.\n */\n ModalAddRandomQuestion.prototype.moveFormElementIntoTab = function(formElement, tabElement) {\n var submitButtons = formElement.find(SELECTORS.SUBMIT_BUTTON_ELEMENT);\n var footer = $('');\n // Hide the header because the tabs show us which part of the form we're\n // looking at.\n formElement.find(SELECTORS.FORM_HEADER).addClass('hidden');\n // Move the element inside a tab.\n formElement.wrap(tabElement);\n // Remove the buttons container element.\n submitButtons.closest(SELECTORS.BUTTON_CONTAINER).remove();\n // Put the button inside a footer.\n submitButtons.appendTo(footer);\n // Add the footer to the end of the category form element.\n footer.appendTo(formElement);\n };\n\n /**\n * Empty the tab content container and move all tabs from the form into the\n * tab container element.\n *\n * @method moveTabsIntoTabContent\n * @param {jquery} form The form element.\n */\n ModalAddRandomQuestion.prototype.moveTabsIntoTabContent = function(form) {\n // Empty it to remove the loading icon.\n var tabContent = this.getBody().find(SELECTORS.TAB_CONTENT).empty();\n // Make sure all tabs are inside the tab content element.\n form.find('[role=\"tabpanel\"]').wrapAll(tabContent);\n };\n\n /**\n * Make sure all of the tabs have a cancel button in their fotter to sit along\n * side the submit button.\n *\n * @method moveCancelButtonToTabs\n * @param {jquey} form The form element.\n */\n ModalAddRandomQuestion.prototype.moveCancelButtonToTabs = function(form) {\n var cancelButton = form.find(SELECTORS.CANCEL_BUTTON_ELEMENT).addClass('ml-1');\n var tabFooters = form.find('[data-region=\"footer\"]');\n // Remove the buttons container element.\n cancelButton.closest(SELECTORS.BUTTON_CONTAINER).remove();\n cancelButton.clone().appendTo(tabFooters);\n };\n\n /**\n * Load the add random question form in a fragement and perform some transformation\n * on the HTML to convert it into tabs for rendering in the modal.\n *\n * @method loadForm\n * @return {promise} Resolved with form HTML and JS.\n */\n ModalAddRandomQuestion.prototype.loadForm = function() {\n return Fragment.loadFragment(\n 'mod_quiz',\n 'add_random_question_form',\n this.getContextId(),\n {\n addonpage: this.getAddOnPageId(),\n cat: this.getCategory(),\n returnurl: this.getReturnUrl(),\n cmid: this.getCMID()\n }\n )\n .then(function(html, js) {\n var form = $(html);\n var existingCategoryFormElement = form.find(SELECTORS.EXISTING_CATEGORY_FORM_ELEMENT);\n var existingCategoryTab = this.getBody().find(SELECTORS.EXISTING_CATEGORY_CONTAINER);\n var newCategoryFormElement = form.find(SELECTORS.NEW_CATEGORY_FORM_ELEMENT);\n var newCategoryTab = this.getBody().find(SELECTORS.NEW_CATEGORY_CONTAINER);\n\n // Transform the form into tabs for better rendering in the modal.\n this.moveFormElementIntoTab(existingCategoryFormElement, existingCategoryTab);\n this.moveFormElementIntoTab(newCategoryFormElement, newCategoryTab);\n this.moveTabsIntoTabContent(form);\n this.moveCancelButtonToTabs(form);\n\n Templates.replaceNode(this.getBody().find(SELECTORS.TAB_CONTENT), form, js);\n return;\n }.bind(this))\n .then(function() {\n // Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the\n // page once the modal is hidden.\n FormChangeChecker.disableAllChecks();\n return;\n })\n .fail(Notification.exception);\n };\n\n /**\n * Override the modal show function to load the form when this modal is first\n * shown.\n *\n * @method show\n */\n ModalAddRandomQuestion.prototype.show = function() {\n Modal.prototype.show.call(this);\n\n if (!this.loadedForm) {\n this.loadForm();\n this.loadedForm = true;\n }\n };\n\n // Automatically register with the modal registry the first time this module is\n // imported so that you can create modals of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(\n ModalAddRandomQuestion.TYPE,\n ModalAddRandomQuestion,\n 'mod_quiz/modal_add_random_question'\n );\n\n registered = true;\n }\n\n return ModalAddRandomQuestion;\n});\n"],"names":["define","$","Notification","Modal","ModalEvents","ModalRegistry","Fragment","Templates","FormChangeChecker","registered","SELECTORS","ModalAddRandomQuestion","root","call","this","contextId","addOnPageId","category","returnUrl","cmid","loadedForm","TYPE","prototype","Object","create","constructor","setContextId","id","getContextId","setAddOnPageId","getBody","find","val","getAddOnPageId","setCategory","getCategory","setReturnUrl","url","getReturnUrl","setCMID","getCMID","moveFormElementIntoTab","formElement","tabElement","submitButtons","footer","addClass","wrap","closest","remove","appendTo","moveTabsIntoTabContent","form","tabContent","empty","wrapAll","moveCancelButtonToTabs","cancelButton","tabFooters","clone","loadForm","loadFragment","addonpage","cat","returnurl","then","html","js","existingCategoryFormElement","existingCategoryTab","newCategoryFormElement","newCategoryTab","replaceNode","bind","disableAllChecks","fail","exception","show","register"],"mappings":"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"}
\ No newline at end of file
+{"version":3,"file":"modal_add_random_question.min.js","sources":["../src/modal_add_random_question.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the add random question modal.\n *\n * @module mod_quiz/modal_add_random_question\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Modal from 'core/modal';\nimport * as Notification from 'core/notification';\nimport * as Fragment from 'core/fragment';\nimport * as Templates from 'core/templates';\nimport * as FormChangeChecker from 'core_form/changechecker';\n\nconst SELECTORS = {\n EXISTING_CATEGORY_CONTAINER: '[data-region=\"existing-category-container\"]',\n EXISTING_CATEGORY_FORM_ELEMENT: '#id_existingcategoryheader',\n NEW_CATEGORY_CONTAINER: '[data-region=\"new-category-container\"]',\n NEW_CATEGORY_FORM_ELEMENT: '#id_newcategoryheader',\n TAB_CONTENT: '[data-region=\"tab-content\"]',\n ADD_ON_PAGE_FORM_ELEMENT: '[name=\"addonpage\"]',\n SUBMIT_BUTTON_ELEMENT: 'input[type=\"submit\"]',\n CANCEL_BUTTON_ELEMENT: 'input[type=\"submit\"][name=\"cancel\"]',\n FORM_HEADER: 'legend',\n BUTTON_CONTAINER: '.fitem',\n};\n\nexport default class ModalAddRandomQuestion extends Modal {\n static TYPE = 'mod_quiz-quiz-add-random-question';\n static TEMPLATE = 'mod_quiz/modal_add_random_question';\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n constructor(root) {\n super(root);\n this.contextId = null;\n this.addOnPageId = null;\n this.category = null;\n this.returnUrl = null;\n this.cmid = null;\n this.loadedForm = false;\n }\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {int} id\n */\n setContextId(id) {\n this.contextId = id;\n }\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {int}\n */\n getContextId() {\n return this.contextId;\n }\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {int} id\n */\n setAddOnPageId(id) {\n this.addOnPageId = id;\n this.getBody().find(SELECTORS.ADD_ON_PAGE_FORM_ELEMENT).val(id);\n }\n\n /**\n * Returns the saved page id for the question to be added to.\n *\n * @method getAddOnPageId\n * @return {int}\n */\n getAddOnPageId() {\n return this.addOnPageId;\n }\n\n /**\n * Set the category for this form. The category is a comma separated\n * category id and category context id.\n *\n * @method setCategory\n * @param {string} category\n */\n setCategory(category) {\n this.category = category;\n }\n\n /**\n * Returns the saved category.\n *\n * @method getCategory\n * @return {string}\n */\n getCategory() {\n return this.category;\n }\n\n /**\n * Set the return URL for the form.\n *\n * @method setReturnUrl\n * @param {string} url\n */\n setReturnUrl(url) {\n this.returnUrl = url;\n }\n\n /**\n * Returns the return URL for the form.\n *\n * @method getReturnUrl\n * @return {string}\n */\n getReturnUrl() {\n return this.returnUrl;\n }\n\n /**\n * Set the course module id for the form.\n *\n * @method setCMID\n * @param {int} id\n */\n setCMID(id) {\n this.cmid = id;\n }\n\n /**\n * Returns the course module id for the form.\n *\n * @method getCMID\n * @return {int}\n */\n getCMID() {\n return this.cmid;\n }\n\n /**\n * Moves a given form element inside (a child of) a given tab element.\n *\n * Hides the 'legend' (e.g. header) element of the form element because the\n * tab has the name.\n *\n * Moves the submit button into a footer element at the bottom of the form\n * element for styling purposes.\n *\n * @method moveFormElementIntoTab\n * @param {jquery} formElement The form element to move into the tab.\n * @param {jquey} tabElement The tab element for the form element to move into.\n */\n moveFormElementIntoTab(formElement, tabElement) {\n const submitButtons = formElement.find(SELECTORS.SUBMIT_BUTTON_ELEMENT);\n const footer = $('');\n // Hide the header because the tabs show us which part of the form we're\n // looking at.\n formElement.find(SELECTORS.FORM_HEADER).addClass('hidden');\n // Move the element inside a tab.\n formElement.wrap(tabElement);\n // Remove the buttons container element.\n submitButtons.closest(SELECTORS.BUTTON_CONTAINER).remove();\n // Put the button inside a footer.\n submitButtons.appendTo(footer);\n // Add the footer to the end of the category form element.\n footer.appendTo(formElement);\n }\n\n /**\n * Empty the tab content container and move all tabs from the form into the\n * tab container element.\n *\n * @method moveTabsIntoTabContent\n * @param {jquery} form The form element.\n */\n moveTabsIntoTabContent(form) {\n // Empty it to remove the loading icon.\n const tabContent = this.getBody().find(SELECTORS.TAB_CONTENT).empty();\n // Make sure all tabs are inside the tab content element.\n form.find('[role=\"tabpanel\"]').wrapAll(tabContent);\n }\n\n /**\n * Make sure all of the tabs have a cancel button in their fotter to sit along\n * side the submit button.\n *\n * @method moveCancelButtonToTabs\n * @param {jquey} form The form element.\n */\n moveCancelButtonToTabs(form) {\n const cancelButton = form.find(SELECTORS.CANCEL_BUTTON_ELEMENT).addClass('ml-1');\n const tabFooters = form.find('[data-region=\"footer\"]');\n // Remove the buttons container element.\n cancelButton.closest(SELECTORS.BUTTON_CONTAINER).remove();\n cancelButton.clone().appendTo(tabFooters);\n }\n\n /**\n * Load the add random question form in a fragement and perform some transformation\n * on the HTML to convert it into tabs for rendering in the modal.\n *\n * @method loadForm\n * @return {promise} Resolved with form HTML and JS.\n */\n loadForm() {\n return Fragment.loadFragment(\n 'mod_quiz',\n 'add_random_question_form',\n this.getContextId(),\n {\n addonpage: this.getAddOnPageId(),\n cat: this.getCategory(),\n returnurl: this.getReturnUrl(),\n cmid: this.getCMID()\n }\n )\n .then((html, js) =>{\n const form = $(html);\n const existingCategoryFormElement = form.find(SELECTORS.EXISTING_CATEGORY_FORM_ELEMENT);\n const existingCategoryTab = this.getBody().find(SELECTORS.EXISTING_CATEGORY_CONTAINER);\n const newCategoryFormElement = form.find(SELECTORS.NEW_CATEGORY_FORM_ELEMENT);\n const newCategoryTab = this.getBody().find(SELECTORS.NEW_CATEGORY_CONTAINER);\n\n // Transform the form into tabs for better rendering in the modal.\n this.moveFormElementIntoTab(existingCategoryFormElement, existingCategoryTab);\n this.moveFormElementIntoTab(newCategoryFormElement, newCategoryTab);\n this.moveTabsIntoTabContent(form);\n this.moveCancelButtonToTabs(form);\n\n Templates.replaceNode(this.getBody().find(SELECTORS.TAB_CONTENT), form, js);\n return;\n })\n .then(() => {\n // Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the\n // page once the modal is hidden.\n FormChangeChecker.disableAllChecks();\n return;\n })\n .catch(Notification.exception);\n }\n\n /**\n * Override the modal show function to load the form when this modal is first\n * shown.\n *\n * @method show\n */\n show() {\n super.show(this);\n\n if (!this.loadedForm) {\n this.loadForm();\n this.loadedForm = true;\n }\n }\n}\n\nModalAddRandomQuestion.registerModalType();\n"],"names":["SELECTORS","ModalAddRandomQuestion","Modal","constructor","root","contextId","addOnPageId","category","returnUrl","cmid","loadedForm","setContextId","id","getContextId","this","setAddOnPageId","getBody","find","val","getAddOnPageId","setCategory","getCategory","setReturnUrl","url","getReturnUrl","setCMID","getCMID","moveFormElementIntoTab","formElement","tabElement","submitButtons","footer","addClass","wrap","closest","remove","appendTo","moveTabsIntoTabContent","form","tabContent","empty","wrapAll","moveCancelButtonToTabs","cancelButton","tabFooters","clone","loadForm","Fragment","loadFragment","addonpage","cat","returnurl","then","html","js","existingCategoryFormElement","existingCategoryTab","newCategoryFormElement","newCategoryTab","Templates","replaceNode","FormChangeChecker","disableAllChecks","catch","Notification","exception","show","registerModalType"],"mappings":"2wDA8BMA,sCAC2B,8CAD3BA,yCAE8B,6BAF9BA,iCAGsB,yCAHtBA,oCAIyB,wBAJzBA,sBAKW,8BALXA,mCAMwB,qBANxBA,gCAOqB,uBAPrBA,gCAQqB,sCARrBA,sBASW,SATXA,2BAUgB,eAGDC,+BAA+BC,eAShDC,YAAYC,YACFA,WACDC,UAAY,UACZC,YAAc,UACdC,SAAW,UACXC,UAAY,UACZC,KAAO,UACPC,YAAa,EAUtBC,aAAaC,SACJP,UAAYO,GASrBC,sBACWC,KAAKT,UAUhBU,eAAeH,SACNN,YAAcM,QACdI,UAAUC,KAAKjB,oCAAoCkB,IAAIN,IAShEO,wBACWL,KAAKR,YAUhBc,YAAYb,eACHA,SAAWA,SASpBc,qBACWP,KAAKP,SAShBe,aAAaC,UACJf,UAAYe,IASrBC,sBACWV,KAAKN,UAShBiB,QAAQb,SACCH,KAAOG,GAShBc,iBACWZ,KAAKL,KAgBhBkB,uBAAuBC,YAAaC,kBAC1BC,cAAgBF,YAAYX,KAAKjB,iCACjC+B,QAAS,mBAAE,8DAGjBH,YAAYX,KAAKjB,uBAAuBgC,SAAS,UAEjDJ,YAAYK,KAAKJ,YAEjBC,cAAcI,QAAQlC,4BAA4BmC,SAElDL,cAAcM,SAASL,QAEvBA,OAAOK,SAASR,aAUpBS,uBAAuBC,YAEbC,WAAazB,KAAKE,UAAUC,KAAKjB,uBAAuBwC,QAE9DF,KAAKrB,KAAK,qBAAqBwB,QAAQF,YAU3CG,uBAAuBJ,YACbK,aAAeL,KAAKrB,KAAKjB,iCAAiCgC,SAAS,QACnEY,WAAaN,KAAKrB,KAAK,0BAE7B0B,aAAaT,QAAQlC,4BAA4BmC,SACjDQ,aAAaE,QAAQT,SAASQ,YAUlCE,kBACWC,SAASC,aACZ,WACA,2BACAlC,KAAKD,eACL,CACIoC,UAAWnC,KAAKK,iBAChB+B,IAAKpC,KAAKO,cACV8B,UAAWrC,KAAKU,eAChBf,KAAMK,KAAKY,YAGlB0B,MAAK,CAACC,KAAMC,YACHhB,MAAO,mBAAEe,MACTE,4BAA8BjB,KAAKrB,KAAKjB,0CACxCwD,oBAAsB1C,KAAKE,UAAUC,KAAKjB,uCAC1CyD,uBAAyBnB,KAAKrB,KAAKjB,qCACnC0D,eAAiB5C,KAAKE,UAAUC,KAAKjB,uCAGtC2B,uBAAuB4B,4BAA6BC,0BACpD7B,uBAAuB8B,uBAAwBC,qBAC/CrB,uBAAuBC,WACvBI,uBAAuBJ,MAE5BqB,UAAUC,YAAY9C,KAAKE,UAAUC,KAAKjB,uBAAwBsC,KAAMgB,OAG3EF,MAAK,KAGFS,kBAAkBC,sBAGrBC,MAAMC,aAAaC,WASxBC,aACUA,KAAKpD,MAENA,KAAKJ,kBACDoC,gBACApC,YAAa,mEA5OTT,8BACH,qDADGA,kCAEC,sCA+OtBA,uBAAuBkE"}
\ No newline at end of file
diff --git a/mod/quiz/amd/build/modal_quiz_question_bank.min.js b/mod/quiz/amd/build/modal_quiz_question_bank.min.js
index f77374364c3..9b8b9a7c194 100644
--- a/mod/quiz/amd/build/modal_quiz_question_bank.min.js
+++ b/mod/quiz/amd/build/modal_quiz_question_bank.min.js
@@ -1,10 +1,3 @@
-/**
- * Contain the logic for the question bank modal.
- *
- * @module mod_quiz/modal_quiz_question_bank
- * @copyright 2018 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define("mod_quiz/modal_quiz_question_bank",["jquery","core/notification","core/modal","core/modal_events","core/modal_registry","core/fragment","core_form/changechecker"],(function($,Notification,Modal,ModalEvents,ModalRegistry,Fragment,FormChangeChecker){var registered=!1,SELECTORS_ADD_TO_QUIZ_CONTAINER="td.addtoquizaction",SELECTORS_ANCHOR="a[href]",SELECTORS_PREVIEW_CONTAINER="td.previewaction",SELECTORS_SEARCH_OPTIONS="#advancedsearch",SELECTORS_DISPLAY_OPTIONS="#displayoptions",SELECTORS_ADD_QUESTIONS_FORM="form#questionsubmit",ModalQuizQuestionBank=function(root){Modal.call(this,root),this.contextId=null,this.addOnPageId=null};return ModalQuizQuestionBank.TYPE="mod_quiz-quiz-question-bank",(ModalQuizQuestionBank.prototype=Object.create(Modal.prototype)).constructor=ModalQuizQuestionBank,ModalQuizQuestionBank.prototype.setContextId=function(id){this.contextId=id},ModalQuizQuestionBank.prototype.getContextId=function(){return this.contextId},ModalQuizQuestionBank.prototype.setAddOnPageId=function(id){this.addOnPageId=id},ModalQuizQuestionBank.prototype.getAddOnPageId=function(){return this.addOnPageId},ModalQuizQuestionBank.prototype.show=function(){return this.reloadBodyContent(window.location.search),Modal.prototype.show.call(this)},ModalQuizQuestionBank.prototype.reloadBodyContent=function(queryString){var promise=Fragment.loadFragment("mod_quiz","quiz_question_bank",this.getContextId(),{querystring:queryString}).fail(Notification.exception);this.setBody(promise)},ModalQuizQuestionBank.prototype.handleAddToQuizEvent=function(e,anchorElement){var href=anchorElement.attr("href")+"&addonpage="+this.getAddOnPageId();anchorElement.attr("href",href)},ModalQuizQuestionBank.prototype.handlePreviewContainerEvent=function(e,anchorElement){window.openpopup(e,{url:anchorElement.attr("href"),name:"questionpreview",options:["height=600","width=800","top=0","left=0","menubar=0","location=0","scrollbars","resizable","toolbar","status","directories=0","fullscreen=0","dependent"].join(",")})},ModalQuizQuestionBank.prototype.handleDisplayOptionFormEvent=function(e){e.stopPropagation(),e.preventDefault();var queryString="?"+$(e.target).closest(SELECTORS_DISPLAY_OPTIONS).serialize();this.reloadBodyContent(queryString)},ModalQuizQuestionBank.prototype.registerDisplayOptionListeners=function(){this.getModal().on("change",SELECTORS_DISPLAY_OPTIONS,function(e){$(e.target).attr("aria-autocomplete")||this.handleDisplayOptionFormEvent(e)}.bind(this)),this.getModal().on("submit",SELECTORS_DISPLAY_OPTIONS,function(e){this.handleDisplayOptionFormEvent(e)}.bind(this))},ModalQuizQuestionBank.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this),this.registerDisplayOptionListeners(),this.getModal().on("submit",SELECTORS_ADD_QUESTIONS_FORM,function(e){var formElement=$(e.currentTarget);$("").attr("type","hidden").attr("name","addonpage").attr("value",this.getAddOnPageId()).appendTo(formElement)}.bind(this)),this.getModal().on("click",SELECTORS_ANCHOR,function(e){var anchorElement=$(e.currentTarget);anchorElement.closest(SELECTORS_ADD_TO_QUIZ_CONTAINER).length?this.handleAddToQuizEvent(e,anchorElement):anchorElement.closest(SELECTORS_PREVIEW_CONTAINER).length?this.handlePreviewContainerEvent(e,anchorElement):anchorElement.closest(SELECTORS_SEARCH_OPTIONS).length||(e.preventDefault(),this.reloadBodyContent(anchorElement.prop("search")))}.bind(this)),this.getRoot().on(ModalEvents.bodyRendered,(function(){FormChangeChecker.disableAllChecks()}))},registered||(ModalRegistry.register(ModalQuizQuestionBank.TYPE,ModalQuizQuestionBank,"core/modal"),registered=!0),ModalQuizQuestionBank}));
+define("mod_quiz/modal_quiz_question_bank",["exports","jquery","core/modal","core/fragment","core_form/changechecker","core/modal_events"],(function(_exports,_jquery,_modal,Fragment,FormChangeChecker,ModalEvents){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),_modal=_interopRequireDefault(_modal),Fragment=_interopRequireWildcard(Fragment),FormChangeChecker=_interopRequireWildcard(FormChangeChecker),ModalEvents=_interopRequireWildcard(ModalEvents);const SELECTORS_ADD_TO_QUIZ_CONTAINER="td.addtoquizaction",SELECTORS_ANCHOR="a[href]",SELECTORS_PREVIEW_CONTAINER="td.previewaction",SELECTORS_SEARCH_OPTIONS="#advancedsearch",SELECTORS_DISPLAY_OPTIONS="#displayoptions",SELECTORS_ADD_QUESTIONS_FORM="form#questionsubmit";class ModalQuizQuestionBank extends _modal.default{constructor(root){super(root),this.contextId=null,this.addOnPageId=null}setContextId(id){this.contextId=id}getContextId(){return this.contextId}setAddOnPageId(id){this.addOnPageId=id}getAddOnPageId(){return this.addOnPageId}show(){return this.reloadBodyContent(window.location.search),super.show(this)}reloadBodyContent(querystring){this.setBody(Fragment.loadFragment("mod_quiz","quiz_question_bank",this.getContextId(),{querystring:querystring}))}handleAddToQuizEvent(e,anchorElement){const href=new URL(anchorElement.attr("href"));href.searchParams.set("addonpage",this.getAddOnPageId()),anchorElement.attr("href",href)}handlePreviewContainerEvent(e,anchorElement){window.openpopup(e,{url:anchorElement.attr("href"),name:"questionpreview",options:["height=600","width=800","top=0","left=0","menubar=0","location=0","scrollbars","resizable","toolbar","status","directories=0","fullscreen=0","dependent"].join(",")})}handleDisplayOptionFormEvent(e){e.stopPropagation(),e.preventDefault();const queryString="?"+(0,_jquery.default)(e.target).closest(SELECTORS_DISPLAY_OPTIONS).serialize();this.reloadBodyContent(queryString)}registerDisplayOptionListeners(){this.getModal().on("change",SELECTORS_DISPLAY_OPTIONS,(e=>{(0,_jquery.default)(e.target).attr("aria-autocomplete")||this.handleDisplayOptionFormEvent(e)})),this.getModal().on("submit",SELECTORS_DISPLAY_OPTIONS,(e=>{this.handleDisplayOptionFormEvent(e)}))}registerEventListeners(){super.registerEventListeners(this),this.registerDisplayOptionListeners(),this.getModal().on("submit",SELECTORS_ADD_QUESTIONS_FORM,(e=>{const formElement=(0,_jquery.default)(e.currentTarget);(0,_jquery.default)("").attr("type","hidden").attr("name","addonpage").attr("value",this.getAddOnPageId()).appendTo(formElement)})),this.getModal().on("click",SELECTORS_ANCHOR,(e=>{const anchorElement=(0,_jquery.default)(e.currentTarget);anchorElement.closest(SELECTORS_ADD_TO_QUIZ_CONTAINER).length?this.handleAddToQuizEvent(e,anchorElement):anchorElement.closest(SELECTORS_PREVIEW_CONTAINER).length?this.handlePreviewContainerEvent(e,anchorElement):anchorElement.closest(SELECTORS_SEARCH_OPTIONS).length||(e.preventDefault(),this.reloadBodyContent(anchorElement.prop("search")))})),this.getRoot().on(ModalEvents.bodyRendered,(()=>{FormChangeChecker.disableAllChecks()}))}}var obj,key,value;return _exports.default=ModalQuizQuestionBank,value="mod_quiz-quiz-question-bank",(key="TYPE")in(obj=ModalQuizQuestionBank)?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,ModalQuizQuestionBank.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_quiz_question_bank.min.js.map
\ No newline at end of file
diff --git a/mod/quiz/amd/build/modal_quiz_question_bank.min.js.map b/mod/quiz/amd/build/modal_quiz_question_bank.min.js.map
index 2ae7e9c9a47..46f0ef7bff8 100644
--- a/mod/quiz/amd/build/modal_quiz_question_bank.min.js.map
+++ b/mod/quiz/amd/build/modal_quiz_question_bank.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_quiz_question_bank.min.js","sources":["../src/modal_quiz_question_bank.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the question bank modal.\n *\n * @module mod_quiz/modal_quiz_question_bank\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/notification',\n 'core/modal',\n 'core/modal_events',\n 'core/modal_registry',\n 'core/fragment',\n 'core_form/changechecker',\n],\nfunction(\n $,\n Notification,\n Modal,\n ModalEvents,\n ModalRegistry,\n Fragment,\n FormChangeChecker,\n) {\n\n var registered = false;\n var SELECTORS = {\n ADD_TO_QUIZ_CONTAINER: 'td.addtoquizaction',\n ANCHOR: 'a[href]',\n PREVIEW_CONTAINER: 'td.previewaction',\n SEARCH_OPTIONS: '#advancedsearch',\n DISPLAY_OPTIONS: '#displayoptions',\n ADD_QUESTIONS_FORM: 'form#questionsubmit',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalQuizQuestionBank = function(root) {\n Modal.call(this, root);\n\n this.contextId = null;\n this.addOnPageId = null;\n };\n\n ModalQuizQuestionBank.TYPE = 'mod_quiz-quiz-question-bank';\n ModalQuizQuestionBank.prototype = Object.create(Modal.prototype);\n ModalQuizQuestionBank.prototype.constructor = ModalQuizQuestionBank;\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {int} id\n */\n ModalQuizQuestionBank.prototype.setContextId = function(id) {\n this.contextId = id;\n };\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {int}\n */\n ModalQuizQuestionBank.prototype.getContextId = function() {\n return this.contextId;\n };\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {int} id\n */\n ModalQuizQuestionBank.prototype.setAddOnPageId = function(id) {\n this.addOnPageId = id;\n };\n\n /**\n * Returns the saved page id for the question to be added it.\n *\n * @method getAddOnPageId\n * @return {int}\n */\n ModalQuizQuestionBank.prototype.getAddOnPageId = function() {\n return this.addOnPageId;\n };\n\n /**\n * Override the parent show function.\n *\n * Reload the body contents when the modal is shown. The current\n * window URL is used to inform the new content that should be\n * displayed.\n *\n * @method show\n * @return {void}\n */\n ModalQuizQuestionBank.prototype.show = function() {\n this.reloadBodyContent(window.location.search);\n return Modal.prototype.show.call(this);\n };\n\n /**\n * Replaces the current body contents with a new version of the question\n * bank.\n *\n * The contents of the question bank are generated using the provided\n * query string.\n *\n * @method reloadBodyContent\n * @param {string} queryString URL encoded string.\n */\n ModalQuizQuestionBank.prototype.reloadBodyContent = function(queryString) {\n // Load the question bank fragment to be displayed in the modal.\n var promise = Fragment.loadFragment(\n 'mod_quiz',\n 'quiz_question_bank',\n this.getContextId(),\n {\n querystring: queryString\n }\n ).fail(Notification.exception);\n\n this.setBody(promise);\n };\n\n /**\n * Update the URL of the anchor element that the user clicked on to make\n * sure that the question is added to the correct page.\n *\n * @method handleAddToQuizEvent\n * @param {event} e A JavaScript event\n * @param {object} anchorElement The anchor element that was triggered\n */\n ModalQuizQuestionBank.prototype.handleAddToQuizEvent = function(e, anchorElement) {\n // If the user clicks the plus icon to add the question to the page\n // directly then we need to intercept the click in order to adjust the\n // href and include the correct add on page id before the page is\n // redirected.\n var href = anchorElement.attr('href') + '&addonpage=' + this.getAddOnPageId();\n anchorElement.attr('href', href);\n };\n\n /**\n * Open a popup window to show the preview of the question.\n *\n * @method handlePreviewContainerEvent\n * @param {event} e A JavaScript event\n * @param {object} anchorElement The anchor element that was triggered\n */\n ModalQuizQuestionBank.prototype.handlePreviewContainerEvent = function(e, anchorElement) {\n var popupOptions = [\n 'height=600',\n 'width=800',\n 'top=0',\n 'left=0',\n 'menubar=0',\n 'location=0',\n 'scrollbars',\n 'resizable',\n 'toolbar',\n 'status',\n 'directories=0',\n 'fullscreen=0',\n 'dependent'\n ];\n window.openpopup(e, {\n url: anchorElement.attr('href'),\n name: 'questionpreview',\n options: popupOptions.join(',')\n });\n };\n\n /**\n * Reload the modal body with the new display options the user has selected.\n *\n * A query string is built using the form elements to be used to generate the\n * new body content.\n *\n * @method handleDisplayOptionFormEvent\n * @param {event} e A JavaScript event\n */\n ModalQuizQuestionBank.prototype.handleDisplayOptionFormEvent = function(e) {\n // Stop propagation to prevent other wild event handlers\n // from submitting the form on change.\n e.stopPropagation();\n e.preventDefault();\n\n var form = $(e.target).closest(SELECTORS.DISPLAY_OPTIONS);\n var queryString = '?' + form.serialize();\n this.reloadBodyContent(queryString);\n };\n\n /**\n * Listen for changes to the display options form.\n *\n * This handles the user changing:\n * - The quiz category select box\n * - The tags to filter by\n * - Show/hide questions from sub categories\n * - Show/hide old questions\n *\n * @method registerDisplayOptionListeners\n */\n ModalQuizQuestionBank.prototype.registerDisplayOptionListeners = function() {\n // Listen for changes to the display options form.\n this.getModal().on('change', SELECTORS.DISPLAY_OPTIONS, function(e) {\n // Get the element that was changed.\n var modifiedElement = $(e.target);\n if (modifiedElement.attr('aria-autocomplete')) {\n // If the element that was change is the autocomplete\n // input then we should ignore it because that is for\n // display purposes only.\n return;\n }\n\n this.handleDisplayOptionFormEvent(e);\n }.bind(this));\n\n // Listen for the display options form submission because the tags\n // filter will submit the form when it is changed.\n this.getModal().on('submit', SELECTORS.DISPLAY_OPTIONS, function(e) {\n this.handleDisplayOptionFormEvent(e);\n }.bind(this));\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalQuizQuestionBank.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // Set up the event handlers for all of the display options.\n this.registerDisplayOptionListeners();\n\n this.getModal().on('submit', SELECTORS.ADD_QUESTIONS_FORM, function(e) {\n // If the user clicks on the \"Add selected questions to the quiz\" button to add some questions to the page\n // then we need to intercept the submit in order to include the correct \"add on page id\" before the form is\n // submitted.\n var formElement = $(e.currentTarget);\n\n $('').attr('type', 'hidden')\n .attr('name', \"addonpage\")\n .attr('value', this.getAddOnPageId())\n .appendTo(formElement);\n }.bind(this));\n\n this.getModal().on('click', SELECTORS.ANCHOR, function(e) {\n var anchorElement = $(e.currentTarget);\n\n // If the anchor element was the add to quiz link.\n if (anchorElement.closest(SELECTORS.ADD_TO_QUIZ_CONTAINER).length) {\n this.handleAddToQuizEvent(e, anchorElement);\n return;\n }\n\n // If the anchor element was a preview question link.\n if (anchorElement.closest(SELECTORS.PREVIEW_CONTAINER).length) {\n this.handlePreviewContainerEvent(e, anchorElement);\n return;\n }\n\n // Click on expand/collaspse search-options. Has its own handler.\n // We should not interfere.\n if (anchorElement.closest(SELECTORS.SEARCH_OPTIONS).length) {\n return;\n }\n\n // Anything else means reload the pop-up contents.\n e.preventDefault();\n this.reloadBodyContent(anchorElement.prop('search'));\n }.bind(this));\n\n // Disable the form change checker when the body is rendered.\n this.getRoot().on(ModalEvents.bodyRendered, function() {\n // Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the\n // page once the modal is hidden.\n FormChangeChecker.disableAllChecks();\n });\n };\n\n // Automatically register with the modal registry the first time this module is\n // imported so that you can create modals of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(\n ModalQuizQuestionBank.TYPE,\n ModalQuizQuestionBank,\n 'core/modal'\n );\n\n registered = true;\n }\n\n return ModalQuizQuestionBank;\n});\n"],"names":["define","$","Notification","Modal","ModalEvents","ModalRegistry","Fragment","FormChangeChecker","registered","SELECTORS","ModalQuizQuestionBank","root","call","this","contextId","addOnPageId","TYPE","prototype","Object","create","constructor","setContextId","id","getContextId","setAddOnPageId","getAddOnPageId","show","reloadBodyContent","window","location","search","queryString","promise","loadFragment","querystring","fail","exception","setBody","handleAddToQuizEvent","e","anchorElement","href","attr","handlePreviewContainerEvent","openpopup","url","name","options","join","handleDisplayOptionFormEvent","stopPropagation","preventDefault","target","closest","serialize","registerDisplayOptionListeners","getModal","on","bind","registerEventListeners","formElement","currentTarget","appendTo","length","prop","getRoot","bodyRendered","disableAllChecks","register"],"mappings":";;;;;;;AAsBAA,2CAAO,CACH,SACA,oBACA,aACA,oBACA,sBACA,gBACA,4BAEJ,SACIC,EACAC,aACAC,MACAC,YACAC,cACAC,SACAC,uBAGIC,YAAa,EACbC,gCACuB,qBADvBA,iBAEQ,UAFRA,4BAGmB,mBAHnBA,yBAIgB,kBAJhBA,0BAKiB,kBALjBA,6BAMoB,sBAQpBC,sBAAwB,SAASC,MACjCR,MAAMS,KAAKC,KAAMF,WAEZG,UAAY,UACZC,YAAc,aAGvBL,sBAAsBM,KAAO,+BAC7BN,sBAAsBO,UAAYC,OAAOC,OAAOhB,MAAMc,YACtBG,YAAcV,sBAS9CA,sBAAsBO,UAAUI,aAAe,SAASC,SAC/CR,UAAYQ,IASrBZ,sBAAsBO,UAAUM,aAAe,kBACpCV,KAAKC,WAUhBJ,sBAAsBO,UAAUO,eAAiB,SAASF,SACjDP,YAAcO,IASvBZ,sBAAsBO,UAAUQ,eAAiB,kBACtCZ,KAAKE,aAahBL,sBAAsBO,UAAUS,KAAO,uBAC9BC,kBAAkBC,OAAOC,SAASC,QAChC3B,MAAMc,UAAUS,KAAKd,KAAKC,OAarCH,sBAAsBO,UAAUU,kBAAoB,SAASI,iBAErDC,QAAU1B,SAAS2B,aACnB,WACA,qBACApB,KAAKU,eACL,CACIW,YAAaH,cAEnBI,KAAKjC,aAAakC,gBAEfC,QAAQL,UAWjBtB,sBAAsBO,UAAUqB,qBAAuB,SAASC,EAAGC,mBAK3DC,KAAOD,cAAcE,KAAK,QAAU,cAAgB7B,KAAKY,iBAC7De,cAAcE,KAAK,OAAQD,OAU/B/B,sBAAsBO,UAAU0B,4BAA8B,SAASJ,EAAGC,eAgBtEZ,OAAOgB,UAAUL,EAAG,CAChBM,IAAKL,cAAcE,KAAK,QACxBI,KAAM,kBACNC,QAlBe,CACf,aACA,YACA,QACA,SACA,YACA,aACA,aACA,YACA,UACA,SACA,gBACA,eACA,aAKsBC,KAAK,QAanCtC,sBAAsBO,UAAUgC,6BAA+B,SAASV,GAGpEA,EAAEW,kBACFX,EAAEY,qBAGEpB,YAAc,IADP9B,EAAEsC,EAAEa,QAAQC,QAAQ5C,2BACF6C,iBACxB3B,kBAAkBI,cAc3BrB,sBAAsBO,UAAUsC,+BAAiC,gBAExDC,WAAWC,GAAG,SAAUhD,0BAA2B,SAAS8B,GAEvCtC,EAAEsC,EAAEa,QACNV,KAAK,2BAOpBO,6BAA6BV,IACpCmB,KAAK7C,YAIF2C,WAAWC,GAAG,SAAUhD,0BAA2B,SAAS8B,QACxDU,6BAA6BV,IACpCmB,KAAK7C,QAQXH,sBAAsBO,UAAU0C,uBAAyB,WAErDxD,MAAMc,UAAU0C,uBAAuB/C,KAAKC,WAGvC0C,sCAEAC,WAAWC,GAAG,SAAUhD,6BAA8B,SAAS8B,OAI5DqB,YAAc3D,EAAEsC,EAAEsB,eAEtB5D,EAAE,aAAayC,KAAK,OAAQ,UACvBA,KAAK,OAAQ,aACbA,KAAK,QAAS7B,KAAKY,kBACnBqC,SAASF,cAChBF,KAAK7C,YAEF2C,WAAWC,GAAG,QAAShD,iBAAkB,SAAS8B,OAC/CC,cAAgBvC,EAAEsC,EAAEsB,eAGpBrB,cAAca,QAAQ5C,iCAAiCsD,YAClDzB,qBAAqBC,EAAGC,eAK7BA,cAAca,QAAQ5C,6BAA6BsD,YAC9CpB,4BAA4BJ,EAAGC,eAMpCA,cAAca,QAAQ5C,0BAA0BsD,SAKpDxB,EAAEY,sBACGxB,kBAAkBa,cAAcwB,KAAK,aAC5CN,KAAK7C,YAGFoD,UAAUR,GAAGrD,YAAY8D,cAAc,WAGxC3D,kBAAkB4D,uBAMrB3D,aACDH,cAAc+D,SACV1D,sBAAsBM,KACtBN,sBACA,cAGJF,YAAa,GAGVE"}
\ No newline at end of file
+{"version":3,"file":"modal_quiz_question_bank.min.js","sources":["../src/modal_quiz_question_bank.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the question bank modal.\n *\n * @module mod_quiz/modal_quiz_question_bank\n * @copyright 2018 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Modal from 'core/modal';\nimport * as Fragment from 'core/fragment';\nimport * as FormChangeChecker from 'core_form/changechecker';\nimport * as ModalEvents from 'core/modal_events';\n\nconst SELECTORS = {\n ADD_TO_QUIZ_CONTAINER: 'td.addtoquizaction',\n ANCHOR: 'a[href]',\n PREVIEW_CONTAINER: 'td.previewaction',\n SEARCH_OPTIONS: '#advancedsearch',\n DISPLAY_OPTIONS: '#displayoptions',\n ADD_QUESTIONS_FORM: 'form#questionsubmit',\n};\n\nexport default class ModalQuizQuestionBank extends Modal {\n static TYPE = 'mod_quiz-quiz-question-bank';\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n constructor(root) {\n super(root);\n\n this.contextId = null;\n this.addOnPageId = null;\n }\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {int} id\n */\n setContextId(id) {\n this.contextId = id;\n }\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {int}\n */\n getContextId() {\n return this.contextId;\n }\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {int} id\n */\n setAddOnPageId(id) {\n this.addOnPageId = id;\n }\n\n /**\n * Returns the saved page id for the question to be added it.\n *\n * @method getAddOnPageId\n * @return {int}\n */\n getAddOnPageId() {\n return this.addOnPageId;\n }\n\n /**\n * Override the parent show function.\n *\n * Reload the body contents when the modal is shown. The current\n * window URL is used to inform the new content that should be\n * displayed.\n *\n * @method show\n * @return {void}\n */\n show() {\n this.reloadBodyContent(window.location.search);\n return super.show(this);\n }\n\n /**\n * Replaces the current body contents with a new version of the question\n * bank.\n *\n * The contents of the question bank are generated using the provided\n * query string.\n *\n * @method reloadBodyContent\n * @param {string} querystring URL encoded string.\n */\n reloadBodyContent(querystring) {\n // Load the question bank fragment to be displayed in the modal.\n this.setBody(Fragment.loadFragment(\n 'mod_quiz',\n 'quiz_question_bank',\n this.getContextId(),\n {\n querystring,\n }\n ));\n }\n\n /**\n * Update the URL of the anchor element that the user clicked on to make\n * sure that the question is added to the correct page.\n *\n * @method handleAddToQuizEvent\n * @param {event} e A JavaScript event\n * @param {object} anchorElement The anchor element that was triggered\n */\n handleAddToQuizEvent(e, anchorElement) {\n // If the user clicks the plus icon to add the question to the page\n // directly then we need to intercept the click in order to adjust the\n // href and include the correct add on page id before the page is\n // redirected.\n const href = new URL(anchorElement.attr('href'));\n href.searchParams.set('addonpage', this.getAddOnPageId());\n anchorElement.attr('href', href);\n }\n\n /**\n * Open a popup window to show the preview of the question.\n *\n * @method handlePreviewContainerEvent\n * @param {event} e A JavaScript event\n * @param {object} anchorElement The anchor element that was triggered\n */\n handlePreviewContainerEvent(e, anchorElement) {\n const popupOptions = [\n 'height=600',\n 'width=800',\n 'top=0',\n 'left=0',\n 'menubar=0',\n 'location=0',\n 'scrollbars',\n 'resizable',\n 'toolbar',\n 'status',\n 'directories=0',\n 'fullscreen=0',\n 'dependent',\n ];\n window.openpopup(e, {\n url: anchorElement.attr('href'),\n name: 'questionpreview',\n options: popupOptions.join(',')\n });\n }\n\n /**\n * Reload the modal body with the new display options the user has selected.\n *\n * A query string is built using the form elements to be used to generate the\n * new body content.\n *\n * @method handleDisplayOptionFormEvent\n * @param {event} e A JavaScript event\n */\n handleDisplayOptionFormEvent(e) {\n // Stop propagation to prevent other wild event handlers\n // from submitting the form on change.\n e.stopPropagation();\n e.preventDefault();\n\n const form = $(e.target).closest(SELECTORS.DISPLAY_OPTIONS);\n const queryString = '?' + form.serialize();\n this.reloadBodyContent(queryString);\n }\n\n /**\n * Listen for changes to the display options form.\n *\n * This handles the user changing:\n * - The quiz category select box\n * - The tags to filter by\n * - Show/hide questions from sub categories\n * - Show/hide old questions\n *\n * @method registerDisplayOptionListeners\n */\n registerDisplayOptionListeners() {\n // Listen for changes to the display options form.\n this.getModal().on('change', SELECTORS.DISPLAY_OPTIONS, (e) => {\n // Get the element that was changed.\n const modifiedElement = $(e.target);\n if (modifiedElement.attr('aria-autocomplete')) {\n // If the element that was change is the autocomplete\n // input then we should ignore it because that is for\n // display purposes only.\n return;\n }\n\n this.handleDisplayOptionFormEvent(e);\n });\n\n // Listen for the display options form submission because the tags\n // filter will submit the form when it is changed.\n this.getModal().on('submit', SELECTORS.DISPLAY_OPTIONS, (e) => {\n this.handleDisplayOptionFormEvent(e);\n });\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n // Set up the event handlers for all of the display options.\n this.registerDisplayOptionListeners();\n\n this.getModal().on('submit', SELECTORS.ADD_QUESTIONS_FORM, (e) => {\n // If the user clicks on the \"Add selected questions to the quiz\" button to add some questions to the page\n // then we need to intercept the submit in order to include the correct \"add on page id\" before the form is\n // submitted.\n const formElement = $(e.currentTarget);\n\n $('').attr('type', 'hidden')\n .attr('name', \"addonpage\")\n .attr('value', this.getAddOnPageId())\n .appendTo(formElement);\n });\n\n this.getModal().on('click', SELECTORS.ANCHOR, (e) => {\n const anchorElement = $(e.currentTarget);\n\n // If the anchor element was the add to quiz link.\n if (anchorElement.closest(SELECTORS.ADD_TO_QUIZ_CONTAINER).length) {\n this.handleAddToQuizEvent(e, anchorElement);\n return;\n }\n\n // If the anchor element was a preview question link.\n if (anchorElement.closest(SELECTORS.PREVIEW_CONTAINER).length) {\n this.handlePreviewContainerEvent(e, anchorElement);\n return;\n }\n\n // Click on expand/collaspse search-options. Has its own handler.\n // We should not interfere.\n if (anchorElement.closest(SELECTORS.SEARCH_OPTIONS).length) {\n return;\n }\n\n // Anything else means reload the pop-up contents.\n e.preventDefault();\n this.reloadBodyContent(anchorElement.prop('search'));\n });\n\n // Disable the form change checker when the body is rendered.\n this.getRoot().on(ModalEvents.bodyRendered, () => {\n // Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the\n // page once the modal is hidden.\n FormChangeChecker.disableAllChecks();\n });\n }\n}\n\nModalQuizQuestionBank.registerModalType();\n"],"names":["SELECTORS","ModalQuizQuestionBank","Modal","constructor","root","contextId","addOnPageId","setContextId","id","getContextId","this","setAddOnPageId","getAddOnPageId","show","reloadBodyContent","window","location","search","super","querystring","setBody","Fragment","loadFragment","handleAddToQuizEvent","e","anchorElement","href","URL","attr","searchParams","set","handlePreviewContainerEvent","openpopup","url","name","options","join","handleDisplayOptionFormEvent","stopPropagation","preventDefault","queryString","target","closest","serialize","registerDisplayOptionListeners","getModal","on","registerEventListeners","formElement","currentTarget","appendTo","length","prop","getRoot","ModalEvents","bodyRendered","FormChangeChecker","disableAllChecks","registerModalType"],"mappings":"2hDA6BMA,gCACqB,qBADrBA,iBAEM,UAFNA,4BAGiB,mBAHjBA,yBAIc,kBAJdA,0BAKe,kBALfA,6BAMkB,4BAGHC,8BAA8BC,eAQ/CC,YAAYC,YACFA,WAEDC,UAAY,UACZC,YAAc,KAUvBC,aAAaC,SACJH,UAAYG,GASrBC,sBACWC,KAAKL,UAUhBM,eAAeH,SACNF,YAAcE,GASvBI,wBACWF,KAAKJ,YAahBO,mBACSC,kBAAkBC,OAAOC,SAASC,QAChCC,MAAML,KAAKH,MAatBI,kBAAkBK,kBAETC,QAAQC,SAASC,aAClB,WACA,qBACAZ,KAAKD,eACL,CACIU,YAAAA,eAaZI,qBAAqBC,EAAGC,qBAKdC,KAAO,IAAIC,IAAIF,cAAcG,KAAK,SACxCF,KAAKG,aAAaC,IAAI,YAAapB,KAAKE,kBACxCa,cAAcG,KAAK,OAAQF,MAU/BK,4BAA4BP,EAAGC,eAgB3BV,OAAOiB,UAAUR,EAAG,CAChBS,IAAKR,cAAcG,KAAK,QACxBM,KAAM,kBACNC,QAlBiB,CACjB,aACA,YACA,QACA,SACA,YACA,aACA,aACA,YACA,UACA,SACA,gBACA,eACA,aAKsBC,KAAK,OAanCC,6BAA6Bb,GAGzBA,EAAEc,kBACFd,EAAEe,uBAGIC,YAAc,KADP,mBAAEhB,EAAEiB,QAAQC,QAAQ1C,2BACF2C,iBAC1B7B,kBAAkB0B,aAc3BI,sCAESC,WAAWC,GAAG,SAAU9C,2BAA4BwB,KAE7B,mBAAEA,EAAEiB,QACRb,KAAK,2BAOpBS,6BAA6Bb,WAKjCqB,WAAWC,GAAG,SAAU9C,2BAA4BwB,SAChDa,6BAA6Bb,MAS1CuB,+BAEUA,uBAAuBrC,WAGxBkC,sCAEAC,WAAWC,GAAG,SAAU9C,8BAA+BwB,UAIlDwB,aAAc,mBAAExB,EAAEyB,mCAEtB,aAAarB,KAAK,OAAQ,UACvBA,KAAK,OAAQ,aACbA,KAAK,QAASlB,KAAKE,kBACnBsC,SAASF,qBAGbH,WAAWC,GAAG,QAAS9C,kBAAmBwB,UACrCC,eAAgB,mBAAED,EAAEyB,eAGtBxB,cAAciB,QAAQ1C,iCAAiCmD,YAClD5B,qBAAqBC,EAAGC,eAK7BA,cAAciB,QAAQ1C,6BAA6BmD,YAC9CpB,4BAA4BP,EAAGC,eAMpCA,cAAciB,QAAQ1C,0BAA0BmD,SAKpD3B,EAAEe,sBACGzB,kBAAkBW,cAAc2B,KAAK,oBAIzCC,UAAUP,GAAGQ,YAAYC,cAAc,KAGxCC,kBAAkBC,6FAxPZ,iDADGxD,6HA8PrBA,sBAAsByD"}
\ No newline at end of file
diff --git a/mod/quiz/amd/src/modal_add_random_question.js b/mod/quiz/amd/src/modal_add_random_question.js
index f34a2b5aa07..7141de7b381 100644
--- a/mod/quiz/amd/src/modal_add_random_question.js
+++ b/mod/quiz/amd/src/modal_add_random_question.js
@@ -20,59 +20,45 @@
* @copyright 2018 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([
- 'jquery',
- 'core/notification',
- 'core/modal',
- 'core/modal_events',
- 'core/modal_registry',
- 'core/fragment',
- 'core/templates',
- 'core_form/changechecker',
-],
-function(
- $,
- Notification,
- Modal,
- ModalEvents,
- ModalRegistry,
- Fragment,
- Templates,
- FormChangeChecker,
-) {
- var registered = false;
- var SELECTORS = {
- EXISTING_CATEGORY_CONTAINER: '[data-region="existing-category-container"]',
- EXISTING_CATEGORY_FORM_ELEMENT: '#id_existingcategoryheader',
- NEW_CATEGORY_CONTAINER: '[data-region="new-category-container"]',
- NEW_CATEGORY_FORM_ELEMENT: '#id_newcategoryheader',
- TAB_CONTENT: '[data-region="tab-content"]',
- ADD_ON_PAGE_FORM_ELEMENT: '[name="addonpage"]',
- SUBMIT_BUTTON_ELEMENT: 'input[type="submit"]',
- CANCEL_BUTTON_ELEMENT: 'input[type="submit"][name="cancel"]',
- FORM_HEADER: 'legend',
- BUTTON_CONTAINER: '.fitem'
- };
+import $ from 'jquery';
+import Modal from 'core/modal';
+import * as Notification from 'core/notification';
+import * as Fragment from 'core/fragment';
+import * as Templates from 'core/templates';
+import * as FormChangeChecker from 'core_form/changechecker';
+
+const SELECTORS = {
+ EXISTING_CATEGORY_CONTAINER: '[data-region="existing-category-container"]',
+ EXISTING_CATEGORY_FORM_ELEMENT: '#id_existingcategoryheader',
+ NEW_CATEGORY_CONTAINER: '[data-region="new-category-container"]',
+ NEW_CATEGORY_FORM_ELEMENT: '#id_newcategoryheader',
+ TAB_CONTENT: '[data-region="tab-content"]',
+ ADD_ON_PAGE_FORM_ELEMENT: '[name="addonpage"]',
+ SUBMIT_BUTTON_ELEMENT: 'input[type="submit"]',
+ CANCEL_BUTTON_ELEMENT: 'input[type="submit"][name="cancel"]',
+ FORM_HEADER: 'legend',
+ BUTTON_CONTAINER: '.fitem',
+};
+
+export default class ModalAddRandomQuestion extends Modal {
+ static TYPE = 'mod_quiz-quiz-add-random-question';
+ static TEMPLATE = 'mod_quiz/modal_add_random_question';
/**
* Constructor for the Modal.
*
* @param {object} root The root jQuery element for the modal
*/
- var ModalAddRandomQuestion = function(root) {
- Modal.call(this, root);
+ constructor(root) {
+ super(root);
this.contextId = null;
this.addOnPageId = null;
this.category = null;
this.returnUrl = null;
this.cmid = null;
this.loadedForm = false;
- };
-
- ModalAddRandomQuestion.TYPE = 'mod_quiz-quiz-add-random-question';
- ModalAddRandomQuestion.prototype = Object.create(Modal.prototype);
- ModalAddRandomQuestion.prototype.constructor = ModalAddRandomQuestion;
+ }
/**
* Save the Moodle context id that the question bank is being
@@ -81,9 +67,9 @@ function(
* @method setContextId
* @param {int} id
*/
- ModalAddRandomQuestion.prototype.setContextId = function(id) {
+ setContextId(id) {
this.contextId = id;
- };
+ }
/**
* Retrieve the saved Moodle context id.
@@ -91,9 +77,9 @@ function(
* @method getContextId
* @return {int}
*/
- ModalAddRandomQuestion.prototype.getContextId = function() {
+ getContextId() {
return this.contextId;
- };
+ }
/**
* Set the id of the page that the question should be added to
@@ -102,10 +88,10 @@ function(
* @method setAddOnPageId
* @param {int} id
*/
- ModalAddRandomQuestion.prototype.setAddOnPageId = function(id) {
+ setAddOnPageId(id) {
this.addOnPageId = id;
this.getBody().find(SELECTORS.ADD_ON_PAGE_FORM_ELEMENT).val(id);
- };
+ }
/**
* Returns the saved page id for the question to be added to.
@@ -113,9 +99,9 @@ function(
* @method getAddOnPageId
* @return {int}
*/
- ModalAddRandomQuestion.prototype.getAddOnPageId = function() {
+ getAddOnPageId() {
return this.addOnPageId;
- };
+ }
/**
* Set the category for this form. The category is a comma separated
@@ -124,9 +110,9 @@ function(
* @method setCategory
* @param {string} category
*/
- ModalAddRandomQuestion.prototype.setCategory = function(category) {
+ setCategory(category) {
this.category = category;
- };
+ }
/**
* Returns the saved category.
@@ -134,9 +120,9 @@ function(
* @method getCategory
* @return {string}
*/
- ModalAddRandomQuestion.prototype.getCategory = function() {
+ getCategory() {
return this.category;
- };
+ }
/**
* Set the return URL for the form.
@@ -144,9 +130,9 @@ function(
* @method setReturnUrl
* @param {string} url
*/
- ModalAddRandomQuestion.prototype.setReturnUrl = function(url) {
+ setReturnUrl(url) {
this.returnUrl = url;
- };
+ }
/**
* Returns the return URL for the form.
@@ -154,9 +140,9 @@ function(
* @method getReturnUrl
* @return {string}
*/
- ModalAddRandomQuestion.prototype.getReturnUrl = function() {
+ getReturnUrl() {
return this.returnUrl;
- };
+ }
/**
* Set the course module id for the form.
@@ -164,9 +150,9 @@ function(
* @method setCMID
* @param {int} id
*/
- ModalAddRandomQuestion.prototype.setCMID = function(id) {
+ setCMID(id) {
this.cmid = id;
- };
+ }
/**
* Returns the course module id for the form.
@@ -174,9 +160,9 @@ function(
* @method getCMID
* @return {int}
*/
- ModalAddRandomQuestion.prototype.getCMID = function() {
+ getCMID() {
return this.cmid;
- };
+ }
/**
* Moves a given form element inside (a child of) a given tab element.
@@ -191,9 +177,9 @@ function(
* @param {jquery} formElement The form element to move into the tab.
* @param {jquey} tabElement The tab element for the form element to move into.
*/
- ModalAddRandomQuestion.prototype.moveFormElementIntoTab = function(formElement, tabElement) {
- var submitButtons = formElement.find(SELECTORS.SUBMIT_BUTTON_ELEMENT);
- var footer = $('');
+ moveFormElementIntoTab(formElement, tabElement) {
+ const submitButtons = formElement.find(SELECTORS.SUBMIT_BUTTON_ELEMENT);
+ const footer = $('');
// Hide the header because the tabs show us which part of the form we're
// looking at.
formElement.find(SELECTORS.FORM_HEADER).addClass('hidden');
@@ -205,7 +191,7 @@ function(
submitButtons.appendTo(footer);
// Add the footer to the end of the category form element.
footer.appendTo(formElement);
- };
+ }
/**
* Empty the tab content container and move all tabs from the form into the
@@ -214,12 +200,12 @@ function(
* @method moveTabsIntoTabContent
* @param {jquery} form The form element.
*/
- ModalAddRandomQuestion.prototype.moveTabsIntoTabContent = function(form) {
+ moveTabsIntoTabContent(form) {
// Empty it to remove the loading icon.
- var tabContent = this.getBody().find(SELECTORS.TAB_CONTENT).empty();
+ const tabContent = this.getBody().find(SELECTORS.TAB_CONTENT).empty();
// Make sure all tabs are inside the tab content element.
form.find('[role="tabpanel"]').wrapAll(tabContent);
- };
+ }
/**
* Make sure all of the tabs have a cancel button in their fotter to sit along
@@ -228,13 +214,13 @@ function(
* @method moveCancelButtonToTabs
* @param {jquey} form The form element.
*/
- ModalAddRandomQuestion.prototype.moveCancelButtonToTabs = function(form) {
- var cancelButton = form.find(SELECTORS.CANCEL_BUTTON_ELEMENT).addClass('ml-1');
- var tabFooters = form.find('[data-region="footer"]');
+ moveCancelButtonToTabs(form) {
+ const cancelButton = form.find(SELECTORS.CANCEL_BUTTON_ELEMENT).addClass('ml-1');
+ const tabFooters = form.find('[data-region="footer"]');
// Remove the buttons container element.
cancelButton.closest(SELECTORS.BUTTON_CONTAINER).remove();
cancelButton.clone().appendTo(tabFooters);
- };
+ }
/**
* Load the add random question form in a fragement and perform some transformation
@@ -243,7 +229,7 @@ function(
* @method loadForm
* @return {promise} Resolved with form HTML and JS.
*/
- ModalAddRandomQuestion.prototype.loadForm = function() {
+ loadForm() {
return Fragment.loadFragment(
'mod_quiz',
'add_random_question_form',
@@ -255,12 +241,12 @@ function(
cmid: this.getCMID()
}
)
- .then(function(html, js) {
- var form = $(html);
- var existingCategoryFormElement = form.find(SELECTORS.EXISTING_CATEGORY_FORM_ELEMENT);
- var existingCategoryTab = this.getBody().find(SELECTORS.EXISTING_CATEGORY_CONTAINER);
- var newCategoryFormElement = form.find(SELECTORS.NEW_CATEGORY_FORM_ELEMENT);
- var newCategoryTab = this.getBody().find(SELECTORS.NEW_CATEGORY_CONTAINER);
+ .then((html, js) =>{
+ const form = $(html);
+ const existingCategoryFormElement = form.find(SELECTORS.EXISTING_CATEGORY_FORM_ELEMENT);
+ const existingCategoryTab = this.getBody().find(SELECTORS.EXISTING_CATEGORY_CONTAINER);
+ const newCategoryFormElement = form.find(SELECTORS.NEW_CATEGORY_FORM_ELEMENT);
+ const newCategoryTab = this.getBody().find(SELECTORS.NEW_CATEGORY_CONTAINER);
// Transform the form into tabs for better rendering in the modal.
this.moveFormElementIntoTab(existingCategoryFormElement, existingCategoryTab);
@@ -270,15 +256,15 @@ function(
Templates.replaceNode(this.getBody().find(SELECTORS.TAB_CONTENT), form, js);
return;
- }.bind(this))
- .then(function() {
+ })
+ .then(() => {
// Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the
// page once the modal is hidden.
FormChangeChecker.disableAllChecks();
return;
})
- .fail(Notification.exception);
- };
+ .catch(Notification.exception);
+ }
/**
* Override the modal show function to load the form when this modal is first
@@ -286,26 +272,14 @@ function(
*
* @method show
*/
- ModalAddRandomQuestion.prototype.show = function() {
- Modal.prototype.show.call(this);
+ show() {
+ super.show(this);
if (!this.loadedForm) {
this.loadForm();
this.loadedForm = true;
}
- };
-
- // 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(
- ModalAddRandomQuestion.TYPE,
- ModalAddRandomQuestion,
- 'mod_quiz/modal_add_random_question'
- );
-
- registered = true;
}
+}
- return ModalAddRandomQuestion;
-});
+ModalAddRandomQuestion.registerModalType();
diff --git a/mod/quiz/amd/src/modal_quiz_question_bank.js b/mod/quiz/amd/src/modal_quiz_question_bank.js
index 3c13c9e9201..3add9296122 100644
--- a/mod/quiz/amd/src/modal_quiz_question_bank.js
+++ b/mod/quiz/amd/src/modal_quiz_question_bank.js
@@ -20,50 +20,36 @@
* @copyright 2018 Ryan Wyllie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define([
- 'jquery',
- 'core/notification',
- 'core/modal',
- 'core/modal_events',
- 'core/modal_registry',
- 'core/fragment',
- 'core_form/changechecker',
-],
-function(
- $,
- Notification,
- Modal,
- ModalEvents,
- ModalRegistry,
- Fragment,
- FormChangeChecker,
-) {
- var registered = false;
- var SELECTORS = {
- ADD_TO_QUIZ_CONTAINER: 'td.addtoquizaction',
- ANCHOR: 'a[href]',
- PREVIEW_CONTAINER: 'td.previewaction',
- SEARCH_OPTIONS: '#advancedsearch',
- DISPLAY_OPTIONS: '#displayoptions',
- ADD_QUESTIONS_FORM: 'form#questionsubmit',
- };
+import $ from 'jquery';
+import Modal from 'core/modal';
+import * as Fragment from 'core/fragment';
+import * as FormChangeChecker from 'core_form/changechecker';
+import * as ModalEvents from 'core/modal_events';
+
+const SELECTORS = {
+ ADD_TO_QUIZ_CONTAINER: 'td.addtoquizaction',
+ ANCHOR: 'a[href]',
+ PREVIEW_CONTAINER: 'td.previewaction',
+ SEARCH_OPTIONS: '#advancedsearch',
+ DISPLAY_OPTIONS: '#displayoptions',
+ ADD_QUESTIONS_FORM: 'form#questionsubmit',
+};
+
+export default class ModalQuizQuestionBank extends Modal {
+ static TYPE = 'mod_quiz-quiz-question-bank';
/**
* Constructor for the Modal.
*
* @param {object} root The root jQuery element for the modal
*/
- var ModalQuizQuestionBank = function(root) {
- Modal.call(this, root);
+ constructor(root) {
+ super(root);
this.contextId = null;
this.addOnPageId = null;
- };
-
- ModalQuizQuestionBank.TYPE = 'mod_quiz-quiz-question-bank';
- ModalQuizQuestionBank.prototype = Object.create(Modal.prototype);
- ModalQuizQuestionBank.prototype.constructor = ModalQuizQuestionBank;
+ }
/**
* Save the Moodle context id that the question bank is being
@@ -72,9 +58,9 @@ function(
* @method setContextId
* @param {int} id
*/
- ModalQuizQuestionBank.prototype.setContextId = function(id) {
+ setContextId(id) {
this.contextId = id;
- };
+ }
/**
* Retrieve the saved Moodle context id.
@@ -82,9 +68,9 @@ function(
* @method getContextId
* @return {int}
*/
- ModalQuizQuestionBank.prototype.getContextId = function() {
+ getContextId() {
return this.contextId;
- };
+ }
/**
* Set the id of the page that the question should be added to
@@ -93,9 +79,9 @@ function(
* @method setAddOnPageId
* @param {int} id
*/
- ModalQuizQuestionBank.prototype.setAddOnPageId = function(id) {
+ setAddOnPageId(id) {
this.addOnPageId = id;
- };
+ }
/**
* Returns the saved page id for the question to be added it.
@@ -103,9 +89,9 @@ function(
* @method getAddOnPageId
* @return {int}
*/
- ModalQuizQuestionBank.prototype.getAddOnPageId = function() {
+ getAddOnPageId() {
return this.addOnPageId;
- };
+ }
/**
* Override the parent show function.
@@ -117,10 +103,10 @@ function(
* @method show
* @return {void}
*/
- ModalQuizQuestionBank.prototype.show = function() {
+ show() {
this.reloadBodyContent(window.location.search);
- return Modal.prototype.show.call(this);
- };
+ return super.show(this);
+ }
/**
* Replaces the current body contents with a new version of the question
@@ -130,21 +116,19 @@ function(
* query string.
*
* @method reloadBodyContent
- * @param {string} queryString URL encoded string.
+ * @param {string} querystring URL encoded string.
*/
- ModalQuizQuestionBank.prototype.reloadBodyContent = function(queryString) {
+ reloadBodyContent(querystring) {
// Load the question bank fragment to be displayed in the modal.
- var promise = Fragment.loadFragment(
+ this.setBody(Fragment.loadFragment(
'mod_quiz',
'quiz_question_bank',
this.getContextId(),
{
- querystring: queryString
+ querystring,
}
- ).fail(Notification.exception);
-
- this.setBody(promise);
- };
+ ));
+ }
/**
* Update the URL of the anchor element that the user clicked on to make
@@ -154,14 +138,15 @@ function(
* @param {event} e A JavaScript event
* @param {object} anchorElement The anchor element that was triggered
*/
- ModalQuizQuestionBank.prototype.handleAddToQuizEvent = function(e, anchorElement) {
+ handleAddToQuizEvent(e, anchorElement) {
// If the user clicks the plus icon to add the question to the page
// directly then we need to intercept the click in order to adjust the
// href and include the correct add on page id before the page is
// redirected.
- var href = anchorElement.attr('href') + '&addonpage=' + this.getAddOnPageId();
+ const href = new URL(anchorElement.attr('href'));
+ href.searchParams.set('addonpage', this.getAddOnPageId());
anchorElement.attr('href', href);
- };
+ }
/**
* Open a popup window to show the preview of the question.
@@ -170,8 +155,8 @@ function(
* @param {event} e A JavaScript event
* @param {object} anchorElement The anchor element that was triggered
*/
- ModalQuizQuestionBank.prototype.handlePreviewContainerEvent = function(e, anchorElement) {
- var popupOptions = [
+ handlePreviewContainerEvent(e, anchorElement) {
+ const popupOptions = [
'height=600',
'width=800',
'top=0',
@@ -184,14 +169,14 @@ function(
'status',
'directories=0',
'fullscreen=0',
- 'dependent'
+ 'dependent',
];
window.openpopup(e, {
url: anchorElement.attr('href'),
name: 'questionpreview',
options: popupOptions.join(',')
});
- };
+ }
/**
* Reload the modal body with the new display options the user has selected.
@@ -202,16 +187,16 @@ function(
* @method handleDisplayOptionFormEvent
* @param {event} e A JavaScript event
*/
- ModalQuizQuestionBank.prototype.handleDisplayOptionFormEvent = function(e) {
+ handleDisplayOptionFormEvent(e) {
// Stop propagation to prevent other wild event handlers
// from submitting the form on change.
e.stopPropagation();
e.preventDefault();
- var form = $(e.target).closest(SELECTORS.DISPLAY_OPTIONS);
- var queryString = '?' + form.serialize();
+ const form = $(e.target).closest(SELECTORS.DISPLAY_OPTIONS);
+ const queryString = '?' + form.serialize();
this.reloadBodyContent(queryString);
- };
+ }
/**
* Listen for changes to the display options form.
@@ -224,11 +209,11 @@ function(
*
* @method registerDisplayOptionListeners
*/
- ModalQuizQuestionBank.prototype.registerDisplayOptionListeners = function() {
+ registerDisplayOptionListeners() {
// Listen for changes to the display options form.
- this.getModal().on('change', SELECTORS.DISPLAY_OPTIONS, function(e) {
+ this.getModal().on('change', SELECTORS.DISPLAY_OPTIONS, (e) => {
// Get the element that was changed.
- var modifiedElement = $(e.target);
+ const modifiedElement = $(e.target);
if (modifiedElement.attr('aria-autocomplete')) {
// If the element that was change is the autocomplete
// input then we should ignore it because that is for
@@ -237,41 +222,41 @@ function(
}
this.handleDisplayOptionFormEvent(e);
- }.bind(this));
+ });
// Listen for the display options form submission because the tags
// filter will submit the form when it is changed.
- this.getModal().on('submit', SELECTORS.DISPLAY_OPTIONS, function(e) {
+ this.getModal().on('submit', SELECTORS.DISPLAY_OPTIONS, (e) => {
this.handleDisplayOptionFormEvent(e);
- }.bind(this));
- };
+ });
+ }
/**
* Set up all of the event handling for the modal.
*
* @method registerEventListeners
*/
- ModalQuizQuestionBank.prototype.registerEventListeners = function() {
+ registerEventListeners() {
// Apply parent event listeners.
- Modal.prototype.registerEventListeners.call(this);
+ super.registerEventListeners(this);
// Set up the event handlers for all of the display options.
this.registerDisplayOptionListeners();
- this.getModal().on('submit', SELECTORS.ADD_QUESTIONS_FORM, function(e) {
+ this.getModal().on('submit', SELECTORS.ADD_QUESTIONS_FORM, (e) => {
// If the user clicks on the "Add selected questions to the quiz" button to add some questions to the page
// then we need to intercept the submit in order to include the correct "add on page id" before the form is
// submitted.
- var formElement = $(e.currentTarget);
+ const formElement = $(e.currentTarget);
$('').attr('type', 'hidden')
.attr('name', "addonpage")
.attr('value', this.getAddOnPageId())
.appendTo(formElement);
- }.bind(this));
+ });
- this.getModal().on('click', SELECTORS.ANCHOR, function(e) {
- var anchorElement = $(e.currentTarget);
+ this.getModal().on('click', SELECTORS.ANCHOR, (e) => {
+ const anchorElement = $(e.currentTarget);
// If the anchor element was the add to quiz link.
if (anchorElement.closest(SELECTORS.ADD_TO_QUIZ_CONTAINER).length) {
@@ -294,27 +279,15 @@ function(
// Anything else means reload the pop-up contents.
e.preventDefault();
this.reloadBodyContent(anchorElement.prop('search'));
- }.bind(this));
+ });
// Disable the form change checker when the body is rendered.
- this.getRoot().on(ModalEvents.bodyRendered, function() {
+ this.getRoot().on(ModalEvents.bodyRendered, () => {
// Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the
// page once the modal is hidden.
FormChangeChecker.disableAllChecks();
});
- };
-
- // 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(
- ModalQuizQuestionBank.TYPE,
- ModalQuizQuestionBank,
- 'core/modal'
- );
-
- registered = true;
}
+}
- return ModalQuizQuestionBank;
-});
+ModalQuizQuestionBank.registerModalType();
diff --git a/payment/amd/build/modal_gateways.min.js b/payment/amd/build/modal_gateways.min.js
index 565b4dc9563..6a1bbd0c997 100644
--- a/payment/amd/build/modal_gateways.min.js
+++ b/payment/amd/build/modal_gateways.min.js
@@ -1,10 +1,3 @@
-define("core_payment/modal_gateways",["exports","jquery","core/custom_interaction_events","core/modal","core/modal_events","core_payment/events","core/modal_registry"],(function(_exports,_jquery,_custom_interaction_events,_modal,_modal_events,_events,_modal_registry){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
-/**
- * Contain the logic for the gateways modal: A modal with proceed and cancel buttons.
- *
- * @module core_payment/modal_gateways
- * @copyright 2020 Shamim Rezaie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),_custom_interaction_events=_interopRequireDefault(_custom_interaction_events),_modal=_interopRequireDefault(_modal),_modal_events=_interopRequireDefault(_modal_events),_events=_interopRequireDefault(_events),_modal_registry=_interopRequireDefault(_modal_registry);let registered=!1;const SELECTORS_PROCEED_BUTTON='[data-action="proceed"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]';class ModalGateways extends _modal.default{constructor(root){super(root)}registerEventListeners(){super.registerEventListeners(),this.getModal().on(_custom_interaction_events.default.events.activate,SELECTORS_PROCEED_BUTTON,((e,data)=>{var proceedEvent=_jquery.default.Event(_events.default.proceed);this.getRoot().trigger(proceedEvent,this),proceedEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())})),this.getModal().on(_custom_interaction_events.default.events.activate,SELECTORS_CANCEL_BUTTON,((e,data)=>{var cancelEvent=_jquery.default.Event(_modal_events.default.cancel);this.getRoot().trigger(cancelEvent,this),cancelEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}))}}return _exports.default=ModalGateways,ModalGateways.TYPE="core_payment-modal_gateways",registered||(_modal_registry.default.register(ModalGateways.TYPE,ModalGateways,"core_payment/modal_gateways"),registered=!0),_exports.default}));
+define("core_payment/modal_gateways",["exports","jquery","core/custom_interaction_events","core/modal","core/modal_events","core_payment/events"],(function(_exports,_jquery,_custom_interaction_events,_modal,_modal_events,_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),_custom_interaction_events=_interopRequireDefault(_custom_interaction_events),_modal=_interopRequireDefault(_modal),_modal_events=_interopRequireDefault(_modal_events),_events=_interopRequireDefault(_events);const SELECTORS_PROCEED_BUTTON='[data-action="proceed"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]';class ModalGateways extends _modal.default{constructor(root){super(root)}registerEventListeners(){super.registerEventListeners(),this.getModal().on(_custom_interaction_events.default.events.activate,SELECTORS_PROCEED_BUTTON,((e,data)=>{var proceedEvent=_jquery.default.Event(_events.default.proceed);this.getRoot().trigger(proceedEvent,this),proceedEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())})),this.getModal().on(_custom_interaction_events.default.events.activate,SELECTORS_CANCEL_BUTTON,((e,data)=>{var cancelEvent=_jquery.default.Event(_modal_events.default.cancel);this.getRoot().trigger(cancelEvent,this),cancelEvent.isDefaultPrevented()||(this.hide(),data.originalEvent.preventDefault())}))}}return _exports.default=ModalGateways,_defineProperty(ModalGateways,"TYPE","core_payment-modal_gateways"),_defineProperty(ModalGateways,"TEMPLATE","core_payment/modal_gateways"),ModalGateways.registerModalType(),_exports.default}));
//# sourceMappingURL=modal_gateways.min.js.map
\ No newline at end of file
diff --git a/payment/amd/build/modal_gateways.min.js.map b/payment/amd/build/modal_gateways.min.js.map
index 6d689ac0fc6..4ad2f06bd59 100644
--- a/payment/amd/build/modal_gateways.min.js.map
+++ b/payment/amd/build/modal_gateways.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"modal_gateways.min.js","sources":["../src/modal_gateways.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the gateways modal: A modal with proceed and cancel buttons.\n *\n * @module core_payment/modal_gateways\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport ModalEvents from 'core/modal_events';\nimport PaymentEvents from 'core_payment/events';\nimport ModalRegistry from 'core/modal_registry';\n\nlet registered = false;\nconst SELECTORS = {\n PROCEED_BUTTON: '[data-action=\"proceed\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n};\n\nexport default class ModalGateways extends Modal {\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n constructor(root) {\n super(root);\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners();\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.PROCEED_BUTTON, (e, data) => {\n var proceedEvent = $.Event(PaymentEvents.proceed);\n this.getRoot().trigger(proceedEvent, this);\n\n if (!proceedEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, (e, data) => {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n }\n}\n\nModalGateways.TYPE = 'core_payment-modal_gateways';\n\n// Automatically register with the modal registry the first time this module is imported so that you can create modals\n// of this type using the modal factory.\nif (!registered) {\n ModalRegistry.register(ModalGateways.TYPE, ModalGateways, 'core_payment/modal_gateways');\n registered = true;\n}\n"],"names":["registered","SELECTORS","ModalGateways","Modal","constructor","root","registerEventListeners","getModal","on","CustomEvents","events","activate","e","data","proceedEvent","$","Event","PaymentEvents","proceed","getRoot","trigger","this","isDefaultPrevented","hide","originalEvent","preventDefault","cancelEvent","ModalEvents","cancel","TYPE","register"],"mappings":";;;;;;;yYA8BIA,YAAa,QACXC,yBACc,0BADdA,wBAEa,+BAGEC,sBAAsBC,eAOvCC,YAAYC,YACFA,MAQVC,+BAEUA,8BAEDC,WAAWC,GAAGC,mCAAaC,OAAOC,SAAUV,0BAA0B,CAACW,EAAGC,YACvEC,aAAeC,gBAAEC,MAAMC,gBAAcC,cACpCC,UAAUC,QAAQN,aAAcO,MAEhCP,aAAaQ,4BACTC,OACLV,KAAKW,cAAcC,0BAItBlB,WAAWC,GAAGC,mCAAaC,OAAOC,SAAUV,yBAAyB,CAACW,EAAGC,YACtEa,YAAcX,gBAAEC,MAAMW,sBAAYC,aACjCT,UAAUC,QAAQM,YAAaL,MAE/BK,YAAYJ,4BACRC,OACLV,KAAKW,cAAcC,4DAMnCvB,cAAc2B,KAAO,8BAIhB7B,qCACa8B,SAAS5B,cAAc2B,KAAM3B,cAAe,+BAC1DF,YAAa"}
\ No newline at end of file
+{"version":3,"file":"modal_gateways.min.js","sources":["../src/modal_gateways.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for the gateways modal: A modal with proceed and cancel buttons.\n *\n * @module core_payment/modal_gateways\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport ModalEvents from 'core/modal_events';\nimport PaymentEvents from 'core_payment/events';\n\nconst SELECTORS = {\n PROCEED_BUTTON: '[data-action=\"proceed\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n};\n\nexport default class ModalGateways extends Modal {\n static TYPE = 'core_payment-modal_gateways';\n static TEMPLATE = 'core_payment/modal_gateways';\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n constructor(root) {\n super(root);\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners();\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.PROCEED_BUTTON, (e, data) => {\n var proceedEvent = $.Event(PaymentEvents.proceed);\n this.getRoot().trigger(proceedEvent, this);\n\n if (!proceedEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, (e, data) => {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n });\n }\n}\n\nModalGateways.registerModalType();\n"],"names":["SELECTORS","ModalGateways","Modal","constructor","root","registerEventListeners","getModal","on","CustomEvents","events","activate","e","data","proceedEvent","$","Event","PaymentEvents","proceed","getRoot","trigger","this","isDefaultPrevented","hide","originalEvent","preventDefault","cancelEvent","ModalEvents","cancel","registerModalType"],"mappings":"0yBA6BMA,yBACc,0BADdA,wBAEa,+BAGEC,sBAAsBC,eASvCC,YAAYC,YACFA,MAQVC,+BAEUA,8BAEDC,WAAWC,GAAGC,mCAAaC,OAAOC,SAAUV,0BAA0B,CAACW,EAAGC,YACvEC,aAAeC,gBAAEC,MAAMC,gBAAcC,cACpCC,UAAUC,QAAQN,aAAcO,MAEhCP,aAAaQ,4BACTC,OACLV,KAAKW,cAAcC,0BAItBlB,WAAWC,GAAGC,mCAAaC,OAAOC,SAAUV,yBAAyB,CAACW,EAAGC,YACtEa,YAAcX,gBAAEC,MAAMW,sBAAYC,aACjCT,UAAUC,QAAQM,YAAaL,MAE/BK,YAAYJ,4BACRC,OACLV,KAAKW,cAAcC,4EAtCdvB,qBACH,+CADGA,yBAEC,+BA0CtBA,cAAc2B"}
\ No newline at end of file
diff --git a/payment/amd/src/modal_gateways.js b/payment/amd/src/modal_gateways.js
index 81abeff6dd2..64e1db583ea 100644
--- a/payment/amd/src/modal_gateways.js
+++ b/payment/amd/src/modal_gateways.js
@@ -26,15 +26,15 @@ 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';
-let registered = false;
const SELECTORS = {
PROCEED_BUTTON: '[data-action="proceed"]',
CANCEL_BUTTON: '[data-action="cancel"]',
};
export default class ModalGateways extends Modal {
+ static TYPE = 'core_payment-modal_gateways';
+ static TEMPLATE = 'core_payment/modal_gateways';
/**
* Constructor for the Modal.
@@ -76,11 +76,4 @@ export default class ModalGateways extends Modal {
}
}
-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;
-}
+ModalGateways.registerModalType();