atome 0.5.1.4 → 0.5.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +23 -2
  3. data/lib/atome/atome.rb +40 -18
  4. data/lib/atome/extensions/atome.rb +5 -26
  5. data/lib/atome/extensions/geolocation.rb +0 -1
  6. data/lib/atome/extensions/matrix.rb +171 -0
  7. data/lib/atome/extensions/ping.rb +9 -11
  8. data/lib/atome/genesis/generators/atome.rb +14 -2
  9. data/lib/atome/genesis/generators/communication.rb +1 -1
  10. data/lib/atome/genesis/generators/event.rb +36 -0
  11. data/lib/atome/genesis/generators/identity.rb +28 -2
  12. data/lib/atome/genesis/generators/material.rb +21 -0
  13. data/lib/atome/genesis/generators/spatial.rb +1 -0
  14. data/lib/atome/genesis/generators/utility.rb +20 -2
  15. data/lib/atome/genesis/genesis.rb +2 -2
  16. data/lib/atome/genesis/sparkle.rb +1 -1
  17. data/lib/atome/helpers/callbacks.rb +76 -0
  18. data/lib/atome/helpers/essentials.rb +10 -5
  19. data/lib/atome/helpers/utilities.rb +52 -8
  20. data/lib/atome/kernel/universe.rb +0 -4
  21. data/lib/atome/presets/atome.rb +12 -8
  22. data/lib/atome/renderers/browser/atome.rb +8 -19
  23. data/lib/atome/renderers/browser/browser.rb +15 -210
  24. data/lib/atome/renderers/browser/effect.rb +2 -2
  25. data/lib/atome/renderers/browser/event.rb +49 -11
  26. data/lib/atome/renderers/browser/geometry.rb +2 -2
  27. data/lib/atome/renderers/browser/helpers/animation_helper.rb +69 -0
  28. data/lib/atome/renderers/browser/helpers/browser_helper.rb +17 -0
  29. data/lib/atome/renderers/browser/helpers/color_helper.rb +33 -0
  30. data/lib/atome/renderers/browser/helpers/drag_helper.rb +39 -0
  31. data/lib/atome/renderers/browser/helpers/effect_helper.rb +26 -0
  32. data/lib/atome/renderers/browser/helpers/event_helper.rb +59 -0
  33. data/lib/atome/renderers/browser/helpers/image_helper.rb +27 -0
  34. data/lib/atome/renderers/browser/helpers/shadow_helper.rb +33 -0
  35. data/lib/atome/renderers/browser/helpers/shape_helper.rb +22 -0
  36. data/lib/atome/renderers/browser/helpers/text_helper.rb +26 -0
  37. data/lib/atome/renderers/browser/helpers/video_helper.rb +43 -0
  38. data/lib/atome/renderers/browser/helpers/web_helper.rb +30 -0
  39. data/lib/atome/renderers/browser/identity.rb +10 -3
  40. data/lib/atome/renderers/browser/material.rb +28 -5
  41. data/lib/atome/renderers/browser/spatial.rb +36 -5
  42. data/lib/atome/renderers/browser/utility.rb +21 -12
  43. data/lib/atome/renderers/headless/utility.rb +2 -2
  44. data/lib/atome/renderers/html/atome.rb +5 -5
  45. data/lib/atome/renderers/html/effect.rb +1 -1
  46. data/lib/atome/renderers/html/event.rb +1 -1
  47. data/lib/atome/renderers/html/geometry.rb +2 -2
  48. data/lib/atome/renderers/html/html.rb +1 -1
  49. data/lib/atome/renderers/html/identity.rb +2 -2
  50. data/lib/atome/renderers/html/spatial.rb +5 -5
  51. data/lib/atome/renderers/html/utility.rb +7 -7
  52. data/lib/atome/renderers/server/utility.rb +2 -2
  53. data/lib/atome/version.rb +1 -1
  54. data/lib/atome.rb +6 -4
  55. data/sig/atome.rbs +1 -0
  56. data/sig/atome_js.rbs +1 -0
  57. data/vendor/assets/build/css/style.css +25 -17
  58. data/vendor/assets/build/index.html +12 -3
  59. data/vendor/assets/build/js/atome/atome.js +150 -145
  60. data/vendor/assets/build/js/atome/atome_helpers/atome_animate.js +65 -0
  61. data/vendor/assets/build/js/atome/atome_helpers/atome_drag.js +85 -0
  62. data/vendor/assets/build/js/atome/atome_helpers/atome_file.js +7 -0
  63. data/vendor/assets/build/js/atome/atome_helpers/atome_sort.js +20 -0
  64. data/vendor/assets/build/js/atome/atome_helpers/atome_time.js +10 -0
  65. data/vendor/assets/build/js/atome/atome_helpers/atome_video.js +12 -0
  66. data/vendor/assets/build/js/third_parties/popmotion.min.js +1 -1
  67. data/vendor/assets/build/js/third_parties/sortable.min.js +2 -0
  68. data/vendor/assets/build/js/third_parties/wad.min.js +9 -0
  69. data/vendor/assets/build/medias/audios/Binrpilot.mp3 +0 -0
  70. data/vendor/assets/build/medias/rubies/examples/_2_solve.rb +45 -0
  71. data/vendor/assets/build/medias/rubies/examples/_audio.rb +178 -0
  72. data/vendor/assets/build/medias/rubies/examples/_dataset.rb +82 -0
  73. data/vendor/assets/build/medias/rubies/examples/_markers.rb +57 -0
  74. data/vendor/assets/build/medias/rubies/examples/_os.rb +29 -0
  75. data/vendor/assets/build/medias/rubies/examples/_vie.rb +211 -0
  76. data/vendor/assets/build/medias/rubies/examples/animation.rb +81 -0
  77. data/vendor/assets/build/medias/rubies/examples/at.rb +21 -0
  78. data/vendor/assets/build/medias/rubies/examples/{atome.new.rb → atome_new.rb} +5 -5
  79. data/vendor/assets/build/medias/rubies/examples/bottom.rb +1 -1
  80. data/vendor/assets/build/medias/rubies/examples/center.rb +21 -0
  81. data/vendor/assets/build/medias/rubies/examples/clone.rb +20 -0
  82. data/vendor/assets/build/medias/rubies/examples/color.rb +20 -15
  83. data/vendor/assets/build/medias/rubies/examples/cursor.rb +7 -0
  84. data/vendor/assets/build/medias/rubies/examples/delete.rb +25 -3
  85. data/vendor/assets/build/medias/rubies/examples/drag.rb +39 -0
  86. data/vendor/assets/build/medias/rubies/examples/edit.rb +12 -0
  87. data/vendor/assets/build/medias/rubies/examples/empty_atome.rb +12 -0
  88. data/vendor/assets/build/medias/rubies/examples/hide.rb +7 -0
  89. data/vendor/assets/build/medias/rubies/examples/matrix.rb +58 -0
  90. data/vendor/assets/build/medias/rubies/examples/monitoring.rb +22 -11
  91. data/vendor/assets/build/medias/rubies/examples/mute.rb +22 -0
  92. data/vendor/assets/build/medias/rubies/examples/on.rb +7 -1
  93. data/vendor/assets/build/medias/rubies/examples/{parent.rb → parents.rb} +6 -6
  94. data/vendor/assets/build/medias/rubies/examples/pause.rb +15 -0
  95. data/vendor/assets/build/medias/rubies/examples/play.rb +15 -0
  96. data/vendor/assets/build/medias/rubies/examples/read.rb +7 -4
  97. data/vendor/assets/build/medias/rubies/examples/remove.rb +16 -0
  98. data/vendor/assets/build/medias/rubies/examples/right.rb +1 -1
  99. data/vendor/assets/build/medias/rubies/examples/schedule.rb +2 -2
  100. data/vendor/assets/build/medias/rubies/examples/shadow.rb +8 -1
  101. data/vendor/assets/build/medias/rubies/examples/sort.rb +19 -0
  102. data/vendor/assets/build/medias/rubies/examples/style.rb +4 -0
  103. data/vendor/assets/build/medias/rubies/examples/time.rb +14 -0
  104. data/vendor/assets/build/medias/rubies/examples/touch.rb +50 -7
  105. data/vendor/assets/build/medias/texts/lorem.txt +1 -0
  106. metadata +50 -7
  107. data/lib/atome/processors/utilities.rb +0 -10
  108. data/vendor/assets/build/medias/rubies/examples/_animation.rb +0 -0
  109. data/vendor/assets/build/medias/rubies/examples/_drag.rb +0 -44
@@ -2,10 +2,10 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:browser_width) do |value|
5
+ generator.build_render(:browser_width) do |value|
6
6
  @browser_object.style[:width] = "#{value}px"
7
7
  end
8
8
 
9
- generator.build_render_method(:browser_height) do |value|
9
+ generator.build_render(:browser_height) do |value|
10
10
  @browser_object.style[:height] = "#{value}px"
11
11
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ def self.anim_convertor(value)
6
+ { left: [:left, "#{value}px"], right: [:right, "#{value}px"], top: [:top, "#{value}px"],
7
+ bottom: [:bottom, "#{value}px"], smooth: ['border-radius', "#{value}px"],
8
+ left_add: ['transform', "translateX(#{value}px)"],
9
+ right_add: ['transform', "translateY(#{value}px)"],
10
+ width: [:width, "#{value}px"], height: [:height, "#{value}px"] }
11
+ end
12
+
13
+ def self.anim_value_analysis(value, particle_found, atome_found)
14
+ case value
15
+ when :self
16
+ # this case mean the user use the current atome so we get the particle value of the atome
17
+ value = atome_found.atome[particle_found]
18
+ when Integer
19
+ value
20
+ else
21
+ # this case mean the user try to pass an id so we get the particle value of the atome
22
+ value = grab(value).atome[particle_found]
23
+ value
24
+ end
25
+ value
26
+ end
27
+
28
+ def self.send_anim_to_js(animation, atome_hash, atome_found, atome_id, animation_atome)
29
+ animated_particle = animation[0]
30
+ start_value = animation[1]
31
+ end_value = animation[2]
32
+ original_particle = animation[3]
33
+ atome_js.JS.animate(animated_particle, atome_hash[:duration], atome_hash[:damping], atome_hash[:ease],
34
+ atome_hash[:mass], atome_hash[:repeat], atome_hash[:stiffness], atome_hash[:velocity],
35
+ start_value, end_value, atome_id, atome_found, atome_hash, original_particle, animation_atome)
36
+ end
37
+
38
+ def self.sanitize_anim_params(value, particle_found, atome_hash, atome_found, atome_id, animation_atome)
39
+ start_value = anim_value_analysis(value, particle_found, atome_found)
40
+ start_value = BrowserHelper.anim_convertor(start_value)[particle_found][1]
41
+ end_value = anim_value_analysis(atome_hash[:end][particle_found], particle_found, atome_found)
42
+ end_value = BrowserHelper.anim_convertor(end_value)[particle_found][1]
43
+ animated_particle = BrowserHelper.anim_convertor(value)[particle_found][0]
44
+ # animation is a stupid array to satisfy rubocop stupidity
45
+ animation = [animated_particle, start_value, end_value, particle_found]
46
+ send_anim_to_js(animation, atome_hash, atome_found, atome_id, animation_atome)
47
+ end
48
+
49
+ def self.anim_pop_motion_converter(atome_hash, atome_found, atome_id, animation_atome)
50
+ atome_hash[:dampingRatio] = atome_hash.delete(:damping)
51
+ atome_hash[:begin].each do |particle_found, value|
52
+ sanitize_anim_params(value, particle_found, atome_hash, atome_found, atome_id, animation_atome)
53
+ end
54
+ end
55
+
56
+ def self.begin_animation(atome_hash, atome_found, atome_id, animation_atome)
57
+ anim_pop_motion_converter(atome_hash, atome_found, atome_id, animation_atome)
58
+ end
59
+
60
+ def self.browser_play_animation(_options, _browser_object, atome_hash, animation_atome, proc)
61
+ atome_hash[:targets] = [:eDen] unless atome_hash[:targets]
62
+ animation_atome.play_active_proc = proc
63
+ atome_hash[:targets].each do |target|
64
+ atome_found = grab(target)
65
+ atome_id = atome_found.atome[:id]
66
+ begin_animation(atome_hash, atome_found, atome_id, animation_atome)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ def self.browser_document
6
+ # Work because of the patched version of opal-browser(0.39)
7
+ Browser.window
8
+ end
9
+
10
+ def self.browser_attach_div(parents, html_object, _atome)
11
+ html_object.append_to(browser_document[parents])
12
+ end
13
+
14
+ def self.browser_attach_style(parents, _html_object, atome)
15
+ browser_document[parents].add_class(atome[:id])
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ def self.browser_colorize_color(color_updated, atome)
6
+ `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.backgroundColor = #{color_updated}`
7
+ end
8
+
9
+ def self.browser_colorize_shadow(color_updated, atome)
10
+ left = atome[:left]
11
+ top = atome[:top]
12
+ blur = atome[:blur]
13
+ direction = atome[:direction]
14
+ shadow_updated = "#{left}px #{top}px #{blur}px #{color_updated} #{direction}"
15
+ `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
16
+ end
17
+
18
+ def self.browser_left_color(_value, _browser_object, _atome)
19
+ puts 'code to write when implementing gradient'
20
+ end
21
+
22
+ def self.browser_right_color(_value, _browser_object, _atome)
23
+ puts 'code to write when implementing gradient'
24
+ end
25
+
26
+ def self.browser_top_color(_value, _browser_object, _atome)
27
+ puts 'code to write when implementing gradient'
28
+ end
29
+
30
+ def self.browser_bottom_color(_value, _browser_object, _atome)
31
+ puts 'code to write when implementing gradient'
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+
5
+ module BrowserHelper
6
+ def self.browser_drag_move(params, atome_id, atome, proc)
7
+ atome.drag_move_proc = proc
8
+ atome_js.JS.drag(params, atome_id, atome)
9
+ end
10
+
11
+ def self.browser_drag_lock(params, atome_id, atome, _proc)
12
+ atome_js.JS.lock(params, atome_id, atome)
13
+ end
14
+
15
+ def self.browser_drag_remove(params, atome_id, atome, _proc)
16
+ params = params != true
17
+ atome_js.JS.remove(params, atome_id, atome)
18
+ end
19
+
20
+ def self.browser_drag_snap(params, atome_id, atome, _proc)
21
+ atome_js.JS.snap(params.to_n, atome_id, atome)
22
+ end
23
+
24
+ def self.browser_drag_inertia(params, atome_id, atome, _proc)
25
+ atome_js.JS.inertia(params, atome_id, atome)
26
+ end
27
+
28
+ def self.browser_drag_constraint(params, atome_id, atome, _proc)
29
+ atome_js.JS.constraint(params.to_n, atome_id, atome)
30
+ end
31
+
32
+ def self.browser_drag_start(_params, _atome_id, atome, proc)
33
+ atome.drag_start_proc = proc
34
+ end
35
+
36
+ def self.browser_drag_end(_params, _atome_id, atome, proc)
37
+ atome.drag_end_proc = proc
38
+ end
39
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ def self.common_shadow_helper
6
+ alert :zgeg
7
+ end
8
+
9
+ def self.browser_blur_style(_browser_object, value, atome)
10
+ b_left = "#{atome[:left]}px"
11
+ b_top = "#{atome[:top]}px"
12
+ b_blur = "#{atome[:blur] = value}px"
13
+ b_red = atome[:red] * 255
14
+ b_green = atome[:green] * 255
15
+ b_blue = (atome[:blue]) * 255
16
+ b_direction = atome[:direction]
17
+ b_alpha = atome[:alpha]
18
+
19
+ shadow_updated = "#{b_left} #{b_top} #{b_blur} rgba(#{b_red}, #{b_green}, #{b_blue}, #{b_alpha}) #{b_direction}"
20
+ `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
21
+ end
22
+
23
+ def self.browser_blur_div(browser_object, value, _atome)
24
+ browser_object.style[:filter] = "blur(#{value}px)"
25
+ end
26
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+
6
+ def self.touch_helper_callback(event, proc)
7
+ instance_exec(event, &proc) if proc.is_a?(Proc)
8
+ end
9
+
10
+ def self.browser_touch_true(browser_object, proc)
11
+ `
12
+ interact('#'+#{browser_object})
13
+ .on('tap', function (event) {
14
+ Opal.BrowserHelper.$touch_helper_callback(event,#{proc});
15
+ })
16
+ `
17
+ end
18
+
19
+ def self.browser_touch_long(browser_object, proc)
20
+ `
21
+ interact('#'+#{browser_object})
22
+ .on('hold', function (event) {
23
+ Opal.BrowserHelper.$touch_helper_callback(event,#{proc});
24
+ })
25
+ `
26
+ end
27
+
28
+ def self.browser_touch_double(browser_object, proc)
29
+ `
30
+ interact('#'+#{browser_object})
31
+ .on('doubletap', function (event) {
32
+ Opal.BrowserHelper.$touch_helper_callback(event,#{proc});
33
+ })
34
+ `
35
+ end
36
+
37
+ def self.browser_touch_down(browser_object, proc)
38
+
39
+ `
40
+ interact('#'+#{browser_object})
41
+ .on('down', function (event) {
42
+ Opal.BrowserHelper.$touch_helper_callback(event,#{proc});
43
+ })
44
+
45
+ `
46
+ end
47
+
48
+ def self.browser_touch_up(browser_object, proc)
49
+ `
50
+ interact('#'+#{browser_object})
51
+ .on('up', function (event) {
52
+ Opal.BrowserHelper.$touch_helper_callback(event,#{proc});
53
+ })
54
+ `
55
+ end
56
+
57
+ end
58
+
59
+
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ # image
6
+ def self.browser_left_image(value, browser_object, _atome)
7
+ browser_object.style[:left] = "#{value}px"
8
+ end
9
+
10
+ def self.browser_right_image(value, browser_object, _atome)
11
+ browser_object.style[:right] = "#{value}px"
12
+ end
13
+
14
+ def self.browser_top_image(value, browser_object, _atome)
15
+ browser_object.style[:top] = "#{value}px"
16
+ end
17
+
18
+ def self.browser_bottom_image(value, browser_object, _atome)
19
+ browser_object.style[:bottom] = "#{value}px"
20
+ end
21
+
22
+ def self.browser_path_image(value, browser_object, _atome)
23
+ browser_object[:src] = value
24
+ end
25
+
26
+
27
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ # shadow
6
+ def self.browser_left_shadow(value, _browser_object, atome)
7
+ ls_left = "#{atome[:left] = value}px"
8
+ ls_top = "#{atome[:top]}px"
9
+ ls_blur = "#{atome[:blur]}px"
10
+ red = atome[:red] * 255
11
+ green = atome[:green] * 255
12
+ blue = (atome[:blue]) * 255
13
+ direction = atome[:direction]
14
+ alpha = atome[:alpha]
15
+
16
+ shadow_updated = "#{ls_left} #{ls_top} #{ls_blur} rgba(#{red}, #{green}, #{blue}, #{alpha}) #{direction}"
17
+ `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
18
+ end
19
+
20
+ def self.browser_top_shadow(value, _browser_object, atome)
21
+ rs_left = "#{atome[:left]}px"
22
+ rs_top = "#{atome[:top] = value}px"
23
+ rs_blur = "#{atome[:blur]}px"
24
+ red = atome[:red] * 255
25
+ green = atome[:green] * 255
26
+ blue = (atome[:blue]) * 255
27
+ direction = atome[:direction]
28
+ alpha = atome[:alpha]
29
+
30
+ shadow_updated = "#{rs_left}px #{rs_top}px #{rs_blur}px rgba(#{red}, #{green}, #{blue}, #{alpha}) #{direction}"
31
+ `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+
6
+ def self.browser_left_shape(value, browser_object, _atome)
7
+ browser_object.style[:left] = "#{value}px"
8
+ end
9
+
10
+ def self.browser_right_shape(value, browser_object, _atome)
11
+ browser_object.style[:right] = "#{value}px"
12
+ end
13
+
14
+ def self.browser_top_shape(value, browser_object, _atome)
15
+ browser_object.style[:top] = "#{value}px"
16
+ end
17
+
18
+ def self.browser_bottom_shape(value, browser_object, _atome)
19
+ browser_object.style[:bottom] = "#{value}px"
20
+ end
21
+
22
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ # text
6
+ def self.browser_left_text(value, browser_object, _atome)
7
+ browser_object.style[:left] = "#{value}px"
8
+ end
9
+
10
+ def self.browser_right_text(value, browser_object, _atome)
11
+ browser_object.style[:right] = "#{value}px"
12
+ end
13
+
14
+ def self.browser_top_text(value, browser_object, _atome)
15
+ browser_object.style[:top] = "#{value}px"
16
+ end
17
+
18
+ def self.browser_bottom_text(value, browser_object, _atome)
19
+ browser_object.style[:bottom] = "#{value}px"
20
+ end
21
+
22
+ def self.browser_data_text(value,atome_send)
23
+ atome_send.browser_object.text = value
24
+ end
25
+
26
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ # video
6
+ def self.browser_left_video(value, browser_object, _atome)
7
+ browser_object.style[:left] = "#{value}px"
8
+ end
9
+
10
+ def self.browser_right_videob(value, browser_object, _atome)
11
+ browser_object.style[:right] = "#{value}px"
12
+ end
13
+
14
+ def self.browser_top_video(value, browser_object, _atome)
15
+ browser_object.style[:top] = "#{value}px"
16
+ end
17
+
18
+ def self.browser_bottom_video(value, browser_object, _atome)
19
+ browser_object.style[:bottom] = "#{value}px"
20
+ end
21
+
22
+ def self.browser_path_video(value, browser_object, _atome)
23
+ browser_object[:src] = value
24
+ end
25
+
26
+ def self.browser_play_video(_value, browser_object_found, atome_hash, atome_object, proc)
27
+ browser_object_found.play
28
+ # TODO : change timeupdate for when possible requestVideoFrameCallback
29
+ # (opal-browser/opal/browser/event.rb line 36)
30
+ video_callback = atome_hash[:code] # this is the video callback not the play callback
31
+ play_callback = proc # this is the video callback not the play callback
32
+ browser_object_found.on(:timeupdate) do |e|
33
+ current_time = browser_object_found.currentTime
34
+ # we update the time particle
35
+ atome_object.time_callback(current_time)
36
+ e.prevent # Prevent the default action (eg. form submission)
37
+ # You can also use `e.stop` to stop propagating the event to other handlers.
38
+
39
+ atome_object.instance_exec(current_time, &video_callback) if video_callback.is_a?(Proc)
40
+ atome_object.instance_exec(current_time, &play_callback) if play_callback.is_a?(Proc)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ # web
6
+ def self.browser_left_web(value, browser_object, _atome)
7
+ browser_object.style[:left] = "#{value}px"
8
+ end
9
+
10
+ def self.browser_right_web(value, browser_object, _atome)
11
+ browser_object.style[:right] = "#{value}px"
12
+ end
13
+
14
+ def self.browser_top_web(value, browser_object, _atome)
15
+ browser_object.style[:top] = "#{value}px"
16
+ end
17
+
18
+ def self.browser_bottom_web(value, browser_object, _atome)
19
+ browser_object.style[:bottom] = "#{value}px"
20
+ end
21
+
22
+ def self.browser_path_web(value, browser_object, _atome)
23
+ browser_object[:src] = value
24
+ end
25
+
26
+ def self.browser_attach_web(parents, html_object, _atome)
27
+ html_object.append_to(browser_document[parents])
28
+ end
29
+
30
+ end
@@ -2,15 +2,15 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:browser_id) do |params|
5
+ generator.build_render(:browser_id) do |params|
6
6
  browser_object.id = params if @atome[:id] != params
7
7
  end
8
8
 
9
- generator.build_render_method(:browser_type) do |params|
9
+ generator.build_render(:browser_type) do |params|
10
10
  send("browser_#{params}", user_proc)
11
11
  end
12
12
 
13
- generator.build_render_method(:browser_parents) do |parents_found|
13
+ generator.build_render(:browser_parents) do |parents_found|
14
14
  parents_found.each do |parent_found|
15
15
  BrowserHelper.send("browser_attach_#{@browser_type}", parent_found, @browser_object, @atome)
16
16
  end
@@ -22,3 +22,10 @@ generator.build_option(:pre_render_children) do |children_pass|
22
22
  atome_found.parents([@atome[:id]])
23
23
  end
24
24
  end
25
+
26
+ generator.build_render(:browser_attach) do |parents_found|
27
+ parents_found.each do |parent_found|
28
+ BrowserHelper.send("browser_attach_#{@browser_type}", parent_found, @browser_object, @atome)
29
+ end
30
+ end
31
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:red) do |value|
5
+ generator.build_render(:red) do |value|
6
6
  red = ((@atome[:red] = value) * 255)
7
7
  green = @atome[:green] * 255
8
8
  blue = @atome[:blue] * 255
@@ -11,7 +11,7 @@ generator.build_render_method(:red) do |value|
11
11
  BrowserHelper.send("browser_colorize_#{@atome[:type]}", color_updated, @atome)
12
12
  end
13
13
 
14
- generator.build_render_method(:green) do |value|
14
+ generator.build_render(:green) do |value|
15
15
  red = @atome[:red] * 255
16
16
  green = (@atome[:green] = value) * 255
17
17
  blue = @atome[:blue] * 255
@@ -20,7 +20,7 @@ generator.build_render_method(:green) do |value|
20
20
  BrowserHelper.send("browser_colorize_#{@atome[:type]}", color_updated, @atome)
21
21
  end
22
22
 
23
- generator.build_render_method(:blue) do |value|
23
+ generator.build_render(:blue) do |value|
24
24
  red = @atome[:red] * 255
25
25
  green = @atome[:green] * 255
26
26
  blue = (@atome[:blue] = value) * 255
@@ -29,7 +29,7 @@ generator.build_render_method(:blue) do |value|
29
29
  BrowserHelper.send("browser_colorize_#{@atome[:type]}", color_updated, @atome)
30
30
  end
31
31
 
32
- generator.build_render_method(:alpha) do |value|
32
+ generator.build_render(:alpha) do |value|
33
33
  red = @atome[:red] * 255
34
34
  green = @atome[:green] * 255
35
35
  blue = @atome[:blue] * 255
@@ -38,6 +38,29 @@ generator.build_render_method(:alpha) do |value|
38
38
  BrowserHelper.send("browser_colorize_#{@atome[:type]}", color_updated, @atome)
39
39
  end
40
40
 
41
- generator.build_render_method(:visual) do |value|
41
+ generator.build_render(:visual) do |value|
42
42
  browser_object.style['font-size'] = "#{value[:size]}px"
43
43
  end
44
+
45
+ generator.build_render(:browser_edit) do |value|
46
+ if value == true
47
+ caret_color = 'white'
48
+ user_select = 'text'
49
+ selection_color= 'blue'
50
+ else
51
+ caret_color = 'transparent'
52
+ user_select = 'none'
53
+ selection_color= 'transparent'
54
+ end
55
+
56
+ @browser_object.attributes[:contenteditable] = value
57
+ @browser_object.style['caret-color'] = caret_color
58
+ @browser_object.style['webkit-user-select'] = user_select
59
+ @browser_object.style['-moz-user-select'] = user_select
60
+ @browser_object.style['user-select'] = user_select
61
+ end
62
+
63
+ generator.build_render(:browser_hide) do |value|
64
+ @browser_object.style[:display] = "none"
65
+
66
+ end
@@ -2,22 +2,53 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:browser_left) do |value, _user_proc|
5
+ generator.build_render(:browser_left) do |value, _user_proc|
6
6
  BrowserHelper.send("browser_left_#{@atome[:type]}", value, @browser_object, @atome)
7
7
  end
8
8
 
9
- generator.build_render_method(:browser_right) do |value, _user_proc|
9
+ generator.build_render(:browser_right) do |value, _user_proc|
10
10
  BrowserHelper.send("browser_right_#{@atome[:type]}", value, @browser_object, @atome)
11
11
  end
12
12
 
13
- generator.build_render_method(:browser_top) do |value, _user_proc|
13
+ generator.build_render(:browser_top) do |value, _user_proc|
14
14
  BrowserHelper.send("browser_top_#{@atome[:type]}", value, @browser_object, @atome)
15
15
  end
16
16
 
17
- generator.build_render_method(:browser_bottom) do |value, _user_proc|
17
+ generator.build_render(:browser_bottom) do |value, _user_proc|
18
18
  BrowserHelper.send("browser_bottom_#{@atome[:type]}", value, @browser_object, @atome)
19
19
  end
20
20
 
21
- generator.build_render_method(:browser_rotate) do |value, _user_proc|
21
+ generator.build_render(:browser_rotate) do |value, _user_proc|
22
22
  @browser_object.style[:transform] = "rotate(#{value}deg)" unless @browser_type == :style
23
23
  end
24
+
25
+ generator.build_render(:browser_center) do |value, _user_proc|
26
+ case value
27
+ when :horizontal
28
+ @browser_object.remove_class(:center)
29
+ @browser_object.remove_class(:center_vertical)
30
+ @browser_object.add_class(:center_horizontal)
31
+ @browser_object.style[:bottom] = :auto
32
+ @browser_object.style[:right] = :auto
33
+ @browser_object.style[:top] = '0px'
34
+ @browser_object.style[:left] = '50%'
35
+ when :vertical
36
+ @browser_object.remove_class(:center)
37
+ @browser_object.remove_class(:center_horizontal)
38
+ @browser_object.add_class(:center_vertical)
39
+ @browser_object.style[:bottom] = :auto
40
+ @browser_object.style[:right] = :auto
41
+ @browser_object.style[:left] = '0px'
42
+ @browser_object.style[:top] = '50%'
43
+ else
44
+ @browser_object.remove_class(:center_vertical)
45
+ @browser_object.remove_class(:center_horizontal)
46
+ @browser_object.add_class(:center)
47
+ @browser_object.style[:bottom] = :auto
48
+ @browser_object.style[:right] = :auto
49
+ @browser_object.style[:left] = '50%'
50
+ @browser_object.style[:top] = '50%'
51
+ end
52
+
53
+ end
54
+
@@ -1,39 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  generator = Genesis.generator
4
- generator.build_render_method(:browser_bloc)
5
- generator.build_render_method(:browser_render)
6
- generator.build_render_method(:browser_delete) do
7
- browser_object&.remove
4
+ generator.build_render(:browser_bloc)
5
+ generator.build_render(:browser_render)
6
+ generator.build_render(:browser_delete) do |params|
7
+ browser_object&.remove if params == true
8
8
  end
9
9
 
10
- generator.build_render_method(:browser_clear) do
10
+ generator.build_render(:browser_clear) do
11
11
  @atome[:children].each do |child_found|
12
12
  grab(child_found).browser_object&.remove
13
13
  end
14
14
  children([])
15
15
  end
16
16
 
17
- generator.build_render_method(:browser_path) do |value|
17
+ generator.build_render(:browser_path) do |value|
18
18
  BrowserHelper.send("browser_path_#{@atome[:type]}", value, @browser_object, @atome)
19
19
  end
20
20
 
21
- generator.build_render_method(:browser_data) do |data|
21
+ generator.build_render(:browser_data) do |data|
22
22
  # according to the type we send the data to different operator
23
23
  type_found = @atome[:type]
24
- send("browser_data_#{type_found}", data)
24
+ BrowserHelper.send("browser_data_#{type_found}", data, self)
25
25
  end
26
26
 
27
- generator.build_render_method(:browser_schedule) do |format_date, proc|
27
+ generator.build_render(:browser_schedule) do |format_date, proc|
28
28
  years = format_date[0]
29
29
  months = format_date[1]
30
30
  days = format_date[2]
31
31
  hours = format_date[3]
32
32
  minutes = format_date[4]
33
33
  seconds = format_date[5]
34
- `atome.jsSchedule(#{years},#{months},#{days},#{hours},#{minutes},#{seconds},#{self},#{proc})`
34
+ atome_js.JS.schedule(years, months, days, hours, minutes, seconds, self, proc)
35
35
  end
36
36
 
37
- generator.build_render_method(:browser_reader) do |file, proc|
38
- `atome.jsReader(#{file},#{self},#{proc})`
37
+ generator.build_render(:browser_reader) do |file, proc|
38
+ atome_js.JS.reader(file, self, proc)
39
39
  end
40
+
41
+ generator.build_render(:browser_cursor) do |value|
42
+ @browser_object.style[:cursor] = value
43
+ end
44
+
45
+ generator.build_render(:browser_overflow) do |value|
46
+ @browser_object.style[:overflow] = value
47
+ end
48
+
@@ -2,5 +2,5 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:headless_schedule)
6
- generator.build_render_method(:headless_reader)
5
+ generator.build_render(:headless_schedule)
6
+ generator.build_render(:headless_reader)