Add fixed scroll position when navigating calendar views (Z#177488) (#2385)

* add fixed scroll position when navigating calendar views

* change from local to sessionStorage

* add check for sessionStorage
This commit is contained in:
Richard Schreiber
2021-12-16 13:36:10 +01:00
committed by GitHub
parent 94a7d02ab1
commit 8fcc314f09
6 changed files with 24 additions and 12 deletions

View File

@@ -180,6 +180,12 @@ $(function () {
$("body").removeClass("nojs");
var scrollpos = sessionStorage ? sessionStorage.getItem('scrollpos') : 0;
if (scrollpos) {
window.scrollTo(0, scrollpos);
sessionStorage.removeItem('scrollpos');
}
$(".accordion-radio").click(function() {
var $input = $("input", this);
if (!$input.prop("checked")) $input.prop('checked', true).trigger("change");
@@ -321,12 +327,18 @@ $(function () {
$(this).slideToggle(300).attr("aria-expanded", true);
});
}
if (sessionStorage) {
$("[data-save-scrollpos]").click(function () {
sessionStorage.setItem('scrollpos', window.scrollY);
});
}
$("#monthselform select").change(function () {
$(this).closest("form").get(0).submit();
if (sessionStorage) sessionStorage.setItem('scrollpos', window.scrollY);
this.form.submit();
});
$("#monthselform input").on("dp.change", function () {
if ($(this).data("DateTimePicker")) { // prevent submit after dp init
if (sessionStorage) sessionStorage.setItem('scrollpos', window.scrollY);
this.form.submit();
}
});