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
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 =
...
@@ -22,6 +22,24 @@ GitLab.GfmAutoComplete =
Milestones
:
Milestones
:
template
:
'<li>${title}</li>'
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.
# Add GFM auto-completion to all input fields, that accept GFM input.
setup
:
(
wrap
)
->
setup
:
(
wrap
)
->
@
input
=
$
(
'.js-gfm-input'
)
@
input
=
$
(
'.js-gfm-input'
)
...
@@ -53,18 +71,37 @@ GitLab.GfmAutoComplete =
...
@@ -53,18 +71,37 @@ GitLab.GfmAutoComplete =
# Emoji
# Emoji
@
input
.
atwho
@
input
.
atwho
at
:
':'
at
:
':'
displayTpl
:
@
Emoji
.
template
displayTpl
:
(
value
)
=>
if
value
.
path
?
@
Emoji
.
template
else
@
Loading
.
template
insertTpl
:
':${name}:'
insertTpl
:
':${name}:'
data
:
[
'loading'
]
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
# Team Members
# Team Members
@
input
.
atwho
@
input
.
atwho
at
:
'@'
at
:
'@'
displayTpl
:
@
Members
.
template
displayTpl
:
(
value
)
=>
if
value
.
username
?
@
Members
.
template
else
@
Loading
.
template
insertTpl
:
'${atwho-at}${username}'
insertTpl
:
'${atwho-at}${username}'
searchKey
:
'search'
searchKey
:
'search'
data
:
[
'loading'
]
callbacks
:
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
beforeSave
:
(
members
)
->
beforeSave
:
(
members
)
->
$
.
map
members
,
(
m
)
->
$
.
map
members
,
(
m
)
->
return
m
if
not
m
.
username
?
title
=
m
.
name
title
=
m
.
name
title
+=
" (
#{
m
.
count
}
)"
if
m
.
count
title
+=
" (
#{
m
.
count
}
)"
if
m
.
count
...
@@ -76,11 +113,21 @@ GitLab.GfmAutoComplete =
...
@@ -76,11 +113,21 @@ GitLab.GfmAutoComplete =
at
:
'#'
at
:
'#'
alias
:
'issues'
alias
:
'issues'
searchKey
:
'search'
searchKey
:
'search'
displayTpl
:
@
Issues
.
template
displayTpl
:
(
value
)
=>
if
value
.
title
?
@
Issues
.
template
else
@
Loading
.
template
data
:
[
'loading'
]
insertTpl
:
'${atwho-at}${id}'
insertTpl
:
'${atwho-at}${id}'
callbacks
:
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
beforeSave
:
(
issues
)
->
beforeSave
:
(
issues
)
->
$
.
map
issues
,
(
i
)
->
$
.
map
issues
,
(
i
)
->
return
i
if
not
i
.
title
?
id
:
i
.
iid
id
:
i
.
iid
title
:
sanitize
(
i
.
title
)
title
:
sanitize
(
i
.
title
)
search
:
"
#{
i
.
iid
}
#{
i
.
title
}
"
search
:
"
#{
i
.
iid
}
#{
i
.
title
}
"
...
@@ -89,11 +136,18 @@ GitLab.GfmAutoComplete =
...
@@ -89,11 +136,18 @@ GitLab.GfmAutoComplete =
at
:
'%'
at
:
'%'
alias
:
'milestones'
alias
:
'milestones'
searchKey
:
'search'
searchKey
:
'search'
displayTpl
:
@
Milestones
.
template
displayTpl
:
(
value
)
=>
if
value
.
title
?
@
Milestones
.
template
else
@
Loading
.
template
insertTpl
:
'${atwho-at}"${title}"'
insertTpl
:
'${atwho-at}"${title}"'
data
:
[
'loading'
]
callbacks
:
callbacks
:
beforeSave
:
(
milestones
)
->
beforeSave
:
(
milestones
)
->
$
.
map
milestones
,
(
m
)
->
$
.
map
milestones
,
(
m
)
->
return
m
if
not
m
.
title
?
id
:
m
.
iid
id
:
m
.
iid
title
:
sanitize
(
m
.
title
)
title
:
sanitize
(
m
.
title
)
search
:
"
#{
m
.
title
}
"
search
:
"
#{
m
.
title
}
"
...
@@ -102,11 +156,21 @@ GitLab.GfmAutoComplete =
...
@@ -102,11 +156,21 @@ GitLab.GfmAutoComplete =
at
:
'!'
at
:
'!'
alias
:
'mergerequests'
alias
:
'mergerequests'
searchKey
:
'search'
searchKey
:
'search'
displayTpl
:
@
Issues
.
template
displayTpl
:
(
value
)
=>
if
value
.
title
?
@
Issues
.
template
else
@
Loading
.
template
data
:
[
'loading'
]
insertTpl
:
'${atwho-at}${id}'
insertTpl
:
'${atwho-at}${id}'
callbacks
:
callbacks
:
sorter
:
@
DefaultOptions
.
sorter
filter
:
@
DefaultOptions
.
filter
beforeInsert
:
@
DefaultOptions
.
beforeInsert
beforeSave
:
(
merges
)
->
beforeSave
:
(
merges
)
->
$
.
map
merges
,
(
m
)
->
$
.
map
merges
,
(
m
)
->
return
m
if
not
m
.
title
?
id
:
m
.
iid
id
:
m
.
iid
title
:
sanitize
(
m
.
title
)
title
:
sanitize
(
m
.
title
)
search
:
"
#{
m
.
iid
}
#{
m
.
title
}
"
search
:
"
#{
m
.
iid
}
#{
m
.
title
}
"
...
@@ -128,3 +192,7 @@ GitLab.GfmAutoComplete =
...
@@ -128,3 +192,7 @@ GitLab.GfmAutoComplete =
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
# load emojis
# load emojis
@
input
.
atwho
'load'
,
':'
,
data
.
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