Class: Ferro::Element::List
- Inherits:
-
BaseElement
- Object
- BaseElement
- Ferro::Element::List
- Defined in:
- opal/opal-ferro/elements/ferro_inline.js.rb
Overview
Creates an inline element. In the DOM creates a: <ol> or <ul> depending on option :type. Set to ‘1’, ‘A’, ‘a’, ‘I’ or ‘i’ to create <ol> elements. Leave option blank to create <ul> elements.
Constant Summary
Constants included from Ferro::Elementary
Ferro::Elementary::RESERVED_NAMES
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Attributes inherited from BaseElement
#children, #domtype, #element, #parent, #sym
Instance Method Summary collapse
-
#_before_create ⇒ Object
Internal method.
-
#add_item(element_class, options = {}) ⇒ Object
Add an item to the (un)ordered list.
-
#first_item ⇒ element
The first item in the list.
-
#item_count ⇒ Integer
The number of items in the list.
-
#last_item ⇒ element
The last item in the list.
-
#unlist_item(sym) ⇒ Object
Remove an item from the (un)ordered list.
Methods inherited from BaseElement
#add_state, #add_states, #classify_state, #component, #dom_id, #factory, #get_text, #html, #initialize, #option_replace, #remove_attribute, #root, #router, #set_attribute, #set_text, #state_active?, #toggle_state, #update_state, #value, #value=
Methods included from Ferro::Elementary
#_after_create, #_stylize, #add_child, #after_create, #before_create, #cascade, #create, #creation, #destroy, #each_child, #forget_children, #method_missing, #remove_child, #style, #symbolize
Constructor Details
This class inherits a constructor from Ferro::BaseElement
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ferro::Elementary
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
29 30 31 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 29 def items @items end |
Instance Method Details
#_before_create ⇒ Object
Internal method.
32 33 34 35 36 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 32 def _before_create @domtype = @options.has_key?(:type) ? :ol : :ul @items = [] @id = Sequence.new 'list_' end |
#add_item(element_class, options = {}) ⇒ Object
Add an item to the (un)ordered list.
42 43 44 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 42 def add_item(element_class, = {}) @items << add_child(@id.next, element_class, ).sym end |
#first_item ⇒ element
The first item in the list.
56 57 58 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 56 def first_item @children[@items.first] end |
#item_count ⇒ Integer
The number of items in the list.
49 50 51 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 49 def item_count @items.length end |
#last_item ⇒ element
The last item in the list.
63 64 65 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 63 def last_item @children[@items.last] end |
#unlist_item(sym) ⇒ Object
Remove an item from the (un)ordered list.
70 71 72 |
# File 'opal/opal-ferro/elements/ferro_inline.js.rb', line 70 def unlist_item(sym) @items.delete_if { |item| item == sym } end |