From efdd0ce313052dc390c0001b5dc8c56e888514d0 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 18 Nov 2013 08:43:25 +0100 Subject: Add an option to collapse the toolbar by default. Fix #258. --- debug_toolbar/middleware.py | 2 ++ debug_toolbar/settings.py | 1 + debug_toolbar/static/debug_toolbar/js/toolbar.js | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 72f190e..bda784d 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -93,6 +93,8 @@ class DebugToolbarMiddleware(object): response = new_response for panel in reversed(toolbar.enabled_panels): panel.disable_instrumentation() + if toolbar.config['SHOW_COLLAPSED'] and 'djdt' not in request.COOKIES: + response.set_cookie('djdt', 'hide', 864000) if ('gzip' not in response.get('Content-Encoding', '') and response.get('Content-Type', '').split(';')[0] in _HTML_TYPES): response.content = replace_insensitive( diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index f284c76..c86688a 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -15,6 +15,7 @@ CONFIG_DEFAULTS = { 'INTERCEPT_REDIRECTS': False, 'SHOW_TOOLBAR_CALLBACK': None, 'EXTRA_SIGNALS': [], + 'SHOW_COLLAPSED': False, 'HIDE_DJANGO_SQL': True, 'SHOW_TEMPLATE_CONTEXT': True, 'TAG': 'body', diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js index 1185ef7..5b10a62 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js @@ -180,7 +180,7 @@ return; } }); - if ($.cookie('djdt')) { + if ($.cookie('djdt') == 'hide') { djdt.hide_toolbar(false); } else { djdt.show_toolbar(false); @@ -235,9 +235,9 @@ } else { $('#djDebugToolbar').show(); } - $.cookie('djdt', null, { + $.cookie('djdt', 'show', { path: '/', - expires: -1 + expires: 10 }); }, ready: function(callback){ -- cgit v1.2.3