| Module | ActionView::Helpers::FlexObjectHelper::InstanceMethods |
| In: |
lib/flexobject_view_helper.rb
|
Returns a path to a Flash object. The src can be supplied as:
# File lib/flexobject_view_helper.rb, line 22
22: def flexobject_path source
23: compute_public_path source, File.join('swfs', FlexScaffold::Config.plugin_name), 'swf'
24: end
Returns a set of tags that display a Flash object within an HTML page.
Options:
The following options are for developers. They default to true in development mode, and false otherwise.
(This method is called flexobject_tags instead of flashobject_tag because it returns a sequence of HTML tags: a div, followed by a script.)
It is also renamed to flex rather than the original flash so that there are not naming clashes if you use openLaszlo at the same time.
# File lib/flexobject_view_helper.rb, line 50
50: def flexobject_tags source, options={}
51: path = flexobject_path source
52: #TODO check why RAILS_ROOT is not absolute
53: #verify_file_exists = options.fetch(:verify_file_exists, ENV['RAILS_ENV'] == 'development')
54: #if verify_file_exists and not File.exists?(File.join(RAILS_ROOT, 'public', path))
55: # return "<div><strong>Warning:</strong> The file <code>#{File.join('public', path)}</code> does not exist. Did you forget to execute <tt>rake flex:compile</tt>?</div>"
56: #end
57: div_id = options[:div_id] || 'flashcontent'
58: flash_id = options[:flash_id] || File.basename(source, '.swf')
59: width, height = (options[:size]||'100%x100%').scan(/^(\d*%?)x(\d*%?)$/).first
60: background_color = options[:background_color] || '#ffffff'
61: flash_version = options[:flash_version] || "7.0.0"
62: variables = options.fetch(:variables, {:lzproxied => false})
63: parameters = options.fetch(:parameters, {:scale => 'noscale'})
64: fallback_html = options[:fallback_html] || %q{<p>Requires the Flash plugin. If the plugin is already installed, click <a href="?detectflash=false">here</a>.</p>}
65: if options.fetch(:check_for_javascript_include, ENV['RAILS_ENV'] == 'development')
66: check_for_javascript ="if (typeof FlashObject == 'undefined') document.getElementById('#{div_id}').innerHTML = '<strong>Warning:</strong> FlashObject is undefined. Did you forget to execute <tt>rake update_javascripts</tt>, or to include <tt><%= javascript_include_tag :defaults %></tt> in your view file?';"
67: end
68: return "<div id=\"\#{div_id}\" style=\"height:\#{height}; width:\#{width}\">\n\#{fallback_html}\n</div>\n<script type=\"text/javascript\">//<![CDATA[\n\#{check_for_javascript}\nvar fo = new FlashObject(\"\#{path}\", \"\#{flash_id}\", \"\#{width}\", \"\#{height}\", \"\#{flash_version}\", \"\#{background_color}\");\n\#{parameters.map{|k,v|%Q[fo.addVariable(\"\#{k}\", \"\#{v}\");]}.join(\"\\n\")}\n\#{variables.map{|k,v|%Q[fo.addVariable(\"\#{k}\", \"\#{v}\");]}.join(\"\\n\")}\nfo.write(\"\#{div_id}\");\n//]]>\n</script>\n"
69: end
Returns a set of tags that display a Flash object within an HTML page. Defaults to v9.0.0
Options:
Example output:
<script language="JavaScript" type="text/javascript"> <!-- // ----------------------------------------------------------------------------- // Globals // Major version of Flash required var requiredMajorVersion = 9; // Minor version of Flash required var requiredMinorVersion = 0; // Minor version of Flash required var requiredRevision = 0; // ----------------------------------------------------------------------------- // --> </script>
# File lib/flexobject_view_helper.rb, line 108
108: def flexobject_version options={}
109:
110: major = options[:major] || 9
111: minor = options[:minor] || 0
112: revision = options[:revision] || 0
113:
114: return "<script language=\"JavaScript\" type=\"text/javascript\">//<![CDATA[\nvar requiredMajorVersion = \#{major};\nvar requiredMinorVersion = \#{minor};\nvar requiredRevision = \#{revision};\n//]]>\n</script>\n"
115: end