X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FDygraphOps.js;h=4dae18e2ec781d19d6394ee7183249e694d0334f;hb=21c079e5c7761be8a0fb1e2d6a4d6ada57fae3a1;hp=5dfa2be25bf3034b9f439e899c5ee3df7b6643f0;hpb=1b89e01f33c071af04e0586163fa3c09ac115b09;p=dygraphs.git diff --git a/auto_tests/tests/DygraphOps.js b/auto_tests/tests/DygraphOps.js index 5dfa2be..4dae18e 100644 --- a/auto_tests/tests/DygraphOps.js +++ b/auto_tests/tests/DygraphOps.js @@ -44,6 +44,13 @@ DygraphOps.defaultEvent_ = { relatedTarget : null }; +/** + * Create an event. Sets default event values except for special ones + * overridden by the 'custom' parameter. + * + * @param command the command to create. + * @param custom an associative array of event attributes and their new values. + */ DygraphOps.createEvent_ = function(command, custom) { var copy = function(from, to) { @@ -81,13 +88,20 @@ DygraphOps.createEvent_ = function(command, custom) { return event; } +/** + * Dispatch an event onto the graph's canvas. + */ +DygraphOps.dispatchCanvasEvent(g, event) { + g.canvas_.dispatchEvent(event); +} + DygraphOps.dispatchDoubleClick = function(g, custom) { var opts = { type : 'dblclick', detail : 2 }; var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + DygraphOps.dispatchCanvasEvent(g, event); }; DygraphOps.dispatchMouseDown_Point = function(g, x, y, custom) { @@ -104,7 +118,7 @@ DygraphOps.dispatchMouseDown_Point = function(g, x, y, custom) { }; var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + DygraphOps.dispatchCanvasEvent(g, event); } DygraphOps.dispatchMouseMove_Point = function(g, x, y, custom) { @@ -120,7 +134,7 @@ DygraphOps.dispatchMouseMove_Point = function(g, x, y, custom) { }; var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + DygraphOps.dispatchCanvasEvent(g, event); }; DygraphOps.dispatchMouseUp_Point = function(g, x, y, custom) { @@ -136,7 +150,7 @@ DygraphOps.dispatchMouseUp_Point = function(g, x, y, custom) { }; var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + DygraphOps.dispatchCanvasEvent(g, event); }; /**