/*! JSON Editor v0.7.22 - JSON Schema -> HTML Editor
* By Jeremy Dorn - https://github.com/jdorn/json-editor/
* Released under the MIT license
*
* Date: 2015-08-12
*/
/**
* See README.md for requirements and usage info
*/
(function() {
/*jshint loopfunc: true */
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
var Class;
(function(){
var initializing = false, fnTest = /xyz/.test(function(){window.postMessage("xyz");}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
Class = function(){};
// Create a new Class that inherits from this class
// Instantiate a base class (but only create the instance,
// don't run the init constructor)
initializing = true;
var prototype = new this();
initializing = false;
// Copy the properties over onto the new prototype
// Check if we're overwriting an existing function
return function() {
// Add a new ._super() method that is the same method
// but on the super-class
// The method only need to be bound temporarily, so we
// remove it when we're done executing
return ret;
};
}
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if ( !initializing && this.init )
}
// Populate our constructed prototype object
// Enforce the constructor to be what we expect
// And make this class extendable
return Class;
};
return Class;
})();
// CustomEvent constructor polyfill
// From MDN
(function () {
return evt;
}
})();
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
}
if (!window.requestAnimationFrame)
return id;
};
if (!window.cancelAnimationFrame)
};
}());
// Array.isArray polyfill
// From MDN
(function() {
if(!Array.isArray) {
};
}
}());
/**
* Taken from jQuery 2.1.3
*
* @param obj
* @returns {boolean}
*/
// Not plain objects:
// - Any object or value whose internal [[Class]] property is not "[object Object]"
// - DOM nodes
// - window
return false;
}
if (obj.constructor && !Object.prototype.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
return false;
}
// If the function hasn't returned already, we're confident that
// |obj| is a plain object, created by {} or constructed with new Object
return true;
};
}
else {
}
}
}
return destination;
};
var i;
if(Array.isArray(obj) || (typeof obj.length === 'number' && obj.length > 0 && (obj.length - 1) in obj)) {
}
}
else {
if (Object.keys) {
}
}
else {
for(i in obj) {
if(!obj.hasOwnProperty(i)) continue;
}
}
}
};
el.dispatchEvent(e);
};
var e = new CustomEvent(event,{
bubbles: true,
cancelable: true
});
el.dispatchEvent(e);
};
throw new Error('element should be an instance of Element');
}
this.init();
};
JSONEditor.prototype = {
// necessary since we remove the ctor property by doing a literal assignment. Without this
// the $isplainobject function will think that this is a plain object.
init: function() {
var self = this;
this.ready = false;
this.theme = new theme_class();
this.uuid = 0;
this.__data = {};
// Fetch all external refs via ajax
this._loadExternalRefs(this.schema, function() {
// Create the root editor
required: true,
});
// Starting data
// Fire ready event asynchronously
window.requestAnimationFrame(function() {
});
});
},
getValue: function() {
if(!this.ready) throw "JSON Editor not ready yet. Listen for 'ready' event before getting the value";
},
if(!this.ready) throw "JSON Editor not ready yet. Listen for 'ready' event before setting the value";
return this;
},
if(!this.ready) throw "JSON Editor not ready yet. Listen for 'ready' event before validating";
// Custom value
}
// Current value (use cached result)
else {
return this.validation_results;
}
},
destroy: function() {
if(this.destroyed) return;
if(!this.ready) return;
this.schema = null;
this.options = null;
this.root = null;
this.root_container = null;
this.validator = null;
this.validation_results = null;
this.theme = null;
this.iconlib = null;
this.template = null;
this.__data = null;
this.ready = false;
this.destroyed = true;
},
return this;
},
// Specific callback
var newcallbacks = [];
}
}
// All callbacks for a specific event
else if(event) {
}
// All callbacks for all events
else {
this.callbacks = {};
}
return this;
},
}
}
return this;
},
if(option === "show_errors") {
this.onChange();
}
// Only the `show_errors` option is supported for now
else {
}
return this;
},
getEditorClass: function(schema) {
var classname;
if(tmp) {
return false;
}
}
});
},
return new editor_class(options);
},
onChange: function() {
if(!this.ready) return;
if(this.firing_change) return;
this.firing_change = true;
var self = this;
window.requestAnimationFrame(function() {
self.firing_change = false;
// Validate and cache results
}
else {
}
// Fire change event
});
return this;
},
var engine;
// Specifying a preset engine
if(typeof name === 'string') {
}
// Specifying a custom engine
else {
}
if(!engine) throw "No template engine set";
},
// Setting data
var uuid;
}
else {
}
}
// Getting data
else {
// No data stored
}
},
registerEditor: function(editor) {
return this;
},
unregisterEditor: function(editor) {
return this;
},
if(!this.editors) return;
},
return this;
},
// If removing all callbacks for a path
if(!callback) {
return this;
}
var newlist = [];
}
return this;
},
notifyWatchers: function(path) {
}
},
isEnabled: function() {
},
enable: function() {
},
disable: function() {
},
if(schema.definitions) {
for(var i in schema.definitions) {
}
}
}
},
_getExternalRefs: function(schema) {
var refs = {};
for(var i in newrefs) {
if(newrefs.hasOwnProperty(i)) {
refs[i] = true;
}
}
};
if(schema.$ref && typeof schema.$ref !== "object" && schema.$ref.substr(0,1) !== "#" && !this.refs[schema.$ref]) {
}
for(var i in schema) {
if(!schema.hasOwnProperty(i)) continue;
if(typeof schema[i][j]==="object") {
}
}
}
}
}
return refs;
},
var self = this;
waiting++;
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState != 4) return;
// Request succeeded
if(r.status === 200) {
var response;
try {
}
catch(e) {
throw "Failed to parse external ref "+url;
}
if(!response || typeof response !== "object") throw "External ref does not contain a valid schema - "+url;
done++;
callback_fired = true;
callback();
}
});
}
// Request failed
else {
throw "Failed to fetch ref via ajax- "+url;
}
};
r.send();
});
if(!waiting) {
callback();
}
},
expandRefs: function(schema) {
}
return schema;
},
expandSchema: function(schema) {
var self = this;
var i;
// Version 3 `type`
// Array of types
// Schema
if(typeof value === 'object') {
}
});
}
// Schema
else {
}
}
// Version 3 `disallow`
// Array of types
// Schema
if(typeof value === 'object') {
}
});
}
// Schema
else {
}
}
// Version 4 `anyOf`
});
}
// Version 4 `dependencies` (schema dependencies)
if(schema.dependencies) {
}
});
}
// Version 4 `not`
}
// allOf schemas should be merged into the parent
}
}
// extends schemas should be merged into parent
if(schema["extends"]) {
// If extends is a schema
}
// If extends is an array of schemas
else {
}
}
delete extended["extends"];
}
// parent should be merged into oneOf schemas
}
}
return this.expandRefs(extended);
},
var self = this;
var extended = {};
// If this key is also defined in obj2, merge them
// Required arrays should be unioned together
// Union arrays and unique
return p;
}, []);
}
// Type should be intersected and is either an array or string
// Make sure we're dealing with arrays
});
// If there's only 1 type and it's a primitive, use a string instead of array
}
}
// All other arrays should be intersected (enum, etc.)
});
}
// Objects should be recursively merged
}
// Otherwise, use the first value
else {
}
}
// Otherwise, just use the one in obj1
else {
}
});
// Properties in obj2 that aren't in obj1
}
});
return extended;
}
};
JSONEditor.defaults = {
themes: {},
templates: {},
iconlibs: {},
editors: {},
languages: {},
resolvers: [],
};
this.jsoneditor = jsoneditor;
this.options = {};
},
},
var self = this;
var errors = [];
var valid, i, j;
// Work on a copy of the schema
/*
* Type Agnostic Validation
*/
// Version 3 `required`
if(typeof value === "undefined") {
property: 'required',
});
// Can't do any more validation at this point
return errors;
}
}
// Value not defined
else if(typeof value === "undefined") {
// If required_by_default is set, all fields are required
property: 'required',
});
}
// Not required, no further validation needed
else {
return errors;
}
}
// `enum`
if(schema["enum"]) {
valid = false;
}
if(!valid) {
property: 'enum',
});
}
}
// `extends` (version 3)
if(schema["extends"]) {
}
}
// `allOf`
}
}
// `anyOf`
valid = false;
valid = true;
break;
}
}
if(!valid) {
property: 'anyOf',
});
}
}
// `oneOf`
valid = 0;
var oneof_errors = [];
// Set the error paths to be path.oneOf[i].rest.of.path
valid++;
}
}
}
if(valid !== 1) {
property: 'oneOf',
});
}
}
// `not`
property: 'not',
});
}
}
// `type` (both Version 3 and Version 4 support)
// Union type
valid = false;
valid = true;
break;
}
}
if(!valid) {
property: 'type',
});
}
}
// Simple type
else {
property: 'type',
});
}
}
}
// `disallow` (version 3)
// Union type
valid = true;
valid = false;
break;
}
}
if(!valid) {
property: 'disallow',
});
}
}
// Simple type
else {
property: 'disallow',
});
}
}
}
/*
* Type Specific Validation
*/
// Number Specific Validation
if(typeof value === "number") {
// `multipleOf` and `divisibleBy`
});
}
}
// `maximum`
property: 'maximum',
});
}
property: 'maximum',
});
}
}
// `minimum`
property: 'minimum',
});
}
property: 'minimum',
});
}
}
}
// String specific validation
else if(typeof value === "string") {
// `maxLength`
property: 'maxLength',
});
}
}
// `minLength`
property: 'minLength',
message: this.translate((schema.minLength===1?'error_notempty':'error_minLength'), [schema.minLength])
});
}
}
// `pattern`
property: 'pattern',
});
}
}
}
// Array specific validation
// `items` and `additionalItems`
// `items` is an array
// If this item has a specific schema tied to it
// Validate against it
}
// If all additional items are allowed
else if(schema.additionalItems === true) {
break;
}
// If additional items is a schema
// TODO: Incompatibility between version 3 and 4 of the spec
else if(schema.additionalItems) {
}
// If no additional items are allowed
else if(schema.additionalItems === false) {
property: 'additionalItems',
});
break;
}
// Default for `additionalItems` is an empty schema
else {
break;
}
}
}
// `items` is a schema
else {
// Each item in the array must validate against the schema
}
}
}
// `maxItems`
property: 'maxItems',
});
}
}
// `minItems`
property: 'minItems',
});
}
}
// `uniqueItems`
if(schema.uniqueItems) {
var seen = {};
property: 'uniqueItems',
});
break;
}
}
}
}
// Object specific validation
// `maxProperties`
if(schema.maxProperties) {
valid = 0;
for(i in value) {
if(!value.hasOwnProperty(i)) continue;
valid++;
}
property: 'maxProperties',
});
}
}
// `minProperties`
if(schema.minProperties) {
valid = 0;
for(i in value) {
if(!value.hasOwnProperty(i)) continue;
valid++;
}
property: 'minProperties',
});
}
}
// Version 4 `required`
property: 'required',
});
}
}
}
// `properties`
var validated_properties = {};
if(schema.properties) {
for(i in schema.properties) {
validated_properties[i] = true;
}
}
// `patternProperties`
if(schema.patternProperties) {
for(i in schema.patternProperties) {
var regex = new RegExp(i);
// Check which properties match
for(j in value) {
if(!value.hasOwnProperty(j)) continue;
validated_properties[j] = true;
}
}
}
}
// The no_additional_properties option currently doesn't work with extended schemas that use oneOf or anyOf
if(typeof schema.additionalProperties === "undefined" && this.jsoneditor.options.no_additional_properties && !schema.oneOf && !schema.anyOf) {
schema.additionalProperties = false;
}
// `additionalProperties`
for(i in value) {
if(!value.hasOwnProperty(i)) continue;
if(!validated_properties[i]) {
// No extra properties allowed
if(!schema.additionalProperties) {
property: 'additionalProperties',
});
break;
}
// Allowed
else if(schema.additionalProperties === true) {
break;
}
// Must match schema
// TODO: incompatibility between version 3 and 4 of the spec
else {
}
}
}
}
// `dependencies`
if(schema.dependencies) {
for(i in schema.dependencies) {
// Doesn't need to meet the dependency
if(typeof value[i] === "undefined") continue;
// Property dependency
property: 'dependencies',
});
}
}
}
// Schema dependency
else {
}
}
}
}
// Custom type validation
});
return errors;
},
// Simple types
if(typeof type === "string") {
else if(type === "object") return value !== null && !(Array.isArray(value)) && typeof value === "object";
else return true;
}
// Schema
else {
}
}
});
/**
* All editors should extend from this class
*/
onChildEditorChange: function(editor) {
this.onChange(true);
},
notify: function() {
},
change: function() {
else this.jsoneditor.onChange();
},
this.notify();
if(this.watch_listener) this.watch_listener();
},
register: function() {
this.jsoneditor.registerEditor(this);
this.onChange();
},
unregister: function() {
if(!this.jsoneditor) return;
this.jsoneditor.unregisterEditor(this);
},
getNumColumns: function() {
return 12;
},
if(this.jsoneditor.options.form_name_root) this.formname = this.formname.replace(/^root\[/,this.jsoneditor.options.form_name_root+'[');
this.link_watchers = [];
},
setContainer: function(container) {
if(this.schema.type && typeof this.schema.type === "string") this.container.setAttribute('data-schematype',this.schema.type);
},
preBuild: function() {
},
build: function() {
},
postBuild: function() {
this.setupWatchListeners();
this.addLinks();
this.setValue(this.getDefault(), true);
this.updateHeaderText();
this.register();
this.onWatchedFieldChange();
},
setupWatchListeners: function() {
var self = this;
// Watched fields
this.watched = {};
this.watched_values = {};
this.watch_listener = function() {
if(self.refreshWatchedFieldValues()) {
}
};
this.register();
}
else {
if(!self.theme.closest(self.container,'[data-schemaid="'+path_parts[0]+'"]')) path_parts.unshift('#');
}
// Find the root node for this template variable
// Keep track of the root node and path for use when rendering the template
}
}
// Dynamic header
if(this.schema.headerTemplate) {
this.header_template = this.jsoneditor.compileTemplate(this.schema.headerTemplate, this.template_engine);
}
},
addLinks: function() {
// Add links
if(!this.no_link_holder) {
}
}
}
},
title = null;
}
return btn;
},
title = null;
}
},
},
// Get mime type of the link
// Template to generate the link href
// Image links
if(type === 'image') {
// When a watched field changes, update the url
});
}
// When a watched field changes, update the url
});
}
// Text links
else {
// When a watched field changes, update the url
});
}
return holder;
},
refreshWatchedFieldValues: function() {
if(!this.watched_values) return;
var watched = {};
var changed = false;
var self = this;
if(this.watched) {
}
}
this.watched_values = watched;
return changed;
},
getWatchedFieldValues: function() {
return this.watched_values;
},
updateHeaderText: function() {
if(this.header) {
// If the header has children, only update the text node's value
break;
}
}
}
// Otherwise, just update the entire node
else {
}
}
},
getHeaderText: function(title_only) {
if(this.header_text) return this.header_text;
else return this.getTitle();
},
onWatchedFieldChange: function() {
var vars;
if(this.header_template) {
i: this.key,
});
if(header_text !== this.header_text) {
this.header_text = header_text;
this.updateHeaderText();
this.notify();
//this.fireChangeHeaderEvent();
}
}
if(this.link_watchers.length) {
vars = this.getWatchedFieldValues();
this.link_watchers[i](vars);
}
}
},
},
getValue: function() {
return this.value;
},
refreshValue: function() {
},
getChildEditors: function() {
return false;
},
destroy: function() {
var self = this;
this.unregister(this);
});
this.watched = null;
this.watched_values = null;
this.watch_listener = null;
this.header_text = null;
this.header_template = null;
this.value = null;
if(this.container && this.container.parentNode) this.container.parentNode.removeChild(this.container);
this.container = null;
this.jsoneditor = null;
this.schema = null;
this.path = null;
this.key = null;
this.parent = null;
},
getDefault: function() {
if(typeof type === "string") {
if(type === "boolean") return false;
if(type === "object") return {};
if(type === "array") return [];
}
return null;
},
getTitle: function() {
},
enable: function() {
this.disabled = false;
},
disable: function() {
this.disabled = true;
},
isEnabled: function() {
return !this.disabled;
},
isRequired: function() {
else if(this.parent && this.parent.schema && Array.isArray(this.parent.schema.required)) return this.parent.schema.required.indexOf(this.key) > -1;
else return false;
},
getDisplayText: function(arr) {
var disp = [];
var used = {};
// Determine how many times each attribute name is used.
// This helps us pick the most distinct display text for the schemas.
}
if(el.description) {
}
}
}
});
// Determine display text for each element of the array
var name;
// If it's a simple string
// Object
else name = "type";
});
// Replace identical display text with "text 1", "text 2", etc.
var inc = {};
});
return disp;
},
try {
throw "getOption is deprecated";
}
catch(e) {
}
},
showValidationErrors: function(errors) {
}
});
getValue: function() {
return null;
},
setValue: function() {
this.onChange();
},
getNumColumns: function() {
return 2;
}
});
register: function() {
this._super();
if(!this.input) return;
},
unregister: function() {
this._super();
if(!this.input) return;
},
var self = this;
if(this.template && !from_template) {
return;
}
if(value === this.serialized) return;
// Sanitize value before setting it
return;
}
// If using SCEditor, update the WYSIWYG
if(this.sceditor_instance) {
}
else if(this.epiceditor) {
}
else if(this.ace_editor) {
}
this.refreshValue();
// Bubble this setValue to parents if the value changed
},
getNumColumns: function() {
var min = Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);
var num;
else num = 2;
},
build: function() {
var self = this, i;
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description);
this.format = this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,'');
}
}
}
// Specific format
if(this.format) {
// Text Area
if(this.format === 'textarea') {
this.input_type = 'textarea';
}
// Range Input
else if(this.format === 'range') {
this.input_type = 'range';
var step = 1;
if(this.schema.multipleOf) {
}
}
// Source Code
else if([
'actionscript',
'batchfile',
'bbcode',
'c',
'c++',
'cpp',
'coffee',
'csharp',
'css',
'dart',
'django',
'ejs',
'erlang',
'golang',
'handlebars',
'haskell',
'haxe',
'html',
'ini',
'jade',
'java',
'javascript',
'json',
'less',
'lisp',
'lua',
'makefile',
'markdown',
'matlab',
'mysql',
'objectivec',
'pascal',
'perl',
'pgsql',
'php',
'python',
'r',
'ruby',
'sass',
'scala',
'scss',
'smarty',
'sql',
'stylus',
'svg',
'twig',
'vbscript',
'xml',
'yaml'
) {
this.input_type = this.format;
this.source_code = true;
}
// HTML5 Input type
else {
this.input_type = this.format;
}
}
// Normal text input
else {
this.input_type = 'text';
}
// minLength, maxLength, and pattern
if(typeof this.schema.maxLength !== "undefined") this.input.setAttribute('maxlength',this.schema.maxLength);
if(typeof this.schema.pattern !== "undefined") this.input.setAttribute('pattern',this.schema.pattern);
else if(typeof this.schema.minLength !== "undefined") this.input.setAttribute('pattern','.{'+this.schema.minLength+',}');
}
else {
}
this.always_disabled = true;
}
this.input
.addEventListener('change',function(e) {
e.preventDefault();
e.stopPropagation();
// Don't allow changing if this field is a template
return;
}
// sanitize value
}
self.refreshValue();
});
if(this.options.expand_height) {
this.adjust_height = function(el) {
if(!el) return;
// Input too short
i=0;
if(i>100) break;
i++;
ch++;
}
}
else {
i=0;
if(i>100) break;
i++;
ch--;
}
}
};
self.adjust_height(this);
});
self.adjust_height(this);
});
this.adjust_height();
}
// Any special formatting that needs to happen after the input is added to the dom
window.requestAnimationFrame(function() {
// Skip in case the input is only a temporary editor,
// otherwise, in the case of an ace_editor creation,
// it will generate an error trying to append it to the missing parentNode
});
// Compile and store the template
this.refreshValue();
}
else {
this.refreshValue();
}
},
enable: function() {
if(!this.always_disabled) {
// TODO: WYSIWYG and Markdown editors
}
this._super();
},
disable: function() {
// TODO: WYSIWYG and Markdown editors
this._super();
},
afterInputReady: function() {
// Code editor
if(this.source_code) {
// WYSIWYG html and bbcode editor
) {
emoticonsEnabled: false,
width: '100%',
height: 300
// Get editor's value
// Set the value and update
});
}
// EpicEditor for markdown (if it's loaded)
container: this.epiceditor_container,
clientSideStorage: false
});
});
}
// ACE editor for everything else
var mode = this.input_type;
mode = 'c_cpp';
}
// The theme
if(JSONEditor.plugins.ace.theme) this.ace_editor.setTheme('ace/theme/'+JSONEditor.plugins.ace.theme);
// The mode
// Listen for changes
self.refreshValue();
});
}
}
},
refreshValue: function() {
this.serialized = this.value;
},
destroy: function() {
// If using SCEditor, destroy the editor instance
if(this.sceditor_instance) {
this.sceditor_instance.destroy();
}
else if(this.epiceditor) {
this.epiceditor.unload();
}
else if(this.ace_editor) {
this.ace_editor.destroy();
}
this.template = null;
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
this._super();
},
/**
* This is overridden in derivative editors
*/
return value;
},
/**
* Re-calculates the value if needed
*/
onWatchedFieldChange: function() {
// If this editor needs to be rendered by a macro template
if(this.template) {
vars = this.getWatchedFieldValues();
}
this._super();
},
showValidationErrors: function(errors) {
var self = this;
else if(!this.is_dirty && this.previous_error_setting===this.jsoneditor.options.show_errors) return;
var messages = [];
}
});
}
else {
}
}
});
},
getNumColumns: function() {
return 2;
},
getValue: function() {
return this.value*1;
}
});
},
getNumColumns: function() {
return 2;
}
});
getDefault: function() {
},
getChildEditors: function() {
return this.editors;
},
register: function() {
this._super();
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
}
}
},
unregister: function() {
this._super();
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
this.editors[i].unregister();
}
}
},
getNumColumns: function() {
},
enable: function() {
this._super();
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
}
}
},
disable: function() {
this.hideEditJSON();
this._super();
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
}
}
},
layoutEditors: function() {
var self = this, i, j;
if(!this.row_container) return;
// Sort editors by propertyOrder
});
var container;
if(this.format === 'grid') {
var rows = [];
if(editor.property_removed) return;
var found = false;
// See if the editor will fit in any of the existing rows first
// If the editor will fit in the row horizontally
// If the editor is close to the other elements in height
// i.e. Don't put a really tall editor in an otherwise short row or vice versa
found = i;
}
}
}
// If there isn't a spot in any of the existing rows, start a new row
if(found === false) {
width: 0,
minh: 999999,
maxh: 0,
editors: []
});
}
//editor: editor,
});
});
// Make almost full rows width 12
// Do this by increasing all editors' sizes proprotionately
// Any left over space goes to the biggest editor
// Don't touch rows with a width of 6 or less
var biggest = false;
var new_width = 0;
}
}
}
// layout hasn't changed
// Layout the form
}
}
}
// Normal layout
else {
if(editor.property_removed) return;
});
}
},
getPropertySchema: function(key) {
// Schema declared directly in properties
// Any matching patternProperties should be merged in
if(this.schema.patternProperties) {
for(var i in this.schema.patternProperties) {
var regex = new RegExp(i);
matched = true;
}
}
}
// Hasn't matched other rules, use additionalProperties schema
if(!matched && this.schema.additionalProperties && typeof this.schema.additionalProperties === "object") {
}
return schema;
},
preBuild: function() {
this._super();
this.editors = {};
this.cached_editors = {};
var self = this;
this.format = this.options.layout || this.options.object_layout || this.schema.format || this.jsoneditor.options.object_layout || 'normal';
this.minwidth = 0;
this.maxwidth = 0;
// If the object should be rendered as a table row
compact: true,
required: true
});
var width = self.editors[key].options.hidden? 0 : (self.editors[key].options.grid_columns || self.editors[key].getNumColumns());
});
this.no_link_holder = true;
}
// If the object should be rendered as a table
// TODO: table display format
throw "Not supported yet";
}
// If the object should be rendered as a div
else {
// Increase the grid width to account for padding
self.minwidth = Math.max(self.minwidth,(self.editors[key].options.grid_columns || self.editors[key].getNumColumns()));
}
});
}
// Sort editors by propertyOrder
});
},
build: function() {
var self = this;
// If the object should be rendered as a table row
this.editor_holder = this.container;
}
}
});
}
// If the object should be rendered as a table
// TODO: table display format
throw "Not supported yet";
}
// If the object should be rendered as a div
else {
// Edit JSON modal
e.preventDefault();
e.stopPropagation();
});
e.preventDefault();
e.stopPropagation();
self.hideEditJSON();
});
// Manage Properties modal
e.preventDefault();
e.stopPropagation();
return;
}
}
}
});
// Description
if(this.schema.description) {
}
// Validation error placeholder area
// Container for child editor area
// Container for rows of child editors
});
// Control buttons
this.collapsed = false;
e.preventDefault();
e.stopPropagation();
}
else {
}
});
// If it should start collapsed
}
// Collapse button disabled
}
}
// Edit JSON Button
e.preventDefault();
e.stopPropagation();
});
// Edit JSON Buttton disabled
}
}
// Object Properties Button
e.preventDefault();
e.stopPropagation();
});
this.refreshAddProperties();
}
// Fix table cell ordering
this.editor_holder = this.container;
});
}
// Layout object editors in grid if needed
else {
// Initial layout
this.layoutEditors();
// Do it again now that we know the approximate heights of elements
this.layoutEditors();
}
},
showEditJSON: function() {
if(!this.editjson_holder) return;
this.hideAddProperty();
// Position the form directly beneath the button
// TODO: edge detection
this.editjson_holder.style.top = this.editjson_button.offsetTop + this.editjson_button.offsetHeight+"px";
// Start the textarea with the current value
// Disable the rest of the form while editing JSON
this.disable();
this.editjson_button.disabled = false;
this.editing_json = true;
},
hideEditJSON: function() {
if(!this.editjson_holder) return;
if(!this.editing_json) return;
this.enable();
this.editing_json = false;
},
saveJSON: function() {
if(!this.editjson_holder) return;
try {
this.hideEditJSON();
}
catch(e) {
throw e;
}
},
toggleEditJSON: function() {
if(this.editing_json) this.hideEditJSON();
else this.showEditJSON();
},
var propertyOrder;
control = null;
break;
}
}
if (control) {
}
},
addPropertyCheckbox: function(key) {
var self = this;
else
control.style.paddingBottom = control.style.marginBottom = control.style.paddingTop = control.style.marginTop = 0;
//control.style.overflowY = 'hidden';
}
else {
}
});
return checkbox;
},
showAddProperty: function() {
if(!this.addproperty_holder) return;
this.hideEditJSON();
// Position the form directly beneath the button
// TODO: edge detection
this.addproperty_holder.style.top = this.addproperty_button.offsetTop + this.addproperty_button.offsetHeight+"px";
// Disable the rest of the form while editing JSON
this.disable();
this.adding_property = true;
this.addproperty_button.disabled = false;
this.refreshAddProperties();
},
hideAddProperty: function() {
if(!this.addproperty_holder) return;
if(!this.adding_property) return;
this.enable();
this.adding_property = false;
},
toggleAddProperty: function() {
if(this.adding_property) this.hideAddProperty();
else this.showAddProperty();
},
removeObjectProperty: function(property) {
this.refreshValue();
this.layoutEditors();
}
},
var self = this;
// Property is already added
// Property was added before and is cached
if(this.cached_editors[name]) {
if(prebuild_only) return;
}
// New property
else {
if(!this.canHaveAdditionalProperties() && (!this.schema.properties || !this.schema.properties[name])) {
return;
}
// Add the property
});
if(!prebuild_only) {
}
}
// If we're only prebuilding the editors, don't refresh values
if(!prebuild_only) {
self.refreshValue();
}
},
onChildEditorChange: function(editor) {
this.refreshValue();
},
canHaveAdditionalProperties: function() {
return this.schema.additionalProperties;
}
},
destroy: function() {
});
if(this.error_holder && this.error_holder.parentNode) this.error_holder.parentNode.removeChild(this.error_holder);
this.editors = null;
this.cached_editors = null;
if(this.editor_holder && this.editor_holder.parentNode) this.editor_holder.parentNode.removeChild(this.editor_holder);
this.editor_holder = null;
this._super();
},
getValue: function() {
for(var i in result) {
if(result.hasOwnProperty(i)) {
}
}
}
return result;
},
refreshValue: function() {
this.value = {};
var self = this;
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
}
if(this.adding_property) this.refreshAddProperties();
},
refreshAddProperties: function() {
if(this.options.disable_properties || (this.options.disable_properties !== false && this.jsoneditor.options.disable_properties)) {
return;
}
// Get number of editors
for(i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
num_props++;
}
// Determine if we can add back removed properties
can_add = this.canHaveAdditionalProperties() && !(typeof this.schema.maxProperties !== "undefined" && num_props >= this.schema.maxProperties);
if(this.addproperty_checkboxes) {
}
this.addproperty_checkboxes = {};
// Check for which editors can't be removed or added back
for(i in this.cached_editors) {
if(!this.cached_editors.hasOwnProperty(i)) continue;
this.addPropertyCheckbox(i);
this.addproperty_checkboxes[i].disabled = true;
}
}
else if(!(i in this.editors)) {
this.addproperty_checkboxes[i].disabled = true;
}
else {
this.addproperty_checkboxes[i].disabled = false;
show_modal = true;
}
}
else {
show_modal = true;
can_remove = true;
}
}
if(this.canHaveAdditionalProperties()) {
show_modal = true;
}
// Additional addproperty checkboxes not tied to a current editor
for(i in this.schema.properties) {
if(this.cached_editors[i]) continue;
show_modal = true;
this.addPropertyCheckbox(i);
}
// If no editors can be added or removed, hide the modal button
if(!show_modal) {
this.hideAddProperty();
}
// If additional properties are disabled
else if(!this.canHaveAdditionalProperties()) {
}
// If no new properties can be added
else if(!can_add) {
this.addproperty_add.disabled = true;
}
// If new properties can be added
else {
this.addproperty_add.disabled = false;
}
},
isRequired: function(editor) {
else return false;
},
var self = this;
// First, set the values for all of the defined properties
// Value explicitly set
if(typeof value[i] !== "undefined") {
}
// Otherwise, remove value unless this is the initial set or it's required
}
// Otherwise, set the value to the default
else {
}
});
if(!self.cached_editors[i]) {
}
});
this.refreshValue();
this.layoutEditors();
this.onChange();
},
showValidationErrors: function(errors) {
var self = this;
// Get all the errors that pertain to this editor
var my_errors = [];
var other_errors = [];
}
else {
}
});
// Show errors for this editor
if(this.error_holder) {
var message = [];
});
}
// Hide error area
else {
}
}
// Show error for the table row if this is inside a table
}
else {
}
}
// Show errors for child editors
});
}
});
getDefault: function() {
return this.schema["default"] || [];
},
register: function() {
this._super();
if(this.rows) {
}
}
},
unregister: function() {
this._super();
if(this.rows) {
this.rows[i].unregister();
}
}
},
getNumColumns: function() {
// Tabs require extra horizontal space
if(this.tabs_holder) {
}
else {
}
},
enable: function() {
if(this.rows) {
}
}
this._super();
},
disable: function() {
if(this.rows) {
}
}
this._super();
},
preBuild: function() {
this._super();
this.rows = [];
this.row_cache = [];
this.hide_delete_buttons = this.options.disable_array_delete || this.jsoneditor.options.disable_array_delete;
this.hide_move_buttons = this.options.disable_array_reorder || this.jsoneditor.options.disable_array_reorder;
},
build: function() {
var self = this;
if(this.schema.description) {
}
this.active_tab = null;
}
else {
}
}
else {
}
// Add controls
this.addControls();
},
onChildEditorChange: function(editor) {
this.refreshValue();
this.refreshTabs(true);
},
getItemTitle: function() {
if(!this.item_title) {
}
else {
this.item_title = 'item';
}
}
return this.item_title;
},
getItemSchema: function(i) {
if(this.schema.additionalItems===true) {
return {};
}
else if(this.schema.additionalItems) {
}
}
else {
}
}
}
else {
return {};
}
},
getItemInfo: function(i) {
var schema = this.getItemSchema(i);
// Check if it's cached
// Get the schema for this item
this.item_info[stringified] = {
width: 12,
};
return this.item_info[stringified];
},
getElementEditor: function(i) {
var item_info = this.getItemInfo(i);
var schema = this.getItemSchema(i);
var holder;
if(this.tabs_holder) {
}
else if(item_info.child_editors) {
}
else {
}
jsoneditor: this.jsoneditor,
parent: this,
required: true
});
if(!ret.title_controls) {
}
return ret;
},
destroy: function() {
this.empty(true);
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
if(this.row_holder && this.row_holder.parentNode) this.row_holder.parentNode.removeChild(this.row_holder);
this.rows = this.row_cache = this.title = this.description = this.row_holder = this.panel = this.controls = null;
this._super();
},
if(!this.rows) return;
var self = this;
if(hard) {
}
});
},
if(hard) {
}
else {
row.unregister();
}
},
getMax: function() {
}
else {
}
},
refreshTabs: function(refresh_headers) {
var self = this;
if(refresh_headers) {
}
else {
}
else {
}
}
});
},
if(serialized === this.serialized) return;
// Make sure value has between minItems and maxItems items in it
}
}
}
var self = this;
// TODO: don't set the row's value if it hasn't changed
}
}
else {
}
});
}
// Set the active tab
var new_active_tab = null;
return false;
}
});
self.refreshTabs(true);
self.refreshTabs();
// TODO: sortable
},
refreshValue: function(force) {
var self = this;
this.value = [];
// Get the value for this editor
});
// If we currently have minItems items in the array
// Hide the move down button for the last row
if(editor.movedown_button) {
}
else {
}
}
// Hide the delete button if we have minItems items
if(editor.delete_button) {
if(minItems) {
}
else {
}
}
// Get the value for this editor
});
var controls_needed = false;
}
// If there are minItems items in the array, hide the delete button beneath the rows
if(minItems || this.hide_delete_buttons) {
}
else {
controls_needed = true;
}
}
else {
// If there are minItems items in the array, hide the delete button beneath the rows
if(minItems || this.hide_delete_buttons) {
}
else {
controls_needed = true;
}
}
// If there are maxItems in the array, hide the add button beneath the rows
}
else {
controls_needed = true;
}
if(!this.collapsed && controls_needed) {
}
else {
}
}
},
var self = this;
if(self.tabs_holder) {
self.refreshTabs();
e.preventDefault();
e.stopPropagation();
});
}
// Buttons to delete row, move row up, and move row down
if(!self.hide_delete_buttons) {
self.rows[i].delete_button = this.getButton(self.getItemTitle(),'delete','Delete '+self.getItemTitle());
e.preventDefault();
e.stopPropagation();
var newval = [];
var new_active_tab = null;
if(j===i) {
// If the one we're deleting is the active tab
// Make the next tab active if there is one
// Note: the next tab is going to be the current tab after deletion
// Otherwise, make the previous tab active if there is one
}
return; // If this is the one we're deleting
}
});
if(new_active_tab) {
self.refreshTabs();
}
});
if(controls_holder) {
}
}
if(i && !self.hide_move_buttons) {
e.preventDefault();
e.stopPropagation();
if(i<=0) return;
self.refreshTabs();
});
if(controls_holder) {
}
}
if(!self.hide_move_buttons) {
e.preventDefault();
e.stopPropagation();
self.refreshTabs();
});
if(controls_holder) {
}
}
self.refreshTabs();
},
addControls: function() {
var self = this;
this.collapsed = false;
e.preventDefault();
e.stopPropagation();
}
else {
}
});
// If it should start collapsed
}
// Collapse button disabled
}
}
// Add "new row" and "delete last" buttons below editor
e.preventDefault();
e.stopPropagation();
}
else {
}
self.refreshTabs();
self.refreshValue();
});
this.delete_last_row_button = this.getButton('Last '+this.getItemTitle(),'delete','Delete Last '+this.getItemTitle());
e.preventDefault();
e.stopPropagation();
var new_active_tab = null;
if(self.rows.length > 1 && self.rows[self.rows.length-1].tab === self.active_tab) new_active_tab = self.rows[self.rows.length-2].tab;
if(new_active_tab) {
self.refreshTabs();
}
});
e.preventDefault();
e.stopPropagation();
});
}
},
showValidationErrors: function(errors) {
var self = this;
// Get all the errors that pertain to this editor
var my_errors = [];
var other_errors = [];
}
else {
}
});
// Show errors for this editor
if(this.error_holder) {
var message = [];
});
}
// Hide error area
else {
}
}
// Show errors for child editors
});
}
});
register: function() {
this._super();
if(this.rows) {
}
}
},
unregister: function() {
this._super();
if(this.rows) {
this.rows[i].unregister();
}
}
},
getNumColumns: function() {
},
preBuild: function() {
this.width = 12;
this._super();
},
build: function() {
var self = this;
// Determine the default value of array element
if(this.schema.description) {
}
}
else {
}
if(this.item_has_child_editors) {
}
}
else {
}
// Row Controls column
// Add controls
this.addControls();
},
onChildEditorChange: function(editor) {
this.refreshValue();
this._super();
},
getItemDefault: function() {
},
getItemTitle: function() {
return this.item_title;
},
getElementEditor: function(i,ignore) {
if(!this.item_has_child_editors) {
}
jsoneditor: this.jsoneditor,
parent: this,
compact: true,
table_row: true
});
if(!ignore) {
}
return ret;
},
destroy: function() {
this.innerHTML = '';
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
if(this.row_holder && this.row_holder.parentNode) this.row_holder.parentNode.removeChild(this.row_holder);
this._super();
},
// Make sure value has between minItems and maxItems items in it
}
}
}
if(serialized === this.serialized) return;
var numrows_changed = false;
var self = this;
// TODO: don't set the row's value if it hasn't changed
}
else {
numrows_changed = true;
}
});
if(!self.item_has_child_editors) {
}
numrows_changed = true;
}
self.refreshValue();
// TODO: sortable
},
refreshRowButtons: function() {
var self = this;
// If we currently have minItems items in the array
var need_row_buttons = false;
// Hide the move down button for the last row
if(editor.movedown_button) {
}
else {
need_row_buttons = true;
}
}
// Hide the delete button if we have minItems items
if(editor.delete_button) {
if(minItems) {
}
else {
need_row_buttons = true;
}
}
if(editor.moveup_button) {
need_row_buttons = true;
}
});
if(need_row_buttons) {
}
else {
}
});
if(need_row_buttons) {
}
else {
}
var controls_needed = false;
}
// If there are minItems items in the array, hide the delete button beneath the rows
if(minItems || this.hide_delete_buttons) {
}
else {
controls_needed = true;
}
}
else {
// If there are minItems items in the array, hide the delete button beneath the rows
if(minItems || this.hide_delete_buttons) {
}
else {
controls_needed = true;
}
}
// If there are maxItems in the array, hide the add button beneath the rows
}
else {
controls_needed = true;
}
if(!controls_needed) {
}
else {
}
},
refreshValue: function() {
var self = this;
this.value = [];
// Get the value for this editor
});
},
var self = this;
// Buttons to delete row, move row up, and move row down
if(!this.hide_delete_buttons) {
e.preventDefault();
e.stopPropagation();
var newval = [];
if(j===i) return; // If this is the one we're deleting
});
});
}
if(i && !this.hide_move_buttons) {
e.preventDefault();
e.stopPropagation();
if(i<=0) return;
});
}
if(!this.hide_move_buttons) {
e.preventDefault();
e.stopPropagation();
});
}
},
addControls: function() {
var self = this;
this.collapsed = false;
if(this.title_controls) {
e.preventDefault();
e.stopPropagation();
}
else {
}
});
// If it should start collapsed
}
// Collapse button disabled
}
}
}
// Add "new row" and "delete last" buttons below editor
e.preventDefault();
e.stopPropagation();
self.refreshValue();
});
this.delete_last_row_button = this.getButton('Last '+this.getItemTitle(),'delete','Delete Last '+this.getItemTitle());
e.preventDefault();
e.stopPropagation();
});
e.preventDefault();
e.stopPropagation();
});
}
});
// Multiple Editor (for when `type` is an array)
register: function() {
if(this.editors) {
if(!this.editors[i]) continue;
this.editors[i].unregister();
}
}
this._super();
},
unregister: function() {
this._super();
if(this.editors) {
if(!this.editors[i]) continue;
this.editors[i].unregister();
}
}
},
getNumColumns: function() {
},
enable: function() {
if(this.editors) {
if(!this.editors[i]) continue;
}
}
this._super();
},
disable: function() {
if(this.editors) {
if(!this.editors[i]) continue;
}
}
this._super();
},
switchEditor: function(i) {
var self = this;
if(!this.editors[i]) {
this.buildChildEditor(i);
}
if(!editor) return;
}
});
self.refreshValue();
},
buildChildEditor: function(i) {
var self = this;
var schema;
if(typeof type === "string") {
}
else {
// If we need to merge `required` arrays
if(type.required && Array.isArray(type.required) && self.schema.required && Array.isArray(self.schema.required)) {
}
}
required: true
});
});
},
preBuild: function() {
var self = this;
this.types = [];
this.type = 0;
this.editors = [];
this.validators = [];
this.keep_values = true;
if(typeof this.jsoneditor.options.keep_oneof_values !== "undefined") this.keep_values = this.jsoneditor.options.keep_oneof_values;
if(typeof this.options.keep_oneof_values !== "undefined") this.keep_values = this.options.keep_oneof_values;
this.oneOf = true;
//self.types[i] = self.jsoneditor.expandSchema(oneof);
});
}
else {
// If any of these primitive types are disallowed
}
var allowed_types = [];
});
this.types = allowed_types;
}
}
}
else {
}
}
},
build: function() {
var self = this;
e.preventDefault();
e.stopPropagation();
});
var schema;
if(typeof type === "string") {
}
else {
// If we need to merge `required` arrays
if(type.required && Array.isArray(type.required) && self.schema.required && Array.isArray(self.schema.required)) {
}
}
});
this.switchEditor(0);
},
onChildEditorChange: function(editor) {
this.refreshValue();
this.refreshHeaderText();
}
this._super();
},
refreshHeaderText: function() {
});
},
refreshValue: function() {
},
// Determine type by getting the first one that validates
var self = this;
return false;
}
});
this.switchEditor(this.type);
this.refreshValue();
},
destroy: function() {
});
if(this.editor_holder && this.editor_holder.parentNode) this.editor_holder.parentNode.removeChild(this.editor_holder);
this._super();
},
showValidationErrors: function(errors) {
var self = this;
// oneOf error paths need to remove the oneOf[i] part before passing to child editors
if(this.oneOf) {
if(!editor) return;
var new_errors = [];
}
});
});
}
else {
if(!editor) return;
});
}
}
});
// Enum Editor (used for objects and arrays with enumerated values)
getNumColumns: function() {
return 4;
},
build: function() {
this.selected = 0;
this.select_options = [];
this.html_values = [];
var self = this;
}
// Switcher
// Display area
self.refreshValue();
});
this.refreshValue();
},
refreshValue: function() {
var self = this;
return false;
}
});
return;
}
},
enable: function() {
this._super();
},
disable: function() {
this._super();
},
var self = this;
if(el === null) {
return '<em>null</em>';
}
// Array or Object
else if(typeof el === "object") {
// TODO: use theme
var ret = '';
// Add the keys to object children
// TODO: use theme
}
// TODO: use theme
});
return ret;
}
// Boolean
else if(typeof el === "boolean") {
}
// String
else if(typeof el === "string") {
}
// Number
else {
return el;
}
},
this.refreshValue();
this.onChange();
}
},
destroy: function() {
if(this.display_area && this.display_area.parentNode) this.display_area.parentNode.removeChild(this.display_area);
this._super();
}
});
// Sanitize value before setting it
}
return;
}
this.onChange();
},
register: function() {
this._super();
if(!this.input) return;
},
unregister: function() {
this._super();
if(!this.input) return;
},
getNumColumns: function() {
if(!this.enum_options) return 3;
}
},
return !!value;
}
return 1*value;
}
}
else {
return ""+value;
}
},
getValue: function() {
return this.value;
},
preBuild: function() {
var self = this;
this.input_type = 'select';
this.enum_options = [];
this.enum_values = [];
this.enum_display = [];
// Enum options enumerated
if(this.schema["enum"]) {
});
if(!this.isRequired()){
}
}
// Boolean
self.enum_values = [true,false];
if(!this.isRequired()){
}
}
// Dynamic Enum
else if(this.schema.enumSource) {
this.enumSource = [];
this.enum_display = [];
this.enum_options = [];
this.enum_values = [];
// Shortcut declaration for using a single array
this.enumSource = [
{
}
];
}
else {
this.enumSource = [
{
}
];
}
}
else {
// Shorthand for watched variable
this.enumSource[i] = {
};
}
// Make a copy of the schema
}
else {
}
}
}
// Now, enumSource is an array of sources
// Walk through this array and fix up the values
if(this.enumSource[i].value) {
this.enumSource[i].value = this.jsoneditor.compileTemplate(this.enumSource[i].value, this.template_engine);
}
if(this.enumSource[i].title) {
this.enumSource[i].title = this.jsoneditor.compileTemplate(this.enumSource[i].title, this.template_engine);
}
if(this.enumSource[i].filter) {
this.enumSource[i].filter = this.jsoneditor.compileTemplate(this.enumSource[i].filter, this.template_engine);
}
}
}
// Other, not supported
else {
throw "'select' editor requires the enum property to be set.";
}
},
build: function() {
var self = this;
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description);
this.always_disabled = true;
}
e.preventDefault();
e.stopPropagation();
});
},
onInputChange: function() {
}
this.onChange(true);
},
setupSelect2: function() {
// If the Select2 library is loaded use it when we have lots of items
if(window.jQuery && window.jQuery.fn && window.jQuery.fn.select2 && (this.enum_options.length > 2 || (this.enum_options.length && this.enumSource))) {
if(this.schema.options && this.schema.options.select2_options) options = $extend(options,this.schema.options.select2_options);
var self = this;
});
}
else {
this.select2 = null;
}
},
postBuild: function() {
this._super();
this.setupSelect2();
},
onWatchedFieldChange: function() {
// If this editor uses a dynamic select box
if(this.enumSource) {
vars = this.getWatchedFieldValues();
var select_options = [];
var select_titles = [];
// Constant values
if(Array.isArray(this.enumSource[i])) {
}
else {
var items = [];
// Static list of items
// A watched field
} else {
}
if(items) {
// Only use a predefined part of the array
if(this.enumSource[i].slice) {
}
// Filter the items
if(this.enumSource[i].filter) {
var new_items = [];
}
}
var item_titles = [];
var item_values = [];
// Rendered value
if(this.enumSource[i].value) {
i: j,
});
}
// Use value directly
else {
item_values[j] = items[j];
}
// Rendered title
if(this.enumSource[i].title) {
i: j,
});
}
// Use value as the title also
else {
item_titles[j] = item_values[j];
}
}
// TODO: sort
}
}
}
var prev_value = this.value;
this.enum_options = select_options;
this.enum_display = select_titles;
this.enum_values = select_options;
if(this.select2) {
}
// If the previous value is still in the new select options, stick with it
this.value = prev_value;
}
// Otherwise, set the value to the first select option
else {
else this.jsoneditor.onChange();
}
this.setupSelect2();
}
this._super();
},
enable: function() {
if(!this.always_disabled) {
}
this._super();
},
disable: function() {
this._super();
},
destroy: function() {
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
if(this.select2) {
this.select2 = null;
}
this._super();
}
});
// Sanitize value before setting it
}
return;
}
if(this.selectize) {
}
this.onChange();
},
register: function() {
this._super();
if(!this.input) return;
},
unregister: function() {
this._super();
if(!this.input) return;
},
getNumColumns: function() {
if(!this.enum_options) return 3;
}
},
return !!value;
}
return 1*value;
}
}
else {
return ""+value;
}
},
getValue: function() {
return this.value;
},
preBuild: function() {
var self = this;
this.input_type = 'select';
this.enum_options = [];
this.enum_values = [];
this.enum_display = [];
// Enum options enumerated
if(this.schema.enum) {
});
}
// Boolean
self.enum_values = [true,false];
}
// Dynamic Enum
else if(this.schema.enumSource) {
this.enumSource = [];
this.enum_display = [];
this.enum_options = [];
this.enum_values = [];
// Shortcut declaration for using a single array
this.enumSource = [
{
}
];
}
else {
this.enumSource = [
{
}
];
}
}
else {
// Shorthand for watched variable
this.enumSource[i] = {
};
}
// Make a copy of the schema
}
else {
}
}
}
// Now, enumSource is an array of sources
// Walk through this array and fix up the values
if(this.enumSource[i].value) {
this.enumSource[i].value = this.jsoneditor.compileTemplate(this.enumSource[i].value, this.template_engine);
}
if(this.enumSource[i].title) {
this.enumSource[i].title = this.jsoneditor.compileTemplate(this.enumSource[i].title, this.template_engine);
}
if(this.enumSource[i].filter) {
this.enumSource[i].filter = this.jsoneditor.compileTemplate(this.enumSource[i].filter, this.template_engine);
}
}
}
// Other, not supported
else {
throw "'select' editor requires the enum property to be set.";
}
},
build: function() {
var self = this;
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description);
this.always_disabled = true;
}
e.preventDefault();
e.stopPropagation();
});
},
onInputChange: function() {
}
this.onChange(true);
},
setupSelectize: function() {
// If the Selectize library is loaded use it when we have lots of items
var self = this;
if(window.jQuery && window.jQuery.fn && window.jQuery.fn.selectize && (this.enum_options.length >= 2 || (this.enum_options.length && this.enumSource))) {
if(this.schema.options && this.schema.options.selectize_options) options = $extend(options,this.schema.options.selectize_options);
{
create: true,
onChange : function() {
}
}));
}
else {
this.selectize = null;
}
},
postBuild: function() {
this._super();
this.setupSelectize();
},
onWatchedFieldChange: function() {
// If this editor uses a dynamic select box
if(this.enumSource) {
vars = this.getWatchedFieldValues();
var select_options = [];
var select_titles = [];
// Constant values
if(Array.isArray(this.enumSource[i])) {
}
// A watched field
// Only use a predefined part of the array
if(this.enumSource[i].slice) {
}
// Filter the items
if(this.enumSource[i].filter) {
var new_items = [];
}
}
var item_titles = [];
var item_values = [];
// Rendered value
if(this.enumSource[i].value) {
i: j,
});
}
// Use value directly
else {
item_values[j] = items[j];
}
// Rendered title
if(this.enumSource[i].title) {
i: j,
});
}
// Use value as the title also
else {
item_titles[j] = item_values[j];
}
}
// TODO: sort
}
}
var prev_value = this.value;
this.enum_options = select_options;
this.enum_display = select_titles;
this.enum_values = select_options;
// If the previous value is still in the new select options, stick with it
this.value = prev_value;
}
// Otherwise, set the value to the first select option
else {
else this.jsoneditor.onChange();
}
if(this.selectize) {
// Update the Selectize options
}
else {
this.setupSelectize();
}
this._super();
}
},
updateSelectizeOptions: function(select_options) {
self = this;
selectized.off();
for(var n in select_options) {
}
});
},
enable: function() {
if(!this.always_disabled) {
if(this.selectize) {
}
}
this._super();
},
disable: function() {
if(this.selectize) {
}
this._super();
},
destroy: function() {
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
if(this.selectize) {
this.selectize = null;
}
this._super();
}
});
preBuild: function() {
this._super();
this.select_options = {};
this.select_values = {};
var e = items_schema["enum"] || [];
this.option_keys = [];
for(i=0; i<e.length; i++) {
// If the sanitized value is different from the enum value, don't include it
if(this.sanitize(e[i]) !== e[i]) continue;
this.select_values[e[i]+""] = e[i];
}
},
build: function() {
var self = this, i;
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description);
this.input_type = 'checkboxes';
this.inputs = {};
this.controls = {};
this.controls[this.option_keys[i]] = this.theme.getFormControl(label, this.inputs[this.option_keys[i]]);
}
}
else {
this.input_type = 'select';
}
this.always_disabled = true;
}
}
e.preventDefault();
e.stopPropagation();
var new_value = [];
if(self.select_options[self.option_keys[i]].selected || self.select_options[self.option_keys[i]].checked) new_value.push(self.select_values[self.option_keys[i]]);
}
});
},
var i;
// Make sure we are dealing with an array of strings so we can check for strict equality
}
// Update selected status of options
for(i in this.select_options) {
if(!this.select_options.hasOwnProperty(i)) continue;
this.select_options[i][this.input_type === "select"? "selected" : "checked"] = (value.indexOf(i) !== -1);
}
this.updateValue(value);
this.onChange();
},
setupSelect2: function() {
if(this.schema.options && this.schema.options.select2_options) options = $extend(options,this.schema.options.select2_options);
var self = this;
});
}
else {
this.select2 = null;
}
},
onInputChange: function() {
this.onChange(true);
},
postBuild: function() {
this._super();
this.setupSelect2();
},
register: function() {
this._super();
if(!this.input) return;
},
unregister: function() {
this._super();
if(!this.input) return;
},
getNumColumns: function() {
for(var i in this.select_values) {
if(!this.select_values.hasOwnProperty(i)) continue;
}
},
updateValue: function(value) {
var changed = false;
var new_value = [];
changed = true;
continue;
}
}
return changed;
},
return 1*value;
}
}
else {
return ""+value;
}
},
enable: function() {
if(!this.always_disabled) {
if(this.input) {
}
else if(this.inputs) {
for(var i in this.inputs) {
if(!this.inputs.hasOwnProperty(i)) continue;
}
}
}
this._super();
},
disable: function() {
if(this.input) {
}
else if(this.inputs) {
for(var i in this.inputs) {
if(!this.inputs.hasOwnProperty(i)) continue;
}
}
this._super();
},
destroy: function() {
if(this.select2) {
this.select2 = null;
}
this._super();
}
});
getNumColumns: function() {
return 4;
},
build: function() {
var self = this;
// Input that holds the base64 string
// Don't show uploader if this is readonly
// File uploader
e.preventDefault();
e.stopPropagation();
var fr = new FileReader();
fr = null;
};
}
});
}
},
refreshPreview: function() {
if(this.last_preview === this.value) return;
this.last_preview = this.value;
if(!this.value) return;
if(!mime) {
}
else {
this.preview.innerHTML = '<strong>Type:</strong> '+mime+', <strong>Size:</strong> '+Math.floor((this.value.length-this.value.split(',')[0].length-1)/1.33333)+' bytes';
}
}
},
enable: function() {
this._super();
},
disable: function() {
this._super();
},
this.refreshPreview();
this.onChange();
}
},
destroy: function() {
this._super();
}
});
getNumColumns: function() {
return 4;
},
build: function() {
var self = this;
// Input that holds the base64 string
// Don't show uploader if this is readonly
// File uploader
e.preventDefault();
e.stopPropagation();
var fr = new FileReader();
fr = null;
};
}
});
}
},
refreshPreview: function() {
if(this.last_preview === this.preview_value) return;
this.last_preview = this.preview_value;
if(!this.preview_value) return;
var self = this;
this.preview.innerHTML = '<strong>Type:</strong> '+mime+', <strong>Size:</strong> '+file.size+' bytes';
}
}
},
},
updateProgress: function(progress) {
if (self.progressBar) {
}
}
});
});
},
enable: function() {
this._super();
},
disable: function() {
this._super();
},
this.onChange();
}
},
destroy: function() {
this._super();
}
});
this.onChange();
},
register: function() {
this._super();
if(!this.input) return;
},
unregister: function() {
this._super();
if(!this.input) return;
},
getNumColumns: function() {
},
build: function() {
var self = this;
}
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description);
this.always_disabled = true;
}
e.preventDefault();
e.stopPropagation();
});
},
enable: function() {
if(!this.always_disabled) {
}
this._super();
},
disable: function() {
this._super();
},
destroy: function() {
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
this._super();
}
});
build: function() {
if(this.schema.description) {
}
delimiter: false,
createOnBlur: true,
create: true
});
},
postBuild: function() {
var self = this;
self.refreshValue();
});
},
destroy: function() {
this.empty(true);
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description);
this._super();
},
var self = this;
});
this.refreshValue(initial);
},
refreshValue: function(force) {
},
showValidationErrors: function(errors) {
var self = this;
// Get all the errors that pertain to this editor
var my_errors = [];
var other_errors = [];
}
else {
}
});
// Show errors for this editor
if(this.error_holder) {
var message = [];
});
}
// Hide error area
else {
}
}
}
});
var matchKey = (function () {
})();
getContainer: function() {
},
getFloatRightLinkHolder: function() {
return el;
},
getModal: function() {
return el;
},
getGridContainer: function() {
return el;
},
getGridRow: function() {
return el;
},
getGridColumn: function() {
return el;
},
},
return el;
},
disableHeader: function(header) {
},
disableLabel: function(label) {
},
enableHeader: function(header) {
},
enableLabel: function(label) {
},
getFormInputLabel: function(text) {
return el;
},
getCheckboxLabel: function(text) {
return el;
},
if(typeof text === "string") {
}
else {
}
return el;
},
getCheckbox: function() {
return el;
},
if(label) {
}
for(var i in controls) {
if(!controls.hasOwnProperty(i)) continue;
}
return el;
},
getSelectInput: function(options) {
return select;
},
getSwitcher: function(options) {
return switcher;
},
getSwitcherOptions: function(switcher) {
},
},
}
},
getTextareaInput: function() {
return el;
},
return el;
},
getFormInputField: function(type) {
return el;
},
afterInputReady: function(input) {
},
}
else {
}
return el;
},
getIndentedPanel: function() {
return el;
},
getChildEditorHolder: function() {
},
getDescription: function(text) {
return el;
},
getCheckboxDescription: function(text) {
return this.getDescription(text);
},
getFormInputDescription: function(text) {
return this.getDescription(text);
},
getHeaderButtonHolder: function() {
return this.getButtonHolder();
},
getButtonHolder: function() {
},
return el;
},
if(icon) {
}
},
getTable: function() {
},
getTableRow: function() {
},
getTableHead: function() {
},
getTableBody: function() {
},
getTableHeaderCell: function(text) {
return el;
},
getTableCell: function() {
return el;
},
getErrorMessage: function(text) {
return el;
},
},
removeInputError: function(input) {
},
addTableRowError: function(row) {
},
removeTableRowError: function(row) {
},
getTabHolder: function() {
el.innerHTML = "<div style='float: left; width: 130px;' class='tabs'></div><div class='content' style='margin-left: 130px;'></div><div style='clear:both;'></div>";
return el;
},
for(var i in styles) {
if(!styles.hasOwnProperty(i)) continue;
}
},
if (matchKey) {
return elem;
} else {
}
}
else {
return false;
}
}
return false;
},
this.applyStyles(el,{
border: '1px solid #ccc',
borderWidth: '1px 0 1px 1px',
textAlign: 'center',
lineHeight: '30px',
borderRadius: '5px',
fontWeight: 'bold',
cursor: 'pointer'
});
return el;
},
getTabContentHolder: function(tab_holder) {
},
getTabContent: function() {
return this.getIndentedPanel();
},
markTabActive: function(tab) {
this.applyStyles(tab,{
opacity: 1,
background: 'white'
});
},
markTabInactive: function(tab) {
this.applyStyles(tab,{
opacity:0.5,
background: ''
});
},
},
getBlockLink: function() {
return link;
},
getBlockLinkHolder: function() {
return el;
},
getLinksHolder: function() {
return el;
},
},
}
});
// TODO: use bootstrap slider
},
getGridContainer: function() {
return el;
},
getGridRow: function() {
return el;
},
getFormInputLabel: function(text) {
return el;
},
},
getSelectInput: function(options) {
return input;
},
getFormInputField: function(type) {
return el;
},
afterInputReady: function(input) {
if(input.controlgroup) return;
input.controlgroup.className = input.controlgroup.className.replace(/control-group/g,'').replace(/[ ]{2,}/g,' ');
input.controls.className = input.controlgroup.className.replace(/controls/g,'').replace(/[ ]{2,}/g,' ');
}
// TODO: use bootstrap slider
},
getIndentedPanel: function() {
return el;
},
getFormInputDescription: function(text) {
return el;
},
}
else {
if(label) {
}
}
return ret;
},
getHeaderButtonHolder: function() {
var el = this.getButtonHolder();
return el;
},
getButtonHolder: function() {
return el;
},
return el;
},
getTable: function() {
return el;
},
}
else {
}
},
removeInputError: function(input) {
},
getTabHolder: function() {
el.innerHTML = "<ul class='nav nav-tabs span2' style='margin-right: 0;'></ul><div class='tab-content span10' style='overflow:visible;'></div>";
return el;
},
a.appendChild(text);
el.appendChild(a);
return el;
},
getTabContentHolder: function(tab_holder) {
},
getTabContent: function() {
return el;
},
markTabActive: function(tab) {
},
markTabInactive: function(tab) {
},
},
getProgressBar: function() {
return container;
},
if (!progressBar) return;
},
updateProgressBarUnknown: function(progressBar) {
if (!progressBar) return;
}
});
getSelectInput: function(options) {
//el.style.width = 'auto';
return el;
},
},
afterInputReady: function(input) {
if(input.controlgroup) return;
}
// TODO: use bootstrap slider
},
getTextareaInput: function() {
return el;
},
// TODO: use better slider
},
getFormInputField: function(type) {
if(type !== 'checkbox') {
}
return el;
},
}
else {
if(label) {
}
}
return group;
},
getIndentedPanel: function() {
return el;
},
getFormInputDescription: function(text) {
return el;
},
getHeaderButtonHolder: function() {
var el = this.getButtonHolder();
return el;
},
getButtonHolder: function() {
return el;
},
return el;
},
getTable: function() {
return el;
},
if(!input.controlgroup) return;
}
else {
}
},
removeInputError: function(input) {
},
getTabHolder: function() {
return el;
},
return el;
},
markTabActive: function(tab) {
},
markTabInactive: function(tab) {
},
getProgressBar: function() {
return container;
},
if (!progressBar) return;
},
updateProgressBarUnknown: function(progressBar) {
if (!progressBar) return;
}
});
// Base Foundation theme
getChildEditorHolder: function() {
return el;
},
getSelectInput: function(options) {
return el;
},
getSwitcher: function(options) {
return el;
},
afterInputReady: function(input) {
}
},
getFormInputLabel: function(text) {
return el;
},
getFormInputField: function(type) {
return el;
},
getFormInputDescription: function(text) {
return el;
},
getIndentedPanel: function() {
return el;
},
getHeaderButtonHolder: function() {
var el = this.getButtonHolder();
return el;
},
getButtonHolder: function() {
return el;
},
return el;
},
}
else {
}
},
removeInputError: function(input) {
},
getProgressBar: function() {
return progressBar;
},
if (!progressBar) return;
},
updateProgressBarUnknown: function(progressBar) {
if (!progressBar) return;
}
});
// Foundation 3 Specific Theme
getHeaderButtonHolder: function() {
return el;
},
getFormInputLabel: function(text) {
return el;
},
getTabHolder: function() {
el.innerHTML = "<dl class='tabs vertical two columns'></dl><div class='tabs-content ten columns'></div>";
return el;
},
var sizes = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve'];
},
a.appendChild(text);
el.appendChild(a);
return el;
},
getTabContentHolder: function(tab_holder) {
},
getTabContent: function() {
return el;
},
markTabActive: function(tab) {
},
markTabInactive: function(tab) {
},
}
});
// Foundation 4 Specific Theme
getHeaderButtonHolder: function() {
return el;
},
},
getFormInputDescription: function(text) {
return el;
},
getFormInputLabel: function(text) {
return el;
}
});
// Foundation 5 Specific Theme
getFormInputDescription: function(text) {
return el;
},
},
return el;
},
getTabHolder: function() {
return el;
},
a.appendChild(text);
el.appendChild(a);
return el;
},
getTabContentHolder: function(tab_holder) {
},
getTabContent: function() {
return el;
},
markTabActive: function(tab) {
},
markTabInactive: function(tab) {
},
}
});
getFormInputLabel: function(text) {
return el;
},
getFormInputDescription: function(text) {
return el;
},
getIndentedPanel: function() {
return el;
},
getChildEditorHolder: function() {
return el;
},
getHeaderButtonHolder: function() {
var el = this.getButtonHolder();
return el;
},
getTable: function() {
return el;
},
}
else {
}
},
removeInputError: function(input) {
},
getProgressBar: function() {
return progressBar;
},
if (!progressBar) return;
},
updateProgressBarUnknown: function(progressBar) {
if (!progressBar) return;
}
});
getTable: function() {
return el;
},
getTableHeaderCell: function(text) {
return el;
},
getTableCell: function() {
return el;
},
getHeaderButtonHolder: function() {
var el = this.getButtonHolder();
return el;
},
getFormInputDescription: function(text) {
return el;
},
}
else {
}
return el;
},
getDescription: function(text) {
return el;
},
getButtonHolder: function() {
return el;
},
getFormInputLabel: function(text) {
return el;
},
// Icon only
}
// Icon and Text
else if(icon) {
}
// Text only
else {
}
return button;
},
// Icon only
}
// Icon and Text
else if(icon) {
}
// Text only
else {
}
},
getIndentedPanel: function() {
return el;
},
afterInputReady: function(input) {
},
}
else {
}
},
removeInputError: function(input) {
},
markTabActive: function(tab) {
},
markTabInactive: function(tab) {
}
});
mapping: {
collapse: '',
expand: '',
"delete": '',
edit: '',
add: '',
cancel: '',
save: '',
moveup: '',
movedown: ''
},
icon_prefix: '',
getIconClass: function(key) {
else return null;
},
if(!iconclass) return null;
return i;
}
});
mapping: {
collapse: 'chevron-down',
expand: 'chevron-up',
"delete": 'trash',
edit: 'pencil',
add: 'plus',
cancel: 'ban-circle',
save: 'ok',
moveup: 'arrow-up',
movedown: 'arrow-down'
},
icon_prefix: 'icon-'
});
mapping: {
collapse: 'chevron-down',
expand: 'chevron-right',
"delete": 'remove',
edit: 'pencil',
add: 'plus',
cancel: 'floppy-remove',
save: 'floppy-saved',
moveup: 'arrow-up',
movedown: 'arrow-down'
},
icon_prefix: 'glyphicon glyphicon-'
});
mapping: {
collapse: 'chevron-down',
expand: 'chevron-right',
"delete": 'remove',
edit: 'pencil',
add: 'plus',
cancel: 'ban-circle',
save: 'save',
moveup: 'arrow-up',
movedown: 'arrow-down'
},
icon_prefix: 'icon-'
});
mapping: {
collapse: 'caret-square-o-down',
expand: 'caret-square-o-right',
"delete": 'times',
edit: 'pencil',
add: 'plus',
cancel: 'ban',
save: 'save',
moveup: 'arrow-up',
movedown: 'arrow-down'
},
icon_prefix: 'fa fa-'
});
mapping: {
collapse: 'minus',
expand: 'plus',
"delete": 'remove',
edit: 'edit',
add: 'add-doc',
cancel: 'error',
save: 'checkmark',
moveup: 'up-arrow',
movedown: 'down-arrow'
},
icon_prefix: 'foundicon-'
});
mapping: {
collapse: 'minus',
expand: 'plus',
"delete": 'x',
edit: 'pencil',
add: 'page-add',
cancel: 'x-circle',
save: 'save',
moveup: 'arrow-up',
movedown: 'arrow-down'
},
icon_prefix: 'fi-'
});
mapping: {
collapse: 'triangle-1-s',
expand: 'triangle-1-e',
"delete": 'trash',
edit: 'pencil',
add: 'plusthick',
cancel: 'closethick',
save: 'disk',
moveup: 'arrowthick-1-n',
movedown: 'arrowthick-1-s'
},
icon_prefix: 'ui-icon ui-icon-'
});
return {
// Shortcut if the template contains no variables
if(!l) return function() { return template; };
// This drastically speeds up template execution
var replacements = [];
var get_replacement = function(i) {
var n = p.length;
var func;
if(n > 1) {
var cur;
for(i=0; i<n; i++) {
if(!cur) break;
}
return cur;
};
}
else {
p = p[0];
return vars[p];
};
}
s: matches[i],
r: func
});
};
for(var i=0; i<l; i++) {
get_replacement(i);
}
// The compiled function
return function(vars) {
var r;
for(i=0; i<l; i++) {
r = replacements[i];
}
return ret;
};
}
};
};
return {
});
return function(context) {
};
}
};
};
return window.Handlebars;
};
return {
return function(context) {
};
}
};
};
return {
return function(context) {
};
}
};
};
return {
return function(view) {
};
}
};
};
};
if(!window._) return false;
return {
return function(context) {
};
}
};
};
// Set the default theme
// Set the default template engine
// Default options when initializing JSON Editor
// String translate function
if(variables) {
}
}
return string;
};
// Translation strings and default languages
/**
* When a property is not set
*/
error_notset: "Property must be set",
/**
* When a string must not be empty
*/
error_notempty: "Value required",
/**
* When a value is not one of the enumerated values
*/
error_enum: "Value must be one of the enumerated values",
/**
* When a value doesn't validate any schema of a 'anyOf' combination
*/
error_anyOf: "Value must validate against at least one of the provided schemas",
/**
* When a value doesn't validate
* @variables This key takes one variable: The number of schemas the value does not validate
*/
error_oneOf: 'Value must validate against exactly one of the provided schemas. It currently validates against {{0}} of the schemas.',
/**
* When a value does not validate a 'not' schema
*/
error_not: "Value must not validate against the provided schema",
/**
* When a value does not match any of the provided types
*/
error_type_union: "Value must be one of the provided types",
/**
* When a value does not match the given type
* @variables This key takes one variable: The type the value should be of
*/
error_type: "Value must be of type {{0}}",
/**
* When the value validates one of the disallowed types
*/
error_disallow_union: "Value must not be one of the provided disallowed types",
/**
* When the value validates a disallowed type
* @variables This key takes one variable: The type the value should not be of
*/
error_disallow: "Value must not be of type {{0}}",
/**
* When a value is not a multiple of or divisible by a given number
* @variables This key takes one variable: The number mentioned above
*/
error_multipleOf: "Value must be a multiple of {{0}}",
/**
* When a value is greater than it's supposed to be (exclusive)
* @variables This key takes one variable: The maximum
*/
error_maximum_excl: "Value must be less than {{0}}",
/**
* When a value is greater than it's supposed to be (inclusive
* @variables This key takes one variable: The maximum
*/
error_maximum_incl: "Value must at most {{0}}",
/**
* When a value is lesser than it's supposed to be (exclusive)
* @variables This key takes one variable: The minimum
*/
error_minimum_excl: "Value must be greater than {{0}}",
/**
* When a value is lesser than it's supposed to be (inclusive)
* @variables This key takes one variable: The minimum
*/
error_minimum_incl: "Value must be at least {{0}}",
/**
* When a value have too many characters
* @variables This key takes one variable: The maximum character count
*/
error_maxLength: "Value must be at most {{0}} characters long",
/**
* When a value does not have enough characters
* @variables This key takes one variable: The minimum character count
*/
error_minLength: "Value must be at least {{0}} characters long",
/**
* When a value does not match a given pattern
*/
error_pattern: "Value must match the provided pattern",
/**
* When an array has additional items whereas it is not supposed to
*/
error_additionalItems: "No additional items allowed in this array",
/**
* When there are to many items in an array
* @variables This key takes one variable: The maximum item count
*/
error_maxItems: "Value must have at most {{0}} items",
/**
* When there are not enough items in an array
* @variables This key takes one variable: The minimum item count
*/
error_minItems: "Value must have at least {{0}} items",
/**
* When an array is supposed to have unique items but has duplicates
*/
error_uniqueItems: "Array must have unique items",
/**
* When there are too many properties in an object
* @variables This key takes one variable: The maximum property count
*/
error_maxProperties: "Object must have at most {{0}} properties",
/**
* When there are not enough properties in an object
* @variables This key takes one variable: The minimum property count
*/
error_minProperties: "Object must have at least {{0}} properties",
/**
* When a required property is not defined
* @variables This key takes one variable: The name of the missing property
*/
error_required: "Object is missing the required property '{{0}}'",
/**
* When there is an additional property is set whereas there should be none
* @variables This key takes one variable: The name of the additional property
*/
error_additional_properties: "No additional properties allowed, but property {{0}} is set",
/**
* When a dependency is not resolved
* @variables This key takes one variable: The name of the missing property for the dependency
*/
error_dependency: "Must have property {{0}}"
};
// Miscellaneous Plugin Settings
JSONEditor.plugins = {
ace: {
theme: ''
},
epiceditor: {
},
sceditor: {
},
select2: {
},
selectize: {
}
};
// Default per-editor options
}
// Set the default resolvers
// Use "multiple" as a fall back for everything
});
// If the type is set and it's a basic type, use the primitive editor
// If the schema is a simple type
});
// Boolean editors
// If explicitly set to 'checkbox', use that
return "checkbox";
}
// Otherwise, default to select menu
}
});
// Use the multiple editor for schemas where the `type` is set to "any"
// If the schema can be of any type
});
// Editor for base64 encoded files
// If the schema can be of any type
return "base64";
}
});
// Editor for uploading files
if(schema.type === "string" && schema.format === "url" && schema.options && schema.options.upload === true) {
}
});
// Use the table editor for arrays with the format set to `table`
// Type `array` with format set to `table`
return "table";
}
});
// Use the `select` editor for dynamic enumSource enums
});
// Use the `enum` or `select` editors for schemas with enumerated properties
if(schema["enum"]) {
return "enum";
}
}
}
});
if(schema.type === "array" && schema.items && !(Array.isArray(schema.items)) && schema.uniqueItems && schema.items["enum"] && ['string','number','integer'].indexOf(schema.items.type) >= 0) {
return 'multiselect';
}
});
// Use the multiple editor for schemas with `oneOf` set
// If this schema uses `oneOf`
});
// If enabled, use Selectize for arrays
return 'arraySelectize';
}
});
/**
* This is a small wrapper for using JSON Editor like a typical jQuery plugin.
*/
(function() {
var self = this;
if(options === 'value') {
// Set value
}
// Get value
else {
}
}
else if(options === 'validate') {
if(!editor) throw "Must initialize jsoneditor before validating";
// Validate a specific value
}
// Validate current value
else {
}
}
else if(options === 'destroy') {
if(editor) {
this.data('jsoneditor',null);
}
}
else {
// Destroy first
if(editor) {
}
// Create editor
// Setup event listeners
});
});
}
return this;
};
}
})();
})();
//# sourceMappingURL=jsoneditor.js.map