diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-10-10 12:45:03 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-10-10 12:45:03 +0400 |
commit | 60b4c88e3a175fa8b1fdebede4a5c5f73df0eee5 (patch) | |
tree | 6471f2fb2d6e6418206eb2edb33ea6dc239c51b1 /app/views | |
parent | a100c5783186f630d4d1185b9bb6e89cf2ac1ba4 (diff) | |
parent | 4d843d2ce1e12525637e2a578896686a4efb9a55 (diff) |
Merge pull request #1664 from riyad/auto-complete-everywhere
Cleanup auto-completion and add it to all GFM inputs
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/issues/_form.html.haml | 4 | ||||
-rw-r--r-- | app/views/layouts/_head_panel.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/_init_auto_complete.html.haml | 17 | ||||
-rw-r--r-- | app/views/merge_requests/_form.html.haml | 2 | ||||
-rw-r--r-- | app/views/notes/_common_form.html.haml | 46 | ||||
-rw-r--r-- | app/views/notes/_create_common_note.js.haml | 1 | ||||
-rw-r--r-- | app/views/wikis/_form.html.haml | 2 |
7 files changed, 24 insertions, 50 deletions
diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index 813ecab2d19..ec3edce066a 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -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'}. diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index f5e423a5abf..7f89bdf0e9a 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -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({ diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml new file mode 100644 index 00000000000..87a74655128 --- /dev/null +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -0,0 +1,17 @@ +: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(); + }); diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index 96692c0f93d..f42d74e1376 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -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 diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index 4ac26d33e66..a9f2907b05a 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -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 => '20x20')}</li>" - }); - }); diff --git a/app/views/notes/_create_common_note.js.haml b/app/views/notes/_create_common_note.js.haml index bbebc2478c5..e7df64c4c1e 100644 --- a/app/views/notes/_create_common_note.js.haml +++ b/app/views/notes/_create_common_note.js.haml @@ -10,4 +10,5 @@ - else :plain $(".note-form-holder").replaceWith("#{escape_javascript(render 'form')}"); + setupGfmAutoComplete(); diff --git a/app/views/wikis/_form.html.haml b/app/views/wikis/_form.html.haml index b05d0a78992..89bbe2ea960 100644 --- a/app/views/wikis/_form.html.haml +++ b/app/views/wikis/_form.html.haml @@ -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" |