You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
777 B

  1. if($('#page-type-edit').length) {
  2. $('.editor-toolbar').attr('data-margin-top', $('#header').height());
  3. var editorToolbarSticky = new Sticky('.editor-toolbar');
  4. //-> Discard
  5. $('.btn-edit-discard').on('click', (ev) => {
  6. $('#modal-edit-discard').toggleClass('is-active');
  7. });
  8. //-> Save
  9. $('.btn-edit-save').on('click', (ev) => {
  10. $.ajax(window.location.href, {
  11. data: {
  12. markdown: mde.value()
  13. },
  14. dataType: 'json',
  15. method: 'PUT'
  16. }).then((rData, rStatus, rXHR) => {
  17. if(rData.ok) {
  18. window.location.assign('/' + $('#page-type-edit').data('entrypath'));
  19. } else {
  20. alerts.pushError('Something went wrong', rData.error);
  21. }
  22. }, (rXHR, rStatus, err) => {
  23. alerts.pushError('Something went wrong', 'Save operation failed.');
  24. });
  25. });
  26. }