start to unify and test listeners

This commit is contained in:
Torsten Ruger 2015-08-18 23:08:12 +02:00
parent f942ed719a
commit ef321dab26
3 changed files with 17 additions and 25 deletions

View File

@ -1,6 +1,19 @@
if RUBY_PLATFORM == 'opal'
require "native"
end
module Main module Main
class ObjectsController < Volt::ModelController class ObjectsController < Volt::ModelController
def index_ready
container = Native(self.container).querySelector("ul")
return unless container
puts "li " + container.innerHTML + " lo"
# red = -> (event) { container.style.backgroundColor = "red" }
red = -> (event) { puts container.tagName }
container.addEventListener("mouseenter" , red)
end
def marker var def marker var
return "Wo" if var.is_a? String return "Wo" if var.is_a? String
var.class.name.split("::").last[0,2] var.class.name.split("::").last[0,2]

View File

@ -4,12 +4,12 @@
<:Body> <:Body>
<li> <li>
<a href="#">{{attrs.object}}</a> <a href="#">{{attrs.object}}</a>
{{ if(is_object?(attrs.id) and (attrs.level < 4)) }} {{ if(is_object?(attrs.id) ) }}
<ul> <ul>
{{content(attrs.id).each do |con3| }} {{content(attrs.id).each do |con3| }}
<li> <li>
<a href="#">{{con3[0]}}</a> <a href="#">{{con3[0]}}</a>
</li> </li>
{{end}} {{end}}
</ul> </ul>
{{ end }} {{ end }}

View File

@ -7,29 +7,8 @@
<div class="register-view"> <div class="register-view">
<ul id="nav"> <ul id="nav">
<a href="#">{{reg.name}} : {{reg.value}}</a> <a href="#">{{reg.name}} : {{reg.value}}</a>
{{ reg.fields.each_with_index do |attribute, index| }} {{ reg.fields.each do |attribute| }}
<li class="field"> <:objects object={{attribute}} id={{attribute.object_id}} />
<a href="#">
{{index}}{{marker(attribute)}}
{{attribute.object_id}}
</a>
{{ if(is_object?(attribute.object_id)) }}
<ul>
{{content(attribute.object_id).each do |con| }}
<li>
<a href="#">{{con[0]}}</a>
{{ if is_object?( con[1])}}
<ul>
{{content(con[1]).each do |con2| }}
<:objects object={{con2[0]}} id={{con2[1]}} level={{3}} />
{{end}}
</ul>
{{ end }}
</li>
{{end}}
</ul>
{{ end }}
</li>
{{end}} {{end}}
</ul> </ul>
</div> </div>