From: Raphaƫl Jakse Date: Mon, 13 Jul 2020 13:50:44 +0000 (+0200) Subject: fix alert placement on iPad 2 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=08a7890bf76023817a9204461eb1e750973a7f32;p=trivabble.git fix alert placement on iPad 2 --- diff --git a/public/alert.css b/public/alert.css index 26ab339..656de45 100644 --- a/public/alert.css +++ b/public/alert.css @@ -12,7 +12,7 @@ -webkit-justify-content:center; justify-content:center; line-height:1.5em; - text-align:center + text-align:center; } .alert-outer { @@ -31,6 +31,15 @@ padding:4px; } +.alert.on-ipad.prompt { + justify-content:flex-start; + position:absolute; +} + +.alert.on-ipad.prompt .alert-outer { + margin-top:1em; +} + .alert-content { padding:1ex } diff --git a/public/alert.js b/public/alert.js index 2dc78d6..6675540 100644 --- a/public/alert.js +++ b/public/alert.js @@ -57,6 +57,11 @@ divAlert.className = "alert"; divAlert.style.display = "none"; + // eslint-disable-next-line require-unicode-regexp + if ((/iPad|iPhone|iPod/g).test(navigator.userAgent)) { + divAlert.classList.add("on-ipad"); + } + divAlertContent = document.createElement("div"); divAlertContent.className = "alert-content"; divAlertContent.style.whiteSpace = "pre-wrap"; @@ -114,6 +119,8 @@ prepare(); } + divAlert.classList.remove("prompt"); + divAlertContent.textContent = msg; divAlertInput.style.display = "none"; divAlertConfirm.style.display = "none"; @@ -130,6 +137,8 @@ prepare(); } + divAlert.classList.add("prompt"); + divAlertContent.textContent = msg; divAlertInput.style.display = ""; alertInput.value = defaultText || ""; @@ -139,12 +148,9 @@ divAlertCallback = callback; divAlert.style.display = ""; - // eslint-disable-next-line require-unicode-regexp - if (!(/iPad|iPhone|iPod/g).test(navigator.userAgent)) { - alertInput.focus(); - alertInput.setSelectionRange(0, alertInput.value.length); - alertInput.select(); - } + alertInput.focus(); + alertInput.setSelectionRange(0, alertInput.value.length); + alertInput.select(); }; global.myConfirm = function (msg, callbackYes, callbackNo) { @@ -152,6 +158,8 @@ prepare(); } + divAlert.classList.remove("prompt"); + divAlertContent.textContent = msg; divAlertInput.style.display = "none"; divAlertConfirm.style.display = ""; diff --git a/public/trivabble.js b/public/trivabble.js index a10be57..90e9dca 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -1436,8 +1436,6 @@ } function initChat() { - chatMessages.style.width = chatMessages.offsetWidth + "px"; - const btn = document.getElementById("chat-btn"); chatTextarea.onmouseup = function () {