Class: Lore::GUI::Form_Element
- Inherits:
-
Object
- Object
- Lore::GUI::Form_Element
- Defined in:
- lib/lore/gui/form_element.rb
Overview
Form element that can be handled by Cuba::GUI::Form.
Direct Known Subclasses
Button, Checkbox, Custom_Element, Date, File, Hidden, Klass_Select, Radio, Select, Text, Textarea
Instance Attribute Summary collapse
-
#attribute_id ⇒ Object
{{{.
-
#attribute_label ⇒ Object
{{{.
-
#attribute_name ⇒ Object
{{{.
-
#attribute_range ⇒ Object
{{{.
-
#attribute_table ⇒ Object
{{{.
-
#attribute_value ⇒ Object
{{{.
-
#id ⇒ Object
{{{.
-
#mode ⇒ Object
{{{.
-
#on_change ⇒ Object
{{{.
-
#on_click ⇒ Object
{{{.
-
#style ⇒ Object
{{{.
-
#style_class ⇒ Object
{{{.
-
#template ⇒ Object
{{{.
-
#template_file ⇒ Object
{{{.
Class Method Summary collapse
Instance Method Summary collapse
-
#label ⇒ Object
Returns attribute label as string.
- #onblur(attribute_id) ⇒ Object
- #onfocus(attribute_id) ⇒ Object
-
#print ⇒ Object
Prints string().
-
#set_attribute_style(style) ⇒ Object
Set style class for element.
-
#set_attribute_value(val) ⇒ Object
Set value for this element.
-
#set_mode(mode = :mutable) ⇒ Object
Set mode for this element.
-
#setup(_attrib_table, _attrib_name, _attrib_label, _attrib_range = nil, _attrib_value = '') ⇒ Object
Expects table name and attribute this element is referring to, as well as label to be used for it.
-
#string ⇒ Object
Returns this element as html string.
Instance Attribute Details
#attribute_id ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def attribute_id @attribute_id end |
#attribute_label ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def attribute_label @attribute_label end |
#attribute_name ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def attribute_name @attribute_name end |
#attribute_range ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def attribute_range @attribute_range end |
#attribute_table ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def attribute_table @attribute_table end |
#attribute_value ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def attribute_value @attribute_value end |
#id ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def id @id end |
#mode ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def mode @mode end |
#on_change ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def on_change @on_change end |
#on_click ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def on_click @on_click end |
#style ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def style @style end |
#style_class ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def style_class @style_class end |
#template ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def template @template end |
#template_file ⇒ Object
{{{
11 12 13 |
# File 'lib/lore/gui/form_element.rb', line 11 def template_file @template_file end |
Class Method Details
.for(clause, label, value = '', range = nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/lore/gui/form_element.rb', line 13 def self.for(clause, label, value='', range=nil) attrib = clause.to_s.split('.') if attrib.length == 3 then new(attrib[0..1].join('.'), attrib[2], label, range, value) else new(nil, clause.to_s, label, range, value) end end |
Instance Method Details
#label ⇒ Object
Returns attribute label as string.
75 76 77 |
# File 'lib/lore/gui/form_element.rb', line 75 def label if @attribute_label.nil? then '' else @attribute_label end end |
#onblur(attribute_id) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/lore/gui/form_element.rb', line 94 def onblur(attribute_id) begin context_help = "Element.removeClassName('#{attribute_id.gsub('.','_')}_wrap', 'focussed' ); Element.removeClassName('#{attribute_id.gsub('.','_')}', 'focussed' );" rescue ::Exception => e context_help = '' end return context_help end |
#onfocus(attribute_id) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/lore/gui/form_element.rb', line 84 def onfocus(attribute_id) begin context_help = "Element.addClassName('#{attribute_id.gsub('.','_')}_wrap', 'focussed' ); Element.addClassName('#{attribute_id.gsub('.','_')}', 'focussed' );" rescue ::Exception => e context_help = '' end return context_help end |
#print ⇒ Object
Prints string()
80 81 82 |
# File 'lib/lore/gui/form_element.rb', line 80 def print puts string() end |
#set_attribute_style(style) ⇒ Object
Set style class for element.
58 59 60 |
# File 'lib/lore/gui/form_element.rb', line 58 def set_attribute_style(style) @style = style end |
#set_attribute_value(val) ⇒ Object
Set value for this element.
53 54 55 |
# File 'lib/lore/gui/form_element.rb', line 53 def set_attribute_value(val) @attribute_value = val end |
#set_mode(mode = :mutable) ⇒ Object
Set mode for this element. Modes are :mutable and :readonly.
64 65 66 |
# File 'lib/lore/gui/form_element.rb', line 64 def set_mode(mode=:mutable) @mode = mode end |
#setup(_attrib_table, _attrib_name, _attrib_label, _attrib_range = nil, _attrib_value = '') ⇒ Object
Expects table name and attribute this element is referring to, as well as label to be used for it. _attrib_range is an array of option values, e.g. needed for select boxes or radio groups, _attrib_value is the elements current value if existing.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/lore/gui/form_element.rb', line 26 def setup(_attrib_table, _attrib_name, _attrib_label, _attrib_range=nil, _attrib_value='') @attribute_table = _attrib_table @attribute_label = _attrib_label @attribute_name = _attrib_name.to_s @attribute_range = _attrib_range @attribute_value = _attrib_value @attribute_id = _attrib_table.to_s.gsub('.','_') + '__' << _attrib_name.to_s @mode = :mutable @template = ERB_Template @template_file = nil @style = '' @style_class = :lore @id = '' @on_click = '' @on_change = '' if @attribute_range.instance_of? Range then @attribute_range = @attribute_range.to_a end end |
#string ⇒ Object
Returns this element as html string. To be overloaded by subclasses.
70 71 72 |
# File 'lib/lore/gui/form_element.rb', line 70 def string '' end |