diff --git a/Gruntfile.js b/Gruntfile.js index 92244248b..ca36da13d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,6 +73,14 @@ module.exports = function(grunt) { } }, jshint: { + options: { + browser: true, + indent: 2, + nonbsp: true, + nonew: true, + immed: true, + latedef: true + }, beforeconcat: [ 'src/class.js', 'src/ie9.js', @@ -105,9 +113,14 @@ module.exports = function(grunt) { // Wrapper for $.fn style initialization 'src/jquery.js' ], - afterconcat: [ - 'dist/jsoneditor.js' - ] + afterconcat: { + options: { + undef: true + }, + files: { + src: ['dist/jsoneditor.js'] + } + } } }); diff --git a/bower.json b/bower.json index af347c9f4..d4242413a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "json-editor", - "version": "0.7.3", + "version": "0.7.4", "authors": [ "Jeremy Dorn " ], diff --git a/dist/jsoneditor.js b/dist/jsoneditor.js index 33f6a9f0c..db6dd0abe 100644 --- a/dist/jsoneditor.js +++ b/dist/jsoneditor.js @@ -1,8 +1,8 @@ -/*! JSON Editor v0.7.3 - JSON Schema -> HTML Editor +/*! JSON Editor v0.7.4 - JSON Schema -> HTML Editor * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license * - * Date: 2014-07-28 + * Date: 2014-07-29 */ /** @@ -17,11 +17,12 @@ * MIT Licensed. */ // Inspired by base2 and Prototype +var Class; (function(){ - var initializing = false, fnTest = /xyz/.test(function(){postMessage("xyz");}) ? /\b_super\b/ : /.*/; + var initializing = false, fnTest = /xyz/.test(function(){window.postMessage("xyz");}) ? /\b_super\b/ : /.*/; // The base Class implementation (does nothing) - this.Class = function(){}; + Class = function(){}; // Create a new Class that inherits from this class Class.extend = function(prop) { @@ -75,6 +76,8 @@ return Class; }; + + return Class; })(); // CustomEvent constructor polyfill @@ -248,7 +251,7 @@ JSONEditor.prototype = { self.ready = true; // Fire ready event asynchronously - requestAnimationFrame(function() { + window.requestAnimationFrame(function() { self.validation_results = self.validator.validate(self.root.getValue()); self.root.showValidationErrors(self.validation_results); self.trigger('ready'); @@ -365,7 +368,7 @@ JSONEditor.prototype = { var self = this; - requestAnimationFrame(function() { + window.requestAnimationFrame(function() { self.firing_change = false; // Validate and cache results @@ -540,7 +543,7 @@ JSONEditor.prototype = { response = JSON.parse(r.responseText); } catch(e) { - console.log(e); + window.console.log(e); throw "Failed to parse external ref "+url; } if(!response || typeof response !== "object") throw "External ref does not contain a valid schema - "+url; @@ -556,7 +559,7 @@ JSONEditor.prototype = { } // Request failed else { - console.log(r); + window.console.log(r); throw "Failed to fetch ref via ajax- "+url; } }; @@ -1692,7 +1695,7 @@ JSONEditor.AbstractEditor = Class.extend({ throw "getOption is deprecated"; } catch(e) { - console.error(e); + window.console.error(e); } return this.options[key]; @@ -2001,12 +2004,12 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ this.container.appendChild(this.control); // If the Select2 library is loaded - if(this.input_type === "select" && window.$ && $.fn && $.fn.select2) { - $(this.input).select2(); + if(this.input_type === "select" && window.jQuery && window.jQuery.fn && window.jQuery.fn.select2) { + window.jQuery(this.input).select2(); } // Any special formatting that needs to happen after the input is added to the dom - requestAnimationFrame(function() { + window.requestAnimationFrame(function() { // Skip in case the input is only a temporary editor, // otherwise, in the case of an ace_editor creation, // it will generate an error trying to append it to the missing parentNode @@ -2042,7 +2045,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ // WYSIWYG html and bbcode editor if(this.options.wysiwyg && ['html','bbcode'].indexOf(this.input_type) >= 0 && - window.$ && $.fn && $.fn.sceditor + window.jQuery && window.jQuery.fn && window.jQuery.fn.sceditor ) { options = $extend({},{ plugins: self.input_type==='html'? 'xhtml' : 'bbcode', @@ -2051,15 +2054,15 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ height: 300 },JSONEditor.plugins.sceditor); - $(self.input).sceditor(options); + window.jQuery(self.input).sceditor(options); - self.sceditor_instance = $(self.input).sceditor('instance'); + self.sceditor_instance = window.jQuery(self.input).sceditor('instance'); self.sceditor_instance.blur(function() { // Get editor's value - var val = $("
"+self.sceditor_instance.val()+"
"); + var val = window.jQuery("
"+self.sceditor_instance.val()+"
"); // Remove sceditor spans/divs - $('#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf',val).remove(); + window.jQuery('#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf',val).remove(); // Set the value and update self.input.value = val.html(); self.value = self.input.value; @@ -2080,7 +2083,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ clientSideStorage: false }); - this.epiceditor = new EpicEditor(options).load(); + this.epiceditor = new window.EpicEditor(options).load(); this.epiceditor.importFile(null,this.getValue()); @@ -2108,14 +2111,14 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ 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 = window.ace.edit(this.ace_container); this.ace_editor.setValue(this.getValue()); // The theme if(JSONEditor.plugins.ace.theme) this.ace_editor.setTheme('ace/theme/'+JSONEditor.plugins.ace.theme); // The mode - mode = ace.require("ace/mode/"+mode); + mode = window.ace.require("ace/mode/"+mode); if(mode) this.ace_editor.getSession().setMode(new mode.Mode()); // Listen for changes @@ -2199,7 +2202,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ if(this.enumSource[i].filter) { var new_items = []; for(j=0; j 2) { - $(this.input).select2(); + if(window.jQuery && window.jQuery.fn && window.jQuery.fn.select2 && this.enum_options.length > 2) { + window.jQuery(this.input).select2(); } }, postBuild: function() { @@ -4913,7 +4918,7 @@ JSONEditor.defaults.editors.multiselect = JSONEditor.AbstractEditor.extend({ } else { this.input_type = 'select'; - this.input = this.theme.getSelectInput(options); + this.input = this.theme.getSelectInput(this.option_keys); this.input.multiple = true; this.input.size = Math.min(10,this.option_keys.length); @@ -5149,8 +5154,8 @@ JSONEditor.AbstractTheme = Class.extend({ getFloatRightLinkHolder: function() { var el = document.createElement('div'); el.style = el.style || {}; - el.style.float = 'right'; - el.style['margin-left'] = '10px'; + el.style.cssFloat = 'right'; + el.style.marginLeft = '10px'; return el; }, getModal: function() { @@ -5684,7 +5689,7 @@ JSONEditor.defaults.themes.bootstrap3 = JSONEditor.AbstractTheme.extend({ group.style.marginTop = '0'; group.appendChild(label); input.style.position = 'relative'; - input.style.float = 'left'; + input.style.cssFloat = 'left'; } else { group.className += ' form-group'; @@ -6375,7 +6380,7 @@ JSONEditor.defaults.templates.ejs = function() { return { compile: function(template) { - var compiled = new EJS({ + var compiled = new window.EJS({ text: template }); @@ -6395,7 +6400,7 @@ JSONEditor.defaults.templates.hogan = function() { return { compile: function(template) { - var compiled = Hogan.compile(template); + var compiled = window.Hogan.compile(template); return function(context) { return compiled.render(context); }; @@ -6409,7 +6414,7 @@ JSONEditor.defaults.templates.markup = function() { return { compile: function(template) { return function(context) { - return Mark.up(template,context); + return window.Mark.up(template,context); }; } }; @@ -6421,7 +6426,7 @@ JSONEditor.defaults.templates.mustache = function() { return { compile: function(template) { return function(view) { - return Mustache.render(template, view); + return window.Mustache.render(template, view); }; } }; @@ -6437,7 +6442,7 @@ JSONEditor.defaults.templates.underscore = function() { return { compile: function(template) { return function(context) { - return _.template(template, context); + return window._.template(template, context); }; } }; @@ -6681,65 +6686,67 @@ JSONEditor.defaults.resolvers.unshift(function(schema) { /** * This is a small wrapper for using JSON Editor like a typical jQuery plugin. */ -if(window.jQuery || window.Zepto) { - window.$ = window.$ || {}; - $.jsoneditor = JSONEditor.defaults; - - (window.jQuery || window.Zepto).fn.jsoneditor = function(options) { - var self = this; - var editor = this.data('jsoneditor'); - if(options === 'value') { - if(!editor) throw "Must initialize jsoneditor before getting/setting the value"; - - // Set value - if(arguments.length > 1) { - editor.setValue(arguments[1]); +(function() { + if(window.jQuery || window.Zepto) { + var $ = window.jQuery || window.Zepto; + $.jsoneditor = JSONEditor.defaults; + + $.fn.jsoneditor = function(options) { + var self = this; + var editor = this.data('jsoneditor'); + if(options === 'value') { + if(!editor) throw "Must initialize jsoneditor before getting/setting the value"; + + // Set value + if(arguments.length > 1) { + editor.setValue(arguments[1]); + } + // Get value + else { + return editor.getValue(); + } } - // Get value - else { - return editor.getValue(); + else if(options === 'validate') { + if(!editor) throw "Must initialize jsoneditor before validating"; + + // Validate a specific value + if(arguments.length > 1) { + return editor.validate(arguments[1]); + } + // Validate current value + else { + return editor.validate(); + } } - } - else if(options === 'validate') { - if(!editor) throw "Must initialize jsoneditor before validating"; - - // Validate a specific value - if(arguments.length > 1) { - return editor.validate(arguments[1]); + else if(options === 'destroy') { + if(editor) { + editor.destroy(); + this.data('jsoneditor',null); + } } - // Validate current value else { - return editor.validate(); - } - } - else if(options === 'destroy') { - if(editor) { - editor.destroy(); - this.data('jsoneditor',null); - } - } - else { - // Destroy first - if(editor) { - editor.destroy(); + // Destroy first + if(editor) { + editor.destroy(); + } + + // Create editor + editor = new JSONEditor(this.get(0),options); + this.data('jsoneditor',editor); + + // Setup event listeners + editor.on('change',function() { + self.trigger('change'); + }); + editor.on('ready',function() { + self.trigger('ready'); + }); } - // Create editor - editor = new JSONEditor(this.get(0),options); - this.data('jsoneditor',editor); - - // Setup event listeners - editor.on('change',function() { - self.trigger('change'); - }); - editor.on('ready',function() { - self.trigger('ready'); - }); - } - - return this; - }; -} + return this; + }; + } +})(); window.JSONEditor = JSONEditor; })(); diff --git a/dist/jsoneditor.min.js b/dist/jsoneditor.min.js index 2c0a9a21f..2f1c559c9 100644 --- a/dist/jsoneditor.min.js +++ b/dist/jsoneditor.min.js @@ -1,10 +1,10 @@ -/*! JSON Editor v0.7.3 - JSON Schema -> HTML Editor +/*! JSON Editor v0.7.4 - JSON Schema -> HTML Editor * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license * - * Date: 2014-07-28 + * Date: 2014-07-29 */ -!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=g&&!h&&(h=!0,b())})}},c.send()}}),g||b()},expandRefs:function(a){for(a=b({},a);a.$ref;){var c=a.$ref;delete a.$ref,a=this.extendSchemas(a,this.refs[c])}return a},expandSchema:function(a){var d,e=this,f=b({},a);if("object"==typeof a.type&&(Array.isArray(a.type)?c(a.type,function(b,c){"object"==typeof c&&(a.type[b]=e.expandSchema(c))}):a.type=e.expandSchema(a.type)),"object"==typeof a.disallow&&(Array.isArray(a.disallow)?c(a.disallow,function(b,c){"object"==typeof c&&(a.disallow[b]=e.expandSchema(c))}):a.disallow=e.expandSchema(a.disallow)),a.anyOf&&c(a.anyOf,function(b,c){a.anyOf[b]=e.expandSchema(c)}),a.dependencies&&c(a.dependencies,function(b,c){"object"!=typeof c||Array.isArray(c)||(a.dependencies[b]=e.expandSchema(c))}),a.not&&(a.not=this.expandSchema(a.not)),a.allOf){for(d=0;d=a.maximum?j.push({path:f,property:"maximum",message:this.translate("error_maximum_excl",[a.maximum])}):!a.exclusiveMaximum&&d>a.maximum&&j.push({path:f,property:"maximum",message:this.translate("error_maximum_incl",[a.maximum])})),a.minimum&&(a.exclusiveMinimum&&d<=a.minimum?j.push({path:f,property:"minimum",message:this.translate("error_minimum_excl",[a.minimum])}):!a.exclusiveMinimum&&da.maxLength&&j.push({path:f,property:"maxLength",message:this.translate("error_maxLength",[a.maxLength])}),a.minLength&&(d+"").lengtha.maxItems&&j.push({path:f,property:"maxItems",message:this.translate("error_maxItems",[a.maxItems])}),a.minItems&&d.lengtha.maxProperties&&j.push({path:f,property:"maxProperties",message:this.translate("error_maxProperties",[a.maxProperties])})}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,i0:1*this.key,i1:1*this.key+1,title:this.getTitle()});var c=this.header_template(a);c!==this.header_text&&(this.header_text=c,this.updateHeaderText(),this.notify())}if(this.link_watchers.length){a=this.getWatchedFieldValues();for(var d=0;d1&&(b[a]=c+" "+e[c])}),b},getOption:function(a){try{throw"getOption is deprecated"}catch(b){console.error(b)}return this.options[a]},showValidationErrors:function(){}}),e.defaults.editors.null=e.AbstractEditor.extend({getValue:function(){return null},setValue:function(){this.jsoneditor.notifyWatchers(this.path)},getNumColumns:function(){return 2}}),e.defaults.editors.string=e.AbstractEditor.extend({register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},setValue:function(a,b,c){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(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),f&&(d.parent?d.parent.onChildEditorChange(d):d.jsoneditor.onChange()),this.watch_listener(),this.jsoneditor.notifyWatchers(this.path)}}},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.options.compact||(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.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),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=[],Array.isArray(this.schema.enumSource))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.options.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.is_dirty=!0,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.theme.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.input.parentNode&&c.afterInputReady()}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},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},e.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.value=c.input.value,c.is_dirty=!0,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({},e.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.is_dirty=!0,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()),e.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+e.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.is_dirty=!0,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&&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=this.schema.maxProperties),this.addproperty_checkboxes&&(this.addproperty_list.innerHTML=""),this.addproperty_checkboxes={};for(a in this.cached_editors)this.cached_editors.hasOwnProperty(a)&&(this.addPropertyCheckbox(a),this.isRequired(this.cached_editors[a])&&a in this.editors&&(this.addproperty_checkboxes[a].disabled=!0),"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):a in this.editors?(e=!0,c=!0):b?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0);this.canHaveAdditionalProperties()&&(e=!0);for(a in this.schema.properties)this.schema.properties.hasOwnProperty(a)&&(this.cached_editors[a]||(e=!0,this.addPropertyCheckbox(a),this.addproperty_checkboxes[a].disabled=!b));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")},isRequired:function(a){return"boolean"==typeof a.schema.required?a.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(a.key)>-1:this.jsoneditor.options.required_by_default?!0:!1},setValue:function(a,b){var d=this;a=a||{},("object"!=typeof a||Array.isArray(a))&&(a={}),c(this.cached_editors,function(c,e){"undefined"!=typeof a[c]?(d.addObjectProperty(c),e.setValue(a[c],b)):b||d.isRequired(e)?e.setValue(e.getDefault(),b):d.removeObjectProperty(c)}),this.canHaveAdditionalProperties()&&c(a,function(a,c){d.cached_editors[a]||(d.addObjectProperty(a),d.editors[a].setValue(c,b))}),this.refreshValue(),this.notify(),this.layoutEditors()},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.options.table_row&&(d.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),c(this.editors,function(a,b){b.showValidationErrors(e)})}}),e.defaults.editors.array=e.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);return"undefined"!=typeof this.item_info[c]?this.item_info[c]:(b=this.jsoneditor.expandRefs(b),this.item_info[c]={title:b.title||"item","default":b.default,width:12,child_editors:b.properties||b.items},this.item_info[c])},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c=this.jsoneditor.expandRefs(c),c.title=b.title+" "+(a+1);var d,e=this.jsoneditor.getEditorClass(c);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.preBuild(),f.build(),f.postBuild(),f.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode&&this.controls.parentNode.removeChild(this.controls),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this.rows=this.row_cache=this.title=this.description=this.row_holder=this.panel=this.controls=null,this._super()},empty:function(a){if(this.rows){var b=this;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 Array.isArray(this.schema.items)&&this.schema.additionalItems===!1?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(a){var b=this;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,b){a=a||[],Array.isArray(a)||(a=[a]);var d=JSON.stringify(a);if(d!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var e=this;c(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):e.row_cache[a]?(e.rows[a]=e.row_cache[a],e.rows[a].setValue(b),e.rows[a].container.style.display="",e.rows[a].tab&&(e.rows[a].tab.style.display=""),e.rows[a].register()):e.addRow(b)});for(var f=a.length;f=this.rows.length;c(this.rows,function(a,c){c.movedown_buttons&&(c.movedown_button.style.display=a===b.rows.length-1?"none":""),c.delete_button&&(c.delete_button.style.display=e?"none":""),b.value[a]=c.getValue()});var f=!1;this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",e||this.hide_delete_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",f=!0)):e||this.hide_delete_buttons?(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="",f=!0):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.getMax()&&this.getMax()<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",f=!0),this.controls.style.display=!this.collapsed&&f?"inline-block":"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));var e=b.rows[d].title_controls||b.rows[d].array_controls;b.hide_delete_buttons||(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(a){a.preventDefault(),a.stopPropagation();var d=1*this.getAttribute("data-i"),e=b.getValue(),f=[],g=null;c(e,function(a,c){return a===d?void(b.rows[a].tab===b.active_tab&&(b.rows[a+1]?g=b.rows[a].tab:a&&(g=b.rows[a-1].tab))):void f.push(c)}),b.setValue(f),g&&(b.active_tab=g,b.refreshTabs()),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),e&&e.appendChild(b.rows[d].delete_button)),d&&!b.hide_move_buttons&&(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(0>=c)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.active_tab=b.rows[c-1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),e&&e.appendChild(b.rows[d].moveup_button)),b.hide_move_buttons||(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.active_tab=b.rows[c+1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),e&&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(d){d.preventDefault(),d.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel&&(a.panel.style.display=""),a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse","Collapse")):(a.collapsed=!0,a.row_holder.style.display="none",a.tabs_holder&&(a.tabs_holder.style.display="none"),a.controls.style.display="none",a.panel&&(a.panel.style.display="none"),a.setButtonText(this,"","expand","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();var c=a.rows.length;a.row_cache[c]?(a.rows[c]=a.row_cache[c],a.rows[c].container.style.display="",a.rows[c].tab&&(a.rows[c].tab.style.display=""),a.rows[c].register()):a.addRow(),a.active_tab=a.rows[c].tab,a.refreshTabs(),a.refreshValue(),a.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(b){b.preventDefault(),b.stopPropagation();var c=a.getValue(),d=null;a.rows.length>1&&a.rows[a.rows.length-1].tab===a.active_tab&&(d=a.rows[a.rows.length-2].tab),c.pop(),a.setValue(c),d&&(a.active_tab=d,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(b){b.preventDefault(),b.stopPropagation(),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)})}}),e.defaults.editors.table=e.defaults.editors.array.extend({register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var d=JSON.stringify(a);if(d!==this.serialized){var e=!1,f=this;c(a,function(a,b){f.rows[a]?f.rows[a].setValue(b):(f.addRow(b),e=!0)});for(var g=a.length;g=this.rows.length,d=!1;c(this.rows,function(c,e){e.movedown_button&&(c===a.rows.length-1?e.movedown_button.style.display="none":(d=!0,e.movedown_button.style.display="")),e.delete_button&&(b?e.delete_button.style.display="none":(d=!0,e.delete_button.style.display="")),e.moveup_button&&(d=!0)}),c(this.rows,function(a,b){b.controls_cell.style.display=d?"":"none"}),this.controls_header_cell.style.display=d?"":"none";var e=!1;this.value.length?1===this.value.length||this.hide_delete_buttons?(this.table.style.display="",this.remove_all_rows_button.style.display="none",b||this.hide_delete_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0)):(this.table.style.display="",b||this.hide_delete_buttons?(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="",e=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.schema.maxItems&&this.schema.maxItems<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",e=!0),this.controls.style.display=e?"":"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);var e=b.rows[d].table_controls;this.hide_delete_buttons||(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(a){a.preventDefault(),a.stopPropagation();var d=1*this.getAttribute("data-i"),e=b.getValue(),f=[];c(e,function(a,b){a!==d&&f.push(b)}),b.setValue(f),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),e.appendChild(b.rows[d].delete_button)),d&&!this.hide_move_buttons&&(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(0>=c)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),e.appendChild(b.rows[d].moveup_button)),this.hide_move_buttons||(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),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&&(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)}}),e.defaults.editors.multiple=e.AbstractEditor.extend({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);Array.isArray(a)||(f="
"+c+": "+f+"
"),d+="
  • "+f+"
  • "}),d=Array.isArray(a)?"
      "+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&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),e.defaults.editors.select=e.AbstractEditor.extend({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(){if(!this.enum_options)return 3;for(var a=this.getTitle().length,b=0;b2&&$(this.input).select2()},postBuild:function(){this._super(),this.theme.afterInputReady(this.input)},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&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()}}),e.defaults.editors.multiselect=e.AbstractEditor.extend({preBuild:function(){this._super(),this.select_options={},this.select_values={};var a=this.jsoneditor.expandRefs(this.schema.items||{}),b=a.enum||[];for(this.option_keys=[],f=0;fType: "+a+", Size: "+Math.floor((this.value.length-this.value.split(",")[0].length-1)/1.33333)+" bytes","image"===a.substr(0,5)){this.preview.innerHTML+="
    ";var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.src=this.value,this.preview.appendChild(b)}}else this.preview.innerHTML="Invalid data URI"}},enable:function(){this.uploader&&(this.uploader.disabled=!1),this._super()},disable:function(){this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.refreshPreview(),this.watch_listener(),this.jsoneditor.notifyWatchers(this.path))},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),e.AbstractTheme=Class.extend({getContainer:function(){return document.createElement("div")},getFloatRightLinkHolder:function(){var a=document.createElement("div");return a.style=a.style||{},a.style.float="right",a.style["margin-left"]="10px",a},getModal:function(){var a=document.createElement("div");return a.style.backgroundColor="white",a.style.border="1px solid black",a.style.boxShadow="3px 3px black",a.style.position="absolute",a.style.zIndex="10",a.style.display="none",a},getGridContainer:function(){var a=document.createElement("div");return a},getGridRow:function(){var a=document.createElement("div");return a.className="row",a},getGridColumn:function(){var a=document.createElement("div");return a},setGridColumnSize:function(){},getLink:function(a){var b=document.createElement("a");return b.setAttribute("href","#"),b.appendChild(document.createTextNode(a)),b},disableHeader:function(a){a.style.color="#ccc"},disableLabel:function(a){a.style.color="#ccc"},enableHeader:function(a){a.style.color=""},enableLabel:function(a){a.style.color=""},getFormInputLabel:function(a){var b=document.createElement("label");return b.appendChild(document.createTextNode(a)),b},getCheckboxLabel:function(a){var b=this.getFormInputLabel(a);return b.style.fontWeight="normal",b},getHeader:function(a){var b=document.createElement("h3");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getCheckbox:function(){var a=this.getFormInputField("checkbox");return a.style.display="inline-block",a.style.width="auto",a},getMultiCheckboxHolder:function(a,b,c){var d=document.createElement("div");b&&(b.style.display="block",d.appendChild(b));for(var e in a)a.hasOwnProperty(e)&&(a[e].style.display="inline-block",a[e].style.marginRight="20px",d.appendChild(a[e]));return c&&d.appendChild(c),d},getSelectInput:function(a){var b=document.createElement("select");return a&&this.setSelectOptions(b,a),b},getSwitcher:function(a){var b=this.getSelectInput(a);return b.style.backgroundColor="transparent",b.style.height="auto",b.style.fontStyle="italic",b.style.fontWeight="normal",b.style.padding="0 0 0 3px",b},getSwitcherOptions:function(a){return a.getElementsByTagName("option")},setSwitcherOptions:function(a,b,c){this.setSelectOptions(a,b,c)},setSelectOptions:function(a,b,c){c=c||[],a.innerHTML="";for(var d=0;d'),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")}}),e.defaults.themes.foundation3=e.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)}}),e.defaults.themes.foundation4=e.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}}),e.defaults.themes.foundation5=e.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)}}),e.defaults.themes.html=e.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")}}),e.defaults.themes.jqueryui=e.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"}}),e.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}}),e.defaults.iconlibs.bootstrap2=e.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-"}),e.defaults.iconlibs.bootstrap3=e.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-"}),e.defaults.iconlibs.fontawesome3=e.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-"}),e.defaults.iconlibs.fontawesome4=e.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-"}),e.defaults.iconlibs.foundation2=e.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-"}),e.defaults.iconlibs.foundation3=e.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-"}),e.defaults.iconlibs.jqueryui=e.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-"}),e.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}}}},e.defaults.templates.ejs=function(){return window.EJS?{compile:function(a){var b=new EJS({text:a});return function(a){return b.render(a)}}}:!1},e.defaults.templates.handlebars=function(){return window.Handlebars},e.defaults.templates.hogan=function(){return window.Hogan?{compile:function(a){var b=Hogan.compile(a);return function(a){return b.render(a)}}}:!1},e.defaults.templates.markup=function(){return window.Mark&&window.Mark.up?{compile:function(a){return function(b){return Mark.up(a,b)}}}:!1},e.defaults.templates.mustache=function(){return window.Mustache?{compile:function(a){return function(b){return Mustache.render(a,b)}}}:!1},e.defaults.templates.swig=function(){return window.swig},e.defaults.templates.underscore=function(){return window._?{compile:function(a){return function(b){return _.template(a,b)}}}:!1},e.defaults.theme="html",e.defaults.template="default",e.defaults.options={},e.defaults.translate=function(a,b){var c=e.defaults.languages[e.defaults.language];if(!c)throw"Unknown language "+e.defaults.language;var d=c[a]||e.defaults.languages[e.defaults.default_language][a];if("undefined"==typeof d)throw"Unknown translate string "+a;if(b)for(var f=0;f=0?"multiselect":void 0}),e.defaults.resolvers.unshift(function(a){return a.oneOf?"multiple":void 0}),(window.jQuery||window.Zepto)&&(window.$=window.$||{},$.jsoneditor=e.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 e(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=e}(); \ No newline at end of file +!function(){var a;!function(){var b=!1,c=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/;return 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},a}(),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=g&&!h&&(h=!0,b())})}},d.send()}}),g||b()},expandRefs:function(a){for(a=c({},a);a.$ref;){var b=a.$ref;delete a.$ref,a=this.extendSchemas(a,this.refs[b])}return a},expandSchema:function(a){var b,e=this,f=c({},a);if("object"==typeof a.type&&(Array.isArray(a.type)?d(a.type,function(b,c){"object"==typeof c&&(a.type[b]=e.expandSchema(c))}):a.type=e.expandSchema(a.type)),"object"==typeof a.disallow&&(Array.isArray(a.disallow)?d(a.disallow,function(b,c){"object"==typeof c&&(a.disallow[b]=e.expandSchema(c))}):a.disallow=e.expandSchema(a.disallow)),a.anyOf&&d(a.anyOf,function(b,c){a.anyOf[b]=e.expandSchema(c)}),a.dependencies&&d(a.dependencies,function(b,c){"object"!=typeof c||Array.isArray(c)||(a.dependencies[b]=e.expandSchema(c))}),a.not&&(a.not=this.expandSchema(a.not)),a.allOf){for(b=0;b=a.maximum?j.push({path:e,property:"maximum",message:this.translate("error_maximum_excl",[a.maximum])}):!a.exclusiveMaximum&&b>a.maximum&&j.push({path:e,property:"maximum",message:this.translate("error_maximum_incl",[a.maximum])})),a.minimum&&(a.exclusiveMinimum&&b<=a.minimum?j.push({path:e,property:"minimum",message:this.translate("error_minimum_excl",[a.minimum])}):!a.exclusiveMinimum&&ba.maxLength&&j.push({path:e,property:"maxLength",message:this.translate("error_maxLength",[a.maxLength])}),a.minLength&&(b+"").lengtha.maxItems&&j.push({path:e,property:"maxItems",message:this.translate("error_maxItems",[a.maxItems])}),a.minItems&&b.lengtha.maxProperties&&j.push({path:e,property:"maxProperties",message:this.translate("error_maxProperties",[a.maxProperties])})}if(a.minProperties){g=0;for(h in b)b.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=c(this.getWatchedFieldValues(),{key:this.key,i:this.key,i0:1*this.key,i1:1*this.key+1,title:this.getTitle()});var b=this.header_template(a);b!==this.header_text&&(this.header_text=b,this.updateHeaderText(),this.notify())}if(this.link_watchers.length){a=this.getWatchedFieldValues();for(var d=0;d1&&(b[a]=d+" "+e[d])}),b},getOption:function(a){try{throw"getOption is deprecated"}catch(b){window.console.error(b)}return this.options[a]},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({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(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),f&&(d.parent?d.parent.onChildEditorChange(d):d.jsoneditor.onChange()),this.watch_listener(),this.jsoneditor.notifyWatchers(this.path)}}},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,b=this;if(this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.format=this.schema.format,!this.format&&this.schema.media&&this.schema.media.type&&(this.format=this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,"")),!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.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=[],Array.isArray(this.schema.enumSource))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.options.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(),b.schema.template)return void(this.value=b.value);var c=this.value,d=b.sanitize(c);c!==d&&(this.value=d),b.is_dirty=!0,b.refreshValue(),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.theme.getFormControl(this.label,this.input,this.description),this.container.appendChild(this.control),"select"===this.input_type&&window.jQuery&&window.jQuery.fn&&window.jQuery.fn.select2&&window.jQuery(this.input).select2(),window.requestAnimationFrame(function(){b.input.parentNode&&b.afterInputReady()}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},afterInputReady:function(){var a,b=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.jQuery&&window.jQuery.fn&&window.jQuery.fn.sceditor)a=c({},{plugins:"html"===b.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300},f.plugins.sceditor),window.jQuery(b.input).sceditor(a),b.sceditor_instance=window.jQuery(b.input).sceditor("instance"),b.sceditor_instance.blur(function(){var a=window.jQuery("
    "+b.sceditor_instance.val()+"
    ");window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",a).remove(),b.input.value=a.html(),b.value=b.input.value,b.is_dirty=!0,b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange(),b.jsoneditor.notifyWatchers(b.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=c({},f.plugins.epiceditor,{container:this.epiceditor_container,clientSideStorage:!1}),this.epiceditor=new window.EpicEditor(a).load(),this.epiceditor.importFile(null,this.getValue()),this.epiceditor.on("update",function(){var a=b.epiceditor.exportFile();b.input.value=a,b.value=a,b.is_dirty=!0,b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange(),b.jsoneditor.notifyWatchers(b.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=window.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=window.ace.require("ace/mode/"+d),d&&this.ace_editor.getSession().setMode(new d.Mode),this.ace_editor.on("change",function(){var a=b.ace_editor.getValue(); +b.input.value=a,b.refreshValue(),b.is_dirty=!0,b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange(),b.jsoneditor.notifyWatchers(b.path)})}b.theme.afterInputReady(b.input)},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.sceditor_instance?this.sceditor_instance.destroy():this.epiceditor?this.epiceditor.unload():this.ace_editor&&this.ace_editor.destroy(),this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a,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=this.schema.maxProperties),this.addproperty_checkboxes&&(this.addproperty_list.innerHTML=""),this.addproperty_checkboxes={};for(a in this.cached_editors)this.cached_editors.hasOwnProperty(a)&&(this.addPropertyCheckbox(a),this.isRequired(this.cached_editors[a])&&a in this.editors&&(this.addproperty_checkboxes[a].disabled=!0),"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):a in this.editors?(e=!0,c=!0):b?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0);this.canHaveAdditionalProperties()&&(e=!0);for(a in this.schema.properties)this.schema.properties.hasOwnProperty(a)&&(this.cached_editors[a]||(e=!0,this.addPropertyCheckbox(a),this.addproperty_checkboxes[a].disabled=!b));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")},isRequired:function(a){return"boolean"==typeof a.schema.required?a.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(a.key)>-1:this.jsoneditor.options.required_by_default?!0:!1},setValue:function(a,b){var c=this;a=a||{},("object"!=typeof a||Array.isArray(a))&&(a={}),d(this.cached_editors,function(d,e){"undefined"!=typeof a[d]?(c.addObjectProperty(d),e.setValue(a[d],b)):b||c.isRequired(e)?e.setValue(e.getDefault(),b):c.removeObjectProperty(d)}),this.canHaveAdditionalProperties()&&d(a,function(a,d){c.cached_editors[a]||(c.addObjectProperty(a),c.editors[a].setValue(d,b))}),this.refreshValue(),this.notify(),this.layoutEditors()},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.options.table_row&&(c.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),d(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?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);return"undefined"!=typeof this.item_info[c]?this.item_info[c]:(b=this.jsoneditor.expandRefs(b),this.item_info[c]={title:b.title||"item","default":b.default,width:12,child_editors:b.properties||b.items},this.item_info[c])},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c=this.jsoneditor.expandRefs(c),c.title=b.title+" "+(a+1);var d,e=this.jsoneditor.getEditorClass(c);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.preBuild(),f.build(),f.postBuild(),f.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode&&this.controls.parentNode.removeChild(this.controls),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this.rows=this.row_cache=this.title=this.description=this.row_holder=this.panel=this.controls=null,this._super()},empty:function(a){if(this.rows){var b=this;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 Array.isArray(this.schema.items)&&this.schema.additionalItems===!1?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(a){var b=this;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,b){a=a||[],Array.isArray(a)||(a=[a]);var c=JSON.stringify(a);if(c!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var e=this;d(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):e.row_cache[a]?(e.rows[a]=e.row_cache[a],e.rows[a].setValue(b),e.rows[a].container.style.display="",e.rows[a].tab&&(e.rows[a].tab.style.display=""),e.rows[a].register()):e.addRow(b)});for(var f=a.length;f=this.rows.length;d(this.rows,function(a,c){c.movedown_buttons&&(c.movedown_button.style.display=a===b.rows.length-1?"none":""),c.delete_button&&(c.delete_button.style.display=e?"none":""),b.value[a]=c.getValue()});var f=!1;this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",e||this.hide_delete_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",f=!0)):e||this.hide_delete_buttons?(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="",f=!0):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.getMax()&&this.getMax()<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",f=!0),this.controls.style.display=!this.collapsed&&f?"inline-block":"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));var e=b.rows[c].title_controls||b.rows[c].array_controls;b.hide_delete_buttons||(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),e=b.getValue(),f=[],g=null;d(e,function(a,d){return a===c?void(b.rows[a].tab===b.active_tab&&(b.rows[a+1]?g=b.rows[a].tab:a&&(g=b.rows[a-1].tab))):void f.push(d)}),b.setValue(f),g&&(b.active_tab=g,b.refreshTabs()),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),e&&e.appendChild(b.rows[c].delete_button)),c&&!b.hide_move_buttons&&(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(0>=c)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.active_tab=b.rows[c-1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),e&&e.appendChild(b.rows[c].moveup_button)),b.hide_move_buttons||(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.active_tab=b.rows[c+1].tab,b.refreshTabs(),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),e&&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(d){d.preventDefault(),d.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel&&(a.panel.style.display=""),a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse","Collapse")):(a.collapsed=!0,a.row_holder.style.display="none",a.tabs_holder&&(a.tabs_holder.style.display="none"),a.controls.style.display="none",a.panel&&(a.panel.style.display="none"),a.setButtonText(this,"","expand","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();var c=a.rows.length;a.row_cache[c]?(a.rows[c]=a.row_cache[c],a.rows[c].container.style.display="",a.rows[c].tab&&(a.rows[c].tab.style.display=""),a.rows[c].register()):a.addRow(),a.active_tab=a.rows[c].tab,a.refreshTabs(),a.refreshValue(),a.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(b){b.preventDefault(),b.stopPropagation();var c=a.getValue(),d=null;a.rows.length>1&&a.rows[a.rows.length-1].tab===a.active_tab&&(d=a.rows[a.rows.length-2].tab),c.pop(),a.setValue(c),d&&(a.active_tab=d,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(b){b.preventDefault(),b.stopPropagation(),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)})}}),f.defaults.editors.table=f.defaults.editors.array.extend({register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var c=JSON.stringify(a);if(c!==this.serialized){var e=!1,f=this;d(a,function(a,b){f.rows[a]?f.rows[a].setValue(b):(f.addRow(b),e=!0)});for(var g=a.length;g=this.rows.length,c=!1;d(this.rows,function(d,e){e.movedown_button&&(d===a.rows.length-1?e.movedown_button.style.display="none":(c=!0,e.movedown_button.style.display="")),e.delete_button&&(b?e.delete_button.style.display="none":(c=!0,e.delete_button.style.display="")),e.moveup_button&&(c=!0)}),d(this.rows,function(a,b){b.controls_cell.style.display=c?"":"none"}),this.controls_header_cell.style.display=c?"":"none";var e=!1;this.value.length?1===this.value.length||this.hide_delete_buttons?(this.table.style.display="",this.remove_all_rows_button.style.display="none",b||this.hide_delete_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0)):(this.table.style.display="",b||this.hide_delete_buttons?(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="",e=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.schema.maxItems&&this.schema.maxItems<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",e=!0),this.controls.style.display=e?"":"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);var e=b.rows[c].table_controls;this.hide_delete_buttons||(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),e=b.getValue(),f=[];d(e,function(a,b){a!==c&&f.push(b)}),b.setValue(f),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),e.appendChild(b.rows[c].delete_button)),c&&!this.hide_move_buttons&&(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(0>=c)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),e.appendChild(b.rows[c].moveup_button)),this.hide_move_buttons||(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(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}}),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&&(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)}}),f.defaults.editors.multiple=f.AbstractEditor.extend({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);Array.isArray(a)||(f="
    "+d+": "+f+"
    "),c+="
  • "+f+"
  • "}),c=Array.isArray(a)?"
      "+c+"
    ":"
      "+c+"
    "}return"boolean"==typeof a?a?"true":"false":"string"==typeof a?a.replace(/&/g,"&").replace(//g,">"):a},setValue:function(a){this.value!==a&&(this.value=a,this.refreshValue(),this.jsoneditor.notifyWatchers(this.path))},destroy:function(){this.display_area&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),f.defaults.editors.select=f.AbstractEditor.extend({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(){if(!this.enum_options)return 3;for(var a=this.getTitle().length,b=0;b2&&window.jQuery(this.input).select2()},postBuild:function(){this._super(),this.theme.afterInputReady(this.input)},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&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()}}),f.defaults.editors.multiselect=f.AbstractEditor.extend({preBuild:function(){this._super(),this.select_options={},this.select_values={};var a=this.jsoneditor.expandRefs(this.schema.items||{}),b=a.enum||[];for(this.option_keys=[],g=0;gType: "+a+", Size: "+Math.floor((this.value.length-this.value.split(",")[0].length-1)/1.33333)+" bytes","image"===a.substr(0,5)){this.preview.innerHTML+="
    ";var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.src=this.value,this.preview.appendChild(b)}}else this.preview.innerHTML="Invalid data URI"}},enable:function(){this.uploader&&(this.uploader.disabled=!1),this._super()},disable:function(){this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.refreshPreview(),this.watch_listener(),this.jsoneditor.notifyWatchers(this.path))},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),f.AbstractTheme=a.extend({getContainer:function(){return document.createElement("div")},getFloatRightLinkHolder:function(){var a=document.createElement("div");return a.style=a.style||{},a.style.cssFloat="right",a.style.marginLeft="10px",a},getModal:function(){var a=document.createElement("div");return a.style.backgroundColor="white",a.style.border="1px solid black",a.style.boxShadow="3px 3px black",a.style.position="absolute",a.style.zIndex="10",a.style.display="none",a},getGridContainer:function(){var a=document.createElement("div");return a},getGridRow:function(){var a=document.createElement("div");return a.className="row",a},getGridColumn:function(){var a=document.createElement("div");return a},setGridColumnSize:function(){},getLink:function(a){var b=document.createElement("a");return b.setAttribute("href","#"),b.appendChild(document.createTextNode(a)),b},disableHeader:function(a){a.style.color="#ccc"},disableLabel:function(a){a.style.color="#ccc"},enableHeader:function(a){a.style.color=""},enableLabel:function(a){a.style.color=""},getFormInputLabel:function(a){var b=document.createElement("label");return b.appendChild(document.createTextNode(a)),b},getCheckboxLabel:function(a){var b=this.getFormInputLabel(a);return b.style.fontWeight="normal",b},getHeader:function(a){var b=document.createElement("h3");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getCheckbox:function(){var a=this.getFormInputField("checkbox");return a.style.display="inline-block",a.style.width="auto",a},getMultiCheckboxHolder:function(a,b,c){var d=document.createElement("div");b&&(b.style.display="block",d.appendChild(b));for(var e in a)a.hasOwnProperty(e)&&(a[e].style.display="inline-block",a[e].style.marginRight="20px",d.appendChild(a[e]));return c&&d.appendChild(c),d},getSelectInput:function(a){var b=document.createElement("select");return a&&this.setSelectOptions(b,a),b},getSwitcher:function(a){var b=this.getSelectInput(a);return b.style.backgroundColor="transparent",b.style.height="auto",b.style.fontStyle="italic",b.style.fontWeight="normal",b.style.padding="0 0 0 3px",b},getSwitcherOptions:function(a){return a.getElementsByTagName("option")},setSwitcherOptions:function(a,b,c){this.setSelectOptions(a,b,c)},setSelectOptions:function(a,b,c){c=c||[],a.innerHTML="";for(var d=0;d'),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=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}}),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(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}}}},f.defaults.templates.ejs=function(){return window.EJS?{compile:function(a){var b=new window.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=window.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 window.Mark.up(a,b)}}}:!1},f.defaults.templates.mustache=function(){return window.Mustache?{compile:function(a){return function(b){return window.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 window._.template(a,b)}}}:!1},f.defaults.theme="html",f.defaults.template="default",f.defaults.options={},f.defaults.translate=function(a,b){var c=f.defaults.languages[f.defaults.language];if(!c)throw"Unknown language "+f.defaults.language;var d=c[a]||f.defaults.languages[f.defaults.default_language][a];if("undefined"==typeof d)throw"Unknown translate string "+a;if(b)for(var e=0;e=0?"multiselect":void 0}),f.defaults.resolvers.unshift(function(a){return a.oneOf?"multiple":void 0}),function(){if(window.jQuery||window.Zepto){var a=window.jQuery||window.Zepto;a.jsoneditor=f.defaults,a.fn.jsoneditor=function(a){var b=this,c=this.data("jsoneditor");if("value"===a){if(!c)throw"Must initialize jsoneditor before getting/setting the value";if(!(arguments.length>1))return c.getValue();c.setValue(arguments[1])}else{if("validate"===a){if(!c)throw"Must initialize jsoneditor before validating";return arguments.length>1?c.validate(arguments[1]):c.validate()}"destroy"===a?c&&(c.destroy(),this.data("jsoneditor",null)):(c&&c.destroy(),c=new 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/src/class.js b/src/class.js index c66681902..d2b3984a2 100644 --- a/src/class.js +++ b/src/class.js @@ -4,11 +4,12 @@ * MIT Licensed. */ // Inspired by base2 and Prototype +var Class; (function(){ - var initializing = false, fnTest = /xyz/.test(function(){postMessage("xyz");}) ? /\b_super\b/ : /.*/; + var initializing = false, fnTest = /xyz/.test(function(){window.postMessage("xyz");}) ? /\b_super\b/ : /.*/; // The base Class implementation (does nothing) - this.Class = function(){}; + Class = function(){}; // Create a new Class that inherits from this class Class.extend = function(prop) { @@ -62,4 +63,6 @@ return Class; }; + + return Class; })(); diff --git a/src/core.js b/src/core.js index f950676b5..61a6fe8ff 100644 --- a/src/core.js +++ b/src/core.js @@ -54,7 +54,7 @@ JSONEditor.prototype = { self.ready = true; // Fire ready event asynchronously - requestAnimationFrame(function() { + window.requestAnimationFrame(function() { self.validation_results = self.validator.validate(self.root.getValue()); self.root.showValidationErrors(self.validation_results); self.trigger('ready'); @@ -171,7 +171,7 @@ JSONEditor.prototype = { var self = this; - requestAnimationFrame(function() { + window.requestAnimationFrame(function() { self.firing_change = false; // Validate and cache results @@ -346,7 +346,7 @@ JSONEditor.prototype = { response = JSON.parse(r.responseText); } catch(e) { - console.log(e); + window.console.log(e); throw "Failed to parse external ref "+url; } if(!response || typeof response !== "object") throw "External ref does not contain a valid schema - "+url; @@ -362,7 +362,7 @@ JSONEditor.prototype = { } // Request failed else { - console.log(r); + window.console.log(r); throw "Failed to fetch ref via ajax- "+url; } }; diff --git a/src/editor.js b/src/editor.js index 77133bd0a..26892fcec 100644 --- a/src/editor.js +++ b/src/editor.js @@ -416,7 +416,7 @@ JSONEditor.AbstractEditor = Class.extend({ throw "getOption is deprecated"; } catch(e) { - console.error(e); + window.console.error(e); } return this.options[key]; diff --git a/src/editors/multiselect.js b/src/editors/multiselect.js index 2053dcaac..cd344f91a 100644 --- a/src/editors/multiselect.js +++ b/src/editors/multiselect.js @@ -38,7 +38,7 @@ JSONEditor.defaults.editors.multiselect = JSONEditor.AbstractEditor.extend({ } else { this.input_type = 'select'; - this.input = this.theme.getSelectInput(options); + this.input = this.theme.getSelectInput(this.option_keys); this.input.multiple = true; this.input.size = Math.min(10,this.option_keys.length); diff --git a/src/editors/object.js b/src/editors/object.js index a9f3bcc40..f0db5e06d 100644 --- a/src/editors/object.js +++ b/src/editors/object.js @@ -323,7 +323,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ e.stopPropagation(); if(self.addproperty_input.value) { if(self.editors[self.addproperty_input.value]) { - alert('there is already a property with that name'); + window.alert('there is already a property with that name'); return; } @@ -490,7 +490,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ this.hideEditJSON(); } catch(e) { - alert('invalid JSON'); + window.alert('invalid JSON'); throw e; } }, diff --git a/src/editors/select.js b/src/editors/select.js index 9c685049e..aa82c48dd 100644 --- a/src/editors/select.js +++ b/src/editors/select.js @@ -116,8 +116,8 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({ this.value = this.enum_values[0]; // If the Select2 library is loaded use it when we have lots of items - if(window.$ && $.fn && $.fn.select2 && this.enum_options.length > 2) { - $(this.input).select2(); + if(window.jQuery && window.jQuery.fn && window.jQuery.fn.select2 && this.enum_options.length > 2) { + window.jQuery(this.input).select2(); } }, postBuild: function() { diff --git a/src/editors/string.js b/src/editors/string.js index 4d325d0e0..53140a19a 100644 --- a/src/editors/string.js +++ b/src/editors/string.js @@ -285,12 +285,12 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ this.container.appendChild(this.control); // If the Select2 library is loaded - if(this.input_type === "select" && window.$ && $.fn && $.fn.select2) { - $(this.input).select2(); + if(this.input_type === "select" && window.jQuery && window.jQuery.fn && window.jQuery.fn.select2) { + window.jQuery(this.input).select2(); } // Any special formatting that needs to happen after the input is added to the dom - requestAnimationFrame(function() { + window.requestAnimationFrame(function() { // Skip in case the input is only a temporary editor, // otherwise, in the case of an ace_editor creation, // it will generate an error trying to append it to the missing parentNode @@ -326,7 +326,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ // WYSIWYG html and bbcode editor if(this.options.wysiwyg && ['html','bbcode'].indexOf(this.input_type) >= 0 && - window.$ && $.fn && $.fn.sceditor + window.jQuery && window.jQuery.fn && window.jQuery.fn.sceditor ) { options = $extend({},{ plugins: self.input_type==='html'? 'xhtml' : 'bbcode', @@ -335,15 +335,15 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ height: 300 },JSONEditor.plugins.sceditor); - $(self.input).sceditor(options); + window.jQuery(self.input).sceditor(options); - self.sceditor_instance = $(self.input).sceditor('instance'); + self.sceditor_instance = window.jQuery(self.input).sceditor('instance'); self.sceditor_instance.blur(function() { // Get editor's value - var val = $("
    "+self.sceditor_instance.val()+"
    "); + var val = window.jQuery("
    "+self.sceditor_instance.val()+"
    "); // Remove sceditor spans/divs - $('#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf',val).remove(); + window.jQuery('#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf',val).remove(); // Set the value and update self.input.value = val.html(); self.value = self.input.value; @@ -364,7 +364,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ clientSideStorage: false }); - this.epiceditor = new EpicEditor(options).load(); + this.epiceditor = new window.EpicEditor(options).load(); this.epiceditor.importFile(null,this.getValue()); @@ -392,14 +392,14 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ 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 = window.ace.edit(this.ace_container); this.ace_editor.setValue(this.getValue()); // The theme if(JSONEditor.plugins.ace.theme) this.ace_editor.setTheme('ace/theme/'+JSONEditor.plugins.ace.theme); // The mode - mode = ace.require("ace/mode/"+mode); + mode = window.ace.require("ace/mode/"+mode); if(mode) this.ace_editor.getSession().setMode(new mode.Mode()); // Listen for changes @@ -483,7 +483,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ if(this.enumSource[i].filter) { var new_items = []; for(j=0; j HTML Editor +/*! JSON Editor v0.7.4 - JSON Schema -> HTML Editor * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license * - * Date: 2014-07-28 + * Date: 2014-07-29 */ /** diff --git a/src/jquery.js b/src/jquery.js index e2f0ab3bc..1ca541d24 100644 --- a/src/jquery.js +++ b/src/jquery.js @@ -1,62 +1,64 @@ /** * This is a small wrapper for using JSON Editor like a typical jQuery plugin. */ -if(window.jQuery || window.Zepto) { - window.$ = window.$ || {}; - $.jsoneditor = JSONEditor.defaults; - - (window.jQuery || window.Zepto).fn.jsoneditor = function(options) { - var self = this; - var editor = this.data('jsoneditor'); - if(options === 'value') { - if(!editor) throw "Must initialize jsoneditor before getting/setting the value"; - - // Set value - if(arguments.length > 1) { - editor.setValue(arguments[1]); +(function() { + if(window.jQuery || window.Zepto) { + var $ = window.jQuery || window.Zepto; + $.jsoneditor = JSONEditor.defaults; + + $.fn.jsoneditor = function(options) { + var self = this; + var editor = this.data('jsoneditor'); + if(options === 'value') { + if(!editor) throw "Must initialize jsoneditor before getting/setting the value"; + + // Set value + if(arguments.length > 1) { + editor.setValue(arguments[1]); + } + // Get value + else { + return editor.getValue(); + } } - // Get value - else { - return editor.getValue(); + else if(options === 'validate') { + if(!editor) throw "Must initialize jsoneditor before validating"; + + // Validate a specific value + if(arguments.length > 1) { + return editor.validate(arguments[1]); + } + // Validate current value + else { + return editor.validate(); + } } - } - else if(options === 'validate') { - if(!editor) throw "Must initialize jsoneditor before validating"; - - // Validate a specific value - if(arguments.length > 1) { - return editor.validate(arguments[1]); + else if(options === 'destroy') { + if(editor) { + editor.destroy(); + this.data('jsoneditor',null); + } } - // Validate current value else { - return editor.validate(); - } - } - else if(options === 'destroy') { - if(editor) { - editor.destroy(); - this.data('jsoneditor',null); - } - } - else { - // Destroy first - if(editor) { - editor.destroy(); + // Destroy first + if(editor) { + editor.destroy(); + } + + // Create editor + editor = new JSONEditor(this.get(0),options); + this.data('jsoneditor',editor); + + // Setup event listeners + editor.on('change',function() { + self.trigger('change'); + }); + editor.on('ready',function() { + self.trigger('ready'); + }); } - // Create editor - editor = new JSONEditor(this.get(0),options); - this.data('jsoneditor',editor); - - // Setup event listeners - editor.on('change',function() { - self.trigger('change'); - }); - editor.on('ready',function() { - self.trigger('ready'); - }); - } - - return this; - }; -} + return this; + }; + } +})(); diff --git a/src/templates/ejs.js b/src/templates/ejs.js index aac568ab4..fe5bcaf5a 100644 --- a/src/templates/ejs.js +++ b/src/templates/ejs.js @@ -3,7 +3,7 @@ JSONEditor.defaults.templates.ejs = function() { return { compile: function(template) { - var compiled = new EJS({ + var compiled = new window.EJS({ text: template }); diff --git a/src/templates/hogan.js b/src/templates/hogan.js index 8e5710121..7e899d2eb 100644 --- a/src/templates/hogan.js +++ b/src/templates/hogan.js @@ -3,7 +3,7 @@ JSONEditor.defaults.templates.hogan = function() { return { compile: function(template) { - var compiled = Hogan.compile(template); + var compiled = window.Hogan.compile(template); return function(context) { return compiled.render(context); }; diff --git a/src/templates/markup.js b/src/templates/markup.js index d6cf248c8..d33d0c697 100644 --- a/src/templates/markup.js +++ b/src/templates/markup.js @@ -4,7 +4,7 @@ JSONEditor.defaults.templates.markup = function() { return { compile: function(template) { return function(context) { - return Mark.up(template,context); + return window.Mark.up(template,context); }; } }; diff --git a/src/templates/mustache.js b/src/templates/mustache.js index 9d6cbba02..3545c7436 100644 --- a/src/templates/mustache.js +++ b/src/templates/mustache.js @@ -4,7 +4,7 @@ JSONEditor.defaults.templates.mustache = function() { return { compile: function(template) { return function(view) { - return Mustache.render(template, view); + return window.Mustache.render(template, view); }; } }; diff --git a/src/templates/underscore.js b/src/templates/underscore.js index 3786b64b7..1b73c3966 100644 --- a/src/templates/underscore.js +++ b/src/templates/underscore.js @@ -4,7 +4,7 @@ JSONEditor.defaults.templates.underscore = function() { return { compile: function(template) { return function(context) { - return _.template(template, context); + return window._.template(template, context); }; } };