MDL-69608 core_form: frozen forms do not have form tag
[moodle.git] / theme / boost / amd / build / form-display-errors.min.js.map
CommitLineData
312ca07b 1{"version":3,"sources":["../src/form-display-errors.js"],"names":["define","$","Event","enhance","elementid","element","document","getElementById","on","Events","FORM_FIELD_VALIDATION","event","msg","preventDefault","parent","closest","feedback","find","prop","addClass","data","attr","html","is","show","focus","removeClass","removeAttr","hide","form","dataset","addEventListener","visibleError","length","boostFormErrorsEnhanced"],"mappings":"AAuBAA,OAAM,mCAAC,CAAC,QAAD,CAAW,YAAX,CAAD,CAA2B,SAASC,CAAT,CAAYC,CAAZ,CAAmB,CAChD,MAAO,CACHC,OAAO,CAAE,iBAASC,CAAT,CAAoB,CACzB,GAAIC,CAAAA,CAAO,CAAGC,QAAQ,CAACC,cAAT,CAAwBH,CAAxB,CAAd,CACA,GAAI,CAACC,CAAL,CAAc,CAGV,MACH,CAEDJ,CAAC,CAACI,CAAD,CAAD,CAAWG,EAAX,CAAcN,CAAK,CAACO,MAAN,CAAaC,qBAA3B,CAAkD,SAASC,CAAT,CAAgBC,CAAhB,CAAqB,CACnED,CAAK,CAACE,cAAN,GADmE,GAE/DC,CAAAA,CAAM,CAAGb,CAAC,CAACI,CAAD,CAAD,CAAWU,OAAX,CAAmB,aAAnB,CAFsD,CAG/DC,CAAQ,CAAGF,CAAM,CAACG,IAAP,CAAY,wBAAZ,CAHoD,CAMnE,GAAmC,UAA9B,EAAAhB,CAAC,CAACI,CAAD,CAAD,CAAWa,IAAX,CAAgB,SAAhB,CAAD,EAA8CJ,CAAM,CAACG,IAAP,CAAY,mBAAZ,CAAlD,CAAoF,CAChFZ,CAAO,CAAGS,CAAM,CAACG,IAAP,CAAY,mBAAZ,CACb,CACD,GAAY,EAAR,GAAAL,CAAJ,CAAgB,CACZE,CAAM,CAACK,QAAP,CAAgB,YAAhB,EACAL,CAAM,CAACM,IAAP,CAAY,yBAAZ,KACAnB,CAAC,CAACI,CAAD,CAAD,CAAWc,QAAX,CAAoB,YAApB,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AN","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 * Custom form error event handler to manipulate the bootstrap markup and show\n * nicely styled errors in an mform.\n *\n * @module theme_boost/form-display-errors\n * @copyright 2016 Damyon Wiese <damyon@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/event'], function($, Event) {\n return {\n enhance: function(elementid) {\n var element = document.getElementById(elementid);\n if (!element) {\n // Some elements (e.g. static) don't have a form field.\n // Hence there is no validation. So, no setup required here.\n return;\n }\n\n $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {\n event.preventDefault();\n var parent = $(element).closest('.form-group');\n var feedback = parent.find('.form-control-feedback');\n\n // Sometimes (atto) we have a hidden textarea backed by a real contenteditable div.\n if (($(element).prop(\"tagName\") == 'TEXTAREA') && parent.find('[contenteditable]')) {\n element = parent.find('[contenteditable]');\n }\n if (msg !== '') {\n parent.addClass('has-danger');\n parent.data('client-validation-error', true);\n $(element).addClass('is-invalid');\n $(element).attr('aria-describedby', feedback.attr('id'));\n $(element).attr('aria-invalid', true);\n feedback.attr('tabindex', 0);\n feedback.html(msg);\n\n // Only display and focus when the error was not already visible.\n // This is so that, when tabbing around the form, you don't get stuck.\n if (!feedback.is(':visible')) {\n feedback.show();\n feedback.focus();\n }\n\n } else {\n if (parent.data('client-validation-error') === true) {\n parent.removeClass('has-danger');\n parent.data('client-validation-error', false);\n $(element).removeClass('is-invalid');\n $(element).removeAttr('aria-describedby');\n $(element).attr('aria-invalid', false);\n feedback.hide();\n }\n }\n });\n\n var form = element.closest('form');\n if (form && !('boostFormErrorsEnhanced' in form.dataset)) {\n form.addEventListener('submit', function() {\n var visibleError = $('.form-control-feedback:visible');\n if (visibleError.length) {\n visibleError[0].focus();\n }\n });\n form.dataset.boostFormErrorsEnhanced = 1;\n }\n }\n };\n});\n"],"file":"form-display-errors.min.js"}