use own implementaion of alert dialog due to some browsers do not allow to copy a message on system alert()

This commit is contained in:
maxpozdeev 2022-08-15 15:12:03 +03:00
parent b9f720c9b3
commit c5b73b17d6
6 changed files with 77 additions and 3 deletions

View file

@ -1031,7 +1031,7 @@ function enableFeedKeyInCurList()
if (curList.feedKey) {
$('#btnFeedKey').addClass('mtt-item-checked');
$('#btnShowFeedKey').removeClass('mtt-item-disabled');
alert(curList.feedKey);
mttAlert(curList.feedKey);
}
else {
$('#btnFeedKey').removeClass('mtt-item-checked');
@ -1044,7 +1044,7 @@ function showFeedKeyInCurList()
{
if (!curList) return false;
if (curList.feedKey === undefined || curList.feedKey === '') return false;
alert(curList.feedKey);
mttAlert(curList.feedKey);
};
@ -2652,6 +2652,26 @@ function mttPrompt(msg, defaultValue, callbackOk, callbackCancel)
}
}
function mttAlert(msg, callbackOk)
{
$("#btnModalOk").click(function() {
$("#modal_overlay, #modal").hide();
$("body").css("overflow", "");
if (typeof callbackOk === 'function')
callbackOk();
});
var modalOverlay = document.getElementById("modal_overlay");
if (!modalOverlay) {
modalOverlay = document.createElement("div");
modalOverlay.id = "modal_overlay";
modalOverlay.style.cssText = "position: absolute; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; background-color: black; opacity: 0.8; display:none;";
document.getElementsByTagName('body')[0].appendChild(modalOverlay);
}
$("#modal .modal-content").text(msg);
$("body").css("overflow", "hidden");
$("#modal_overlay, #modal").show();
}
/*
* History and Hash change

View file

@ -21,6 +21,7 @@
--color-btn-default: #fff;
--color-btn-hover: #444;
--color-submit: #444;
--color-submit-hover: #555;
--color-row-underlinig: #303030;
--color-border-default: #555;
--color-border-focus: #5a8df0;

View file

@ -24,6 +24,7 @@
--color-btn-default: #000;
--color-btn-hover: #efefef;
--color-submit: #eee;
--color-submit-hover: #ddd;
--color-row-underlinig: #dedede;
--color-border-default: #ccc;
--color-border-focus: #5a8df0;
@ -109,7 +110,7 @@ body {
flex-direction:column;
align-items:center;
}
body, td, th, input, textarea, select {
body, td, th, input, textarea, select, button {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", /*Roboto,*/ Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
font-size: 1rem;
}
@ -921,6 +922,41 @@ li.mtt-item-hidden { display:none; }
}
#modal {
position: absolute;
z-index: 1000;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
min-width: 200px;
max-width: 1000px; /* same as #mtt */
border: 1px solid var(--color-menu-border);
background: var(--color-bg);
box-shadow: var(--color-popup-shadow);
border-radius: 5px;
opacity: 1;
}
#modal .modal-content {
padding: 1.5rem;
}
#modal .modal-bottom {
border-top: 1px solid var(--color-border-default);
text-align: center;
padding: 0.8rem;
}
#modal .modal-bottom button {
min-width: 4rem;
padding: 4px 6px;
margin: 0 4px;
background-color: var(--color-submit);
border: 1px solid var(--color-border-default);
border-radius: 3px;
transition: background-color 0.1s ease-out;
}
#modal .modal-bottom button:hover {
background-color: var(--color-submit-hover);
}
/* font for small screens */
@media only screen and (max-width: 600px), only screen and (max-height: 600px) {
html {
@ -1021,4 +1057,12 @@ li.mtt-item-hidden { display:none; }
border-radius:14px;
}
#modal {
width: 90%;
}
#modal .modal-bottom button {
padding: 7px;
border-radius:14px;
}
} /* end of @media min 600px */

View file

@ -117,6 +117,7 @@
"action_delete": "Delete",
"action_priority": "Priority",
"action_move": "Move to",
"action_ok": "OK",
"notes": "Notes:",
"notes_show": "Show",
"notes_hide": "Hide",

View file

@ -117,6 +117,7 @@
"action_delete": "Удалить",
"action_priority": "Приоритет",
"action_move": "Переместить в",
"action_ok": "ОК",
"notes": "Заметки:",
"notes_show": "Показать",
"notes_hide": "Скрыть",

View file

@ -278,6 +278,13 @@ $().ready(function(){
</ul>
</div>
<div id="modal" style="display:none">
<div class="modal-content"></div>
<div class="modal-bottom">
<button id="btnModalOk"><?php _e('action_ok');?></button>
</div>
</div>
</div><!-- end of #mtt -->
<div id="footer">