Skip to content

Commit

Permalink
Prevent debug breaking in front-end
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed Mar 18, 2017
1 parent 93841e1 commit 6a6b209
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
5 changes: 2 additions & 3 deletions administrator/templates/atum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,9 @@

</div>

<div id="debug-wrapper"></div>
<jdoc:include type="modules" name="debug" style="none" />

</div>

<jdoc:include type="modules" name="debug" style="none" />

</body>
</html>
25 changes: 25 additions & 0 deletions media/plg_system_debug/js/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

(function( Joomla, document ) {
"use strict";

document.addEventListener('DOMContentLoaded', function() {
Joomla.toggleContainer = function(name)
{
var e = document.getElementById(name); // MooTools might not be available ;)
e.style.display = (e.style.display == 'none') ? 'block' : 'none';
};

var sidebarWrapper = document.getElementById('sidebar-wrapper'),
debugWrapper = document.getElementById('system-debug');
if (sidebarWrapper && debugWrapper) {
debugWrapper.style.marginLeft = '60px';
}
});

}( Joomla, document ));
1 change: 1 addition & 0 deletions media/plg_system_debug/js/debug.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions plugins/system/debug/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function onAfterDispatch()
if ((JDEBUG || $this->debugLang) && $this->isAuthorisedDisplayDebug())
{
JHtml::_('stylesheet', 'system/debug.css', array('version' => 'auto', 'relative' => true));
JHtml::_('script', 'plg_system_debug/debug.min.js', array('version' => 'auto', 'relative' => true));
}

// Only if debugging is enabled for SQL query popovers.
Expand Down Expand Up @@ -254,13 +255,6 @@ public function onAfterRespond()

$html = array();

// Some "mousewheel protecting" JS.
$html[] = "<script>function toggleContainer(name)
{
var e = document.getElementById(name);// MooTools might not be available ;)
e.style.display = (e.style.display == 'none') ? 'block' : 'none';
}</script>";

$html[] = '<div id="system-debug" class="profiler">';

$html[] = '<h1>' . JText::_('PLG_DEBUG_TITLE') . '</h1>';
Expand Down Expand Up @@ -324,7 +318,7 @@ public function onAfterRespond()

$html[] = '</div>';

echo str_replace('<div id="debug-wrapper"></div>', implode('', $html) . '<div id="debug-wrapper"></div>', $contents);
echo str_replace('</body>', implode('', $html) . '</body>', $contents);
}

/**
Expand Down Expand Up @@ -426,7 +420,7 @@ protected function display($item, array $errors = array())

$html = array();

$js = "toggleContainer('dbg_container_" . $item . "');";
$js = "Joomla.toggleContainer('dbg_container_" . $item . "');";

$class = 'dbg-header' . $status;

Expand Down

0 comments on commit 6a6b209

Please sign in to comment.