Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
fa2119a4
Commit
fa2119a4
authored
9 years ago
by
Rodrigo Nascimento
Browse files
Options
Downloads
Patches
Plain Diff
Improve popup completion
parent
a34da702
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/views/app/message-popup.coffee
+38
-3
38 additions, 3 deletions
client/views/app/message-popup.coffee
with
38 additions
and
3 deletions
client/views/app/message-popup.coffee
+
38
−
3
View file @
fa2119a4
getCursorPosition
=
(
input
)
->
if
not
input
?
then
return
if
input
.
selectionStart
?
return
input
.
selectionStart
else
if
document
.
selection
?
input
.
focus
()
sel
=
document
.
selection
.
createRange
()
selLen
=
document
.
selection
.
createRange
().
text
.
length
sel
.
moveStart
(
'character'
,
-
input
.
value
.
length
)
return
sel
.
text
.
length
-
selLen
setCursorPosition
=
(
input
,
caretPos
)
->
if
not
input
?
then
return
if
input
.
selectionStart
?
input
.
focus
()
return
input
.
setSelectionRange
(
caretPos
,
caretPos
)
else
if
document
.
selection
?
range
=
input
.
createTextRange
()
range
.
move
(
'character'
,
caretPos
)
range
.
select
()
val
=
(
v
,
d
)
->
val
=
(
v
,
d
)
->
return
if
v
?
then
v
else
d
return
if
v
?
then
v
else
d
...
@@ -52,7 +73,18 @@ Template.messagePopup.onCreated ->
...
@@ -52,7 +73,18 @@ Template.messagePopup.onCreated ->
if
event
.
which
is
13
if
event
.
which
is
13
template
.
open
.
set
false
template
.
open
.
set
false
template
.
input
.
value
=
template
.
input
.
value
.
replace
template
.
selectorRegex
,
template
.
prefix
+
template
.
value
.
curValue
+
template
.
suffix
value
=
template
.
input
.
value
caret
=
getCursorPosition
(
template
.
input
)
firstPartValue
=
value
.
substr
0
,
caret
lastPartValue
=
value
.
substr
caret
firstPartValue
=
firstPartValue
.
replace
(
template
.
selectorRegex
,
template
.
prefix
+
template
.
value
.
curValue
+
template
.
suffix
)
template
.
input
.
value
=
firstPartValue
+
lastPartValue
setCursorPosition
template
.
input
,
firstPartValue
.
length
event
.
preventDefault
()
event
.
preventDefault
()
event
.
stopPropagation
()
event
.
stopPropagation
()
...
@@ -63,8 +95,11 @@ Template.messagePopup.onCreated ->
...
@@ -63,8 +95,11 @@ Template.messagePopup.onCreated ->
event
.
stopPropagation
()
event
.
stopPropagation
()
return
return
if
template
.
matchSelectorRegex
.
test
template
.
input
.
value
value
=
template
.
input
.
value
template
.
textFilter
.
set
(
template
.
input
.
value
.
match
(
template
.
selectorRegex
)[
1
])
value
=
value
.
substr
0
,
getCursorPosition
(
template
.
input
)
if
template
.
matchSelectorRegex
.
test
value
template
.
textFilter
.
set
(
value
.
match
(
template
.
selectorRegex
)[
1
])
template
.
open
.
set
true
template
.
open
.
set
true
else
else
template
.
open
.
set
false
template
.
open
.
set
false
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment