diff --git a/lib/amd/build/modal_backdrop.min.js b/lib/amd/build/modal_backdrop.min.js index e8f2f2905e1..7322a23bd57 100644 --- a/lib/amd/build/modal_backdrop.min.js +++ b/lib/amd/build/modal_backdrop.min.js @@ -1,10 +1,3 @@ -/** - * Contain the logic for modal backdrops. - * - * @module core/modal_backdrop - * @copyright 2016 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("core/modal_backdrop",["jquery","core/templates","core/notification","core/fullscreen"],(function($,Templates,Notification,Fullscreen){var SELECTORS_ROOT='[data-region="modal-backdrop"]',ModalBackdrop=function(root){this.root=$(root),this.isAttached=!1,this.attachmentPoint=document.createElement("div"),document.body.append(this.attachmentPoint),this.root.is(SELECTORS_ROOT)||Notification.exception({message:"Element is not a modal backdrop"})};return ModalBackdrop.prototype.getRoot=function(){return this.root},ModalBackdrop.prototype.getAttachmentPoint=function(){return $(Fullscreen.getElement()||this.attachmentPoint)},ModalBackdrop.prototype.attachToDOM=function(){this.getAttachmentPoint().append(this.root),this.isAttached||(this.isAttached=!0)},ModalBackdrop.prototype.setZIndex=function(value){this.root.css("z-index",value)},ModalBackdrop.prototype.isVisible=function(){return this.root.hasClass("show")},ModalBackdrop.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")},ModalBackdrop.prototype.show=function(){this.isVisible()||(this.attachToDOM(),this.root.removeClass("hide").addClass("show"))},ModalBackdrop.prototype.hide=function(){this.isVisible()&&(this.hasTransitions()?this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this)):this.getRoot().removeClass("show").addClass("hide"),$(document.body).find(this.getRoot()).length&&$(document.body).append(this.getRoot()))},ModalBackdrop.prototype.destroy=function(){this.root.remove(),this.attachmentPoint.remove()},ModalBackdrop})); +define("core/modal_backdrop",["exports","jquery","./notification","./fullscreen"],(function(_exports,_jquery,Notification,Fullscreen){var obj;function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj},Notification=_interopRequireWildcard(Notification),Fullscreen=_interopRequireWildcard(Fullscreen);const SELECTORS_ROOT='[data-region="modal-backdrop"]';return _exports.default=class{constructor(root){_defineProperty(this,"root",null),_defineProperty(this,"isAttached",!1),_defineProperty(this,"attachmentPoint",null),this.root=(0,_jquery.default)(root),this.isAttached=!1,this.attachmentPoint=document.createElement("div"),document.body.append(this.attachmentPoint),this.root.is(SELECTORS_ROOT)||Notification.exception({message:"Element is not a modal backdrop"})}getRoot(){return this.root}getAttachmentPoint(){return(0,_jquery.default)(Fullscreen.getElement()||this.attachmentPoint)}attachToDOM(){this.getAttachmentPoint().append(this.root),this.isAttached||(this.isAttached=!0)}setZIndex(value){this.root.css("z-index",value)}isVisible(){return this.root.hasClass("show")}hasTransitions(){return this.getRoot().hasClass("fade")}show(){this.isVisible()||(this.attachToDOM(),this.root.removeClass("hide").addClass("show"))}hide(){this.isVisible()&&(this.hasTransitions()?this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",(()=>{this.getRoot().removeClass("show").addClass("hide")})):this.getRoot().removeClass("show").addClass("hide"),(0,_jquery.default)(document.body).find(this.getRoot()).length&&(0,_jquery.default)(document.body).append(this.getRoot()))}destroy(){this.root.remove(),this.attachmentPoint.remove()}},_exports.default})); //# sourceMappingURL=modal_backdrop.min.js.map \ No newline at end of file diff --git a/lib/amd/build/modal_backdrop.min.js.map b/lib/amd/build/modal_backdrop.min.js.map index 681dbec7532..fc509670840 100644 --- a/lib/amd/build/modal_backdrop.min.js.map +++ b/lib/amd/build/modal_backdrop.min.js.map @@ -1 +1 @@ -{"version":3,"file":"modal_backdrop.min.js","sources":["../src/modal_backdrop.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for modal backdrops.\n *\n * @module core/modal_backdrop\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],\n function($, Templates, Notification, Fullscreen) {\n\n var SELECTORS = {\n ROOT: '[data-region=\"modal-backdrop\"]',\n };\n\n /**\n * Constructor for ModalBackdrop.\n *\n * @class core/modal_backdrop\n * @param {object} root The root element for the modal backdrop\n */\n var ModalBackdrop = function(root) {\n this.root = $(root);\n this.isAttached = false;\n this.attachmentPoint = document.createElement('div');\n document.body.append(this.attachmentPoint);\n\n if (!this.root.is(SELECTORS.ROOT)) {\n Notification.exception({message: 'Element is not a modal backdrop'});\n }\n };\n\n /**\n * Get the root element of this modal backdrop.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n ModalBackdrop.prototype.getRoot = function() {\n return this.root;\n };\n\n /**\n * Gets the jQuery wrapped node that the Modal should be attached to.\n *\n * @returns {jQuery}\n */\n ModalBackdrop.prototype.getAttachmentPoint = function() {\n return $(Fullscreen.getElement() || this.attachmentPoint);\n };\n\n /**\n * Add the modal backdrop to the page, if it hasn't already been added.\n *\n * @method attachToDOM\n */\n ModalBackdrop.prototype.attachToDOM = function() {\n this.getAttachmentPoint().append(this.root);\n\n if (this.isAttached) {\n return;\n }\n\n this.isAttached = true;\n };\n\n /**\n * Set the z-index value for this backdrop.\n *\n * @method setZIndex\n * @param {int} value The z-index value\n */\n ModalBackdrop.prototype.setZIndex = function(value) {\n this.root.css('z-index', value);\n };\n\n /**\n * Check if this backdrop is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n ModalBackdrop.prototype.isVisible = function() {\n return this.root.hasClass('show');\n };\n\n /**\n * Check if this backdrop has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n ModalBackdrop.prototype.hasTransitions = function() {\n return this.getRoot().hasClass('fade');\n };\n\n /**\n * Display this backdrop. The backdrop will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n */\n ModalBackdrop.prototype.show = function() {\n if (this.isVisible()) {\n return;\n }\n\n this.attachToDOM();\n\n this.root.removeClass('hide').addClass('show');\n };\n\n /**\n * Hide this backdrop.\n *\n * @method hide\n */\n ModalBackdrop.prototype.hide = function() {\n if (!this.isVisible()) {\n return;\n }\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {\n this.getRoot().removeClass('show').addClass('hide');\n }.bind(this));\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n // Ensure the modal is moved onto the body node if it is still attached to the DOM.\n if ($(document.body).find(this.getRoot()).length) {\n $(document.body).append(this.getRoot());\n }\n };\n\n /**\n * Remove this backdrop from the DOM.\n *\n * @method destroy\n */\n ModalBackdrop.prototype.destroy = function() {\n this.root.remove();\n this.attachmentPoint.remove();\n };\n\n return ModalBackdrop;\n});\n"],"names":["define","$","Templates","Notification","Fullscreen","SELECTORS","ModalBackdrop","root","isAttached","attachmentPoint","document","createElement","body","append","this","is","exception","message","prototype","getRoot","getAttachmentPoint","getElement","attachToDOM","setZIndex","value","css","isVisible","hasClass","hasTransitions","show","removeClass","addClass","hide","one","bind","find","length","destroy","remove"],"mappings":";;;;;;;AAsBAA,6BAAO,CAAC,SAAU,iBAAkB,oBAAqB,oBACpD,SAASC,EAAGC,UAAWC,aAAcC,gBAElCC,eACM,iCASNC,cAAgB,SAASC,WACpBA,KAAON,EAAEM,WACTC,YAAa,OACbC,gBAAkBC,SAASC,cAAc,OAC9CD,SAASE,KAAKC,OAAOC,KAAKL,iBAErBK,KAAKP,KAAKQ,GAAGV,iBACdF,aAAaa,UAAU,CAACC,QAAS,4CAUzCX,cAAcY,UAAUC,QAAU,kBACvBL,KAAKP,MAQfD,cAAcY,UAAUE,mBAAqB,kBAClCnB,EAAEG,WAAWiB,cAAgBP,KAAKL,kBAQ9CH,cAAcY,UAAUI,YAAc,gBAC7BF,qBAAqBP,OAAOC,KAAKP,MAElCO,KAAKN,kBAIJA,YAAa,IAStBF,cAAcY,UAAUK,UAAY,SAASC,YACpCjB,KAAKkB,IAAI,UAAWD,QAS7BlB,cAAcY,UAAUQ,UAAY,kBACzBZ,KAAKP,KAAKoB,SAAS,SAS9BrB,cAAcY,UAAUU,eAAiB,kBAC9Bd,KAAKK,UAAUQ,SAAS,SASnCrB,cAAcY,UAAUW,KAAO,WACvBf,KAAKY,mBAIJJ,mBAEAf,KAAKuB,YAAY,QAAQC,SAAS,UAQ3CzB,cAAcY,UAAUc,KAAO,WACtBlB,KAAKY,cAINZ,KAAKc,sBAEAT,UAAUc,IAAI,mDAAoD,gBAC9Dd,UAAUW,YAAY,QAAQC,SAAS,SAC9CG,KAAKpB,YAEFK,UAAUW,YAAY,QAAQC,SAAS,QAI5C9B,EAAES,SAASE,MAAMuB,KAAKrB,KAAKK,WAAWiB,QACtCnC,EAAES,SAASE,MAAMC,OAAOC,KAAKK,aASrCb,cAAcY,UAAUmB,QAAU,gBACzB9B,KAAK+B,cACL7B,gBAAgB6B,UAGlBhC"} \ No newline at end of file +{"version":3,"file":"modal_backdrop.min.js","sources":["../src/modal_backdrop.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Contain the logic for modal backdrops.\n *\n * @module core/modal_backdrop\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport $ from 'jquery';\nimport * as Notification from './notification';\nimport * as Fullscreen from './fullscreen';\n\nconst SELECTORS = {\n ROOT: '[data-region=\"modal-backdrop\"]',\n};\n\nexport default class ModalBackdrop {\n root = null;\n isAttached = false;\n attachmentPoint = null;\n\n /**\n * Constructor for ModalBackdrop.\n *\n * @class core/modal_backdrop\n * @param {HTMLElement|jQuery} root The root element for the modal backdrop\n */\n constructor(root) {\n this.root = $(root);\n this.isAttached = false;\n this.attachmentPoint = document.createElement('div');\n document.body.append(this.attachmentPoint);\n\n if (!this.root.is(SELECTORS.ROOT)) {\n Notification.exception({message: 'Element is not a modal backdrop'});\n }\n }\n\n /**\n * Get the root element of this modal backdrop.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n getRoot() {\n return this.root;\n }\n\n /**\n * Gets the jQuery wrapped node that the Modal should be attached to.\n *\n * @returns {jQuery}\n */\n getAttachmentPoint() {\n return $(Fullscreen.getElement() || this.attachmentPoint);\n }\n\n /**\n * Add the modal backdrop to the page, if it hasn't already been added.\n *\n * @method attachToDOM\n */\n attachToDOM() {\n this.getAttachmentPoint().append(this.root);\n\n if (this.isAttached) {\n return;\n }\n\n this.isAttached = true;\n }\n\n /**\n * Set the z-index value for this backdrop.\n *\n * @method setZIndex\n * @param {int} value The z-index value\n */\n setZIndex(value) {\n this.root.css('z-index', value);\n }\n\n /**\n * Check if this backdrop is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n isVisible() {\n return this.root.hasClass('show');\n }\n\n /**\n * Check if this backdrop has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n hasTransitions() {\n return this.getRoot().hasClass('fade');\n }\n\n /**\n * Display this backdrop. The backdrop will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n */\n show() {\n if (this.isVisible()) {\n return;\n }\n\n this.attachToDOM();\n this.root.removeClass('hide').addClass('show');\n }\n\n /**\n * Hide this backdrop.\n *\n * @method hide\n */\n hide() {\n if (!this.isVisible()) {\n return;\n }\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', () => {\n this.getRoot().removeClass('show').addClass('hide');\n });\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n // Ensure the modal is moved onto the body node if it is still attached to the DOM.\n if ($(document.body).find(this.getRoot()).length) {\n $(document.body).append(this.getRoot());\n }\n }\n\n /**\n * Remove this backdrop from the DOM.\n *\n * @method destroy\n */\n destroy() {\n this.root.remove();\n this.attachmentPoint.remove();\n }\n}\n"],"names":["SELECTORS","constructor","root","isAttached","attachmentPoint","document","createElement","body","append","this","is","Notification","exception","message","getRoot","getAttachmentPoint","Fullscreen","getElement","attachToDOM","setZIndex","value","css","isVisible","hasClass","hasTransitions","show","removeClass","addClass","hide","one","find","length","destroy","remove"],"mappings":"y9CA0BMA,eACI,+DAcNC,YAAYC,kCAVL,yCACM,0CACK,WASTA,MAAO,mBAAEA,WACTC,YAAa,OACbC,gBAAkBC,SAASC,cAAc,OAC9CD,SAASE,KAAKC,OAAOC,KAAKL,iBAErBK,KAAKP,KAAKQ,GAAGV,iBACdW,aAAaC,UAAU,CAACC,QAAS,oCAUzCC,iBACWL,KAAKP,KAQhBa,4BACW,mBAAEC,WAAWC,cAAgBR,KAAKL,iBAQ7Cc,mBACSH,qBAAqBP,OAAOC,KAAKP,MAElCO,KAAKN,kBAIJA,YAAa,GAStBgB,UAAUC,YACDlB,KAAKmB,IAAI,UAAWD,OAS7BE,mBACWb,KAAKP,KAAKqB,SAAS,QAS9BC,wBACWf,KAAKK,UAAUS,SAAS,QASnCE,OACQhB,KAAKa,mBAIJJ,mBACAhB,KAAKwB,YAAY,QAAQC,SAAS,SAQ3CC,OACSnB,KAAKa,cAINb,KAAKe,sBAEAV,UAAUe,IAAI,oDAAoD,UAC9Df,UAAUY,YAAY,QAAQC,SAAS,gBAG3Cb,UAAUY,YAAY,QAAQC,SAAS,SAI5C,mBAAEtB,SAASE,MAAMuB,KAAKrB,KAAKK,WAAWiB,4BACpC1B,SAASE,MAAMC,OAAOC,KAAKK,YASrCkB,eACS9B,KAAK+B,cACL7B,gBAAgB6B"} \ No newline at end of file diff --git a/lib/amd/src/modal_backdrop.js b/lib/amd/src/modal_backdrop.js index 6da66ca5615..219040a6ba0 100644 --- a/lib/amd/src/modal_backdrop.js +++ b/lib/amd/src/modal_backdrop.js @@ -20,20 +20,26 @@ * @copyright 2016 Ryan Wyllie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], - function($, Templates, Notification, Fullscreen) { +import $ from 'jquery'; +import * as Notification from './notification'; +import * as Fullscreen from './fullscreen'; - var SELECTORS = { - ROOT: '[data-region="modal-backdrop"]', - }; +const SELECTORS = { + ROOT: '[data-region="modal-backdrop"]', +}; + +export default class ModalBackdrop { + root = null; + isAttached = false; + attachmentPoint = null; /** * Constructor for ModalBackdrop. * * @class core/modal_backdrop - * @param {object} root The root element for the modal backdrop + * @param {HTMLElement|jQuery} root The root element for the modal backdrop */ - var ModalBackdrop = function(root) { + constructor(root) { this.root = $(root); this.isAttached = false; this.attachmentPoint = document.createElement('div'); @@ -42,7 +48,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], if (!this.root.is(SELECTORS.ROOT)) { Notification.exception({message: 'Element is not a modal backdrop'}); } - }; + } /** * Get the root element of this modal backdrop. @@ -50,25 +56,25 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], * @method getRoot * @return {object} jQuery object */ - ModalBackdrop.prototype.getRoot = function() { + getRoot() { return this.root; - }; + } - /** - * Gets the jQuery wrapped node that the Modal should be attached to. - * - * @returns {jQuery} - */ - ModalBackdrop.prototype.getAttachmentPoint = function() { - return $(Fullscreen.getElement() || this.attachmentPoint); - }; + /** + * Gets the jQuery wrapped node that the Modal should be attached to. + * + * @returns {jQuery} + */ + getAttachmentPoint() { + return $(Fullscreen.getElement() || this.attachmentPoint); + } /** * Add the modal backdrop to the page, if it hasn't already been added. * * @method attachToDOM */ - ModalBackdrop.prototype.attachToDOM = function() { + attachToDOM() { this.getAttachmentPoint().append(this.root); if (this.isAttached) { @@ -76,7 +82,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], } this.isAttached = true; - }; + } /** * Set the z-index value for this backdrop. @@ -84,9 +90,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], * @method setZIndex * @param {int} value The z-index value */ - ModalBackdrop.prototype.setZIndex = function(value) { + setZIndex(value) { this.root.css('z-index', value); - }; + } /** * Check if this backdrop is visible. @@ -94,9 +100,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], * @method isVisible * @return {bool} */ - ModalBackdrop.prototype.isVisible = function() { + isVisible() { return this.root.hasClass('show'); - }; + } /** * Check if this backdrop has CSS transitions applied. @@ -104,9 +110,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], * @method hasTransitions * @return {bool} */ - ModalBackdrop.prototype.hasTransitions = function() { + hasTransitions() { return this.getRoot().hasClass('fade'); - }; + } /** * Display this backdrop. The backdrop will be attached to the DOM if it hasn't @@ -114,31 +120,30 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], * * @method show */ - ModalBackdrop.prototype.show = function() { + show() { if (this.isVisible()) { return; } this.attachToDOM(); - this.root.removeClass('hide').addClass('show'); - }; + } /** * Hide this backdrop. * * @method hide */ - ModalBackdrop.prototype.hide = function() { + hide() { if (!this.isVisible()) { return; } if (this.hasTransitions()) { // Wait for CSS transitions to complete before hiding the element. - this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() { + this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', () => { this.getRoot().removeClass('show').addClass('hide'); - }.bind(this)); + }); } else { this.getRoot().removeClass('show').addClass('hide'); } @@ -147,17 +152,15 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], if ($(document.body).find(this.getRoot()).length) { $(document.body).append(this.getRoot()); } - }; + } /** * Remove this backdrop from the DOM. * * @method destroy */ - ModalBackdrop.prototype.destroy = function() { + destroy() { this.root.remove(); this.attachmentPoint.remove(); - }; - - return ModalBackdrop; -}); + } +}