Module: check_mk
Branch: master
Commit: 9773f152af9780829e88fc32b4c33e229a37365e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9773f152af9780…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jan 18 16:07:41 2012 +0100
Various optimizations in ValueSpecs
---
web/htdocs/check_mk.css | 51 +++++++++++++++++++++++++++++++++++++++++++++++
web/htdocs/valuespec.py | 24 +++++++++++-----------
web/htdocs/wato.css | 31 ----------------------------
3 files changed, 63 insertions(+), 43 deletions(-)
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index 57802d8..078cef3 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -241,3 +241,54 @@ div.warning {
border-color: #fc0;
}
+/*-ValueSpec---------------------------------------------------------------.
+| __ __ _ ____ |
+| \ \ / /_ _| |_ _ ___/ ___| _ __ ___ ___ |
+| \ \ / / _` | | | | |/ _ \___ \| '_ \ / _ \/ __| |
+| \ V / (_| | | |_| | __/___) | |_) | __/ (__ |
+| \_/ \__,_|_|\__,_|\___|____/| .__/ \___|\___| |
+| |_| |
++--------------------------------------------------------------------------+
+| Styles needed for HTML code produced by valuespec.py. |
+'-------------------------------------------------------------------------*/
+
+td.content ul.help {
+ color: white;
+ font-style: italic;
+ font-size: 8pt;
+ padding: 0;
+ margin: 0 0 5px 0;
+ /* width: 300px; */
+}
+
+table.dictionary {
+}
+
+table.dictionary td.dictright {
+ white-space: nowrap;
+ padding: 0px;
+ border-style: none;
+}
+
+div.dictelement * {
+ font-size: 8pt;
+}
+div.dictelement {
+ font-size: 8pt;
+ padding-left: 10px;
+ border-left: 2px solid #ccc;
+ margin-left: 8px;
+ margin-bottom: 10px;
+ margin-top: 3px;
+ float: none;
+}
+
+td.content table.valuespec_tuple td.left {
+ padding-right: 10px;
+}
+
+td.content table.valuespec_tuple td.right,
+td.content table.valuespec_tuple td.left {
+ vertical-align: top;
+ padding-bottom: 10px;
+}
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 4eb9180..e72bf38 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -190,7 +190,7 @@ class Integer(ValueSpec):
if self._label:
html.write(self._label)
html.write(" ")
- html.number_input(varprefix, self._display_format % value, size = self._size)
+ html.number_input(varprefix, str(value), size = self._size)
if self._unit:
html.write(" ")
html.write(self._unit)
@@ -686,19 +686,18 @@ class OptionalDropdownChoice(ValueSpec):
if val == value:
defval = str(n)
options.append(("other", self._otherlabel))
- html.select(varprefix, options, defval,
attrs={"style":"float:left;"},
+ html.select(varprefix, options, defval, #
attrs={"style":"float:left;"},
onchange="valuespec_toggle_dropdown(this,
'%s_ex');" % varprefix )
-
if html.form_submitted():
div_is_open = html.var(varprefix) == "other"
else:
div_is_open = self.value_is_explicit(value)
- html.write('<div id="%s_ex" style="white-space: nowrap;
%s">' % (
+ html.write('<span id="%s_ex" style="white-space: nowrap;
%s">' % (
varprefix, not div_is_open and "display: none;" or ""))
- html.write(" ")
+ html.write(" ")
self._explicit.render_input(varprefix + "_ex", value)
- html.write("</div>")
+ html.write("</span>")
def value_to_text(self, value):
return self._explicit.value_to_text(value)
@@ -936,7 +935,7 @@ class Dictionary(ValueSpec):
def render_input(self, varprefix, value):
html.write("<table class=dictionary>")
for param, vs in self._elements:
- html.write("<tr><td>")
+ html.write("<tr><td class=dictleft>")
vp = varprefix + "_" + param
div_id = vp
if self._optional_keys:
@@ -948,17 +947,18 @@ class Dictionary(ValueSpec):
else:
visible = True
- if self._columns == 2:
- html.write('<div style="float: left">')
html.write(" %s" % vs.title())
if self._columns == 2:
- html.write(': </div>')
+ html.write(':')
+ if vs.help():
+ html.write("<ul class=help>%s</ul>" %
vs.help())
+ html.write('</td><td class=dictright>')
else:
html.write("<br>")
- html.write('<div class=dictelement id="%s"
style="float: left; display: %s">' % (
+ html.write('<div class=dictelement id="%s"
style="display: %s">' % (
div_id, not visible and "none" or ""))
- if vs.help():
+ if self._columns == 1 and vs.help():
html.write("<ul class=help>%s</ul>" % vs.help())
vs.render_input(vp, value.get(param, vs.canonical_value()))
html.write("</div></td></tr>")
diff --git a/web/htdocs/wato.css b/web/htdocs/wato.css
index 4021bac..62de082 100644
--- a/web/htdocs/wato.css
+++ b/web/htdocs/wato.css
@@ -303,37 +303,6 @@ Boston, MA 02110-1301 USA.
position: relative;
top: -3px;
}
-.wato table.ruleeditor td.content ul.help {
- color: white;
- font-style: italic;
- font-size: 8pt;
- padding: 0;
- margin: 0 0 5px 0;
- width: 300px;
-}
-
-.wato div.dictelement * {
- font-size: 8pt;
-}
-.wato div.dictelement {
- font-size: 8pt;
- padding-left: 10px;
- border-left: 2px solid #ccc;
- margin-left: 8px;
- margin-bottom: 10px;
- margin-top: 3px;
- float: none;
-}
-
-.wato table.form.ruleeditor td.content table.valuespec_tuple td.left {
- padding-right: 10px;
-}
-
-.wato table.form.ruleeditor td.content table.valuespec_tuple td.right,
-.wato table.form.ruleeditor td.content table.valuespec_tuple td.left {
- vertical-align: top;
- padding-bottom: 10px;
-}
.wato div.rule div.title {
position: absolute;