Commit 13e72f5a6ffa7332488ad495610971e540ea3fd1
Exists in
master
and in
4 other branches
Merge branch 'NARKOZ-front-end'
Showing
14 changed files
with
75 additions
and
99 deletions
Show diff stats
app/assets/javascripts/gfm_auto_complete.js.coffee
1 | +# Creates the variables for setting up GFM auto-completion | |
1 | 2 | |
2 | -### | |
3 | - Creates the variables for setting up GFM auto-completion | |
4 | -### | |
5 | 3 | # 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} | |
8 | 7 | |
9 | 8 | # 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} | |
15 | 12 | |
13 | +# Add GFM auto-completion to all input fields, that accept GFM input. | |
14 | +window.setupGfmAutoComplete = -> | |
15 | + $input = $('.js-gfm-input') | |
16 | 16 | |
17 | + # Emoji | |
18 | + $input.atWho ':', | |
19 | + data: autocompleteEmoji.data, | |
20 | + tpl: autocompleteEmoji.template | |
17 | 21 | |
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) -> | |
33 | 24 | (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() | |
54 | 44 | |
55 | 45 | # so the next request gets the next page |
56 | - autocompleteMembersParams.page += 1; | |
57 | - ).call(); | |
58 | 46 | \ No newline at end of file |
47 | + autocompleteMembers.params.page += 1 | |
48 | + ).call() | ... | ... |
app/assets/javascripts/graph.js.coffee
... | ... | @@ -1,10 +0,0 @@ |
1 | -initGraphNav = -> | |
2 | - $('.graph svg').css 'position', 'relative' | |
3 | - | |
4 | - $('body').bind 'keyup', (e) -> | |
5 | - if e.keyCode is 37 # left | |
6 | - $('.graph svg').animate left: '+=400' | |
7 | - else if e.keyCode is 39 # right | |
8 | - $('.graph svg').animate left: '-=400' | |
9 | - | |
10 | -window.initGraphNav = initGraphNav |
app/assets/javascripts/loader.js.coffee
app/assets/javascripts/main.js.coffee
... | ... | @@ -7,7 +7,7 @@ window.slugify = (text) -> |
7 | 7 | window.ajaxGet = (url) -> |
8 | 8 | $.ajax({type: "GET", url: url, dataType: "script"}) |
9 | 9 | |
10 | - # Disable button if text field is empty | |
10 | +# Disable button if text field is empty | |
11 | 11 | window.disableButtonIfEmptyField = (field_selector, button_selector) -> |
12 | 12 | field = $(field_selector) |
13 | 13 | closest_submit = field.closest("form").find(button_selector) |
... | ... | @@ -15,21 +15,21 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> |
15 | 15 | closest_submit.disable() if field.val() is "" |
16 | 16 | |
17 | 17 | field.on "keyup", -> |
18 | - if $(this).val() is "" | |
18 | + if $(@).val() is "" | |
19 | 19 | closest_submit.disable() |
20 | 20 | else |
21 | 21 | closest_submit.enable() |
22 | 22 | |
23 | 23 | $ -> |
24 | 24 | # Click a .one_click_select field, select the contents |
25 | - $(".one_click_select").live 'click', -> $(this).select() | |
25 | + $(".one_click_select").on 'click', -> $(@).select() | |
26 | 26 | |
27 | 27 | # Initialize chosen selects |
28 | 28 | $('select.chosen').chosen() |
29 | 29 | |
30 | 30 | # Disable form buttons while a form is submitting |
31 | 31 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> |
32 | - buttons = $('[type="submit"]', this) | |
32 | + buttons = $('[type="submit"]', @) | |
33 | 33 | |
34 | 34 | switch e.type |
35 | 35 | when 'ajax:beforeSend', 'submit' |
... | ... | @@ -38,7 +38,7 @@ $ -> |
38 | 38 | buttons.enable() |
39 | 39 | |
40 | 40 | # Show/Hide the profile menu when hovering the account box |
41 | - $('.account-box').hover -> $(this).toggleClass('hover') | |
41 | + $('.account-box').hover -> $(@).toggleClass('hover') | |
42 | 42 | |
43 | 43 | # Focus search field by pressing 's' key |
44 | 44 | $(document).keypress (e) -> |
... | ... | @@ -52,22 +52,22 @@ $ -> |
52 | 52 | |
53 | 53 | # Commit show suppressed diff |
54 | 54 | $(".supp_diff_link").bind "click", -> |
55 | - $(this).next('table').show() | |
56 | - $(this).remove() | |
55 | + $(@).next('table').show() | |
56 | + $(@).remove() | |
57 | 57 | |
58 | 58 | # Note markdown preview |
59 | 59 | $(document).on 'click', '#preview-link', (e) -> |
60 | - $('#preview-note').text('Loading...') | |
60 | + $('#preview-note').text 'Loading...' | |
61 | 61 | |
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 | |
64 | 64 | |
65 | 65 | note = $('#note_note').val() |
66 | 66 | |
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.' | |
69 | 69 | else |
70 | - $.post $(this).attr('href'), {note: note}, (data) -> | |
70 | + $.post $(@).attr('href'), {note: note}, (data) -> | |
71 | 71 | $('#preview-note').html(data) |
72 | 72 | |
73 | 73 | $('#preview-note, #note_note').toggle() |
... | ... | @@ -79,14 +79,14 @@ $ -> |
79 | 79 | $.fn.extend chosen: (options) -> |
80 | 80 | default_options = search_contains: "true" |
81 | 81 | $.extend default_options, options |
82 | - _chosen.apply this, [default_options] | |
82 | + _chosen.apply @, [default_options] | |
83 | 83 | |
84 | 84 | # Disable an element and add the 'disabled' Bootstrap class |
85 | 85 | $.fn.extend disable: -> |
86 | - $(this).attr('disabled', 'disabled').addClass('disabled') | |
86 | + $(@).attr('disabled', 'disabled').addClass('disabled') | |
87 | 87 | |
88 | 88 | # Enable an element and remove the 'disabled' Bootstrap class |
89 | 89 | $.fn.extend enable: -> |
90 | - $(this).removeAttr('disabled').removeClass('disabled') | |
90 | + $(@).removeAttr('disabled').removeClass('disabled') | |
91 | 91 | |
92 | 92 | )(jQuery) | ... | ... |
app/assets/javascripts/projects.js.coffee
... | ... | @@ -22,3 +22,10 @@ $ -> |
22 | 22 | # Ref switcher |
23 | 23 | $('.project-refs-select').on 'change', -> |
24 | 24 | $(@).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
app/views/issues/_form.html.haml
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | = f.label :title do |
13 | 13 | %strong= "Subject *" |
14 | 14 | .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 | |
16 | 16 | .issue_middle_block |
17 | 17 | .issue_assignee |
18 | 18 | = f.label :assignee_id do |
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | .clearfix |
38 | 38 | = f.label :description, "Details" |
39 | 39 | .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 | |
41 | 41 | %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. |
42 | 42 | |
43 | 43 | ... | ... |
app/views/layouts/_init_auto_complete.html.haml
1 | 1 | :javascript |
2 | 2 | $(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}"; | |
5 | 5 | |
6 | - autocompleteEmojiData = #{raw emoji_autocomplete_source}; | |
6 | + autocompleteEmoji.data = #{raw emoji_autocomplete_source}; | |
7 | 7 | // 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) { | |
9 | 9 | return { |
10 | 10 | name: value, |
11 | 11 | insert: value+':', | ... | ... |
app/views/merge_requests/_form.html.haml
... | ... | @@ -30,12 +30,12 @@ |
30 | 30 | .clearfix |
31 | 31 | .main_box |
32 | 32 | .top_box_content |
33 | - = f.label :title do | |
33 | + = f.label :title do | |
34 | 34 | %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 | |
36 | 36 | .middle_box_content |
37 | - = f.label :assignee_id do | |
38 | - %i.icon-user | |
37 | + = f.label :assignee_id do | |
38 | + %i.icon-user | |
39 | 39 | Assign to |
40 | 40 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) |
41 | 41 | ... | ... |
app/views/notes/_common_form.html.haml
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | |
9 | 9 | = f.hidden_field :noteable_id |
10 | 10 | = 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' | |
12 | 12 | #preview-note.preview_note.hide |
13 | 13 | .hint |
14 | 14 | .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. | ... | ... |
app/views/notes/_per_line_form.html.haml
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | = f.hidden_field :noteable_id |
14 | 14 | = f.hidden_field :noteable_type |
15 | 15 | = 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' | |
17 | 17 | .note_actions |
18 | 18 | .buttons |
19 | 19 | = f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note" | ... | ... |
app/views/projects/graph.html.haml
app/views/wikis/_form.html.haml
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | |
22 | 22 | .bottom_box_content |
23 | 23 | = f.label :content |
24 | - .input= f.text_area :content, class: 'span8 gfm-input' | |
24 | + .input= f.text_area :content, class: 'span8 js-gfm-input' | |
25 | 25 | .actions |
26 | 26 | = f.submit 'Save', class: "save-btn btn" |
27 | 27 | = link_to "Cancel", project_wiki_path(@project, :index), class: "btn cancel-btn" | ... | ... |
spec/requests/api/projects_spec.rb
... | ... | @@ -239,7 +239,7 @@ describe Gitlab::API do |
239 | 239 | end |
240 | 240 | |
241 | 241 | describe "GET /projects/:id/snippets" do |
242 | - it "should return a project snippet" do | |
242 | + it "should return an array of project snippets" do | |
243 | 243 | get api("/projects/#{project.code}/snippets", user) |
244 | 244 | response.status.should == 200 |
245 | 245 | json_response.should be_an Array | ... | ... |