htmlgrid 1.1.6 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/TooltipDialog.txt +73 -0
  3. data/interaction_no_inline.txt +1216 -0
  4. data/lib/htmlgrid/booleanvalue.rb +14 -14
  5. data/lib/htmlgrid/button.rb +9 -9
  6. data/lib/htmlgrid/centeredcomposite.rb +21 -20
  7. data/lib/htmlgrid/component.rb +214 -197
  8. data/lib/htmlgrid/composite.rb +332 -301
  9. data/lib/htmlgrid/datevalue.rb +12 -12
  10. data/lib/htmlgrid/div.rb +9 -9
  11. data/lib/htmlgrid/divcomposite.rb +44 -43
  12. data/lib/htmlgrid/divform.rb +8 -8
  13. data/lib/htmlgrid/divlist.rb +17 -19
  14. data/lib/htmlgrid/divtemplate.rb +6 -6
  15. data/lib/htmlgrid/dojotoolkit.rb +86 -53
  16. data/lib/htmlgrid/errormessage.rb +47 -43
  17. data/lib/htmlgrid/form.rb +70 -62
  18. data/lib/htmlgrid/formlist.rb +14 -14
  19. data/lib/htmlgrid/grid.rb +111 -67
  20. data/lib/htmlgrid/image.rb +17 -16
  21. data/lib/htmlgrid/infomessage.rb +15 -14
  22. data/lib/htmlgrid/input.rb +34 -32
  23. data/lib/htmlgrid/inputcheckbox.rb +13 -13
  24. data/lib/htmlgrid/inputcurrency.rb +9 -9
  25. data/lib/htmlgrid/inputdate.rb +11 -11
  26. data/lib/htmlgrid/inputfile.rb +13 -12
  27. data/lib/htmlgrid/inputradio.rb +9 -9
  28. data/lib/htmlgrid/inputtext.rb +10 -10
  29. data/lib/htmlgrid/javascript.rb +17 -16
  30. data/lib/htmlgrid/label.rb +53 -49
  31. data/lib/htmlgrid/labeltext.rb +8 -8
  32. data/lib/htmlgrid/link.rb +31 -27
  33. data/lib/htmlgrid/list.rb +121 -110
  34. data/lib/htmlgrid/namedcomponent.rb +28 -25
  35. data/lib/htmlgrid/pass.rb +11 -11
  36. data/lib/htmlgrid/passthru.rb +20 -17
  37. data/lib/htmlgrid/popuplink.rb +41 -39
  38. data/lib/htmlgrid/reset.rb +8 -8
  39. data/lib/htmlgrid/richtext.rb +22 -20
  40. data/lib/htmlgrid/select.rb +28 -26
  41. data/lib/htmlgrid/span.rb +9 -9
  42. data/lib/htmlgrid/spancomposite.rb +18 -18
  43. data/lib/htmlgrid/spanlist.rb +9 -9
  44. data/lib/htmlgrid/staticinput.rb +14 -13
  45. data/lib/htmlgrid/submit.rb +9 -9
  46. data/lib/htmlgrid/template.rb +124 -112
  47. data/lib/htmlgrid/text.rb +9 -9
  48. data/lib/htmlgrid/textarea.rb +19 -17
  49. data/lib/htmlgrid/ulcomposite.rb +22 -22
  50. data/lib/htmlgrid/ullist.rb +9 -9
  51. data/lib/htmlgrid/urllink.rb +38 -36
  52. data/lib/htmlgrid/value.rb +9 -9
  53. data/lib/htmlgrid/version.rb +2 -2
  54. data/test/stub/cgi.rb +10 -7
  55. data/test/suite.rb +3 -3
  56. data/test/test_add_row.rb +12 -13
  57. data/test/test_component.rb +141 -91
  58. data/test/test_composite.rb +85 -46
  59. data/test/test_datevalue.rb +28 -24
  60. data/test/test_divlist.rb +126 -0
  61. data/test/test_dojotoolkit.rb +41 -26
  62. data/test/test_form.rb +89 -73
  63. data/test/test_formlist.rb +77 -65
  64. data/test/test_grid.rb +256 -208
  65. data/test/test_input.rb +37 -31
  66. data/test/test_interaction_list.rb +106 -70
  67. data/test/test_label.rb +91 -77
  68. data/test/test_list.rb +110 -95
  69. data/test/test_select.rb +35 -30
  70. data/test/test_template.rb +66 -55
  71. data/test/test_text.rb +36 -31
  72. metadata +20 -3
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -22,18 +22,18 @@
22
22
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
23
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
24
  #
25
- # DateValue -- htmlgrid -- 10.03.2003 -- hwyss@ywesee.com
25
+ # DateValue -- htmlgrid -- 10.03.2003 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/namedcomponent'
27
+ require "htmlgrid/namedcomponent"
28
28
 
29
29
  module HtmlGrid
30
- class DateValue < NamedComponent
31
- LABEL = true
32
- def to_html(context)
33
- date = @model.send(@name)
34
- if(date.respond_to?(:strftime))
35
- date.strftime(@lookandfeel.lookup(:date_format))
36
- end
37
- end
38
- end
30
+ class DateValue < NamedComponent
31
+ LABEL = true
32
+ def to_html(context)
33
+ date = @model.send(@name)
34
+ if date.respond_to?(:strftime)
35
+ date.strftime(@lookandfeel.lookup(:date_format))
36
+ end
37
+ end
38
+ end
39
39
  end
data/lib/htmlgrid/div.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -24,14 +24,14 @@
24
24
  #
25
25
  # Div -- oddb -- 12.11.2004 -- jlang@ywesee.com, usenguel@ywesee.com
26
26
 
27
- require 'htmlgrid/component'
27
+ require "htmlgrid/component"
28
28
 
29
29
  module HtmlGrid
30
- class Div < Component
31
- def to_html(context)
32
- context.div(@attributes) {
33
- super << dynamic_html(context)
34
- }
35
- end
36
- end
30
+ class Div < Component
31
+ def to_html(context)
32
+ context.div(@attributes) {
33
+ super << dynamic_html(context)
34
+ }
35
+ end
36
+ end
37
37
  end
@@ -1,52 +1,53 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  # DivComposite -- HtmlGrid -- 19.04.2005 -- hwyss@ywesee.com
4
4
 
5
- require 'htmlgrid/composite'
5
+ require "htmlgrid/composite"
6
6
 
7
7
  module HtmlGrid
8
- class DivComposite < TagComposite
9
- def compose(model=@model)
10
- ypos = -1
11
- xpos = 0
12
- div = nil
13
- components.sort_by { |matrix, component|
14
- [matrix.at(1), matrix.at(0), matrix[2..-1]]
15
- }.each { |matrix, component|
16
- if((mpos = matrix.at(1).to_i) > ypos)
17
- xpos = 0
18
- ypos = mpos
19
- div = []
20
- @grid.push(div)
21
- css = {}
22
- if(klass = css_map[ypos])
23
- css.store('class', klass)
24
- end
25
- if(id = css_id_map[ypos])
26
- css.store('id', id)
27
- end
28
- if(style = css_style_map[ypos])
29
- css.store('style', style)
30
- end
31
- @css_grid.push(css.empty? ? nil : css)
32
- end
33
- div.push(label(create(component, model), component))
34
- }
35
- end
36
- def to_html(context)
37
- res = ''
38
- @grid.each_with_index { |div, idx|
8
+ class DivComposite < TagComposite
9
+ def compose(model = @model)
10
+ ypos = -1
11
+ xpos = 0
12
+ div = nil
13
+ components.sort_by { |matrix, component|
14
+ [matrix.at(1), matrix.at(0), matrix[2..-1]]
15
+ }.each { |matrix, component|
16
+ if (mpos = matrix.at(1).to_i) > ypos
17
+ xpos = 0
18
+ ypos = mpos
19
+ div = []
20
+ @grid.push(div)
21
+ css = {}
22
+ if (klass = css_map[ypos])
23
+ css.store("class", klass)
24
+ end
25
+ if (id = css_id_map[ypos])
26
+ css.store("id", id)
27
+ end
28
+ if (style = css_style_map[ypos])
29
+ css.store("style", style)
30
+ end
31
+ @css_grid.push(css.empty? ? nil : css)
32
+ end
33
+ div.push(label(create(component, model), component))
34
+ }
35
+ end
36
+
37
+ def to_html(context)
38
+ res = ""
39
+ @grid&.each_with_index { |div, idx|
39
40
  res << context.div(tag_attributes(idx)) {
40
- div.flatten.inject('') { |html, item|
41
- html << if(item.respond_to?(:to_html))
42
- item.to_html(context).force_encoding('utf-8')
43
- else
44
- item.to_s
45
- end
41
+ div.flatten.inject("") { |html, item|
42
+ html << if item.respond_to?(:to_html)
43
+ item.to_html(context).force_encoding("utf-8")
44
+ else
45
+ item.to_s
46
+ end
46
47
  }
47
48
  }
48
- }
49
- res
50
- end
51
- end
49
+ }
50
+ res
51
+ end
52
+ end
52
53
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -22,14 +22,14 @@
22
22
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
23
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
24
  #
25
- # Form -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
25
+ # Form -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/form'
28
- require 'htmlgrid/divcomposite'
29
- require 'htmlgrid/submit'
27
+ require "htmlgrid/form"
28
+ require "htmlgrid/divcomposite"
29
+ require "htmlgrid/submit"
30
30
 
31
31
  module HtmlGrid
32
- class DivForm < DivComposite
33
- include FormMethods
34
- end
32
+ class DivForm < DivComposite
33
+ include FormMethods
34
+ end
35
35
  end
@@ -1,26 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  # HtmlGrid::DivList -- davaz.com -- 20.09.2005 -- mhuggler@ywesee.com
4
4
 
5
- require 'htmlgrid/divcomposite'
5
+ require "htmlgrid/divcomposite"
6
6
 
7
7
  module HtmlGrid
8
- class DivList < HtmlGrid::DivComposite
9
- def compose
10
- @model.each_with_index { |item, idx|
8
+ class DivList < HtmlGrid::DivComposite
9
+ def compose
10
+ @model&.each_with_index { |item, idx|
11
11
  @list_index = idx
12
- super(item)
13
- }
14
- =begin
15
- if(header = self.class.const_get(:HEADER))
16
- @grid.push(create(header, @model, @session))
17
- @css_grid.push(nil)
18
- end
19
- if(footer = self.class.const_get(:FOOTER))
20
- @grid.push(create(footer, @model, @session))
21
- @css_grid.push(nil)
22
- end
23
- =end
24
- end
25
- end
12
+ super(item)
13
+ }
14
+ # if(header = self.class.const_get(:HEADER))
15
+ # @grid.push(create(header, @model, @session))
16
+ # @css_grid.push(nil)
17
+ # end
18
+ # if(footer = self.class.const_get(:FOOTER))
19
+ # @grid.push(create(footer, @model, @session))
20
+ # @css_grid.push(nil)
21
+ # end
22
+ end
23
+ end
26
24
  end
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  # DivTemplate -- htmlgrid -- 04.05.2005 -- hwyss@ywesee.com
4
4
 
5
- require 'htmlgrid/divcomposite'
6
- require 'htmlgrid/template'
5
+ require "htmlgrid/divcomposite"
6
+ require "htmlgrid/template"
7
7
 
8
8
  module HtmlGrid
9
- class DivTemplate < DivComposite
10
- include TemplateMethods
11
- end
9
+ class DivTemplate < DivComposite
10
+ include TemplateMethods
11
+ end
12
12
  end
@@ -1,128 +1,161 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  # HtmlGrid::DojoToolkit -- davaz.com -- 06.04.2012 -- yasaka@ywesee.com
4
4
  # HtmlGrid::DojoToolkit -- davaz.com -- 14.03.2006 -- mhuggler@ywesee.com
5
5
 
6
- require 'htmlgrid/component'
7
- require 'htmlgrid/div'
8
- require 'htmlgrid/template'
6
+ require "htmlgrid/component"
7
+ require "htmlgrid/div"
9
8
 
10
9
  module HtmlGrid
11
10
  class Component
12
11
  @@msie_ptrn = /MSIE\s*(\d)/
13
12
  attr_accessor :dojo_tooltip
14
- def dojo_tag(widget, args={}, inner_html='')
13
+ # DOJO_VERSION >= 1.7.0 only (removed old version support)
14
+ def dojo_tag(widget, args = {}, inner_html = "")
15
15
  div = HtmlGrid::Div.new(@model, @session, self)
16
- div.set_attribute('data-dojo-type', widget)
16
+ div.set_attribute("data-dojo-type", widget)
17
17
  args.each { |key, value|
18
18
  if value.is_a?(Array)
19
- value = value.join(',')
19
+ value = value.join(",")
20
20
  end
21
21
  div.set_attribute(key, value)
22
22
  }
23
23
  div.value = inner_html
24
24
  div
25
25
  end
26
+
26
27
  def dojo_title=(value)
27
28
  tooltip = HtmlGrid::Div.new(@model, @session, self)
28
29
  tooltip.value = value
29
30
  self.dojo_tooltip = tooltip
30
31
  end
32
+
31
33
  def dojo_parse_on_load
32
34
  if @container.respond_to?(:dojo_parse_on_load)
33
35
  @container.dojo_parse_on_load
34
36
  end
35
37
  end
36
38
  unless method_defined?(:dojo_dynamic_html)
37
- alias :dojo_dynamic_html :dynamic_html
39
+ alias_method :dojo_dynamic_html, :dynamic_html
38
40
  def dynamic_html(context)
39
- html = ''
41
+ html = ""
40
42
  attrs = {
41
- 'data-dojo-type' => 'dijit/TooltipDialog',
42
- 'data-dojo-props' => "connectId:#{css_id}",
43
- 'id' => "#{css_id}_widget",
44
- 'style' => 'display: none',
43
+ # NOTE:
44
+ # DOJO >= 1.8 has support for type name separated by '/'
45
+ # but, <= 1.7 must be separated with '.'
46
+ "data-dojo-type" => "dijit/TooltipDialog",
47
+ "data-dojo-props" => "connectId:#{css_id}",
48
+ "id" => "#{css_id}_widget",
49
+ "style" => "display: none"
45
50
  }
46
51
  unless (match = @@msie_ptrn.match(@session.user_agent)) \
47
52
  && match[1].to_i < 7
48
53
  attrs.update({
49
- 'toggle' => 'fade',
50
- 'toggleDuration' => '500',
54
+ "toggle" => "fade",
55
+ "toggleDuration" => "500"
51
56
  })
52
57
  end
53
58
  @dojo_tooltip ||= nil
54
59
  if @dojo_tooltip.is_a?(String)
55
- if @dojo_tooltip !~ /^http/ # e.g. javascript
56
- attrs.store('href', "#@dojo_tooltip")
60
+ if !/^http/.match?(@dojo_tooltip) # e.g. javascript
61
+ attrs.store("href", @dojo_tooltip.to_s)
57
62
  else
58
- attrs.store('href', @dojo_tooltip)
63
+ attrs.store("href", @dojo_tooltip)
59
64
  end
60
65
  html << context.div(attrs)
61
66
  elsif @dojo_tooltip.respond_to?(:to_html)
62
67
  @dojo_tooltip.attributes.update(attrs)
63
- html << @dojo_tooltip.to_html(context).force_encoding('utf-8')
68
+ html << @dojo_tooltip.to_html(context).force_encoding("utf-8")
64
69
  end
65
70
  unless html.empty? || dojo_parse_on_load
66
- html << context.script('type' => 'text/javascript') { "dojoConfig.searchIds.push('#{css_id}')" }
71
+ html << context.script("type" => "text/javascript") {
72
+ "dojoConfig.searchIds.push('#{css_id}')"
73
+ }
67
74
  end
68
75
  # call original dynamic_html
69
76
  dojo_dynamic_html(context) << html
70
77
  end
71
78
  end
72
79
  end
73
- module DojoToolkit
74
- module DojoTemplate
75
- DOJO_DEBUG = true
76
- DOJO_BACK_BUTTON = false
80
+
81
+ module DojoToolkit
82
+ module DojoTemplate
83
+ DOJO_DEBUG = false
84
+ DOJO_BACK_BUTTON = false
77
85
  DOJO_ENCODING = nil
78
86
  DOJO_PARSE_ON_LOAD = true
79
- DOJO_PREFIX = []
80
- DOJO_REQUIRE = []
87
+ DOJO_PREFIX = []
88
+ DOJO_REQUIRE = []
81
89
  def dynamic_html_headers(context)
82
90
  headers = super
83
91
  encoding = self.class::DOJO_ENCODING
84
92
  encoding ||= Encoding.default_external
85
93
  dojo_path = @lookandfeel.resource_global(:dojo_js)
86
- dojo_path ||= '/resources/dojo/dojo/dojo.js'
87
- args = { 'type' => 'text/javascript'}
94
+ dojo_path ||= "/resources/dojo/dojo/dojo.js"
95
+ args = {"type" => "text/javascript"}
88
96
  packages = ""
89
- unless(self.class::DOJO_PREFIX.empty?)
97
+ unless self.class::DOJO_PREFIX.empty?
90
98
  packages = self.class::DOJO_PREFIX.collect { |prefix, path|
91
99
  "{ name: '#{prefix}', location: '#{path}' }"
92
100
  }.join(",")
93
101
  end
94
- puts "dynamic_html_headers with pkgs: #{packages}"
95
- config =config = [
102
+ config = [
103
+ "parseOnLoad: #{self.class::DOJO_PARSE_ON_LOAD}",
104
+ "isDebug: #{self.class::DOJO_DEBUG}",
105
+ "preventBackButtonFix: #{!self.class::DOJO_BACK_BUTTON}",
106
+ "bindEncoding: '#{encoding}'",
107
+ "searchIds: []",
108
+ "urchin: ''",
96
109
  "has: {
97
- 'dojo-debug-messages': true
110
+ 'dojo-firebug': #{self.class::DOJO_DEBUG},
111
+ 'dojo-debug-messages': #{self.class::DOJO_DEBUG}
98
112
  }",
99
- ].join(',')
100
- headers << %(<script>
101
- var dojoConfig = {
102
- parseOnLoad: true,
103
- isDebug: true,
104
- async: true,
105
- urchin: '',
106
- };
107
- </script>)
113
+ "packages: [ #{packages} ]"
114
+ ].join(",")
115
+ args.store("data-dojo-config", config)
116
+ args.store("src", dojo_path)
108
117
  headers << context.script(args)
109
- { 'text/css' => File.join(File.dirname(dojo_path), "/resources/dojo.css"),
110
- 'text/javascript' => dojo_path,
111
- }.each do |type, path|
112
- if (content = get_inline(path))
113
- headers << context.style(:type =>type) { content }
118
+ args = {"type" => "text/javascript"}
119
+ headers << context.script(args) {
120
+ package_paths = self.class::DOJO_REQUIRE.map { |req|
121
+ "'#{req}'"
122
+ }.join(",")
123
+ package_names = self.class::DOJO_REQUIRE.map { |req|
124
+ req.split("/").last
125
+ }.join(",")
126
+ if @dojo_onloads
127
+ onloads = ""
128
+ @dojo_onloads.each { |onload|
129
+ onloads << "#{onload}\n"
130
+ }
131
+ script =
132
+ "require([#{package_paths}], function(#{package_names}) {" \
133
+ "ready(function() {" \
134
+ "#{onloads}" \
135
+ "});" \
136
+ "});"
114
137
  else
115
- headers << context.style(:type =>type, :src => path) { "@import \"#{path}\";" }
138
+ script = "require([#{package_paths}]);"
116
139
  end
117
- end
140
+ script
141
+ }
142
+ dojo_dir = File.dirname(dojo_path)
143
+ headers << context.style(type: "text/css") {
144
+ <<-EOS
145
+ @import "#{File.join(dojo_dir, "/resources/dojo.css")}";
146
+ @import "#{File.join(dojo_dir, "../dijit/themes/tundra/tundra.css")}";
147
+ EOS
148
+ }
118
149
  headers
119
150
  end
151
+
120
152
  def dojo_parse_on_load
121
153
  self.class::DOJO_PARSE_ON_LOAD
122
154
  end
123
- def onload=(script)
124
- (@dojo_onloads ||= []).push(script)
125
- end
126
- end
127
- end
155
+
156
+ def onload=(script)
157
+ (@dojo_onloads ||= []).push(script)
158
+ end
159
+ end
160
+ end
128
161
  end