Module: check_mk
Branch: master
Commit: b515966a6c0460e320eb4c651c3a6910b38051ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b515966a6c0460…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 31 15:20:58 2017 +0100
Fixed accidently sidebar folding when selecting a site from a performance snapin
Change-Id: I9cd026ba56b4b5e919717cac2354d15ff12b28d5
---
web/htdocs/js/checkmk.js | 1 -
web/htdocs/js/sidebar.js | 67 ++++++++++++++++++++++++++----------------------
web/htdocs/sidebar.py | 2 +-
3 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 025de3b..0d8e22b 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1678,7 +1678,6 @@ function table_init_rowselect(oTable) {
return highlight_row(this, false);
};
elem.onclick = function(e) {
- console.log(this.parentNode);
return toggle_row(e, this);
};
elem = null;
diff --git a/web/htdocs/js/sidebar.js b/web/htdocs/js/sidebar.js
index 9289f83..229a66c 100644
--- a/web/htdocs/js/sidebar.js
+++ b/web/htdocs/js/sidebar.js
@@ -427,40 +427,42 @@ var startY = 0;
var startScroll = 0;
function startDragScroll(event) {
- if (!event)
- event = window.event;
+ if (!event)
+ event = window.event;
- if (g_sidebar_folded) {
- unfold_sidebar();
- return false;
- }
- else if (!g_sidebar_folded && event.clientX < 10) {
- fold_sidebar();
- return false;
- }
+ var target = getTarget(event);
+ var button = getButton(event);
+ if (button != 'LEFT')
+ return true; // only care about left clicks!
- var target = getTarget(event);
- var button = getButton(event);
+ if (g_sidebar_folded) {
+ unfold_sidebar();
+ return prevent_default_events(event);
+ }
+ else if (!g_sidebar_folded && event.clientX < 10 && target.tagName
!= "OPTION") {
+ // When clicking on an <option> of the "core performance"
snapins, an event
+ // with event.clientX equal 0 is triggered, don't know why. Filter out
clicks
+ // on OPTION tags.
+ fold_sidebar();
+ return prevent_default_events(event);
+ }
- if (dragging === false && button == 'LEFT'
- && target.tagName != 'A'
- && target.tagName != 'INPUT'
- && target.tagName != 'SELECT'
- && !(target.tagName == 'DIV' && target.className ==
'heading')) {
- if (event.preventDefault)
- event.preventDefault();
- if (event.stopPropagation)
- event.stopPropagation();
- event.returnValue = false;
+ if (dragging === false
+ && target.tagName != 'A'
+ && target.tagName != 'INPUT'
+ && target.tagName != 'SELECT'
+ && target.tagName != 'OPTION'
+ && !(target.tagName == 'DIV' && target.className ==
'heading')) {
- dragging = event;
- startY = event.clientY;
- startScroll = document.getElementById('side_content').scrollTop;
+ dragging = event;
+ startY = event.clientY;
+ startScroll = document.getElementById('side_content').scrollTop;
- return false;
- }
- return true;
+ return prevent_default_events(event);
+ }
+
+ return true;
}
function stopDragScroll(event){
@@ -902,9 +904,14 @@ function add_html_var(url, varname, value) {
* Event console site selection
*************************************************/
-function set_snapin_site(ident, select_field) {
- get_url('sidebar_ajax_set_snapin_site.py?ident=' + encodeURIComponent(ident)
+ '&site=' + encodeURIComponent(select_field.value));
+function set_snapin_site(event, ident, select_field) {
+ if (!event)
+ event = window.event;
+
+ get_url('sidebar_ajax_set_snapin_site.py?ident=' + encodeURIComponent(ident)
+ + '&site=' + encodeURIComponent(select_field.value));
location.reload();
+ return prevent_default_events(event);
}
/************************************************
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index e30c66f..57575f6 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -149,7 +149,7 @@ def snapin_site_choice(ident, choices):
return None
site_choices = [ ("", _("All sites")), ] + site_choices
- html.select("site", site_choices, site, onchange="set_snapin_site(%s,
this)" % json.dumps(ident))
+ html.select("site", site_choices, site,
onchange="set_snapin_site(event, %s, this)" % json.dumps(ident))
return only_sites