fix alert placement on iPad 2
authorRaphaël Jakse <raphael.trivabble@jakse.fr>
Mon, 13 Jul 2020 13:50:44 +0000 (15:50 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Mon, 13 Jul 2020 13:54:09 +0000 (15:54 +0200)
public/alert.css
public/alert.js
public/trivabble.js

index 26ab33900ebffd6a5a9a80708bee1051de1abc1d..656de4501c72c360748bf1b768535b881dd35366 100644 (file)
@@ -12,7 +12,7 @@
     -webkit-justify-content:center;
     justify-content:center;
     line-height:1.5em;
-    text-align:center
+    text-align:center;
 }
 
 .alert-outer {
     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
 }
index 2dc78d62a280c5e169bef7046250b89385872a13..6675540f5ff65d96a4d89bb85657dee9d464b0d5 100644 (file)
         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";
             prepare();
         }
 
+        divAlert.classList.remove("prompt");
+
         divAlertContent.textContent = msg;
         divAlertInput.style.display = "none";
         divAlertConfirm.style.display = "none";
             prepare();
         }
 
+        divAlert.classList.add("prompt");
+
         divAlertContent.textContent = msg;
         divAlertInput.style.display = "";
         alertInput.value = defaultText || "";
         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) {
             prepare();
         }
 
+        divAlert.classList.remove("prompt");
+
         divAlertContent.textContent = msg;
         divAlertInput.style.display = "none";
         divAlertConfirm.style.display = "";
index a10be57229e8abe68085498209ee39484c019bf8..90e9dcafeea092b279ee57db962bc90c5b9086e3 100644 (file)
     }
 
     function initChat() {
-        chatMessages.style.width = chatMessages.offsetWidth + "px";
-
         const btn = document.getElementById("chat-btn");
 
         chatTextarea.onmouseup = function () {