Permalink
Browse files

Added support for custom viewport attributes.

  • Loading branch information...
1 parent 0245a58 commit 4e31d51d70f1732a69c54c1df15b6481f1d652ae Anton Lindqvist committed Aug 30, 2010
Showing with 8 additions and 3 deletions.
  1. +3 −2 lib/iphone_helpers.rb
  2. +5 −1 test/iphone_helpers_test.rb
View
@@ -36,8 +36,9 @@ def iphone_status_bar(options)
end
def iphone_viewport(options)
- options[:name] = 'viewport'
- options[:content] = 'width=device-width; initial-scale=1.0; maximum-scale=1.0;'
+ defaults = {'initial-scale' => 1.0, 'maximum-scale' => 1.0, 'width' => 'device-width'}.to_options!
+ content = defaults.merge(options).collect { |k,v| "#{k}=#{v}" }.join('; ')
+ options = {:content => content, :name => 'viewport'}
[:meta, options]
end
end
@@ -32,6 +32,10 @@ class IphoneHelpersTest < ActionView::TestCase
end
test 'viewport' do
- assert_equal iphone(:viewport), '<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" name="viewport" />'
+ assert_equal iphone(:viewport), '<meta content="initial-scale=1.0; width=device-width; maximum-scale=1.0" name="viewport" />'
+ end
+
+ test 'viewport with custom width and height' do
+ assert_equal iphone(:viewport, :width => 320, :height => 480), '<meta content="initial-scale=1.0; width=320; height=480; maximum-scale=1.0" name="viewport" />'
end
end

0 comments on commit 4e31d51

Please sign in to comment.