Skip to content
This repository
Browse code

Reorg options_for_javascript and array_or_string_for_javascript

  • Loading branch information...
commit 657d85580e914caf368a8a12ff5642e4d979ab7e 1 parent 570e02c
Joshua Peek josh authored
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
95 95 def javascript_cdata_section(content) #:nodoc:
96 96 "\n//#{cdata_section("\n#{content}\n//")}\n"
97 97 end
98   -
99   - protected
100   - def options_for_javascript(options)
101   - if options.empty?
102   - '{}'
103   - else
104   - "{#{options.keys.map { |k| "#{k}:#{options[k]}" }.sort.join(', ')}}"
105   - end
106   - end
107   -
108   - def array_or_string_for_javascript(option)
109   - if option.kind_of?(Array)
110   - "['#{option.join('\',\'')}']"
111   - elsif !option.nil?
112   - "'#{option}'"
113   - end
114   - end
115 98 end
116 99 end
117 100 end
8 actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -624,6 +624,14 @@ def update_page_tag(html_options = {}, &block)
624 624 end
625 625
626 626 protected
  627 + def options_for_javascript(options)
  628 + if options.empty?
  629 + '{}'
  630 + else
  631 + "{#{options.keys.map { |k| "#{k}:#{options[k]}" }.sort.join(', ')}}"
  632 + end
  633 + end
  634 +
627 635 def options_for_ajax(options)
628 636 js_options = build_callbacks(options)
629 637
9 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
@@ -216,6 +216,15 @@ def drop_receiving_element_js(element_id, options = {}) #:nodoc:
216 216
217 217 %(Droppables.add(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
218 218 end
  219 +
  220 + protected
  221 + def array_or_string_for_javascript(option)
  222 + if option.kind_of?(Array)
  223 + "['#{option.join('\',\'')}']"
  224 + elsif !option.nil?
  225 + "'#{option}'"
  226 + end
  227 + end
219 228 end
220 229
221 230 module PrototypeHelper

0 comments on commit 657d855

Please sign in to comment.
Something went wrong with that request. Please try again.