summaryrefslogtreecommitdiffstats
path: root/app/views/journals/edit.js.erb
blob: 73631840f4d511dc298d61034c8bc3318aa83a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$("#journal-<%= @journal.id %>-notes").hide();

if ($("form#journal-<%= @journal.id %>-form").length > 0) {
  // journal edit form already loaded
  $("#journal-<%= @journal.id %>-form").show();
} else {
  $("#journal-<%= @journal.id %>-notes").after('<%= escape_javascript(render :partial => 'notes_form') %>');
}

// Focus on the textarea
(() => {
  const textarea = $("#journal-<%= @journal.id %>-form .wiki-edit");
  if (textarea.length > 0) {
    textarea.focus();
    const textareaLength = textarea.val().length;
    textarea.get(0).setSelectionRange(textareaLength, textareaLength);
  }
})();