X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FDygraphOps.js;h=e32660c88364e0522ac371104a6242959ccaa592;hb=17aad8df5fcf2221055dc6564e7806e72b61e37f;hp=5dfa2be25bf3034b9f439e899c5ee3df7b6643f0;hpb=6ace73a81e14176f18a521979b38ba98a70cf642;p=dygraphs.git diff --git a/auto_tests/tests/DygraphOps.js b/auto_tests/tests/DygraphOps.js index 5dfa2be..e32660c 100644 --- a/auto_tests/tests/DygraphOps.js +++ b/auto_tests/tests/DygraphOps.js @@ -44,7 +44,14 @@ DygraphOps.defaultEvent_ = { relatedTarget : null }; -DygraphOps.createEvent_ = function(command, custom) { +/** + * 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) { if (from != null) { @@ -81,13 +88,20 @@ DygraphOps.createEvent_ = function(command, custom) { return event; } +/** + * Dispatch an event onto the graph's canvas. + */ +DygraphOps.dispatchCanvasEvent = function(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); }; /**