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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
60b4c88e
Commit
60b4c88e
authored
Oct 10, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1664 from riyad/auto-complete-everywhere
Cleanup auto-completion and add it to all GFM inputs
parents
a100c578
4d843d2c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
89 additions
and
66 deletions
+89
-66
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+57
-0
app/assets/javascripts/issues.js
app/assets/javascripts/issues.js
+2
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+6
-0
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+0
-6
app/views/issues/_form.html.haml
app/views/issues/_form.html.haml
+2
-2
app/views/layouts/_head_panel.html.haml
app/views/layouts/_head_panel.html.haml
+2
-0
app/views/layouts/_init_auto_complete.html.haml
app/views/layouts/_init_auto_complete.html.haml
+17
-0
app/views/merge_requests/_form.html.haml
app/views/merge_requests/_form.html.haml
+1
-1
app/views/notes/_common_form.html.haml
app/views/notes/_common_form.html.haml
+0
-46
app/views/notes/_create_common_note.js.haml
app/views/notes/_create_common_note.js.haml
+1
-0
app/views/wikis/_form.html.haml
app/views/wikis/_form.html.haml
+1
-1
spec/helpers/notes_helper_spec.rb
spec/helpers/notes_helper_spec.rb
+0
-10
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
0 → 100644
View file @
60b4c88e
###
Creates the variables for setting up GFM auto-completion
###
# Emoji
window
.
autocompleteEmojiData
=
[];
window
.
autocompleteEmojiTemplate
=
"<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>"
;
# Team Members
window
.
autocompleteMembersUrl
=
""
;
window
.
autocompleteMembersParams
=
private_token
:
""
page
:
1
window
.
autocompleteMembersData
=
[];
###
Add GFM auto-completion to all input fields, that accept GFM input.
###
window
.
setupGfmAutoComplete
=
->
###
Emoji
###
$
(
'.gfm-input'
).
atWho
':'
,
data
:
autocompleteEmojiData
,
tpl
:
autocompleteEmojiTemplate
###
Team Members
###
$
(
'.gfm-input'
).
atWho
'@'
,
(
query
,
callback
)
->
(
getMoreMembers
=
->
$
.
getJSON
(
autocompleteMembersUrl
,
autocompleteMembersParams
)
.
success
(
members
)
->
# pick the data we need
newMembersData
=
$
.
map
members
,
(
m
)
->
m
.
name
# add the new page of data to the rest
$
.
merge
autocompleteMembersData
,
newMembersData
# show the pop-up with a copy of the current data
callback
autocompleteMembersData
[..]
# are we past the last page?
if
newMembersData
.
length
==
0
# set static data and stop callbacks
$
(
'.gfm-input'
).
atWho
'@'
,
data
:
autocompleteMembersData
callback
:
null
else
# get next page
getMoreMembers
()
# so the next request gets the next page
autocompleteMembersParams
.
page
+=
1
;
).
call
();
\ No newline at end of file
app/assets/javascripts/issues.js
View file @
60b4c88e
...
...
@@ -6,6 +6,7 @@ function switchToNewIssue(form){
$
(
"
#new_issue_dialog
"
).
show
(
"
fade
"
,
{
direction
:
"
right
"
},
150
);
$
(
'
.top-tabs .add_new
'
).
hide
();
disableButtonIfEmptyField
(
"
#issue_title
"
,
"
.save-btn
"
);
setupGfmAutoComplete
();
});
}
...
...
@@ -17,6 +18,7 @@ function switchToEditIssue(form){
$
(
"
#edit_issue_dialog
"
).
show
(
"
fade
"
,
{
direction
:
"
right
"
},
150
);
$
(
'
.add_new
'
).
hide
();
disableButtonIfEmptyField
(
"
#issue_title
"
,
"
.save-btn
"
);
setupGfmAutoComplete
();
});
}
...
...
app/helpers/application_helper.rb
View file @
60b4c88e
...
...
@@ -98,6 +98,12 @@ module ApplicationHelper
[
projects
,
default_nav
,
project_nav
].
flatten
.
to_json
end
def
emoji_autocomplete_source
# should be an array of strings
# so to_s can be called, because it is sufficient and to_json is too slow
Emoji
::
NAMES
.
to_s
end
def
ldap_enable?
Devise
.
omniauth_providers
.
include?
(
:ldap
)
end
...
...
app/helpers/notes_helper.rb
View file @
60b4c88e
...
...
@@ -14,10 +14,4 @@ module NotesHelper
"vote downvote"
end
end
def
emoji_for_completion
# should be an array of strings
# so to_s can be called, because it is sufficient and to_json is too slow
Emoji
::
NAMES
end
end
app/views/issues/_form.html.haml
View file @
60b4c88e
...
...
@@ -12,7 +12,7 @@
=
f
.
label
:title
do
%strong
=
"Subject *"
.input
=
f
.
text_field
:title
,
maxlength:
255
,
class:
"xxlarge"
=
f
.
text_field
:title
,
maxlength:
255
,
class:
"xxlarge
gfm-input
"
.issue_middle_block
.issue_assignee
=
f
.
label
:assignee_id
do
...
...
@@ -37,7 +37,7 @@
.clearfix
=
f
.
label
:description
,
"Details"
.input
=
f
.
text_area
:description
,
maxlength:
2000
,
class:
"xxlarge"
,
rows:
14
=
f
.
text_area
:description
,
maxlength:
2000
,
class:
"xxlarge
gfm-input
"
,
rows:
14
%p
.hint
Issues are parsed with
#{
link_to
"GitLab Flavored Markdown"
,
help_markdown_path
,
target:
'_blank'
}
.
...
...
app/views/layouts/_head_panel.html.haml
View file @
60b4c88e
...
...
@@ -28,6 +28,8 @@
My profile
=
link_to
'Logout'
,
destroy_user_session_path
,
class:
"logout"
,
method: :delete
=
render
"layouts/init_auto_complete"
:javascript
$
(
function
(){
$
(
"
#search
"
).
autocomplete
({
...
...
app/views/layouts/_init_auto_complete.html.haml
0 → 100644
View file @
60b4c88e
:javascript
$
(
function
()
{
autocompleteMembersUrl
=
"
#{
"/api/v2/projects/#{@project.code}/members"
if
@project
}
"
;
autocompleteMembersParams
.
private_token
=
"
#{
current_user
.
authentication_token
}
"
;
autocompleteEmojiData
=
#{
raw
emoji_autocomplete_source
}
;
// convert the list so that the items have the right format for completion
autocompleteEmojiData
=
$
.
map
(
autocompleteEmojiData
,
function
(
value
)
{
return
{
name
:
value
,
insert
:
value
+
'
:
'
,
image
:
'
#{
image_path
(
"emoji"
)
}
/
'
+
value
+
'
.png
'
}
});
setupGfmAutoComplete
();
});
app/views/merge_requests/_form.html.haml
View file @
60b4c88e
...
...
@@ -38,7 +38,7 @@
.top_box_content
=
f
.
label
:title
do
%strong
=
"Title *"
.input
=
f
.
text_field
:title
,
class:
"input-xxlarge pad"
,
maxlength:
255
,
rows:
5
.input
=
f
.
text_field
:title
,
class:
"input-xxlarge pad
gfm-input
"
,
maxlength:
255
,
rows:
5
.middle_box_content
=
f
.
label
:assignee_id
do
%i
.icon-user
...
...
app/views/notes/_common_form.html.haml
View file @
60b4c88e
...
...
@@ -36,49 +36,3 @@
%a
.file_upload.btn.small
Upload File
=
f
.
file_field
:attachment
,
class:
"input-file"
%span
.hint
Any file less than 10 MB
:javascript
$
(
function
(){
// init auto-completion of team members
var
membersUrl
=
"
#{
root_url
}
/api/v2/projects/
#{
@project
.
code
}
/members
"
;
var
membersParams
=
{
private_token
:
"
#{
current_user
.
authentication_token
}
"
,
page
:
1
,
};
var
membersData
=
[];
$
(
'
.gfm-input
'
).
atWho
(
'
@
'
,
function
(
query
,
callback
)
{
(
function
getMoreMembers
()
{
$
.
getJSON
(
membersUrl
,
membersParams
).
success
(
function
(
members
)
{
// pick the data we need
var
newMembersData
=
$
.
map
(
members
,
function
(
member
)
{
return
member
.
name
});
// add the new page of data to the rest
$
.
merge
(
membersData
,
newMembersData
);
// show the pop-up with a copy of the current data
callback
(
membersData
.
slice
(
0
));
// are we past the last page?
if
(
newMembersData
.
length
==
0
)
{
// set static data and stop callbacks
$
(
'
.gfm-input
'
).
atWho
(
'
@
'
,
{
data
:
membersData
,
callback
:
null
});
}
else
{
// get next page
getMoreMembers
();
}
});
// next request will get the next page
membersParams
.
page
+=
1
;
})();
});
// init auto-completion of emoji
var
emoji
=
#{
emoji_for_completion
}
;
// convert the list so that the items have the right format for completion
emoji
=
$
.
map
(
emoji
,
function
(
value
)
{
return
{
key
:
value
+
'
:
'
,
name
:
value
}});
$
(
'
.gfm-input
'
).
atWho
(
'
:
'
,
{
data
:
emoji
,
tpl
:
"
<li data-value='${key}'>${name}
#{
escape_javascript
image_tag
(
'
emoji
/
$
{
name
}.
png
', :size => '
20
x20
'
)
}
</li>
"
});
});
app/views/notes/_create_common_note.js.haml
View file @
60b4c88e
...
...
@@ -10,4 +10,5 @@
-
else
:plain
$(".note-form-holder").replaceWith("
#{
escape_javascript
(
render
'form'
)
}
");
setupGfmAutoComplete();
app/views/wikis/_form.html.haml
View file @
60b4c88e
...
...
@@ -21,7 +21,7 @@
.bottom_box_content
=
f
.
label
:content
.input
=
f
.
text_area
:content
,
class:
'span8'
.input
=
f
.
text_area
:content
,
class:
'span8
gfm-input
'
.actions
=
f
.
submit
'Save'
,
class:
"save-btn btn"
=
link_to
"Cancel"
,
project_wiki_path
(
@project
,
:index
),
class:
"btn cancel-btn"
spec/helpers/notes_helper_spec.rb
deleted
100644 → 0
View file @
a100c578
require
'spec_helper'
describe
NotesHelper
do
describe
"#emoji_for_completion"
do
it
"should be an Array of Strings"
do
emoji_for_completion
.
should
be_a
(
Array
)
emoji_for_completion
.
each
{
|
emoji
|
emoji
.
should
be_a
(
String
)
}
end
end
end
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