PDF UX: instant rotate, delete all protection, reorder >1 only
- Rotate: click page = instant rotate + sync (no select+button) - Delete: cannot delete all pages (error message) - Reorder: grid only shown when >1 page - Visual feedback: rotated page dims, hint shows progress
This commit is contained in:
parent
9193a98bc4
commit
b8b1339309
@ -745,8 +745,7 @@
|
||||
<span class="option-label" style="margin-top:8px;">Нажмите на страницы для поворота</span>
|
||||
<div class="page-grid" id="rotatePageGrid"></div>
|
||||
<div class="grid-action-bar">
|
||||
<button class="grid-action-btn primary" id="btnRotateSelected" disabled onclick="executeRotatePages()">Повернуть выбранные (<span id="rotateCount">0</span>)</button>
|
||||
<span class="page-grid-hint" id="rotateHint"></span>
|
||||
<span class="page-grid-hint" id="rotateHint">Нажмите на страницу для поворота</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1189,7 +1188,14 @@
|
||||
if (_sel && typeof renderPageGrid === 'function') {
|
||||
renderPageGrid('deletePageGrid', 'deleteHint', _sel.id, _sel.pages, 'delete');
|
||||
renderPageGrid('rotatePageGrid', 'rotateHint', _sel.id, _sel.pages, 'rotate');
|
||||
renderPageGrid('reorderPageGrid', 'reorderHint', _sel.id, _sel.pages, 'reorder');
|
||||
if (_sel.pages > 1) {
|
||||
renderPageGrid('reorderPageGrid', 'reorderHint', _sel.id, _sel.pages, 'reorder');
|
||||
} else {
|
||||
var rg = document.getElementById('reorderPageGrid');
|
||||
var rh = document.getElementById('reorderHint');
|
||||
if (rg) rg.innerHTML = '';
|
||||
if (rh) rh.textContent = 'Нужно больше одной страницы';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1719,15 +1725,13 @@
|
||||
});
|
||||
} else if (mode === 'rotate') {
|
||||
thumb.addEventListener('click', () => {
|
||||
thumb.classList.toggle('selected');
|
||||
// Visual rotation preview
|
||||
if (thumb.classList.contains('selected')) {
|
||||
const angle = state.rotateAngle || 90;
|
||||
thumb.classList.add('rotate-' + angle);
|
||||
} else {
|
||||
thumb.classList.remove('rotate-90', 'rotate-180', 'rotate-270');
|
||||
}
|
||||
updateRotateCount();
|
||||
// Immediate rotate on click
|
||||
const angle = state.rotateAngle || 90;
|
||||
thumb.classList.add('rotate-' + angle);
|
||||
thumb.style.pointerEvents = 'none';
|
||||
thumb.style.opacity = '0.6';
|
||||
// Auto-execute rotate for this page
|
||||
autoRotatePage(parseInt(thumb.dataset.page), angle);
|
||||
});
|
||||
} else if (mode === 'reorder') {
|
||||
// Drag and drop
|
||||
@ -1797,6 +1801,11 @@
|
||||
if (!pages.length) { showError('Выберите страницы'); return; }
|
||||
const fileId = state.selectedFileId;
|
||||
if (!fileId) { showError('Выберите файл'); return; }
|
||||
const selFile = state.files.find(f => f.id === fileId);
|
||||
if (selFile && pages.length >= selFile.pages) {
|
||||
showError('Нельзя удалить все страницы');
|
||||
return;
|
||||
}
|
||||
clearError();
|
||||
// Hide deleted pages visually
|
||||
const grid = document.getElementById('deletePageGrid');
|
||||
@ -1917,6 +1926,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Auto-rotate single page on click
|
||||
let _rotateTimeout = null;
|
||||
function autoRotatePage(pageNum, angle) {
|
||||
clearTimeout(_rotateTimeout);
|
||||
const hint = document.getElementById('rotateHint');
|
||||
if (hint) hint.textContent = 'Поворот страницы ' + pageNum + '...';
|
||||
_rotateTimeout = setTimeout(async () => {
|
||||
const fileId = state.selectedFileId;
|
||||
if (!fileId) return;
|
||||
try {
|
||||
const res = await fetch('/pdf/rotate', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({ fileId, pages: String(pageNum), angle })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
if (hint) hint.textContent = 'Страница ' + pageNum + ' повёрнута';
|
||||
await syncAfterOperation(data);
|
||||
} catch(e) {
|
||||
if (hint) hint.textContent = 'Ошибка: ' + e.message;
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user