rev |
line source |
bsw/jbe@19
|
1 local initiative = param.get("initiative", "table")
|
bsw/jbe@19
|
2 local expanded = param.get("expanded", atom.boolean)
|
bsw/jbe@19
|
3 local expandable = param.get("expandable", atom.boolean)
|
bsw/jbe@19
|
4
|
bsw/jbe@19
|
5 local head_name = "initiative_head_" .. tostring(initiative.id)
|
bsw/jbe@19
|
6 local link_name = "initiative_link_" .. tostring(initiative.id)
|
bsw/jbe@19
|
7 local name = "initiative_content_" .. tostring(initiative.id)
|
bsw/jbe@19
|
8 local icon_name = "initiative_icon_" .. tostring(initiative.id)
|
bsw/jbe@19
|
9
|
bsw/jbe@19
|
10 ui.container{
|
bsw/jbe@19
|
11 attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
|
bsw/jbe@19
|
12 content = function()
|
bsw/jbe@19
|
13 local web20 = config.user_tab_mode == "accordeon"
|
bsw/jbe@19
|
14 or config.user_tab_mode == "accordeon_first_expanded"
|
bsw/jbe@19
|
15 or config.user_tab_mode == "accordeon_all_expanded"
|
bsw/jbe@19
|
16 local onclick
|
bsw/jbe@19
|
17 if web20 then
|
bsw/jbe@19
|
18 if expandable then
|
bsw/jbe@19
|
19 onclick =
|
bsw/jbe@19
|
20 'if (lf_initiative_expanded["' .. name .. '"]) {' ..
|
bsw/jbe@19
|
21 'lf_initiative_expanded["' .. name .. '"]=false;' ..
|
bsw/jbe@19
|
22 'document.getElementById("' .. name .. '_content").innerHTML=" ";' ..
|
bsw/jbe@19
|
23 'document.getElementById("' .. name .. '").style.display="none";' ..
|
bsw/jbe@19
|
24 '} else {' ..
|
bsw/jbe@19
|
25 'lf_initiative_expanded["' .. name .. '"] = true;' ..
|
bsw/jbe@19
|
26 'document.getElementById("' .. name .. '").style.display="block"; ' ..
|
bsw/jbe@19
|
27 'var hourglass_el = document.getElementById("' .. icon_name .. '");' ..
|
bsw/jbe@19
|
28 'var hourglass_src = hourglass_el.src;' ..
|
bsw/jbe@19
|
29 'hourglass_el.src = "' .. encode.url{ static = "icons/16/connect.png" } .. '";' ..
|
bsw/jbe@19
|
30 'partialMultiLoad(' ..
|
bsw/jbe@19
|
31 '{ trace: "trace", system_error: "system_error", ' .. name .. '_content: "default" },' ..
|
bsw/jbe@19
|
32 '{},' ..
|
bsw/jbe@19
|
33 '"error",' ..
|
bsw/jbe@19
|
34 '"' .. request.get_relative_baseurl() .. 'initiative/show_partial/' .. tostring(initiative.id) .. '.html?&_webmcp_json_slots[]=default&_webmcp_json_slots[]=support&_webmcp_json_slots[]=trace&_webmcp_json_slots[]=system_error",' ..
|
bsw/jbe@19
|
35 '{},' ..
|
bsw/jbe@19
|
36 '{},' ..
|
bsw/jbe@19
|
37 'function() {' ..
|
bsw/jbe@19
|
38 'hourglass_el.src = hourglass_src;' ..
|
bsw/jbe@19
|
39 '},' ..
|
bsw/jbe@19
|
40 'function() {' ..
|
bsw/jbe@19
|
41 'hourglass_el.src = hourglass_src;' ..
|
bsw/jbe@19
|
42 '}' ..
|
bsw/jbe@19
|
43 '); ' ..
|
bsw/jbe@19
|
44 '}' ..
|
bsw/jbe@19
|
45 'return(false);'
|
bsw/jbe@19
|
46 else
|
bsw/jbe@19
|
47 onclick = "document.location.href = document.getElementById('" .. link_name .. "').href;"
|
bsw/jbe@19
|
48 end
|
bsw/jbe@19
|
49 end
|
bsw/jbe@19
|
50 local module = "initiative"
|
bsw/jbe@19
|
51 local view = "show"
|
bsw/jbe@19
|
52 local id = initiative.id
|
bsw/jbe@19
|
53 local params = {}
|
bsw/jbe@19
|
54 ui.container{
|
bsw/jbe@19
|
55 attr = {
|
bsw/jbe@19
|
56 name = name,
|
bsw/jbe@19
|
57 class = "ui_tabs_accordeon_head",
|
bsw/jbe@19
|
58 id = head_name,
|
bsw/jbe@19
|
59 onclick = onclick,
|
bsw/jbe@19
|
60 },
|
bsw/jbe@19
|
61 content = function()
|
bsw/jbe@19
|
62
|
bsw@29
|
63 ui.list{
|
bsw@29
|
64 attr = { class = "nohover" },
|
bsw@29
|
65 records = { { a = 1} },
|
bsw@29
|
66 columns = {
|
bsw@29
|
67 {
|
bsw@273
|
68 field_attr = { style = "width: 3em; padding: 0; text-align: center;"},
|
bsw@29
|
69 content = function()
|
bsw@29
|
70 if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then
|
bsw@29
|
71 ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank }
|
bsw@29
|
72 elseif web20 then
|
bsw@29
|
73 ui.image{
|
bsw@29
|
74 attr = {
|
bsw@29
|
75 width = 16,
|
bsw@29
|
76 height = 16,
|
bsw@29
|
77 id = icon_name,
|
bsw@29
|
78 style = "float: left;"
|
bsw@29
|
79 },
|
bsw@29
|
80 static = "icons/16/script.png"
|
bsw@29
|
81 }
|
bsw@29
|
82 else
|
bsw@29
|
83 slot.put(" ")
|
bsw@29
|
84 end
|
bsw@29
|
85 end
|
bsw@29
|
86 },
|
bsw/jbe@19
|
87
|
bsw@29
|
88 {
|
bsw@29
|
89 field_attr = { style = "width: 110px; padding: 0;"},
|
bsw@29
|
90 content = function()
|
bsw/jbe@48
|
91 if initiative.issue.fully_frozen and initiative.issue.closed then
|
bsw@29
|
92 if initiative.issue.ranks_available then
|
bsw@29
|
93 if initiative.negative_votes and initiative.positive_votes then
|
bsw@29
|
94 local max_value = initiative.issue.voter_count
|
bsw@29
|
95 ui.bargraph{
|
bsw@29
|
96 max_value = max_value,
|
bsw@29
|
97 width = 100,
|
bsw@29
|
98 bars = {
|
bsw@29
|
99 { color = "#0a0", value = initiative.positive_votes },
|
bsw@29
|
100 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
|
bsw@29
|
101 { color = "#a00", value = initiative.negative_votes },
|
bsw@29
|
102 }
|
bsw@29
|
103 }
|
bsw@29
|
104 else
|
bsw@29
|
105 slot.put(" ")
|
bsw@29
|
106 end
|
bsw@29
|
107 else
|
bsw@29
|
108 slot.put(_"Counting of votes")
|
bsw@29
|
109 end
|
bsw@273
|
110 else
|
bsw@273
|
111 local max_value = initiative.issue.population or 0
|
bsw/jbe@19
|
112 ui.bargraph{
|
bsw/jbe@19
|
113 max_value = max_value,
|
bsw/jbe@19
|
114 width = 100,
|
poelzi@159
|
115 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
|
poelzi@159
|
116 quorum_color = "#00F",
|
bsw/jbe@19
|
117 bars = {
|
bsw@29
|
118 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
|
bsw@29
|
119 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
|
bsw@29
|
120 { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
|
bsw/jbe@19
|
121 }
|
bsw/jbe@19
|
122 }
|
bsw/jbe@19
|
123 end
|
bsw/jbe@19
|
124 end
|
bsw@29
|
125 },
|
bsw@29
|
126
|
bsw@29
|
127 {
|
bsw@29
|
128 field_attr = { style = "padding: 0;"},
|
bsw/jbe@19
|
129 content = function()
|
bsw@29
|
130 local link_class
|
bsw@29
|
131 if initiative.revoked then
|
bsw@29
|
132 link_class = "revoked"
|
bsw/jbe@19
|
133 end
|
bsw@29
|
134 ui.link{
|
bsw@29
|
135 attr = { id = link_name, class = link_class },
|
bsw@29
|
136 content = function()
|
bsw@29
|
137 local name
|
bsw@29
|
138 if initiative.name_highlighted then
|
bsw@29
|
139 name = encode.highlight(initiative.name_highlighted)
|
bsw@29
|
140 else
|
bsw@29
|
141 name = encode.html(initiative.shortened_name)
|
bsw@29
|
142 end
|
bsw@29
|
143 slot.put(name)
|
bsw@29
|
144 end,
|
bsw@29
|
145 module = module,
|
bsw@29
|
146 view = view,
|
bsw@29
|
147 id = id,
|
bsw@29
|
148 params = params,
|
bsw@29
|
149 }
|
bsw@29
|
150
|
bsw@29
|
151 if initiative.issue.state == "new" then
|
bsw@29
|
152 ui.image{
|
bsw@29
|
153 static = "icons/16/new.png"
|
bsw@29
|
154 }
|
bsw@29
|
155 end
|
bsw@29
|
156 if initiative.is_supporter then
|
bsw@29
|
157 slot.put(" ")
|
bsw@29
|
158 local label = _"You are supporting this initiative"
|
bsw@29
|
159 ui.image{
|
bsw@29
|
160 attr = { alt = label, title = label },
|
bsw@29
|
161 static = "icons/16/thumb_up_green.png"
|
bsw@29
|
162 }
|
bsw@29
|
163 end
|
bsw@29
|
164 if initiative.is_potential_supporter then
|
bsw@29
|
165 slot.put(" ")
|
bsw@29
|
166 local label = _"You are potential supporter of this initiative"
|
bsw@29
|
167 ui.image{
|
bsw@29
|
168 attr = { alt = label, title = label },
|
bsw@29
|
169 static = "icons/16/thumb_up.png"
|
bsw@29
|
170 }
|
bsw@29
|
171 end
|
bsw@29
|
172 if initiative.is_initiator then
|
bsw@29
|
173 slot.put(" ")
|
mail@239
|
174 local label = _"You are initiator of this initiative"
|
bsw@29
|
175 ui.image{
|
bsw@29
|
176 attr = { alt = label, title = label },
|
bsw@29
|
177 static = "icons/16/user_edit.png"
|
bsw@29
|
178 }
|
bsw@29
|
179 end
|
bsw@29
|
180
|
bsw@29
|
181 end
|
bsw/jbe@19
|
182 }
|
bsw/jbe@19
|
183 }
|
bsw@29
|
184 }
|
bsw/jbe@19
|
185 end
|
bsw/jbe@19
|
186 }
|
bsw/jbe@19
|
187 end
|
bsw/jbe@19
|
188 }
|
bsw/jbe@19
|
189
|
bsw/jbe@19
|
190 if ui.is_partial_loading_enabled() then
|
bsw/jbe@19
|
191 ui.container{
|
bsw/jbe@19
|
192 attr = {
|
bsw/jbe@19
|
193 id = name,
|
bsw/jbe@19
|
194 class = "ui_tabs_accordeon_content",
|
bsw/jbe@19
|
195 style = not expanded and "display: none;" or nil
|
bsw/jbe@19
|
196 },
|
bsw/jbe@19
|
197 content = function()
|
bsw/jbe@19
|
198 ui.container{
|
bsw/jbe@19
|
199 attr = { id = name .. "_content", style = "clear: left;" },
|
bsw/jbe@19
|
200 content = function()
|
bsw/jbe@19
|
201 execute.view{
|
bsw/jbe@19
|
202 module = "initiative",
|
bsw/jbe@19
|
203 view = "show_partial",
|
bsw/jbe@19
|
204 params = {
|
bsw/jbe@19
|
205 initiative = initiative,
|
bsw/jbe@19
|
206 expanded = expanded
|
bsw/jbe@19
|
207 }
|
bsw/jbe@19
|
208 }
|
bsw/jbe@19
|
209 end
|
bsw/jbe@19
|
210 }
|
bsw/jbe@19
|
211 end
|
bsw/jbe@19
|
212 }
|
bsw/jbe@19
|
213 end |