Class: Ferro::Document
- Inherits:
-
Object
- Object
- Ferro::Document
- Includes:
- Elementary
- Defined in:
- opal/opal-ferro/ferro_document.js.rb
Overview
This is the entry point for any Ferro application. It represents the top level object of the Master Object Model (MOM). There should be only one class that inhertits from FerroDocument in an application. This class attaches itself to the DOM ‘document.body` object. Any existing child nodes of `document.body` are removed.
Constant Summary
Constants included from Elementary
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#compositor ⇒ Object
readonly
Returns the value of attribute compositor.
-
#sym ⇒ Object
readonly
Returns the value of attribute sym.
Instance Method Summary collapse
-
#component ⇒ Object
The document class is a component.
-
#domtype ⇒ Object
Returns the domtype of the document instance.
-
#element ⇒ Object
Returns the DOM element.
-
#factory ⇒ Object
Returns the one and only instance of the factory.
-
#initialize ⇒ Document
constructor
Create the document and start the creation process (casading).
-
#page404(pathname) ⇒ Object
Callback for the router when no matching routes can be found.
-
#parent ⇒ Object
The document doesn’t have a parent so returns itself.
-
#root ⇒ Object
The document class is the root element.
-
#router ⇒ Object
Returns the one and only instance of the router.
-
#switch_compositor_theme(theme) ⇒ Object
Switch to a new theme for the compositor, this will remove/add CSS classes for all elements as needed.
Methods included from Elementary
#_after_create, #_before_create, #_stylize, #add_child, #after_create, #before_create, #cascade, #create, #creation, #destroy, #each_child, #forget_children, #method_missing, #remove_child, #style, #symbolize
Constructor Details
#initialize ⇒ Document
Create the document and start the creation process (casading).
19 20 21 22 23 24 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 19 def initialize @compositor = nil @sym = :document @children = {} creation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ferro::Elementary
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
15 16 17 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 15 def children @children end |
#compositor ⇒ Object (readonly)
Returns the value of attribute compositor.
15 16 17 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 15 def compositor @compositor end |
#sym ⇒ Object (readonly)
Returns the value of attribute sym.
15 16 17 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 15 def sym @sym end |
Instance Method Details
#component ⇒ Object
The document class is a component.
47 48 49 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 47 def component self end |
#domtype ⇒ Object
Returns the domtype of the document instance.
52 53 54 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 52 def domtype :body end |
#element ⇒ Object
Returns the DOM element.
32 33 34 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 32 def element factory.body end |
#factory ⇒ Object
Returns the one and only instance of the factory.
37 38 39 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 37 def factory @factory ||= Factory.new(self, @compositor) end |
#page404(pathname) ⇒ Object
Callback for the router when no matching routes can be found. Override this method to add custom behavior.
76 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 76 def page404(pathname);end |
#parent ⇒ Object
The document doesn’t have a parent so returns itself.
27 28 29 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 27 def parent self end |
#root ⇒ Object
The document class is the root element.
42 43 44 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 42 def root self end |
#router ⇒ Object
Returns the one and only instance of the router.
66 67 68 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 66 def router @router ||= Router.new(method(:page404)) end |
#switch_compositor_theme(theme) ⇒ Object
Switch to a new theme for the compositor, this will remove/add CSS classes for all elements as needed.
param [Symbol] theme The new theme name
61 62 63 |
# File 'opal/opal-ferro/ferro_document.js.rb', line 61 def switch_compositor_theme(theme) @compositor.switch_theme(self, theme) if @compositor end |