mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
1 line
7.2 KiB
Plaintext
1 line
7.2 KiB
Plaintext
{"version":3,"sources":["../src/modal_backdrop.js"],"names":["define","$","Templates","Notification","Fullscreen","SELECTORS","ROOT","ModalBackdrop","root","isAttached","attachmentPoint","document","createElement","body","append","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":"AAuBAA,OAAM,uBAAC,CAAC,QAAD,CAAW,gBAAX,CAA6B,mBAA7B,CAAkD,iBAAlD,CAAD,CACD,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqCC,CAArC,CAAiD,IAE9CC,CAAAA,CAAS,CAAG,CACZC,IAAI,CAAE,kCADM,CAFkC,CAW9CC,CAAa,CAAG,SAASC,CAAT,CAAe,CAC/B,KAAKA,IAAL,CAAYP,CAAC,CAACO,CAAD,CAAb,CACA,KAAKC,UAAL,IACA,KAAKC,eAAL,CAAuBC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAvB,CACAD,QAAQ,CAACE,IAAT,CAAcC,MAAd,CAAqB,KAAKJ,eAA1B,EAEA,GAAI,CAAC,KAAKF,IAAL,CAAUO,EAAV,CAAaV,CAAS,CAACC,IAAvB,CAAL,CAAmC,CAC/BH,CAAY,CAACa,SAAb,CAAuB,CAACC,OAAO,CAAE,iCAAV,CAAvB,CACH,CACJ,CApBiD,CA4BlDV,CAAa,CAACW,SAAd,CAAwBC,OAAxB,CAAkC,UAAW,CACzC,MAAO,MAAKX,IACf,CAFD,CASCD,CAAa,CAACW,SAAd,CAAwBE,kBAAxB,CAA6C,UAAW,CACpD,MAAOnB,CAAAA,CAAC,CAACG,CAAU,CAACiB,UAAX,IAA2B,KAAKX,eAAjC,CACX,CAFD,CASDH,CAAa,CAACW,SAAd,CAAwBI,WAAxB,CAAsC,UAAW,CAC7C,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AKhB,OAAL,EAAtB,EAAsCiB,MAA1C,CAAkD,CAC9CnC,CAAC,CAACU,QAAQ,CAACE,IAAV,CAAD,CAAiBC,MAAjB,CAAwB,KAAKK,OAAL,EAAxB,CACH,CACJ,CAlBD,CAyBAZ,CAAa,CAACW,SAAd,CAAwBmB,OAAxB,CAAkC,UAAW,CACzC,KAAK7B,IAAL,CAAU8B,MAAV,GACA,KAAK5B,eAAL,CAAqB4B,MAArB,EACH,CAHD,CAKA,MAAO/B,CAAAA,CACV,CA3IK,CAAN","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 <http://www.gnu.org/licenses/>.\n\n/**\n * Contain the logic for modal backdrops.\n *\n * @module core/modal_backdrop\n * @class modal_backdrop\n * @copyright 2016 Ryan Wyllie <ryan@moodle.com>\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 * @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"],"file":"modal_backdrop.min.js"} |