Skip to content

Commit d3231d2

Browse files
committed
Toogle views hints (if enabled) by default ci-label
1 parent 33b7967 commit d3231d2

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

system/Debug/Toolbar/Views/toolbar.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var ciDebugBar = {
1717
ciDebugBar.createListeners();
1818
ciDebugBar.setToolbarState();
1919
ciDebugBar.setToolbarPosition();
20-
ciDebugBar.setViewsHints();
20+
ciDebugBar.toogleViewsHints();
2121
},
2222

2323
//--------------------------------------------------------------------
@@ -35,15 +35,7 @@ var ciDebugBar = {
3535
//--------------------------------------------------------------------
3636

3737
showTab: function()
38-
{
39-
// Get the target tab, if any
40-
var tab = this.getAttribute('data-tab');
41-
42-
// Check our current state.
43-
var state = document.getElementById(tab).style.display;
44-
45-
if (tab == undefined) return true;
46-
38+
{
4739
// Hide all tabs
4840
var tabs = document.querySelectorAll('#debug-bar .tab');
4941

@@ -58,14 +50,25 @@ var ciDebugBar = {
5850
for (var i=0; i < labels.length; i++)
5951
{
6052
ciDebugBar.removeClass(labels[i], 'active');
53+
}
54+
55+
// Get the target tab, if any
56+
var tab = document.getElementById(this.getAttribute('data-tab'));
57+
58+
// If the label have not a tab stops here
59+
if (! tab) {
60+
return;
6161
}
6262

63+
// Check our current state.
64+
var state = tab.style.display;
65+
6366
// Show/hide the selected tab
6467
if (state != 'block')
6568
{
66-
document.getElementById(tab).style.display = 'block';
69+
tab.style.display = 'block';
6770
ciDebugBar.addClass(this.parentNode, 'active');
68-
}
71+
}
6972
},
7073

7174
//--------------------------------------------------------------------
@@ -149,11 +152,20 @@ var ciDebugBar = {
149152

150153
//--------------------------------------------------------------------
151154

152-
setViewsHints: function()
155+
toogleViewsHints: function()
153156
{
154-
var views = document.getElementsByClassName('debug-view');
155-
var btn = document.getElementById('toogle-debug-views');
157+
var btn = document.querySelector('[data-tab=ci-views]');
156158

159+
// If the Views Collector is inactive stops here
160+
if (! btn)
161+
{
162+
return;
163+
}
164+
165+
btn = btn.parentNode;
166+
167+
var views = document.getElementsByClassName('debug-view');
168+
157169
if (ciDebugBar.readCookie('debug-view'))
158170
{
159171
for (var i = 0; i < views.length; i++)

0 commit comments

Comments
 (0)