add the fix to the other files too

This commit is contained in:
Fabian Franz 2017-12-02 19:21:14 +01:00
parent 28b6dff793
commit b2f0465cec
3 changed files with 38 additions and 25 deletions

View File

@ -36,9 +36,24 @@
* @param value encoded text
* @return string decoded text
*/
function htmlDecode(value) {
return $("<textarea/>").html(value).text();
}
function htmlDecode(value) {
return $("<textarea/>").html(value).text();
}
/**
* Check if sessionStorage is available
*
* @return boolean if sessionStorage is available.
*/
function checkSessionStorageExists() {
if ('sessionStorage' in window) {
if (window.sessionStorage != null) {
return true;
}
}
return false;
}
/**
*
@ -240,17 +255,19 @@ function watchScrollPosition() {
}
// link on scroll event handler
$(window).scroll(function(){
sessionStorage.setItem('scrollpos', current_location()+"|"+$(window).scrollTop());
});
if (checkSessionStorageExists()) {
$(window).scroll(function(){
sessionStorage.setItem('scrollpos', current_location()+"|"+$(window).scrollTop());
});
// move to last known position on page load
$( document ).ready(function() {
var scrollpos = sessionStorage.getItem('scrollpos');
if (scrollpos != null) {
if (scrollpos.split('|')[0] == current_location()) {
$(window).scrollTop(scrollpos.split('|')[1]);
// move to last known position on page load
$( document ).ready(function() {
var scrollpos = sessionStorage.getItem('scrollpos');
if (scrollpos != null) {
if (scrollpos.split('|')[0] == current_location()) {
$(window).scrollTop(scrollpos.split('|')[1]);
}
}
}
});
});
}
}

View File

@ -228,14 +228,6 @@ function addMultiSelectClearUI() {
});
}
function checkSessionStorageExists() {
if ('sessionStorage' in window) {
if (window.sessionStorage != null) {
return true;
}
}
return false;
}
/**
* setup form help buttons

View File

@ -151,17 +151,21 @@ $pagetitle .= html_safe(sprintf(' | %s.%s', $config['system']['hostname'], $conf
$('[id*="show_all_help"]').toggleClass("fa-toggle-on fa-toggle-off");
$('[id*="show_all_help"]').toggleClass("text-success text-danger");
if ($('[id*="show_all_help"]').hasClass("fa-toggle-on")) {
sessionStorage.setItem('all_help_preset', 1);
if (checkSessionStorageExists()) {
sessionStorage.setItem('all_help_preset', 1);
}
$('[for*="help_for"]').addClass("show");
$('[for*="help_for"]').removeClass("hidden");
} else {
sessionStorage.setItem('all_help_preset', 0);
if (checkSessionStorageExists()) {
sessionStorage.setItem('all_help_preset', 0);
}
$('[for*="help_for"]').addClass("hidden");
$('[for*="help_for"]').removeClass("show");
}
event.preventDefault();
});
if (sessionStorage.getItem('all_help_preset') == 1) {
if (checkSessionStorageExists() && sessionStorage.getItem('all_help_preset') == 1) {
// show all help messages when preset was stored
$('[id*="show_all_help"]').toggleClass("fa-toggle-on fa-toggle-off");
$('[id*="show_all_help"]').toggleClass("text-success text-danger");