Class: Lore::GUI::Textarea

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

Overview

Form textarea element (<textarea …></textarea>). Subclass of Form_Element.

Constant Summary collapse

@@textarea_count =

{{{

0

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

Class Method Summary collapse

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(_table, _attrib_name, _attrib_label, _attrib_range = nil, _attrib_value = nil) ⇒ Textarea

Returns a new instance of Textarea.



234
235
236
# File 'lib/lore/gui/form_element.rb', line 234

def initialize(_table, _attrib_name, _attrib_label, _attrib_range=nil, _attrib_value=nil)
  setup(_table, _attrib_name, _attrib_label, _attrib_range, _attrib_value)
end

Class Method Details

.reset_counterObject



238
239
240
# File 'lib/lore/gui/form_element.rb', line 238

def self.reset_counter
  @@textarea_count = 0
end

Instance Method Details

#stringObject



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/lore/gui/form_element.rb', line 242

def string

  @@textarea_count += 1
  @attribute_id = 'lore_textarea_' << @@textarea_count.to_s if @mode == :mutable

  if @attribute_value.nil? then @attribute_value = '' end
  
  if @mode == :mutable then
    template = @template.new('textarea.rhtml')
  elsif @mode == :readonly then
    template = @template.new('textarea_readonly.rhtml')
  end

  data = {
    :attributes => {
      :id      => @attribute_id, 
      :class   => @style_class.to_s, 
      :name    => @attribute_table+'.'+@attribute_name, 
      :style   => @style, 
      :onfocus => onfocus("#{@attribute_id}"), 
      :onblur  => onblur("#{@attribute_id}"), 
    },
    :value   => @attribute_value
  }
#     data[:attributes][:id] = 'lore_textarea_' << @@textarea_count.to_s if @mode == :mutable
  template.set_data(data)
  template.string()
end