%PDF- %PDF-
Direktori : /home/vacivi36/ava/question/bank/previewquestion/amd/build/ |
Current File : /home/vacivi36/ava/question/bank/previewquestion/amd/build/preview.min.js.map |
{"version":3,"file":"preview.min.js","sources":["../src/preview.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 * Javascript for preview.\n *\n * @module qbank_preview/preview\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Safat Shahin <safatshahin@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\n\n/**\n * Set up the actions.\n *\n * @method init\n * @param {bool} redirect Redirect.\n * @param {string} url url to redirect.\n */\nexport const init = (redirect, url) => {\n if (!redirect) {\n let closeButton = document.getElementById('close-previewquestion-page');\n closeButton.onclick = () => {\n if (window.opener === null) {\n location.href = url;\n } else {\n window.close();\n }\n };\n }\n // Set up the form to be displayed.\n setupQuestionForm('responseform');\n};\n\n/**\n * Set up the form element to be displayed.\n *\n * @method setupQuestionForm\n * @param {string} formElement The form element.\n */\nconst setupQuestionForm = (formElement) => {\n let form = document.getElementById(formElement);\n if (form) {\n // Turning off browser autocomplete.\n autocompleteOff(form);\n // Stop a question form being submitted more than once.\n preventRepeatSubmission(form);\n // Removes any '.questionflagsavebutton's, since we have JavaScript to toggle.\n removeClass('.questionflagsavebutton', form);\n // Scroll to the position indicated by scrollpos= in the URL, if it is there.\n scrollToSavedPos(form);\n }\n};\n\n/**\n * Set the autocomplete off.\n *\n * @method autocompleteOff\n * @param {object} form The form element.\n */\nconst autocompleteOff = (form) => {\n form.setAttribute(\"autocomplete\", \"off\");\n};\n\n/**\n * Event handler to stop a question form being submitted more than once.\n *\n * @method preventRepeatSubmission\n * @param {object} form The form element.\n */\nconst preventRepeatSubmission = (form) => {\n form.addEventListener(\"submit\", function() {\n $(this).submit(function() {\n return false;\n });\n return true;\n });\n};\n\n/**\n * Removes a class inside an element.\n *\n * @method removeClass\n * @param {string} classname Class name.\n * @param {object} form The form element.\n */\nconst removeClass = (classname, form) => {\n form.querySelectorAll(classname).forEach(e => e.remove());\n};\n\n/**\n * If there is a parameter like scrollpos=123 in the URL, scroll to that saved position.\n * (Note: Moodle 4.0 and above do NOT support Internet Explorer 11 and below.)\n *\n * @method scrollToSavedPos\n * @param {object} form The form element.\n */\nconst scrollToSavedPos = (form) => {\n let matches = window.location.href.match(/^.*[?&]scrollpos=(\\d*)(?:&|$|#).*$/, '$1');\n if (matches) {\n // DOMContentLoaded is the effective one here. I am leaving the immediate call to\n // window.scrollTo in case it reduces flicker.\n window.scrollTo(0, matches[1]);\n form.addEventListener(\"DOMContentLoaded\", () => {\n window.scrollTo(0, matches[1]);\n });\n }\n};\n"],"names":["redirect","url","document","getElementById","onclick","window","opener","location","href","close","setupQuestionForm","formElement","form","autocompleteOff","preventRepeatSubmission","removeClass","scrollToSavedPos","setAttribute","addEventListener","this","submit","classname","querySelectorAll","forEach","e","remove","matches","match","scrollTo"],"mappings":";;;;;;;;wJAiCoB,CAACA,SAAUC,WACtBD,SAAU,CACOE,SAASC,eAAe,8BAC9BC,QAAU,KACI,OAAlBC,OAAOC,OACPC,SAASC,KAAOP,IAEhBI,OAAOI,SAKnBC,kBAAkB,uBAShBA,kBAAqBC,kBACnBC,KAAOV,SAASC,eAAeQ,aAC/BC,OAEAC,gBAAgBD,MAEhBE,wBAAwBF,MAExBG,YAAY,0BAA2BH,MAEvCI,iBAAiBJ,QAUnBC,gBAAmBD,OACrBA,KAAKK,aAAa,eAAgB,QAShCH,wBAA2BF,OAC7BA,KAAKM,iBAAiB,UAAU,qCAC1BC,MAAMC,QAAO,kBACJ,MAEJ,MAWTL,YAAc,CAACM,UAAWT,QAC5BA,KAAKU,iBAAiBD,WAAWE,SAAQC,GAAKA,EAAEC,YAU9CT,iBAAoBJ,WAClBc,QAAUrB,OAAOE,SAASC,KAAKmB,MAAM,qCAAsC,MAC3ED,UAGArB,OAAOuB,SAAS,EAAGF,QAAQ,IAC3Bd,KAAKM,iBAAiB,oBAAoB,KACtCb,OAAOuB,SAAS,EAAGF,QAAQ"}