Sindbad~EG File Manager

Current Path : /var/www/html/universidad.bristol.com.py/lib/amd/build/local/reactive/
Upload File :
Current File : /var/www/html/universidad.bristol.com.py/lib/amd/build/local/reactive/overlay.min.js.map

{"version":3,"file":"overlay.min.js","sources":["../../../src/local/reactive/overlay.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 * Element overlay methods.\n *\n * This module is used to create overlay information on components. For example\n * to generate or destroy file drop-zones.\n *\n * @module     core/local/reactive/overlay\n * @copyright  2022 Ferran Recio <ferran@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Templates from 'core/templates';\nimport Prefetch from 'core/prefetch';\n\n// Prefetch the overlay html.\nconst overlayTemplate = 'core/local/reactive/overlay';\nPrefetch.prefetchTemplate(overlayTemplate);\n\n/**\n * @var {boolean} isInitialized if the module is capturing the proper page events.\n */\nlet isInitialized = false;\n\n/**\n * @var {Object} isInitialized if the module is capturing the proper page events.\n */\nconst selectors = {\n    OVERLAY: \"[data-overlay]\",\n    REPOSITION: \"[data-overlay-dynamic]\",\n    NAVBAR: \"nav.navbar.fixed-top\",\n};\n\n/**\n * Adds an overlay to a specific page element.\n *\n * @param {Object} definition the overlay definition.\n * @param {String|Promise} definition.content an optional overlay content.\n * @param {String|Promise} definition.icon an optional icon content.\n * @param {String} definition.classes an optional CSS classes\n * @param {HTMLElement} parent the parent object\n * @return {HTMLElement|undefined} the new page element.\n */\nexport const addOverlay = async(definition, parent) => {\n    // Validate non of the passed params is a promise.\n    if (definition.content && typeof definition.content !== 'string') {\n        definition.content = await definition.content;\n    }\n    if (definition.icon && typeof definition.icon !== 'string') {\n        definition.icon = await definition.icon;\n    }\n    const data = {\n        content: definition.content,\n        css: definition.classes ?? 'file-drop-zone',\n    };\n    let overlay;\n    try {\n        const {html, js} = await Templates.renderForPromise(overlayTemplate, data);\n        Templates.appendNodeContents(parent, html, js);\n        overlay = parent.querySelector(selectors.OVERLAY);\n        rePositionPreviewInfoElement(overlay);\n        init();\n    } catch (error) {\n        throw error;\n    }\n    return overlay;\n};\n\n/**\n * Adds an overlay to a specific page element.\n *\n * @param {HTMLElement} overlay the parent object\n */\nexport const removeOverlay = (overlay) => {\n    if (!overlay || !overlay.parentNode) {\n        return;\n    }\n    // Remove any forced parentNode position.\n    if (overlay.dataset?.overlayPosition) {\n        delete overlay.parentNode.style.position;\n    }\n    overlay.parentNode.removeChild(overlay);\n};\n\nexport const removeAllOverlays = () => {\n    document.querySelectorAll(selectors.OVERLAY).forEach(\n        (overlay) => {\n            removeOverlay(overlay);\n        }\n    );\n};\n\n/**\n * Re-position the preview information element by calculating the section position.\n *\n * @param {Object} overlay the overlay element.\n */\nconst rePositionPreviewInfoElement = function(overlay) {\n    if (!overlay) {\n        throw new Error('Inexistent overlay element');\n    }\n    // Add relative position to the parent object.\n    if (!overlay.parentNode?.style?.position) {\n        overlay.parentNode.style.position = 'relative';\n        overlay.dataset.overlayPosition = \"true\";\n    }\n    // Get the element to reposition.\n    const target = overlay.querySelector(selectors.REPOSITION);\n    if (!target) {\n        return;\n    }\n    // Get the new bounds.\n    const rect = overlay.getBoundingClientRect();\n    const sectionHeight = parseInt(window.getComputedStyle(overlay).height, 10);\n    const sectionOffset = rect.top;\n    const previewHeight = parseInt(window.getComputedStyle(target).height, 10) +\n        (2 * parseInt(window.getComputedStyle(target).padding, 10));\n    // Calculate the new target position.\n    let top, bottom;\n    if (sectionOffset < 0) {\n        if (sectionHeight + sectionOffset >= previewHeight) {\n            // We have enough space here, just stick the preview to the top.\n            let offSetTop = 0 - sectionOffset;\n            const navBar = document.querySelector(selectors.NAVBAR);\n            if (navBar) {\n                offSetTop = offSetTop + navBar.offsetHeight;\n            }\n            top = offSetTop + 'px';\n            bottom = 'unset';\n        } else {\n            // We do not have enough space here, just stick the preview to the bottom.\n            top = 'unset';\n            bottom = 0;\n        }\n    } else {\n        top = 0;\n        bottom = 'unset';\n    }\n\n    target.style.top = top;\n    target.style.bottom = bottom;\n};\n\n// Update overlays when the page scrolls.\nconst init = () => {\n    if (isInitialized) {\n        return;\n    }\n    // Add scroll events.\n    document.addEventListener('scroll', () => {\n        document.querySelectorAll(selectors.OVERLAY).forEach(\n            (overlay) => {\n                rePositionPreviewInfoElement(overlay);\n            }\n        );\n    }, true);\n};\n"],"names":["prefetchTemplate","selectors","async","definition","parent","content","icon","data","css","classes","overlay","html","js","Templates","renderForPromise","appendNodeContents","querySelector","rePositionPreviewInfoElement","init","error","removeOverlay","parentNode","dataset","_overlay$dataset","overlayPosition","style","position","removeChild","document","querySelectorAll","forEach","Error","_overlay$parentNode","_overlay$parentNode$s","target","rect","getBoundingClientRect","sectionHeight","parseInt","window","getComputedStyle","height","sectionOffset","top","previewHeight","padding","bottom","offSetTop","navBar","offsetHeight","addEventListener"],"mappings":";;;;;;;;;;sPA+BSA,iBADe,qCAWlBC,kBACO,iBADPA,qBAEU,yBAFVA,iBAGM,2CAacC,MAAMC,WAAYC,kCAEpCD,WAAWE,SAAyC,iBAAvBF,WAAWE,UACxCF,WAAWE,cAAgBF,WAAWE,SAEtCF,WAAWG,MAAmC,iBAApBH,WAAWG,OACrCH,WAAWG,WAAaH,WAAWG,YAEjCC,KAAO,CACTF,QAASF,WAAWE,QACpBG,gCAAKL,WAAWM,2DAAW,sBAE3BC,kBAEMC,KAACA,KAADC,GAAOA,UAAYC,mBAAUC,iBAzCnB,8BAyCqDP,yBAC3DQ,mBAAmBX,OAAQO,KAAMC,IAC3CF,QAAUN,OAAOY,cAAcf,mBAC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