Module: check_mk
Branch: master
Commit: b7429379202a47c8bbecf84a3973a2db8b18d701
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b7429379202a47…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue May 22 08:04:01 2012 +0200
FIX: fix folding problems with dependent host tags
---
ChangeLog | 3 +++
web/htdocs/check_mk.css | 4 ++++
web/htdocs/forms.py | 14 +++++++-------
web/htdocs/htmllib.py | 7 ++-----
web/htdocs/js/checkmk.js | 40 +++++++++++++++++++++++++++++++++++-----
web/htdocs/pages.css | 4 ++++
6 files changed, 55 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 589bbb2..39e0d63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1.2.0b5:
+ WATO:
+ * FIX: fix folding problems with dependent host tags
+
Multisite:
* FIX: remove refresh button from dashboard.
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index 8c12bcc..aa94eb2 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -285,6 +285,10 @@ ul.treeangle li {
margin-left: 16px;
padding-left: 20px;
list-style: disc;
+ display: block;
+}
+ul.closed {
+ display: none;
}
diff --git a/web/htdocs/forms.py b/web/htdocs/forms.py
index 02dc244..8d71bb2 100644
--- a/web/htdocs/forms.py
+++ b/web/htdocs/forms.py
@@ -118,7 +118,7 @@ def header(title, isopen = True, table_id = ""):
fold_id = strip_bad_chars(title)
g_section_isopen = html.begin_foldable_container(
html.form_name and html.form_name or "nform", fold_id, isopen,
title, indent="nform")
- html.write('<tr class=top style="display: %s"><td
colspan=2></td></tr>' % (not g_section_isopen and "none" or
""))
+ html.write('<tr class="top %s"><td
colspan=2></td></tr>' % (g_section_isopen and "open" or
"closed"))
g_header_open = True
g_section_open = False
@@ -127,8 +127,8 @@ def container():
global g_section_open
if g_section_open:
html.write('</td></tr>')
- html.write('<tr style="display: %s"><td colspan=2
class=container>' %
- (not g_section_isopen and "none" or ""))
+ html.write('<tr class="%s"><td colspan=2
class=container>' %
+ (g_section_isopen and "open" or "closed"))
g_section_open = True
def section(title = None, checkbox = None, id = "", simple=False):
@@ -137,8 +137,8 @@ def section(title = None, checkbox = None, id = "",
simple=False):
html.write('</td></tr>')
if id:
id = ' id="%s"' % id
- html.write('<tr style="display: %s"%s><td
class="legend%s">' %
- (not g_section_isopen and "none" or "", id, simple and
" simple" or ""))
+ html.write('<tr class="%s"%s><td
class="legend%s">' %
+ (g_section_isopen and "open" or "closed", id, simple and
" simple" or ""))
if title:
html.write('<div class="title%s">%s<span
class="dots">%s</span></div>' %
(checkbox and " withcheckbox" or "", title,
"."*100))
@@ -161,7 +161,7 @@ def end():
if g_section_open:
html.write('</td></tr>')
html.end_foldable_container()
- html.write('<tr class=bottom style="display: %s"><td
colspan=2></td></tr>'
- % (not g_section_isopen and "none" or ""))
+ html.write('<tr class="bottom %s"><td
colspan=2></td></tr>'
+ % (g_section_isopen and "open" or "closed"))
html.write('</table>')
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index c4b1808..511dca9 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1118,9 +1118,6 @@ class html:
self.write('<tr class=heading><td id="nform.%s.%s" %s
colspan=2>' % (treename, id, onclick))
self.write('%s</td></tr>' % title)
else:
- if indent == "form":
- self.write('<table id="topic_%s"
style="display:table" class="form nomargin"><tr%s><td
class=title>' % \
- (id.encode("utf-8"), first and '
class="top"' or ''))
self.write('<img align=absbottom class="treeangle"
id="treeimg.%s.%s" '
'src="images/tree_%s.png" %s>' %
(treename, id, img_num, onclick))
@@ -1136,8 +1133,8 @@ class html:
if indent == "form":
self.write("</td></tr></table>")
indent_style += "margin: 0; "
- self.write('<ul class="treeangle" style="%s display:
%s" id="tree.%s.%s">' %
- (indent_style, (not isopen) and "none" or "block",
treename, id))
+ self.write('<ul class="treeangle %s" style="%s"
id="tree.%s.%s">' %
+ (isopen and "open" or "closed", indent_style,
treename, id))
# give caller information about current toggling state (needed for nform)
return isopen
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 36392b8..8e6bdf3 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -796,21 +796,51 @@ function folding_step(oImg, state, step) {
setTimeout(function() { folding_step(oImg, state, step); }, fold_steps[step]);
}
+/* Check if an element has a certain css class. */
+function has_class(o, cn) {
+ var parts = o.className.split(' ');
+ for (x=0; x<parts.length; x++) {
+ if (parts[x] == cn)
+ return true;
+ }
+ return false;
+}
+
+function remove_class(o, cn) {
+ var parts = o.className.split(' ');
+ var new_parts = Array();
+ for (x=0; x<parts.length; x++) {
+ if (parts[x] != cn)
+ new_parts.push(parts[x]);
+ }
+ o.className = new_parts.join(" ");
+}
+
+function add_class(o, cn) {
+ o.className += " " + cn;
+}
+
+function change_class(o, a, b) {
+ remove_class(o, a);
+ add_class(o, b);
+}
+
+
function toggle_tree_state(tree, name, oContainer) {
var state;
- if (oContainer.style.display == 'none') {
- oContainer.style.display = '';
+ if (has_class(oContainer, 'closed')) {
+ change_class(oContainer, 'closed', 'open');
state = 'on';
if (oContainer.tagName == 'TR') { // handle in-table toggling
while (oContainer = oContainer.nextSibling)
- oContainer.style.display = '';
+ change_class(oContainer, 'closed', 'open');
}
} else {
- oContainer.style.display = 'none';
+ change_class(oContainer, 'open', 'closed');
state = 'off';
if (oContainer.tagName == 'TR') { // handle in-table toggling
while (oContainer = oContainer.nextSibling)
- oContainer.style.display = 'none';
+ change_class(oContainer, 'open', 'closed');
}
}
get_url('tree_openclose.py?tree=' + escape(tree) + '&name=' +
escape(name) + '&state=' + state);
diff --git a/web/htdocs/pages.css b/web/htdocs/pages.css
index 31f98e5..c823e5c 100644
--- a/web/htdocs/pages.css
+++ b/web/htdocs/pages.css
@@ -511,6 +511,10 @@ table.nform {
border-style: solid;
}
+table.nform tr.closed {
+ display: none;
+}
+
table.nform tr.heading td {
color: white;
}