diff --git a/Axuno.Tools/FileSystem/IEmbeddedResourceQuery.cs b/Axuno.Tools/FileSystem/IEmbeddedResourceQuery.cs index 3372896d..3d46f814 100644 --- a/Axuno.Tools/FileSystem/IEmbeddedResourceQuery.cs +++ b/Axuno.Tools/FileSystem/IEmbeddedResourceQuery.cs @@ -16,7 +16,7 @@ public interface IEmbeddedResourceQuery Stream? Read(string resource); /// - /// Reads an embedded resource from the assembly of . + /// Reads an embedded resource from the assembly of . /// /// /// @@ -32,7 +32,7 @@ public interface IEmbeddedResourceQuery Stream? Read(string assemblyName, string resource); /// - /// Gets all resource names from the assembly of . + /// Gets all resource names from the assembly of . /// /// /// diff --git a/League/Gruntfile.js b/League/Gruntfile.js index cfcdb430..f1b14855 100644 --- a/League/Gruntfile.js +++ b/League/Gruntfile.js @@ -79,7 +79,7 @@ module.exports = function (grunt) { }, build: { files: { - 'wwwroot/js/site.min.js': ['Scripts/Site.ModalForm.js', 'Scripts/Site.ShowPassword.js', 'node_modules/js-cookie/src/js.cookie.js'], + 'wwwroot/js/site.min.js': ['Scripts/Polyfill.js', 'Scripts/Site.ModalForm.js', 'Scripts/Site.ShowPassword.js', 'node_modules/js-cookie/src/js.cookie.js'], } } }, diff --git a/League/Scripts/Polyfill.js b/League/Scripts/Polyfill.js new file mode 100644 index 00000000..f52a3cae --- /dev/null +++ b/League/Scripts/Polyfill.js @@ -0,0 +1,14 @@ +/** + * Polyfill for Element.closest + */ +if (typeof (Element.prototype.closest == 'undefined')) { + Element.prototype.closest = function (property, value) { + var x = this; + while (x = x.parentElement) { + if (x[property] == value) { + return this; + } + } + return null; + } +} diff --git a/League/Scripts/Site.ModalForm.js b/League/Scripts/Site.ModalForm.js index f4b3cb68..458b6e2a 100644 --- a/League/Scripts/Site.ModalForm.js +++ b/League/Scripts/Site.ModalForm.js @@ -232,27 +232,35 @@ Site.ModalForm = function () { } }); - document.addEventListener('click', function(event) { + document.addEventListener('click', function (event) { + if (event == null) return; + submittingElement = event.target; + if (event.target.matches('[site-data="submit"]')) { event.preventDefault(); - handleSiteDataSubmit(event); + handleSiteDataSubmit(); } }); // A TagHelper creates a button //modalContainer.querySelector('[site-data="submit"]').addEventListener('click', function(event) { - async function handleSiteDataSubmit(event) { - submittingElement = event.target; + async function handleSiteDataSubmit() { + // first search the form where the submitting element is in. let form = submittingElement.closest('form'); // If not found, take the first form inside the modal - if (form === null) { - form = event.target.closest('.modal').querySelector('form'); + if (!(form instanceof HTMLFormElement)) { + form = submittingElement.closest('.modal').querySelector('form'); + } + if (!(form instanceof HTMLFormElement)) { + // Try to access the first form in the document + form = document.forms[0]; } - if (form === null) { + if (!(form instanceof HTMLFormElement)) { JL(loggerName).error({ 'msg': 'No form found' }); + return; } const elements = document.querySelectorAll('.modal-footer button, .modal-footer input[type="button"], .modal-footer input[type="submit"]'); diff --git a/League/Views/Team/MyTeam.cshtml b/League/Views/Team/MyTeam.cshtml index b00ef4aa..98b7dcea 100644 --- a/League/Views/Team/MyTeam.cshtml +++ b/League/Views/Team/MyTeam.cshtml @@ -246,7 +246,7 @@ {