From fde914d3ad42e14fbad105c830705c732684a1a5 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 3 Oct 2022 19:02:22 +0200 Subject: [PATCH] netteForms: showModal uses by default --- src/assets/netteForms.js | 43 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/assets/netteForms.js b/src/assets/netteForms.js index c1b6c7774..d5245a94c 100644 --- a/src/assets/netteForms.js +++ b/src/assets/netteForms.js @@ -307,33 +307,30 @@ * Display modal window. */ Nette.showModal = function(message, onclose) { - var dialog = document.createElement('dialog'), - ua = navigator.userAgentData; - - if (ua && dialog.showModal - && ua.brands.some(function(item) { return item.brand === 'Opera' || (item.brand === 'Chromium' && ua.mobile); }) - ) { - var style = document.createElement('style'); - style.innerText = '.netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }'; - - var button = document.createElement('button'); - button.innerText = 'OK'; - button.onclick = function () { - dialog.remove(); - onclose(); - }; + var dialog = document.createElement('dialog'); - dialog.setAttribute('class', 'netteFormsModal'); - dialog.innerText = message + '\n\n'; - dialog.appendChild(style); - dialog.appendChild(button); - document.body.appendChild(dialog); - dialog.showModal(); + if (!dialog.showModal) { + alert(message); + onclose(); return; } - alert(message); - onclose(); + var style = document.createElement('style'); + style.innerText = '.netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }'; + + var button = document.createElement('button'); + button.innerText = 'OK'; + button.onclick = function () { + dialog.remove(); + onclose(); + }; + + dialog.setAttribute('class', 'netteFormsModal'); + dialog.innerText = message + '\n\n'; + dialog.appendChild(style); + dialog.appendChild(button); + document.body.appendChild(dialog); + dialog.showModal(); };