liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 387:e012250163ca
Make yellow boxes the same color
| author | bsw | 
|---|---|
| date | Mon Mar 05 14:51:58 2012 +0100 (2012-03-05) | 
| parents | 89d32158bfd5 | 
| children | 699b9fa7bc36 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local selected = param.get("selected", atom.boolean)
     5 ui.container{ attr = { class = "initiative" }, content = function()
     7   ui.container{ attr = { class = "rank" }, content = function()
     8     if initiative.issue.accepted and initiative.issue.closed
     9       and initiative.issue.ranks_available or initiative.admitted == false
    10     then 
    11       ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    12     else
    13       ui.image{ static = "icons/16/script.png" }
    14     end
    15   end }
    17   ui.container{ attr = { class = "bar" }, content = function()
    18     if initiative.issue.fully_frozen and initiative.issue.closed then
    19       if initiative.issue.ranks_available then 
    20         if initiative.negative_votes and initiative.positive_votes then
    21           local max_value = initiative.issue.voter_count
    22           ui.bargraph{
    23             max_value = max_value,
    24             width = 100,
    25             bars = {
    26               { color = "#0a0", value = initiative.positive_votes },
    27               { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    28               { color = "#a00", value = initiative.negative_votes },
    29             }
    30           }
    31         else
    32           slot.put(" ")
    33         end
    34       else
    35         slot.put(_"Counting of votes")
    36       end
    37     else
    38       local max_value = initiative.issue.population or 0
    39       ui.bargraph{
    40         max_value = max_value,
    41         width = 100,
    42         quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
    43         quorum_color = "#00F",
    44         bars = {
    45           { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    46           { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    47           { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
    48         }
    49       }
    50     end
    51   end }
    53   ui.container{ attr = { class = "interest" }, content = function()
    54     if initiative.is_initiator then
    55       local label = _"You are initiator of this initiative"
    56       ui.image{
    57         attr = { alt = label, title = label },
    58         static = "icons/16/user_edit.png"
    59       }
    60     elseif initiative.is_supporter then
    61       local label = _"You are supporter of this initiative"
    62       ui.image{
    63         attr = { alt = label, title = label },
    64         static = "icons/16/thumb_up_green.png"
    65       }
    66     elseif initiative.is_potential_supporter then
    67       local label = _"You are potentially supporter of this initiative"
    68       ui.image{
    69         attr = { alt = label, title = label },
    70         static = "icons/16/thumb_up.png"
    71       }
    72     elseif initiative.is_supporter_via_delegation then
    73       local label = _"You are supporter of this initiative via delegation"
    74       ui.image{
    75         attr = { alt = label, title = label },
    76         static = "icons/16/thumb_up_green.png"
    77       }
    78     end
    79   end }
    81   ui.container{ attr = { class = "name" }, content = function()
    82     local link_class = "initiative_link"
    83     if initiative.revoked then
    84       link_class = "revoked"
    85     end
    86     if selected then
    87       link_class = link_class .. " selected"
    88     end
    89     if initiative.is_supporter then
    90       link_class = link_class .. " supported"
    91     end
    92     if initiative.is_potential_supporter then
    93       link_class = link_class .. " potentially_supported"
    94     end
    95     if initiative.is_supporter_via_delegation then
    96       link_class = link_class .. " supported"
    97     end
    98     ui.link{
    99       attr = { class = link_class },
   100       content = function()
   101         local name
   102         if initiative.name_highlighted then
   103           name = encode.highlight(initiative.name_highlighted)
   104         else
   105           name = encode.html(initiative.shortened_name)
   106         end
   107         ui.tag{ content = "i" .. initiative.id .. ": " }
   108         slot.put(name)
   109       end,
   110       module  = "initiative",
   111       view    = "show",
   112       id      = initiative.id
   113     }
   115   end }
   117 end }
