adding an ajax loader, and pull out the js from the middle of the view
This commit is contained in:
parent
2a30e60fe0
commit
b8b6557379
3 changed files with 18 additions and 9 deletions
|
|
@ -34,8 +34,10 @@ class PeopleController < ApplicationController
|
|||
#only do it if it is an email address
|
||||
if diaspora_id?(search_query)
|
||||
@people = Person.where(:diaspora_handle => search_query.downcase)
|
||||
Webfinger.in_background(search_query) if @people.empty?
|
||||
@background_query = search_query.downcase
|
||||
if @people.empty?
|
||||
Webfinger.in_background(search_query)
|
||||
@background_query = search_query.downcase
|
||||
end
|
||||
end
|
||||
@people = @people.paginate(:page => params[:page], :per_page => 15)
|
||||
@hashes = hashes_for_people(@people, @aspects)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
- content_for :head do
|
||||
= include_javascripts :people
|
||||
= javascript_include_tag 'contact-list'
|
||||
- if @background_query.present?
|
||||
:javascript
|
||||
$(document).ready(function() { List.startSearchDelay('#{@background_query}') } );
|
||||
|
||||
.span-24.last
|
||||
= search_header
|
||||
|
|
@ -19,13 +22,12 @@
|
|||
#people_stream.stream
|
||||
- if @hashes.empty?
|
||||
- if @background_query.present?
|
||||
%p
|
||||
=t('.searching')
|
||||
:javascript
|
||||
$(document).ready(function() { List.startSearchDelay('#{@background_query}') } );
|
||||
%p
|
||||
= t('.searching')
|
||||
= image_tag '/images/static-loader.png', :class => 'loader'
|
||||
- else
|
||||
%p
|
||||
=t('.no_one_found')
|
||||
= t('.no_one_found')
|
||||
- else
|
||||
- for hash in @hashes
|
||||
= render :partial => 'people/person', :locals => hash
|
||||
|
|
|
|||
|
|
@ -53,9 +53,14 @@ describe PeopleController do
|
|||
assigns[:people][0].id.should == @unsearchable_eugene.id
|
||||
end
|
||||
|
||||
it 'sets the background query task' do
|
||||
it 'does not the background query task if the user is found' do
|
||||
get :index, :q => "Eugene@Example.ORG"
|
||||
assigns[:background_query].should == "eugene@example.org"
|
||||
assigns[:background_query].should == nil
|
||||
end
|
||||
|
||||
it 'sets background query task if the user is not found' do
|
||||
get :index, :q => "Eugene@Example1.ORG"
|
||||
assigns[:background_query].should == "eugene@example1.org"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue