bsw/jbe@19: local initiative = param.get("initiative", "table") bsw/jbe@19: local expanded = param.get("expanded", atom.boolean) bsw/jbe@19: local expandable = param.get("expandable", atom.boolean) bsw/jbe@19: bsw/jbe@19: local head_name = "initiative_head_" .. tostring(initiative.id) bsw/jbe@19: local link_name = "initiative_link_" .. tostring(initiative.id) bsw/jbe@19: local name = "initiative_content_" .. tostring(initiative.id) bsw/jbe@19: local icon_name = "initiative_icon_" .. tostring(initiative.id) bsw/jbe@19: bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") }, bsw/jbe@19: content = function() bsw/jbe@19: local web20 = config.user_tab_mode == "accordeon" bsw/jbe@19: or config.user_tab_mode == "accordeon_first_expanded" bsw/jbe@19: or config.user_tab_mode == "accordeon_all_expanded" bsw/jbe@19: local onclick bsw/jbe@19: if web20 then bsw/jbe@19: if expandable then bsw/jbe@19: onclick = bsw/jbe@19: 'if (lf_initiative_expanded["' .. name .. '"]) {' .. bsw/jbe@19: 'lf_initiative_expanded["' .. name .. '"]=false;' .. bsw/jbe@19: 'document.getElementById("' .. name .. '_content").innerHTML=" ";' .. bsw/jbe@19: 'document.getElementById("' .. name .. '").style.display="none";' .. bsw/jbe@19: '} else {' .. bsw/jbe@19: 'lf_initiative_expanded["' .. name .. '"] = true;' .. bsw/jbe@19: 'document.getElementById("' .. name .. '").style.display="block"; ' .. bsw/jbe@19: 'var hourglass_el = document.getElementById("' .. icon_name .. '");' .. bsw/jbe@19: 'var hourglass_src = hourglass_el.src;' .. bsw/jbe@19: 'hourglass_el.src = "' .. encode.url{ static = "icons/16/connect.png" } .. '";' .. bsw/jbe@19: 'partialMultiLoad(' .. bsw/jbe@19: '{ trace: "trace", system_error: "system_error", ' .. name .. '_content: "default" },' .. bsw/jbe@19: '{},' .. bsw/jbe@19: '"error",' .. bsw/jbe@19: '"' .. 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: '{},' .. bsw/jbe@19: '{},' .. bsw/jbe@19: 'function() {' .. bsw/jbe@19: 'hourglass_el.src = hourglass_src;' .. bsw/jbe@19: '},' .. bsw/jbe@19: 'function() {' .. bsw/jbe@19: 'hourglass_el.src = hourglass_src;' .. bsw/jbe@19: '}' .. bsw/jbe@19: '); ' .. bsw/jbe@19: '}' .. bsw/jbe@19: 'return(false);' bsw/jbe@19: else bsw/jbe@19: onclick = "document.location.href = document.getElementById('" .. link_name .. "').href;" bsw/jbe@19: end bsw/jbe@19: end bsw/jbe@19: local module = "initiative" bsw/jbe@19: local view = "show" bsw/jbe@19: local id = initiative.id bsw/jbe@19: local params = {} bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: name = name, bsw/jbe@19: class = "ui_tabs_accordeon_head", bsw/jbe@19: id = head_name, bsw/jbe@19: onclick = onclick, bsw/jbe@19: }, bsw/jbe@19: content = function() bsw/jbe@19: bsw@29: ui.list{ bsw@29: attr = { class = "nohover" }, bsw@29: records = { { a = 1} }, bsw@29: columns = { bsw@29: { bsw@29: field_attr = { style = "width: 4em; padding: 0;"}, bsw@29: content = function() bsw@29: if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then bsw@29: ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank } bsw@29: elseif web20 then bsw@29: ui.image{ bsw@29: attr = { bsw@29: width = 16, bsw@29: height = 16, bsw@29: id = icon_name, bsw@29: style = "float: left;" bsw@29: }, bsw@29: static = "icons/16/script.png" bsw@29: } bsw@29: else bsw@29: slot.put(" ") bsw@29: end bsw@29: end bsw@29: }, bsw/jbe@19: bsw@29: { bsw@29: field_attr = { style = "width: 110px; padding: 0;"}, bsw@29: content = function() bsw/jbe@48: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@29: if initiative.issue.ranks_available then bsw@29: if initiative.negative_votes and initiative.positive_votes then bsw@29: local max_value = initiative.issue.voter_count bsw@29: ui.bargraph{ bsw@29: max_value = max_value, bsw@29: width = 100, bsw@29: bars = { bsw@29: { color = "#0a0", value = initiative.positive_votes }, bsw@29: { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, bsw@29: { color = "#a00", value = initiative.negative_votes }, bsw@29: } bsw@29: } bsw@29: else bsw@29: slot.put(" ") bsw@29: end bsw@29: else bsw@29: slot.put(_"Counting of votes") bsw@29: end bsw@29: elseif initiative.issue.population then bsw@29: local max_value = initiative.issue.population bsw/jbe@19: ui.bargraph{ bsw/jbe@19: max_value = max_value, bsw/jbe@19: width = 100, poelzi@159: quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), poelzi@159: quorum_color = "#00F", bsw/jbe@19: bars = { bsw@29: { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, bsw@29: { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@29: { color = "#eee", value = max_value - (initiative.supporter_count or 0) }, bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: else bsw/jbe@19: slot.put(" ") bsw/jbe@19: end bsw/jbe@19: end bsw@29: }, bsw@29: bsw@29: { bsw@29: field_attr = { style = "padding: 0;"}, bsw/jbe@19: content = function() bsw@29: local link_class bsw@29: if initiative.revoked then bsw@29: link_class = "revoked" bsw/jbe@19: end bsw@29: ui.link{ bsw@29: attr = { id = link_name, class = link_class }, bsw@29: content = function() bsw@29: local name bsw@29: if initiative.name_highlighted then bsw@29: name = encode.highlight(initiative.name_highlighted) bsw@29: else bsw@29: name = encode.html(initiative.shortened_name) bsw@29: end bsw@29: slot.put(name) bsw@29: end, bsw@29: module = module, bsw@29: view = view, bsw@29: id = id, bsw@29: params = params, bsw@29: } bsw@29: bsw@29: if initiative.issue.state == "new" then bsw@29: ui.image{ bsw@29: static = "icons/16/new.png" bsw@29: } bsw@29: end bsw@29: if initiative.is_supporter then bsw@29: slot.put(" ") bsw@29: local label = _"You are supporting this initiative" bsw@29: ui.image{ bsw@29: attr = { alt = label, title = label }, bsw@29: static = "icons/16/thumb_up_green.png" bsw@29: } bsw@29: end bsw@29: if initiative.is_potential_supporter then bsw@29: slot.put(" ") bsw@29: local label = _"You are potential supporter of this initiative" bsw@29: ui.image{ bsw@29: attr = { alt = label, title = label }, bsw@29: static = "icons/16/thumb_up.png" bsw@29: } bsw@29: end bsw@29: if initiative.is_initiator then bsw@29: slot.put(" ") bsw@29: local label = _"You are iniator of this initiative" bsw@29: ui.image{ bsw@29: attr = { alt = label, title = label }, bsw@29: static = "icons/16/user_edit.png" bsw@29: } bsw@29: end bsw@29: bsw@29: end bsw/jbe@19: } bsw/jbe@19: } bsw@29: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: bsw/jbe@19: if ui.is_partial_loading_enabled() then bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: id = name, bsw/jbe@19: class = "ui_tabs_accordeon_content", bsw/jbe@19: style = not expanded and "display: none;" or nil bsw/jbe@19: }, bsw/jbe@19: content = function() bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { id = name .. "_content", style = "clear: left;" }, bsw/jbe@19: content = function() bsw/jbe@19: execute.view{ bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show_partial", bsw/jbe@19: params = { bsw/jbe@19: initiative = initiative, bsw/jbe@19: expanded = expanded bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end