diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..4e9fc77c3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +dist/* merge=own diff --git a/Gruntfile.js b/Gruntfile.js index a3b8796a0..e054eef68 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -70,6 +70,43 @@ module.exports = function(grunt) { files: ["src/**/*.js"], tasks: ["concat"] } + }, + jshint: { + beforeconcat: [ + 'src/class.js', + 'src/ie9.js', + + // Utils like extend, each, and trigger + 'src/utilities.js', + + // The main JSONEditor class + 'src/core.js', + + // JSON Schema validator + 'src/validator.js', + + // All the editors + 'src/editor.js', + 'src/editors/*.js', + + // All the themes and iconlibs + 'src/theme.js', + 'src/themes/*.js', + 'src/iconlib.js', + 'src/iconlibs/*.js', + + // The JS templating engines + 'src/templates/*.js', + + // Set the defaults + 'src/defaults.js', + + // Wrapper for $.fn style initialization + 'src/jquery.js' + ], + afterconcat: [ + 'dist/jsoneditor.js' + ] } }); @@ -77,8 +114,9 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-jshint'); // Default task. - grunt.registerTask('default', ['concat', 'uglify']); + grunt.registerTask('default', ['jshint:beforeconcat','concat','jshint:afterconcat','uglify']); }; diff --git a/bower.json b/bower.json index 8376ad53a..e76d748f2 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "json-editor", - "version": "0.6.11", + "version": "0.6.12", "authors": [ "Jeremy Dorn " ], diff --git a/dist/jsoneditor.js b/dist/jsoneditor.js index 99b886eee..4bd958bf3 100644 --- a/dist/jsoneditor.js +++ b/dist/jsoneditor.js @@ -1,8 +1,8 @@ -/*! JSON Editor v0.6.11 - JSON Schema -> HTML Editor +/*! JSON Editor v0.6.12 - JSON Schema -> HTML Editor * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license * - * Date: 2014-05-29 + * Date: 2014-06-08 */ /** @@ -11,12 +11,71 @@ (function() { +/*jshint loopfunc: true */ /* Simple JavaScript Inheritance -* By John Resig http://ejohn.org/ -* MIT Licensed. -*/ + * By John Resig http://ejohn.org/ + * MIT Licensed. + */ // Inspired by base2 and Prototype -var Class;!function(){var a=!1,b=/xyz/.test(function(){})?/\b_super\b/:/.*/;Class=function(){},Class.extend=function(c){function g(){!a&&this.init&&this.init.apply(this,arguments)}var d=this.prototype;a=!0;var e=new this;a=!1;for(var f in c)e[f]="function"==typeof c[f]&&"function"==typeof d[f]&&b.test(c[f])?function(a,b){return function(){var c=this._super;this._super=d[a];var e=b.apply(this,arguments);return this._super=c,e}}(f,c[f]):c[f];return g.prototype=e,g.prototype.constructor=g,g.extend=arguments.callee,g}}(); +(function(){ + var initializing = false, fnTest = /xyz/.test(function(){postMessage("xyz");}) ? /\b_super\b/ : /.*/; + + // The base Class implementation (does nothing) + this.Class = function(){}; + + // Create a new Class that inherits from this class + Class.extend = function(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 = arguments.callee; + + return Class; + }; +})(); // CustomEvent constructor polyfill // From MDN @@ -26,7 +85,7 @@ var Class;!function(){var a=!1,b=/xyz/.test(function(){})?/\b_super\b/:/.*/;Clas var evt = document.createEvent( 'CustomEvent' ); evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); return evt; - }; + } CustomEvent.prototype = window.Event.prototype; @@ -40,8 +99,8 @@ var Class;!function(){var a=!1,b=/xyz/.test(function(){})?/\b_super\b/:/.*/;Clas 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']; + window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || + window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) @@ -96,13 +155,14 @@ var $extend = function(destination) { var $each = function(obj,callback) { if(!obj) return; + var i; if(typeof obj.length !== 'undefined') { - for(var i=0; i=0) { holder = this.theme.getBlockLinkHolder(); - var link = this.theme.getBlockLink(); + link = this.theme.getBlockLink(); link.setAttribute('target','_blank'); var media = document.createElement(type); @@ -1584,8 +1639,9 @@ JSONEditor.AbstractEditor = Class.extend({ else return this.getTitle(); }, onWatchedFieldChange: function() { + var vars; if(this.header_template) { - var vars = $extend(this.getWatchedFieldValues(),{ + vars = $extend(this.getWatchedFieldValues(),{ key: this.key, i: this.key, title: this.getTitle() @@ -1599,7 +1655,7 @@ JSONEditor.AbstractEditor = Class.extend({ } } if(this.link_watchers.length) { - var vars = this.getWatchedFieldValues(); + vars = this.getWatchedFieldValues(); for(var i=0; i= 0 - && window.$ && $.fn && $.fn.sceditor + if(this.options.wysiwyg && + ['html','bbcode'].indexOf(this.input_type) >= 0 && + window.$ && $.fn && $.fn.sceditor ) { - $(self.input).sceditor({ + options = $extend({},{ plugins: self.input_type==='html'? 'xhtml' : 'bbcode', emoticonsEnabled: false, width: '100%', height: 300 - }); + },JSONEditor.plugins.sceditor); + + $(self.input).sceditor(options); self.sceditor_instance = $(self.input).sceditor('instance'); @@ -2132,7 +2190,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ this.input.parentNode.insertBefore(this.epiceditor_container,this.input); this.input.style.display = 'none'; - var options = $extend({},JSONEditor.plugins.epiceditor,{ + options = $extend({},JSONEditor.plugins.epiceditor,{ container: this.epiceditor_container, clientSideStorage: false }); @@ -2171,7 +2229,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ // The theme if(JSONEditor.plugins.ace.theme) this.ace_editor.setTheme('ace/theme/'+JSONEditor.plugins.ace.theme); // The mode - var mode = ace.require("ace/mode/"+mode); + mode = ace.require("ace/mode/"+mode); if(mode) this.ace_editor.getSession().setMode(new mode.Mode()); // Listen for changes @@ -2223,16 +2281,16 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ * Re-calculates the value if needed */ onWatchedFieldChange: function() { - var self = this; + var self = this, vars, j; // If this editor needs to be rendered by a macro template if(this.template) { - var vars = this.getWatchedFieldValues(); + vars = this.getWatchedFieldValues(); this.setValue(this.template(vars),false,true); } // If this editor uses a dynamic select box if(this.enumSource) { - var vars = this.getWatchedFieldValues(); + vars = this.getWatchedFieldValues(); var select_options = []; var select_titles = []; @@ -2253,7 +2311,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ // Filter the items if(this.enumSource[i].filter) { var new_items = []; - for(var j=0; j height)) { + if(!height || (rows[i].minh*0.5 < height && rows[i].maxh*2 > height)) { found = i; } } @@ -2464,11 +2522,11 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ // 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(var i=0; i rows[i].editors[biggest].width) biggest = j; rows[i].editors[j].width *= 12/rows[i].width; @@ -2486,10 +2544,10 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ // Layout the form container = document.createElement('div'); - for(var i=0; i HTML Editor +/*! JSON Editor v0.6.12 - JSON Schema -> HTML Editor * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license * - * Date: 2014-05-29 + * Date: 2014-06-08 */ -!function(){var a;!function(){var b=!1,c=/xyz/.test(function(){})?/\b_super\b/:/.*/;a=function(){},a.extend=function(a){function d(){!b&&this.init&&this.init.apply(this,arguments)}var e=this.prototype;b=!0;var f=new this;b=!1;for(var g in a)f[g]="function"==typeof a[g]&&"function"==typeof e[g]&&c.test(a[g])?function(a,b){return function(){var c=this._super;this._super=e[a];var d=b.apply(this,arguments);return this._super=c,d}}(g,a[g]):a[g];return d.prototype=f,d.prototype.constructor=d,d.extend=arguments.callee,d}}(),function(){function a(a,b){b=b||{bubbles:!1,cancelable:!1,detail:void 0};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail),c}a.prototype=window.Event.prototype,window.CustomEvent=a}(),function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c=e){if(h)return;h=!0,i._getRefs(a,b)}},d(k,function(){e++}),e?d(k,function(b,c){i._getRefs(c,function(c){i.refs["#/definitions/"+b]=c,f++,g(a)})}):g(a)}else if(a.$ref){var l=a.$ref;if(delete a.$ref,i.refs[l]&&i.refs[l]instanceof Array)i.refs[l].push(function(){a=c({},i.refs[l],a),b(a)});else if(i.refs[l])a=c({},i.refs[l],a),b(a);else{if(!i.options.ajax)throw"Must set ajax option to true to load external url "+l;var m=new XMLHttpRequest;m.open("GET",l,!0),m.onreadystatechange=function(){if(4==m.readyState){if(200===m.status){var e=JSON.parse(m.responseText);return i.refs[l]=[],i._getRefs(e,function(e){var f=i.refs[l];i.refs[l]=e,a=c({},i.refs[l],a),b(a),d(f,function(a,b){b()})}),void 0}throw"Failed to fetch ref via ajax- "+l}},m.send()}}else e=f=0,g=function(a){if(f>=e){if(h)return;h=!0,b(a)}},d(a,function(a,b){"object"==typeof b&&b&&b instanceof Array?d(b,function(a,b){"object"!=typeof b||!b||b instanceof Array||e++}):"object"==typeof b&&b&&e++}),e?d(a,function(b,c){"object"==typeof c&&c&&c instanceof Array?d(c,function(c,d){"object"!=typeof d||!d||d instanceof Array||i._getRefs(d,function(d){a[b][c]=d,f++,g(a)})}):"object"==typeof c&&c&&i._getRefs(c,function(c){a[b]=c,f++,g(a)})}):g(a)},validate:function(a){return this._validateSchema(this.schema,a)},_validateSchema:function(a,b,e){var f,h,i,j=[],k=JSON.stringify(b);if(e=e||"root",a=c({},a),a.required&&a.required===!0){if("undefined"==typeof b)return j.push({path:e,property:"required",message:"Property must be set"}),j}else if("undefined"==typeof b){if(!this.options.required_by_default)return j;j.push({path:e,property:"required",message:"Property must be set"})}if(a.enum){for(f=!1,h=0;h=a.maximum?j.push({path:e,property:"maximum",message:"Value must be less than "+a.maximum}):!a.exclusiveMaximum&&b>a.maximum&&j.push({path:e,property:"maximum",message:"Value must be at most "+a.maximum})),a.minimum&&(a.exclusiveMinimum&&b<=a.minimum?j.push({path:e,property:"minimum",message:"Value must be greater than "+a.minimum}):!a.exclusiveMinimum&&ba.maxLength&&j.push({path:e,property:"maxLength",message:"Value must be at most "+a.maxLength+" characters long"}),a.minLength&&(b+"").lengtha.maxItems&&j.push({path:e,property:"maxItems",message:"Value must have at most "+a.maxItems+" items"}),a.minItems&&b.lengtha.maxProperties&&j.push({path:e,property:"maxProperties",message:"Object must have at most "+a.maxProperties+" properties"})}if(a.minProperties){f=0;for(h in b)b.hasOwnProperty(h)&&f++;f=0){b=this.theme.getBlockLinkHolder();var f=this.theme.getBlockLink();f.setAttribute("target","_blank");var h=document.createElement(d);h.setAttribute("controls","controls"),this.theme.createMediaLink(b,f,h),this.link_watchers.push(function(b){var c=e(b);f.setAttribute("href",c),f.textContent=a.rel||c,h.setAttribute("src",c)})}else b=this.theme.getBlockLink(),b.setAttribute("target","_blank"),b.textContent=a.rel,this.link_watchers.push(function(c){var d=e(c);b.setAttribute("href",d),b.textContent=a.rel||d});return 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(){this.header&&(this.header.textContent=this.getHeaderText())},getHeaderText:function(a){return this.header_text?this.header_text:a?this.schema.title:this.getTitle()},onWatchedFieldChange:function(){if(this.header_template){var a=c(this.getWatchedFieldValues(),{key:this.key,i:this.key,title:this.getTitle()}),b=this.header_template(a);b!==this.header_text&&(this.header_text=b,this.updateHeaderText(),this.fireChangeHeaderEvent())}if(this.link_watchers.length)for(var a=this.getWatchedFieldValues(),d=0;d1&&(b[a]=d+" "+e[d])}),b},showValidationErrors:function(){}}),g.defaults.editors.null=g.AbstractEditor.extend({getValue:function(){return null},setValue:function(){this.jsoneditor.notifyWatchers(this.path)},getNumColumns:function(){return 2}}),g.defaults.editors.string=g.AbstractEditor.extend({getDefault:function(){return this.schema.default||""},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){var d=this;if((!this.template||c)&&(a=a||"","object"==typeof a&&(a=JSON.stringify(a)),"string"!=typeof a&&(a=""+a),a!==this.serialized)){var e=this.sanitize(a);if(this.select_options&&this.select_options.indexOf(e)<0&&(e=this.select_options[0]),this.input.value!==e){this.input.value=e,this.sceditor_instance?this.sceditor_instance.val(e):this.epiceditor?this.epiceditor.importFile(null,e):this.ace_editor&&this.ace_editor.setValue(e);var f=c||this.getValue()!==a;this.refreshValue(),f&&(d.parent?d.parent.onChildEditorChange(d):d.jsoneditor.onChange()),this.watch_listener(),this.jsoneditor.notifyWatchers(this.path)}}},removeProperty:function(){this._super(),this.input.style.display="none",this.description&&(this.description.style.display="none"),this.theme.disableLabel(this.label)},addProperty:function(){this._super(),this.input.style.display="",this.description&&(this.description.style.display=""),this.theme.enableLabel(this.label)},getNumColumns:function(){var a,b=Math.ceil(this.getTitle().length/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.getOption("compact",!1)||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),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.schema.enum)this.input_type="select",this.select_options=this.schema.enum,this.input=this.theme.getSelectInput(this.select_options);else if(this.schema.enumSource){if(this.input_type="select",this.input=this.theme.getSelectInput([]),this.enumSource=[],this.schema.enumSource instanceof Array)for(var b=0;b=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);"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.getOption("compact")&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact"),(this.schema.readOnly||this.schema.readonly||this.schema.template)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),a.schema.template)return this.value=a.value,void 0;var c=this.value,d=a.sanitize(c);c!==d&&(this.value=d),a.refreshValue(),a.watch_listener(),a.jsoneditor.notifyWatchers(a.path),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.getTheme().getFormControl(this.label,this.input,this.description),this.container.appendChild(this.control),"select"===this.input_type&&window.$&&$.fn&&$.fn.select2&&$(this.input).select2(),requestAnimationFrame(function(){a.afterInputReady()}),this.register(),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue(),this.jsoneditor.notifyWatchers(this.path)):(this.refreshValue(),this.jsoneditor.notifyWatchers(this.path))},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},afterInputReady:function(){var a=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.$&&$.fn&&$.fn.sceditor)$(a.input).sceditor({plugins:"html"===a.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300}),a.sceditor_instance=$(a.input).sceditor("instance"),a.sceditor_instance.blur(function(){var b=$("
"+a.sceditor_instance.val()+"
");$("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",b).remove(),a.input.value=b.html(),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(),a.jsoneditor.notifyWatchers(a.path)});else if("markdown"===this.input_type&&window.EpicEditor){this.epiceditor_container=document.createElement("div"),this.input.parentNode.insertBefore(this.epiceditor_container,this.input),this.input.style.display="none";var b=c({},g.plugins.epiceditor,{container:this.epiceditor_container,clientSideStorage:!1}); -this.epiceditor=new EpicEditor(b).load(),this.epiceditor.importFile(null,this.getValue()),this.epiceditor.on("update",function(){var b=a.epiceditor.exportFile();a.input.value=b,a.value=b,a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(),a.jsoneditor.notifyWatchers(a.path)})}else if(window.ace){var d=this.input_type;("cpp"===d||"c++"===d||"c"===d)&&(d="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=ace.edit(this.ace_container),this.ace_editor.setValue(this.getValue()),g.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+g.plugins.ace.theme);var d=ace.require("ace/mode/"+d);d&&this.ace_editor.getSession().setMode(new d.Mode),this.ace_editor.on("change",function(){var b=a.ace_editor.getValue();a.input.value=b,a.refreshValue(),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(),a.jsoneditor.notifyWatchers(a.path)})}a.theme.afterInputReady(a.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.epiceditor?this.epiceditor.unload():this.ace_editor&&this.ace_editor.destroy(),this.template=null,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(){if(this.template){var a=this.getWatchedFieldValues();this.setValue(this.template(a),!1,!0)}if(this.enumSource){for(var a=this.getWatchedFieldValues(),b=[],c=[],d=0;df)&&(d=g);d===!1&&(c.push({width:0,minh:999999,maxh:0,editors:[]}),d=c.length-1),c[d].editors.push({key:a,width:e,height:f}),c[d].width+=e,c[d].minh=Math.min(c[d].minh,f),c[d].maxh=Math.max(c[d].maxh,f)}});for(var e=0;ec[e].editors[f].width&&(f=h),c[e].editors[h].width*=12/c[e].width,c[e].editors[h].width=Math.floor(c[e].editors[h].width),g+=c[e].editors[h].width;12>g&&(c[e].editors[f].width+=12-g),c[e].width=12}if(this.layout===JSON.stringify(c))return!1;this.layout=JSON.stringify(c),b=document.createElement("div");for(var e=0;e=0),a.editors[b]=a.jsoneditor.createEditor(d,{jsoneditor:a.jsoneditor,schema:c,container:e,path:a.path+"."+b,parent:a,required:f}),a.minwidth=Math.max(a.minwidth,a.editors[b].getNumColumns()),a.maxwidth+=a.editors[b].getNumColumns()}),this.layoutEditors(),this.layoutEditors(),this.title_controls=this.getTheme().getHeaderButtonHolder(),this.editjson_controls=this.getTheme().getHeaderButtonHolder(),this.addproperty_controls=this.getTheme().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","Collapse"),this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(){a.collapsed?(a.editor_holder.style.display="",a.collapsed=!1,a.setButtonText(a.toggle_button,"","collapse","Collapse")):(a.editor_holder.style.display="none",a.collapsed=!0,a.setButtonText(a.toggle_button,"","expand","Expand"))}),this.options.collapsed&&e(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.addEventListener("click",function(){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.addEventListener("click",function(){a.toggleAddProperty()}),this.addproperty_controls.appendChild(this.addproperty_button),this.addproperty_controls.appendChild(this.addproperty_holder),this.refreshAddProperties()}this.jsoneditor.notifyWatchers(this.path)},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)},saveJSON:function(){if(this.editjson_holder)try{var a=JSON.parse(this.editjson_textarea.value);this.setValue(a),this.hideEditJSON()}catch(b){throw alert("invalid JSON"),b}},toggleEditJSON:function(){this.editing_json?this.hideEditJSON():this.showEditJSON()},addPropertyCheckbox:function(a){var b=this.editors[a];if(b){var c,d,e,f=this;return c=f.theme.getCheckbox(),c.style.width="auto",d=f.theme.getCheckboxLabel(a),e=f.theme.getFormControl(d,c),e.style.paddingBottom=e.style.marginBottom=e.style.paddingTop=e.style.marginTop=0,e.style.height="auto",f.addproperty_list.appendChild(e),c.checked=!b.property_removed,b.isRequired()&&(c.disabled=!0),c.addEventListener("change",function(){c.checked?f.addObjectProperty(a):f.removeObjectProperty(a)}),c}},showAddProperty:function(){if(this.addproperty_holder){this.hideEditJSON(),this.addproperty_holder.style.left=this.addproperty_button.offsetLeft+"px",this.addproperty_holder.style.top=this.addproperty_button.offsetTop+this.addproperty_button.offsetHeight+"px",this.addproperty_list.innerHTML="";var a=this;this.addproperty_checkboxes={},d(this.editors,function(b){a.addproperty_checkboxes[b]=a.addPropertyCheckbox(b)}),this.disable(),this.adding_property=!0,this.addproperty_button.disabled=!1,this.addproperty_holder.style.display="",this.refreshAddProperties()}},hideAddProperty:function(){this.addproperty_holder&&this.adding_property&&(this.addproperty_holder.style.display="none",this.enable(),this.adding_property=!1)},toggleAddProperty:function(){this.adding_property?this.hideAddProperty():this.showAddProperty()},removeObjectProperty:function(a){this.editors[a]&&(this.editors[a].property_removed=!0,this.editors[a].unregister(),this.refreshValue(),this.layoutEditors(),this.jsoneditor.notifyWatchers(this.path),this.parent?this.parent.onChildEditorChange(this):this.jsoneditor.onChange())},addObjectProperty:function(a){var b=this;if(this.editors[a]){if(!this.editors[a].property_removed)return;this.editors[a].property_removed=!1,this.editors[a].register(),this.jsoneditor.notifyWatchers(this.editors[a].path)}else{var e={},f=!1;b.schema.patternProperties&&d(b.schema.patternProperties,function(b,d){var g=new RegExp(b);g.test(a)&&(f=!0,e=c(e,d))}),f||"object"!=typeof b.schema.additionalProperties||(e=c(e,b.schema.additionalProperties));var g=b.jsoneditor.getEditorClass(e,b.jsoneditor),h=b.getTheme().getChildEditorHolder();b.editor_holder.appendChild(h),b.editors[a]=b.jsoneditor.createEditor(g,{jsoneditor:b.jsoneditor,schema:e,container:h,path:b.path+"."+a,parent:b,required:!1}),b.editors[a].not_core=!0}b.refreshValue(),b.jsoneditor.notifyWatchers(b.path),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange(),b.layoutEditors()},onChildEditorChange:function(a){this.refreshValue(),this._super(a)},canHaveAdditionalProperties:function(){return this.schema.additionalProperties!==!1&&!this.jsoneditor.options.no_additional_properties},destroy:function(){d(this.editors,function(a,b){b.destroy()}),this.editor_holder.innerHTML="",this.title&&this.title.parentNode.removeChild(this.title),this.error_holder&&this.error_holder.parentNode.removeChild(this.error_holder),this.editors=null,this.editor_holder.parentNode.removeChild(this.editor_holder),this.editor_holder=null,this._super()},refreshValue:function(){this.value={},this.serialized="";var a=this,b=0,c=!1,e=this.editors;d(this.editors,function(a,b){b.property_removed&&b.not_core&&(e={},c=!0)}),d(this.editors,function(d,f){if(f.property_removed){if(!f.not_core&&c)e[d]=f;else if(f.not_core){var g=f.container;f.destroy(),g.parentNode&&g.parentNode.removeChild(g)}}else c&&(e[d]=f),b++,a.value[d]=f.getValue()}),this.editors=e,this.adding_property&&this.refreshAddProperties()},refreshAddProperties:function(){if(this.options.disable_properties||this.jsoneditor.options.disable_properties)return this.addproperty_controls.style.display="none",void 0;var a,b=!1,c=!1,d=0,e=!1;for(a in this.editors)this.editors.hasOwnProperty(a)&&(this.editors[a].property_removed||d++);b=this.canHaveAdditionalProperties()&&!("undefined"!=typeof this.schema.maxProperties&&d>=this.schema.maxProperties);for(a in this.editors)this.editors.hasOwnProperty(a)&&(this.editors[a].isRequired()?this.addproperty_checkboxes&&this.addproperty_checkboxes[a]&&(this.addproperty_checkboxes[a].disabled=!0):"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?this.addproperty_checkboxes&&this.addproperty_checkboxes[a]?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):this.editors[a].property_removed&&b&&(e=!0):this.editors[a].property_removed?this.addproperty_checkboxes&&this.addproperty_checkboxes[a]?b?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0:b&&(e=!0):(this.addproperty_checkboxes&&this.addproperty_checkboxes[a]&&(this.addproperty_checkboxes[a].disabled=!1),e=!0,c=!0));if(this.canHaveAdditionalProperties()&&(e=!0),this.addproperty_checkboxes)for(var a in this.addproperty_checkboxes)this.addproperty_checkboxes.hasOwnProperty(a)&&(this.editors[a]||(e=!0,this.addproperty_checkboxes[a].disabled=!b&&!c));e?this.canHaveAdditionalProperties()?this.addproperty_add.disabled=b?!1:!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},setValue:function(a,b){var c=this;a=a||{},("object"!=typeof a||a instanceof Array)&&(a={}),d(this.editors,function(d,e){if("undefined"!=typeof a[d])e.property_removed&&c.addObjectProperty(d),e.setValue(a[d],b);else{if(!b&&!e.property_removed&&!e.isRequired())return c.removeObjectProperty(d),void 0;e.setValue(e.getDefault(),b)}}),this.canHaveAdditionalProperties()&&d(a,function(a,d){c.editors[a]||(c.addObjectProperty(a),c.editors[a]&&c.editors[a].setValue(d,b))}),this.refreshValue(),this.jsoneditor.notifyWatchers(this.path)},showValidationErrors:function(a){var b=this,c=[],e=[];if(d(a,function(a,d){d.path===b.path?c.push(d):e.push(d)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",d(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";this.getOption("table_row")&&(c.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),d(this.editors,function(a,b){b.showValidationErrors(e)})}}),g.defaults.editors.array=g.AbstractEditor.extend({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?c({},this.schema.additionalItems):void 0:c({},this.schema.items[a]):this.schema.items?c({},this.schema.items):{}},getItemInfo:function(a){var b=this.getItemSchema(a);this.item_info=this.item_info||{};var c=JSON.stringify(b);if("undefined"!=typeof this.item_info[c])return this.item_info[c];var d=document.createElement("div");this.container.appendChild(d),d.addEventListener("change_header_text",function(a){a.preventDefault(),a.stopPropagation()});var e=this.jsoneditor.getEditorClass(b,this.jsoneditor);return e=this.jsoneditor.createEditor(e,{jsoneditor:this.jsoneditor,schema:b,container:d,path:this.path+"."+a,parent:this,required:!0}),this.item_info[c]={child_editors:e.getChildEditors()?!0:!1,title:b.title||"item",width:e.getNumColumns(),"default":e.getDefault()},e.destroy(),d.parentNode&&d.parentNode.removeChild(d),this.item_info[c]},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c.title=b.title+" "+a;var d,e=this.jsoneditor.getEditorClass(c,this.jsoneditor);d=this.tabs_holder?this.theme.getTabContent():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.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode.removeChild(this.controls),this.panel&&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;d(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 this.schema.items instanceof Array&&0==this.schema.additionalItems?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(a){var b=this;d(this.rows,function(c,d){d.tab&&(a?d.tab_text.textContent=d.getHeaderText():d.tab===b.active_tab?(b.theme.markTabActive(d.tab),d.container.style.display=""):(b.theme.markTabInactive(d.tab),d.container.style.display="none"))})},setValue:function(a){a=a||[],a instanceof Array||(a=[a]);var b=JSON.stringify(a);if(b!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var c=this;d(a,function(a,b){c.rows[a]?c.rows[a].setValue(b):c.row_cache[a]?(c.rows[a]=c.row_cache[a],c.rows[a].setValue(b),c.rows[a].container.style.display="",c.rows[a].tab&&(c.rows[a].tab.style.display=""),c.rows[a].register()):c.addRow(b)});for(var e=a.length;e=this.rows.length;d(this.rows,function(b,d){d.movedown_button.style.display=b===a.rows.length-1?"none":"",d.delete_button.style.display=c?"none":"",a.value[b]=d.getValue()}),this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",this.delete_last_row_button.style.display=c?"none":""):c?(this.delete_last_row_button.style.display="none",this.delete_last_row_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display=""):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.add_row_button.style.display=this.getMax()&&this.getMax()<=this.rows.length?"none":""}},addRow:function(a){var b=this,c=this.rows.length;b.rows[c]=this.getElementEditor(c),b.row_cache[c]=b.rows[c],b.tabs_holder&&(b.rows[c].tab_text=document.createElement("span"),b.rows[c].tab_text.textContent=b.rows[c].getHeaderText(),b.rows[c].tab=b.theme.getTab(b.rows[c].tab_text),b.rows[c].tab.addEventListener("click",function(a){b.active_tab=b.rows[c].tab,b.refreshTabs(),a.preventDefault(),a.stopPropagation()}),b.theme.addTab(b.tabs_holder,b.rows[c].tab)),b.rows[c].delete_button=this.getButton(b.getItemTitle(),"delete","Delete "+b.getItemTitle()),b.rows[c].delete_button.className+=" delete",b.rows[c].delete_button.setAttribute("data-i",c),b.rows[c].delete_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),c=b.getValue(),e=[],f=null;d(c,function(c,d){return c===a?(b.rows[c].tab===b.active_tab&&(b.rows[c+1]?f=b.rows[c+1].tab:c&&(f=b.rows[c-1].tab)),void 0):(e.push(d),void 0)}),b.setValue(e),f&&(b.active_tab=f,b.refreshTabs()),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),b.rows[c].moveup_button=this.getButton("","moveup","Move up"),b.rows[c].moveup_button.className+=" moveup",b.rows[c].moveup_button.setAttribute("data-i",c),b.rows[c].moveup_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i");if(!(0>=a)){var c=b.getValue(),d=c[a-1];c[a-1]=c[a],c[a]=d,b.setValue(c),b.active_tab=b.rows[a-1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),b.rows[c].movedown_button=this.getButton("","movedown","Move down"),b.rows[c].movedown_button.className+=" movedown",b.rows[c].movedown_button.setAttribute("data-i",c),b.rows[c].movedown_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),c=b.getValue();if(!(a>=c.length-1)){var d=c[a+1];c[a+1]=c[a],c[a]=d,b.setValue(c),b.active_tab=b.rows[a+1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}});var e=b.rows[c].title_controls||b.rows[c].array_controls;e&&(e.appendChild(b.rows[c].delete_button),c&&e.appendChild(b.rows[c].moveup_button),e.appendChild(b.rows[c].movedown_button)),a&&b.rows[c].setValue(a),b.refreshTabs()},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse","Collapse"),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(){a.collapsed?(a.collapsed=!1,a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse","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.setButtonText(this,"","expand","Expand"))}),this.options.collapsed&&e(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","Add "+this.getItemTitle()),this.add_row_button.addEventListener("click",function(){var b=a.rows.length;a.row_cache[b]?(a.rows[b]=a.row_cache[b],a.rows[b].container.style.display="",a.rows[b].tab&&(a.rows[b].tab.style.display=""),a.rows[b].register()):a.addRow(),a.active_tab=a.rows[b].tab,a.refreshTabs(),a.refreshValue(),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(),a.jsoneditor.notifyWatchers(a.path)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton("Last "+this.getItemTitle(),"delete","Delete Last "+this.getItemTitle()),this.delete_last_row_button.addEventListener("click",function(){var b=a.getValue(),c=null;a.rows.length>1&&a.rows[a.rows.length-1].tab===a.active_tab&&(c=a.rows[a.rows.length-2].tab),b.pop(),a.setValue(b),c&&(a.active_tab=c,a.refreshTabs()),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton("All","delete","Delete All"),this.remove_all_rows_button.addEventListener("click",function(){a.setValue([]),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),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=[],e=[];if(d(a,function(a,d){d.path===b.path?c.push(d):e.push(d)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",d(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";d(this.rows,function(a,b){b.showValidationErrors(e)})}}),g.defaults.editors.table=g.defaults.editors.array.extend({addProperty:function(){this._super(),this.value.length&&(this.table.style.display="")},removeProperty:function(){this._super(),this.table.style.display="none"},register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var b=JSON.stringify(a);if(b!==this.serialized){var c=!1,e=this;d(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):(e.addRow(b),c=!0)});for(var f=a.length;f=this.rows.length;d(this.rows,function(c,d){d.movedown_button.style.display=c===a.rows.length-1?"none":"",d.delete_button.style.display=b?"none":""}),this.value.length?1===this.value.length?(this.table.style.display="",this.remove_all_rows_button.style.display="none",this.delete_last_row_button.style.display=b?"none":""):(this.table.style.display="",b?(this.delete_last_row_button.style.display="none",this.delete_last_row_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="")):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.add_row_button.style.display=this.schema.maxItems&&this.schema.maxItems<=this.rows.length?"none":""},refreshValue:function(){var a=this;this.value=[],d(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),b.rows[c].delete_button=this.getButton("","delete","Delete"),b.rows[c].delete_button.className+=" delete",b.rows[c].delete_button.setAttribute("data-i",c),b.rows[c].delete_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),c=b.getValue(),e=[];d(c,function(b,c){b!==a&&e.push(c)}),b.setValue(e),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),b.rows[c].moveup_button=this.getButton("","moveup","Move up"),b.rows[c].moveup_button.className+=" moveup",b.rows[c].moveup_button.setAttribute("data-i",c),b.rows[c].moveup_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i");if(!(0>=a)){var c=b.getValue(),d=c[a-1];c[a-1]=c[a],c[a]=d,b.setValue(c),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),b.rows[c].movedown_button=this.getButton("","movedown","Move down"),b.rows[c].movedown_button.className+=" movedown",b.rows[c].movedown_button.setAttribute("data-i",c),b.rows[c].movedown_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),c=b.getValue();if(!(a>=c.length-1)){var d=c[a+1];c[a+1]=c[a],c[a]=d,b.setValue(c),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}});var e=b.rows[c].table_controls;e.appendChild(b.rows[c].delete_button),c&&e.appendChild(b.rows[c].moveup_button),e.appendChild(b.rows[c].movedown_button),a&&b.rows[c].setValue(a),b.jsoneditor.notifyWatchers(b.path)},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse","Collapse"),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","Collapse")):(a.collapsed=!0,a.panel.style.display="none",a.setButtonText(this,"","expand","Expand"))}),this.options.collapsed&&e(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","Add "+this.getItemTitle()),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.addRow(),a.refreshValue(),a.refreshRowButtons(),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton("Last "+this.getItemTitle(),"delete","Delete Last "+this.getItemTitle()),this.delete_last_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation();var c=a.getValue();c.pop(),a.setValue(c),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton("All","delete","Delete All"),this.remove_all_rows_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.setValue([]),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.remove_all_rows_button)}}),g.defaults.editors.multiple=g.AbstractEditor.extend({getDefault:function(){return this.schema.default||null},register:function(){if(this.editors){for(var a=0;anull";if("object"==typeof a){var c="";return d(a,function(d,e){var f=b.getHTML(e);a instanceof Array||(f="
"+d+": "+f+"
"),c+="
  • "+f+"
  • "}),c=a instanceof Array?"
      "+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.jsoneditor.notifyWatchers(this.path))},destroy:function(){this.display_area.parentNode.removeChild(this.display_area),this.title.parentNode.removeChild(this.title),this.switcher.parentNode.removeChild(this.switcher),this._super()}}),g.defaults.editors.select=g.AbstractEditor.extend({getDefault:function(){return this.schema.default||""},setValue:function(a){a=this.typecast(a||"");var b=a;this.enum_values.indexOf(b)<0&&(b=this.enum_values[0]),this.value!==b&&(this.input.value=this.enum_options[this.enum_values.indexOf(b)],this.value=b,this.jsoneditor.notifyWatchers(this.path))},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){for(var a=this.getTitle().length,b=0;b2&&$(this.input).select2(),this.register(),a.theme.afterInputReady(a.input),this.jsoneditor.notifyWatchers(this.path)},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},destroy:function(){this.label&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode.removeChild(this.description),this.input.parentNode.removeChild(this.input),this._super()}}),g.defaults.editors.multiselect=g.AbstractEditor.extend({getDefault:function(){return[]},build:function(){var a=this;this.getOption("compact",!1)||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.select_options={},this.select_values={};for(var b=this.schema.items.enum||[],c=[],d=0;d'),a.errmsg=a.parentNode.getElementsByClassName("errormsg")[0]),a.errmsg.textContent=b)},removeInputError:function(a){a.errmsg&&(a.group.className=a.group.className.replace(/ error/g,""),a.errmsg.style.display="none")}}),g.defaults.themes.foundation3=g.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},getFormInputLabel:function(a){var b=this._super(a);return b.style.fontWeight="bold",b},getTabHolder:function(){var a=document.createElement("div");return a.className="row",a.innerHTML="
    ",a},setGridColumnSize:function(a,b){var c=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];a.className="columns "+c[b]},getTab:function(a){var b=document.createElement("dd"),c=document.createElement("a");return c.setAttribute("href","#"),c.appendChild(a),b.appendChild(c),b},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.className="content active",a.style.paddingLeft="5px",a},markTabActive:function(a){a.className+=" active"},markTabInactive:function(a){a.className=a.className.replace(/\s*active/g,"")},addTab:function(a,b){a.children[0].appendChild(b)}}),g.defaults.themes.foundation4=g.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},setGridColumnSize:function(a,b){a.className="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}}),g.defaults.themes.foundation5=g.defaults.themes.foundation.extend({getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},setGridColumnSize:function(a,b){a.className="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(){var a=document.createElement("div");return a.innerHTML="
    ",a},getTab:function(a){var b=document.createElement("dd"),c=document.createElement("a");return c.setAttribute("href","#"),c.appendChild(a),b.appendChild(c),b},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.className="content active",a.style.paddingLeft="5px",a},markTabActive:function(a){a.className+=" active"},markTabInactive:function(a){a.className=a.className.replace(/\s*active/g,"")},addTab:function(a,b){a.children[0].appendChild(b)}}),g.defaults.themes.html=g.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="5px",a.style.borderRadius="3px",a},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")}}),g.defaults.themes.jqueryui=g.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.className="ui-state-active",b.style.fontWeight="bold",b},getTableCell:function(){var a=this._super();return a.className="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){var d=this._super(a,b,c);return"checkbox"===b.type?(d.style.lineHeight="25px",d.style.padding="3px 0"):d.style.padding="4px 0 8px 0",d},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.className="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.className="ui-button ui-widget ui-state-default ui-corner-all",b&&!a?(d.className+=" ui-button-icon-only",b.className+=" ui-button-icon-primary ui-icon-primary",d.appendChild(b)):b?(d.className+=" ui-button-text-icon-primary",b.className+=" ui-button-icon-primary ui-icon-primary",d.appendChild(b)):d.className+=" ui-button-text-only";var e=document.createElement("span");return e.className="ui-button-text",e.textContent=a||c||".",d.appendChild(e),d.setAttribute("title",c),d},setButtonText:function(a,b,c,d){a.innerHTML="",a.className="ui-button ui-widget ui-state-default ui-corner-all",c&&!b?(a.className+=" ui-button-icon-only",c.className+=" ui-button-icon-primary ui-icon-primary",a.appendChild(c)):c?(a.className+=" ui-button-text-icon-primary",c.className+=" ui-button-icon-primary ui-icon-primary",a.appendChild(c)):a.className+=" ui-button-text-only";var e=document.createElement("span");e.className="ui-button-text",e.textContent=b||d||".",a.appendChild(e),a.setAttribute("title",d)},getIndentedPanel:function(){var a=document.createElement("div");return a.className="ui-widget-content ui-corner-all",a.style.padding="1em 1.4em",a.style.marginBottom="20px",a},afterInputReady:function(a){a.controls||(a.controls=this.closest(a,".form-control"))},addInputError:function(a,b){a.controls&&(a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("div"),a.errmsg.className="ui-state-error",a.controls.appendChild(a.errmsg)),a.errmsg.textContent=b)},removeInputError:function(a){a.errmsg&&(a.errmsg.style.display="none")},markTabActive:function(a){a.className=a.className.replace(/\s*ui-widget-header/g,"")+" ui-state-active"},markTabInactive:function(a){a.className=a.className.replace(/\s*ui-state-active/g,"")+" ui-widget-header"}}),g.AbstractIconLib=a.extend({mapping:{collapse:"",expand:"","delete":"",edit:"",add:"",cancel:"",save:"",moveup:"",movedown:""},icon_prefix:"",getIconClass:function(a){return this.mapping[a]?this.icon_prefix+this.mapping[a]:null},getIcon:function(a){var b=this.getIconClass(a);if(!b)return null;var c=document.createElement("i");return c.className=b,c}}),g.defaults.iconlibs.bootstrap2=g.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:"icon-"}),g.defaults.iconlibs.bootstrap3=g.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-"}),g.defaults.iconlibs.fontawesome3=g.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-"}),g.defaults.iconlibs.fontawesome4=g.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"},icon_prefix:"fa fa-"}),g.defaults.iconlibs.foundation2=g.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-"}),g.defaults.iconlibs.foundation3=g.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-"}),g.defaults.iconlibs.jqueryui=g.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-"}),g.defaults.templates.default=function(){var a=function(b){var e={};return d(b,function(b,f){if("object"==typeof f&&null!==f){var g={};d(f,function(a,c){g[b+"."+a]=c}),c(e,a(g))}else e[b]=f}),e};return{compile:function(b){return function(c){var e=a(c),f=b+"";return d(e,function(a,b){f=f.replace(new RegExp("{{\\s*"+a+"\\s*}}","g"),b)}),f}}}},g.defaults.templates.ejs=function(){return window.EJS?{compile:function(a){var b=new EJS({text:a});return function(a){return b.render(a)}}}:!1},g.defaults.templates.handlebars=function(){return window.Handlebars},g.defaults.templates.hogan=function(){return window.Hogan?{compile:function(a){var b=Hogan.compile(a);return function(a){return b.render(a)}}}:!1},g.defaults.templates.markup=function(){return window.Mark&&window.Mark.up?{compile:function(a){return function(b){return Mark.up(a,b)}}}:!1},g.defaults.templates.mustache=function(){return window.Mustache?{compile:function(a){return function(b){return Mustache.render(a,b)}}}:!1},g.defaults.templates.swig=function(){return window.swig},g.defaults.templates.underscore=function(){return window._?{compile:function(a){return function(b){return _.template(a,b)}}}:!1},g.defaults.theme="html",g.defaults.template="default",g.defaults.options={},g.plugins={ace:{theme:""},epiceditor:{}};for(var h in g.defaults.editors)g.defaults.editors.hasOwnProperty(h)&&(g.defaults.editors[h].options=g.defaults.editors.options||{});g.defaults.resolvers.unshift(function(a){return"string"!=typeof a.type?"multiple":void 0}),g.defaults.resolvers.unshift(function(a){return"string"==typeof a.type?a.type:void 0}),g.defaults.resolvers.unshift(function(a){return"boolean"===a.type?"select":void 0}),g.defaults.resolvers.unshift(function(a){return"any"===a.type?"multiple":void 0}),g.defaults.resolvers.unshift(function(a){return"array"==a.type&&"table"==a.format?"table":void 0}),g.defaults.resolvers.unshift(function(a){if(a.enum){if("array"===a.type||"object"===a.type)return"enum";if("number"===a.type||"integer"===a.type||"string"===a.type)return"select"}}),g.defaults.resolvers.unshift(function(a){return"array"===a.type&&a.items&&!(a.items instanceof Array)&&a.uniqueItems&&a.items.enum&&["string","number","integer"].indexOf(a.items.type)>=0?"multiselect":void 0}),g.defaults.resolvers.unshift(function(a){return a.oneOf?"multiple":void 0}),(window.jQuery||window.Zepto)&&(window.$=window.$||{},$.jsoneditor=g.defaults,(window.jQuery||window.Zepto).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 g(this.get(0),a),this.data("jsoneditor",c),c.on("change",function(){b.trigger("change")}),c.on("ready",function(){b.trigger("ready")}))}return this}),window.JSONEditor=g}(); \ No newline at end of file +!function(){!function(){var a=!1,b=/xyz/.test(function(){postMessage("xyz")})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(c){function d(){!a&&this.init&&this.init.apply(this,arguments)}var e=this.prototype;a=!0;var f=new this;a=!1;for(var g in c)f[g]="function"==typeof c[g]&&"function"==typeof e[g]&&b.test(c[g])?function(a,b){return function(){var c=this._super;this._super=e[a];var d=b.apply(this,arguments);return this._super=c,d}}(g,c[g]):c[g];return d.prototype=f,d.prototype.constructor=d,d.extend=arguments.callee,d}}(),function(){function a(a,b){b=b||{bubbles:!1,cancelable:!1,detail:void 0};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail),c}a.prototype=window.Event.prototype,window.CustomEvent=a}(),function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c=e){if(h)return;h=!0,i._getRefs(a,d)}},c(k,function(){e++}),e?c(k,function(b,c){i._getRefs(c,function(c){i.refs["#/definitions/"+b]=c,f++,g(a)})}):g(a)}else if(a.$ref){var l=a.$ref;if(delete a.$ref,i.refs[l]&&i.refs[l]instanceof Array)i.refs[l].push(function(){a=b({},i.refs[l],a),d(a)});else if(i.refs[l])a=b({},i.refs[l],a),d(a);else{if(!i.options.ajax)throw"Must set ajax option to true to load external url "+l;var m=new XMLHttpRequest;m.open("GET",l,!0),m.onreadystatechange=function(){if(4==m.readyState){if(200===m.status){var e=JSON.parse(m.responseText);return i.refs[l]=[],void i._getRefs(e,function(e){var f=i.refs[l];i.refs[l]=e,a=b({},i.refs[l],a),d(a),c(f,function(a,b){b()})})}throw"Failed to fetch ref via ajax- "+l}},m.send()}}else e=f=0,g=function(a){if(f>=e){if(h)return;h=!0,d(a)}},c(a,function(a,b){"object"==typeof b&&b&&b instanceof Array?c(b,function(a,b){"object"!=typeof b||!b||b instanceof Array||e++}):"object"==typeof b&&b&&e++}),e?c(a,function(b,d){"object"==typeof d&&d&&d instanceof Array?c(d,function(c,d){"object"!=typeof d||!d||d instanceof Array||i._getRefs(d,function(d){a[b][c]=d,f++,g(a)})}):"object"==typeof d&&d&&i._getRefs(d,function(c){a[b]=c,f++,g(a)})}):g(a)},validate:function(a){return this._validateSchema(this.schema,a)},_validateSchema:function(a,d,e){var g,h,i,j=[],k=JSON.stringify(d);if(e=e||"root",a=b({},a),a.required&&a.required===!0){if("undefined"==typeof d)return j.push({path:e,property:"required",message:"Property must be set"}),j}else if("undefined"==typeof d){if(!this.options.required_by_default)return j;j.push({path:e,property:"required",message:"Property must be set"})}if(a.enum){for(g=!1,h=0;h=a.maximum?j.push({path:e,property:"maximum",message:"Value must be less than "+a.maximum}):!a.exclusiveMaximum&&d>a.maximum&&j.push({path:e,property:"maximum",message:"Value must be at most "+a.maximum})),a.minimum&&(a.exclusiveMinimum&&d<=a.minimum?j.push({path:e,property:"minimum",message:"Value must be greater than "+a.minimum}):!a.exclusiveMinimum&&da.maxLength&&j.push({path:e,property:"maxLength",message:"Value must be at most "+a.maxLength+" characters long"}),a.minLength&&(d+"").lengtha.maxItems&&j.push({path:e,property:"maxItems",message:"Value must have at most "+a.maxItems+" items"}),a.minItems&&d.lengtha.maxProperties&&j.push({path:e,property:"maxProperties",message:"Object must have at most "+a.maxProperties+" properties"})}if(a.minProperties){g=0;for(h in d)d.hasOwnProperty(h)&&g++;g=0){b=this.theme.getBlockLinkHolder(),c=this.theme.getBlockLink(),c.setAttribute("target","_blank");var h=document.createElement(e);h.setAttribute("controls","controls"),this.theme.createMediaLink(b,c,h),this.link_watchers.push(function(b){var d=f(b);c.setAttribute("href",d),c.textContent=a.rel||d,h.setAttribute("src",d)})}else b=this.theme.getBlockLink(),b.setAttribute("target","_blank"),b.textContent=a.rel,this.link_watchers.push(function(c){var d=f(c);b.setAttribute("href",d),b.textContent=a.rel||d});return 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(){this.header&&(this.header.textContent=this.getHeaderText())},getHeaderText:function(a){return this.header_text?this.header_text:a?this.schema.title:this.getTitle()},onWatchedFieldChange:function(){var a;if(this.header_template){a=b(this.getWatchedFieldValues(),{key:this.key,i:this.key,title:this.getTitle()});var c=this.header_template(a);c!==this.header_text&&(this.header_text=c,this.updateHeaderText(),this.fireChangeHeaderEvent())}if(this.link_watchers.length){a=this.getWatchedFieldValues();for(var d=0;d1&&(b[a]=c+" "+e[c])}),b},showValidationErrors:function(){}}),f.defaults.editors.null=f.AbstractEditor.extend({getValue:function(){return null},setValue:function(){this.jsoneditor.notifyWatchers(this.path)},getNumColumns:function(){return 2}}),f.defaults.editors.string=f.AbstractEditor.extend({getDefault:function(){return this.schema.default||""},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){var d=this;if((!this.template||c)&&(a=a||"","object"==typeof a&&(a=JSON.stringify(a)),"string"!=typeof a&&(a=""+a),a!==this.serialized)){var e=this.sanitize(a);if(this.select_options&&this.select_options.indexOf(e)<0&&(e=this.select_options[0]),this.input.value!==e){this.input.value=e,this.sceditor_instance?this.sceditor_instance.val(e):this.epiceditor?this.epiceditor.importFile(null,e):this.ace_editor&&this.ace_editor.setValue(e);var f=c||this.getValue()!==a;this.refreshValue(),f&&(d.parent?d.parent.onChildEditorChange(d):d.jsoneditor.onChange()),this.watch_listener(),this.jsoneditor.notifyWatchers(this.path)}}},removeProperty:function(){this._super(),this.input.style.display="none",this.description&&(this.description.style.display="none"),this.theme.disableLabel(this.label)},addProperty:function(){this._super(),this.input.style.display="",this.description&&(this.description.style.display=""),this.theme.enableLabel(this.label)},getNumColumns:function(){var a,b=Math.ceil(this.getTitle().length/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,c=this;if(this.getOption("compact",!1)||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),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.schema.enum)this.input_type="select",this.select_options=this.schema.enum,this.input=this.theme.getSelectInput(this.select_options);else if(this.schema.enumSource){if(this.input_type="select",this.input=this.theme.getSelectInput([]),this.enumSource=[],this.schema.enumSource instanceof Array)for(a=0;a=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);"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.getOption("compact")&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact"),(this.schema.readOnly||this.schema.readonly||this.schema.template)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(a){if(a.preventDefault(),a.stopPropagation(),c.schema.template)return void(this.value=c.value);var b=this.value,d=c.sanitize(b);b!==d&&(this.value=d),c.refreshValue(),c.watch_listener(),c.jsoneditor.notifyWatchers(c.path),c.parent?c.parent.onChildEditorChange(c):c.jsoneditor.onChange()}),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.getTheme().getFormControl(this.label,this.input,this.description),this.container.appendChild(this.control),"select"===this.input_type&&window.$&&$.fn&&$.fn.select2&&$(this.input).select2(),requestAnimationFrame(function(){c.afterInputReady()}),this.register(),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue(),this.jsoneditor.notifyWatchers(this.path)):(this.refreshValue(),this.jsoneditor.notifyWatchers(this.path))},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},afterInputReady:function(){var a,c=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.$&&$.fn&&$.fn.sceditor)a=b({},{plugins:"html"===c.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300},f.plugins.sceditor),$(c.input).sceditor(a),c.sceditor_instance=$(c.input).sceditor("instance"),c.sceditor_instance.blur(function(){var a=$("
    "+c.sceditor_instance.val()+"
    ");$("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",a).remove(),c.input.value=a.html(),c.parent?c.parent.onChildEditorChange(c):c.jsoneditor.onChange(),c.jsoneditor.notifyWatchers(c.path)});else if("markdown"===this.input_type&&window.EpicEditor)this.epiceditor_container=document.createElement("div"),this.input.parentNode.insertBefore(this.epiceditor_container,this.input),this.input.style.display="none",a=b({},f.plugins.epiceditor,{container:this.epiceditor_container,clientSideStorage:!1}),this.epiceditor=new EpicEditor(a).load(),this.epiceditor.importFile(null,this.getValue()),this.epiceditor.on("update",function(){var a=c.epiceditor.exportFile(); +c.input.value=a,c.value=a,c.parent?c.parent.onChildEditorChange(c):c.jsoneditor.onChange(),c.jsoneditor.notifyWatchers(c.path)});else if(window.ace){var d=this.input_type;("cpp"===d||"c++"===d||"c"===d)&&(d="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=ace.edit(this.ace_container),this.ace_editor.setValue(this.getValue()),f.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+f.plugins.ace.theme),d=ace.require("ace/mode/"+d),d&&this.ace_editor.getSession().setMode(new d.Mode),this.ace_editor.on("change",function(){var a=c.ace_editor.getValue();c.input.value=a,c.refreshValue(),c.parent?c.parent.onChildEditorChange(c):c.jsoneditor.onChange(),c.jsoneditor.notifyWatchers(c.path)})}c.theme.afterInputReady(c.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.epiceditor?this.epiceditor.unload():this.ace_editor&&this.ace_editor.destroy(),this.template=null,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,b;if(this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this.enumSource){a=this.getWatchedFieldValues();for(var c=[],d=[],e=0;ee)&&(c=g);c===!1&&(f.push({width:0,minh:999999,maxh:0,editors:[]}),c=f.length-1),f[c].editors.push({key:a,width:d,height:e}),f[c].width+=d,f[c].minh=Math.min(f[c].minh,e),f[c].maxh=Math.max(f[c].maxh,e)}}),a=0;af[a].editors[g].width&&(g=b),f[a].editors[b].width*=12/f[a].width,f[a].editors[b].width=Math.floor(f[a].editors[b].width),h+=f[a].editors[b].width;12>h&&(f[a].editors[g].width+=12-h),f[a].width=12}if(this.layout===JSON.stringify(f))return!1;for(this.layout=JSON.stringify(f),e=document.createElement("div"),a=0;a=0),a.editors[b]=a.jsoneditor.createEditor(d,{jsoneditor:a.jsoneditor,schema:c,container:e,path:a.path+"."+b,parent:a,required:f}),a.minwidth=Math.max(a.minwidth,a.editors[b].getNumColumns()),a.maxwidth+=a.editors[b].getNumColumns()}),this.layoutEditors(),this.layoutEditors(),this.title_controls=this.getTheme().getHeaderButtonHolder(),this.editjson_controls=this.getTheme().getHeaderButtonHolder(),this.addproperty_controls=this.getTheme().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","Collapse"),this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(){a.collapsed?(a.editor_holder.style.display="",a.collapsed=!1,a.setButtonText(a.toggle_button,"","collapse","Collapse")):(a.editor_holder.style.display="none",a.collapsed=!0,a.setButtonText(a.toggle_button,"","expand","Expand"))}),this.options.collapsed&&d(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.addEventListener("click",function(){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.addEventListener("click",function(){a.toggleAddProperty()}),this.addproperty_controls.appendChild(this.addproperty_button),this.addproperty_controls.appendChild(this.addproperty_holder),this.refreshAddProperties()}this.jsoneditor.notifyWatchers(this.path)},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)},saveJSON:function(){if(this.editjson_holder)try{var a=JSON.parse(this.editjson_textarea.value);this.setValue(a),this.hideEditJSON()}catch(b){throw alert("invalid JSON"),b}},toggleEditJSON:function(){this.editing_json?this.hideEditJSON():this.showEditJSON()},addPropertyCheckbox:function(a){var b=this.editors[a];if(b){var c,d,e,f=this;return c=f.theme.getCheckbox(),c.style.width="auto",d=f.theme.getCheckboxLabel(a),e=f.theme.getFormControl(d,c),e.style.paddingBottom=e.style.marginBottom=e.style.paddingTop=e.style.marginTop=0,e.style.height="auto",f.addproperty_list.appendChild(e),c.checked=!b.property_removed,b.isRequired()&&(c.disabled=!0),c.addEventListener("change",function(){c.checked?f.addObjectProperty(a):f.removeObjectProperty(a)}),c}},showAddProperty:function(){if(this.addproperty_holder){this.hideEditJSON(),this.addproperty_holder.style.left=this.addproperty_button.offsetLeft+"px",this.addproperty_holder.style.top=this.addproperty_button.offsetTop+this.addproperty_button.offsetHeight+"px",this.addproperty_list.innerHTML="";var a=this;this.addproperty_checkboxes={},c(this.editors,function(b){a.addproperty_checkboxes[b]=a.addPropertyCheckbox(b)}),this.disable(),this.adding_property=!0,this.addproperty_button.disabled=!1,this.addproperty_holder.style.display="",this.refreshAddProperties()}},hideAddProperty:function(){this.addproperty_holder&&this.adding_property&&(this.addproperty_holder.style.display="none",this.enable(),this.adding_property=!1)},toggleAddProperty:function(){this.adding_property?this.hideAddProperty():this.showAddProperty()},removeObjectProperty:function(a){this.editors[a]&&(this.editors[a].property_removed=!0,this.editors[a].unregister(),this.refreshValue(),this.layoutEditors(),this.jsoneditor.notifyWatchers(this.path),this.parent?this.parent.onChildEditorChange(this):this.jsoneditor.onChange())},addObjectProperty:function(a){var d=this;if(this.editors[a]){if(!this.editors[a].property_removed)return;this.editors[a].property_removed=!1,this.editors[a].register(),this.jsoneditor.notifyWatchers(this.editors[a].path)}else{var e={},f=!1;d.schema.patternProperties&&c(d.schema.patternProperties,function(c,d){var g=new RegExp(c);g.test(a)&&(f=!0,e=b(e,d))}),f||"object"!=typeof d.schema.additionalProperties||(e=b(e,d.schema.additionalProperties));var g=d.jsoneditor.getEditorClass(e,d.jsoneditor),h=d.getTheme().getChildEditorHolder();d.editor_holder.appendChild(h),d.editors[a]=d.jsoneditor.createEditor(g,{jsoneditor:d.jsoneditor,schema:e,container:h,path:d.path+"."+a,parent:d,required:!1}),d.editors[a].not_core=!0}d.refreshValue(),d.jsoneditor.notifyWatchers(d.path),d.parent?d.parent.onChildEditorChange(d):d.jsoneditor.onChange(),d.layoutEditors()},onChildEditorChange:function(a){this.refreshValue(),this._super(a)},canHaveAdditionalProperties:function(){return this.schema.additionalProperties!==!1&&!this.jsoneditor.options.no_additional_properties},destroy:function(){c(this.editors,function(a,b){b.destroy()}),this.editor_holder.innerHTML="",this.title&&this.title.parentNode.removeChild(this.title),this.error_holder&&this.error_holder.parentNode.removeChild(this.error_holder),this.editors=null,this.editor_holder.parentNode.removeChild(this.editor_holder),this.editor_holder=null,this._super()},refreshValue:function(){this.value={},this.serialized="";var a=this,b=0,d=!1,e=this.editors;c(this.editors,function(a,b){b.property_removed&&b.not_core&&(e={},d=!0)}),c(this.editors,function(c,f){if(f.property_removed){if(!f.not_core&&d)e[c]=f;else if(f.not_core){var g=f.container;f.destroy(),g.parentNode&&g.parentNode.removeChild(g)}}else d&&(e[c]=f),b++,a.value[c]=f.getValue()}),this.editors=e,this.adding_property&&this.refreshAddProperties()},refreshAddProperties:function(){if(this.options.disable_properties||this.jsoneditor.options.disable_properties)return void(this.addproperty_controls.style.display="none");var a,b=!1,c=!1,d=0,e=!1;for(a in this.editors)this.editors.hasOwnProperty(a)&&(this.editors[a].property_removed||d++);b=this.canHaveAdditionalProperties()&&!("undefined"!=typeof this.schema.maxProperties&&d>=this.schema.maxProperties);for(a in this.editors)this.editors.hasOwnProperty(a)&&(this.editors[a].isRequired()?this.addproperty_checkboxes&&this.addproperty_checkboxes[a]&&(this.addproperty_checkboxes[a].disabled=!0):"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?this.addproperty_checkboxes&&this.addproperty_checkboxes[a]?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):this.editors[a].property_removed&&b&&(e=!0):this.editors[a].property_removed?this.addproperty_checkboxes&&this.addproperty_checkboxes[a]?b?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0:b&&(e=!0):(this.addproperty_checkboxes&&this.addproperty_checkboxes[a]&&(this.addproperty_checkboxes[a].disabled=!1),e=!0,c=!0));if(this.canHaveAdditionalProperties()&&(e=!0),this.addproperty_checkboxes)for(a in this.addproperty_checkboxes)this.addproperty_checkboxes.hasOwnProperty(a)&&(this.editors[a]||(e=!0,this.addproperty_checkboxes[a].disabled=!b&&!c));e?this.canHaveAdditionalProperties()?this.addproperty_add.disabled=b?!1:!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},setValue:function(a,b){var d=this;a=a||{},("object"!=typeof a||a instanceof Array)&&(a={}),c(this.editors,function(c,e){if("undefined"!=typeof a[c])e.property_removed&&d.addObjectProperty(c),e.setValue(a[c],b);else{if(!b&&!e.property_removed&&!e.isRequired())return void d.removeObjectProperty(c);e.setValue(e.getDefault(),b)}}),this.canHaveAdditionalProperties()&&c(a,function(a,c){d.editors[a]||(d.addObjectProperty(a),d.editors[a]&&d.editors[a].setValue(c,b))}),this.refreshValue(),this.jsoneditor.notifyWatchers(this.path)},showValidationErrors:function(a){var b=this,d=[],e=[];if(c(a,function(a,c){c.path===b.path?d.push(c):e.push(c)}),this.error_holder)if(d.length){this.error_holder.innerHTML="",this.error_holder.style.display="",c(d,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";this.getOption("table_row")&&(d.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),c(this.editors,function(a,b){b.showValidationErrors(e)})}}),f.defaults.editors.array=f.AbstractEditor.extend({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?b({},this.schema.additionalItems):void 0:b({},this.schema.items[a]):this.schema.items?b({},this.schema.items):{}},getItemInfo:function(a){var b=this.getItemSchema(a);this.item_info=this.item_info||{};var c=JSON.stringify(b);if("undefined"!=typeof this.item_info[c])return this.item_info[c];var d=document.createElement("div");this.container.appendChild(d),d.addEventListener("change_header_text",function(a){a.preventDefault(),a.stopPropagation()});var e=this.jsoneditor.getEditorClass(b,this.jsoneditor);return e=this.jsoneditor.createEditor(e,{jsoneditor:this.jsoneditor,schema:b,container:d,path:this.path+"."+a,parent:this,required:!0}),this.item_info[c]={child_editors:e.getChildEditors()?!0:!1,title:b.title||"item",width:e.getNumColumns(),"default":e.getDefault()},e.destroy(),d.parentNode&&d.parentNode.removeChild(d),this.item_info[c]},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c.title=b.title+" "+a;var d,e=this.jsoneditor.getEditorClass(c,this.jsoneditor);d=this.tabs_holder?this.theme.getTabContent():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.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode.removeChild(this.controls),this.panel&&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;c(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 this.schema.items instanceof Array&&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;c(this.rows,function(c,d){d.tab&&(a?d.tab_text.textContent=d.getHeaderText():d.tab===b.active_tab?(b.theme.markTabActive(d.tab),d.container.style.display=""):(b.theme.markTabInactive(d.tab),d.container.style.display="none"))})},setValue:function(a){a=a||[],a instanceof Array||(a=[a]);var b=JSON.stringify(a);if(b!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var d=this;c(a,function(a,b){d.rows[a]?d.rows[a].setValue(b):d.row_cache[a]?(d.rows[a]=d.row_cache[a],d.rows[a].setValue(b),d.rows[a].container.style.display="",d.rows[a].tab&&(d.rows[a].tab.style.display=""),d.rows[a].register()):d.addRow(b)});for(var e=a.length;e=this.rows.length;c(this.rows,function(b,c){c.movedown_button.style.display=b===a.rows.length-1?"none":"",c.delete_button.style.display=d?"none":"",a.value[b]=c.getValue()}),this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",this.delete_last_row_button.style.display=d?"none":""):d?(this.delete_last_row_button.style.display="none",this.delete_last_row_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display=""):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.add_row_button.style.display=this.getMax()&&this.getMax()<=this.rows.length?"none":""}},addRow:function(a){var b=this,d=this.rows.length;b.rows[d]=this.getElementEditor(d),b.row_cache[d]=b.rows[d],b.tabs_holder&&(b.rows[d].tab_text=document.createElement("span"),b.rows[d].tab_text.textContent=b.rows[d].getHeaderText(),b.rows[d].tab=b.theme.getTab(b.rows[d].tab_text),b.rows[d].tab.addEventListener("click",function(a){b.active_tab=b.rows[d].tab,b.refreshTabs(),a.preventDefault(),a.stopPropagation()}),b.theme.addTab(b.tabs_holder,b.rows[d].tab)),b.rows[d].delete_button=this.getButton(b.getItemTitle(),"delete","Delete "+b.getItemTitle()),b.rows[d].delete_button.className+=" delete",b.rows[d].delete_button.setAttribute("data-i",d),b.rows[d].delete_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),d=b.getValue(),e=[],f=null;c(d,function(c,d){return c===a?void(b.rows[c].tab===b.active_tab&&(b.rows[c+1]?f=b.rows[c+1].tab:c&&(f=b.rows[c-1].tab))):void e.push(d)}),b.setValue(e),f&&(b.active_tab=f,b.refreshTabs()),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),b.rows[d].moveup_button=this.getButton("","moveup","Move up"),b.rows[d].moveup_button.className+=" moveup",b.rows[d].moveup_button.setAttribute("data-i",d),b.rows[d].moveup_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i");if(!(0>=a)){var c=b.getValue(),d=c[a-1];c[a-1]=c[a],c[a]=d,b.setValue(c),b.active_tab=b.rows[a-1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),b.rows[d].movedown_button=this.getButton("","movedown","Move down"),b.rows[d].movedown_button.className+=" movedown",b.rows[d].movedown_button.setAttribute("data-i",d),b.rows[d].movedown_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),c=b.getValue();if(!(a>=c.length-1)){var d=c[a+1];c[a+1]=c[a],c[a]=d,b.setValue(c),b.active_tab=b.rows[a+1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}});var e=b.rows[d].title_controls||b.rows[d].array_controls;e&&(e.appendChild(b.rows[d].delete_button),d&&e.appendChild(b.rows[d].moveup_button),e.appendChild(b.rows[d].movedown_button)),a&&b.rows[d].setValue(a),b.refreshTabs()},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse","Collapse"),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(){a.collapsed?(a.collapsed=!1,a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse","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.setButtonText(this,"","expand","Expand"))}),this.options.collapsed&&d(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","Add "+this.getItemTitle()),this.add_row_button.addEventListener("click",function(){var b=a.rows.length;a.row_cache[b]?(a.rows[b]=a.row_cache[b],a.rows[b].container.style.display="",a.rows[b].tab&&(a.rows[b].tab.style.display=""),a.rows[b].register()):a.addRow(),a.active_tab=a.rows[b].tab,a.refreshTabs(),a.refreshValue(),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(),a.jsoneditor.notifyWatchers(a.path)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton("Last "+this.getItemTitle(),"delete","Delete Last "+this.getItemTitle()),this.delete_last_row_button.addEventListener("click",function(){var b=a.getValue(),c=null;a.rows.length>1&&a.rows[a.rows.length-1].tab===a.active_tab&&(c=a.rows[a.rows.length-2].tab),b.pop(),a.setValue(b),c&&(a.active_tab=c,a.refreshTabs()),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton("All","delete","Delete All"),this.remove_all_rows_button.addEventListener("click",function(){a.setValue([]),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),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,d=[],e=[];if(c(a,function(a,c){c.path===b.path?d.push(c):e.push(c)}),this.error_holder)if(d.length){this.error_holder.innerHTML="",this.error_holder.style.display="",c(d,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";c(this.rows,function(a,b){b.showValidationErrors(e)})}}),f.defaults.editors.table=f.defaults.editors.array.extend({addProperty:function(){this._super(),this.value.length&&(this.table.style.display="")},removeProperty:function(){this._super(),this.table.style.display="none"},register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var b=JSON.stringify(a);if(b!==this.serialized){var d=!1,e=this;c(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):(e.addRow(b),d=!0)});for(var f=a.length;f=this.rows.length;c(this.rows,function(c,d){d.movedown_button.style.display=c===a.rows.length-1?"none":"",d.delete_button.style.display=b?"none":""}),this.value.length?1===this.value.length?(this.table.style.display="",this.remove_all_rows_button.style.display="none",this.delete_last_row_button.style.display=b?"none":""):(this.table.style.display="",b?(this.delete_last_row_button.style.display="none",this.delete_last_row_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="")):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.add_row_button.style.display=this.schema.maxItems&&this.schema.maxItems<=this.rows.length?"none":""},refreshValue:function(){var a=this;this.value=[],c(this.rows,function(b,c){a.value[b]=c.getValue()}),this.serialized=JSON.stringify(this.value)},addRow:function(a){var b=this,d=this.rows.length;b.rows[d]=this.getElementEditor(d),b.rows[d].delete_button=this.getButton("","delete","Delete"),b.rows[d].delete_button.className+=" delete",b.rows[d].delete_button.setAttribute("data-i",d),b.rows[d].delete_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),d=b.getValue(),e=[];c(d,function(b,c){b!==a&&e.push(c)}),b.setValue(e),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),b.rows[d].moveup_button=this.getButton("","moveup","Move up"),b.rows[d].moveup_button.className+=" moveup",b.rows[d].moveup_button.setAttribute("data-i",d),b.rows[d].moveup_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i");if(!(0>=a)){var c=b.getValue(),d=c[a-1];c[a-1]=c[a],c[a]=d,b.setValue(c),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),b.rows[d].movedown_button=this.getButton("","movedown","Move down"),b.rows[d].movedown_button.className+=" movedown",b.rows[d].movedown_button.setAttribute("data-i",d),b.rows[d].movedown_button.addEventListener("click",function(){var a=1*this.getAttribute("data-i"),c=b.getValue();if(!(a>=c.length-1)){var d=c[a+1];c[a+1]=c[a],c[a]=d,b.setValue(c),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}});var e=b.rows[d].table_controls;e.appendChild(b.rows[d].delete_button),d&&e.appendChild(b.rows[d].moveup_button),e.appendChild(b.rows[d].movedown_button),a&&b.rows[d].setValue(a),b.jsoneditor.notifyWatchers(b.path)},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse","Collapse"),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","Collapse")):(a.collapsed=!0,a.panel.style.display="none",a.setButtonText(this,"","expand","Expand"))}),this.options.collapsed&&d(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","Add "+this.getItemTitle()),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.addRow(),a.refreshValue(),a.refreshRowButtons(),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton("Last "+this.getItemTitle(),"delete","Delete Last "+this.getItemTitle()),this.delete_last_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation();var c=a.getValue();c.pop(),a.setValue(c),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton("All","delete","Delete All"),this.remove_all_rows_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.setValue([]),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}),a.controls.appendChild(this.remove_all_rows_button)}}),f.defaults.editors.multiple=f.AbstractEditor.extend({getDefault:function(){return this.schema.default||null},register:function(){if(this.editors){for(var a=0;anull";if("object"==typeof a){var d="";return c(a,function(c,e){var f=b.getHTML(e);a instanceof Array||(f="
    "+c+": "+f+"
    "),d+="
  • "+f+"
  • "}),d=a instanceof Array?"
      "+d+"
    ":"
      "+d+"
    "}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.jsoneditor.notifyWatchers(this.path))},destroy:function(){this.display_area.parentNode.removeChild(this.display_area),this.title.parentNode.removeChild(this.title),this.switcher.parentNode.removeChild(this.switcher),this._super()}}),f.defaults.editors.select=f.AbstractEditor.extend({getDefault:function(){return this.schema.default||""},setValue:function(a){a=this.typecast(a||"");var b=a;this.enum_values.indexOf(b)<0&&(b=this.enum_values[0]),this.value!==b&&(this.input.value=this.enum_options[this.enum_values.indexOf(b)],this.value=b,this.jsoneditor.notifyWatchers(this.path))},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){for(var a=this.getTitle().length,b=0;b2&&$(this.input).select2(),this.register(),a.theme.afterInputReady(a.input),this.jsoneditor.notifyWatchers(this.path)},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},destroy:function(){this.label&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode.removeChild(this.description),this.input.parentNode.removeChild(this.input),this._super()}}),f.defaults.editors.multiselect=f.AbstractEditor.extend({getDefault:function(){return[]},build:function(){var a,b=this;this.getOption("compact",!1)||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.select_options={},this.select_values={};var c=this.schema.items.enum||[],d=[];for(a=0;a'),a.errmsg=a.parentNode.getElementsByClassName("errormsg")[0]),a.errmsg.textContent=b)},removeInputError:function(a){a.errmsg&&(a.group.className=a.group.className.replace(/ error/g,""),a.errmsg.style.display="none")}}),f.defaults.themes.foundation3=f.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},getFormInputLabel:function(a){var b=this._super(a);return b.style.fontWeight="bold",b},getTabHolder:function(){var a=document.createElement("div");return a.className="row",a.innerHTML="
    ",a},setGridColumnSize:function(a,b){var c=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];a.className="columns "+c[b]},getTab:function(a){var b=document.createElement("dd"),c=document.createElement("a");return c.setAttribute("href","#"),c.appendChild(a),b.appendChild(c),b},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.className="content active",a.style.paddingLeft="5px",a},markTabActive:function(a){a.className+=" active"},markTabInactive:function(a){a.className=a.className.replace(/\s*active/g,"")},addTab:function(a,b){a.children[0].appendChild(b)}}),f.defaults.themes.foundation4=f.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},setGridColumnSize:function(a,b){a.className="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}}),f.defaults.themes.foundation5=f.defaults.themes.foundation.extend({getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},setGridColumnSize:function(a,b){a.className="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(){var a=document.createElement("div");return a.innerHTML="
    ",a},getTab:function(a){var b=document.createElement("dd"),c=document.createElement("a");return c.setAttribute("href","#"),c.appendChild(a),b.appendChild(c),b},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.className="content active",a.style.paddingLeft="5px",a},markTabActive:function(a){a.className+=" active"},markTabInactive:function(a){a.className=a.className.replace(/\s*active/g,"")},addTab:function(a,b){a.children[0].appendChild(b)}}),f.defaults.themes.html=f.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="5px",a.style.borderRadius="3px",a},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")}}),f.defaults.themes.jqueryui=f.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.className="ui-state-active",b.style.fontWeight="bold",b},getTableCell:function(){var a=this._super();return a.className="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){var d=this._super(a,b,c);return"checkbox"===b.type?(d.style.lineHeight="25px",d.style.padding="3px 0"):d.style.padding="4px 0 8px 0",d},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.className="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.className="ui-button ui-widget ui-state-default ui-corner-all",b&&!a?(d.className+=" ui-button-icon-only",b.className+=" ui-button-icon-primary ui-icon-primary",d.appendChild(b)):b?(d.className+=" ui-button-text-icon-primary",b.className+=" ui-button-icon-primary ui-icon-primary",d.appendChild(b)):d.className+=" ui-button-text-only";var e=document.createElement("span");return e.className="ui-button-text",e.textContent=a||c||".",d.appendChild(e),d.setAttribute("title",c),d},setButtonText:function(a,b,c,d){a.innerHTML="",a.className="ui-button ui-widget ui-state-default ui-corner-all",c&&!b?(a.className+=" ui-button-icon-only",c.className+=" ui-button-icon-primary ui-icon-primary",a.appendChild(c)):c?(a.className+=" ui-button-text-icon-primary",c.className+=" ui-button-icon-primary ui-icon-primary",a.appendChild(c)):a.className+=" ui-button-text-only";var e=document.createElement("span");e.className="ui-button-text",e.textContent=b||d||".",a.appendChild(e),a.setAttribute("title",d)},getIndentedPanel:function(){var a=document.createElement("div");return a.className="ui-widget-content ui-corner-all",a.style.padding="1em 1.4em",a.style.marginBottom="20px",a},afterInputReady:function(a){a.controls||(a.controls=this.closest(a,".form-control"))},addInputError:function(a,b){a.controls&&(a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("div"),a.errmsg.className="ui-state-error",a.controls.appendChild(a.errmsg)),a.errmsg.textContent=b)},removeInputError:function(a){a.errmsg&&(a.errmsg.style.display="none")},markTabActive:function(a){a.className=a.className.replace(/\s*ui-widget-header/g,"")+" ui-state-active"},markTabInactive:function(a){a.className=a.className.replace(/\s*ui-state-active/g,"")+" ui-widget-header"}}),f.AbstractIconLib=Class.extend({mapping:{collapse:"",expand:"","delete":"",edit:"",add:"",cancel:"",save:"",moveup:"",movedown:""},icon_prefix:"",getIconClass:function(a){return this.mapping[a]?this.icon_prefix+this.mapping[a]:null},getIcon:function(a){var b=this.getIconClass(a);if(!b)return null;var c=document.createElement("i");return c.className=b,c}}),f.defaults.iconlibs.bootstrap2=f.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:"icon-"}),f.defaults.iconlibs.bootstrap3=f.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-"}),f.defaults.iconlibs.fontawesome3=f.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-"}),f.defaults.iconlibs.fontawesome4=f.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"},icon_prefix:"fa fa-"}),f.defaults.iconlibs.foundation2=f.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-"}),f.defaults.iconlibs.foundation3=f.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-"}),f.defaults.iconlibs.jqueryui=f.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-"}),f.defaults.templates.default=function(){var a=function(d){var e={};return c(d,function(d,f){if("object"==typeof f&&null!==f){var g={};c(f,function(a,b){g[d+"."+a]=b}),b(e,a(g))}else e[d]=f}),e};return{compile:function(b){return function(d){var e=a(d),f=b+"";return c(e,function(a,b){f=f.replace(new RegExp("{{\\s*"+a+"\\s*}}","g"),b)}),f}}}},f.defaults.templates.ejs=function(){return window.EJS?{compile:function(a){var b=new EJS({text:a});return function(a){return b.render(a)}}}:!1},f.defaults.templates.handlebars=function(){return window.Handlebars},f.defaults.templates.hogan=function(){return window.Hogan?{compile:function(a){var b=Hogan.compile(a);return function(a){return b.render(a)}}}:!1},f.defaults.templates.markup=function(){return window.Mark&&window.Mark.up?{compile:function(a){return function(b){return Mark.up(a,b)}}}:!1},f.defaults.templates.mustache=function(){return window.Mustache?{compile:function(a){return function(b){return Mustache.render(a,b)}}}:!1},f.defaults.templates.swig=function(){return window.swig},f.defaults.templates.underscore=function(){return window._?{compile:function(a){return function(b){return _.template(a,b)}}}:!1},f.defaults.theme="html",f.defaults.template="default",f.defaults.options={},f.plugins={ace:{theme:""},epiceditor:{},sceditor:{}};for(var g in f.defaults.editors)f.defaults.editors.hasOwnProperty(g)&&(f.defaults.editors[g].options=f.defaults.editors.options||{});f.defaults.resolvers.unshift(function(a){return"string"!=typeof a.type?"multiple":void 0}),f.defaults.resolvers.unshift(function(a){return"string"==typeof a.type?a.type:void 0}),f.defaults.resolvers.unshift(function(a){return"boolean"===a.type?"select":void 0}),f.defaults.resolvers.unshift(function(a){return"any"===a.type?"multiple":void 0}),f.defaults.resolvers.unshift(function(a){return"array"==a.type&&"table"==a.format?"table":void 0}),f.defaults.resolvers.unshift(function(a){if(a.enum){if("array"===a.type||"object"===a.type)return"enum";if("number"===a.type||"integer"===a.type||"string"===a.type)return"select"}}),f.defaults.resolvers.unshift(function(a){return"array"===a.type&&a.items&&!(a.items instanceof Array)&&a.uniqueItems&&a.items.enum&&["string","number","integer"].indexOf(a.items.type)>=0?"multiselect":void 0}),f.defaults.resolvers.unshift(function(a){return a.oneOf?"multiple":void 0}),(window.jQuery||window.Zepto)&&(window.$=window.$||{},$.jsoneditor=f.defaults,(window.jQuery||window.Zepto).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 f(this.get(0),a),this.data("jsoneditor",c),c.on("change",function(){b.trigger("change")}),c.on("ready",function(){b.trigger("ready")}))}return this}),window.JSONEditor=f}(); \ No newline at end of file diff --git a/package.json b/package.json index 9242cea9b..4baab750f 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "grunt-contrib-concat": "~0.3.0", "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-watch": "~0.5.3", + "grunt-contrib-jshint": "^0.10.0" "grunt": "~0.4.2" } } diff --git a/src/class.js b/src/class.js index 8cf774e4d..c66681902 100644 --- a/src/class.js +++ b/src/class.js @@ -1,6 +1,65 @@ +/*jshint loopfunc: true */ /* Simple JavaScript Inheritance -* By John Resig http://ejohn.org/ -* MIT Licensed. -*/ + * By John Resig http://ejohn.org/ + * MIT Licensed. + */ // Inspired by base2 and Prototype -var Class;!function(){var a=!1,b=/xyz/.test(function(){})?/\b_super\b/:/.*/;Class=function(){},Class.extend=function(c){function g(){!a&&this.init&&this.init.apply(this,arguments)}var d=this.prototype;a=!0;var e=new this;a=!1;for(var f in c)e[f]="function"==typeof c[f]&&"function"==typeof d[f]&&b.test(c[f])?function(a,b){return function(){var c=this._super;this._super=d[a];var e=b.apply(this,arguments);return this._super=c,e}}(f,c[f]):c[f];return g.prototype=e,g.prototype.constructor=g,g.extend=arguments.callee,g}}(); +(function(){ + var initializing = false, fnTest = /xyz/.test(function(){postMessage("xyz");}) ? /\b_super\b/ : /.*/; + + // The base Class implementation (does nothing) + this.Class = function(){}; + + // Create a new Class that inherits from this class + Class.extend = function(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 = arguments.callee; + + return Class; + }; +})(); diff --git a/src/core.js b/src/core.js index 67425795e..fab57f166 100644 --- a/src/core.js +++ b/src/core.js @@ -141,8 +141,8 @@ JSONEditor.prototype = { var classname; $each(JSONEditor.defaults.resolvers,function(i,resolver) { - var tmp; - if(tmp = resolver(schema)) { + var tmp = resolver(schema); + if(tmp) { if(JSONEditor.defaults.editors[tmp]) { classname = tmp; return false; diff --git a/src/defaults.js b/src/defaults.js index 66a97c48d..a14f8d0d4 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -14,6 +14,9 @@ JSONEditor.plugins = { }, epiceditor: { + }, + sceditor: { + } }; diff --git a/src/editor.js b/src/editor.js index d96146a4a..06660180b 100644 --- a/src/editor.js +++ b/src/editor.js @@ -139,7 +139,7 @@ JSONEditor.AbstractEditor = Class.extend({ this.watch_listener(); }, getButton: function(text, icon, title) { - var btnClass = 'json-editor-btn-'+icon + var btnClass = 'json-editor-btn-'+icon; if(!this.iconlib) icon = null; else icon = this.iconlib.getIcon(icon); @@ -167,7 +167,7 @@ JSONEditor.AbstractEditor = Class.extend({ if(this.link_holder) this.link_holder.appendChild(link); }, getLink: function(data) { - var holder; + var holder, link; // Get mime type of the link var mime = data.mediaType || 'application/javascript'; @@ -179,7 +179,7 @@ JSONEditor.AbstractEditor = Class.extend({ // Image links if(type === 'image') { holder = this.theme.getBlockLinkHolder(); - var link = document.createElement('a'); + link = document.createElement('a'); link.setAttribute('target','_blank'); var image = document.createElement('img'); @@ -197,7 +197,7 @@ JSONEditor.AbstractEditor = Class.extend({ else if(['audio','video'].indexOf(type) >=0) { holder = this.theme.getBlockLinkHolder(); - var link = this.theme.getBlockLink(); + link = this.theme.getBlockLink(); link.setAttribute('target','_blank'); var media = document.createElement(type); @@ -267,8 +267,9 @@ JSONEditor.AbstractEditor = Class.extend({ else return this.getTitle(); }, onWatchedFieldChange: function() { + var vars; if(this.header_template) { - var vars = $extend(this.getWatchedFieldValues(),{ + vars = $extend(this.getWatchedFieldValues(),{ key: this.key, i: this.key, title: this.getTitle() @@ -282,7 +283,7 @@ JSONEditor.AbstractEditor = Class.extend({ } } if(this.link_watchers.length) { - var vars = this.getWatchedFieldValues(); + vars = this.getWatchedFieldValues(); for(var i=0; i height)) { + if(!height || (rows[i].minh*0.5 < height && rows[i].maxh*2 > height)) { found = i; } } @@ -103,11 +103,11 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ // 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(var i=0; i rows[i].editors[biggest].width) biggest = j; rows[i].editors[j].width *= 12/rows[i].width; @@ -125,10 +125,10 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ // Layout the form container = document.createElement('div'); - for(var i=0; i= 0 - && window.$ && $.fn && $.fn.sceditor + if(this.options.wysiwyg && + ['html','bbcode'].indexOf(this.input_type) >= 0 && + window.$ && $.fn && $.fn.sceditor ) { - $(self.input).sceditor({ + options = $extend({},{ plugins: self.input_type==='html'? 'xhtml' : 'bbcode', emoticonsEnabled: false, width: '100%', height: 300 - }); + },JSONEditor.plugins.sceditor); + + $(self.input).sceditor(options); self.sceditor_instance = $(self.input).sceditor('instance'); @@ -360,7 +362,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ this.input.parentNode.insertBefore(this.epiceditor_container,this.input); this.input.style.display = 'none'; - var options = $extend({},JSONEditor.plugins.epiceditor,{ + options = $extend({},JSONEditor.plugins.epiceditor,{ container: this.epiceditor_container, clientSideStorage: false }); @@ -399,7 +401,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ // The theme if(JSONEditor.plugins.ace.theme) this.ace_editor.setTheme('ace/theme/'+JSONEditor.plugins.ace.theme); // The mode - var mode = ace.require("ace/mode/"+mode); + mode = ace.require("ace/mode/"+mode); if(mode) this.ace_editor.getSession().setMode(new mode.Mode()); // Listen for changes @@ -451,16 +453,16 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ * Re-calculates the value if needed */ onWatchedFieldChange: function() { - var self = this; + var self = this, vars, j; // If this editor needs to be rendered by a macro template if(this.template) { - var vars = this.getWatchedFieldValues(); + vars = this.getWatchedFieldValues(); this.setValue(this.template(vars),false,true); } // If this editor uses a dynamic select box if(this.enumSource) { - var vars = this.getWatchedFieldValues(); + vars = this.getWatchedFieldValues(); var select_options = []; var select_titles = []; @@ -481,7 +483,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ // Filter the items if(this.enumSource[i].filter) { var new_items = []; - for(var j=0; j HTML Editor +/*! JSON Editor v0.6.12 - JSON Schema -> HTML Editor * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license * - * Date: 2014-05-29 + * Date: 2014-06-08 */ /** diff --git a/src/templates/default.js b/src/templates/default.js index 2d0c8433d..ba9d936d7 100644 --- a/src/templates/default.js +++ b/src/templates/default.js @@ -24,7 +24,7 @@ JSONEditor.defaults.templates.default = function() { var ret = template+""; // Only supports basic {{var}} macro replacement $each(expanded,function(key,value) { - ret = ret.replace(new RegExp('\{\{\\s*'+key+'\\s*\}\}','g'),value); + ret = ret.replace(new RegExp('{{\\s*'+key+'\\s*}}','g'),value); }); return ret; }; diff --git a/src/templates/hogan.js b/src/templates/hogan.js index 461f23f1f..8e5710121 100644 --- a/src/templates/hogan.js +++ b/src/templates/hogan.js @@ -6,7 +6,7 @@ JSONEditor.defaults.templates.hogan = function() { var compiled = Hogan.compile(template); return function(context) { return compiled.render(context); - } + }; } }; }; diff --git a/src/templates/mustache.js b/src/templates/mustache.js index 57ab04e1c..9d6cbba02 100644 --- a/src/templates/mustache.js +++ b/src/templates/mustache.js @@ -5,7 +5,7 @@ JSONEditor.defaults.templates.mustache = function() { compile: function(template) { return function(view) { return Mustache.render(template, view); - } + }; } }; }; diff --git a/src/theme.js b/src/theme.js index 3dc8abaa3..84a1828ac 100644 --- a/src/theme.js +++ b/src/theme.js @@ -304,7 +304,7 @@ JSONEditor.AbstractTheme = Class.extend({ }, markTabInactive: function(tab) { this.applyStyles(tab,{ - opacity:.5, + opacity:0.5, background: '' }); }, diff --git a/src/utilities.js b/src/utilities.js index 76a011df8..ab48fc3e8 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -34,13 +34,14 @@ var $extend = function(destination) { var $each = function(obj,callback) { if(!obj) return; + var i; if(typeof obj.length !== 'undefined') { - for(var i=0; i