liquid_feedback_frontend

diff app/main/initiative/_list_element.lua @ 19:00d1004545f1

Dynamic interface using XMLHttpRequests, and many other changes

Bugfixes:
- Only allow voting on admitted initiatives
- Repaired issue search
- Don't display delegations for closed issues on member page
- Don't show revoke link in initiative, when issue is already half_frozen
- Localization for voting JavaScript
- Display author of suggestions

Disclosure of voting data after voting is finished:
- Possibility to inspect every ballot including preferences
- Show number of voters preferring one initiative to another initiative

Interface behaviour changes:
- Reversed default order of drafts
- Default order of suggestions changed
- Show new drafts of initiatives only once per day in timeline

Accessibility:
- Barrier-free voting implemented
- POST links are now accessible without JavaScript
- Changed gray for unsatisfied supporters in bar graph to a lighter gray

Other interface improvements:
- Optical enhancements
- Dynamic interface using XMLHttpRequests
- Show usage terms in about section
- Show own membership in area listing
- Show uninformed supporters greyed out and marked with yellow question mark
- Warning box in non-admitted initiatives
- When voted, don't display voting notice and change label of voting link
- Show object counts in more tabulator heads
- Enlarged member statement input field

Miscellaneous:
- Code cleanup
- Added README file containing installation instructions
- Use new WebMCP function ui.filters{...} instead of own ui.filter and ui.order functions
author bsw/jbe
date Sat Feb 20 22:10:31 2010 +0100 (2010-02-20)
parents
children b195682957dc
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/initiative/_list_element.lua	Sat Feb 20 22:10:31 2010 +0100
     1.3 @@ -0,0 +1,208 @@
     1.4 +local initiative = param.get("initiative", "table")
     1.5 +local expanded = param.get("expanded", atom.boolean)
     1.6 +local expandable = param.get("expandable", atom.boolean)
     1.7 +
     1.8 +local head_name = "initiative_head_" ..    tostring(initiative.id)
     1.9 +local link_name = "initiative_link_" ..    tostring(initiative.id)
    1.10 +local name      = "initiative_content_" .. tostring(initiative.id)
    1.11 +local icon_name = "initiative_icon_" ..    tostring(initiative.id)
    1.12 +
    1.13 +ui.container{
    1.14 +  attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
    1.15 +  content = function()
    1.16 +    local web20 = config.user_tab_mode == "accordeon"
    1.17 +      or config.user_tab_mode == "accordeon_first_expanded"
    1.18 +      or config.user_tab_mode == "accordeon_all_expanded"
    1.19 +    local onclick
    1.20 +    if web20 then
    1.21 +      if expandable then
    1.22 +      onclick = 
    1.23 +        'if (lf_initiative_expanded["' .. name .. '"]) {' ..
    1.24 +          'lf_initiative_expanded["' .. name .. '"]=false;' ..
    1.25 +          'document.getElementById("' .. name .. '_content").innerHTML=" ";' ..
    1.26 +          'document.getElementById("' .. name .. '").style.display="none";' ..
    1.27 +        '} else {' ..
    1.28 +          'lf_initiative_expanded["' .. name .. '"] = true;' ..
    1.29 +          'document.getElementById("' .. name .. '").style.display="block"; ' ..
    1.30 +          'var hourglass_el = document.getElementById("' .. icon_name .. '");' ..
    1.31 +          'var hourglass_src = hourglass_el.src;' ..
    1.32 +          'hourglass_el.src = "' .. encode.url{ static = "icons/16/connect.png" } .. '";' ..
    1.33 +          'partialMultiLoad(' ..
    1.34 +            '{ trace: "trace", system_error: "system_error", ' .. name .. '_content: "default" },' ..
    1.35 +            '{},' ..
    1.36 +            '"error",' ..
    1.37 +            '"' .. 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",' ..
    1.38 +            '{},' ..
    1.39 +            '{},' ..
    1.40 +            'function() {' ..
    1.41 +              'hourglass_el.src = hourglass_src;' ..
    1.42 +            '},' ..
    1.43 +            'function() {' ..
    1.44 +              'hourglass_el.src = hourglass_src;' ..
    1.45 +            '}' ..
    1.46 +          '); ' ..
    1.47 +        '}' ..
    1.48 +        'return(false);'
    1.49 +      else
    1.50 +        onclick = "document.location.href = document.getElementById('" .. link_name .. "').href;"
    1.51 +      end
    1.52 +    end
    1.53 +    local module = "initiative"
    1.54 +    local view = "show"
    1.55 +    local id = initiative.id
    1.56 +    local params = {}
    1.57 +    ui.container{
    1.58 +      attr = {
    1.59 +        name = name,
    1.60 +        class = "ui_tabs_accordeon_head",
    1.61 +        id = head_name,
    1.62 +        onclick = onclick,
    1.63 +      },
    1.64 +      content = function()
    1.65 +
    1.66 +        ui.container{
    1.67 +          attr = { style = "float: left; width: 4em;"},
    1.68 +          content = function()
    1.69 +            if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then 
    1.70 +              ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank }
    1.71 +            elseif web20 then
    1.72 +              ui.image{
    1.73 +                attr = {
    1.74 +                  width = 16,
    1.75 +                  height = 16,
    1.76 +                  id = icon_name,
    1.77 +                  style = "float: left;"
    1.78 +                },
    1.79 +                static = "icons/16/script.png"
    1.80 +              }
    1.81 +            else
    1.82 +              slot.put(" ")
    1.83 +            end
    1.84 +          end
    1.85 +        }
    1.86 +
    1.87 +        ui.container{
    1.88 +          attr = { style = "float: left; width: 110px;"},
    1.89 +          content = function()
    1.90 +            if initiative.issue.accepted and initiative.issue.closed then
    1.91 +              if initiative.issue.ranks_available then 
    1.92 +                if initiative.negative_votes and initiative.positive_votes then
    1.93 +                  local max_value = initiative.issue.voter_count
    1.94 +                  ui.bargraph{
    1.95 +                    max_value = max_value,
    1.96 +                    width = 100,
    1.97 +                    bars = {
    1.98 +                      { color = "#0a0", value = initiative.positive_votes },
    1.99 +                      { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
   1.100 +                      { color = "#a00", value = initiative.negative_votes },
   1.101 +                    }
   1.102 +                  }
   1.103 +                else
   1.104 +                  slot.put(" ")
   1.105 +                end
   1.106 +              else
   1.107 +                slot.put(_"Counting of votes")
   1.108 +              end
   1.109 +            elseif initiative.issue.population then
   1.110 +              local max_value = initiative.issue.population
   1.111 +              ui.bargraph{
   1.112 +                max_value = max_value,
   1.113 +                width = 100,
   1.114 +                bars = {
   1.115 +                  { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
   1.116 +                  { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
   1.117 +                  { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
   1.118 +                }
   1.119 +              }
   1.120 +            else
   1.121 +              slot.put(" ")
   1.122 +            end
   1.123 +          end
   1.124 +        }
   1.125 +
   1.126 +        ui.container{
   1.127 +          attr = { style = "float: left;"},
   1.128 +          content = function()
   1.129 +            local link_class
   1.130 +            if initiative.revoked then
   1.131 +              link_class = "revoked"
   1.132 +            end
   1.133 +            ui.link{
   1.134 +              attr = { id = link_name, class = link_class },
   1.135 +              content = function()
   1.136 +                local name
   1.137 +                if initiative.name_highlighted then
   1.138 +                  name = encode.highlight(initiative.name_highlighted)
   1.139 +                else
   1.140 +                  name = encode.html(initiative.name)
   1.141 +                end
   1.142 +                slot.put(name)
   1.143 +              end,
   1.144 +              module  = module,
   1.145 +              view    = view,
   1.146 +              id      = id,
   1.147 +              params  = params,
   1.148 +            }
   1.149 +          end
   1.150 +        }
   1.151 +
   1.152 +        if initiative.issue.state == "new" then
   1.153 +          ui.image{
   1.154 +            static = "icons/16/new.png"
   1.155 +          }
   1.156 +        end
   1.157 +        if initiative.is_supporter then
   1.158 +          slot.put(" ")
   1.159 +          local label = _"You are supporting this initiative"
   1.160 +          ui.image{
   1.161 +            attr = { alt = label, title = label },
   1.162 +            static = "icons/16/thumb_up_green.png"
   1.163 +          }
   1.164 +        end
   1.165 +        if initiative.is_potential_supporter then
   1.166 +          slot.put(" ")
   1.167 +          local label = _"You are potential supporter of this initiative"
   1.168 +          ui.image{
   1.169 +            attr = { alt = label, title = label },
   1.170 +            static = "icons/16/thumb_up.png"
   1.171 +          }
   1.172 +        end
   1.173 +        if initiative.is_initiator then
   1.174 +          slot.put(" ")
   1.175 +          local label = _"You are iniator of this initiative"
   1.176 +          ui.image{
   1.177 +            attr = { alt = label, title = label },
   1.178 +            static = "icons/16/user_edit.png"
   1.179 +          }
   1.180 +        end
   1.181 +
   1.182 +        slot.put("<br style='clear: left' />")
   1.183 +      end
   1.184 +    }
   1.185 +  end
   1.186 +}
   1.187 +
   1.188 +if ui.is_partial_loading_enabled() then
   1.189 +  ui.container{
   1.190 +    attr = {
   1.191 +      id = name,
   1.192 +      class = "ui_tabs_accordeon_content",
   1.193 +      style = not expanded and "display: none;" or nil
   1.194 +    },
   1.195 +    content = function()
   1.196 +      ui.container{
   1.197 +        attr = { id = name .. "_content", style = "clear: left;" },
   1.198 +        content = function()
   1.199 +          execute.view{
   1.200 +            module = "initiative",
   1.201 +            view = "show_partial",
   1.202 +            params = {
   1.203 +              initiative = initiative,
   1.204 +              expanded = expanded
   1.205 +            }
   1.206 +          }
   1.207 +        end
   1.208 +      }
   1.209 +    end
   1.210 +  }
   1.211 +end
   1.212 \ No newline at end of file

Impressum / About Us