{"version":3,"file":"tabtitle.min.js","sources":["https:\/\/moodle.tau.ac.il\/2023\/course\/format\/multitopic\/amd\/src\/courseformat\/contenttabs\/tabtitle.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 * Tab header component.\n *\n * This component is used to control specific tab interactions like drag and drop.\n *\n * @module format_multitopic\/courseformat\/contenttabs\/tabtitle\n * @class format_multitopic\/courseformat\/contenttabs\/tabtitle\n * @copyright 2023 James Calder and Otago Polytechnic\n * @copyright based on work by 2021 Ferran Recio \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nimport DndSectionItem from 'core_courseformat\/local\/courseeditor\/dndsectionitem';\n\nexport default class extends DndSectionItem {\n\n \/**\n * Constructor hook.\n *\n * @param {Object} descriptor\n *\/\n create(descriptor) {\n \/\/ Optional component name for debugging.\n this.name = 'contenttabs_tabtitle';\n \/\/ We need our id to watch specific events.\n\n \/\/ Get main info from the descriptor.\n this.id = descriptor.id;\n this.section = descriptor.section;\n this.course = descriptor.course;\n this.fullregion = descriptor.fullregion;\n }\n\n \/**\n * Initial state ready method.\n *\n * @param {Object} state the initial state\n *\/\n stateReady(state) {\n this.configDragDrop(this.id, state, this.fullregion);\n }\n\n \/**\n * Initial state ready method.\n *\n * @param {number} sectionid the section id\n * @param {Object} state the initial state\n * @param {Element} fullregion the complete section region to mark as dragged\n *\/\n configDragDrop(sectionid, state, fullregion) {\n super.configDragDrop(sectionid, state, fullregion);\n if (fullregion.className.match(\/\\btab_level_(\\d+)\\b\/)[1] != this.section.levelsan) {\n this.getDraggableData = undefined;\n }\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 \/\/ We accept a section that fits\n if (dropdata?.type === 'section') {\n const sectionzeroid = this.course.sectionlist[0];\n const origin = this.reactive.get(\"section\", dropdata.id);\n const targettablevel = this.fullregion.className.match(\/\\btab_level_(\\d+)\\b\/)[1];\n return dropdata?.id != this.id && targettablevel < origin.levelsan\n && origin.id != sectionzeroid;\n }\n return false;\n }\n\n \/**\n * Display the component dropzone.\n *\/\n showDropZone() {\n this.element.classList.add(this.classes.DROPZONE);\n }\n\n \/**\n * Hide the component dropzone.\n *\/\n hideDropZone() {\n this.element.classList.remove(this.classes.DROPZONE);\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.\n if (dropdata.type == 'section') {\n const origin = this.reactive.get(\"section\", dropdata.id);\n const target = this.section;\n const targettablevel = this.fullregion.className.match(\/\\btab_level_(\\d+)\\b\/)[1];\n if (targettablevel < origin.levelsan) {\n this.reactive.dispatch('fmtSectionMoveInto', [origin.id], target.id);\n }\n }\n }\n\n}"],"names":["DndSectionItem","create","descriptor","name","id","section","course","fullregion","stateReady","state","configDragDrop","this","sectionid","className","match","levelsan","getDraggableData","undefined","validateDropData","dropdata","type","sectionzeroid","sectionlist","origin","reactive","get","targettablevel","showDropZone","element","classList","add","classes","DROPZONE","hideDropZone","remove","drop","target","dispatch"],"mappings":";;;;;;;;;;;oLA6B6BA,wBAOzBC,OAAOC,iBAEEC,KAAO,4BAIPC,GAAKF,WAAWE,QAChBC,QAAUH,WAAWG,aACrBC,OAASJ,WAAWI,YACpBC,WAAaL,WAAWK,WAQjCC,WAAWC,YACFC,eAAeC,KAAKP,GAAIK,MAAOE,KAAKJ,YAU7CG,eAAeE,UAAWH,MAAOF,kBACvBG,eAAeE,UAAWH,MAAOF,YACnCA,WAAWM,UAAUC,MAAM,uBAAuB,IAAMH,KAAKN,QAAQU,gBAChEC,sBAAmBC,GAUhCC,iBAAiBC,aAEU,aAAnBA,MAAAA,gBAAAA,SAAUC,MAAoB,OACxBC,cAAgBV,KAAKL,OAAOgB,YAAY,GACxCC,OAASZ,KAAKa,SAASC,IAAI,UAAWN,SAASf,IAC\/CsB,eAAiBf,KAAKJ,WAAWM,UAAUC,MAAM,uBAAuB,UACvEK,MAAAA,gBAAAA,SAAUf,KAAMO,KAAKP,IAAMsB,eAAiBH,OAAOR,UAC\/CQ,OAAOnB,IAAMiB,qBAErB,EAMXM,oBACSC,QAAQC,UAAUC,IAAInB,KAAKoB,QAAQC,UAM5CC,oBACSL,QAAQC,UAAUK,OAAOvB,KAAKoB,QAAQC,UAQ\/CG,KAAKhB,aAEoB,WAAjBA,SAASC,KAAmB,OACtBG,OAASZ,KAAKa,SAASC,IAAI,UAAWN,SAASf,IAC\/CgC,OAASzB,KAAKN,QACGM,KAAKJ,WAAWM,UAAUC,MAAM,uBAAuB,GACzDS,OAAOR,eACnBS,SAASa,SAAS,qBAAsB,CAACd,OAAOnB,IAAKgC,OAAOhC"}