Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support to AssetTagHelper#javascript_include_tag for having :de…

…faults appear anywhere in the list, so you can now make one call ala javascript_include_tag(:defaults, "my_scripts") or javascript_include_tag("my_scripts", :defaults) depending on how you want the load order (closes #3506) [Bob Silva]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3696 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit fed41fbe8b79725904437230ac9e7abfb53df651 1 parent b56cac5
David Heinemeier Hansson dhh authored
2  actionpack/CHANGELOG
View
@@ -1,5 +1,7 @@
*SVN*
+* Added support to AssetTagHelper#javascript_include_tag for having :defaults appear anywhere in the list, so you can now make one call ala javascript_include_tag(:defaults, "my_scripts") or javascript_include_tag("my_scripts", :defaults) depending on how you want the load order #3506 [Bob Silva]
+
* 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]
9 actionpack/lib/action_view/helpers/asset_tag_helper.rb
View
@@ -59,11 +59,10 @@ def javascript_path(source)
# <tt>controllers/application.rb</tt> and <tt>helpers/application_helper.rb</tt>.
def javascript_include_tag(*sources)
options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
- if sources.first == :defaults
- sources = @@javascript_default_sources.dup
- if defined?(RAILS_ROOT) and File.exists?("#{RAILS_ROOT}/public/javascripts/application.js")
- sources << 'application'
- end
+ if sources.include?(:defaults)
+ sources = sources[0..(sources.index(:defaults))] + @@javascript_default_sources.dup + sources[(sources.index(:defaults) + 1)..sources.length]
+ sources.delete(:defaults)
+ sources << "application" if defined?(RAILS_ROOT) and File.exists?("#{RAILS_ROOT}/public/javascripts/application.js")
end
sources.collect { |source|
source = javascript_path(source)
6 actionpack/test/template/asset_tag_helper_test.rb
View
@@ -49,7 +49,9 @@ def relative_url_root
%(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>),
%(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>),
%(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>),
- %(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>)
+ %(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>),
+ %(javascript_include_tag(:defaults, "test")) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/test.js" type="text/javascript"></script>),
+ %(javascript_include_tag("test", :defaults)) => %(<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>)
}
StylePathToTag = {
@@ -95,7 +97,7 @@ def test_register_javascript_include_default
ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2'
assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
end
-
+
def test_style_path
StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
end
6 actionpack/test/template/scriptaculous_helper_test.rb
View
@@ -28,11 +28,11 @@ 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'}});",
+ assert_equal "new Effect.DropOut('dropme',{queue:{limit:2,scope:'test',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}});",
+ assert_equal "new Effect.DropOut('dropme',{queue:{limit:2,scope:'list'}});",
visual_effect(:drop_out, 'dropme', :queue => {:scope => :list, :limit => 2})
- assert_equal "new Effect.DropOut('dropme',{queue:{scope:'test',limit:2,position:'end'}});",
+ assert_equal "new Effect.DropOut('dropme',{queue:{limit:2,scope:'test',position:'end'}});",
visual_effect(:drop_out, 'dropme', :queue => {:position => :end, :scope => :test, :limit => 2})
end
Please sign in to comment.
Something went wrong with that request. Please try again.