Browse Source

moved options to network

flowchartTest
Alex de Mulder 9 years ago
parent
commit
fbf94397bb
3 changed files with 12 additions and 7 deletions
  1. +7
    -1
      examples/network/01_basic_usage.html
  2. +2
    -1
      lib/network/Network.js
  3. +3
    -5
      lib/network/modules/Validator.js

+ 7
- 1
examples/network/01_basic_usage.html View File

@ -52,6 +52,12 @@
// network.setOptions({nodes:{color:'red'}})
network.on("rightClick",function(e){console.log(e)})
</script>
<pre>
var options = {
manipulation: 'hello',
physics:{barnesHut:{gravitationslPull:34}, solver:'banana'},
groups:{'bla':{color:{backsground:'red'}, borderWidth:5}}
}
</pre>
</body>
</html>

+ 2
- 1
lib/network/Network.js View File

@ -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);

+ 3
- 5
lib/network/modules/Validator.js View File

@ -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;

Loading…
Cancel
Save