mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
[Organization] Move page on left or right
This commit is contained in:
parent
a848163e2d
commit
653036f28d
@ -183,38 +183,15 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
|
||||
});
|
||||
canvasContainer.querySelector('.btn-drag-here_mobile').addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
canvasContainer.querySelector('.btn-drag-here-left').click();
|
||||
movePagesDragged(this.parentNode, 'right');
|
||||
});
|
||||
canvasContainer.querySelector('.btn-drag-here-right').addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
canvasContainer.querySelector('.btn-drag-here-left').click();
|
||||
movePagesDragged(this.parentNode, 'right');
|
||||
});
|
||||
canvasContainer.querySelector('.btn-drag-here-left').addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
let pageHere = this.parentNode;
|
||||
let after = false;
|
||||
let pageHereFound = false;
|
||||
document.querySelectorAll('.canvas-container').forEach(function(page) {
|
||||
if(page.id == pageHere.id) {
|
||||
pageHereFound = true;
|
||||
}
|
||||
if(!after && isPageDragged(page) && !pageHereFound) {
|
||||
after = true;
|
||||
}
|
||||
});
|
||||
document.querySelectorAll('.canvas-container .input-drag:checked').forEach(function(item) {
|
||||
let page = item.parentNode;
|
||||
if(after) {
|
||||
pageHere.insertAdjacentElement('afterend', page);
|
||||
} else {
|
||||
pageHere.insertAdjacentElement('beforebegin', page);
|
||||
}
|
||||
page.querySelector('input[type=checkbox].input-drag').checked = false;
|
||||
});
|
||||
updateGlobalState();
|
||||
document.querySelectorAll('.canvas-container').forEach(function(page) {
|
||||
updatePageState(page);
|
||||
});
|
||||
movePagesDragged(this.parentNode, 'left');
|
||||
});
|
||||
canvasContainer.querySelector('.btn-cancel').addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
@ -381,6 +358,22 @@ var isPageDragged = function(page) {
|
||||
return page.querySelector('input[type=checkbox].input-drag').checked;
|
||||
}
|
||||
|
||||
var movePagesDragged = function(pageHere, position) {
|
||||
document.querySelectorAll('.canvas-container .input-drag:checked').forEach(function(item) {
|
||||
let page = item.parentNode;
|
||||
if(position == 'right') {
|
||||
pageHere.insertAdjacentElement('afterend', page);
|
||||
} else {
|
||||
pageHere.insertAdjacentElement('beforebegin', page);
|
||||
}
|
||||
page.querySelector('input[type=checkbox].input-drag').checked = false;
|
||||
});
|
||||
updateGlobalState();
|
||||
document.querySelectorAll('.canvas-container').forEach(function(page) {
|
||||
updatePageState(page);
|
||||
});
|
||||
}
|
||||
|
||||
var toggleDeletePage = function(page) {
|
||||
deletePage(page, isPageDeleted(page))
|
||||
updateGlobalState();
|
||||
|
Loading…
Reference in New Issue
Block a user