From fbf94397bb91f5c60a0be44da3e5e922595aa296 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Fri, 24 Apr 2015 14:16:23 +0200 Subject: [PATCH] moved options to network --- examples/network/01_basic_usage.html | 8 +++++++- lib/network/Network.js | 3 ++- lib/network/modules/Validator.js | 8 +++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/network/01_basic_usage.html b/examples/network/01_basic_usage.html index 964d4d9f..50b7a595 100644 --- a/examples/network/01_basic_usage.html +++ b/examples/network/01_basic_usage.html @@ -52,6 +52,12 @@ // network.setOptions({nodes:{color:'red'}}) network.on("rightClick",function(e){console.log(e)}) - +
+var options = {
+  manipulation: 'hello',
+  physics:{barnesHut:{gravitationslPull:34}, solver:'banana'},
+  groups:{'bla':{color:{backsground:'red'}, borderWidth:5}}
+}
+  
diff --git a/lib/network/Network.js b/lib/network/Network.js index d994797d..065a6f45 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -26,6 +26,7 @@ import ManipulationSystem from "./modules/ManipulationSystem"; import ConfigurationSystem from "./modules/ConfigurationSystem"; import Validator from "./modules/Validator"; import {printStyle} from "./modules/Validator"; +import allOptions from './modules/components/AllOptions.js'; /** * @constructor Network @@ -135,7 +136,7 @@ Emitter(Network.prototype); Network.prototype.setOptions = function (options) { if (options !== undefined) { - let errorFound = Validator.validate(options); + let errorFound = Validator.validate(options,allOptions); if (errorFound === true) { options = {}; console.log('%cErrors have been found in the supplied options object. None of the options will be used.', printStyle); diff --git a/lib/network/modules/Validator.js b/lib/network/modules/Validator.js index 64717c6c..e37f51ab 100644 --- a/lib/network/modules/Validator.js +++ b/lib/network/modules/Validator.js @@ -1,7 +1,5 @@ var util = require('../../util'); - -import allOptions from './components/AllOptions.js' let errorFound = false; let printStyle = 'background: #FFeeee; color: #dd0000'; /** @@ -17,11 +15,11 @@ class Validator { * @param subObject * @returns {boolean} */ - static validate(options, subObject) { + static validate(options, referenceOptions, subObject) { errorFound = false; - let usedOptions = allOptions; + let usedOptions = referenceOptions; if (subObject !== undefined) { - usedOptions = allOptions[subObject]; + usedOptions = referenceOptions[subObject]; } Validator.parse(options, usedOptions, []); return errorFound;