Class: Scarpe::Webview::DocumentRoot
- Defined in:
- lib/scarpe/wv/document_root.rb
Overview
A DocumentRoot is a Flow, with all the same properties and basic behavior. It also reserves space for Builtins like fonts, alerts, etc. which don't have individual Shoes::Drawable objects.
Constant Summary
Constants included from Shoes::Log
Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary
Attributes inherited from Drawable
#children, #parent, #shoes_linkable_id
Attributes inherited from Shoes::Linkable
Instance Method Summary collapse
- #element(&block) ⇒ Object
-
#initialize(properties) ⇒ DocumentRoot
constructor
A new instance of DocumentRoot.
Methods inherited from Slot
#html_attributes, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #update_dom_event
Methods inherited from Drawable
#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html
Methods included from Shoes::Log
configure_logger, #log_init, logger
Methods inherited from Shoes::Linkable
#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event
Constructor Details
#initialize(properties) ⇒ DocumentRoot
Returns a new instance of DocumentRoot.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/scarpe/wv/document_root.rb', line 8 def initialize(properties) super @fonts = [] @alerts = [] bind_shoes_event(event_name: "builtin") do |cmd_name, args| case cmd_name when "font" @fonts << args[0] # Can't just create font_updater and alert_updater on initialize - not everything is set up @font_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(html_id: "root-fonts") @font_updater.inner_html = font_contents when "alert" bind_ok_event @alerts << args[0] @alert_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(html_id: "root-alerts") @alert_updater.inner_html = alert_contents else raise Scarpe::UnknownBuiltinCommandError, "Unexpected builtin command: #{cmd_name.inspect}!" end end end |
Instance Method Details
#element(&block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scarpe/wv/document_root.rb', line 32 def element(&block) contents = block ? block.call : "" super do contents + HTML.render do |h| h.div(id: "root-fonts") do font_contents end h.div(id: "root-alerts") do alert_contents end end end end |