Skip to content

Commit eb779a4

Browse files
committed
Add double-click panel rollup feature, thanks to @rolandtoth
1 parent 88966db commit eb779a4

File tree

4 files changed

+79
-16
lines changed

4 files changed

+79
-16
lines changed

TracyDebugger.module

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
3232
'summary' => __('Tracy debugger from Nette with several PW specific custom tools.', __FILE__),
3333
'author' => 'Adrian Jones',
3434
'href' => 'https://processwire.com/talk/topic/12208-tracy-debugger/',
35-
'version' => '4.10.7',
35+
'version' => '4.10.8',
3636
'autoload' => true,
3737
'singular' => true,
3838
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -783,7 +783,7 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
783783
$this->wire('config')->paths->TracyDebugger.'styles.css'
784784
);
785785

786-
Debugger::$customJsFiles[] = $this->wire('config')->paths->TracyDebugger.'scripts/panel-resizer.js';
786+
Debugger::$customJsFiles[] = $this->wire('config')->paths->TracyDebugger.'scripts/main.js';
787787

788788
if(in_array('fileEditor', static::$showPanels)) {
789789
// these need to be loaded here (not just in File Editor panel) so that File Editor links

scripts/main.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function tracyResizePanel(panel, type) {
2+
panel = document.getElementById("tracy-debug-panel-"+panel);
3+
panel.style.left = '0px';
4+
if(type == 'fullscreen') {
5+
panel.style.top = '0px';
6+
panel.style.height = '100vh';
7+
panel.style.width = '100vw';
8+
}
9+
else {
10+
panel.style.top = 'calc(50vh - 22px)';
11+
panel.style.height = '50vh';
12+
panel.style.width = '100vw';
13+
}
14+
}
15+
16+
// panel rollup thanks to @tpr / @rolandtoth
17+
// jQuery .on() equivalent
18+
var filterEventHandler = function (selector, callback) {
19+
return (!callback || !callback.call) ? null : function (e) {
20+
var target = e.target || e.srcElement || null;
21+
while (target && target.parentElement && target.parentElement.querySelectorAll) {
22+
var elms = target.parentElement.querySelectorAll(selector);
23+
for (var i = 0; i < elms.length; i++) {
24+
if (elms[i] === target) {
25+
e.filterdTarget = elms[i];
26+
callback.call(elms[i], e);
27+
return;
28+
}
29+
}
30+
target = target.parentElement;
31+
}
32+
};
33+
};
34+
35+
// toggle rollup state on double click
36+
document.addEventListener("dblclick", filterEventHandler(".tracy-panel h1", function (e) {
37+
e.filterdTarget.parentElement.classList.toggle("tracy-mode-rollup");
38+
}));
39+
40+
// remove rolled up state on closing the panel
41+
document.addEventListener("mouseup", filterEventHandler(".tracy-panel.tracy-mode-rollup [rel=\'close\']", function (e) {
42+
e.filterdTarget.parentElement.parentElement.classList.remove("tracy-mode-rollup");
43+
}));
44+
45+
// hide rolled up panels to allow Tracy save their position correctly
46+
window.addEventListener("beforeunload", function () {
47+
var $rollupPanels = document.querySelectorAll(".tracy-mode-rollup");
48+
49+
if($rollupPanels.length) {
50+
for(var i = 0; i < $rollupPanels.length; i++) {
51+
$rollupPanels[i].style.visibility = "hidden";
52+
$rollupPanels[i].classList.remove("tracy-mode-rollup");
53+
}
54+
}
55+
});

scripts/panel-resizer.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

styles.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ body.tracyHidden:before {
108108
padding-right: 35px !important;
109109
color: #444444 !important;
110110
text-transform: none !important;
111+
user-select: none;
111112
}
112113

113114
#tracy-debug input:not(.ace_search_field) {
@@ -1203,4 +1204,25 @@ ul.pw-info-links {
12031204

12041205
.ace_editor, .ace_editor * {
12051206
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace !important;
1207+
}
1208+
1209+
/*panel rollup*/
1210+
#tracy-debug .tracy-panel.tracy-mode-rollup {
1211+
min-height: 0 !important;
1212+
resize: none !important;
1213+
max-height: 47px !important;
1214+
width: auto !important;
1215+
min-width: unset !important;
1216+
}
1217+
#tracy-debug .tracy-panel.tracy-mode-rollup .tracy-inner,
1218+
#tracy-debug .tracy-panel.tracy-mode-rollup .resizeIcons,
1219+
#tracy-debug .tracy-panel.tracy-mode-rollup a[rel="window"] {
1220+
display: none;
1221+
}
1222+
#tracy-debug .tracy-panel.tracy-mode-rollup h1 {
1223+
border-bottom: none !important;
1224+
border-right: 1rem solid transparent;
1225+
}
1226+
#tracy-debug .tracy-panel.tracy-mode-rollup h1 a {
1227+
pointer-events: none;
12061228
}

0 commit comments

Comments
 (0)