Class: Lore::GUI::Button

Inherits:
Form_Element show all
Defined in:
lib/lore/gui/form_element.rb

Overview

Form button element (<input type=“button” … />). Subclass of Form_Element.

Instance Attribute Summary collapse

Attributes inherited from Form_Element

#attribute_id, #attribute_label, #attribute_name, #attribute_range, #attribute_table, #attribute_value, #id, #mode, #on_change, #on_click, #style, #style_class, #template_file

Instance Method Summary collapse

Methods inherited from Form_Element

for, #label, #onblur, #onfocus, #print, #set_attribute_style, #set_attribute_value, #set_mode, #setup

Constructor Details

#initialize(_type, _value, _style_class = nil) ⇒ Button

Returns a new instance of Button.



628
629
630
631
632
633
634
# File 'lib/lore/gui/form_element.rb', line 628

def initialize(_type, _value, _style_class=nil)
  @button_type     = _type
  @button_label    = _value
  @attribute_value = _value
  @style_class     = _style_class
  @template        = ERB_Template
end

Instance Attribute Details

#templateObject

{{{



626
627
628
# File 'lib/lore/gui/form_element.rb', line 626

def template
  @template
end

Instance Method Details

#stringObject



636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
# File 'lib/lore/gui/form_element.rb', line 636

def string
  
  template = @template.new('button.rhtml')

  data = {
    :attributes => { 
      :id      => @attribute_id, 
      :class => @style_class.to_s, 
      :type => @button_type, 
      :value => @button_label
    }
  }

  template.set_data(data)
  template.string
  
end