mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Cleaning up of javascript_helper array options, add :only to sortable_element #1761 [Thomas Fuchs]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1843 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
03d9159025
commit
4dc2dc1402
1 changed files with 13 additions and 16 deletions
|
@ -363,11 +363,7 @@ module ActionView
|
||||||
function << "'#{url_for(options[:url])}'"
|
function << "'#{url_for(options[:url])}'"
|
||||||
|
|
||||||
js_options = {}
|
js_options = {}
|
||||||
if options[:tokens] and options[:tokens].kind_of?(Array)
|
js_options[:tokens] = array_or_string_for_javascript(options[:tokens]) if options[:tokens]
|
||||||
js_options[:tokens] = "['#{options[:tokens].join('\',\'')}']"
|
|
||||||
elsif options[:tokens]
|
|
||||||
js_options[:tokens] = "'#{options[:tokens]}'" if options[:tokens]
|
|
||||||
end
|
|
||||||
js_options[:callback] = "function(element, value) { return #{options[:with]} }" if options[:with]
|
js_options[:callback] = "function(element, value) { return #{options[:with]} }" if options[:with]
|
||||||
js_options[:indicator] = "'#{options[:indicator]}'" if options[:indicator]
|
js_options[:indicator] = "'#{options[:indicator]}'" if options[:indicator]
|
||||||
function << (', ' + options_for_javascript(js_options) + ')')
|
function << (', ' + options_for_javascript(js_options) + ')')
|
||||||
|
@ -453,11 +449,8 @@ module ActionView
|
||||||
options[option] = "'#{options[option]}'" if options[option]
|
options[option] = "'#{options[option]}'" if options[option]
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:containment] and options[:containment].kind_of?(Array)
|
options[:containment] = array_or_string_for_javascript(options[:containment]) if options[:containment]
|
||||||
options[:containment] = "['#{options[:containment].join('\',\'')}']"
|
options[:only] = array_or_string_for_javascript(options[:only]) if options[:only]
|
||||||
elsif options[:containment]
|
|
||||||
options[:containment] = "'#{options[:containment]}'" if options[:containment]
|
|
||||||
end
|
|
||||||
|
|
||||||
javascript_tag("Sortable.create('#{element_id}', #{options_for_javascript(options)})")
|
javascript_tag("Sortable.create('#{element_id}', #{options_for_javascript(options)})")
|
||||||
end
|
end
|
||||||
|
@ -488,12 +481,7 @@ module ActionView
|
||||||
options[:onDrop] ||= "function(element){" + remote_function(options) + "}"
|
options[:onDrop] ||= "function(element){" + remote_function(options) + "}"
|
||||||
options.delete_if { |key, value| AJAX_OPTIONS.include?(key) }
|
options.delete_if { |key, value| AJAX_OPTIONS.include?(key) }
|
||||||
|
|
||||||
if options[:accept] and options[:accept].kind_of?(Array)
|
options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept]
|
||||||
options[:accept] = "['#{options[:accept].join('\',\'')}']"
|
|
||||||
elsif options[:accept]
|
|
||||||
options[:accept] = "'#{options[:accept]}'" if options[:accept]
|
|
||||||
end
|
|
||||||
|
|
||||||
options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
|
options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
|
||||||
|
|
||||||
javascript_tag("Droppables.add('#{element_id}', #{options_for_javascript(options)})")
|
javascript_tag("Droppables.add('#{element_id}', #{options_for_javascript(options)})")
|
||||||
|
@ -515,6 +503,15 @@ module ActionView
|
||||||
'{' + options.map {|k, v| "#{k}:#{v}"}.sort.join(', ') + '}'
|
'{' + options.map {|k, v| "#{k}:#{v}"}.sort.join(', ') + '}'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def array_or_string_for_javascript(option)
|
||||||
|
js_option = if option.kind_of?(Array)
|
||||||
|
"['#{option.join('\',\'')}']"
|
||||||
|
elsif !option.nil?
|
||||||
|
"'#{option}'"
|
||||||
|
end
|
||||||
|
js_option
|
||||||
|
end
|
||||||
|
|
||||||
def options_for_ajax(options)
|
def options_for_ajax(options)
|
||||||
js_options = build_callbacks(options)
|
js_options = build_callbacks(options)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue