{"version":3,"sources":["https:\/\/dl-ice.spbstu.ru\/lib\/form\/amd\/src\/events.js"],"names":["changesMadeString","then","string","catch","changesMadeCheck","e","returnValue","types","uploadStarted","uploadCompleted","triggerUploadStarted","elementId","window","addEventListener","customEvent","CustomEvent","bubbles","cancellable","element","document","getElementById","dispatchEvent","triggerUploadCompleted","removeEventListener"],"mappings":"6LA2BA,GAAIA,CAAAA,CAAJ,CACA,iBAAU,yBAAV,CAAqC,QAArC,EAA+CC,IAA\/C,CAAoD,SAAAC,CAAM,CAAI,CAC1DF,CAAiB,CAAGE,CAApB,CACA,MAAOA,CAAAA,CACV,CAHD,EAGGC,KAHH,G,GASMC,CAAAA,CAAgB,CAAG,SAAAC,CAAC,CAAI,CAC1B,GAAIA,CAAJ,CAAO,CACHA,CAAC,CAACC,WAAF,CAAgBN,CACnB,CACJ,C,CAKYO,CAAK,CAAG,CACjBC,aAAa,CAAE,yBADE,CAEjBC,eAAe,CAAE,2BAFA,C,kCAWe,QAAvBC,CAAAA,oBAAuB,CAAAC,CAAS,CAAI,CAE7CC,MAAM,CAACC,gBAAP,CAAwB,cAAxB,CAAwCT,CAAxC,EAF6C,GAGvCU,CAAAA,CAAW,CAAG,GAAIC,CAAAA,WAAJ,CAAgBR,CAAK,CAACC,aAAtB,CAAqC,CACrDQ,OAAO,GAD8C,CAErDC,WAAW,GAF0C,CAArC,CAHyB,CAOvCC,CAAO,CAAGC,QAAQ,CAACC,cAAT,CAAwBT,CAAxB,CAP6B,CAQ7CO,CAAO,CAACG,aAAR,CAAsBP,CAAtB,EAEA,MAAOA,CAAAA,CACV,C,0BAQqC,QAAzBQ,CAAAA,sBAAyB,CAAAX,CAAS,CAAI,CAE\/CC,MAAM,CAACW,mBAAP,CAA2B,cAA3B,CAA2CnB,CAA3C,EAF+C,GAGzCU,CAAAA,CAAW,CAAG,GAAIC,CAAAA,WAAJ,CAAgBR,CAAK,CAACE,eAAtB,CAAuC,CACvDO,OAAO,GADgD,CAEvDC,WAAW,GAF4C,CAAvC,CAH2B,CAOzCC,CAAO,CAAGC,QAAQ,CAACC,cAAT,CAAwBT,CAAxB,CAP+B,CAQ\/CO,CAAO,CAACG,aAAR,CAAsBP,CAAtB,EAEA,MAAOA,CAAAA,CACV,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 .\n\n\/**\n * Contain the events the form component can trigger.\n *\n * @module core_form\/events\n * @package core_form\n * @copyright 2021 Huong Nguyen \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n * @since 3.10\n *\/\n\nimport {get_string as getString} from 'core\/str';\n\nlet changesMadeString;\ngetString('changesmadereallygoaway', 'moodle').then(string => {\n changesMadeString = string;\n return string;\n}).catch();\n\n\/**\n * Prevent user navigate away when upload progress still running.\n * @param {Event} e The event\n *\/\nconst changesMadeCheck = e => {\n if (e) {\n e.returnValue = changesMadeString;\n }\n};\n\n\/**\n * List of the events.\n **\/\nexport const types = {\n uploadStarted: 'core_form\/uploadStarted',\n uploadCompleted: 'core_form\/uploadCompleted',\n};\n\n\/**\n * Trigger upload start event.\n *\n * @param {String} elementId\n * @returns {CustomEvent}\n *\/\nexport const triggerUploadStarted = elementId => {\n \/\/ Add an additional check for changes made.\n window.addEventListener('beforeunload', changesMadeCheck);\n const customEvent = new CustomEvent(types.uploadStarted, {\n bubbles: true,\n cancellable: false\n });\n const element = document.getElementById(elementId);\n element.dispatchEvent(customEvent);\n\n return customEvent;\n};\n\n\/**\n * Trigger upload complete event.\n *\n * @param {String} elementId\n * @returns {CustomEvent}\n *\/\nexport const triggerUploadCompleted = elementId => {\n \/\/ Remove the additional check for changes made.\n window.removeEventListener('beforeunload', changesMadeCheck);\n const customEvent = new CustomEvent(types.uploadCompleted, {\n bubbles: true,\n cancellable: false\n });\n const element = document.getElementById(elementId);\n element.dispatchEvent(customEvent);\n\n return customEvent;\n};\n"],"file":"events.min.js"}