HEX
Server: LiteSpeed
System: Linux server.zepintelhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: enamadmin (1026)
PHP: 8.2.30
Disabled: exec,system,passthru,shell_exec,proc_open,popen,apache_child_terminate
Upload Files
File: /home/enamadmin/public_html/aaelearningb/course/format/amd/build/local/courseindex/cm.min.js.map
{"version":3,"file":"cm.min.js","sources":["../../../src/local/courseindex/cm.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 * Course index cm component.\n *\n * This component is used to control specific course modules interactions like drag and drop.\n *\n * @module     core_courseformat/local/courseindex/cm\n * @class      core_courseformat/local/courseindex/cm\n * @copyright  2021 Ferran Recio <ferran@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport DndCmItem from 'core_courseformat/local/courseeditor/dndcmitem';\nimport Templates from 'core/templates';\nimport Prefetch from 'core/prefetch';\nimport Config from 'core/config';\nimport Pending from \"core/pending\";\n\n// Prefetch the completion icons template.\nconst completionTemplate = 'core_courseformat/local/courseindex/cmcompletion';\nPrefetch.prefetchTemplate(completionTemplate);\n\nexport default class Component extends DndCmItem {\n\n    /**\n     * Constructor hook.\n     */\n    create() {\n        // Optional component name for debugging.\n        this.name = 'courseindex_cm';\n        // Default query selectors.\n        this.selectors = {\n            CM_NAME: `[data-for='cm_name']`,\n            CM_COMPLETION: `[data-for='cm_completion']`,\n        };\n        // Default classes to toggle on refresh.\n        this.classes = {\n            CMHIDDEN: 'dimmed',\n            LOCKED: 'editinprogress',\n            RESTRICTIONS: 'restrictions',\n            PAGEITEM: 'pageitem',\n            INDENTED: 'indented',\n        };\n        // We need our id to watch specific events.\n        this.id = this.element.dataset.id;\n    }\n\n    /**\n     * Static method to create a component instance form the mustache template.\n     *\n     * @param {element|string} target the DOM main element or its ID\n     * @param {object} selectors optional css selector overrides\n     * @return {Component}\n     */\n    static init(target, selectors) {\n        return new this({\n            element: document.getElementById(target),\n            selectors,\n        });\n    }\n\n    /**\n     * Initial state ready method.\n     *\n     * @param {Object} state the course state.\n     */\n    stateReady(state) {\n        this.configDragDrop(this.id);\n        const cm = state.cm.get(this.id);\n        const course = state.course;\n        // Refresh completion icon.\n        this._refreshCompletion({\n            state,\n            element: cm,\n        });\n        const url = new URL(window.location.href);\n        const anchor = url.hash.replace('#', '');\n        // Check if the current url is the cm url.\n        if (window.location.href == cm.url\n            || (window.location.href.includes(course.baseurl) && anchor == cm.anchor)\n        ) {\n            this.element.scrollIntoView({block: \"center\"});\n        }\n        // Check if this we are displaying this activity page.\n        if (Config.contextid != Config.courseContextId && Config.contextInstanceId == this.id) {\n            this.reactive.dispatch('setPageItem', 'cm', this.id, true);\n            this.element.scrollIntoView({block: \"center\"});\n        }\n        // Add anchor logic if the element is not user visible or the element hasn't URL.\n        if (!cm.uservisible || !cm.url) {\n            const element = this.getElement(this.selectors.CM_NAME);\n            this.addEventListener(\n                element,\n                'click',\n                this._activityAnchor,\n            );\n            // If the element is not user visible we also need to update the anchor link including the section page.\n            if (!document.getElementById(cm.anchor)) {\n                element.setAttribute('href', this._getActivitySectionURL(cm));\n            }\n        }\n    }\n\n    /**\n     * Component watchers.\n     *\n     * @returns {Array} of watchers\n     */\n    getWatchers() {\n        return [\n            {watch: `cm[${this.id}]:deleted`, handler: this.remove},\n            {watch: `cm[${this.id}]:updated`, handler: this._refreshCm},\n            {watch: `cm[${this.id}].completionstate:updated`, handler: this._refreshCompletion},\n            {watch: `course.pageItem:updated`, handler: this._refreshPageItem},\n        ];\n    }\n\n    /**\n     * Update a course index cm using the state information.\n     *\n     * @param {object} param\n     * @param {Object} param.element details the update details.\n     */\n    _refreshCm({element}) {\n        // Update classes.\n        this.element.classList.toggle(this.classes.CMHIDDEN, !element.visible);\n        this.getElement(this.selectors.CM_NAME).innerHTML = element.name;\n        this.element.classList.toggle(this.classes.DRAGGING, element.dragging ?? false);\n        this.element.classList.toggle(this.classes.LOCKED, element.locked ?? false);\n        this.element.classList.toggle(this.classes.RESTRICTIONS, element.hascmrestrictions ?? false);\n        this.element.classList.toggle(this.classes.INDENTED, element.indent);\n        this.locked = element.locked;\n    }\n\n    /**\n     * Handle a page item update.\n     *\n     * @param {Object} details the update details\n     * @param {Object} details.element the course state data.\n     */\n    _refreshPageItem({element}) {\n        if (!element.pageItem) {\n            return;\n        }\n        const isPageId = (element.pageItem.type == 'cm' && element.pageItem.id == this.id);\n        this.element.classList.toggle(this.classes.PAGEITEM, isPageId);\n        if (isPageId && !this.reactive.isEditing) {\n            this.element.scrollIntoView({block: \"nearest\"});\n        }\n    }\n\n    /**\n     * Update the activity completion icon.\n     *\n     * @param {Object} details the update details\n     * @param {Object} details.state the state data\n     * @param {Object} details.element the element data\n     */\n    async _refreshCompletion({state, element}) {\n        // No completion icons are displayed in edit mode.\n        if (this.reactive.isEditing || !element.istrackeduser) {\n            return;\n        }\n        // Check if the completion value has changed.\n        const completionElement = this.getElement(this.selectors.CM_COMPLETION);\n        if (!completionElement || completionElement.dataset.value == element.completionstate) {\n            return;\n        }\n\n        // Collect section information from the state.\n        const exporter = this.reactive.getExporter();\n        const data = exporter.cmCompletion(state, element);\n\n        const {html, js} = await Templates.renderForPromise(completionTemplate, data);\n        Templates.replaceNode(completionElement, html, js);\n    }\n\n    /**\n     * The activity anchor event.\n     *\n     * @param {Event} event\n     */\n    _activityAnchor(event) {\n        const cm = this.reactive.get('cm', this.id);\n        // If the user cannot access the element but the element is present in the page\n        // the new url should be an anchor link.\n        const element = document.getElementById(cm.anchor);\n        if (element) {\n            // Make sure the section is expanded.\n            this.reactive.dispatch('sectionContentCollapsed', [cm.sectionid], false);\n            // Marc the element as page item once the event is handled.\n            const pendingAnchor = new Pending(`courseformat/activity:openAnchor`);\n            setTimeout(() => {\n                this.reactive.dispatch('setPageItem', 'cm', cm.id);\n                pendingAnchor.resolve();\n            }, 50);\n            return;\n        }\n        // If the element is not present in the page we need to go to the specific section.\n        event.preventDefault();\n        window.location = this._getActivitySectionURL(cm);\n    }\n\n    /**\n     * Get the anchor link in section page for the cm.\n     *\n     * @param {Object} cm the course module data.\n     * @return {String} the anchor link.\n     */\n    _getActivitySectionURL(cm) {\n        let section = this.reactive.get('section', cm.sectionid);\n\n        // If the section is delegated get its parent section if it has one.\n        if (section.component && section.parentsectionid) {\n            section = this.reactive.get('section', section.parentsectionid);\n        }\n\n        if (!section) {\n            return '#';\n        }\n\n        return `${section.sectionurl}#${cm.anchor}`;\n    }\n}\n"],"names":["prefetchTemplate","Component","DndCmItem","create","name","selectors","CM_NAME","CM_COMPLETION","classes","CMHIDDEN","LOCKED","RESTRICTIONS","PAGEITEM","INDENTED","id","this","element","dataset","target","document","getElementById","stateReady","state","configDragDrop","cm","get","course","_refreshCompletion","anchor","URL","window","location","href","hash","replace","url","includes","baseurl","scrollIntoView","block","Config","contextid","courseContextId","contextInstanceId","reactive","dispatch","uservisible","getElement","addEventListener","_activityAnchor","setAttribute","_getActivitySectionURL","getWatchers","watch","handler","remove","_refreshCm","_refreshPageItem","classList","toggle","visible","innerHTML","DRAGGING","dragging","locked","hascmrestrictions","indent","pageItem","isPageId","type","isEditing","istrackeduser","completionElement","value","completionstate","data","getExporter","cmCompletion","html","js","Templates","renderForPromise","replaceNode","event","sectionid","pendingAnchor","Pending","setTimeout","resolve","preventDefault","section","component","parentsectionid","sectionurl"],"mappings":";;;;;;;;;;iUAkCSA,iBADkB,0DAGNC,kBAAkBC,mBAKnCC,cAESC,KAAO,sBAEPC,UAAY,CACbC,+BACAC,iDAGCC,QAAU,CAC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