Class: Aurita::GUI::Button
- Defined in:
- lib/aurita-gui/button.rb
Overview
Specialization of Aurita::GUI::Element, extending it by @icon to display in the button.
Usage:
b = Button.new(:type => :submit, # default is :button
:icon => '/path/to/icon.png', # default is no icon
:onclick => 'alert('button clicked'); ") {
'click me'
}
Change button text:
b.content = 'Custom button text'
Disable icon again:
b.icon = false
Direct Known Subclasses
Instance Attribute Summary collapse
-
#icon ⇒ Object
Returns the value of attribute icon.
Attributes inherited from Element
#attrib, #force_closing_tag, #gui_element_id, #parent, #tag
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(params, &block) ⇒ Button
constructor
A new instance of Button.
Methods inherited from Element
#+, #<<, #[], #[]=, #add_class, #aurita_gui_element, #clear_floating, #css_classes, #find_by_dom_id, #get_content, #has_content?, #id, #id=, #inspect, #js_init_code, #length, #method_missing, #recurse, #remove_class, #set_content, #string, #swap, #to_ary, #touch, #touched?, #type=, #untouch
Methods included from Marshal_Helper_Class_Methods
Methods included from Marshal_Helper
Constructor Details
#initialize(params, &block) ⇒ Button
Returns a new instance of Button.
29 30 31 32 33 34 35 |
# File 'lib/aurita-gui/button.rb', line 29 def initialize(params, &block) params[:tag] = :button params[:type] = :button unless params[:type] @icon = params[:icon] params.delete(:icon) super(params, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Aurita::GUI::Element
Instance Attribute Details
#icon ⇒ Object
Returns the value of attribute icon.
27 28 29 |
# File 'lib/aurita-gui/button.rb', line 27 def icon @icon end |
Instance Method Details
#content ⇒ Object
37 38 39 40 41 42 |
# File 'lib/aurita-gui/button.rb', line 37 def content if @icon then return [ HTML.img(:src => @icon), @content ] end return @content end |