Current Path : C:/Users/Mahmood/Desktop/moodle/course/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/course/amd/build/copy_modal.min.js.map |
{"version":3,"sources":["../src/copy_modal.js"],"names":["define","$","Str","ModalFactory","ModalEvents","ajax","Fragment","Notification","Config","CopyModal","contextid","course","modalObj","spinner","createModal","get_string","then","title","create","type","types","DEFAULT","body","large","done","modal","getRoot","on","processModalForm","e","formredirect","preventDefault","setBody","hide","catch","exception","Error","updateModalBody","formdata","params","JSON","stringify","id","shortname","setTitle","loadFragment","copyform","find","serialize","formjson","invalid","merge","length","first","focus","call","methodname","args","jsonformdata","redirect","wwwroot","window","location","assign","fail","init","context","url","URL","getAttribute","URLSearchParams","search","courseid","get","response","show"],"mappings":"AA2BAA,OAAM,0BAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,oBAAvB,CAA6C,mBAA7C,CACC,WADD,CACc,eADd,CAC+B,mBAD/B,CACoD,aADpD,CAAD,CAEE,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA+BC,CAA/B,CAA4CC,CAA5C,CAAkDC,CAAlD,CAA4DC,CAA5D,CAA0EC,CAA1E,CAAkF,IAKlFC,CAAAA,CAAS,CAAG,EALsE,CAMlFC,CANkF,CAOlFC,CAPkF,CAQlFC,CARkF,CASlFC,CAAO,oFAT2E,CAkBtF,QAASC,CAAAA,CAAT,EAAuB,CAEnBZ,CAAG,CAACa,UAAJ,CAAe,SAAf,EAA0BC,IAA1B,CAA+B,SAASC,CAAT,CAAgB,CAE3Cd,CAAY,CAACe,MAAb,CAAoB,CAChBC,IAAI,CAAEhB,CAAY,CAACiB,KAAb,CAAmBC,OADT,CAEhBJ,KAAK,CAAEA,CAFS,CAGhBK,IAAI,CAAET,CAHU,CAIhBU,KAAK,GAJW,CAApB,EAMCC,IAND,CAMM,SAASC,CAAT,CAAgB,CAClBb,CAAQ,CAAGa,CAAX,CAEAb,CAAQ,CAACc,OAAT,GAAmBC,EAAnB,CAAsB,OA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B,CAAqB,OAArB,CAA8B,SAASE,CAAT,CAAY,CACtCA,CAAC,CAACE,cAAF,GADsC,GAElCoC,CAAAA,CAAG,CAAG,GAAIC,CAAAA,GAAJ,CAAQ,KAAKC,YAAL,CAAkB,MAAlB,CAAR,CAF4B,CAGlC9B,CAAM,CAAG,GAAI+B,CAAAA,eAAJ,CAAoBH,CAAG,CAACI,MAAxB,CAHyB,CAIlCC,CAAQ,CAAGjC,CAAM,CAACkC,GAAP,CAAW,IAAX,CAJuB,CAMtCpE,CAAI,CAACkD,IAAL,CAAU,CAAC,CACPC,UAAU,CAAE,yBADL,CAEPC,IAAI,CAAE,CACF,QAAW,CAAC,IAAO,CAACe,CAAD,CAAR,CADT,CAFC,CAAD,CAAV,EAKI,CALJ,EAKOhD,IALP,CAKY,SAASkD,CAAT,CAAmB,CAE3B/D,CAAM,CAAG+D,CAAQ,CAAC,CAAD,CAAjB,CACArC,CAAe,EAElB,CAVD,EAUG2B,IAVH,CAUQ,UAAW,CACfzD,CAAY,CAAC4B,SAAb,CAAuB,GAAIC,CAAAA,KAAJ,CAAU,uBAAV,CAAvB,CACH,CAZD,EAcAxB,CAAQ,CAAC+D,IAAT,EACH,CArBD,CAuBH,CA7BD,CA+BA,MAAOlE,CAAAA,CACV,CAlKK,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 * This module provides the course copy modal from the course and\n * category management screen.\n *\n * @module course\n * @package core\n * @copyright 2020 onward The Moodle Users Association <https://moodleassociation.org/>\n * @author Matt Porritt <mattp@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.9\n */\n\ndefine(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events',\n 'core/ajax', 'core/fragment', 'core/notification', 'core/config'],\n function($, Str, ModalFactory, ModalEvents, ajax, Fragment, Notification, Config) {\n\n /**\n * Module level variables.\n */\n var CopyModal = {};\n var contextid;\n var course;\n var modalObj;\n var spinner = '<p class=\"text-center\">'\n + '<i class=\"fa fa-spinner fa-pulse fa-2x fa-fw\"></i>'\n + '</p>';\n\n /**\n * Creates the modal for the course copy form\n *\n * @private\n */\n function createModal() {\n // Get the Title String.\n Str.get_string('loading').then(function(title) {\n // Create the Modal.\n ModalFactory.create({\n type: ModalFactory.types.DEFAULT,\n title: title,\n body: spinner,\n large: true\n })\n .done(function(modal) {\n modalObj = modal;\n // Explicitly handle form click events.\n modalObj.getRoot().on('click', '#id_submitreturn', processModalForm);\n modalObj.getRoot().on('click', '#id_submitdisplay', function(e) {\n e.formredirect = true;\n processModalForm(e);\n\n });\n modalObj.getRoot().on('click', '#id_cancel', function(e) {\n e.preventDefault();\n modalObj.setBody(spinner);\n modalObj.hide();\n });\n });\n return;\n }).catch(function() {\n Notification.exception(new Error('Failed to load string: loading'));\n });\n }\n\n /**\n * Updates the body of the modal window.\n *\n * @param {Object} formdata\n * @private\n */\n function updateModalBody(formdata) {\n if (typeof formdata === \"undefined\") {\n formdata = {};\n }\n\n var params = {\n 'jsonformdata': JSON.stringify(formdata),\n 'courseid': course.id\n };\n\n modalObj.setBody(spinner);\n Str.get_string('copycoursetitle', 'backup', course.shortname).then(function(title) {\n modalObj.setTitle(title);\n modalObj.setBody(Fragment.loadFragment('course', 'new_base_form', contextid, params));\n return;\n }).catch(function() {\n Notification.exception(new Error('Failed to load string: copycoursetitle'));\n });\n }\n\n /**\n * Updates Moodle form with selected information.\n *\n * @param {Object} e\n * @private\n */\n function processModalForm(e) {\n e.preventDefault(); // Stop modal from closing.\n\n // Form data.\n var copyform = modalObj.getRoot().find('form').serialize();\n var formjson = JSON.stringify(copyform);\n\n // Handle invalid form fields for better UX.\n var invalid = $.merge(\n modalObj.getRoot().find('[aria-invalid=\"true\"]'),\n modalObj.getRoot().find('.error')\n );\n\n if (invalid.length) {\n invalid.first().focus();\n return;\n }\n\n // Submit form via ajax.\n ajax.call([{\n methodname: 'core_backup_submit_copy_form',\n args: {\n jsonformdata: formjson\n },\n }])[0].done(function() {\n // For submission succeeded.\n modalObj.setBody(spinner);\n modalObj.hide();\n\n if (e.formredirect == true) {\n // We are redirecting to copy progress display.\n let redirect = Config.wwwroot + \"/backup/copyprogress.php?id=\" + course.id;\n window.location.assign(redirect);\n }\n\n }).fail(function() {\n // Form submission failed server side, redisplay with errors.\n updateModalBody(copyform);\n });\n }\n\n /**\n * Initialise the class.\n *\n * @param {Object} context\n * @public\n */\n CopyModal.init = function(context) {\n contextid = context;\n // Setup the initial Modal.\n createModal();\n\n // Setup the click handlers on the copy buttons.\n $('.action-copy').on('click', function(e) {\n e.preventDefault(); // Stop. Hammer time.\n let url = new URL(this.getAttribute('href'));\n let params = new URLSearchParams(url.search);\n let courseid = params.get('id');\n\n ajax.call([{ // Get the course information.\n methodname: 'core_course_get_courses',\n args: {\n 'options': {'ids': [courseid]},\n },\n }])[0].done(function(response) {\n // We have the course info get the modal content.\n course = response[0];\n updateModalBody();\n\n }).fail(function() {\n Notification.exception(new Error('Failed to load course'));\n });\n\n modalObj.show();\n });\n\n };\n\n return CopyModal;\n});\n"],"file":"copy_modal.min.js"}