Module: Ziya::HtmlHelpers::Gauges

Includes:
Base
Included in:
Gauges::Base
Defined in:
lib/ziya/html_helpers/gauges.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

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_gauge(url, swf_path, options) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
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
# File 'lib/ziya/html_helpers/gauges.rb', line 42

def _ziya_gauge( url, swf_path, options )
  # Setup options for opaque mode
  setup_wmode( options )      
  
  # setup width and height
  setup_movie_size( options )
  
  color_param  = ziya_tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
  color_param += ziya_tag( 'param', {:name  => "wmode", :value => options[:wmode]}, true )

  xml_swf_path = swf_path % [options[:swf_path], url]
  xml_swf_path << "&amp;timestamp=#{Time.now.to_i}" if options[:use_cache] == true
  xml_swf_path << "&amp;timeout=#{options[:timeout]}&amp;retry=#{options[:retry]}" if options[:timeout]
  xml_swf_path << "&amp;stage_width=#{options[:width]}&amp;stage_height=#{options[:height]}" if options[:use_stage] == true
  tags = <<-TAGS
    <object codebase="#{codebase}" classid="#{options[:class_id]}" id="#{options[:id]}" height="#{options[:height]}" width="#{options[:width]}">
      <param name="scale" value="noscale"/>
      <param name="align" value="#{options[:align]}"/>            
      <param name="bgcolor" value="#{options[:bgcolor]}"/>
      <param name="wmode" value="#{options[:wmode]}"/>                                  
      <param name="movie" value="#{xml_swf_path}"/>
      <param name="menu" value="true"/>
      <param name="allowFullScreen" value="true"/>
      <param name="allowScriptAccess" value="#{options[:script_access]}"/>            
      <param name="quality" value="high"/>
      <param name="play" value="true"/>                        
      <param name="devicefont" value="false"/>
      <embed scale="noscale"
        allowfullscreen="true" 
        allowscriptaccess="#{options[:script_access]}" 
        bgcolor="#{options[:bgcolor]}" 
        devicefont="false" 
        src="#{xml_swf_path}" 
        menu="true" 
        name="#{options[:id]}" 
        play="true" 
        pluginspage="#{plugin_url}" 
        quality="high" 
        salign="#{options[:salign]}" 
        src="#{xml_swf_path}" 
        type="#{mime}" 
        wmode="#{options[:wmode]}" 
        salign="#{options[:salign]}" 
        height="#{options[:height]}" 
        width="#{options[:width]}">
   </object>        
  TAGS
end

#class_idObject



22
# File 'lib/ziya/html_helpers/gauges.rb', line 22

def class_id()           "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" end

#codebaseObject



23
# File 'lib/ziya/html_helpers/gauges.rb', line 23

def codebase()           "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0"; end

#default_gauge_optionsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ziya/html_helpers/gauges.rb', line 25

def default_gauge_options
  { :width          => "200",
    :height         => "200",
    :align          => "middle",
    :scale          => "noscale",
    :script_access  => "sameDomain",
    :salign         => "",
    :class          => "",   
    :class_id       => "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",    
    :id             => "ziya_gauge",
    :swf_path       => gauge_path,
    :use_cache      => false,
    :timeout        => 30,
    :retry          => 2,
    :use_stage      => false }    
end

#gauge_pathObject



21
# File 'lib/ziya/html_helpers/gauges.rb', line 21

def gauge_path()         "/gauges"; end

#gauges_swfObject

Const accessors…



20
# File 'lib/ziya/html_helpers/gauges.rb', line 20

def gauges_swf()         "%s/gauge.swf?xml_source=%s"; end

#ziya_gauge(url, gauge_options = {}) ⇒ Object

generates necessary html tags to display a gauge.



11
12
13
14
# File 'lib/ziya/html_helpers/gauges.rb', line 11

def ziya_gauge( url, gauge_options={} )
  options = default_gauge_options.merge( gauge_options )                    
  _ziya_gauge( url, gauges_swf, options )
end