mirror of https://github.com/requarks/wiki
parent
f0916dcfe6
commit
492bb9efa6
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,29 @@
|
||||
|
||||
//-> Create New Document
|
||||
|
||||
let suggestedCreatePath = currentBasePath + '/new-page';
|
||||
|
||||
$('.btn-create-prompt').on('click', (ev) => {
|
||||
$('#txt-create-prompt').val(suggestedCreatePath);
|
||||
$('#modal-create-prompt').toggleClass('is-active');
|
||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length);
|
||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden');
|
||||
});
|
||||
|
||||
$('#txt-create-prompt').on('keypress', (ev) => {
|
||||
if(ev.which === 13) {
|
||||
$('.btn-create-go').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-create-go').on('click', (ev) => {
|
||||
|
||||
let newDocPath = makeSafePath($('#txt-create-prompt').val());
|
||||
if(_.isEmpty(newDocPath)) {
|
||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden');
|
||||
} else {
|
||||
$('#txt-create-prompt').parent().addClass('is-loading');
|
||||
window.location.assign('/create/' + newDocPath);
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,49 @@
|
||||
|
||||
//-> Move Existing Document
|
||||
|
||||
if(currentBasePath !== '') {
|
||||
$('.btn-move-prompt').removeClass('is-hidden');
|
||||
}
|
||||
|
||||
let moveInitialDocument = _.lastIndexOf(currentBasePath, '/') + 1;
|
||||
|
||||
$('.btn-move-prompt').on('click', (ev) => {
|
||||
$('#txt-move-prompt').val(currentBasePath);
|
||||
$('#modal-move-prompt').toggleClass('is-active');
|
||||
setInputSelection($('#txt-move-prompt').get(0), moveInitialDocument, currentBasePath.length);
|
||||
$('#txt-move-prompt').removeClass('is-danger').next().addClass('is-hidden');
|
||||
});
|
||||
|
||||
$('#txt-move-prompt').on('keypress', (ev) => {
|
||||
if(ev.which === 13) {
|
||||
$('.btn-move-go').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-move-go').on('click', (ev) => {
|
||||
|
||||
let newDocPath = makeSafePath($('#txt-move-prompt').val());
|
||||
if(_.isEmpty(newDocPath) || newDocPath === currentBasePath || newDocPath === 'home') {
|
||||
$('#txt-move-prompt').addClass('is-danger').next().removeClass('is-hidden');
|
||||
} else {
|
||||
$('#txt-move-prompt').parent().addClass('is-loading');
|
||||
|
||||
$.ajax(window.location.href, {
|
||||
data: {
|
||||
move: newDocPath
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'PUT'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
if(rData.ok) {
|
||||
window.location.assign('/' + newDocPath);
|
||||
} else {
|
||||
alerts.pushError('Something went wrong', rData.error);
|
||||
}
|
||||
}, (rXHR, rStatus, err) => {
|
||||
alerts.pushError('Something went wrong', 'Save operation failed.');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
@ -1,34 +1,9 @@
|
||||
|
||||
if($('#page-type-view').length) {
|
||||
|
||||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') + '/' : '';
|
||||
let suggestedCreatePath = currentBasePath + 'new-page';
|
||||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : '';
|
||||
|
||||
//-> Create New Document
|
||||
|
||||
$('.btn-create-prompt').on('click', (ev) => {
|
||||
$('#txt-create-prompt').val(suggestedCreatePath);
|
||||
$('#modal-create-prompt').toggleClass('is-active');
|
||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length, suggestedCreatePath.length);
|
||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden');
|
||||
});
|
||||
|
||||
$('#txt-create-prompt').on('keypress', (ev) => {
|
||||
if(ev.which === 13) {
|
||||
$('.btn-create-go').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-create-go').on('click', (ev) => {
|
||||
|
||||
let newDocPath = makeSafePath($('#txt-create-prompt').val());
|
||||
if(_.isEmpty(newDocPath)) {
|
||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden');
|
||||
} else {
|
||||
$('#txt-create-prompt').parent().addClass('is-loading');
|
||||
window.location.assign('/create/' + newDocPath);
|
||||
}
|
||||
|
||||
});
|
||||
//=include ../modals/create.js
|
||||
//=include ../modals/move.js
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
|
||||
.modal#modal-move-prompt
|
||||
.modal-background
|
||||
.modal-container
|
||||
.modal-content
|
||||
.card.is-fullwidth
|
||||
header.card-header.is-info
|
||||
p.card-header-title Move document
|
||||
.card-content
|
||||
.content
|
||||
label.label Enter the new document path:
|
||||
p.control
|
||||
input.input(type='text', placeholder='page-name')#txt-move-prompt
|
||||
span.help.is-danger.is-hidden This document path is invalid or not allowed!
|
||||
span Note that moving or renaming documents can lead to broken links. Make sure to edit any page that links to this document afterwards!
|
||||
footer.card-footer
|
||||
a.card-footer-item.btn-move-prompt Discard
|
||||
a.card-footer-item.btn-move-go Move
|
@ -1,9 +1,29 @@
|
||||
extends ../layout.pug
|
||||
|
||||
block rootNavCenter
|
||||
h2.nav-item= pageData.meta.title
|
||||
|
||||
block rootNavRight
|
||||
i.nav-item#notifload
|
||||
a.nav-item.btn-move-prompt.is-hidden
|
||||
| Move
|
||||
a.nav-item(href='/' + pageData.meta.path)
|
||||
| Normal View
|
||||
span.nav-item
|
||||
a.button(href='/edit/' + pageData.meta.path)
|
||||
span.icon
|
||||
i.fa.fa-edit
|
||||
span Edit
|
||||
a.button.is-primary.btn-create-prompt
|
||||
span.icon
|
||||
i.fa.fa-plus
|
||||
span Create
|
||||
|
||||
block content
|
||||
|
||||
#page-type-source(data-entrypath=pageData.meta.path)
|
||||
.ace-container
|
||||
#source-display= pageData.markdown
|
||||
|
||||
include ../modals/create
|
||||
include ../modals/create.pug
|
||||
include ../modals/move.pug
|
||||
|
Loading…
Reference in new issue