192 lines
5.9 KiB
PHP
192 lines
5.9 KiB
PHP
</div> <!-- /admin-content -->
|
|
</div> <!-- /admin-wrapper -->
|
|
|
|
<footer class="admin-footer">
|
|
<style>
|
|
.admin-footer {
|
|
background: #f1f1f1;
|
|
border-top: 1px solid #ddd;
|
|
padding: 15px 20px;
|
|
margin-left: 220px;
|
|
text-align: center;
|
|
color: #555;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.admin-footer a {
|
|
color: #0073aa;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.admin-footer a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
@media (max-width: 782px) {
|
|
.admin-footer {
|
|
margin-left: 36px;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<p>
|
|
© <?php echo date('Y'); ?> <strong>togethere.cloud</strong> | Panel Administracyjny
|
|
</p>
|
|
</footer>
|
|
|
|
<script>
|
|
(function () {
|
|
const sidebar = document.querySelector('.admin-sidebar');
|
|
if (!sidebar) {
|
|
return;
|
|
}
|
|
|
|
const storageKey = 'admin-sidebar-scroll-top';
|
|
const hashPrefix = '#admin-sidebar-scroll=';
|
|
let restoreTimerId = null;
|
|
let stopRestoreLock = false;
|
|
|
|
const getSavedScroll = () => {
|
|
const savedValue = sessionStorage.getItem(storageKey);
|
|
if (savedValue === null) {
|
|
return null;
|
|
}
|
|
|
|
const scrollTop = Number.parseInt(savedValue, 10);
|
|
return Number.isNaN(scrollTop) ? null : scrollTop;
|
|
};
|
|
|
|
const getHashScroll = () => {
|
|
if (!window.location.hash || !window.location.hash.startsWith(hashPrefix)) {
|
|
return null;
|
|
}
|
|
|
|
const rawValue = window.location.hash.slice(hashPrefix.length);
|
|
const scrollTop = Number.parseInt(rawValue, 10);
|
|
return Number.isNaN(scrollTop) ? null : scrollTop;
|
|
};
|
|
|
|
const getRestoreTarget = () => {
|
|
const hashScroll = getHashScroll();
|
|
if (hashScroll !== null) {
|
|
return hashScroll;
|
|
}
|
|
|
|
return getSavedScroll();
|
|
};
|
|
|
|
const saveScroll = () => {
|
|
sessionStorage.setItem(storageKey, String(sidebar.scrollTop));
|
|
};
|
|
|
|
const updateLinkWithScroll = (link) => {
|
|
if (!(link instanceof HTMLAnchorElement) || !link.href) {
|
|
return;
|
|
}
|
|
|
|
const url = new URL(link.href, window.location.origin);
|
|
url.hash = 'admin-sidebar-scroll=' + String(sidebar.scrollTop);
|
|
link.href = url.toString();
|
|
};
|
|
|
|
const clearHashScroll = () => {
|
|
if (getHashScroll() === null || !window.history.replaceState) {
|
|
return;
|
|
}
|
|
|
|
const cleanUrl = window.location.pathname + window.location.search;
|
|
window.history.replaceState(window.history.state, document.title, cleanUrl);
|
|
};
|
|
|
|
const clearRestoreLock = () => {
|
|
if (restoreTimerId !== null) {
|
|
window.clearInterval(restoreTimerId);
|
|
restoreTimerId = null;
|
|
}
|
|
};
|
|
|
|
const restoreScroll = () => {
|
|
const scrollTop = getRestoreTarget();
|
|
if (scrollTop === null) {
|
|
return;
|
|
}
|
|
|
|
sidebar.scrollTop = scrollTop;
|
|
};
|
|
|
|
const startRestoreLock = () => {
|
|
const scrollTop = getRestoreTarget();
|
|
clearRestoreLock();
|
|
|
|
if (scrollTop === null) {
|
|
return;
|
|
}
|
|
|
|
stopRestoreLock = false;
|
|
restoreScroll();
|
|
window.requestAnimationFrame(restoreScroll);
|
|
|
|
let attempts = 0;
|
|
restoreTimerId = window.setInterval(() => {
|
|
if (stopRestoreLock) {
|
|
clearRestoreLock();
|
|
return;
|
|
}
|
|
|
|
attempts += 1;
|
|
if (Math.abs(sidebar.scrollTop - scrollTop) > 1) {
|
|
sidebar.scrollTop = scrollTop;
|
|
}
|
|
|
|
if (attempts >= 30) {
|
|
clearRestoreLock();
|
|
}
|
|
}, 50);
|
|
|
|
window.setTimeout(clearHashScroll, 0);
|
|
};
|
|
|
|
const releaseRestoreLock = () => {
|
|
stopRestoreLock = true;
|
|
clearRestoreLock();
|
|
};
|
|
|
|
startRestoreLock();
|
|
|
|
sidebar.addEventListener('scroll', saveScroll, { passive: true });
|
|
sidebar.addEventListener('wheel', saveScroll, { passive: true });
|
|
sidebar.addEventListener('touchmove', saveScroll, { passive: true });
|
|
sidebar.addEventListener('pointerdown', releaseRestoreLock, { passive: true });
|
|
sidebar.addEventListener('mouseenter', releaseRestoreLock, { passive: true });
|
|
|
|
sidebar.querySelectorAll('a[href]').forEach((link) => {
|
|
link.addEventListener('click', function () {
|
|
updateLinkWithScroll(link);
|
|
}, true);
|
|
link.addEventListener('mousedown', function () {
|
|
updateLinkWithScroll(link);
|
|
}, true);
|
|
link.addEventListener('pointerdown', function () {
|
|
updateLinkWithScroll(link);
|
|
}, true);
|
|
link.addEventListener('click', saveScroll, true);
|
|
link.addEventListener('mousedown', saveScroll, true);
|
|
link.addEventListener('pointerdown', saveScroll, true);
|
|
});
|
|
|
|
document.addEventListener('visibilitychange', function () {
|
|
if (document.visibilityState === 'hidden') {
|
|
saveScroll();
|
|
}
|
|
});
|
|
|
|
window.addEventListener('load', startRestoreLock);
|
|
window.addEventListener('pageshow', startRestoreLock);
|
|
window.addEventListener('pagehide', saveScroll);
|
|
window.addEventListener('beforeunload', saveScroll);
|
|
})();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|