2008-11-22 00:05:53 +00:00
|
|
|
module Zoomifier
|
|
|
|
module ViewHelpers
|
2008-11-24 04:41:10 +00:00
|
|
|
def zoomify_image_tag(source, options = {})
|
2008-11-24 08:18:49 +00:00
|
|
|
raise ArgumentError unless [:id, :width, :height].all? {|o| options[o] }
|
2008-11-25 04:18:47 +00:00
|
|
|
if File.file?(path = RAILS_ROOT + '/public/images/' + source)
|
|
|
|
Zoomifier::zoomify(path)
|
|
|
|
end
|
2008-11-24 08:18:49 +00:00
|
|
|
s = content_tag :div, { :id => options[:id] } do
|
2008-11-24 04:54:53 +00:00
|
|
|
image_tag source, options.merge({ :id => nil })
|
|
|
|
end
|
2008-11-24 08:18:49 +00:00
|
|
|
zoomify_path = image_path(source).gsub(/\.[^.]+$/, '')
|
2008-11-25 04:18:47 +00:00
|
|
|
s += javascript_tag "swfobject.embedSWF('/swfs/zoomifyViewer.swf', '#{options[:id]}', '#{options[:width]}', '#{options[:height]}', '9.0.0', false, { zoomifyImagePath: '#{zoomify_path}/' });"
|
2008-11-24 08:18:49 +00:00
|
|
|
s
|
2008-11-22 00:05:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|