Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"task_indicator.min.js","sources":["../src/task_indicator.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 * Task indicator\n *\n * Watches the progress bar inside the task indicator for updates, and redirects when the progress is complete.\n *\n * @module     core/task_indicator\n * @copyright  2024 Catalyst IT Europe Ltd\n * @author     Mark Johnson <mark.johnson@catalyst-eu.net>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class {\n    /**\n     * Watch the progress bar for updates.\n     *\n     * When the progress bar is updated to 100%, wait a couple of seconds so the user gets to see it if they are watching,\n     * then redirect to the specified URL.\n     *\n     * @param {String} id The ID of the progress bar element.\n     * @param {String} redirectUrl Optional URL to redirect to once the task is complete.\n     */\n    static init(id, redirectUrl) {\n        const bar = document.getElementById(id);\n        bar.addEventListener('update', (event) => {\n            const percent = event?.detail?.percent;\n            if (percent > 0) {\n                // Once progress starts, display the progress bar and remove the run link.\n                bar.classList.remove('stored-progress-notstarted');\n                const runlink = document.querySelector(`.runlink[data-idnumber=${id}]`);\n                if (runlink) {\n                    runlink.remove();\n                }\n            }\n            // Once the progress bar completes, redirect the page.\n            if (redirectUrl !== '' && percent === 100) {\n                window.setTimeout(() => window.location.assign(redirectUrl), 2000);\n            }\n        });\n    }\n}\n"],"names":["id","redirectUrl","bar","document","getElementById","addEventListener","event","percent","detail","_event$detail","classList","remove","runlink","querySelector","window","setTimeout","location","assign"],"mappings":";;;;;;;;;;;kBAmCgBA,GAAIC,mBACNC,IAAMC,SAASC,eAAeJ,IACpCE,IAAIG,iBAAiB,UAAWC,gCACtBC,QAAUD,MAAAA,6BAAAA,MAAOE,uCAAPC,cAAeF,WAC3BA,QAAU,EAAG,CAEbL,IAAIQ,UAAUC,OAAO,oCACfC,QAAUT,SAASU,+CAAwCb,SAC7DY,SACAA,QAAQD,SAII,KAAhBV,aAAkC,MAAZM,SACtBO,OAAOC,YAAW,IAAMD,OAAOE,SAASC,OAAOhB,cAAc"}