Permalink
Browse files

Reorg options_for_javascript and array_or_string_for_javascript

  • Loading branch information...
1 parent 570e02c commit 657d85580e914caf368a8a12ff5642e4d979ab7e @josh josh committed Jan 30, 2010
View
17 actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -95,23 +95,6 @@ def javascript_tag(content_or_options_with_block = nil, html_options = {}, &bloc
def javascript_cdata_section(content) #:nodoc:
"\n//#{cdata_section("\n#{content}\n//")}\n"
end
-
- protected
- def options_for_javascript(options)
- if options.empty?
- '{}'
- else
- "{#{options.keys.map { |k| "#{k}:#{options[k]}" }.sort.join(', ')}}"
- end
- end
-
- def array_or_string_for_javascript(option)
- if option.kind_of?(Array)
- "['#{option.join('\',\'')}']"
- elsif !option.nil?
- "'#{option}'"
- end
- end
end
end
end
View
8 actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -624,6 +624,14 @@ def update_page_tag(html_options = {}, &block)
end
protected
+ def options_for_javascript(options)
+ if options.empty?
+ '{}'
+ else
+ "{#{options.keys.map { |k| "#{k}:#{options[k]}" }.sort.join(', ')}}"
+ end
+ end
+
def options_for_ajax(options)
js_options = build_callbacks(options)
View
9 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
@@ -216,6 +216,15 @@ def drop_receiving_element_js(element_id, options = {}) #:nodoc:
%(Droppables.add(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
end
+
+ protected
+ def array_or_string_for_javascript(option)
+ if option.kind_of?(Array)
+ "['#{option.join('\',\'')}']"
+ elsif !option.nil?
+ "'#{option}'"
+ end
+ end
end
module PrototypeHelper

0 comments on commit 657d855

Please sign in to comment.