Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for visual effects scoped queues to the visual_effect h…

…elper #3530 [Abdur-Rahman Advany]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3687 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit d0bd952aff3f42ed95eed701916bbdf9e6f01cca 1 parent abe5b15
@madrobby madrobby authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added support for visual effects scoped queues to the visual_effect helper #3530 [Abdur-Rahman Advany]
+
* Added .rxml (and any non-rhtml template, really) supportfor CaptureHelper#content_for and CaptureHelper#capture #3287 [Brian Takita]
* Added script.aculo.us drag and drop helpers to RJS [Thomas Fuchs]. Examples:
View
7 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
@@ -43,7 +43,12 @@ module ScriptaculousHelper
# http://script.aculo.us for more documentation.
def visual_effect(name, element_id = false, js_options = {})
element = element_id ? "'#{element_id}'" : "element"
- js_options[:queue] = "'#{js_options[:queue]}'" if js_options[:queue]
+
+ js_options[:queue] = if js_options[:queue].is_a?(Hash)
+ '{' + js_options[:queue].map {|k, v| k == :limit ? "#{k}:#{v}" : "#{k}:'#{v}'" }.join(',') + '}'
+ elsif js_options[:queue]
+ "'#{js_options[:queue]}'"
+ end if js_options[:queue]
if TOGGLE_EFFECTS.include? name.to_sym
"Effect.toggle(#{element},'#{name.to_s.gsub(/^toggle_/,'')}',#{options_for_javascript(js_options)});"
View
6 actionpack/test/template/scriptaculous_helper_test.rb
@@ -28,6 +28,12 @@ def test_effect
assert_equal "new Effect.Fade('fademe',{duration:4.0});", visual_effect(:fade, "fademe", :duration => 4.0)
assert_equal "new Effect.Shake(element,{});", visual_effect(:shake)
assert_equal "new Effect.DropOut('dropme',{queue:'end'});", visual_effect(:drop_out, 'dropme', :queue => :end)
+ assert_equal "new Effect.DropOut('dropme',{queue:{scope:'test',limit:2,position:'end'}});",
+ visual_effect(:drop_out, 'dropme', :queue => {:position => "end", :scope => "test", :limit => 2})
+ assert_equal "new Effect.DropOut('dropme',{queue:{scope:'list',limit:2}});",
+ visual_effect(:drop_out, 'dropme', :queue => {:scope => :list, :limit => 2})
+ assert_equal "new Effect.DropOut('dropme',{queue:{scope:'test',limit:2,position:'end'}});",
+ visual_effect(:drop_out, 'dropme', :queue => {:position => :end, :scope => :test, :limit => 2})
end
def test_toggle_effects
Please sign in to comment.
Something went wrong with that request. Please try again.