Commit 3c5a3fe0 authored by randx's avatar randx

Merge branch 'front-end' of https://github.com/NARKOZ/gitlabhq into NARKOZ-front-end

Conflicts:
	app/views/issues/_form.html.haml
parents 2e0e63e1 414080cb
# Creates the variables for setting up GFM auto-completion
###
Creates the variables for setting up GFM auto-completion
###
# Emoji # Emoji
window.autocompleteEmojiData = []; data = []
window.autocompleteEmojiTemplate = "<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.autocompleteEmoji = {data, template}
# Team Members # Team Members
window.autocompleteMembersUrl = ""; url = '';
window.autocompleteMembersParams = params = {private_token: '', page: 1}
private_token: "" window.autocompleteMembers = {data, url, params}
page: 1
window.autocompleteMembersData = [];
# Add GFM auto-completion to all input fields, that accept GFM input.
window.setupGfmAutoComplete = ->
$input = $('.js-gfm-input')
# Emoji
$input.atWho ':',
data: autocompleteEmoji.data,
tpl: autocompleteEmoji.template
### # Team Members
Add GFM auto-completion to all input fields, that accept GFM input. $input.atWho '@', (query, callback) ->
###
window.setupGfmAutoComplete = ->
###
Emoji
###
$('.gfm-input').atWho ':',
data: autocompleteEmojiData,
tpl: autocompleteEmojiTemplate
###
Team Members
###
$('.gfm-input').atWho '@', (query, callback) ->
(getMoreMembers = -> (getMoreMembers = ->
$.getJSON(autocompleteMembersUrl, autocompleteMembersParams) $.getJSON(autocompleteMembers.url, autocompleteMembers.params).success (members) ->
.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 autocompleteMembersData, 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 autocompleteMembersData[..]
# are we past the last page?
# are we past the last page? if newMembersData.length is 0
if newMembersData.length == 0 # set static data and stop callbacks
# set static data and stop callbacks $input.atWho '@',
$('.gfm-input').atWho '@', data: autocompleteMembers.data
data: autocompleteMembersData 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
autocompleteMembersParams.page += 1; autocompleteMembers.params.page += 1
).call(); ).call()
\ No newline at end of file
initGraphNav = ->
$('.graph svg').css 'position', 'relative'
$('body').bind 'keyup', (e) ->
if e.keyCode is 37 # left
$('.graph svg').animate left: '+=400'
else if e.keyCode is 39 # right
$('.graph svg').animate left: '-=400'
window.initGraphNav = initGraphNav
Loader =
html: (width) ->
$('<img>').attr src: '/assets/ajax-loader.gif', width: width
window.Loader = Loader
...@@ -7,7 +7,7 @@ window.slugify = (text) -> ...@@ -7,7 +7,7 @@ window.slugify = (text) ->
window.ajaxGet = (url) -> window.ajaxGet = (url) ->
$.ajax({type: "GET", url: url, dataType: "script"}) $.ajax({type: "GET", url: url, dataType: "script"})
# Disable button if text field is empty # Disable button if text field is empty
window.disableButtonIfEmptyField = (field_selector, button_selector) -> window.disableButtonIfEmptyField = (field_selector, button_selector) ->
field = $(field_selector) field = $(field_selector)
closest_submit = field.closest("form").find(button_selector) closest_submit = field.closest("form").find(button_selector)
...@@ -15,21 +15,21 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> ...@@ -15,21 +15,21 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) ->
closest_submit.disable() if field.val() is "" closest_submit.disable() if field.val() is ""
field.on "keyup", -> field.on "keyup", ->
if $(this).val() is "" if $(@).val() is ""
closest_submit.disable() closest_submit.disable()
else else
closest_submit.enable() closest_submit.enable()
$ -> $ ->
# Click a .one_click_select field, select the contents # Click a .one_click_select field, select the contents
$(".one_click_select").live 'click', -> $(this).select() $(".one_click_select").on 'click', -> $(@).select()
# Initialize chosen selects # Initialize chosen selects
$('select.chosen').chosen() $('select.chosen').chosen()
# Disable form buttons while a form is submitting # Disable form buttons while a form is submitting
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->
buttons = $('[type="submit"]', this) buttons = $('[type="submit"]', @)
switch e.type switch e.type
when 'ajax:beforeSend', 'submit' when 'ajax:beforeSend', 'submit'
...@@ -38,7 +38,7 @@ $ -> ...@@ -38,7 +38,7 @@ $ ->
buttons.enable() buttons.enable()
# Show/Hide the profile menu when hovering the account box # Show/Hide the profile menu when hovering the account box
$('.account-box').hover -> $(this).toggleClass('hover') $('.account-box').hover -> $(@).toggleClass('hover')
# Focus search field by pressing 's' key # Focus search field by pressing 's' key
$(document).keypress (e) -> $(document).keypress (e) ->
...@@ -52,22 +52,22 @@ $ -> ...@@ -52,22 +52,22 @@ $ ->
# Commit show suppressed diff # Commit show suppressed diff
$(".supp_diff_link").bind "click", -> $(".supp_diff_link").bind "click", ->
$(this).next('table').show() $(@).next('table').show()
$(this).remove() $(@).remove()
# Note markdown preview # Note markdown preview
$(document).on 'click', '#preview-link', (e) -> $(document).on 'click', '#preview-link', (e) ->
$('#preview-note').text('Loading...') $('#preview-note').text 'Loading...'
previewLinkText = if $(this).text() == 'Preview' then 'Edit' else 'Preview' previewLinkText = if $(@).text() is 'Preview' then 'Edit' else 'Preview'
$(this).text(previewLinkText) $(@).text previewLinkText
note = $('#note_note').val() note = $('#note_note').val()
if note.trim().length == 0 if note.trim().length is 0
$('#preview-note').text("Nothing to preview.") $('#preview-note').text 'Nothing to preview.'
else else
$.post $(this).attr('href'), {note: note}, (data) -> $.post $(@).attr('href'), {note: note}, (data) ->
$('#preview-note').html(data) $('#preview-note').html(data)
$('#preview-note, #note_note').toggle() $('#preview-note, #note_note').toggle()
...@@ -79,14 +79,14 @@ $ -> ...@@ -79,14 +79,14 @@ $ ->
$.fn.extend chosen: (options) -> $.fn.extend chosen: (options) ->
default_options = search_contains: "true" default_options = search_contains: "true"
$.extend default_options, options $.extend default_options, options
_chosen.apply this, [default_options] _chosen.apply @, [default_options]
# Disable an element and add the 'disabled' Bootstrap class # Disable an element and add the 'disabled' Bootstrap class
$.fn.extend disable: -> $.fn.extend disable: ->
$(this).attr('disabled', 'disabled').addClass('disabled') $(@).attr('disabled', 'disabled').addClass('disabled')
# Enable an element and remove the 'disabled' Bootstrap class # Enable an element and remove the 'disabled' Bootstrap class
$.fn.extend enable: -> $.fn.extend enable: ->
$(this).removeAttr('disabled').removeClass('disabled') $(@).removeAttr('disabled').removeClass('disabled')
)(jQuery) )(jQuery)
...@@ -22,3 +22,10 @@ $ -> ...@@ -22,3 +22,10 @@ $ ->
# Ref switcher # Ref switcher
$('.project-refs-select').on 'change', -> $('.project-refs-select').on 'change', ->
$(@).parents('form').submit() $(@).parents('form').submit()
class @GraphNav
@init: ->
$('.graph svg').css 'position', 'relative'
$('body').bind 'keyup', (e) ->
$('.graph svg').animate(left: '+=400') if e.keyCode is 37 # left
$('.graph svg').animate(left: '-=400') if e.keyCode is 39 # right
$ ->
$('#snippets-table .snippet').live 'click', (e) ->
if e.target.nodeName isnt 'A' and e.target.nodeName isnt 'INPUT'
location.href = $(@).attr 'url'
e.stopPropagation()
false
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
= f.label :title do = f.label :title do
%strong= "Subject *" %strong= "Subject *"
.input .input
= f.text_field :title, maxlength: 255, class: "xxlarge gfm-input", autofocus: true = f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true
.issue_middle_block .issue_middle_block
.issue_assignee .issue_assignee
= f.label :assignee_id do = f.label :assignee_id do
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
.clearfix .clearfix
= f.label :description, "Details" = f.label :description, "Details"
.input .input
= f.text_area :description, maxlength: 2000, class: "xxlarge gfm-input", rows: 14 = f.text_area :description, maxlength: 2000, class: "xxlarge js-gfm-input", rows: 14
%p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
......
:javascript :javascript
$(function() { $(function() {
autocompleteMembersUrl = "#{ "/api/v2/projects/#{@project.code}/members" if @project }"; autocompleteMembers.url = "#{ "/api/v2/projects/#{@project.code}/members" if @project }";
autocompleteMembersParams.private_token = "#{current_user.authentication_token}"; autocompleteMembers.params.private_token = "#{current_user.private_token}";
autocompleteEmojiData = #{raw emoji_autocomplete_source}; autocompleteEmoji.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
autocompleteEmojiData = $.map(autocompleteEmojiData, function(value) { autocompleteEmoji.data = $.map(autocompleteEmoji.data, function(value) {
return { return {
name: value, name: value,
insert: value+':', insert: value+':',
......
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
.clearfix .clearfix
.main_box .main_box
.top_box_content .top_box_content
= f.label :title do = f.label :title do
%strong= "Title *" %strong= "Title *"
.input= f.text_field :title, class: "input-xxlarge pad gfm-input", maxlength: 255, rows: 5 .input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5
.middle_box_content .middle_box_content
= f.label :assignee_id do = f.label :assignee_id do
%i.icon-user %i.icon-user
Assign to Assign to
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= f.hidden_field :noteable_id = f.hidden_field :noteable_id
= f.hidden_field :noteable_type = f.hidden_field :noteable_type
= f.text_area :note, size: 255, class: 'note-text gfm-input' = f.text_area :note, size: 255, class: 'note-text js-gfm-input'
#preview-note.preview_note.hide #preview-note.preview_note.hide
.hint .hint
.right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= f.hidden_field :noteable_id = f.hidden_field :noteable_id
= f.hidden_field :noteable_type = f.hidden_field :noteable_type
= f.hidden_field :line_code = f.hidden_field :line_code
= f.text_area :note, size: 255, class: 'line-note-text gfm-input' = f.text_area :note, size: 255, class: 'line-note-text js-gfm-input'
.note_actions .note_actions
.buttons .buttons
= f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note" = f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note"
......
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
initGraph(); initGraph();
$(function(){ $(function(){
branchGraph($("#holder")[0]); branchGraph($("#holder")[0]);
initGraphNav(); GraphNav.init();
}); });
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
.bottom_box_content .bottom_box_content
= f.label :content = f.label :content
.input= f.text_area :content, class: 'span8 gfm-input' .input= f.text_area :content, class: 'span8 js-gfm-input'
.actions .actions
= f.submit 'Save', class: "save-btn btn" = f.submit 'Save', class: "save-btn btn"
= link_to "Cancel", project_wiki_path(@project, :index), class: "btn cancel-btn" = link_to "Cancel", project_wiki_path(@project, :index), class: "btn cancel-btn"
...@@ -239,7 +239,7 @@ describe Gitlab::API do ...@@ -239,7 +239,7 @@ describe Gitlab::API do
end end
describe "GET /projects/:id/snippets" do describe "GET /projects/:id/snippets" do
it "should return a project snippet" do it "should return an array of project snippets" do
get api("/projects/#{project.code}/snippets", user) get api("/projects/#{project.code}/snippets", user)
response.status.should == 200 response.status.should == 200
json_response.should be_an Array json_response.should be_an Array
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment