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
Kazuhiko Shiozaki
gitlab-ce
Commits
a5861b8f
Commit
a5861b8f
authored
Dec 11, 2012
by
Cyril
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix gfm autocomplete for usernames
parent
d3b8952f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
46 deletions
+52
-46
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+52
-46
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
View file @
a5861b8f
# Creates the variables for setting up GFM auto-completion
# Creates the variables for setting up GFM auto-completion
window
.
GitLab
?=
{}
window
.
GitLab
?=
{}
GitLab
.
GfmAutoComplete
?=
{}
GitLab
.
GfmAutoComplete
=
# Emoji
data
=
[]
template
=
"<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>"
GitLab
.
GfmAutoComplete
.
Emoji
=
{
data
,
template
}
# Team Members
data
=
[]
url
=
''
;
params
=
{
private_token
:
''
,
page
:
1
}
GitLab
.
GfmAutoComplete
.
Members
=
{
data
,
url
,
params
}
# Add GFM auto-completion to all input fields, that accept GFM input.
GitLab
.
GfmAutoComplete
.
setup
=
->
input
=
$
(
'.js-gfm-input'
)
# Emoji
# Emoji
input
.
atWho
':'
,
Emoji
:
data
:
GitLab
.
GfmAutoComplete
.
Emoji
.
data
,
data
:
[]
t
pl
:
GitLab
.
GfmAutoComplete
.
Emoji
.
template
t
emplate
:
'<li data-value="${insert}">${name} <img alt="${name}" height="20" src="${image}" width="20" /></li>'
# Team Members
# Team Members
input
.
atWho
'@'
,
(
query
,
callback
)
->
Members
:
(
getMoreMembers
=
->
data
:
[]
$
.
getJSON
(
GitLab
.
GfmAutoComplete
.
Members
.
url
,
GitLab
.
GfmAutoComplete
.
Members
.
params
)
url
:
''
.
success
(
members
)
->
params
:
# pick the data we need
private_token
:
''
newMembersData
=
$
.
map
(
members
,
(
m
)
->
m
.
name
)
page
:
1
template
:
'<li data-value="${username}">${username} <small>${name}</small></li>'
# add the new page of data to the rest
$
.
merge
(
GitLab
.
GfmAutoComplete
.
Members
.
data
,
newMembersData
)
# Add GFM auto-completion to all input fields, that accept GFM input.
setup
:
->
# show the pop-up with a copy of the current data
input
=
$
(
'.js-gfm-input'
)
callback
(
GitLab
.
GfmAutoComplete
.
Members
.
data
[..])
# Emoji
# are we past the last page?
input
.
atWho
':'
,
if
newMembersData
.
length
is
0
data
:
@
Emoji
.
data
# set static data and stop callbacks
tpl
:
@
Emoji
.
template
input
.
atWho
'@'
,
data
:
GitLab
.
GfmAutoComplete
.
Members
.
data
# Team Members
callback
:
null
input
.
atWho
'@'
,
else
tpl
:
@
Members
.
template
# get next page
callback
:
(
query
,
callback
)
=>
getMoreMembers
()
(
getMoreMembers
=
=>
$
.
getJSON
(
@
Members
.
url
,
@
Members
.
params
).
done
(
members
)
=>
# so the next request gets the next page
# pick the data we need
GitLab
.
GfmAutoComplete
.
Members
.
params
.
page
+=
1
newMembersData
=
$
.
map
(
members
,
(
m
)
->
).
call
()
username
:
m
.
username
name
:
m
.
name
)
# add the new page of data to the rest
$
.
merge
(
@
Members
.
data
,
newMembersData
)
# show the pop-up with a copy of the current data
callback
(
@
Members
.
data
[..])
# are we past the last page?
if
newMembersData
.
length
is
0
# set static data and stop callbacks
input
.
atWho
'@'
,
data
:
@
Members
.
data
callback
:
null
else
# get next page
getMoreMembers
()
# so the next callback requests the next page
@
Members
.
params
.
page
+=
1
).
call
()
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