From: Robert Konigsberg Date: Tue, 14 Jun 2011 17:13:44 +0000 (-0400) Subject: Extract the function that pushes an event onto the chart, for reuse outside this... X-Git-Tag: v1.0.0~458^2~7 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=21c079e5c7761be8a0fb1e2d6a4d6ada57fae3a1;p=dygraphs.git Extract the function that pushes an event onto the chart, for reuse outside this method. --- 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); }; /**