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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
53866711
Commit
53866711
authored
May 17, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show loading indicator for autocomplete
Closes #15435
parent
fbef0cc9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
5 deletions
+73
-5
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+73
-5
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
View file @
53866711
...
...
@@ -22,6 +22,24 @@ GitLab.GfmAutoComplete =
Milestones
:
template
:
'<li>${title}</li>'
Loading
:
template
:
'<li><i class="fa fa-refresh fa-spin"></i> Loading...</li>'
DefaultOptions
:
sorter
:
(
query
,
items
,
searchKey
)
->
return
items
if
items
[
0
].
name
?
and
items
[
0
].
name
is
'loading'
$
.
fn
.
atwho
.
default
.
callbacks
.
sorter
(
query
,
items
,
searchKey
)
filter
:
(
query
,
data
,
searchKey
)
->
return
data
if
data
[
0
]
is
'loading'
$
.
fn
.
atwho
.
default
.
callbacks
.
filter
(
query
,
data
,
searchKey
)
beforeInsert
:
(
value
)
->
if
value
.
indexOf
(
'undefined'
)
@
at
else
value
# Add GFM auto-completion to all input fields, that accept GFM input.
setup
:
(
wrap
)
->
@
input
=
$
(
'.js-gfm-input'
)
...
...
@@ -53,18 +71,37 @@ GitLab.GfmAutoComplete =
# Emoji
@
input
.
atwho
at
:
':'
displayTpl
:
@
Emoji
.
template
displayTpl
:
(
value
)
=>
if
value
.
path
?
@
Emoji
.
template
else
@
Loading
.
template
insertTpl
:
':${name}:'
data
:
[
'loading'
]
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
# Team Members
@
input
.
atwho
at
:
'@'
displayTpl
:
@
Members
.
template
displayTpl
:
(
value
)
=>
if
value
.
username
?
@
Members
.
template
else
@
Loading
.
template
insertTpl
:
'${atwho-at}${username}'
searchKey
:
'search'
data
:
[
'loading'
]
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
beforeSave
:
(
members
)
->
$
.
map
members
,
(
m
)
->
return
m
if
not
m
.
username
?
title
=
m
.
name
title
+=
" (
#{
m
.
count
}
)"
if
m
.
count
...
...
@@ -76,11 +113,21 @@ GitLab.GfmAutoComplete =
at
:
'#'
alias
:
'issues'
searchKey
:
'search'
displayTpl
:
@
Issues
.
template
displayTpl
:
(
value
)
=>
if
value
.
title
?
@
Issues
.
template
else
@
Loading
.
template
data
:
[
'loading'
]
insertTpl
:
'${atwho-at}${id}'
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
beforeSave
:
(
issues
)
->
$
.
map
issues
,
(
i
)
->
return
i
if
not
i
.
title
?
id
:
i
.
iid
title
:
sanitize
(
i
.
title
)
search
:
"
#{
i
.
iid
}
#{
i
.
title
}
"
...
...
@@ -89,11 +136,18 @@ GitLab.GfmAutoComplete =
at
:
'%'
alias
:
'milestones'
searchKey
:
'search'
displayTpl
:
@
Milestones
.
template
displayTpl
:
(
value
)
=>
if
value
.
title
?
@
Milestones
.
template
else
@
Loading
.
template
insertTpl
:
'${atwho-at}"${title}"'
data
:
[
'loading'
]
callbacks
:
beforeSave
:
(
milestones
)
->
$
.
map
milestones
,
(
m
)
->
return
m
if
not
m
.
title
?
id
:
m
.
iid
title
:
sanitize
(
m
.
title
)
search
:
"
#{
m
.
title
}
"
...
...
@@ -102,11 +156,21 @@ GitLab.GfmAutoComplete =
at
:
'!'
alias
:
'mergerequests'
searchKey
:
'search'
displayTpl
:
@
Issues
.
template
displayTpl
:
(
value
)
=>
if
value
.
title
?
@
Issues
.
template
else
@
Loading
.
template
data
:
[
'loading'
]
insertTpl
:
'${atwho-at}${id}'
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
beforeSave
:
(
merges
)
->
$
.
map
merges
,
(
m
)
->
return
m
if
not
m
.
title
?
id
:
m
.
iid
title
:
sanitize
(
m
.
title
)
search
:
"
#{
m
.
iid
}
#{
m
.
title
}
"
...
...
@@ -128,3 +192,7 @@ GitLab.GfmAutoComplete =
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
# load emojis
@
input
.
atwho
'load'
,
':'
,
data
.
emojis
# This trigger at.js again
# otherwise we would be stuck with loading until the user types
$
(
':focus'
).
trigger
(
'keyup'
)
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