annotate env/ui/tabs.lua @ 286:c587d8762e62
Registration process updated for Core 2.0, lockable member fields, notification settings
author |
bsw |
date |
Sat Feb 25 11:51:37 2012 +0100 (2012-02-25) |
parents |
fecd4c13054a |
children |
44f9a09ea51c |
rev |
line source |
bsw@278
|
1 function ui.tabs(tabs)
|
bsw@286
|
2 local attr = tabs.attr or {}
|
bsw@286
|
3 attr.class = (attr.class and attr.class .. " " or "") .. "ui_tabs"
|
bsw@278
|
4 ui.container{
|
bsw@286
|
5 attr = attr,
|
bsw@278
|
6 content = function()
|
bsw/jbe@0
|
7 local params = param.get_all_cgi()
|
bsw@278
|
8 local current_tab = params["tab"]
|
bsw@278
|
9 ui.container{
|
bsw@278
|
10 attr = { class = "ui_tabs_links" },
|
bsw/jbe@0
|
11 content = function()
|
bsw@278
|
12 for i, tab in ipairs(tabs) do
|
bsw@278
|
13 params["tab"] = i > 1 and tab.name or nil
|
bsw@278
|
14 ui.link{
|
bsw@278
|
15 attr = {
|
bsw@278
|
16 class = (
|
bsw@278
|
17 tab.name == current_tab and "selected" .. (tab.class and (" " .. tab.class) or "") or
|
bsw@278
|
18 not current_tab and i == 1 and "selected" .. (tab.class and (" " .. tab.class) or "") or
|
bsw@278
|
19 "" .. (tab.class and (" " .. tab.class) or "")
|
bsw@278
|
20 )
|
bsw@278
|
21 },
|
bsw@278
|
22 module = request.get_module(),
|
bsw@278
|
23 view = request.get_view(),
|
bsw@278
|
24 id = param.get_id_cgi(),
|
bsw@278
|
25 content = tab.label,
|
bsw@278
|
26 params = params
|
bsw/jbe@0
|
27 }
|
bsw@278
|
28 slot.put(" ")
|
bsw/jbe@0
|
29 end
|
bsw/jbe@0
|
30 end
|
bsw/jbe@0
|
31 }
|
bsw@278
|
32 for i, tab in ipairs(tabs) do
|
bsw@278
|
33 if tab.name == current_tab and i > 1 then
|
bsw@278
|
34 app.html_title.prefix = tab.label
|
bsw/jbe@19
|
35 end
|
bsw@278
|
36 if tab.name == current_tab or not current_tab and i == 1 then
|
bsw@278
|
37 ui.container{
|
bsw@278
|
38 attr = { class = "ui_tabs_content" },
|
bsw@278
|
39 content = function()
|
bsw@278
|
40 if tab.content then
|
bsw@278
|
41 tab.content()
|
bsw@278
|
42 else
|
bsw@278
|
43 execute.view{
|
bsw@278
|
44 module = tab.module,
|
bsw@278
|
45 view = tab.view,
|
bsw@278
|
46 id = tab.id,
|
bsw@278
|
47 params = tab.params,
|
bsw@278
|
48 }
|
bsw@278
|
49 end
|
bsw@278
|
50 end
|
bsw@278
|
51 }
|
bsw/jbe@19
|
52 end
|
bsw/jbe@19
|
53 end
|
bsw/jbe@0
|
54 end
|
bsw@278
|
55 }
|
jorges@102
|
56 end
|