dom-rb 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/csr/dom/browser_ext/node.rb +22 -2
- data/csr/dom/builder/base.rb +23 -3
- data/csr/dom/builder/helpers.rb +70 -46
- data/csr/dom/debug.rb +8 -0
- data/csr/dom/table/base.rb +29 -29
- data/csr/dom/table/row.rb +1 -1
- data/csr/dom/table/section.rb +1 -2
- data/csr/dom/util.rb +2 -2
- data/lib/dom/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a45ec1b37800175c10637af2132159e857134034
|
4
|
+
data.tar.gz: 686553f3bb65c377133c71f81a81f9934f8625ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b2f054907109c9a38fd298a89df5c5678ce7cedac4fb280446bd7df3187dd0eba7f3f827efd264c0ac8cca76e1fa40786bccf8a9b7cb41a382cdc8fa9c18739
|
7
|
+
data.tar.gz: 8e6acd49fec6b390b79fbc8c2d7e62e90f8a0a59d2ee8730881a8f56729d061373b8e616060411169e65db37890abd0a4b0017f3278fc0be95ba735b277b9a79
|
data/csr/dom/browser_ext/node.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'opal-browser'
|
2
|
+
require 'dom/debug'
|
2
3
|
|
3
4
|
# Add binding management to Browser::DOM::Node
|
4
5
|
|
@@ -25,6 +26,8 @@ end
|
|
25
26
|
class Browser
|
26
27
|
class DOM
|
27
28
|
class Node
|
29
|
+
include CSR::DOM::Debug
|
30
|
+
|
28
31
|
def as_native
|
29
32
|
@native
|
30
33
|
end
|
@@ -33,7 +36,7 @@ class Browser
|
|
33
36
|
def check_jquery
|
34
37
|
%x(
|
35
38
|
if (typeof jQuery === 'undefined') {
|
36
|
-
throw new Error('Bootstrap\'s JavaScript requires jQuery')
|
39
|
+
throw new Error('Bootstrap\'s JavaScript requires jQuery');
|
37
40
|
}
|
38
41
|
)
|
39
42
|
end
|
@@ -41,7 +44,7 @@ class Browser
|
|
41
44
|
def check_bootstrap
|
42
45
|
%x(
|
43
46
|
if (typeof($.fn.tooltip) === 'undefined') {
|
44
|
-
throw new Error('Bootstrap.js not loaded')
|
47
|
+
throw new Error('Bootstrap.js not loaded');
|
45
48
|
}
|
46
49
|
)
|
47
50
|
end
|
@@ -57,13 +60,30 @@ class Browser
|
|
57
60
|
# 4. 'destroy'
|
58
61
|
# see http://getbootstrap.com/javascript/#tooltips
|
59
62
|
def tooltip(arg=nil)
|
63
|
+
if String === arg
|
64
|
+
arg = {
|
65
|
+
title: arg,
|
66
|
+
trigger: 'hover focus',
|
67
|
+
}
|
68
|
+
end
|
69
|
+
debug 0, ->{[__FILE__, __LINE__, __method__, "arg=#{arg}"]}
|
60
70
|
check_bootstrap
|
71
|
+
debug 0, ->{[__FILE__, __LINE__, __method__, "@native=#{@native}"]}
|
61
72
|
`$(#@native).tooltip(#{arg.to_n})`
|
73
|
+
debug 0, ->{[__FILE__, __LINE__, __method__]}
|
62
74
|
end
|
63
75
|
|
64
76
|
def popover(arg=nil)
|
77
|
+
debug 0, ->{[__FILE__, __LINE__, __method__]}
|
78
|
+
if String === arg
|
79
|
+
arg = {
|
80
|
+
title: arg,
|
81
|
+
trigger: 'hover focus',
|
82
|
+
}
|
83
|
+
end
|
65
84
|
check_bootstrap
|
66
85
|
`$(#@native).popover(#{arg.to_n})`
|
86
|
+
debug 0, ->{[__FILE__, __LINE__, __method__]}
|
67
87
|
end
|
68
88
|
|
69
89
|
def bindings=(bindings)
|
data/csr/dom/builder/base.rb
CHANGED
@@ -19,6 +19,7 @@ module CSR
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def div(attributes: nil, content: nil)
|
22
|
+
debug 0, ->{[ __FILE__, __LINE__, __method__]}
|
22
23
|
tag(:div, attributes: attributes, content: content)
|
23
24
|
end
|
24
25
|
|
@@ -27,28 +28,40 @@ module CSR
|
|
27
28
|
# Any attributes or content which is a Proc will be
|
28
29
|
# resolved by proc.call.
|
29
30
|
def tag(name, attributes: nil, content: nil)
|
30
|
-
|
31
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
32
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__, "tag=#{name} attributes=#{attributes} content=#{content}" ]}
|
31
33
|
attributes = attributes ? attributes : {}
|
32
34
|
namespace = attributes[:namespace]
|
35
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
33
36
|
element = document.create_element(name, {namespace: namespace})
|
37
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
34
38
|
id = attributes.delete(:id) || attributes.delete('id')
|
39
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
35
40
|
if id
|
41
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
36
42
|
id = id.call if Proc === id
|
43
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
37
44
|
element.id = id
|
38
45
|
end
|
39
46
|
bindings = []
|
47
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
40
48
|
attributes.each do |key, value|
|
49
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__, "key=#{key} value=#{value}"]}
|
41
50
|
if key == :style
|
51
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
42
52
|
value = resolve_value(element, value, bindings, id, :style, name)
|
43
53
|
if value
|
44
54
|
value = normalize_style(value)
|
45
55
|
element.style(value)
|
46
56
|
end
|
57
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
47
58
|
elsif key[0,2] == 'on'
|
48
59
|
# event stuff is in browser/event/base.rb
|
60
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
49
61
|
event = key[2..-1]
|
50
62
|
element.on(event, &value)
|
51
63
|
else
|
64
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
52
65
|
value = resolve_value(element, value, bindings, id, key, name)
|
53
66
|
if value
|
54
67
|
key = sanitize_attribute(key)
|
@@ -56,14 +69,21 @@ module CSR
|
|
56
69
|
end
|
57
70
|
end
|
58
71
|
end
|
72
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
59
73
|
content = resolve_value(element, content, bindings, id, :content, name)
|
74
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
60
75
|
if content
|
76
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
61
77
|
content = sanitize_content(content)
|
78
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
62
79
|
element << content
|
63
80
|
end
|
81
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
64
82
|
if bindings
|
83
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__]}
|
65
84
|
element.bindings = bindings
|
66
85
|
end
|
86
|
+
debug 3, ->{[ __FILE__, __LINE__, __method__, "element=#{element}"]}
|
67
87
|
element
|
68
88
|
end
|
69
89
|
|
@@ -72,7 +92,7 @@ module CSR
|
|
72
92
|
end
|
73
93
|
|
74
94
|
def resolve_value(element, value, bindings, id, attr, tag_name)
|
75
|
-
debug
|
95
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "tag=#{tag_name} value=#{value} bindings=#{bindings} id=#{id} attr=#{attr}" ]}
|
76
96
|
result = case value
|
77
97
|
when BoundProc
|
78
98
|
# debug 1, ->{[ __FILE__, __LINE__, __method__, "BoundProc===value" ]}
|
@@ -95,7 +115,7 @@ module CSR
|
|
95
115
|
# debug 1, ->{[ __FILE__, __LINE__, __method__, "value=#{value}" ]}
|
96
116
|
value
|
97
117
|
end
|
98
|
-
debug
|
118
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "result=#{result}" ]}
|
99
119
|
result
|
100
120
|
end
|
101
121
|
|
data/csr/dom/builder/helpers.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'dom/builder/base'
|
2
|
+
require 'dom/debug'
|
2
3
|
|
3
4
|
# adds helper to CSR::DOM::Builder
|
4
5
|
|
@@ -6,8 +7,10 @@ module CSR
|
|
6
7
|
module DOM
|
7
8
|
module Builder
|
8
9
|
module_function
|
10
|
+
include CSR::DOM::Debug
|
9
11
|
|
10
|
-
def icon(name, callback: nil, attributes: nil)
|
12
|
+
def icon(name, callback: nil, attributes: nil, tooltip: nil, popover: nil)
|
13
|
+
debug 0, ->{[ __FILE__, __LINE__, __method__, "name=#{name} callback=#{callback} attributes=#{attributes} tooltip=#{tooltip}" ]}
|
11
14
|
style = {
|
12
15
|
text_align: 'center',
|
13
16
|
color: 'inherit',
|
@@ -30,13 +33,22 @@ module CSR
|
|
30
33
|
}.merge(
|
31
34
|
callback ? { onclick: callback } : {}
|
32
35
|
)
|
33
|
-
|
36
|
+
debug 0, ->{[ __FILE__, __LINE__, __method__, "attributes=#{attributes}" ]}
|
37
|
+
icon = tag(
|
34
38
|
:span,
|
35
39
|
attributes: attributes
|
36
40
|
)
|
41
|
+
debug 0, ->{[ __FILE__, __LINE__, __method__, "icon=#{icon}" ]}
|
42
|
+
if tooltip
|
43
|
+
icon.tooltip(tooltip)
|
44
|
+
elsif popover
|
45
|
+
icon.popover(popover)
|
46
|
+
end
|
47
|
+
debug 0, ->{[ __FILE__, __LINE__, __method__, "icon=#{icon}" ]}
|
48
|
+
icon
|
37
49
|
end
|
38
50
|
|
39
|
-
def icon_with_anchor(icon_name, href, icon_attributes: nil, anchor_attributes: nil)
|
51
|
+
def icon_with_anchor(icon_name, href, icon_attributes: nil, anchor_attributes: nil, tooltip: nil, popover: nil)
|
40
52
|
attributes = { href: href }
|
41
53
|
if anchor_attributes
|
42
54
|
attributes = anchor_attributes.merge(attributes)
|
@@ -44,11 +56,11 @@ module CSR
|
|
44
56
|
tag(
|
45
57
|
:a,
|
46
58
|
attributes: attributes,
|
47
|
-
content: icon(icon_name, attributes: icon_attributes)
|
59
|
+
content: icon(icon_name, attributes: icon_attributes, tooltip: tooltip, popover: popover)
|
48
60
|
)
|
49
61
|
end
|
50
62
|
|
51
|
-
def plus_sign_icon_anchor(href, icon_attributes: nil, anchor_attributes: nil)
|
63
|
+
def plus_sign_icon_anchor(href, icon_attributes: nil, anchor_attributes: nil, tooltip: nil, popover: nil)
|
52
64
|
_icon_attributes = {
|
53
65
|
style: {
|
54
66
|
color: 'lightgreen',
|
@@ -62,39 +74,49 @@ module CSR
|
|
62
74
|
:plus_sign,
|
63
75
|
href,
|
64
76
|
icon_attributes: _icon_attributes,
|
65
|
-
anchor_attributes: anchor_attributes
|
77
|
+
anchor_attributes: anchor_attributes,
|
78
|
+
tooltip: tooltip,
|
79
|
+
popover: popover
|
66
80
|
)
|
67
81
|
end
|
68
82
|
|
69
|
-
def remove_sign_icon(callback
|
83
|
+
def remove_sign_icon(callback: nil, tooltip: nil, popover: nil)
|
70
84
|
icon(
|
71
85
|
:remove_sign,
|
72
86
|
callback: callback,
|
73
|
-
attributes: { style: {color: 'red'} }
|
87
|
+
attributes: { style: {color: 'red'} },
|
88
|
+
tooltip: tooltip,
|
89
|
+
popover: popover
|
74
90
|
)
|
75
91
|
end
|
76
92
|
|
77
|
-
def refresh_icon(callback
|
93
|
+
def refresh_icon(callback: nil, tooltip: nil, popover: nil)
|
78
94
|
icon(
|
79
95
|
:refresh,
|
80
96
|
callback: callback,
|
81
|
-
attributes: { style: {color: 'inherit'} }
|
97
|
+
attributes: { style: {color: 'inherit'} },
|
98
|
+
tooltip: tooltip,
|
99
|
+
popover: popover
|
82
100
|
)
|
83
101
|
end
|
84
102
|
|
85
|
-
def save_icon(callback
|
103
|
+
def save_icon(callback: nil, tooltip: nil, popover: nil)
|
86
104
|
icon(
|
87
105
|
:save,
|
88
106
|
callback: callback,
|
89
|
-
attributes: { style: {color: 'inherit'} }
|
107
|
+
attributes: { style: {color: 'inherit'} },
|
108
|
+
tooltip: tooltip,
|
109
|
+
popover: popover
|
90
110
|
)
|
91
111
|
end
|
92
112
|
|
93
|
-
def hamburger_icon(callback
|
113
|
+
def hamburger_icon(callback: nil, tooltip: nil, popover: nil)
|
94
114
|
icon(
|
95
115
|
:menu_hamburger,
|
96
116
|
callback: callback,
|
97
|
-
attributes: { style: {color: 'inherit'} }
|
117
|
+
attributes: { style: {color: 'inherit'} },
|
118
|
+
tooltip: tooltip,
|
119
|
+
popover: popover
|
98
120
|
)
|
99
121
|
end
|
100
122
|
|
@@ -171,7 +193,8 @@ module CSR
|
|
171
193
|
# argument attributes take precedence
|
172
194
|
_icon_attributes = _icon_attributes.merge(icon_attributes)
|
173
195
|
end
|
174
|
-
drop_down_icon(
|
196
|
+
drop_down_icon(
|
197
|
+
icon: 'plus-sign',
|
175
198
|
items: items,
|
176
199
|
menu_right: menu_right,
|
177
200
|
icon_attributes: _icon_attributes,
|
@@ -190,7 +213,7 @@ module CSR
|
|
190
213
|
)
|
191
214
|
end
|
192
215
|
|
193
|
-
def div_with_icon(callback, icon: nil, pull: nil, attributes: nil, content: nil, icon_style: {}, tooltip: nil, popover: nil)
|
216
|
+
def div_with_icon(callback: nil, icon: nil, pull: nil, attributes: nil, content: nil, icon_style: {}, tooltip: nil, popover: nil)
|
194
217
|
icon ||= 'question-sign'
|
195
218
|
pull ||= 'left'
|
196
219
|
pull = pull.to_s
|
@@ -226,7 +249,7 @@ module CSR
|
|
226
249
|
)
|
227
250
|
end
|
228
251
|
|
229
|
-
def div_with_sort_icon(callback, direction: 0, content: nil)
|
252
|
+
def div_with_sort_icon(callback: nil, direction: 0, content: nil)
|
230
253
|
if direction != 0
|
231
254
|
tag(
|
232
255
|
:div,
|
@@ -261,42 +284,38 @@ module CSR
|
|
261
284
|
end
|
262
285
|
end
|
263
286
|
|
264
|
-
def div_with_menu_up_down(callback, up: true, down: false, content: nil, pull: 'left')
|
265
|
-
div_with_up_down_icon(callback, which: :menu, up: up, down: down, content: content, pull: pull)
|
287
|
+
def div_with_menu_up_down(callback: nil, up: true, down: false, content: nil, pull: 'left')
|
288
|
+
div_with_up_down_icon(callback: callback, which: :menu, up: up, down: down, content: content, pull: pull)
|
266
289
|
end
|
267
290
|
|
268
|
-
def div_with_collapse_up_down(callback, up: true, down: false, content: nil, pull: 'left')
|
269
|
-
div_with_up_down_icon(callback, which: :collapse, up: up, down: down, content: content, pull: pull)
|
291
|
+
def div_with_collapse_up_down(callback: nil, up: true, down: false, content: nil, pull: 'left')
|
292
|
+
div_with_up_down_icon(callback: callback, which: :collapse, up: up, down: down, content: content, pull: pull)
|
270
293
|
end
|
271
294
|
|
272
295
|
# which can be :collapse or :menu (or string equivalents)
|
273
|
-
def div_with_up_down_icon(callback, which: :menu, up: true, down: false, content: nil, pull: 'left')
|
296
|
+
def div_with_up_down_icon(callback: nil, which: :menu, up: true, down: false, content: nil, pull: 'left')
|
274
297
|
up = up && !down
|
275
298
|
pull = pull.to_s
|
276
299
|
left = pull == 'left'
|
277
|
-
|
278
|
-
:
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
}
|
297
|
-
}
|
298
|
-
)
|
299
|
-
] + arrify(content)
|
300
|
+
icon_attributes = {
|
301
|
+
class: "glyphicon glyphicon-#{which}-#{up ? 'up' : 'down'} pull-#{pull}",
|
302
|
+
style: {
|
303
|
+
font_size: 'smaller',
|
304
|
+
margin_top: '0.2em',
|
305
|
+
margin_left: left ? '0.3em' : '0.5em',
|
306
|
+
margin_right: left ? '0.5em' : '0.3em',
|
307
|
+
vertical_align: 'middle',
|
308
|
+
color: 'inherit',
|
309
|
+
background_color: 'inherit',
|
310
|
+
}
|
311
|
+
}
|
312
|
+
icon = tag(
|
313
|
+
:span,
|
314
|
+
attributes: icon_attributes
|
315
|
+
)
|
316
|
+
div(
|
317
|
+
attributes: { onclick: callback, style: { cursor: 'pointer' } },
|
318
|
+
content: arrify(icon, content)
|
300
319
|
)
|
301
320
|
end
|
302
321
|
|
@@ -321,7 +340,12 @@ module CSR
|
|
321
340
|
margin_right: '0.5em'
|
322
341
|
}
|
323
342
|
},
|
324
|
-
content: drop_down_icon(
|
343
|
+
content: drop_down_icon(
|
344
|
+
icon: icon,
|
345
|
+
items: items,
|
346
|
+
menu_right: pull.to_s == 'right',
|
347
|
+
menu_attributes: menu_attributes
|
348
|
+
)
|
325
349
|
),
|
326
350
|
content
|
327
351
|
)
|
data/csr/dom/debug.rb
CHANGED
@@ -18,6 +18,14 @@ module CSR
|
|
18
18
|
`StackTrace.get().then(callback).catch(errback)`
|
19
19
|
end
|
20
20
|
|
21
|
+
def at_debug_level(l)
|
22
|
+
prev= debug_level
|
23
|
+
self.debug_level = 1
|
24
|
+
result = yield
|
25
|
+
self.debug_level = prev
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
21
29
|
def debug_level=(l)
|
22
30
|
@debug_level = l
|
23
31
|
end
|
data/csr/dom/table/base.rb
CHANGED
@@ -40,33 +40,33 @@ module CSR
|
|
40
40
|
|
41
41
|
def initialize(**options)
|
42
42
|
# self.debug_level = 1
|
43
|
-
debug
|
43
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "options: #{options}" ]}
|
44
44
|
@id = options[:id] || hex_id
|
45
45
|
@rooted = false
|
46
46
|
init_sections(options)
|
47
47
|
@raw_columns = options[:columns]
|
48
48
|
@context = options[:context]
|
49
|
-
debug
|
49
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
50
50
|
init_caption(options)
|
51
|
-
debug
|
51
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
52
52
|
init_css_style(options)
|
53
|
-
debug
|
53
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
54
54
|
init_row_sources(options)
|
55
|
-
debug
|
55
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
56
56
|
init_visibility
|
57
|
-
debug
|
57
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
58
58
|
init_sorting(options)
|
59
|
-
debug
|
59
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
60
60
|
init_accordion(options)
|
61
|
-
debug
|
61
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
62
62
|
end
|
63
63
|
|
64
64
|
def columns
|
65
65
|
unless @columns
|
66
66
|
@columns = if Proc === @raw_columns
|
67
|
-
debug
|
67
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@raw_columns=#{@raw_columns}"]}
|
68
68
|
c = @raw_columns.call
|
69
|
-
debug
|
69
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@columns=#{@columns}"]}
|
70
70
|
c
|
71
71
|
else
|
72
72
|
@raw_columns
|
@@ -80,52 +80,52 @@ module CSR
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def root
|
83
|
-
debug
|
83
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
|
84
84
|
@root ||= tag(
|
85
85
|
:table,
|
86
86
|
attributes: attributes,
|
87
87
|
content: content
|
88
88
|
)
|
89
89
|
@rooted = true
|
90
|
-
debug
|
90
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@root=#{@root}" ]}
|
91
91
|
@root
|
92
92
|
end
|
93
93
|
|
94
94
|
def attributes
|
95
|
-
debug
|
95
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
|
96
96
|
result = {
|
97
97
|
class: css,
|
98
98
|
style: style
|
99
99
|
}
|
100
|
-
debug
|
100
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "result=#{result}" ]}
|
101
101
|
result
|
102
102
|
end
|
103
103
|
|
104
104
|
def content
|
105
|
-
debug
|
105
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
106
106
|
content = arrify(caption, sections)
|
107
107
|
result = content.map {|e| e.root }
|
108
|
-
debug
|
108
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "result=#{result}" ]}
|
109
109
|
result
|
110
110
|
end
|
111
111
|
|
112
112
|
def caption
|
113
|
-
debug
|
113
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__]}
|
114
114
|
@caption ||= caption_content ? CSR::DOM::Table::Caption.new(self, caption_content) : nil
|
115
|
-
debug
|
115
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@caption=#{@caption}" ]}
|
116
116
|
@caption
|
117
117
|
end
|
118
118
|
|
119
119
|
def sections
|
120
120
|
@sections ||= section_ids.map do |id|
|
121
|
-
debug
|
121
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "id=#{id}"]}
|
122
122
|
section = CSR::DOM::Table::Section.new(self, id)
|
123
|
-
debug
|
123
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "section=#{section}"]}
|
124
124
|
section
|
125
125
|
end.reject do |section|
|
126
126
|
section.empty?
|
127
127
|
end
|
128
|
-
debug
|
128
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@sections=#{@sections}"]}
|
129
129
|
@sections
|
130
130
|
end
|
131
131
|
|
@@ -186,7 +186,7 @@ module CSR
|
|
186
186
|
end
|
187
187
|
|
188
188
|
def update
|
189
|
-
# debug
|
189
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
|
190
190
|
@root = nil
|
191
191
|
init_sorting
|
192
192
|
update_caption
|
@@ -200,7 +200,7 @@ module CSR
|
|
200
200
|
def update_sections(ids = nil)
|
201
201
|
ids = ids || section_ids
|
202
202
|
ids.each do |id|
|
203
|
-
# debug
|
203
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__, "id=#{id} " ]}
|
204
204
|
update_section(id)
|
205
205
|
end
|
206
206
|
end
|
@@ -228,7 +228,7 @@ module CSR
|
|
228
228
|
# columns may be visible column indexes or Column's
|
229
229
|
def update_row(section_id, source, columns = nil)
|
230
230
|
section = section(section_id)
|
231
|
-
debug
|
231
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "section_id=#{section_id} source=#{source} columns=#{columns} section=#{section}" ]}
|
232
232
|
if section
|
233
233
|
section.update_row(source, columns)
|
234
234
|
end
|
@@ -238,7 +238,7 @@ module CSR
|
|
238
238
|
# column may be visible column index or a Column
|
239
239
|
def update_cell(section_id, source, column)
|
240
240
|
section = section(section_id)
|
241
|
-
debug
|
241
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "section_id=#{section_id} source=#{source} column=#{column} section=#{section}" ]}
|
242
242
|
if section
|
243
243
|
section.update_cell(source, column)
|
244
244
|
end
|
@@ -257,7 +257,7 @@ module CSR
|
|
257
257
|
section_ids.each do |id|
|
258
258
|
@row_sources[id] = options[:"#{id}_rows"]
|
259
259
|
end
|
260
|
-
debug
|
260
|
+
debug 2, ->{[ __FILE__, __LINE__, __method__, "@row_sources=#{@row_sources}" ]}
|
261
261
|
end
|
262
262
|
|
263
263
|
def init_accordion(options)
|
@@ -274,7 +274,7 @@ module CSR
|
|
274
274
|
end
|
275
275
|
|
276
276
|
def init_sorting(options = nil)
|
277
|
-
# debug
|
277
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
|
278
278
|
if options
|
279
279
|
@initial_sort_column_id = options[:sort_column_id]
|
280
280
|
@initial_sort_order = options[:sort_order]
|
@@ -287,11 +287,11 @@ module CSR
|
|
287
287
|
if @sort_column_id
|
288
288
|
columns.each { |c| sort_orders[c.id] = c.id == sort_column_id ? @sort_order : 1 }
|
289
289
|
end
|
290
|
-
# debug
|
290
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__, "@sort_column_id=#{@sort_column_id}" ]}
|
291
291
|
end
|
292
292
|
|
293
293
|
def update_sorting(sort_column_id)
|
294
|
-
# debug
|
294
|
+
# debug 2, ->{[ __FILE__, __LINE__, __method__, "column_id=#{column_id}" ]}
|
295
295
|
if @sort_column_id == sort_column_id
|
296
296
|
sort_orders[@sort_column_id] *= -1
|
297
297
|
else
|
data/csr/dom/table/row.rb
CHANGED
@@ -102,7 +102,7 @@ module CSR
|
|
102
102
|
if head? && column.sort?
|
103
103
|
debug 1, ->{[ __FILE__, __LINE__, __method__, "section.id=#{@section.id} row_index=#{@index} column.id=#{column.id} content=#{content}" ]}
|
104
104
|
content = div_with_sort_icon(
|
105
|
-
column.sort_callback,
|
105
|
+
callback: column.sort_callback,
|
106
106
|
direction: @table.sort_column_id == column.id ? @table.sort_order : 0,
|
107
107
|
content: content
|
108
108
|
)
|
data/csr/dom/table/section.rb
CHANGED
@@ -125,11 +125,10 @@ module CSR
|
|
125
125
|
unless @row_sources
|
126
126
|
# debug 1, ->{[ __FILE__, __LINE__, __method__, "@id=#{@id}" ]}
|
127
127
|
source = @table.row_source(@id)
|
128
|
+
source = source.call if Proc === source
|
128
129
|
@row_sources = case source
|
129
130
|
when Fixnum
|
130
131
|
source.times.to_a
|
131
|
-
when Proc
|
132
|
-
source.call
|
133
132
|
when NilClass
|
134
133
|
[]
|
135
134
|
else
|
data/csr/dom/util.rb
CHANGED
@@ -72,13 +72,13 @@ module CSR
|
|
72
72
|
unless style.respond_to?(:to_h)
|
73
73
|
raise TypeError, "#{__FILE__}[#{__LINE__}] : style #{style.class} must respond to :to_h"
|
74
74
|
end
|
75
|
-
debug 1, ->{[ __FILE__, __LINE__, __method__, "style=#{style}" ]}
|
75
|
+
# debug 1, ->{[ __FILE__, __LINE__, __method__, "style=#{style}" ]}
|
76
76
|
result = {}
|
77
77
|
style.to_h.each do |k,v|
|
78
78
|
k = k.to_s.gsub('_', '-')
|
79
79
|
result[k] = v.to_s
|
80
80
|
end
|
81
|
-
debug 1, ->{[ __FILE__, __LINE__, __method__, "result=#{result}" ]}
|
81
|
+
# debug 1, ->{[ __FILE__, __LINE__, __method__, "result=#{result}" ]}
|
82
82
|
result
|
83
83
|
end
|
84
84
|
end
|
data/lib/dom/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dom-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Gunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal-browser
|