atome 0.5.7.0.3 → 0.3191
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of atome might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/README.md +5 -77
- data/Rakefile +7 -502
- data/app_builder_helpers/Rakefile +235 -0
- data/documentation/framework/enhance_atome.md +1 -1
- data/documentation/installation/atome_server.md +1 -66
- data/documentation/tutorials/tutorials.md +0 -7
- data/exe/atome +157 -819
- data/lib/atome/atome_native_extensions.rb +3 -0
- data/lib/atome/extensions/geolocation.rb +1 -1
- data/lib/atome/extensions/ping.rb +11 -10
- data/lib/atome/extensions/sha.rb +6 -8
- data/lib/atome/kernel/atome_genesis.rb +93 -0
- data/lib/atome/kernel/generators/shapes.rb +7 -0
- data/lib/atome/kernel/properties/geometry.rb +120 -0
- data/lib/atome/kernel/universe.rb +24 -295
- data/lib/atome/renderers/headless/headless.rb +0 -0
- data/lib/atome/renderers/headless/properties/generator.rb +0 -0
- data/lib/atome/renderers/opal/atome_opal_extensions.rb +4 -0
- data/lib/{platform_specific → atome/renderers}/opal/extensions/geolocation.rb +1 -1
- data/lib/atome/renderers/opal/extensions/ping.rb +13 -0
- data/lib/atome/renderers/opal/extensions/sha.rb +11 -0
- data/lib/atome/renderers/opal/opal_browser.rb +8 -0
- data/lib/{platform_specific → atome/renderers}/opal/opal_parser.rb +0 -1
- data/lib/atome/renderers/opal/properties/generator.rb +6 -0
- data/lib/atome/renderers/server/server.rb +0 -0
- data/lib/atome/version.rb +1 -2
- data/lib/atome.rb +16 -35
- data/sig/atome.rbs +0 -75
- data/vendor/assets/Guardfile +4 -0
- data/vendor/assets/Rakefile +2 -12
- data/vendor/assets/application/index.rb +2 -7
- data/vendor/assets/build/css/style.css +53 -0
- data/vendor/assets/build/index.html +24 -0
- data/vendor/assets/build/js/application.js +0 -0
- data/vendor/assets/build/js/third_parties/interact.min.js +4 -0
- data/vendor/assets/build/js/third_parties/popmotion.min.js +1 -0
- data/vendor/assets/examples/misc.rb +219 -0
- data/vendor/assets/examples/ping.rb +3 -0
- data/vendor/assets/examples/storage.rb +9 -0
- data/vendor/assets/examples/view_example.rb +21 -0
- data/vendor/assets/server/atome_server.rb +96 -33
- data/vendor/assets/server/config.ru +3 -8
- metadata +69 -512
- data/CHANGELOG.md +0 -21
- data/atome.gemspec +0 -100
- data/documentation/basic.md +0 -241
- data/documentation/deep learning/architecture.txt +0 -3763
- data/documentation/deep learning/atome.png +0 -0
- data/documentation/deep learning/basic_infos.txt +0 -289
- data/documentation/deep learning/example_of_users_code.rb +0 -1810
- data/documentation/deep learning/misc.txt +0 -24
- data/documentation/deep learning/ruby_js_example.rb +0 -272
- data/documentation/deep learning/wasm_script_help.text +0 -14
- data/documentation/installation/buiding_atome.md +0 -307
- data/lib/atome/atome.rb +0 -131
- data/lib/atome/extensions/atome.rb +0 -705
- data/lib/atome/extensions/mathematics.rb +0 -20
- data/lib/atome/genesis/atomes.rb +0 -109
- data/lib/atome/genesis/genesis.rb +0 -272
- data/lib/atome/genesis/particles/atome.rb +0 -4
- data/lib/atome/genesis/particles/communication.rb +0 -43
- data/lib/atome/genesis/particles/effect.rb +0 -14
- data/lib/atome/genesis/particles/event.rb +0 -344
- data/lib/atome/genesis/particles/geometry.rb +0 -31
- data/lib/atome/genesis/particles/hierarchy.rb +0 -105
- data/lib/atome/genesis/particles/identity.rb +0 -82
- data/lib/atome/genesis/particles/material.rb +0 -119
- data/lib/atome/genesis/particles/property.rb +0 -147
- data/lib/atome/genesis/particles/security.rb +0 -77
- data/lib/atome/genesis/particles/spatial.rb +0 -98
- data/lib/atome/genesis/particles/time.rb +0 -4
- data/lib/atome/genesis/particles/utility.rb +0 -261
- data/lib/atome/genesis/presets.rb +0 -10
- data/lib/atome/genesis/sparkle.rb +0 -217
- data/lib/atome/kernel/black_matter.rb +0 -22
- data/lib/atome/presets/atome.rb +0 -79
- data/lib/atome/utilities/color_helper/color/cmyk.rb +0 -263
- data/lib/atome/utilities/color_helper/color/css.rb +0 -7
- data/lib/atome/utilities/color_helper/color/grayscale.rb +0 -197
- data/lib/atome/utilities/color_helper/color/hsl.rb +0 -240
- data/lib/atome/utilities/color_helper/color/palette/adobecolor.rb +0 -260
- data/lib/atome/utilities/color_helper/color/palette/gimp.rb +0 -104
- data/lib/atome/utilities/color_helper/color/palette/monocontrast.rb +0 -164
- data/lib/atome/utilities/color_helper/color/palette.rb +0 -4
- data/lib/atome/utilities/color_helper/color/rgb/colors.rb +0 -167
- data/lib/atome/utilities/color_helper/color/rgb/contrast.rb +0 -57
- data/lib/atome/utilities/color_helper/color/rgb/metallic.rb +0 -28
- data/lib/atome/utilities/color_helper/color/rgb.rb +0 -715
- data/lib/atome/utilities/color_helper/color/yiq.rb +0 -62
- data/lib/atome/utilities/color_helper/color.rb +0 -415
- data/lib/atome/utilities/essentials.rb +0 -70
- data/lib/atome/utilities/sanitizer.rb +0 -13
- data/lib/atome/utilities/security.rb +0 -71
- data/lib/atome/utilities/utilities.rb +0 -656
- data/lib/atome_relative.rb +0 -39
- data/lib/molecules/_deprecated_examples/site.rb +0 -34
- data/lib/molecules/init.rb +0 -31
- data/lib/molecules/intuition/_deprecated_inputs.rb +0 -111
- data/lib/molecules/intuition/_deprecated_toolbox.rb +0 -282
- data/lib/molecules/intuition/utillities.rb +0 -408
- data/lib/platform_specific/opal/atome_opal_extensions.rb +0 -11
- data/lib/platform_specific/opal/extensions/color.rb +0 -30
- data/lib/platform_specific/opal/extensions/js.rb +0 -20
- data/lib/platform_specific/opal/extensions/object.rb +0 -6
- data/lib/platform_specific/opal/extensions/ping.rb +0 -31
- data/lib/platform_specific/opal/extensions/sha.rb +0 -25
- data/lib/platform_specific/opal/opal.rb +0 -5
- data/lib/platform_specific/wasm/atome_wasm_extensions.rb +0 -11
- data/lib/renderers/headless/headless.rb +0 -18
- data/lib/renderers/headless/index.rb +0 -6
- data/lib/renderers/headless/index_relative.rb +0 -6
- data/lib/renderers/headless/utility.rb +0 -6
- data/lib/renderers/html/atome.rb +0 -2
- data/lib/renderers/html/atome_html.rb +0 -22
- data/lib/renderers/html/communication.rb +0 -3
- data/lib/renderers/html/effect.rb +0 -51
- data/lib/renderers/html/event.rb +0 -59
- data/lib/renderers/html/geometry.rb +0 -49
- data/lib/renderers/html/hierarchy.rb +0 -248
- data/lib/renderers/html/html.rb +0 -1688
- data/lib/renderers/html/identity.rb +0 -104
- data/lib/renderers/html/index.rb +0 -19
- data/lib/renderers/html/index_relative.rb +0 -20
- data/lib/renderers/html/material.rb +0 -88
- data/lib/renderers/html/property.rb +0 -52
- data/lib/renderers/html/security.rb +0 -1
- data/lib/renderers/html/spatial.rb +0 -75
- data/lib/renderers/html/time.rb +0 -1
- data/lib/renderers/html/utility.rb +0 -170
- data/lib/renderers/renderer.rb +0 -16
- data/lib/renderers/server/index.rb +0 -4
- data/lib/renderers/server/index_relative.rb +0 -4
- data/lib/renderers/server/utility.rb +0 -4
- data/sig/atome_js.rbs +0 -1
- data/sig/batch.rbs +0 -7
- data/sig/browser_helper.rbs +0 -14
- data/sig/essentials.rbs +0 -11
- data/sig/genesis.rbs +0 -3
- data/sig/global_variables.rbs +0 -1
- data/sig/matrix.rbs +0 -5
- data/sig/object.rbs +0 -7
- data/sig/universe.rbs +0 -3
- data/src/utilities/host_mode.rb +0 -5
- data/vendor/assets/application/examples/affect.rb +0 -8
- data/vendor/assets/application/examples/aid.rb +0 -10
- data/vendor/assets/application/examples/allow_copy.rb +0 -13
- data/vendor/assets/application/examples/allow_system_right_click.rb +0 -16
- data/vendor/assets/application/examples/alternate.rb +0 -36
- data/vendor/assets/application/examples/animation.rb +0 -91
- data/vendor/assets/application/examples/apply.rb +0 -8
- data/vendor/assets/application/examples/atome.rb +0 -5
- data/vendor/assets/application/examples/atome_particle_validation.rb +0 -7
- data/vendor/assets/application/examples/atome_sparkle_use.rb +0 -6
- data/vendor/assets/application/examples/atomizer.rb +0 -86
- data/vendor/assets/application/examples/attach.rb +0 -34
- data/vendor/assets/application/examples/attached.rb +0 -45
- data/vendor/assets/application/examples/b64_to_image.rb +0 -9
- data/vendor/assets/application/examples/basic_understanding.rb +0 -54
- data/vendor/assets/application/examples/behavior.rb +0 -32
- data/vendor/assets/application/examples/blur.rb +0 -26
- data/vendor/assets/application/examples/border.rb +0 -75
- data/vendor/assets/application/examples/browse.rb +0 -17
- data/vendor/assets/application/examples/categories.rb +0 -5
- data/vendor/assets/application/examples/category.rb +0 -16
- data/vendor/assets/application/examples/center.rb +0 -7
- data/vendor/assets/application/examples/clear.rb +0 -96
- data/vendor/assets/application/examples/clones&monitoring.rb +0 -105
- data/vendor/assets/application/examples/code.rb +0 -13
- data/vendor/assets/application/examples/color.rb +0 -54
- data/vendor/assets/application/examples/compute.rb +0 -16
- data/vendor/assets/application/examples/console.rb +0 -4
- data/vendor/assets/application/examples/convert.rb +0 -163
- data/vendor/assets/application/examples/copy.rb +0 -25
- data/vendor/assets/application/examples/copybck.rb +0 -68
- data/vendor/assets/application/examples/css.rb +0 -6
- data/vendor/assets/application/examples/database_handling.rb +0 -39
- data/vendor/assets/application/examples/debug.rb +0 -78
- data/vendor/assets/application/examples/delete.rb +0 -105
- data/vendor/assets/application/examples/dig.rb +0 -13
- data/vendor/assets/application/examples/display.rb +0 -279
- data/vendor/assets/application/examples/display_bck.rb +0 -164
- data/vendor/assets/application/examples/drag.rb +0 -54
- data/vendor/assets/application/examples/drop.rb +0 -35
- data/vendor/assets/application/examples/duplicate.rb +0 -70
- data/vendor/assets/application/examples/edit.rb +0 -24
- data/vendor/assets/application/examples/encode.rb +0 -6
- data/vendor/assets/application/examples/encrypt.rb +0 -6
- data/vendor/assets/application/examples/example.rb +0 -27
- data/vendor/assets/application/examples/executor.rb +0 -36
- data/vendor/assets/application/examples/file.rb +0 -16
- data/vendor/assets/application/examples/fill.rb +0 -23
- data/vendor/assets/application/examples/find.rb +0 -158
- data/vendor/assets/application/examples/fit.rb +0 -26
- data/vendor/assets/application/examples/fonts.rb +0 -15
- data/vendor/assets/application/examples/generator_and_build.rb +0 -15
- data/vendor/assets/application/examples/getter.rb +0 -16
- data/vendor/assets/application/examples/grab.rb +0 -14
- data/vendor/assets/application/examples/gradient.rb +0 -40
- data/vendor/assets/application/examples/group.rb +0 -44
- data/vendor/assets/application/examples/help.rb +0 -17
- data/vendor/assets/application/examples/hierarchy.rb +0 -21
- data/vendor/assets/application/examples/history.rb +0 -32
- data/vendor/assets/application/examples/holder.rb +0 -62
- data/vendor/assets/application/examples/hypertext.rb +0 -113
- data/vendor/assets/application/examples/image.rb +0 -5
- data/vendor/assets/application/examples/import.rb +0 -33
- data/vendor/assets/application/examples/increment.rb +0 -23
- data/vendor/assets/application/examples/infos.rb +0 -10
- data/vendor/assets/application/examples/input.rb +0 -34
- data/vendor/assets/application/examples/int8.rb +0 -17
- data/vendor/assets/application/examples/js&ruby.rb +0 -18
- data/vendor/assets/application/examples/keyboard.rb +0 -59
- data/vendor/assets/application/examples/layout.rb +0 -38
- data/vendor/assets/application/examples/list.rb +0 -72
- data/vendor/assets/application/examples/localstorage.rb +0 -19
- data/vendor/assets/application/examples/login.rb +0 -84
- data/vendor/assets/application/examples/markup.rb +0 -4
- data/vendor/assets/application/examples/match.rb +0 -115
- data/vendor/assets/application/examples/matrix.rb +0 -118
- data/vendor/assets/application/examples/monitor.rb +0 -14
- data/vendor/assets/application/examples/on_resize.rb +0 -7
- data/vendor/assets/application/examples/on_the_fly_ruby_code_loading.rb +0 -9
- data/vendor/assets/application/examples/online.rb +0 -3
- data/vendor/assets/application/examples/opacity.rb +0 -9
- data/vendor/assets/application/examples/over.rb +0 -29
- data/vendor/assets/application/examples/paint.rb +0 -29
- data/vendor/assets/application/examples/particles.rb +0 -4
- data/vendor/assets/application/examples/percent_to_px.rb +0 -4
- data/vendor/assets/application/examples/play.rb +0 -50
- data/vendor/assets/application/examples/preset.rb +0 -33
- data/vendor/assets/application/examples/random.rb +0 -42
- data/vendor/assets/application/examples/raw_html.rb +0 -48
- data/vendor/assets/application/examples/read.rb +0 -13
- data/vendor/assets/application/examples/recorder.rb +0 -74
- data/vendor/assets/application/examples/refresh.rb +0 -62
- data/vendor/assets/application/examples/remove.rb +0 -60
- data/vendor/assets/application/examples/repeat.rb +0 -26
- data/vendor/assets/application/examples/resize.rb +0 -17
- data/vendor/assets/application/examples/scroll.rb +0 -11
- data/vendor/assets/application/examples/security.rb +0 -76
- data/vendor/assets/application/examples/select_text.rb +0 -18
- data/vendor/assets/application/examples/selected.rb +0 -35
- data/vendor/assets/application/examples/server.rb +0 -24
- data/vendor/assets/application/examples/shadow.rb +0 -60
- data/vendor/assets/application/examples/shapes.rb +0 -6
- data/vendor/assets/application/examples/shortcut.rb +0 -25
- data/vendor/assets/application/examples/site.rb +0 -41
- data/vendor/assets/application/examples/size.rb +0 -17
- data/vendor/assets/application/examples/sliders.rb +0 -17
- data/vendor/assets/application/examples/smooth.rb +0 -9
- data/vendor/assets/application/examples/style.rb +0 -4
- data/vendor/assets/application/examples/sub_atome_manipulation.rb +0 -20
- data/vendor/assets/application/examples/svg_img_to_vector.rb +0 -6
- data/vendor/assets/application/examples/svg_vectorizer.rb +0 -21
- data/vendor/assets/application/examples/sync.rb +0 -38
- data/vendor/assets/application/examples/table.rb +0 -76
- data/vendor/assets/application/examples/tagged.rb +0 -24
- data/vendor/assets/application/examples/terminal.rb +0 -4
- data/vendor/assets/application/examples/test.rb +0 -584
- data/vendor/assets/application/examples/text.rb +0 -5
- data/vendor/assets/application/examples/tick.rb +0 -29
- data/vendor/assets/application/examples/tools.rb +0 -666
- data/vendor/assets/application/examples/touch.rb +0 -41
- data/vendor/assets/application/examples/type_mutation.rb +0 -18
- data/vendor/assets/application/examples/unit.rb +0 -14
- data/vendor/assets/application/examples/universe.rb +0 -8
- data/vendor/assets/application/examples/vector.rb +0 -37
- data/vendor/assets/application/examples/video.rb +0 -14
- data/vendor/assets/application/examples/wait.rb +0 -6
- data/vendor/assets/application/examples/www.rb +0 -10
- data/vendor/assets/server/atome_server_wasm.rb +0 -54
- data/vendor/assets/server/capture.rb +0 -10
- data/vendor/assets/server/database.rb +0 -63
- data/vendor/assets/server/eDen.rb +0 -302
- data/vendor/assets/server/extensions.rb +0 -13
- data/vendor/assets/src/css/style.css +0 -167
- data/vendor/assets/src/index.html +0 -45
- data/vendor/assets/src/index_opal.html +0 -40
- data/vendor/assets/src/index_server.html +0 -38
- data/vendor/assets/src/index_server_wasm.html +0 -45
- data/vendor/assets/src/index_wasm.html +0 -50
- data/vendor/assets/src/js/atome/atome.js +0 -506
- data/vendor/assets/src/js/atome/atome_helpers/add_font.js +0 -46
- data/vendor/assets/src/js/atome/atome_helpers/atome_animate.js +0 -65
- data/vendor/assets/src/js/atome/atome_helpers/atome_drag.js +0 -124
- data/vendor/assets/src/js/atome/atome_helpers/atome_drop.js +0 -12
- data/vendor/assets/src/js/atome/atome_helpers/atome_events.js +0 -171
- data/vendor/assets/src/js/atome/atome_helpers/atome_over.js +0 -43
- data/vendor/assets/src/js/atome/atome_helpers/atome_sort.js +0 -20
- data/vendor/assets/src/js/atome/atome_helpers/atome_time.js +0 -10
- data/vendor/assets/src/js/atome/atome_helpers/atome_video.js +0 -12
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +0 -35
- data/vendor/assets/src/js/atome/atome_helpers/file.js +0 -12
- data/vendor/assets/src/js/atome/specific/opal.js +0 -111
- data/vendor/assets/src/js/atome/specific/wasm.js +0 -123
- data/vendor/assets/src/js/molecules/web.js +0 -4
- data/vendor/assets/src/js/third_parties/browser.script.iife.min.js +0 -13
- data/vendor/assets/src/js/third_parties/fabric.min.js +0 -1
- data/vendor/assets/src/js/third_parties/html-to-image.min.js +0 -2
- data/vendor/assets/src/js/third_parties/interact.min.js +0 -3
- data/vendor/assets/src/js/third_parties/jsencrypt.min.js +0 -2
- data/vendor/assets/src/js/third_parties/papaparse.min.js +0 -7
- data/vendor/assets/src/js/third_parties/popmotion.min.js +0 -1
- data/vendor/assets/src/js/third_parties/sortable.min.js +0 -2
- data/vendor/assets/src/js/third_parties/three.min.js +0 -6
- data/vendor/assets/src/js/third_parties/w3color.js +0 -646
- data/vendor/assets/src/js/third_parties/wad.min.js +0 -9
- data/vendor/assets/src/js/third_parties/zim.min.js +0 -1
- data/vendor/assets/src/medias/audios/audio_missing.wav +0 -0
- data/vendor/assets/src/medias/audios/clap.wav +0 -0
- data/vendor/assets/src/medias/audios/cowbell.wav +0 -0
- data/vendor/assets/src/medias/audios/hihat.wav +0 -0
- data/vendor/assets/src/medias/audios/kick.wav +0 -0
- data/vendor/assets/src/medias/audios/riff.m4a +0 -0
- data/vendor/assets/src/medias/audios/snare.wav +0 -0
- data/vendor/assets/src/medias/audios/tom.wav +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/LICENSE.txt +0 -202
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Black.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Bold.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Italic.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Light.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Medium.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Regular.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-Thin.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/LICENSE.txt +0 -202
- data/vendor/assets/src/medias/fonts/Roboto_Slab/README.txt +0 -71
- data/vendor/assets/src/medias/fonts/Roboto_Slab/RobotoSlab-VariableFont_wght.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-Black.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-Bold.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-ExtraBold.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-ExtraLight.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-Light.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-Medium.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-Regular.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-SemiBold.ttf +0 -0
- data/vendor/assets/src/medias/fonts/Roboto_Slab/static/RobotoSlab-Thin.ttf +0 -0
- data/vendor/assets/src/medias/images/atome.svg +0 -12
- data/vendor/assets/src/medias/images/ballanim.png +0 -0
- data/vendor/assets/src/medias/images/blank.png +0 -0
- data/vendor/assets/src/medias/images/green_planet.png +0 -0
- data/vendor/assets/src/medias/images/icons/Lowpass.svg +0 -8
- data/vendor/assets/src/medias/images/icons/activate.svg +0 -3
- data/vendor/assets/src/medias/images/icons/audio.svg +0 -7
- data/vendor/assets/src/medias/images/icons/band_pass.svg +0 -8
- data/vendor/assets/src/medias/images/icons/clear.svg +0 -5
- data/vendor/assets/src/medias/images/icons/color.svg +0 -5
- data/vendor/assets/src/medias/images/icons/copy.svg +0 -8
- data/vendor/assets/src/medias/images/icons/create.svg +0 -3
- data/vendor/assets/src/medias/images/icons/delete.svg +0 -8
- data/vendor/assets/src/medias/images/icons/edit-.svg +0 -4
- data/vendor/assets/src/medias/images/icons/edit.svg +0 -4
- data/vendor/assets/src/medias/images/icons/edition.svg +0 -4
- data/vendor/assets/src/medias/images/icons/email.svg +0 -13
- data/vendor/assets/src/medias/images/icons/equalizer-.svg +0 -5
- data/vendor/assets/src/medias/images/icons/equalizer.svg +0 -5
- data/vendor/assets/src/medias/images/icons/filter.svg +0 -4
- data/vendor/assets/src/medias/images/icons/folder.svg +0 -4
- data/vendor/assets/src/medias/images/icons/group.svg +0 -6
- data/vendor/assets/src/medias/images/icons/hamburger.svg +0 -8
- data/vendor/assets/src/medias/images/icons/high_pass.svg +0 -5
- data/vendor/assets/src/medias/images/icons/link.svg +0 -4
- data/vendor/assets/src/medias/images/icons/load.svg +0 -4
- data/vendor/assets/src/medias/images/icons/low_pass.svg +0 -5
- data/vendor/assets/src/medias/images/icons/mail_gray.svg +0 -6
- data/vendor/assets/src/medias/images/icons/mail_green.svg +0 -6
- data/vendor/assets/src/medias/images/icons/mail_orange.svg +0 -6
- data/vendor/assets/src/medias/images/icons/microphone.svg +0 -7
- data/vendor/assets/src/medias/images/icons/midi_in.svg +0 -4
- data/vendor/assets/src/medias/images/icons/midi_out.svg +0 -4
- data/vendor/assets/src/medias/images/icons/modules.svg +0 -11
- data/vendor/assets/src/medias/images/icons/paste.svg +0 -4
- data/vendor/assets/src/medias/images/icons/pause.svg +0 -5
- data/vendor/assets/src/medias/images/icons/play.svg +0 -7
- data/vendor/assets/src/medias/images/icons/record.svg +0 -4
- data/vendor/assets/src/medias/images/icons/save.svg +0 -5
- data/vendor/assets/src/medias/images/icons/select--.svg +0 -4
- data/vendor/assets/src/medias/images/icons/select-.svg +0 -5
- data/vendor/assets/src/medias/images/icons/select-all.svg +0 -4
- data/vendor/assets/src/medias/images/icons/select.svg +0 -4
- data/vendor/assets/src/medias/images/icons/settings.svg +0 -5
- data/vendor/assets/src/medias/images/icons/settings0.svg +0 -2
- data/vendor/assets/src/medias/images/icons/settings1.svg +0 -17
- data/vendor/assets/src/medias/images/icons/settings2.svg +0 -25
- data/vendor/assets/src/medias/images/icons/settings_old.svg +0 -6
- data/vendor/assets/src/medias/images/icons/shape.svg +0 -7
- data/vendor/assets/src/medias/images/icons/speaker.svg +0 -6
- data/vendor/assets/src/medias/images/icons/stop.svg +0 -4
- data/vendor/assets/src/medias/images/icons/tool.svg +0 -7
- data/vendor/assets/src/medias/images/icons/tools.svg +0 -9
- data/vendor/assets/src/medias/images/icons/undo.svg +0 -4
- data/vendor/assets/src/medias/images/icons/undo2.svg +0 -4
- data/vendor/assets/src/medias/images/icons/validate.svg +0 -9
- data/vendor/assets/src/medias/images/icons/vie.svg +0 -3
- data/vendor/assets/src/medias/images/icons/wave-saw.svg +0 -3
- data/vendor/assets/src/medias/images/icons/wave-sine.svg +0 -3
- data/vendor/assets/src/medias/images/icons/wave-square-.svg +0 -4
- data/vendor/assets/src/medias/images/icons/wave-square.svg +0 -3
- data/vendor/assets/src/medias/images/icons/wave-triangle.svg +0 -3
- data/vendor/assets/src/medias/images/icons/waveform-.svg +0 -4
- data/vendor/assets/src/medias/images/icons/waveform.svg +0 -7
- data/vendor/assets/src/medias/images/logos/Facebook.svg +0 -8
- data/vendor/assets/src/medias/images/logos/GitHub Black.svg +0 -7
- data/vendor/assets/src/medias/images/logos/GitHub.svg +0 -7
- data/vendor/assets/src/medias/images/logos/LinkedIn-full.svg +0 -109
- data/vendor/assets/src/medias/images/logos/LinkedIn.svg +0 -11
- data/vendor/assets/src/medias/images/logos/Orange/Facebook.svg +0 -8
- data/vendor/assets/src/medias/images/logos/Orange/TikTok.svg +0 -11
- data/vendor/assets/src/medias/images/logos/Orange/Twitter.svg +0 -8
- data/vendor/assets/src/medias/images/logos/Orange/instagram.svg +0 -8
- data/vendor/assets/src/medias/images/logos/Orange/vimeo.svg +0 -8
- data/vendor/assets/src/medias/images/logos/Orange/youtube.svg +0 -7
- data/vendor/assets/src/medias/images/logos/TikTok.svg +0 -11
- data/vendor/assets/src/medias/images/logos/Twitter.svg +0 -35
- data/vendor/assets/src/medias/images/logos/X.svg +0 -5
- data/vendor/assets/src/medias/images/logos/YouTube.svg +0 -1
- data/vendor/assets/src/medias/images/logos/apple.svg +0 -4
- data/vendor/assets/src/medias/images/logos/atome.svg +0 -12
- data/vendor/assets/src/medias/images/logos/freebsd.png +0 -0
- data/vendor/assets/src/medias/images/logos/freebsd.svg +0 -8
- data/vendor/assets/src/medias/images/logos/gray/Facebook.svg +0 -8
- data/vendor/assets/src/medias/images/logos/gray/TikTok.svg +0 -11
- data/vendor/assets/src/medias/images/logos/gray/Twitter.svg +0 -8
- data/vendor/assets/src/medias/images/logos/gray/instagram.svg +0 -8
- data/vendor/assets/src/medias/images/logos/gray/vimeo.svg +0 -8
- data/vendor/assets/src/medias/images/logos/gray/youtube.svg +0 -7
- data/vendor/assets/src/medias/images/logos/gray/youtube2.svg +0 -13
- data/vendor/assets/src/medias/images/logos/instagram.svg +0 -6
- data/vendor/assets/src/medias/images/logos/tiktok_back.svg +0 -1
- data/vendor/assets/src/medias/images/logos/vimeo.svg +0 -17
- data/vendor/assets/src/medias/images/noise.svg +0 -17
- data/vendor/assets/src/medias/images/red_planet.png +0 -0
- data/vendor/assets/src/medias/images/tile.png +0 -0
- data/vendor/assets/src/medias/texts/lorem.txt +0 -1
- data/vendor/assets/src/medias/utils/infos/color.rb +0 -29
- data/vendor/assets/src/medias/utils/infos/width.rb +0 -25
- data/vendor/assets/src/medias/videos/video_missing.mp4 +0 -0
- data/vendor/assets/src-tauri/.gitignore +0 -4
- data/vendor/assets/src-tauri/Cargo.toml +0 -27
- data/vendor/assets/src-tauri/build.rs +0 -3
- data/vendor/assets/src-tauri/icons/128x128.png +0 -0
- data/vendor/assets/src-tauri/icons/128x128@2x.png +0 -0
- data/vendor/assets/src-tauri/icons/32x32.png +0 -0
- data/vendor/assets/src-tauri/icons/Square107x107Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square142x142Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square150x150Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square284x284Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square30x30Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square310x310Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square44x44Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square71x71Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/Square89x89Logo.png +0 -0
- data/vendor/assets/src-tauri/icons/StoreLogo.png +0 -0
- data/vendor/assets/src-tauri/icons/icon.icns +0 -0
- data/vendor/assets/src-tauri/icons/icon.ico +0 -0
- data/vendor/assets/src-tauri/icons/icon.png +0 -0
- data/vendor/assets/src-tauri/src/main.rs +0 -71
- data/vendor/assets/src-tauri/tauri.conf.json +0 -70
- data/vendor/assets/src-wasm/wasm/wasi-vfs-osx_arm +0 -0
- data/vendor/assets/src-wasm/wasm/wasi-vfs-osx_x86 +0 -0
- data/vendor/assets/src-wasm/wasm/wasi-vfs-unix +0 -0
- data/vendor/assets/src-wasm/wasm/wasi-vfs.exe +0 -0
- /data/vendor/assets/{src → build}/favicon.ico +0 -0
- /data/vendor/assets/{src/js/third_parties → build/js}/ping.min.js +0 -0
- /data/vendor/assets/{src → build}/js/third_parties/interact.min.js.map +0 -0
- /data/vendor/assets/{src → build}/js/third_parties/sha256.min.js +0 -0
data/lib/renderers/html/html.rb
DELETED
@@ -1,1688 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# this class is aimed at html rendering
|
4
|
-
|
5
|
-
class HTML
|
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
|
-
def initialize(id_found, current_atome)
|
24
|
-
@element ||= JS.global[:document].getElementById(id_found.to_s)
|
25
|
-
@id = id_found
|
26
|
-
@original_atome = current_atome
|
27
|
-
@touch_removed = {}
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def object
|
32
|
-
@element
|
33
|
-
end
|
34
|
-
|
35
|
-
def hypertext(params)
|
36
|
-
current_div = JS.global[:document].getElementById(@id.to_s)
|
37
|
-
current_div[:innerHTML] = params
|
38
|
-
end
|
39
|
-
|
40
|
-
def add_font_to_css(params)
|
41
|
-
font_path = params[:path]
|
42
|
-
font_name = params[:name]
|
43
|
-
str_to_eval = <<STRDELIM
|
44
|
-
var styleSheet = document.styleSheets[0];
|
45
|
-
styleSheet.insertRule(`
|
46
|
-
@font-face {
|
47
|
-
font-family: '#{font_name}';
|
48
|
-
src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
|
49
|
-
}`, styleSheet.cssRules.length);
|
50
|
-
STRDELIM
|
51
|
-
JS.eval(str_to_eval)
|
52
|
-
end
|
53
|
-
|
54
|
-
def add_css_to_atomic_style(css)
|
55
|
-
style_element = JS.global[:document].getElementById('atomic_style')
|
56
|
-
text_node = JS.global[:document].createTextNode(css)
|
57
|
-
style_element.appendChild(text_node)
|
58
|
-
end
|
59
|
-
|
60
|
-
def convert_to_css(data)
|
61
|
-
conditions = data[:condition]
|
62
|
-
apply = data[:alterations]
|
63
|
-
|
64
|
-
# Convert the conditions
|
65
|
-
condition_strings = []
|
66
|
-
|
67
|
-
if conditions[:max]
|
68
|
-
condition_strings << "(max-width: #{conditions[:max][:width]}px)" if conditions[:max][:width]
|
69
|
-
condition_strings << "(max-height: #{conditions[:max][:height]}px)" if conditions[:max][:height]
|
70
|
-
end
|
71
|
-
|
72
|
-
if conditions[:min]
|
73
|
-
condition_strings << "(min-width: #{conditions[:min][:width]}px)" if conditions[:min][:width]
|
74
|
-
condition_strings << "(min-height: #{conditions[:min][:height]}px)" if conditions[:min][:height]
|
75
|
-
end
|
76
|
-
|
77
|
-
operator = conditions[:operator] == :and ? 'and' : 'or'
|
78
|
-
|
79
|
-
# Convert properties to apply
|
80
|
-
property_strings = []
|
81
|
-
apply.each do |key, values|
|
82
|
-
inner_properties = []
|
83
|
-
values.each do |property, value|
|
84
|
-
if property == :color
|
85
|
-
inner_properties << "background-color: #{value} !important;"
|
86
|
-
else
|
87
|
-
inner_properties << "#{property}: #{value}px !important;" if value.is_a?(Integer)
|
88
|
-
inner_properties << "#{property}: #{value} !important;" if value.is_a?(Symbol)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
# Prefix each key with "#"
|
92
|
-
property_strings << "##{key} {\n#{inner_properties.join("\n")}\n}"
|
93
|
-
end
|
94
|
-
|
95
|
-
# let it build
|
96
|
-
css = "@media #{condition_strings.join(" #{operator} ")} {\n#{property_strings.join("\n")}\n}"
|
97
|
-
add_css_to_atomic_style(css)
|
98
|
-
css
|
99
|
-
end
|
100
|
-
|
101
|
-
def css_to_data(css)
|
102
|
-
data = {
|
103
|
-
:condition => {},
|
104
|
-
:apply => {}
|
105
|
-
}
|
106
|
-
# Extract conditions
|
107
|
-
media_conditions = css.match(/@media ([^\{]+)/)[1].split(',').map(&:strip)
|
108
|
-
media_conditions.each do |condition|
|
109
|
-
type = condition.match(/(max|min)-/)[1].to_sym
|
110
|
-
property = condition.match(/(width|height)/)[1].to_sym
|
111
|
-
value = condition.match(/(\d+)/)[1].to_i
|
112
|
-
|
113
|
-
data[:condition][type] ||= {}
|
114
|
-
data[:condition][type][property] = value
|
115
|
-
end
|
116
|
-
|
117
|
-
# Extract properties to be applied
|
118
|
-
css.scan(/(\w+) \{([^\}]+)\}/).each do |match|
|
119
|
-
key = match[0].to_sym
|
120
|
-
properties = match[1].split(';').map(&:strip).reject(&:empty?)
|
121
|
-
|
122
|
-
data[:apply][key] ||= {}
|
123
|
-
properties.each do |property|
|
124
|
-
prop, value = property.split(':').map(&:strip)
|
125
|
-
if prop == 'background-color'
|
126
|
-
data[:apply][key][:color] = value.to_sym
|
127
|
-
elsif value[-2..] == 'px'
|
128
|
-
data[:apply][key][prop.to_sym] = value.to_i
|
129
|
-
else
|
130
|
-
data[:apply][key][prop.to_sym] = value.to_sym
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
data
|
136
|
-
end
|
137
|
-
|
138
|
-
def extract_properties(properties_string)
|
139
|
-
properties_hash = {}
|
140
|
-
properties = properties_string.split(';').map(&:strip).reject(&:empty?)
|
141
|
-
properties.each do |property|
|
142
|
-
key, value = property.split(':').map(&:strip)
|
143
|
-
properties_hash[key] = value
|
144
|
-
end
|
145
|
-
properties_hash
|
146
|
-
end
|
147
|
-
|
148
|
-
def get_page_style
|
149
|
-
main_view = JS.global[:document].getElementById('view')
|
150
|
-
main_view_content = main_view[:innerHTML].to_s
|
151
|
-
style_tags = main_view_content.split(/<\/?style[^>]*>/i).select.with_index { |_, index| index.odd? }
|
152
|
-
style_tags = style_tags.join('')
|
153
|
-
style_tags = style_tags.split("\n")
|
154
|
-
hash_result = {}
|
155
|
-
inside_media = false
|
156
|
-
media_hash = {}
|
157
|
-
|
158
|
-
style_tags.each do |line|
|
159
|
-
line = line.strip
|
160
|
-
next if line.empty? || line.start_with?('/*')
|
161
|
-
|
162
|
-
if inside_media
|
163
|
-
if line == '}'
|
164
|
-
hash_result['@media'] << media_hash
|
165
|
-
inside_media = false
|
166
|
-
next
|
167
|
-
end
|
168
|
-
|
169
|
-
selector, properties = line.split('{').map(&:strip)
|
170
|
-
next unless properties&.end_with?('}')
|
171
|
-
|
172
|
-
properties = properties[0...-1].strip
|
173
|
-
media_hash[selector] = extract_properties(properties)
|
174
|
-
elsif line.start_with?('@media')
|
175
|
-
media_content = line.match(/@media\s*\(([^)]+)\)\s*{/)
|
176
|
-
next unless media_content
|
177
|
-
|
178
|
-
media_query = media_content[1]
|
179
|
-
hash_result['@media'] = [media_query]
|
180
|
-
inside_media = true
|
181
|
-
else
|
182
|
-
selector, properties = line.split('{').map(&:strip)
|
183
|
-
next unless properties&.end_with?('}')
|
184
|
-
|
185
|
-
properties = properties[0...-1].strip
|
186
|
-
hash_result[selector] = extract_properties(properties)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
hash_result
|
190
|
-
end
|
191
|
-
|
192
|
-
def hyperedit(params, usr_bloc)
|
193
|
-
html_object = JS.global[:document].getElementById(params.to_s)
|
194
|
-
particles_from_style = {}
|
195
|
-
# we get all the styles tag present in the page
|
196
|
-
get_page_style
|
197
|
-
if html_object[:className].to_s
|
198
|
-
classes_found = html_object[:className].to_s.split(' ')
|
199
|
-
classes_found.each do |class_found|
|
200
|
-
if get_page_style[".#{class_found}"]
|
201
|
-
particles_from_style = particles_from_style.merge(get_page_style[".#{class_found}"])
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
particles_found = {}
|
207
|
-
particles_found[:data] = html_object[:innerText].to_s.chomp
|
208
|
-
particles_found[:markup] = html_object[:tagName].to_s
|
209
|
-
|
210
|
-
style_found = html_object[:style][:cssText].to_s
|
211
|
-
|
212
|
-
style_found.split(';').each do |pair|
|
213
|
-
key, value = pair.split(':').map(&:strip)
|
214
|
-
particles_from_style[key.to_sym] = value if key && value
|
215
|
-
end
|
216
|
-
|
217
|
-
# alert "hyperedit"
|
218
|
-
|
219
|
-
particles_found = particles_found.merge(particles_from_style)
|
220
|
-
current_atome = grab(@id)
|
221
|
-
usr_bloc.call(particles_found)
|
222
|
-
# current_atome.callback({ hyperedit: particles_found })
|
223
|
-
# current_atome.call(:hyperedit)
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
def match(params)
|
228
|
-
css_converted = convert_to_css(params)
|
229
|
-
css_to_data(css_converted)
|
230
|
-
end
|
231
|
-
|
232
|
-
def connect(params, &bloc)
|
233
|
-
type = params[:type]
|
234
|
-
server = params[:address]
|
235
|
-
# user=params[:user]
|
236
|
-
# pass=params[:pass]
|
237
|
-
# atomes=params[:atomes]
|
238
|
-
# particles=params[:particles]
|
239
|
-
# 'atomeJS.connect' is in the communication.js file ( connect: function (type, server, )
|
240
|
-
JS.eval("atomeJS.connect('#{type}','#{server}')")
|
241
|
-
|
242
|
-
# @websocket = JS.new(JS.global.WebSocket.new("#{type}://#{server}"))
|
243
|
-
|
244
|
-
# JS.eval("atomeJS.connect('ws://#{server}')")
|
245
|
-
end
|
246
|
-
|
247
|
-
def send_message(message)
|
248
|
-
JS.eval("atomeJS.ws_sender('#{message}')")
|
249
|
-
end
|
250
|
-
|
251
|
-
def close_websocket
|
252
|
-
@websocket.close
|
253
|
-
end
|
254
|
-
|
255
|
-
def attr(attribute, value)
|
256
|
-
@element.setAttribute(attribute.to_s, value.to_s)
|
257
|
-
self
|
258
|
-
end
|
259
|
-
|
260
|
-
def add_class(class_to_add)
|
261
|
-
@element[:classList].add(class_to_add.to_s)
|
262
|
-
self
|
263
|
-
end
|
264
|
-
|
265
|
-
def remove_class(class_to_remove)
|
266
|
-
@element[:classList].remove(class_to_remove.to_s)
|
267
|
-
self
|
268
|
-
end
|
269
|
-
|
270
|
-
def id(id)
|
271
|
-
attr('id', id)
|
272
|
-
self
|
273
|
-
end
|
274
|
-
|
275
|
-
def check_double(id)
|
276
|
-
# we remove any element if the id already exist
|
277
|
-
element_to_delete = JS.global[:document].getElementById(id.to_s)
|
278
|
-
delete(id) unless element_to_delete.inspect == 'null'
|
279
|
-
end
|
280
|
-
|
281
|
-
def shape(id)
|
282
|
-
# we remove any element if the id already exist
|
283
|
-
check_double(id)
|
284
|
-
markup_found = @original_atome.markup || :div
|
285
|
-
@element_type = markup_found.to_s
|
286
|
-
@element = JS.global[:document].createElement(@element_type)
|
287
|
-
JS.global[:document][:body].appendChild(@element)
|
288
|
-
add_class('atome')
|
289
|
-
id(id)
|
290
|
-
self
|
291
|
-
end
|
292
|
-
|
293
|
-
def text(id)
|
294
|
-
# we remove any element if the id already exist
|
295
|
-
check_double(id)
|
296
|
-
markup_found = @original_atome.markup || :pre
|
297
|
-
@element_type = markup_found.to_s
|
298
|
-
@element = JS.global[:document].createElement(@element_type)
|
299
|
-
JS.global[:document][:body].appendChild(@element)
|
300
|
-
add_class('atome')
|
301
|
-
id(id)
|
302
|
-
####
|
303
|
-
|
304
|
-
# editable_pres = JS.global[:document].querySelectorAll('pre[contenteditable="true"]')
|
305
|
-
# editable_pres_array = Array.new(editable_pres[:length].to_i) { |i| editable_pres.call(:item, i) }
|
306
|
-
# editable_pres_array.each do |pre|
|
307
|
-
# pre.addEventListener('input') do
|
308
|
-
# if pre[:innerText].strip == ''
|
309
|
-
# pre[:innerHTML] = '​' # Insère un caractère d'espace insécable
|
310
|
-
# end
|
311
|
-
# end
|
312
|
-
# end
|
313
|
-
|
314
|
-
# editable_pres = JS.global[:document].querySelectorAll('pre[contenteditable="true"]')
|
315
|
-
#
|
316
|
-
# editable_pres_array = Array.new(editable_pres[:length].to_i) { |i| editable_pres.call(:item, i) }
|
317
|
-
# editable_pres_array.each do |pre|
|
318
|
-
# pre.addEventListener('click') do
|
319
|
-
# pre.focus()
|
320
|
-
# pre[:style][:caretColor] = 'blue' # Changez la couleur du curseur en bleu
|
321
|
-
# end
|
322
|
-
# end
|
323
|
-
###
|
324
|
-
self
|
325
|
-
end
|
326
|
-
|
327
|
-
def select_text(range)
|
328
|
-
# TODO : use atome color object instead of basic css color
|
329
|
-
back_color = grab(:back_selection)
|
330
|
-
text_color = grab(:text_selection)
|
331
|
-
|
332
|
-
back_color_rgba = "rgba(#{back_color.red * 255},#{back_color.green * 255},#{back_color.blue * 255}, #{back_color.alpha})"
|
333
|
-
text_color_rgba = "rgba(#{text_color.red * 255},#{text_color.green * 255},#{text_color.blue * 255}, #{text_color.alpha})"
|
334
|
-
|
335
|
-
range = JS.global[:document].createRange()
|
336
|
-
range.selectNodeContents(@element)
|
337
|
-
selection = JS.global[:window].getSelection()
|
338
|
-
selection.removeAllRanges()
|
339
|
-
selection.addRange(range)
|
340
|
-
@element.focus()
|
341
|
-
style = JS.global[:document].createElement('style')
|
342
|
-
style[:innerHTML] = "::selection { background-color: #{back_color_rgba}; color: #{text_color_rgba}; }"
|
343
|
-
JS.global[:document][:head].appendChild(style)
|
344
|
-
return unless @element[:innerText].to_s.length == 1
|
345
|
-
|
346
|
-
@element[:innerHTML] = '​'
|
347
|
-
end
|
348
|
-
|
349
|
-
def image(id)
|
350
|
-
# we remove any element if the id already exist
|
351
|
-
check_double(id)
|
352
|
-
markup_found = @original_atome.markup || :img
|
353
|
-
@element_type = markup_found.to_s
|
354
|
-
@element = JS.global[:document].createElement(@element_type)
|
355
|
-
JS.global[:document][:body].appendChild(@element)
|
356
|
-
add_class('atome')
|
357
|
-
self.id(id)
|
358
|
-
|
359
|
-
self
|
360
|
-
end
|
361
|
-
|
362
|
-
def video(id)
|
363
|
-
# we remove any element if the id already exist
|
364
|
-
check_double(id)
|
365
|
-
markup_found = @original_atome.markup || :video
|
366
|
-
@element_type = markup_found.to_s
|
367
|
-
@element = JS.global[:document].createElement(@element_type)
|
368
|
-
JS.global[:document][:body].appendChild(@element)
|
369
|
-
add_class('atome')
|
370
|
-
self.id(id)
|
371
|
-
self
|
372
|
-
end
|
373
|
-
|
374
|
-
def www(id)
|
375
|
-
# we remove any element if the id already exist
|
376
|
-
check_double(id)
|
377
|
-
markup_found = @original_atome.markup || :iframe
|
378
|
-
@element_type = markup_found.to_s
|
379
|
-
@element = JS.global[:document].createElement(@element_type)
|
380
|
-
JS.global[:document][:body].appendChild(@element)
|
381
|
-
add_class('atome')
|
382
|
-
@element.setAttribute('src', 'https://www.youtube.com/embed/lLeQZ8Llkso?si=MMsGBEXELy9yBl9R')
|
383
|
-
# below we get image to feed width and height if needed
|
384
|
-
# image = JS.global[:Image].new
|
385
|
-
self.id(id)
|
386
|
-
self
|
387
|
-
end
|
388
|
-
|
389
|
-
def raw(id)
|
390
|
-
# we remove any element if the id already exist
|
391
|
-
check_double(id)
|
392
|
-
@element = JS.global[:document].createElement('div')
|
393
|
-
add_class('atome')
|
394
|
-
self.id(id)
|
395
|
-
JS.global[:document][:body].appendChild(@element)
|
396
|
-
self
|
397
|
-
end
|
398
|
-
|
399
|
-
def svg(id)
|
400
|
-
# we remove any element if the id already exist
|
401
|
-
check_double(id)
|
402
|
-
markup_found = @original_atome.markup || 'svg'
|
403
|
-
@element_type = markup_found.to_s
|
404
|
-
svg_ns = 'http://www.w3.org/2000/svg'
|
405
|
-
@element = JS.global[:document].createElementNS(svg_ns, 'svg')
|
406
|
-
JS.global[:document][:body].appendChild(@element)
|
407
|
-
@element.setAttribute('viewBox', '0 0 1024 1024')
|
408
|
-
@element.setAttribute('version', '1.1')
|
409
|
-
add_class('atome')
|
410
|
-
self.id(id)
|
411
|
-
self
|
412
|
-
end
|
413
|
-
|
414
|
-
def svg_data(all_datas)
|
415
|
-
# we remove previous datas
|
416
|
-
# @element.innerHTML = ''
|
417
|
-
all_datas.each do |full_data|
|
418
|
-
full_data.each do |type_passed, datas|
|
419
|
-
|
420
|
-
svg_ns = 'http://www.w3.org/2000/svg'
|
421
|
-
new_path = JS.global[:document].createElementNS(svg_ns.to_s, type_passed.to_s)
|
422
|
-
JS.global[:document][:body].appendChild(new_path)
|
423
|
-
datas.each do |property, value|
|
424
|
-
new_path.setAttribute(property.to_s, value.to_s)
|
425
|
-
end
|
426
|
-
@element.appendChild(new_path)
|
427
|
-
end
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
def update_svg_data(data)
|
432
|
-
data.each do |type_passed, datas|
|
433
|
-
element_to_update = JS.global[:document].getElementById(type_passed.to_s)
|
434
|
-
datas.each do |property, value|
|
435
|
-
element_to_update.setAttribute(property.to_s, value.to_s)
|
436
|
-
end
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
def colorize_svg_data(data)
|
441
|
-
command = <<-JS
|
442
|
-
let svgElement = document.getElementById("#{@id}");
|
443
|
-
if (!svgElement) {
|
444
|
-
return [];
|
445
|
-
}
|
446
|
-
var children = svgElement.children;
|
447
|
-
var ids = [];
|
448
|
-
for (var i = 0; i < children.length; i++) {
|
449
|
-
var element = document.getElementById(children[i].id); // Récupérer l'élément par son ID
|
450
|
-
if (element) {
|
451
|
-
element.setAttribute('fill', '#{data}'); // Modifier l'attribut fill
|
452
|
-
element.setAttribute('stroke', '#{data}'); // Modifier l'attribut stroke
|
453
|
-
}
|
454
|
-
ids.push(children[i].id);
|
455
|
-
}
|
456
|
-
return ids
|
457
|
-
JS
|
458
|
-
JS.eval(command)
|
459
|
-
end
|
460
|
-
|
461
|
-
def raw_data(html_string)
|
462
|
-
@element[:innerHTML] = html_string
|
463
|
-
end
|
464
|
-
|
465
|
-
def video_path(video_path, type = 'video/mp4')
|
466
|
-
source = JS.global[:document].createElement('source')
|
467
|
-
source.setAttribute('src', video_path)
|
468
|
-
source.setAttribute('type', type)
|
469
|
-
@element.appendChild(source)
|
470
|
-
end
|
471
|
-
|
472
|
-
def sanitize_text(text)
|
473
|
-
text.to_s
|
474
|
-
.gsub('&', "\&")
|
475
|
-
.gsub('<', "\<")
|
476
|
-
.gsub('>', "\>")
|
477
|
-
.gsub('"', '"')
|
478
|
-
.gsub("'", "\'")
|
479
|
-
end
|
480
|
-
|
481
|
-
def innerText(data)
|
482
|
-
sanitized_data = sanitize_text(data.to_s)
|
483
|
-
@element[:innerText] = sanitized_data
|
484
|
-
end
|
485
|
-
|
486
|
-
def textContent(data)
|
487
|
-
@element[:textContent] = data
|
488
|
-
end
|
489
|
-
|
490
|
-
def path(objet_path)
|
491
|
-
@element.setAttribute('src', objet_path)
|
492
|
-
# below we get image to feed width and height if needed
|
493
|
-
# image = JS.global[:Image].new
|
494
|
-
@element[:src] = objet_path
|
495
|
-
@element[:onload] = lambda do |_event|
|
496
|
-
@element[:width]
|
497
|
-
@element[:height]
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
|
-
def transform(property, value = nil)
|
502
|
-
transform_needed = "#{property}(#{value}deg)"
|
503
|
-
@element[:style][:transform] = transform_needed.to_s
|
504
|
-
end
|
505
|
-
|
506
|
-
def style(property, value = nil)
|
507
|
-
if value
|
508
|
-
@element[:style][property] = value.to_s
|
509
|
-
elsif value.nil?
|
510
|
-
@element[:style][property]
|
511
|
-
else
|
512
|
-
# If value is explicitly set to false, remove the property
|
513
|
-
command = "document.getElementById('#{@id}').style.removeProperty('#{property}')"
|
514
|
-
JS.eval(command)
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
def fill(params)
|
519
|
-
# we remove previous background
|
520
|
-
elements_to_remove = @element.getElementsByClassName('background')
|
521
|
-
|
522
|
-
elements_to_remove = elements_to_remove.to_a
|
523
|
-
elements_to_remove.each do |child|
|
524
|
-
@element.removeChild(child)
|
525
|
-
end
|
526
|
-
params.each do |param|
|
527
|
-
background_layer = JS.global[:document].createElement("div")
|
528
|
-
background_layer[:style][:transform] = "rotate(#{param[:rotate]}deg)" # Applique une rotation de 45 degrés à l'élément
|
529
|
-
background_layer[:style][:position] = "absolute"
|
530
|
-
|
531
|
-
if param[:position]
|
532
|
-
background_layer[:style][:top] = "#{param[:position][:x]}px"
|
533
|
-
background_layer[:style][:left] = "#{param[:position][:y]}px"
|
534
|
-
else
|
535
|
-
background_layer[:style][:top] = "0"
|
536
|
-
background_layer[:style][:left] = "0"
|
537
|
-
end
|
538
|
-
|
539
|
-
if param[:size]
|
540
|
-
background_layer[:style][:width] = "#{param[:size][:x]}px"
|
541
|
-
background_layer[:style][:height] = "#{param[:size][:y]}px"
|
542
|
-
else
|
543
|
-
background_layer[:style][:width] = "100%"
|
544
|
-
background_layer[:style][:height] = "100%"
|
545
|
-
end
|
546
|
-
|
547
|
-
atome_path = grab(param[:atome]).path
|
548
|
-
background_layer[:style][:backgroundImage] = "url('#{atome_path}')"
|
549
|
-
background_layer[:style][:backgroundRepeat] = 'repeat'
|
550
|
-
background_layer[:className] = 'background'
|
551
|
-
background_layer[:style][:opacity] = param[:opacity]
|
552
|
-
if param[:repeat]
|
553
|
-
img_width = @original_atome.width / param[:repeat][:x]
|
554
|
-
img_height = @original_atome.height / param[:repeat][:y]
|
555
|
-
background_layer[:style][:backgroundSize] = "#{img_width}px #{img_height}px"
|
556
|
-
else
|
557
|
-
background_layer[:style][:backgroundSize] = "#{param[:width]}px #{param[:height]}px"
|
558
|
-
end
|
559
|
-
@element.appendChild(background_layer)
|
560
|
-
end
|
561
|
-
end
|
562
|
-
|
563
|
-
def filter(property, value)
|
564
|
-
filter_needed = "#{property}(#{value})"
|
565
|
-
@element[:style][:filter] = filter_needed
|
566
|
-
end
|
567
|
-
|
568
|
-
def backdropFilter(property, value)
|
569
|
-
filter_needed = "#{property}(#{value})"
|
570
|
-
@element[:style][:"-webkit-backdrop-filter"] = filter_needed
|
571
|
-
end
|
572
|
-
|
573
|
-
def currentTime(time)
|
574
|
-
@element[:currentTime] = time
|
575
|
-
end
|
576
|
-
|
577
|
-
def animation_frame_callback(proc_pass, play_content)
|
578
|
-
JS.global[:window].requestAnimationFrame(-> (timestamp) {
|
579
|
-
current_time = @element[:currentTime]
|
580
|
-
fps = 30
|
581
|
-
current_frame = (current_time.to_f * fps).to_i
|
582
|
-
@original_atome.instance_exec({ frame: current_frame, time: current_time }, &proc_pass) if proc_pass.is_a? Proc
|
583
|
-
# we update play instance variable so if user ask for atome.play it will return current frame
|
584
|
-
play_content[:play] = current_frame
|
585
|
-
animation_frame_callback(proc_pass, play_content)
|
586
|
-
})
|
587
|
-
end
|
588
|
-
|
589
|
-
def action(_particle, action_found, option = nil)
|
590
|
-
|
591
|
-
# alert option
|
592
|
-
if action_found == :stop
|
593
|
-
currentTime(option)
|
594
|
-
@element.pause
|
595
|
-
elsif action_found == :pause
|
596
|
-
@element.pause
|
597
|
-
else
|
598
|
-
currentTime(option)
|
599
|
-
proc_found = @original_atome.instance_variable_get('@play_code')[action_found]
|
600
|
-
play_content = @original_atome.instance_variable_get('@play')
|
601
|
-
animation_frame_callback(proc_found, play_content)
|
602
|
-
@element.play
|
603
|
-
end
|
604
|
-
end
|
605
|
-
|
606
|
-
def append_to(parent_id_found)
|
607
|
-
parent_found = JS.global[:document].getElementById(parent_id_found.to_s)
|
608
|
-
parent_found.appendChild(@element)
|
609
|
-
self
|
610
|
-
end
|
611
|
-
|
612
|
-
# def visible(param)
|
613
|
-
# @element[:style][:display] = param.to_s
|
614
|
-
# end
|
615
|
-
|
616
|
-
def delete(id_to_delete)
|
617
|
-
element_to_delete = JS.global[:document].getElementById(id_to_delete.to_s)
|
618
|
-
element_to_delete.remove if element_to_delete
|
619
|
-
end
|
620
|
-
|
621
|
-
def append(child_id_found)
|
622
|
-
child_found = JS.global[:document].getElementById(child_id_found.to_s)
|
623
|
-
@element.appendChild(child_found)
|
624
|
-
self
|
625
|
-
end
|
626
|
-
|
627
|
-
# events handlers
|
628
|
-
def on(property, _option)
|
629
|
-
bloc = @original_atome.instance_variable_get('@on_code')[:view_resize]
|
630
|
-
property = property.to_s
|
631
|
-
|
632
|
-
if property.start_with?('media:')
|
633
|
-
# extract request from property
|
634
|
-
media_query = property.split(':', 2).last
|
635
|
-
|
636
|
-
mql = JS.global[:window].matchMedia(media_query)
|
637
|
-
|
638
|
-
event_handler = ->(event) do
|
639
|
-
bloc.call({ matches: event[:matches] }) if bloc.is_a? Proc
|
640
|
-
end
|
641
|
-
|
642
|
-
# add a listener to matchMedia object
|
643
|
-
mql.addListener(event_handler)
|
644
|
-
|
645
|
-
elsif property == 'resize'
|
646
|
-
event_handler = ->(event) do
|
647
|
-
width = JS.global[:window][:innerWidth]
|
648
|
-
height = JS.global[:window][:innerHeight]
|
649
|
-
bloc.call({ width: width, height: height }) if bloc.is_a? Proc
|
650
|
-
end
|
651
|
-
JS.global[:window].addEventListener('resize', event_handler)
|
652
|
-
else
|
653
|
-
event_handler = ->(event) do
|
654
|
-
bloc.call(event) if bloc.is_a? Proc
|
655
|
-
end
|
656
|
-
@element.addEventListener(property, event_handler)
|
657
|
-
end
|
658
|
-
end
|
659
|
-
|
660
|
-
def keyboard_press(_option)
|
661
|
-
@keyboard_press = @original_atome.instance_variable_get('@keyboard_code')[:press]
|
662
|
-
|
663
|
-
keypress_handler = ->(native_event) do
|
664
|
-
|
665
|
-
event = Native(native_event)
|
666
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
667
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
668
|
-
# group etc..
|
669
|
-
@keyboard_press.call(event) if @keyboard_press.is_a?(Proc)
|
670
|
-
end
|
671
|
-
@element.addEventListener('keypress', keypress_handler)
|
672
|
-
end
|
673
|
-
|
674
|
-
def keyboard_down(_option)
|
675
|
-
@keyboard_down = @original_atome.instance_variable_get('@keyboard_code')[:down]
|
676
|
-
|
677
|
-
keypress_handler = ->(event) do
|
678
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
679
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
680
|
-
# group etc..
|
681
|
-
@keyboard_down.call(event) if @keyboard_down.is_a?(Proc)
|
682
|
-
end
|
683
|
-
@element.addEventListener('keydown', keypress_handler)
|
684
|
-
end
|
685
|
-
|
686
|
-
def keyboard_up(_option)
|
687
|
-
@keyboard_up = @original_atome.instance_variable_get('@keyboard_code')[:up]
|
688
|
-
|
689
|
-
keypress_handler = ->(event) do
|
690
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
691
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
692
|
-
# group etc..
|
693
|
-
@keyboard_up.call(event) if @keyboard_up.is_a?(Proc)
|
694
|
-
end
|
695
|
-
@element.addEventListener('keyup', keypress_handler)
|
696
|
-
end
|
697
|
-
|
698
|
-
def keyboard_remove(option)
|
699
|
-
case option
|
700
|
-
when :down
|
701
|
-
@keyboard_down = ''
|
702
|
-
when :up
|
703
|
-
@keyboard_up = ''
|
704
|
-
when :down
|
705
|
-
@keyboard_press = ''
|
706
|
-
else
|
707
|
-
@keyboard_down = ''
|
708
|
-
@keyboard_up = ''
|
709
|
-
@keyboard_press = ''
|
710
|
-
end
|
711
|
-
end
|
712
|
-
|
713
|
-
def event(action, variance, option = nil)
|
714
|
-
send("#{action}_#{variance}", option)
|
715
|
-
end
|
716
|
-
|
717
|
-
def restrict_movement(restricted_x, restricted_y)
|
718
|
-
@original_atome.left(restricted_x)
|
719
|
-
@original_atome.top(restricted_y)
|
720
|
-
end
|
721
|
-
|
722
|
-
def drag_remove(option)
|
723
|
-
|
724
|
-
interact = JS.eval("return interact('##{@id}')")
|
725
|
-
|
726
|
-
case option
|
727
|
-
when :start
|
728
|
-
@drag_start = ''
|
729
|
-
when :end, :stop
|
730
|
-
@drag_end = ''
|
731
|
-
when :move
|
732
|
-
interact.draggable(false)
|
733
|
-
interact.unset
|
734
|
-
@drag_move = nil
|
735
|
-
when :locked
|
736
|
-
@drag_locked = ''
|
737
|
-
when :restrict
|
738
|
-
@drag_restrict = ''
|
739
|
-
else
|
740
|
-
# to remove all interact event ( touch, drag, scale, ... uncomment below)
|
741
|
-
@drag_start = ''
|
742
|
-
@drag_end = ''
|
743
|
-
@drag_locked = ''
|
744
|
-
@drag_restrict = ''
|
745
|
-
@drag_move = nil
|
746
|
-
interact.draggable(false)
|
747
|
-
interact.unset
|
748
|
-
end
|
749
|
-
|
750
|
-
end
|
751
|
-
|
752
|
-
def drag_start(_option)
|
753
|
-
interact = JS.eval("return interact('##{@id}')")
|
754
|
-
@drag_start = @original_atome.instance_variable_get('@drag_code')[:start]
|
755
|
-
interact.on('dragstart') do |native_event|
|
756
|
-
event = Native(native_event)
|
757
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
758
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
759
|
-
# group etc..
|
760
|
-
@drag_start.call(event) if @drag_start.is_a?(Proc)
|
761
|
-
end
|
762
|
-
end
|
763
|
-
|
764
|
-
def drag_end(_option)
|
765
|
-
interact = JS.eval("return interact('##{@id}')")
|
766
|
-
@drag_end = @original_atome.instance_variable_get('@drag_code')[:end]
|
767
|
-
interact.on('dragend') do |native_event|
|
768
|
-
event = Native(native_event)
|
769
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
770
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
771
|
-
# group etc..
|
772
|
-
@drag_end.call(event) if @drag_end.is_a?(Proc)
|
773
|
-
end
|
774
|
-
end
|
775
|
-
|
776
|
-
def drag_move(_option)
|
777
|
-
|
778
|
-
interact = JS.eval("return interact('##{@id}')")
|
779
|
-
# interact.draggable(false)
|
780
|
-
|
781
|
-
interact.draggable({
|
782
|
-
drag: true,
|
783
|
-
inertia: { resistance: 12,
|
784
|
-
minSpeed: 200,
|
785
|
-
endSpeed: 100 },
|
786
|
-
})
|
787
|
-
|
788
|
-
@drag_move = @original_atome.instance_variable_get('@drag_code')[:move]
|
789
|
-
interact.on('dragmove') do |native_event|
|
790
|
-
# the use of Native is only for Opal (look at lib/platform_specific/atome_wasm_extensions.rb for more infos)
|
791
|
-
event = Native(native_event)
|
792
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
793
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
794
|
-
# group etc..
|
795
|
-
@drag_move.call(event) if @drag_move.is_a?(Proc)
|
796
|
-
Universe.allow_tool_operations = false
|
797
|
-
dx = event[:dx]
|
798
|
-
dy = event[:dy]
|
799
|
-
x = (@original_atome.left || 0) + dx.to_f
|
800
|
-
y = (@original_atome.top || 0) + dy.to_f
|
801
|
-
@original_atome.left(x)
|
802
|
-
@original_atome.top(y)
|
803
|
-
end
|
804
|
-
end
|
805
|
-
|
806
|
-
def drag_restrict(option)
|
807
|
-
interact = JS.eval("return interact('##{@id}')")
|
808
|
-
interact.draggable({
|
809
|
-
drag: true,
|
810
|
-
inertia: { resistance: 12,
|
811
|
-
minSpeed: 200,
|
812
|
-
endSpeed: 100 },
|
813
|
-
})
|
814
|
-
|
815
|
-
@drag_move = @original_atome.instance_variable_get('@drag_code')[:restrict]
|
816
|
-
if option.instance_of? Hash
|
817
|
-
max_left = grab(:view).to_px(:width)
|
818
|
-
max_top = grab(:view).to_px(:height)
|
819
|
-
min_left = 0
|
820
|
-
min_top = 0
|
821
|
-
|
822
|
-
if option[:max]
|
823
|
-
max_left = option[:max][:left] || max_left
|
824
|
-
max_top = option[:max][:top] || max_top
|
825
|
-
else
|
826
|
-
max_left
|
827
|
-
max_top
|
828
|
-
end
|
829
|
-
if option[:min]
|
830
|
-
min_left = option[:min][:left] || min_left
|
831
|
-
min_top = option[:min][:top] || min_top
|
832
|
-
else
|
833
|
-
min_left
|
834
|
-
min_top
|
835
|
-
end
|
836
|
-
else
|
837
|
-
parent_found = grab(option)
|
838
|
-
min_left = parent_found.left
|
839
|
-
min_top = parent_found.top
|
840
|
-
parent_width = parent_found.compute({ particle: :width })[:value]
|
841
|
-
parent_height = parent_found.compute({ particle: :height })[:value]
|
842
|
-
original_width = @original_atome.width
|
843
|
-
original_height = @original_atome.height
|
844
|
-
max_left = min_left + parent_width - original_width
|
845
|
-
max_top = min_top + parent_height - original_height
|
846
|
-
end
|
847
|
-
|
848
|
-
interact.on('dragmove') do |native_event|
|
849
|
-
# the use of Native is only for Opal (look at lib/platform_specific/atome_wasm_extensions.rb for more infos)
|
850
|
-
event = Native(native_event)
|
851
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
852
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
853
|
-
# group etc..
|
854
|
-
@drag_move.call(event) if @drag_move.is_a?(Proc)
|
855
|
-
dx = event[:dx]
|
856
|
-
dy = event[:dy]
|
857
|
-
x = (@original_atome.left || 0) + dx.to_f
|
858
|
-
y = (@original_atome.top || 0) + dy.to_f
|
859
|
-
restricted_x = [[x, min_left].max, max_left].min
|
860
|
-
restricted_y = [[y, min_top].max, max_top].min
|
861
|
-
restrict_movement(restricted_x, restricted_y)
|
862
|
-
end
|
863
|
-
end
|
864
|
-
|
865
|
-
def drag_locked(_option)
|
866
|
-
interact = JS.eval("return interact('##{@id}')")
|
867
|
-
interact.draggable({
|
868
|
-
drag: true,
|
869
|
-
inertia: { resistance: 12,
|
870
|
-
minSpeed: 200,
|
871
|
-
endSpeed: 100 }
|
872
|
-
})
|
873
|
-
|
874
|
-
@drag_lock = @original_atome.instance_variable_get('@drag_code')[:locked]
|
875
|
-
interact.on('dragmove') do |native_event|
|
876
|
-
# the use of Native is only for Opal (look at lib/platform_specific/atome_wasm_extensions.rb for more infos)
|
877
|
-
event = Native(native_event)
|
878
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
879
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
880
|
-
# group etc..
|
881
|
-
@drag_lock.call(event) if @drag_lock.is_a?(Proc)
|
882
|
-
end
|
883
|
-
end
|
884
|
-
|
885
|
-
def drop_action(native_event, bloc)
|
886
|
-
event = Native(native_event)
|
887
|
-
draggable_element = event[:relatedTarget][:id].to_s
|
888
|
-
dropzone_element = event[:target][:id].to_s
|
889
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
890
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
891
|
-
# group etc..
|
892
|
-
bloc.call({ source: draggable_element, destination: dropzone_element }) if bloc.is_a?(Proc)
|
893
|
-
end
|
894
|
-
|
895
|
-
def drop_activate(_option)
|
896
|
-
interact = JS.eval("return interact('##{@id}')")
|
897
|
-
@drop_activate = @original_atome.instance_variable_get('@drop_code')[:activate]
|
898
|
-
|
899
|
-
interact.dropzone({
|
900
|
-
accept: nil, # Accept any element
|
901
|
-
overlap: 0.75,
|
902
|
-
ondropactivate: lambda do |native_event|
|
903
|
-
drop_action(native_event, @drop_activate)
|
904
|
-
end
|
905
|
-
})
|
906
|
-
end
|
907
|
-
|
908
|
-
def drop_deactivate(_option)
|
909
|
-
interact = JS.eval("return interact('##{@id}')")
|
910
|
-
@drop_deactivate = @original_atome.instance_variable_get('@drop_code')[:deactivate]
|
911
|
-
interact.dropzone({
|
912
|
-
# accept: nil, # Accept any element
|
913
|
-
# overlap: 0.75,
|
914
|
-
# FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
|
915
|
-
ondropdeactivate: lambda do |native_event|
|
916
|
-
drop_action(native_event, @drop_deactivate)
|
917
|
-
end
|
918
|
-
})
|
919
|
-
end
|
920
|
-
|
921
|
-
def drop_dropped(_option)
|
922
|
-
@drop_dropped = @original_atome.instance_variable_get('@drop_code')[:dropped]
|
923
|
-
interact = JS.eval("return interact('##{@id}')")
|
924
|
-
interact.dropzone({
|
925
|
-
# accept: nil, # Accept any element
|
926
|
-
overlap: 0.75,
|
927
|
-
# FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
|
928
|
-
ondrop: lambda do |native_event|
|
929
|
-
drop_action(native_event, @drop_dropped)
|
930
|
-
end
|
931
|
-
})
|
932
|
-
end
|
933
|
-
|
934
|
-
def drop_enter(_option)
|
935
|
-
interact = JS.eval("return interact('##{@id}')")
|
936
|
-
|
937
|
-
@drop_enter = @original_atome.instance_variable_get('@drop_code')[:enter]
|
938
|
-
|
939
|
-
interact.dropzone({
|
940
|
-
# accept: nil,
|
941
|
-
overlap: 0.001,
|
942
|
-
# FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
|
943
|
-
ondragenter: lambda do |native_event|
|
944
|
-
drop_action(native_event, @drop_enter)
|
945
|
-
end
|
946
|
-
})
|
947
|
-
end
|
948
|
-
|
949
|
-
def drop_leave(_option)
|
950
|
-
interact = JS.eval("return interact('##{@id}')")
|
951
|
-
@drop_leave = @original_atome.instance_variable_get('@drop_code')[:leave]
|
952
|
-
|
953
|
-
interact.dropzone({
|
954
|
-
# accept: nil,
|
955
|
-
# overlap: 0.75,
|
956
|
-
# FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
|
957
|
-
ondragleave: lambda do |native_event|
|
958
|
-
drop_action(native_event, @drop_leave)
|
959
|
-
end
|
960
|
-
})
|
961
|
-
|
962
|
-
end
|
963
|
-
|
964
|
-
def drop_remove(option)
|
965
|
-
case option
|
966
|
-
when :activate
|
967
|
-
@drop_activate = ''
|
968
|
-
when :deactivate
|
969
|
-
@drop_deactivate = ''
|
970
|
-
when :dropped
|
971
|
-
@drop_dropped = ''
|
972
|
-
when :enter
|
973
|
-
@drop_enter = ''
|
974
|
-
when :leave
|
975
|
-
@drop_leave = ''
|
976
|
-
else
|
977
|
-
# to remove all interact event ( touch, drag, scale, ... uncomment below)
|
978
|
-
interact = JS.eval("return interact('##{@id}')")
|
979
|
-
interact.unset
|
980
|
-
@drop_activate = ''
|
981
|
-
@drop_deactivate = ''
|
982
|
-
@drop_dropped = ''
|
983
|
-
@drop_enter = ''
|
984
|
-
@drop_leave = ''
|
985
|
-
|
986
|
-
end
|
987
|
-
|
988
|
-
end
|
989
|
-
|
990
|
-
def resize(params, options)
|
991
|
-
interact = JS.eval("return interact('##{@id}')")
|
992
|
-
if params == :remove
|
993
|
-
@resize = ''
|
994
|
-
interact.resizable(false)
|
995
|
-
else
|
996
|
-
min_width = options[:min][:width] || 10
|
997
|
-
min_height = options[:min][:height] || 10
|
998
|
-
max_width = options[:max][:width] || 3000
|
999
|
-
max_height = options[:max][:height] || 3000
|
1000
|
-
@resize = @original_atome.instance_variable_get('@resize_code')[:resize]
|
1001
|
-
interact.resizable({
|
1002
|
-
edges: { left: true, right: true, top: true, bottom: true },
|
1003
|
-
inertia: true,
|
1004
|
-
modifiers: [],
|
1005
|
-
listeners: {
|
1006
|
-
move: lambda do |native_event|
|
1007
|
-
Universe.allow_tool_operations = false
|
1008
|
-
# if @resize.is_a?(Proc)
|
1009
|
-
event = Native(native_event)
|
1010
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1011
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1012
|
-
# group etc..
|
1013
|
-
@resize.call(event) if @resize.is_a?(Proc)
|
1014
|
-
x = (@element[:offsetLeft].to_i || 0)
|
1015
|
-
y = (@element[:offsetTop].to_i || 0)
|
1016
|
-
width = event[:rect][:width]
|
1017
|
-
height = event[:rect][:height]
|
1018
|
-
# Translate when resizing from any corner
|
1019
|
-
x += event[:deltaRect][:left].to_f
|
1020
|
-
y += event[:deltaRect][:top].to_f
|
1021
|
-
@original_atome.width width.to_i if width.to_i.between?(min_width, max_width)
|
1022
|
-
@original_atome.height height.to_i if height.to_i.between?(min_height, max_height)
|
1023
|
-
@original_atome.left(x)
|
1024
|
-
@original_atome.top(y)
|
1025
|
-
end
|
1026
|
-
# end
|
1027
|
-
},
|
1028
|
-
|
1029
|
-
})
|
1030
|
-
end
|
1031
|
-
|
1032
|
-
end
|
1033
|
-
|
1034
|
-
def overflow(params, bloc)
|
1035
|
-
style(:overflow, params)
|
1036
|
-
@overflow = @original_atome.instance_variable_get('@overflow_code')[:overflow]
|
1037
|
-
@element.addEventListener('scroll', lambda do |event|
|
1038
|
-
scroll_top = @element[:scrollTop].to_i
|
1039
|
-
scroll_left = @element[:scrollLeft].to_i
|
1040
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1041
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1042
|
-
# group etc..
|
1043
|
-
@overflow.call({ left: scroll_left, top: scroll_top }) if @overflow.is_a?(Proc)
|
1044
|
-
end)
|
1045
|
-
end
|
1046
|
-
|
1047
|
-
def over_over(_option)
|
1048
|
-
interact = JS.eval("return interact('##{@id}')")
|
1049
|
-
@over_over = @original_atome.over_code[:over]
|
1050
|
-
interact.on('mouseover') do |native_event|
|
1051
|
-
JS.global[:myRubyMouseOverCallback] = Proc.new { @original_atome.over_code[:over].call }
|
1052
|
-
JS.eval("document.querySelector('##{@id}').addEventListener('mouseleave', myRubyMouseOverCallback);")
|
1053
|
-
event = Native(native_event)
|
1054
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1055
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1056
|
-
# group etc..
|
1057
|
-
@over_over.call(event) if @over_over.is_a?(Proc)
|
1058
|
-
end
|
1059
|
-
end
|
1060
|
-
|
1061
|
-
def over_enter(_option)
|
1062
|
-
@over_enter = @original_atome.instance_variable_get('@over_code')[:enter]
|
1063
|
-
return unless @over_enter
|
1064
|
-
|
1065
|
-
@over_enter_callback = lambda do |event|
|
1066
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1067
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1068
|
-
# group etc..
|
1069
|
-
@over_enter.call(event) if @over_enter.is_a?(Proc)
|
1070
|
-
end
|
1071
|
-
@element.addEventListener('mouseenter', @over_enter_callback)
|
1072
|
-
|
1073
|
-
end
|
1074
|
-
|
1075
|
-
def over_leave(_option)
|
1076
|
-
@over_leave = @original_atome.instance_variable_get('@over_code')[:leave]
|
1077
|
-
return unless @over_leave
|
1078
|
-
|
1079
|
-
@over_leave_callback = lambda do |event|
|
1080
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1081
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1082
|
-
# group etc..
|
1083
|
-
@over_leave.call(event) if @over_leave.is_a?(Proc)
|
1084
|
-
end
|
1085
|
-
@element.addEventListener('mouseleave', @over_leave_callback)
|
1086
|
-
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
def over_remove(option)
|
1090
|
-
case option
|
1091
|
-
when :enter
|
1092
|
-
if @over_enter_callback
|
1093
|
-
# Remove the event listener using the same lambda
|
1094
|
-
@element.removeEventListener('mouseenter', @over_enter_callback)
|
1095
|
-
@over_enter_callback = nil
|
1096
|
-
@over_enter = nil
|
1097
|
-
end
|
1098
|
-
when :leave
|
1099
|
-
@element.removeEventListener('mouseleave', @over_leave_callback)
|
1100
|
-
@over_leave_callback = nil
|
1101
|
-
@over_leave = nil
|
1102
|
-
when :over
|
1103
|
-
@over_over = ''
|
1104
|
-
else
|
1105
|
-
@element.removeEventListener('mouseenter', @over_enter_callback)
|
1106
|
-
@over_enter_callback = nil
|
1107
|
-
@over_enter = nil
|
1108
|
-
@element.removeEventListener('mouseleave', @over_leave_callback)
|
1109
|
-
@over_leave_callback = nil
|
1110
|
-
@over_leave = nil
|
1111
|
-
@over_over = ''
|
1112
|
-
end
|
1113
|
-
end
|
1114
|
-
|
1115
|
-
def event_validation(action_proc)
|
1116
|
-
action_proc.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1117
|
-
end
|
1118
|
-
|
1119
|
-
def touch_down(_option)
|
1120
|
-
@element[:style][:cursor] = 'pointer'
|
1121
|
-
|
1122
|
-
@touch_down = @original_atome.instance_variable_get('@touch_code')[:down]
|
1123
|
-
interact = JS.eval("return interact('##{@id}')")
|
1124
|
-
unless @touch_removed[:down]
|
1125
|
-
interact.on('down') do |native_event|
|
1126
|
-
event = Native(native_event)
|
1127
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1128
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1129
|
-
# group etc..
|
1130
|
-
# unless Universe.edit_mode == true
|
1131
|
-
# @touch_down.call(event) if @touch_down.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1132
|
-
@touch_down.call(event) if event_validation(@touch_down)
|
1133
|
-
# end
|
1134
|
-
end
|
1135
|
-
end
|
1136
|
-
end
|
1137
|
-
|
1138
|
-
def touch_tap(_option)
|
1139
|
-
# alert :touch_tap
|
1140
|
-
@element[:style][:cursor] = 'pointer'
|
1141
|
-
interact = JS.eval("return interact('##{@id}')")
|
1142
|
-
touch_tap = @original_atome.instance_variable_get('@touch_code')[:tap]
|
1143
|
-
# unless @touch_removed[:tap]
|
1144
|
-
interact.on('tap') do |native_event|
|
1145
|
-
# alert 'touchy'
|
1146
|
-
event = Native(native_event)
|
1147
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1148
|
-
# and it's lead to a problem of context and force the use of grab(:view) when using atome method such as shape ,
|
1149
|
-
# group etc..
|
1150
|
-
# @touch_tap.call(event) if @touch_tap.is_a?(Proc) && !Universe.edit_mode || !@original_atome.tag[:system]
|
1151
|
-
touch_tap.call(event) if event_validation(touch_tap)
|
1152
|
-
end
|
1153
|
-
# end
|
1154
|
-
|
1155
|
-
end
|
1156
|
-
|
1157
|
-
def touch_up(_option)
|
1158
|
-
@element[:style][:cursor] = 'pointer'
|
1159
|
-
interact = JS.eval("return interact('##{@id}')")
|
1160
|
-
@touch_up = @original_atome.instance_variable_get('@touch_code')[:up]
|
1161
|
-
unless @touch_removed[:up]
|
1162
|
-
interact.on('up') do |native_event|
|
1163
|
-
event = Native(native_event)
|
1164
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1165
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1166
|
-
# group etc..
|
1167
|
-
# @touch_up.call(event) if @touch_up.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1168
|
-
@touch_up.call(event) if event_validation(@touch_up)
|
1169
|
-
end
|
1170
|
-
|
1171
|
-
end
|
1172
|
-
end
|
1173
|
-
|
1174
|
-
def touch_double(_option)
|
1175
|
-
@element[:style][:cursor] = 'pointer'
|
1176
|
-
interact = JS.eval("return interact('##{@id}')")
|
1177
|
-
@touch_double = @original_atome.instance_variable_get('@touch_code')[:double]
|
1178
|
-
unless @touch_removed[:double]
|
1179
|
-
interact.on('doubletap') do |native_event|
|
1180
|
-
event = Native(native_event)
|
1181
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1182
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1183
|
-
# group etc..
|
1184
|
-
# @touch_double.call(event) if @touch_double.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1185
|
-
@touch_double.call(event) if event_validation(@touch_double)
|
1186
|
-
|
1187
|
-
end
|
1188
|
-
end
|
1189
|
-
|
1190
|
-
end
|
1191
|
-
|
1192
|
-
def touch_long(_option)
|
1193
|
-
@element[:style][:cursor] = 'pointer'
|
1194
|
-
@touch_long = @original_atome.instance_variable_get('@touch_code')[:long]
|
1195
|
-
interact = JS.eval("return interact('##{@id}')")
|
1196
|
-
unless @touch_removed[:long]
|
1197
|
-
interact.on('hold') do |native_event|
|
1198
|
-
event = Native(native_event)
|
1199
|
-
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1200
|
-
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1201
|
-
# group etc..
|
1202
|
-
@touch_long.call(event) if event_validation(@touch_long)
|
1203
|
-
# @touch_long.call(event) if @touch_long.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1204
|
-
# @touch_double.call(event) if event_validation(@touch_double)
|
1205
|
-
|
1206
|
-
end
|
1207
|
-
end
|
1208
|
-
end
|
1209
|
-
|
1210
|
-
def touch_remove(option)
|
1211
|
-
@element[:style][:cursor] = 'default'
|
1212
|
-
case option
|
1213
|
-
when :double
|
1214
|
-
@touch_double = ''
|
1215
|
-
@touch_removed[:double] = true
|
1216
|
-
when :down
|
1217
|
-
@touch_down = ''
|
1218
|
-
@touch_removed[:down] = true
|
1219
|
-
when :long
|
1220
|
-
@touch_removed[:long] = true
|
1221
|
-
@touch_long = ''
|
1222
|
-
when :tap
|
1223
|
-
@touch_removed[:tap] = true
|
1224
|
-
@touch_tap = ''
|
1225
|
-
when :up
|
1226
|
-
@touch_removed[:up] = true
|
1227
|
-
@touch_up = ''
|
1228
|
-
else
|
1229
|
-
interact = JS.eval("return interact('##{@id}')")
|
1230
|
-
interact.unset
|
1231
|
-
# @original_atome.instance_variable_set('@touch_code')
|
1232
|
-
@original_atome.instance_variable_set('@touch_code', nil)
|
1233
|
-
# @touch_removed[:double] = true
|
1234
|
-
# @touch_removed[:down] = true
|
1235
|
-
# @touch_removed[:long] = true
|
1236
|
-
# @touch_removed[:tap] = true
|
1237
|
-
# @touch_removed[:up] = true
|
1238
|
-
# @touch_double = ''
|
1239
|
-
# @touch_down = ''
|
1240
|
-
# @touch_long = ''
|
1241
|
-
# @touch_tap = ''
|
1242
|
-
# @touch_up = ''
|
1243
|
-
# to remove all interact event ( touch, drag, scale, ... uncomment below)
|
1244
|
-
# interact = JS.eval("return interact('##{@id}')")
|
1245
|
-
# interact.unset
|
1246
|
-
end
|
1247
|
-
|
1248
|
-
end
|
1249
|
-
|
1250
|
-
def internet
|
1251
|
-
JS.eval('return navigator.onLine')
|
1252
|
-
end
|
1253
|
-
|
1254
|
-
def terminal(id, cmd)
|
1255
|
-
if Atome.host == 'tauri'
|
1256
|
-
JS.eval("terminal('#{id}','#{cmd}')")
|
1257
|
-
else
|
1258
|
-
JS.eval("distant_terminal('#{id}','#{cmd}')")
|
1259
|
-
end
|
1260
|
-
end
|
1261
|
-
|
1262
|
-
def read(id, file)
|
1263
|
-
if Atome.host == 'tauri'
|
1264
|
-
JS.eval("readFile('#{id}','#{file}')")
|
1265
|
-
else
|
1266
|
-
puts ' work in progress'
|
1267
|
-
end
|
1268
|
-
end
|
1269
|
-
|
1270
|
-
def browse(id, file)
|
1271
|
-
if Atome.host == 'tauri'
|
1272
|
-
JS.eval("browseFile('#{id}','#{file}')")
|
1273
|
-
else
|
1274
|
-
puts 'work in progress'
|
1275
|
-
end
|
1276
|
-
end
|
1277
|
-
|
1278
|
-
def handle_input
|
1279
|
-
@original_atome.instance_variable_set('@data', @element[:innerText].to_s)
|
1280
|
-
end
|
1281
|
-
|
1282
|
-
# this method update the data content of the atome
|
1283
|
-
def update_data(params)
|
1284
|
-
# we update the @data of the atome
|
1285
|
-
@input_listener ||= lambda { |event| handle_input }
|
1286
|
-
if params
|
1287
|
-
@element.addEventListener('input', &@input_listener)
|
1288
|
-
else
|
1289
|
-
@element.removeEventListener('input', &@input_listener)
|
1290
|
-
end
|
1291
|
-
end
|
1292
|
-
|
1293
|
-
# animation below
|
1294
|
-
def animate(animation_properties)
|
1295
|
-
command = <<~JS
|
1296
|
-
var target_div = document.getElementById('#{@id}');
|
1297
|
-
window.currentAnimation = popmotion.animate({
|
1298
|
-
from: #{animation_properties[:from]},
|
1299
|
-
to: #{animation_properties[:to]},
|
1300
|
-
duration: #{animation_properties[:duration]},
|
1301
|
-
onUpdate: function(v) {
|
1302
|
-
atomeJsToRuby("puts x= "+v)
|
1303
|
-
atomeJsToRuby("grab('#{@id}').left("+v+")")
|
1304
|
-
},
|
1305
|
-
onComplete: function() {
|
1306
|
-
window.currentAnimation = null;
|
1307
|
-
atomeJsToRuby("puts :complete")
|
1308
|
-
}
|
1309
|
-
});
|
1310
|
-
JS
|
1311
|
-
JS.eval(command)
|
1312
|
-
end
|
1313
|
-
|
1314
|
-
def play_animation(properties)
|
1315
|
-
puts 'change for standard method : action'
|
1316
|
-
required_keys = [:from, :to, :duration]
|
1317
|
-
unless properties.is_a?(Hash) && (required_keys - properties.keys).empty?
|
1318
|
-
raise ArgumentError, 'Properties must be a hash with :from, :to, and :duration keys'
|
1319
|
-
end
|
1320
|
-
|
1321
|
-
animate(properties)
|
1322
|
-
|
1323
|
-
end
|
1324
|
-
|
1325
|
-
def stop_animation
|
1326
|
-
JS.eval('if (window.currentAnimation) window.currentAnimation.stop();')
|
1327
|
-
end
|
1328
|
-
|
1329
|
-
# Table manipulation
|
1330
|
-
|
1331
|
-
def table(data)
|
1332
|
-
table_html = JS.global[:document].createElement('table')
|
1333
|
-
thead = JS.global[:document].createElement('thead')
|
1334
|
-
|
1335
|
-
max_length = data.max_by { |row| row.keys.length }.keys.length
|
1336
|
-
|
1337
|
-
if @original_atome.option[:header]
|
1338
|
-
header_row = JS.global[:document].createElement('tr')
|
1339
|
-
|
1340
|
-
max_length.times do |i|
|
1341
|
-
th = JS.global[:document].createElement('th')
|
1342
|
-
th[:textContent] = data.map { |row| row.keys[i].to_s }.compact.first || ''
|
1343
|
-
header_row.appendChild(th)
|
1344
|
-
end
|
1345
|
-
|
1346
|
-
thead.appendChild(header_row)
|
1347
|
-
end
|
1348
|
-
|
1349
|
-
table_html.appendChild(thead)
|
1350
|
-
tbody = JS.global[:document].createElement('tbody')
|
1351
|
-
|
1352
|
-
data.each_with_index do |row, row_index|
|
1353
|
-
tr = JS.global[:document].createElement('tr')
|
1354
|
-
|
1355
|
-
max_length.times do |cell_index|
|
1356
|
-
td = JS.global[:document].createElement('td')
|
1357
|
-
cell_size = set_td_style(td)
|
1358
|
-
cell_height = cell_size[:cell_height]
|
1359
|
-
|
1360
|
-
cell_value = row.values[cell_index]
|
1361
|
-
if cell_value.instance_of? Atome
|
1362
|
-
cell_value.fit(cell_height)
|
1363
|
-
html_element = JS.global[:document].getElementById(cell_value.id.to_s)
|
1364
|
-
td.appendChild(html_element)
|
1365
|
-
html_element[:style][:transformOrigin] = 'top left'
|
1366
|
-
html_element[:style][:position] = 'relative'
|
1367
|
-
cell_value.top(0)
|
1368
|
-
cell_value.left(0)
|
1369
|
-
else
|
1370
|
-
td[:textContent] = cell_value.to_s
|
1371
|
-
end
|
1372
|
-
tr.appendChild(td)
|
1373
|
-
end
|
1374
|
-
|
1375
|
-
tbody.appendChild(tr)
|
1376
|
-
end
|
1377
|
-
table_html.appendChild(tbody)
|
1378
|
-
JS.global[:document].querySelector("##{@id}").appendChild(table_html)
|
1379
|
-
end
|
1380
|
-
|
1381
|
-
def refresh_table(_params)
|
1382
|
-
# first we need to extact all atome from the table or they will be deleted by the table refres
|
1383
|
-
data = @original_atome.data
|
1384
|
-
data.each do |row|
|
1385
|
-
row.each do |k, v|
|
1386
|
-
v.attach(:view) if v.instance_of? Atome
|
1387
|
-
end
|
1388
|
-
end
|
1389
|
-
table_element = JS.global[:document].querySelector("##{@id} table")
|
1390
|
-
if table_element.nil?
|
1391
|
-
puts 'Table not found'
|
1392
|
-
return
|
1393
|
-
end
|
1394
|
-
(table_element[:rows].to_a.length - 1).downto(1) do |i|
|
1395
|
-
table_element.deleteRow(i)
|
1396
|
-
end
|
1397
|
-
|
1398
|
-
max_cells = data.map { |row| row.keys.length }.max
|
1399
|
-
|
1400
|
-
data.each do |row|
|
1401
|
-
new_row = table_element.insertRow(-1)
|
1402
|
-
max_cells.times do |i|
|
1403
|
-
key = row.keys[i]
|
1404
|
-
value = row[key]
|
1405
|
-
cell = new_row.insertCell(-1)
|
1406
|
-
if value.instance_of? Atome
|
1407
|
-
html_element = JS.global[:document].getElementById(value.id.to_s)
|
1408
|
-
cell.appendChild(html_element)
|
1409
|
-
else
|
1410
|
-
cell[:textContent] = value.to_s
|
1411
|
-
end
|
1412
|
-
set_td_style(cell)
|
1413
|
-
end
|
1414
|
-
end
|
1415
|
-
end
|
1416
|
-
|
1417
|
-
def set_td_style(td)
|
1418
|
-
cell_height = 50
|
1419
|
-
td[:style][:border] = '1px solid black'
|
1420
|
-
td[:style][:backgroundColor] = 'white'
|
1421
|
-
td[:style][:boxShadow] = '10px 10px 5px #888888'
|
1422
|
-
td[:style][:width] = "#{cell_height}px"
|
1423
|
-
td[:style]['min-width'] = "#{cell_height}px"
|
1424
|
-
td[:style]['max-width'] = "#{cell_height}px"
|
1425
|
-
td[:style]['min-height'] = "#{cell_height}px"
|
1426
|
-
td[:style]['max-height'] = "#{cell_height}px"
|
1427
|
-
td[:style][:height] = "#{cell_height}px"
|
1428
|
-
td[:style][:overflow] = 'hidden'
|
1429
|
-
{ cell_height: cell_height, cell_width: cell_height }
|
1430
|
-
end
|
1431
|
-
|
1432
|
-
def insert_cell(params)
|
1433
|
-
row_index, cell_index = params[:cell]
|
1434
|
-
new_content = params[:content]
|
1435
|
-
container = JS.global[:document].getElementById(@id.to_s)
|
1436
|
-
|
1437
|
-
table = container.querySelector('table')
|
1438
|
-
if table.nil?
|
1439
|
-
puts 'No table found in the container'
|
1440
|
-
return
|
1441
|
-
end
|
1442
|
-
|
1443
|
-
row = table.querySelectorAll('tr')[row_index]
|
1444
|
-
if row.nil?
|
1445
|
-
puts "Row at index #{row_index} not found"
|
1446
|
-
return
|
1447
|
-
end
|
1448
|
-
|
1449
|
-
cell = row.querySelectorAll('td')[cell_index]
|
1450
|
-
if cell.nil?
|
1451
|
-
puts "Cell at index #{cell_index} in row #{row_index} not found"
|
1452
|
-
return
|
1453
|
-
end
|
1454
|
-
|
1455
|
-
if new_content.instance_of? Atome
|
1456
|
-
cell.innerHTML = ''
|
1457
|
-
html_element = JS.global[:document].getElementById(new_content.id.to_s)
|
1458
|
-
cell.appendChild(html_element)
|
1459
|
-
else
|
1460
|
-
cell[:textContent] = new_content.to_s
|
1461
|
-
end
|
1462
|
-
end
|
1463
|
-
|
1464
|
-
def insert_row(params)
|
1465
|
-
insert_at_index = params[:row]
|
1466
|
-
table_element = JS.global[:document].querySelector("##{@id} table")
|
1467
|
-
|
1468
|
-
if table_element.nil?
|
1469
|
-
puts 'Tableau non trouvé'
|
1470
|
-
return
|
1471
|
-
end
|
1472
|
-
|
1473
|
-
tbody = table_element.querySelector('tbody')
|
1474
|
-
|
1475
|
-
header_row = table_element.querySelector('thead tr')
|
1476
|
-
column_count = header_row ? header_row.querySelectorAll('th').to_a.length : 0
|
1477
|
-
|
1478
|
-
new_row = JS.global[:document].createElement('tr')
|
1479
|
-
column_count.times do |cell_index|
|
1480
|
-
td = JS.global[:document].createElement('td')
|
1481
|
-
set_td_style(td)
|
1482
|
-
new_row.appendChild(td)
|
1483
|
-
end
|
1484
|
-
|
1485
|
-
if insert_at_index.zero?
|
1486
|
-
tbody.insertBefore(new_row, tbody.firstChild)
|
1487
|
-
else
|
1488
|
-
reference_row = tbody.querySelectorAll('tr').to_a[insert_at_index]
|
1489
|
-
tbody.insertBefore(new_row, reference_row)
|
1490
|
-
end
|
1491
|
-
|
1492
|
-
end
|
1493
|
-
|
1494
|
-
def insert_column(params)
|
1495
|
-
insert_at_index = params[:column]
|
1496
|
-
table_element = JS.global[:document].querySelector("##{@id} table")
|
1497
|
-
if table_element.nil?
|
1498
|
-
puts 'Table not found'
|
1499
|
-
return
|
1500
|
-
end
|
1501
|
-
rows = table_element.querySelectorAll('tr').to_a
|
1502
|
-
rows.each_with_index do |row, index|
|
1503
|
-
if index == 0
|
1504
|
-
# case1
|
1505
|
-
else
|
1506
|
-
new_cell = JS.global[:document].createElement('td')
|
1507
|
-
new_cell[:innerText] = ''
|
1508
|
-
set_td_style(new_cell)
|
1509
|
-
if insert_at_index.zero?
|
1510
|
-
row.insertBefore(new_cell, row.firstChild)
|
1511
|
-
else
|
1512
|
-
child_nodes = row.querySelectorAll('td').to_a
|
1513
|
-
|
1514
|
-
if insert_at_index < child_nodes.length
|
1515
|
-
reference_cell = child_nodes[insert_at_index]
|
1516
|
-
row.insertBefore(new_cell, reference_cell)
|
1517
|
-
else
|
1518
|
-
row.appendChild(new_cell)
|
1519
|
-
end
|
1520
|
-
end
|
1521
|
-
end
|
1522
|
-
|
1523
|
-
end
|
1524
|
-
|
1525
|
-
end
|
1526
|
-
|
1527
|
-
def table_insert(params)
|
1528
|
-
if params[:cell]
|
1529
|
-
insert_cell(params)
|
1530
|
-
elsif params[:row]
|
1531
|
-
insert_row(params)
|
1532
|
-
elsif params[:column]
|
1533
|
-
insert_column(params)
|
1534
|
-
end
|
1535
|
-
|
1536
|
-
end
|
1537
|
-
|
1538
|
-
def remove(params)
|
1539
|
-
# puts "remove => #{params}"
|
1540
|
-
# TODO: FIXME: "html : must create a case here #{params} (#{@original_atome.id})"
|
1541
|
-
case params
|
1542
|
-
when Hash
|
1543
|
-
params.each do |k, v|
|
1544
|
-
case k
|
1545
|
-
when :row
|
1546
|
-
row_index = params[:row]
|
1547
|
-
table_element = JS.global[:document].querySelector("##{@id} table")
|
1548
|
-
|
1549
|
-
if table_element.nil?
|
1550
|
-
puts 'Table not found'
|
1551
|
-
return
|
1552
|
-
end
|
1553
|
-
|
1554
|
-
rows = table_element.querySelectorAll('tbody tr').to_a
|
1555
|
-
|
1556
|
-
if row_index >= rows.length
|
1557
|
-
puts "row not found : #{row_index}"
|
1558
|
-
return
|
1559
|
-
end
|
1560
|
-
row_to_remove = rows[row_index]
|
1561
|
-
|
1562
|
-
row_to_remove[:parentNode].removeChild(row_to_remove)
|
1563
|
-
|
1564
|
-
rows.each_with_index do |row, i|
|
1565
|
-
next if i <= row_index
|
1566
|
-
end
|
1567
|
-
when :column
|
1568
|
-
column_index = params[:column]
|
1569
|
-
table_element = JS.global[:document].querySelector("##{@id} table")
|
1570
|
-
|
1571
|
-
if table_element.nil?
|
1572
|
-
puts 'Table not found'
|
1573
|
-
return
|
1574
|
-
end
|
1575
|
-
|
1576
|
-
rows = table_element.querySelectorAll('tbody tr').to_a
|
1577
|
-
rows.each do |row|
|
1578
|
-
cells = row.querySelectorAll('td').to_a
|
1579
|
-
if column_index < cells.length
|
1580
|
-
cell_to_remove = cells[column_index]
|
1581
|
-
cell_to_remove[:parentNode].removeChild(cell_to_remove)
|
1582
|
-
end
|
1583
|
-
end
|
1584
|
-
when :all
|
1585
|
-
case v
|
1586
|
-
when :paint
|
1587
|
-
style(:background, 'none')
|
1588
|
-
# style('box-shadow', 'none')
|
1589
|
-
# style('text-shadow', 'none')
|
1590
|
-
when :color
|
1591
|
-
when :shadow
|
1592
|
-
style('box-shadow', 'none')
|
1593
|
-
style('text-shadow', 'none')
|
1594
|
-
style("filter", 'none')
|
1595
|
-
end
|
1596
|
-
end
|
1597
|
-
end
|
1598
|
-
else
|
1599
|
-
@original_atome.apply.delete(params)
|
1600
|
-
style(:background, 'none')
|
1601
|
-
style('box-shadow', 'none')
|
1602
|
-
style('text-shadow', 'none')
|
1603
|
-
style("boxShadow", 'none')
|
1604
|
-
style("filter", 'none')
|
1605
|
-
@original_atome.apply(@original_atome.apply)
|
1606
|
-
end
|
1607
|
-
|
1608
|
-
end
|
1609
|
-
|
1610
|
-
def table_remove(params)
|
1611
|
-
if params[:row]
|
1612
|
-
elsif params[:column]
|
1613
|
-
end
|
1614
|
-
end
|
1615
|
-
|
1616
|
-
# atomisation!
|
1617
|
-
def atomized(html_object)
|
1618
|
-
html_object = html_object[0] if html_object.instance_of? Array
|
1619
|
-
@element = html_object
|
1620
|
-
end
|
1621
|
-
|
1622
|
-
def center(options, attach)
|
1623
|
-
@center_options = options
|
1624
|
-
|
1625
|
-
@parent = grab(attach)
|
1626
|
-
|
1627
|
-
apply_centering(@center_options, @parent)
|
1628
|
-
|
1629
|
-
if @center_options[:dynamic]
|
1630
|
-
event_handler = ->(event) do
|
1631
|
-
apply_centering(@center_options, @parent)
|
1632
|
-
end
|
1633
|
-
JS.global[:window].addEventListener('resize', event_handler)
|
1634
|
-
end
|
1635
|
-
end
|
1636
|
-
|
1637
|
-
def record_audio(params)
|
1638
|
-
duration = params[:duration] * 1000
|
1639
|
-
name = params[:name]
|
1640
|
-
JS.eval("recordAudio(#{duration},'#{@id}', '#{name}')")
|
1641
|
-
end
|
1642
|
-
|
1643
|
-
def record_video(params)
|
1644
|
-
duration = params[:duration] * 1000
|
1645
|
-
name = params[:name]
|
1646
|
-
JS.eval("recordVideo(#{duration},'#{@id}', '#{name}')")
|
1647
|
-
end
|
1648
|
-
|
1649
|
-
def stop_video_preview(id)
|
1650
|
-
JS.eval("stopPreview('#{id}')")
|
1651
|
-
end
|
1652
|
-
|
1653
|
-
def video_preview(id, video, audio)
|
1654
|
-
JS.eval("create_preview('#{id}','#{video}','#{audio}')")
|
1655
|
-
end
|
1656
|
-
|
1657
|
-
def stop_media_recorder(id)
|
1658
|
-
JS.eval("writeatomestore('#{id}', 'record', 'stop')")
|
1659
|
-
end
|
1660
|
-
|
1661
|
-
private
|
1662
|
-
|
1663
|
-
def apply_centering(options, parent)
|
1664
|
-
if options[:x]
|
1665
|
-
x_position = calculate_position(options[:x], parent.to_px(:width), @original_atome.to_px(:width))
|
1666
|
-
@original_atome.left(x_position)
|
1667
|
-
end
|
1668
|
-
|
1669
|
-
if options[:y]
|
1670
|
-
y_position = calculate_position(options[:y], parent.to_px(:height), @original_atome.to_px(:height))
|
1671
|
-
@original_atome.top(y_position)
|
1672
|
-
end
|
1673
|
-
end
|
1674
|
-
|
1675
|
-
def calculate_position(option, parent_dimension, self_dimension)
|
1676
|
-
if option.is_a?(String) && option.end_with?('%')
|
1677
|
-
percent = option.chop.to_f / 100.0
|
1678
|
-
(parent_dimension - self_dimension) * percent
|
1679
|
-
elsif option == 0
|
1680
|
-
(parent_dimension - self_dimension) / 2.0
|
1681
|
-
else
|
1682
|
-
option
|
1683
|
-
end
|
1684
|
-
end
|
1685
|
-
|
1686
|
-
end
|
1687
|
-
|
1688
|
-
|