atome 0.5.7.3.6 → 0.5.7.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/documentation/deep learning/architecture.txt +4 -4
  4. data/documentation/deep learning/basic_infos.txt +2 -2
  5. data/documentation/deep learning/example_of_users_code.rb +43 -43
  6. data/documentation/installation/buiding_atome.md +2 -2
  7. data/lib/atome/atome.rb +24 -56
  8. data/lib/atome/extensions/atome.rb +31 -77
  9. data/lib/atome/extensions/sha.rb +7 -7
  10. data/lib/atome/genesis/atomes.rb +1 -1
  11. data/lib/atome/genesis/genesis.rb +6 -95
  12. data/lib/atome/genesis/particles/communication.rb +1 -1
  13. data/lib/atome/genesis/particles/event.rb +0 -8
  14. data/lib/atome/genesis/particles/geometry.rb +3 -4
  15. data/lib/atome/genesis/particles/hierarchy.rb +28 -27
  16. data/lib/atome/genesis/particles/identity.rb +0 -30
  17. data/lib/atome/genesis/particles/material.rb +13 -12
  18. data/lib/atome/genesis/particles/property.rb +41 -16
  19. data/lib/atome/genesis/particles/security.rb +0 -45
  20. data/lib/atome/genesis/particles/utility.rb +77 -137
  21. data/lib/atome/genesis/sparkle.rb +3 -12
  22. data/lib/atome/kernel/black_matter.rb +2 -0
  23. data/lib/atome/kernel/universe.rb +5 -45
  24. data/lib/atome/presets/atome.rb +0 -22
  25. data/lib/atome/utilities/utilities.rb +19 -8
  26. data/lib/atome/version.rb +2 -1
  27. data/lib/molecules/init.rb +0 -14
  28. data/lib/molecules/intuition/tools.rb +24 -43
  29. data/lib/molecules/intuition/utilities.rb +261 -135
  30. data/lib/platform_specific/opal/atome_opal_extensions.rb +0 -1
  31. data/lib/platform_specific/opal/extensions/color.rb +0 -5
  32. data/lib/platform_specific/opal/extensions/geolocation.rb +5 -5
  33. data/lib/platform_specific/opal/extensions/object.rb +1 -1
  34. data/lib/platform_specific/opal/extensions/ping.rb +11 -20
  35. data/lib/renderers/html/effect.rb +0 -11
  36. data/lib/renderers/html/event.rb +0 -7
  37. data/lib/renderers/html/geometry.rb +0 -31
  38. data/lib/renderers/html/html.rb +32 -128
  39. data/lib/renderers/html/material.rb +0 -22
  40. data/lib/renderers/html/spatial.rb +0 -9
  41. data/lib/renderers/html/utility.rb +5 -8
  42. data/lib/renderers/renderer.rb +0 -1
  43. data/vendor/assets/application/examples/account.rb +35 -0
  44. data/vendor/assets/application/examples/actor&role.rb +23 -0
  45. data/vendor/assets/application/examples/animation.rb +1 -1
  46. data/vendor/assets/application/examples/applications.rb +26 -77
  47. data/vendor/assets/application/examples/atome.rb +1 -1
  48. data/vendor/assets/application/examples/attach.rb +7 -7
  49. data/vendor/assets/application/examples/attached.rb +13 -15
  50. data/vendor/assets/application/examples/basic_understanding.rb +1 -1
  51. data/vendor/assets/application/examples/buttons.rb +48 -0
  52. data/vendor/assets/application/examples/clear.rb +12 -12
  53. data/vendor/assets/application/examples/clones&monitoring.rb +1 -1
  54. data/vendor/assets/application/examples/delete.rb +19 -14
  55. data/vendor/assets/application/examples/detach.rb +8 -0
  56. data/vendor/assets/application/examples/dig.rb +1 -1
  57. data/vendor/assets/application/examples/display.rb +6 -6
  58. data/vendor/assets/application/examples/drag.rb +1 -1
  59. data/vendor/assets/application/examples/duplicate.rb +6 -6
  60. data/vendor/assets/application/examples/exchange.rb +17 -0
  61. data/vendor/assets/application/examples/generator_and_build.rb +3 -3
  62. data/vendor/assets/application/examples/hierarchy.rb +5 -5
  63. data/vendor/assets/application/examples/layout.rb +1 -1
  64. data/vendor/assets/application/examples/preset.rb +3 -3
  65. data/vendor/assets/application/examples/selected.rb +1 -1
  66. data/vendor/assets/application/examples/shapes.rb +1 -1
  67. data/vendor/assets/application/examples/size.rb +1 -1
  68. data/vendor/assets/application/examples/test.rb +0 -320
  69. data/vendor/assets/application/examples/tools.rb +136 -192
  70. data/vendor/assets/application/examples/unfasten.rb +23 -0
  71. data/vendor/assets/application/index.rb +1 -1
  72. data/vendor/assets/server/atome_server.rb +1 -0
  73. data/vendor/assets/server/capture.rb +0 -1
  74. data/vendor/assets/server/database.rb +0 -1
  75. data/vendor/assets/server/eDen.rb +16 -94
  76. data/vendor/assets/src/index_server_wasm.html +1 -0
  77. data/vendor/assets/src/index_wasm.html +0 -6
  78. data/vendor/assets/src/js/atome/specific/wasm.js +22 -4
  79. data/vendor/assets/src/js/third_parties/three.min.js +1 -1
  80. data/vendor/assets/src/medias/fonts/Roboto/LICENSE.txt +1 -1
  81. data/vendor/assets/src/medias/fonts/Roboto_Slab/LICENSE.txt +1 -1
  82. metadata +8 -6
  83. data/lib/molecules/_deprecated_examples/site.rb +0 -34
  84. data/lib/molecules/intuition/_deprecated_inputs.rb +0 -111
  85. data/lib/molecules/intuition/_deprecated_toolbox.rb +0 -282
  86. data/lib/platform_specific/opal/extensions/sha.rb +0 -25
@@ -1,10 +1,147 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ class Atome
4
+ def reorder_menu
5
+ disposition = data[:inactive][:disposition]
6
+ margin = data[:inactive][:margin]
7
+ spacing = data[:inactive][:spacing]
8
+ inactive_style = data[:inactive]
9
+ keys_to_exclude = [:margin, :spacing, :disposition, :text]
10
+ inactive_style = inactive_style.reject { |key, _| keys_to_exclude.include?(key) }
11
+ fasten.each_with_index do |atome_f, index|
12
+ menu_item = grab(atome_f)
13
+ if disposition == :horizontal
14
+ menu_item.left = margin[:left] + (inactive_style[:width] + spacing) * index
15
+ menu_item.top = margin[:top]
16
+ else
17
+ menu_item.top = margin[:top] + (inactive_style[:height] + spacing) * index
18
+ menu_item.left = margin[:left]
19
+ end
20
+ end
21
+ end
22
+
23
+ def remove_menu_item(item_to_remove)
24
+ grab(item_to_remove).delete(recursive: true)
25
+ reorder_menu
26
+ end
27
+
28
+ def create_new_button(button_id, position_in_menu, label, code)
29
+ essential_keys = [:inactive, :active]
30
+ buttons_style = data.select { |key, _value| essential_keys.include?(key) }
31
+ menu_item = box({ id: button_id })
32
+ actor({ button_id => :button })
33
+ menu_item.role(:button)
34
+ menu_item.text({ data: label, id: "#{button_id}_label" })
35
+ menu_item.code({ button_code: code })
36
+
37
+ inactive_style = buttons_style[:inactive]
38
+ active_style = buttons_style[:active]
39
+ if active_style
40
+ active_state_text = active_style[:text]
41
+ keys_to_exclude = [:margin, :spacing, :disposition, :text]
42
+
43
+ active_style = active_style.reject { |key, _| keys_to_exclude.include?(key) }
44
+ end
45
+
46
+ if inactive_style
47
+ inactive_state_text = inactive_style[:text]
48
+ margin = inactive_style[:margin]
49
+ spacing = inactive_style[:spacing]
50
+ disposition = inactive_style[:disposition]
51
+ keys_to_exclude = [:margin, :spacing, :disposition, :text]
52
+ inactive_style = inactive_style.reject { |key, _| keys_to_exclude.include?(key) }
53
+ menu_item.set(inactive_style)
54
+
55
+ # reorder_menu
56
+ if disposition == :horizontal
57
+ menu_item.left = margin[:left] + (inactive_style[:width] + spacing) * position_in_menu
58
+ menu_item.top = margin[:top]
59
+ else
60
+ menu_item.top = margin[:top] + (inactive_style[:height] + spacing) * position_in_menu
61
+ menu_item.left = margin[:left]
62
+ end
63
+
64
+ menu_item.text.each do |text_f|
65
+ grab(text_f).set(inactive_state_text)
66
+ end
67
+
68
+ end
69
+
70
+ menu_item.touch(:down) do
71
+ unless @active_item == menu_item.id
72
+
73
+ menu_item.text.each do |text_f|
74
+ # below we unset any active style
75
+ fasten.each do |item_id|
76
+ unless button_id == item_id
77
+ grab(item_id).remove({ all: :shadow })
78
+ grab(item_id).set(inactive_style)
79
+ grab("#{item_id}_label").remove({ all: :shadow })
80
+ grab("#{item_id}_label").set(inactive_state_text)
81
+ end
82
+ grab(text_f).set(active_state_text)
83
+ end
84
+
85
+ end
86
+ menu_item.set(active_style)
87
+ code&.call
88
+ @active_item = menu_item.id
89
+ end
90
+
91
+ end
92
+
93
+ end
94
+
95
+ def add_button(params)
96
+ params.each do |button_id, params|
97
+ label = params[:text]
98
+ code = params[:code]
99
+ index = fasten.length
100
+ create_new_button(button_id, index, label, code)
101
+ end
102
+ false
103
+ end
104
+
105
+ def resize_matrix(params)
106
+ width(params[:width])
107
+ height(params[:height])
108
+ current_matrix = self
109
+ real_width = current_matrix.to_px(:width)
110
+ real_height = current_matrix.to_px(:height)
111
+ spacing = current_matrix.data[:spacing]
112
+ matrix_cells = current_matrix.data[:matrix]
113
+
114
+ total_spacing_x = spacing * (matrix_cells.collect.length ** (0.5) + 1)
115
+ total_spacing_y = spacing * (matrix_cells.collect.length ** (0.5) + 1)
116
+
117
+ if real_width > real_height
118
+ full_size = real_width
119
+ available_width = full_size - total_spacing_x
120
+ available_height = full_size - total_spacing_y
121
+ else
122
+ full_size = real_width
123
+ available_width = full_size - total_spacing_x
124
+ available_height = full_size - total_spacing_y
125
+ end
126
+
127
+ box_width = available_width / matrix_cells.collect.length ** (0.5)
128
+ box_height = available_height / matrix_cells.collect.length ** (0.5)
129
+
130
+ matrix_cells.collect.each_with_index do |box_id, index|
131
+ box = grab(box_id)
132
+ box.width(box_width)
133
+ box.height(box_height)
134
+ box.left((box_width + spacing) * (index % matrix_cells.collect.length ** (0.5)) + spacing)
135
+ box.top((box_height + spacing) * (index / matrix_cells.collect.length ** (0.5)).floor + spacing)
136
+ end
137
+
138
+ end
139
+ end
140
+
3
141
  new(molecule: :input) do |params, bloc|
4
142
  params[:height] ||= 15
5
143
  params[:width] ||= 222
6
144
  new_id = params.delete(:id) || identity_generator
7
-
8
145
  trigger = params.delete(:trigger)
9
146
  trigger ||= :return
10
147
  limit = params.delete(:limit)
@@ -15,8 +152,6 @@ new(molecule: :input) do |params, bloc|
15
152
  text_params ||= {}
16
153
  default_text = params.delete(:default)
17
154
  component = params.delete(:component)
18
- # component ||= {}
19
-
20
155
  default_text ||= :input
21
156
  default_parent = if self.instance_of?(Atome)
22
157
  id
@@ -37,44 +172,33 @@ new(molecule: :input) do |params, bloc|
37
172
  position: :absolute
38
173
  }.merge(text_params)
39
174
  )
40
- # text_input.set()
41
175
  text_input.touch(:down) do
42
176
  input_back.tick(:input)
43
177
  text_input.edit(true)
44
178
  end
45
179
 
46
180
  input_back.touch(:up) do
47
- if input_back.tick[:input] == 1
48
- text_input.component({ selected: true })
49
- end
181
+ text_input.component({ selected: true }) if input_back.tick[:input] == 1
50
182
  end
51
183
 
52
184
  text_input.keyboard(:down) do |native_event|
53
- # text_input.component({ selected: { color: :red, text: :red } })
54
-
55
185
  event = Native(native_event)
56
186
  if event[:keyCode].to_s == '8' || event[:keyCode].to_s == '46'
57
187
  # always allow
58
188
  elsif event[:keyCode].to_s == '13'
59
189
  # we prevent the input
60
- if trigger == :return
61
- bloc.call(text_input.data)
62
- end
190
+ bloc.call(text_input.data) if trigger == :return
63
191
  text_input.edit(false)
64
192
  event.preventDefault()
65
193
  elsif text_input.data.length > limit
66
194
  event.preventDefault()
67
195
  end
68
- if trigger == :down
69
- bloc.call(text_input.data)
70
- end
196
+ bloc.call(text_input.data) if trigger == :down
71
197
  end
72
198
 
73
- text_input.keyboard(:up) do |native_event|
199
+ text_input.keyboard(:up) do |_native_event|
74
200
  input_back.data = text_input.data
75
- if trigger == :up
76
- bloc.call(text_input.data)
77
- end
201
+ bloc.call(text_input.data) if trigger == :up
78
202
  end
79
203
  params.each do |part_f, val_f|
80
204
  input_back.send(part_f, val_f)
@@ -84,13 +208,11 @@ new(molecule: :input) do |params, bloc|
84
208
  end
85
209
 
86
210
  new(molecule: :list) do |params, _bloc|
87
-
88
211
  styles_found = params.delete(:styles)
89
212
  element = params.delete(:element)
90
213
  listing = params.delete(:listing)
91
214
  action = params.delete(:action)
92
215
  new_id = params.delete(:id) || identity_generator
93
-
94
216
  styles_found ||= {
95
217
  width: 99,
96
218
  height: 33,
@@ -105,12 +227,8 @@ new(molecule: :list) do |params, _bloc|
105
227
  top: :center,
106
228
  color: :orange,
107
229
  type: :text }
108
- unless params[:width]
109
- params[:width] = styles_found[:width]
110
- end
111
- unless element[:width]
112
- element[:width] = styles_found[width]
113
- end
230
+ params[:width] = styles_found[:width] unless params[:width]
231
+ element[:width] = styles_found[width] unless element[:width]
114
232
  margin = styles_found[:margin]
115
233
  height_found = styles_found[:height]
116
234
 
@@ -168,7 +286,7 @@ new({ molecule: :slider }) do |params, bloc|
168
286
  red: 0, green: 0, blue: 0, alpha: 0.7
169
287
  })
170
288
 
171
- range = slider.box({ id: "#{slider.id}_range", top: :auto, bottom: 0,tag: { system: true } })
289
+ range = slider.box({ id: "#{slider.id}_range", top: :auto, bottom: 0, tag: { system: true } })
172
290
  range.remove(:box_color)
173
291
  if range_found
174
292
  range.apply(slider_shadow.id,)
@@ -288,81 +406,9 @@ new({ molecule: :slider }) do |params, bloc|
288
406
  slider
289
407
 
290
408
  end
291
- new(molecule: :button) do |params, bloc|
292
- params[:height] ||= 25
293
- params[:width] ||= 25
294
- states = params.delete(:states) || 1
295
- new_id = params.delete(:id) || identity_generator
296
-
297
- back_col = params.delete(:back)
298
- back_col ||= :grey
299
-
300
- default_parent = if self.instance_of?(Atome)
301
- id
302
- else
303
- :view
304
- end
305
- attach_to = params[:attach] || default_parent
306
- renderer_found = grab(attach_to).renderers
307
- button = box(
308
- { renderers: renderer_found, id: new_id, type: :shape, color: back_col,
309
- left: 0, top: 0, data: '', attach: attach_to,
310
- smooth: 3, overflow: :hidden,tag: { system: true }
311
- })
312
- button.remove(:box_color)
313
- button.touch(:down) do
314
- button.tick(:button)
315
- bloc.call((button.tick[:button] - 1) % states)
316
-
317
- end
318
-
319
- params.each do |part_f, val_f|
320
- button.send(part_f, val_f)
321
- end
322
-
323
- button
324
- end
325
409
 
326
410
  new({ particle: :cells })
327
411
 
328
- class Atome
329
- def resize_matrix(params)
330
-
331
- width(params[:width])
332
- height(params[:height])
333
- current_matrix = self
334
- real_width = current_matrix.to_px(:width)
335
- real_height = current_matrix.to_px(:height)
336
- spacing = current_matrix.data[:spacing]
337
- matrix_cells = current_matrix.data[:matrix]
338
-
339
- total_spacing_x = spacing * (matrix_cells.collect.length ** (0.5) + 1)
340
- total_spacing_y = spacing * (matrix_cells.collect.length ** (0.5) + 1)
341
-
342
- if real_width > real_height
343
- full_size = real_width
344
- available_width = full_size - total_spacing_x
345
- available_height = full_size - total_spacing_y
346
- else
347
- full_size = real_width
348
- available_width = full_size - total_spacing_x
349
- available_height = full_size - total_spacing_y
350
- end
351
-
352
- box_width = available_width / matrix_cells.collect.length ** (0.5)
353
- box_height = available_height / matrix_cells.collect.length ** (0.5)
354
-
355
- matrix_cells.collect.each_with_index do |box_id, index|
356
- box = grab(box_id)
357
- box.width(box_width)
358
- box.height(box_height)
359
- box.left((box_width + spacing) * (index % matrix_cells.collect.length ** (0.5)) + spacing)
360
- box.top((box_height + spacing) * (index / matrix_cells.collect.length ** (0.5)).floor + spacing)
361
- end
362
-
363
- end
364
- end
365
-
366
412
  new(molecule: :matrix) do |params, &bloc|
367
413
  params ||= {}
368
414
  # We test if self is main if so we attach the matrix to the view
@@ -438,61 +484,116 @@ new(molecule: :application) do |params, &bloc|
438
484
  else
439
485
  identity_generator
440
486
  end
487
+
441
488
  main_app = box({ id: id_f, width: :auto, height: :auto, top: 0, bottom: 0, left: 0, right: 0, apply: :app_color,
442
489
  category: :application })
443
490
  main_app.remove(:box_color)
444
491
  main_app.instance_variable_set('@pages', {})
445
- menu = params.delete(:menu)
446
- main_app.box(menu.merge({ id: "#{id_f}_menu" })) if menu
447
- params.each do |part_f, val_f|
448
- main_app.send(part_f, val_f)
492
+ main_app.role(:application)
493
+
494
+ menu = buttons({
495
+ id: "#{id_f}_menu",
496
+ attach: id_f,
497
+ inactive: { text: { color: :gray }, width: 66, height: 12, spacing: 3, disposition: :horizontal,
498
+ color: :orange, margin: { left: 33, top: 12 } },
499
+ active: { text: { color: :white, shadow: {} }, color: :blue, shadow: {} },
500
+ })
501
+ main_app.define_singleton_method(:menu) do
502
+ menu
503
+ end
504
+ main_app.define_singleton_method(:pages) do
505
+ @pages
506
+ end
507
+
508
+ main_app.define_singleton_method(:insert) do |bloc_to_add|
509
+ bloc_to_add.each do |page_id, params_f|
510
+ params_f.each do |block_id, block_content|
511
+ @pages[page_id][:blocks] ||= {}
512
+ @pages[page_id][:blocks][block_id.to_sym] = block_content
513
+ end
514
+ @blocks ||= {}
515
+ @blocks[page_id] = @pages[page_id][:blocks]
516
+ end
517
+
518
+ end
519
+ main_app.define_singleton_method(:extract) do |bloc_to_extract|
520
+ bloc_to_extract.each do |page_id, block_id|
521
+ @blocks[page_id].delete(block_id)
522
+ end
523
+
524
+ end
525
+
526
+ main_app.define_singleton_method(:blocks) do
527
+ @blocks
449
528
  end
529
+ main_app.define_singleton_method(:margin) do
530
+ @margin = params[:margin]
531
+ end
532
+ main_app.define_singleton_method(:spacing) do
533
+ @spacing = params[:spacing]
534
+ end
535
+
450
536
  main_app
451
537
  end
452
538
 
453
- new(molecule: :page) do |params, &bloc|
539
+ new(molecule: :page) do |params = nil, &bloc|
540
+ allow_menu = params.delete(:menu)
454
541
  if params[:id]
455
542
  id_f = params.delete(:id)
456
- page_name=params.delete(:name)
543
+ page_name = params.delete(:name)
457
544
  @pages[id_f.to_sym] = params
458
545
  else
459
546
  puts "must send an id"
460
547
  end
461
- page_name= page_name || id_f
462
- menu_f= grab("#{@id}_menu")
463
- page_title=menu_f.text({ data: page_name })
464
- page_title.touch(:down) do
548
+ page_name = page_name || id_f
549
+ item_code = lambda do
465
550
  show(id_f)
466
551
  end
467
-
552
+ unless allow_menu == false
553
+ menu_f = grab("#{@id}_menu")
554
+ menu_f.add_button({ "#{@id}_menu_item_#{page_name}" => {
555
+ text: page_name,
556
+ code: item_code
557
+ } })
558
+ actor({ "#{@id}_menu_item_#{page_name}" => :buttons })
559
+ end
468
560
  end
469
561
 
470
562
  new(molecule: :show) do |page_id, &bloc|
563
+
471
564
  params = @pages[page_id.to_sym]
472
565
  params ||= {}
473
566
  footer = params.delete(:footer)
474
567
  header = params.delete(:header)
475
568
  left_side_bar = params.delete(:left_side_bar)
476
569
  right_side_bar = params.delete(:right_side_bar)
477
- # modules = params.delete(:modules)
478
570
  basic_size = 30
479
- attached.each do |page_id_found|
571
+ fasten.each do |page_id_found|
480
572
  page_found = grab(page_id_found)
481
- # puts "#{page_id_found} : #{page_found}"
482
- page_found.delete({ recursive: true }) if page_found && page_found.category.include?(:page)
573
+ page_found.delete({ recursive: true }) if page_found&.category&.include?(:page)
483
574
  end
484
575
  color({ id: :page_color, red: 0.1, green: 0.1, blue: 0.1 })
485
- # TODO : remove the patch below when possible
486
- id_f = if params[:id]
487
- params.delete(:id)
488
- else
489
- "#{id_f}_#{identity_generator}"
490
- end
576
+
577
+ id_f = "#{id}_content"
491
578
  main_page = box({ width: :auto, depth: -1, height: :auto, id: id_f, top: 0, bottom: 0, left: 0, right: 0, apply: :page_color, category: :page })
492
579
  main_page.remove(:box_color)
493
580
 
494
- main_page.set(params)
581
+ new_page = main_page.box({ width: '100%', height: '100%', top: 0, left: 0, id: page_id })
582
+
583
+ # now looking for associated blocks
584
+ blocks_found = params[:blocks]
585
+ @prev_bloc_height = 0
586
+ blocks_found&.each_with_index do |(bloc_id, bloc_content), index|
587
+
588
+ new_bloc = new_page.box({ id: bloc_id, width: '100%', height: 99, top: spacing + @prev_bloc_height, bottom: 0, left: 0, right: 0 })
589
+ new_bloc.set(bloc_content)
590
+ @prev_bloc_height = @prev_bloc_height + new_bloc.height + spacing
591
+ end
592
+
593
+ keys_to_exclude = [:blocks]
594
+ particles_to_apply = params.reject { |key, _| keys_to_exclude.include?(key) }
495
595
 
596
+ new_page.set(particles_to_apply)
496
597
  if footer
497
598
  new_footer = box({ left: 0, depth: -1, right: 0, width: :auto, top: :auto, bottom: 0, height: basic_size, category: :footer, id: "#{id_f}_footer" })
498
599
  new_footer.remove(:box_color)
@@ -517,7 +618,7 @@ new(molecule: :show) do |page_id, &bloc|
517
618
  new_left_side_bar.set(left_side_bar)
518
619
  end
519
620
 
520
- attached.each do |item_id_found|
621
+ fasten.each do |item_id_found|
521
622
  item_found = grab(item_id_found)
522
623
  if item_found&.category&.include?(:footer)
523
624
  main_page.height(:auto)
@@ -531,24 +632,49 @@ new(molecule: :show) do |page_id, &bloc|
531
632
  if item_found&.category&.include?(:right_side_bar)
532
633
  main_page.width(:auto)
533
634
  main_page.left(item_found.width)
534
- if footer
535
- grab("#{id_f}_footer").right(basic_size)
536
- end
537
- if header
538
- grab("#{id_f}_header").right(basic_size)
539
- end
635
+ grab("#{id_f}_footer").right(basic_size) if footer
636
+ grab("#{id_f}_header").right(basic_size) if header
540
637
  end
541
638
 
542
639
  if item_found&.category&.include?(:left_side_bar)
543
640
  main_page.width(:auto)
544
641
  main_page.right(item_found.width)
545
- if footer
546
- grab("#{id_f}_footer").left(basic_size)
547
- end
548
- if header
549
- grab("#{id_f}_header").left(basic_size)
550
- end
642
+ grab("#{id_f}_footer").left(basic_size) if footer
643
+ grab("#{id_f}_header").left(basic_size) if header
551
644
  end
552
645
  end
553
646
  main_page
647
+ end
648
+
649
+ new(molecule: :buttons) do |params, &bloc|
650
+ role_f = params.delete(:role)
651
+ actor_f = params.delete(:actor)
652
+ params_saf = deep_copy(params)
653
+ context = params.delete(:attach) || :view
654
+ id_f = params.delete(:id) || identity_generator
655
+ main = grab(context).box({ id: id_f })
656
+ main.role(role_f) || main.role(:buttons)
657
+ main.actor(actor_f) if actor_f
658
+ main.color({ blue: 0.5, red: 1, green: 1, alpha: 0 })
659
+ main.data(params_saf)
660
+ default = params.delete(:inactive) || {}
661
+ main.data[:default] = default
662
+ default_text = default.delete(:text)
663
+ main.data[:default_text] = default_text
664
+ active = params.delete(:active) || {}
665
+ inactive = {}
666
+ active.each_key do |part_f|
667
+ inactive[part_f] = default[part_f]
668
+ end
669
+ inactive_text = {}
670
+ active.each_key do |part_f|
671
+ inactive_text[part_f] = default_text[part_f]
672
+ end
673
+ params.each_with_index do |(item_id, part_f), index|
674
+ label = part_f[:text]
675
+ code = part_f[:code]
676
+ main.create_new_button(item_id, index, label, code)
677
+ end
678
+ main
679
+
554
680
  end
@@ -4,7 +4,6 @@ require 'extensions/object'
4
4
  require 'extensions/js'
5
5
  require 'extensions/geolocation'
6
6
  require 'extensions/ping'
7
- require 'extensions/sha'
8
7
  require 'extensions/color'
9
8
  require 'native'
10
9
  require 'promise'
@@ -3,11 +3,6 @@
3
3
  # rgb utility
4
4
  class Atome
5
5
  def rgb_html(string)
6
- # `
7
- # col = w3color(#{string});
8
- # rgb_col=col.toRgb();
9
- # return Opal.hash(rgb_col)
10
- # `
11
6
  js_code = <<-JS
12
7
  var col = w3color('#{string}');
13
8
  var rgb_col = col.toRgb();
@@ -2,13 +2,13 @@
2
2
 
3
3
  class Atome
4
4
  def geolocation
5
- localisation = {latitude: nil, longitude: nil}
5
+ localisation = { latitude: nil, longitude: nil }
6
6
  $window.navigator.geolocate.then do |pos|
7
- localisation[:latitude] = pos.coords.latitude
8
- localisation[:longitude] = pos.coords.longitude
7
+ localisation[:latitude] = pos.coords.latitude
8
+ localisation[:longitude] = pos.coords.longitude
9
9
  end.rescue do |err|
10
- p err
11
- localisation = nil
10
+ p err
11
+ nil
12
12
  end
13
13
  end
14
14
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # main add on
4
4
  def alert(val)
5
- JS.eval("alert('#{val}')")
5
+ JS.eval("alert('#{val.to_s}')")
6
6
  end
@@ -4,28 +4,19 @@
4
4
  class Atome
5
5
  def ping(my_proc = false)
6
6
  instance_exec(my_proc) if my_proc.is_a?(Proc)
7
- # ` var p = new Ping();
8
- # p.ping('https://'+#{address}+'', function (err, data) {
9
- # if (err) {
10
- # return false;
11
- # } else {
12
- # console.log("the site "+#{address}+" is up!");
13
- # }
14
- # });
15
- # `
16
- js_code = <<-JS
17
- var p = new Ping();
18
- p.ping('https://' + "#{address}" + '', function (err, data) {
19
- if (err) {
20
- return false;
21
- } else {
22
- console.log("the site " + "#{address}" + " is up!");
23
- }
24
- });
25
- JS
7
+
8
+ js_code = <<~JS
9
+ var p = new Ping();
10
+ p.ping('https://' + "#{address}" + '', function (err, data) {
11
+ if (err) {
12
+ return false;
13
+ } else {
14
+ console.log("the site " + "#{address}" + " is up!");
15
+ }
16
+ });
17
+ JS
26
18
 
27
19
  # Exécute le code JavaScript
28
20
  JS.eval(js_code)
29
-
30
21
  end
31
22
  end
@@ -28,7 +28,6 @@ new({ renderer: :html, method: :blur, type: :integer }) do |params, _user_proc|
28
28
  end
29
29
  end
30
30
 
31
-
32
31
  new({ renderer: :html, method: :blur, type: :integer, specific: :shadow }) do |params, _user_proc|
33
32
  if params[:affect] == :back
34
33
  html.backdropFilter(:blur, "#{params[:value]}px")
@@ -39,13 +38,3 @@ new({ renderer: :html, method: :blur, type: :integer, specific: :shadow }) do |p
39
38
  affect(affect)
40
39
  end
41
40
 
42
- # new({ particle: :blur, category: :effect, type: :int , specific: :shadow}) do |params|
43
- # alert :cool
44
- # if affect.nil?
45
- # affect_to = affect
46
- # else
47
- # affect_to = [:self]
48
- # end
49
- # val= { value: params, affect: affect_to } unless params.instance_of?(Hash)
50
- # val
51
- # end
@@ -1,13 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  new({ method: :drag, type: :symbol, renderer: :html }) do |params|
4
- # if @drag
5
- # option = @drag[params]
6
- # else
7
- # params = :remove
8
- # option = true
9
- # end
10
- # html.event(:drag, params, option)
11
4
 
12
5
  if params
13
6
  option = @drag[params]