Module: check_mk
Branch: master
Commit: 1ff5f23615b2d0fe61a1c8298fba5e4ae2c728af
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1ff5f23615b2d0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 14 06:21:33 2013 +0100
Intermediate state for improvement of commands form
---
web/htdocs/htmllib.py | 8 +++++++-
web/htdocs/js/checkmk.js | 13 +++++++++++++
web/plugins/views/commands.py | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index da03f6d..a039672 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -512,7 +512,7 @@ class html:
def add_form_var(self, varname):
self.form_vars.append(varname)
- def text_input(self, varname, default_value = "", cssclass =
"text", label = None, id = None, **args):
+ def text_input(self, varname, default_value = "", cssclass =
"text", label = None, id = None, submit = None, **args):
if default_value == None:
default_value = ""
addprops = ""
@@ -533,6 +533,12 @@ class html:
elif add_style:
addprops += " style=\"%s\"" % add_style
+ if submit:
+ addprops += " id='hirn' "
+
self.final_javascript('document.getElementById("hirn").onkeydown = '
+ 'function(e) { if (!e) e = window.event;
textinput_enter_submit(e, "%s"); };' % submit)
+
+
value = self.req.vars.get(varname, default_value)
error = self.user_errors.get(varname)
html = ""
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 236d898..58ed332 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -509,6 +509,19 @@ function pnp_hover_contents(url) {
}
// ----------------------------------------------------------------------------
+// Handle Enter key in textfields
+// ----------------------------------------------------------------------------
+function textinput_enter_submit(e, submit) {
+ var keyCode = e.which || e.keyCode;
+ if (keyCode == 13) {
+ /* alert(submit); */
+ e.returnValue = false;
+ e.cancelBubble = true;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
// Synchronous action handling
// ----------------------------------------------------------------------------
// Protocol is:
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index ee2930e..d526a9b 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -259,7 +259,7 @@ multisite_commands.append({
html.checkbox("_ack_persistent", False, label=_('persistent
comment')) == \
html.write("<hr>") == \
html.write(_("Comment") + ": ") == \
- html.text_input("_ack_comment", size=48),
+ html.text_input("_ack_comment", size=48,
submit="_acknowledge"),
"action" : command_acknowledgement,
"group" : _("Acknowledge"),
})