{"version":3,"file":"offcanvas.min.js","sources":["https:\/\/moodle.sapir.ac.il\/2022\/theme\/learnr\/amd\/src\/offcanvas.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 * Theme LearnR - JS code off-canvas\n *\n * @module theme_learnr\/offcanvas\n * @copyright 2022 bdecent gmbh \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\ndefine(['jquery', 'theme_boost\/drawers', 'core\/modal'], function($, Drawers, Modal) {\n\n let modalBackdrop = null;\n\n \/**\n * Helper function to get the OffCanvas backdrop and add an EventListener which closes\n * the drawer as soon as the user clicks on the backdrop.\n *\n * @returns {object}\n *\/\n const getDrawerBackdrop = function() {\n if (!modalBackdrop) {\n modalBackdrop = Modal.prototype.getBackdrop().then(backdrop => {\n backdrop.getAttachmentPoint().get(0).addEventListener('click', e => {\n e.preventDefault();\n var currentDrawer = Drawers.getDrawerInstanceForNode(\n document.getElementById('theme_learnr-drawers-offcanvas')\n );\n currentDrawer.closeDrawer(false);\n backdrop.hide();\n });\n return backdrop;\n })\n .catch();\n }\n return modalBackdrop;\n };\n\n \/**\n * Used this listener to hide the off canvas drawer from the page.\n *\/\n function initOffcanvasBackdrop() {\n \/\/ Add EventListener for showing a drawer.\n document.addEventListener(Drawers.eventTypes.drawerShown, function(e) {\n \/\/ If the drawer which is shown is _not_ the offcanvas drawer, return.\n if (e.target.id != 'theme_learnr-drawers-offcanvas') {\n return null;\n }\n\n \/\/ Get the drawer's backdrop and show it.\n getDrawerBackdrop().then(backdrop => {\n backdrop.show();\n return backdrop;\n })\n .catch();\n\n return true;\n });\n\n \/\/ Add EventListener for hiding a drawer.\n document.addEventListener(Drawers.eventTypes.drawerHide, function(e) {\n \/\/ If the drawer which is hidden is _not_ the offcanvas drawer, return.\n if (e.target.id != 'theme_learnr-drawers-offcanvas') {\n return null;\n }\n\n getDrawerBackdrop().then(backdrop => {\n backdrop.hide();\n return backdrop;\n })\n .catch();\n\n return true;\n });\n }\n\n return {\n init: function() {\n initOffcanvasBackdrop();\n }\n };\n});\n"],"names":["define","$","Drawers","Modal","modalBackdrop","getDrawerBackdrop","prototype","getBackdrop","then","backdrop","getAttachmentPoint","get","addEventListener","e","preventDefault","getDrawerInstanceForNode","document","getElementById","closeDrawer","hide","catch","init","eventTypes","drawerShown","target","id","show","drawerHide"],"mappings":";;;;;;;AAuBAA,qCAAO,CAAC,SAAU,sBAAuB,eAAe,SAASC,EAAGC,QAASC,WAErEC,cAAgB,WAQdC,kBAAoB,kBACjBD,gBACAA,cAAgBD,MAAMG,UAAUC,cAAcC,MAAKC,WAChDA,SAASC,qBAAqBC,IAAI,GAAGC,iBAAiB,SAASC,IAC3DA,EAAEC,iBACkBZ,QAAQa,yBACxBC,SAASC,eAAe,wCAEdC,aAAY,GAC1BT,SAASU,UAENV,YAEVW,SAEEhB,qBAyCJ,CACHiB,KAAM,WAlCNL,SAASJ,iBAAiBV,QAAQoB,WAAWC,aAAa,SAASV,SAE5C,uCAAfA,EAAEW,OAAOC,GACF,MAIXpB,oBAAoBG,MAAKC,WACrBA,SAASiB,OACFjB,YAEVW,SAEM,MAIXJ,SAASJ,iBAAiBV,QAAQoB,WAAWK,YAAY,SAASd,SAE3C,uCAAfA,EAAEW,OAAOC,GACF,MAGXpB,oBAAoBG,MAAKC,WACrBA,SAASU,OACFV,YAEVW,SAEM"}