Class: HtmlGrid::Composite
- Inherits:
-
AbstractComposite
- Object
- Component
- AbstractComposite
- HtmlGrid::Composite
- Defined in:
- lib/htmlgrid/composite.rb
Direct Known Subclasses
Constant Summary collapse
- COLSPAN_MAP =
{}
- COMPONENT_CSS_MAP =
{}
- CSS_MAP =
{}
- DEFAULT_CLASS =
InputText- VERTICAL =
false
Constants inherited from AbstractComposite
AbstractComposite::CSS_CLASS, AbstractComposite::CSS_ID, AbstractComposite::CSS_ID_MAP, AbstractComposite::CSS_STYLE_MAP, AbstractComposite::LABELS, AbstractComposite::LEGACY_INTERFACE, AbstractComposite::LOOKANDFEEL_MAP, AbstractComposite::SYMBOL_MAP
Constants inherited from Component
HtmlGrid::Component::CSS_CLASS, HtmlGrid::Component::CSS_ID, HtmlGrid::Component::HTML_ATTRIBUTES, HtmlGrid::Component::HTTP_HEADERS, HtmlGrid::Component::LABEL
Instance Attribute Summary
Attributes inherited from Component
#attributes, #dojo_tooltip, #model, #value
Instance Method Summary collapse
- #compose(model = @model, offset = [0,0], bg_flag = false) ⇒ Object (also: #_compose)
- #compose_colspan(offset) ⇒ Object
- #event ⇒ Object
-
#full_colspan ⇒ Object
def explode! @grid.explode! super end.
- #insert_row(ypos, txt, css_class = nil) ⇒ Object
- #to_html(context) ⇒ Object
Methods inherited from AbstractComposite
Methods inherited from Component
#_to_html, #autofill?, #css_class, #css_class=, #css_id, #css_id=, #dojo_9?, #dojo_dynamic_html, #dojo_parse_widgets, #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, offset = [0,0], bg_flag = false) ⇒ Object Also known as: _compose
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/htmlgrid/composite.rb', line 197 def compose(model=@model, offset=[0,0], bg_flag=false) comps = components css = css_map cids = css_id_map ccss = component_css_map colsp = colspan_map suffix = resolve_suffix(model, bg_flag) comps.keys.concat(css.keys).concat(colsp.keys).uniq.sort_by { |key| [key.size, key] }.each { |key| nkey = key[0,2] matrix = resolve_offset(key, offset) nmatrix = resolve_offset(nkey, offset) comp = compose_component(model, comps[key], matrix) if(style = css[key]) @grid.add_style(style + suffix, *matrix) elsif(style = css[nkey]) @grid.add_style(style + suffix, *nmatrix) end if(id = cids[key] || cids[nkey]) comp.css_id = id end if(span = colsp[key]) @grid.set_colspan(matrix.at(0), matrix.at(1), span) end } # component-styles depend on components having been initialized # -> separate iteration ccss.each { |key, cstyle| matrix = resolve_offset(key, offset) @grid.add_component_style(cstyle + suffix, *matrix) } =begin compose_components(model, offset) compose_css(offset) compose_colspan(offset) =end end |
#compose_colspan(offset) ⇒ Object
236 237 238 239 240 241 |
# File 'lib/htmlgrid/composite.rb', line 236 def compose_colspan(offset) colspan_map.each { |matrix, span| res = resolve_offset(matrix, offset) @grid.set_colspan(res.at(0), res.at(1), span) } end |
#event ⇒ Object
242 243 244 |
# File 'lib/htmlgrid/composite.rb', line 242 def event @container.event if @container.respond_to?(:event) end |
#full_colspan ⇒ Object
def explode! @grid.explode! super end
251 252 253 254 255 256 |
# File 'lib/htmlgrid/composite.rb', line 251 def full_colspan raw_span = components.keys.collect{ |key| key.at(0) }.max.to_i (raw_span > 0) ? raw_span + 1 : nil end |
#insert_row(ypos, txt, css_class = nil) ⇒ Object
257 258 259 260 261 |
# File 'lib/htmlgrid/composite.rb', line 257 def insert_row(ypos, txt, css_class=nil) @grid.insert_row(ypos, txt) @grid.set_colspan(0,ypos) @grid.add_style(css_class, 0, ypos) if(css_class) end |
#to_html(context) ⇒ Object
262 263 264 265 |
# File 'lib/htmlgrid/composite.rb', line 262 def to_html(context) @grid.set_attributes(@attributes) super << @grid.to_html(context).force_encoding('utf-8') end |