mirror of
https://github.com/humhub/humhub.git
synced 2025-01-18 06:38:14 +01:00
Enh: use LocalStorage in panel menu
Use LocalStorage to save panel menu's state instead of cookies
This commit is contained in:
parent
d434197aee
commit
f99f993cb0
@ -13,6 +13,4 @@ HumHub Change Log (DEVELOP)
|
|||||||
- Chng: Removed `atwho` asset and dependency
|
- Chng: Removed `atwho` asset and dependency
|
||||||
- Cnng: Removed old IE support
|
- Cnng: Removed old IE support
|
||||||
- Fix #2946: Use Yii2 default timezone handling
|
- Fix #2946: Use Yii2 default timezone handling
|
||||||
|
- Enh: use LocalStorage in panel menu
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ $this->registerJsFile("@web-static/js/panelMenu.js", ['position' => yii\web\View
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
// check and set panel state from cookie
|
// check and set panel state from LocalStorage
|
||||||
checkPanelMenuCookie('<?= $this->context->id; ?>');
|
checkPanelMenuCookie('<?= $this->context->id; ?>');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -8,7 +8,7 @@ function togglePanelUp($id) {
|
|||||||
$('#' + $id + ' .panel-expand').show();
|
$('#' + $id + ' .panel-expand').show();
|
||||||
$('#' + $id).addClass('panel-collapsed');
|
$('#' + $id).addClass('panel-collapsed');
|
||||||
|
|
||||||
$.cookie('pm_' + $id, 'collapsed', 5*365);
|
localStorage.setItem('pm_' + $id, 'collapsed');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ function togglePanelDown($id) {
|
|||||||
$('#' + $id + ' .panel-collapse').show();
|
$('#' + $id + ' .panel-collapse').show();
|
||||||
$('#' + $id).removeClass('panel-collapsed');
|
$('#' + $id).removeClass('panel-collapsed');
|
||||||
|
|
||||||
$.cookie('pm_' + $id, 'expanded', 5*365);
|
localStorage.removeItem('pm_' + $id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,17 +30,9 @@ function togglePanelDown($id) {
|
|||||||
* Check and change current panel state, if necessary
|
* Check and change current panel state, if necessary
|
||||||
*/
|
*/
|
||||||
function checkPanelMenuCookie($id) {
|
function checkPanelMenuCookie($id) {
|
||||||
|
// checks if panel's saved state in LocalStorage is collapsed
|
||||||
// check if cookie exists
|
if (localStorage.getItem('pm_' + $id) === 'collapsed') {
|
||||||
if ($.cookie('pm_' + $id) == undefined) {
|
|
||||||
|
|
||||||
// if not, create new cookie with current panel state
|
|
||||||
$.cookie('pm_' + $id, 'expanded', 5*365);
|
|
||||||
} else if ($.cookie('pm_' + $id) == 'collapsed') {
|
|
||||||
|
|
||||||
// collapse panel, if cookie is 'collapsed'
|
|
||||||
$('#' + $id + ' .panel-body').css({
|
$('#' + $id + ' .panel-body').css({
|
||||||
overflow: 'hidden',
|
|
||||||
display: 'none'
|
display: 'none'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,7 +40,5 @@ function checkPanelMenuCookie($id) {
|
|||||||
$('#' + $id + ' .panel-collapse').hide();
|
$('#' + $id + ' .panel-collapse').hide();
|
||||||
$('#' + $id + ' .panel-expand').show();
|
$('#' + $id + ' .panel-expand').show();
|
||||||
$('#' + $id).addClass('panel-collapsed');
|
$('#' + $id).addClass('panel-collapsed');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user