From dd8541c232a12ffeec7e11c1d3954c3b3ff77670 Mon Sep 17 00:00:00 2001 From: Donald Ball Date: Mon, 24 Nov 2008 02:18:49 -0600 Subject: [PATCH] adding swfobject embedding --- lib/zoomifier_helper.rb | 7 +++++-- spec/zoomifier_helper_spec.rb | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/zoomifier_helper.rb b/lib/zoomifier_helper.rb index acdeefd..6cb94ab 100644 --- a/lib/zoomifier_helper.rb +++ b/lib/zoomifier_helper.rb @@ -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 diff --git a/spec/zoomifier_helper_spec.rb b/spec/zoomifier_helper_spec.rb index 9df9bd6..1ae8a41 100644 --- a/spec/zoomifier_helper_spec.rb +++ b/spec/zoomifier_helper_spec.rb @@ -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 == - '
Foo Bar
' + @view.zoomify_image_tag('foo.jpg', { :id => 'foo', :alt => 'Foo Bar', :width => 800, :height => 500 }).should == + '
Foo Bar
' + + "' end end