Class: Ferro::Combo::Search
- Inherits:
-
Form::Base
- Object
- BaseElement
- Form::Base
- Ferro::Combo::Search
- Defined in:
- opal/opal-ferro/elements/ferro_combos.js.rb
Overview
Creates a form with a text input and a submit button. Specify option :button_text to set the submit button text. Specify option :placeholder to set a placeholder text for the input. Two states are defined: search-input-open, search-submit-open to define CSS rules.
Constant Summary
Constants included from Elementary
Instance Attribute Summary
Attributes inherited from BaseElement
#children, #domtype, #element, #parent, #sym
Instance Method Summary collapse
-
#_before_create ⇒ Object
Internal method.
-
#cascade ⇒ Object
Internal method.
-
#do_submit ⇒ Object
Internal method.
-
#submitted(value) ⇒ Object
Override this method to specify what happens when submit button is clicked or enter key is pressed.
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 Elementary
#_after_create, #_stylize, #add_child, #after_create, #before_create, #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 Method Details
#_before_create ⇒ Object
Internal method.
13 14 15 16 |
# File 'opal/opal-ferro/elements/ferro_combos.js.rb', line 13 def _before_create @button_text = option_replace :button_text, ' ' @placeholder = option_replace :placeholder, ' Search...' end |
#cascade ⇒ Object
Internal method.
19 20 21 22 |
# File 'opal/opal-ferro/elements/ferro_combos.js.rb', line 19 def cascade add_child :entry, SearchInput, { placeholder: @placeholder } add_child :submit, SearchSubmit, { content: @button_text } end |
#do_submit ⇒ Object
Internal method.
25 26 27 28 29 30 31 32 33 34 |
# File 'opal/opal-ferro/elements/ferro_combos.js.rb', line 25 def do_submit value = entry.value.strip submitted(value) if !value.empty? entry.toggle_state :search_input_open submit.toggle_state :search_submit_open entry.value = nil entry.set_focus if entry.state_active?(:search_input_open) end |
#submitted(value) ⇒ Object
Override this method to specify what happens when submit button is clicked or enter key is pressed.
40 |
# File 'opal/opal-ferro/elements/ferro_combos.js.rb', line 40 def submitted(value);end |