2016-08-28 15:27:05 +00:00
|
|
|
|
|
|
|
if($('#page-type-edit').length) {
|
|
|
|
|
2016-08-31 03:38:21 +00:00
|
|
|
$('.editor-toolbar').attr('data-margin-top', $('#header').height());
|
|
|
|
var editorToolbarSticky = new Sticky('.editor-toolbar');
|
|
|
|
|
2016-08-28 15:27:05 +00:00
|
|
|
//-> Discard
|
|
|
|
|
|
|
|
$('.btn-edit-discard').on('click', (ev) => {
|
|
|
|
$('#modal-edit-discard').toggleClass('is-active');
|
|
|
|
});
|
|
|
|
|
|
|
|
//-> Save
|
|
|
|
|
|
|
|
$('.btn-edit-save').on('click', (ev) => {
|
|
|
|
|
2016-08-29 05:21:35 +00:00
|
|
|
$.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.');
|
|
|
|
});
|
2016-08-28 15:27:05 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|