From ee157cd4417064e88414edd3c53912395164c74b Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 30 Oct 2018 12:43:48 +0100 Subject: add default configuration files --- basicConfig/webcontent/js/js_country.js | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 basicConfig/webcontent/js/js_country.js (limited to 'basicConfig/webcontent/js/js_country.js') diff --git a/basicConfig/webcontent/js/js_country.js b/basicConfig/webcontent/js/js_country.js new file mode 100644 index 00000000..5dcea90e --- /dev/null +++ b/basicConfig/webcontent/js/js_country.js @@ -0,0 +1,42 @@ +function clickCountryFlag(element) { + if (!element) return false; + + var form = element.target.closest("form"); + + if (!form) return false; + + form.submit(); + return false; +} + + +/* Set JS events by EventListener to prevent problems with CSP*/ +document.addEventListener("DOMContentLoaded", function(event) { + + /* Element.closest polyfill - https://developer.mozilla.org/en-US/docs/Web/API/Element/closest License: public domain*/ + if (!Element.prototype.matches) + Element.prototype.matches = Element.prototype.msMatchesSelector || + Element.prototype.webkitMatchesSelector; + + if (!Element.prototype.closest) + Element.prototype.closest = function(s) { + var el = this; + if (!document.documentElement.contains(el)) return null; + do { + if (el.matches(s)) return el; + el = el.parentElement || el.parentNode; + } while (el !== null && el.nodeType === 1); + return null; + }; + + /* set Click events by EventListener to prevent JavaScript in HTML which can be a problem with CSP*/ + var allFlags = document.getElementsByClassName("countryimage"); + for (i=0;i