{"version":3,"file":"coursecover.min.js","sources":["https:\/\/leren.vluchtelingenwerk.nl\/admin\/tool\/catalogue\/amd\/src\/coursecover.js"],"sourcesContent":["\/\/ This file is part of Moodle Workplace https:\/\/moodle.com\/workplace based on Moodle\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\/\/ Moodle Workplace\u2122 Code is the collection of software scripts\n\/\/ (plugins and modifications, and any derivations thereof) that are\n\/\/ exclusively owned and licensed by Moodle under the terms of this\n\/\/ proprietary Moodle Workplace License (\"MWL\") alongside Moodle's open\n\/\/ software package offering which itself is freely downloadable at\n\/\/ \"download.moodle.org\" and which is provided by Moodle under a single\n\/\/ GNU General Public License version 3.0, dated 29 June 2007 (\"GPL\").\n\/\/ MWL is strictly controlled by Moodle Pty Ltd and its certified\n\/\/ premium partners. Wherever conflicting terms exist, the terms of the\n\/\/ MWL are binding and shall prevail.\n\n\/**\n * Set this course cover page as seen.\n *\n * @module tool_catalogue\/coursecover\n * @author 2022 Bas Brands \n * @copyright 2022 Moodle Pty Ltd \n * @license Moodle Workplace License, distribution is restricted, contact support@moodle.com\n *\/\n\nimport SELECTORS from '.\/selectors';\nimport Notification from 'core\/notification';\nimport {setUserPreferences} from 'tool_catalogue\/local\/repository\/userpreferences';\n\n\/**\n * Set user preference to show course content.\n *\n * @param {Number} courseId The course id.\n * @param {Number} userId The user id.\n *\/\nexport const init = (courseId, userId) => {\n\n document.addEventListener('click', (event) => {\n \/\/ Proceed to course content.\n const startCourseButton = event.target.closest(SELECTORS.actions.startCourse);\n if (startCourseButton) {\n const preferences = [{\n 'userid': userId,\n 'name': `tool_catalogue_show_course_content_${courseId}`,\n 'value': true\n }];\n setUserPreferences(preferences).then((data) => {\n if (data.saved) {\n const modal = startCourseButton.closest(SELECTORS.regions.courseCoverModal);\n const modalBackdrop = document.querySelector(SELECTORS.regions.courseCoverModalBackdrop);\n \/\/ Hide bootstrap modal.\n modal.classList.remove('show');\n modalBackdrop.classList.replace('show', 'hide');\n }\n return;\n }).catch(Notification.exception);\n }\n });\n};\n"],"names":["courseId","userId","document","addEventListener","event","startCourseButton","target","closest","SELECTORS","actions","startCourse","preferences","then","data","saved","modal","regions","courseCoverModal","modalBackdrop","querySelector","courseCoverModalBackdrop","classList","remove","replace","catch","Notification","exception"],"mappings":";;;;;;;;kMA6CoB,CAACA,SAAUC,UAE3BC,SAASC,iBAAiB,SAAUC,cAE1BC,kBAAoBD,MAAME,OAAOC,QAAQC,mBAAUC,QAAQC,gBAC7DL,kBAAmB,OACbM,YAAc,CAAC,QACPV,yDACoCD,iBACrC,4CAEMW,aAAaC,MAAMC,UAC9BA,KAAKC,MAAO,OACNC,MAAQV,kBAAkBE,QAAQC,mBAAUQ,QAAQC,kBACpDC,cAAgBhB,SAASiB,cAAcX,mBAAUQ,QAAQI,0BAE\/DL,MAAMM,UAAUC,OAAO,QACvBJ,cAAcG,UAAUE,QAAQ,OAAQ,YAG7CC,MAAMC,sBAAaC"}