Skip to content

Commit 3c5a3fe

Browse files
committed
Merge branch 'front-end' of https://github.com/NARKOZ/gitlabhq into NARKOZ-front-end
Conflicts: app/views/issues/_form.html.haml
2 parents 2e0e63e + 414080c commit 3c5a3fe

14 files changed

+75
-99
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,47 @@
1+
# Creates the variables for setting up GFM auto-completion
12

2-
###
3-
Creates the variables for setting up GFM auto-completion
4-
###
53
# Emoji
6-
window.autocompleteEmojiData = [];
7-
window.autocompleteEmojiTemplate = "<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>";
4+
data = []
5+
template = "<li data-value='${insert}'>${name} <img alt='${name}' height='20' src='${image}' width='20' /></li>"
6+
window.autocompleteEmoji = {data, template}
87

98
# Team Members
10-
window.autocompleteMembersUrl = "";
11-
window.autocompleteMembersParams =
12-
private_token: ""
13-
page: 1
14-
window.autocompleteMembersData = [];
9+
url = '';
10+
params = {private_token: '', page: 1}
11+
window.autocompleteMembers = {data, url, params}
1512

13+
# Add GFM auto-completion to all input fields, that accept GFM input.
14+
window.setupGfmAutoComplete = ->
15+
$input = $('.js-gfm-input')
1616

17+
# Emoji
18+
$input.atWho ':',
19+
data: autocompleteEmoji.data,
20+
tpl: autocompleteEmoji.template
1721

18-
###
19-
Add GFM auto-completion to all input fields, that accept GFM input.
20-
###
21-
window.setupGfmAutoComplete = ->
22-
###
23-
Emoji
24-
###
25-
$('.gfm-input').atWho ':',
26-
data: autocompleteEmojiData,
27-
tpl: autocompleteEmojiTemplate
28-
29-
###
30-
Team Members
31-
###
32-
$('.gfm-input').atWho '@', (query, callback) ->
22+
# Team Members
23+
$input.atWho '@', (query, callback) ->
3324
(getMoreMembers = ->
34-
$.getJSON(autocompleteMembersUrl, autocompleteMembersParams)
35-
.success (members) ->
36-
# pick the data we need
37-
newMembersData = $.map members, (m) -> m.name
38-
39-
# add the new page of data to the rest
40-
$.merge autocompleteMembersData, newMembersData
41-
42-
# show the pop-up with a copy of the current data
43-
callback autocompleteMembersData[..]
44-
45-
# are we past the last page?
46-
if newMembersData.length == 0
47-
# set static data and stop callbacks
48-
$('.gfm-input').atWho '@',
49-
data: autocompleteMembersData
50-
callback: null
51-
else
52-
# get next page
53-
getMoreMembers()
25+
$.getJSON(autocompleteMembers.url, autocompleteMembers.params).success (members) ->
26+
# pick the data we need
27+
newMembersData = $.map members, (m) -> m.name
28+
29+
# add the new page of data to the rest
30+
$.merge autocompleteMembers.data, newMembersData
31+
32+
# show the pop-up with a copy of the current data
33+
callback autocompleteMembers.data[..]
34+
35+
# are we past the last page?
36+
if newMembersData.length is 0
37+
# set static data and stop callbacks
38+
$input.atWho '@',
39+
data: autocompleteMembers.data
40+
callback: null
41+
else
42+
# get next page
43+
getMoreMembers()
5444

5545
# so the next request gets the next page
56-
autocompleteMembersParams.page += 1;
57-
).call();
46+
autocompleteMembers.params.page += 1
47+
).call()

app/assets/javascripts/graph.js.coffee

-10
This file was deleted.

app/assets/javascripts/loader.js.coffee

-5
This file was deleted.

app/assets/javascripts/main.js.coffee

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ window.slugify = (text) ->
77
window.ajaxGet = (url) ->
88
$.ajax({type: "GET", url: url, dataType: "script"})
99

10-
# Disable button if text field is empty
10+
# Disable button if text field is empty
1111
window.disableButtonIfEmptyField = (field_selector, button_selector) ->
1212
field = $(field_selector)
1313
closest_submit = field.closest("form").find(button_selector)
1414

1515
closest_submit.disable() if field.val() is ""
1616

1717
field.on "keyup", ->
18-
if $(this).val() is ""
18+
if $(@).val() is ""
1919
closest_submit.disable()
2020
else
2121
closest_submit.enable()
2222

2323
$ ->
2424
# Click a .one_click_select field, select the contents
25-
$(".one_click_select").live 'click', -> $(this).select()
25+
$(".one_click_select").on 'click', -> $(@).select()
2626

2727
# Initialize chosen selects
2828
$('select.chosen').chosen()
2929

3030
# Disable form buttons while a form is submitting
3131
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->
32-
buttons = $('[type="submit"]', this)
32+
buttons = $('[type="submit"]', @)
3333

3434
switch e.type
3535
when 'ajax:beforeSend', 'submit'
@@ -38,7 +38,7 @@ $ ->
3838
buttons.enable()
3939

4040
# Show/Hide the profile menu when hovering the account box
41-
$('.account-box').hover -> $(this).toggleClass('hover')
41+
$('.account-box').hover -> $(@).toggleClass('hover')
4242

4343
# Focus search field by pressing 's' key
4444
$(document).keypress (e) ->
@@ -52,22 +52,22 @@ $ ->
5252

5353
# Commit show suppressed diff
5454
$(".supp_diff_link").bind "click", ->
55-
$(this).next('table').show()
56-
$(this).remove()
55+
$(@).next('table').show()
56+
$(@).remove()
5757

5858
# Note markdown preview
5959
$(document).on 'click', '#preview-link', (e) ->
60-
$('#preview-note').text('Loading...')
60+
$('#preview-note').text 'Loading...'
6161

62-
previewLinkText = if $(this).text() == 'Preview' then 'Edit' else 'Preview'
63-
$(this).text(previewLinkText)
62+
previewLinkText = if $(@).text() is 'Preview' then 'Edit' else 'Preview'
63+
$(@).text previewLinkText
6464

6565
note = $('#note_note').val()
6666

67-
if note.trim().length == 0
68-
$('#preview-note').text("Nothing to preview.")
67+
if note.trim().length is 0
68+
$('#preview-note').text 'Nothing to preview.'
6969
else
70-
$.post $(this).attr('href'), {note: note}, (data) ->
70+
$.post $(@).attr('href'), {note: note}, (data) ->
7171
$('#preview-note').html(data)
7272

7373
$('#preview-note, #note_note').toggle()
@@ -79,14 +79,14 @@ $ ->
7979
$.fn.extend chosen: (options) ->
8080
default_options = search_contains: "true"
8181
$.extend default_options, options
82-
_chosen.apply this, [default_options]
82+
_chosen.apply @, [default_options]
8383

8484
# Disable an element and add the 'disabled' Bootstrap class
8585
$.fn.extend disable: ->
86-
$(this).attr('disabled', 'disabled').addClass('disabled')
86+
$(@).attr('disabled', 'disabled').addClass('disabled')
8787

8888
# Enable an element and remove the 'disabled' Bootstrap class
8989
$.fn.extend enable: ->
90-
$(this).removeAttr('disabled').removeClass('disabled')
90+
$(@).removeAttr('disabled').removeClass('disabled')
9191

9292
)(jQuery)

app/assets/javascripts/projects.js.coffee

+7
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ $ ->
2222
# Ref switcher
2323
$('.project-refs-select').on 'change', ->
2424
$(@).parents('form').submit()
25+
26+
class @GraphNav
27+
@init: ->
28+
$('.graph svg').css 'position', 'relative'
29+
$('body').bind 'keyup', (e) ->
30+
$('.graph svg').animate(left: '+=400') if e.keyCode is 37 # left
31+
$('.graph svg').animate(left: '-=400') if e.keyCode is 39 # right

app/assets/javascripts/snippets.js.coffee

-6
This file was deleted.

app/views/issues/_form.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
= f.label :title do
1313
%strong= "Subject *"
1414
.input
15-
= f.text_field :title, maxlength: 255, class: "xxlarge gfm-input", autofocus: true
15+
= f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true
1616
.issue_middle_block
1717
.issue_assignee
1818
= f.label :assignee_id do
@@ -37,7 +37,7 @@
3737
.clearfix
3838
= f.label :description, "Details"
3939
.input
40-
= f.text_area :description, maxlength: 2000, class: "xxlarge gfm-input", rows: 14
40+
= f.text_area :description, maxlength: 2000, class: "xxlarge js-gfm-input", rows: 14
4141
%p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
4242

4343

app/views/layouts/_init_auto_complete.html.haml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
:javascript
22
$(function() {
3-
autocompleteMembersUrl = "#{ "/api/v2/projects/#{@project.code}/members" if @project }";
4-
autocompleteMembersParams.private_token = "#{current_user.authentication_token}";
3+
autocompleteMembers.url = "#{ "/api/v2/projects/#{@project.code}/members" if @project }";
4+
autocompleteMembers.params.private_token = "#{current_user.private_token}";
55

6-
autocompleteEmojiData = #{raw emoji_autocomplete_source};
6+
autocompleteEmoji.data = #{raw emoji_autocomplete_source};
77
// convert the list so that the items have the right format for completion
8-
autocompleteEmojiData = $.map(autocompleteEmojiData, function(value) {
8+
autocompleteEmoji.data = $.map(autocompleteEmoji.data, function(value) {
99
return {
1010
name: value,
1111
insert: value+':',

app/views/merge_requests/_form.html.haml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
.clearfix
3131
.main_box
3232
.top_box_content
33-
= f.label :title do
33+
= f.label :title do
3434
%strong= "Title *"
35-
.input= f.text_field :title, class: "input-xxlarge pad gfm-input", maxlength: 255, rows: 5
35+
.input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5
3636
.middle_box_content
37-
= f.label :assignee_id do
38-
%i.icon-user
37+
= f.label :assignee_id do
38+
%i.icon-user
3939
Assign to
4040
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
4141

app/views/notes/_common_form.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
= f.hidden_field :noteable_id
1010
= f.hidden_field :noteable_type
11-
= f.text_area :note, size: 255, class: 'note-text gfm-input'
11+
= f.text_area :note, size: 255, class: 'note-text js-gfm-input'
1212
#preview-note.preview_note.hide
1313
.hint
1414
.right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.

app/views/notes/_per_line_form.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
= f.hidden_field :noteable_id
1414
= f.hidden_field :noteable_type
1515
= f.hidden_field :line_code
16-
= f.text_area :note, size: 255, class: 'line-note-text gfm-input'
16+
= f.text_area :note, size: 255, class: 'line-note-text js-gfm-input'
1717
.note_actions
1818
.buttons
1919
= f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note"

app/views/projects/graph.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
initGraph();
1111
$(function(){
1212
branchGraph($("#holder")[0]);
13-
initGraphNav();
13+
GraphNav.init();
1414
});

app/views/wikis/_form.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
.bottom_box_content
2323
= f.label :content
24-
.input= f.text_area :content, class: 'span8 gfm-input'
24+
.input= f.text_area :content, class: 'span8 js-gfm-input'
2525
.actions
2626
= f.submit 'Save', class: "save-btn btn"
2727
= link_to "Cancel", project_wiki_path(@project, :index), class: "btn cancel-btn"

spec/requests/api/projects_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
end
240240

241241
describe "GET /projects/:id/snippets" do
242-
it "should return a project snippet" do
242+
it "should return an array of project snippets" do
243243
get api("/projects/#{project.code}/snippets", user)
244244
response.status.should == 200
245245
json_response.should be_an Array

0 commit comments

Comments
 (0)