1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-26 02:11:15 +00:00
redmine/app/views/journals/edit.js.erb
Marius Balteanu f94370962a Focus on the textarea after clicking the Edit Journal button (#40556).
Patch by Yasu Saku (@skys).

git-svn-id: https://svn.redmine.org/redmine/trunk@22791 e93f8b46-1217-0410-a6f0-8f06a7374b81
2024-04-28 06:53:52 +00:00

19 lines
600 B
Plaintext

$("#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);
}
})();