Skip to content

Commit 20f235a

Browse files
committed
Restore applyStyle()
This reverts commit 87364f7.
1 parent 725d566 commit 20f235a

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ const djdt = {
278278
return value;
279279
},
280280
},
281+
applyStyle: function(name) {
282+
var selector = '#djDebug [data-' + name + ']';
283+
document.querySelectorAll(selector).forEach(function(element) {
284+
element.style[name] = element.getAttribute('data-' + name);
285+
});
286+
},
281287
};
282288
window.djdt = {
283289
show_toolbar: djdt.show_toolbar,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(function () {
2+
djdt.applyStyle('padding-left');
3+
})();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(function () {
2+
djdt.applyStyle('background-color');
3+
})();

debug_toolbar/templates/debug_toolbar/panels/profiling.html

Lines changed: 3 additions & 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 %}
@@ -32,3 +32,5 @@
3232
{% endfor %}
3333
</tbody>
3434
</table>
35+
36+
<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}" async></script>

debug_toolbar/templates/debug_toolbar/panels/sql.html

Lines changed: 6 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 %}
@@ -122,3 +122,5 @@
122122
{% else %}
123123
<p>{% trans "No SQL queries were recorded during this request." %}</p>
124124
{% endif %}
125+
126+
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" async></script>

0 commit comments

Comments
 (0)