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
Léo-Paul Géneau
gitlab-ce
Commits
1cda6246
Commit
1cda6246
authored
Nov 21, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GFM JS code style
parent
00464099
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
31 deletions
+35
-31
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+31
-27
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 @
1cda6246
# Creates the variables for setting up GFM auto-completion
# Creates the variables for setting up GFM auto-completion
window
.
GitLab
?=
{}
window
.
GitLab
.
AutoComplete
?=
{}
# Emoji
# Emoji
data
=
[]
data
=
[]
template
=
"<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
.
autocomplete
Emoji
=
{
data
,
template
}
window
.
GitLab
.
AutoComplete
.
Emoji
=
{
data
,
template
}
# Team Members
# Team Members
url
=
''
;
url
=
''
;
params
=
{
private_token
:
''
,
page
:
1
}
params
=
{
private_token
:
''
,
page
:
1
}
window
.
autocomplete
Members
=
{
data
,
url
,
params
}
window
.
GitLab
.
AutoComplete
.
Members
=
{
data
,
url
,
params
}
# Add GFM auto-completion to all input fields, that accept GFM input.
# Add GFM auto-completion to all input fields, that accept GFM input.
window
.
setupGfmAutoComplete
=
->
window
.
setupGfmAutoComplete
=
->
$
input
=
$
(
'.js-gfm-input'
)
input
=
$
(
'.js-gfm-input'
)
# Emoji
# Emoji
$
input
.
atWho
':'
,
input
.
atWho
':'
,
data
:
autocomplete
Emoji
.
data
,
data
:
GitLab
.
AutoComplete
.
Emoji
.
data
,
tpl
:
autocomplete
Emoji
.
template
tpl
:
GitLab
.
AutoComplete
.
Emoji
.
template
# Team Members
# Team Members
$
input
.
atWho
'@'
,
(
query
,
callback
)
->
input
.
atWho
'@'
,
(
query
,
callback
)
->
(
getMoreMembers
=
->
(
getMoreMembers
=
->
$
.
getJSON
(
autocompleteMembers
.
url
,
autocompleteMembers
.
params
).
success
(
members
)
->
$
.
getJSON
(
GitLab
.
AutoComplete
.
Members
.
url
,
GitLab
.
AutoComplete
.
Members
.
params
)
.
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
autocompleteMembers
.
data
,
newMembersData
$
.
merge
(
GitLab
.
AutoComplete
.
Members
.
data
,
newMembersData
)
# show the pop-up with a copy of the current data
# show the pop-up with a copy of the current data
callback
autocompleteMembers
.
data
[..]
callback
(
GitLab
.
AutoComplete
.
Members
.
data
[..])
# are we past the last page?
# are we past the last page?
if
newMembersData
.
length
is
0
if
newMembersData
.
length
is
0
# set static data and stop callbacks
# set static data and stop callbacks
$
input
.
atWho
'@'
,
input
.
atWho
'@'
,
data
:
autocomplete
Members
.
data
data
:
GitLab
.
AutoComplete
.
Members
.
data
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
autocomplete
Members
.
params
.
page
+=
1
GitLab
.
AutoComplete
.
Members
.
params
.
page
+=
1
).
call
()
).
call
()
app/views/layouts/_init_auto_complete.html.haml
View file @
1cda6246
:javascript
:javascript
$
(
function
()
{
$
(
function
()
{
autocomplete
Members
.
url
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
GitLab
.
AutoComplete
.
Members
.
url
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
autocomplete
Members
.
params
.
private_token
=
"
#{
current_user
.
private_token
}
"
;
GitLab
.
AutoComplete
.
Members
.
params
.
private_token
=
"
#{
current_user
.
private_token
}
"
;
autocomplete
Emoji
.
data
=
#{
raw
emoji_autocomplete_source
}
;
GitLab
.
AutoComplete
.
Emoji
.
data
=
#{
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
(
autocomplete
Emoji
.
data
,
function
(
value
)
{
GitLab
.
AutoComplete
.
Emoji
.
data
=
$
.
map
(
GitLab
.
AutoComplete
.
Emoji
.
data
,
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