Skip to content

Commit e6fde5e

Browse files
committed
restore applyStyle()
This reverts commit 87364f7.
1 parent b139099 commit e6fde5e

File tree

6 files changed

+16
-5
lines changed

6 files changed

+16
-5
lines changed

debug_toolbar/panels/profiling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from colorsys import hsv_to_rgb
44
from pstats import Stats
55

6+
from django.templatetags.static import static
67
from django.utils.html import format_html
78
from django.utils.translation import gettext_lazy as _
89

debug_toolbar/panels/sql/panel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pprint import saferepr
55

66
from django.db import connections
7+
from django.templatetags.static import static
78
from django.urls import path
89
from django.utils.translation import gettext_lazy as _, ngettext_lazy as __
910

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const djdt = {
4444
inner.previousElementSibling.remove(); // Remove AJAX loader
4545
inner.innerHTML = data.content;
4646
$$.executeScripts(data.scripts);
47+
$$.applyStyle('padding-left');
48+
$$.applyStyle('background-color');
4749
});
4850
}
4951
}
@@ -285,6 +287,7 @@ window.djdt = {
285287
init: djdt.init,
286288
close: djdt.hide_one_level,
287289
cookie: djdt.cookie,
290+
applyStyle: djdt.applyStyle,
288291
};
289292

290293
if (document.readyState !== "loading") {

debug_toolbar/static/debug_toolbar/js/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ const $$ = {
3232
document.head.appendChild(el);
3333
});
3434
},
35+
applyStyle(name) {
36+
const selector = '#djDebug [data-' + name + ']';
37+
document.querySelectorAll(selector).forEach(function(element) {
38+
element.style[name] = element.getAttribute('data-' + name);
39+
});
40+
},
3541
};
3642

3743
function ajax(url, init) {

debug_toolbar/templates/debug_toolbar/panels/profiling.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{% for call in func_list %}
1515
<tr class="{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %}" id="profilingMain_{{ call.id }}">
1616
<td>
17-
<div style="padding-left:{{ call.indent }}px">
17+
<div data-padding-left="{{ call.indent }}px">
1818
{% if call.has_subfuncs %}
1919
<button type="button" class="djProfileToggleDetails djToggleSwitch" data-toggle-name="profilingMain" data-toggle-id="{{ call.id }}">-</button>
2020
{% else %}

debug_toolbar/templates/debug_toolbar/panels/sql.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ul>
33
{% for alias, info in databases %}
44
<li>
5-
<strong><span class="djdt-color" style="background-color:rgb({{ info.rgb_color|join:', ' }})"></span> {{ alias }}</strong>
5+
<strong><span class="djdt-color" data-background-color="rgb({{ info.rgb_color|join:', ' }})"></span> {{ alias }}</strong>
66
{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %}
77
{% if info.similar_count %}
88
{% blocktrans with count=info.similar_count trimmed %}
@@ -40,21 +40,21 @@
4040
<tbody>
4141
{% for query in queries %}
4242
<tr class="{% if query.is_slow %} djDebugRowWarning{% endif %}" id="sqlMain_{{ forloop.counter }}">
43-
<td><span class="djdt-color" style="background-color:rgb({{ query.rgb_color|join:', '}})"></span></td>
43+
<td><span class="djdt-color" data-background-color"rgb({{ query.rgb_color|join:', '}})"></span></td>
4444
<td class="djdt-toggle">
4545
<button type="button" class="djToggleSwitch" data-toggle-name="sqlMain" data-toggle-id="{{ forloop.counter }}">+</button>
4646
</td>
4747
<td>
4848
<div class="djDebugSql">{{ query.sql|safe }}</div>
4949
{% if query.similar_count %}
5050
<strong>
51-
<span class="djdt-color" style="background-color:{{ query.similar_color }}"></span>
51+
<span class="djdt-color" data-background-color"{{ query.similar_color }}"></span>
5252
{% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %}
5353
</strong>
5454
{% endif %}
5555
{% if query.duplicate_count %}
5656
<strong>
57-
<span class="djdt-color" style="background-color:{{ query.duplicate_color }}"></span>
57+
<span class="djdt-color" data-background-color"{{ query.duplicate_color }}"></span>
5858
{% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %}
5959
</strong>
6060
{% endif %}

0 commit comments

Comments
 (0)