Fixes sidebar sliding

main
Yasen Pramatarov 2024-08-05 20:21:34 +03:00
parent 54b998a1a8
commit 0cfa9d811e
2 changed files with 18 additions and 3 deletions

View File

@ -14,9 +14,13 @@ document.addEventListener('DOMContentLoaded', function () {
function applySavedState() {
var savedState = localStorage.getItem('sidebarState');
if (savedState === 'collapsed') {
toggleButton.value = ">>";
toggleButton.textContent = ">>";
sidebar.classList.add('collapsed');
mainContent.classList.add('expanded');
} else {
toggleButton.value = "<<";
toggleButton.textContent = "<<";
sidebar.classList.remove('collapsed');
mainContent.classList.remove('expanded');
}
@ -29,6 +33,14 @@ document.addEventListener('DOMContentLoaded', function () {
// toggle sidebar and main content
sidebar.classList.toggle('collapsed');
mainContent.classList.toggle('expanded');
// Toggle the value between ">>" and "<<"
if (toggleButton.value === ">>") {
toggleButton.value = "<<";
toggleButton.textContent = "<<";
} else {
toggleButton.value = ">>";
toggleButton.textContent = ">>";
}
// Update with the new state
updateStorage();

View File

@ -2,9 +2,12 @@
<!-- Menu -->
<div class="menu-container">
<ul class="menu-left">
<button class="btn btn-secondary" type="button" id="toggleSidebarButton">
sidebar
</button>
<div class="container">
<div class="row">
<div class="col-4"><img src="" />JILO</div>
<div class="col-4"><button class="btn btn-secondary" type="button" id="toggleSidebarButton" value=">>"></button></div>
</div>
</div>
<li><a href="index.php">home</a></li>
<?php if ( isset($_SESSION['username']) ) { ?>