# Author:: Davide D'Agostino aka DAddYE # WebSite:: http://www.lipsiasoft.com require 'action_view' module ActionView #:nodoc: module Helpers # :nodoc: module FlashObjectHelper # :nodoc: def self.included(base) base.class_eval do include InstanceMethods end end module InstanceMethods # Returns a set of tags that display a Flash object within an # HTML page. # # Options: # * :div_id - the HTML +id+ of the +div+ element that is used to contain the Flash object; default "flashcontent" # * :flash_id - the +id+ of the Flash object itself. # * :background_color - the background color of the Flash object; default white # * :flash_version - the version of the Flash player that is required; default "7" # * :size - the size of the Flash object, in the form "100x100". Defaults to "100%x100%" # * :variables - a Hash of initialization variables that are passed to the object; default {:lzproxied => false} # * :parameters - a Hash of parameters that configure the display of the object; default {:scale => 'noscale'} # * :fallback_html - HTML text that is displayed when the Flash player is not available. # # The following options are for developers. They default to true in # development mode, and false otherwise. # * :check_for_javascript_include - if true, the return value will cause the browser to display a diagnostic message if the FlashObject JavaScript was not included. # * :verify_file_exists - if true, the return value will cause the browser to display a diagnostic message if the Flash object does not exist. # # (This method is called flashobject_tag instead of flashobject_tag # because it returns a *sequence* of HTML tags: a +div+, followed by # a +script+.) def flashobject_tag source, options={} verify_file_exists = options.fetch(:verify_file_exists, ENV['RAILS_ENV'] == 'development') if verify_file_exists and not File.exists? File.join(RAILS_ROOT, 'public', source) return "
#{File.join('public', source)} does not exist. Did you forget to execute rake applets?Requires the Flash plugin. If the plugin is already installed, click here.
} if options.fetch(:check_for_javascript_include, ENV['RAILS_ENV'] == 'development') check_for_javascript ="if (typeof FlashObject == 'undefined') document.getElementById('#{div_id}').innerHTML = 'Warning: FlashObject is undefined. Did you forget to execute rake update_javascripts, or to include <%= javascript_include_tag :defaults %> in your view file?';" end return <<-"EOF"