bsw/jbe@0: bsw/jbe@19: local initiative = param.get("initiative", "table") bsw/jbe@19: local supporter = Supporter:by_pk(initiative.id, app.session.member.id) bsw/jbe@19: bsw/jbe@19: local unique_string = multirand.string(16, '0123456789abcdef') bsw/jbe@19: bsw/jbe@19: bsw/jbe@19: local partial = { bsw/jbe@19: routing = { bsw/jbe@19: default = { bsw/jbe@19: mode = "redirect", bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show_support", bsw/jbe@19: id = initiative.id bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@0: bsw/jbe@19: local routing = { bsw/jbe@19: default = { bsw/jbe@19: mode = "redirect", bsw/jbe@19: module = request.get_module(), bsw/jbe@19: view = request.get_view(), bsw/jbe@19: id = param.get_id_cgi(), bsw/jbe@19: params = param.get_all_cgi() bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: bsw/jbe@19: if not initiative.issue.fully_frozen and not initiative.issue.closed then bsw/jbe@19: if supporter then bsw/jbe@19: if not supporter:has_critical_opinion() then bsw@10: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: class = "head head_supporter", bsw/jbe@19: style = "cursor: pointer;", bsw/jbe@19: onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'block';" bsw/jbe@19: }, bsw@10: content = function() bsw/jbe@19: ui.image{ bsw/jbe@19: static = "icons/16/thumb_up_green.png" bsw/jbe@0: } bsw/jbe@19: slot.put(_"Your are supporter") bsw/jbe@19: ui.image{ bsw/jbe@19: static = "icons/16/dropdown.png" bsw/jbe@19: } bsw@10: end bsw@10: } bsw@10: else bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: class = "head head_potential_supporter", bsw/jbe@19: style = "cursor: pointer;", bsw/jbe@19: onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'block';" bsw/jbe@19: }, bsw/jbe@19: content = function() bsw/jbe@19: ui.image{ bsw/jbe@19: static = "icons/16/thumb_up.png" bsw/jbe@19: } bsw/jbe@19: slot.put(_"Your are potential supporter") bsw/jbe@19: ui.image{ bsw/jbe@19: static = "icons/16/dropdown.png" bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "content", id = "support_content_" .. unique_string .. "" }, bsw/jbe@19: content = function() bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: class = "close", bsw/jbe@19: style = "cursor: pointer;", bsw/jbe@19: onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'none';" bsw/jbe@19: }, bsw@10: content = function() bsw/jbe@19: ui.image{ static = "icons/16/cross.png" } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: if supporter then bsw/jbe@19: ui.link{ bsw/jbe@19: image = { static = "icons/16/thumb_down_red.png" }, bsw/jbe@19: text = _"Remove my support from this initiative", bsw/jbe@19: module = "initiative", bsw/jbe@19: action = "remove_support", bsw/jbe@19: id = initiative.id, bsw/jbe@19: routing = routing, bsw/jbe@19: partial = partial bsw/jbe@0: } bsw/jbe@19: else bsw/jbe@19: end bsw/jbe@0: end bsw/jbe@19: } bsw/jbe@19: else bsw/jbe@19: if not initiative.revoked then bsw/jbe@19: local params = param.get_all_cgi() bsw/jbe@19: params.dyn = nil bsw/jbe@19: ui.link{ bsw/jbe@19: image = { static = "icons/16/thumb_up_green.png" }, bsw/jbe@19: text = _"Support this initiative", bsw/jbe@19: module = "initiative", bsw/jbe@19: action = "add_support", bsw/jbe@19: id = initiative.id, bsw/jbe@19: routing = routing, bsw/jbe@19: partial = partial bsw/jbe@19: } bsw/jbe@4: end bsw@10: end bsw/jbe@19: end bsw@10: