Class: Lore::GUI::Checkbox
- Inherits:
-
Form_Element
- Object
- Form_Element
- Lore::GUI::Checkbox
- Defined in:
- lib/lore/gui/form_element.rb
Overview
Form checkbox element (<input type=“checkbox” …>). Subclass of Form_Element.
Instance Attribute Summary
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, #template_file
Instance Method Summary collapse
-
#initialize(_table, _attrib_name, _attrib_label, _attrib_range = nil, _attrib_value = nil) ⇒ Checkbox
constructor
{{{.
-
#string ⇒ Object
def.
Methods inherited from Form_Element
for, #label, #onblur, #onfocus, #print, #set_attribute_style, #set_attribute_value, #set_mode, #setup
Constructor Details
#initialize(_table, _attrib_name, _attrib_label, _attrib_range = nil, _attrib_value = nil) ⇒ Checkbox
{{{
421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/lore/gui/form_element.rb', line 421 def initialize(_table, _attrib_name, _attrib_label, _attrib_range=nil, _attrib_value=nil) setup(_table, _attrib_name, _attrib_label, _attrib_range, _attrib_value) if _attrib_label.instance_of? Array then @attribute_label = _attrib_label[0] @attribute_sublabel = _attrib_label[1] else @attribute_label = _attrib_label.to_s @attribute_sublabel = nil end @style_class = :lore_checkbox end |
Instance Method Details
#string ⇒ Object
def
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/lore/gui/form_element.rb', line 435 def string if @mode == :mutable then template = @template.new('checkbox.rhtml') checkboxes = '' checkbox_index = 0 if @attribute_label.nil? or @attribute_label == '' then label = '' end @attribute_range.each { |value| if !@attribute_sublabel.nil? and !@attribute_sublabel[value].nil? then label = @attribute_sublabel[value] else # Allow label to be empty, don't use value # if not set. # label = value end if value == @attribute_value then data = { :id => @attribute_id, :class => @style_class.to_s, :name => @attribute_table+'.'+@attribute_name, :onfocus => onfocus("#{@attribute_table}__#{@attribute_name}"), :onblur => onblur("#{@attribute_table}__#{@attribute_name}"), :value => value, :checked => 'checked' } else data = { :id => @attribute_id, :class => @style_class.to_s, :onfocus => onfocus("#{@attribute_table}__#{@attribute_name}"), :onblur => onblur("#{@attribute_table}__#{@attribute_name}"), :name => @attribute_table+'.'+@attribute_name, :value => value } end template.set_data(:attributes => data) checkboxes += template.string checkboxes += label.to_s checkbox_index += 1 } elsif @mode == :readonly then template = @template.new('text_readonly.rhtml') if !@attribute_sublabel.nil? and !@attribute_sublabel[@attribute_value].nil? then label = @attribute_sublabel[@attribute_value] else label = @attribute_value end data = {:label => label} template.set_data(data) checkboxes = template.string end row_template = @template.new('checkbox_row.rhtml') row_template.set_data(:checkboxes => checkboxes) row_template.string end |