Module: Ziya::HtmlHelpers::Maps

Includes:
Base
Included in:
Maps::Base
Defined in:
lib/ziya/html_helpers/maps.rb

Instance Method Summary collapse

Methods included from Base

#escape_chars, #escape_once, #escape_url, #mime, #plugin_url, #setup_movie_size, #setup_wmode, #tag, #tag_options

Instance Method Details

#_ziya_map(url, swf_file, options) ⇒ Object

generates actual html tags



37
38
39
40
41
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
# File 'lib/ziya/html_helpers/maps.rb', line 37

def _ziya_map( url, swf_file, options )    
  # Setup options for opaque mode
  setup_wmode( options )      

  # setup width and height
  setup_movie_size( options )

  color_param  = tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
  color_param += tag( 'param', {:name  => "wmode", :value => options[:wmode]}, true )

  xml_swf_path = gen_sw_path( options[:swf_path], swf_file, url )
  xml_swf_path << "&amp;timestamp=#{Time.now.to_i}" if options[:cache]
      
  tags = <<-TAGS
  <object codebase="#{options[:codebase]}" classid="#{options[:class_id]}" id="#{options[:id]}" height="#{options[:height]}" width="#{options[:width]}">
    <param name="align"             value="#{options[:align]}"/>            
    <param name="Flashvars"         value="lcId=#{options[:id]}"/>      
    <param name="bgcolor"           value="#{options[:bgcolor]}"/>
    <param name="wmode"             value="#{options[:wmode]}"/>                                  
    <param name="movie"             value="#{xml_swf_path}"/>
    <param name="quality"           value="#{options[:quality]}"/>
    <embed scale="noscale" 
      flashvars         = "lcId=#{options[:id]}" 
      bgcolor           = "#{options[:bgcolor]}" 
      src               = "#{xml_swf_path}" 
      name              = "#{options[:id]}" 
      pluginspage       = "#{plugin_url}" 
      quality           = "high" 
      type              = "#{mime}" 
      wmode             = "#{options[:wmode]}" 
      align             = "#{options[:align]}" 
      height            = "#{options[:height]}" 
      width             = "#{options[:width]}"/>            
   </object>
  TAGS
      
end

#default_map_optionsObject

default options



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ziya/html_helpers/maps.rb', line 8

def default_map_options
  { 
    :width          => "400",
    :height         => "300",
    :map_type       => :world,
    :id             => "ziya_map",
    :code_base      => "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0",
    :align          => "top",
    :quality        => "high",
    :wmode          => "opaque",   
    :class_id       => "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
    :swf_path       => "/maps/map_library",
    :use_cache      => false
  }
end

#gen_sw_path(path, swf_file, url) ⇒ Object

generates swf path



25
26
27
28
# File 'lib/ziya/html_helpers/maps.rb', line 25

def gen_sw_path( path, swf_file, url )
  path_directive = "#{path}/%s?data_file=%s"
  path_directive % [swf_file, escape_url( url )]
end

#maps_swfObject



5
# File 'lib/ziya/html_helpers/maps.rb', line 5

def maps_swf()         "#{maps_swf_base}?data_file=%s"; end

#maps_swf_baseObject



4
# File 'lib/ziya/html_helpers/maps.rb', line 4

def maps_swf_base()    "/maps"; end

#ziya_map(url, map_options = {}) ⇒ Object

generates necessary tags for map support



31
32
33
34
# File 'lib/ziya/html_helpers/maps.rb', line 31

def ziya_map( url, map_options={} )
  options = default_map_options.merge( map_options )    
  _ziya_map( url, "#{options[:map_type]}.swf", options )
end