Skip to content

Commit

Permalink
some stragglers fixed. Docs next
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedonovan committed Jan 15, 2013
1 parent 5d4336f commit 3345670
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/formtest.lua
Expand Up @@ -31,7 +31,7 @@ local f = form.new {

local h2,p = html.tags 'h2,p'

local hashlist = html.list:specialize {map = html.map2list, render = '%s = %s'}
local hashlist = html.specialize (html.list,{map = html.map2list, render = '%s = %s'})

local last_mem = collectgarbage("count")

Expand Down
23 changes: 11 additions & 12 deletions examples/tree.lua
Expand Up @@ -7,7 +7,7 @@ local data_to_id,set_handler,set_data = jq.data_to_id, jq.set_handler, jq.set_da
local app = orbiter.new(html)

html.set_defaults {
styles = "/resources/css/jquery.treeview.css",
styles = "/resources/css/jquery.treeview.css",
scripts = "/resources/javascript/jquery.treeview.js",
inline_script = [[
function treeview_create(id,body) {
Expand Down Expand Up @@ -50,7 +50,7 @@ function file (data)
if data.attribs then
table.update(args,data.attribs)
end
return {
return {
span(args),
id = data_to_id(data)
}
Expand All @@ -75,7 +75,7 @@ local Folder = util.class(){

function process_children(children)
for i,item in ipairs(children) do
if not util.class_of(item,Folder) and not html.is_doc(item) then
if not util.class_of(item,Folder) and not html.is_doc(item) then
children[i] = file(item)
end
end
Expand All @@ -92,7 +92,7 @@ function folder (children)
local hidden = children.hidden
children.hidden = nil
local data = children.data or label
children.data = nil
children.data = nil
if hidden and #children==0 then children = {''} end
process_children(children)
return Folder{span{label,class='folder'},
Expand All @@ -118,29 +118,29 @@ function treeview (t)
set_handler('click',id,t)
set_handler('expanding',id,t)
set_handler('collapsing',id,t)
return {
return {
html.list(t),
html.script ('treeview_create("%s","")' % id)
html.script (('treeview_create("%s","")'):format(id))
}
end

function tree_fragment(id,t)
local bb = fragment(t)
local markup = html.raw_tostring(bb)
print('markup\n',markup)
return 'treeview_create("%s","%s")' % {id,markup}
return ('treeview_create("%s","%s")'):format(id,markup)
end

function add_tree(t)
return function() return tree_fragment(t.id,t) end
end
end

-- note that any item in the html list can itself be a simple list; in this case
-- the items will be appended to the list. This allows the treeview() function
-- to do its magic without needing to return a single element.
function app:index(web)
return html {
treeview{id='browser';
treeview {id='browser';
click = function(data)
return jq.alert("clicked "..tostring(data))
end;
Expand All @@ -159,15 +159,14 @@ function app:index(web)
'fred','Pebbles','Wilma',
}
},
link('http://snippets.luacode.org','so fine')
}
link('http://snippets.luacode.org','so fine')
}
},
jq.button('Add',add_tree{id="browser",
"more",
'and again',
'finally'
});
});
}
end

Expand Down

0 comments on commit 3345670

Please sign in to comment.