atome 0.5.5.7.7 → 0.5.5.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/atome +110 -91
- data/lib/atome/atome.rb +4 -1
- data/lib/atome/extensions/atome.rb +319 -2
- data/lib/atome/genesis/generators/atome.rb +10 -1
- data/lib/atome/genesis/generators/communication.rb +10 -2
- data/lib/atome/genesis/generators/effect.rb +7 -1
- data/lib/atome/genesis/generators/event.rb +4 -3
- data/lib/atome/genesis/generators/geometry.rb +31 -4
- data/lib/atome/genesis/generators/identity.rb +3 -0
- data/lib/atome/genesis/generators/material.rb +1 -0
- data/lib/atome/genesis/generators/property.rb +76 -0
- data/lib/atome/genesis/generators/security.rb +4 -2
- data/lib/atome/genesis/generators/utility.rb +27 -12
- data/lib/atome/genesis/sparkle.rb +3 -2
- data/lib/atome/helpers/essentials.rb +3 -2
- data/lib/atome/version.rb +1 -1
- data/lib/platform_specific/opal/extensions/js.rb +1 -2
- data/lib/renderers/html/atome.rb +0 -1
- data/lib/renderers/html/effect.rb +7 -3
- data/lib/renderers/html/geometry.rb +11 -5
- data/lib/renderers/html/hierarchy.rb +1 -1
- data/lib/renderers/html/html.rb +304 -19
- data/lib/renderers/html/identity.rb +8 -0
- data/lib/renderers/html/material.rb +14 -0
- data/lib/renderers/html/property.rb +35 -0
- data/lib/renderers/html/spatial.rb +14 -5
- data/lib/renderers/html/utility.rb +25 -1
- data/sig/global_variables.rbs +1 -0
- data/vendor/assets/application/examples/a_concat.rb +3 -0
- data/vendor/assets/application/examples/atomizer.rb +86 -0
- data/vendor/assets/application/examples/blur.rb +6 -0
- data/vendor/assets/application/examples/border.rb +6 -0
- data/vendor/assets/application/examples/compute.rb +16 -0
- data/vendor/assets/application/examples/console.rb +4 -0
- data/vendor/assets/application/examples/dig.rb +13 -0
- data/vendor/assets/application/examples/fit.rb +26 -0
- data/vendor/assets/application/examples/import.rb +33 -0
- data/vendor/assets/application/examples/infos.rb +10 -0
- data/vendor/assets/application/examples/messaging.rb +17 -4
- data/vendor/assets/application/examples/shortcut.rb +25 -0
- data/vendor/assets/application/examples/size.rb +17 -0
- data/vendor/assets/application/examples/table.rb +76 -0
- data/vendor/assets/application/examples/text.rb +1 -1
- data/vendor/assets/application/works/vie.rb +3 -0
- data/vendor/assets/server/atome_server.rb +40 -7
- data/vendor/assets/server/capture.rb +1 -1
- data/vendor/assets/src/index.html +7 -6
- data/vendor/assets/src/index_opal.html +11 -6
- data/vendor/assets/src/index_server.html +11 -7
- data/vendor/assets/src/index_server_wasm.html +7 -6
- data/vendor/assets/src/js/atome/atome.js +0 -95
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +9 -7
- metadata +15 -2
data/lib/renderers/html/html.rb
CHANGED
@@ -4,6 +4,23 @@
|
|
4
4
|
|
5
5
|
class HTML
|
6
6
|
|
7
|
+
def self.locate(selector, base_element = JS.global[:document][:body])
|
8
|
+
return base_element if selector.empty?
|
9
|
+
|
10
|
+
if selector.has_key?(:id)
|
11
|
+
base_element.querySelector("##{selector[:id]}")
|
12
|
+
elsif selector.has_key?(:parent)
|
13
|
+
parent = base_element.querySelector("##{selector[:parent]}")
|
14
|
+
return nil if parent.nil?
|
15
|
+
parent.querySelectorAll("*").to_a
|
16
|
+
elsif selector.has_key?(:html)
|
17
|
+
html_element = selector[:html]
|
18
|
+
return nil if html_element.nil?
|
19
|
+
html_element.querySelectorAll("*").to_a
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
7
24
|
def initialize(id_found, current_atome)
|
8
25
|
@element ||= JS.global[:document].getElementById(id_found.to_s)
|
9
26
|
@id = id_found
|
@@ -38,7 +55,7 @@ class HTML
|
|
38
55
|
condition_strings << "(min-height: #{conditions[:min][:height]}px)" if conditions[:min][:height]
|
39
56
|
end
|
40
57
|
|
41
|
-
operator = conditions[:operator] == :and ?
|
58
|
+
operator = conditions[:operator] == :and ? 'and' : 'or'
|
42
59
|
|
43
60
|
# Convert properties to apply
|
44
61
|
property_strings = []
|
@@ -86,9 +103,9 @@ class HTML
|
|
86
103
|
data[:apply][key] ||= {}
|
87
104
|
properties.each do |property|
|
88
105
|
prop, value = property.split(':').map(&:strip)
|
89
|
-
if prop ==
|
106
|
+
if prop == 'background-color'
|
90
107
|
data[:apply][key][:color] = value.to_sym
|
91
|
-
elsif value[-2..] ==
|
108
|
+
elsif value[-2..] == 'px'
|
92
109
|
data[:apply][key][prop.to_sym] = value.to_i
|
93
110
|
else
|
94
111
|
data[:apply][key][prop.to_sym] = value.to_sym
|
@@ -121,30 +138,30 @@ class HTML
|
|
121
138
|
|
122
139
|
style_tags.each do |line|
|
123
140
|
line = line.strip
|
124
|
-
next if line.empty? || line.start_with?(
|
141
|
+
next if line.empty? || line.start_with?('/*')
|
125
142
|
|
126
143
|
if inside_media
|
127
|
-
if line ==
|
128
|
-
hash_result[
|
144
|
+
if line == '}'
|
145
|
+
hash_result['@media'] << media_hash
|
129
146
|
inside_media = false
|
130
147
|
next
|
131
148
|
end
|
132
149
|
|
133
150
|
selector, properties = line.split('{').map(&:strip)
|
134
|
-
next unless properties&.end_with?(
|
151
|
+
next unless properties&.end_with?('}')
|
135
152
|
|
136
153
|
properties = properties[0...-1].strip
|
137
154
|
media_hash[selector] = extract_properties(properties)
|
138
|
-
elsif line.start_with?(
|
155
|
+
elsif line.start_with?('@media')
|
139
156
|
media_content = line.match(/@media\s*\(([^)]+)\)\s*{/)
|
140
157
|
next unless media_content
|
141
158
|
|
142
159
|
media_query = media_content[1]
|
143
|
-
hash_result[
|
160
|
+
hash_result['@media'] = [media_query]
|
144
161
|
inside_media = true
|
145
162
|
else
|
146
163
|
selector, properties = line.split('{').map(&:strip)
|
147
|
-
next unless properties&.end_with?(
|
164
|
+
next unless properties&.end_with?('}')
|
148
165
|
|
149
166
|
properties = properties[0...-1].strip
|
150
167
|
hash_result[selector] = extract_properties(properties)
|
@@ -294,6 +311,7 @@ class HTML
|
|
294
311
|
style[:innerHTML] = "::selection { background-color: #{back_color_rgba}; color: #{text_color_rgba}; }"
|
295
312
|
JS.global[:document][:head].appendChild(style)
|
296
313
|
return unless @element[:innerText].to_s.length == 1
|
314
|
+
|
297
315
|
@element[:innerHTML] = '​'
|
298
316
|
end
|
299
317
|
|
@@ -306,6 +324,7 @@ class HTML
|
|
306
324
|
JS.global[:document][:body].appendChild(@element)
|
307
325
|
add_class('atome')
|
308
326
|
self.id(id)
|
327
|
+
|
309
328
|
self
|
310
329
|
end
|
311
330
|
|
@@ -351,8 +370,8 @@ class HTML
|
|
351
370
|
check_double(id)
|
352
371
|
markup_found = @original_atome.markup || 'svg'
|
353
372
|
@element_type = markup_found.to_s
|
354
|
-
svg_ns =
|
355
|
-
@element = JS.global[:document].createElementNS(svg_ns,
|
373
|
+
svg_ns = 'http://www.w3.org/2000/svg'
|
374
|
+
@element = JS.global[:document].createElementNS(svg_ns, 'svg')
|
356
375
|
JS.global[:document][:body].appendChild(@element)
|
357
376
|
@element.setAttribute('viewBox', '0 0 1024 1024')
|
358
377
|
@element.setAttribute('version', '1.1')
|
@@ -363,7 +382,7 @@ class HTML
|
|
363
382
|
|
364
383
|
def svg_data(data)
|
365
384
|
data.each do |type_passed, datas|
|
366
|
-
svg_ns =
|
385
|
+
svg_ns = 'http://www.w3.org/2000/svg'
|
367
386
|
new_path = JS.global[:document].createElementNS(svg_ns.to_s, type_passed.to_s)
|
368
387
|
JS.global[:document][:body].appendChild(new_path)
|
369
388
|
datas.each do |property, value|
|
@@ -419,7 +438,7 @@ class HTML
|
|
419
438
|
.gsub('&', "\&")
|
420
439
|
.gsub('<', "\<")
|
421
440
|
.gsub('>', "\>")
|
422
|
-
.gsub('"', "
|
441
|
+
.gsub('"', '"')
|
423
442
|
.gsub("'", "\'")
|
424
443
|
end
|
425
444
|
|
@@ -465,6 +484,11 @@ class HTML
|
|
465
484
|
@element[:style][:filter] = filter_needed
|
466
485
|
end
|
467
486
|
|
487
|
+
def backdropFilter(property, value)
|
488
|
+
filter_needed = "#{property}(#{value})"
|
489
|
+
@element[:style][:"-webkit-backdrop-filter"] = filter_needed
|
490
|
+
end
|
491
|
+
|
468
492
|
def currentTime(time)
|
469
493
|
@element[:currentTime] = time
|
470
494
|
end
|
@@ -1094,7 +1118,7 @@ class HTML
|
|
1094
1118
|
if Atome.host == 'tauri'
|
1095
1119
|
JS.eval("readFile('#{id}','#{file}')")
|
1096
1120
|
else
|
1097
|
-
puts
|
1121
|
+
puts ' work in progress'
|
1098
1122
|
end
|
1099
1123
|
end
|
1100
1124
|
|
@@ -1102,12 +1126,12 @@ class HTML
|
|
1102
1126
|
if Atome.host == 'tauri'
|
1103
1127
|
JS.eval("browseFile('#{id}','#{file}')")
|
1104
1128
|
else
|
1105
|
-
puts
|
1129
|
+
puts 'work in progress'
|
1106
1130
|
end
|
1107
1131
|
end
|
1108
1132
|
|
1109
1133
|
def handle_input
|
1110
|
-
@original_atome.instance_variable_set(
|
1134
|
+
@original_atome.instance_variable_set('@data', @element[:innerText].to_s)
|
1111
1135
|
end
|
1112
1136
|
|
1113
1137
|
# this method update the data content of the atome
|
@@ -1146,7 +1170,7 @@ class HTML
|
|
1146
1170
|
puts 'change for standard method : action'
|
1147
1171
|
required_keys = [:from, :to, :duration]
|
1148
1172
|
unless properties.is_a?(Hash) && (required_keys - properties.keys).empty?
|
1149
|
-
raise ArgumentError,
|
1173
|
+
raise ArgumentError, 'Properties must be a hash with :from, :to, and :duration keys'
|
1150
1174
|
end
|
1151
1175
|
|
1152
1176
|
animate(properties)
|
@@ -1154,7 +1178,268 @@ class HTML
|
|
1154
1178
|
end
|
1155
1179
|
|
1156
1180
|
def stop_animation
|
1157
|
-
JS.eval(
|
1181
|
+
JS.eval('if (window.currentAnimation) window.currentAnimation.stop();')
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
# Table manipulation
|
1185
|
+
|
1186
|
+
def table(data)
|
1187
|
+
table_html = JS.global[:document].createElement('table')
|
1188
|
+
thead = JS.global[:document].createElement('thead')
|
1189
|
+
|
1190
|
+
max_length = data.max_by { |row| row.keys.length }.keys.length
|
1191
|
+
|
1192
|
+
if @original_atome.option[:header]
|
1193
|
+
header_row = JS.global[:document].createElement('tr')
|
1194
|
+
|
1195
|
+
max_length.times do |i|
|
1196
|
+
th = JS.global[:document].createElement('th')
|
1197
|
+
th[:textContent] = data.map { |row| row.keys[i].to_s }.compact.first || ''
|
1198
|
+
header_row.appendChild(th)
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
thead.appendChild(header_row)
|
1202
|
+
end
|
1203
|
+
|
1204
|
+
table_html.appendChild(thead)
|
1205
|
+
tbody = JS.global[:document].createElement('tbody')
|
1206
|
+
|
1207
|
+
data.each_with_index do |row, row_index|
|
1208
|
+
tr = JS.global[:document].createElement('tr')
|
1209
|
+
|
1210
|
+
max_length.times do |cell_index|
|
1211
|
+
td = JS.global[:document].createElement('td')
|
1212
|
+
cell_size = set_td_style(td)
|
1213
|
+
cell_height = cell_size[:cell_height]
|
1214
|
+
|
1215
|
+
cell_value = row.values[cell_index]
|
1216
|
+
if cell_value.instance_of? Atome
|
1217
|
+
cell_value.fit(cell_height)
|
1218
|
+
html_element = JS.global[:document].getElementById(cell_value.id.to_s)
|
1219
|
+
td.appendChild(html_element)
|
1220
|
+
html_element[:style][:transformOrigin] = 'top left'
|
1221
|
+
html_element[:style][:position] = 'relative'
|
1222
|
+
cell_value.top(0)
|
1223
|
+
cell_value.left(0)
|
1224
|
+
else
|
1225
|
+
td[:textContent] = cell_value.to_s
|
1226
|
+
end
|
1227
|
+
tr.appendChild(td)
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
tbody.appendChild(tr)
|
1231
|
+
end
|
1232
|
+
table_html.appendChild(tbody)
|
1233
|
+
JS.global[:document].querySelector("##{@id}").appendChild(table_html)
|
1158
1234
|
end
|
1159
1235
|
|
1236
|
+
def refresh_table(_params)
|
1237
|
+
# first we need to extact all atome from the table or they will be deleted by the table refres
|
1238
|
+
data = @original_atome.data
|
1239
|
+
data.each do |row|
|
1240
|
+
row.each do |k, v|
|
1241
|
+
v.attach(:view) if v.instance_of? Atome
|
1242
|
+
end
|
1243
|
+
end
|
1244
|
+
table_element = JS.global[:document].querySelector("##{@id} table")
|
1245
|
+
if table_element.nil?
|
1246
|
+
puts 'Table not found'
|
1247
|
+
return
|
1248
|
+
end
|
1249
|
+
(table_element[:rows].to_a.length - 1).downto(1) do |i|
|
1250
|
+
table_element.deleteRow(i)
|
1251
|
+
end
|
1252
|
+
|
1253
|
+
max_cells = data.map { |row| row.keys.length }.max
|
1254
|
+
|
1255
|
+
data.each do |row|
|
1256
|
+
new_row = table_element.insertRow(-1)
|
1257
|
+
max_cells.times do |i|
|
1258
|
+
key = row.keys[i]
|
1259
|
+
value = row[key]
|
1260
|
+
cell = new_row.insertCell(-1)
|
1261
|
+
if value.instance_of? Atome
|
1262
|
+
html_element = JS.global[:document].getElementById(value.id.to_s)
|
1263
|
+
cell.appendChild(html_element)
|
1264
|
+
else
|
1265
|
+
cell[:textContent] = value.to_s
|
1266
|
+
end
|
1267
|
+
set_td_style(cell)
|
1268
|
+
end
|
1269
|
+
end
|
1270
|
+
end
|
1271
|
+
def set_td_style(td)
|
1272
|
+
cell_height = 50
|
1273
|
+
td[:style][:border] = '1px solid black'
|
1274
|
+
td[:style][:backgroundColor] = 'white'
|
1275
|
+
td[:style][:boxShadow] = '10px 10px 5px #888888'
|
1276
|
+
td[:style][:width] = "#{cell_height}px"
|
1277
|
+
td[:style]['min-width'] = "#{cell_height}px"
|
1278
|
+
td[:style]['max-width'] = "#{cell_height}px"
|
1279
|
+
td[:style]['min-height'] = "#{cell_height}px"
|
1280
|
+
td[:style]['max-height'] = "#{cell_height}px"
|
1281
|
+
td[:style][:height] = "#{cell_height}px"
|
1282
|
+
td[:style][:overflow] = 'hidden'
|
1283
|
+
{ cell_height: cell_height, cell_width: cell_height }
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
|
1287
|
+
def insert_cell(params)
|
1288
|
+
row_index, cell_index = params[:cell]
|
1289
|
+
new_content = params[:content]
|
1290
|
+
container = JS.global[:document].getElementById(@id.to_s)
|
1291
|
+
|
1292
|
+
table = container.querySelector('table')
|
1293
|
+
if table.nil?
|
1294
|
+
puts 'No table found in the container'
|
1295
|
+
return
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
row = table.querySelectorAll('tr')[row_index]
|
1299
|
+
if row.nil?
|
1300
|
+
puts "Row at index #{row_index} not found"
|
1301
|
+
return
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
cell = row.querySelectorAll('td')[cell_index]
|
1305
|
+
if cell.nil?
|
1306
|
+
puts "Cell at index #{cell_index} in row #{row_index} not found"
|
1307
|
+
return
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
if new_content.instance_of? Atome
|
1311
|
+
cell.innerHTML = ''
|
1312
|
+
html_element = JS.global[:document].getElementById(new_content.id.to_s)
|
1313
|
+
cell.appendChild(html_element)
|
1314
|
+
else
|
1315
|
+
cell[:textContent] = new_content.to_s
|
1316
|
+
end
|
1317
|
+
end
|
1318
|
+
|
1319
|
+
def insert_row(params)
|
1320
|
+
insert_at_index = params[:row]
|
1321
|
+
table_element = JS.global[:document].querySelector("##{@id} table")
|
1322
|
+
|
1323
|
+
if table_element.nil?
|
1324
|
+
puts 'Tableau non trouvé'
|
1325
|
+
return
|
1326
|
+
end
|
1327
|
+
|
1328
|
+
tbody = table_element.querySelector('tbody')
|
1329
|
+
|
1330
|
+
header_row = table_element.querySelector('thead tr')
|
1331
|
+
column_count = header_row ? header_row.querySelectorAll('th').to_a.length : 0
|
1332
|
+
|
1333
|
+
new_row = JS.global[:document].createElement('tr')
|
1334
|
+
column_count.times do |cell_index|
|
1335
|
+
td = JS.global[:document].createElement('td')
|
1336
|
+
set_td_style(td)
|
1337
|
+
new_row.appendChild(td)
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
if insert_at_index.zero?
|
1341
|
+
tbody.insertBefore(new_row, tbody.firstChild)
|
1342
|
+
else
|
1343
|
+
reference_row = tbody.querySelectorAll('tr').to_a[insert_at_index]
|
1344
|
+
tbody.insertBefore(new_row, reference_row)
|
1345
|
+
end
|
1346
|
+
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
def insert_column(params)
|
1350
|
+
insert_at_index = params[:column]
|
1351
|
+
table_element = JS.global[:document].querySelector("##{@id} table")
|
1352
|
+
if table_element.nil?
|
1353
|
+
puts 'Table not found'
|
1354
|
+
return
|
1355
|
+
end
|
1356
|
+
rows = table_element.querySelectorAll('tr').to_a
|
1357
|
+
rows.each_with_index do |row, index|
|
1358
|
+
if index == 0
|
1359
|
+
# case1
|
1360
|
+
else
|
1361
|
+
new_cell = JS.global[:document].createElement('td')
|
1362
|
+
new_cell[:innerText] = ''
|
1363
|
+
set_td_style(new_cell)
|
1364
|
+
if insert_at_index.zero?
|
1365
|
+
row.insertBefore(new_cell, row.firstChild)
|
1366
|
+
else
|
1367
|
+
child_nodes = row.querySelectorAll('td').to_a
|
1368
|
+
|
1369
|
+
if insert_at_index < child_nodes.length
|
1370
|
+
reference_cell = child_nodes[insert_at_index]
|
1371
|
+
row.insertBefore(new_cell, reference_cell)
|
1372
|
+
else
|
1373
|
+
row.appendChild(new_cell)
|
1374
|
+
end
|
1375
|
+
end
|
1376
|
+
end
|
1377
|
+
|
1378
|
+
end
|
1379
|
+
|
1380
|
+
end
|
1381
|
+
|
1382
|
+
def table_insert(params)
|
1383
|
+
if params[:cell]
|
1384
|
+
insert_cell(params)
|
1385
|
+
elsif params[:row]
|
1386
|
+
insert_row(params)
|
1387
|
+
elsif params[:column]
|
1388
|
+
insert_column(params)
|
1389
|
+
end
|
1390
|
+
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
|
1394
|
+
def table_remove(params)
|
1395
|
+
if params[:row]
|
1396
|
+
row_index = params[:row]
|
1397
|
+
table_element = JS.global[:document].querySelector("##{@id} table")
|
1398
|
+
|
1399
|
+
if table_element.nil?
|
1400
|
+
puts 'Table not found'
|
1401
|
+
return
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
rows = table_element.querySelectorAll('tbody tr').to_a
|
1405
|
+
|
1406
|
+
if row_index >= rows.length
|
1407
|
+
puts "row not found : #{row_index}"
|
1408
|
+
return
|
1409
|
+
end
|
1410
|
+
row_to_remove = rows[row_index]
|
1411
|
+
|
1412
|
+
row_to_remove[:parentNode].removeChild(row_to_remove)
|
1413
|
+
|
1414
|
+
rows.each_with_index do |row, i|
|
1415
|
+
next if i <= row_index
|
1416
|
+
end
|
1417
|
+
elsif params[:column]
|
1418
|
+
column_index = params[:column]
|
1419
|
+
table_element = JS.global[:document].querySelector("##{@id} table")
|
1420
|
+
|
1421
|
+
if table_element.nil?
|
1422
|
+
puts 'Table not found'
|
1423
|
+
return
|
1424
|
+
end
|
1425
|
+
|
1426
|
+
rows = table_element.querySelectorAll('tbody tr').to_a
|
1427
|
+
rows.each do |row|
|
1428
|
+
cells = row.querySelectorAll('td').to_a
|
1429
|
+
if column_index < cells.length
|
1430
|
+
cell_to_remove = cells[column_index]
|
1431
|
+
cell_to_remove[:parentNode].removeChild(cell_to_remove)
|
1432
|
+
end
|
1433
|
+
end
|
1434
|
+
|
1435
|
+
end
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
# atomisation!
|
1439
|
+
def atomized(html_object)
|
1440
|
+
html_object=html_object[0] if html_object.instance_of? Array
|
1441
|
+
@element = html_object
|
1442
|
+
end
|
1160
1443
|
end
|
1444
|
+
|
1445
|
+
|
@@ -82,3 +82,11 @@ new({ renderer: :html, method: :category, type: :symbol }) do |category_names|
|
|
82
82
|
html.add_class(category_name)
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
new({ method: :data, type: :string, specific: :matrix, renderer: :html }) do |value, _user_proc|
|
87
|
+
html.table(value)
|
88
|
+
end
|
89
|
+
|
90
|
+
new({ method: :type, type: :hash, specific: :atomized, renderer: :html }) do |value, _user_proc|
|
91
|
+
html.atomized(alien)
|
92
|
+
end
|
@@ -51,3 +51,17 @@ new({ method: :remove, renderer: :html, type: :string }) do |object_id_to_remove
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
|
56
|
+
new({ method: :border, type: :hash, renderer: :html }) do |value, _user_proc|
|
57
|
+
thickness = value[:thickness] || 5
|
58
|
+
type = value[:pattern] || :solid
|
59
|
+
color = if value[:color]
|
60
|
+
color_found = value[:color]
|
61
|
+
"#{color_found.red * 255},#{color_found.green * 255},#{color_found.blue * 255},#{color_found.alpha} "
|
62
|
+
else
|
63
|
+
"0,0,0,1"
|
64
|
+
end
|
65
|
+
|
66
|
+
html.style(:border, "#{type} #{thickness}px rgba(#{color})")
|
67
|
+
end
|
@@ -22,3 +22,38 @@ new({ renderer: :html, method: :edit }) do |params|
|
|
22
22
|
html.attr(:contenteditable, params)
|
23
23
|
html.update_data(params)
|
24
24
|
end
|
25
|
+
|
26
|
+
|
27
|
+
new({ method: :border, type: :hash, renderer: :html }) do |value, _user_proc|
|
28
|
+
thickness = value[:thickness] || 5
|
29
|
+
type = value[:pattern] || :solid
|
30
|
+
color = if value[:color]
|
31
|
+
color_found = value[:color]
|
32
|
+
"#{color_found.red * 255},#{color_found.green * 255},#{color_found.blue * 255},#{color_found.alpha} "
|
33
|
+
else
|
34
|
+
"0,0,0,1"
|
35
|
+
end
|
36
|
+
|
37
|
+
html.style(:border, "#{type} #{thickness}px rgba(#{color})")
|
38
|
+
end
|
39
|
+
|
40
|
+
new({ method: :clean, renderer: :html, type: :hash }) do |params|
|
41
|
+
html.table_clean(params)
|
42
|
+
end
|
43
|
+
|
44
|
+
new({ method: :insert, renderer: :html, type: :hash }) do |params|
|
45
|
+
html.table_insert(params)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
new({ method: :remove, renderer: :html, type: :hash }) do |params|
|
51
|
+
html.table_remove(params)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
new({ method: :sort, renderer: :html, type: :hash }) do |params|
|
58
|
+
html.refresh_table(params)
|
59
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
new({ method: :top, type: :integer, renderer: :html }) do |params|
|
4
|
-
|
4
|
+
# TODO: replace px with the unit specified by the user or sepcified by default by the system
|
5
|
+
params="#{params}px" unless params.instance_of?(Symbol)
|
6
|
+
html.style(:top, params)
|
7
|
+
|
5
8
|
end
|
6
9
|
|
7
10
|
new({ method: :top, type: :integer, renderer: :html, specific: :text }) do |params|
|
@@ -10,19 +13,25 @@ end
|
|
10
13
|
new({ method: :top, type: :integer, renderer: :html, specific: :shadow })
|
11
14
|
|
12
15
|
new({ method: :bottom, type: :integer, renderer: :html }) do |params|
|
13
|
-
|
16
|
+
# TODO: replace px with the unit specified by the user or sepcified by default by the system
|
17
|
+
params="#{params}px" unless params.instance_of?(Symbol)
|
18
|
+
html.style(:bottom, params)
|
14
19
|
end
|
15
20
|
|
16
21
|
new({ method: :bottom, type: :integer, renderer: :html, specific: :text }) do |params|
|
17
|
-
html.style(:bottom,
|
22
|
+
html.style(:bottom, params)
|
18
23
|
end
|
19
24
|
|
20
25
|
new({ method: :right, type: :integer, renderer: :html }) do |params|
|
21
|
-
|
26
|
+
# TODO: replace px with the unit specified by the user or sepcified by default by the system
|
27
|
+
params="#{params}px" unless params.instance_of?(Symbol)
|
28
|
+
html.style(:right, params)
|
22
29
|
end
|
23
30
|
|
24
31
|
new({ method: :left, type: :integer, renderer: :html }) do |params|
|
25
|
-
|
32
|
+
# TODO: replace px with the unit specified by the user or sepcified by default by the system
|
33
|
+
params="#{params}px" unless params.instance_of?(Symbol)
|
34
|
+
html.style(:left, params)
|
26
35
|
end
|
27
36
|
|
28
37
|
new({ method: :left, type: :integer, specific: :color, renderer: :html })
|
@@ -84,7 +84,31 @@ new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
|
84
84
|
end
|
85
85
|
|
86
86
|
|
87
|
-
new({ renderer: :html, method: :selected, specific: :text
|
87
|
+
new({ renderer: :html, method: :selected, specific: :text }) do |value, &bloc|
|
88
88
|
html.select_text(value)
|
89
89
|
end
|
90
90
|
|
91
|
+
new({ method: :compute, type: :hash, renderer: :html }) do |params|
|
92
|
+
element = JS.global[:document].getElementById(@id.to_s)
|
93
|
+
bounding_box = element.getBoundingClientRect()
|
94
|
+
|
95
|
+
top = bounding_box[:top]
|
96
|
+
left = bounding_box[:left]
|
97
|
+
width = bounding_box[:width]
|
98
|
+
height = bounding_box[:height]
|
99
|
+
value_found = case params[:particle]
|
100
|
+
when :left
|
101
|
+
left.to_f
|
102
|
+
when :top
|
103
|
+
top.to_f
|
104
|
+
when :width
|
105
|
+
width.to_f
|
106
|
+
when :height
|
107
|
+
height.to_f
|
108
|
+
else
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
@compute[:value] = value_found
|
112
|
+
end
|
113
|
+
|
114
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
$current_hovered_element: untyped
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# dummies html objects :
|
4
|
+
|
5
|
+
#object 1
|
6
|
+
div_rouge = JS.global[:document].call(:createElement, "div")
|
7
|
+
|
8
|
+
div_rouge[:style][:backgroundColor] = "red"
|
9
|
+
div_rouge[:style][:width] = "100px"
|
10
|
+
div_rouge[:style][:height] = "100px"
|
11
|
+
div_rouge.setAttribute('id', "my_div")
|
12
|
+
div_view = JS.global[:document].getElementById('view')
|
13
|
+
div_view.appendChild(div_rouge)
|
14
|
+
|
15
|
+
|
16
|
+
#object 2
|
17
|
+
span_bleu = JS.global[:document].call(:createElement, "span")
|
18
|
+
span_bleu[:style][:backgroundColor] = "blue"
|
19
|
+
span_bleu[:innerHTML] = "blue"
|
20
|
+
span_bleu[:style][:width] = "10px"
|
21
|
+
span_bleu[:style][:height] = "8px"
|
22
|
+
div_rouge.appendChild(span_bleu)
|
23
|
+
|
24
|
+
|
25
|
+
#object 2
|
26
|
+
span_white = JS.global[:document].call(:createElement, "h1")
|
27
|
+
span_white[:style][:color] = "white"
|
28
|
+
span_white[:innerHTML] = "Hello"
|
29
|
+
span_white[:style][:width] = "10px"
|
30
|
+
span_white[:style][:height] = "80px"
|
31
|
+
span_white[:style][:top] = "80px"
|
32
|
+
span_bleu.appendChild(span_white)
|
33
|
+
|
34
|
+
|
35
|
+
# usage example
|
36
|
+
# div_result = HTML.locate(id: 'my_div') # Recherche par ID
|
37
|
+
# alert "id found : #{div_result[:id]}" if div_result
|
38
|
+
|
39
|
+
# first_result = HTML.locate(parent: :view)[1]
|
40
|
+
# result_found = HTML.locate(html: first_result)
|
41
|
+
# alert result_found[0][:tagName]
|
42
|
+
|
43
|
+
# if span_result
|
44
|
+
# span_result.to_a.each do |child|
|
45
|
+
# alert "child found: #{child[:tagName]}"
|
46
|
+
# end
|
47
|
+
# enfants = span_result.to_a.map do |child|
|
48
|
+
# "tag: #{child[:tagName]}, ID: #{child[:id] || 'non défini'}"
|
49
|
+
# end
|
50
|
+
# alert "children found : #{enfants.join(', ')}"
|
51
|
+
# end
|
52
|
+
|
53
|
+
|
54
|
+
wait 1 do
|
55
|
+
div_result = HTML.locate(parent: :view)[0]
|
56
|
+
atomized_el= atomizer({ target: div_result, id: :my_html_obj })
|
57
|
+
atomized_el.color(:pink)
|
58
|
+
atomized_el.position(:absolute)
|
59
|
+
atomized_el.left(66)
|
60
|
+
atomized_el.top(99)
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
wait 2 do
|
65
|
+
div_result = HTML.locate(id: 'my_div') # find by ID
|
66
|
+
|
67
|
+
atomized_el= atomizer({ target: div_result, id: :my_second_html_obj })
|
68
|
+
atomized_el.rotate(55)
|
69
|
+
atomized_el.color(:purple)
|
70
|
+
# atomized_el.display(:block)
|
71
|
+
atomized_el.position(:absolute)
|
72
|
+
atomized_el.left(255)
|
73
|
+
atomized_el.top(255)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
wait 3 do
|
78
|
+
first_result = HTML.locate(parent: :view)[1]
|
79
|
+
result_found = HTML.locate(html: first_result) # Attention HTML.locate always return an array you have to chose
|
80
|
+
new_atomized_el= atomizer({ target: result_found, id: :my_third_html_obj })
|
81
|
+
new_atomized_el.display(:block)
|
82
|
+
new_atomized_el.position(:absolute)
|
83
|
+
new_atomized_el.rotate(12)
|
84
|
+
end
|
85
|
+
|
86
|
+
|