Created
January 13, 2011 23:33
-
-
Save rjungemann/778845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UiController < ApplicationController | |
layout 'standard_with_top' | |
def index | |
end | |
def buttons | |
end | |
def accordion | |
render :layout => 'standard_narrow_left_sidebar_and_top_and_local_nav' | |
end | |
def scroll_panel | |
end | |
def forms | |
end | |
def panels | |
end | |
def fb_autocomplete | |
end | |
def fb_autocomplete_friends | |
callback = params[:callback] | |
term = params[:term] | |
raise "Term must be provided." unless term | |
friends = [ | |
{ :label => user_container("Alice"), :value => "Alice" }, | |
{ :label => user_container("Alfred"), :value => "Alfred" }, | |
{ :label => user_container("Bob"), :value => "Bob" }, | |
{ :label => user_container("Eve"), :value => "Eve" } | |
].find_all { |f| f[:value].downcase.match(/^#{term.downcase}/) } | |
response = if callback | |
%{@callback(#{@friends.to_json})} | |
else | |
friends.to_json | |
end | |
render({ :content_type => :js, :text => response }) | |
end | |
private | |
def user_container name | |
%{ | |
<div class="friend_container"> | |
<div class="friend_image"><div class="image"></div></div> | |
<div class="friend_name">#{name}</div> | |
<div class="friend_info">More Info...</div> | |
</div> | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment