diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-01-30 16:13:49 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-30 16:13:49 -0600 |
commit | 657d85580e914caf368a8a12ff5642e4d979ab7e (patch) | |
tree | e5273a885b0d93c0cfda24bb7584a6ffb335deb9 /actionpack/lib/action_view/helpers | |
parent | 570e02c96a12ad06888b4ba8d6d8bd3262705dcf (diff) | |
download | rails-657d85580e914caf368a8a12ff5642e4d979ab7e.tar.gz rails-657d85580e914caf368a8a12ff5642e4d979ab7e.tar.bz2 rails-657d85580e914caf368a8a12ff5642e4d979ab7e.zip |
Reorg options_for_javascript and array_or_string_for_javascript
Diffstat (limited to 'actionpack/lib/action_view/helpers')
3 files changed, 17 insertions, 17 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 19243f092a..7dca9849c0 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -95,23 +95,6 @@ module ActionView 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 diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 4a32875e00..d335d89274 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -624,6 +624,14 @@ module ActionView 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) diff --git a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb index 189c14c97a..37319cca1b 100644 --- a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +++ b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb @@ -216,6 +216,15 @@ module ActionView %(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 |