Skip to content

Commit 740d2be

Browse files
committed
fix: initialize standalone toolbar
1 parent 787375f commit 740d2be

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

system/Debug/Toolbar/Views/toolbar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ var ciDebugBar = {
88
icon: null,
99

1010
init: function () {
11-
this.toolbarContainer = document.getElementById("toolbarContainer");
11+
// Standalone debugbar pages do not have #toolbarContainer, use body as fallback.
12+
this.toolbarContainer = document.getElementById("toolbarContainer") || document.body;
1213
this.toolbar = document.getElementById("debug-bar");
1314
this.icon = document.getElementById("debug-icon");
1415

system/Debug/Toolbar/Views/toolbar.tpl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<script id="toolbar_js">
2929
var ciSiteURL = "<?= rtrim(site_url(), '/') ?>"
3030
<?= file_get_contents(__DIR__ . '/toolbar.js') ?>
31+
<?= file_get_contents(__DIR__ . '/toolbarstandalone.js') ?>
3132
</script>
3233
<div id="debug-icon" class="debug-bar-ndisplay">
3334
<a id="debug-icon-link">
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Bootstrap for standalone Debug Toolbar pages (?debugbar_time=...).
3+
*/
4+
5+
if (! document.getElementById('debugbar_loader')) {
6+
if (typeof loadDoc !== 'function') {
7+
window.loadDoc = function (time) {
8+
if (isNaN(time)) {
9+
return;
10+
}
11+
12+
localStorage.setItem('debugbar-time', time);
13+
localStorage.setItem('debugbar-time-new', time);
14+
window.location.href = ciSiteURL + '?debugbar_time=' + time;
15+
};
16+
}
17+
18+
(function () {
19+
function initStandaloneToolbar() {
20+
if (typeof ciDebugBar !== 'object') {
21+
return;
22+
}
23+
24+
if (! document.getElementById('debug-bar') || ! document.getElementById('debug-icon')) {
25+
return;
26+
}
27+
28+
ciDebugBar.init();
29+
}
30+
31+
if (document.readyState === 'loading') {
32+
document.addEventListener('DOMContentLoaded', initStandaloneToolbar, false);
33+
} else {
34+
initStandaloneToolbar();
35+
}
36+
})();
37+
}

user_guide_src/source/changelogs/v4.7.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Bugs Fixed
3434

3535
- **ContentSecurityPolicy:** Fixed a bug where ``generateNonces()`` produces corrupted JSON responses by replacing CSP nonce placeholders with unescaped double quotes. The method now automatically JSON-escapes nonce attributes when the response Content-Type is JSON.
3636
- **Session:** Fixed a bug in ``MemcachedHandler`` where the constructor incorrectly threw an exception when ``savePath`` was not empty.
37+
- **Toolbar:** Fixed a bug where the standalone toolbar page loaded from ``?debugbar_time=...`` was not interactive.
3738

3839
See the repo's
3940
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

0 commit comments

Comments
 (0)