Make page rewrite optional

This commit is contained in:
2026-05-07 19:35:10 +02:00
parent a18f991c0b
commit d8089d9cb3
4 changed files with 80 additions and 40 deletions
+39 -9
View File
@@ -56,16 +56,46 @@ function movePage() {
preselect: parent,
hideFiles: true,
confirmLabel: 'NEXT',
allowRoot: false,
onSelect: function (newParent) {
promptPageName('Move — new name?', currentName, 'MOVE', function (name) {
var dest = (newParent === '/' ? '' : newParent) + '/' + name;
var form = document.createElement('form');
form.method = 'POST';
form.action = window.location.pathname + '?move=' +
encodeURIComponent(dest);
document.body.appendChild(form);
form.submit();
var input = document.createElement('input');
input.type = 'text';
input.className = 'modal-input';
input.placeholder = 'Page name';
input.value = currentName;
var linksCheckbox = document.createElement('input');
linksCheckbox.type = 'checkbox';
linksCheckbox.id = 'move-update-links';
var linksLabel = document.createElement('label');
linksLabel.htmlFor = linksCheckbox.id;
linksLabel.className = 'modal-checkbox';
linksLabel.appendChild(linksCheckbox);
linksLabel.appendChild(document.createTextNode('Update links'));
var body = document.createDocumentFragment();
body.appendChild(input);
body.appendChild(linksLabel);
openModal({
title: 'Move — new name?',
body: body,
confirm: {
label: 'MOVE',
onConfirm: function () {
var name = input.value.trim();
if (!name) return;
var dest = (newParent === '/' ? '' : newParent) + '/' + name;
var action = window.location.pathname + '?move=' +
encodeURIComponent(dest);
if (linksCheckbox.checked) action += '&links=1';
var form = document.createElement('form');
form.method = 'POST';
form.action = action;
document.body.appendChild(form);
form.submit();
}
}
});
}
});