Skip to content

Commit efdd0ce

Browse files
committed
Add an option to collapse the toolbar by default.
Fix #258.
1 parent 7697c93 commit efdd0ce

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

debug_toolbar/middleware.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def process_response(self, request, response):
9393
response = new_response
9494
for panel in reversed(toolbar.enabled_panels):
9595
panel.disable_instrumentation()
96+
if toolbar.config['SHOW_COLLAPSED'] and 'djdt' not in request.COOKIES:
97+
response.set_cookie('djdt', 'hide', 864000)
9698
if ('gzip' not in response.get('Content-Encoding', '') and
9799
response.get('Content-Type', '').split(';')[0] in _HTML_TYPES):
98100
response.content = replace_insensitive(

debug_toolbar/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'INTERCEPT_REDIRECTS': False,
1616
'SHOW_TOOLBAR_CALLBACK': None,
1717
'EXTRA_SIGNALS': [],
18+
'SHOW_COLLAPSED': False,
1819
'HIDE_DJANGO_SQL': True,
1920
'SHOW_TEMPLATE_CONTEXT': True,
2021
'TAG': 'body',

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
return;
181181
}
182182
});
183-
if ($.cookie('djdt')) {
183+
if ($.cookie('djdt') == 'hide') {
184184
djdt.hide_toolbar(false);
185185
} else {
186186
djdt.show_toolbar(false);
@@ -235,9 +235,9 @@
235235
} else {
236236
$('#djDebugToolbar').show();
237237
}
238-
$.cookie('djdt', null, {
238+
$.cookie('djdt', 'show', {
239239
path: '/',
240-
expires: -1
240+
expires: 10
241241
});
242242
},
243243
ready: function(callback){

docs/configuration.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ Toolbar options
7070
toolbar with Angular.js, set this to ``'ng-non-bindable'`` or
7171
``'class="ng-non-bindable"'``.
7272

73+
* ``SHOW_COLLAPSED``
74+
75+
Default: ``False``
76+
77+
If changed to ``True``, the toolbar will be collapsed by default.
78+
7379
* ``SHOW_TOOLBAR_CALLBACK``
7480

7581
Default: ``None``

0 commit comments

Comments
 (0)