Skip to content

Commit

Permalink
New option to collapse Console panel's snippets pane. Fix undefined i…
Browse files Browse the repository at this point in the history
…ndex when updating to recent versions where snippets are moved to disk.
  • Loading branch information
adrianbj committed Apr 28, 2020
1 parent d780c69 commit 4ee5a98
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
5 changes: 2 additions & 3 deletions TracyDebugger.module.php
Expand Up @@ -32,7 +32,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with several PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/topic/12208-tracy-debugger/',
'version' => '4.21.8',
'version' => '4.21.9',
'autoload' => 9999, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand Down Expand Up @@ -4066,8 +4066,7 @@ public function getModuleConfigInputfields(array $data) {
public function ___upgrade($fromVersion, $toVersion) {

// move old snippets from Tracy module settings DB table to filesystem
if($this->data['snippets']) {
$this->wire('log')->save('testing', 'move snippets');
if(isset($this->data['snippets'])) {
$snippetsPath = $this->wire('config')->paths->site.$this->data['snippetsPath'].'/TracyDebugger/snippets/';
if(!file_exists($snippetsPath)) wireMkdir($snippetsPath, true);
foreach(json_decode($this->data['snippets']) as $snippet) {
Expand Down
22 changes: 20 additions & 2 deletions panels/ConsolePanel.php
Expand Up @@ -318,6 +318,23 @@ public function getPanel() {
tracyConsole.tce.focus();
},
toggleSnippetsPane: function() {
if(tracyConsole.getCookie('tracySnippetsPaneCollapsed') == 1) {
document.cookie = "tracySnippetsPaneCollapsed=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
document.getElementById("tracyConsoleMainContainer").style.width = "calc(100% - 290px)";
document.getElementById("tracySnippetsContainer").classList.remove('tracyHidden');
document.getElementById("snippetPaneToggle").innerHTML = ">";
}
else {
var expires = new Date();
expires.setMinutes(expires.getMinutes() + (10 * 365 * 24 * 60));
document.cookie = "tracySnippetsPaneCollapsed=1;expires="+expires.toGMTString()+";path=/";
document.getElementById("tracyConsoleMainContainer").style.width = "100%";
document.getElementById("tracySnippetsContainer").classList.add('tracyHidden');
document.getElementById("snippetPaneToggle").innerHTML = "<";
}
},
toggleKeyboardShortcuts: function() {
document.getElementById("consoleKeyboardShortcuts").classList.toggle('tracyHidden');
},
Expand Down Expand Up @@ -1082,7 +1099,7 @@ function loadFAIfNotAlreadyLoaded() {
<div style="position: relative; height: calc(100% - 45px)">
<div id="tracyConsoleMainContainer" style="position: absolute; height: 100%">
<div id="tracyConsoleMainContainer" style="position: absolute; height: 100%; width: '.($this->wire('input')->cookie->tracySnippetsPaneCollapsed ? '100%' : 'calc(100% - 290px)').'">
<div id="consoleKeyboardShortcuts" class="keyboardShortcuts tracyHidden">';
$panel = 'console';
Expand Down Expand Up @@ -1125,6 +1142,7 @@ function loadFAIfNotAlreadyLoaded() {
</select>
</span>
<input id="runInjectButton" title="&bull; Run (CTRL/CMD + Enter)&#10;&bull; Clear & Run (ALT/OPT + Enter)&#10;&bull; Reload from Disk, Clear & Run&#10;(CTRL/CMD + ALT/OPT + Enter)" type="submit" onclick="tracyConsole.processTracyCode()" value="' . (!$this->tracyIncludeCode || $this->tracyIncludeCode['when'] === 'off' ? 'Run' : 'Inject') . '" />
<span id="snippetPaneToggle" title="Toggle snippets pane" style="float:right; font-weight: bold; cursor: pointer" onclick="tracyConsole.toggleSnippetsPane()">'.($this->wire('input')->cookie->tracySnippetsPaneCollapsed ? '<' : '>').'</span>
</div>
<div id="tracyConsoleContainer" class="split" style="height: 100%; min-height: '.$codeLineHeight.'px">
Expand All @@ -1146,7 +1164,7 @@ function loadFAIfNotAlreadyLoaded() {
</div>
</div>
<div id="tracySnippetsContainer" style="position: absolute; right:0; margin: 0 0 0 10px; width: 275px; height: calc(100% - 15px)">
<div id="tracySnippetsContainer" style="position: absolute; right:0; margin: 0 0 0 10px; width: 275px; height: calc(100% - 15px);"'.($this->wire('input')->cookie->tracySnippetsPaneCollapsed ? ' class="tracyHidden"' : '').'">
<div style="padding-bottom:5px">
Sort: <a href="#" onclick="tracyConsole.sortList(\'alphabetical\')">alphabetical</a>&nbsp;|&nbsp;<a href="#" onclick="tracyConsole.sortList(\'chronological\')">chronological</a>
</div>
Expand Down
3 changes: 0 additions & 3 deletions styles.css
Expand Up @@ -793,16 +793,13 @@ ul.pw-info-links {
}

#tracy-debug [id^="tracy-debug-panel-"][class*="tracy-mode-"] #tracyConsoleMainContainer {
float: left;
width: calc(100% - 290px);
float: left;
display: block;
}

#tracy-debug [id^="tracy-debug-panel-"][class*="tracy-mode-window"] #tracyConsoleMainContainer {
float: left;
width: calc(100% - 240px) !important;
float: left;
display: block;
}

Expand Down

0 comments on commit 4ee5a98

Please sign in to comment.