Current Path : /var/www/ljmtc/cbt/course/amd/build/ |
Current File : /var/www/ljmtc/cbt/course/amd/build/downloadcontent.min.js.map |
{"version":3,"sources":["../src/downloadcontent.js"],"names":["init","pendingPromise","Pending","on","e","type","which","enter","space","preventDefault","displayDownloadConfirmation","currentTarget","resolve","downloadModalTrigger","ModalFactory","create","title","dataset","downloadTitle","types","SAVE_CANCEL","body","downloadBody","buttons","save","downloadButtonText","templateContext","classes","then","modal","show","saveButton","document","querySelector","cancelButton","modalContainer","CustomEvents","events","activate","downloadContent","destroy","downloadForm","createElement","action","downloadLink","method","target","downloadSesskey","name","value","Config","sesskey","appendChild","style","display","submit","removeChild"],"mappings":"siBAwBA,OACA,OACA,OACA,OACA,O,ylBAQO,GAAMA,CAAAA,CAAI,CAAG,UAAM,CACtB,GAAMC,CAAAA,CAAc,CAAG,GAAIC,UAA3B,CAGA,cAAO,uBAAP,EAAgCC,EAAhC,CAAmC,eAAnC,CAAoD,SAACC,CAAD,CAAO,CACvD,GAAe,OAAX,GAAAA,CAAC,CAACC,IAAF,EAAsBD,CAAC,CAACE,KAAF,GAAYC,OAAlC,EAA2CH,CAAC,CAACE,KAAF,GAAYE,OAA3D,CAAkE,CAC9DJ,CAAC,CAACK,cAAF,GACAC,CAA2B,CAACN,CAAC,CAACO,aAAH,CAC9B,CACJ,CALD,EAOAV,CAAc,CAACW,OAAf,EACH,CAZM,C,YAqBDF,CAAAA,CAA2B,CAAG,SAACG,CAAD,CAA0B,CAC1DC,CAAY,CAACC,MAAb,CAAoB,CAChBC,KAAK,CAAEH,CAAoB,CAACI,OAArB,CAA6BC,aADpB,CAEhBb,IAAI,CAAES,CAAY,CAACK,KAAb,CAAmBC,WAFT,CAGhBC,IAAI,cAAQR,CAAoB,CAACI,OAArB,CAA6BK,YAArC,QAHY,CAIhBC,OAAO,CAAE,CACLC,IAAI,CAAEX,CAAoB,CAACI,OAArB,CAA6BQ,kBAD9B,CAJO,CAOhBC,eAAe,CAAE,CACbC,OAAO,CAA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CAAe,CAACE,KAAhB,CAAwBC,UAAOC,OAA/B,CACAV,CAAY,CAACW,WAAb,CAAyBL,CAAzB,EACAN,CAAY,CAACY,KAAb,CAAmBC,OAAnB,CAA6B,MAA7B,CAEAtB,QAAQ,CAACX,IAAT,CAAc+B,WAAd,CAA0BX,CAA1B,EACAA,CAAY,CAACc,MAAb,GACAvB,QAAQ,CAACX,IAAT,CAAcmC,WAAd,CAA0Bf,CAA1B,EAGAZ,CAAK,CAACW,OAAN,EACH,C","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 * Functions related to downloading course content.\n *\n * @module core_course/downloadcontent\n * @package core_course\n * @copyright 2020 Michael Hawkins <michaelh@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Config from 'core/config';\nimport CustomEvents from 'core/custom_interaction_events';\nimport * as ModalFactory from 'core/modal_factory';\nimport jQuery from 'jquery';\nimport Pending from 'core/pending';\nimport {enter, space} from 'core/key_codes';\n\n/**\n * Set up listener to trigger the download course content modal.\n *\n * @return {void}\n */\nexport const init = () => {\n const pendingPromise = new Pending();\n\n // Add event listeners for click and enter/space keys.\n jQuery('[data-downloadcourse]').on('click keydown', (e) => {\n if (e.type === 'click' || e.which === enter || e.which === space) {\n e.preventDefault();\n displayDownloadConfirmation(e.currentTarget);\n }\n });\n\n pendingPromise.resolve();\n};\n\n/**\n * Display the download course content modal.\n *\n * @method displayDownloadConfirmation\n * @param {Object} downloadModalTrigger The DOM element that triggered the download modal.\n * @return {void}\n */\nconst displayDownloadConfirmation = (downloadModalTrigger) => {\n ModalFactory.create({\n title: downloadModalTrigger.dataset.downloadTitle,\n type: ModalFactory.types.SAVE_CANCEL,\n body: `<p>${downloadModalTrigger.dataset.downloadBody}</p>`,\n buttons: {\n save: downloadModalTrigger.dataset.downloadButtonText\n },\n templateContext: {\n classes: 'downloadcoursecontentmodal'\n }\n })\n .then(modal => {\n // Display the modal.\n modal.show();\n\n const saveButton = document.querySelector('.modal .downloadcoursecontentmodal [data-action=\"save\"]');\n const cancelButton = document.querySelector('.modal .downloadcoursecontentmodal [data-action=\"cancel\"]');\n const modalContainer = document.querySelector('.modal[data-region=\"modal-container\"]');\n\n // Create listener to trigger the download when the \"Download\" button is pressed.\n jQuery(saveButton).on(CustomEvents.events.activate, (e) => downloadContent(e, downloadModalTrigger, modal));\n\n // Create listener to destroy the modal when closing modal by cancelling.\n jQuery(cancelButton).on(CustomEvents.events.activate, () => {\n modal.destroy();\n });\n\n // Create listener to destroy the modal when closing modal by clicking outside of it.\n if (modalContainer.querySelector('.downloadcoursecontentmodal')) {\n jQuery(modalContainer).on(CustomEvents.events.activate, () => {\n modal.destroy();\n });\n }\n });\n};\n\n/**\n * Trigger downloading of course content.\n *\n * @method downloadContent\n * @param {Event} e The event triggering the download.\n * @param {Object} downloadModalTrigger The DOM element that triggered the download modal.\n * @param {Object} modal The modal object.\n * @return {void}\n */\nconst downloadContent = (e, downloadModalTrigger, modal) => {\n e.preventDefault();\n\n // Create a form to submit the file download request, so we can avoid sending sesskey over GET.\n const downloadForm = document.createElement('form');\n downloadForm.action = downloadModalTrigger.dataset.downloadLink;\n downloadForm.method = 'POST';\n // Open download in a new tab, so current course view is not disrupted.\n downloadForm.target = '_blank';\n const downloadSesskey = document.createElement('input');\n downloadSesskey.name = 'sesskey';\n downloadSesskey.value = Config.sesskey;\n downloadForm.appendChild(downloadSesskey);\n downloadForm.style.display = 'none';\n\n document.body.appendChild(downloadForm);\n downloadForm.submit();\n document.body.removeChild(downloadForm);\n\n // Destroy the modal to prevent duplicates if reopened later.\n modal.destroy();\n};\n"],"file":"downloadcontent.min.js"}