From 52ead496617bf781e0f11909ea7a7b023e9dc95d Mon Sep 17 00:00:00 2001
From: Gavin Wahl
Date: Sun, 11 Jan 2015 15:24:25 -0700
Subject: [PATCH 1/2] Remove the use of inline scripts for CSP compatibility
---
debug_toolbar/static/debug_toolbar/js/jquery_existing.js | 1 +
debug_toolbar/static/debug_toolbar/js/jquery_post.js | 1 +
debug_toolbar/static/debug_toolbar/js/jquery_pre.js | 1 +
debug_toolbar/templates/debug_toolbar/base.html | 6 +++---
4 files changed, 6 insertions(+), 3 deletions(-)
create mode 100644 debug_toolbar/static/debug_toolbar/js/jquery_existing.js
create mode 100644 debug_toolbar/static/debug_toolbar/js/jquery_post.js
create mode 100644 debug_toolbar/static/debug_toolbar/js/jquery_pre.js
diff --git a/debug_toolbar/static/debug_toolbar/js/jquery_existing.js b/debug_toolbar/static/debug_toolbar/js/jquery_existing.js
new file mode 100644
index 000000000..085495a65
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/js/jquery_existing.js
@@ -0,0 +1 @@
+var djdt = {jQuery: jQuery};
diff --git a/debug_toolbar/static/debug_toolbar/js/jquery_post.js b/debug_toolbar/static/debug_toolbar/js/jquery_post.js
new file mode 100644
index 000000000..d94e6755a
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/js/jquery_post.js
@@ -0,0 +1 @@
+var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;
diff --git a/debug_toolbar/static/debug_toolbar/js/jquery_pre.js b/debug_toolbar/static/debug_toolbar/js/jquery_pre.js
new file mode 100644
index 000000000..d94199668
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/js/jquery_pre.js
@@ -0,0 +1 @@
+var _djdt_define_backup = window.define; window.define = undefined;
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index c64628350..1c1f4a15b 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -5,11 +5,11 @@
{% if toolbar.config.JQUERY_URL %}
-
+
-
+
{% else %}
-
+
{% endif %}
Date: Sun, 11 Jan 2015 16:08:03 -0700
Subject: [PATCH 2/2] Remove the use of inline styles for CSP compatibility
---
debug_toolbar/static/debug_toolbar/css/print.css | 3 +++
debug_toolbar/static/debug_toolbar/css/toolbar.css | 13 +++++++++++++
debug_toolbar/static/debug_toolbar/js/toolbar.js | 10 +++++++++-
.../static/debug_toolbar/js/toolbar.profiling.js | 1 +
.../static/debug_toolbar/js/toolbar.sql.js | 3 +++
.../static/debug_toolbar/js/toolbar.timer.js | 7 +++++--
debug_toolbar/templates/debug_toolbar/base.html | 10 ++++------
.../templates/debug_toolbar/panels/cache.html | 2 +-
.../templates/debug_toolbar/panels/profiling.html | 5 ++---
.../templates/debug_toolbar/panels/request.html | 8 ++++----
.../templates/debug_toolbar/panels/sql.html | 10 +++++-----
.../templates/debug_toolbar/panels/templates.html | 4 ++--
.../templates/debug_toolbar/panels/timer.html | 10 +++++-----
13 files changed, 57 insertions(+), 29 deletions(-)
create mode 100644 debug_toolbar/static/debug_toolbar/css/print.css
diff --git a/debug_toolbar/static/debug_toolbar/css/print.css b/debug_toolbar/static/debug_toolbar/css/print.css
new file mode 100644
index 000000000..c9241e90b
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/css/print.css
@@ -0,0 +1,3 @@
+#djDebug {
+ display:none;
+}
diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css
index a02768fb0..57e42e4cb 100644
--- a/debug_toolbar/static/debug_toolbar/css/toolbar.css
+++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css
@@ -646,3 +646,16 @@
display: none;
}
}
+
+#djDebug .width-20 {
+ width: 20%;
+}
+#djDebug .width-60 {
+ width: 60%;
+}
+#djDebug .width-60 {
+ width: 60%;
+}
+#djDebug .highlighted {
+ background-color: lightgrey;
+}
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js
index 7bd10454a..62752cd21 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js
@@ -285,13 +285,21 @@
return value;
}
+ },
+ applyStyle: function(name) {
+ $('#djDebug [data-' + name + ']').each(function() {
+ var css = {};
+ css[name] = $(this).data(name);
+ $(this).css(css);
+ });
}
};
$.extend(publicAPI, {
show_toolbar: djdt.show_toolbar,
hide_toolbar: djdt.hide_toolbar,
close: djdt.close,
- cookie: djdt.cookie
+ cookie: djdt.cookie,
+ applyStyle: djdt.applyStyle
});
$(document).ready(djdt.init);
})(djdt.jQuery, djdt);
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js
index 1018e9b41..2389bace9 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js
@@ -17,4 +17,5 @@
subcalls.hide();
}
});
+ djdt.applyStyle('padding-left');
})(djdt.jQuery);
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js
index e470ac8fa..109a74d0e 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js
@@ -4,4 +4,7 @@
$(this).parent().find('.djDebugCollapsed').toggle();
$(this).parent().find('.djDebugUncollapsed').toggle();
});
+ djdt.applyStyle('background-color');
+ djdt.applyStyle('left');
+ djdt.applyStyle('width');
})(djdt.jQuery);
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
index cc9d6ae70..0c0f4a5bb 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
@@ -24,14 +24,17 @@
if (endStat) {
// Render a start through end bar
$row.html('' + stat.replace('Start', '') + ' ' +
- ' ' +
+ ' ' +
'' + (perf.timing[stat] - timingOffset) + ' (+' + (perf.timing[endStat] - perf.timing[stat]) + ') ');
+ $row.find('strong').css({width: getCSSWidth(stat, endStat)});
} else {
// Render a point in time
$row.html('' + stat + ' ' +
- ' ' +
+ ' ' +
'' + (perf.timing[stat] - timingOffset) + ' ');
+ $row.find('strong').css({width: 2});
}
+ $row.find('djDebugLineChart').css({left: getLeft(stat) + '%'});
$('#djDebugBrowserTimingTableBody').append($row);
}
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index 1c1f4a15b..0f4d36b63 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -1,7 +1,5 @@
{% load i18n %}{% load static from staticfiles %}{% load url from future %}
-
+
{% if toolbar.config.JQUERY_URL %}
@@ -12,10 +10,10 @@
{% endif %}
-