annotate env/ui/tabs.lua @ 1429:2305d3cb16da
Fixed wrong variable name2
author |
bsw |
date |
Fri Oct 05 21:57:26 2018 +0200 (2018-10-05) |
parents |
904f6807f7fa |
children |
|
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@1145
|
7 local params = request.get_param_strings()
|
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@1145
|
13 local params = request.get_param_strings()
|
bsw@292
|
14 if tab.link_params then
|
bsw@292
|
15 for key, value in pairs(tab.link_params) do
|
bsw@292
|
16 params[key] = value
|
bsw@292
|
17 end
|
bsw@292
|
18 end
|
bsw@278
|
19 params["tab"] = i > 1 and tab.name or nil
|
bsw@278
|
20 ui.link{
|
bsw@278
|
21 attr = {
|
bsw@278
|
22 class = (
|
bsw@278
|
23 tab.name == current_tab and "selected" .. (tab.class and (" " .. tab.class) or "") or
|
bsw@278
|
24 not current_tab and i == 1 and "selected" .. (tab.class and (" " .. tab.class) or "") or
|
bsw@278
|
25 "" .. (tab.class and (" " .. tab.class) or "")
|
bsw@278
|
26 )
|
bsw@278
|
27 },
|
bsw@278
|
28 module = request.get_module(),
|
bsw@278
|
29 view = request.get_view(),
|
bsw@1145
|
30 id = request.get_id_string(),
|
bsw@278
|
31 content = tab.label,
|
bsw@278
|
32 params = params
|
bsw/jbe@0
|
33 }
|
bsw@278
|
34 slot.put(" ")
|
bsw/jbe@0
|
35 end
|
bsw/jbe@0
|
36 end
|
bsw/jbe@0
|
37 }
|
bsw@278
|
38 for i, tab in ipairs(tabs) do
|
bsw@278
|
39 if tab.name == current_tab and i > 1 then
|
bsw@278
|
40 app.html_title.prefix = tab.label
|
bsw/jbe@19
|
41 end
|
bsw@278
|
42 if tab.name == current_tab or not current_tab and i == 1 then
|
bsw@278
|
43 ui.container{
|
bsw@278
|
44 attr = { class = "ui_tabs_content" },
|
bsw@278
|
45 content = function()
|
bsw@278
|
46 if tab.content then
|
bsw@278
|
47 tab.content()
|
bsw@278
|
48 else
|
bsw@278
|
49 execute.view{
|
bsw@278
|
50 module = tab.module,
|
bsw@278
|
51 view = tab.view,
|
bsw@278
|
52 id = tab.id,
|
bsw@278
|
53 params = tab.params,
|
bsw@278
|
54 }
|
bsw@278
|
55 end
|
bsw@278
|
56 end
|
bsw@278
|
57 }
|
bsw/jbe@19
|
58 end
|
bsw/jbe@19
|
59 end
|
bsw/jbe@0
|
60 end
|
bsw@278
|
61 }
|
jorges@102
|
62 end
|