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