From e28541d4888ed8318ef57ca07d58aa21f191e68c Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Fri, 24 Feb 2012 15:16:09 -0800 Subject: [PATCH] Use a css class to hide the selected dropdown choice. This makes JS dropdown implementations simpler since they have all of the choices in the DOM. --- r2/r2/public/static/css/reddit.css | 4 ++++ r2/r2/templates/navmenu.html | 15 ++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index 3ccd44961..1a0fa1ed5 100755 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -300,6 +300,10 @@ ul.flat-vert {text-align: left;} background-color: #c7def7; } +.drop-choices a.choice.selected { + display: none; +} + .dropdown.heavydrop .selected{ background: white none no-repeat scroll center right; background-image: url(../droparrow.gif); diff --git a/r2/r2/templates/navmenu.html b/r2/r2/templates/navmenu.html index 06f1e7f48..a16fd86ce 100644 --- a/r2/r2/templates/navmenu.html +++ b/r2/r2/templates/navmenu.html @@ -46,15 +46,12 @@
%for option in thing: - %if option != thing.selected: - %if thing.use_post: - ${post_link(option.title, option.base_path, option.path, - option.action_params, _sr_path=option.sr_path, - _class="choice " + option.css_class)} - %else: - ${plain_link(option.title, option.path, _sr_path = option.sr_path, - _class = "choice" + " " + option.css_class)} - %endif + <% _class = "choice " + option.css_class + (" selected" if option == thing.selected else "") %> + %if thing.use_post: + ${post_link(option.title, option.base_path, option.path, + option.action_params, _sr_path=option.sr_path, _class=_class)} + %else: + ${plain_link(option.title, option.path, _sr_path = option.sr_path, _class=_class)} %endif %endfor