BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ba1e9495
Commit
ba1e9495
authored
Apr 19, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '30008-textarea-focus' into 'master'
update textarea height and refocus when attaching files Closes #30008 See merge request !10300
parents
5613c325
ee65f5ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
dropzone_input.js
app/assets/javascripts/dropzone_input.js
+7
-4
30008-textarea-focus.yml
changelogs/unreleased/30008-textarea-focus.yml
+4
-0
No files found.
app/assets/javascripts/dropzone_input.js
View file @
ba1e9495
...
...
@@ -130,13 +130,15 @@ window.DropzoneInput = (function() {
var
afterSelection
,
beforeSelection
,
caretEnd
,
caretStart
,
textEnd
;
var
formattedText
=
text
;
if
(
shouldPad
)
formattedText
+=
"
\
n
\
n"
;
caretStart
=
$
(
child
)[
0
].
selectionStart
;
caretEnd
=
$
(
child
)[
0
].
selectionEnd
;
const
textarea
=
child
.
get
(
0
);
caretStart
=
textarea
.
selectionStart
;
caretEnd
=
textarea
.
selectionEnd
;
textEnd
=
$
(
child
).
val
().
length
;
beforeSelection
=
$
(
child
).
val
().
substring
(
0
,
caretStart
);
afterSelection
=
$
(
child
).
val
().
substring
(
caretEnd
,
textEnd
);
$
(
child
).
val
(
beforeSelection
+
formattedText
+
afterSelection
);
child
.
get
(
0
).
setSelectionRange
(
caretStart
+
formattedText
.
length
,
caretEnd
+
formattedText
.
length
);
textarea
.
setSelectionRange
(
caretStart
+
formattedText
.
length
,
caretEnd
+
formattedText
.
length
);
textarea
.
style
.
height
=
`
${
textarea
.
scrollHeight
}
px`
;
return
form_textarea
.
trigger
(
"input"
);
};
getFilename
=
function
(
e
)
{
...
...
@@ -180,7 +182,7 @@ window.DropzoneInput = (function() {
};
insertToTextArea
=
function
(
filename
,
url
)
{
return
$
(
child
).
val
(
function
(
index
,
val
)
{
return
val
.
replace
(
"{{"
+
filename
+
"}}"
,
url
+
"
\
n"
);
return
val
.
replace
(
"{{"
+
filename
+
"}}"
,
url
);
});
};
appendToTextArea
=
function
(
url
)
{
...
...
@@ -215,6 +217,7 @@ window.DropzoneInput = (function() {
form
.
find
(
".markdown-selector"
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$
(
this
).
closest
(
'.gfm-form'
).
find
(
'.div-dropzone'
).
click
();
form_textarea
.
focus
();
});
}
...
...
changelogs/unreleased/30008-textarea-focus.yml
0 → 100644
View file @
ba1e9495
---
title
:
refocus textarea after attaching a file
merge_request
:
author
:
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