{"version":3,"file":"modal_backdrop.min.js","sources":["https:\/\/inclusivemediatraining.eu\/lib\/amd\/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"}