1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-07-24 10:12:54 +02:00

use SessionStorage to remember flag

This commit is contained in:
Barry vd. Heuvel
2024-03-19 19:22:43 +01:00
parent 1a551f462d
commit bbdd3075a0
2 changed files with 11 additions and 2 deletions

View File

@@ -1058,7 +1058,11 @@ if (typeof(PhpDebugBar) == 'undefined') {
var AjaxHandler = PhpDebugBar.AjaxHandler = function(debugbar, headerName, autoShow) {
this.debugbar = debugbar;
this.headerName = headerName || 'phpdebugbar';
this.autoShow = typeof(autoShow) == 'undefined' ? true : autoShow;
if (sessionStorage.getItem('phpdebugbar-ajaxhandler-autoshow') !== null) {
this.autoShow = JSON.parse(sessionStorage.getItem('phpdebugbar-ajaxhandler-autoshow'));
} else {
this.autoShow = typeof(autoShow) == 'undefined' ? true : autoShow;
}
};
$.extend(AjaxHandler.prototype, {
@@ -1099,6 +1103,11 @@ if (typeof(PhpDebugBar) == 'undefined') {
return Object.prototype.toString.call(response) == '[object XMLHttpRequest]'
},
setAutoShow: function(autoshow) {
this.autoShow = autoshow;
sessionStorage.setItem('phpdebugbar-ajaxhandler-autoshow', JSON.stringify(autoshow));
},
/**
* Checks if the HEADER-id exists and loads the dataset using the open handler
*

View File

@@ -670,7 +670,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
this.$autoshow = $('<input type=checkbox>')
.on('click', function() {
if (window.phpdebugbar.ajaxHandler) {
window.phpdebugbar.ajaxHandler.autoShow = $(this).is(':checked');
window.phpdebugbar.ajaxHandler.setAutoShow($(this).is(':checked'));
}
});