adding swfobject embedding
This commit is contained in:
parent
79b5706eda
commit
dd8541c232
@ -1,10 +1,13 @@
|
||||
module Zoomifier
|
||||
module ViewHelpers
|
||||
def zoomify_image_tag(source, options = {})
|
||||
raise ArgumentError unless options[:id]
|
||||
content_tag :div, { :id => options[:id] } do
|
||||
raise ArgumentError unless [:id, :width, :height].all? {|o| options[o] }
|
||||
s = content_tag :div, { :id => options[:id] } do
|
||||
image_tag source, options.merge({ :id => nil })
|
||||
end
|
||||
zoomify_path = image_path(source).gsub(/\.[^.]+$/, '')
|
||||
s += javascript_tag "swfobject.embedSWF('/swf/zoomifyViewer.swf', '#{options[:id]}', '#{options[:width]}', '#{options[:height]}', '9.0.0', false, { zoomifyImagePath: '#{zoomify_path}/' });"
|
||||
s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,10 @@ describe Zoomifier::ViewHelpers do
|
||||
end
|
||||
|
||||
it "should generate the zoomify markup" do
|
||||
@view.zoomify_image_tag('foo.jpg', { :id => 'foo', :alt => 'Foo Bar' }).should ==
|
||||
'<div id="foo"><img alt="Foo Bar" src="/images/foo.jpg" /></div>'
|
||||
@view.zoomify_image_tag('foo.jpg', { :id => 'foo', :alt => 'Foo Bar', :width => 800, :height => 500 }).should ==
|
||||
'<div id="foo"><img alt="Foo Bar" height="500" src="/images/foo.jpg" width="800" /></div>' +
|
||||
"<script type=\"text/javascript\">\n//<![CDATA[\n" +
|
||||
"swfobject.embedSWF('/swf/zoomifyViewer.swf', 'foo', '800', '500', '9.0.0', false, { zoomifyImagePath: '/images/foo/' });\n//]]>\n" +
|
||||
'</script>'
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user