AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"sticky-footer.min.js","sources":["../src/sticky-footer.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 * Sticky footer wrapper module.\n *\n * Themes are responsible for implementing the sticky footer. However,\n * modules can interact with the sticky footer using this module.\n *\n * @module core/sticky-footer\n *
@copyright 2023 Ferran Recio <ferran@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {dispatchEvent} from 'core/event_dispatcher';\n\nlet manager = {};\n\nlet enabled = false;\n\nlet initialized = false;\n\nexport const SELECTORS = {\n STICKYFOOTER: '.stickyfooter',\n};\n\nconst CLASSES = {\n INVISIBLE: 'v-hidden',\n};\n\nexport const eventTypes = {\n stickyFooterStateChanged: 'core/stickyfooter_state_changed',\n};\n\n/**\n * Enable sticky footer in the page.\n */\nexport const enableStickyFooter = () => {\n enabled = true;\n if (manager.enableStickyFooter === undefined) {\n document.querySelector(SELECTORS.STICKYFOOTER)?.classList.remove(CLASSES.INVISIBLE);\n return;\n }\n manager.enableStickyFooter();\n notifyStickyFooterStateChange(true);\n};\n\n/**\n * Disable sticky footer in the page.\n */\nexport const disableStickyFooter = () => {\n enabled = false;\n if (manager.disableStickyFooter === undefined) {\n
document.querySelector(SELECTORS.STICKYFOOTER)?.classList.add(CLASSES.INVISIBLE);\n return;\n }\n manager.disableStickyFooter();\n notifyStickyFooterStateChange(false);\n};\n\n/**\n * Register the theme sticky footer methods.\n *\n * @param {Object} themeManager the manager object with all the needed methods.\n * @param {Function} themeManager.enableStickyFooter enable sticky footer method\n * @param {Function} themeManager.disableStickyFooter disable sticky footer method\n */\nexport const registerManager = (themeManager) => {\n manager = themeManager;\n if (enabled) {\n enableStickyFooter();\n }\n};\n\n/**\n * Initialize the module if the theme does not implement its own init.\n */\nexport const init = () => {\n if (initialized) {\n return;\n }\n initialized = true;\n\n const isDisabled = document.querySelector(SELECTORS.STICKYFOOTER)?.dataset.disable;\n if (isDisabled) {\n disableStickyFooter();\n } else {\n enableStickyFooter();\n
}\n};\n\n/**\n * Dispatch an event to notify that the state (enabled/disabled) of the sticky footer has changed.\n *\n * @param {boolean} enabled Whether the sticky footer has been enabled or disabled.\n */\nconst notifyStickyFooterStateChange = (enabled) => {\n dispatchEvent(eventTypes.stickyFooterStateChanged, {enabled: enabled}, document, {cancelable: false});\n};\n"],"names":["manager","enabled","initialized","SELECTORS","STICKYFOOTER","CLASSES","eventTypes","stickyFooterStateChanged","enableStickyFooter","undefined","notifyStickyFooterStateChange","document","querySelector","classList","remove","disableStickyFooter","add","themeManager","_document$querySelect3","dataset","disable","cancelable"],"mappings":";;;;;;;;;;;IA4BIA,QAAU,GAEVC,SAAU,EAEVC,aAAc,QAELC,UAAY,CACrBC,aAAc,oDAGZC,kBACS,WAGFC,WAAa,CACtBC,yBAA0B,wEAMjBC,mBAAqB,gCAC9BP,SAAU,OACyBQ,IAA/BT,QAAQQ,qBAIZR,QAAQQ,qBACRE,+BAA8B,kCAJ1BC,SAASC,cAAcT,UAAUC,sEAAeS,UAAUC,OAAOT,yEAU5DU,oBAAsB,iCAC/Bd,SAAU,OAC0BQ,IAAhCT,QAAQe,sBAIZf,QAAQe,sBACRL,+
BAA8B,mCAJ1BC,SAASC,cAAcT,UAAUC,wEAAeS,UAAUG,IAAIX,8FActCY,eAC5BjB,QAAUiB,aACNhB,SACAO,oCAOY,mCACZN,mBAGJA,aAAc,kCAEKS,SAASC,cAAcT,UAAUC,uDAAjCc,uBAAgDC,QAAQC,SAEvEL,sBAEAP,4BASFE,8BAAiCT,8CACrBK,WAAWC,yBAA0B,CAACN,QAASA,SAAUU,SAAU,CAACU,YAAY"}