From 77b4d0236fccc774e7d2fc65c763e54ffc732609 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 18 May 2023 14:19:46 +0800 Subject: [PATCH] MDL-78306 core: Provide helper method to register modals classes --- lib/amd/build/local/modal/alert.min.js | 9 +- lib/amd/build/local/modal/alert.min.js.map | 2 +- lib/amd/build/modal.min.js | 2 +- lib/amd/build/modal.min.js.map | 2 +- lib/amd/build/modal_cancel.min.js | 9 +- lib/amd/build/modal_cancel.min.js.map | 2 +- lib/amd/build/modal_copy_to_clipboard.min.js | 2 +- .../build/modal_copy_to_clipboard.min.js.map | 2 +- lib/amd/build/modal_delete_cancel.min.js | 9 +- lib/amd/build/modal_delete_cancel.min.js.map | 2 +- lib/amd/build/modal_factory.min.js | 2 +- lib/amd/build/modal_factory.min.js.map | 2 +- lib/amd/build/modal_registry.min.js | 16 ++-- lib/amd/build/modal_registry.min.js.map | 2 +- lib/amd/build/modal_save_cancel.min.js | 9 +- lib/amd/build/modal_save_cancel.min.js.map | 2 +- .../moodlenet/send_activity_modal.min.js | 2 +- .../moodlenet/send_activity_modal.min.js.map | 2 +- lib/amd/src/local/modal/alert.js | 7 +- lib/amd/src/modal.js | 25 +++++- lib/amd/src/modal_cancel.js | 7 +- lib/amd/src/modal_copy_to_clipboard.js | 7 +- lib/amd/src/modal_delete_cancel.js | 7 +- lib/amd/src/modal_factory.js | 23 ++--- lib/amd/src/modal_registry.js | 86 +++++++++---------- lib/amd/src/modal_save_cancel.js | 7 +- lib/amd/src/moodlenet/send_activity_modal.js | 9 +- .../plugins/equation/amd/build/modal.min.js | 2 +- .../equation/amd/build/modal.min.js.map | 2 +- .../tiny/plugins/equation/amd/src/modal.js | 9 +- .../tiny/plugins/h5p/amd/build/modal.min.js | 2 +- .../plugins/h5p/amd/build/modal.min.js.map | 2 +- lib/editor/tiny/plugins/h5p/amd/src/modal.js | 10 +-- .../tiny/plugins/link/amd/build/modal.min.js | 2 +- .../plugins/link/amd/build/modal.min.js.map | 2 +- lib/editor/tiny/plugins/link/amd/src/modal.js | 9 +- .../plugins/media/amd/build/embedmodal.min.js | 2 +- .../media/amd/build/embedmodal.min.js.map | 2 +- .../plugins/media/amd/build/imagemodal.min.js | 2 +- .../media/amd/build/imagemodal.min.js.map | 2 +- .../tiny/plugins/media/amd/src/embedmodal.js | 10 +-- .../tiny/plugins/media/amd/src/imagemodal.js | 10 +-- .../recordrtc/amd/build/audio_recorder.min.js | 2 +- .../amd/build/audio_recorder.min.js.map | 2 +- .../recordrtc/amd/build/video_recorder.min.js | 2 +- .../amd/build/video_recorder.min.js.map | 2 +- .../recordrtc/amd/src/audio_recorder.js | 11 +-- .../recordrtc/amd/src/video_recorder.js | 11 +-- payment/amd/build/modal_gateways.min.js | 9 +- payment/amd/build/modal_gateways.min.js.map | 2 +- payment/amd/src/modal_gateways.js | 13 +-- 51 files changed, 162 insertions(+), 216 deletions(-) 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 3d182bab113..4866f0dcb09 100644 --- a/lib/amd/build/modal.min.js +++ b/lib/amd/build/modal.min.js @@ -1,3 +1,3 @@ -define("core/modal",["exports","jquery","core/templates","core/notification","core/key_codes","core/modal_backdrop","core/modal_events","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,_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),_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){_defineProperty(this,"backdropPromise",null),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()}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,"modalCounter",0),_exports.default})); +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 6e502eca004..5478043a9d4 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 */\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 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 {Promise} Module singleton for the backdrop to be reused by all Modal instances */\n 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 /**\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 * 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","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","Error","text","setRemoveOnClose","setReturnElement","setButtonDisabled","disabled","attr","removeAttr"],"mappings":"itEAqCMA,oBACS,kCADTA,gBAEK,wBAFLA,iBAGM,yBAHNA,gBAIK,wBAJLA,eAKI,uBALJA,iBAMM,yBANNA,eAOI,uBAPJA,iBAQM,gBARNA,eASI,OATJA,mBAUQ,iBAVRA,sBAWW,qBAIXC,kBACO,eADPA,mBAEQ,4BAGOC,MAgBjBC,YAAYC,6CAdM,WAeTA,MAAO,mBAAEA,WAETC,MAAQC,KAAKF,KAAKG,KAAKP,sBACvBQ,OAASF,KAAKD,MAAME,KAAKP,uBACzBS,cAAgBC,gBAAEC,gBAClBC,MAAQN,KAAKE,OAAOD,KAAKP,sBACzBa,aAAeH,gBAAEC,gBACjBG,KAAOR,KAAKD,MAAME,KAAKP,qBACvBe,YAAcL,gBAAEC,gBAChBK,OAASV,KAAKD,MAAME,KAAKP,uBACzBiB,cAAgBP,gBAAEC,gBAClBO,eAAiB,QACjBC,YAAa,OACbC,OAAS,UACTC,SAAW,UACXC,WAAahB,KAAKiB,oBAClBC,gBAAkBC,SAASC,cAAc,OAC9CD,SAASX,KAAKa,OAAOrB,KAAKkB,sBACrBI,aAAe,KAEftB,KAAKF,KAAKyB,GAAG7B,sBACd8B,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AyBF,OAAS,YAElDO,SACAN,OAAOO,KAAK,WAAY,IAExBP,OAAOQ,WAAW,2DA17BT/L,qBAQK"} \ 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 * @class 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":"0yEAsCMA,oBACS,kCADTA,gBAEK,wBAFLA,iBAGM,yBAHNA,gBAIK,wBAJLA,eAKI,uBALJA,iBAMM,yBANNA,eAOI,uBAPJA,iBAQM,gBARNA,eASI,OATJA,mBAUQ,iBAVRA,sBAWW,qBAIXC,kBACO,eADPA,mBAEQ,4BAGOC,MAkBjBC,YAAYC,WACHA,MAAO,mBAAEA,WAETC,MAAQC,KAAKF,KAAKG,KAAKP,sBACvBQ,OAASF,KAAKD,MAAME,KAAKP,uBACzBS,cAAgBC,gBAAEC,gBAClBC,MAAQN,KAAKE,OAAOD,KAAKP,sBACzBa,aAA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ElI,MAAMoI,UACJH,YAAYG,YAIfjI,MAAM5B,aAAaC,WAEb0J,EAaXG,cAAcC,OAAQxH,aACZyH,OAASxL,KAAKyD,YAAYxD,KAAKD,KAAKyK,kBAAkBc,aAEvDC,aACK,IAAI1J,MAAM,uBAAyByJ,OAAS,mBAG/CvL,KAAKgE,SAASD,MAAOyH,OAAOC,KAAKxH,KAAKuH,SASjDf,kBAAkBc,cACP,iBAAmBA,OAAS,KAQvCG,iBAAiB1E,aACR0C,cAAgB1C,OAQzB2E,iBAAiB/I,cACRtB,aAAesB,QASxBgJ,kBAAkBL,OAAQM,gBAChBL,OAASxL,KAAKyD,YAAYxD,KAAKD,KAAKyK,kBAAkBc,aAEvDC,aACK,IAAI1J,MAAM,uBAAyByJ,OAAS,YAElDM,SACAL,OAAOM,KAAK,WAAY,IAExBN,OAAOO,WAAW,2DA98BTnM,iBAEC,8BAFDA,wBAKQ,sBALRA,qBAWK"} \ 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_factory.min.js b/lib/amd/build/modal_factory.min.js index 7ead5a15b48..3c906f8f711 100644 --- a/lib/amd/build/modal_factory.min.js +++ b/lib/amd/build/modal_factory.min.js @@ -5,6 +5,6 @@ * @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}})); +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 TYPES={DEFAULT:"DEFAULT",SAVE_CANCEL:ModalSaveCancel.TYPE,DELETE_CANCEL:ModalDeleteCancel.TYPE,CANCEL:ModalCancel.TYPE,ALERT:ModalAlert.TYPE};ModalRegistry.register(TYPES.DEFAULT,Modal,Modal.TEMPLATE);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}})); //# 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..9b56730a2a9 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":";;;;;;;AAsBAA,4BAAO,CAAC,SAAU,oBAAqB,sBAAuB,aACtD,yBAA0B,2BAA4B,oBAAqB,yBAC3E,iBAAkB,oBAAqB,iCAC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MAAMM,UAAUhB,YAAYe,QAG5Bf,YAAYiB,SACZC,OAAOC,QAAQnB,YAAYiB,SAASG,SAAQ,mBAAUC,IAAKC,YACvDZ,MAAMa,cAAcF,IAAKC,UAI7BnB,SACAO,MAAMc,gBAG+B,IAA9BxB,YAAYyB,eAEnBf,MAAMgB,iBAAiB1B,YAAYyB,eAGvCf,MAAMiB,cAActB,cAEbK,qBAGc,IAAlBT,gBAxJI,SAASZ,aAAcY,eAAgBD,iBAElD4B,qBAAuB,KAGvBC,mBAA4D,mBAA/B7B,YAAY8B,gBAEzCC,kBAAoB,SAASC,EAAGC,UAC5BC,eAAiB,IAAI3D,QAAQ,qDACjCqD,qBAAuBhE,EAAEoE,EAAEG,eAC3B9C,aAAaE,MAAK,SAASmB,cACnBmB,oBAGA7B,YAAY8B,gBAAgBF,qBAAsBlB,OAGtDA,MAAM0B,OAEC1B,SAEVnB,KAAK2C,eAAeG,SACrBJ,KAAKK,cAAcC,qBAMnBC,MAAMC,QAAQxC,gBAAiB,KAC3ByC,SAAWzC,eAAe,GAC9BA,eAAiBA,eAAe,GAEhC3B,aAAaX,OAAOsC,eAAgB,CAAC3B,aAAaqE,OAAOC,WACzD3C,eAAe4C,GAAGvE,aAAaqE,OAAOC,SAAUF,SAAUX,wBAE1DzD,aAAaX,OAAOsC,eAAgB,CAAC3B,aAAaqE,OAAOC,WACzD3C,eAAe4C,GAAGvE,aAAaqE,OAAOC,SAAUb,mBAGpD1C,aAAaE,MAAK,SAASmB,cACvBA,MAAMoC,UAAUD,GAAGhF,YAAYkF,QAAQ,WAEN,OAAzBnB,sBACAA,qBAAqBoB,WAItBtC,SA0GPuC,CAAa5D,aAAcY,eAAgBD,aAGxCX,cAKP6D,MAAOzE"} \ 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 */\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 /**\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: ModalSaveCancel.TYPE,\n DELETE_CANCEL: ModalDeleteCancel.TYPE,\n CANCEL: ModalCancel.TYPE,\n ALERT: ModalAlert.TYPE,\n };\n\n // Register the common set of modals.\n ModalRegistry.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 */\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","TYPES","DEFAULT","SAVE_CANCEL","TYPE","DELETE_CANCEL","CANCEL","ALERT","register","TEMPLATE","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":";;;;;;;AAsBAA,4BAAO,CAAC,SAAU,oBAAqB,sBAAuB,aACtD,yBAA0B,2BAA4B,oBAAqB,yBAC3E,iBAAkB,oBAAqB,iCACvC,iBACJ,SAASC,EAAGC,YAAaC,cAAeC,MAAOC,gBAAiBC,kBAC5DC,YAAaC,WAAYC,UAAWC,aAAcC,aAAcC,aAchEC,MAAQ,CACRC,QAAS,UACTC,YAAaV,gBAAgBW,KAC7BC,cAAeX,kBAAkBU,KACjCE,OAAQX,YAAYS,KACpBG,MAAOX,WAAWQ,MAItBb,cAAciB,SAASP,MAAMC,QAASV,MAAOA,MAAMiB,cA2F/CC,eAAiB,SAASC,aAAcC,qBACpCC,aAAeF,aAAaG,SAE5BC,aAAelB,UAAUmB,OAAOH,aAAcD,iBAC7CK,MAAK,SAASC,UACPC,aAAe9B,EAAE6B,aAvBT,SAASP,aAAcQ,qBAC3CA,aAAe9B,EAAE8B,cAEL,IAAIC,EADHT,aAAaU,QACHF,cAqBRG,CAAkBX,aAAcQ,iBAE1CI,KAAKzB,aAAa0B,kBAEhBT,oBAsEJ,CACHU,OA5DS,SAASC,YAAaC,oBAK3BhB,aAJAiB,KAAOF,YAAYE,MAAQ3B,MAAMC,QACjC2B,UAAUH,YAAYI,MAEtBC,cAAeL,YAAYM,eAAe,eAAgBN,YAAYO,WAEtErB,gBAAkB,IAEtBD,aAAepB,cAAc2C,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,YAAYmF,QAAQ,WAEN,OAAzBnB,sBACAA,qBAAqBoB,WAItBtC,SA0GPuC,CAAa5D,aAAcY,eAAgBD,aAGxCX,cAKP6D,MAAO3E"} \ 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/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 0ec52e3df1e..bdd89e32d4b 100644 --- a/lib/amd/src/modal.js +++ b/lib/amd/src/modal.js @@ -28,6 +28,7 @@ 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'; @@ -56,8 +57,11 @@ const TEMPLATES = { }; 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 */ - backdropPromise = null; + static backdropPromise = null; /** * @var {Number} A counter that gets incremented for each modal created. @@ -65,7 +69,6 @@ export default class Modal { */ static modalCounter = 0; - /** * Constructor for the Modal. * @@ -119,6 +122,24 @@ export default class Modal { 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. * 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_factory.js b/lib/amd/src/modal_factory.js index 3295da4e489..9bc4935a82b 100644 --- a/lib/amd/src/modal_factory.js +++ b/lib/amd/src/modal_factory.js @@ -27,15 +27,6 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal', 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', - }; - /** * The available types of modals. * @@ -50,18 +41,14 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal', */ var TYPES = { DEFAULT: 'DEFAULT', - SAVE_CANCEL: 'SAVE_CANCEL', - DELETE_CANCEL: 'DELETE_CANCEL', - CANCEL: 'CANCEL', - ALERT: 'ALERT', + 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); + ModalRegistry.register(TYPES.DEFAULT, Modal, Modal.TEMPLATE); /** * Set up the events required to show the modal and return focus when the modal 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/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();