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.

33 lines
1.0 KiB

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