Module: HtmlGrid::DojoToolkit::DojoTemplate

Defined in:
lib/htmlgrid/dojotoolkit.rb

Constant Summary collapse

DOJO_DEBUG =
true
DOJO_BACK_BUTTON =
false
DOJO_ENCODING =
nil
DOJO_PARSE_ON_LOAD =
true
DOJO_PREFIX =
[]
DOJO_REQUIRE =
[]

Instance Method Summary collapse

Instance Method Details

#dojo_parse_on_loadObject



120
121
122
# File 'lib/htmlgrid/dojotoolkit.rb', line 120

def dojo_parse_on_load
  self.class::DOJO_PARSE_ON_LOAD
end

#dynamic_html_headers(context) ⇒ Object



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
111
112
113
114
115
116
117
118
119
# File 'lib/htmlgrid/dojotoolkit.rb', line 81

def dynamic_html_headers(context)
  headers = super
  encoding = self.class::DOJO_ENCODING
  encoding ||= Encoding.default_external
  dojo_path = @lookandfeel.resource_global(:dojo_js)
  dojo_path ||= '/resources/dojo/dojo/dojo.js'
  args = { 'type' => 'text/javascript'}
  packages = ""
  unless(self.class::DOJO_PREFIX.empty?)
    packages = self.class::DOJO_PREFIX.collect { |prefix, path|
      "{ name: '#{prefix}', location: '#{path}' }"
    }.join(",")
  end
  puts "dynamic_html_headers with pkgs: #{packages}"
  config =config = [
    "has: {
       'dojo-debug-messages': true
    }",
  ].join(',')
  headers << %(<script>
 var dojoConfig = {
      parseOnLoad: true,
      isDebug: true,
      async: true,
      urchin: '',
  };
</script>)
  headers << context.script(args)
  {  'text/css'         => File.join(File.dirname(dojo_path), "/resources/dojo.css"),
     'text/javascript'  => dojo_path,
  }.each do |type, path|
    if (content = get_inline(path))
      headers << context.style(:type =>type) { content }
    else
      headers << context.style(:type =>type, :src => path) { "@import \"#{path}\";" }
    end
  end
  headers
end

#onload=(script) ⇒ Object



123
124
125
# File 'lib/htmlgrid/dojotoolkit.rb', line 123

def onload=(script)
	(@dojo_onloads ||= []).push(script)
end