rename create_element to div and create to create_element

This commit is contained in:
Torsten Ruger 2015-08-22 01:05:35 +02:00
parent 6925a3fefa
commit b21ca406c8
2 changed files with 12 additions and 2 deletions

View File

@ -8,10 +8,11 @@ class ElementView
raise "implement me to return an Element"
end
def create_element name_class
def div name_class , text = nil
name , clazz = name_class.split(".")
name = "div" if name.empty?
element = $document.create_element(name)
element.text = text if text
return element unless clazz
if( clazz.is_a? Array )
clazz.each { |c| add_class_or_id( element , cl )}
@ -36,4 +37,13 @@ class ElementView
node.append_to wrapper
end
def create_element class_or_id , text = nil
@element = div( class_or_id , text)
end
def add class_or_id , tex = nil
element = div( class_or_id , tex)
element.append_to @element
element
end
end

View File

@ -13,7 +13,7 @@ class ListView < ElementView
end
def draw on
@container_element = create_element(self.root)
@container_element = div(self.root)
@elements = @children.collect do | c |
elem = c.draw(@container_element)
elem.append_to(@container_element)