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
Jérome Perrin
gitlab-ce
Commits
3e800c3b
Commit
3e800c3b
authored
Nov 21, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor GFM JS naming and access
parent
1cda6246
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
19 deletions
+20
-19
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+12
-11
app/assets/javascripts/issues.js
app/assets/javascripts/issues.js
+2
-2
app/views/layouts/_init_auto_complete.html.haml
app/views/layouts/_init_auto_complete.html.haml
+5
-5
app/views/notes/_create_common_note.js.haml
app/views/notes/_create_common_note.js.haml
+1
-1
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
View file @
3e800c3b
# Creates the variables for setting up GFM auto-completion
window
.
GitLab
?=
{}
window
.
GitLab
.
AutoComplete
?=
{}
GitLab
.
Gfm
AutoComplete
?=
{}
# Emoji
data
=
[]
template
=
"<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>"
window
.
GitLab
.
AutoComplete
.
Emoji
=
{
data
,
template
}
GitLab
.
Gfm
AutoComplete
.
Emoji
=
{
data
,
template
}
# Team Members
data
=
[]
url
=
''
;
params
=
{
private_token
:
''
,
page
:
1
}
window
.
GitLab
.
AutoComplete
.
Members
=
{
data
,
url
,
params
}
GitLab
.
Gfm
AutoComplete
.
Members
=
{
data
,
url
,
params
}
# Add GFM auto-completion to all input fields, that accept GFM input.
window
.
setupGfmAutoComplete
=
->
GitLab
.
GfmAutoComplete
.
setup
=
->
input
=
$
(
'.js-gfm-input'
)
# Emoji
input
.
atWho
':'
,
data
:
GitLab
.
AutoComplete
.
Emoji
.
data
,
tpl
:
GitLab
.
AutoComplete
.
Emoji
.
template
data
:
GitLab
.
Gfm
AutoComplete
.
Emoji
.
data
,
tpl
:
GitLab
.
Gfm
AutoComplete
.
Emoji
.
template
# Team Members
input
.
atWho
'@'
,
(
query
,
callback
)
->
(
getMoreMembers
=
->
$
.
getJSON
(
GitLab
.
AutoComplete
.
Members
.
url
,
GitLab
.
AutoComplete
.
Members
.
params
)
$
.
getJSON
(
GitLab
.
GfmAutoComplete
.
Members
.
url
,
GitLab
.
Gfm
AutoComplete
.
Members
.
params
)
.
success
(
members
)
->
# pick the data we need
newMembersData
=
$
.
map
(
members
,
(
m
)
->
m
.
name
)
# add the new page of data to the rest
$
.
merge
(
GitLab
.
AutoComplete
.
Members
.
data
,
newMembersData
)
$
.
merge
(
GitLab
.
Gfm
AutoComplete
.
Members
.
data
,
newMembersData
)
# show the pop-up with a copy of the current data
callback
(
GitLab
.
AutoComplete
.
Members
.
data
[..])
callback
(
GitLab
.
Gfm
AutoComplete
.
Members
.
data
[..])
# are we past the last page?
if
newMembersData
.
length
is
0
# set static data and stop callbacks
input
.
atWho
'@'
,
data
:
GitLab
.
AutoComplete
.
Members
.
data
data
:
GitLab
.
Gfm
AutoComplete
.
Members
.
data
callback
:
null
else
# get next page
getMoreMembers
()
# so the next request gets the next page
GitLab
.
AutoComplete
.
Members
.
params
.
page
+=
1
GitLab
.
Gfm
AutoComplete
.
Members
.
params
.
page
+=
1
).
call
()
app/assets/javascripts/issues.js
View file @
3e800c3b
...
...
@@ -5,7 +5,7 @@ function switchToNewIssue(){
$
(
"
#new_issue_dialog
"
).
show
(
"
fade
"
,
{
direction
:
"
right
"
},
150
);
$
(
'
.top-tabs .add_new
'
).
hide
();
disableButtonIfEmptyField
(
"
#issue_title
"
,
"
.save-btn
"
);
setupGfmAutoComplete
();
GitLab
.
GfmAutoComplete
.
setup
();
});
}
...
...
@@ -16,7 +16,7 @@ function switchToEditIssue(){
$
(
"
#edit_issue_dialog
"
).
show
(
"
fade
"
,
{
direction
:
"
right
"
},
150
);
$
(
'
.add_new
'
).
hide
();
disableButtonIfEmptyField
(
"
#issue_title
"
,
"
.save-btn
"
);
setupGfmAutoComplete
();
GitLab
.
GfmAutoComplete
.
setup
();
});
}
...
...
app/views/layouts/_init_auto_complete.html.haml
View file @
3e800c3b
:javascript
$
(
function
()
{
GitLab
.
AutoComplete
.
Members
.
url
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
GitLab
.
AutoComplete
.
Members
.
params
.
private_token
=
"
#{
current_user
.
private_token
}
"
;
GitLab
.
Gfm
AutoComplete
.
Members
.
url
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
GitLab
.
Gfm
AutoComplete
.
Members
.
params
.
private_token
=
"
#{
current_user
.
private_token
}
"
;
GitLab
.
AutoComplete
.
Emoji
.
data
=
#{
raw
emoji_autocomplete_source
}
;
GitLab
.
Gfm
AutoComplete
.
Emoji
.
data
=
#{
raw
emoji_autocomplete_source
}
;
// convert the list so that the items have the right format for completion
GitLab
.
AutoComplete
.
Emoji
.
data
=
$
.
map
(
GitLab
.
AutoComplete
.
Emoji
.
data
,
function
(
value
)
{
GitLab
.
GfmAutoComplete
.
Emoji
.
data
=
$
.
map
(
GitLab
.
Gfm
AutoComplete
.
Emoji
.
data
,
function
(
value
)
{
return
{
name
:
value
,
insert
:
value
+
'
:
'
,
...
...
@@ -13,5 +13,5 @@
}
});
setupGfmAutoComplete
();
GitLab
.
GfmAutoComplete
.
setup
();
});
app/views/notes/_create_common_note.js.haml
View file @
3e800c3b
...
...
@@ -10,5 +10,5 @@
-
else
:plain
$(".note-form-holder").replaceWith("
#{
escape_javascript
(
render
'form'
)
}
");
setupGfmAutoComplete();
GitLab.GfmAutoComplete.setup();
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