1 |
efrain |
1 |
{"version":3,"file":"recommendations.min.js","sources":["../src/recommendations.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 <http://www.gnu.org/licenses/>.\n\n/**\n * A javascript module to handle toggling activity chooser recommendations.\n *\n * @module core_course/recommendations\n * @copyright 2020 Adrian Greeve <adrian@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Do an ajax call to toggle the recommendation\n *\n * @param {object} e The event\n * @return {void}\n */\nconst toggleRecommendation = (e) => {\n let data = {\n methodname: 'core_course_toggle_activity_recommendation',\n args: {\n area: e.currentTarget.dataset.area,\n id: e.currentTarget.dataset.id\n }\n };\n Ajax.call([data])[0].fail(Notification.exception);\n};\n\n/**\n * Initialisation function\n *\n * @return {void}\n */\nexport const init = () => {\n const checkboxelements = document.querySelectorAll(\"[data-area]\");\n checkboxelements.forEach((checkbox) => {\n checkbox.addEventListener('change', toggleRecommendation);\n });\n};\n"],"names":["toggleRecommendation","e","data","methodname","args","area","currentTarget","dataset","id","call","fail","Notification","exception","document","querySelectorAll","forEach","checkbox","addEventListener"],"mappings":";;;;;;;gLAgCMA,qBAAwBC,QACtBC,KAAO,CACPC,WAAY,6CACZC,KAAM,CACFC,KAAMJ,EAAEK,cAAcC,QAAQF,KAC9BG,GAAIP,EAAEK,cAAcC,QAAQC,mBAG/BC,KAAK,CAACP,OAAO,GAAGQ,KAAKC,sBAAaC,0BAQvB,KACSC,SAASC,iBAAiB,eAClCC,SAASC,WACtBA,SAASC,iBAAiB,SAAUjB"}
|