{"version":3,"file":"dndcmitem.min.js","sources":["https:\/\/www.alsg.org\/home\/course\/format\/amd\/src\/local\/courseeditor\/dndcmitem.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 * Course index cm component.\n *\n * This component is used to control specific course modules interactions like drag and drop\n * in both course index and course content.\n *\n * @module core_courseformat\/local\/courseeditor\/dndcmitem\n * @class core_courseformat\/local\/courseeditor\/dndcmitem\n * @copyright 2021 Ferran Recio \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nimport {BaseComponent, DragDrop} from 'core\/reactive';\n\nexport default class extends BaseComponent {\n\n \/**\n * Configure the component drag and drop.\n *\n * @param {number} cmid course module id\n *\/\n configDragDrop(cmid) {\n\n this.id = cmid;\n\n \/\/ Drag and drop is only available for components compatible course formats.\n if (this.reactive.isEditing && this.reactive.supportComponents) {\n \/\/ Init element drag and drop.\n this.dragdrop = new DragDrop(this);\n \/\/ Save dropzone classes.\n this.classes = this.dragdrop.getClasses();\n }\n }\n\n \/**\n * Remove all subcomponents dependencies.\n *\/\n destroy() {\n if (this.dragdrop !== undefined) {\n this.dragdrop.unregister();\n }\n }\n\n \/\/ Drag and drop methods.\n\n \/**\n * The element drop start hook.\n *\n * @param {Object} dropdata the dropdata\n *\/\n dragStart(dropdata) {\n this.reactive.dispatch('cmDrag', [dropdata.id], true);\n }\n\n \/**\n * The element drop end hook.\n *\n * @param {Object} dropdata the dropdata\n *\/\n dragEnd(dropdata) {\n this.reactive.dispatch('cmDrag', [dropdata.id], false);\n }\n\n \/**\n * Get the draggable data of this component.\n *\n * @returns {Object} exported course module drop data\n *\/\n getDraggableData() {\n const exporter = this.reactive.getExporter();\n return exporter.cmDraggableData(this.reactive.state, this.id);\n }\n\n \/**\n * Validate if the drop data can be dropped over the component.\n *\n * @param {Object} dropdata the exported drop data.\n * @returns {boolean}\n *\/\n validateDropData(dropdata) {\n return dropdata?.type === 'cm';\n }\n\n \/**\n * Display the component dropzone.\n *\n * @param {Object} dropdata the accepted drop data\n *\/\n showDropZone(dropdata) {\n \/\/ If we are the next cmid of the dragged element we accept the drop because otherwise it\n \/\/ will get captured by the section. However, we won't trigger any mutation.\n if (dropdata.nextcmid != this.id && dropdata.id != this.id) {\n this.element.classList.add(this.classes.DROPUP);\n }\n }\n\n \/**\n * Hide the component dropzone.\n *\/\n hideDropZone() {\n this.element.classList.remove(this.classes.DROPUP);\n }\n\n \/**\n * Drop event handler.\n *\n * @param {Object} dropdata the accepted drop data\n *\/\n drop(dropdata) {\n \/\/ Call the move mutation if necessary.\n if (dropdata.id != this.id && dropdata.nextcmid != this.id) {\n this.reactive.dispatch('cmMove', [dropdata.id], null, this.id);\n }\n }\n\n}\n"],"names":["BaseComponent","configDragDrop","cmid","id","this","reactive","isEditing","supportComponents","dragdrop","DragDrop","classes","getClasses","destroy","undefined","unregister","dragStart","dropdata","dispatch","dragEnd","getDraggableData","getExporter","cmDraggableData","state","validateDropData","type","showDropZone","nextcmid","element","classList","add","DROPUP","hideDropZone","remove","drop"],"mappings":";;;;;;;;;;;;uBA6B6BA,wBAOzBC,eAAeC,WAENC,GAAKD,KAGNE,KAAKC,SAASC,WAAaF,KAAKC,SAASE,yBAEpCC,SAAW,IAAIC,mBAASL,WAExBM,QAAUN,KAAKI,SAASG,cAOrCC,eAC0BC,IAAlBT,KAAKI,eACAA,SAASM,aAWtBC,UAAUC,eACDX,SAASY,SAAS,SAAU,CAACD,SAASb,KAAK,GAQpDe,QAAQF,eACCX,SAASY,SAAS,SAAU,CAACD,SAASb,KAAK,GAQpDgB,0BACqBf,KAAKC,SAASe,cACfC,gBAAgBjB,KAAKC,SAASiB,MAAOlB,KAAKD,IAS9DoB,iBAAiBP,gBACa,QAAnBA,MAAAA,gBAAAA,SAAUQ,MAQrBC,aAAaT,UAGLA,SAASU,UAAYtB,KAAKD,IAAMa,SAASb,IAAMC,KAAKD,SAC\/CwB,QAAQC,UAAUC,IAAIzB,KAAKM,QAAQoB,QAOhDC,oBACSJ,QAAQC,UAAUI,OAAO5B,KAAKM,QAAQoB,QAQ\/CG,KAAKjB,UAEGA,SAASb,IAAMC,KAAKD,IAAMa,SAASU,UAAYtB,KAAKD,SAC\/CE,SAASY,SAAS,SAAU,CAACD,SAASb,IAAK,KAAMC,KAAKD"}