Made second parameter name in function set(json, name) deprecated. Use setName(name) instead.

This commit is contained in:
josdejong 2013-04-30 15:16:13 +02:00
parent 501099056b
commit 132861b5bc
2 changed files with 19 additions and 6 deletions

View File

@ -5,15 +5,23 @@
* {String} mode Editor mode. Available values: * {String} mode Editor mode. Available values:
* 'tree' (default), 'view', * 'tree' (default), 'view',
* 'form', 'text', and 'code'. * 'form', 'text', and 'code'.
* {Boolean} search Enable search box.
* True by default
* {Boolean} history Enable history (undo/redo).
* True by default
* {function} change Callback method, triggered * {function} change Callback method, triggered
* on change of contents * on change of contents
* {Boolean} search Enable search box.
* True by default
* Only applicable for modes
* 'tree', 'view', and 'form'
* {Boolean} history Enable history (undo/redo).
* True by default
* Only applicable for modes
* 'tree', 'view', and 'form'
* {String} name Field name for the root node. * {String} name Field name for the root node.
* Only applicable for modes
* 'tree', 'view', and 'form'
* {Number} indentation Number of indentation * {Number} indentation Number of indentation
* spaces. 4 by default. * spaces. 4 by default.
* Only applicable for
* modes 'text' and 'code'
* @param {Object | undefined} json JSON object * @param {Object | undefined} json JSON object
*/ */
function JSONEditor (container, options, json) { function JSONEditor (container, options, json) {
@ -117,8 +125,10 @@ JSONEditor.prototype.getName = function () {
}; };
/** /**
* Change the mode of the editor * Change the mode of the editor.
* @param {String} mode * JSONEditor will be extended with all methods needed for the chosen mode.
* @param {String} mode Available modes: 'tree' (default), 'view', 'form',
* 'text', and 'code'.
*/ */
JSONEditor.prototype.setMode = function (mode) { JSONEditor.prototype.setMode = function (mode) {
var container = this.container, var container = this.container,

View File

@ -131,6 +131,9 @@ TreeEditor.focusNode = undefined;
TreeEditor.prototype.set = function (json, name) { TreeEditor.prototype.set = function (json, name) {
// adjust field name for root node // adjust field name for root node
if (name) { if (name) {
// TODO: deprecated since version 2.2.0. Cleanup some day.
console.log('Warning: second parameter "name" is deprecated. ' +
'Use setName(name) instead.');
this.options.name = name; this.options.name = name;
} }