Module: check_mk
Branch: master
Commit: c2167f5dcc4f10d7948e4afde5ff7de868bdcdc6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c2167f5dcc4f10…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 27 18:26:34 2015 +0100
Simplified host/service icon rendering; Added hover effect to action icons
---
web/htdocs/htmllib.py | 22 ++++++++++++++++------
web/htdocs/pages.css | 4 ++++
web/plugins/icons/builtin.py | 2 +-
web/plugins/views/painters.py | 14 +++++---------
4 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 6bf70db..ddbda1b 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -395,18 +395,21 @@ class html:
def icon(self, help, icon):
self.write(self.render_icon(icon, help))
- def render_icon(self, icon_name, help="", middle=True, id=None):
+ def render_icon(self, icon_name, help="", middle=True, id=None,
cssclass=None):
align = middle and ' align=absmiddle' or ''
title = help and ' title="%s"' % self.attrencode(help) or
""
id = id and ' id="%s"' % id or ''
+ cssclass = cssclass and ' ' + cssclass
- return '<img src="%s" class=icon%s%s%s />' %
(self.detect_icon_path(icon_name), align, title, id)
+ return '<img src="%s" class="icon%s"%s%s%s />'
% \
+ (self.detect_icon_path(icon_name), cssclass, align, title, id)
def empty_icon(self):
self.write('<img class=icon src="images/trans.png" />')
- def render_icon_button(self, url, help, icon, id="", onclick="",
style="", target="", cssclass=""):
+ def render_icon_button(self, url, help, icon, id="", onclick="",
+ style="", target="",
cssclass="", ty="button"):
if id:
id = "id='%s' " % id
@@ -423,10 +426,15 @@ class html:
if cssclass:
cssclass = 'class="%s" ' % cssclass
+ if ty == "icon":
+ icon = self.detect_icon_path(icon)
+ else:
+ icon = "images/button_" + icon + ".png"
+
return '<a %s%s%s%s%sonfocus="if (this.blur) this.blur();"
href="%s">' \
'<img align=absmiddle class=iconbutton title="%s"
' \
- 'src="images/button_%s.png">' \
- '</a>' % (id, onclick, style, target, cssclass, url,
self.attrencode(help), icon)
+ 'src="%s"></a>' % (id, onclick, style,
target, cssclass,
+ url, self.attrencode(help), icon)
def icon_button(self, *args, **kwargs):
@@ -477,7 +485,9 @@ class html:
self.begin_context_buttons()
if icon:
- title = '<img src="%s">%s' %
(self.attrencode(self.detect_icon_path(icon)), self.attrencode(title))
+ title = '<img src="%s">%s' % \
+ (self.attrencode(self.detect_icon_path(icon)),
+ self.attrencode(title))
if id:
idtext = " id='%s'" % self.attrencode(id)
diff --git a/web/htdocs/pages.css b/web/htdocs/pages.css
index 6740d7c..18c92a7 100644
--- a/web/htdocs/pages.css
+++ b/web/htdocs/pages.css
@@ -1162,3 +1162,7 @@ tr.data td.pnpgraph div.pnp_graph > a.popup_trigger > img.icon
{
box-shadow: none;
margin: 0;
}
+
+div.popup_trigger img.iconbutton {
+ padding: 0;
+}
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 955a994..ef8a083 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -85,7 +85,7 @@ def paint_action_menu(what, row, tags, host_custom_vars):
url_vars.append(('_display_options',
html.var('_display_options')))
return html.render_popup_trigger(
- html.render_icon('menu', _('Open the action menu')),
+ html.render_icon('menu', _('Open the action menu'),
cssclass="iconbutton"),
'action_menu', 'action_menu', url_vars=url_vars)
multisite_icons_and_actions['action_menu'] = {
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 901f628..ce78910 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -295,17 +295,13 @@ def paint_icons(what, row):
onclick = ''
if url.startswith('onclick:'):
- onclick = ' onclick="%s"' % url[8:]
+ onclick = url[8:]
url = 'javascript:void(0)'
- target = ""
- if target_frame != "_self":
- target = " target=\"%s\"" % target_frame
-
- output += '<a href="%s"%s%s>' % (url, target,
onclick)
- output += html.render_icon(icon_name, title)
- if url_spec:
- output += '</a>'
+ output += html.render_icon_button(url, title, icon_name,
+ onclick=onclick, target=target_frame,
ty="icon")
+ else:
+ output += html.render_icon(icon_name, title)
else:
output += icon[1]