From 34395a45b94d115e9912597a9aa7317fb87d0ebb Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 24 Sep 2013 12:48:17 +0200 Subject: [PATCH] toplevel menu template has support for dropdowns for now this is used to make the list smaller (read, less wide) --- myslice/viewutils.py | 30 ++++++++++++++++++++--------- views/static/css/topmenu.css | 5 +++-- views/templates/widget-topmenu.html | 29 +++++++++++++++++++++------- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/myslice/viewutils.py b/myslice/viewutils.py index eaa2dcb5..f00a4515 100644 --- a/myslice/viewutils.py +++ b/myslice/viewutils.py @@ -1,25 +1,37 @@ # a set of utilities to help make the global layout consistent across views +# dropdowns are kind of ad hoc for now, and limited to one level +# [ +# ### a regular first-level button +# {'label':...,'href':...}, +# ### a dropdown +# { 'label': ..., 'href'=..., 'dropdown':True, 'contents': [ { 'label':.., 'href'} ] } +# , ..] def topmenu_items (current,request=None): has_user=request.user.is_authenticated() result=[] if has_user: result.append({'label':'Platforms', 'href': '/portal/platforms/'}) - result.append({ 'label':'Dashboard', 'href': '/portal/dashboard/'}) + result.append({'label':'Dashboard', 'href': '/portal/dashboard/'}) # This should probably go in dashboard at some point - result.append({ 'label':'Request a slice', 'href': '/portal/slice_request/'}) - result.append({'label':'My Account', 'href': '/portal/account/'}) + dropdown = [] + dropdown.append({'label':'Request a slice', 'href': '/portal/slice_request/'}) + dropdown.append({'label':'My Account', 'href': '/portal/account/'}) + dropdown.append({'label':'Contact Support', 'href': '/portal/contact/'}) + result.append({'label': 'More', 'href':"#", 'dropdown':True, 'contents':dropdown}) else: result.append({'label':'Home', 'href': '/login'}) # looks like this is accessible to non-logged users result.append({'label':'Platforms', 'href': '/portal/platforms/'}) - result.append({ 'label':'Register', 'href': '/portal/register/'}) - result.append({'label':'Contact Support', 'href': '/portal/contact/'}) + result.append({'label':'Register', 'href': '/portal/register/'}) + result.append({'label':'Contact Support', 'href': '/portal/contact/'}) + # mark active for d in result: - #if d['label'].lower()find(current)>=0: d['is_active']=True - if d['label'] == current: d['is_active']=True - if not request: return result -# result.append (login_out_items [ has_user] ) + if 'dropdown' in d: + for dd in d['contents']: + if dd['label'] == current: dd['is_active']=True + else: + if d['label'] == current: d['is_active']=True return result def the_user (request): diff --git a/views/static/css/topmenu.css b/views/static/css/topmenu.css index 344acdc3..f7c78315 100644 --- a/views/static/css/topmenu.css +++ b/views/static/css/topmenu.css @@ -6,9 +6,10 @@ body { /* center the buttons vertically in the header */ div.topmenu { padding-top: 7px; } -ul.logged-in { padding-top: 10px; } +ul.logged-in { padding-top: 12px; } button#logout { /* margin-left: 8px; */ margin-bottom: 10px; } -ul.logged-in, button.logged-in { font-size: x-small; } +ul.logged-in { font-size: x-small; } +button.logged-in { font-size: small; } diff --git a/views/templates/widget-topmenu.html b/views/templates/widget-topmenu.html index 81a10c50..64030788 100644 --- a/views/templates/widget-topmenu.html +++ b/views/templates/widget-topmenu.html @@ -2,7 +2,8 @@ {% insert_str prelude "css/bootstrap.css" %} {% insert_str prelude "css/topmenu.css" %} {% insert_str prelude "js/logout.js" %} - + -- 2.43.0