Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"sources":["../src/dragndrop.js"],"names":["init","window","console","log","columnnotes","document","getElementsByClassName","Array","from","forEach","column","Sortable","create","group","draggable","pull","onEnd","evt","to","oldDraggableIndex","newDraggableIndex","noteid","parseInt","item","id","replace","oldcolumnid","newcolumnid","oldindex","newindex","promise","Ajax","call","methodname","args","done","response","JSON","stringify","fail","ex"],"mappings":"wcAwBA,uDACA,O,6iBAEoB,QAAPA,CAAAA,IAAO,EAAM,CACtBC,MAAM,CAACC,OAAP,CAAeC,GAAf,CAAmB,sBAAnB,EAEA,GAAIC,CAAAA,CAAW,CAAGC,QAAQ,CAACC,sBAAT,CAAgC,YAAhC,CAAlB,CAEAC,KAAK,CAACC,IAAN,CAAWJ,CAAX,EAAwBK,OAAxB,CAAgC,SAACC,CAAD,CAAY,CAEzBC,UAASC,MAAT,CAAgBF,CAAhB,CAAwB,CACnCG,KAAK,CAAE,YAD4B,CAEnCC,SAAS,CAAE,SAFwB,CAGnCC,IAAI,CAAE,MAH6B,CAKnCC,KAAK,CAAE,eAAoBC,CAApB,CAAyB,CAE5B,GAAKA,CAAG,CAACT,IAAJ,GAAaS,CAAG,CAACC,EAAlB,EAA0BD,CAAG,CAACE,iBAAJ,GAA0BF,CAAG,CAACG,iBAA5D,CAAgF,CAE9E,CAFF,IAEQ,IACAC,CAAAA,CAAM,CAAGC,QAAQ,CAACL,CAAG,CAACM,IAAJ,CAASC,EAAT,CAAYC,OAAZ,CAAoB,SAApB,CAA+B,EAA/B,EAAmCA,OAAnC,CAA2C,WAA3C,CAAwD,EAAxD,CAAD,CADjB,CAEAC,CAAW,CAAGJ,QAAQ,CAACL,CAAG,CAACT,IAAJ,CAASgB,EAAT,CAAYC,OAAZ,CAAoB,QAApB,CAA8B,EAA9B,CAAD,CAFtB,CAGAE,CAAW,CAAGL,QAAQ,CAACL,CAAG,CAACC,EAAJ,CAAOM,EAAP,CAAUC,OAAV,CAAkB,QAAlB,CAA4B,EAA5B,CAAD,CAHtB,CAIAG,CAAQ,CAAGX,CAAG,CAACE,iBAAJ,CAAwB,CAJnC,CAKAU,CAAQ,CAAGZ,CAAG,CAACG,iBAAJ,CAAwB,CALnC,CAMAU,CAAO,CAAGC,CAAI,CAACC,IAAL,CAAU,CAAC,CACrBC,UAAU,CAAE,wCADS,CAErBC,IAAI,CAAE,CAAEb,MAAM,CAAEA,CAAV,CACEK,WAAW,CAAEA,CADf,CAEEC,WAAW,CAAEA,CAFf,CAGEC,QAAQ,CAAEA,CAHZ,CAIEC,QAAQ,CAAEA,CAJZ,CAFe,CAAD,CAAV,CANV,CAeJC,CAAO,CAAC,CAAD,CAAP,CAAWK,IAAX,CAAgB,SAASC,CAAT,CAAmB,CAC/BnC,MAAM,CAACC,OAAP,CAAeC,GAAf,CAAmB,oCAAsCkC,IAAI,CAACC,SAAL,CAAeF,CAAf,CAAzD,CACH,CAFD,EAEGG,IAFH,CAEQ,SAASC,CAAT,CAAa,CACjBvC,MAAM,CAACC,OAAP,CAAeC,GAAf,CAAmB,mCAAqCkC,IAAI,CAACC,SAAL,CAAeE,CAAf,CAAxD,CACH,CAJD,CAKH,CACJ,CA9BkC,CAAxB,CAgClB,CAlCD,CAmCF,C","sourcesContent":["\n// 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 * JavaScript for the drag'n'drop functionnality.\n *\n * @package   mod_stickynotes\n * @copyright 2021 Sébastien Mehr <sebmehr.fr>\n * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Sortable from 'sortablejs';\nimport * as Ajax from 'core/ajax';\n\nexport const init = () => {\n    window.console.log('we have been started');\n\n    var columnnotes = document.getElementsByClassName('columnnote');\n\n    Array.from(columnnotes).forEach((column) => {\n        // Do stuff here\n        var sortable = Sortable.create(column, {\n            group: \"columnnote\",\n            draggable: \".stickynotemod\",\n            pull: \"true\",\n\n            onEnd: function (/**Event*/evt) {\n\n                if ((evt.from === evt.to) && (evt.oldDraggableIndex === evt.newDraggableIndex)) {\n                    return;\n                 } else {\n                    var noteid = parseInt(evt.item.id.replace('element', '').replace('container', ''));\n                    var oldcolumnid = parseInt(evt.from.id.replace('column', ''));\n                    var newcolumnid = parseInt(evt.to.id.replace('column', ''));\n                    var oldindex = evt.oldDraggableIndex + 1;\n                    var newindex = evt.newDraggableIndex + 1;\n                    var promise = Ajax.call([{\n                        methodname: 'mod_stickynotes_changing_note_position',\n                        args: { noteid: noteid,\n                                oldcolumnid: oldcolumnid,\n                                newcolumnid: newcolumnid,\n                                oldindex: oldindex,\n                                newindex: newindex\n                            },\n                    }]);\n                    promise[0].done(function(response) {\n                        window.console.log('mod_stickynotes/dragndrop success' + JSON.stringify(response));\n                    }).fail(function(ex) {\n                        window.console.log('mod_stickynotes/dragndrop erreur' + JSON.stringify(ex));\n                    });\n                }\n            },\n        });\n    });\n };"],"file":"dragndrop.min.js"}