X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FDygraphOps.js;h=d792259839cdfe5747d2d838ee2168e369630775;hb=36a27704957dda706074a857884d52c1cf5a974c;hp=ad67b2a3ed0e2ed38e6c6d70313b73e17290c59d;hpb=9c8314318c3f11f2d3e26ce6e67f1ac07841ca93;p=dygraphs.git diff --git a/auto_tests/tests/DygraphOps.js b/auto_tests/tests/DygraphOps.js index ad67b2a..d792259 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); + var event = DygraphOps.createEvent(opts, custom); + DygraphOps.dispatchCanvasEvent(g, event); }; DygraphOps.dispatchMouseDown_Point = function(g, x, y, custom) { @@ -103,8 +117,8 @@ DygraphOps.dispatchMouseDown_Point = function(g, x, y, custom) { clientY : pageY, }; - var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + var event = DygraphOps.createEvent(opts, custom); + DygraphOps.dispatchCanvasEvent(g, event); } DygraphOps.dispatchMouseMove_Point = function(g, x, y, custom) { @@ -119,8 +133,8 @@ DygraphOps.dispatchMouseMove_Point = function(g, x, y, custom) { clientY : pageY, }; - var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + var event = DygraphOps.createEvent(opts, custom); + DygraphOps.dispatchCanvasEvent(g, event); }; DygraphOps.dispatchMouseUp_Point = function(g, x, y, custom) { @@ -135,10 +149,14 @@ DygraphOps.dispatchMouseUp_Point = function(g, x, y, custom) { clientY : pageY, }; - var event = DygraphOps.createEvent_(opts, custom); - g.canvas_.dispatchEvent(event); + var event = DygraphOps.createEvent(opts, custom); + DygraphOps.dispatchCanvasEvent(g, event); }; +/** + * Dispatches a mouse down using the graph's data coordinate system. + * (The y value mapped to the first axis.) + */ DygraphOps.dispatchMouseDown = function(g, x, y, custom) { DygraphOps.dispatchMouseDown_Point( g, @@ -147,6 +165,10 @@ DygraphOps.dispatchMouseDown = function(g, x, y, custom) { custom); }; +/** + * Dispatches a mouse move using the graph's data coordinate system. + * (The y value mapped to the first axis.) + */ DygraphOps.dispatchMouseMove = function(g, x, y, custom) { DygraphOps.dispatchMouseMove_Point( g, @@ -155,6 +177,10 @@ DygraphOps.dispatchMouseMove = function(g, x, y, custom) { custom); }; +/** + * Dispatches a mouse up using the graph's data coordinate system. + * (The y value mapped to the first axis.) + */ DygraphOps.dispatchMouseUp = function(g, x, y, custom) { DygraphOps.dispatchMouseUp_Point( g,