Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
76534e77
Commit
76534e77
authored
Jan 29, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keeps cursor at the correct place after changing text in dropzone
parent
fc334e72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
+2
-7
app/assets/javascripts/dropzone_input.js.coffee
app/assets/javascripts/dropzone_input.js.coffee
+2
-7
No files found.
app/assets/javascripts/dropzone_input.js.coffee
View file @
76534e77
...
@@ -65,13 +65,7 @@ class @DropzoneInput
...
@@ -65,13 +65,7 @@ class @DropzoneInput
return
return
success
:
(
header
,
response
)
->
success
:
(
header
,
response
)
->
link_markdown
=
response
.
link
.
markdown
pasteText
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
"
return
return
error
:
(
temp
,
errorMessage
)
->
error
:
(
temp
,
errorMessage
)
->
...
@@ -133,6 +127,7 @@ class @DropzoneInput
...
@@ -133,6 +127,7 @@ class @DropzoneInput
beforeSelection
=
$
(
child
).
val
().
substring
0
,
caretStart
beforeSelection
=
$
(
child
).
val
().
substring
0
,
caretStart
afterSelection
=
$
(
child
).
val
().
substring
caretEnd
,
textEnd
afterSelection
=
$
(
child
).
val
().
substring
caretEnd
,
textEnd
$
(
child
).
val
beforeSelection
+
text
+
afterSelection
$
(
child
).
val
beforeSelection
+
text
+
afterSelection
child
.
get
(
0
).
setSelectionRange
caretStart
+
text
.
length
,
caretEnd
+
text
.
length
form_textarea
.
trigger
"input"
form_textarea
.
trigger
"input"
getFilename
=
(
e
)
->
getFilename
=
(
e
)
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment