liquid_feedback_frontend
diff app/main/initiative/_list_element.lua @ 373:76d7eafb3893
Make things work with small screens like mobile devices in portrait mode
| author | bsw |
|---|---|
| date | Sat Mar 03 17:28:55 2012 +0100 (2012-03-03) |
| parents | 7d6a3c411f99 |
| children | 89d32158bfd5 |
line diff
1.1 --- a/app/main/initiative/_list_element.lua Thu Mar 01 22:56:35 2012 +0100 1.2 +++ b/app/main/initiative/_list_element.lua Sat Mar 03 17:28:55 2012 +0100 1.3 @@ -1,133 +1,117 @@ 1.4 local initiative = param.get("initiative", "table") 1.5 local selected = param.get("selected", atom.boolean) 1.6 1.7 -ui.list{ 1.8 - attr = { class = "nohover" }, 1.9 - records = { { a = 1} }, 1.10 - columns = { 1.11 - { 1.12 - field_attr = { style = "width: 3em; text-align: center;"}, 1.13 - content = function() 1.14 - if 1.15 - initiative.issue.accepted and initiative.issue.closed 1.16 - and initiative.issue.ranks_available or initiative.admitted == false 1.17 - then 1.18 - ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible } 1.19 - else 1.20 - slot.put(" ") 1.21 - end 1.22 - end 1.23 - }, 1.24 + 1.25 +ui.container{ attr = { class = "initiative" }, content = function() 1.26 1.27 - { 1.28 - field_attr = { style = "width: 100px;"}, 1.29 - content = function() 1.30 - if initiative.issue.fully_frozen and initiative.issue.closed then 1.31 - if initiative.issue.ranks_available then 1.32 - if initiative.negative_votes and initiative.positive_votes then 1.33 - local max_value = initiative.issue.voter_count 1.34 - ui.bargraph{ 1.35 - max_value = max_value, 1.36 - width = 100, 1.37 - bars = { 1.38 - { color = "#0a0", value = initiative.positive_votes }, 1.39 - { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, 1.40 - { color = "#a00", value = initiative.negative_votes }, 1.41 - } 1.42 - } 1.43 - else 1.44 - slot.put(" ") 1.45 - end 1.46 - else 1.47 - slot.put(_"Counting of votes") 1.48 - end 1.49 - else 1.50 - local max_value = initiative.issue.population or 0 1.51 + ui.container{ attr = { class = "rank" }, content = function() 1.52 + if initiative.issue.accepted and initiative.issue.closed 1.53 + and initiative.issue.ranks_available or initiative.admitted == false 1.54 + then 1.55 + ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible } 1.56 + else 1.57 + slot.put('<img src="null.png" width="28" height="1" />') 1.58 + end 1.59 + end } 1.60 + 1.61 + ui.container{ attr = { class = "bar" }, content = function() 1.62 + if initiative.issue.fully_frozen and initiative.issue.closed then 1.63 + if initiative.issue.ranks_available then 1.64 + if initiative.negative_votes and initiative.positive_votes then 1.65 + local max_value = initiative.issue.voter_count 1.66 ui.bargraph{ 1.67 max_value = max_value, 1.68 width = 100, 1.69 - quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), 1.70 - quorum_color = "#00F", 1.71 bars = { 1.72 - { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, 1.73 - { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, 1.74 - { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) }, 1.75 + { color = "#0a0", value = initiative.positive_votes }, 1.76 + { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, 1.77 + { color = "#a00", value = initiative.negative_votes }, 1.78 } 1.79 } 1.80 - end 1.81 - end 1.82 - }, 1.83 - { 1.84 - field_attr = { style = "width: 24px;" }, 1.85 - content = function() 1.86 - if initiative.is_initiator then 1.87 - slot.put(" ") 1.88 - local label = _"You are initiator of this initiative" 1.89 - ui.image{ 1.90 - attr = { alt = label, title = label }, 1.91 - static = "icons/16/user_edit.png" 1.92 - } 1.93 - elseif initiative.is_supporter then 1.94 + else 1.95 slot.put(" ") 1.96 - local label = _"You are supporter of this initiative" 1.97 - ui.image{ 1.98 - attr = { alt = label, title = label }, 1.99 - static = "icons/16/thumb_up_green.png" 1.100 - } 1.101 - elseif initiative.is_potential_supporter then 1.102 - slot.put(" ") 1.103 - local label = _"You are potentially supporter of this initiative" 1.104 - ui.image{ 1.105 - attr = { alt = label, title = label }, 1.106 - static = "icons/16/thumb_up.png" 1.107 - } 1.108 - elseif initiative.is_supporter_via_delegation then 1.109 - slot.put(" ") 1.110 - local label = _"You are supporter of this initiative via delegation" 1.111 - ui.image{ 1.112 - attr = { alt = label, title = label }, 1.113 - static = "icons/16/thumb_up_green.png" 1.114 - } 1.115 end 1.116 - 1.117 + else 1.118 + slot.put(_"Counting of votes") 1.119 end 1.120 - }, 1.121 - { 1.122 + else 1.123 + local max_value = initiative.issue.population or 0 1.124 + ui.bargraph{ 1.125 + max_value = max_value, 1.126 + width = 100, 1.127 + quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), 1.128 + quorum_color = "#00F", 1.129 + bars = { 1.130 + { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, 1.131 + { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, 1.132 + { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) }, 1.133 + } 1.134 + } 1.135 + end 1.136 + end } 1.137 + 1.138 + ui.container{ attr = { class = "interest" }, content = function() 1.139 + if initiative.is_initiator then 1.140 + local label = _"You are initiator of this initiative" 1.141 + ui.image{ 1.142 + attr = { alt = label, title = label }, 1.143 + static = "icons/16/user_edit.png" 1.144 + } 1.145 + elseif initiative.is_supporter then 1.146 + local label = _"You are supporter of this initiative" 1.147 + ui.image{ 1.148 + attr = { alt = label, title = label }, 1.149 + static = "icons/16/thumb_up_green.png" 1.150 + } 1.151 + elseif initiative.is_potential_supporter then 1.152 + local label = _"You are potentially supporter of this initiative" 1.153 + ui.image{ 1.154 + attr = { alt = label, title = label }, 1.155 + static = "icons/16/thumb_up.png" 1.156 + } 1.157 + elseif initiative.is_supporter_via_delegation then 1.158 + local label = _"You are supporter of this initiative via delegation" 1.159 + ui.image{ 1.160 + attr = { alt = label, title = label }, 1.161 + static = "icons/16/thumb_up_green.png" 1.162 + } 1.163 + end 1.164 + end } 1.165 + 1.166 + ui.container{ attr = { class = "name" }, content = function() 1.167 + local link_class = "initiative_link" 1.168 + if initiative.revoked then 1.169 + link_class = "revoked" 1.170 + end 1.171 + if selected then 1.172 + link_class = link_class .. " selected" 1.173 + end 1.174 + if initiative.is_supporter then 1.175 + link_class = link_class .. " supported" 1.176 + end 1.177 + if initiative.is_potential_supporter then 1.178 + link_class = link_class .. " potentially_supported" 1.179 + end 1.180 + if initiative.is_supporter_via_delegation then 1.181 + link_class = link_class .. " supported" 1.182 + end 1.183 + ui.link{ 1.184 + attr = { class = link_class }, 1.185 content = function() 1.186 - local link_class = "initiative_link" 1.187 - if initiative.revoked then 1.188 - link_class = "revoked" 1.189 - end 1.190 - if selected then 1.191 - link_class = link_class .. " selected" 1.192 - end 1.193 - if initiative.is_supporter then 1.194 - link_class = link_class .. " supported" 1.195 - end 1.196 - if initiative.is_potential_supporter then 1.197 - link_class = link_class .. " potentially_supported" 1.198 - end 1.199 - if initiative.is_supporter_via_delegation then 1.200 - link_class = link_class .. " supported" 1.201 + local name 1.202 + if initiative.name_highlighted then 1.203 + name = encode.highlight(initiative.name_highlighted) 1.204 + else 1.205 + name = encode.html(initiative.shortened_name) 1.206 end 1.207 - ui.link{ 1.208 - attr = { class = link_class }, 1.209 - content = function() 1.210 - local name 1.211 - if initiative.name_highlighted then 1.212 - name = encode.highlight(initiative.name_highlighted) 1.213 - else 1.214 - name = encode.html(initiative.shortened_name) 1.215 - end 1.216 - ui.tag{ content = "i" .. initiative.id .. ": " } 1.217 - slot.put(name) 1.218 - end, 1.219 - module = "initiative", 1.220 - view = "show", 1.221 - id = initiative.id 1.222 - } 1.223 - 1.224 - end 1.225 + ui.tag{ content = "i" .. initiative.id .. ": " } 1.226 + slot.put(name) 1.227 + end, 1.228 + module = "initiative", 1.229 + view = "show", 1.230 + id = initiative.id 1.231 } 1.232 - } 1.233 -} 1.234 + 1.235 + end } 1.236 + 1.237 +end } 1.238 \ No newline at end of file