mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 06:48:01 -05:00
Created new toggle_button def, reduced code duplication for save/hide buttons
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
<%namespace file="printable.html" import="arrow, score"/>
|
||||
<%namespace file="link.html" import="tagline"/>
|
||||
<%namespace file="utils.html" import="plain_link" />
|
||||
<%namespace file="utils.compact" import="icon_button" />
|
||||
<%namespace file="utils.compact" import="icon_button, toggle_button" />
|
||||
<%namespace file="printablebuttons.html" import="state_button" />
|
||||
|
||||
<div class="thing link id-${thing._fullname}">
|
||||
@@ -124,23 +124,11 @@ there's also a discussion going on here:
|
||||
</div>
|
||||
<%def name="hide_button()">
|
||||
%if c.user_is_loggedin:
|
||||
%if thing.hidden:
|
||||
${icon_button("Hide","hide-icon", onclick="change_state(this, 'hide', hide_thing)", outer_class="hide-button", style="display: none;")}
|
||||
${icon_button("Unhide","unhide-icon", onclick="change_state(this, 'unhide', hide_thing)", outer_class="unhide-button")}
|
||||
%else:
|
||||
${icon_button("Hide","hide-icon", onclick="change_state(this, 'hide', hide_thing)", outer_class="hide-button", herp="derp")}
|
||||
${icon_button("Unhide","unhide-icon", onclick="change_state(this, 'unhide', hide_thing)", outer_class="unhide-button", style="display: none;")}
|
||||
%endif
|
||||
${toggle_button("hide", thing.hidden)}
|
||||
%endif
|
||||
</%def>
|
||||
<%def name="save_button()">
|
||||
%if c.user_is_loggedin:
|
||||
%if thing.saved:
|
||||
${icon_button("Unsave", "unsave-icon", onclick="change_state(this, 'unsave', unsave_thing, true)", outer_class="unsave-button")}
|
||||
${icon_button("Save", "save-icon", onclick="change_state(this, 'save', save_thing, true)", outer_class="save-button", style="display: none;")}
|
||||
%else:
|
||||
${icon_button("Unsave", "unsave-icon", onclick="change_state(this, 'unsave', unsave_thing, true)", outer_class="unsave-button", style="display: none;")}
|
||||
${icon_button("Save", "save-icon", onclick="change_state(this, 'save', save_thing, true)", outer_class="save-button")}
|
||||
%endif
|
||||
${toggle_button("save", thing.saved)}
|
||||
%endif
|
||||
</%def>
|
||||
@@ -19,7 +19,9 @@
|
||||
## All portions of the code written by CondeNet are Copyright (c) 2006-2010
|
||||
## CondeNet, Inc. All Rights Reserved.
|
||||
################################################################################
|
||||
|
||||
<%!
|
||||
import string
|
||||
%>
|
||||
|
||||
<%def name="icon_button(text, css_class, href='javascript:void(0)', outer_class='', **kw)">
|
||||
<a href="${href}"
|
||||
@@ -33,3 +35,24 @@
|
||||
<div class="${css_class}"></div>${text}
|
||||
</a>
|
||||
</%def>
|
||||
<%def name="toggle_button(togglename, toggled=False)">
|
||||
<%
|
||||
if toggled:
|
||||
togglestyle = {"style": "display: none;"}
|
||||
untogglestyle = {}
|
||||
else:
|
||||
togglestyle = {}
|
||||
untogglestyle = {"style": "display: none;"}
|
||||
endif
|
||||
|
||||
if togglename == "hide":
|
||||
untext = ""
|
||||
else:
|
||||
untext = "un"
|
||||
endif
|
||||
%>
|
||||
##Hide/Save
|
||||
${icon_button( string.capitalize(togglename), togglename + "-icon", onclick="change_state(this,'" + togglename + "', " + togglename + "_thing)", outer_class=togglename + "-button", **togglestyle)}
|
||||
##Unhide/Unsave
|
||||
${icon_button( "Un" + togglename, "un" + togglename + "-icon", onclick="change_state(this,'un" + togglename + "', " + untext + togglename + "_thing)", outer_class= "un" + togglename + "-button", **untogglestyle)}
|
||||
</%def>
|
||||
|
||||
Reference in New Issue
Block a user