mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
When going back a page, scroll to the last known vertical position
This is only needed for JS-enhanced links. Without javascript to mess it up, the browser handles this 100% correctly by itself.
This commit is contained in:
parent
203bd5070c
commit
075b8f67fe
@ -145,3 +145,22 @@ function characterCount()
|
|||||||
{
|
{
|
||||||
return $("#id_status").val().length + $("#id_spoiler_text").val().length;
|
return $("#id_status").val().length + $("#id_spoiler_text").val().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function savePlace()
|
||||||
|
{
|
||||||
|
sessionStorage.setItem("lastScrollPos", window.scrollY);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function restorePlace(ev)
|
||||||
|
{
|
||||||
|
var lastScrollPos = sessionStorage.getItem('lastScrollPos');
|
||||||
|
Intercooler.ready(function (elt)
|
||||||
|
{
|
||||||
|
if (elt[0].tagName == 'BODY')
|
||||||
|
{
|
||||||
|
window.scrollTo(0, lastScrollPos);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -40,7 +40,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
<body class="has-navbar-fixed-top" ic-history-elt="true"
|
<body class="has-navbar-fixed-top" ic-history-elt="true"
|
||||||
ic-global-include='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'>
|
ic-global-include='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'
|
||||||
|
ic-on-beforeSend="savePlace()">
|
||||||
<div id="page-load-indicator"> </div>
|
<div id="page-load-indicator"> </div>
|
||||||
{% block navbar %}
|
{% block navbar %}
|
||||||
<nav class="navbar is-fixed-top" role="navigation"
|
<nav class="navbar is-fixed-top" role="navigation"
|
||||||
@ -199,6 +200,8 @@
|
|||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
document.addEventListener('DOMContentLoaded', menuPrepare);
|
document.addEventListener('DOMContentLoaded', menuPrepare);
|
||||||
|
$(document).on('handle.onpopstate.ic',
|
||||||
|
restorePlace);
|
||||||
</script>
|
</script>
|
||||||
{% block page_scripts_inline %}
|
{% block page_scripts_inline %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user