%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/ava/lib/form/amd/build/
Upload File :
Create Path :
Current File : /home/vacivi36/ava/lib/form/amd/build/collapsesections.min.js.map

{"version":3,"file":"collapsesections.min.js","sources":["../src/collapsesections.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 * Collapse or expand all form sections on clicking the expand all / collapse al link.\n *\n * @module core_form/collapsesections\n * @copyright 2021 Bas Brands\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.0\n */\n\nimport $ from 'jquery';\nimport Pending from 'core/pending';\n\nconst SELECTORS = {\n    FORMHEADER: '.fheader',\n    FORMCONTAINER: '.fcontainer',\n};\n\nconst CLASSES = {\n    SHOW: 'show',\n    COLLAPSED: 'collapsed'\n};\n\n/**\n * Initialises the form section collapse / expand action.\n *\n * @param {string} collapsesections the collapse/expand link id.\n */\nexport const init = collapsesections => {\n    // All jQuery in this code can be replaced when MDL-71979 is integrated (move to Bootstrap 5).\n    const pendingPromise = new Pending('core_form/collapsesections');\n    const collapsemenu = document.querySelector(collapsesections);\n    const formParent = collapsemenu.closest('form');\n    collapsemenu.addEventListener('keydown', e => {\n        if (e.key === 'Enter' || e.key === ' ') {\n            e.preventDefault();\n            collapsemenu.click();\n        }\n    });\n\n    // Override default collapse class if all containers are expanded on page load\n    let expandedcount = 0;\n    const formcontainercount = $(SELECTORS.FORMCONTAINER).length;\n    $(SELECTORS.FORMCONTAINER).each((_, collapsecontainer) => {\n        if (collapsecontainer.classList.contains(CLASSES.SHOW)) {\n            expandedcount++;\n        }\n    });\n\n    if (formcontainercount === expandedcount) {\n        collapsemenu.classList.remove(CLASSES.COLLAPSED);\n        collapsemenu.setAttribute('aria-expanded', true);\n    }\n\n    collapsemenu.addEventListener('click', () => {\n        let action = 'hide';\n        if (collapsemenu.classList.contains(CLASSES.COLLAPSED)) {\n            action = 'show';\n        }\n\n        formParent.querySelectorAll(SELECTORS.FORMCONTAINER).forEach((collapsecontainer) => {\n            $(collapsecontainer).collapse(action);\n        });\n    });\n\n    // Ensure collapse menu button adds aria-controls attribute referring to each collapsible element.\n    const collapseElements = $(SELECTORS.FORMHEADER);\n    const collapseElementIds = [...collapseElements].map((element, index) => {\n        element.id = element.id || `collapseElement-${index}`;\n        return element.id;\n    });\n    collapsemenu.setAttribute('aria-controls', collapseElementIds.join(' '));\n\n    $(SELECTORS.FORMCONTAINER).on('hidden.bs.collapse', () => {\n        let allCollapsed = true;\n\n        formParent.querySelectorAll(SELECTORS.FORMCONTAINER).forEach((collapsecontainer) => {\n            if (collapsecontainer.classList.contains(CLASSES.SHOW)) {\n                allCollapsed = false;\n            }\n        });\n\n        if (allCollapsed) {\n            collapsemenu.classList.add(CLASSES.COLLAPSED);\n            collapsemenu.setAttribute('aria-expanded', false);\n        }\n    });\n    $(SELECTORS.FORMCONTAINER).on('shown.bs.collapse', () => {\n        let allExpanded = true;\n\n        formParent.querySelectorAll(SELECTORS.FORMCONTAINER).forEach((collapsecontainer) => {\n            if (!collapsecontainer.classList.contains(CLASSES.SHOW)) {\n                allExpanded = false;\n            }\n        });\n\n        if (allExpanded) {\n            collapsemenu.classList.remove(CLASSES.COLLAPSED);\n            collapsemenu.setAttribute('aria-expanded', true);\n        }\n    });\n    pendingPromise.resolve();\n};\n"],"names":["SELECTORS","CLASSES","collapsesections","pendingPromise","Pending","collapsemenu","document","querySelector","formParent","closest","addEventListener","e","key","preventDefault","click","expandedcount","formcontainercount","length","each","_","collapsecontainer","classList","contains","remove","setAttribute","action","querySelectorAll","forEach","collapse","collapseElementIds","map","element","index","id","join","on","allCollapsed","add","allExpanded","resolve"],"mappings":";;;;;;;;0KA2BMA,qBACU,WADVA,wBAEa,cAGbC,aACI,OADJA,kBAES,0BAQKC,yBAEVC,eAAiB,IAAIC,iBAAQ,8BAC7BC,aAAeC,SAASC,cAAcL,kBACtCM,WAAaH,aAAaI,QAAQ,QACxCJ,aAAaK,iBAAiB,WAAWC,IACvB,UAAVA,EAAEC,KAA6B,MAAVD,EAAEC,MACvBD,EAAEE,iBACFR,aAAaS,gBAKjBC,cAAgB,QACdC,oBAAqB,mBAAEhB,yBAAyBiB,2BACpDjB,yBAAyBkB,MAAK,CAACC,EAAGC,qBAC5BA,kBAAkBC,UAAUC,SAASrB,eACrCc,mBAIJC,qBAAuBD,gBACvBV,aAAagB,UAAUE,OAAOtB,mBAC9BI,aAAamB,aAAa,iBAAiB,IAG/CnB,aAAaK,iBAAiB,SAAS,SAC/Be,OAAS,OACTpB,aAAagB,UAAUC,SAASrB,qBAChCwB,OAAS,QAGbjB,WAAWkB,iBAAiB1B,yBAAyB2B,SAASP,wCACxDA,mBAAmBQ,SAASH,oBAMhCI,mBAAqB,KADF,mBAAE7B,uBACsB8B,KAAI,CAACC,QAASC,SAC3DD,QAAQE,GAAKF,QAAQE,8BAAyBD,OACvCD,QAAQE,MAEnB5B,aAAamB,aAAa,gBAAiBK,mBAAmBK,KAAK,0BAEjElC,yBAAyBmC,GAAG,sBAAsB,SAC5CC,cAAe,EAEnB5B,WAAWkB,iBAAiB1B,yBAAyB2B,SAASP,oBACtDA,kBAAkBC,UAAUC,SAASrB,gBACrCmC,cAAe,MAInBA,eACA/B,aAAagB,UAAUgB,IAAIpC,mBAC3BI,aAAamB,aAAa,iBAAiB,2BAGjDxB,yBAAyBmC,GAAG,qBAAqB,SAC3CG,aAAc,EAElB9B,WAAWkB,iBAAiB1B,yBAAyB2B,SAASP,oBACrDA,kBAAkBC,UAAUC,SAASrB,gBACtCqC,aAAc,MAIlBA,cACAjC,aAAagB,UAAUE,OAAOtB,mBAC9BI,aAAamB,aAAa,iBAAiB,OAGnDrB,eAAeoC"}

Zerion Mini Shell 1.0