atome 0.5.7.3.9 → 0.5.7.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/atome/atome.rb +24 -56
  3. data/lib/atome/extensions/atome.rb +21 -57
  4. data/lib/atome/extensions/sha.rb +7 -7
  5. data/lib/atome/genesis/genesis.rb +0 -89
  6. data/lib/atome/genesis/particles/communication.rb +1 -1
  7. data/lib/atome/genesis/particles/event.rb +0 -8
  8. data/lib/atome/genesis/particles/geometry.rb +0 -1
  9. data/lib/atome/genesis/particles/hierarchy.rb +0 -34
  10. data/lib/atome/genesis/particles/identity.rb +0 -30
  11. data/lib/atome/genesis/particles/material.rb +0 -11
  12. data/lib/atome/genesis/particles/property.rb +14 -16
  13. data/lib/atome/genesis/particles/security.rb +0 -45
  14. data/lib/atome/genesis/particles/utility.rb +17 -185
  15. data/lib/atome/genesis/sparkle.rb +3 -12
  16. data/lib/atome/kernel/black_matter.rb +0 -1
  17. data/lib/atome/kernel/universe.rb +5 -45
  18. data/lib/atome/presets/atome.rb +0 -22
  19. data/lib/atome/version.rb +1 -1
  20. data/lib/molecules/init.rb +0 -14
  21. data/lib/molecules/intuition/tools.rb +3 -22
  22. data/lib/molecules/intuition/utilities.rb +166 -82
  23. data/lib/platform_specific/opal/atome_opal_extensions.rb +0 -1
  24. data/lib/platform_specific/opal/extensions/color.rb +0 -5
  25. data/lib/platform_specific/opal/extensions/geolocation.rb +5 -5
  26. data/lib/platform_specific/opal/extensions/ping.rb +11 -20
  27. data/lib/renderers/html/atome_html.rb +16 -0
  28. data/lib/renderers/html/effect.rb +0 -11
  29. data/lib/renderers/html/event.rb +0 -7
  30. data/lib/renderers/html/geometry.rb +0 -31
  31. data/lib/renderers/html/html.rb +13 -134
  32. data/lib/renderers/html/material.rb +0 -22
  33. data/lib/renderers/html/spatial.rb +0 -9
  34. data/lib/renderers/html/utility.rb +5 -8
  35. data/lib/renderers/renderer.rb +0 -1
  36. data/vendor/assets/application/examples/applications.rb +24 -71
  37. data/vendor/assets/application/examples/buttons.rb +5 -4
  38. data/vendor/assets/application/examples/to_px.rb +9 -0
  39. data/vendor/assets/application/examples/unfasten.rb +15 -9
  40. data/vendor/assets/application/index.rb +1 -1
  41. data/vendor/assets/server/capture.rb +0 -1
  42. data/vendor/assets/server/database.rb +0 -1
  43. data/vendor/assets/server/eDen.rb +5 -80
  44. data/vendor/assets/src/index_server_wasm.html +0 -3
  45. data/vendor/assets/src/index_wasm.html +0 -6
  46. metadata +3 -6
  47. data/lib/molecules/_deprecated_examples/site.rb +0 -34
  48. data/lib/molecules/intuition/_deprecated_inputs.rb +0 -111
  49. data/lib/molecules/intuition/_deprecated_toolbox.rb +0 -282
  50. data/lib/platform_specific/opal/extensions/sha.rb +0 -25
@@ -13,15 +13,10 @@ class Atome
13
13
  # TODO : remove Essentials.default_params[atome_preset] || {} as it is
14
14
  # applied twice because preset is now a particle
15
15
  preset_params = Essentials.default_params[atome_preset] || {}
16
- # preset_params = {preset: atome_preset}
17
16
  basic_params[:type] = preset_params[:type] || :element
18
- # basic_params[:aid] = identity_generator(:a)
19
- # alert "common => #{params[:id]}"
20
- # alert "basic_params #{basic_params[:id].class}"
21
17
  basic_params[:id] = params[:id] || identity_generator
22
18
  basic_params[:renderers] = @renderers || preset_params[:renderers]
23
19
  essential_params = basic_params.merge(preset_params)
24
- #
25
20
  reordered_params = essential_params.reject { |key, _| params.has_key?(key) }
26
21
  params = reordered_params.merge(params)
27
22
  params[:id] = params[:id].to_sym
@@ -45,23 +40,6 @@ class Atome
45
40
  Atome.new(params, &bloc)
46
41
  end
47
42
 
48
- # def box(params = {}, &bloc)
49
- # atome_preset = :box
50
- # params = atome_common(atome_preset, params)
51
- # preset_common(params, &bloc)
52
- # end
53
- #
54
- # # def intuition(params = {}, &bloc)
55
- # # atome_preset = :intuition
56
- # # params = atome_common(atome_preset, params)
57
- # # preset_common(params, &bloc)
58
- # # end
59
- #
60
- # def circle(params = {}, &bloc)
61
- # atome_preset = :circle
62
- # params = atome_common(atome_preset, params)
63
- # preset_common(params, &bloc)
64
- # end
65
43
  end
66
44
 
67
45
 
data/lib/atome/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # return atome version
4
4
 
5
5
  class Atome
6
- VERSION = '0.5.7.3.9'
6
+ VERSION = '0.5.7.4.3'
7
7
  end
@@ -6,10 +6,6 @@ end
6
6
 
7
7
  class Object
8
8
  include Molecule
9
- # we add a getter for the molecule in standard ruby Object
10
- # def molecule
11
- # @molecule
12
- # end
13
9
  end
14
10
 
15
11
  class Atome
@@ -17,15 +13,5 @@ class Atome
17
13
  end
18
14
 
19
15
 
20
- # tests
21
- # new({application: :compose, header: true, footer: true })
22
- #
23
- # new(page: {name: :home, application: :compose, attach: :root })
24
- #
25
- # new(module: {name: :home, application: :compose, attach: :root })
26
-
27
-
28
-
29
-
30
16
 
31
17
 
@@ -67,11 +67,9 @@ class Atome
67
67
  atome_found = grab(id_found)
68
68
  # unless (atome_found && atome_found.tag[:system])
69
69
  puts 'we have to check if operation is a creation or an alteration to include or exclude the view '
70
- # alert atome_touched
71
70
  Universe.active_tools.each do |tool|
72
- # alert "#{tool}, #{atome_found.id}"
73
71
  apply_tool(tool, atome_found, event)
74
- end # if atome_found #&& !atome_found.tag[:system]
72
+ end
75
73
 
76
74
  break
77
75
  end
@@ -122,8 +120,6 @@ class Atome
122
120
  end
123
121
 
124
122
  def creation(current_tool, tool_actions, atome_touched, a_event)
125
- # we store prev_local_storage prior to lock it to prevent unwanted logs
126
- # prev_local_storage=Universe.allow_localstorage()
127
123
  @creation_mode = true
128
124
  storage_allowed = Universe.allow_localstorage
129
125
  Universe.allow_localstorage = false
@@ -142,7 +138,6 @@ class Atome
142
138
  else
143
139
  grab(:view).send(atome, temp_val)
144
140
  end
145
- # current_tool.data[:treated] << new_atome
146
141
  current_tool.data[:created] << new_atome
147
142
  params.delete(:atome_touched)
148
143
  params[new_atome: new_atome]
@@ -174,9 +169,7 @@ class Atome
174
169
  else
175
170
  atome_touched
176
171
  end
177
- # unless method_found == :alteration && (target.id == :view_color || target.id == :view)
178
- unless method_found == :alteration && target.tag[:system]
179
-
172
+ unless method_found == :alteration && target.tag[:system]
180
173
 
181
174
  tools_scheme[:particles]&.each do |particle_f, value_f|
182
175
  target.send(particle_f, value_f)
@@ -220,7 +213,6 @@ class Atome
220
213
  tool.data[:created] = []
221
214
  tool.data[:prev_states] = {}
222
215
  # generic behavior
223
- # tool.apply(:active_tool_col)
224
216
  grab("#{tool_name}_icon").color(:white)
225
217
  grab("#{tool_name}_label").color(:white)
226
218
  Universe.active_tools << tool_name
@@ -251,8 +243,7 @@ class Atome
251
243
  Atome.apply_tool(tool_name, atome_found, event)
252
244
  end
253
245
  end
254
-
255
- # # activate tool analysis test
246
+ # activate tool analysis test
256
247
  Atome.activate_click_analysis
257
248
  tool.active(true)
258
249
  end
@@ -284,7 +275,6 @@ class Atome
284
275
  # generic behavior
285
276
  # we remove touch and resize binding on newly created atomes
286
277
  tool.apply(:inactive_tool_col)
287
- # alert tool.data[:created]
288
278
  tool.data[:created]&.each do |new_atome|
289
279
  new_atome.drag(false)
290
280
  new_atome.resize(:remove)
@@ -299,7 +289,6 @@ class Atome
299
289
  tool_name = "#{params[:name]}_tool"
300
290
  index = params[:index]
301
291
  tool_scheme = params[:scheme]
302
- # @tool_scheme=params[:scheme]
303
292
  toolbox = params[:toolbox] || {}
304
293
  orientation_wanted = tool_scheme[:orientation] || :sn
305
294
 
@@ -351,8 +340,6 @@ class Atome
351
340
  action: action,
352
341
  allow_alteration: true,
353
342
  allow_creation: true,
354
- # activation: tool_scheme[:activation],
355
- # inactivation: tool_scheme[:inactivation], zone: tool_scheme[:zone],
356
343
  post: tool_scheme[:post],
357
344
  pre: tool_scheme[:pre],
358
345
  }
@@ -421,8 +408,6 @@ class Atome
421
408
  if particle.instance_variable_get('@active')
422
409
  grab(slider_id).delete({ force: true })
423
410
  particle.instance_variable_set('@active', false)
424
- # particle.top(:auto)
425
- # particle.top(:bottom)
426
411
  particle.height(size)
427
412
  particle.top(0)
428
413
  else
@@ -446,9 +431,7 @@ class Atome
446
431
  if grab(slider_id).instance_variable_get('@initialised')
447
432
  Atome.selection.each do |atome_id_to_treat|
448
433
 
449
- # puts "-------> #{tool_scheme[:particles][particle_name]} , #{value }"
450
434
  tool_scheme[:particles][particle_name] = value.to_f / 100
451
- # tools_scheme[:particles]
452
435
  atome_found = grab(atome_id_to_treat)
453
436
  target = grab(atome_found.color.last)
454
437
 
@@ -495,10 +478,8 @@ class Atome
495
478
  tick[tool_name] = 0
496
479
  end
497
480
  end
498
- # puts 'reactivation'
499
481
  tool.instance_variable_set('@prevent_action', false)
500
482
  end
501
-
502
483
  end
503
484
 
504
485
  end
@@ -1,11 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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 reorder_blocs
24
+ @prev_bloc_height = 0
25
+ fasten.each do |bloc_f|
26
+ potential_bloc = grab(bloc_f)
27
+ spacing = potential_bloc.spacing
28
+ if potential_bloc.role && potential_bloc.role.include?(:block)
29
+ potential_bloc.top(spacing + @prev_bloc_height)
30
+ @prev_bloc_height = @prev_bloc_height + potential_bloc.height + spacing
31
+ end
32
+ end
33
+ end
34
+
35
+ def remove_menu_item(item_to_remove)
36
+ grab(item_to_remove).delete(recursive: true)
37
+ reorder_menu
38
+ end
4
39
 
5
40
  def create_new_button(button_id, position_in_menu, label, code)
6
41
  essential_keys = [:inactive, :active]
7
- buttons_style = data.select { |key, value| essential_keys.include?(key) }
42
+ buttons_style = data.select { |key, _value| essential_keys.include?(key) }
8
43
  menu_item = box({ id: button_id })
44
+ actor({ button_id => :button })
45
+ menu_item.role(:button)
9
46
  menu_item.text({ data: label, id: "#{button_id}_label" })
10
47
  menu_item.code({ button_code: code })
11
48
 
@@ -14,6 +51,7 @@ class Atome
14
51
  if active_style
15
52
  active_state_text = active_style[:text]
16
53
  keys_to_exclude = [:margin, :spacing, :disposition, :text]
54
+
17
55
  active_style = active_style.reject { |key, _| keys_to_exclude.include?(key) }
18
56
  end
19
57
 
@@ -26,6 +64,7 @@ class Atome
26
64
  inactive_style = inactive_style.reject { |key, _| keys_to_exclude.include?(key) }
27
65
  menu_item.set(inactive_style)
28
66
 
67
+ # reorder_menu
29
68
  if disposition == :horizontal
30
69
  menu_item.left = margin[:left] + (inactive_style[:width] + spacing) * position_in_menu
31
70
  menu_item.top = margin[:top]
@@ -42,29 +81,33 @@ class Atome
42
81
 
43
82
  menu_item.touch(:down) do
44
83
  unless @active_item == menu_item.id
45
- menu_item.set(active_style)
84
+
46
85
  menu_item.text.each do |text_f|
47
- grab(text_f).set(active_state_text)
48
- end
49
- fasten.each do |item_id|
50
- unless button_id == item_id
51
- grab(item_id).remove({ all: :shadow })
52
- grab(item_id).set(inactive_style)
53
- grab("#{item_id}_label").remove({ all: :shadow })
54
- grab("#{item_id}_label").set(inactive_state_text)
86
+ # below we unset any active style
87
+ fasten.each do |item_id|
88
+ unless button_id == item_id
89
+ grab(item_id).remove({ all: :shadow })
90
+ grab(item_id).set(inactive_style)
91
+ grab("#{item_id}_label").remove({ all: :shadow })
92
+ grab("#{item_id}_label").set(inactive_state_text)
93
+ end
94
+ grab(text_f).set(active_state_text)
55
95
  end
96
+
56
97
  end
57
- code.call if code
98
+ menu_item.set(active_style)
99
+ code&.call
100
+ @active_item = menu_item.id
58
101
  end
59
- @active_item = menu_item.id
102
+
60
103
  end
104
+
61
105
  end
62
106
 
63
107
  def add_button(params)
64
108
  params.each do |button_id, params|
65
109
  label = params[:text]
66
110
  code = params[:code]
67
- # {"new_button"=>{"text"=>"button1", "code"=>#<Proc:0xafe>}}
68
111
  index = fasten.length
69
112
  create_new_button(button_id, index, label, code)
70
113
  end
@@ -72,7 +115,6 @@ class Atome
72
115
  end
73
116
 
74
117
  def resize_matrix(params)
75
-
76
118
  width(params[:width])
77
119
  height(params[:height])
78
120
  current_matrix = self
@@ -106,14 +148,12 @@ class Atome
106
148
  end
107
149
 
108
150
  end
109
-
110
151
  end
111
152
 
112
153
  new(molecule: :input) do |params, bloc|
113
154
  params[:height] ||= 15
114
155
  params[:width] ||= 222
115
156
  new_id = params.delete(:id) || identity_generator
116
-
117
157
  trigger = params.delete(:trigger)
118
158
  trigger ||= :return
119
159
  limit = params.delete(:limit)
@@ -124,8 +164,6 @@ new(molecule: :input) do |params, bloc|
124
164
  text_params ||= {}
125
165
  default_text = params.delete(:default)
126
166
  component = params.delete(:component)
127
- # component ||= {}
128
-
129
167
  default_text ||= :input
130
168
  default_parent = if self.instance_of?(Atome)
131
169
  id
@@ -146,44 +184,33 @@ new(molecule: :input) do |params, bloc|
146
184
  position: :absolute
147
185
  }.merge(text_params)
148
186
  )
149
- # text_input.set()
150
187
  text_input.touch(:down) do
151
188
  input_back.tick(:input)
152
189
  text_input.edit(true)
153
190
  end
154
191
 
155
192
  input_back.touch(:up) do
156
- if input_back.tick[:input] == 1
157
- text_input.component({ selected: true })
158
- end
193
+ text_input.component({ selected: true }) if input_back.tick[:input] == 1
159
194
  end
160
195
 
161
196
  text_input.keyboard(:down) do |native_event|
162
- # text_input.component({ selected: { color: :red, text: :red } })
163
-
164
197
  event = Native(native_event)
165
198
  if event[:keyCode].to_s == '8' || event[:keyCode].to_s == '46'
166
199
  # always allow
167
200
  elsif event[:keyCode].to_s == '13'
168
201
  # we prevent the input
169
- if trigger == :return
170
- bloc.call(text_input.data)
171
- end
202
+ bloc.call(text_input.data) if trigger == :return
172
203
  text_input.edit(false)
173
204
  event.preventDefault()
174
205
  elsif text_input.data.length > limit
175
206
  event.preventDefault()
176
207
  end
177
- if trigger == :down
178
- bloc.call(text_input.data)
179
- end
208
+ bloc.call(text_input.data) if trigger == :down
180
209
  end
181
210
 
182
- text_input.keyboard(:up) do |native_event|
211
+ text_input.keyboard(:up) do |_native_event|
183
212
  input_back.data = text_input.data
184
- if trigger == :up
185
- bloc.call(text_input.data)
186
- end
213
+ bloc.call(text_input.data) if trigger == :up
187
214
  end
188
215
  params.each do |part_f, val_f|
189
216
  input_back.send(part_f, val_f)
@@ -193,13 +220,11 @@ new(molecule: :input) do |params, bloc|
193
220
  end
194
221
 
195
222
  new(molecule: :list) do |params, _bloc|
196
-
197
223
  styles_found = params.delete(:styles)
198
224
  element = params.delete(:element)
199
225
  listing = params.delete(:listing)
200
226
  action = params.delete(:action)
201
227
  new_id = params.delete(:id) || identity_generator
202
-
203
228
  styles_found ||= {
204
229
  width: 99,
205
230
  height: 33,
@@ -214,12 +239,8 @@ new(molecule: :list) do |params, _bloc|
214
239
  top: :center,
215
240
  color: :orange,
216
241
  type: :text }
217
- unless params[:width]
218
- params[:width] = styles_found[:width]
219
- end
220
- unless element[:width]
221
- element[:width] = styles_found[width]
222
- end
242
+ params[:width] = styles_found[:width] unless params[:width]
243
+ element[:width] = styles_found[width] unless element[:width]
223
244
  margin = styles_found[:margin]
224
245
  height_found = styles_found[:height]
225
246
 
@@ -475,22 +496,65 @@ new(molecule: :application) do |params, &bloc|
475
496
  else
476
497
  identity_generator
477
498
  end
499
+
478
500
  main_app = box({ id: id_f, width: :auto, height: :auto, top: 0, bottom: 0, left: 0, right: 0, apply: :app_color,
479
501
  category: :application })
480
502
  main_app.remove(:box_color)
481
503
  main_app.instance_variable_set('@pages', {})
504
+ main_app.role(:application)
505
+
506
+ menu = buttons({
507
+ id: "#{id_f}_menu",
508
+ # left: 66,
509
+ depth: 9999,
510
+ attach: id_f,
511
+ inactive: { text: { color: :gray }, width: 66, height: 12, spacing: 3, disposition: :horizontal,
512
+ color: :orange, margin: { left: 33, top: 12 } },
513
+ active: { text: { color: :white, shadow: {} }, color: :blue, shadow: {} },
514
+ })
515
+ main_app.define_singleton_method(:menu) do
516
+ menu
517
+ end
518
+ main_app.define_singleton_method(:pages) do
519
+ @pages
520
+ end
521
+
522
+ main_app.define_singleton_method(:insert) do |bloc_to_add|
523
+ bloc_to_add.each do |page_id, params_f|
524
+
525
+ params_f.each do |block_id, block_content|
526
+ @pages[page_id][:blocks] ||= {}
527
+ @pages[page_id][:blocks][block_id.to_sym] = block_content
528
+ end
529
+ @blocks ||= {}
530
+ @blocks[page_id] = @pages[page_id][:blocks]
531
+ end
532
+
533
+ end
534
+ main_app.define_singleton_method(:extract) do |bloc_to_extract|
535
+
536
+ bloc_to_extract.each do |page_id, block_id|
537
+ grab(block_id).delete({ recursive: true })
538
+ @blocks[page_id].delete(block_id)
539
+ grab(page_id).reorder_blocs
540
+ end
541
+
542
+ end
543
+
544
+ main_app.define_singleton_method(:blocks) do
545
+ @blocks
546
+ end
547
+ main_app.define_singleton_method(:margin) do
548
+ @margin = params[:margin]
549
+ end
550
+ main_app.define_singleton_method(:spacing) do
551
+ @spacing = params[:spacing]
552
+ end
482
553
 
483
- buttons({
484
- id: "#{id_f}_menu",
485
- attach: id_f,
486
- inactive: { text: { color: :gray }, width: 66, height: 12, spacing: 3, disposition: :horizontal,
487
- color: :orange, margin: { left: 33, top: 12 } },
488
- active: { text: { color: :white, shadow: {} }, color: :blue, shadow: {} },
489
- })
490
554
  main_app
491
555
  end
492
556
 
493
- new(molecule: :page) do |params, &bloc|
557
+ new(molecule: :page) do |params = nil, &bloc|
494
558
  allow_menu = params.delete(:menu)
495
559
  if params[:id]
496
560
  id_f = params.delete(:id)
@@ -510,55 +574,77 @@ new(molecule: :page) do |params, &bloc|
510
574
  code: item_code
511
575
  } })
512
576
  actor({ "#{@id}_menu_item_#{page_name}" => :buttons })
513
- menu_f.role([:button])
514
577
  end
515
578
  end
516
579
 
517
580
  new(molecule: :show) do |page_id, &bloc|
581
+
518
582
  params = @pages[page_id.to_sym]
519
583
  params ||= {}
520
584
  footer = params.delete(:footer)
521
585
  header = params.delete(:header)
522
586
  left_side_bar = params.delete(:left_side_bar)
523
587
  right_side_bar = params.delete(:right_side_bar)
524
- # modules = params.delete(:modules)
525
588
  basic_size = 30
526
589
  fasten.each do |page_id_found|
527
590
  page_found = grab(page_id_found)
528
- page_found.delete({ recursive: true }) if page_found && page_found.category.include?(:page)
591
+ page_found.delete({ recursive: true }) if page_found&.category&.include?(:page)
529
592
  end
530
593
  color({ id: :page_color, red: 0.1, green: 0.1, blue: 0.1 })
531
- # TODO : remove the patch below when possible
532
- id_f = if params[:id]
533
- params.delete(:id)
534
- else
535
- "#{id_f}_#{identity_generator}"
536
- end
594
+
595
+ id_f = "#{id}_content"
537
596
  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 })
538
597
  main_page.remove(:box_color)
539
598
 
540
- main_page.set(params)
599
+ new_page = main_page.box({ width: '100%', height: '100%', top: 0, left: 0, id: page_id })
600
+
601
+ # now looking for associated blocks
602
+ blocks_found = params[:blocks]
603
+ @prev_bloc_height = 0
604
+ blocks_found&.each do |bloc_id, bloc_content|
541
605
 
606
+ new_bloc = new_page.box({ id: bloc_id, role: :block, width: '100%', height: 99, top: spacing + @prev_bloc_height, bottom: 0, left: 0, right: 0, spacing: spacing })
607
+
608
+ new_bloc.define_singleton_method(:subs) do |sub_params|
609
+ @prev_sub_width = 0
610
+ sub_params.each do |sub_id, sub_content|
611
+ sub_created = new_bloc.box({ id: sub_id, height: '100%', left: @prev_sub_width })
612
+ sub_created.set(sub_content)
613
+ @prev_sub_width = @prev_sub_width + sub_created.to_px(:width) + spacing
614
+ sub_created.width(sub_created.to_percent(:width))
615
+ sub_created.left(sub_created.to_percent(:left))
616
+ end
617
+
618
+ end
619
+ new_bloc.set(bloc_content)
620
+
621
+ @prev_bloc_height = @prev_bloc_height + new_bloc.height + spacing
622
+ end
623
+
624
+ keys_to_exclude = [:blocks]
625
+ particles_to_apply = params.reject { |key, _| keys_to_exclude.include?(key) }
626
+
627
+ new_page.set(particles_to_apply)
542
628
  if footer
543
- new_footer = box({ left: 0, depth: -1, right: 0, width: :auto, top: :auto, bottom: 0, height: basic_size, category: :footer, id: "#{id_f}_footer" })
629
+ new_footer = box({ left: 0, depth: 999, right: 0, width: :auto, top: :auto, bottom: 0, height: basic_size, category: :footer, id: "#{id_f}_footer" })
544
630
  new_footer.remove(:box_color)
545
631
  new_footer.set(footer)
546
632
  end
547
633
 
548
634
  if header
549
- new_header = box({ left: 0, right: 0, depth: -1, width: :auto, top: 0, height: basic_size, category: :header, id: "#{id_f}_header" })
635
+ new_header = box({ left: 0, right: 0, depth: 999, width: :auto, top: 0, height: basic_size, category: :header, id: "#{id_f}_header" })
550
636
  new_header.remove(:box_color)
551
637
  new_header.set(header)
552
638
  end
553
639
 
554
640
  if right_side_bar
555
- new_right_side_bar = box({ left: :auto, depth: -1, right: 0, width: basic_size, top: 0, bottom: 0, height: :auto, category: :right_side_bar, id: "#{id_f}_right_side_bar" })
641
+ new_right_side_bar = box({ left: :auto, depth: 999, right: 0, width: basic_size, top: 0, bottom: 0, height: :auto, category: :right_side_bar, id: "#{id_f}_right_side_bar" })
556
642
  new_right_side_bar.remove(:box_color)
557
643
  new_right_side_bar.set(right_side_bar)
558
644
  end
559
645
 
560
646
  if left_side_bar
561
- new_left_side_bar = box({ left: 0, right: :auto, depth: -1, width: basic_size, top: 0, bottom: 0, height: :auto, category: :left_side_bar, id: "#{id_f}_left_side_bar" })
647
+ new_left_side_bar = box({ left: 0, right: :auto, depth: 999, width: basic_size, top: 0, bottom: 0, height: :auto, category: :left_side_bar, id: "#{id_f}_left_side_bar" })
562
648
  new_left_side_bar.remove(:box_color)
563
649
  new_left_side_bar.set(left_side_bar)
564
650
  end
@@ -577,35 +663,36 @@ new(molecule: :show) do |page_id, &bloc|
577
663
  if item_found&.category&.include?(:right_side_bar)
578
664
  main_page.width(:auto)
579
665
  main_page.left(item_found.width)
580
- if footer
581
- grab("#{id_f}_footer").right(basic_size)
582
- end
583
- if header
584
- grab("#{id_f}_header").right(basic_size)
585
- end
666
+ grab("#{id_f}_footer").right(basic_size) if footer
667
+ grab("#{id_f}_header").right(basic_size) if header
586
668
  end
587
669
 
588
670
  if item_found&.category&.include?(:left_side_bar)
589
671
  main_page.width(:auto)
590
672
  main_page.right(item_found.width)
591
- if footer
592
- grab("#{id_f}_footer").left(basic_size)
593
- end
594
- if header
595
- grab("#{id_f}_header").left(basic_size)
596
- end
673
+ grab("#{id_f}_footer").left(basic_size) if footer
674
+ grab("#{id_f}_header").left(basic_size) if header
597
675
  end
598
676
  end
599
677
  main_page
600
678
  end
601
679
 
680
+
681
+
602
682
  new(molecule: :buttons) do |params, &bloc|
683
+
684
+ keys_to_keep = [:inactive, :active]
685
+ remaining_params = remove_key_pair_but(params, keys_to_keep)
686
+ params = filter_keys_to_keep(params, keys_to_keep)
687
+
603
688
  role_f = params.delete(:role)
604
689
  actor_f = params.delete(:actor)
605
690
  params_saf = deep_copy(params)
606
- context = params.delete(:attach) || :view
607
- id = params.delete(:id) || identity_generator
608
- main = grab(context).box({ id: id })
691
+ context = remaining_params.delete(:attach) || :view
692
+ id_f = remaining_params.delete(:id) || identity_generator
693
+ main = grab(context).box({ id: id_f })
694
+ main.set(remaining_params)
695
+
609
696
  main.role(role_f) || main.role(:buttons)
610
697
  main.actor(actor_f) if actor_f
611
698
  main.color({ blue: 0.5, red: 1, green: 1, alpha: 0 })
@@ -615,7 +702,6 @@ new(molecule: :buttons) do |params, &bloc|
615
702
  default_text = default.delete(:text)
616
703
  main.data[:default_text] = default_text
617
704
  active = params.delete(:active) || {}
618
- active_text = active.delete(:text)
619
705
  inactive = {}
620
706
  active.each_key do |part_f|
621
707
  inactive[part_f] = default[part_f]
@@ -624,12 +710,10 @@ new(molecule: :buttons) do |params, &bloc|
624
710
  active.each_key do |part_f|
625
711
  inactive_text[part_f] = default_text[part_f]
626
712
  end
627
-
628
713
  params.each_with_index do |(item_id, part_f), index|
629
714
  label = part_f[:text]
630
715
  code = part_f[:code]
631
716
  main.create_new_button(item_id, index, label, code)
632
-
633
717
  end
634
718
  main
635
719
 
@@ -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