aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/java_script_macros_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/java_script_macros_helper.rb20
1 files changed, 14 insertions, 6 deletions
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:
- # <form id="myElement-in-place-edit-form" target="specified url">
- # <input name="value" text="The content of myElement"/>
- # <input type="submit" value="ok"/>
- # <a onclick="javascript to cancel the editing">cancel</a>
- # </form>
+ # <form id="myElement-in-place-edit-form" target="specified url">
+ # <input name="value" text="The content of myElement"/>
+ # <input type="submit" value="ok"/>
+ # <a onclick="javascript to cancel the editing">cancel</a>
+ # </form>
#
# 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:
# <tt>:rows</tt>:: Number of rows (more than 1 will use a TEXTAREA)
+ # <tt>:cols</tt>:: Number of characters the text input should span (works for both INPUT and TEXTAREA)
+ # <tt>:size</tt>:: Synonym for :cols when using a single line text input.
# <tt>:cancel_text</tt>:: The text on the cancel link. (default: "cancel")
# <tt>:save_text</tt>:: The text on the save link. (default: "ok")
+ # <tt>:loading_text</tt>:: The text to display when submitting to the server (default: "Saving...")
# <tt>:external_control</tt>:: The id of an external control used to enter edit mode.
+ # <tt>:load_text_url</tt>:: URL where initial value of editor (content) is retrieved.
# <tt>:options</tt>:: Pass through options to the AJAX call (see prototype's Ajax.Updater)
# <tt>:with</tt>:: 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?