aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
diff options
context:
space:
mode:
authorThomas Fuchs <thomas@fesch.at>2006-02-26 14:20:21 +0000
committerThomas Fuchs <thomas@fesch.at>2006-02-26 14:20:21 +0000
commitd11f8d551640c94e22c221c3bee39ab572b1dc72 (patch)
tree731a29bbd880d42dc1c169779d0a7fa9a37cd93f /actionpack/lib/action_view/helpers/scriptaculous_helper.rb
parent6a83ebfe703e922c4b0e2333521ed23208003f13 (diff)
downloadrails-d11f8d551640c94e22c221c3bee39ab572b1dc72.tar.gz
rails-d11f8d551640c94e22c221c3bee39ab572b1dc72.tar.bz2
rails-d11f8d551640c94e22c221c3bee39ab572b1dc72.zip
Added script.aculo.us drag and drop helpers to RJS [Thomas Fuchs]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3667 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/scriptaculous_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/scriptaculous_helper.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
index e64966d919..5498ae1cd9 100644
--- a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
+++ b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb
@@ -67,6 +67,10 @@ module ActionView
# You can change the behaviour with various options, see
# http://script.aculo.us for more documentation.
def sortable_element(element_id, options = {})
+ javascript_tag(sortable_element_js(element_id, options).chop!)
+ end
+
+ def sortable_element_js(element_id, options = {}) #:nodoc:
options[:with] ||= "Sortable.serialize('#{element_id}')"
options[:onUpdate] ||= "function(){" + remote_function(options) + "}"
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
@@ -78,7 +82,7 @@ module ActionView
options[:containment] = array_or_string_for_javascript(options[:containment]) if options[:containment]
options[:only] = array_or_string_for_javascript(options[:only]) if options[:only]
- javascript_tag("Sortable.create('#{element_id}', #{options_for_javascript(options)})")
+ %(Sortable.create('#{element_id}', #{options_for_javascript(options)});)
end
# Makes the element with the DOM ID specified by +element_id+ draggable.
@@ -87,9 +91,13 @@ module ActionView
# <%= draggable_element("my_image", :revert => true)
#
# You can change the behaviour with various options, see
- # http://script.aculo.us for more documentation.
+ # http://script.aculo.us for more documentation.
def draggable_element(element_id, options = {})
- javascript_tag("new Draggable('#{element_id}', #{options_for_javascript(options)})")
+ javascript_tag(draggable_element_js(element_id, options).chop!)
+ end
+
+ def draggable_element_js(element_id, options = {}) #:nodoc:
+ %(new Draggable('#{element_id}', #{options_for_javascript(options)});)
end
# Makes the element with the DOM ID specified by +element_id+ receive
@@ -104,14 +112,18 @@ module ActionView
# You can change the behaviour with various options, see
# http://script.aculo.us for more documentation.
def drop_receiving_element(element_id, options = {})
+ javascript_tag(drop_receiving_element_js(element_id, options).chop!)
+ end
+
+ def drop_receiving_element_js(element_id, options = {}) #:nodoc:
options[:with] ||= "'id=' + encodeURIComponent(element.id)"
options[:onDrop] ||= "function(element){" + remote_function(options) + "}"
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
-
+
options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept]
options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
-
- javascript_tag("Droppables.add('#{element_id}', #{options_for_javascript(options)})")
+
+ %(Droppables.add('#{element_id}', #{options_for_javascript(options)});)
end
end
end