Migrate most of core dygraphs to ES6 modules.
[dygraphs.git] / src / dygraph-options.js
index d21ccc1..8affcdf 100644 (file)
@@ -5,25 +5,18 @@
  */
 
 /**
- * @fileoverview DygraphOptions is responsible for parsing and returning information about options.
- *
- * Still tightly coupled to Dygraphs, we could remove some of that, you know.
+ * @fileoverview DygraphOptions is responsible for parsing and returning
+ * information about options.
  */
 
-var DygraphOptions = (function() {
-/*jshint strict:false */
-
-// For "production" code, this gets set to false by uglifyjs.
-// Need to define it outside of "use strict", hence the nested IIFEs.
-if (typeof(DEBUG) === 'undefined') DEBUG=true;
-
-return (function() {
-
 // TODO: remove this jshint directive & fix the warnings.
 /*jshint sub:true */
 /*global Dygraph:false */
 "use strict";
 
+import * as utils from './dygraph-utils';
+import DEFAULT_ATTRS from './dygraph-default-attrs';
+
 /*
  * Interesting member variables: (REMOVING THIS LIST AS I CLOSURIZE)
  * global_ - global attributes (common among all graphs, AIUI)
@@ -167,13 +160,13 @@ DygraphOptions.prototype.reparseSeries = function() {
   }
 
   var axis_opts = this.user_["axes"] || {};
-  Dygraph.update(this.yAxes_[0].options, axis_opts["y"] || {});
+  utils.update(this.yAxes_[0].options, axis_opts["y"] || {});
   if (this.yAxes_.length > 1) {
-    Dygraph.update(this.yAxes_[1].options, axis_opts["y2"] || {});
+    utils.update(this.yAxes_[1].options, axis_opts["y2"] || {});
   }
-  Dygraph.update(this.xAxis_.options, axis_opts["x"] || {});
+  utils.update(this.xAxis_.options, axis_opts["x"] || {});
 
-  if (DEBUG) this.validateOptions_();
+  // if (DEBUG) this.validateOptions_();
 };
 
 /**
@@ -200,8 +193,8 @@ DygraphOptions.prototype.getGlobalDefault_ = function(name) {
   if (this.global_.hasOwnProperty(name)) {
     return this.global_[name];
   }
-  if (Dygraph.DEFAULT_ATTRS.hasOwnProperty(name)) {
-    return Dygraph.DEFAULT_ATTRS[name];
+  if (DEFAULT_ATTRS.hasOwnProperty(name)) {
+    return DEFAULT_ATTRS[name];
   }
   return null;
 };
@@ -255,7 +248,7 @@ DygraphOptions.prototype.getForAxis = function(name, axis) {
     }
   }
   // Default axis options third.
-  var defaultAxisOptions = Dygraph.DEFAULT_ATTRS.axes[axisString];
+  var defaultAxisOptions = DEFAULT_ATTRS.axes[axisString];
   if (defaultAxisOptions.hasOwnProperty(name)) {
     return defaultAxisOptions[name];
   }
@@ -329,7 +322,9 @@ DygraphOptions.prototype.seriesNames = function() {
   return this.labels_;
 };
 
-if (DEBUG) {
+// TODO: fix this
+// if (DEBUG) {
+if (false) {
 
 /**
  * Validate all options.
@@ -399,7 +394,4 @@ DygraphOptions.resetWarnings_ = function() {
 
 }
 
-return DygraphOptions;
-
-})();
-})();
+export default DygraphOptions;