diff options
| author | Aymeric Augustin | 2013-11-18 08:43:25 +0100 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-18 08:43:40 +0100 |
| commit | efdd0ce313052dc390c0001b5dc8c56e888514d0 (patch) | |
| tree | 99dd848bfe0b8fcae0f6f798aadfa96acbdef99f /debug_toolbar | |
| parent | 7697c93692cb251acec174e91431f6aa2b1ebce5 (diff) | |
| download | django-debug-toolbar-efdd0ce313052dc390c0001b5dc8c56e888514d0.tar.bz2 | |
Add an option to collapse the toolbar by default.
Fix #258.
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/middleware.py | 2 | ||||
| -rw-r--r-- | debug_toolbar/settings.py | 1 | ||||
| -rw-r--r-- | debug_toolbar/static/debug_toolbar/js/toolbar.js | 6 |
3 files changed, 6 insertions, 3 deletions
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){ |
