Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/admin/tool/moodlenet/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/admin/tool/moodlenet/amd/build/instance_form.min.js.map

{"version":3,"sources":["../src/instance_form.js"],"names":["define","Validator","Selectors","LoadingIcon","Templates","Notification","$","registerListenerEvents","page","addEventListener","e","target","matches","action","submit","input","querySelector","overlay","region","spinner","validationArea","document","classList","remove","addIconToContainerWithPromise","validation","then","result","resolve","add","innerText","message","setTimeout","window","location","domain","catch","chooserNavigateToMnet","showMoodleNet","footerData","carousel","modal","innerHTML","spinnerPromise","addIconToContainer","transitionPromiseResolver","transitionPromise","Promise","when","replaceNodeContents","customcarouseltemplate","exception","one","setFooter","render","chooserNavigateFromMnet","customfootertemplate","footerClickListener","closest","preventDefault","getBody","find","moodleNet","closeOption"],"mappings":"AA+BAA,OAAM,gCAAC,CAAC,0BAAD,CACC,0BADD,CAEC,kBAFD,CAGC,gBAHD,CAIC,mBAJD,CAKC,QALD,CAAD,CAMF,SAASC,CAAT,CACSC,CADT,CAESC,CAFT,CAGSC,CAHT,CAISC,CAJT,CAKSC,CALT,CAKY,IAQRC,CAAAA,CAAsB,CAAG,SAAgCC,CAAhC,CAAsC,CAC/DA,CAAI,CAACC,gBAAL,CAAsB,OAAtB,CAA+B,SAASC,CAAT,CAAY,CAGvC,GAAIA,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBV,CAAS,CAACW,MAAV,CAAiBC,MAAlC,CAAJ,CAA+C,IACvCC,CAAAA,CAAK,CAAGP,CAAI,CAACQ,aAAL,CAAmB,0BAAnB,CAD+B,CAEvCC,CAAO,CAAGT,CAAI,CAACQ,aAAL,CAAmBd,CAAS,CAACgB,MAAV,CAAiBC,OAApC,CAF6B,CAGvCC,CAAc,CAAGC,QAAQ,CAACL,aAAT,CAAuBd,CAAS,CAACgB,MAAV,CAAiBE,cAAxC,CAHsB,CAK3CH,CAAO,CAACK,SAAR,CAAkBC,MAAlB,CAAyB,Q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B4C,SAA/B,EAA0C,CAA1C,CAHgF,CAKtGzB,CAAqB,CAACC,CAAD,CAAgBC,CAAhB,CAA4BC,CAA5B,CAAsCC,CAAtC,CACxB,CAED,GAAI/B,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBV,CAAS,CAACW,MAAV,CAAiBkD,WAAlC,CAAJ,CAAoD,CAChD,GAAMvB,CAAAA,CAAQ,CAAGlC,CAAC,CAACmC,CAAK,CAACmB,OAAN,GAAgB,CAAhB,EAAmB5C,aAAnB,CAAiCd,CAAS,CAACgB,MAAV,CAAiBsB,QAAlD,CAAD,CAAlB,CAEAe,CAAuB,CAACf,CAAD,CAAWC,CAAX,CAAkBF,CAAlB,CAC1B,CACJ,CAEM,CAGV,CAzIK,CAAN","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 * Our basic form manager for when a user either enters\n * their profile url or just wants to browse.\n *\n * This file is a mishmash of JS functions we need for both the standalone (M3.7, M3.8)\n * plugin & Moodle 3.9 functions. The 3.9 Functions have a base understanding that certain\n * things exist i.e. directory structures for templates. When this feature goes 3.9+ only\n * The goal is that we can quickly gut all AMD modules into bare JS files and use ES6 guidelines.\n * Till then this will have to do.\n *\n * @module     tool_moodlenet/instance_form\n * @package    tool_moodlenet\n * @copyright  2020 Mathew May <mathew.solutions>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['tool_moodlenet/validator',\n        'tool_moodlenet/selectors',\n        'core/loadingicon',\n        'core/templates',\n        'core/notification',\n        'jquery'],\n    function(Validator,\n             Selectors,\n             LoadingIcon,\n             Templates,\n             Notification,\n             $) {\n\n    /**\n     * Add the event listeners to our form.\n     *\n     * @method registerListenerEvents\n     * @param {HTMLElement} page The whole page element for our form area\n     */\n    var registerListenerEvents = function registerListenerEvents(page) {\n        page.addEventListener('click', function(e) {\n\n            // Our fake submit button / browse button.\n            if (e.target.matches(Selectors.action.submit)) {\n                var input = page.querySelector('[data-var=\"mnet-link\"]');\n                var overlay = page.querySelector(Selectors.region.spinner);\n                var validationArea = document.querySelector(Selectors.region.validationArea);\n\n                overlay.classList.remove('d-none');\n                var spinner = LoadingIcon.addIconToContainerWithPromise(overlay);\n                Validator.validation(input)\n                    .then(function(result) {\n                        spinner.resolve();\n                        overlay.classList.add('d-none');\n                        if (result.result) {\n                            input.classList.remove('is-invalid'); // Just in case the class has been applied already.\n                            input.classList.add('is-valid');\n                            validationArea.innerText = result.message;\n                            validationArea.classList.remove('text-danger');\n                            validationArea.classList.add('text-success');\n                            // Give the user some time to see their input is valid.\n                            setTimeout(function() {\n                                window.location = result.domain;\n                            }, 1000);\n                        } else {\n                            input.classList.add('is-invalid');\n                            validationArea.innerText = result.message;\n                            validationArea.classList.add('text-danger');\n                        }\n                        return;\n                }).catch();\n            }\n        });\n    };\n\n    /**\n     * Given a user wishes to see the MoodleNet profile url form transition them there.\n     *\n     * @method chooserNavigateToMnet\n     * @param {HTMLElement} showMoodleNet The chooser's area for ment\n     * @param {Object} footerData Our footer object to render out\n     * @param {jQuery} carousel Our carousel instance to manage\n     * @param {jQuery} modal Our modal instance to manage\n     */\n    var chooserNavigateToMnet = function(showMoodleNet, footerData, carousel, modal) {\n        showMoodleNet.innerHTML = '';\n\n        // Add a spinner.\n        var spinnerPromise = LoadingIcon.addIconToContainer(showMoodleNet);\n\n        // Used later...\n        var transitionPromiseResolver = null;\n        var transitionPromise = new Promise(resolve => {\n            transitionPromiseResolver = resolve;\n        });\n\n        $.when(\n            spinnerPromise,\n            transitionPromise\n        ).then(function() {\n                Templates.replaceNodeContents(showMoodleNet, footerData.customcarouseltemplate, '');\n                return;\n        }).catch(Notification.exception);\n\n        // We apply our handlers in here to minimise plugin dependency in the Chooser.\n        registerListenerEvents(showMoodleNet);\n\n        // Move to the next slide, and resolve the transition promise when it's done.\n        carousel.one('slid.bs.carousel', function() {\n            transitionPromiseResolver();\n        });\n        // Trigger the transition between 'pages'.\n        carousel.carousel(2);\n        // eslint-disable-next-line max-len\n        modal.setFooter(Templates.render('tool_moodlenet/chooser_footer_close_mnet', {}));\n    };\n\n    /**\n     * Given a user no longer wishes to see the MoodleNet profile url form transition them from there.\n     *\n     * @method chooserNavigateFromMnet\n     * @param {jQuery} carousel Our carousel instance to manage\n     * @param {jQuery} modal Our modal instance to manage\n     * @param {Object} footerData Our footer object to render out\n     */\n    var chooserNavigateFromMnet = function(carousel, modal, footerData) {\n        // Trigger the transition between 'pages'.\n        carousel.carousel(0);\n        modal.setFooter(footerData.customfootertemplate);\n    };\n\n        /**\n         * Create the custom listener that would handle anything in the footer.\n         *\n         * @param {Event} e The event being triggered.\n         * @param {Object} footerData The data generated from the exporter.\n         * @param {Object} modal The chooser modal.\n         */\n    var footerClickListener = function(e, footerData, modal) {\n        if (e.target.matches(Selectors.action.showMoodleNet) || e.target.closest(Selectors.action.showMoodleNet)) {\n            e.preventDefault();\n            const carousel = $(modal.getBody()[0].querySelector(Selectors.region.carousel));\n            const showMoodleNet = carousel.find(Selectors.region.moodleNet)[0];\n\n            chooserNavigateToMnet(showMoodleNet, footerData, carousel, modal);\n        }\n        // From the help screen go back to the module overview.\n        if (e.target.matches(Selectors.action.closeOption)) {\n            const carousel = $(modal.getBody()[0].querySelector(Selectors.region.carousel));\n\n            chooserNavigateFromMnet(carousel, modal, footerData);\n        }\n    };\n\n    return {\n        footerClickListener: footerClickListener\n    };\n});\n"],"file":"instance_form.min.js"}