From 523d54b56d612a791f16468ae3776ac12fd71bb7 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Tue, 21 Feb 2006 10:52:35 +0000 Subject: Added various InPlaceEditor options, #3746, #3891, #3896, #3906 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3626 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../action_view/helpers/java_script_macros_helper.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_view') 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 5641d55bc8..4237909f1d 100644 --- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb @@ -12,11 +12,11 @@ module ActionView # # A form is automatically created and displayed when the user clicks the element, # something like this: - #
- # - # - # cancel - #
+ #
+ # + # + # cancel + #
# # The form is serialized and sent to the server using an AJAX call, the action on # the server should process the value and return the updated value in the body of @@ -29,9 +29,13 @@ module ActionView # # Addtional +options+ are: # :rows:: Number of rows (more than 1 will use a TEXTAREA) + # :cols:: Number of characters the text input should span (works for both INPUT and TEXTAREA) + # :size:: Synonym for :cols when using a single line text input. # :cancel_text:: The text on the cancel link. (default: "cancel") # :save_text:: The text on the save link. (default: "ok") + # :loading_text:: The text to display when submitting to the server (default: "Saving...") # :external_control:: The id of an external control used to enter edit mode. + # :load_text_url:: URL where initial value of editor (content) is retrieved. # :options:: Pass through options to the AJAX call (see prototype's Ajax.Updater) # :with:: JavaScript snippet that should return what is to be sent # in the AJAX call, +form+ is an implicit parameter @@ -43,8 +47,12 @@ module ActionView js_options = {} js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text] js_options['okText'] = %('#{options[:save_text]}') if options[:save_text] + js_options['loadingText'] = %('#{options[:loading_text]}') if options[:loading_text] js_options['rows'] = options[:rows] if options[:rows] - js_options['externalControl'] = options[:external_control] if options[:external_control] + js_options['cols'] = options[:cols] if options[:cols] + js_options['size'] = options[:size] if options[:size] + js_options['externalControl'] = "'#{options[:external_control]}'" if options[:external_control] + js_options['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if options[:load_text_url] js_options['ajaxOptions'] = options[:options] if options[:options] js_options['callback'] = "function(form) { return #{options[:with]} }" if options[:with] function << (', ' + options_for_javascript(js_options)) unless js_options.empty? -- cgit v1.2.3