Autoría | Ultima modificación | Ver Log |
{"version":3,"file":"showmore.min.js","sources":["../src/showmore.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 * Initializes and handles events fow 'showmore' components.\n *\n * @module core/showmore\n * @copyright 2023 Mikel Martín <mikel@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */
\n\nconst Selectors = {\n actions: {\n toggleContent: '[data-action=\"toggle-content\"]'\n },\n regions: {\n main: '[data-region=\"showmore\"]'\n }\n};\n\nlet initialized = false;\n\n/**\n * Initialise module\n *\n * @method\n */\nexport const init = () => {\n\n if (initialized) {\n // We already added the event listeners (can be called multiple times by mustache template).\n return;\n }\n\n // Listen for click events.\n document.addEventListener('click', (event) => {\n const toggleContent = event.target.closest(Selectors.actions.toggleContent);\n if (toggleContent) {\n const region = toggleContent.closest(Selectors.regions.main);\n region.classList.toggle('collapsed');\n const toggleButton = region.querySelector(Selectors.actions.toggleContent);\n toggleButton.setAttribute('aria-expanded', !region.classList.contains('collapsed'));\n }\n });\n\n initialized = true;\n};\n"],"names":["Sele
ctors","toggleContent","main","initialized","document","addEventListener","event","target","closest","region","classList","toggle","querySelector","setAttribute","contains"],"mappings":";;;;;;;;MAuBMA,kBACO,CACLC,cAAe,kCAFjBD,kBAIO,CACLE,KAAM,gCAIVC,aAAc,gBAOE,KAEZA,cAMJC,SAASC,iBAAiB,SAAUC,cAC1BL,cAAgBK,MAAMC,OAAOC,QAAQR,kBAAkBC,kBACzDA,cAAe,OACTQ,OAASR,cAAcO,QAAQR,kBAAkBE,MACvDO,OAAOC,UAAUC,OAAO,aACHF,OAAOG,cAAcZ,kBAAkBC,eAC/CY,aAAa,iBAAkBJ,OAAOC,UAAUI,SAAS,kBAI9EX,aAAc"}