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>
|
<span class="option-label" style="margin-top:8px;">Нажмите на страницы для поворота</span>
|
||||||
<div class="page-grid" id="rotatePageGrid"></div>
|
<div class="page-grid" id="rotatePageGrid"></div>
|
||||||
<div class="grid-action-bar">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1189,7 +1188,14 @@
|
|||||||
if (_sel && typeof renderPageGrid === 'function') {
|
if (_sel && typeof renderPageGrid === 'function') {
|
||||||
renderPageGrid('deletePageGrid', 'deleteHint', _sel.id, _sel.pages, 'delete');
|
renderPageGrid('deletePageGrid', 'deleteHint', _sel.id, _sel.pages, 'delete');
|
||||||
renderPageGrid('rotatePageGrid', 'rotateHint', _sel.id, _sel.pages, 'rotate');
|
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') {
|
} else if (mode === 'rotate') {
|
||||||
thumb.addEventListener('click', () => {
|
thumb.addEventListener('click', () => {
|
||||||
thumb.classList.toggle('selected');
|
// Immediate rotate on click
|
||||||
// Visual rotation preview
|
const angle = state.rotateAngle || 90;
|
||||||
if (thumb.classList.contains('selected')) {
|
thumb.classList.add('rotate-' + angle);
|
||||||
const angle = state.rotateAngle || 90;
|
thumb.style.pointerEvents = 'none';
|
||||||
thumb.classList.add('rotate-' + angle);
|
thumb.style.opacity = '0.6';
|
||||||
} else {
|
// Auto-execute rotate for this page
|
||||||
thumb.classList.remove('rotate-90', 'rotate-180', 'rotate-270');
|
autoRotatePage(parseInt(thumb.dataset.page), angle);
|
||||||
}
|
|
||||||
updateRotateCount();
|
|
||||||
});
|
});
|
||||||
} else if (mode === 'reorder') {
|
} else if (mode === 'reorder') {
|
||||||
// Drag and drop
|
// Drag and drop
|
||||||
@ -1797,6 +1801,11 @@
|
|||||||
if (!pages.length) { showError('Выберите страницы'); return; }
|
if (!pages.length) { showError('Выберите страницы'); return; }
|
||||||
const fileId = state.selectedFileId;
|
const fileId = state.selectedFileId;
|
||||||
if (!fileId) { showError('Выберите файл'); return; }
|
if (!fileId) { showError('Выберите файл'); return; }
|
||||||
|
const selFile = state.files.find(f => f.id === fileId);
|
||||||
|
if (selFile && pages.length >= selFile.pages) {
|
||||||
|
showError('Нельзя удалить все страницы');
|
||||||
|
return;
|
||||||
|
}
|
||||||
clearError();
|
clearError();
|
||||||
// Hide deleted pages visually
|
// Hide deleted pages visually
|
||||||
const grid = document.getElementById('deletePageGrid');
|
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>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user