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

View File

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