Module: check_mk
Branch: master
Commit: a2820238299ba3d567936794423f6b0b58a541db
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a2820238299ba3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 22 13:10:42 2016 +0100
TextAscii and TextUnicode now support try_max_width
Change-Id: I93e56b7dcb43147a1ce3fffd04846c9bcafe724e
---
web/htdocs/htmllib.py | 10 +++++++++-
web/htdocs/valuespec.py | 3 ++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index e88687c..423d334 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1886,7 +1886,15 @@ class html(DeprecationWrapper):
# View
style, size = None, None
- if "size" in args and args["size"]:
+ if args.get("try_max_width"):
+ style = "width: calc(100% - 10px); "
+ if "size" in args:
+ cols = int(args["size"])
+ else:
+ cols = 16
+ style += "min-width: %d.8ex; " % cols
+
+ elif "size" in args and args["size"]:
if args["size"] == "max":
style = "width: 100%;"
else:
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 8657d60..91c797a 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -366,6 +366,7 @@ class TextAscii(ValueSpec):
super(TextAscii, self).__init__(**kwargs)
self._label = kwargs.get("label")
self._size = kwargs.get("size", 25) # also possible:
"max"
+ self._try_max_width = kwargs.get("try_max_width", False) # If set, uses
calc(100%-10px)
self._cssclass = kwargs.get("cssclass", "text")
self._strip = kwargs.get("strip", True)
self._attrencode = kwargs.get("attrencode", True)
@@ -410,6 +411,7 @@ class TextAscii(ValueSpec):
html.text_input(varprefix, value,
size=self._size,
+ try_max_width=self._try_max_width,
read_only=self._read_only,
cssclass=self._cssclass,
type=type_,
@@ -956,7 +958,6 @@ class TextAreaUnicode(TextUnicode):
def __init__(self, **kwargs):
TextUnicode.__init__(self, **kwargs)
self._cols = kwargs.get("cols", 60)
- self._try_max_width = kwargs.get("try_max_width", False) # If set, uses
calc(100%-10px)
self._rows = kwargs.get("rows", 20) # Allowed: "auto" ->
Auto resizing
self._minrows = kwargs.get("minrows", 0) # Minimum number of initial
rows when "auto"
self._monospaced = kwargs.get("monospaced", False) # select TT font