From 79127d43b3fe438f229f7cd8869195de477a943a Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 6 May 2015 17:02:32 +0200 Subject: [PATCH] Added text input to ConfigurationSystem, added support for moment data type --- lib/network/modules/ConfigurationSystem.js | 25 +++++++++++++++++++++- lib/network/modules/Validator.js | 5 ++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/network/modules/ConfigurationSystem.js b/lib/network/modules/ConfigurationSystem.js index c2e57e10..b48d5124 100644 --- a/lib/network/modules/ConfigurationSystem.js +++ b/lib/network/modules/ConfigurationSystem.js @@ -347,6 +347,29 @@ class ConfigurationSystem { this._makeItem(path, label, checkbox); } + /** + * make a text input field for string options. + * @param defaultValue + * @param value + * @param path + * @private + */ + _makeTextInput(defaultValue, value, path) { + var checkbox = document.createElement('input'); + checkbox.type = 'text'; + checkbox.className = 'vis-network-configuration text'; + checkbox.value = value; + if (value !== defaultValue) { + this.changedOptions.push({path:path, value:value}); + } + + let me = this; + checkbox.onchange = function() {me._update(this.value, path)}; + + let label = this._makeLabel(path[path.length-1], path); + this._makeItem(path, label, checkbox); + } + /** * make a color field with a color picker for color fields @@ -418,7 +441,7 @@ class ConfigurationSystem { this._handleArray(item, value, newPath); } else if (typeof item === 'string') { - this._handleString(item, value, newPath); + this._makeTextInput(item, value, newPath); } else if (typeof item === 'boolean') { this._makeCheckbox(item, value, newPath); diff --git a/lib/network/modules/Validator.js b/lib/network/modules/Validator.js index 1404e4da..b2851dc3 100644 --- a/lib/network/modules/Validator.js +++ b/lib/network/modules/Validator.js @@ -141,7 +141,10 @@ class Validator { return 'date'; } if (object.nodeType !== undefined) { - return 'dom' + return 'dom'; + } + if (object._isAMomentObject === true) { + return 'moment'; } return 'object'; }