Module: check_mk
Branch: master
Commit: be64ef1985e78b372649a4474e4c0aa254b5788a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=be64ef1985e78b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 21 15:09:02 2013 +0100
Allow function keys for context buttons
---
web/htdocs/htmllib.py | 21 ++++++++++++---------
web/htdocs/js/checkmk.js | 7 ++++---
web/htdocs/pages.css | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index d05a70f..c4afaad 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -191,6 +191,13 @@ class html:
self.plugged = False
self.keybindings = []
+ RETURN = 13
+ SHIFT = 16
+ CTRL = 17
+ ALT = 18
+ BACKSPACE = 8
+ F1 = 112
+
def set_buffering(self, b):
self.buffering = b
@@ -479,7 +486,7 @@ class html:
self.write("</td></tr></table>\n")
self.context_buttons_open = False
- def context_button(self, title, url, icon=None, hot=False, id=None, bestof=None,
hover_title=''):
+ def context_button(self, title, url, icon=None, hot=False, id=None, bestof=None,
hover_title='', fkey=None):
display = "block"
if bestof:
counts = config.load_user_file("buttoncounts", {})
@@ -499,7 +506,7 @@ class html:
idtext = " id='%s'" % id
else:
idtext = ""
- self.write('<div%s style="display:%s"
class="contextlink%s" ' % (idtext, display, hot and " hot" or
""))
+ self.write('<div%s style="display:%s"
class="contextlink%s%s" ' % (idtext, display, hot and " hot" or
"", fkey and " button" or ""))
self.context_button_hover_code(hot and "_hot" or "")
self.write('>')
self.write('<a href="%s"' % url)
@@ -507,6 +514,9 @@ class html:
self.write(' title="%s"' % hover_title)
if bestof:
self.write(' onmousedown="count_context_button(this);
document.location=this.href; " ')
+ if fkey:
+ title += '<div class=keysym>F%d</div>' % fkey
+ self.add_keybinding([html.F1 + (fkey - 1)],
"document.location='%s';" % url)
self.write('>%s</a></div>\n' % title)
def context_button_hover_code(self, what):
@@ -1279,13 +1289,6 @@ document.body.onkeyup = keybindings_keyup;
self.set_cookie(varname, '', time.time() - 60)
# Keyboard control
-
- RETURN = 13
- SHIFT = 16
- CTRL = 17
- ALT = 18
- BACKSPACE = 8
-
def add_keybinding(self, keylist, jscode):
self.keybindings.append([keylist, jscode])
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 82f17b4..c196b0c 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1939,7 +1939,7 @@ function keybindings_keydown(e) {
if (!e) e = window.event;
var keyCode = e.which || e.keyCode;
keybindings_pressedkeys.push(keyCode);
- keybindings_check(e);
+ return keybindings_check(e);
}
function keybindings_keyup(e) {
@@ -1956,15 +1956,16 @@ function keybindings_keyup(e) {
function keybindings_check(e) {
for (var i in keybindings) {
var keylist = keybindings[i][0];
- var jscode = keybindings[i][1];
if (keybindings_check_keylist(keylist)) {
if (e.stopPropagation)
e.stopPropagation();
e.cancelBubble = true;
+ var jscode = keybindings[i][1];
eval(jscode);
- return;
+ return false;
}
}
+ return true;
}
function keybindings_check_keylist(keylist)
diff --git a/web/htdocs/pages.css b/web/htdocs/pages.css
index fd32ce9..12a0006 100644
--- a/web/htdocs/pages.css
+++ b/web/htdocs/pages.css
@@ -840,3 +840,45 @@ div.help table.help td {
div.help table.help td.tt {
font-family: courier, monospace;
}
+
+/*--Various----------------------------------------------------------------.
+| __ __ _ |
+| \ \ / /_ _ _ __(_) ___ _ _ ___ |
+| \ \ / / _` | '__| |/ _ \| | | / __| |
+| \ V / (_| | | | | (_) | |_| \__ \ |
+| \_/ \__,_|_| |_|\___/ \__,_|___/ |
+| |
+'-------------------------------------------------------------------------*/
+
+div.keysym {
+ text-align: center;
+ color: white;
+ /* font-style: italic; */
+ border-width: 2px;
+ border-style: solid;
+ border-color: #888 #444 #000 #666;
+ border-radius: 4px;
+ box-shadow: 0.5px 0.5px 1px #000;
+ background-color: #333;
+ padding: 2px 5px;
+ margin: 0px 1px;
+ display: inline-block;
+}
+
+
+/* Contextlinks with embedded keyboard button */
+div.contextlink div.keysym {
+ background-color: #467;
+ border-color: #8ab #245 #134 #79a;
+ border-width: 2px;
+ padding: 1px 5px;
+ font-size: 6pt;
+ position: absolute;
+ top: 4px;
+ right: 5px;
+}
+
+div.contextlink.button a {
+ width: 135px;
+}
+