v1.3.47: fix InvokeStrategy in archive handler, modal error display, draggable modals
This commit is contained in:
@@ -22,6 +22,7 @@ function openCreateArchive() {
|
||||
if (fileInput) fileInput.value = '';
|
||||
var aiRes = document.getElementById('ca-ai-result');
|
||||
if (aiRes) { aiRes.style.display = 'none'; aiRes.textContent = ''; }
|
||||
hideModalError('ca-error');
|
||||
document.getElementById('create-archive-modal').classList.add('open');
|
||||
document.getElementById('ca-name').focus();
|
||||
}
|
||||
@@ -77,6 +78,7 @@ async function submitCreateArchive() {
|
||||
await reloadAll();
|
||||
} catch (e) {
|
||||
progress.stop('Ошибка создания: ' + e.message, 'err');
|
||||
showModalError('ca-error', 'Ошибка: ' + e.message);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ function openCreateCode() {
|
||||
toggleScheduleFields('cc');
|
||||
var aiRes = document.getElementById('cc-ai-result');
|
||||
if (aiRes) { aiRes.style.display = 'none'; aiRes.textContent = ''; }
|
||||
hideModalError('cc-error');
|
||||
document.getElementById('create-code-modal').classList.add('open');
|
||||
document.getElementById('cc-name').focus();
|
||||
}
|
||||
@@ -65,6 +66,7 @@ async function submitCreateCode() {
|
||||
await reloadAll();
|
||||
} catch (e) {
|
||||
progress.stop('Ошибка создания: ' + e.message, 'err');
|
||||
showModalError('cc-error', 'Ошибка: ' + e.message);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,68 @@
|
||||
/* modals.js — управление модальными окнами Help и Invoke */
|
||||
|
||||
// makeDraggable — делает .panel внутри modalId перетаскиваемым за заголовок (h3).
|
||||
function makeDraggable(modalId) {
|
||||
var modal = document.getElementById(modalId);
|
||||
if (!modal) return;
|
||||
var panel = modal.querySelector('.panel');
|
||||
if (!panel) return;
|
||||
var handle = panel.querySelector('h3');
|
||||
if (!handle) return;
|
||||
|
||||
handle.style.cursor = 'move';
|
||||
handle.style.userSelect = 'none';
|
||||
|
||||
var startX, startY, startLeft, startTop;
|
||||
|
||||
handle.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
var rect = panel.getBoundingClientRect();
|
||||
// Переводим в position:fixed если ещё не
|
||||
if (!panel.style.left) {
|
||||
panel.style.position = 'fixed';
|
||||
panel.style.left = rect.left + 'px';
|
||||
panel.style.top = rect.top + 'px';
|
||||
panel.style.margin = '0';
|
||||
}
|
||||
startX = e.clientX;
|
||||
startY = e.clientY;
|
||||
startLeft = parseInt(panel.style.left, 10) || rect.left;
|
||||
startTop = parseInt(panel.style.top, 10) || rect.top;
|
||||
|
||||
function onMove(e) {
|
||||
var dx = e.clientX - startX;
|
||||
var dy = e.clientY - startY;
|
||||
panel.style.left = (startLeft + dx) + 'px';
|
||||
panel.style.top = (startTop + dy) + 'px';
|
||||
}
|
||||
function onUp() {
|
||||
document.removeEventListener('mousemove', onMove);
|
||||
document.removeEventListener('mouseup', onUp);
|
||||
}
|
||||
document.addEventListener('mousemove', onMove);
|
||||
document.addEventListener('mouseup', onUp);
|
||||
});
|
||||
}
|
||||
|
||||
// Инициализация после загрузки DOM
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
['create-code-modal', 'create-archive-modal', 'edit-modal', 'help-modal', 'invoke-modal'].forEach(makeDraggable);
|
||||
});
|
||||
|
||||
// showModalError — показывает ошибку внутри модалки.
|
||||
// errorDivId — id элемента с классом modal-error.
|
||||
function showModalError(errorDivId, message) {
|
||||
var el = document.getElementById(errorDivId);
|
||||
if (!el) return;
|
||||
el.textContent = message;
|
||||
el.style.display = 'block';
|
||||
}
|
||||
|
||||
function hideModalError(errorDivId) {
|
||||
var el = document.getElementById(errorDivId);
|
||||
if (el) { el.style.display = 'none'; el.textContent = ''; }
|
||||
}
|
||||
|
||||
function openHelp() {
|
||||
document.getElementById('help-modal').classList.add('open');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user