wikijs-fork/client/js/pages/edit.js
2016-08-30 23:38:21 -04:00

35 lines
777 B
JavaScript

if($('#page-type-edit').length) {
$('.editor-toolbar').attr('data-margin-top', $('#header').height());
var editorToolbarSticky = new Sticky('.editor-toolbar');
//-> Discard
$('.btn-edit-discard').on('click', (ev) => {
$('#modal-edit-discard').toggleClass('is-active');
});
//-> Save
$('.btn-edit-save').on('click', (ev) => {
$.ajax(window.location.href, {
data: {
markdown: mde.value()
},
dataType: 'json',
method: 'PUT'
}).then((rData, rStatus, rXHR) => {
if(rData.ok) {
window.location.assign('/' + $('#page-type-edit').data('entrypath'));
} else {
alerts.pushError('Something went wrong', rData.error);
}
}, (rXHR, rStatus, err) => {
alerts.pushError('Something went wrong', 'Save operation failed.');
});
});
}