Skip to content

Unify show/hide JS logic through the djdt-hidden class #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debug_toolbar/panels/sql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def reformat_sql(sql, with_toggle=False):
return formatted
simple = simplify(parse_sql(sql, aligned_indent=False))
uncollapsed = '<span class="djDebugUncollapsed">{}</span>'.format(simple)
collapsed = '<span class="djDebugCollapsed">{}</span>'.format(formatted)
collapsed = '<span class="djDebugCollapsed djdt-hidden">{}</span>'.format(formatted)
return collapsed + uncollapsed


Expand Down
2 changes: 0 additions & 2 deletions debug_toolbar/static/debug_toolbar/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@
}

#djDebug .djdt-panelContent {
display: none;
position: fixed;
margin: 0;
top: 0;
Expand Down Expand Up @@ -351,7 +350,6 @@
}

#djDebug .djDebugCollapsed {
display: none;
color: #333;
}

Expand Down
7 changes: 3 additions & 4 deletions debug_toolbar/static/debug_toolbar/js/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const $$ = {
});
},
show: function(element) {
element.style.display = 'block';
element.classList.remove('djdt-hidden');
},
hide: function(element) {
element.style.display = 'none';
element.classList.add('djdt-hidden');
},
toggle: function(element, value) {
if (value) {
Expand All @@ -21,8 +21,7 @@ const $$ = {
}
},
visible: function(element) {
const style = getComputedStyle(element);
return style.display !== 'none';
element.classList.contains('djdt-hidden');
},
executeScripts: function(scripts) {
scripts.forEach(function(script) {
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/templates/debug_toolbar/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
{% for panel in toolbar.panels %}
{% include "debug_toolbar/includes/panel_content.html" %}
{% endfor %}
<div id="djDebugWindow" class="djdt-panelContent"></div>
<div id="djDebugWindow" class="djdt-panelContent djdt-hidden"></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load static %}

{% if panel.has_content and panel.enabled %}
<div id="{{ panel.panel_id }}" class="djdt-panelContent">
<div id="{{ panel.panel_id }}" class="djdt-panelContent djdt-hidden">
<div class="djDebugPanelTitle">
<a href="" class="djDebugClose">×</a>
<h3>{{ panel.title }}</h3>
Expand Down
2 changes: 1 addition & 1 deletion tests/panels/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_escapes_panel_title(self):
self.assertContains(
response,
"""
<div id="CustomPanel" class="djdt-panelContent">
<div id="CustomPanel" class="djdt-panelContent djdt-hidden">
<div class="djDebugPanelTitle">
<a href="" class="djDebugClose">×</a>
<h3>Title with special chars &amp;&quot;&#39;&lt;&gt;</h3>
Expand Down
2 changes: 1 addition & 1 deletion tests/panels/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_panel_title(self):
self.assertContains(
response,
"""
<div id="SettingsPanel" class="djdt-panelContent">
<div id="SettingsPanel" class="djdt-panelContent djdt-hidden">
<div class="djDebugPanelTitle">
<a href="" class="djDebugClose">×</a>
<h3>Settings from None</h3>
Expand Down