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
57c134c3
Commit
57c134c3
authored
Oct 16, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup coffeescript code for mentions auto-complete
parent
ec1bccb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
51 deletions
+41
-51
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+37
-47
app/views/layouts/_init_auto_complete.html.haml
app/views/layouts/_init_auto_complete.html.haml
+4
-4
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
View file @
57c134c3
# Creates the variables for setting up GFM auto-completion
###
Creates the variables for setting up GFM auto-completion
###
# Emoji
# Emoji
window
.
autocompleteEmojiData
=
[];
data
=
[]
window
.
autocompleteEmojiTemplate
=
"<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>"
;
template
=
"<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>"
window
.
autocompleteEmoji
=
{
data
,
template
}
# Team Members
# Team Members
window
.
autocompleteMembersUrl
=
""
;
url
=
''
;
window
.
autocompleteMembersParams
=
params
=
{
private_token
:
''
,
page
:
1
}
private_token
:
""
window
.
autocompleteMembers
=
{
data
,
url
,
params
}
page
:
1
window
.
autocompleteMembersData
=
[];
# Add GFM auto-completion to all input fields, that accept GFM input.
window
.
setupGfmAutoComplete
=
->
$input
=
$
(
'.js-gfm-input'
)
# Emoji
$input
.
atWho
':'
,
data
:
autocompleteEmoji
.
data
,
tpl
:
autocompleteEmoji
.
template
###
# Team Members
Add GFM auto-completion to all input fields, that accept GFM input.
$input
.
atWho
'@'
,
(
query
,
callback
)
->
###
window
.
setupGfmAutoComplete
=
->
###
Emoji
###
$
(
'.js-gfm-input'
).
atWho
':'
,
data
:
autocompleteEmojiData
,
tpl
:
autocompleteEmojiTemplate
###
Team Members
###
$
(
'.js-gfm-input'
).
atWho
'@'
,
(
query
,
callback
)
->
(
getMoreMembers
=
->
(
getMoreMembers
=
->
$
.
getJSON
(
autocompleteMembersUrl
,
autocompleteMembersParams
)
$
.
getJSON
(
autocompleteMembers
.
url
,
autocompleteMembers
.
params
).
success
(
members
)
->
.
success
(
members
)
->
# pick the data we need
# pick the data we need
newMembersData
=
$
.
map
members
,
(
m
)
->
m
.
name
newMembersData
=
$
.
map
members
,
(
m
)
->
m
.
name
# add the new page of data to the rest
# add the new page of data to the rest
$
.
merge
autocompleteMembersD
ata
,
newMembersData
$
.
merge
autocompleteMembers
.
d
ata
,
newMembersData
# show the pop-up with a copy of the current data
# show the pop-up with a copy of the current data
callback
autocompleteMembersD
ata
[..]
callback
autocompleteMembers
.
d
ata
[..]
# are we past the last page?
# are we past the last page?
if
newMembersData
.
length
==
0
if
newMembersData
.
length
is
0
# set static data and stop callbacks
# set static data and stop callbacks
$
(
'.js-gfm-input'
)
.
atWho
'@'
,
$input
.
atWho
'@'
,
data
:
autocompleteMembersD
ata
data
:
autocompleteMembers
.
d
ata
callback
:
null
callback
:
null
else
else
# get next page
# get next page
getMoreMembers
()
getMoreMembers
()
# so the next request gets the next page
# so the next request gets the next page
autocompleteMembers
Params
.
page
+=
1
;
autocompleteMembers
.
params
.
page
+=
1
).
call
()
;
).
call
()
app/views/layouts/_init_auto_complete.html.haml
View file @
57c134c3
:javascript
:javascript
$
(
function
()
{
$
(
function
()
{
autocompleteMembers
U
rl
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
autocompleteMembers
.
u
rl
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
autocompleteMembers
Params
.
private_token
=
"
#{
current_user
.
authentication
_token
}
"
;
autocompleteMembers
.
params
.
private_token
=
"
#{
current_user
.
private
_token
}
"
;
autocompleteEmoji
D
ata
=
#{
raw
emoji_autocomplete_source
}
;
autocompleteEmoji
.
d
ata
=
#{
raw
emoji_autocomplete_source
}
;
// convert the list so that the items have the right format for completion
// convert the list so that the items have the right format for completion
autocompleteEmoji
Data
=
$
.
map
(
autocompleteEmojiD
ata
,
function
(
value
)
{
autocompleteEmoji
.
data
=
$
.
map
(
autocompleteEmoji
.
d
ata
,
function
(
value
)
{
return
{
return
{
name
:
value
,
name
:
value
,
insert
:
value
+
'
:
'
,
insert
:
value
+
'
:
'
,
...
...
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