From 922ab778f494c86ba55dc26ae95d555fc78ff938 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 21 Mar 2013 22:14:07 +0400 Subject: [PATCH] #37: search user by keyup instead of 'press enter' --- app/assets/javascripts/extra/tracker.js | 22 ++++++------------- app/assets/stylesheets/design/custom.scss | 2 +- .../projects/issues/_assigned_popup.html.haml | 4 +++- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index d358f9b31..7acee8c69 100644 --- a/app/assets/javascripts/extra/tracker.js +++ b/app/assets/javascripts/extra/tracker.js @@ -115,24 +115,16 @@ $(document).ready(function() { return false; }; - $('#search_user').live('submit', function() { - var id = $(this).attr('id'); - if(id.indexOf('user') != -1) { // FIXME - var which = 'users'; - } - else if (id.indexOf('labels') != -1) { - var which = 'labels'; - } - $.ajax({ + var isSearchUser = null; + $('#search_user').on('keyup', function() { + if (isSearchUser != null) { isSearchUser.abort(); } + isSearchUser = $.ajax({ type: 'GET', - url: $(this).attr("action"), + url: $('#search_user_path').attr('path'), data: $(this).serialize(), success: function(data){ - $('#manage_issue_'+ which +'_list').html(data); - }, - error: function(data){ - alert('error') // TODO remove - } + $('#manage_issue_users_list').html(data); + } }); return false; }); diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index cef509faa..9c52d8eca 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -1949,7 +1949,7 @@ article .activity .top { font-weight: bold; .title { display: inline-block; } } - form { + .search-container { padding: 10px 15px 10px 10px; border-bottom: 1px solid #D6D6D6; input { diff --git a/app/views/projects/issues/_assigned_popup.html.haml b/app/views/projects/issues/_assigned_popup.html.haml index 851d4951c..0b11772dc 100644 --- a/app/views/projects/issues/_assigned_popup.html.haml +++ b/app/views/projects/issues/_assigned_popup.html.haml @@ -2,9 +2,11 @@ .header .title= t('layout.issues.assign_someone') %span.icon-remove-circle - = form_tag search_collaborators_project_issues_path(@project, :id => @issue.id), :id => 'search_user', :method => :get do + .search-container + #search_user_path{:path => search_collaborators_project_issues_path(@project, :id => @issue.id)} = tracker_search_field(:search_user, t('layout.issues.search_user')) + - unless [:new, :create].include?(action_name.to_sym) = form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_assignee issue'} do |f| = hidden_field_tag "user-default_assignee", nil, :name => 'issue[assignee_id]'