Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"validation.min.js","sources":["../src/validation.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 to handle survey validation.\n *\n * @module     mod_survey/validation\n * @copyright  2017 Dan Poltawski <dan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since      3.3\n */\nimport {get_string as getString} from 'core/str';\nimport Notification from 'core/notification';\n\n/**\n * Prevents form submission until all radio buttons are chosen, displays\n * modal error if any choices are missing.\n *\n * @param {String} formid HTML id of form\n */\nexport const ensureRadiosChosen = (formid) => {\n    const form = document.getElementById(formid);\n    form.addEventListener('submit', (e) => {\n        const optionsToSet = form.querySelectorAll('input[type=\"radio\"][data-survey-default=\"true\"]:checked');\n        if (optionsToSet.length !== 0) {\n            Notification.alert(\n                getString('error'),\n                getString('questionsnotanswered', 'survey'),\n                getString('ok'),\n            );\n            e.preventDefault();\n        }\n    });\n};\n"],"names":["formid","form","document","getElementById","addEventListener","e","querySelectorAll","length","alert","preventDefault"],"mappings":";;;;;;;;gMAgCmCA,eACzBC,KAAOC,SAASC,eAAeH,QACrCC,KAAKG,iBAAiB,UAAWC,IAED,IADPJ,KAAKK,iBAAiB,2DAC1BC,+BACAC,OACT,mBAAU,UACV,mBAAU,uBAAwB,WAClC,mBAAU,OAEdH,EAAEI"}