|
|
@ -1,6 +1,6 @@ |
|
|
|
var util = require('../util'); |
|
|
|
|
|
|
|
import ColorPicker from './../network/modules/components/ColorPicker' |
|
|
|
import ColorPicker from './ColorPicker' |
|
|
|
|
|
|
|
/** |
|
|
|
* The way this works is for all properties of this.possible options, you can supply the property name in any form to list the options. |
|
|
@ -16,7 +16,7 @@ import ColorPicker from './../network/modules/components/ColorPicker' |
|
|
|
* @param configureOptions | the fully configured and predefined options set found in allOptions.js |
|
|
|
* @param pixelRatio | canvas pixel ratio |
|
|
|
*/ |
|
|
|
class ConfigurationSystem { |
|
|
|
class Configurator { |
|
|
|
constructor(parentModule, defaultContainer, configureOptions, pixelRatio = 1) { |
|
|
|
this.parent = parentModule; |
|
|
|
this.changedOptions = []; |
|
|
@ -35,7 +35,7 @@ class ConfigurationSystem { |
|
|
|
this.moduleOptions = {}; |
|
|
|
this.domElements = []; |
|
|
|
this.colorPicker = new ColorPicker(pixelRatio); |
|
|
|
this.wrapper; |
|
|
|
this.wrapper = undefined; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -92,25 +92,24 @@ class ConfigurationSystem { |
|
|
|
|
|
|
|
/** |
|
|
|
* Create all DOM elements |
|
|
|
* @param {Boolean | String} config |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
_create() { |
|
|
|
this._clean(); |
|
|
|
this.changedOptions = []; |
|
|
|
|
|
|
|
let config = this.options.filter; |
|
|
|
let filter = this.options.filter; |
|
|
|
let counter = 0; |
|
|
|
let show = false; |
|
|
|
for (let option in this.configureOptions) { |
|
|
|
if (this.configureOptions.hasOwnProperty(option)) { |
|
|
|
this.allowCreation = false; |
|
|
|
show = false; |
|
|
|
if (typeof config === 'function') { |
|
|
|
show = config(option,[]); |
|
|
|
if (typeof filter === 'function') { |
|
|
|
show = filter(option,[]); |
|
|
|
show = show || this._handleObject(this.configureOptions[option], [option]); |
|
|
|
} |
|
|
|
else if (config === true || config.indexOf(option) !== -1) { |
|
|
|
else if (filter === true || filter.indexOf(option) !== -1) { |
|
|
|
show = true; |
|
|
|
} |
|
|
|
|
|
|
@ -450,13 +449,16 @@ class ConfigurationSystem { |
|
|
|
*/ |
|
|
|
_handleObject(obj, path = []) { |
|
|
|
let show = false; |
|
|
|
let config = this.options.filter; |
|
|
|
let filter = this.options.filter; |
|
|
|
let visibleInSet = false; |
|
|
|
for (let subObj in obj) { |
|
|
|
if (obj.hasOwnProperty(subObj)) { |
|
|
|
show = false; |
|
|
|
if (typeof config === 'function') { |
|
|
|
show = config(subObj,path); |
|
|
|
if (typeof filter === 'function') { |
|
|
|
show = filter(subObj,path); |
|
|
|
} |
|
|
|
else if (filter === true) { |
|
|
|
show = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (show !== false) { |
|
|
@ -583,4 +585,4 @@ class ConfigurationSystem { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default ConfigurationSystem; |
|
|
|
export default Configurator; |