Module: check_mk
Branch: master
Commit: 629e70ac9ba7aa4651664a1f82ad0ce680d58393
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=629e70ac9ba7aa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 17 19:11:53 2011 +0200
FIX: Fixed initial folding state on page loading on pages with multiple foldings opened
---
ChangeLog | 1 +
web/htdocs/js/check_mk.js | 57 ++++++++++++++++++++++-----------------------
web/htdocs/views.py | 7 +++--
3 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 92a39ab..7f2acd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,7 @@
* FIX: "view_name" variable missing error message when opening view.py
while using the "BI Aggregation Groups" and "Hosts" snapins in
sidebar
* FIX: Fixed styling of form input elements in IE + styling improvements
+ * FIX: Fixed initial folding state on page loading on pages with multiple foldings
opened
* Introduced basic infrastructure for multilanguage support in Multisite
* Make 'Views' snapin foldable
* Replace old main view by dashboard
diff --git a/web/htdocs/js/check_mk.js b/web/htdocs/js/check_mk.js
index 75f330d..c6d9dc6 100644
--- a/web/htdocs/js/check_mk.js
+++ b/web/htdocs/js/check_mk.js
@@ -566,33 +566,37 @@ function handleReload(url) {
// --------------------------------------------------------------------------
// BI
// --------------------------------------------------------------------------
-var tree_anim_o = null;
+//
+var fold_steps = [ 0, 10, 10, 15, 20, 30, 40, 55, 80 ];
function toggle_folding(oImg, state) {
- tree_anim_o = oImg;
- if (state) {
- oImg.src = "images/tree_10.png";
- setTimeout("set_tree_animation_step('20');", 10);
- setTimeout("set_tree_animation_step('30');", 20);
- setTimeout("set_tree_animation_step('40');", 35);
- setTimeout("set_tree_animation_step('50');", 55);
- setTimeout("set_tree_animation_step('60');", 85);
- setTimeout("set_tree_animation_step('70');", 125);
- setTimeout("set_tree_animation_step('80');", 180);
- setTimeout("set_tree_animation_step('90');", 260);
-
- }
- else {
- oImg.src = "images/tree_80.png";
- setTimeout("set_tree_animation_step('70');", 10);
- setTimeout("set_tree_animation_step('60');", 20);
- setTimeout("set_tree_animation_step('50');", 35);
- setTimeout("set_tree_animation_step('40');", 55);
- setTimeout("set_tree_animation_step('30');", 85);
- setTimeout("set_tree_animation_step('20');", 125);
- setTimeout("set_tree_animation_step('10');", 180);
- setTimeout("set_tree_animation_step('00');", 260);
+ // state
+ // 0: is currently opened and should be closed now
+ // 1: is currently closed and should be opened now
+ setTimeout("folding_step('" + oImg.id + "', " + state +
");", 0);
+}
+
+function folding_step(objId, state, step) {
+ // Initialize unset step
+ if(typeof step === 'undefined')
+ if(state == 1)
+ step = 1;
+ else
+ step = 8;
+
+ document.getElementById(objId).src = "images/tree_" + step +
"0.png";
+
+ if(state == 1) {
+ if(step == 9)
+ return;
+ step += 1;
+ } else {
+ if(step == 0)
+ return;
+ step -= 1;
}
+
+ setTimeout("folding_step('" + objId + "', " + state +
", " + step + ");", fold_steps[step]);
}
function toggle_tree_state(tree, name, oContainer) {
@@ -627,11 +631,6 @@ function toggle_subtree(oImg)
get_url(url);
}
-function set_tree_animation_step(num)
-{
- tree_anim_o.src = "images/tree_" + num + ".png";
-}
-
function toggle_foldable_container(treename, id) {
var oImg = document.getElementById('treeimg.' + treename + '.' +
id);
var oBox = document.getElementById('tree.' + treename + '.' + id);
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 6fa53db..164e657 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -539,9 +539,9 @@ function toggle_section(nr, oImg) {
var oContent = document.getElementById("ed_" + nr);
toggle_tree_state('vieweditor', nr, oContent);
if (oContent.style.display == "none")
- toggle_folding(oImg, 1);
- else
toggle_folding(oImg, 0);
+ else
+ toggle_folding(oImg, 1);
oContent = null;
}
""")
@@ -558,9 +558,10 @@ function toggle_section(nr, oImg) {
def section_footer(sid):
html.write("</div></td></tr>\n")
+ # Open the section when the user had it open last time
states = weblib.get_tree_states('vieweditor')
if states.get(str(sid), 'off') == 'on':
- html.javascript('toggle_section("%d", this)' % sid)
+ html.javascript('toggle_section("%d",
document.getElementById("img_%s"))' % (sid, sid))
# Properties
sid = 2