Module: check_mk
Branch: master
Commit: 3d265081ac84d324964236159720b0b70898e8e8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d265081ac84d3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 20 18:14:11 2010 +0200
Fixed repositioning the sidebar scroll state after refreshing the page
---
ChangeLog | 1 +
web/htdocs/sidebar.js | 37 +++++++++++++++++++++++++++++++++++++
web/htdocs/sidebar.py | 2 +-
3 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e32a509..8239c9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
user
* Setting doctype in sidebar frame now
* Fixed invalid sidebar css height/width definition
+ * Fixed repositioning the sidebar scroll state after refreshing the page
1.1.8:
Checks & Agents:
diff --git a/web/htdocs/sidebar.js b/web/htdocs/sidebar.js
index 2b6ad97..e829401 100644
--- a/web/htdocs/sidebar.js
+++ b/web/htdocs/sidebar.js
@@ -682,3 +682,40 @@ function toggle_folder(o, folderId) {
next = null;
img = null;
}
+
+/************************************************
+ * Save/Restore scroll position
+ *************************************************/
+
+function setCookie(cookieName, value,expiredays) {
+ var exdate = new Date();
+ exdate.setDate(exdate.getDate() + expiredays);
+ document.cookie = cookieName + "=" + escape(value) +
+ ((expiredays == null) ? "" : ";expires=" +
exdate.toUTCString());
+}
+
+function getCookie(cookieName) {
+ if(document.cookie.length == 0)
+ return null;
+
+ var cookieStart = document.cookie.indexOf(cookieName + "=");
+ if(cookieStart == -1)
+ return null;
+
+ cookieStart = cookieStart + cookieName.length + 1;
+ var cookieEnd = document.cookie.indexOf(";", cookieStart);
+ if(cookieEnd == -1)
+ cookieEnd = document.cookie.length;
+ return unescape(document.cookie.substring(cookieStart, cookieEnd));
+}
+
+function initScrollPos() {
+ var scrollPos = getCookie('sidebarScrollPos');
+ if(!scrollPos)
+ scrollPos = 0;
+ document.getElementById('side_content').scrollTop = scrollPos;
+}
+
+function storeScrollPos() {
+ setCookie('sidebarScrollPos',
document.getElementById('side_content').scrollTop, null);
+}
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index d715b68..8dec507 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -133,7 +133,7 @@ def page_side(h):
<script type="text/javascript"
src="check_mk.js"></script>
<script type="text/javascript"
src="sidebar.js"></script>
</head>
-<body class="side">
+<body class="side" onload="initScrollPos()"
onunload="storeScrollPos()">
<div id="check_mk_sidebar">""")
views.html = h