From 87a677347e9df53f4746aa95f1f4e490d03a8e0e Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 5 Jul 2012 17:52:44 -0300 Subject: [PATCH] Including a helper method for using token_input --- app/helpers/application_helper.rb | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+), 0 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2aaf9a3..fae3f0e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1337,4 +1337,53 @@ module ApplicationHelper _("Are you sure that you want to remove the item \"#{article.name}\"?") end end + + def token_input_field_tag(name, element_id, search_action, options = {}, text_field_options = {}, html_options = {}) + options[:min_chars] ||= 3 + options[:hint_text] ||= _("Type in a search term") + options[:no_results_text] ||= _("No results") + options[:searching_text] ||= _("Searching...") + options[:search_delay] ||= 1000 + options[:prevent_duplicates] ||= true + options[:backspace_delete_item] ||= false + options[:focus] ||= false + options[:avoid_enter] ||= true + options[:on_result] ||= 'null' + options[:on_add] ||= 'null' + options[:on_delete] ||= 'null' + options[:on_ready] ||= 'null' + + result = text_field_tag(name, nil, text_field_options.merge(html_options.merge({:id => element_id}))) + result += + " + " + result + end + end -- libgit2 0.21.2