diff options
author | Phil Hughes <me@iamphill.com> | 2016-01-29 15:55:31 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-01-29 15:55:31 +0000 |
commit | 76534e776e76ef868de7f41fa03bc933882a7b1e (patch) | |
tree | 0c517947ca0748eb4a9b27cc4781107520179127 /app/assets | |
parent | fc334e72f40ab5394c70f5cd29829dc3c0b0d485 (diff) | |
download | gitlab-ce-76534e776e76ef868de7f41fa03bc933882a7b1e.tar.gz |
Keeps cursor at the correct place after changing text in dropzone
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/dropzone_input.js.coffee | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/app/assets/javascripts/dropzone_input.js.coffee b/app/assets/javascripts/dropzone_input.js.coffee index 32a5594a5b1..b502131a99d 100644 --- a/app/assets/javascripts/dropzone_input.js.coffee +++ b/app/assets/javascripts/dropzone_input.js.coffee @@ -65,13 +65,7 @@ class @DropzoneInput return success: (header, response) -> - link_markdown = response.link.markdown - child = $(dropzone[0]).children("textarea") - cursor_pos = child.prop "selectionStart" - value = $(child).val() - new_text = "#{value.substring(0, cursor_pos)}#{link_markdown}#{value.substring(cursor_pos, value.length)}" - - $(child).val new_text + "\n" + pasteText response.link.markdown return error: (temp, errorMessage) -> @@ -133,6 +127,7 @@ class @DropzoneInput beforeSelection = $(child).val().substring 0, caretStart afterSelection = $(child).val().substring caretEnd, textEnd $(child).val beforeSelection + text + afterSelection + child.get(0).setSelectionRange caretStart + text.length, caretEnd + text.length form_textarea.trigger "input" getFilename = (e) -> |