From cae3ea433966184fa0f27ff9372d09ee935958d3 Mon Sep 17 00:00:00 2001 From: "Gun.io Whitespace Robot" Date: Thu, 27 Oct 2011 11:10:35 -0400 Subject: [PATCH] Remove whitespace [Gun.io WhitespaceBot] --- .gitignore | 20 ++++++++++++++++++++ README | 8 ++++---- Rakefile | 20 ++++++++++---------- auto_complete_jquery.gemspec | 10 +++++----- lib/auto_complete_jquery.rb | 20 ++++++++++---------- 5 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac8f968 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Logs and databases # +###################### +*.log + +# OS generated files # +###################### +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db diff --git a/README b/README index be06998..0165932 100644 --- a/README +++ b/README @@ -9,15 +9,15 @@ Rails auto_complete plugin. It provides the same auto_complete_for method for your controllers, but eliminates the various view helper methods, as those are not needed when using jQuery and Unobtrusive JavaScript. -To use this, you need to have jQuery and the autocomplete plugin mentioned -above (as well as appropriate CSS). Then, there are four aspects of setting +To use this, you need to have jQuery and the autocomplete plugin mentioned +above (as well as appropriate CSS). Then, there are four aspects of setting up an auto-complete field: 1) Create the text field in your view, which is just a regular form text field as you'd create in a Rails erb view: <%= post.text_field :title, :autocomplete =>"off" %> - + 2) Include the appropriate JS files and CSS in your layout or similar: <%= stylesheet_link_tag 'jquery.ui.autocomplete' %> @@ -49,7 +49,7 @@ the find method used to search for the records: For more information, see: * jQuery site: http://jquery.com * Dylan Verheul jquery autocomplete plugin site: http://www.dyve.net/jquery/?autocomplete -* Good article on jQuery and Rails (note this mentions a different jquery autocomplete +* Good article on jQuery and Rails (note this mentions a different jquery autocomplete plugin, which was originally used in this plugin): http://errtheblog.com/posts/73-the-jskinny-on-jquery * Original Rails auto_complete plugin: http://github.com/rails/auto_complete diff --git a/Rakefile b/Rakefile index 2ceb70a..2db62e6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,11 @@ -require 'rake' -require 'rake/rdoctask' - -desc 'Generate documentation for auto_complete plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Auto Complete jQuery' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') +require 'rake' +require 'rake/rdoctask' + +desc 'Generate documentation for auto_complete plugin.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'Auto Complete jQuery' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') end diff --git a/auto_complete_jquery.gemspec b/auto_complete_jquery.gemspec index 681e37f..60873e0 100644 --- a/auto_complete_jquery.gemspec +++ b/auto_complete_jquery.gemspec @@ -8,11 +8,11 @@ Gem::Specification.new do |s| s.description = "This plugin provides a auto-complete method for your controllers to be used with Dylan Verheul's jquery autocomplete plugin." s.has_rdoc = true s.authors = ["Chris Bailey"] - s.files = ["CHANGELOG", - "README", - "Rakefile", - "auto_complete_jquery.gemspec", - "init.rb", + s.files = ["CHANGELOG", + "README", + "Rakefile", + "auto_complete_jquery.gemspec", + "init.rb", "lib/auto_complete_jquery.rb"] s.rdoc_options = ["--main", "README"] s.extra_rdoc_files = ["CHANGELOG", "README"] diff --git a/lib/auto_complete_jquery.rb b/lib/auto_complete_jquery.rb index ffbc5bb..2d6259b 100644 --- a/lib/auto_complete_jquery.rb +++ b/lib/auto_complete_jquery.rb @@ -1,5 +1,5 @@ -module AutoCompleteJquery - +module AutoCompleteJquery + def self.included(base) base.extend(ClassMethods) end @@ -17,34 +17,34 @@ def self.included(base) # # By default, auto_complete_for limits the results to 10 entries, # and sorts by the given field. - # + # # auto_complete_for takes a third parameter, an options hash to # the find method used to search for the records: # # auto_complete_for :post, :title, :limit => 15, :order => 'created_at DESC' # - # For help on defining text input fields with autocompletion, + # For help on defining text input fields with autocompletion, # see ActionView::Helpers::JavaScriptHelper. # - # For more on jQuery auto-complete, see the docs for the jQuery autocomplete + # For more on jQuery auto-complete, see the docs for the jQuery autocomplete # plugin used in conjunction with this plugin: # * http://www.dyve.net/jquery/?autocomplete module ClassMethods def auto_complete_for(object, method, options = {}) define_method("auto_complete_for_#{object}_#{method}") do object_constant = object.to_s.camelize.constantize - - find_options = { - :conditions => [ "LOWER(#{method}) LIKE ?", '%' + params[:q].downcase + '%' ], + + find_options = { + :conditions => [ "LOWER(#{method}) LIKE ?", '%' + params[:q].downcase + '%' ], :order => "#{method} ASC", :select => "#{object_constant.table_name}.#{method}", :limit => 10 }.merge!(options) - + @items = object_constant.find(:all, find_options).collect(&method) render :text => @items.join("\n") end end end - + end