Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit c1ff030

Browse files
committed
Add feature - close debug bar with cookie save
1 parent ace343c commit c1ff030

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

module/ggrachdev.debugbar/classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ public static function render(Debugger $debugger): string {
9696

9797
self::addViewInRightSlot('<a target="_blank" href="/bitrix/admin/site_edit.php?LID=' . \SITE_ID . '&lang=ru" class="ggrach__debug_bar__right__item type-notice-success" title="Текущая страница">' . SITE_CHARSET . '</a>');
9898

99+
$debugBarIsClosed = $_COOKIE['ggrach_debug_bar_is_close'] == 'true';
100+
99101
self::addViewInRightSlot('<a href="javascript:void(0);" data-click="toggle_debug_bar" class="ggrach__debug_bar__right__item ggrach__debug_bar__right__item_close ggrach-debug-bar-color-black" title="Скрыть / Раскрыть фильтр">&#215;</a>');
100102

101-
$view = '<section class="ggrach__overlay" style="display: none;"></section><section class="ggrach__debug_bar">';
103+
$view = '<section class="ggrach__overlay" style="display: none;"></section><section class="ggrach__debug_bar '.($debugBarIsClosed ? 'hide-debug-bar' : '').'">';
102104

103105
$view .= self::renderLeftView();
104106
$view .= self::renderRightView();

module/ggrachdev.debugbar/install/js/initializer.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Ggrach.DebugBar = {
3838
});
3939
}
4040

41-
4241
document.querySelector('[data-click="toggle_debug_bar"]').addEventListener('click', function (e) {
4342
e.preventDefault();
4443
Ggrach.DebugBar.toggle();
@@ -57,15 +56,26 @@ Ggrach.DebugBar = {
5756
},
5857

5958
toggle: function () {
59+
if(this.getDebugBar().classList.contains('hide-debug-bar'))
60+
{
61+
BX.setCookie('ggrach_debug_bar_is_close', 'false', {expires: (60 * 60 * 2), path: '/'});
62+
}
63+
else
64+
{
65+
BX.setCookie('ggrach_debug_bar_is_close', 'true', {expires: (60 * 60 * 2), path: '/'});
66+
}
67+
6068
this.getDebugBar().classList.toggle('hide-debug-bar');
6169
},
6270

6371
hide: function () {
6472
this.getDebugBar().classList.add('hide-debug-bar');
73+
BX.setCookie('ggrach_debug_bar_is_close', 'true', {expires: (60 * 60 * 2), path: '/'});
6574
},
6675

6776
show: function () {
6877
this.getDebugBar().classList.remove('hide-debug-bar');
78+
BX.setCookie('ggrach_debug_bar_is_close', 'false', {expires: (60 * 60 * 2), path: '/'});
6979
}
7080
};
7181

0 commit comments

Comments
 (0)