|
@ -11,15 +11,15 @@ class ConfigurationSystem { |
|
|
this.network = network; |
|
|
this.network = network; |
|
|
|
|
|
|
|
|
this.possibleOptions = { |
|
|
this.possibleOptions = { |
|
|
nodesHandler: { |
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
borderWidthSelected: 2, |
|
|
|
|
|
|
|
|
nodes: { |
|
|
|
|
|
borderWidth: [1, 0, 10, 1], |
|
|
|
|
|
borderWidthSelected: [2, 0, 10, 1], |
|
|
color: { |
|
|
color: { |
|
|
border: 'color', |
|
|
border: 'color', |
|
|
background: 'color', |
|
|
background: 'color', |
|
|
highlight: { |
|
|
highlight: { |
|
|
border: 'color', |
|
|
border: 'color', |
|
|
background: '#D2E5FF' |
|
|
|
|
|
|
|
|
background: 'color' |
|
|
}, |
|
|
}, |
|
|
hover: { |
|
|
hover: { |
|
|
border: 'color', |
|
|
border: 'color', |
|
@ -27,15 +27,15 @@ class ConfigurationSystem { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
fixed: { |
|
|
fixed: { |
|
|
x:false, |
|
|
|
|
|
y:false |
|
|
|
|
|
|
|
|
x: false, |
|
|
|
|
|
y: false |
|
|
}, |
|
|
}, |
|
|
font: { |
|
|
font: { |
|
|
color: 'color', |
|
|
color: 'color', |
|
|
size: [14,0,100,1], // px
|
|
|
|
|
|
face: ['arial','verdana','tahoma'], |
|
|
|
|
|
|
|
|
size: [14, 0, 100, 1], // px
|
|
|
|
|
|
face: ['arial', 'verdana', 'tahoma'], |
|
|
background: 'color', |
|
|
background: 'color', |
|
|
stroke: [0,0,50,1], // px
|
|
|
|
|
|
|
|
|
stroke: [0, 0, 50, 1], // px
|
|
|
strokeColor: 'color' |
|
|
strokeColor: 'color' |
|
|
}, |
|
|
}, |
|
|
group: 'string', |
|
|
group: 'string', |
|
@ -43,101 +43,101 @@ class ConfigurationSystem { |
|
|
icon: { |
|
|
icon: { |
|
|
face: 'string', //'FontAwesome',
|
|
|
face: 'string', //'FontAwesome',
|
|
|
code: 'string', //'\uf007',
|
|
|
code: 'string', //'\uf007',
|
|
|
size: [50,0,200,1], //50,
|
|
|
|
|
|
color:'color' //'#aa00ff'
|
|
|
|
|
|
|
|
|
size: [50, 0, 200, 1], //50,
|
|
|
|
|
|
color: 'color' //'#aa00ff'
|
|
|
}, |
|
|
}, |
|
|
image: 'string', // --> URL
|
|
|
image: 'string', // --> URL
|
|
|
physics: true, |
|
|
physics: true, |
|
|
scaling: { |
|
|
scaling: { |
|
|
min: [10,0,200,1], |
|
|
|
|
|
max: [30,0,200,1], |
|
|
|
|
|
|
|
|
min: [10, 0, 200, 1], |
|
|
|
|
|
max: [30, 0, 200, 1], |
|
|
label: { |
|
|
label: { |
|
|
enabled: true, |
|
|
enabled: true, |
|
|
min: [14,0,200,1], |
|
|
|
|
|
max: [30,0,200,1], |
|
|
|
|
|
maxVisible: [30,0,200,1], |
|
|
|
|
|
drawThreshold: [3,0,20,1] |
|
|
|
|
|
|
|
|
min: [14, 0, 200, 1], |
|
|
|
|
|
max: [30, 0, 200, 1], |
|
|
|
|
|
maxVisible: [30, 0, 200, 1], |
|
|
|
|
|
drawThreshold: [3, 0, 20, 1] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
shape: ['ellipse','box','circle','circularImage','database','diamond','dot','icon','image','square','star','text','triangle','triangleDown'], |
|
|
|
|
|
size: [25,0,200,1] |
|
|
|
|
|
|
|
|
shape: ['ellipse', 'box', 'circle', 'circularImage', 'database', 'diamond', 'dot', 'icon', 'image', 'square', 'star', 'text', 'triangle', 'triangleDown'], |
|
|
|
|
|
size: [25, 0, 200, 1] |
|
|
}, |
|
|
}, |
|
|
edgesHandler: { |
|
|
|
|
|
|
|
|
edges: { |
|
|
arrows: { |
|
|
arrows: { |
|
|
to: {enabled: false, scaleFactor:[1,0,3,0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
|
|
|
|
|
|
middle: {enabled: false, scaleFactor:[1,0,3,0.05]}, |
|
|
|
|
|
from: {enabled: false, scaleFactor:[1,0,3,0.05]} |
|
|
|
|
|
|
|
|
to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
|
|
|
|
|
|
middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, |
|
|
|
|
|
from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]} |
|
|
}, |
|
|
}, |
|
|
color: { |
|
|
color: { |
|
|
color:'color', |
|
|
|
|
|
highlight:'color', |
|
|
|
|
|
|
|
|
color: 'color', |
|
|
|
|
|
highlight: 'color', |
|
|
hover: 'color', |
|
|
hover: 'color', |
|
|
inherit: { |
|
|
inherit: { |
|
|
enabled: true, |
|
|
enabled: true, |
|
|
source: ['from','to'], // from / to
|
|
|
|
|
|
|
|
|
source: ['from', 'to'], // from / to
|
|
|
useGradients: false |
|
|
useGradients: false |
|
|
}, |
|
|
}, |
|
|
opacity:[1,0,1,0.05] |
|
|
|
|
|
|
|
|
opacity: [1, 0, 1, 0.05] |
|
|
}, |
|
|
}, |
|
|
dashes:{ |
|
|
|
|
|
|
|
|
dashes: { |
|
|
enabled: false, |
|
|
enabled: false, |
|
|
length: [5,0,50,1], |
|
|
|
|
|
gap: [5,0,50,1], |
|
|
|
|
|
altLength: [5,0,50,1] |
|
|
|
|
|
|
|
|
length: [5, 0, 50, 1], |
|
|
|
|
|
gap: [5, 0, 50, 1], |
|
|
|
|
|
altLength: [5, 0, 50, 1] |
|
|
}, |
|
|
}, |
|
|
font: { |
|
|
font: { |
|
|
color: 'color', |
|
|
color: 'color', |
|
|
size: [14,0,100,1], // px
|
|
|
|
|
|
face: ['arial','verdana','tahoma'], |
|
|
|
|
|
|
|
|
size: [14, 0, 100, 1], // px
|
|
|
|
|
|
face: ['arial', 'verdana', 'tahoma'], |
|
|
background: 'color', |
|
|
background: 'color', |
|
|
stroke: [0,0,50,1], // px
|
|
|
|
|
|
|
|
|
stroke: [0, 0, 50, 1], // px
|
|
|
strokeColor: 'color', |
|
|
strokeColor: 'color', |
|
|
align:['horizontal','top','middle','bottom'] |
|
|
|
|
|
|
|
|
align: ['horizontal', 'top', 'middle', 'bottom'] |
|
|
}, |
|
|
}, |
|
|
hidden: false, |
|
|
hidden: false, |
|
|
hoverWidth: [1.5,0,10,0.1], |
|
|
|
|
|
|
|
|
hoverWidth: [1.5, 0, 10, 0.1], |
|
|
physics: true, |
|
|
physics: true, |
|
|
scaling: { |
|
|
scaling: { |
|
|
min: [10,0,200,1], |
|
|
|
|
|
max: [30,0,200,1], |
|
|
|
|
|
|
|
|
min: [10, 0, 200, 1], |
|
|
|
|
|
max: [30, 0, 200, 1], |
|
|
label: { |
|
|
label: { |
|
|
enabled: true, |
|
|
enabled: true, |
|
|
min: [14,0,200,1], |
|
|
|
|
|
max: [30,0,200,1], |
|
|
|
|
|
maxVisible: [30,0,200,1], |
|
|
|
|
|
drawThreshold: [3,0,20,1] |
|
|
|
|
|
|
|
|
min: [14, 0, 200, 1], |
|
|
|
|
|
max: [30, 0, 200, 1], |
|
|
|
|
|
maxVisible: [30, 0, 200, 1], |
|
|
|
|
|
drawThreshold: [3, 0, 20, 1] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
selfReferenceSize:[20,0,200,1], |
|
|
|
|
|
|
|
|
selfReferenceSize: [20, 0, 200, 1], |
|
|
smooth: { |
|
|
smooth: { |
|
|
enabled: true, |
|
|
enabled: true, |
|
|
dynamic: true, |
|
|
dynamic: true, |
|
|
type: ["continuous",'discrete','diagonalCross','straightCross','horizontal','vertical','curvedCW','curvedCCW'], |
|
|
|
|
|
roundness: [0.5,0,1,0.05] |
|
|
|
|
|
|
|
|
type: ["continuous", 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW'], |
|
|
|
|
|
roundness: [0.5, 0, 1, 0.05] |
|
|
}, |
|
|
}, |
|
|
width: [1,0,30,1], |
|
|
|
|
|
widthSelectionMultiplier: [2,0,5,0.1] |
|
|
|
|
|
|
|
|
width: [1, 0, 30, 1], |
|
|
|
|
|
widthSelectionMultiplier: [2, 0, 5, 0.1] |
|
|
}, |
|
|
}, |
|
|
layout:{ |
|
|
|
|
|
randomSeed: [0,0,500,1], |
|
|
|
|
|
|
|
|
layout: { |
|
|
|
|
|
randomSeed: [0, 0, 500, 1], |
|
|
hierarchical: { |
|
|
hierarchical: { |
|
|
enabled:false, |
|
|
|
|
|
levelSeparation: [150,20,500,5], |
|
|
|
|
|
direction: ["UD",'DU','LR','RL'], // UD, DU, LR, RL
|
|
|
|
|
|
sortMethod: ["hubsize",'directed'] // hubsize, directed
|
|
|
|
|
|
|
|
|
enabled: false, |
|
|
|
|
|
levelSeparation: [150, 20, 500, 5], |
|
|
|
|
|
direction: ["UD", 'DU', 'LR', 'RL'], // UD, DU, LR, RL
|
|
|
|
|
|
sortMethod: ["hubsize", 'directed'] // hubsize, directed
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
interaction: { |
|
|
interaction: { |
|
|
dragNodes:true, |
|
|
|
|
|
|
|
|
dragNodes: true, |
|
|
dragView: true, |
|
|
dragView: true, |
|
|
zoomView: true, |
|
|
zoomView: true, |
|
|
hoverEnabled: false, |
|
|
hoverEnabled: false, |
|
|
showNavigationIcons: false, |
|
|
showNavigationIcons: false, |
|
|
tooltip: { |
|
|
tooltip: { |
|
|
delay: [300,0,1000,25], |
|
|
|
|
|
|
|
|
delay: [300, 0, 1000, 25], |
|
|
fontColor: 'color', |
|
|
fontColor: 'color', |
|
|
fontSize: [14,0,40,1], // px
|
|
|
|
|
|
fontFace: ['arial','verdana','tahoma'], |
|
|
|
|
|
|
|
|
fontSize: [14, 0, 40, 1], // px
|
|
|
|
|
|
fontFace: ['arial', 'verdana', 'tahoma'], |
|
|
color: { |
|
|
color: { |
|
|
border: 'color', |
|
|
border: 'color', |
|
|
background: 'color' |
|
|
background: 'color' |
|
@ -145,15 +145,15 @@ class ConfigurationSystem { |
|
|
}, |
|
|
}, |
|
|
keyboard: { |
|
|
keyboard: { |
|
|
enabled: false, |
|
|
enabled: false, |
|
|
speed: {x: [10,0,40,1], y: [10,0,40,1], zoom: [0.02,0,0.1,0.005]}, |
|
|
|
|
|
|
|
|
speed: {x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005]}, |
|
|
bindToWindow: true |
|
|
bindToWindow: true |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
manipulation:{ |
|
|
|
|
|
|
|
|
manipulation: { |
|
|
enabled: false, |
|
|
enabled: false, |
|
|
initiallyVisible: false, |
|
|
initiallyVisible: false, |
|
|
locale: ['en','nl'], |
|
|
|
|
|
functionality:{ |
|
|
|
|
|
|
|
|
locale: ['en', 'nl'], |
|
|
|
|
|
functionality: { |
|
|
addNode: true, |
|
|
addNode: true, |
|
|
addEdge: true, |
|
|
addEdge: true, |
|
|
editNode: true, |
|
|
editNode: true, |
|
@ -164,33 +164,33 @@ class ConfigurationSystem { |
|
|
}, |
|
|
}, |
|
|
physics: { |
|
|
physics: { |
|
|
barnesHut: { |
|
|
barnesHut: { |
|
|
theta: [0.5,0.1,1,0.05], |
|
|
|
|
|
gravitationalConstant: [-2000,-300000,0,50], |
|
|
|
|
|
centralGravity: [0.3,0,10,0.05], |
|
|
|
|
|
springLength: [95,0,500,5], |
|
|
|
|
|
springConstant: [0.04,0,5,0.005], |
|
|
|
|
|
damping: [0.09,0,1,0.01] |
|
|
|
|
|
|
|
|
theta: [0.5, 0.1, 1, 0.05], |
|
|
|
|
|
gravitationalConstant: [-2000, -300000, 0, 50], |
|
|
|
|
|
centralGravity: [0.3, 0, 10, 0.05], |
|
|
|
|
|
springLength: [95, 0, 500, 5], |
|
|
|
|
|
springConstant: [0.04, 0, 5, 0.005], |
|
|
|
|
|
damping: [0.09, 0, 1, 0.01] |
|
|
}, |
|
|
}, |
|
|
repulsion: { |
|
|
repulsion: { |
|
|
centralGravity: [0.2,0,10,0.05], |
|
|
|
|
|
springLength: [200,0,500,5], |
|
|
|
|
|
springConstant: [0.05,0,5,0.005], |
|
|
|
|
|
nodeDistance: [100,0,500,5], |
|
|
|
|
|
damping: [0.09,0,1,0.01] |
|
|
|
|
|
|
|
|
centralGravity: [0.2, 0, 10, 0.05], |
|
|
|
|
|
springLength: [200, 0, 500, 5], |
|
|
|
|
|
springConstant: [0.05, 0, 5, 0.005], |
|
|
|
|
|
nodeDistance: [100, 0, 500, 5], |
|
|
|
|
|
damping: [0.09, 0, 1, 0.01] |
|
|
}, |
|
|
}, |
|
|
hierarchicalRepulsion: { |
|
|
hierarchicalRepulsion: { |
|
|
centralGravity: 0.2, |
|
|
|
|
|
springLength: [100,0,500,5], |
|
|
|
|
|
springConstant: [0.01,0,5,0.005], |
|
|
|
|
|
nodeDistance: [120,0,500,5], |
|
|
|
|
|
damping: [0.09,0,1,0.01] |
|
|
|
|
|
|
|
|
centralGravity: [0.2, 0, 10, 0.05], |
|
|
|
|
|
springLength: [100, 0, 500, 5], |
|
|
|
|
|
springConstant: [0.01, 0, 5, 0.005], |
|
|
|
|
|
nodeDistance: [120, 0, 500, 5], |
|
|
|
|
|
damping: [0.09, 0, 1, 0.01] |
|
|
}, |
|
|
}, |
|
|
maxVelocity: [50,0,150,1], |
|
|
|
|
|
minVelocity: [0.1,0.01,0.5,0.01], |
|
|
|
|
|
solver: ['BarnesHut','Repulsion','HierarchicalRepulsion'], |
|
|
|
|
|
timestep: [0.5,0,1,0.05] |
|
|
|
|
|
|
|
|
maxVelocity: [50, 0, 150, 1], |
|
|
|
|
|
minVelocity: [0.1, 0.01, 0.5, 0.01], |
|
|
|
|
|
solver: ['BarnesHut', 'Repulsion', 'HierarchicalRepulsion'], |
|
|
|
|
|
timestep: [0.5, 0, 1, 0.05] |
|
|
}, |
|
|
}, |
|
|
selection:{ |
|
|
|
|
|
|
|
|
selection: { |
|
|
select: true, |
|
|
select: true, |
|
|
selectConnectedEdges: true |
|
|
selectConnectedEdges: true |
|
|
}, |
|
|
}, |
|
@ -208,6 +208,12 @@ class ConfigurationSystem { |
|
|
setOptions(options) { |
|
|
setOptions(options) { |
|
|
if (options !== undefined) { |
|
|
if (options !== undefined) { |
|
|
util.deepExtend(this.actualOptions, options); |
|
|
util.deepExtend(this.actualOptions, options); |
|
|
|
|
|
if (options.configurationContainer !== undefined) { |
|
|
|
|
|
this.container = options.configurationContainer; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
this.container = this.network.body.container; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (options.configure !== undefined && options.configure !== false) { |
|
|
if (options.configure !== undefined && options.configure !== false) { |
|
|
let config; |
|
|
let config; |
|
@ -240,75 +246,215 @@ class ConfigurationSystem { |
|
|
*/ |
|
|
*/ |
|
|
_create(config) { |
|
|
_create(config) { |
|
|
this._clean(); |
|
|
this._clean(); |
|
|
|
|
|
|
|
|
|
|
|
let counter = 0; |
|
|
for (let option in this.possibleOptions) { |
|
|
for (let option in this.possibleOptions) { |
|
|
if (this.possibleOptions.hasOwnProperty(option)) { |
|
|
if (this.possibleOptions.hasOwnProperty(option)) { |
|
|
if (config === true || config.indexOf(option) !== -1) { |
|
|
if (config === true || config.indexOf(option) !== -1) { |
|
|
let optionObj = this.possibleOptions[option]; |
|
|
let optionObj = this.possibleOptions[option]; |
|
|
|
|
|
|
|
|
|
|
|
if (counter > 0) { |
|
|
|
|
|
this._makeBreak(); |
|
|
|
|
|
} |
|
|
// a header for the category
|
|
|
// a header for the category
|
|
|
this._makeHeader(option); |
|
|
this._makeHeader(option); |
|
|
|
|
|
|
|
|
// get the suboptions
|
|
|
// get the suboptions
|
|
|
for (let subOption in optionObj) { |
|
|
|
|
|
if (optionObj.hasOwnProperty(subOption)) { |
|
|
|
|
|
this._makeLabel(subOption); |
|
|
|
|
|
let subOptionObj = optionObj[subOption]; |
|
|
|
|
|
if (subOptionObj instanceof Array) { |
|
|
|
|
|
this._handleArray(option, subOption, subOptionObj); |
|
|
|
|
|
} |
|
|
|
|
|
else if (subOptionObj instanceof Object) { |
|
|
|
|
|
this._handleObject(option, subOption, subOptionObj); |
|
|
|
|
|
} |
|
|
|
|
|
else if (typeof subOptionObj === 'string') { |
|
|
|
|
|
this._handleString(option, subOption, subOptionObj); |
|
|
|
|
|
} |
|
|
|
|
|
else if (typeof subOptionObj === 'boolean') { |
|
|
|
|
|
this._handleBoolean(option, subOption, subOptionObj); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
console.error("dont know how to handle", subOptionObj); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let path = [option]; |
|
|
|
|
|
this._handleObject(optionObj, path); |
|
|
} |
|
|
} |
|
|
|
|
|
counter++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._push(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_push() { |
|
|
|
|
|
for (var i = 0; i < this.domElements.length; i++) { |
|
|
|
|
|
this.container.appendChild(this.domElements[i]); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_clean() { |
|
|
_clean() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_getValue(path) { |
|
|
|
|
|
let base = this.actualOptions; |
|
|
|
|
|
for (let i = 0; i < path.length; i++) { |
|
|
|
|
|
if (base[path[i]] !== undefined) { |
|
|
|
|
|
base = base[path[i]]; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
base = undefined; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return base; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_addToPath(path, newValue) { |
|
|
|
|
|
let newPath = []; |
|
|
|
|
|
for (let i = 0; i < path.length; i++) { |
|
|
|
|
|
newPath.push(path[i]); |
|
|
|
|
|
} |
|
|
|
|
|
newPath.push(newValue); |
|
|
|
|
|
return newPath; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
_makeHeader(name) { |
|
|
_makeHeader(name) { |
|
|
console.log("header",name); |
|
|
|
|
|
//let div = document.createElement('div');
|
|
|
|
|
|
//div.className = 'vis-network-configuration header';
|
|
|
|
|
|
//div.innerHTML = name;
|
|
|
|
|
|
//this.domElements.push(div);
|
|
|
|
|
|
|
|
|
let div = document.createElement('div'); |
|
|
|
|
|
div.className = 'vis-network-configuration header'; |
|
|
|
|
|
div.innerHTML = name; |
|
|
|
|
|
this.domElements.push(div); |
|
|
|
|
|
this._makeBreak(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_makeLabel(name, path) { |
|
|
|
|
|
let div = document.createElement('div'); |
|
|
|
|
|
div.className = 'vis-network-configuration label'; |
|
|
|
|
|
div.innerHTML = name; |
|
|
|
|
|
div.style.left = ((path.length - 1) * 10) + 'px'; |
|
|
|
|
|
this.domElements.push(div); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_makeDropdown(arr, value) { |
|
|
|
|
|
let select = document.createElement('select'); |
|
|
|
|
|
select.className = 'vis-network-configuration select'; |
|
|
|
|
|
let selectedValue = 0; |
|
|
|
|
|
if (value !== undefined) { |
|
|
|
|
|
if (arr.indexOf(value) !== -1) { |
|
|
|
|
|
selectedValue = arr.indexOf(value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < arr.length; i++) { |
|
|
|
|
|
let option = document.createElement("option"); |
|
|
|
|
|
option.value = arr[i]; |
|
|
|
|
|
if (i == selectedValue) { |
|
|
|
|
|
option.selected = 'selected'; |
|
|
|
|
|
} |
|
|
|
|
|
option.innerHTML = arr[i]; |
|
|
|
|
|
select.appendChild(option); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
select.onchange = function () {me._update(this.value, path);} |
|
|
|
|
|
|
|
|
|
|
|
this.domElements.push(select); |
|
|
|
|
|
this._makeBreak(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_makeRange(arr, value, path) { |
|
|
|
|
|
let defaultValue = arr[0]; |
|
|
|
|
|
let min = arr[1]; |
|
|
|
|
|
let max = arr[2]; |
|
|
|
|
|
let step = arr[3]; |
|
|
|
|
|
let range = document.createElement('input'); |
|
|
|
|
|
range.type = 'range'; |
|
|
|
|
|
range.className = 'vis-network-configuration range' |
|
|
|
|
|
range.value = defaultValue; |
|
|
|
|
|
range.min = min; |
|
|
|
|
|
range.max = max; |
|
|
|
|
|
range.step = step; |
|
|
|
|
|
if (value !== undefined) { |
|
|
|
|
|
range.value = value; |
|
|
|
|
|
if (value * 0.1 < min) { |
|
|
|
|
|
range.min = value / 10; |
|
|
|
|
|
} |
|
|
|
|
|
if (value * 10 > max && max !== 1) { |
|
|
|
|
|
range.max = value * 10; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
let input = document.createElement("input"); |
|
|
|
|
|
input.className = 'vis-network-configuration rangeinput' |
|
|
|
|
|
input.value = range.value; |
|
|
|
|
|
|
|
|
|
|
|
var me = this; |
|
|
|
|
|
range.onchange = function () {input.value = this.value; me._update(this.value, path);} |
|
|
|
|
|
range.oninput = function () {input.value = this.value;} |
|
|
|
|
|
this.domElements.push(range); |
|
|
|
|
|
this.domElements.push(input); |
|
|
|
|
|
this._makeBreak(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_makeLabel(name) { |
|
|
|
|
|
console.log("label",name); |
|
|
|
|
|
//let div = document.createElement('div');
|
|
|
|
|
|
//div.className = 'vis-network-configuration label';
|
|
|
|
|
|
//div.innerHTML = name;
|
|
|
|
|
|
//this.domElements.push(div);
|
|
|
|
|
|
|
|
|
_makeCheckbox(defaultValue, value, path) { |
|
|
|
|
|
var checkbox = document.createElement('input'); |
|
|
|
|
|
checkbox.type = "checkbox"; |
|
|
|
|
|
checkbox.checked = defaultValue; |
|
|
|
|
|
if (value !== undefined) { |
|
|
|
|
|
checkbox.checked = value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let me = this; |
|
|
|
|
|
checkbox.onchange = function() {me._update(this.value, path)} |
|
|
|
|
|
|
|
|
|
|
|
this.domElements.push(checkbox); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_handleObject(category, subcategory, obj) { |
|
|
|
|
|
console.log("obj",obj); |
|
|
|
|
|
|
|
|
_makeBreak() { |
|
|
|
|
|
this.domElements.push(document.createElement("br")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_handleArray(category, subcategory, arr) { |
|
|
|
|
|
console.log("arr",arr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_handleObject(obj, path = []) { |
|
|
|
|
|
for (let subObj in obj) { |
|
|
|
|
|
if (obj.hasOwnProperty(subObj)) { |
|
|
|
|
|
let item = obj[subObj]; |
|
|
|
|
|
let value = this._getValue(path); |
|
|
|
|
|
|
|
|
|
|
|
let newPath = this._addToPath(path, subObj); |
|
|
|
|
|
if (item instanceof Array) { |
|
|
|
|
|
this._handleArray(subObj, item, value, newPath); |
|
|
|
|
|
} |
|
|
|
|
|
else if (typeof item === 'string') { |
|
|
|
|
|
this._handleString(subObj, item, value, newPath); |
|
|
|
|
|
} |
|
|
|
|
|
else if (typeof item === 'boolean') { |
|
|
|
|
|
this._handleBoolean(subObj, item, value, newPath); |
|
|
|
|
|
} |
|
|
|
|
|
else if (item instanceof Object) { |
|
|
|
|
|
this._makeLabel(subObj, newPath); |
|
|
|
|
|
this._makeBreak(); |
|
|
|
|
|
this._handleObject(item, newPath); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
console.error("dont know how to handle", item, subObj, newPath); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_handleArray(optionName, arr, value, path) { |
|
|
|
|
|
this._makeLabel(optionName, path); |
|
|
|
|
|
|
|
|
|
|
|
if (typeof arr[0] === 'string') { |
|
|
|
|
|
this._makeDropdown(arr, value, path); |
|
|
|
|
|
} |
|
|
|
|
|
else if (typeof arr[0] === 'number') { |
|
|
|
|
|
this._makeRange(arr, value, path); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_handleString(optionName, string, value, path) { |
|
|
|
|
|
if (string !== 'color') { |
|
|
|
|
|
this._makeLabel(optionName, path); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
this._makeLabel(optionName, path); |
|
|
|
|
|
//console.log("string", string, value, path);
|
|
|
|
|
|
} |
|
|
|
|
|
this._makeLabel(string, []); |
|
|
|
|
|
this._makeBreak(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_handleString(category, subcategory, string) { |
|
|
|
|
|
console.log("string",string); |
|
|
|
|
|
|
|
|
_handleBoolean(optionName, boolean, value, path) { |
|
|
|
|
|
this._makeLabel(optionName, path); |
|
|
|
|
|
this._makeCheckbox(boolean, value, path); |
|
|
|
|
|
this._makeBreak(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_handleBoolean(category, subcategory, boolean) { |
|
|
|
|
|
console.log("boolean",boolean); |
|
|
|
|
|
|
|
|
_update(value, path) { |
|
|
|
|
|
console.log("updated", value, path) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|