From 65658b148908c628f053a1e023f98f705148b180 Mon Sep 17 00:00:00 2001
From: Tobias Bengfort
Date: Thu, 30 Aug 2018 20:37:06 +0200
Subject: [PATCH 1/6] use element for template contexts
not: not supported in edge
https://caniuse.com/#feat=details
---
debug_toolbar/static/debug_toolbar/css/toolbar.css | 11 +----------
.../static/debug_toolbar/js/toolbar.template.js | 11 -----------
.../templates/debug_toolbar/panels/templates.html | 14 ++++++++------
3 files changed, 9 insertions(+), 27 deletions(-)
delete mode 100644 debug_toolbar/static/debug_toolbar/js/toolbar.template.js
diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css
index 6aa4f7156..74528a06d 100644
--- a/debug_toolbar/static/debug_toolbar/css/toolbar.css
+++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css
@@ -314,7 +314,7 @@
padding-right:.5em;
}
-#djDebug .djTemplateHideContextDiv {
+#djDebug .djTemplateContext {
background-color:#fff;
}
@@ -423,15 +423,6 @@
}
-#djDebug a.djTemplateShowContext, #djDebug a.djTemplateShowContext span.toggleArrow {
- color:#999;
-}
-
-#djDebug a.djTemplateShowContext:hover, #djDebug a.djTemplateShowContext:hover span.toggleArrow {
- color:#000;
- cursor:pointer;
-}
-
#djDebug .djDebugSqlWrap {
position:relative;
}
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js
deleted file mode 100644
index fcddc9307..000000000
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js
+++ /dev/null
@@ -1,11 +0,0 @@
-(function ($) {
- var uarr = String.fromCharCode(0x25b6),
- darr = String.fromCharCode(0x25bc);
-
- $('a.djTemplateShowContext').on('click', function(event) {
- event.preventDefault();
- var arrow = $(this).children('.toggleArrow');
- arrow.html(arrow.html() == uarr ? darr : uarr);
- $(this).parent().next().toggle();
- });
-})(djdt.jQuery);
diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html
index a39cede00..fcfa2d6f8 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/templates.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html
@@ -18,8 +18,10 @@ {% blocktrans count templates|length as template_count %}Template{% plural %
{{ template.template.origin_name|addslashes }}
{% if template.context %}
-
- {{ template.context }}
+
+ {% trans "Toggle context" %}
+ {{ template.context }}
+
{% endif %}
{% endfor %}
@@ -34,13 +36,13 @@ {% blocktrans count context_processors|length as context_processors_count %}
{% for key, value in context_processors.items %}
{{ key|escape }}
-
- {{ value|escape }}
+
+ {% trans "Toggle context" %}
+ {{ value|escape }}
+
{% endfor %}
{% else %}
{% trans "None" %}
{% endif %}
-
-
From 970a6d4728eae24641ae26fd4f01fb552eb6e94d Mon Sep 17 00:00:00 2001
From: Tobias Bengfort
Date: Fri, 31 Aug 2018 14:17:49 +0200
Subject: [PATCH 2/6] rm .djDebugToggle
This is duplicated functionality. You can already toggle the entries
using .djToggleSwitch
---
debug_toolbar/panels/sql/utils.py | 4 ++--
debug_toolbar/static/debug_toolbar/js/toolbar.sql.js | 5 -----
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/debug_toolbar/panels/sql/utils.py b/debug_toolbar/panels/sql/utils.py
index c0bd4f4e0..197e4849c 100644
--- a/debug_toolbar/panels/sql/utils.py
+++ b/debug_toolbar/panels/sql/utils.py
@@ -30,8 +30,8 @@ def reformat_sql(sql):
def swap_fields(sql):
expr = r'SELECT (...........*?) FROM'
subs = (r'SELECT '
- r'••• '
- r'\1 '
+ r'••• '
+ r'\1 '
r'FROM')
return re.sub(expr, subs, sql)
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js
index aec16d510..959f39a2d 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js
@@ -1,9 +1,4 @@
(function ($) {
- $('#djDebug a.djDebugToggle').on('click', function(event) {
- event.preventDefault();
- $(this).parent().find('.djDebugCollapsed').toggle();
- $(this).parent().find('.djDebugUncollapsed').toggle();
- });
djdt.applyStyle('background-color');
djdt.applyStyle('left');
djdt.applyStyle('width');
From aebcf7b1552b6b965ebd9c912ce79cd5f80ea495 Mon Sep 17 00:00:00 2001
From: Tobias Bengfort
Date: Fri, 31 Aug 2018 14:44:49 +0200
Subject: [PATCH 3/6] rm djDebugHoverable
AFAIU it is never used because the background-color is always
overwritten by applyStyle
---
debug_toolbar/static/debug_toolbar/css/toolbar.css | 7 -------
debug_toolbar/static/debug_toolbar/js/toolbar.js | 5 -----
debug_toolbar/templates/debug_toolbar/panels/cache.html | 2 +-
debug_toolbar/templates/debug_toolbar/panels/sql.html | 4 ++--
4 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css
index 74528a06d..34b143b8a 100644
--- a/debug_toolbar/static/debug_toolbar/css/toolbar.css
+++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css
@@ -532,13 +532,6 @@
#djDebug .djDebugEndTransaction div.djDebugLineChart strong {
border-right: 1px solid #94b24d;
}
-#djDebug .djDebugHover div.djDebugLineChart strong {
- background-color: #000;
-}
-#djDebug .djDebugInTransaction.djDebugHover div.djDebugLineChart strong {
- background-color: #94b24d;
-}
-
#djDebug .djdt-panelContent ul.djdt-stats {
position: relative;
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js
index 678192f8c..7a158deef 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js
@@ -188,11 +188,6 @@
} else {
djdt.show_toolbar(false);
}
- $('#djDebug .djDebugHoverable').on('hover', function(){
- $(this).addClass('djDebugHover');
- }, function(){
- $(this).removeClass('djDebugHover');
- });
djdt.isReady = true;
$.each(djdt.events.ready, function(_, callback){
callback(djdt);
diff --git a/debug_toolbar/templates/debug_toolbar/panels/cache.html b/debug_toolbar/templates/debug_toolbar/panels/cache.html
index 014e5f621..39c9089b8 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/cache.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/cache.html
@@ -59,7 +59,7 @@ {% trans "Calls" %}
{{ call.kwargs|escape }} |
{{ call.backend }} |
-
+
|
{{ call.trace }} |
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index ccede1664..05af3d43f 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -26,7 +26,7 @@
{% for query in queries %}
-
+
| |
+
@@ -66,7 +66,7 @@
{% endif %}
|
-
+
|
From 081ee0bd3d67a20485d6cbbf216554d119571ecb Mon Sep 17 00:00:00 2001
From: Tobias Bengfort
Date: Tue, 4 Sep 2018 18:10:31 +0200
Subject: [PATCH 4/6] do not close debugwindow twice
this is already handled in the close.djDebug event listener
---
debug_toolbar/static/debug_toolbar/js/toolbar.js | 5 -----
1 file changed, 5 deletions(-)
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js
index 7a158deef..3cdb5b269 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js
@@ -82,11 +82,6 @@
var message = ''+xhr.status+': '+xhr.statusText+' ';
$('#djDebugWindow').html(message).show();
});
-
- $('#djDebugWindow').on('click', 'a.djDebugBack', function(event) {
- event.preventDefault();
- $(this).parent().parent().hide();
- });
});
// Used by the cache, profiling and SQL panels
From 5c3880263d9ebfa16d9f81f6929bec3d0ffd1853 Mon Sep 17 00:00:00 2001
From: Tobias Bengfort
Date: Wed, 5 Sep 2018 21:55:56 +0200
Subject: [PATCH 5/6] do not remove .djdt-active twice
already done in close.djDebug handler
---
debug_toolbar/static/debug_toolbar/js/toolbar.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js
index 3cdb5b269..a6ed95112 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js
@@ -15,7 +15,6 @@
var current = $('#djDebug #' + this.className);
if (current.is(':visible')) {
$(document).trigger('close.djDebug');
- $(this).parent().removeClass('djdt-active');
} else {
$('.djdt-panelContent').hide(); // Hide any that are already open
var inner = current.find('.djDebugPanelContent .djdt-scroll'),
@@ -45,7 +44,6 @@
$('#djDebug').on('click', 'a.djDebugClose', function(event) {
event.preventDefault();
$(document).trigger('close.djDebug');
- $('#djDebugToolbar li').removeClass('djdt-active');
});
$('#djDebug').on('click', '.djDebugPanelButton input[type=checkbox]', function() {
djdt.cookie.set($(this).attr('data-cookie'), $(this).prop('checked') ? 'on' : 'off', {
From 02d19b6dd1bd2eb8bbbf6023caa3106bcda0863c Mon Sep 17 00:00:00 2001
From: Tobias Bengfort
Date: Wed, 5 Sep 2018 22:09:07 +0200
Subject: [PATCH 6/6] more explicit closing
---
.../static/debug_toolbar/js/toolbar.js | 58 +++++++++----------
1 file changed, 26 insertions(+), 32 deletions(-)
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js
index a6ed95112..296e1b4bc 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js
@@ -14,9 +14,13 @@
}
var current = $('#djDebug #' + this.className);
if (current.is(':visible')) {
- $(document).trigger('close.djDebug');
+ djdt.hide_panels();
} else {
- $('.djdt-panelContent').hide(); // Hide any that are already open
+ djdt.hide_panels();
+
+ current.show();
+ $(this).parent().addClass('djdt-active');
+
var inner = current.find('.djDebugPanelContent .djdt-scroll'),
store_id = $('#djDebug').data('store-id');
if (store_id && inner.children().length === 0) {
@@ -36,14 +40,11 @@
$('#djDebugWindow').html(message).show();
});
}
- current.show();
- $('#djDebugToolbar li').removeClass('djdt-active');
- $(this).parent().addClass('djdt-active');
}
});
$('#djDebug').on('click', 'a.djDebugClose', function(event) {
event.preventDefault();
- $(document).trigger('close.djDebug');
+ djdt.hide_one_level();
});
$('#djDebug').on('click', '.djDebugPanelButton input[type=checkbox]', function() {
djdt.cookie.set($(this).attr('data-cookie'), $(this).prop('checked') ? 'on' : 'off', {
@@ -159,22 +160,7 @@
}
});
$(document).on('close.djDebug', function() {
- // If a sub-panel is open, close that
- if ($('#djDebugWindow').is(':visible')) {
- $('#djDebugWindow').hide();
- return;
- }
- // If a panel is open, close that
- if ($('.djdt-panelContent').is(':visible')) {
- $('.djdt-panelContent').hide();
- $('#djDebugToolbar li').removeClass('djdt-active');
- return;
- }
- // Otherwise, just minimize the toolbar
- if ($('#djDebugToolbar').is(':visible')) {
- djdt.hide_toolbar(true);
- return;
- }
+ djdt.hide_one_level();
});
if (djdt.cookie.get('djdt') == 'hide') {
djdt.hide_toolbar(false);
@@ -186,18 +172,15 @@
callback(djdt);
});
},
- close: function() {
- $(document).trigger('close.djDebug');
- return false;
- },
- hide_toolbar: function(setCookie) {
- // close any sub panels
+ hide_panels: function() {
$('#djDebugWindow').hide();
- // close all panels
$('.djdt-panelContent').hide();
$('#djDebugToolbar li').removeClass('djdt-active');
- // finally close toolbar
+ },
+ hide_toolbar: function(setCookie) {
+ djdt.hide_panels();
$('#djDebugToolbar').hide('fast');
+
var handle = $('#djDebugToolbarHandle');
handle.show();
// set handle position
@@ -206,8 +189,10 @@
handleTop = Math.min(handleTop, window.innerHeight - handle.outerHeight() - 10);
handle.css({top: handleTop + 'px'});
}
+
// Unbind keydown
$(document).off('keydown.djDebug');
+
if (setCookie) {
djdt.cookie.set('djdt', 'hide', {
path: '/',
@@ -215,11 +200,20 @@
});
}
},
+ hide_one_level: function() {
+ if ($('#djDebugWindow').is(':visible')) {
+ $('#djDebugWindow').hide();
+ } else if ($('.djdt-panelContent').is(':visible')) {
+ djdt.hide_panels();
+ } else {
+ djdt.hide_toolbar(true);
+ }
+ },
show_toolbar: function(animate) {
// Set up keybindings
$(document).on('keydown.djDebug', function(e) {
if (e.keyCode == 27) {
- djdt.close();
+ djdt.hide_one_level();
}
});
$('#djDebugToolbarHandle').hide();
@@ -284,7 +278,7 @@
$.extend(publicAPI, {
show_toolbar: djdt.show_toolbar,
hide_toolbar: djdt.hide_toolbar,
- close: djdt.close,
+ close: djdt.hide_one_level,
cookie: djdt.cookie,
applyStyle: djdt.applyStyle
});
|