Module: Ziya::HtmlHelpers::Charts
- Includes:
- Base
- Included in:
- Charts::Base, Charts::Support::Draw, YamlHelpers::Charts
- Defined in:
- lib/ziya/html_helpers/charts.rb
Overview
Generates necessary html flash tag to support ZiYa
TODO – Rewrite to use content tag block instead…
Author: Fernand Galiana
Instance Method Summary collapse
-
#_ziya_chart(url, swf_path, swf_file, options) ⇒ Object
generated the object and embed tag necessary for the flash movie.
- #chart_path ⇒ Object
- #charts_swf ⇒ Object
- #charts_swf_base ⇒ Object
- #class_id ⇒ Object
- #codebase ⇒ Object
-
#composite_base_url ⇒ Object
Const accessors…
- #composite_url ⇒ Object
- #default_chart_options ⇒ Object
-
#gen_composite_path(swf_chart_dir, url, chart_id = null) ⇒ Object
genereates composite chart urls.
-
#gen_swf_path(path_directive, swf_dir, url) ⇒ Object
generates swf path.
-
#ziya_chart(url, chart_options = {}) ⇒ Object
generates neccessary html tags to display a chart.
-
#ziya_chart_js(url, chart_options = {}) ⇒ Object
generates necessary object and embed tags to display a flash movie on various browsers using javascript.
-
#ziya_javascript_include_tag(opts = {}) ⇒ Object
generates a javascript tag to include the js script to create object and embed tags.
Methods included from Base
#escape_chars, #escape_once, #escape_url, #mime, #plugin_url, #setup_movie_size, #setup_wmode, #tag_options, #ziya_tag
Instance Method Details
#_ziya_chart(url, swf_path, swf_file, options) ⇒ Object
generated the object and embed tag necessary for the flash movie
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/ziya/html_helpers/charts.rb', line 152 def _ziya_chart( url, swf_path, swf_file, ) # Setup options for opaque mode setup_wmode( ) # setup width and height setup_movie_size( ) color_param = ziya_tag( 'param', {:name => 'bgcolor', :value => [:bgcolor]}, true ) color_param += ziya_tag( 'param', {:name => "wmode", :value => [:wmode]}, true ) xml_swf_path = gen_swf_path( swf_path, [:swf_path], url ) xml_swf_path << "&timestamp=#{Time.now.to_i}" if [:cache] == false xml_swf_path << "&timeout=#{[:timeout]}" if [:timeout] xml_swf_path << "&stage_width=#{[:width]}&stage_height=#{[:height]}" if [:use_stage] == true = <<-TAGS <object codebase="#{codebase}" classid="#{class_id}" id="#{[:id]}" height="#{[:height]}" width="#{[:width]}"> <param name="scale" value="noscale"/> <param name="salign" value="#{[:salign]}"/> <param name="bgcolor" value="#{[:bgcolor]}"/> <param name="wmode" value="#{[:wmode]}"/> <param name="movie" value="#{[:asset_url]}/#{swf_file}"/> <param name="Flashvars" value="#{xml_swf_path}&chart_id=#{[:id]}"/> <param name="menu" value="true"/> <param name="allowFullScreen" value="true"/> <param name="allowScriptAccess" value="#{[:script_access]}"/> <param name="quality" value="high"/> <param name="play" value="true"/> <param name="devicefont" value="false"/> <embed scale="noscale" allowfullscreen = "true" allowscriptaccess = "#{[:script_access]}" bgcolor = "#{[:bgcolor]}" devicefont = "false" flashvars = "#{xml_swf_path}&chart_id=#{[:id]}" menu = "true" name = "#{[:id]}" play = "true" pluginspage = "#{plugin_url}" quality = "high" salign = "#{[:salign]}" src = "#{[:asset_url]}/#{swf_file}" type = "#{mime}" wmode = "#{[:wmode]}" align = "#{[:align]}" height = "#{[:height]}" width = "#{[:width]}"/> </object> TAGS end |
#chart_path ⇒ Object
142 |
# File 'lib/ziya/html_helpers/charts.rb', line 142 def chart_path() "/charts"; end |
#charts_swf ⇒ Object
141 |
# File 'lib/ziya/html_helpers/charts.rb', line 141 def charts_swf() "#{charts_swf_base}&xml_source=%s"; end |
#charts_swf_base ⇒ Object
140 |
# File 'lib/ziya/html_helpers/charts.rb', line 140 def charts_swf_base() "library_path=%s/charts_library"; end |
#class_id ⇒ Object
143 |
# File 'lib/ziya/html_helpers/charts.rb', line 143 def class_id() "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" end |
#codebase ⇒ Object
144 |
# File 'lib/ziya/html_helpers/charts.rb', line 144 def codebase() "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2"; end |
#composite_base_url ⇒ Object
Const accessors…
138 |
# File 'lib/ziya/html_helpers/charts.rb', line 138 def composite_base_url() "%s/charts.swf?library_path=%s/charts_library" end |
#composite_url ⇒ Object
139 |
# File 'lib/ziya/html_helpers/charts.rb', line 139 def composite_url() "#{composite_base_url}&xml_source=%s" end |
#default_chart_options ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ziya/html_helpers/charts.rb', line 32 def { :width => "400", :height => "300", :bgcolor => "ffffff", :wmode => "opaque", :menu => true, :full_screen => true, :align => "l", :salign => "tl", :scale => "noscale", :use_cache => false, :timeout => nil, :retry => 2, :use_stage => false, :id => "ziya_chart", :swf_path => chart_path, :asset_url => chart_path } end |
#gen_composite_path(swf_chart_dir, url, chart_id = null) ⇒ Object
genereates composite chart urls
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ziya/html_helpers/charts.rb', line 123 def gen_composite_path( swf_chart_dir, url, chart_id=null ) buff = "" if url buff = composite_url % [swf_chart_dir, swf_chart_dir, escape_url( url )] else buff = composite_base_url % [swf_chart_dir, "/charts" ] end buff << "&chart_id=#{chart_id}" if chart_id buff end |
#gen_swf_path(path_directive, swf_dir, url) ⇒ Object
generates swf path
147 148 149 |
# File 'lib/ziya/html_helpers/charts.rb', line 147 def gen_swf_path( path_directive, swf_dir, url ) path_directive % [swf_dir, escape_url( url )] end |
#ziya_chart(url, chart_options = {}) ⇒ Object
generates neccessary html tags to display a chart.
113 114 115 116 117 118 119 120 |
# File 'lib/ziya/html_helpers/charts.rb', line 113 def ziya_chart( url, = {} ) = .merge( ) flash_vars = url ? charts_swf : charts_swf_base buff = _ziya_chart( url, flash_vars, "charts.swf", ) (respond_to? :raw) ? raw( buff ) : buff end |
#ziya_chart_js(url, chart_options = {}) ⇒ Object
generates necessary object and embed tags to display a flash movie on various browsers using javascript
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ziya/html_helpers/charts.rb', line 55 def ziya_chart_js( url, ={} ) = .merge( ) # Setup options for opaque mode setup_wmode( ) # setup width and height setup_movie_size( ) flash_vars = url ? charts_swf : charts_swf_base xml_swf_path = flash_vars % [[:swf_path], escape_url(url)] xml_swf_path << "&chart_id=#{[:id]}" xml_swf_path << "×tamp=#{Time.now.to_i}" if [:cache] == false xml_swf_path << "&timeout=#{[:timeout]}&retry=#{[:retry]}" if [:timeout] xml_swf_path << "&stage_width=#{[:width]}&stage_height=#{[:height]}" if [:use_stage] == true js = <<-JS <script language="javascript" type="text/javascript"> if (AC_FL_RunContent == 0 || DetectFlashVer == 0) { alert( "This page requires AC_RunActiveContent.js." ); } else { var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); if( hasRightVersion ) { AC_FL_RunContent( 'codebase' , 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2', 'width' , '#{[:width]}', 'height' , '#{[:height]}', 'scale' , '#{[:scale]}', 'salign' , '#{[:salign]}', 'bgcolor' , '#{[:bgcolor]}', 'wmode' , '#{[:wmode]}', 'movie' , '#{[:swf_path]}/charts', 'src' , '#{[:swf_path]}/charts', 'FlashVars' , '#{xml_swf_path}', 'id' , '#{[:id]}', 'name' , '#{[:id]}', 'menu' , '#{[:]}', 'allowFullScreen' , '#{[:full_screen]}', 'allowScriptAccess','sameDomain', 'quality' , 'high', 'align' , '#{[:align]}', 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer', 'play' , 'true', 'devicefont' , 'false' ); } else { var alternateContent = 'This content requires the Adobe Flash Player. ' + '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.'; document.write(alternateContent); } } </script> JS end |
#ziya_javascript_include_tag(opts = {}) ⇒ Object
generates a javascript tag to include the js script to create object and embed tags
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ziya/html_helpers/charts.rb', line 12 def ziya_javascript_include_tag( opts={} ) = { :swf_path => chart_path, :major_vers => 9, :minor_vers => 0, :req_vers => 45 }.merge!( opts ) js = <<-JS <script language="javascript" type="text/javascript"> AC_FL_RunContent = 0; DetectFlashVer = 0; </script> <script src="#{[:swf_path]}/AC_RunActiveContent.js" language="javascript"></script> <script language="javascript" type="text/javascript"> var requiredMajorVersion = #{[:major_vers]}; var requiredMinorVersion = #{[:minor_vers]}; var requiredRevision = #{[:req_vers]}; </script> JS end |