lib/atome/helpers/utilities.rb in atome-0.5.5.6.5 vs lib/atome/helpers/utilities.rb in atome-0.5.5.6.6
- old
+ new
@@ -1,13 +1,22 @@
# frozen_string_literal: true
# toolbox method here
require 'json'
+
class Atome
class << self
+
+ def file_handler(parent, content, bloc)
+ grab(parent).instance_exec(content, &bloc)
+ end
+
+
+
def controller_sender(message)
return if $host == :html
+
json_msg = message.to_json
js_json_msg = json_msg.inspect
js_command = "atomeJS.controller_sender(#{js_json_msg})"
JS.eval(js_command)
end
@@ -42,10 +51,13 @@
# end
end
# local server messaging
+ def file_for_opal(parent, bloc)
+ JS.eval("fileForOpal('#{parent}', #{bloc})")
+ end
def response_listener(hashed_msg)
js_action = hashed_msg.JS[:action]
js_body = hashed_msg.JS[:body]
send(js_action, js_body)
@@ -125,10 +137,11 @@
end
def atome_post_process(element, params, new_atome, &user_proc)
return unless Atome.instance_variable_get("@post_#{element}").is_a?(Proc)
+
new_atome.instance_exec(params, user_proc, &Atome.instance_variable_get("@post_#{element}"))
end
def atome_processor(element, params, &user_proc)
@@ -278,10 +291,11 @@
Universe.current_user = user_id
else
debug "#{user_id} not found"
end
end
+
def remove_layout
display(:default)
# we get the current parent (the previous layout)
parent_found = grab(attach)
# we get the parent of the parent
@@ -294,8 +308,7 @@
# we delete the parent (the layout) if it no more children attached
if parent_found.attached.length == 0
parent_found.delete(true)
end
end
-
end