Module: check_mk
Branch: master
Commit: a99afd475f882023ba198fcb0b0f9483244cb33c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a99afd475f8820…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 14 15:33:25 2015 +0200
Cleaned up old event handling realted js code a bit
---
web/htdocs/js/checkmk.js | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 25c325a..4770be8 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1461,7 +1461,6 @@ function unhide_context_buttons(oA)
}
oA.parentNode.style.display = "none";
oNode = null;
- oDiv = null;
}
// .-----------------------------------------------------------------------.
@@ -2005,44 +2004,30 @@ function view_toggle_form(oButton, idForm) {
}
function init_optiondial(id) {
- oDiv = document.getElementById(id);
+ var oDiv = document.getElementById(id);
make_unselectable(oDiv);
var eventname = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" :
"mousewheel"
-
- if (oDiv.attachEvent) //if IE (and Opera depending on user setting)
- oDiv.attachEvent("on" + eventname, optiondial_wheel)
- else if (oDiv.addEventListener) //WC3 browsers
- oDiv.addEventListener(eventname, optiondial_wheel, false)
-
+ add_event_handler(eventname, optiondial_wheel);
}
-var dial_direction = 1;
+var g_dial_direction = 1;
function optiondial_wheel(e) {
var evt = window.event || e;
var delta = evt.detail ? evt.detail * (-120) : evt.wheelDelta;
- var oDiv;
- if (evt.target) oDiv = evt.target;
- else if (evt.srcElement) oDiv = evt.srcElement;
+ var oDiv = getTarget(evt);
if (evt.nodeType == 3) // defeat Safari bug
oDiv = oDiv.parentNode;
while (!oDiv.className)
oDiv = oDiv.parentNode;
-
- code = ('' + (oDiv.onclick)).replace("this",
"oDiv").replace("onclick", "dial_wheel_function");
- eval(code);
if (delta > 0)
- dial_direction = -1;
- dial_wheel_function(e);
- dial_direction = 1;
-
- if (evt.preventDefault)
- evt.preventDefault();
- else
- return false;
+ g_dial_direction = -1;
+ oDiv.onclick(e);
+ g_dial_direction = 1;
+ return prevent_default_events(e);
}
// used for refresh und num_columns
@@ -2054,7 +2039,7 @@ function view_dial_option(oDiv, viewname, option, choices) {
val = choice[0];
title = choice[1];
if (has_class(oDiv, "val_" + val)) {
- var new_choice = choices[(c + choices.length + dial_direction) %
choices.length];
+ var new_choice = choices[(c + choices.length + g_dial_direction) %
choices.length];
change_class(oDiv, "val_" + val, "val_" +
new_choice[0]);
break;
}
@@ -2065,11 +2050,11 @@ function view_dial_option(oDiv, viewname, option, choices) {
speed = 10;
for (var way = 0; way <= 10; way +=1) {
step += speed;
- setTimeout("turn_dial('" + option + "', '', "
+ way + "," + dial_direction + ")", step);
+ setTimeout("turn_dial('" + option + "', '', "
+ way + "," + g_dial_direction + ")", step);
}
for (var way = -10; way <= 0; way +=1) {
step += speed;
- setTimeout("turn_dial('" + option + "', '" +
new_choice[1] + "', " + way + "," + dial_direction +
")", step);
+ setTimeout("turn_dial('" + option + "', '" +
new_choice[1] + "', " + way + "," + g_dial_direction +
")", step);
}
get_url_sync("ajax_set_viewoption.py?view_name=" + viewname +