From 21c079e5c7761be8a0fb1e2d6a4d6ada57fae3a1 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Tue, 14 Jun 2011 13:13:44 -0400 Subject: [PATCH] Extract the function that pushes an event onto the chart, for reuse outside this method. --- auto_tests/tests/DygraphOps.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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); }; /** -- 2.7.4