htmlgrid 1.1.7 → 1.2.2

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/lib/htmlgrid/booleanvalue.rb +14 -14
  3. data/lib/htmlgrid/button.rb +9 -9
  4. data/lib/htmlgrid/centeredcomposite.rb +21 -20
  5. data/lib/htmlgrid/component.rb +214 -197
  6. data/lib/htmlgrid/composite.rb +332 -301
  7. data/lib/htmlgrid/datevalue.rb +12 -12
  8. data/lib/htmlgrid/div.rb +9 -9
  9. data/lib/htmlgrid/divcomposite.rb +44 -43
  10. data/lib/htmlgrid/divform.rb +8 -8
  11. data/lib/htmlgrid/divlist.rb +17 -19
  12. data/lib/htmlgrid/divtemplate.rb +6 -6
  13. data/lib/htmlgrid/dojotoolkit.rb +54 -48
  14. data/lib/htmlgrid/errormessage.rb +47 -43
  15. data/lib/htmlgrid/form.rb +70 -62
  16. data/lib/htmlgrid/formlist.rb +14 -14
  17. data/lib/htmlgrid/grid.rb +111 -67
  18. data/lib/htmlgrid/image.rb +17 -16
  19. data/lib/htmlgrid/infomessage.rb +15 -14
  20. data/lib/htmlgrid/input.rb +34 -32
  21. data/lib/htmlgrid/inputcheckbox.rb +13 -13
  22. data/lib/htmlgrid/inputcurrency.rb +9 -9
  23. data/lib/htmlgrid/inputdate.rb +11 -11
  24. data/lib/htmlgrid/inputfile.rb +13 -12
  25. data/lib/htmlgrid/inputradio.rb +9 -9
  26. data/lib/htmlgrid/inputtext.rb +10 -10
  27. data/lib/htmlgrid/javascript.rb +17 -16
  28. data/lib/htmlgrid/label.rb +53 -49
  29. data/lib/htmlgrid/labeltext.rb +8 -8
  30. data/lib/htmlgrid/link.rb +31 -27
  31. data/lib/htmlgrid/list.rb +121 -110
  32. data/lib/htmlgrid/namedcomponent.rb +28 -25
  33. data/lib/htmlgrid/pass.rb +11 -11
  34. data/lib/htmlgrid/passthru.rb +20 -17
  35. data/lib/htmlgrid/popuplink.rb +41 -39
  36. data/lib/htmlgrid/reset.rb +8 -8
  37. data/lib/htmlgrid/richtext.rb +22 -20
  38. data/lib/htmlgrid/select.rb +28 -26
  39. data/lib/htmlgrid/span.rb +9 -9
  40. data/lib/htmlgrid/spancomposite.rb +18 -18
  41. data/lib/htmlgrid/spanlist.rb +9 -9
  42. data/lib/htmlgrid/staticinput.rb +14 -13
  43. data/lib/htmlgrid/submit.rb +9 -9
  44. data/lib/htmlgrid/template.rb +121 -105
  45. data/lib/htmlgrid/text.rb +9 -9
  46. data/lib/htmlgrid/textarea.rb +19 -17
  47. data/lib/htmlgrid/ulcomposite.rb +22 -22
  48. data/lib/htmlgrid/ullist.rb +9 -9
  49. data/lib/htmlgrid/urllink.rb +38 -36
  50. data/lib/htmlgrid/value.rb +9 -9
  51. data/lib/htmlgrid/version.rb +2 -2
  52. data/test/stub/cgi.rb +10 -7
  53. data/test/suite.rb +3 -3
  54. data/test/test_add_row.rb +12 -13
  55. data/test/test_component.rb +141 -91
  56. data/test/test_composite.rb +85 -46
  57. data/test/test_datevalue.rb +28 -24
  58. data/test/test_divlist.rb +126 -0
  59. data/test/test_dojotoolkit.rb +41 -26
  60. data/test/test_form.rb +89 -73
  61. data/test/test_formlist.rb +77 -65
  62. data/test/test_grid.rb +256 -208
  63. data/test/test_input.rb +37 -31
  64. data/test/test_interaction_list.rb +106 -70
  65. data/test/test_label.rb +91 -77
  66. data/test/test_list.rb +110 -95
  67. data/test/test_select.rb +35 -30
  68. data/test/test_template.rb +66 -55
  69. data/test/test_text.rb +36 -31
  70. metadata +17 -4
  71. data/TooltipDialog.txt +0 -73
  72. data/interaction_no_inline.txt +0 -1216
@@ -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,72 +1,74 @@
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'
6
+ require "htmlgrid/component"
7
+ require "htmlgrid/div"
8
8
 
9
9
  module HtmlGrid
10
10
  class Component
11
11
  @@msie_ptrn = /MSIE\s*(\d)/
12
12
  attr_accessor :dojo_tooltip
13
13
  # DOJO_VERSION >= 1.7.0 only (removed old version support)
14
- def dojo_tag(widget, args={}, inner_html='')
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
43
  # NOTE:
42
44
  # DOJO >= 1.8 has support for type name separated by '/'
43
45
  # but, <= 1.7 must be separated with '.'
44
- 'data-dojo-type' => 'dijit/TooltipDialog',
45
- 'data-dojo-props' => "connectId:#{css_id}",
46
- 'id' => "#{css_id}_widget",
47
- 'style' => 'display: none',
46
+ "data-dojo-type" => "dijit/TooltipDialog",
47
+ "data-dojo-props" => "connectId:#{css_id}",
48
+ "id" => "#{css_id}_widget",
49
+ "style" => "display: none"
48
50
  }
49
51
  unless (match = @@msie_ptrn.match(@session.user_agent)) \
50
52
  && match[1].to_i < 7
51
53
  attrs.update({
52
- 'toggle' => 'fade',
53
- 'toggleDuration' => '500',
54
+ "toggle" => "fade",
55
+ "toggleDuration" => "500"
54
56
  })
55
57
  end
56
58
  @dojo_tooltip ||= nil
57
59
  if @dojo_tooltip.is_a?(String)
58
- if @dojo_tooltip !~ /^http/ # e.g. javascript
59
- attrs.store('href', "#@dojo_tooltip")
60
+ if !/^http/.match?(@dojo_tooltip) # e.g. javascript
61
+ attrs.store("href", @dojo_tooltip.to_s)
60
62
  else
61
- attrs.store('href', @dojo_tooltip)
63
+ attrs.store("href", @dojo_tooltip)
62
64
  end
63
65
  html << context.div(attrs)
64
66
  elsif @dojo_tooltip.respond_to?(:to_html)
65
67
  @dojo_tooltip.attributes.update(attrs)
66
- html << @dojo_tooltip.to_html(context).force_encoding('utf-8')
68
+ html << @dojo_tooltip.to_html(context).force_encoding("utf-8")
67
69
  end
68
70
  unless html.empty? || dojo_parse_on_load
69
- html << context.script('type' => 'text/javascript') {
71
+ html << context.script("type" => "text/javascript") {
70
72
  "dojoConfig.searchIds.push('#{css_id}')"
71
73
  }
72
74
  end
@@ -75,23 +77,24 @@ module HtmlGrid
75
77
  end
76
78
  end
77
79
  end
78
- module DojoToolkit
79
- module DojoTemplate
80
- DOJO_DEBUG = false
81
- DOJO_BACK_BUTTON = false
80
+
81
+ module DojoToolkit
82
+ module DojoTemplate
83
+ DOJO_DEBUG = false
84
+ DOJO_BACK_BUTTON = false
82
85
  DOJO_ENCODING = nil
83
86
  DOJO_PARSE_ON_LOAD = true
84
- DOJO_PREFIX = []
85
- DOJO_REQUIRE = []
87
+ DOJO_PREFIX = []
88
+ DOJO_REQUIRE = []
86
89
  def dynamic_html_headers(context)
87
90
  headers = super
88
91
  encoding = self.class::DOJO_ENCODING
89
92
  encoding ||= Encoding.default_external
90
93
  dojo_path = @lookandfeel.resource_global(:dojo_js)
91
- dojo_path ||= '/resources/dojo/dojo/dojo.js'
92
- args = { 'type' => 'text/javascript'}
94
+ dojo_path ||= "/resources/dojo/dojo/dojo.js"
95
+ args = {"type" => "text/javascript"}
93
96
  packages = ""
94
- unless(self.class::DOJO_PREFIX.empty?)
97
+ unless self.class::DOJO_PREFIX.empty?
95
98
  packages = self.class::DOJO_PREFIX.collect { |prefix, path|
96
99
  "{ name: '#{prefix}', location: '#{path}' }"
97
100
  }.join(",")
@@ -108,48 +111,51 @@ module HtmlGrid
108
111
  'dojo-debug-messages': #{self.class::DOJO_DEBUG}
109
112
  }",
110
113
  "packages: [ #{packages} ]"
111
- ].join(',')
112
- args.store('data-dojo-config', config)
113
- args.store('src', dojo_path)
114
+ ].join(",")
115
+ args.store("data-dojo-config", config)
116
+ args.store("src", dojo_path)
114
117
  headers << context.script(args)
115
- args = { 'type' => 'text/javascript' }
118
+ args = {"type" => "text/javascript"}
116
119
  headers << context.script(args) {
117
120
  package_paths = self.class::DOJO_REQUIRE.map { |req|
118
121
  "'#{req}'"
119
- }.join(',')
122
+ }.join(",")
120
123
  package_names = self.class::DOJO_REQUIRE.map { |req|
121
- req.split('/').last
122
- }.join(',')
124
+ req.split("/").last
125
+ }.join(",")
123
126
  if @dojo_onloads
124
- onloads = ''
127
+ onloads = ""
125
128
  @dojo_onloads.each { |onload|
126
129
  onloads << "#{onload}\n"
127
130
  }
128
131
  script =
129
- "require([#{package_paths}], function(#{package_names}) {" \
130
- "ready(function() {" \
131
- "#{onloads}" \
132
- "});" \
133
- "});"
132
+ "require([#{package_paths}], function(#{package_names}) {" \
133
+ "ready(function() {" \
134
+ "#{onloads}" \
135
+ "});" \
136
+ "});"
134
137
  else
135
138
  script = "require([#{package_paths}]);"
136
139
  end
137
140
  script
138
141
  }
139
142
  dojo_dir = File.dirname(dojo_path)
140
- headers << context.style(:type => "text/css") { <<-EOS
143
+ headers << context.style(type: "text/css") {
144
+ <<-EOS
141
145
  @import "#{File.join(dojo_dir, "/resources/dojo.css")}";
142
146
  @import "#{File.join(dojo_dir, "../dijit/themes/tundra/tundra.css")}";
143
- EOS
147
+ EOS
144
148
  }
145
149
  headers
146
150
  end
151
+
147
152
  def dojo_parse_on_load
148
153
  self.class::DOJO_PARSE_ON_LOAD
149
154
  end
150
- def onload=(script)
151
- (@dojo_onloads ||= []).push(script)
152
- end
153
- end
154
- end
155
+
156
+ def onload=(script)
157
+ (@dojo_onloads ||= []).push(script)
158
+ end
159
+ end
160
+ end
155
161
  end