Module: check_mk
Branch: master
Commit: 129e26e753569a3f888f0d34b1c1659d6c8f452a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=129e26e753569a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Jan 1 14:29:37 2012 +0100
Moved code from WATO to valuespec
---
web/htdocs/js/checkmk.js | 37 +++++++++++++++++++++++++++++++++++++
web/htdocs/js/wato.js | 26 --------------------------
web/htdocs/valuespec.py | 6 +++---
web/htdocs/wato.py | 6 +++---
4 files changed, 43 insertions(+), 32 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index a8737b8..3c6382c 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1346,3 +1346,40 @@ function unhide_context_buttons(oA)
oDiv = null;
}
+// .-----------------------------------------------------------------------.
+// | __ __ _ ____ |
+// | \ \ / /_ _| |_ _ ___/ ___| _ __ ___ ___ |
+// | \ \ / / _` | | | | |/ _ \___ \| '_ \ / _ \/ __| |
+// | \ V / (_| | | |_| | __/___) | |_) | __/ (__ |
+// | \_/ \__,_|_|\__,_|\___|____/| .__/ \___|\___| |
+// | |_| |
+// +-----------------------------------------------------------------------+
+// | Functions needed by HTML code from ValueSpec (valuespec.py) |
+// '-----------------------------------------------------------------------'
+
+function valuespec_toggle_option(oCheckbox, divid, negate) {
+ var oDiv = document.getElementById(divid);
+ if ((oCheckbox.checked && !negate) || (!oCheckbox.checked &&
negate))
+ oDiv.style.display = "";
+ else
+ oDiv.style.display = "none";
+ oDiv = null;
+}
+
+function valuespec_toggle_dropdown(oDropdown, divid) {
+ var oDiv = document.getElementById(divid);
+ if (oDropdown.value == "other") oDiv.style.display = "";
+ else
+ oDiv.style.display = "none";
+ oDiv = null;
+}
+
+function valuespec_toggle_dropdownn(oDropdown, divid) {
+ var oDiv = document.getElementById(divid);
+ if (oDropdown.value == "ignore")
+ oDiv.style.display = "none";
+ else
+ oDiv.style.display = "";
+ oDiv = null;
+}
+
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index c4dac0e..fc7b944 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -147,32 +147,6 @@ function wato_fix_visibility() {
}
}
-function wato_toggle_option(oCheckbox, divid, negate) {
- var oDiv = document.getElementById(divid);
- if ((oCheckbox.checked && !negate) || (!oCheckbox.checked &&
negate))
- oDiv.style.display = "";
- else
- oDiv.style.display = "none";
- oDiv = null;
-}
-
-function wato_toggle_dropdown(oDropdown, divid) {
- var oDiv = document.getElementById(divid);
- if (oDropdown.value == "other") oDiv.style.display = "";
- else
- oDiv.style.display = "none";
- oDiv = null;
-}
-
-function wato_toggle_dropdownn(oDropdown, divid) {
- var oDiv = document.getElementById(divid);
- if (oDropdown.value == "ignore")
- oDiv.style.display = "none";
- else
- oDiv.style.display = "";
- oDiv = null;
-}
-
// ----------------------------------------------------------------------------
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index a288aac..8c0fa99 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -499,7 +499,7 @@ class OptionalDropdownChoice(ValueSpec):
defval = str(n)
options.append(("other", self._otherlabel))
html.select(varprefix, options, defval,
attrs={"style":"float:left;"},
- onchange="wato_toggle_dropdown(this, '%s_ex');" %
varprefix )
+ onchange="valuespec_toggle_dropdown(this,
'%s_ex');" % varprefix )
if html.form_submitted():
div_is_open = html.var(varprefix) == "other"
@@ -561,7 +561,7 @@ class Optional(ValueSpec):
checked = self._negate != (value != None)
html.write("<div style=\"float: none;\">")
html.checkbox(varprefix + "_use" , checked,
- onclick="wato_toggle_option(this, %r, %r)" %
+ onclick="valuespec_toggle_option(this, %r, %r)" %
(div_id, self._negate and 1 or 0))
if self._label:
html.write(self._label)
@@ -761,7 +761,7 @@ class Dictionary(ValueSpec):
if visible == None:
visible = param in value
html.checkbox(vp + "_USE", param in value,
- onclick="wato_toggle_option(this, %r)" % div_id)
+ onclick="valuespec_toggle_option(this, %r)" %
div_id)
html.write(" %s<br>" % vs.title())
html.write('<div class=dictelement id="%s"
style="display: %s">' % (
div_id, not visible and "none" or ""))
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 40220ab..be43355 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -8709,7 +8709,7 @@ def mode_edit_rule(phase):
("ignore", _("ignore")),
("is", _("is")),
("isnot", _("isnot"))], deflt,
- onchange="wato_toggle_dropdownn(this, 'tag_sel_%s');" %
id)
+ onchange="valuespec_toggle_dropdownn(this,
'tag_sel_%s');" % id)
html.write("</td><td>")
if html.form_submitted():
div_is_open = html.var("tag_" + id) != "ignore"
@@ -8735,7 +8735,7 @@ def mode_edit_rule(phase):
div_id = "div_all_hosts"
checked = host_list != ALL_HOSTS
- html.checkbox("explicit_hosts", checked,
onclick="wato_toggle_option(this, %r)" % div_id)
+ html.checkbox("explicit_hosts", checked,
onclick="valuespec_toggle_option(this, %r)" % div_id)
html.write(" " + _("Specify explicit host names"))
html.write('<div id="%s" style="display: %s">' % (
div_id, not checked and "none" or ""))
@@ -8799,7 +8799,7 @@ def mode_edit_rule(phase):
if checked == None: # read from rule itself
checked = len(item_list) == 0 or item_list[0] != ""
div_id = "itemlist"
- html.checkbox("explicit_services", checked,
onclick="wato_toggle_option(this, %r)" % div_id)
+ html.checkbox("explicit_services", checked,
onclick="valuespec_toggle_option(this, %r)" % div_id)
html.write(" " + _("Specify explicit values"))
html.write('<div id="%s" style="display: %s; padding:
0px;">' % (
div_id, not checked and "none" or ""))