From 4ff72c3db0f2808d92a9dc20b1feb1cf3462f73c Mon Sep 17 00:00:00 2001 From: sebdet Date: Mon, 18 Mar 2019 16:26:44 +0100 Subject: Improve Policy window Improve the policy window in the Clamp UI & update Json-editor lib Issue-ID: CLAMP-264 Change-Id: I602641f4e849385aecc16b646c0aa4f0dcfbcf12 Signed-off-by: sebdet --- .../META-INF/resources/designer/lib/jsoneditor.js | 10236 +------------------ .../resources/designer/scripts/ToscaModelCtrl.js | 6 +- 2 files changed, 13 insertions(+), 10229 deletions(-) (limited to 'src/main') diff --git a/src/main/resources/META-INF/resources/designer/lib/jsoneditor.js b/src/main/resources/META-INF/resources/designer/lib/jsoneditor.js index 2966fac97..3d8990507 100644 --- a/src/main/resources/META-INF/resources/designer/lib/jsoneditor.js +++ b/src/main/resources/META-INF/resources/designer/lib/jsoneditor.js @@ -1,10235 +1,19 @@ /** * @name JSON Editor * @description JSON Schema Based Editor - * Deprecation notice - * This repo is no longer maintained (see also https://github.com/jdorn/json-editor/issues/800) - * Development is continued at https://github.com/json-editor/json-editor - * For details please visit https://github.com/json-editor/json-editor/issues/5 - * @version 1.1.0-beta.2 + * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800) + * @version 1.3.5 * @author Jeremy Dorn * @see https://github.com/jdorn/json-editor/ * @see https://github.com/json-editor/json-editor * @license MIT * @example see README.md and docs/ for requirements, examples 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 - Class.extend = function extend(prop) { - var _super = this.prototype; - - // 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 - for (var name in prop) { - // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? - (function(name, fn){ - return function() { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]) : - prop[name]; - } - - // The dummy class constructor - function Class() { - // All construction is actually done in the init method - if ( !initializing && this.init ) - this.init.apply(this, arguments); - } - - // Populate our constructed prototype object - Class.prototype = prototype; - - // Enforce the constructor to be what we expect - Class.prototype.constructor = Class; - - // And make this class extendable - Class.extend = extend; - - return Class; - }; - - return Class; -})(); - -// CustomEvent constructor polyfill -// From MDN -(function () { - function CustomEvent ( event, params ) { - params = params || { bubbles: false, cancelable: false, detail: undefined }; - var evt = document.createEvent( 'CustomEvent' ); - evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); - return evt; - } - - CustomEvent.prototype = window.Event.prototype; - - window.CustomEvent = CustomEvent; -})(); - -// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel -// MIT license -(function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || - window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -}()); - -// Array.isArray polyfill -// From MDN -(function() { - if(!Array.isArray) { - Array.isArray = function(arg) { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; - } -}()); -/** - * Taken from jQuery 2.1.3 - * - * @param obj - * @returns {boolean} - */ -var $isplainobject = function( obj ) { - // Not plain objects: - // - Any object or value whose internal [[Class]] property is not "[object Object]" - // - DOM nodes - // - window - if (typeof obj !== "object" || obj.nodeType || (obj !== null && obj === obj.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; -}; - -var $extend = function(destination) { - var source, i,property; - for(i=1; i 0 && (obj.length - 1) in obj)) { - for(i=0; i= waiting && !callback_fired) { - callback_fired = true; - callback(); - } - }); - } - // Request failed - else { - window.console.log(r); - throw "Failed to fetch ref via ajax- "+url; - } - }; - r.send(); - }); - - if(!waiting) { - callback(); - } - }, - expandRefs: function(schema) { - schema = $extend({},schema); - - while (schema.$ref) { - var ref = schema.$ref; - delete schema.$ref; - - if(!this.refs[ref]) ref = decodeURIComponent(ref); - - schema = this.extendSchemas(schema,this.refs[ref]); - } - return schema; - }, - expandSchema: function(schema) { - var self = this; - var extended = $extend({},schema); - var i; - - // Version 3 `type` - if(typeof schema.type === 'object') { - // Array of types - if(Array.isArray(schema.type)) { - $each(schema.type, function(key,value) { - // Schema - if(typeof value === 'object') { - schema.type[key] = self.expandSchema(value); - } - }); - } - // Schema - else { - schema.type = self.expandSchema(schema.type); - } - } - // Version 3 `disallow` - if(typeof schema.disallow === 'object') { - // Array of types - if(Array.isArray(schema.disallow)) { - $each(schema.disallow, function(key,value) { - // Schema - if(typeof value === 'object') { - schema.disallow[key] = self.expandSchema(value); - } - }); - } - // Schema - else { - schema.disallow = self.expandSchema(schema.disallow); - } - } - // Version 4 `anyOf` - if(schema.anyOf) { - $each(schema.anyOf, function(key,value) { - schema.anyOf[key] = self.expandSchema(value); - }); - } - // Version 4 `dependencies` (schema dependencies) - if(schema.dependencies) { - $each(schema.dependencies,function(key,value) { - if(typeof value === "object" && !(Array.isArray(value))) { - schema.dependencies[key] = self.expandSchema(value); - } - }); - } - // Version 4 `not` - if(schema.not) { - schema.not = this.expandSchema(schema.not); - } - - // allOf schemas should be merged into the parent - if(schema.allOf) { - for(i=0; i schema.minimum) : (value >= schema.minimum); - - // Use math.js is available - if(window.math) { - valid = window.math[schema.exclusiveMinimum?'larger':'largerEq']( - window.math.bignumber(value), - window.math.bignumber(schema.minimum) - ); - } - // Use Decimal.js if available - else if(window.Decimal) { - valid = (new window.Decimal(value))[schema.exclusiveMinimum?'gt':'gte'](new window.Decimal(schema.minimum)); - } - - if(!valid) { - errors.push({ - path: path, - property: 'minimum', - message: this.translate( - (schema.exclusiveMinimum?'error_minimum_excl':'error_minimum_incl'), - [schema.title ? schema.title : path.split('-').pop().trim(), schema.minimum] - ) - }); - } - } - } - // String specific validation - else if(typeof value === "string") { - // `maxLength` - if(schema.maxLength) { - if((value+"").length > schema.maxLength) { - errors.push({ - path: path, - property: 'maxLength', - message: this.translate('error_maxLength', - [schema.title ? schema.title : path.split('-').pop().trim(), schema.maxLength]) - }); - } - } - - // `minLength` -- Commented because we are validating required field. - if(schema.minLength) { - if((value+"").length < schema.minLength) { - errors.push({ - path: path, - property: 'minLength', - message: this.translate((schema.minLength===1?'error_notempty':'error_minLength'), - [schema.title ? schema.title : path.split('-').pop().trim(), schema.minLength]) - }); - } - } - - // `pattern` - if(schema.pattern) { - if(!(new RegExp(schema.pattern)).test(value)) { - errors.push({ - path: path, - property: 'pattern', - message: this.translate('error_pattern', - [schema.title ? schema.title : path.split('-').pop().trim(), schema.pattern]) - }); - } - } - } - // Array specific validation - else if(typeof value === "object" && value !== null && Array.isArray(value)) { - // `items` and `additionalItems` - if(schema.items) { - // `items` is an array - if(Array.isArray(schema.items)) { - for(i=0; i schema.maxItems) { - errors.push({ - path: path, - property: 'maxItems', - message: this.translate('error_maxItems', [schema.maxItems]) - }); - } - } - - // `minItems` - if(schema.minItems) { - if(value.length < schema.minItems) { - errors.push({ - path: path, - property: 'minItems', - message: this.translate('error_minItems', [schema.minItems]) - }); - } - } - - // `uniqueItems` - if(schema.uniqueItems) { - var seen = {}; - for(i=0; i schema.maxProperties) { - errors.push({ - path: path, - property: 'maxProperties', - message: this.translate('error_maxProperties', [schema.maxProperties]) - }); - } - } - - // `minProperties` - if(schema.minProperties) { - valid = 0; - for(i in value) { - if(!value.hasOwnProperty(i)) continue; - valid++; - } - if(valid < schema.minProperties) { - errors.push({ - path: path, - property: 'minProperties', - message: this.translate('error_minProperties', [schema.minProperties]) - }); - } - } - - // Version 4 `required` - if(typeof schema.required !== "undefined" && Array.isArray(schema.required)) { - for(i=0; i 0)) { - - errors = errors.concat(this._validateSchema(schema.properties[i],value[i],path+'.'+i)); - } - validated_properties[i] = true; - } - } - - // `patternProperties` - if(schema.patternProperties) { - for(i in schema.patternProperties) { - if(!schema.patternProperties.hasOwnProperty(i)) continue; - var regex = new RegExp(i); - - // Check which properties match - for(j in value) { - if(!value.hasOwnProperty(j)) continue; - if(regex.test(j)) { - validated_properties[j] = true; - errors = errors.concat(this._validateSchema(schema.patternProperties[i],value[j],path+'.'+j)); - } - } - } - } - - // 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` - if(typeof schema.additionalProperties !== "undefined") { - for(i in value) { - if(!value.hasOwnProperty(i)) continue; - if(!validated_properties[i]) { - // No extra properties allowed - if(!schema.additionalProperties) { - errors.push({ - path: path, - property: 'additionalProperties', - message: this.translate('error_additional_properties', [i]) - }); - break; - } - // Allowed - else if(schema.additionalProperties === true) { - break; - } - // Must match schema - // TODO: incompatibility between version 3 and 4 of the spec - else { - errors = errors.concat(this._validateSchema(schema.additionalProperties,value[i],path+'.'+i)); - } - } - } - } - - // `dependencies` - if(schema.dependencies) { - for(i in schema.dependencies) { - if(!schema.dependencies.hasOwnProperty(i)) continue; - - // Doesn't need to meet the dependency - if(typeof value[i] === "undefined") continue; - - // Property dependency - if(Array.isArray(schema.dependencies[i])) { - for(j=0; j 0; - } else { - this.dependenciesFulfilled = !value || value.length === 0; - } - } - - if (this.dependenciesFulfilled !== previousStatus) { - this.notify(); - } - - if (this.dependenciesFulfilled) { - wrapper.style.display = 'block'; - } else { - wrapper.style.display = 'none'; - } - }, - setContainer: function(container) { - this.container = container; - if(this.schema.id) this.container.setAttribute('data-schemaid',this.schema.id); - if(this.schema.type && typeof this.schema.type === "string") this.container.setAttribute('data-schematype',this.schema.type); - this.container.setAttribute('data-schemapath',this.path); - this.container.style.padding = '4px'; - }, - - 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 = {}; - if(this.schema.vars) this.schema.watch = this.schema.vars; - this.watched_values = {}; - this.watch_listener = function() { - if(self.refreshWatchedFieldValues()) { - self.onWatchedFieldChange(); - } - }; - - if(this.schema.hasOwnProperty('watch')) { - var path,path_parts,first,root,adjusted_path; - - for(var name in this.schema.watch) { - if(!this.schema.watch.hasOwnProperty(name)) continue; - path = this.schema.watch[name]; - - if(Array.isArray(path)) { - if(path.length<2) continue; - path_parts = [path[0]].concat(path[1].split('.')); - } - else { - path_parts = path.split('.'); - if(!self.theme.closest(self.container,'[data-schemaid="'+path_parts[0]+'"]')) path_parts.unshift('#'); - } - first = path_parts.shift(); - - if(first === '#') first = self.jsoneditor.schema.id || 'root'; - - // Find the root node for this template variable - root = self.theme.closest(self.container,'[data-schemaid="'+first+'"]'); - if(!root) throw "Could not find ancestor node with id "+first; - - // Keep track of the root node and path for use when rendering the template - adjusted_path = root.getAttribute('data-schemapath') + '.' + path_parts.join('.'); - - self.jsoneditor.watch(adjusted_path,self.watch_listener); - - self.watched[name] = adjusted_path; - } - } - - // 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) { - this.link_holder = this.theme.getLinksHolder(); - this.container.appendChild(this.link_holder); - if(this.schema.links) { - for(var i=0; i=0) { - holder = this.theme.getBlockLinkHolder(); - - link = this.theme.getBlockLink(); - link.setAttribute('target','_blank'); - - var media = document.createElement(type); - media.setAttribute('controls','controls'); - - this.theme.createMediaLink(holder,link,media); - - // When a watched field changes, update the url - this.link_watchers.push(function(vars) { - var url = href(vars); - var rel = relTemplate(vars); - link.setAttribute('href',url); - link.textContent = rel || url; - media.setAttribute('src',url); - }); - } - // Text links - else { - link = holder = this.theme.getBlockLink(); - holder.setAttribute('target','_blank'); - holder.textContent = data.rel; - - // When a watched field changes, update the url - this.link_watchers.push(function(vars) { - var url = href(vars); - var rel = relTemplate(vars); - holder.setAttribute('href',url); - holder.textContent = rel || url; - }); - } - - if(download && link) { - if(download === true) { - link.setAttribute('download',''); - } - else { - this.link_watchers.push(function(vars) { - link.setAttribute('download',download(vars)); - }); - } - } - - if(data.class) link.className = link.className + ' ' + data.class; - - return holder; - }, - refreshWatchedFieldValues: function() { - if(!this.watched_values) return; - var watched = {}; - var changed = false; - var self = this; - - if(this.watched) { - var val,editor; - for(var name in this.watched) { - if(!this.watched.hasOwnProperty(name)) continue; - editor = self.jsoneditor.getEditor(this.watched[name]); - val = editor? editor.getValue() : null; - if(self.watched_values[name] !== val) changed = true; - watched[name] = val; - } - } - - watched.self = this.getValue(); - if(this.watched_values.self !== watched.self) changed = true; - - 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 - if(this.header.children.length) { - for(var i=0; i -1; - else if(this.jsoneditor.options.required_by_default) return true; - 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. - $each(arr,function(i,el) { - if(el.title) { - used[el.title] = used[el.title] || 0; - used[el.title]++; - } - if(el.description) { - used[el.description] = used[el.description] || 0; - used[el.description]++; - } - if(el.format) { - used[el.format] = used[el.format] || 0; - used[el.format]++; - } - if(el.type) { - used[el.type] = used[el.type] || 0; - used[el.type]++; - } - }); - - // Determine display text for each element of the array - $each(arr,function(i,el) { - var name; - - // If it's a simple string - if(typeof el === "string") name = el; - // Object - else if(el.title && used[el.title]<=1) name = el.title; - else if(el.format && used[el.format]<=1) name = el.format; - else if(el.type && used[el.type]<=1) name = el.type; - else if(el.description && used[el.description]<=1) name = el.descripton; - else if(el.title) name = el.title; - else if(el.format) name = el.format; - else if(el.type) name = el.type; - else if(el.description) name = el.description; - else if(JSON.stringify(el).length < 50) name = JSON.stringify(el); - else name = "type"; - - disp.push(name); - }); - - // Replace identical display text with "text 1", "text 2", etc. - var inc = {}; - $each(disp,function(i,name) { - inc[name] = inc[name] || 0; - inc[name]++; - - if(used[name] > 1) disp[i] = name + " " + inc[name]; - }); - - return disp; - }, - getOption: function(key) { - try { - throw "getOption is deprecated"; - } - catch(e) { - window.console.error(e); - } - - return this.options[key]; - }, - showValidationErrors: function(errors) { - - } -}); - -JSONEditor.defaults.editors["null"] = JSONEditor.AbstractEditor.extend({ - getValue: function() { - if (!this.dependenciesFulfilled) { - return undefined; - } - return null; - }, - setValue: function() { - this.onChange(); - }, - getNumColumns: function() { - return 2; - } -}); - -JSONEditor.defaults.editors.qbldr = JSONEditor.AbstractEditor.extend({ - register: function() { - this._super(); - if(!this.input) return; - this.input.setAttribute('name',this.formname); - }, - unregister: function() { - this._super(); - if(!this.input) return; - this.input.removeAttribute('name'); - }, - setValue: function(value, initial) { - var self = this; - - if(typeof value === "undefined" || typeof this.jqbldrId === "undefined" || value === this.value) { - return; - } - - if ((initial === true) && (value !== "") && (value !== null)) { - $(this.jqbldrId).queryBuilder('off','rulesChanged'); - $(this.jqbldrId).queryBuilder('setRulesFromSQL', value); - var filter_result = $(this.jqbldrId).queryBuilder('getSQL'); - value = filter_result === null ? null : filter_result.sql; - $(this.jqbldrId).queryBuilder('on', 'rulesChanged', this.qbldrRulesChangedCb.bind(this)); - } - - this.input.value = value; - this.value = value; - - // Bubble this setValue to parents if the value changed - this.onChange(true); - }, - getValue: function() { - var self = this; - - if (this.value === "" || this.value === null) { - return undefined; - } else { - return this.value; - } - }, - - getNumColumns: function() { - return 12; - }, - - qbldrRulesChangedCb: function(eventObj) { - var self = this; - - $(this.jqbldrId).queryBuilder('off','rulesChanged'); - - var filter_result = $(this.jqbldrId).queryBuilder('getSQL'); - - if (filter_result !== null) { - this.setValue(filter_result.sql); - } - - $(this.jqbldrId).queryBuilder('on', 'rulesChanged', this.qbldrRulesChangedCb.bind(this)); - - return; - }, - preBuild: function() { - var self = this; - this._super(); - }, - build: function() { - var self = this; - - this.qschema = this.schema.qschema; - this.qbldrId = this.path; - this.jqbldrId = '#' + this.qbldrId; - this.jqbldrId = this.jqbldrId.replace(/\./g,'\\.'); - - this.qgrid = this.theme.getGridContainer(); - this.qgrid.style.padding = '4px'; - this.qgrid.style.border = '1px solid #e3e3e3'; - - this.gridrow1 = this.theme.getGridRow(); - this.gridrow1.style.padding = '4px'; - - this.gridrow2 = this.theme.getGridRow(); - this.gridrow2.style.padding = '4px'; - - this.title = this.getTitle(); - this.label = this.theme.getFormInputLabel(this.title); - - this.input = this.theme.getTextareaInput(); - this.input.disabled = 'true'; - - this.control = this.theme.getFormControl(this.label, this.input, this.description); - - this.gridrow2.setAttribute('id',this.qbldrId); - - this.container.appendChild(this.qgrid); // attach the grid to container - - this.qgrid.appendChild(this.gridrow1); // attach gridrow1 to grid - this.gridrow1.appendChild(this.control); // attach control form to gridrow1 - - this.qgrid.appendChild(this.gridrow2); - - var options = { conditions: [ 'AND', 'OR'], sort_filters: true }; - - $.extend(this.qschema, options); - - $(this.jqbldrId).queryBuilder(this.qschema); - - //$(this.jqbldrId).queryBuilder('on', 'rulesChanged', this.qbldrRulesChangedCb.bind(this)); - //$(this.jqbldrId).queryBuilder('on', 'afterUpdateRuleValue', this.qbldrRulesChangedCb.bind(this)); - $(this.jqbldrId).queryBuilder('on', 'rulesChanged', this.qbldrRulesChangedCb.bind(this)); - }, - enable: function() { - this._super(); - }, - disable: function() { - this._super(); - }, - afterInputReady: function() { - var self = this, options; - self.theme.afterInputReady(self.input); - }, - refreshValue: function() { - this.value = this.input.value; - if(typeof this.value !== "string") this.value = ''; - }, - destroy: function() { - var self = this; - this._super(); - }, - /** - * This is overridden in derivative editors - */ - sanitize: function(value) { - return value; - }, - /** - * Re-calculates the value if needed - */ - onWatchedFieldChange: function() { - var self = this, vars, j; - - this._super(); - }, - showValidationErrors: function(errors) { - var self = this; - - if(this.jsoneditor.options.show_errors === "always") {} - else if(this.previous_error_setting===this.jsoneditor.options.show_errors) return; - - this.previous_error_setting = this.jsoneditor.options.show_errors; - - var messages = []; - $each(errors,function(i,error) { - if(error.path === self.path) { - messages.push(error.message); - } - }); - - this.input.controlgroup = this.control; - - if(messages.length) { - this.theme.addInputError(this.input, messages.join('. ')+'.'); - } - else { - this.theme.removeInputError(this.input); - } - } -}); - -JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ - register: function() { - this._super(); - if(!this.input) return; - this.input.setAttribute('name',this.formname); - }, - unregister: function() { - this._super(); - if(!this.input) return; - this.input.removeAttribute('name'); - }, - setValue: function(value,initial,from_template) { - var self = this; - - if(this.template && !from_template) { - return; - } - - if(value === null || typeof value === 'undefined') value = ""; - else if(typeof value === "object") value = JSON.stringify(value); - else if(typeof value !== "string") value = ""+value; - - if(value === this.serialized) return; - - // Sanitize value before setting it - var sanitized = this.sanitize(value); - - if(this.input.value === sanitized) { - return; - } - - this.input.value = sanitized; - - // If using SCEditor, update the WYSIWYG - if(this.sceditor_instance) { - this.sceditor_instance.val(sanitized); - } - else if(this.SimpleMDE) { - this.SimpleMDE.value(sanitized); - } - else if(this.ace_editor) { - this.ace_editor.setValue(sanitized); - } - - var changed = from_template || this.getValue() !== value; - - this.refreshValue(); - - if(initial) this.is_dirty = false; - else if(this.jsoneditor.options.show_errors === "change") this.is_dirty = true; - - if(this.adjust_height) this.adjust_height(this.input); - - // Bubble this setValue to parents if the value changed - this.onChange(changed); - }, - getNumColumns: function() { - var min = Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5); - var num; - - if(this.input_type === 'textarea') num = 6; - else if(['text','email'].indexOf(this.input_type) >= 0) num = 4; - else num = 2; - - return Math.min(12,Math.max(min,num)); - }, - build: function() { - var self = this, i; - if(!this.options.compact) this.header = this.label = this.theme.getFormInputLabel(this.getTitle()); - if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description); - if(this.options.infoText) this.infoButton = this.theme.getInfoButton(this.options.infoText); - - this.format = this.schema.format; - if(!this.format && this.schema.media && this.schema.media.type) { - this.format = this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,''); - } - if(!this.format && this.options.default_format) { - this.format = this.options.default_format; - } - if(this.options.format) { - this.format = this.options.format; - } - - // Specific format - if(this.format) { - // Text Area - if(this.format === 'textarea') { - this.input_type = 'textarea'; - this.input = this.theme.getTextareaInput(); - } - // Range Input - else if(this.format === 'range') { - this.input_type = 'range'; - var min = this.schema.minimum || 0; - var max = this.schema.maximum || Math.max(100,min+1); - var step = 1; - if(this.schema.multipleOf) { - if(min%this.schema.multipleOf) min = Math.ceil(min/this.schema.multipleOf)*this.schema.multipleOf; - if(max%this.schema.multipleOf) max = Math.floor(max/this.schema.multipleOf)*this.schema.multipleOf; - step = this.schema.multipleOf; - } - - this.input = this.theme.getRangeInput(min,max,step); - } - // Source Code - else if([ - 'actionscript', - 'batchfile', - 'bbcode', - 'c', - 'c++', - 'cpp', - 'coffee', - 'csharp', - 'css', - 'dart', - 'django', - 'ejs', - 'erlang', - 'golang', - 'groovy', - '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' - ].indexOf(this.format) >= 0 - ) { - this.input_type = this.format; - this.source_code = true; - - this.input = this.theme.getTextareaInput(); - } - // HTML5 Input type - else { - this.input_type = this.format; - this.input = this.theme.getFormInputField(this.input_type); - } - } - // Normal text input - else { - this.input_type = 'text'; - this.input = this.theme.getFormInputField(this.input_type); - } - - // 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+',}'); - - if(this.options.compact) { - this.container.className += ' compact'; - } - else { - if(this.options.input_width) this.input.style.width = this.options.input_width; - } - - if(this.schema.readOnly || this.schema.readonly || this.schema.template) { - this.always_disabled = true; - this.input.disabled = true; - } - - this.input - .addEventListener('change',function(e) { - e.preventDefault(); - e.stopPropagation(); - - // Don't allow changing if this field is a template - if(self.schema.template) { - this.value = self.value; - return; - } - - var val = this.value; - - // sanitize value - var sanitized = self.sanitize(val); - if(val !== sanitized) { - this.value = sanitized; - } - - self.is_dirty = true; - - self.refreshValue(); - self.onChange(true); - }); - - if(this.options.input_height) this.input.style.height = this.options.input_height; - if(this.options.expand_height) { - this.adjust_height = function(el) { - if(!el) return; - var i, ch=el.offsetHeight; - // Input too short - if(el.offsetHeight < el.scrollHeight) { - i=0; - while(el.offsetHeight < el.scrollHeight+3) { - if(i>100) break; - i++; - ch++; - el.style.height = ch+'px'; - } - } - else { - i=0; - while(el.offsetHeight >= el.scrollHeight+3) { - if(i>100) break; - i++; - ch--; - el.style.height = ch+'px'; - } - el.style.height = (ch+1)+'px'; - } - }; - - this.input.addEventListener('keyup',function(e) { - self.adjust_height(this); - }); - this.input.addEventListener('change',function(e) { - self.adjust_height(this); - }); - this.adjust_height(); - } - - if(this.format) this.input.setAttribute('data-schemaformat',this.format); - - this.control = this.theme.getFormControl(this.label, this.input, this.description, this.infoButton); - this.container.appendChild(this.control); - - // 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 - if(self.input.parentNode) self.afterInputReady(); - if(self.adjust_height) self.adjust_height(self.input); - }); - - // Compile and store the template - if(this.schema.template) { - this.template = this.jsoneditor.compileTemplate(this.schema.template, this.template_engine); - this.refreshValue(); - } - else { - this.refreshValue(); - } - }, - enable: function() { - if(!this.always_disabled) { - this.input.disabled = false; - // TODO: WYSIWYG and Markdown editors - this._super(); - } - }, - disable: function(always_disabled) { - if(always_disabled) this.always_disabled = true; - this.input.disabled = true; - // TODO: WYSIWYG and Markdown editors - this._super(); - }, - afterInputReady: function() { - var self = this, options; - - // Code editor - if(this.source_code) { - // WYSIWYG html and bbcode editor - if(this.options.wysiwyg && - ['html','bbcode'].indexOf(this.input_type) >= 0 && - window.jQuery && window.jQuery.fn && window.jQuery.fn.sceditor - ) { - options = $extend({},{ - plugins: self.input_type==='html'? 'xhtml' : 'bbcode', - emoticonsEnabled: false, - width: '100%', - height: 300 - },JSONEditor.plugins.sceditor,self.options.sceditor_options||{}); - - window.jQuery(self.input).sceditor(options); - - self.sceditor_instance = window.jQuery(self.input).sceditor('instance'); - - self.sceditor_instance.blur(function() { - // Get editor's value - var val = window.jQuery("
"+self.sceditor_instance.val()+"
"); - // Remove sceditor spans/divs - window.jQuery('#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf',val).remove(); - // Set the value and update - self.input.value = val.html(); - self.value = self.input.value; - self.is_dirty = true; - self.onChange(true); - }); - } - // SimpleMDE for markdown (if it's loaded) - else if (this.input_type === 'markdown' && window.SimpleMDE) { - options = $extend({},JSONEditor.plugins.SimpleMDE,{ - element: this.input - }); - - this.SimpleMDE = new window.SimpleMDE((options)); - - this.SimpleMDE.codemirror.on("change",function() { - self.value = self.SimpleMDE.value(); - self.is_dirty = true; - self.onChange(true); - }); - } - // ACE editor for everything else - else if(window.ace) { - var mode = this.input_type; - // aliases for c/cpp - if(mode === 'cpp' || mode === 'c++' || mode === 'c') { - mode = 'c_cpp'; - } - - this.ace_container = document.createElement('div'); - this.ace_container.style.width = '100%'; - this.ace_container.style.position = 'relative'; - this.ace_container.style.height = '400px'; - this.input.parentNode.insertBefore(this.ace_container,this.input); - this.input.style.display = 'none'; - this.ace_editor = window.ace.edit(this.ace_container); - - this.ace_editor.setValue(this.getValue()); - - // The theme - if(JSONEditor.plugins.ace.theme) this.ace_editor.setTheme('ace/theme/'+JSONEditor.plugins.ace.theme); - // The mode - this.ace_editor.getSession().setMode('ace/mode/' + this.schema.format); - - // Listen for changes - this.ace_editor.on('change',function() { - var val = self.ace_editor.getValue(); - self.input.value = val; - self.refreshValue(); - self.is_dirty = true; - self.onChange(true); - }); - } - } - - self.theme.afterInputReady(self.input); - }, - refreshValue: function() { - this.value = this.input.value; - if(typeof this.value !== "string") this.value = ''; - this.serialized = this.value; - }, - destroy: function() { - // If using SCEditor, destroy the editor instance - if(this.sceditor_instance) { - this.sceditor_instance.destroy(); - } - else if(this.SimpleMDE) { - this.SimpleMDE.destroy(); - } - else if(this.ace_editor) { - this.ace_editor.destroy(); - } - - - this.template = null; - if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); - if(this.label && this.label.parentNode) this.label.parentNode.removeChild(this.label); - if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description); - - this._super(); - }, - /** - * This is overridden in derivative editors - */ - sanitize: function(value) { - return value; - }, - /** - * Re-calculates the value if needed - */ - onWatchedFieldChange: function() { - var self = this, vars, j; - - // If this editor needs to be rendered by a macro template - if(this.template) { - vars = this.getWatchedFieldValues(); - this.setValue(this.template(vars),false,true); - } - - this._super(); - }, - showValidationErrors: function(errors) { - var self = this; - - if(this.jsoneditor.options.show_errors === "always") {} - else if(!this.is_dirty && this.previous_error_setting===this.jsoneditor.options.show_errors) return; - - this.previous_error_setting = this.jsoneditor.options.show_errors; - - var messages = []; - $each(errors,function(i,error) { - if(error.path === self.path) { - messages.push(error.message); - } - }); - - this.input.controlgroup = this.control; - - if(messages.length) { - this.theme.addInputError(this.input, messages.join('. ')+'.'); - } - else { - this.theme.removeInputError(this.input); - } - } -}); - -/** - * Created by Mehmet Baker on 12.04.2017 - */ -JSONEditor.defaults.editors.hidden = JSONEditor.AbstractEditor.extend({ - register: function () { - this._super(); - if (!this.input) return; - this.input.setAttribute('name', this.formname); - }, - unregister: function () { - this._super(); - if (!this.input) return; - this.input.removeAttribute('name'); - }, - setValue: function (value, initial, from_template) { - var self = this; - - if(this.template && !from_template) { - return; - } - - if(value === null || typeof value === 'undefined') value = ""; - else if(typeof value === "object") value = JSON.stringify(value); - else if(typeof value !== "string") value = ""+value; - - if(value === this.serialized) return; - - // Sanitize value before setting it - var sanitized = this.sanitize(value); - - if(this.input.value === sanitized) { - return; - } - - this.input.value = sanitized; - - var changed = from_template || this.getValue() !== value; - - this.refreshValue(); - - if(initial) this.is_dirty = false; - else if(this.jsoneditor.options.show_errors === "change") this.is_dirty = true; - - if(this.adjust_height) this.adjust_height(this.input); - - // Bubble this setValue to parents if the value changed - this.onChange(changed); - }, - getNumColumns: function () { - return 2; - }, - enable: function () { - this._super(); - }, - disable: function () { - this._super(); - }, - refreshValue: function () { - this.value = this.input.value; - if (typeof this.value !== "string") this.value = ''; - this.serialized = this.value; - }, - destroy: function () { - this.template = null; - if (this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); - if (this.label && this.label.parentNode) this.label.parentNode.removeChild(this.label); - if (this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description); - - this._super(); - }, - /** - * This is overridden in derivative editors - */ - sanitize: function (value) { - return value; - }, - /** - * Re-calculates the value if needed - */ - onWatchedFieldChange: function () { - var self = this, vars, j; - - // If this editor needs to be rendered by a macro template - if (this.template) { - vars = this.getWatchedFieldValues(); - this.setValue(this.template(vars), false, true); - } - - this._super(); - }, - build: function () { - var self = this; - - this.format = this.schema.format; - if (!this.format && this.options.default_format) { - this.format = this.options.default_format; - } - if (this.options.format) { - this.format = this.options.format; - } - - this.input_type = 'hidden'; - this.input = this.theme.getFormInputField(this.input_type); - - if (this.format) this.input.setAttribute('data-schemaformat', this.format); - - this.container.appendChild(this.input); - - // Compile and store the template - if (this.schema.template) { - this.template = this.jsoneditor.compileTemplate(this.schema.template, this.template_engine); - this.refreshValue(); - } - else { - this.refreshValue(); - } - } -}); -JSONEditor.defaults.editors.number = JSONEditor.defaults.editors.string.extend({ - build: function() { - this._super(); - - if (typeof this.schema.minimum !== "undefined") { - var minimum = this.schema.minimum; - - if (typeof this.schema.exclusiveMinimum !== "undefined") { - minimum += 1; - } - - this.input.setAttribute("min", minimum); - } - - if (typeof this.schema.maximum !== "undefined") { - var maximum = this.schema.maximum; - - if (typeof this.schema.exclusiveMaximum !== "undefined") { - maximum -= 1; - } - - this.input.setAttribute("max", maximum); - } - - if (typeof this.schema.step !== "undefined") { - var step = this.schema.step || 1; - this.input.setAttribute("step", step); - } - - }, - sanitize: function(value) { - return (value+"").replace(/[^0-9\.\-eE]/g,''); - }, - getNumColumns: function() { - return 2; - }, - getValue: function() { - if (!this.dependenciesFulfilled) { - return undefined; - } - return this.value===''?undefined:this.value*1; - } -}); - -JSONEditor.defaults.editors.integer = JSONEditor.defaults.editors.number.extend({ - sanitize: function(value) { - value = value + ""; - return value.replace(/[^0-9\-]/g,''); - }, - getNumColumns: function() { - return 2; - } -}); - -JSONEditor.defaults.editors.rating = JSONEditor.defaults.editors.integer.extend({ - build: function() { - var self = this, i; - if(!this.options.compact) this.header = this.label = this.theme.getFormInputLabel(this.getTitle()); - if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description); - - // Dynamically add the required CSS the first time this editor is used - var styleId = 'json-editor-style-rating'; - var styles = document.getElementById(styleId); - if (!styles) { - var style = document.createElement('style'); - style.id = styleId; - style.type = 'text/css'; - style.innerHTML = - ' .rating-container {' + - ' display: inline-block;' + - ' clear: both;' + - ' }' + - ' ' + - ' .rating {' + - ' float:left;' + - ' }' + - ' ' + - ' /* :not(:checked) is a filter, so that browsers that don’t support :checked don’t' + - ' follow these rules. Every browser that supports :checked also supports :not(), so' + - ' it doesn’t make the test unnecessarily selective */' + - ' .rating:not(:checked) > input {' + - ' position:absolute;' + - ' top:-9999px;' + - ' clip:rect(0,0,0,0);' + - ' }' + - ' ' + - ' .rating:not(:checked) > label {' + - ' float:right;' + - ' width:1em;' + - ' padding:0 .1em;' + - ' overflow:hidden;' + - ' white-space:nowrap;' + - ' cursor:pointer;' + - ' color:#ddd;' + - ' }' + - ' ' + - ' .rating:not(:checked) > label:before {' + - ' content: \'★ \';' + - ' }' + - ' ' + - ' .rating > input:checked ~ label {' + - ' color: #FFB200;' + - ' }' + - ' ' + - ' .rating:not([readOnly]):not(:checked) > label:hover,' + - ' .rating:not([readOnly]):not(:checked) > label:hover ~ label {' + - ' color: #FFDA00;' + - ' }' + - ' ' + - ' .rating:not([readOnly]) > input:checked + label:hover,' + - ' .rating:not([readOnly]) > input:checked + label:hover ~ label,' + - ' .rating:not([readOnly]) > input:checked ~ label:hover,' + - ' .rating:not([readOnly]) > input:checked ~ label:hover ~ label,' + - ' .rating:not([readOnly]) > label:hover ~ input:checked ~ label {' + - ' color: #FF8C0D;' + - ' }' + - ' ' + - ' .rating:not([readOnly]) > label:active {' + - ' position:relative;' + - ' top:2px;' + - ' left:2px;' + - ' }'; - document.getElementsByTagName('head')[0].appendChild(style); - } - - this.input = this.theme.getFormInputField('hidden'); - this.container.appendChild(this.input); - - // Required to keep height - var ratingContainer = document.createElement('div'); - ratingContainer.className = 'rating-container'; - - // Contains options for rating - var group = document.createElement('div'); - group.setAttribute('name', this.formname); - group.className = 'rating'; - ratingContainer.appendChild(group); - - if(this.options.compact) this.container.setAttribute('class',this.container.getAttribute('class')+' compact'); - - var max = this.schema.maximum ? this.schema.maximum : 5; - if (this.schema.exclusiveMaximum) max--; - - this.inputs = []; - for(i=max; i>0; i--) { - var id = this.formname + i; - var radioInput = this.theme.getFormInputField('radio'); - radioInput.setAttribute('id', id); - radioInput.setAttribute('value', i); - radioInput.setAttribute('name', this.formname); - group.appendChild(radioInput); - this.inputs.push(radioInput); - - var label = document.createElement('label'); - label.setAttribute('for', id); - label.appendChild(document.createTextNode(i + (i == 1 ? ' star' : ' stars'))); - group.appendChild(label); - } - - if(this.schema.readOnly || this.schema.readonly) { - this.always_disabled = true; - $each(this.inputs,function(i,input) { - group.setAttribute("readOnly", "readOnly"); - input.disabled = true; - }); - } - - ratingContainer - .addEventListener('change',function(e) { - e.preventDefault(); - e.stopPropagation(); - - self.input.value = e.srcElement.value; - - self.is_dirty = true; - - self.refreshValue(); - self.watch_listener(); - self.jsoneditor.notifyWatchers(self.path); - if(self.parent) self.parent.onChildEditorChange(self); - else self.jsoneditor.onChange(); - }); - - this.control = this.theme.getFormControl(this.label, ratingContainer, this.description); - this.container.appendChild(this.control); - - this.refreshValue(); - }, - setValue: function(val) { - var sanitized = this.sanitize(val); - if(this.value === sanitized) { - return; - } - var self = this; - $each(this.inputs,function(i,input) { - if (input.value === sanitized) { - input.checked = true; - self.value = sanitized; - self.input.value = self.value; - self.watch_listener(); - self.jsoneditor.notifyWatchers(self.path); - return false; - } - }); - } -}); - -JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ - getDefault: function() { - return $extend({},this.schema["default"] || {}); - }, - getChildEditors: function() { - return this.editors; - }, - register: function() { - this._super(); - if(this.editors) { - for(var i in this.editors) { - if(!this.editors.hasOwnProperty(i)) continue; - this.editors[i].register(); - } - } - }, - 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() { - return Math.max(Math.min(12,this.maxwidth),3); - }, - enable: function() { - if(!this.always_disabled) { - if(this.editjson_button) this.editjson_button.disabled = false; - if(this.addproperty_button) this.addproperty_button.disabled = false; - - this._super(); - if(this.editors) { - for(var i in this.editors) { - if(!this.editors.hasOwnProperty(i)) continue; - this.editors[i].enable(); - } - } - } - }, - disable: function(always_disabled) { - if(always_disabled) this.always_disabled = true; - if(this.editjson_button) this.editjson_button.disabled = true; - if(this.addproperty_button) this.addproperty_button.disabled = true; - this.hideEditJSON(); - - this._super(); - if(this.editors) { - for(var i in this.editors) { - if(!this.editors.hasOwnProperty(i)) continue; - this.editors[i].disable(always_disabled); - } - } - }, - layoutEditors: function() { - var self = this, i, j; - - if(!this.row_container) return; - - // Sort editors by propertyOrder - this.property_order = Object.keys(this.editors); - this.property_order = this.property_order.sort(function(a,b) { - var ordera = self.editors[a].schema.propertyOrder; - var orderb = self.editors[b].schema.propertyOrder; - if(typeof ordera !== "number") ordera = 1000; - if(typeof orderb !== "number") orderb = 1000; - - return ordera - orderb; - }); - - var container = document.createElement('div'); - var isCategoriesFormat = (this.format === 'categories'); - - if(this.format === 'grid') { - var rows = []; - $each(this.property_order, function(j,key) { - var editor = self.editors[key]; - if(editor.property_removed) return; - var found = false; - var width = editor.options.hidden? 0 : (editor.options.grid_columns || editor.getNumColumns()); - var height = editor.options.hidden? 0 : editor.container.offsetHeight; - // See if the editor will fit in any of the existing rows first - for(var i=0; i height)) { - found = i; - } - } - } - - // If there isn't a spot in any of the existing rows, start a new row - if(found === false) { - rows.push({ - width: 0, - minh: 999999, - maxh: 0, - editors: [] - }); - found = rows.length-1; - } - - rows[found].editors.push({ - key: key, - //editor: editor, - width: width, - height: height - }); - rows[found].width += width; - rows[found].minh = Math.min(rows[found].minh,height); - rows[found].maxh = Math.max(rows[found].maxh,height); - }); - - // 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 - for(i=0; i rows[i].editors[biggest].width) biggest = j; - rows[i].editors[j].width *= 12/rows[i].width; - rows[i].editors[j].width = Math.floor(rows[i].editors[j].width); - new_width += rows[i].editors[j].width; - } - if(new_width < 12) rows[i].editors[biggest].width += 12-new_width; - rows[i].width = 12; - } - } - - // layout hasn't changed - if(this.layout === JSON.stringify(rows)) return false; - this.layout = JSON.stringify(rows); - - // Layout the form - for(i=0; i 0){ - //If first pane is object or array, insert before a simple pane - if(newTabPanesContainer.firstChild.isObjOrArray){ - //Append pane for simple properties - aPane.appendChild(containerSimple); - newTabPanesContainer.insertBefore(aPane,newTabPanesContainer.firstChild); - //Add "Basic" tab - self.theme.insertBasicTopTab(editor.tab,newTabs_holder); - //newTabs_holder.firstChild.insertBefore(editor.tab,newTabs_holder.firstChild.firstChild); - //Update the basicPane - editor.basicPane = aPane; - } - else { - //We already have a first "Basic" pane, just add the new property to it, so - //do nothing; - } - } - //There is no pane, so add the first (simple) pane - else { - //Append pane for simple properties - aPane.appendChild(containerSimple); - newTabPanesContainer.appendChild(aPane); - //Add "Basic" tab - //newTabs_holder.firstChild.appendChild(editor.tab); - self.theme.addTopTab(newTabs_holder,editor.tab); - //Update the basicPane - editor.basicPane = aPane; - } - } - //Objects and arrays earn it's own panes - else { - aPane.appendChild(gridRow); - newTabPanesContainer.appendChild(aPane); - //newTabs_holder.firstChild.appendChild(editor.tab); - self.theme.addTopTab(newTabs_holder,editor.tab); - } - - if(editor.options.hidden) editor.container.style.display = 'none'; - else self.theme.setGridColumnSize(editor.container,12); - //Now, add the property editor to the row - gridRow.appendChild(editor.container); - //Update the container (same as self.rows[x].container) - editor.container = aPane; - - }); - - //Erase old panes - while (this.tabPanesContainer.firstChild) { - this.tabPanesContainer.removeChild(this.tabPanesContainer.firstChild); - } - - //Erase old tabs and set the new ones - var parentTabs_holder = this.tabs_holder.parentNode; - parentTabs_holder.removeChild(parentTabs_holder.firstChild); - parentTabs_holder.appendChild(newTabs_holder); - - this.tabPanesContainer = newTabPanesContainer; - this.tabs_holder = newTabs_holder; - - //Activate the first tab - var firstTab = this.theme.getFirstTab(this.tabs_holder); - if(firstTab){ - $trigger(firstTab,'click'); - } - return; - } - // !isCategoriesFormat - else { - $each(this.property_order, function(i,key) { - var editor = self.editors[key]; - if(editor.property_removed) return; - var row = self.theme.getGridRow(); - container.appendChild(row); - - if(editor.options.hidden) editor.container.style.display = 'none'; - else self.theme.setGridColumnSize(editor.container,12); - row.appendChild(editor.container); - }); - } - //for grid and normal layout - while (this.row_container.firstChild) { - this.row_container.removeChild(this.row_container.firstChild); - } - this.row_container.appendChild(container); - }, - getPropertySchema: function(key) { - // Schema declared directly in properties - var schema = this.schema.properties[key] || {}; - schema = $extend({},schema); - var matched = this.schema.properties[key]? true : false; - - // Any matching patternProperties should be merged in - if(this.schema.patternProperties) { - for(var i in this.schema.patternProperties) { - if(!this.schema.patternProperties.hasOwnProperty(i)) continue; - var regex = new RegExp(i); - if(regex.test(key)) { - schema.allOf = schema.allOf || []; - schema.allOf.push(this.schema.patternProperties[i]); - matched = true; - } - } - } - - // Hasn't matched other rules, use additionalProperties schema - if(!matched && this.schema.additionalProperties && typeof this.schema.additionalProperties === "object") { - schema = $extend({},this.schema.additionalProperties); - } - - 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.schema.properties = this.schema.properties || {}; - - this.minwidth = 0; - this.maxwidth = 0; - - // If the object should be rendered as a table row - if(this.options.table_row) { - $each(this.schema.properties, function(key,schema) { - var editor = self.jsoneditor.getEditorClass(schema); - self.editors[key] = self.jsoneditor.createEditor(editor,{ - jsoneditor: self.jsoneditor, - schema: schema, - path: self.path+'.'+key, - parent: self, - compact: true, - required: true - }); - self.editors[key].preBuild(); - - var width = self.editors[key].options.hidden? 0 : (self.editors[key].options.grid_columns || self.editors[key].getNumColumns()); - - self.minwidth += width; - self.maxwidth += width; - }); - this.no_link_holder = true; - } - // If the object should be rendered as a table - else if(this.options.table) { - // TODO: table display format - throw "Not supported yet"; - } - // If the object should be rendered as a div - else { - if(!this.schema.defaultProperties) { - if(this.jsoneditor.options.display_required_only || this.options.display_required_only) { - this.schema.defaultProperties = []; - $each(this.schema.properties, function(k,s) { - if(self.isRequired({key: k, schema: s})) { - self.schema.defaultProperties.push(k); - } - }); - } - else { - self.schema.defaultProperties = Object.keys(self.schema.properties); - } - } - - // Increase the grid width to account for padding - self.maxwidth += 1; - - $each(this.schema.defaultProperties, function(i,key) { - self.addObjectProperty(key, true); - - if(self.editors[key]) { - self.minwidth = Math.max(self.minwidth,(self.editors[key].options.grid_columns || self.editors[key].getNumColumns())); - self.maxwidth += (self.editors[key].options.grid_columns || self.editors[key].getNumColumns()); - } - }); - } - - // Sort editors by propertyOrder - this.property_order = Object.keys(this.editors); - this.property_order = this.property_order.sort(function(a,b) { - var ordera = self.editors[a].schema.propertyOrder; - var orderb = self.editors[b].schema.propertyOrder; - if(typeof ordera !== "number") ordera = 1000; - if(typeof orderb !== "number") orderb = 1000; - - return ordera - orderb; - }); - }, - //"Borrow" from arrays code - addTab: function(idx){ - var self = this; - var isObjOrArray = self.rows[idx].schema && (self.rows[idx].schema.type === "object" || self.rows[idx].schema.type === "array"); - if(self.tabs_holder) { - self.rows[idx].tab_text = document.createElement('span'); - - if(!isObjOrArray){ - self.rows[idx].tab_text.textContent = (typeof self.schema.basicCategoryTitle === 'undefined') ? "Basic" : self.schema.basicCategoryTitle; - } else { - self.rows[idx].tab_text.textContent = self.rows[idx].getHeaderText(); - } - self.rows[idx].tab = self.theme.getTopTab(self.rows[idx].tab_text,self.rows[idx].tab_text.textContent); - self.rows[idx].tab.addEventListener('click', function(e) { - self.active_tab = self.rows[idx].tab; - self.refreshTabs(); - e.preventDefault(); - e.stopPropagation(); - }); - - } - - }, - addRow: function(editor, tabHolder, holder) { - var self = this; - var rowsLen = this.rows.length; - var isObjOrArray = editor.schema.type === "object" || editor.schema.type === "array"; - - //Add a row - self.rows[rowsLen] = editor; - //container stores the editor corresponding pane to set the display style when refreshing Tabs - self.rows[rowsLen].container = holder; - - if(!isObjOrArray){ - - //This is the first simple property to be added, - //add a ("Basic") tab for it and save it's row number - if(typeof self.basicTab === "undefined"){ - self.addTab(rowsLen); - //Store the index row of the first simple property added - self.basicTab = rowsLen; - self.basicPane = holder; - self.theme.addTopTab(tabHolder, self.rows[rowsLen].tab); - } - - else { - //Any other simple property gets the same tab (and the same pane) as the first one, - //so, when 'click' event is fired from a row, it gets the correct ("Basic") tab - self.rows[rowsLen].tab = self.rows[self.basicTab].tab; - self.rows[rowsLen].tab_text = self.rows[self.basicTab].tab_text; - self.rows[rowsLen].container = self.rows[self.basicTab].container; - } - } - else { - self.addTab(rowsLen); - self.theme.addTopTab(tabHolder, self.rows[rowsLen].tab); - } - }, - //Mark the active tab and make visible the corresponding pane, hide others - refreshTabs: function(refresh_headers) { - var self = this; - var basicTabPresent = typeof self.basicTab !== 'undefined'; - var basicTabRefreshed = false; - - $each(this.rows, function(i,row) { - //If it's an orphan row (some property which has been deleted), return - if(!row.tab || !row.container || !row.container.parentNode) return; - - if(basicTabPresent && row.tab == self.rows[self.basicTab].tab && basicTabRefreshed) return; - - if(refresh_headers) { - row.tab_text.textContent = row.getHeaderText(); - } - else { - //All rows of simple properties point to the same tab, so refresh just once - if(basicTabPresent && row.tab == self.rows[self.basicTab].tab) basicTabRefreshed = true; - - if(row.tab === self.active_tab) { - self.theme.markTabActive(row); - } - else { - self.theme.markTabInactive(row); - } - } - }); - }, - build: function() { - var self = this; - - var isCategoriesFormat = (this.format === 'categories'); - this.rows=[]; - this.active_tab = null; - - // If the object should be rendered as a table row - if(this.options.table_row) { - this.editor_holder = this.container; - $each(this.editors, function(key,editor) { - var holder = self.theme.getTableCell(); - self.editor_holder.appendChild(holder); - - editor.setContainer(holder); - editor.build(); - editor.postBuild(); - - if(self.editors[key].options.hidden) { - holder.style.display = 'none'; - } - if(self.editors[key].options.input_width) { - holder.style.width = self.editors[key].options.input_width; - } - }); - } - // If the object should be rendered as a table - else if(this.options.table) { - // TODO: table display format - throw "Not supported yet"; - } - // If the object should be rendered as a div - else { - this.header = document.createElement('span'); - this.header.textContent = this.getTitle(); - this.title = this.theme.getHeader(this.header); - this.container.appendChild(this.title); - this.container.style.position = 'relative'; - - // Edit JSON modal - this.editjson_holder = this.theme.getModal(); - this.editjson_textarea = this.theme.getTextareaInput(); - this.editjson_textarea.style.height = '170px'; - this.editjson_textarea.style.width = '300px'; - this.editjson_textarea.style.display = 'block'; - this.editjson_save = this.getButton('Save','save','Save'); - this.editjson_save.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - self.saveJSON(); - }); - this.editjson_cancel = this.getButton('Cancel','cancel','Cancel'); - this.editjson_cancel.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - self.hideEditJSON(); - }); - this.editjson_holder.appendChild(this.editjson_textarea); - this.editjson_holder.appendChild(this.editjson_save); - this.editjson_holder.appendChild(this.editjson_cancel); - - // Manage Properties modal - this.addproperty_holder = this.theme.getModal(); - this.addproperty_list = document.createElement('div'); - this.addproperty_list.style.width = '295px'; - this.addproperty_list.style.maxHeight = '160px'; - this.addproperty_list.style.padding = '5px 0'; - this.addproperty_list.style.overflowY = 'auto'; - this.addproperty_list.style.overflowX = 'hidden'; - this.addproperty_list.style.paddingLeft = '5px'; - this.addproperty_list.setAttribute('class', 'property-selector'); - this.addproperty_add = this.getButton('add','add','add'); - this.addproperty_input = this.theme.getFormInputField('text'); - this.addproperty_input.setAttribute('placeholder','Property name...'); - this.addproperty_input.style.width = '220px'; - this.addproperty_input.style.marginBottom = '0'; - this.addproperty_input.style.display = 'inline-block'; - this.addproperty_add.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - if(self.addproperty_input.value) { - if(self.editors[self.addproperty_input.value]) { - window.alert('there is already a property with that name'); - return; - } - - self.addObjectProperty(self.addproperty_input.value); - if(self.editors[self.addproperty_input.value]) { - self.editors[self.addproperty_input.value].disable(); - } - self.onChange(true); - } - }); - this.addproperty_holder.appendChild(this.addproperty_list); - this.addproperty_holder.appendChild(this.addproperty_input); - this.addproperty_holder.appendChild(this.addproperty_add); - var spacer = document.createElement('div'); - spacer.style.clear = 'both'; - this.addproperty_holder.appendChild(spacer); - - - // Description - if(this.schema.description) { - this.description = this.theme.getDescription(this.schema.description); - this.container.appendChild(this.description); - } - - // Validation error placeholder area - this.error_holder = document.createElement('div'); - this.container.appendChild(this.error_holder); - - // Container for child editor area - this.editor_holder = this.theme.getIndentedPanel(); - this.container.appendChild(this.editor_holder); - - // Container for rows of child editors - this.row_container = this.theme.getGridContainer(); - - if(isCategoriesFormat) { - this.tabs_holder = this.theme.getTopTabHolder(this.schema.title); - this.tabPanesContainer = this.theme.getTopTabContentHolder(this.tabs_holder); - this.editor_holder.appendChild(this.tabs_holder); - } - else { - this.tabs_holder = this.theme.getTabHolder(this.schema.title); - this.tabPanesContainer = this.theme.getTabContentHolder(this.tabs_holder); - this.editor_holder.appendChild(this.row_container); - } - - $each(this.editors, function(key,editor) { - var aPane = self.theme.getTabContent(); - var holder = self.theme.getGridColumn(); - var isObjOrArray = (editor.schema && (editor.schema.type === 'object' || editor.schema.type === 'array')) ? true : false; - aPane.isObjOrArray = isObjOrArray; - - if(isCategoriesFormat){ - if(isObjOrArray) { - var single_row_container = self.theme.getGridContainer(); - single_row_container.appendChild(holder); - aPane.appendChild(single_row_container); - self.tabPanesContainer.appendChild(aPane); - self.row_container = single_row_container; - } - else { - if(typeof self.row_container_basic === 'undefined'){ - self.row_container_basic = self.theme.getGridContainer(); - aPane.appendChild(self.row_container_basic); - if(self.tabPanesContainer.childElementCount == 0){ - self.tabPanesContainer.appendChild(aPane); - } - else { - self.tabPanesContainer.insertBefore(aPane,self.tabPanesContainer.childNodes[1]); - } - } - self.row_container_basic.appendChild(holder); - } - - self.addRow(editor,self.tabs_holder,aPane); - - aPane.id = editor.schema.title; //editor.schema.path//tab_text.textContent - - } - else { - self.row_container.appendChild(holder); - } - - editor.setContainer(holder); - editor.build(); - editor.postBuild(); - }); - - if(this.rows[0]){ - $trigger(this.rows[0].tab,'click'); - } - - // Control buttons - this.title_controls = this.theme.getHeaderButtonHolder(); - this.editjson_controls = this.theme.getHeaderButtonHolder(); - this.addproperty_controls = this.theme.getHeaderButtonHolder(); - this.title.appendChild(this.title_controls); - this.title.appendChild(this.editjson_controls); - this.title.appendChild(this.addproperty_controls); - - // Show/Hide button - this.collapsed = false; - this.toggle_button = this.getButton('', 'collapse', this.translate('button_collapse')); - this.title_controls.appendChild(this.toggle_button); - this.toggle_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - if(self.collapsed) { - self.editor_holder.style.display = ''; - self.collapsed = false; - self.setButtonText(self.toggle_button,'','collapse',self.translate('button_collapse')); - } - else { - self.editor_holder.style.display = 'none'; - self.collapsed = true; - self.setButtonText(self.toggle_button,'','expand',self.translate('button_expand')); - } - }); - - // If it should start collapsed - if(this.options.collapsed) { - $trigger(this.toggle_button,'click'); - } - - // Collapse button disabled - if(this.schema.options && typeof this.schema.options.disable_collapse !== "undefined") { - if(this.schema.options.disable_collapse) this.toggle_button.style.display = 'none'; - } - else if(this.jsoneditor.options.disable_collapse) { - this.toggle_button.style.display = 'none'; - } - - // Edit JSON Button - this.editjson_button = this.getButton('JSON','edit','Edit JSON'); - this.editjson_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - self.toggleEditJSON(); - }); - this.editjson_controls.appendChild(this.editjson_button); - this.editjson_controls.appendChild(this.editjson_holder); - - // Edit JSON Buttton disabled - if(this.schema.options && typeof this.schema.options.disable_edit_json !== "undefined") { - if(this.schema.options.disable_edit_json) this.editjson_button.style.display = 'none'; - } - else if(this.jsoneditor.options.disable_edit_json) { - this.editjson_button.style.display = 'none'; - } - - // Object Properties Button - this.addproperty_button = this.getButton('Properties','edit','Object Properties'); - this.addproperty_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - self.toggleAddProperty(); - }); - this.addproperty_controls.appendChild(this.addproperty_button); - this.addproperty_controls.appendChild(this.addproperty_holder); - this.refreshAddProperties(); - } - - // Fix table cell ordering - if(this.options.table_row) { - this.editor_holder = this.container; - $each(this.property_order,function(i,key) { - self.editor_holder.appendChild(self.editors[key].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.left = this.editjson_button.offsetLeft+"px"; - this.editjson_holder.style.top = this.editjson_button.offsetTop + this.editjson_button.offsetHeight+"px"; - - // Start the textarea with the current value - this.editjson_textarea.value = JSON.stringify(this.getValue(),null,2); - - // Disable the rest of the form while editing JSON - this.disable(); - - this.editjson_holder.style.display = ''; - this.editjson_button.disabled = false; - this.editing_json = true; - }, - hideEditJSON: function() { - if(!this.editjson_holder) return; - if(!this.editing_json) return; - - this.editjson_holder.style.display = 'none'; - this.enable(); - this.editing_json = false; - }, - saveJSON: function() { - if(!this.editjson_holder) return; - - try { - var json = JSON.parse(this.editjson_textarea.value); - this.setValue(json); - this.hideEditJSON(); - } - catch(e) { - window.alert('invalid JSON'); - throw e; - } - }, - toggleEditJSON: function() { - if(this.editing_json) this.hideEditJSON(); - else this.showEditJSON(); - }, - insertPropertyControlUsingPropertyOrder: function (property, control, container) { - var propertyOrder; - if (this.schema.properties[property]) - propertyOrder = this.schema.properties[property].propertyOrder; - if (typeof propertyOrder !== "number") propertyOrder = 1000; - control.propertyOrder = propertyOrder; - - for (var i = 0; i < container.childNodes.length; i++) { - var child = container.childNodes[i]; - if (control.propertyOrder < child.propertyOrder) { - this.addproperty_list.insertBefore(control, child); - control = null; - break; - } - } - if (control) { - this.addproperty_list.appendChild(control); - } - }, - addPropertyCheckbox: function(key) { - var self = this; - var checkbox, label, labelText, control; - - checkbox = self.theme.getCheckbox(); - checkbox.style.width = 'auto'; - - if (this.schema.properties[key] && this.schema.properties[key].title) - labelText = this.schema.properties[key].title; - else - labelText = key; - - label = self.theme.getCheckboxLabel(labelText); - - control = self.theme.getFormControl(label,checkbox); - control.style.paddingBottom = control.style.marginBottom = control.style.paddingTop = control.style.marginTop = 0; - control.style.height = 'auto'; - //control.style.overflowY = 'hidden'; - - this.insertPropertyControlUsingPropertyOrder(key, control, this.addproperty_list); - - checkbox.checked = key in this.editors; - checkbox.addEventListener('change',function() { - if(checkbox.checked) { - self.addObjectProperty(key); - } - else { - self.removeObjectProperty(key); - } - self.onChange(true); - }); - self.addproperty_checkboxes[key] = checkbox; - - 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.left = this.addproperty_button.offsetLeft+"px"; - 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.addproperty_holder.style.display = ''; - this.refreshAddProperties(); - }, - hideAddProperty: function() { - if(!this.addproperty_holder) return; - if(!this.adding_property) return; - - this.addproperty_holder.style.display = 'none'; - this.enable(); - - this.adding_property = false; - }, - toggleAddProperty: function() { - if(this.adding_property) this.hideAddProperty(); - else this.showAddProperty(); - }, - removeObjectProperty: function(property) { - if(this.editors[property]) { - this.editors[property].unregister(); - delete this.editors[property]; - - this.refreshValue(); - this.layoutEditors(); - } - }, - addObjectProperty: function(name, prebuild_only) { - var self = this; - - // Property is already added - if(this.editors[name]) return; - - // Property was added before and is cached - if(this.cached_editors[name]) { - this.editors[name] = this.cached_editors[name]; - if(prebuild_only) return; - this.editors[name].register(); - } - // New property - else { - if(!this.canHaveAdditionalProperties() && (!this.schema.properties || !this.schema.properties[name])) { - return; - } - - var schema = self.getPropertySchema(name); - if(typeof schema.propertyOrder !== 'number'){ - // if the propertyOrder undefined, then set a smart default value. - schema.propertyOrder = Object.keys(self.editors).length + 1000; - } - - - // Add the property - var editor = self.jsoneditor.getEditorClass(schema); - - self.editors[name] = self.jsoneditor.createEditor(editor,{ - jsoneditor: self.jsoneditor, - schema: schema, - path: self.path+'.'+name, - parent: self - }); - self.editors[name].preBuild(); - - if(!prebuild_only) { - var holder = self.theme.getChildEditorHolder(); - self.editor_holder.appendChild(holder); - self.editors[name].setContainer(holder); - self.editors[name].build(); - self.editors[name].postBuild(); - } - - self.cached_editors[name] = self.editors[name]; - } - - // If we're only prebuilding the editors, don't refresh values - if(!prebuild_only) { - self.refreshValue(); - self.layoutEditors(); - } - }, - onChildEditorChange: function(editor) { - this.refreshValue(); - this._super(editor); - }, - canHaveAdditionalProperties: function() { - if (typeof this.schema.additionalProperties === "boolean") {//# sourceMappingURL=jsoneditor.js.map - return this.schema.additionalProperties; - } - return !this.jsoneditor.options.no_additional_properties; - }, - destroy: function() { - $each(this.cached_editors, function(i,el) { - el.destroy(); - }); - if(this.editor_holder) this.editor_holder.innerHTML = ''; - if(this.title && this.title.parentNode) this.title.parentNode.removeChild(this.title); - 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() { - if (!this.dependenciesFulfilled) { - return undefined; - } - var result = this._super(); - if(this.jsoneditor.options.remove_empty_properties || this.options.remove_empty_properties) { - for (var i in result) { - if (result.hasOwnProperty(i)) { - if ((typeof result[i] === 'undefined' || result[i] === '') || - (Object.keys(result[i]).length == 0 && result[i].constructor == Object) || - (Array.isArray(result[i]) && result[i].length == 0)) { - delete result[i]; - } - } - } - } - - return result; - }, - refreshValue: function() { - this.value = {}; - var self = this; - - for(var i in this.editors) { - if(!this.editors.hasOwnProperty(i)) continue; - this.value[i] = this.editors[i].getValue(); - } - - if(this.adding_property) this.refreshAddProperties(); - }, - refreshAddProperties: function() { - if(this.options.disable_properties || (this.options.disable_properties !== false && this.jsoneditor.options.disable_properties)) { - this.addproperty_controls.style.display = 'none'; - return; - } - - var can_add = false, can_remove = false, num_props = 0, i, show_modal = false; - - // 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_list.innerHTML = ''; - } - 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); - - if(this.isRequired(this.cached_editors[i]) && i in this.editors) { - this.addproperty_checkboxes[i].disabled = true; - } - - if(typeof this.schema.minProperties !== "undefined" && num_props <= this.schema.minProperties) { - this.addproperty_checkboxes[i].disabled = this.addproperty_checkboxes[i].checked; - if(!this.addproperty_checkboxes[i].checked) show_modal = true; - } - else if(!(i in this.editors)) { - if(!can_add && !this.schema.properties.hasOwnProperty(i)) { - 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.schema.properties.hasOwnProperty(i)) continue; - 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(); - this.addproperty_controls.style.display = 'none'; - } - // If additional properties are disabled - else if(!this.canHaveAdditionalProperties()) { - this.addproperty_add.style.display = 'none'; - this.addproperty_input.style.display = 'none'; - } - // 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) { - if(typeof editor.schema.required === "boolean") return editor.schema.required; - else if(Array.isArray(this.schema.required)) return this.schema.required.indexOf(editor.key) > -1; - else if(this.jsoneditor.options.required_by_default) return true; - else return false; - }, - setValue: function(value, initial) { - var self = this; - value = value || {}; - - if(typeof value !== "object" || Array.isArray(value)) value = {}; - - // First, set the values for all of the defined properties - $each(this.cached_editors, function(i,editor) { - // Value explicitly set - if(typeof value[i] !== "undefined") { - self.addObjectProperty(i); - editor.setValue(value[i],initial); - } - // Otherwise, remove value unless this is the initial set or it's required - else if(!initial && !self.isRequired(editor)) { - self.removeObjectProperty(i); - } - // Otherwise, set the value to the default - else { - editor.setValue(editor.getDefault(),initial); - } - }); - - $each(value, function(i,val) { - if(!self.cached_editors[i]) { - self.addObjectProperty(i); - if(self.editors[i]) self.editors[i].setValue(val,initial); - } - }); - - 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 = []; - $each(errors, function(i,error) { - if(error.path === self.path) { - my_errors.push(error); - } - else { - other_errors.push(error); - } - }); - - // Show errors for this editor - if(this.error_holder) { - if(my_errors.length) { - var message = []; - this.error_holder.innerHTML = ''; - this.error_holder.style.display = ''; - $each(my_errors, function(i,error) { - self.error_holder.appendChild(self.theme.getErrorMessage(error.message)); - }); - } - // Hide error area - else { - this.error_holder.style.display = 'none'; - } - } - - // Show error for the table row if this is inside a table - if(this.options.table_row) { - if(my_errors.length) { - this.theme.addTableRowError(this.container); - } - else { - this.theme.removeTableRowError(this.container); - } - } - - // Show errors for child editors - $each(this.editors, function(i,editor) { - editor.showValidationErrors(other_errors); - }); - } -}); - -JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({ - getDefault: function() { - return this.schema["default"] || []; - }, - register: function() { - this._super(); - if(this.rows) { - for(var i=0; i= this.schema.items.length) { - if(this.schema.additionalItems===true) { - return {}; - } - else if(this.schema.additionalItems) { - return $extend({},this.schema.additionalItems); - } - } - else { - return $extend({},this.schema.items[i]); - } - } - else if(this.schema.items) { - return $extend({},this.schema.items); - } - else { - return {}; - } - }, - getItemInfo: function(i) { - var schema = this.getItemSchema(i); - - // Check if it's cached - this.item_info = this.item_info || {}; - var stringified = JSON.stringify(schema); - if(typeof this.item_info[stringified] !== "undefined") return this.item_info[stringified]; - - // Get the schema for this item - schema = this.jsoneditor.expandRefs(schema); - - this.item_info[stringified] = { - title: schema.title || "item", - 'default': schema["default"], - width: 12, - child_editors: schema.properties || schema.items - }; - - return this.item_info[stringified]; - }, - getElementEditor: function(i) { - var item_info = this.getItemInfo(i); - var schema = this.getItemSchema(i); - schema = this.jsoneditor.expandRefs(schema); - schema.title = item_info.title+' '+(i+1); - - var editor = this.jsoneditor.getEditorClass(schema); - - var holder; - if(this.tabs_holder) { - if(this.schema.format === 'tabs-top') { - holder = this.theme.getTopTabContent(); - } - else { - holder = this.theme.getTabContent(); - } - holder.id = this.path+'.'+i; - } - else if(item_info.child_editors) { - holder = this.theme.getChildEditorHolder(); - } - else { - holder = this.theme.getIndentedPanel(); - } - - this.row_holder.appendChild(holder); - - var ret = this.jsoneditor.createEditor(editor,{ - jsoneditor: this.jsoneditor, - schema: schema, - container: holder, - path: this.path+'.'+i, - parent: this, - required: true - }); - ret.preBuild(); - ret.build(); - ret.postBuild(); - - if(!ret.title_controls) { - ret.array_controls = this.theme.getButtonHolder(); - holder.appendChild(ret.array_controls); - } - - return ret; - }, - destroy: function() { - this.empty(true); - if(this.title && this.title.parentNode) this.title.parentNode.removeChild(this.title); - 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); - if(this.controls && this.controls.parentNode) this.controls.parentNode.removeChild(this.controls); - if(this.panel && this.panel.parentNode) this.panel.parentNode.removeChild(this.panel); - - this.rows = this.row_cache = this.title = this.description = this.row_holder = this.panel = this.controls = null; - - this._super(); - }, - empty: function(hard) { - if(!this.rows) return; - var self = this; - $each(this.rows,function(i,row) { - if(hard) { - if(row.tab && row.tab.parentNode) row.tab.parentNode.removeChild(row.tab); - self.destroyRow(row,true); - self.row_cache[i] = null; - } - self.rows[i] = null; - }); - self.rows = []; - if(hard) self.row_cache = []; - }, - destroyRow: function(row,hard) { - var holder = row.container; - if(hard) { - row.destroy(); - if(holder.parentNode) holder.parentNode.removeChild(holder); - if(row.tab && row.tab.parentNode) row.tab.parentNode.removeChild(row.tab); - } - else { - if(row.tab) row.tab.style.display = 'none'; - holder.style.display = 'none'; - row.unregister(); - } - }, - getMax: function() { - if((Array.isArray(this.schema.items)) && this.schema.additionalItems === false) { - return Math.min(this.schema.items.length,this.schema.maxItems || Infinity); - } - else { - return this.schema.maxItems || Infinity; - } - }, - refreshTabs: function(refresh_headers) { - var self = this; - $each(this.rows, function(i,row) { - if(!row.tab) return; - - if(refresh_headers) { - row.tab_text.textContent = row.getHeaderText(); - } - else { - if(row.tab === self.active_tab) { - self.theme.markTabActive(row); - } - else { - self.theme.markTabInactive(row); - } - } - }); - }, - setValue: function(value, initial) { - // Update the array's value, adding/removing rows when necessary - value = value || []; - - if(!(Array.isArray(value))) value = [value]; - - var serialized = JSON.stringify(value); - if(serialized === this.serialized) return; - - // Make sure value has between minItems and maxItems items in it - if(this.schema.minItems) { - while(value.length < this.schema.minItems) { - value.push(this.getItemInfo(value.length)["default"]); - } - } - if(this.getMax() && value.length > this.getMax()) { - value = value.slice(0,this.getMax()); - } - - var self = this; - $each(value,function(i,val) { - if(self.rows[i]) { - // TODO: don't set the row's value if it hasn't changed - self.rows[i].setValue(val,initial); - } - else if(self.row_cache[i]) { - self.rows[i] = self.row_cache[i]; - self.rows[i].setValue(val,initial); - self.rows[i].container.style.display = ''; - if(self.rows[i].tab) self.rows[i].tab.style.display = ''; - self.rows[i].register(); - } - else { - self.addRow(val,initial); - } - }); - - for(var j=value.length; j= this.rows.length; - - $each(this.rows,function(i,editor) { - // Hide the move down button for the last row - if(editor.movedown_button) { - if(i === self.rows.length - 1) { - editor.movedown_button.style.display = 'none'; - } - else { - editor.movedown_button.style.display = ''; - } - } - - // Hide the delete button if we have minItems items - if(editor.delete_button) { - if(minItems) { - editor.delete_button.style.display = 'none'; - } - else { - editor.delete_button.style.display = ''; - } - } - - // Get the value for this editor - self.value[i] = editor.getValue(); - }); - - var controls_needed = false; - - if(!this.value.length) { - this.delete_last_row_button.style.display = 'none'; - this.remove_all_rows_button.style.display = 'none'; - } - else if(this.value.length === 1) { - this.remove_all_rows_button.style.display = 'none'; - - // If there are minItems items in the array, or configured to hide the delete_last_row button, hide the delete button beneath the rows - if(minItems || this.hide_delete_last_row_buttons) { - this.delete_last_row_button.style.display = 'none'; - } - else { - this.delete_last_row_button.style.display = ''; - controls_needed = true; - } - } - else { - if(minItems || this.hide_delete_last_row_buttons) { - this.delete_last_row_button.style.display = 'none'; - } - else { - this.delete_last_row_button.style.display = ''; - controls_needed = true; - } - - if(minItems || this.hide_delete_all_rows_buttons) { - this.remove_all_rows_button.style.display = 'none'; - } - else { - this.remove_all_rows_button.style.display = ''; - controls_needed = true; - } - } - - // If there are maxItems in the array, hide the add button beneath the rows - if((this.getMax() && this.getMax() <= this.rows.length) || this.hide_add_button){ - this.add_row_button.style.display = 'none'; - } - else { - this.add_row_button.style.display = ''; - controls_needed = true; - } - - if(!this.collapsed && controls_needed) { - this.controls.style.display = 'inline-block'; - } - else { - this.controls.style.display = 'none'; - } - } - }, - addRow: function(value, initial) { - var self = this; - var i = this.rows.length; - - self.rows[i] = this.getElementEditor(i); - self.row_cache[i] = self.rows[i]; - - if(self.tabs_holder) { - self.rows[i].tab_text = document.createElement('span'); - self.rows[i].tab_text.textContent = self.rows[i].getHeaderText(); - if(self.schema.format === 'tabs-top'){ - self.rows[i].tab = self.theme.getTopTab(self.rows[i].tab_text,self.rows[i].path); - self.theme.addTopTab(self.tabs_holder, self.rows[i].tab); - } - else { - self.rows[i].tab = self.theme.getTab(self.rows[i].tab_text,self.rows[i].path); - self.theme.addTab(self.tabs_holder, self.rows[i].tab); - } - self.rows[i].tab.addEventListener('click', function(e) { - self.active_tab = self.rows[i].tab; - self.refreshTabs(); - e.preventDefault(); - e.stopPropagation(); - }); - - } - - var controls_holder = self.rows[i].title_controls || self.rows[i].array_controls; - - // 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',this.translate('button_delete_row_title',[self.getItemTitle()])); - self.rows[i].delete_button.className += ' delete'; - self.rows[i].delete_button.setAttribute('data-i',i); - self.rows[i].delete_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - if (self.jsoneditor.options.prompt_before_delete === true) { - if (confirm("Confirm to remove.") === false) { - return false; - } - } - - var i = this.getAttribute('data-i')*1; - - var value = self.getValue(); - - var newval = []; - var new_active_tab = null; - $each(value,function(j,row) { - if(j===i) { - // If the one we're deleting is the active tab - if(self.rows[j].tab === self.active_tab) { - // Make the next tab active if there is one - // Note: the next tab is going to be the current tab after deletion - if(self.rows[j+1]) new_active_tab = self.rows[j].tab; - // Otherwise, make the previous tab active if there is one - else if(j) new_active_tab = self.rows[j-1].tab; - } - - return; // If this is the one we're deleting - } - newval.push(row); - }); - self.setValue(newval); - if(new_active_tab) { - self.active_tab = new_active_tab; - self.refreshTabs(); - } - - self.onChange(true); - }); - - if(controls_holder) { - controls_holder.appendChild(self.rows[i].delete_button); - } - } - - //Button to copy an array element and add it as last element - if(self.show_copy_button){ - self.rows[i].copy_button = this.getButton(self.getItemTitle(),'copy','Copy '+self.getItemTitle()); - self.rows[i].copy_button.className += ' copy'; - self.rows[i].copy_button.setAttribute('data-i',i); - self.rows[i].copy_button.addEventListener('click',function(e) { - var value = self.getValue(); - e.preventDefault(); - e.stopPropagation(); - var i = this.getAttribute('data-i')*1; - - $each(value,function(j,row) { - if(j===i) { - value.push(row); - return; - } - }); - - self.setValue(value); - self.refreshValue(true); - self.onChange(true); - - }); - - controls_holder.appendChild(self.rows[i].copy_button); - } - - - if(i && !self.hide_move_buttons) { - self.rows[i].moveup_button = this.getButton('','moveup',this.translate('button_move_up_title')); - self.rows[i].moveup_button.className += ' moveup'; - self.rows[i].moveup_button.setAttribute('data-i',i); - self.rows[i].moveup_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - var i = this.getAttribute('data-i')*1; - - if(i<=0) return; - var rows = self.getValue(); - var tmp = rows[i-1]; - rows[i-1] = rows[i]; - rows[i] = tmp; - - self.setValue(rows); - self.active_tab = self.rows[i-1].tab; - self.refreshTabs(); - - self.onChange(true); - }); - - if(controls_holder) { - controls_holder.appendChild(self.rows[i].moveup_button); - } - } - - if(!self.hide_move_buttons) { - self.rows[i].movedown_button = this.getButton('','movedown',this.translate('button_move_down_title')); - self.rows[i].movedown_button.className += ' movedown'; - self.rows[i].movedown_button.setAttribute('data-i',i); - self.rows[i].movedown_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - var i = this.getAttribute('data-i')*1; - - var rows = self.getValue(); - if(i>=rows.length-1) return; - var tmp = rows[i+1]; - rows[i+1] = rows[i]; - rows[i] = tmp; - - self.setValue(rows); - self.active_tab = self.rows[i+1].tab; - self.refreshTabs(); - self.onChange(true); - }); - - if(controls_holder) { - controls_holder.appendChild(self.rows[i].movedown_button); - } - } - - if(value) self.rows[i].setValue(value, initial); - self.refreshTabs(); - }, - addControls: function() { - var self = this; - - this.collapsed = false; - this.toggle_button = this.getButton('','collapse',this.translate('button_collapse')); - this.title_controls.appendChild(this.toggle_button); - var row_holder_display = self.row_holder.style.display; - var controls_display = self.controls.style.display; - this.toggle_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - if(self.collapsed) { - self.collapsed = false; - if(self.panel) self.panel.style.display = ''; - self.row_holder.style.display = row_holder_display; - if(self.tabs_holder) self.tabs_holder.style.display = ''; - self.controls.style.display = controls_display; - self.setButtonText(this,'','collapse',self.translate('button_collapse')); - } - else { - self.collapsed = true; - self.row_holder.style.display = 'none'; - if(self.tabs_holder) self.tabs_holder.style.display = 'none'; - self.controls.style.display = 'none'; - if(self.panel) self.panel.style.display = 'none'; - self.setButtonText(this,'','expand',self.translate('button_expand')); - } - }); - - // If it should start collapsed - if(this.options.collapsed) { - $trigger(this.toggle_button,'click'); - } - - // Collapse button disabled - if(this.schema.options && typeof this.schema.options.disable_collapse !== "undefined") { - if(this.schema.options.disable_collapse) this.toggle_button.style.display = 'none'; - } - else if(this.jsoneditor.options.disable_collapse) { - this.toggle_button.style.display = 'none'; - } - - // Add "new row" and "delete last" buttons below editor - this.add_row_button = this.getButton(this.getItemTitle(),'add',this.translate('button_add_row_title',[this.getItemTitle()])); - - this.add_row_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - var i = self.rows.length; - if(self.row_cache[i]) { - self.rows[i] = self.row_cache[i]; - self.rows[i].setValue(self.rows[i].getDefault(), true); - self.rows[i].container.style.display = ''; - if(self.rows[i].tab) self.rows[i].tab.style.display = ''; - self.rows[i].register(); - } - else { - self.addRow(); - } - self.active_tab = self.rows[i].tab; - self.refreshTabs(); - self.refreshValue(); - self.onChange(true); - }); - self.controls.appendChild(this.add_row_button); - - this.delete_last_row_button = this.getButton(this.translate('button_delete_last',[this.getItemTitle()]),'delete',this.translate('button_delete_last_title',[this.getItemTitle()])); - this.delete_last_row_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - if (self.jsoneditor.options.prompt_before_delete === true) { - if (confirm("Confirm to remove.") === false) { - return false; - } - } - - var rows = self.getValue(); - - 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; - - rows.pop(); - self.setValue(rows); - if(new_active_tab) { - self.active_tab = new_active_tab; - self.refreshTabs(); - } - self.onChange(true); - }); - self.controls.appendChild(this.delete_last_row_button); - - this.remove_all_rows_button = this.getButton(this.translate('button_delete_all'),'delete',this.translate('button_delete_all_title')); - this.remove_all_rows_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - if (self.jsoneditor.options.prompt_before_delete === true) { - if (confirm("Confirm to remove.") === false) { - return false; - } - } - - self.setValue([]); - self.onChange(true); - }); - self.controls.appendChild(this.remove_all_rows_button); - - if(self.tabs) { - this.add_row_button.style.width = '100%'; - this.add_row_button.style.textAlign = 'left'; - this.add_row_button.style.marginBottom = '3px'; - - this.delete_last_row_button.style.width = '100%'; - this.delete_last_row_button.style.textAlign = 'left'; - this.delete_last_row_button.style.marginBottom = '3px'; - - this.remove_all_rows_button.style.width = '100%'; - this.remove_all_rows_button.style.textAlign = 'left'; - this.remove_all_rows_button.style.marginBottom = '3px'; - } - }, - showValidationErrors: function(errors) { - var self = this; - - // Get all the errors that pertain to this editor - var my_errors = []; - var other_errors = []; - $each(errors, function(i,error) { - if(error.path === self.path) { - my_errors.push(error); - } - else { - other_errors.push(error); - } - }); - - // Show errors for this editor - if(this.error_holder) { - if(my_errors.length) { - var message = []; - this.error_holder.innerHTML = ''; - this.error_holder.style.display = ''; - $each(my_errors, function(i,error) { - self.error_holder.appendChild(self.theme.getErrorMessage(error.message)); - }); - } - // Hide error area - else { - this.error_holder.style.display = 'none'; - } - } - - // Show errors for child editors - $each(this.rows, function(i,row) { - row.showValidationErrors(other_errors); - }); - } -}); - -JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({ - register: function() { - this._super(); - if(this.rows) { - for(var i=0; i this.schema.maxItems) { - value = value.slice(0,this.schema.maxItems); - } - - var serialized = JSON.stringify(value); - if(serialized === this.serialized) return; - - var numrows_changed = false; - - var self = this; - $each(value,function(i,val) { - if(self.rows[i]) { - // TODO: don't set the row's value if it hasn't changed - self.rows[i].setValue(val); - } - else { - self.addRow(val); - numrows_changed = true; - } - }); - - for(var j=value.length; j= this.rows.length; - - var need_row_buttons = false; - $each(this.rows,function(i,editor) { - // Hide the move down button for the last row - if(editor.movedown_button) { - if(i === self.rows.length - 1) { - editor.movedown_button.style.display = 'none'; - } - else { - need_row_buttons = true; - editor.movedown_button.style.display = ''; - } - } - - // Hide the delete button if we have minItems items - if(editor.delete_button) { - if(minItems) { - editor.delete_button.style.display = 'none'; - } - else { - need_row_buttons = true; - editor.delete_button.style.display = ''; - } - } - - if(editor.moveup_button) { - need_row_buttons = true; - } - }); - - // Show/hide controls column in table - $each(this.rows,function(i,editor) { - if(need_row_buttons) { - editor.controls_cell.style.display = ''; - } - else { - editor.controls_cell.style.display = 'none'; - } - }); - if(need_row_buttons) { - this.controls_header_cell.style.display = ''; - } - else { - this.controls_header_cell.style.display = 'none'; - } - - var controls_needed = false; - - if(!this.value.length) { - this.delete_last_row_button.style.display = 'none'; - this.remove_all_rows_button.style.display = 'none'; - this.table.style.display = 'none'; - } - else if(this.value.length === 1) { - this.table.style.display = ''; - this.remove_all_rows_button.style.display = 'none'; - - // If there are minItems items in the array, or configured to hide the delete_last_row button, hide the delete button beneath the rows - if(minItems || this.hide_delete_last_row_buttons) { - this.delete_last_row_button.style.display = 'none'; - } - else { - this.delete_last_row_button.style.display = ''; - controls_needed = true; - } - } - else { - this.table.style.display = ''; - - if(minItems || this.hide_delete_last_row_buttons) { - this.delete_last_row_button.style.display = 'none'; - } - else { - this.delete_last_row_button.style.display = ''; - controls_needed = true; - } - - if(minItems || this.hide_delete_all_rows_buttons) { - this.remove_all_rows_button.style.display = 'none'; - } - else { - this.remove_all_rows_button.style.display = ''; - controls_needed = true; - } - } - - // If there are maxItems in the array, hide the add button beneath the rows - if((this.schema.maxItems && this.schema.maxItems <= this.rows.length) || this.hide_add_button) { - this.add_row_button.style.display = 'none'; - } - else { - this.add_row_button.style.display = ''; - controls_needed = true; - } - - if(!controls_needed) { - this.controls.style.display = 'none'; - } - else { - this.controls.style.display = ''; - } - }, - refreshValue: function() { - var self = this; - this.value = []; - - $each(this.rows,function(i,editor) { - // Get the value for this editor - self.value[i] = editor.getValue(); - }); - this.serialized = JSON.stringify(this.value); - }, - addRow: function(value) { - var self = this; - var i = this.rows.length; - - self.rows[i] = this.getElementEditor(i); - - var controls_holder = self.rows[i].table_controls; - - // Buttons to delete row, move row up, and move row down - if(!this.hide_delete_buttons) { - self.rows[i].delete_button = this.getButton('','delete',this.translate('button_delete_row_title_short')); - self.rows[i].delete_button.className += ' delete'; - self.rows[i].delete_button.setAttribute('data-i',i); - self.rows[i].delete_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - var i = this.getAttribute('data-i')*1; - - var value = self.getValue(); - - var newval = []; - $each(value,function(j,row) { - if(j===i) return; // If this is the one we're deleting - newval.push(row); - }); - self.setValue(newval); - self.onChange(true); - }); - controls_holder.appendChild(self.rows[i].delete_button); - } - - - if(i && !this.hide_move_buttons) { - self.rows[i].moveup_button = this.getButton('','moveup',this.translate('button_move_up_title')); - self.rows[i].moveup_button.className += ' moveup'; - self.rows[i].moveup_button.setAttribute('data-i',i); - self.rows[i].moveup_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - var i = this.getAttribute('data-i')*1; - - if(i<=0) return; - var rows = self.getValue(); - var tmp = rows[i-1]; - rows[i-1] = rows[i]; - rows[i] = tmp; - - self.setValue(rows); - self.onChange(true); - }); - controls_holder.appendChild(self.rows[i].moveup_button); - } - - if(!this.hide_move_buttons) { - self.rows[i].movedown_button = this.getButton('','movedown',this.translate('button_move_down_title')); - self.rows[i].movedown_button.className += ' movedown'; - self.rows[i].movedown_button.setAttribute('data-i',i); - self.rows[i].movedown_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - var i = this.getAttribute('data-i')*1; - var rows = self.getValue(); - if(i>=rows.length-1) return; - var tmp = rows[i+1]; - rows[i+1] = rows[i]; - rows[i] = tmp; - - self.setValue(rows); - self.onChange(true); - }); - controls_holder.appendChild(self.rows[i].movedown_button); - } - - if(value) self.rows[i].setValue(value); - }, - addControls: function() { - var self = this; - - this.collapsed = false; - this.toggle_button = this.getButton('','collapse',this.translate('button_collapse')); - if(this.title_controls) { - this.title_controls.appendChild(this.toggle_button); - this.toggle_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - if(self.collapsed) { - self.collapsed = false; - self.panel.style.display = ''; - self.setButtonText(this,'','collapse',self.translate('button_collapse')); - } - else { - self.collapsed = true; - self.panel.style.display = 'none'; - self.setButtonText(this,'','expand',self.translate('button_expand')); - } - }); - - // If it should start collapsed - if(this.options.collapsed) { - $trigger(this.toggle_button,'click'); - } - - // Collapse button disabled - if(this.schema.options && typeof this.schema.options.disable_collapse !== "undefined") { - if(this.schema.options.disable_collapse) this.toggle_button.style.display = 'none'; - } - else if(this.jsoneditor.options.disable_collapse) { - this.toggle_button.style.display = 'none'; - } - } - - // Add "new row" and "delete last" buttons below editor - this.add_row_button = this.getButton(this.getItemTitle(),'add',this.translate('button_add_row_title',[this.getItemTitle()])); - this.add_row_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - self.addRow(); - self.refreshValue(); - self.refreshRowButtons(); - self.onChange(true); - }); - self.controls.appendChild(this.add_row_button); - - this.delete_last_row_button = this.getButton(this.translate('button_delete_last',[this.getItemTitle()]),'delete',this.translate('button_delete_last_title',[this.getItemTitle()])); - this.delete_last_row_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - var rows = self.getValue(); - rows.pop(); - self.setValue(rows); - self.onChange(true); - }); - self.controls.appendChild(this.delete_last_row_button); - - this.remove_all_rows_button = this.getButton(this.translate('button_delete_all'),'delete',this.translate('button_delete_all_title')); - this.remove_all_rows_button.addEventListener('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - - self.setValue([]); - self.onChange(true); - }); - self.controls.appendChild(this.remove_all_rows_button); - } -}); - -// Multiple Editor (for when `type` is an array, also when `oneOf` is present) -JSONEditor.defaults.editors.multiple = JSONEditor.AbstractEditor.extend({ - register: function() { - if(this.editors) { - for(var i=0; inull'; - } - // Array or Object - else if(typeof el === "object") { - // TODO: use theme - var ret = ''; - - $each(el,function(i,child) { - var html = self.getHTML(child); - - // Add the keys to object children - if(!(Array.isArray(el))) { - // TODO: use theme - html = '
'+i+': '+html+'
'; - } - - // TODO: use theme - ret += '
  • '+html+'
  • '; - }); - - if(Array.isArray(el)) ret = '
      '+ret+'
    '; - else ret = "
      "+ret+'
    '; - - return ret; - } - // Boolean - else if(typeof el === "boolean") { - return el? 'true' : 'false'; - } - // String - else if(typeof el === "string") { - return el.replace(/&/g,'&').replace(//g,'>'); - } - // Number - else { - return el; - } - }, - setValue: function(val) { - if(this.value !== val) { - this.value = val; - this.refreshValue(); - this.onChange(); - } - }, - destroy: function() { - if(this.display_area && this.display_area.parentNode) this.display_area.parentNode.removeChild(this.display_area); - if(this.title && this.title.parentNode) this.title.parentNode.removeChild(this.title); - if(this.switcher && this.switcher.parentNode) this.switcher.parentNode.removeChild(this.switcher); - - this._super(); - } -}); - -JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({ - setValue: function(value,initial) { - value = this.typecast(value||''); - - // Sanitize value before setting it - var sanitized = value; - if(this.enum_values.indexOf(sanitized) < 0) { - sanitized = this.enum_values[0]; - } - - if(this.value === sanitized) { - return; - } - - this.input.value = this.enum_options[this.enum_values.indexOf(sanitized)]; - if(this.select2) { - if(this.select2v4) - this.select2.val(this.input.value).trigger("change"); - else - this.select2.select2('val',this.input.value); - } - this.value = sanitized; - this.onChange(); - this.change(); - }, - register: function() { - this._super(); - if(!this.input) return; - this.input.setAttribute('name',this.formname); - }, - unregister: function() { - this._super(); - if(!this.input) return; - this.input.removeAttribute('name'); - }, - getNumColumns: function() { - if(!this.enum_options) return 3; - var longest_text = this.getTitle().length; - for(var i=0; i 2 || (this.enum_options.length && this.enumSource))) { - var options = $extend({},JSONEditor.plugins.select2); - if(this.schema.options && this.schema.options.select2_options) options = $extend(options,this.schema.options.select2_options); - this.select2 = window.jQuery(this.input).select2(options); - this.select2v4 = this.select2.select2.hasOwnProperty("amd"); - - var self = this; - this.select2.on('select2-blur',function() { - if(self.select2v4) - self.input.value = self.select2.val(); - else - self.input.value = self.select2.select2('val'); - - self.onInputChange(); - }); - - this.select2.on('change',function() { - if(self.select2v4) - self.input.value = self.select2.val(); - else - self.input.value = self.select2.select2('val'); - - self.onInputChange(); - }); - } - else { - this.select2 = null; - } - }, - postBuild: function() { - this._super(); - this.theme.afterInputReady(this.input); - this.setupSelect2(); - }, - onWatchedFieldChange: function() { - var self = this, vars, j; - - // If this editor uses a dynamic select box - if(this.enumSource) { - vars = this.getWatchedFieldValues(); - var select_options = []; - var select_titles = []; - - for(var i=0; i= 2 || (this.enum_options.length && this.enumSource))) { - var options = $extend({},JSONEditor.plugins.selectize); - if(this.schema.options && this.schema.options.selectize_options) options = $extend(options,this.schema.options.selectize_options); - this.selectize = window.jQuery(this.input).selectize($extend(options, - { - // set the create option to true by default, or to the user specified value if defined - create: ( options.create === undefined ? true : options.create), - onChange : function() { - self.onInputChange(); - } - })); - } - else { - this.selectize = null; - } - }, - postBuild: function() { - this._super(); - this.theme.afterInputReady(this.input); - this.setupSelectize(); - }, - onWatchedFieldChange: function() { - var self = this, vars, j; - - // If this editor uses a dynamic select box - if(this.enumSource) { - vars = this.getWatchedFieldValues(); - var select_options = []; - var select_titles = []; - - for(var i=0; iSize: '+Math.floor((this.value.length-this.value.split(',')[0].length-1)/1.33333)+' bytes'; - if(mime.substr(0,5)==="image") { - this.preview.innerHTML += '
    '; - var img = document.createElement('img'); - img.style.maxWidth = '100%'; - img.style.maxHeight = '100px'; - img.src = this.value; - this.preview.appendChild(img); - } - } - }, - enable: function() { - if(!this.always_disabled) { - if(this.uploader) this.uploader.disabled = false; - this._super(); - } - }, - disable: function(always_disabled) { - if(always_disabled) this.always_disabled = true; - if(this.uploader) this.uploader.disabled = true; - this._super(); - }, - setValue: function(val) { - if(this.value !== val) { - this.value = val; - this.input.value = this.value; - this.refreshPreview(); - this.onChange(); - } - }, - destroy: function() { - if(this.preview && this.preview.parentNode) this.preview.parentNode.removeChild(this.preview); - if(this.title && this.title.parentNode) this.title.parentNode.removeChild(this.title); - if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); - if(this.uploader && this.uploader.parentNode) this.uploader.parentNode.removeChild(this.uploader); - - this._super(); - } -}); - -JSONEditor.defaults.editors.upload = JSONEditor.AbstractEditor.extend({ - getNumColumns: function() { - return 4; - }, - build: function() { - var self = this; - this.title = this.header = this.label = this.theme.getFormInputLabel(this.getTitle()); - - // Input that holds the base64 string - this.input = this.theme.getFormInputField('hidden'); - this.container.appendChild(this.input); - - // Don't show uploader if this is readonly - if(!this.schema.readOnly && !this.schema.readonly) { - - if(!this.jsoneditor.options.upload) throw "Upload handler required for upload editor"; - - // File uploader - this.uploader = this.theme.getFormInputField('file'); - - this.uploader.addEventListener('change',function(e) { - e.preventDefault(); - e.stopPropagation(); - - if(this.files && this.files.length) { - var fr = new FileReader(); - fr.onload = function(evt) { - self.preview_value = evt.target.result; - self.refreshPreview(); - self.onChange(true); - fr = null; - }; - fr.readAsDataURL(this.files[0]); - } - }); - } - - var description = this.schema.description; - if (!description) description = ''; - - this.preview = this.theme.getFormInputDescription(description); - this.container.appendChild(this.preview); - - this.control = this.theme.getFormControl(this.label, this.uploader||this.input, this.preview); - this.container.appendChild(this.control); - }, - refreshPreview: function() { - if(this.last_preview === this.preview_value) return; - this.last_preview = this.preview_value; - - this.preview.innerHTML = ''; - - if(!this.preview_value) return; - - var self = this; - - var mime = this.preview_value.match(/^data:([^;,]+)[;,]/); - if(mime) mime = mime[1]; - if(!mime) mime = 'unknown'; - - var file = this.uploader.files[0]; - - this.preview.innerHTML = 'Type: '+mime+', Size: '+file.size+' bytes'; - if(mime.substr(0,5)==="image") { - this.preview.innerHTML += '
    '; - var img = document.createElement('img'); - img.style.maxWidth = '100%'; - img.style.maxHeight = '100px'; - img.src = this.preview_value; - this.preview.appendChild(img); - } - - this.preview.innerHTML += '
    '; - var uploadButton = this.getButton('Upload', 'upload', 'Upload'); - this.preview.appendChild(uploadButton); - uploadButton.addEventListener('click',function(event) { - event.preventDefault(); - - uploadButton.setAttribute("disabled", "disabled"); - self.theme.removeInputError(self.uploader); - - if (self.theme.getProgressBar) { - self.progressBar = self.theme.getProgressBar(); - self.preview.appendChild(self.progressBar); - } - - self.jsoneditor.options.upload(self.path, file, { - success: function(url) { - self.setValue(url); - - if(self.parent) self.parent.onChildEditorChange(self); - else self.jsoneditor.onChange(); - - if (self.progressBar) self.preview.removeChild(self.progressBar); - uploadButton.removeAttribute("disabled"); - }, - failure: function(error) { - self.theme.addInputError(self.uploader, error); - if (self.progressBar) self.preview.removeChild(self.progressBar); - uploadButton.removeAttribute("disabled"); - }, - updateProgress: function(progress) { - if (self.progressBar) { - if (progress) self.theme.updateProgressBar(self.progressBar, progress); - else self.theme.updateProgressBarUnknown(self.progressBar); - } - } - }); - }); - - if(this.jsoneditor.options.auto_upload || this.schema.options.auto_upload) { - uploadButton.dispatchEvent(new MouseEvent('click')); - this.preview.removeChild(uploadButton); - } - }, - enable: function() { - if(!this.always_disabled) { - if(this.uploader) this.uploader.disabled = false; - this._super(); - } - }, - disable: function(always_disabled) { - if(always_disabled) this.always_disabled = true; - if(this.uploader) this.uploader.disabled = true; - this._super(); - }, - setValue: function(val) { - if(this.value !== val) { - this.value = val; - this.input.value = this.value; - this.onChange(); - } - }, - destroy: function() { - if(this.preview && this.preview.parentNode) this.preview.parentNode.removeChild(this.preview); - if(this.title && this.title.parentNode) this.title.parentNode.removeChild(this.title); - if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); - if(this.uploader && this.uploader.parentNode) this.uploader.parentNode.removeChild(this.uploader); - - this._super(); - } -}); - -JSONEditor.defaults.editors.checkbox = JSONEditor.AbstractEditor.extend({ - setValue: function(value,initial) { - this.value = !!value; - this.input.checked = this.value; - this.onChange(); - }, - register: function() { - this._super(); - if(!this.input) return; - this.input.setAttribute('name',this.formname); - }, - unregister: function() { - this._super(); - if(!this.input) return; - this.input.removeAttribute('name'); - }, - getNumColumns: function() { - return Math.min(12,Math.max(this.getTitle().length/7,2)); - }, - build: function() { - var self = this; - if(!this.options.compact) { - this.label = this.header = this.theme.getCheckboxLabel(this.getTitle()); - } - if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description); - if(this.options.infoText) this.infoButton = this.theme.getInfoButton(this.options.infoText); - if(this.options.compact) this.container.className += ' compact'; - - this.input = this.theme.getCheckbox(); - this.control = this.theme.getFormControl(this.label, this.input, this.description, this.infoButton); - - if(this.schema.readOnly || this.schema.readonly) { - this.always_disabled = true; - this.input.disabled = true; - } - - this.input.addEventListener('change',function(e) { - e.preventDefault(); - e.stopPropagation(); - self.value = this.checked; - self.onChange(true); - }); - - this.container.appendChild(this.control); - }, - enable: function() { - if(!this.always_disabled) { - this.input.disabled = false; - this._super(); - } - }, - disable: function(always_disabled) { - if(always_disabled) this.always_disabled = true; - this.input.disabled = true; - this._super(); - }, - destroy: function() { - if(this.label && this.label.parentNode) this.label.parentNode.removeChild(this.label); - if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description); - if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); - this._super(); - }, - showValidationErrors: function (errors) { - var self = this; - - if (this.jsoneditor.options.show_errors === "always") {} - - else if (!this.is_dirty && this.previous_error_setting === this.jsoneditor.options.show_errors) { - return; - } - - this.previous_error_setting = this.jsoneditor.options.show_errors; - - var messages = []; - $each(errors, function (i, error) { - if (error.path === self.path) { - messages.push(error.message); - } - }); - - this.input.controlgroup = this.control; - - if (messages.length) { - this.theme.addInputError(this.input, messages.join('. ') + '.'); - } - else { - this.theme.removeInputError(this.input); - } - } -}); - -JSONEditor.defaults.editors.arraySelectize = JSONEditor.AbstractEditor.extend({ - build: function() { - this.title = this.theme.getFormInputLabel(this.getTitle()); - - this.title_controls = this.theme.getHeaderButtonHolder(); - this.title.appendChild(this.title_controls); - this.error_holder = document.createElement('div'); - - if(this.schema.description) { - this.description = this.theme.getDescription(this.schema.description); - } - - this.input = document.createElement('select'); - this.input.setAttribute('multiple', 'multiple'); - - var group = this.theme.getFormControl(this.title, this.input, this.description); - - this.container.appendChild(group); - this.container.appendChild(this.error_holder); - - window.jQuery(this.input).selectize({ - delimiter: false, - createOnBlur: true, - create: true - }); - }, - postBuild: function() { - var self = this; - this.input.selectize.on('change', function(event) { - self.refreshValue(); - self.onChange(true); - }); - }, - destroy: function() { - this.empty(true); - if(this.title && this.title.parentNode) this.title.parentNode.removeChild(this.title); - if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description); - if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); - - this._super(); - }, - empty: function(hard) {}, - setValue: function(value, initial) { - var self = this; - // Update the array's value, adding/removing rows when necessary - value = value || []; - if(!(Array.isArray(value))) value = [value]; - - this.input.selectize.clearOptions(); - this.input.selectize.clear(true); - - value.forEach(function(item) { - self.input.selectize.addOption({text: item, value: item}); - }); - this.input.selectize.setValue(value); - - this.refreshValue(initial); - }, - refreshValue: function(force) { - this.value = this.input.selectize.getValue(); - }, - showValidationErrors: function(errors) { - var self = this; - - // Get all the errors that pertain to this editor - var my_errors = []; - var other_errors = []; - $each(errors, function(i,error) { - if(error.path === self.path) { - my_errors.push(error); - } - else { - other_errors.push(error); - } - }); - - // Show errors for this editor - if(this.error_holder) { - - if(my_errors.length) { - var message = []; - this.error_holder.innerHTML = ''; - this.error_holder.style.display = ''; - $each(my_errors, function(i,error) { - self.error_holder.appendChild(self.theme.getErrorMessage(error.message)); - }); - } - // Hide error area - else { - this.error_holder.style.display = 'none'; - } - } - } -}); - -var matchKey = (function () { - var elem = document.documentElement; - - if (elem.matches) return 'matches'; - else if (elem.webkitMatchesSelector) return 'webkitMatchesSelector'; - else if (elem.mozMatchesSelector) return 'mozMatchesSelector'; - else if (elem.msMatchesSelector) return 'msMatchesSelector'; - else if (elem.oMatchesSelector) return 'oMatchesSelector'; -})(); - -JSONEditor.AbstractTheme = Class.extend({ - getContainer: function() { - return document.createElement('div'); - }, - getFloatRightLinkHolder: function() { - var el = document.createElement('div'); - el.style = el.style || {}; - el.style.cssFloat = 'right'; - el.style.marginLeft = '10px'; - return el; - }, - getModal: function() { - var el = document.createElement('div'); - el.style.backgroundColor = 'white'; - el.style.border = '1px solid black'; - el.style.boxShadow = '3px 3px black'; - el.style.position = 'absolute'; - el.style.zIndex = '10'; - el.style.display = 'none'; - return el; - }, - getGridContainer: function() { - var el = document.createElement('div'); - return el; - }, - getGridRow: function() { - var el = document.createElement('div'); - el.className = 'row'; - return el; - }, - getGridColumn: function() { - var el = document.createElement('div'); - return el; - }, - setGridColumnSize: function(el,size) { - - }, - getLink: function(text) { - var el = document.createElement('a'); - el.setAttribute('href','#'); - el.appendChild(document.createTextNode(text)); - return el; - }, - disableHeader: function(header) { - header.style.color = '#ccc'; - }, - disableLabel: function(label) { - label.style.color = '#ccc'; - }, - enableHeader: function(header) { - header.style.color = ''; - }, - enableLabel: function(label) { - label.style.color = ''; - }, - getInfoButton: function(text) { - var icon = document.createElement('span'); - icon.innerText = "ⓘ"; - icon.style.fontSize = "16px"; - icon.style.fontWeight = "bold"; - icon.style.padding = ".25rem"; - icon.style.position = "relative"; - icon.style.display = "inline-block"; - - var tooltip = document.createElement('span'); - tooltip.style.fontSize = "12px"; - icon.style.fontWeight = "normal"; - tooltip.style["font-family"] = "sans-serif"; - tooltip.style.visibility = "hidden"; - tooltip.style["background-color"] = "rgba(50, 50, 50, .75)"; - tooltip.style.margin = "0 .25rem"; - tooltip.style.color = "#FAFAFA"; - tooltip.style.padding = ".5rem 1rem"; - tooltip.style["border-radius"] = ".25rem"; - tooltip.style.width = "20rem"; - tooltip.style.position = "absolute"; - tooltip.innerText = text; - icon.onmouseover = function() { - tooltip.style.visibility = "visible"; - }; - icon.onmouseleave = function() { - tooltip.style.visibility = "hidden"; - }; - - icon.appendChild(tooltip); - - return icon; - }, - getFormInputLabel: function(text) { - var el = document.createElement('label'); - el.appendChild(document.createTextNode(text)); - return el; - }, - getCheckboxLabel: function(text) { - var el = this.getFormInputLabel(text); - el.style.fontWeight = 'normal'; - return el; - }, - getHeader: function(text) { - var el = document.createElement('h3'); - if(typeof text === "string") { - el.textContent = text; - el.style.fontWeight = 'bold'; - el.style.fontSize = '12px'; - el.style.padding = '4px'; - } - else { - el.appendChild(text); - } - - return el; - }, - getCheckbox: function() { - var el = this.getFormInputField('checkbox'); - el.style.display = 'inline-block'; - el.style.width = 'auto'; - return el; - }, - getMultiCheckboxHolder: function(controls,label,description) { - var el = document.createElement('div'); - - if(label) { - label.style.display = 'block'; - el.appendChild(label); - } - - for(var i in controls) { - if(!controls.hasOwnProperty(i)) continue; - controls[i].style.display = 'inline-block'; - controls[i].style.marginRight = '20px'; - el.appendChild(controls[i]); - } - - if(description) el.appendChild(description); - - return el; - }, - getSelectInput: function(options) { - var select = document.createElement('select'); - if(options) this.setSelectOptions(select, options); - return select; - }, - getSwitcher: function(options) { - var switcher = this.getSelectInput(options); - switcher.style.backgroundColor = 'transparent'; - switcher.style.display = 'inline-block'; - switcher.style.fontStyle = 'italic'; - switcher.style.fontWeight = 'normal'; - switcher.style.height = 'auto'; - switcher.style.marginBottom = 0; - switcher.style.marginLeft = '5px'; - switcher.style.padding = '0 0 0 3px'; - switcher.style.width = 'auto'; - return switcher; - }, - getSwitcherOptions: function(switcher) { - return switcher.getElementsByTagName('option'); - }, - setSwitcherOptions: function(switcher, options, titles) { - this.setSelectOptions(switcher, options, titles); - }, - setSelectOptions: function(select, options, titles) { - titles = titles || []; - select.innerHTML = ''; - for(var i=0; i
    "; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.innerHTML = "
    "; - return el; - }, - applyStyles: function(el,styles) { - for(var i in styles) { - if(!styles.hasOwnProperty(i)) continue; - el.style[i] = styles[i]; - } - }, - closest: function(elem, selector) { - while (elem && elem !== document) { - if (elem[matchKey]) { - if (elem[matchKey](selector)) { - return elem; - } else { - elem = elem.parentNode; - } - } - else { - return false; - } - } - return false; - }, - insertBasicTopTab: function(tab, newTabs_holder ) { - newTabs_holder.firstChild.insertBefore(tab,newTabs_holder.firstChild.firstChild); - }, - getTab: function(span, tabId) { - var el = document.createElement('div'); - el.appendChild(span); - el.id = tabId; - el.style = el.style || {}; - this.applyStyles(el,{ - border: '1px solid #ccc', - borderWidth: '1px 0 1px 1px', - textAlign: 'center', - lineHeight: '30px', - borderRadius: '5px', - borderBottomRightRadius: 0, - borderTopRightRadius: 0, - fontWeight: 'bold', - cursor: 'pointer' - }); - return el; - }, - getTopTab: function(span, tabId) { - var el = document.createElement('div'); - el.id = tabId; - el.appendChild(span); - el.style = el.style || {}; - this.applyStyles(el,{ - float: 'left', - border: '1px solid #ccc', - borderWidth: '1px 1px 0px 1px', - textAlign: 'center', - lineHeight: '30px', - borderRadius: '5px', - paddingLeft:'5px', - paddingRight:'5px', - borderBottomRightRadius: 0, - borderBottomLeftRadius: 0, - fontWeight: 'bold', - cursor: 'pointer' - }); - return el; - }, - getTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTopTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTabContent: function() { - return this.getIndentedPanel(); - }, - getTopTabContent: function() { - return this.getTopIndentedPanel(); - }, - markTabActive: function(row) { - this.applyStyles(row.tab,{ - opacity: 1, - background: 'white' - }); - row.container.style.display = ''; - }, - markTabInactive: function(row) { - this.applyStyles(row.tab,{ - opacity:0.5, - background: '' - }); - row.container.style.display = 'none'; - }, - addTab: function(holder, tab) { - holder.children[0].appendChild(tab); - }, - addTopTab: function(holder, tab) { - holder.children[0].appendChild(tab); - }, - getBlockLink: function() { - var link = document.createElement('a'); - link.style.display = 'block'; - return link; - }, - getBlockLinkHolder: function() { - var el = document.createElement('div'); - return el; - }, - getLinksHolder: function() { - var el = document.createElement('div'); - return el; - }, - createMediaLink: function(holder,link,media) { - holder.appendChild(link); - media.style.width='100%'; - holder.appendChild(media); - }, - createImageLink: function(holder,link,image) { - holder.appendChild(link); - link.appendChild(image); - }, - getFirstTab: function(holder){ - return holder.firstChild.firstChild; - } -}); - -JSONEditor.defaults.themes.bootstrap2 = JSONEditor.AbstractTheme.extend({ - getRangeInput: function(min, max, step) { - // TODO: use bootstrap slider - return this._super(min, max, step); - }, - getGridContainer: function() { - var el = document.createElement('div'); - el.className = 'container-fluid'; - el.style.padding = '4px'; - return el; - }, - getGridRow: function() { - var el = document.createElement('div'); - el.className = 'row-fluid'; - return el; - }, - getFormInputLabel: function(text) { - var el = this._super(text); - el.style.display = 'inline-block'; - el.style.fontWeight = 'bold'; - return el; - }, - setGridColumnSize: function(el,size) { - el.className = 'span'+size; - }, - getSelectInput: function(options) { - var input = this._super(options); - input.style.width = 'auto'; - input.style.maxWidth = '98%'; - return input; - }, - getFormInputField: function(type) { - var el = this._super(type); - el.style.width = '98%'; - return el; - }, - afterInputReady: function(input) { - if(input.controlgroup) return; - input.controlgroup = this.closest(input,'.control-group'); - input.controls = this.closest(input,'.controls'); - if(this.closest(input,'.compact')) { - 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,' '); - input.style.marginBottom = 0; - } - if (this.queuedInputErrorText) { - var text = this.queuedInputErrorText; - delete this.queuedInputErrorText; - this.addInputError(input,text); - } - - // TODO: use bootstrap slider - }, - getIndentedPanel: function() { - var el = document.createElement('div'); - el.className = 'well well-small'; - el.style.padding = '4px'; - return el; - }, - getInfoButton: function(text) { - var icon = document.createElement('span'); - icon.className = "icon-info-sign pull-right"; - icon.style.padding = ".25rem"; - icon.style.position = "relative"; - icon.style.display = "inline-block"; - - var tooltip = document.createElement('span'); - tooltip.style["font-family"] = "sans-serif"; - tooltip.style.visibility = "hidden"; - tooltip.style["background-color"] = "rgba(50, 50, 50, .75)"; - tooltip.style.margin = "0 .25rem"; - tooltip.style.color = "#FAFAFA"; - tooltip.style.padding = ".5rem 1rem"; - tooltip.style["border-radius"] = ".25rem"; - tooltip.style.width = "25rem"; - tooltip.style.transform = "translateX(-27rem) translateY(-.5rem)"; - tooltip.style.position = "absolute"; - tooltip.innerText = text; - icon.onmouseover = function() { - tooltip.style.visibility = "visible"; - }; - icon.onmouseleave = function() { - tooltip.style.visibility = "hidden"; - }; - - icon.appendChild(tooltip); - - return icon; - }, - getFormInputDescription: function(text) { - var el = document.createElement('p'); - el.className = 'help-inline'; - el.textContent = text; - return el; - }, - getFormControl: function(label, input, description, infoText) { - var ret = document.createElement('div'); - ret.className = 'control-group'; - - var controls = document.createElement('div'); - controls.className = 'controls'; - - if(label && input.getAttribute('type') === 'checkbox') { - ret.appendChild(controls); - label.className += ' checkbox'; - label.appendChild(input); - controls.appendChild(label); - if(infoText) controls.appendChild(infoText); - controls.style.height = '30px'; - } - else { - if(label) { - label.className += ' control-label'; - ret.appendChild(label); - } - if(infoText) controls.appendChild(infoText); - controls.appendChild(input); - ret.appendChild(controls); - } - - if(description) controls.appendChild(description); - - return ret; - }, - getHeaderButtonHolder: function() { - var el = this.getButtonHolder(); - el.style.marginLeft = '10px'; - return el; - }, - getButtonHolder: function() { - var el = document.createElement('div'); - el.className = 'btn-group'; - return el; - }, - getButton: function(text, icon, title) { - var el = this._super(text, icon, title); - el.className += ' btn btn-default'; - el.style.backgroundColor = '#f2bfab'; - el.style.border = '1px solid #ddd'; - return el; - }, - getTable: function() { - var el = document.createElement('table'); - el.className = 'table table-bordered'; - el.style.width = 'auto'; - el.style.maxWidth = 'none'; - return el; - }, - addInputError: function(input,text) { - if(!input.controlgroup) { - this.queuedInputErrorText = text; - return; - } - if(!input.controlgroup || !input.controls) return; - input.controlgroup.className += ' error'; - if(!input.errmsg) { - input.errmsg = document.createElement('p'); - input.errmsg.className = 'help-block errormsg'; - input.controls.appendChild(input.errmsg); - } - else { - input.errmsg.style.display = ''; - } - - input.errmsg.textContent = text; - }, - removeInputError: function(input) { - if(!input.controlgroup) { - delete this.queuedInputErrorText; - } - if(!input.errmsg) return; - input.errmsg.style.display = 'none'; - input.controlgroup.className = input.controlgroup.className.replace(/\s?error/g,''); - }, - getTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'tabbable tabs-left'; - el.innerHTML = "
    "; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'tabbable tabs-over'; - el.innerHTML = "
    "; - return el; - }, - getTab: function(text,tabId) { - var el = document.createElement('li'); - el.className = 'nav-item'; - var a = document.createElement('a'); - a.setAttribute('href','#' + tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTopTab: function(text,tabId) { - var el = document.createElement('li'); - el.className = 'nav-item'; - var a = document.createElement('a'); - a.setAttribute('href','#' + tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTopTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTabContent: function() { - var el = document.createElement('div'); - el.className = 'tab-pane'; - return el; - }, - getTopTabContent: function() { - var el = document.createElement('div'); - el.className = 'tab-pane'; - return el; - }, - markTabActive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.tab.className += ' active'; - row.container.className = row.container.className.replace(/\s?active/g,''); - row.container.className += ' active'; - }, - markTabInactive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.container.className = row.container.className.replace(/\s?active/g,''); - }, - addTab: function(holder, tab) { - holder.children[0].appendChild(tab); - }, - addTopTab: function(holder, tab) { - holder.children[0].appendChild(tab); - }, - getProgressBar: function() { - var container = document.createElement('div'); - container.className = 'progress'; - - var bar = document.createElement('div'); - bar.className = 'bar'; - bar.style.width = '0%'; - container.appendChild(bar); - - return container; - }, - updateProgressBar: function(progressBar, progress) { - if (!progressBar) return; - - progressBar.firstChild.style.width = progress + "%"; - }, - updateProgressBarUnknown: function(progressBar) { - if (!progressBar) return; - - progressBar.className = 'progress progress-striped active'; - progressBar.firstChild.style.width = '100%'; - } -}); - -JSONEditor.defaults.themes.bootstrap3 = JSONEditor.AbstractTheme.extend({ - getSelectInput: function(options) { - var el = this._super(options); - el.className += 'form-control'; - //el.style.width = 'auto'; - return el; - }, - getGridContainer: function() { - var el = document.createElement('div'); - el.className = 'container-fluid'; - el.style.padding = '4px'; - return el; - }, - getGridRow: function() { - var el = document.createElement('div'); - el.className = 'row-fluid'; - el.style.padding = '4px'; - return el; - }, - setGridColumnSize: function(el,size) { - el.className = 'col-md-'+size; - }, - afterInputReady: function(input) { - if(input.controlgroup) return; - input.controlgroup = this.closest(input,'.form-group'); - if(this.closest(input,'.compact')) { - input.controlgroup.style.marginBottom = 0; - } - if (this.queuedInputErrorText) { - var text = this.queuedInputErrorText; - delete this.queuedInputErrorText; - this.addInputError(input,text); - } - - // TODO: use bootstrap slider - }, - getRangeInput: function(min, max, step) { - // TODO: use better slider - return this._super(min, max, step); - }, - getFormInputField: function(type) { - var el = this._super(type); - if(type !== 'checkbox') { - el.className += 'form-control'; - } - return el; - }, - getFormControl: function(label, input, description, infoText) { - var group = document.createElement('div'); - - if(label && input.type === 'checkbox') { - group.className += ' checkbox'; - label.appendChild(input); - label.style.fontSize = '12px'; - group.style.marginTop = '0'; - if(infoText) group.appendChild(infoText); - group.appendChild(label); - input.style.position = 'relative'; - input.style.cssFloat = 'left'; - } - else { - group.className += ' form-group'; - if(label) { - label.className += ' control-label'; - group.appendChild(label); - } - - if(infoText) group.appendChild(infoText); - group.appendChild(input); - } - - if(description) group.appendChild(description); - - return group; - }, - getIndentedPanel: function() { - var el = document.createElement('div'); - el.className = 'well well-sm'; - el.style.padding = '4px'; - return el; - }, - getInfoButton: function(text) { - var icon = document.createElement('span'); - icon.className = "glyphicon glyphicon-info-sign pull-right"; - icon.style.padding = ".25rem"; - icon.style.position = "relative"; - icon.style.display = "inline-block"; - - var tooltip = document.createElement('span'); - tooltip.style["font-family"] = "sans-serif"; - tooltip.style.visibility = "hidden"; - tooltip.style["background-color"] = "rgba(50, 50, 50, .75)"; - tooltip.style.margin = "0 .25rem"; - tooltip.style.color = "#FAFAFA"; - tooltip.style.padding = ".5rem 1rem"; - tooltip.style["border-radius"] = ".25rem"; - tooltip.style.width = "25rem"; - tooltip.style.transform = "translateX(-27rem) translateY(-.5rem)"; - tooltip.style.position = "absolute"; - tooltip.innerText = text; - icon.onmouseover = function() { - tooltip.style.visibility = "visible"; - }; - icon.onmouseleave = function() { - tooltip.style.visibility = "hidden"; - }; - - icon.appendChild(tooltip); - - return icon; - }, - getFormInputDescription: function(text) { - var el = document.createElement('p'); - el.className = 'help-block'; - el.innerHTML = text; - return el; - }, - getHeaderButtonHolder: function() { - var el = this.getButtonHolder(); - el.style.marginLeft = '5px'; - return el; - }, - getButtonHolder: function() { - var el = document.createElement('div'); - el.className = 'btn-group'; - return el; - }, - getButton: function(text, icon, title) { - var el = this._super(text, icon, title); - el.className += ' btn btn-default'; - el.style.backgroundColor = '#f2bfab'; - el.style.border = '1px solid #ddd'; - return el; - }, - getTable: function() { - var el = document.createElement('table'); - el.className = 'table table-bordered'; - el.style.width = 'auto'; - el.style.maxWidth = 'none'; - return el; - }, - - addInputError: function(input,text) { - if(!input.controlgroup) { - this.queuedInputErrorText = text; - return; - } - input.controlgroup.className = input.controlgroup.className.replace(/\s?has-error/g,''); - input.controlgroup.className += ' has-error'; - if(!input.errmsg) { - input.errmsg = document.createElement('p'); - input.errmsg.className = 'help-block errormsg'; - input.controlgroup.appendChild(input.errmsg); - } - else { - input.errmsg.style.display = ''; - } - - input.errmsg.textContent = text; - }, - removeInputError: function(input) { - if(!input.controlgroup) { - delete this.queuedInputErrorText; - } - if(!input.errmsg) return; - input.errmsg.style.display = 'none'; - input.controlgroup.className = input.controlgroup.className.replace(/\s?has-error/g,''); - }, - getTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.innerHTML = "
    "; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.innerHTML = "
    "; - return el; - }, - getTab: function(text, tabId) { - var el = document.createElement('a'); - el.className = 'list-group-item'; - el.setAttribute('href','#'+tabId); - el.appendChild(text); - return el; - }, - getTopTab: function(text, tabId) { - var el = document.createElement('li'); - var a = document.createElement('a'); - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - markTabActive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.tab.className += ' active'; - row.container.style.display = ''; - }, - markTabInactive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.container.style.display = 'none'; - }, - getProgressBar: function() { - var min = 0, max = 100, start = 0; - - var container = document.createElement('div'); - container.className = 'progress'; - - var bar = document.createElement('div'); - bar.className = 'progress-bar'; - bar.setAttribute('role', 'progressbar'); - bar.setAttribute('aria-valuenow', start); - bar.setAttribute('aria-valuemin', min); - bar.setAttribute('aria-valuenax', max); - bar.innerHTML = start + "%"; - container.appendChild(bar); - - return container; - }, - updateProgressBar: function(progressBar, progress) { - if (!progressBar) return; - - var bar = progressBar.firstChild; - var percentage = progress + "%"; - bar.setAttribute('aria-valuenow', progress); - bar.style.width = percentage; - bar.innerHTML = percentage; - }, - updateProgressBarUnknown: function(progressBar) { - if (!progressBar) return; - - var bar = progressBar.firstChild; - progressBar.className = 'progress progress-striped active'; - bar.removeAttribute('aria-valuenow'); - bar.style.width = '100%'; - bar.innerHTML = ''; - } -}); - -JSONEditor.defaults.themes.bootstrap4 = JSONEditor.AbstractTheme.extend({ - getSelectInput: function(options) { - var el = this._super(options); - el.className += "form-control"; - //el.style.width = 'auto'; - return el; - }, - setGridColumnSize: function(el, size) { - el.className = "col-md-" + size; - }, - afterInputReady: function(input) { - if (input.controlgroup) return; - input.controlgroup = this.closest(input, ".form-group"); - if (this.closest(input, ".compact")) { - input.controlgroup.style.marginBottom = 0; - } - - // TODO: use bootstrap slider - }, - getTextareaInput: function() { - var el = document.createElement("textarea"); - el.className = "form-control"; - return el; - }, - getRangeInput: function(min, max, step) { - // TODO: use better slider - return this._super(min, max, step); - }, - getFormInputField: function(type) { - var el = this._super(type); - if (type !== "checkbox") { - el.className += "form-control"; - } - return el; - }, - getFormControl: function(label, input, description) { - var group = document.createElement("div"); - - if (label && input.type === "checkbox") { - group.className += " checkbox"; - label.appendChild(input); - label.style.fontSize = "12px"; - group.style.marginTop = "0"; - group.appendChild(label); - input.style.position = "relative"; - input.style.cssFloat = "left"; - } else { - group.className += " form-group"; - if (label) { - label.className += " form-control-label"; - group.appendChild(label); - } - group.appendChild(input); - } - - if (description) group.appendChild(description); - - return group; - }, - getIndentedPanel: function() { - var el = document.createElement("div"); - el.className = "card card-body bg-light"; - return el; - }, - getFormInputDescription: function(text) { - var el = document.createElement("p"); - el.className = "form-text"; - el.innerHTML = text; - return el; - }, - getHeaderButtonHolder: function() { - var el = this.getButtonHolder(); - el.style.marginLeft = "10px"; - return el; - }, - getButtonHolder: function() { - var el = document.createElement("div"); - el.className = "btn-group"; - return el; - }, - getButton: function(text, icon, title) { - var el = this._super(text, icon, title); - el.className += "btn btn-secondary"; - return el; - }, - getTable: function() { - var el = document.createElement("table"); - el.className = "table-bordered table-sm"; - el.style.width = "auto"; - el.style.maxWidth = "none"; - return el; - }, - - addInputError: function(input, text) { - if (!input.controlgroup) return; - input.controlgroup.className += " has-error"; - if (!input.errmsg) { - input.errmsg = document.createElement("p"); - input.errmsg.className = "form-text errormsg"; - input.controlgroup.appendChild(input.errmsg); - } else { - input.errmsg.style.display = ""; - } - - input.errmsg.textContent = text; - }, - removeInputError: function(input) { - if (!input.errmsg) return; - input.errmsg.style.display = "none"; - input.controlgroup.className = input.controlgroup.className.replace( - /\s?has-error/g, - "" - ); - }, - getTabHolder: function(propertyName) { - var el = document.createElement("div"); - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - el.innerHTML = - "
    "; -el.className = "row"; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.innerHTML = "
    "; - return el; - }, - getTab: function(text,tabId) { - var liel = document.createElement('li'); - liel.className = 'nav-item'; - var ael = document.createElement("a"); - ael.className = "nav-link"; - ael.setAttribute("style",'padding:10px;'); - ael.setAttribute("href", "#" + tabId); - ael.appendChild(text); - liel.appendChild(ael); - return liel; - }, - getTopTab: function(text, tabId) { - var el = document.createElement('li'); - el.className = 'nav-item'; - var a = document.createElement('a'); - a.className = 'nav-link'; - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - markTabActive: function(row) { - var el = row.tab.firstChild; - el.className = el.className.replace(/\s?active/g,''); - el.className += " active"; - row.container.style.display = ''; - }, - markTabInactive: function(row) { - var el = row.tab.firstChild; - el.className = el.className.replace(/\s?active/g,''); - row.container.style.display = 'none'; - }, - getProgressBar: function() { - var min = 0, - max = 100, - start = 0; - - var container = document.createElement("div"); - container.className = "progress"; - - var bar = document.createElement("div"); - bar.className = "progress-bar"; - bar.setAttribute("role", "progressbar"); - bar.setAttribute("aria-valuenow", start); - bar.setAttribute("aria-valuemin", min); - bar.setAttribute("aria-valuenax", max); - bar.innerHTML = start + "%"; - container.appendChild(bar); - - return container; - }, - updateProgressBar: function(progressBar, progress) { - if (!progressBar) return; - - var bar = progressBar.firstChild; - var percentage = progress + "%"; - bar.setAttribute("aria-valuenow", progress); - bar.style.width = percentage; - bar.innerHTML = percentage; - }, - updateProgressBarUnknown: function(progressBar) { - if (!progressBar) return; - - var bar = progressBar.firstChild; - progressBar.className = "progress progress-striped active"; - bar.removeAttribute("aria-valuenow"); - bar.style.width = "100%"; - bar.innerHTML = ""; - } -}); - -// Base Foundation theme -JSONEditor.defaults.themes.foundation = JSONEditor.AbstractTheme.extend({ - getChildEditorHolder: function() { - var el = document.createElement('div'); - el.style.marginBottom = '15px'; - return el; - }, - getSelectInput: function(options) { - var el = this._super(options); - el.style.minWidth = 'none'; - el.style.padding = '5px'; - el.style.marginTop = '3px'; - return el; - }, - getSwitcher: function(options) { - var el = this._super(options); - el.style.paddingRight = '8px'; - return el; - }, - afterInputReady: function(input) { - if(input.group) return; - if(this.closest(input,'.compact')) { - input.style.marginBottom = 0; - } - input.group = this.closest(input,'.form-control'); - if (this.queuedInputErrorText) { - var text = this.queuedInputErrorText; - delete this.queuedInputErrorText; - this.addInputError(input,text); - } - }, - getFormInputLabel: function(text) { - var el = this._super(text); - el.style.display = 'inline-block'; - return el; - }, - getFormInputField: function(type) { - var el = this._super(type); - el.style.width = '100%'; - el.style.marginBottom = type==='checkbox'? '0' : '12px'; - return el; - }, - getFormInputDescription: function(text) { - var el = document.createElement('p'); - el.textContent = text; - el.style.marginTop = '-10px'; - el.style.fontStyle = 'italic'; - return el; - }, - getIndentedPanel: function() { - var el = document.createElement('div'); - el.className = 'panel'; - el.style.paddingBottom = 0; - return el; - }, - getHeaderButtonHolder: function() { - var el = this.getButtonHolder(); - el.style.display = 'inline-block'; - el.style.marginLeft = '10px'; - el.style.verticalAlign = 'middle'; - return el; - }, - getButtonHolder: function() { - var el = document.createElement('div'); - el.className = 'button-group'; - return el; - }, - getButton: function(text, icon, title) { - var el = this._super(text, icon, title); - el.className += ' small button'; - return el; - }, - addInputError: function(input,text) { - if(!input.group) { - this.queuedInputErrorText = text; - return; - } - input.group.className += ' error'; - - if(!input.errmsg) { - input.insertAdjacentHTML('afterend',''); - input.errmsg = input.parentNode.getElementsByClassName('error')[0]; - } - else { - input.errmsg.style.display = ''; - } - - input.errmsg.textContent = text; - }, - removeInputError: function(input) { - if(!input.group) { - delete this.queuedInputErrorText; - } - if(!input.errmsg) return; - input.group.className = input.group.className.replace(/ error/g,''); - input.errmsg.style.display = 'none'; - }, - getProgressBar: function() { - var progressBar = document.createElement('div'); - progressBar.className = 'progress'; - - var meter = document.createElement('span'); - meter.className = 'meter'; - meter.style.width = '0%'; - progressBar.appendChild(meter); - return progressBar; - }, - updateProgressBar: function(progressBar, progress) { - if (!progressBar) return; - progressBar.firstChild.style.width = progress + '%'; - }, - updateProgressBarUnknown: function(progressBar) { - if (!progressBar) return; - progressBar.firstChild.style.width = '100%'; - } -}); - -// Foundation 3 Specific Theme -JSONEditor.defaults.themes.foundation3 = JSONEditor.defaults.themes.foundation.extend({ - getHeaderButtonHolder: function() { - var el = this._super(); - el.style.fontSize = '.6em'; - return el; - }, - getFormInputLabel: function(text) { - var el = this._super(text); - el.style.fontWeight = 'bold'; - return el; - }, - getTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'row'; - el.innerHTML = '
    '; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'row'; - el.innerHTML = '
    '; - return el; - }, - setGridColumnSize: function(el,size) { - var sizes = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve']; - el.className = 'columns '+sizes[size]; - }, - getTab: function(text, tabId) { - var el = document.createElement('dd'); - var a = document.createElement('a'); - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTopTab: function(text, tabId) { - var el = document.createElement('dd'); - var a = document.createElement('a'); - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTopTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTabContent: function() { - var el = document.createElement('div'); - el.className = 'content active'; - el.style.paddingLeft = '5px'; - return el; - }, - getTopTabContent: function() { - var el = document.createElement('div'); - el.className = 'content active'; - el.style.paddingLeft = '5px'; - return el; - }, - markTabActive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.tab.className += ' active'; - row.container.style.display = ''; - }, - markTabInactive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.container.style.display = 'none'; - }, - addTab: function(holder, tab) { - holder.children[0].appendChild(tab); - }, - addTopTab: function(holder, tab) { - holder.children[0].appendChild(tab); - } -}); - -// Foundation 4 Specific Theme -JSONEditor.defaults.themes.foundation4 = JSONEditor.defaults.themes.foundation.extend({ - getHeaderButtonHolder: function() { - var el = this._super(); - el.style.fontSize = '.6em'; - return el; - }, - setGridColumnSize: function(el,size) { - el.className = 'columns large-'+size; - }, - getFormInputDescription: function(text) { - var el = this._super(text); - el.style.fontSize = '.8rem'; - return el; - }, - getFormInputLabel: function(text) { - var el = this._super(text); - el.style.fontWeight = 'bold'; - return el; - } -}); - -// Foundation 5 Specific Theme -JSONEditor.defaults.themes.foundation5 = JSONEditor.defaults.themes.foundation.extend({ - getFormInputDescription: function(text) { - var el = this._super(text); - el.style.fontSize = '.8rem'; - return el; - }, - setGridColumnSize: function(el,size) { - el.className = 'columns medium-'+size; - }, - getButton: function(text, icon, title) { - var el = this._super(text,icon,title); - el.className = el.className.replace(/\s*small/g,'') + ' tiny'; - return el; - }, - getTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.innerHTML = '
    '; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'row'; - el.innerHTML = '
    '; - return el; - }, - getTab: function(text, tabId) { - var el = document.createElement('dd'); - var a = document.createElement('a'); - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTopTab: function(text, tabId) { - var el = document.createElement('dd'); - var a = document.createElement('a'); - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTopTabContentHolder: function(tab_holder) { - return tab_holder.children[1]; - }, - getTabContent: function() { - var el = document.createElement('div'); - el.className = 'tab-content active'; - el.style.paddingLeft = '5px'; - return el; - }, - getTopTabContent: function() { - var el = document.createElement('div'); - el.className = 'tab-content active'; - el.style.paddingLeft = '5px'; - return el; - }, - markTabActive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.tab.className += ' active'; - row.container.style.display = ''; - }, - markTabInactive: function(row) { - row.tab.className = row.tab.className.replace(/\s?active/g,''); - row.container.style.display = 'none'; - }, - addTab: function(holder, tab) { - holder.children[0].appendChild(tab); - }, - addTopTab: function(holder, tab) { - holder.children[0].appendChild(tab); - } - -}); - -JSONEditor.defaults.themes.foundation6 = JSONEditor.defaults.themes.foundation5.extend({ - getIndentedPanel: function() { - var el = document.createElement('div'); - el.className = 'callout secondary'; - el.className.style = 'padding-left: 10px; margin-left: 10px;'; - return el; - }, - getButtonHolder: function() { - var el = document.createElement('div'); - el.className = 'button-group tiny'; - el.style.marginBottom = 0; - return el; - }, - getFormInputLabel: function(text) { - var el = this._super(text); - el.style.display = 'block'; - return el; - }, - getFormControl: function(label, input, description, infoText) { - var el = document.createElement('div'); - el.className = 'form-control'; - if(label) el.appendChild(label); - if(input.type === 'checkbox') { - label.insertBefore(input,label.firstChild); - } - else if (label) { - if(infoText) label.appendChild(infoText); - label.appendChild(input); - } else { - if(infoText) el.appendChild(infoText); - el.appendChild(input); - } - - if(description) label.appendChild(description); - return el; - }, - addInputError: function(input,text) { - if(!input.group) return; - input.group.className += ' error'; - - if(!input.errmsg) { - var errorEl = document.createElement('span'); - errorEl.className = 'form-error is-visible'; - input.group.getElementsByTagName('label')[0].appendChild(errorEl); - - input.className = input.className + ' is-invalid-input'; - - input.errmsg = errorEl; - } - else { - input.errmsg.style.display = ''; - input.className = ''; - } - - input.errmsg.textContent = text; - }, - removeInputError: function(input) { - if(!input.errmsg) return; - input.className = input.className.replace(/ is-invalid-input/g,''); - if(input.errmsg.parentNode) { - input.errmsg.parentNode.removeChild(input.errmsg); - } - }, - getTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'grid-x'; - el.innerHTML = '
      '; - return el; - }, - getTopTabHolder: function(propertyName) { - var pName = (typeof propertyName === 'undefined')? "" : propertyName; - var el = document.createElement('div'); - el.className = 'grid-y'; - el.innerHTML = '
        '; - return el; - - - }, - insertBasicTopTab: function(tab, newTabs_holder ) { - newTabs_holder.firstChild.firstChild.insertBefore(tab,newTabs_holder.firstChild.firstChild.firstChild); - }, - getTab: function(text, tabId) { - var el = document.createElement('li'); - el.className = 'tabs-title'; - var a = document.createElement('a'); - a.setAttribute('href','#'+tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTopTab: function(text, tabId) { - var el = document.createElement('li'); - el.className = 'tabs-title'; - var a = document.createElement('a'); - a.setAttribute('href','#' + tabId); - a.appendChild(text); - el.appendChild(a); - return el; - }, - getTabContentHolder: function(tab_holder) { - return tab_holder.children[1].firstChild; - }, - getTopTabContentHolder: function(tab_holder) { - return tab_holder.firstChild.children[1]; - }, - getTabContent: function() { - var el = document.createElement('div'); - el.className = 'tabs-panel'; - el.style.paddingLeft = '5px'; - return el; - }, - getTopTabContent: function() { - var el = document.createElement('div'); - el.className = 'tabs-panel'; - el.style.paddingLeft = '5px'; - return el; - }, - markTabActive: function(row) { - row.tab.className = row.tab.className.replace(/\s?is-active/g,''); - row.tab.className += ' is-active'; - row.tab.firstChild.setAttribute('aria-selected', 'true'); - - row.container.className = row.container.className.replace(/\s?is-active/g,''); - row.container.className += ' is-active'; - row.container.setAttribute('aria-selected', 'true'); - }, - markTabInactive: function(row) { - row.tab.className = row.tab.className.replace(/\s?is-active/g,''); - row.tab.firstChild.removeAttribute('aria-selected'); - - row.container.className = row.container.className.replace(/\s?is-active/g,''); - row.container.removeAttribute('aria-selected'); - }, - addTab: function(holder, tab) { - holder.children[0].firstChild.appendChild(tab); - }, - addTopTab: function(holder, tab) { - holder.firstChild.children[0].appendChild(tab); - }, - getFirstTab: function(holder){ - return holder.firstChild.firstChild.firstChild; - } -}); - -JSONEditor.defaults.themes.html = JSONEditor.AbstractTheme.extend({ - getFormInputLabel: function(text) { - var el = this._super(text); - el.style.display = 'block'; - el.style.marginBottom = '3px'; - el.style.fontWeight = 'bold'; - return el; - }, - getFormInputDescription: function(text) { - var el = this._super(text); - el.style.fontSize = '.8em'; - el.style.margin = 0; - el.style.display = 'inline-block'; - el.style.fontStyle = 'italic'; - return el; - }, - getIndentedPanel: function() { - var el = this._super(); - el.style.border = '1px solid #ddd'; - el.style.padding = '5px'; - el.style.margin = '10px'; - el.style.borderRadius = '3px'; - return el; - }, - getTopIndentedPanel: function() { - return this.getIndentedPanel(); - }, - getChildEditorHolder: function() { - var el = this._super(); - el.style.marginBottom = '8px'; - return el; - }, - getHeaderButtonHolder: function() { - var el = this.getButtonHolder(); - el.style.display = 'inline-block'; - el.style.marginLeft = '10px'; - el.style.fontSize = '.8em'; - el.style.verticalAlign = 'middle'; - return el; - }, - getTable: function() { - var el = this._super(); - el.style.borderBottom = '1px solid #ccc'; - el.style.marginBottom = '5px'; - return el; - }, - addInputError: function(input, text) { - input.style.borderColor = 'red'; - - if(!input.errmsg) { - var group = this.closest(input,'.form-control'); - input.errmsg = document.createElement('div'); - input.errmsg.setAttribute('class','errmsg'); - input.errmsg.style = input.errmsg.style || {}; - input.errmsg.style.color = 'red'; - group.appendChild(input.errmsg); - } - else { - input.errmsg.style.display = 'block'; - } - - input.errmsg.innerHTML = ''; - input.errmsg.appendChild(document.createTextNode(text)); - }, - removeInputError: function(input) { - input.style.borderColor = ''; - if(input.errmsg) input.errmsg.style.display = 'none'; - }, - getProgressBar: function() { - var max = 100, start = 0; - - var progressBar = document.createElement('progress'); - progressBar.setAttribute('max', max); - progressBar.setAttribute('value', start); - return progressBar; - }, - updateProgressBar: function(progressBar, progress) { - if (!progressBar) return; - progressBar.setAttribute('value', progress); - }, - updateProgressBarUnknown: function(progressBar) { - if (!progressBar) return; - progressBar.removeAttribute('value'); - } -}); - -JSONEditor.defaults.themes.jqueryui = JSONEditor.AbstractTheme.extend({ - getTable: function() { - var el = this._super(); - el.setAttribute('cellpadding',5); - el.setAttribute('cellspacing',0); - return el; - }, - getTableHeaderCell: function(text) { - var el = this._super(text); - el.className = 'ui-state-active'; - el.style.fontWeight = 'bold'; - return el; - }, - getTableCell: function() { - var el = this._super(); - el.className = 'ui-widget-content'; - return el; - }, - getHeaderButtonHolder: function() { - var el = this.getButtonHolder(); - el.style.marginLeft = '10px'; - el.style.fontSize = '.6em'; - el.style.display = 'inline-block'; - return el; - }, - getFormInputDescription: function(text) { - var el = this.getDescription(text); - el.style.marginLeft = '10px'; - el.style.display = 'inline-block'; - return el; - }, - getFormControl: function(label, input, description, infoText) { - var el = this._super(label,input,description, infoText); - if(input.type === 'checkbox') { - el.style.lineHeight = '25px'; - - el.style.padding = '3px 0'; - } - else { - el.style.padding = '4px'; - } - return el; - }, - getDescription: function(text) { - var el = document.createElement('span'); - el.style.fontSize = '.8em'; - el.style.fontStyle = 'italic'; - el.textContent = text; - return el; - }, - getButtonHolder: function() { - var el = document.createElement('div'); - el.className = 'ui-buttonset'; - el.style.fontSize = '.7em'; - return el; - }, - getFormInputLabel: function(text) { - var el = document.createElement('label'); - el.style.fontWeight = 'bold'; - el.style.display = 'block'; - el.textContent = text; - return el; - }, - getButton: function(text, icon, title) { - var button = document.createElement("button"); - button.className = 'ui-button ui-widget ui-state-default ui-corner-all'; - - // Icon only - if(icon && !text) { - button.className += ' ui-button-icon-only'; - icon.className += ' ui-button-icon-primary ui-icon-primary'; - button.appendChild(icon); - } - // Icon and Text - else if(icon) { - button.className += ' ui-button-text-icon-primary'; - icon.className += ' ui-button-icon-primary ui-icon-primary'; - button.appendChild(icon); - } - // Text only - else { - button.className += ' ui-button-text-only'; - } - - var el = document.createElement('span'); - el.className = 'ui-button-text'; - el.textContent = text||title||"."; - button.appendChild(el); - - button.setAttribute('title',title); - - return button; - }, - setButtonText: function(button,text, icon, title) { - button.innerHTML = ''; - button.className = 'ui-button ui-widget ui-state-default ui-corner-all'; - - // Icon only - if(icon && !text) { - button.className += ' ui-button-icon-only'; - icon.className += ' ui-button-icon-primary ui-icon-primary'; - button.appendChild(icon); - } - // Icon and Text - else if(icon) { - button.className += ' ui-button-text-icon-primary'; - icon.className += ' ui-button-icon-primary ui-icon-primary'; - button.appendChild(icon); - } - // Text only - else { - button.className += ' ui-button-text-only'; - } - - var el = document.createElement('span'); - el.className = 'ui-button-text'; - el.textContent = text||title||"."; - button.appendChild(el); - - button.setAttribute('title',title); - }, - getIndentedPanel: function() { - var el = document.createElement('div'); - el.className = 'ui-widget-content ui-corner-all'; - el.style.padding = '1em 1.4em'; - el.style.marginBottom = '20px'; - return el; - }, - afterInputReady: function(input) { - if(input.controls) return; - input.controls = this.closest(input,'.form-control'); - if (this.queuedInputErrorText) { - var text = this.queuedInputErrorText; - delete this.queuedInputErrorText; - this.addInputError(input,text); - } - }, - addInputError: function(input,text) { - if(!input.controls) { - this.queuedInputErrorText = text; - return; - } - if(!input.errmsg) { - input.errmsg = document.createElement('div'); - input.errmsg.className = 'ui-state-error'; - input.controls.appendChild(input.errmsg); - } - else { - input.errmsg.style.display = ''; - } - - input.errmsg.textContent = text; - }, - removeInputError: function(input) { - if(!input.controls) { - delete this.queuedInputErrorText; - } - if(!input.errmsg) return; - input.errmsg.style.display = 'none'; - }, - markTabActive: function(row) { - row.tab.className = row.tab.className.replace(/\s?ui-widget-header/g,'').replace(/\s?ui-state-active/g,'')+' ui-state-active'; - row.container.style.display = ''; - }, - markTabInactive: function(row) { - row.tab.className = row.tab.className.replace(/\s?ui-state-active/g,'').replace(/\s?ui-widget-header/g,'')+' ui-widget-header'; - row.container.style.display = 'none'; - } -}); - -JSONEditor.defaults.themes.barebones = JSONEditor.AbstractTheme.extend({ - getFormInputLabel: function (text) { - var el = this._super(text); - return el; - }, - getFormInputDescription: function (text) { - var el = this._super(text); - return el; - }, - getIndentedPanel: function () { - var el = this._super(); - return el; - }, - getChildEditorHolder: function () { - var el = this._super(); - return el; - }, - getHeaderButtonHolder: function () { - var el = this.getButtonHolder(); - return el; - }, - getTable: function () { - var el = this._super(); - return el; - }, - addInputError: function (input, text) { - if (!input.errmsg) { - var group = this.closest(input, '.form-control'); - input.errmsg = document.createElement('div'); - input.errmsg.setAttribute('class', 'errmsg'); - group.appendChild(input.errmsg); - } - else { - input.errmsg.style.display = 'block'; - } - - input.errmsg.innerHTML = ''; - input.errmsg.appendChild(document.createTextNode(text)); - }, - removeInputError: function (input) { - input.style.borderColor = ''; - if (input.errmsg) input.errmsg.style.display = 'none'; - }, - getProgressBar: function () { - var max = 100, start = 0; - - var progressBar = document.createElement('progress'); - progressBar.setAttribute('max', max); - progressBar.setAttribute('value', start); - return progressBar; - }, - updateProgressBar: function (progressBar, progress) { - if (!progressBar) return; - progressBar.setAttribute('value', progress); - }, - updateProgressBarUnknown: function (progressBar) { - if (!progressBar) return; - progressBar.removeAttribute('value'); - } -}); - -JSONEditor.defaults.themes.materialize = JSONEditor.AbstractTheme.extend({ - - /** - * Applies grid size to specified element. - * - * @param {HTMLElement} el The DOM element to have specified size applied. - * @param {int} size The grid column size. - * @see http://materializecss.com/grid.html - */ - setGridColumnSize: function(el, size) { - el.className = 'col s' + size; - }, - - /** - * Gets a wrapped button element for a header. - * - * @returns {HTMLElement} The wrapped button element. - */ - getHeaderButtonHolder: function() { - return this.getButtonHolder(); - }, - - /** - * Gets a wrapped button element. - * - * @returns {HTMLElement} The wrapped button element. - */ - getButtonHolder: function() { - return document.createElement('span'); - }, - - /** - * Gets a single button element. - * - * @param {string} text The button text. - * @param {HTMLElement} icon The icon object. - * @param {string} title The button title. - * @returns {HTMLElement} The button object. - * @see http://materializecss.com/buttons.html - */ - getButton: function(text, icon, title) { - - // Prepare icon. - if (text) { - icon.className += ' left'; - icon.style.marginRight = '5px'; - } - - // Create and return button. - var el = this._super(text, icon, title); - el.className = 'waves-effect waves-light btn'; - el.style.fontSize = '0.75rem'; - el.style.height = '20px'; - el.style.lineHeight = '20px'; - el.style.marginLeft = '4px'; - el.style.padding = '0 0.5rem'; - return el; - - }, - - /** - * Gets a form control object consisiting of several sub objects. - * - * @param {HTMLElement} label The label element. - * @param {HTMLElement} input The input element. - * @param {string} description The element description. - * @param {string} infoText The element information text. - * @returns {HTMLElement} The assembled DOM element. - * @see http://materializecss.com/forms.html - */ - getFormControl: function(label, input, description, infoText) { - - var ctrl, - type = input.type; - - // Checkboxes get wrapped in p elements. - if (type && type === 'checkbox') { - - ctrl = document.createElement('p'); - ctrl.appendChild(input); - if (label) { - label.setAttribute('for', input.id); - ctrl.appendChild(label); - } - return ctrl; - - } - - // Anything else gets wrapped in divs. - ctrl = this._super(label, input, description, infoText); - - // Not .input-field for select wrappers. - if (!type || !type.startsWith('select')) - ctrl.className = 'input-field'; - - // Color needs special attention. - if (type && type === 'color') { - input.style.height = '3rem'; - input.style.width = '100%'; - input.style.margin = '5px 0 20px 0'; - input.style.padding = '3px'; - - if (label) { - label.style.transform = 'translateY(-14px) scale(0.8)'; - label.style['-webkit-transform'] = 'translateY(-14px) scale(0.8)'; - label.style['-webkit-transform-origin'] = '0 0'; - label.style['transform-origin'] = '0 0'; - } - } - - return ctrl; - - }, - - getDescription: function(text) { - var el = document.createElement('div'); - el.className = 'grey-text'; - el.style.marginTop = '-15px'; - el.innerHTML = text; - return el; - }, - - /** - * Gets a header element. - * - * @param {string|HTMLElement} text The header text or element. - * @returns {HTMLElement} The header element. - */ - getHeader: function(text) { - - var el = document.createElement('h5'); - - if (typeof text === 'string') { - el.textContent = text; - } else { - el.appendChild(text); - } - - return el; - - }, - - getChildEditorHolder: function() { - - var el = document.createElement('div'); - el.marginBottom = '10px'; - return el; - - }, - - getIndentedPanel: function() { - var el = document.createElement("div"); - el.className = "card-panel"; - return el; - }, - - getTable: function() { - - var el = document.createElement('table'); - el.className = 'striped bordered'; - el.style.marginBottom = '10px'; - return el; - - }, - - getTableRow: function() { - return document.createElement('tr'); - }, - - getTableHead: function() { - return document.createElement('thead'); - }, - - getTableBody: function() { - return document.createElement('tbody'); - }, - - getTableHeaderCell: function(text) { - - var el = document.createElement('th'); - el.textContent = text; - return el; - - }, - - getTableCell: function() { - - var el = document.createElement('td'); - return el; - - }, - - /** - * Gets the tab holder element. - * - * @returns {HTMLElement} The tab holder component. - * @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602 - */ - getTabHolder: function() { - - var html = [ - '
        ', - '
          ', - '
        ', - '
        ', - '
        ', - '
        ' - ].join("\n"); - - var el = document.createElement('div'); - el.className = 'row card-panel'; - el.innerHTML = html; - return el; - - }, - - /** - * Add specified tab to specified holder element. - * - * @param {HTMLElement} holder The tab holder element. - * @param {HTMLElement} tab The tab to add. - */ - addTab: function(holder, tab) { - holder.children[0].children[0].appendChild(tab); - }, - - /** - * Gets a single tab element. - * - * @param {HTMLElement} span The tab's content. - * @returns {HTMLElement} The tab element. - * @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602 - */ - getTab: function(span) { - - var el = document.createElement('li'); - el.className = 'tab'; - this.applyStyles(el, { - width: '100%', - textAlign: 'left', - lineHeight: '24px', - height: '24px', - fontSize: '14px', - cursor: 'pointer' - }); - el.appendChild(span); - return el; - }, - - /** - * Marks specified tab as active. - * - * @returns {HTMLElement} The tab element. - * @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602 - */ - markTabActive: function(tab) { - - this.applyStyles(tab, { - width: '100%', - textAlign: 'left', - lineHeight: '24px', - height: '24px', - fontSize: '14px', - cursor: 'pointer', - color: 'rgba(238,110,115,1)', - transition: 'border-color .5s ease', - borderRight: '3px solid #424242' - }); - - }, - - /** - * Marks specified tab as inactive. - * - * @returns {HTMLElement} The tab element. - * @see https://github.com/Dogfalo/materialize/issues/2542#issuecomment-233458602 - */ - markTabInactive: function(tab) { - - this.applyStyles(tab, { - width: '100%', - textAlign: 'left', - lineHeight: '24px', - height: '24px', - fontSize: '14px', - cursor: 'pointer', - color: 'rgba(238,110,115,0.7)' - }); - - }, - - /** - * Returns the element that holds the tab contents. - * - * @param {HTMLElement} tabHolder The full tab holder element. - * @returns {HTMLElement} The content element inside specified tab holder. - */ - getTabContentHolder: function(tabHolder) { - return tabHolder.children[1]; - }, - - /** - * Creates and returns a tab content element. - * - * @returns {HTMLElement} The new tab content element. - */ - getTabContent: function() { - return document.createElement('div'); - }, - - /** - * Adds an error message to the specified input element. - * - * @param {HTMLElement} input The input element that caused the error. - * @param {string} text The error message. - */ - addInputError: function(input, text) { - - // Get the parent element. Should most likely be a
        . - var parent = input.parentNode, - el; - - if (!parent) return; - - // Remove any previous error. - this.removeInputError(input); - - // Append an error message div. - el = document.createElement('div'); - el.className = 'error-text red-text'; - el.textContent = text; - parent.appendChild(el); - - }, - - /** - * Removes any error message from the specified input element. - * - * @param {HTMLElement} input The input element that previously caused the error. - */ - removeInputError: function(input) { - - // Get the parent element. Should most likely be a
        . - var parent = input.parentElement, - els; - - if (!parent) return; - - // Remove all elements having class .error-text. - els = parent.getElementsByClassName('error-text'); - for (var i = 0; i < els.length; i++) - parent.removeChild(els[i]); - - }, - - addTableRowError: function(row) { - }, - - removeTableRowError: function(row) { - }, - - /** - * Gets a select DOM element. - * - * @param {object} options The option values. - * @return {HTMLElement} The DOM element. - * @see http://materializecss.com/forms.html#select - */ - getSelectInput: function(options) { - - var select = this._super(options); - select.className = 'browser-default'; - return select; - - }, - - /** - * Gets a textarea DOM element. - * - * @returns {HTMLElement} The DOM element. - * @see http://materializecss.com/forms.html#textarea - */ - getTextareaInput: function() { - var el = document.createElement('textarea'); - el.style.marginBottom = '5px'; - el.style.fontSize = '1rem'; - el.style.fontFamily = 'monospace'; - return el; - }, - - getCheckbox: function() { - - var el = this.getFormInputField('checkbox'); - el.id = this.createUuid(); - return el; - - }, - - /** - * Gets the modal element for displaying Edit JSON and Properties dialogs. - * - * @returns {HTMLElement} The modal DOM element. - * @see http://materializecss.com/cards.html - */ - getModal: function() { - - var el = document.createElement('div'); - el.className = 'card-panel z-depth-3'; - el.style.padding = '5px'; - el.style.position = 'absolute'; - el.style.zIndex = '10'; - el.style.display = 'none'; - return el; - - }, - - /** - * Creates and returns a RFC4122 version 4 compliant unique id. - * - * @returns {string} A GUID. - * @see https://stackoverflow.com/a/2117523 - */ - createUuid: function() { - - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); - - } - -}); - -JSONEditor.AbstractIconLib = Class.extend({ - mapping: { - collapse: '', - expand: '', - "delete": '', - edit: '', - add: '', - cancel: '', - save: '', - moveup: '', - movedown: '' - }, - icon_prefix: '', - getIconClass: function(key) { - if(this.mapping[key]) return this.icon_prefix+this.mapping[key]; - else return null; - }, - getIcon: function(key) { - var iconclass = this.getIconClass(key); - - if(!iconclass) return null; - - var i = document.createElement('i'); - i.className = iconclass; - return i; - } -}); - -JSONEditor.defaults.iconlibs.bootstrap2 = JSONEditor.AbstractIconLib.extend({ - 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: 'glyphicon glyphicon-' -}); - -JSONEditor.defaults.iconlibs.bootstrap3 = JSONEditor.AbstractIconLib.extend({ - 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-' -}); - -JSONEditor.defaults.iconlibs.fontawesome3 = JSONEditor.AbstractIconLib.extend({ - 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-' -}); - -JSONEditor.defaults.iconlibs.fontawesome4 = JSONEditor.AbstractIconLib.extend({ - 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', - copy: 'files-o' - }, - icon_prefix: 'fa fa-' -}); - -JSONEditor.defaults.iconlibs.foundation2 = JSONEditor.AbstractIconLib.extend({ - 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-' -}); - -JSONEditor.defaults.iconlibs.foundation3 = JSONEditor.AbstractIconLib.extend({ - 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-' -}); - -JSONEditor.defaults.iconlibs.jqueryui = JSONEditor.AbstractIconLib.extend({ - 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-' -}); - -JSONEditor.defaults.iconlibs.materialicons = JSONEditor.AbstractIconLib.extend({ - - mapping: { - collapse: 'arrow_drop_up', - expand: 'arrow_drop_down', - "delete": 'delete', - edit: 'edit', - add: 'add', - cancel: 'cancel', - save: 'save', - moveup: 'arrow_upward', - movedown: 'arrow_downward', - copy: 'content_copy' - }, - - icon_class: 'material-icons', - icon_prefix: '', - - getIconClass: function(key) { - - // This method is unused. - - return this.icon_class; - }, - - getIcon: function(key) { - - // Get the mapping. - var mapping = this.mapping[key]; - if (!mapping) return null; - - // @see http://materializecss.com/icons.html - var i = document.createElement('i'); - i.className = this.icon_class; - var t = document.createTextNode(mapping); - i.appendChild(t); - return i; - - } -}); - -JSONEditor.defaults.templates["default"] = function() { - return { - compile: function(template) { - var matches = template.match(/{{\s*([a-zA-Z0-9\-_ \.]+)\s*}}/g); - var l = matches && matches.length; - - // Shortcut if the template contains no variables - if(!l) return function() { return template; }; - - // Pre-compute the search/replace functions - // This drastically speeds up template execution - var replacements = []; - var get_replacement = function(i) { - var p = matches[i].replace(/[{}]+/g,'').trim().split('.'); - var n = p.length; - var func; - - if(n > 1) { - var cur; - func = function(vars) { - cur = vars; - for(i=0; i= 0) { - // For enumerated strings, number, or integers - if(schema.items.enum) { - return 'multiselect'; - } - // For non-enumerated strings (tag editor) - else if(JSONEditor.plugins.selectize.enable && schema.items.type === "string") { - return 'arraySelectize'; - } - } -}); -// Use the multiple editor for schemas with `oneOf` set -JSONEditor.defaults.resolvers.unshift(function(schema) { - // If this schema uses `oneOf` or `anyOf` - if(schema.oneOf || schema.anyOf) return "multiple"; -}); - -/** - * This is a small wrapper for using JSON Editor like a typical jQuery plugin. - */ -(function() { - if(window.jQuery || window.Zepto) { - var $ = window.jQuery || window.Zepto; - $.jsoneditor = JSONEditor.defaults; - - $.fn.jsoneditor = function(options) { - var self = this; - var editor = this.data('jsoneditor'); - if(options === 'value') { - if(!editor) throw "Must initialize jsoneditor before getting/setting the value"; - - // Set value - if(arguments.length > 1) { - editor.setValue(arguments[1]); - } - // Get value - else { - return editor.getValue(); - } - } - else if(options === 'validate') { - if(!editor) throw "Must initialize jsoneditor before validating"; - - // Validate a specific value - if(arguments.length > 1) { - return editor.validate(arguments[1]); - } - // Validate current value - else { - return editor.validate(); - } - } - else if(options === 'destroy') { - if(editor) { - editor.destroy(); - this.data('jsoneditor',null); - } - } - else { - // Destroy first - if(editor) { - editor.destroy(); - } - - // Create editor - editor = new JSONEditor(this.get(0),options); - this.data('jsoneditor',editor); - - // Setup event listeners - editor.on('change',function() { - self.trigger('change'); - }); - editor.on('ready',function() { - self.trigger('ready'); - }); - } - - return this; - }; - } -})(); - - window.JSONEditor = JSONEditor; -})(); +!function(a,b){"use strict";var c=b(a);"object"==typeof module&&null!=module&&module.exports?module.exports=c:"function"==typeof define&&define.amd?define(function(){return c}):a.JSONEditor=c}("undefined"!=typeof window?window:this,function(a,b){var c;!function(){var a=!1,b=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/;return c=function(){},c.extend=function d(c){function e(){!a&&this.init&&this.init.apply(this,arguments)}var f=this.prototype;a=!0;var g=new this;a=!1;for(var h in c)g[h]="function"==typeof c[h]&&"function"==typeof f[h]&&b.test(c[h])?function(a,b){return function(){var c=this._super;this._super=f[a];var d=b.apply(this,arguments);return this._super=c,d}}(h,c[h]):c[h];return e.prototype=g,e.prototype.constructor=e,e.extend=d,e},c}(),function(){function a(a,c){c=c||{bubbles:!1,cancelable:!1,detail:b};var d=document.createEvent("CustomEvent");return d.initCustomEvent(a,c.bubbles,c.cancelable,c.detail),d}a.prototype=window.Event.prototype,window.CustomEvent=a}(),function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c0&&a.length-1 in a){for(c=0;c=i&&!j&&(j=!0,b())},c,k)}},f.send()}}),i||b()},expandRefs:function(a){for(a=e({},a);a.$ref;){var b=this.refs_with_info[a.$ref];delete a.$ref;var c="";b.$ref.startsWith("#")&&(c=b.fetchUrl);var d=c+b.$ref;this.refs[d]||(d=c+decodeURIComponent(b.$ref)),a=this.extendSchemas(a,e({},this.refs[d]))}return a},expandSchema:function(a,b){var c,d=this,g=e({},a);if("object"==typeof a.type&&(Array.isArray(a.type)?f(a.type,function(b,c){"object"==typeof c&&(a.type[b]=d.expandSchema(c))}):a.type=d.expandSchema(a.type)),"object"==typeof a.disallow&&(Array.isArray(a.disallow)?f(a.disallow,function(b,c){"object"==typeof c&&(a.disallow[b]=d.expandSchema(c))}):a.disallow=d.expandSchema(a.disallow)),a.anyOf&&f(a.anyOf,function(b,c){a.anyOf[b]=d.expandSchema(c)}),a.dependencies&&f(a.dependencies,function(b,c){"object"!=typeof c||Array.isArray(c)||(a.dependencies[b]=d.expandSchema(c))}),a.not&&(a.not=this.expandSchema(a.not)),a.allOf){for(c=0;ca.minimum:c>=a.minimum,window.math?g=window.math[a.exclusiveMinimum?"larger":"largerEq"](window.math.bignumber(c),window.math.bignumber(a.minimum)):window.Decimal&&(g=new window.Decimal(c)[a.exclusiveMinimum?"gt":"gte"](new window.Decimal(a.minimum))),g||l.push({path:d,property:"minimum",message:this.translate(a.exclusiveMinimum?"error_minimum_excl":"error_minimum_incl",[a.minimum])}))}else if("string"==typeof c)a.maxLength&&(c+"").length>a.maxLength&&l.push({path:d,property:"maxLength",message:this.translate("error_maxLength",[a.maxLength])}),a.minLength&&(c+"").lengtha.maxItems&&l.push({path:d,property:"maxItems",message:this.translate("error_maxItems",[a.maxItems])}),a.minItems&&c.lengtha.maxProperties&&l.push({path:d,property:"maxProperties",message:this.translate("error_maxProperties",[a.maxProperties])})}if(a.minProperties){g=0;for(i in c)c.hasOwnProperty(i)&&g++;g0:this.dependenciesFulfilled=!g||0===g.length):this.dependenciesFulfilled=!1,this.dependenciesFulfilled!==h&&this.notify(),this.dependenciesFulfilled?d.style.display="block":d.style.display="none"}},setContainer:function(a){this.container=a,this.schema.id&&this.container.setAttribute("data-schemaid",this.schema.id),this.schema.type&&"string"==typeof this.schema.type&&this.container.setAttribute("data-schematype",this.schema.type),this.container.setAttribute("data-schemapath",this.path)},preBuild:function(){},build:function(){},postBuild:function(){this.setupWatchListeners(),this.addLinks(),this.setValue(this.getDefault(),!0),this.updateHeaderText(),this.register(),this.onWatchedFieldChange()},setupWatchListeners:function(){var a=this;if(this.watched={},this.schema.vars&&(this.schema.watch=this.schema.vars),this.watched_values={},this.watch_listener=function(){a.refreshWatchedFieldValues()&&a.onWatchedFieldChange()},this.schema.hasOwnProperty("watch")){var b,c,d,e,f;for(var g in this.schema.watch)if(this.schema.watch.hasOwnProperty(g)){if(b=this.schema.watch[g],Array.isArray(b)){if(b.length<2)continue;c=[b[0]].concat(b[1].split("."))}else c=b.split("."),a.theme.closest(a.container,'[data-schemaid="'+c[0]+'"]')||c.unshift("#");if(d=c.shift(),"#"===d&&(d=a.jsoneditor.schema.id||"root"),e=a.theme.closest(a.container,'[data-schemaid="'+d+'"]'),!e)throw"Could not find ancestor node with id "+d;f=e.getAttribute("data-schemapath")+"."+c.join("."),a.jsoneditor.watch(f,a.watch_listener),a.watched[g]=f}}this.schema.headerTemplate&&(this.header_template=this.jsoneditor.compileTemplate(this.schema.headerTemplate,this.template_engine))},addLinks:function(){if(!this.no_link_holder&&(this.link_holder=this.theme.getLinksHolder(),this.container.appendChild(this.link_holder),this.schema.links))for(var a=0;a=0){b=this.theme.getBlockLinkHolder(),c=this.theme.getBlockLink(),c.setAttribute("target","_blank");var j=document.createElement(e);j.setAttribute("controls","controls"),this.theme.createMediaLink(b,c,j),this.link_watchers.push(function(a){var b=f(a),d=g(a);c.setAttribute("href",b),c.textContent=d||b,j.setAttribute("src",b)})}else c=b=this.theme.getBlockLink(),b.setAttribute("target","_blank"),b.textContent=a.rel,this.link_watchers.push(function(a){var c=f(a),d=g(a);b.setAttribute("href",c),b.textContent=d||c});return h&&c&&(h===!0?c.setAttribute("download",""):this.link_watchers.push(function(a){c.setAttribute("download",h(a))})),a["class"]&&c.classList.add(a["class"]),b},refreshWatchedFieldValues:function(){if(this.watched_values){var a={},b=!1,c=this;if(this.watched){var d,e;for(var f in this.watched)this.watched.hasOwnProperty(f)&&(e=c.jsoneditor.getEditor(this.watched[f]),d=e?e.getValue():null,c.watched_values[f]!==d&&(b=!0),a[f]=d)}return a.self=this.getValue(),this.watched_values.self!==a.self&&(b=!0),this.watched_values=a,b}},getWatchedFieldValues:function(){return this.watched_values},updateHeaderText:function(){if(this.header)if(this.header.children.length){for(var a=0;a-1:!!this.jsoneditor.options.required_by_default},getDisplayText:function(a){var b=[],c={};f(a,function(a,b){b.title&&(c[b.title]=c[b.title]||0,c[b.title]++),b.description&&(c[b.description]=c[b.description]||0,c[b.description]++),b.format&&(c[b.format]=c[b.format]||0,c[b.format]++),b.type&&(c[b.type]=c[b.type]||0,c[b.type]++)}),f(a,function(a,d){var e;e="string"==typeof d?d:d.title&&c[d.title]<=1?d.title:d.format&&c[d.format]<=1?d.format:d.type&&c[d.type]<=1?d.type:d.description&&c[d.description]<=1?d.descripton:d.title?d.title:d.format?d.format:d.type?d.type:d.description?d.description:JSON.stringify(d).length<500?JSON.stringify(d):"type",b.push(e)});var d={};return f(b,function(a,e){d[e]=d[e]||0,d[e]++,c[e]>1&&(b[a]=e+" "+d[e])}),b},getValidId:function(a){return a=a===b?"":a.toString(),a.replace(/\s+/g,"-")},setInputAttributes:function(a){if(this.schema.options&&this.schema.options.inputAttributes){var b=this.schema.options.inputAttributes,c=["name","type"].concat(a);for(var d in b)b.hasOwnProperty(d)&&c.indexOf(d.toLowerCase())==-1&&this.input.setAttribute(d,b[d])}},getOption:function(a){try{throw"getOption is deprecated"}catch(b){window.console.error(b)}return this.options[a]},showValidationErrors:function(a){}}),h.defaults.editors["null"]=h.AbstractEditor.extend({getValue:function(){return this.dependenciesFulfilled?null:b},setValue:function(){this.onChange()},getNumColumns:function(){return 2}}),h.defaults.editors.string=h.AbstractEditor.extend({register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},setValue:function(a,b,c){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a), +a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d,this.sceditor_instance?this.sceditor_instance.val(d):this.SimpleMDE?this.SimpleMDE.value(d):this.ace_editor&&(this.ace_editor.setValue(d),this.ace_editor.session.getSelection().clearSelection(),this.ace_editor.resize());var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){var a,b=Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);return a="textarea"===this.input_type?6:["text","email"].indexOf(this.input_type)>=0?4:2,Math.min(12,Math.max(b,a))},build:function(){var a=this;if(this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.format=this.schema.format,!this.format&&this.schema.media&&this.schema.media.type&&(this.format=this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,"")),!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.format)if("textarea"===this.format)this.input_type="textarea",this.input=this.theme.getTextareaInput();else if("range"===this.format){this.input_type="range";var b=this.schema.minimum||0,c=this.schema.maximum||Math.max(100,b+1),d=1;this.schema.multipleOf&&(b%this.schema.multipleOf&&(b=Math.ceil(b/this.schema.multipleOf)*this.schema.multipleOf),c%this.schema.multipleOf&&(c=Math.floor(c/this.schema.multipleOf)*this.schema.multipleOf),d=this.schema.multipleOf),this.input=this.theme.getRangeInput(b,c,d)}else["actionscript","batchfile","bbcode","c","c++","cpp","coffee","csharp","css","dart","django","ejs","erlang","golang","groovy","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","sqlserver","stylus","svg","twig","vbscript","xml","yaml"].indexOf(this.format)>=0?(this.input_type=this.format,this.source_code=!0,this.input=this.theme.getTextareaInput()):(this.input_type=this.format,this.input=this.theme.getFormInputField(this.input_type));else this.input_type="text",this.input=this.theme.getFormInputField(this.input_type);if("undefined"!=typeof this.schema.maxLength&&this.input.setAttribute("maxlength",this.schema.maxLength),"undefined"!=typeof this.schema.pattern?this.input.setAttribute("pattern",this.schema.pattern):"undefined"!=typeof this.schema.minLength&&this.input.setAttribute("pattern",".{"+this.schema.minLength+",}"),this.options.compact?this.container.classList.add("compact"):this.options.input_width&&(this.input.style.width=this.options.input_width),(this.schema.readOnly||this.schema.readonly||this.schema.template)&&(this.always_disabled=!0,this.input.setAttribute("readonly","true")),this.setInputAttributes(["maxlength","pattern","readonly","min","max","step"]),this.input.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),a.schema.template)return void(this.value=a.value);var c=this.value,d=a.sanitize(c);c!==d&&(this.value=d),a.is_dirty=!0,a.refreshValue(),a.onChange(!0)}),this.options.input_height&&(this.input.style.height=this.options.input_height),this.options.expand_height&&(this.adjust_height=function(a){if(a){var b,c=a.offsetHeight;if(a.offsetHeight100);)b++,c++,a.style.height=c+"px";else{for(b=0;a.offsetHeight>=a.scrollHeight+3&&!(b>100);)b++,c--,a.style.height=c+"px";a.style.height=c+1+"px"}}},this.input.addEventListener("keyup",function(b){a.adjust_height(this)}),this.input.addEventListener("change",function(b){a.adjust_height(this)}),this.adjust_height()),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.theme.getFormControl(this.label,this.input,this.description,this.infoButton),"range"===this.format){var e=document.createElement("output");e.setAttribute("class","range-output"),this.control.appendChild(e),e.value=this.schema["default"],this.input.addEventListener("change",function(){e.value=a.input.value}),this.input.addEventListener("input",function(){e.value=a.input.value})}this.container.appendChild(this.control),window.requestAnimationFrame(function(){a.input.parentNode&&a.afterInputReady(),a.adjust_height&&a.adjust_height(a.input)}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},postBuild:function(){this._super(),window.Cleave&&this.schema.options&&"object"==typeof this.schema.options.cleave&&(this.cleave=new window.Cleave(this.input,this.schema.options.cleave))},enable:function(){this.always_disabled||(this.input.disabled=!1,this._super())},disable:function(a){a&&(this.always_disabled=!0),this.input.disabled=!0,this._super()},afterInputReady:function(){var a,b=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.jQuery&&window.jQuery.fn&&window.jQuery.fn.sceditor)a=e({},{plugins:"html"===b.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300},h.plugins.sceditor,b.options.sceditor_options||{}),window.jQuery(b.input).sceditor(a),b.sceditor_instance=window.jQuery(b.input).sceditor("instance"),b.sceditor_instance.blur(function(){var a=window.jQuery("
        "+b.sceditor_instance.val()+"
        ");window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",a).remove(),b.input.value=a.html(),b.value=b.input.value,b.is_dirty=!0,b.onChange(!0)});else if("markdown"===this.input_type&&window.SimpleMDE)a=e({},h.plugins.SimpleMDE,{element:this.input}),this.SimpleMDE=new window.SimpleMDE(a),this.SimpleMDE.codemirror.on("change",function(){b.value=b.SimpleMDE.value(),b.is_dirty=!0,b.onChange(!0)});else if(window.ace){var c=this.input_type;"cpp"!==c&&"c++"!==c&&"c"!==c||(c="c_cpp"),this.ace_container=document.createElement("div"),this.ace_container.style.width="100%",this.ace_container.style.position="relative",this.ace_container.style.height="400px",this.input.parentNode.insertBefore(this.ace_container,this.input),this.input.style.display="none",this.ace_editor=window.ace.edit(this.ace_container);var d=this.schema.options&&this.schema.options.ace;d&&this.ace_editor.setOptions(d),this.ace_editor.setValue(this.getValue()),this.ace_editor.session.getSelection().clearSelection(),this.ace_editor.resize(),h.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+h.plugins.ace.theme),this.ace_editor.getSession().setMode("ace/mode/"+this.schema.format),this.ace_editor.on("change",function(){var a=b.ace_editor.getValue();b.input.value=a,b.refreshValue(),b.is_dirty=!0,b.onChange(!0)})}b.theme.afterInputReady(b.input)},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.sceditor_instance?this.sceditor_instance.destroy():this.SimpleMDE?(this.SimpleMDE.toTextArea(),this.SimpleMDE=null):this.ace_editor&&this.ace_editor.destroy(),this.cleave&&this.cleave.destroy(),this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];f(a,function(a,d){d.path===b.path&&c.push(d.message)}),c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),h.defaults.editors.hidden=h.AbstractEditor.extend({register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},setValue:function(a,b,c){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a),a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d;var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){return 2},enable:function(){this._super()},disable:function(){this._super()},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},build:function(){this.format=this.schema.format,!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.input_type="hidden",this.input=this.theme.getFormInputField(this.input_type),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.container.appendChild(this.input),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()}}),h.defaults.editors.number=h.defaults.editors.string.extend({build:function(){if(this._super(),"undefined"!=typeof this.schema.minimum){var a=this.schema.minimum;"undefined"!=typeof this.schema.exclusiveMinimum&&(a+=1),this.input.setAttribute("min",a)}if("undefined"!=typeof this.schema.maximum){var b=this.schema.maximum;"undefined"!=typeof this.schema.exclusiveMaximum&&(b-=1),this.input.setAttribute("max",b)}if("undefined"!=typeof this.schema.step){var c=this.schema.step||1;this.input.setAttribute("step",c)}this.setInputAttributes(["maxlength","pattern","readonly","min","max","step"])},sanitize:function(a){return(a+"").replace(/[^0-9\.\-eE]/g,"")},getNumColumns:function(){return 2},getValue:function(){return this.dependenciesFulfilled?""===this.value?b:1*this.value:b}}),h.defaults.editors.integer=h.defaults.editors.number.extend({sanitize:function(a){return a+="",a.replace(/[^0-9\-]/g,"")},getNumColumns:function(){return 2}}),h.defaults.editors.rating=h.defaults.editors.integer.extend({build:function(){var a,b=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description));var c="json-editor-style-rating",d=document.getElementById(c);if(!d){var e=document.createElement("style");e.id=c,e.type="text/css",e.innerHTML=" .rating-container { display: inline-block; clear: both; } .rating { float:left; } /* :not(:checked) is a filter, so that browsers that don’t support :checked don’t follow these rules. Every browser that supports :checked also supports :not(), so it doesn’t make the test unnecessarily selective */ .rating:not(:checked) > input { position:absolute; top:-9999px; clip:rect(0,0,0,0); } .rating:not(:checked) > label { float:right; width:1em; padding:0 .1em; overflow:hidden; white-space:nowrap; cursor:pointer; color:#ddd; } .rating:not(:checked) > label:before { content: '★ '; } .rating > input:checked ~ label { color: #FFB200; } .rating:not([readOnly]):not(:checked) > label:hover, .rating:not([readOnly]):not(:checked) > label:hover ~ label { color: #FFDA00; } .rating:not([readOnly]) > input:checked + label:hover, .rating:not([readOnly]) > input:checked + label:hover ~ label, .rating:not([readOnly]) > input:checked ~ label:hover, .rating:not([readOnly]) > input:checked ~ label:hover ~ label, .rating:not([readOnly]) > label:hover ~ input:checked ~ label { color: #FF8C0D; } .rating:not([readOnly]) > label:active { position:relative; top:2px; left:2px; }",document.getElementsByTagName("head")[0].appendChild(e)}this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input);var g=document.createElement("div");g.classList.add("rating-container");var h=document.createElement("div");h.setAttribute("name",this.formname),h.classList.add("rating"),g.appendChild(h),this.options.compact&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact");var i=this.schema.maximum?this.schema.maximum:5;for(this.schema.exclusiveMaximum&&i--,this.inputs=[],a=i;a>0;a--){var j=this.formname+a,k=this.theme.getFormInputField("radio");k.setAttribute("id",j),k.setAttribute("value",a),k.setAttribute("name",this.formname),h.appendChild(k),this.inputs.push(k);var l=document.createElement("label");l.setAttribute("for",j),l.appendChild(document.createTextNode(a+(1==a?" star":" stars"))),h.appendChild(l)}(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,f(this.inputs,function(a,b){h.setAttribute("readOnly","readOnly"),b.disabled=!0})),g.addEventListener("change",function(a){a.preventDefault(),a.stopPropagation(),b.input.value=a.srcElement.value,b.is_dirty=!0,b.refreshValue(),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),this.control=this.theme.getFormControl(this.label,g,this.description),this.container.appendChild(this.control),this.refreshValue()},setValue:function(a){var b=this.sanitize(a);if(this.value!==b){var c=this;f(this.inputs,function(a,d){if(d.value===b)return d.checked=!0,c.value=b,c.input.value=c.value,c.watch_listener(),c.jsoneditor.notifyWatchers(c.path),!1})}}}),h.defaults.editors.object=h.AbstractEditor.extend({getDefault:function(){return e({},this.schema["default"]||{})},getChildEditors:function(){return this.editors},register:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].register()},unregister:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].unregister()},getNumColumns:function(){return Math.max(Math.min(12,this.maxwidth),3)},enable:function(){if(!this.always_disabled&&(this.editjson_button&&(this.editjson_button.disabled=!1),this.addproperty_button&&(this.addproperty_button.disabled=!1),this._super(),this.editors))for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].enable()},disable:function(a){if(a&&(this.always_disabled=!0),this.editjson_button&&(this.editjson_button.disabled=!0),this.addproperty_button&&(this.addproperty_button.disabled=!0),this.hideEditJSON(),this._super(),this.editors)for(var b in this.editors)this.editors.hasOwnProperty(b)&&this.editors[b].disable(a)},layoutEditors:function(){var a,b,c=this;if(this.row_container){this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(a,b){var d=c.editors[a].schema.propertyOrder,e=c.editors[b].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e});var d,e="categories"===this.format;if("grid"===this.format){var h=[];for(f(this.property_order,function(a,b){var d=c.editors[b];if(!d.property_removed){for(var e=!1,f=d.options.hidden?0:d.options.grid_columns||d.getNumColumns(),g=d.options.hidden?0:d.container.offsetHeight,i=0;ig)&&(e=i);e===!1&&(h.push({width:0,minh:999999,maxh:0,editors:[]}),e=h.length-1),h[e].editors.push({key:b,width:f,height:g}),h[e].width+=f,h[e].minh=Math.min(h[e].minh,g),h[e].maxh=Math.max(h[e].maxh,g)}}),a=0;ah[a].editors[i].width&&(i=b),h[a].editors[b].width*=12/h[a].width,h[a].editors[b].width=Math.floor(h[a].editors[b].width),j+=h[a].editors[b].width;j<12&&(h[a].editors[i].width+=12-j),h[a].width=12}if(this.layout===JSON.stringify(h))return!1;for(this.layout=JSON.stringify(h),d=document.createElement("div"),a=0;a0?p.firstChild.isObjOrArray&&(e.appendChild(n),p.insertBefore(e,p.firstChild),c.theme.insertBasicTopTab(d.tab,o),d.basicPane=e):(e.appendChild(n),p.appendChild(e),c.theme.addTopTab(o,d.tab),d.basicPane=e)),d.options.hidden?d.container.style.display="none":c.theme.setGridColumnSize(d.container,12),g.appendChild(d.container),d.rowPane=e}});this.tabPanesContainer.firstChild;)this.tabPanesContainer.removeChild(this.tabPanesContainer.firstChild);var q=this.tabs_holder.parentNode;q.removeChild(q.firstChild),q.appendChild(o),this.tabPanesContainer=p,this.tabs_holder=o;var r=this.theme.getFirstTab(this.tabs_holder);return void(r&&g(r,"click"))}f(this.property_order,function(a,b){var e=c.editors[b];if(!e.property_removed){var f=c.theme.getGridRow();d.appendChild(f),e.options.hidden?e.container.style.display="none":c.theme.setGridColumnSize(e.container,12),f.appendChild(e.container)}})}for(;this.row_container.firstChild;)this.row_container.removeChild(this.row_container.firstChild);this.row_container.appendChild(d)}},getPropertySchema:function(a){var b=this.schema.properties[a]||{};b=e({},b);var c=!!this.schema.properties[a];if(this.schema.patternProperties)for(var d in this.schema.patternProperties)if(this.schema.patternProperties.hasOwnProperty(d)){var f=new RegExp(d);f.test(a)&&(b.allOf=b.allOf||[],b.allOf.push(this.schema.patternProperties[d]),c=!0)}return!c&&this.schema.additionalProperties&&"object"==typeof this.schema.additionalProperties&&(b=e({},this.schema.additionalProperties)),b},preBuild:function(){this._super(),this.editors={},this.cached_editors={};var a=this;if(this.format=this.options.layout||this.options.object_layout||this.schema.format||this.jsoneditor.options.object_layout||"normal",this.schema.properties=this.schema.properties||{},this.minwidth=0,this.maxwidth=0,this.options.table_row)f(this.schema.properties,function(b,c){var d=a.jsoneditor.getEditorClass(c);a.editors[b]=a.jsoneditor.createEditor(d,{jsoneditor:a.jsoneditor,schema:c,path:a.path+"."+b,parent:a,compact:!0,required:!0}),a.editors[b].preBuild();var e=a.editors[b].options.hidden?0:a.editors[b].options.grid_columns||a.editors[b].getNumColumns();a.minwidth+=e,a.maxwidth+=e}),this.no_link_holder=!0;else{if(this.options.table)throw"Not supported yet";this.schema.defaultProperties||(this.jsoneditor.options.display_required_only||this.options.display_required_only?(this.schema.defaultProperties=[],f(this.schema.properties,function(b,c){a.isRequired({key:b,schema:c})&&a.schema.defaultProperties.push(b)})):a.schema.defaultProperties=Object.keys(a.schema.properties)),a.maxwidth+=1,f(this.schema.defaultProperties,function(b,c){a.addObjectProperty(c,!0),a.editors[c]&&(a.minwidth=Math.max(a.minwidth,a.editors[c].options.grid_columns||a.editors[c].getNumColumns()),a.maxwidth+=a.editors[c].options.grid_columns||a.editors[c].getNumColumns())})}this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(b,c){var d=a.editors[b].schema.propertyOrder,e=a.editors[c].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e})},addTab:function(a){var b=this,c=b.rows[a].schema&&("object"===b.rows[a].schema.type||"array"===b.rows[a].schema.type);b.tabs_holder&&(b.rows[a].tab_text=document.createElement("span"),c?b.rows[a].tab_text.textContent=b.rows[a].getHeaderText():b.rows[a].tab_text.textContent="undefined"==typeof b.schema.basicCategoryTitle?"Basic":b.schema.basicCategoryTitle,b.rows[a].tab=b.theme.getTopTab(b.rows[a].tab_text,this.getValidId(b.rows[a].tab_text.textContent)),b.rows[a].tab.addEventListener("click",function(c){b.active_tab=b.rows[a].tab,b.refreshTabs(),c.preventDefault(),c.stopPropagation()}))},addRow:function(a,b,c){var d=this,e=this.rows.length,f="object"===a.schema.type||"array"===a.schema.type;d.rows[e]=a,d.rows[e].rowPane=c,f?(d.addTab(e),d.theme.addTopTab(b,d.rows[e].tab)):"undefined"==typeof d.basicTab?(d.addTab(e),d.basicTab=e,d.basicPane=c,d.theme.addTopTab(b,d.rows[e].tab)):(d.rows[e].tab=d.rows[d.basicTab].tab,d.rows[e].tab_text=d.rows[d.basicTab].tab_text,d.rows[e].rowPane=d.rows[d.basicTab].rowPane)},refreshTabs:function(a){var b=this,c="undefined"!=typeof b.basicTab,d=!1;f(this.rows,function(e,f){f.tab&&f.rowPane&&f.rowPane.parentNode&&(c&&f.tab==b.rows[b.basicTab].tab&&d||(a?f.tab_text.textContent=f.getHeaderText():(c&&f.tab==b.rows[b.basicTab].tab&&(d=!0),f.tab===b.active_tab?b.theme.markTabActive(f):b.theme.markTabInactive(f))))})},build:function(){var a=this,b="categories"===this.format;if(this.rows=[],this.active_tab=null,this.options.table_row)this.editor_holder=this.container,f(this.editors,function(b,c){var d=a.theme.getTableCell();a.editor_holder.appendChild(d),c.setContainer(d),c.build(),c.postBuild(),a.editors[b].options.hidden&&(d.style.display="none"),a.editors[b].options.input_width&&(d.style.width=a.editors[b].options.input_width)});else{if(this.options.table)throw"Not supported yet";this.header=document.createElement("span"),this.header.textContent=this.getTitle(),this.title=this.theme.getHeader(this.header),this.container.appendChild(this.title),this.container.style.position="relative",this.editjson_holder=this.theme.getModal(),this.editjson_textarea=this.theme.getTextareaInput(),this.editjson_textarea.style.height="170px",this.editjson_textarea.style.width="300px",this.editjson_textarea.style.display="block",this.editjson_save=this.getButton("Save","save","Save"),this.editjson_save.classList.add("json-editor-btntype-save"),this.editjson_save.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.saveJSON()}),this.editjson_copy=this.getButton("Copy","copy","Copy"),this.editjson_copy.classList.add("json-editor-btntype-copy"),this.editjson_copy.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.copyJSON()}),this.editjson_cancel=this.getButton("Cancel","cancel","Cancel"),this.editjson_cancel.classList.add("json-editor-btntype-cancel"),this.editjson_cancel.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.hideEditJSON()}),this.editjson_holder.appendChild(this.editjson_textarea),this.editjson_holder.appendChild(this.editjson_save),this.editjson_holder.appendChild(this.editjson_copy),this.editjson_holder.appendChild(this.editjson_cancel),this.addproperty_holder=this.theme.getModal(),this.addproperty_list=document.createElement("div"),this.addproperty_list.style.width="295px",this.addproperty_list.style.maxHeight="160px",this.addproperty_list.style.padding="5px 0",this.addproperty_list.style.overflowY="auto",this.addproperty_list.style.overflowX="hidden",this.addproperty_list.style.paddingLeft="5px",this.addproperty_list.setAttribute("class","property-selector"),this.addproperty_add=this.getButton("add","add","add"),this.addproperty_add.classList.add("json-editor-btntype-add"),this.addproperty_input=this.theme.getFormInputField("text"),this.addproperty_input.setAttribute("placeholder","Property name..."),this.addproperty_input.style.width="220px",this.addproperty_input.style.marginBottom="0",this.addproperty_input.style.display="inline-block",this.addproperty_add.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),a.addproperty_input.value){if(a.editors[a.addproperty_input.value])return void window.alert("there is already a property with that name");a.addObjectProperty(a.addproperty_input.value),a.editors[a.addproperty_input.value]&&a.editors[a.addproperty_input.value].disable(),a.onChange(!0)}}),this.addproperty_holder.appendChild(this.addproperty_list),this.addproperty_holder.appendChild(this.addproperty_input),this.addproperty_holder.appendChild(this.addproperty_add);var c=document.createElement("div");c.style.clear="both",this.addproperty_holder.appendChild(c),document.addEventListener("click",function(a){!this.addproperty_holder.contains(a.target)&&this.adding_property&&(a.preventDefault(),a.stopPropagation(),this.toggleAddProperty())}.bind(this)),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description),this.container.appendChild(this.description)),this.error_holder=document.createElement("div"),this.container.appendChild(this.error_holder),this.editor_holder=this.theme.getIndentedPanel(),this.container.appendChild(this.editor_holder),this.row_container=this.theme.getGridContainer(),b?(this.tabs_holder=this.theme.getTopTabHolder(this.getValidId(this.schema.title)),this.tabPanesContainer=this.theme.getTopTabContentHolder(this.tabs_holder),this.editor_holder.appendChild(this.tabs_holder)):(this.tabs_holder=this.theme.getTabHolder(this.getValidId(this.schema.title)),this.tabPanesContainer=this.theme.getTabContentHolder(this.tabs_holder),this.editor_holder.appendChild(this.row_container)),f(this.editors,function(c,d){var e=a.theme.getTabContent(),f=a.theme.getGridColumn(),g=!(!d.schema||"object"!==d.schema.type&&"array"!==d.schema.type);if(e.isObjOrArray=g,b){if(g){var h=a.theme.getGridContainer();h.appendChild(f),e.appendChild(h),a.tabPanesContainer.appendChild(e),a.row_container=h}else"undefined"==typeof a.row_container_basic&&(a.row_container_basic=a.theme.getGridContainer(),e.appendChild(a.row_container_basic),0==a.tabPanesContainer.childElementCount?a.tabPanesContainer.appendChild(e):a.tabPanesContainer.insertBefore(e,a.tabPanesContainer.childNodes[1])),a.row_container_basic.appendChild(f);a.addRow(d,a.tabs_holder,e),e.id=a.getValidId(d.schema.title)}else a.row_container.appendChild(f);d.setContainer(f),d.build(),d.postBuild()}),this.rows[0]&&g(this.rows[0].tab,"click"),this.title_controls=this.theme.getHeaderButtonHolder(),this.editjson_controls=this.theme.getHeaderButtonHolder(),this.addproperty_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.title.appendChild(this.editjson_controls),this.title.appendChild(this.addproperty_controls),this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.editor_holder.style.display="",a.collapsed=!1,a.setButtonText(a.toggle_button,"","collapse",a.translate("button_collapse"))):(a.editor_holder.style.display="none",a.collapsed=!0,a.setButtonText(a.toggle_button,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.editjson_button=this.getButton("JSON","edit","Edit JSON"),this.editjson_button.classList.add("json-editor-btntype-editjson"),this.editjson_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.toggleEditJSON()}),this.editjson_controls.appendChild(this.editjson_button),this.editjson_controls.appendChild(this.editjson_holder),this.schema.options&&"undefined"!=typeof this.schema.options.disable_edit_json?this.schema.options.disable_edit_json&&(this.editjson_button.style.display="none"):this.jsoneditor.options.disable_edit_json&&(this.editjson_button.style.display="none"),this.addproperty_button=this.getButton("Properties","edit","Object Properties"),this.addproperty_button.classList.add("json-editor-btntype-properties"),this.addproperty_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.toggleAddProperty()}),this.addproperty_controls.appendChild(this.addproperty_button),this.addproperty_controls.appendChild(this.addproperty_holder),this.refreshAddProperties()}this.options.table_row?(this.editor_holder=this.container,f(this.property_order,function(b,c){a.editor_holder.appendChild(a.editors[c].container)})):(this.layoutEditors(),this.layoutEditors())},showEditJSON:function(){this.editjson_holder&&(this.hideAddProperty(),this.editjson_holder.style.left=this.editjson_button.offsetLeft+"px",this.editjson_holder.style.top=this.editjson_button.offsetTop+this.editjson_button.offsetHeight+"px",this.editjson_textarea.value=JSON.stringify(this.getValue(),null,2),this.disable(),this.editjson_holder.style.display="",this.editjson_button.disabled=!1,this.editing_json=!0)},hideEditJSON:function(){this.editjson_holder&&this.editing_json&&(this.editjson_holder.style.display="none",this.enable(),this.editing_json=!1)},copyJSON:function(){if(this.editjson_holder){var a=document.createElement("textarea");a.value=this.editjson_textarea.value,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}},saveJSON:function(){if(this.editjson_holder)try{var a=JSON.parse(this.editjson_textarea.value);this.setValue(a),this.hideEditJSON(),this.onChange(!0)}catch(b){throw window.alert("invalid JSON"),b}},toggleEditJSON:function(){this.editing_json?this.hideEditJSON():this.showEditJSON()},insertPropertyControlUsingPropertyOrder:function(a,b,c){var d;this.schema.properties[a]&&(d=this.schema.properties[a].propertyOrder),"number"!=typeof d&&(d=1e3),b.propertyOrder=d;for(var e=0;e=this.schema.maxProperties),this.addproperty_checkboxes&&(this.addproperty_list.innerHTML=""),this.addproperty_checkboxes={};for(a in this.cached_editors)this.cached_editors.hasOwnProperty(a)&&(this.addPropertyCheckbox(a),this.isRequired(this.cached_editors[a])&&a in this.editors&&(this.addproperty_checkboxes[a].disabled=!0),"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):a in this.editors?(e=!0,c=!0):b||this.schema.properties.hasOwnProperty(a)?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0);this.canHaveAdditionalProperties()&&(e=!0);for(a in this.schema.properties)this.schema.properties.hasOwnProperty(a)&&(this.cached_editors[a]||(e=!0,this.addPropertyCheckbox(a)));e?this.canHaveAdditionalProperties()?b?this.addproperty_add.disabled=!1:this.addproperty_add.disabled=!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},isRequired:function(a){return"boolean"==typeof a.schema.required?a.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(a.key)>-1:!!this.jsoneditor.options.required_by_default},setValue:function(a,b){var c=this;a=a||{},("object"!=typeof a||Array.isArray(a))&&(a={}),f(this.cached_editors,function(d,e){"undefined"!=typeof a[d]?(c.addObjectProperty(d),e.setValue(a[d],b)):b||c.isRequired(e)?e.setValue(e.getDefault(),b):c.removeObjectProperty(d)}),f(a,function(a,d){c.cached_editors[a]||(c.addObjectProperty(a),c.editors[a]&&c.editors[a].setValue(d,b))}),this.refreshValue(),this.layoutEditors(),this.onChange()},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";this.options.table_row&&(c.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),f(this.editors,function(a,b){b.showValidationErrors(d)})}}),h.defaults.editors.array=h.AbstractEditor.extend({askConfirmation:function(){return this.jsoneditor.options.prompt_before_delete!==!0||confirm("Are you sure you want to remove this node?")!==!1},getDefault:function(){return this.schema["default"]||[]},register:function(){if(this._super(),this.rows)for(var a=0;a=this.schema.items.length?this.schema.additionalItems===!0?{}:this.schema.additionalItems?e({},this.schema.additionalItems):void 0:e({},this.schema.items[a]):this.schema.items?e({},this.schema.items):{}},getItemInfo:function(a){var b=this.getItemSchema(a);this.item_info=this.item_info||{};var c=JSON.stringify(b);return"undefined"!=typeof this.item_info[c]?this.item_info[c]:(b=this.jsoneditor.expandRefs(b),this.item_info[c]={title:b.title||"item","default":b["default"],width:12,child_editors:b.properties||b.items},this.item_info[c])},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c=this.jsoneditor.expandRefs(c),c.title=b.title+" "+(a+1);var d,e=this.jsoneditor.getEditorClass(c);this.tabs_holder?(d="tabs-top"===this.schema.format?this.theme.getTopTabContent():this.theme.getTabContent(),d.id=this.path+"."+a):d=b.child_editors?this.theme.getChildEditorHolder():this.theme.getIndentedPanel(),this.row_holder.appendChild(d);var f=this.jsoneditor.createEditor(e,{jsoneditor:this.jsoneditor,schema:c,container:d,path:this.path+"."+a,parent:this,required:!0});return f.preBuild(),f.build(),f.postBuild(),f.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode&&this.controls.parentNode.removeChild(this.controls),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this.rows=this.row_cache=this.title=this.description=this.row_holder=this.panel=this.controls=null,this._super()},empty:function(a){if(this.rows){var b=this;f(this.rows,function(c,d){a&&(d.tab&&d.tab.parentNode&&d.tab.parentNode.removeChild(d.tab),b.destroyRow(d,!0),b.row_cache[c]=null),b.rows[c]=null}),b.rows=[],a&&(b.row_cache=[])}},destroyRow:function(a,b){var c=a.container;b?(a.destroy(),c.parentNode&&c.parentNode.removeChild(c),a.tab&&a.tab.parentNode&&a.tab.parentNode.removeChild(a.tab)):(a.tab&&(a.tab.style.display="none"),c.style.display="none",a.unregister())},getMax:function(){return Array.isArray(this.schema.items)&&this.schema.additionalItems===!1?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(a){var b=this;f(this.rows,function(c,d){d.tab&&(a?d.tab_text.textContent=d.getHeaderText():d.tab===b.active_tab?b.theme.markTabActive(d):b.theme.markTabInactive(d))})},setValue:function(a,b){a=a||[],Array.isArray(a)||(a=[a]);var c=JSON.stringify(a);if(c!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var d=this;f(a,function(a,c){d.rows[a]?d.rows[a].setValue(c,b):d.row_cache[a]?(d.rows[a]=d.row_cache[a],d.rows[a].setValue(c,b),d.rows[a].container.style.display="",d.rows[a].tab&&(d.rows[a].tab.style.display=""),d.rows[a].register()):d.addRow(c,b)});for(var e=a.length;e=this.rows.length;f(this.rows,function(a,c){c.movedown_button&&(a===b.rows.length-1?c.movedown_button.style.display="none":c.movedown_button.style.display=""),c.delete_button&&(d?c.delete_button.style.display="none":c.delete_button.style.display=""),b.value[a]=c.getValue()});var e=!1;this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",d||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0)):(d||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0),d||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",e=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.getMax()&&this.getMax()<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",e=!0),!this.collapsed&&e?this.controls.style.display="inline-block":this.controls.style.display="none"}},addRow:function(a,b){var c=this,d=this.rows.length;c.rows[d]=this.getElementEditor(d),c.row_cache[d]=c.rows[d],c.tabs_holder&&(c.rows[d].tab_text=document.createElement("span"),c.rows[d].tab_text.textContent=c.rows[d].getHeaderText(),"tabs-top"===c.schema.format?(c.rows[d].tab=c.theme.getTopTab(c.rows[d].tab_text,this.getValidId(c.rows[d].path)),c.theme.addTopTab(c.tabs_holder,c.rows[d].tab)):(c.rows[d].tab=c.theme.getTab(c.rows[d].tab_text,this.getValidId(c.rows[d].path)),c.theme.addTab(c.tabs_holder,c.rows[d].tab)),c.rows[d].tab.addEventListener("click",function(a){c.active_tab=c.rows[d].tab,c.refreshTabs(),a.preventDefault(),a.stopPropagation()}));var e=c.rows[d].title_controls||c.rows[d].array_controls;c.hide_delete_buttons||(c.rows[d].delete_button=this.getButton(c.getItemTitle(),"delete",this.translate("button_delete_row_title",[c.getItemTitle()])),c.rows[d].delete_button.classList.add("delete","json-editor-btntype-delete"),c.rows[d].delete_button.setAttribute("data-i",d),c.rows[d].delete_button.addEventListener("click",function(a){if(a.preventDefault(),a.stopPropagation(),!c.askConfirmation())return!1;var b=1*this.getAttribute("data-i"),d=c.getValue(),e=[],g=null;f(d,function(a,c){a!==b&&e.push(c)}),c.empty(!0),c.setValue(e),c.rows[b]?g=c.rows[b].tab:c.rows[b-1]&&(g=c.rows[b-1].tab),g&&(c.active_tab=g,c.refreshTabs()),c.onChange(!0),c.jsoneditor.trigger("deleteRow")}),e&&e.appendChild(c.rows[d].delete_button)),c.show_copy_button&&(c.rows[d].copy_button=this.getButton(c.getItemTitle(),"copy","Copy "+c.getItemTitle()),c.rows[d].copy_button.classList.add("copy","json-editor-btntype-copy"),c.rows[d].copy_button.setAttribute("data-i",d),c.rows[d].copy_button.addEventListener("click",function(a){var b=c.getValue();a.preventDefault(),a.stopPropagation();var d=1*this.getAttribute("data-i");f(b,function(a,c){a===d&&b.push(c)}),c.setValue(b),c.refreshValue(!0),c.onChange(!0)}),e.appendChild(c.rows[d].copy_button)),d&&!c.hide_move_buttons&&(c.rows[d].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),c.rows[d].moveup_button.classList.add("moveup","json-editor-btntype-move"),c.rows[d].moveup_button.setAttribute("data-i",d),c.rows[d].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i");if(!(b<=0)){var d=c.getValue(),e=d[b-1];d[b-1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b-1].tab,c.refreshTabs(),c.onChange(!0),c.jsoneditor.trigger("moveRow")}}),e&&e.appendChild(c.rows[d].moveup_button)),c.hide_move_buttons||(c.rows[d].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),c.rows[d].movedown_button.classList.add("movedown","json-editor-btntype-move"),c.rows[d].movedown_button.setAttribute("data-i",d),c.rows[d].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i"),d=c.getValue();if(!(b>=d.length-1)){var e=d[b+1];d[b+1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b+1].tab,c.refreshTabs(),c.onChange(!0),c.jsoneditor.trigger("moveRow")}}),e&&e.appendChild(c.rows[d].movedown_button)),a&&c.rows[d].setValue(a,b),c.refreshTabs()},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls.appendChild(this.toggle_button);var b=a.row_holder.style.display,c=a.controls.style.display;this.toggle_button.addEventListener("click",function(d){d.preventDefault(),d.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel&&(a.panel.style.display=""),a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.row_holder.style.display="none",a.tabs_holder&&(a.tabs_holder.style.display="none"),a.controls.style.display="none",a.panel&&(a.panel.style.display="none"),a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.add_row_button=this.getButton(this.getItemTitle(),"add",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.classList.add("json-editor-btntype-add"),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation();var c=a.rows.length;a.row_cache[c]?(a.rows[c]=a.row_cache[c],a.rows[c].setValue(a.rows[c].getDefault(),!0),a.rows[c].container.style.display="",a.rows[c].tab&&(a.rows[c].tab.style.display=""),a.rows[c].register()):a.addRow(),a.active_tab=a.rows[c].tab,a.refreshTabs(),a.refreshValue(),a.onChange(!0),a.jsoneditor.trigger("addRow")}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.classList.add("json-editor-btntype-deletelast"),this.delete_last_row_button.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),!a.askConfirmation())return!1;var c=a.getValue(),d=null;c.pop(),a.empty(!0),a.setValue(c),a.rows[a.rows.length-1]&&(d=a.rows[a.rows.length-1].tab),d&&(a.active_tab=d,a.refreshTabs()),a.onChange(!0),a.jsoneditor.trigger("deleteRow")}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")),this.remove_all_rows_button.classList.add("json-editor-btntype-deleteall"),this.remove_all_rows_button.addEventListener("click",function(b){return b.preventDefault(),b.stopPropagation(),!!a.askConfirmation()&&(a.empty(!0),a.setValue([]),a.onChange(!0),void a.jsoneditor.trigger("deleteAllRows"))}),a.controls.appendChild(this.remove_all_rows_button),a.tabs&&(this.add_row_button.style.width="100%",this.add_row_button.style.textAlign="left",this.add_row_button.style.marginBottom="3px",this.delete_last_row_button.style.width="100%",this.delete_last_row_button.style.textAlign="left",this.delete_last_row_button.style.marginBottom="3px",this.remove_all_rows_button.style.width="100%",this.remove_all_rows_button.style.textAlign="left",this.remove_all_rows_button.style.marginBottom="3px")},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";f(this.rows,function(a,b){b.showValidationErrors(d)})}}),h.defaults.editors.table=h.defaults.editors.array.extend({register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var c=JSON.stringify(a);if(c!==this.serialized){var d=!1,e=this;f(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):(e.addRow(b),d=!0)});for(var g=a.length;g=this.rows.length,c=!1;f(this.rows,function(d,e){e.movedown_button&&(d===a.rows.length-1?e.movedown_button.style.display="none":(c=!0,e.movedown_button.style.display="")),e.delete_button&&(b?e.delete_button.style.display="none":(c=!0,e.delete_button.style.display="")),e.moveup_button&&(c=!0)}),f(this.rows,function(a,b){c?b.controls_cell.style.display="":b.controls_cell.style.display="none"}),c?this.controls_header_cell.style.display="":this.controls_header_cell.style.display="none";var d=!1;this.value.length?1===this.value.length?(this.table.style.display="",this.remove_all_rows_button.style.display="none",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",d=!0)):(this.table.style.display="",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",d=!0),b||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",d=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.schema.maxItems&&this.schema.maxItems<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",d=!0),d?this.controls.style.display="":this.controls.style.display="none"},refreshValue:function(){var a=this;this.value=[],f(this.rows,function(b,c){a.value[b]=c.getValue()}),this.serialized=JSON.stringify(this.value)},addRow:function(a){var b=this,c=this.rows.length;b.rows[c]=this.getElementEditor(c);var d=b.rows[c].table_controls;this.hide_delete_buttons||(b.rows[c].delete_button=this.getButton("","delete",this.translate("button_delete_row_title_short")),b.rows[c].delete_button.classList.add("delete","json-editor-btntype-delete"),b.rows[c].delete_button.setAttribute("data-i",c),b.rows[c].delete_button.addEventListener("click",function(a){if(a.preventDefault(),a.stopPropagation(),!b.askConfirmation())return!1;var c=1*this.getAttribute("data-i"),d=b.getValue(),e=[];f(d,function(a,b){a!==c&&e.push(b)}),b.setValue(e),b.onChange(!0)}),d.appendChild(b.rows[c].delete_button)),c&&!this.hide_move_buttons&&(b.rows[c].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),b.rows[c].moveup_button.classList.add("moveup","json-editor-btntype-move"),b.rows[c].moveup_button.setAttribute("data-i",c),b.rows[c].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(c<=0)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),d.appendChild(b.rows[c].moveup_button)),this.hide_move_buttons||(b.rows[c].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),b.rows[c].movedown_button.classList.add("movedown","json-editor-btntype-move"),b.rows[c].movedown_button.setAttribute("data-i",c),b.rows[c].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),d.appendChild(b.rows[c].movedown_button)),a&&b.rows[c].setValue(a)},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls&&(this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel.style.display="",a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.panel.style.display="none",a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none")),this.add_row_button=this.getButton(this.getItemTitle(),"add",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.classList.add("json-editor-btntype-add"),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.addRow(),a.refreshValue(),a.refreshRowButtons(),a.onChange(!0)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.classList.add("json-editor-btntype-deletelast"),this.delete_last_row_button.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),!a.askConfirmation())return!1;var c=a.getValue();c.pop(),a.setValue(c),a.onChange(!0)}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")), +this.remove_all_rows_button.classList.add("json-editor-btntype-deleteall"),this.remove_all_rows_button.addEventListener("click",function(b){return b.preventDefault(),b.stopPropagation(),!!a.askConfirmation()&&(a.setValue([]),void a.onChange(!0))}),a.controls.appendChild(this.remove_all_rows_button)}}),h.defaults.editors.multiple=h.AbstractEditor.extend({register:function(){if(this.editors){for(var a=0;anull";if("object"==typeof a){var c="";return f(a,function(d,e){var f=b.getHTML(e);Array.isArray(a)||(f="
        "+d+": "+f+"
        "),c+="
      • "+f+"
      • "}),c=Array.isArray(a)?"
          "+c+"
        ":"
          "+c+"
        "}return"boolean"==typeof a?a?"true":"false":"string"==typeof a?a.replace(/&/g,"&").replace(//g,">"):a},setValue:function(a){this.value!==a&&(this.value=a,this.refreshValue(),this.onChange())},destroy:function(){this.display_area&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),h.defaults.editors.select=h.AbstractEditor.extend({setValue:function(a,b){a=this.typecast(a||"");var c=a;this.enum_values.indexOf(c)<0&&(c=this.enum_values[0]),this.value!==c&&(b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.input.value=this.enum_options[this.enum_values.indexOf(c)],this.select2&&(this.select2v4?this.select2.val(this.input.value).trigger("change"):this.select2.select2("val",this.input.value)),this.value=c,this.onChange(),this.change())},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){if(!this.enum_options)return 3;for(var a=this.getTitle().length,b=0;b2||this.enum_options.length&&this.enumSource)){var a=e({},h.plugins.select2);this.schema.options&&this.schema.options.select2_options&&(a=e(a,this.schema.options.select2_options)),this.select2=window.jQuery(this.input).select2(a),this.select2v4=this.select2.select2.hasOwnProperty("amd");var b=this;this.select2.on("select2-blur",function(){b.select2v4?b.input.value=b.select2.val():b.input.value=b.select2.select2("val"),b.onInputChange()}),this.select2.on("change",function(){b.select2v4?b.input.value=b.select2.val():b.input.value=b.select2.select2("val"),b.onInputChange()})}else this.select2=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelect2()},onWatchedFieldChange:function(){var a,b;if(this.enumSource){a=this.getWatchedFieldValues();for(var c=[],d=[],e=0;e=2||this.enum_options.length&&this.enumSource)){var c=e({},h.plugins.selectize);this.schema.options&&this.schema.options.selectize_options&&(c=e(c,this.schema.options.selectize_options)),this.selectize=window.jQuery(this.input).selectize(e(c,{create:c.create===b||c.create,onChange:function(){a.onInputChange()}}))}else this.selectize=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelectize()},onWatchedFieldChange:function(){var a,c;if(this.enumSource){a=this.getWatchedFieldValues();for(var d=[],e=[],f=0;f1&&a.schema.options&&a.schema.options.multiple&&1==a.schema.options.multiple&&a.parent&&"object"==a.parent.schema.type&&a.parent.parent&&"array"==a.parent.parent.schema.type){a.arrayEditor=a.jsoneditor.getEditor(a.parent.parent.path),a.value=a.arrayEditor.getValue(),a.total=this.files.length,a.current_item_index=parseInt(a.parent.key),a.count=a.current_item_index;for(var c=0;cType: "+a+", Size: "+Math.floor((this.value.length-this.value.split(",")[0].length-1)/1.33333)+" bytes","image"===a.substr(0,5)){this.preview.innerHTML+="
        ";var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.src=this.value,this.preview.appendChild(b)}}else this.preview.innerHTML="Invalid data URI"}},enable:function(){this.always_disabled||(this.uploader&&(this.uploader.disabled=!1),this._super())},disable:function(a){a&&(this.always_disabled=!0),this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.refreshPreview(),this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),h.defaults.editors.upload=h.AbstractEditor.extend({getNumColumns:function(){return 4},build:function(){var a=this;if(this.title=this.header=this.label=this.theme.getFormInputLabel(this.getTitle()),this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input),!this.schema.readOnly&&!this.schema.readonly){if(!this.jsoneditor.options.upload)throw"Upload handler required for upload editor";this.uploader=this.theme.getFormInputField("file"),this.uploader.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),this.files&&this.files.length){var c=new FileReader;c.onload=function(b){a.preview_value=b.target.result,a.refreshPreview(),a.onChange(!0),c=null},c.readAsDataURL(this.files[0])}})}var b=this.schema.description;b||(b=""),this.preview=this.theme.getFormInputDescription(b),this.container.appendChild(this.preview),this.control=this.theme.getFormControl(this.label,this.uploader||this.input,this.preview),this.container.appendChild(this.control),window.requestAnimationFrame(function(){if(a.value){var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.onload=function(c){a.preview.appendChild(b)},b.onerror=function(a){console.error("upload error",a)},b.src=a.container.querySelector("a").href}})},refreshPreview:function(){if(this.last_preview!==this.preview_value&&(this.last_preview=this.preview_value,this.preview.innerHTML="",this.preview_value)){var a=this,b=this.preview_value.match(/^data:([^;,]+)[;,]/);b&&(b=b[1]),b||(b="unknown");var c=this.uploader.files[0];if(this.preview.innerHTML="Type: "+b+", Size: "+c.size+" bytes","image"===b.substr(0,5)){this.preview.innerHTML+="
        ";var d=document.createElement("img");d.style.maxWidth="100%",d.style.maxHeight="100px",d.src=this.preview_value,this.preview.appendChild(d)}this.preview.innerHTML+="
        ";var e=this.getButton("Upload","upload","Upload");this.preview.appendChild(e),e.addEventListener("click",function(b){b.preventDefault(),e.setAttribute("disabled","disabled"),a.theme.removeInputError(a.uploader),a.theme.getProgressBar&&(a.progressBar=a.theme.getProgressBar(),a.preview.appendChild(a.progressBar)),a.jsoneditor.options.upload(a.path,c,{success:function(b){a.setValue(b),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(), +a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},failure:function(b){a.theme.addInputError(a.uploader,b),a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},updateProgress:function(b){a.progressBar&&(b?a.theme.updateProgressBar(a.progressBar,b):a.theme.updateProgressBarUnknown(a.progressBar))}})}),(this.jsoneditor.options.auto_upload||this.schema.options.auto_upload)&&(e.dispatchEvent(new MouseEvent("click")),this.preview.removeChild(e))}},enable:function(){this.always_disabled||(this.uploader&&(this.uploader.disabled=!1),this._super())},disable:function(a){a&&(this.always_disabled=!0),this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),h.defaults.editors.checkbox=h.AbstractEditor.extend({setValue:function(a,b){this.value=!!a,this.input.checked=this.value,this.onChange()},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){return Math.min(12,Math.max(this.getTitle().length/7,2))},build:function(){var a=this;this.options.compact||(this.label=this.header=this.theme.getCheckboxLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.options.compact&&this.container.classList.add("compact"),this.input=this.theme.getCheckbox(),this.control=this.theme.getFormControl(this.label,this.input,this.description,this.infoButton),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(b){b.preventDefault(),b.stopPropagation(),a.value=this.checked,a.onChange(!0)}),this.container.appendChild(this.control)},enable:function(){this.always_disabled||(this.input.disabled=!1,this._super())},disable:function(a){a&&(this.always_disabled=!0),this.input.disabled=!0,this._super()},destroy:function(){this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];f(a,function(a,d){d.path===b.path&&c.push(d.message)}),this.input.controlgroup=this.control,c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),h.defaults.editors.arraySelectize=h.AbstractEditor.extend({build:function(){this.title=this.theme.getFormInputLabel(this.getTitle()),this.title_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.error_holder=document.createElement("div"),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description)),this.input=document.createElement("select"),this.input.setAttribute("multiple","multiple");var a=this.theme.getFormControl(this.title,this.input,this.description);this.container.appendChild(a),this.container.appendChild(this.error_holder),window.jQuery(this.input).selectize({delimiter:!1,createOnBlur:!0,create:!0})},postBuild:function(){var a=this;this.input.selectize.on("change",function(b){a.refreshValue(),a.onChange(!0)})},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},empty:function(a){},setValue:function(a,b){var c=this;a=a||[],Array.isArray(a)||(a=[a]),this.input.selectize.clearOptions(),this.input.selectize.clear(!0),a.forEach(function(a){c.input.selectize.addOption({text:a,value:a})}),this.input.selectize.setValue(a),this.refreshValue(b)},refreshValue:function(a){this.value=this.input.selectize.getValue()},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none"}}),h.defaults.editors.starrating=h.defaults.editors.string.extend({build:function(){var a=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.options.compact&&this.container.classList.add("compact"),this.ratingContainer=document.createElement("div"),this.ratingContainer.classList.add("starrating"),this.enum_values=this.schema["enum"],this.radioGroup=[];for(var b=function(b){b.preventDefault(),b.stopPropagation(),a.setValue(this.value),a.onChange(!0)},c=this.enum_values.length-1;c>-1;c--){var d=this.key+"-"+c,e=this.theme.getFormInputField("radio");e.name=this.formname+"[starrating]",e.value=this.enum_values[c],e.id=d,e.addEventListener("change",b,!1),this.radioGroup.push(e);var f=document.createElement("label");f.htmlFor=d,f.title=this.enum_values[c],this.options.displayValue&&f.classList.add("starrating-display-enabled"),this.ratingContainer.appendChild(e),this.ratingContainer.appendChild(f)}if(this.options.displayValue&&(this.displayRating=document.createElement("div"),this.displayRating.classList.add("starrating-display"),this.displayRating.innerText=this.enum_values[0],this.ratingContainer.appendChild(this.displayRating)),this.schema.readOnly||this.schema.readonly){this.always_disabled=!0;for(var g=0;c0){var d=new Date(1e3*a),e=d.getFullYear(),f=this.zeroPad(d.getMonth()+1),g=this.zeroPad(d.getDate()),h=this.zeroPad(d.getHours()),i=this.zeroPad(d.getMinutes()),j=this.zeroPad(d.getSeconds()),k=[e,f,g].join("-"),l=[h,i,j].join(":"),m=k+" "+l;"date"==this.schema.format?m=k:"time"==this.schema.format&&(m=l),this.input.value=m,this.flatpickr&&this.flatpickr.setDate(m)}},destroy:function(){this.flatpickr&&this.flatpickr.destroy(),this.flatpickr=null,this._super()},zeroPad:function(a){return("0"+a).slice(-2)}}),h.defaults.editors.signature=h.defaults.editors.string.extend({build:function(){var a=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description));var b=this.formname.replace(/\W/g,"");if("function"==typeof SignaturePad){var c="json-editor-style-signature";document.getElementById(c);this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input);var d=document.createElement("div");d.classList.add("signature-container");var e=document.createElement("canvas");e.setAttribute("name",b),e.classList.add("signature"),d.appendChild(e),a.signaturePad=new window.SignaturePad(e,{onEnd:function(){a.signaturePad.isEmpty()?a.input.value="":a.input.value=a.signaturePad.toDataURL(),a.is_dirty=!0,a.refreshValue(),a.watch_listener(),a.jsoneditor.notifyWatchers(a.path),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}});var g=document.createElement("div"),h=document.createElement("button");h.classList.add("tiny","button"),h.innerHTML="Clear signature",g.appendChild(h),d.appendChild(g),this.options.compact&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact"),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,f(this.inputs,function(a,b){e.setAttribute("readOnly","readOnly"),b.disabled=!0})),h.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.signaturePad.clear(),a.signaturePad.strokeEnd()}),this.control=this.theme.getFormControl(this.label,d,this.description),this.container.appendChild(this.control),this.refreshValue(),e.width=d.offsetWidth,a.options&&a.options.canvas_height?e.height=a.options.canvas_height:e.height="300"}else{var i=document.createElement("p");i.innerHTML="Signature pad is not available, please include SignaturePad from https://github.com/szimek/signature_pad",this.container.appendChild(i)}},setValue:function(a){var b=this;if("function"==typeof SignaturePad){var c=(this.formname.replace(/\W/g,""),this.sanitize(a));if(this.value===c)return;return b.value=c,b.input.value=b.value,b.signaturePad.clear(),a&&""!=a&&b.signaturePad.fromDataURL(a),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),!1}},destroy:function(){var a=this;this.formname.replace(/\W/g,"");a.signaturePad.off(),delete a.signaturePad}});var i=function(){var a=document.documentElement;return a.matches?"matches":a.webkitMatchesSelector?"webkitMatchesSelector":a.mozMatchesSelector?"mozMatchesSelector":a.msMatchesSelector?"msMatchesSelector":a.oMatchesSelector?"oMatchesSelector":void 0}();return h.AbstractTheme=c.extend({getContainer:function(){return document.createElement("div")},getFloatRightLinkHolder:function(){var a=document.createElement("div");return a.style=a.style||{},a.style.cssFloat="right",a.style.marginLeft="10px",a},getModal:function(){var a=document.createElement("div");return a.style.backgroundColor="white",a.style.border="1px solid black",a.style.boxShadow="3px 3px black",a.style.position="absolute",a.style.zIndex="10",a.style.display="none",a},getGridContainer:function(){var a=document.createElement("div");return a},getGridRow:function(){var a=document.createElement("div");return a.classList.add("row"),a},getGridColumn:function(){var a=document.createElement("div");return a},setGridColumnSize:function(a,b){},getLink:function(a){var b=document.createElement("a");return b.setAttribute("href","#"),b.appendChild(document.createTextNode(a)),b},disableHeader:function(a){a.style.color="#ccc"},disableLabel:function(a){a.style.color="#ccc"},enableHeader:function(a){a.style.color=""},enableLabel:function(a){a.style.color=""},getInfoButton:function(a){var b=document.createElement("span");b.innerText="ⓘ",b.style.fontSize="16px",b.style.fontWeight="bold",b.style.padding=".25rem",b.style.position="relative",b.style.display="inline-block";var c=document.createElement("span");return c.style.fontSize="12px",b.style.fontWeight="normal",c.style["font-family"]="sans-serif",c.style.visibility="hidden",c.style["background-color"]="rgba(50, 50, 50, .75)",c.style.margin="0 .25rem",c.style.color="#FAFAFA",c.style.padding=".5rem 1rem",c.style["border-radius"]=".25rem",c.style.width="20rem",c.style.position="absolute",c.innerText=a,b.onmouseover=function(){c.style.visibility="visible"},b.onmouseleave=function(){c.style.visibility="hidden"},b.appendChild(c),b},getFormInputLabel:function(a){var b=document.createElement("label");return b.appendChild(document.createTextNode(a)),b},getCheckboxLabel:function(a){var b=this.getFormInputLabel(a);return b.style.fontWeight="normal",b},getHeader:function(a){var b=document.createElement("h3");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getCheckbox:function(){var a=this.getFormInputField("checkbox");return a.style.display="inline-block",a.style.width="auto",a},getMultiCheckboxHolder:function(a,b,c){var d=document.createElement("div");b&&(b.style.display="block",d.appendChild(b));for(var e in a)a.hasOwnProperty(e)&&(a[e].style.display="inline-block",a[e].style.marginRight="20px",d.appendChild(a[e]));return c&&d.appendChild(c),d},getSelectInput:function(a){var b=document.createElement("select");return a&&this.setSelectOptions(b,a),b},getSwitcher:function(a){var b=this.getSelectInput(a);return b.style.backgroundColor="transparent",b.style.display="inline-block",b.style.fontStyle="italic",b.style.fontWeight="normal",b.style.height="auto",b.style.marginBottom=0,b.style.marginLeft="5px",b.style.padding="0 0 0 3px",b.style.width="auto",b},getSwitcherOptions:function(a){return a.getElementsByTagName("option")},setSwitcherOptions:function(a,b,c){this.setSelectOptions(a,b,c)},setSelectOptions:function(a,b,c){c=c||[],a.innerHTML="";for(var d=0;d
        ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
        ",c},applyStyles:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a.style[c]=b[c])},closest:function(a,b){for(;a&&a!==document;){if(!a[i])return!1;if(a[i](b))return a;a=a.parentNode}return!1},insertBasicTopTab:function(a,b){b.firstChild.insertBefore(a,b.firstChild.firstChild)},getTab:function(a,b){var c=document.createElement("div");return c.appendChild(a),c.id=b,c.style=c.style||{},this.applyStyles(c,{border:"1px solid #ccc",borderWidth:"1px 0 1px 1px",textAlign:"center",lineHeight:"30px",borderRadius:"5px",borderBottomRightRadius:0,borderTopRightRadius:0,fontWeight:"bold",cursor:"pointer"}),c},getTopTab:function(a,b){var c=document.createElement("div");return c.id=b,c.appendChild(a),c.style=c.style||{},this.applyStyles(c,{"float":"left",border:"1px solid #ccc",borderWidth:"1px 1px 0px 1px",textAlign:"center",lineHeight:"30px",borderRadius:"5px",paddingLeft:"5px",paddingRight:"5px",borderBottomRightRadius:0,borderBottomLeftRadius:0,fontWeight:"bold",cursor:"pointer"}),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){return this.getIndentedPanel()},getTopTabContent:function(){return this.getTopIndentedPanel()},markTabActive:function(a){this.applyStyles(a.tab,{opacity:1,background:"white"}),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){this.applyStyles(a.tab,{opacity:.5,background:""}),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)},getBlockLink:function(){var a=document.createElement("a");return a.style.display="block",a},getBlockLinkHolder:function(){var a=document.createElement("div");return a},getLinksHolder:function(){var a=document.createElement("div");return a},createMediaLink:function(a,b,c){a.appendChild(b),c.style.width="100%",a.appendChild(c)},createImageLink:function(a,b,c){a.appendChild(b),b.appendChild(c)},getFirstTab:function(a){return a.firstChild.firstChild},getInputGroup:function(a,c){return b}}),h.defaults.themes.bootstrap2=h.AbstractTheme.extend({getRangeInput:function(a,b,c){return this._super(a,b,c)},getGridContainer:function(){var a=document.createElement("div");return a.classList.add("container-fluid"),a},getGridRow:function(){var a=document.createElement("div");return a.classList.add("row-fluid"),a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="inline-block",b.style.fontWeight="bold",b},setGridColumnSize:function(a,b){a.classList.add("span"+b)},getSelectInput:function(a){var b=this._super(a);return b.style.width="auto",b.style.maxWidth="98%",b},getFormInputField:function(a){var b=this._super(a);return b.style.width="98%",b},afterInputReady:function(a){if(!a.controlgroup&&(a.controlgroup=this.closest(a,".control-group"),a.controls=this.closest(a,".controls"),this.closest(a,".compact")&&(a.controlgroup.className=a.controlgroup.className.replace(/control-group/g,"").replace(/[ ]{2,}/g," "),a.controls.className=a.controlgroup.className.replace(/controls/g,"").replace(/[ ]{2,}/g," "),a.style.marginBottom=0),this.queuedInputErrorText)){var b=this.queuedInputErrorText;delete this.queuedInputErrorText,this.addInputError(a,b)}},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("well","well-small"),a.style.paddingBottom=0,a},getInfoButton:function(a){var b=document.createElement("span");b.classList.add("icon-info-sign","pull-right"),b.style.padding=".25rem",b.style.position="relative",b.style.display="inline-block";var c=document.createElement("span");return c.style["font-family"]="sans-serif",c.style.visibility="hidden",c.style["background-color"]="rgba(50, 50, 50, .75)",c.style.margin="0 .25rem",c.style.color="#FAFAFA",c.style.padding=".5rem 1rem",c.style["border-radius"]=".25rem",c.style.width="25rem",c.style.transform="translateX(-27rem) translateY(-.5rem)",c.style.position="absolute",c.innerText=a,b.onmouseover=function(){c.style.visibility="visible"},b.onmouseleave=function(){c.style.visibility="hidden"},b.appendChild(c),b},getFormInputDescription:function(a){var b=document.createElement("p");return b.classList.add("help-inline"),b.textContent=a,b},getFormControl:function(a,b,c,d){var e=document.createElement("div");e.classList.add("control-group");var f=document.createElement("div");return f.classList.add("controls"),a&&"checkbox"===b.getAttribute("type")?(e.appendChild(f),a.classList.add("checkbox"),a.appendChild(b),f.appendChild(a),d&&f.appendChild(d),f.style.height="30px"):(a&&(a.classList.add("control-label"),e.appendChild(a)),d&&f.appendChild(d),f.appendChild(b),e.appendChild(f)),c&&f.appendChild(c),e},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.marginLeft="10px",a},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("btn-group"),a},getButton:function(a,b,c){var d=this._super(a,b,c);return d.classList.add("btn","btn-default"),d},getTable:function(){var a=document.createElement("table");return a.classList.add("table","table-bordered"),a.style.width="auto",a.style.maxWidth="none",a},addInputError:function(a,b){return a.controlgroup?void(a.controlgroup&&a.controls&&(a.controlgroup.classList.add("error"),a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("p"),a.errmsg.classList.add("help-block","errormsg"),a.controls.appendChild(a.errmsg)),a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.controlgroup||delete this.queuedInputErrorText,a.errmsg&&(a.errmsg.style.display="none",a.controlgroup.classList.remove("error"))},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("tabbable","tabs-left"),c.innerHTML="
        ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("tabbable","tabs-over"),c.innerHTML="
        ",c},getTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)},getProgressBar:function(){var a=document.createElement("div");a.classList.add("progress");var b=document.createElement("div");return b.classList.add("bar"),b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.classList.add("progress","progress-striped","active"),a.firstChild.style.width="100%")},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-append"),c.appendChild(a);for(var d=0;d
        ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
        ",c},getTab:function(a,b){var c=document.createElement("li");c.setAttribute("role","presentation");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),d.setAttribute("aria-controls",b),d.setAttribute("role","tab"),d.setAttribute("data-toggle","tab"),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.setAttribute("role","presentation");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),d.setAttribute("aria-controls",b),d.setAttribute("role","tab"),d.setAttribute("data-toggle","tab"),c.appendChild(d),c},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},getProgressBar:function(){var a=0,b=100,c=0,d=document.createElement("div");d.classList.add("progress");var e=document.createElement("div");return e.classList.add("progress-bar"),e.setAttribute("role","progressbar"),e.setAttribute("aria-valuenow",c), +e.setAttribute("aria-valuemin",a),e.setAttribute("aria-valuenax",b),e.innerHTML=c+"%",d.appendChild(e),d},updateProgressBar:function(a,b){if(a){var c=a.firstChild,d=b+"%";c.setAttribute("aria-valuenow",b),c.style.width=d,c.innerHTML=d}},updateProgressBarUnknown:function(a){if(a){var b=a.firstChild;a.classList.add("progress","progress-striped","active"),b.removeAttribute("aria-valuenow"),b.style.width="100%",b.innerHTML=""}},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-group"),c.appendChild(a);var d=document.createElement("div");d.classList.add("input-group-btn"),c.appendChild(d);for(var e=0;e
        ",b.classList.add("row"),b},addTab:function(a,b){a.children[0].children[0].appendChild(b)},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
        ",c},getTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.classList.add("nav-link"),d.setAttribute("style","padding:10px;"),d.setAttribute("href","#"+b),d.setAttribute("data-toggle","tab"),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.classList.add("nav-link"),d.setAttribute("href","#"+b),d.setAttribute("data-toggle","tab"),d.appendChild(a),c.appendChild(d),c},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},markTabActive:function(a){a.tab.firstChild.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.firstChild.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},getProgressBar:function(){var a=0,b=100,c=0,d=document.createElement("div");d.classList.add("progress");var e=document.createElement("div");return e.classList.add("progress-bar"),e.setAttribute("role","progressbar"),e.setAttribute("aria-valuenow",c),e.setAttribute("aria-valuemin",a),e.setAttribute("aria-valuenax",b),e.innerHTML=c+"%",d.appendChild(e),d},updateProgressBar:function(a,b){if(a){var c=a.firstChild,d=b+"%";c.setAttribute("aria-valuenow",b),c.style.width=d,c.innerHTML=d}},updateProgressBarUnknown:function(a){if(a){var b=a.firstChild;a.classList.add("progress","progress-striped","active"),b.removeAttribute("aria-valuenow"),b.style.width="100%",b.innerHTML=""}},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-group"),c.appendChild(a);var d=document.createElement("div");d.classList.add("input-group-prepend"),c.appendChild(d);for(var e=0;e'),a.errmsg=a.parentNode.getElementsByClassName("error")[0]),void(a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.group||delete this.queuedInputErrorText,a.errmsg&&(a.group.classList.remove("error"),a.errmsg.style.display="none")},getProgressBar:function(){var a=document.createElement("div");a.classList.add("progress");var b=document.createElement("span");return b.classList.add("meter"),b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.firstChild.style.width="100%")},getInputGroup:function(a,c){if(!a)return b;var d=document.createElement("div");d.classList.add("input-group"),a.classList.add("input-group-field"),d.appendChild(a);for(var e=0;e
        ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("row"),c.innerHTML='
        ',c},setGridColumnSize:function(a,b){var c=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];a.classList.add("columns",c[b])},getTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("content","active"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("content","active"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)}}),h.defaults.themes.foundation4=h.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},setGridColumnSize:function(a,b){a.classList.add("columns","large-"+b)},getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},getFormInputLabel:function(a){var b=this._super(a);return b.style.fontWeight="bold",b}}),h.defaults.themes.foundation5=h.defaults.themes.foundation.extend({getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},setGridColumnSize:function(a,b){a.classList.add("columns","medium-"+b)},getButton:function(a,b,c){var d=this._super(a,b,c);return d.className=d.className.replace(/\s*small/g,"")+" tiny",d},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML='
        ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("row"),c.innerHTML='
        ',c},getTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-content","active"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-content","active"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)}}),h.defaults.themes.foundation6=h.defaults.themes.foundation5.extend({getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("callout","secondary"),a.style="padding-left: 10px; margin-left: 10px;",a},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("button-group","tiny"),a.style.marginBottom=0,a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b},getFormControl:function(a,b,c,d){var e=document.createElement("div");return e.classList.add("form-control"),a&&e.appendChild(a),"checkbox"===b.type?a.insertBefore(b,a.firstChild):a?(d&&a.appendChild(d),a.appendChild(b)):(d&&e.appendChild(d),e.appendChild(b)),c&&a.appendChild(c),e},addInputError:function(a,b){if(a.group){if(a.group.classList.add("error"),a.errmsg)a.errmsg.style.display="",a.className="";else{var c=document.createElement("span");c.classList.add("form-error","is-visible"),a.group.getElementsByTagName("label")[0].appendChild(c),a.classList.add("is-invalid-input"),a.errmsg=c}a.errmsg.textContent=b}},removeInputError:function(a){a.errmsg&&(a.classList.remove("is-invalid-input"),a.errmsg.parentNode&&a.errmsg.parentNode.removeChild(a.errmsg))},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("grid-x"),c.innerHTML='
          ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("grid-y"),c.innerHTML='
            ',c},insertBasicTopTab:function(a,b){b.firstChild.firstChild.insertBefore(a,b.firstChild.firstChild.firstChild)},getTab:function(a,b){var c=document.createElement("li");c.classList.add("tabs-title");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("tabs-title");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1].firstChild},getTopTabContentHolder:function(a){return a.firstChild.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tabs-panel"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tabs-panel"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("is-active"),a.tab.firstChild.setAttribute("aria-selected","true"),"undefined"!=typeof a.rowPane?(a.rowPane.classList.add("is-active"),a.rowPane.setAttribute("aria-selected","true")):(a.container.classList.add("is-active"),a.container.setAttribute("aria-selected","true"))},markTabInactive:function(a){a.tab.classList.remove("is-active"),a.tab.firstChild.removeAttribute("aria-selected"),"undefined"!=typeof a.rowPane?(a.rowPane.classList.remove("is-active"),a.rowPane.removeAttribute("aria-selected")):(a.container.classList.remove("is-active"),a.container.removeAttribute("aria-selected"))},addTab:function(a,b){a.children[0].firstChild.appendChild(b)},addTopTab:function(a,b){a.firstChild.children[0].appendChild(b)},getFirstTab:function(a){return a.firstChild.firstChild.firstChild}}),h.defaults.themes.html=h.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b.style.marginBottom="3px",b.style.fontWeight="bold",b},getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8em",b.style.margin=0,b.style.display="inline-block",b.style.fontStyle="italic",b},getIndentedPanel:function(){var a=this._super();return a.style.border="1px solid #ddd",a.style.padding="5px",a.style.margin="10px",a.style.borderRadius="3px",a},getTopIndentedPanel:function(){return this.getIndentedPanel()},getChildEditorHolder:function(){var a=this._super();return a.style.marginBottom="8px",a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.display="inline-block",a.style.marginLeft="10px",a.style.fontSize=".8em",a.style.verticalAlign="middle",a},getTable:function(){var a=this._super();return a.style.borderBottom="1px solid #ccc",a.style.marginBottom="5px",a},addInputError:function(a,b){if(a.style.borderColor="red",a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),a.errmsg.style=a.errmsg.style||{},a.errmsg.style.color="red",c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),h.defaults.themes.jqueryui=h.AbstractTheme.extend({getTable:function(){var a=this._super();return a.setAttribute("cellpadding",5),a.setAttribute("cellspacing",0),a},getTableHeaderCell:function(a){var b=this._super(a);return b.classList.add("ui-state-active"),b.style.fontWeight="bold",b},getTableCell:function(){var a=this._super();return a.classList.add("ui-widget-content"),a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.marginLeft="10px",a.style.fontSize=".6em",a.style.display="inline-block",a},getFormInputDescription:function(a){var b=this.getDescription(a);return b.style.marginLeft="10px",b.style.display="inline-block",b},getFormControl:function(a,b,c,d){var e=this._super(a,b,c,d);return"checkbox"===b.type?(e.style.lineHeight="25px",e.style.padding="3px 0"):e.style.padding="4px 0 8px 0",e},getDescription:function(a){var b=document.createElement("span");return b.style.fontSize=".8em",b.style.fontStyle="italic",b.textContent=a,b},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("ui-buttonset"),a.style.fontSize=".7em",a},getFormInputLabel:function(a){var b=document.createElement("label");return b.style.fontWeight="bold",b.style.display="block",b.textContent=a,b},getButton:function(a,b,c){var d=document.createElement("button");d.classList.add("ui-button","ui-widget","ui-state-default","ui-corner-all"),b&&!a?(d.classList.add("ui-button-icon-only"),b.classList.add("ui-button-icon-primary","ui-icon-primary"),d.appendChild(b)):b?(d.classList.add("ui-button-text-icon-primary"),b.classList.add("ui-button-icon-primary","ui-icon-primary"),d.appendChild(b)):d.classList.add("ui-button-text-only");var e=document.createElement("span");return e.classList.add("ui-button-text"),e.textContent=a||c||".",d.appendChild(e),d.setAttribute("title",c),d},setButtonText:function(a,b,c,d){a.innerHTML="",a.classList.add("ui-button","ui-widget","ui-state-default","ui-corner-all"),c&&!b?(a.classList.add("ui-button-icon-only"),c.classList.add("ui-button-icon-primary","ui-icon-primary"),a.appendChild(c)):c?(a.classList.add("ui-button-text-icon-primary"),c.classList.add("ui-button-icon-primary","ui-icon-primary"),a.appendChild(c)):a.classList.add("ui-button-text-only");var e=document.createElement("span");e.classList.add("ui-button-text"),e.textContent=b||d||".",a.appendChild(e),a.setAttribute("title",d)},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("ui-widget-content","ui-corner-all"),a.style.padding="1em 1.4em",a.style.marginBottom="20px",a},afterInputReady:function(a){if(!a.controls&&(a.controls=this.closest(a,".form-control"),this.queuedInputErrorText)){var b=this.queuedInputErrorText;delete this.queuedInputErrorText,this.addInputError(a,b)}},addInputError:function(a,b){return a.controls?(a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("div"),a.errmsg.classList.add("ui-state-error"),a.controls.appendChild(a.errmsg)),void(a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.controls||delete this.queuedInputErrorText,a.errmsg&&(a.errmsg.style.display="none")},markTabActive:function(a){a.tab.classList.remove("ui-widget-header"),a.tab.classList.add("ui-state-active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.add("ui-widget-header"),a.tab.classList.remove("ui-state-active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"}}),h.defaults.themes.barebones=h.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b},getFormInputDescription:function(a){var b=this._super(a);return b},getIndentedPanel:function(){var a=this._super();return a},getChildEditorHolder:function(){var a=this._super();return a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a},getTable:function(){var a=this._super();return a},addInputError:function(a,b){if(a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),h.defaults.themes.materialize=h.AbstractTheme.extend({setGridColumnSize:function(a,b){a.classList.add("col"),a.classList.add("s"+b)},getHeaderButtonHolder:function(){return this.getButtonHolder()},getButtonHolder:function(){return document.createElement("span")},getButton:function(a,b,c){a&&(b.classList.add("left"),b.style.marginRight="5px");var d=this._super(a,b,c);return d.classList.add("waves-effect","waves-light","btn"),d.style.fontSize="0.75rem",d.style.height="24px",d.style.lineHeight="24px",d.style.marginLeft="5px",d.style.padding="0 0.5rem",d},getFormControl:function(a,b,c,d){var e,f=b.type;if(f&&"checkbox"===f){if(e=document.createElement("p"),a){var g=document.createElement("span");g.innerHTML=a.innerHTML,a.innerHTML="",a.setAttribute("for",b.id),e.appendChild(a),a.appendChild(b),a.appendChild(g)}else e.appendChild(b);return e}return e=this._super(a,b,c,d),f&&f.startsWith("select")||e.classList.add("input-field"),f&&"color"===f&&(b.style.height="3rem",b.style.width="100%",b.style.margin="5px 0 20px 0",b.style.padding="3px",a&&(a.style.transform="translateY(-14px) scale(0.8)",a.style["-webkit-transform"]="translateY(-14px) scale(0.8)",a.style["-webkit-transform-origin"]="0 0",a.style["transform-origin"]="0 0")),e},getDescription:function(a){var b=document.createElement("div");return b.classList.add("grey-text"),b.style.marginTop="-15px",b.innerHTML=a,b},getHeader:function(a){var b=document.createElement("h5");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getChildEditorHolder:function(){var a=document.createElement("div");return a.marginBottom="10px",a},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("card-panel"),a},getTable:function(){var a=document.createElement("table");return a.classList.add("striped","bordered"),a.style.marginBottom="10px",a},getTableRow:function(){return document.createElement("tr")},getTableHead:function(){return document.createElement("thead")},getTableBody:function(){return document.createElement("tbody")},getTableHeaderCell:function(a){var b=document.createElement("th");return b.textContent=a,b},getTableCell:function(){var a=document.createElement("td");return a},getTabHolder:function(){var a=['
            ','
              ',"
            ","
            ",'
            ',"
            "].join("\n"),b=document.createElement("div");return b.classList.add("row","card-panel"),b.innerHTML=a,b},addTab:function(a,b){a.children[0].children[0].appendChild(b)},getTab:function(a){var b=document.createElement("li");return b.classList.add("tab"),b.style=b.style||{},this.applyStyles(b,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer"}),b.appendChild(a),b},markTabActive:function(a){a.style=a.style||{},this.applyStyles(a,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer",color:"rgba(238,110,115,1)",transition:"border-color .5s ease",borderRight:"3px solid #424242"})},markTabInactive:function(a){a.style=a.style||{},this.applyStyles(a,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer",color:"rgba(238,110,115,0.7)"})},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){return document.createElement("div")},addInputError:function(a,b){var c,d=a.parentNode;d&&(this.removeInputError(a),c=document.createElement("div"),c.classList.add("error-text","red-text"),c.textContent=b,d.appendChild(c))},removeInputError:function(a){var b,c=a.parentElement;if(c){b=c.getElementsByClassName("error-text");for(var d=0;d1){var g;c=function(b){for(g=b,a=0;a=0){if(a.items["enum"])return"multiselect";if(h.plugins.selectize.enable&&"string"===a.items.type)return"arraySelectize"}}),h.defaults.resolvers.unshift(function(a){if(a.oneOf||a.anyOf)return"multiple"}),h.defaults.resolvers.unshift(function(a){if(["string","integer"].indexOf(a.type)!==-1&&["date","time","datetime-local"].indexOf(a.format)!==-1)return"datetime"}),h.defaults.resolvers.unshift(function(a){if("string"===a.type&&"starrating"===a.format)return"starrating"}),function(){if(window.jQuery||window.Zepto){var a=window.jQuery||window.Zepto;a.jsoneditor=h.defaults,a.fn.jsoneditor=function(a){var b=this,c=this.data("jsoneditor");if("value"===a){if(!c)throw"Must initialize jsoneditor before getting/setting the value";if(!(arguments.length>1))return c.getValue();c.setValue(arguments[1])}else{if("validate"===a){if(!c)throw"Must initialize jsoneditor before validating";return arguments.length>1?c.validate(arguments[1]):c.validate()}"destroy"===a?c&&(c.destroy(),this.data("jsoneditor",null)):(c&&c.destroy(),c=new h(this.get(0),a),this.data("jsoneditor",c),c.on("change",function(){b.trigger("change")}),c.on("ready",function(){b.trigger("ready")}))}return this}}}(),h}); +//# sourceMappingURL=jsoneditor.min.js.map \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js index 129c5d984..1901d95e6 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js @@ -36,11 +36,11 @@ app.controller('ToscaModelCtrl', } var editorData = getMsProperty(selectedPolicy); - JSONEditor.defaults.options.theme = 'bootstrap3'; - JSONEditor.defaults.options.iconlib = 'bootstrap2'; + JSONEditor.defaults.options.theme = 'bootstrap4'; + //JSONEditor.defaults.options.iconlib = 'bootstrap2'; JSONEditor.defaults.options.object_layout = 'grid'; JSONEditor.defaults.options.disable_properties = true; - JSONEditor.defaults.options.disable_edit_json = true; + JSONEditor.defaults.options.disable_edit_json = false; JSONEditor.defaults.options.disable_array_reorder = true; JSONEditor.defaults.options.disable_array_delete_last_row = true; JSONEditor.defaults.options.disable_array_delete_all_rows = false; -- cgit 1.2.3-korg