7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/helpers/swfobject_helper.rb', line 7
def swf_tag(name, options = {})
width = height = nil
if options[:size]
width, height = options[:size].split("x")
else
width = options.delete(:width)
height = options.delete(:height)
end
if options[:flashvars]
flashvars = {}
options[:flashvars].each_pair do |k, v|
flashvars[CGI.escape(k.to_s)] = CGI.escape(v.to_s)
end
else
flashvars = options[:flashvars]
end
code = "swfobject.embedSWF('%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s);" % [
swf_path("#{name}.swf"),
options[:dom_id] || name,
width,
height,
options[:version] || "9.0.0",
swf_path("expressInstall.swf"),
flashvars.to_json,
options[:params].to_json,
options[:attributes].to_json,
options[:callback] ? options[:callback] : "null",
]
javascript_tag(code)
end
|