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.

28 lines
891 B

  1. //-> Create New Document
  2. let suggestedCreatePath = currentBasePath + '/new-page';
  3. $('.btn-create-prompt').on('click', (ev) => {
  4. $('#txt-create-prompt').val(suggestedCreatePath);
  5. $('#modal-create-prompt').toggleClass('is-active');
  6. setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length);
  7. $('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden');
  8. });
  9. $('#txt-create-prompt').on('keypress', (ev) => {
  10. if(ev.which === 13) {
  11. $('.btn-create-go').trigger('click');
  12. }
  13. });
  14. $('.btn-create-go').on('click', (ev) => {
  15. let newDocPath = makeSafePath($('#txt-create-prompt').val());
  16. if(_.isEmpty(newDocPath)) {
  17. $('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden');
  18. } else {
  19. $('#txt-create-prompt').parent().addClass('is-loading');
  20. window.location.assign('/create/' + newDocPath);
  21. }
  22. });