1441 |
ariadna |
1 |
{"version":3,"file":"displayunlisted.min.js","sources":["../src/displayunlisted.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 * Module to handle toggling \"Display unlisted\" preference\n *\n * @module core_contentbank/displayunlisted\n * @copyright 2023 Daniel Neis Araujo\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport {setUserPreference} from 'core_user/repository';\n\n/**\n * Initialize module, add event listeners\n *\n * @param {String} elementSelector\n */\nexport const init = elementSelector => {\n document.addEventListener('click', event => {\n const element = event.target.closest(elementSelector);\n if (element) {\n const pendingPromise = new Pending('core_contentbank/displayunlisted');\n\n setUserPreference('core_contentbank_displayunlisted', !!element.checked)\n .then(() => {\n pendingPromise.resolve();\n return document.location.reload();\n })\n .catch(Notification.exception);\n }\n });\n};\n"],"names":["elementSelector","document","addEventListener","event","element","target","closest","pendingPromise","Pending","checked","then","resolve","location","reload","catch","Notification","exception"],"mappings":";;;;;;;8LAgCoBA,kBAChBC,SAASC,iBAAiB,SAASC,cACzBC,QAAUD,MAAME,OAAOC,QAAQN,oBACjCI,QAAS,OACHG,eAAiB,IAAIC,iBAAQ,sEAEjB,qCAAsCJ,QAAQK,SAC3DC,MAAK,KACFH,eAAeI,UACRV,SAASW,SAASC,YAE5BC,MAAMC,sBAAaC"}
|