liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 277:bde068b37608

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

Impressum / About Us