Class: UnderOs::UI::Collection::Item

Inherits:
View show all
Defined in:
lib/under_os/ui/collection/item.rb

Overview

This is the collection item class that you supposed to inherit (well, if you need to)

Constant Summary

Constants included from Wrap

Wrap::INSTANCES_CACHE, Wrap::RAW_WRAPS_MAP, Wrap::WRAPS_TAGS_MAP

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from View

#initialize, #inspect

Methods included from Manipulation

#append, #clear, #insert, #insertTo, #prepend, #remove

Methods included from Traversing

#children, #empty?, #find, #first, #matches, #parent, #siblings

Methods included from Dimensions

#position, #position=, #size, #size=

Methods included from Animation

#animate, #fade_in, #fade_out, #highlight

Methods included from UnderOs::UI::Commons

#data, #data=, #hidden, #hide, #id, #id=, #page, #show, #tagName, #toggle, #visible

Methods included from Styles

#addClass, #className, #className=, #classNames, #classNames=, #hasClass, #radioClass, #removeClass, #repaint, #style, #style=, #toggleClass

Methods included from Events

#emit, #off, #on, #on=

Methods included from Wrap

included

Constructor Details

This class inherits a constructor from UnderOs::UI::View

Class Method Details

.build(collection, &builder) ⇒ Object



9
10
11
12
13
# File 'lib/under_os/ui/collection/item.rb', line 9

def self.build(collection, &builder)
  @builders           ||= {}
  @builders[collection] = builder
  collection.item_class = self
end

.for(collection, stylesheet = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/under_os/ui/collection/item.rb', line 15

def self.for(collection, stylesheet=nil)
  new.tap do |view|
    def view.parent; @_parent; end
    view.instance_variable_set('@_parent', collection)

    @builders[collection] && @builders[collection].call.each do |child|
      view.insert child
    end

    view.repaint(stylesheet || UnderOs::App.history.current_page.stylesheet)
  end
end

Instance Method Details

#cleanupObject



28
29
30
# File 'lib/under_os/ui/collection/item.rb', line 28

def cleanup
  # implement me if you need to clean cells between reuse
end