From 516dc2c0f16cf187f981b5e8648a7f7f1b31d190 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Wed, 28 Sep 2005 08:20:47 +0000 Subject: Update script.aculo.us to 1.5_rc2, and Prototype to 1.4.0_pre7 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2386 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../helpers/java_script_macros_helper.rb | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view/helpers/java_script_macros_helper.rb') diff --git a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb index 8c67edd645..1cc814feaf 100644 --- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb @@ -74,9 +74,8 @@ module ActionView # input field. # # Required +options+ are: - # :url:: Specifies the DOM ID of the element whose - # innerHTML should be updated with the autocomplete - # entries returned by XMLHttpRequest. + # :url:: URL to call for autocompletion results + # in url_for format. # # Addtional +options+ are: # :update:: Specifies the DOM ID of the element whose @@ -130,10 +129,41 @@ module ActionView # See the RDoc on ActionController::AutoComplete to learn more about this. def text_field_with_auto_complete(object, method, tag_options = {}, completion_options = {}) (completion_options[:skip_style] ? "" : auto_complete_stylesheet) + - text_field(object, method, { :autocomplete => "off" }.merge!(tag_options)) + + text_field(object, method, tag_options) + content_tag("div", "", :id => "#{object}_#{method}_auto_complete", :class => "auto_complete") + auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}" } }.update(completion_options)) end + + private + def auto_complete_stylesheet + content_tag("style", <<-EOT + div.auto_complete { + width: 350px; + background: #fff; + } + div.auto_complete ul { + border:1px solid #888; + margin:0; + padding:0; + width:100%; + list-style-type:none; + } + div.auto_complete ul li { + margin:0; + padding:3px; + } + div.auto_complete ul li.selected { + background-color: #ffb; + } + div.auto_complete ul strong.highlight { + color: #800; + margin:0; + padding:0; + } + EOT + ) + end + end end end -- cgit v1.2.3