liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 274:aec9df5b4cd3

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

Impressum / About Us