Class: HtmlGrid::DivComposite

Inherits:
TagComposite show all
Defined in:
lib/htmlgrid/divcomposite.rb

Direct Known Subclasses

DivForm, DivList, DivTemplate

Constant Summary

Constants inherited from AbstractComposite

AbstractComposite::CSS_CLASS, AbstractComposite::CSS_ID, AbstractComposite::CSS_ID_MAP, AbstractComposite::CSS_MAP, AbstractComposite::CSS_STYLE_MAP, AbstractComposite::DEFAULT_CLASS, AbstractComposite::LABELS, AbstractComposite::LEGACY_INTERFACE, AbstractComposite::LOOKANDFEEL_MAP, AbstractComposite::SYMBOL_MAP

Constants inherited from Component

Component::CSS_CLASS, Component::CSS_ID, Component::HTML_ATTRIBUTES, Component::HTTP_HEADERS, Component::LABEL

Instance Attribute Summary

Attributes inherited from Component

#attributes, #dojo_tooltip, #model, #value

Instance Method Summary collapse

Methods inherited from TagComposite

#create, #insert_row, #label, #setup_grid, #submit, #tag_attributes

Methods inherited from AbstractComposite

component, #create, #init

Methods inherited from Component

#_to_html, #autofill?, #css_class, #css_class=, #css_id, #css_id=, #dojo_dynamic_html, #dojo_parse_on_load, #dojo_tag, #dojo_title=, #dynamic_html, #escape, #escape_symbols, #formname, #http_headers, #initialize, #label=, #label?, #onclick=, #onload=, #onsubmit=, #set_attribute, #tabindex=

Constructor Details

This class inherits a constructor from HtmlGrid::Component

Instance Method Details

#compose(model = @model) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/htmlgrid/divcomposite.rb', line 9

def compose(model=@model)
	ypos = -1
	xpos = 0
	div = nil
	components.sort_by { |matrix, component|
		[matrix.at(1), matrix.at(0), matrix[2..-1]]
	}.each { |matrix, component|
		if((mpos = matrix.at(1).to_i) > ypos)
			xpos = 0
			ypos = mpos
			div = []
			@grid.push(div)
			css = {}
			if(klass = css_map[ypos])
				css.store('class', klass)
			end
			if(id = css_id_map[ypos])
				css.store('id', id)
			end
			if(style = css_style_map[ypos])
				css.store('style', style)
			end
			@css_grid.push(css.empty? ? nil : css)
		end
		div.push(label(create(component, model), component))
	}
end

#to_html(context) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/htmlgrid/divcomposite.rb', line 36

def to_html(context)
	res = ''
	@grid.each_with_index { |div, idx|
      res << context.div(tag_attributes(idx)) {
        div.flatten.inject('') { |html, item|
          html << if(item.respond_to?(:to_html))
                    item.to_html(context).force_encoding('utf-8')
                  else
                    item.to_s
                  end
        }
      }
	}
	res
end