Merge pull request #674 from danvk/module
[dygraphs.git] / src / extras / synchronizer.js
index dd4329c..bf5b6f3 100644 (file)
 /* global Dygraph:false */
 'use strict';
 
-Dygraph.synchronize = function(/* dygraphs..., opts */) {
+var Dygraph;
+if (window.Dygraph) {
+  Dygraph = window.Dygraph;
+} else if (typeof(module) !== 'undefined') {
+  Dygraph = require('../dygraph');
+}
+
+var synchronize = function(/* dygraphs..., opts */) {
   if (arguments.length === 0) {
     throw 'Invalid invocation of Dygraph.synchronize(). Need >= 1 argument.';
   }
@@ -217,4 +224,6 @@ function attachSelectionHandlers(gs, prevCallbacks) {
   }
 }
 
+Dygraph.synchronize = synchronize;
+
 })();