diff --git a/README.rst b/README.rst index 5081ca1..c20ef74 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,40 @@ Current features * **template tags**: tag templates to automate different types of auto-configurations (eg: mesh, WDS, 4G) * **simple HTTP resources**: allow devices to automatically download configuration updates * **VPN management**: easily create VPN servers and clients +* **Template variables**: makes it possible to declare context (configuration variables) in template configuration while setting the default values for these declared context in the default values field to bypass validation. + +we can create a configuration in advanced mode with the following: + +.. code-block:: python + + { + "interfaces": [ + { + "type": "ethernet", + "name": "eth1", + "mtu": 1500, + "mac": "{{mac}}", + "autostart": true, + "disabled": false, + "addresses": [], + "network": "" + } + ] + } + +with the configuration above, we will need to set our default values field with the following +json value specifying a default value for the `{{mac}}` variable. + +.. code-block:: python + + { + "mac": "00:0a:95:9d:68:17" + } + +**note**: the following condition must be met for us to pass the validation: + - default_values must be a valid json + - values in default_values must be correctly set in JSON format + - default values must be set for all declared variables. Project goals ------------- diff --git a/django_netjsonconfig/base/admin.py b/django_netjsonconfig/base/admin.py index 55586a6..aecb5bf 100644 --- a/django_netjsonconfig/base/admin.py +++ b/django_netjsonconfig/base/admin.py @@ -370,6 +370,7 @@ class AbstractTemplateAdmin(BaseConfigAdmin): 'vpn', 'auto_cert', 'tags', + 'default_values', 'default', 'config', 'created', diff --git a/django_netjsonconfig/base/base.py b/django_netjsonconfig/base/base.py index 6dc24aa..0fafe3b 100644 --- a/django_netjsonconfig/base/base.py +++ b/django_netjsonconfig/base/base.py @@ -148,15 +148,21 @@ def get_backend_instance(self, template_instances=None): """ backend = self.backend_class kwargs = {'config': self.get_config()} + context = {} # determine if we can pass templates # expecting a many2many relationship if hasattr(self, 'templates'): if template_instances is None: template_instances = self.templates.all() - kwargs['templates'] = [t.config for t in template_instances] + templates_list = list() + for t in template_instances: + templates_list.append(t.config) + context.update(t.get_context()) + kwargs['templates'] = templates_list # pass context to backend if get_context method is defined if hasattr(self, 'get_context'): - kwargs['context'] = self.get_context() + context.update(self.get_context()) + kwargs['context'] = context backend_instance = backend(**kwargs) # remove accidentally duplicated files when combining config and templates # this may happen if a device uses multiple VPN client templates diff --git a/django_netjsonconfig/base/template.py b/django_netjsonconfig/base/template.py index 491e1b9..037d7be 100644 --- a/django_netjsonconfig/base/template.py +++ b/django_netjsonconfig/base/template.py @@ -1,3 +1,4 @@ +from collections import OrderedDict from copy import copy from django.contrib.admin.models import ADDITION, LogEntry @@ -5,6 +6,7 @@ from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import ugettext_lazy as _ +from jsonfield import JSONField from taggit.managers import TaggableManager from ..settings import DEFAULT_AUTO_CERT @@ -73,6 +75,19 @@ class AbstractTemplate(BaseConfig): 'valid only for the VPN type' ), ) + default_values = JSONField( + _('Default Values'), + default=dict, + blank=True, + help_text=_( + 'A dictionary containing the default ' + 'values for the variables used by this ' + 'template; these default variables will ' + 'be used during schema validation.' + ), + load_kwargs={'object_pairs_hook': OrderedDict}, + dump_kwargs={'indent': 4}, + ) __template__ = True class Meta: @@ -114,7 +129,6 @@ def clean(self, *args, **kwargs): * clears VPN specific fields if type is not VPN * automatically determines configuration if necessary """ - super().clean(*args, **kwargs) if self.type == 'vpn' and not self.vpn: raise ValidationError( {'vpn': _('A VPN must be selected when template type is "VPN"')} @@ -124,14 +138,14 @@ def clean(self, *args, **kwargs): self.auto_cert = False if self.type == 'vpn' and not self.config: self.config = self.vpn.auto_client(auto_cert=self.auto_cert) + super().clean(*args, **kwargs) def get_context(self): - c = { - 'id': str(self.id), - 'name': self.name, - } - c.update(super().get_context()) - return c + context = {} + if self.default_values: + context = copy(self.default_values) + context.update(super().get_context()) + return context def clone(self, user): clone = copy(self) diff --git a/django_netjsonconfig/migrations/0044_template_default_values.py b/django_netjsonconfig/migrations/0044_template_default_values.py new file mode 100644 index 0000000..383b88f --- /dev/null +++ b/django_netjsonconfig/migrations/0044_template_default_values.py @@ -0,0 +1,27 @@ +# Generated by Django 3.0.4 on 2020-04-08 23:46 + +import collections +from django.db import migrations +import jsonfield.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_netjsonconfig', '0043_add_indexes_on_ip_fields'), + ] + + operations = [ + migrations.AddField( + model_name='template', + name='default_values', + field=jsonfield.fields.JSONField( + blank=True, + default=dict, + dump_kwargs={'ensure_ascii': False, 'indent': 4}, + help_text='A dictionary containing the default values for the variables used by this template; these default variables will be used during schema validation.', + load_kwargs={'object_pairs_hook': collections.OrderedDict}, + verbose_name='Default Values', + ), + ), + ] diff --git a/django_netjsonconfig/static/django-netjsonconfig/js/lib/advanced-mode.js b/django_netjsonconfig/static/django-netjsonconfig/js/lib/advanced-mode.js index a6895fb..b46c017 100644 --- a/django_netjsonconfig/static/django-netjsonconfig/js/lib/advanced-mode.js +++ b/django_netjsonconfig/static/django-netjsonconfig/js/lib/advanced-mode.js @@ -3244,26 +3244,26 @@ return /******/ (function(modules) { // webpackBootstrap text: text }; }, - + next = function (c) { // If a c parameter is provided, verify that it matches the current character. if (c && c !== ch) { error("Expected '" + c + "' instead of '" + ch + "'"); } - + // Get the next character. When there are no more characters, // return the empty string. - + ch = text.charAt(at); at += 1; return ch; }, - + number = function () { // Parse a number value. var number, string = ''; - + if (ch === '-') { string = '-'; next('-'); @@ -3297,14 +3297,14 @@ return /******/ (function(modules) { // webpackBootstrap return number; } }, - + string = function () { // Parse a string value. var hex, i, string = '', uffff; - + // When parsing for string values, we must look for " and \ characters. if (ch === '"') { while (next()) { @@ -3461,7 +3461,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = function (source, reviver) { var result; - + text = source; at = 0; ch = ' '; @@ -3520,7 +3520,7 @@ return /******/ (function(modules) { // webpackBootstrap // backslash characters, then we can safely slap some quotes around it. // Otherwise we must also replace the offending characters with safe escape // sequences. - + escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { var c = meta[a]; @@ -3538,47 +3538,47 @@ return /******/ (function(modules) { // webpackBootstrap mind = gap, partial, value = holder[key]; - + // If the value has a toJSON method, call it to obtain a replacement value. if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); } - + // If we were called with a replacer function, then call the replacer to // obtain a replacement value. if (typeof rep === 'function') { value = rep.call(holder, key, value); } - + // What happens next depends on the value's type. switch (typeof value) { case 'string': return quote(value); - + case 'number': // JSON numbers must be finite. Encode non-finite numbers as null. return isFinite(value) ? String(value) : 'null'; - + case 'boolean': case 'null': // If the value is a boolean or null, convert it to a string. Note: // typeof null does not produce 'null'. The case is included here in // the remote chance that this gets fixed someday. return String(value); - + case 'object': if (!value) return 'null'; gap += indent; partial = []; - + // Array.isArray if (Object.prototype.toString.apply(value) === '[object Array]') { length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; } - + // Join all of the elements together, separated with commas, and // wrap them in brackets. v = partial.length === 0 ? '[]' : gap ? @@ -3587,7 +3587,7 @@ return /******/ (function(modules) { // webpackBootstrap gap = mind; return v; } - + // If the replacer is an array, use it to select the members to be // stringified. if (rep && typeof rep === 'object') { @@ -3613,7 +3613,7 @@ return /******/ (function(modules) { // webpackBootstrap } } } - + // Join all of the member texts together, separated with commas, // and wrap them in braces. @@ -3629,7 +3629,7 @@ return /******/ (function(modules) { // webpackBootstrap var i; gap = ''; indent = ''; - + // If the space parameter is a number, make an indent string containing that // many spaces. if (typeof space === 'number') { @@ -3649,7 +3649,7 @@ return /******/ (function(modules) { // webpackBootstrap && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } - + // Make a fake root object containing our value under the key of ''. // Return the result of stringifying the value. return str('', {'': value}); @@ -4423,7 +4423,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 19 */ /***/ function(module, exports) { - + /** * slice() reference. */ @@ -10745,7 +10745,7 @@ return /******/ (function(modules) { // webpackBootstrap .replace(/\\v/g,'\v') .replace(/\\f/g,'\f') .replace(/\\b/g,'\b'); - + break; case 2:this.$ = Number(yytext); break; @@ -11069,7 +11069,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this._input === "") { return this.EOF; } else { - this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), + this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), {text: "", token: null, line: this.yylineno}); } }, @@ -16165,7 +16165,7 @@ return /******/ (function(modules) { // webpackBootstrap } this.textarea = null; - + this._debouncedValidate = null; }; @@ -16302,8 +16302,8 @@ return /******/ (function(modules) { // webpackBootstrap var errors = []; var json; try { - json = this.get(); // this can fail when there is no valid json - doValidate = true; + json = cleanData(this.get()); // this can fail when there is no valid json + doValidate = true; } catch (err) { // no valid JSON, don't validate @@ -16710,7 +16710,7 @@ return /******/ (function(modules) { // webpackBootstrap return a; } var array = [], lengthBefore; - + array.splice.apply(array, makeArray(20)); array.splice.apply(array, makeArray(26)); @@ -16751,7 +16751,7 @@ return /******/ (function(modules) { // webpackBootstrap var removed = this.slice(pos, pos+removeCount); var insert = slice.call(arguments, 2); - var add = insert.length; + var add = insert.length; if (pos === length) { if (add) { this.push.apply(this, insert); @@ -17430,12 +17430,12 @@ return /******/ (function(modules) { // webpackBootstrap doc = doc || document; if (id && exports.hasCssString(id, doc)) return null; - + var style; - + if (id) cssText += "\n/*# sourceURL=ace/css/" + id + " */"; - + if (doc.createStyleSheet) { style = doc.createStyleSheet(); style.cssText = cssText; @@ -17466,7 +17466,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.getInnerWidth = function(element) { return ( parseInt(exports.computedStyle(element, "paddingLeft"), 10) + - parseInt(exports.computedStyle(element, "paddingRight"), 10) + + parseInt(exports.computedStyle(element, "paddingRight"), 10) + element.clientWidth ); }; @@ -17701,10 +17701,10 @@ return /******/ (function(modules) { // webpackBootstrap ret.escape = ret.esc; ret.del = ret["delete"]; ret[173] = '-'; - + (function() { var mods = ["cmd", "ctrl", "alt", "shift"]; - for (var i = Math.pow(2, mods.length); i--;) { + for (var i = Math.pow(2, mods.length); i--;) { ret.KEY_MODS[i] = mods.filter(function(x) { return i & ret.KEY_MODS[x]; }).join("-") + "-"; @@ -17751,11 +17751,11 @@ return /******/ (function(modules) { // webpackBootstrap exports.isWin = (os == "win"); exports.isMac = (os == "mac"); exports.isLinux = (os == "linux"); - exports.isIE = + exports.isIE = (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]) : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie - + exports.isOldIE = exports.isIE && exports.isIE < 9; exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko"; exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4; @@ -17849,7 +17849,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.addListener(document, "mousemove", eventHandler, true); exports.addListener(document, "mouseup", onMouseUp, true); exports.addListener(document, "dragstart", onMouseUp, true); - + return onMouseUp; }; @@ -17873,7 +17873,7 @@ return /******/ (function(modules) { // webpackBootstrap callback(e); }); - } + } }; exports.addMouseWheelListener = function(el, callback) { @@ -17903,7 +17903,7 @@ return /******/ (function(modules) { // webpackBootstrap e.wheelY = (e.deltaY || 0) * 5; break; } - + callback(e); }); } else { @@ -17922,7 +17922,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) { var clicks = 0; - var startX, startY, timer; + var startX, startY, timer; var eventNames = { 2: "dblclick", 3: "tripleclick", @@ -17952,7 +17952,7 @@ return /******/ (function(modules) { // webpackBootstrap startY = e.clientY; } } - + e._clicks = clicks; eventHandler[callbackName]("mousedown", e); @@ -18015,14 +18015,14 @@ return /******/ (function(modules) { // webpackBootstrap } } } - + if (keyCode in keys.MODIFIER_KEYS) { keyCode = -1; } if (hashId & 8 && (keyCode >= 91 && keyCode <= 93)) { keyCode = -1; } - + if (!hashId && keyCode === 13) { var location = "location" in e ? e.location : e.keyLocation; if (location === 3) { @@ -18031,7 +18031,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } } - + if (useragent.isChromeOS && hashId & 8) { callback(e, hashId, keyCode); if (e.defaultPrevented) @@ -18042,7 +18042,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) { return false; } - + return callback(e, hashId, keyCode); } @@ -18187,7 +18187,7 @@ return /******/ (function(modules) { // webpackBootstrap for (var i=0, l=array.length; i 0 || rows > 0) @@ -21415,7 +21415,7 @@ return /******/ (function(modules) { // webpackBootstrap if (rule.token.length == 1 || matchcount == 1) { rule.token = rule.token[0]; } else if (matchcount - 1 != rule.token.length) { - this.reportError("number of classes and regexp groups doesn't match", { + this.reportError("number of classes and regexp groups doesn't match", { rule: rule, groupCount: matchcount - 1 }); @@ -21452,12 +21452,12 @@ return /******/ (function(modules) { // webpackBootstrap if (!rule.onMatch) rule.onMatch = null; } - + if (!ruleRegExps.length) { mapping[0] = 0; ruleRegExps.push("$"); } - + splitterRurles.forEach(function(rule) { rule.splitRegex = this.createSplitterRegexp(rule.regex, flag); }, this); @@ -21470,7 +21470,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$setMaxTokenCount = function(m) { MAX_TOKEN_COUNT = m | 0; }; - + this.$applyToken = function(str) { var values = this.splitRegex.exec(str).slice(1); var types = this.token.apply(this, values); @@ -21547,7 +21547,7 @@ return /******/ (function(modules) { // webpackBootstrap } if (src.charAt(0) != "^") src = "^" + src; if (src.charAt(src.length - 1) != "$") src += "$"; - + return new RegExp(src, (flag||"").replace("g", "")); }; this.getLineTokens = function(line, startState) { @@ -21611,7 +21611,7 @@ return /******/ (function(modules) { // webpackBootstrap } else { currentState = rule.next(currentState, stack); } - + state = this.states[currentState]; if (!state) { this.reportError("state doesn't exist", currentState); @@ -21672,7 +21672,7 @@ return /******/ (function(modules) { // webpackBootstrap if (token.type) tokens.push(token); - + if (stack.length > 1) { if (stack[0] !== currentState) stack.unshift("#tmp", currentState); @@ -21682,9 +21682,9 @@ return /******/ (function(modules) { // webpackBootstrap state : stack.length ? stack : currentState }; }; - + this.reportError = config.reportError; - + }).call(Tokenizer.prototype); exports.Tokenizer = Tokenizer; @@ -21845,7 +21845,7 @@ return /******/ (function(modules) { // webpackBootstrap i--; toInsert = null; } - + if (rule.keywordMap) { rule.token = this.createKeywordMapper( rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive @@ -21904,7 +21904,7 @@ return /******/ (function(modules) { // webpackBootstrap } this.$behaviours[name][action] = callback; } - + this.addBehaviours = function (behaviours) { for (var key in behaviours) { for (var action in behaviours[key]) { @@ -21912,13 +21912,13 @@ return /******/ (function(modules) { // webpackBootstrap } } } - + this.remove = function (name) { if (this.$behaviours && this.$behaviours[name]) { delete this.$behaviours[name]; } } - + this.inherit = function (mode, filter) { if (typeof mode === "function") { var behaviours = new mode().getBehaviours(filter); @@ -21927,7 +21927,7 @@ return /******/ (function(modules) { // webpackBootstrap } this.addBehaviours(behaviours); } - + this.getBehaviours = function (filter) { if (!filter) { return this.$behaviours; @@ -22010,23 +22010,23 @@ return /******/ (function(modules) { // webpackBootstrap this.$tokenIndex = token ? token.index : -1; }; - (function() { + (function() { this.stepBackward = function() { this.$tokenIndex -= 1; - + while (this.$tokenIndex < 0) { this.$row -= 1; if (this.$row < 0) { this.$row = 0; return null; } - + this.$rowTokens = this.$session.getTokens(this.$row); this.$tokenIndex = this.$rowTokens.length - 1; } - + return this.$rowTokens[this.$tokenIndex]; - }; + }; this.stepForward = function() { this.$tokenIndex += 1; var rowCount; @@ -22042,34 +22042,34 @@ return /******/ (function(modules) { // webpackBootstrap this.$rowTokens = this.$session.getTokens(this.$row); this.$tokenIndex = 0; } - + return this.$rowTokens[this.$tokenIndex]; - }; + }; this.getCurrentToken = function () { return this.$rowTokens[this.$tokenIndex]; - }; + }; this.getCurrentTokenRow = function () { return this.$row; - }; + }; this.getCurrentTokenColumn = function() { var rowTokens = this.$rowTokens; var tokenIndex = this.$tokenIndex; var column = rowTokens[tokenIndex].start; if (column !== undefined) return column; - + column = 0; while (tokenIndex > 0) { tokenIndex -= 1; column += rowTokens[tokenIndex].value.length; } - - return column; + + return column; }; this.getCurrentTokenPosition = function() { return {row: this.$row, column: this.getCurrentTokenColumn()}; }; - + }).call(TokenIterator.prototype); exports.TokenIterator = TokenIterator; @@ -22170,7 +22170,7 @@ return /******/ (function(modules) { // webpackBootstrap var lineCommentStart = this.lineCommentStart; } regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?"); - + insertAtTabStop = session.getUseSoftTabs(); var uncomment = function(line, i) { @@ -22193,7 +22193,7 @@ return /******/ (function(modules) { // webpackBootstrap var testRemove = function(line, i) { return regexpStart.test(line); }; - + var shouldInsertSpace = function(line, before, after) { var spaces = 0; while (before-- && line.charAt(before) == " ") @@ -22330,7 +22330,7 @@ return /******/ (function(modules) { // webpackBootstrap } } - var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent", + var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent", "checkOutdent", "autoOutdent", "transformAction", "getCompletions"]; for (var i = 0; i < delegations.length; i++) { @@ -22375,7 +22375,7 @@ return /******/ (function(modules) { // webpackBootstrap } } }; - + this.getKeywords = function(append) { if (!this.completionKeywords) { var rules = this.$tokenizer.rules; @@ -22388,7 +22388,7 @@ return /******/ (function(modules) { // webpackBootstrap completionKeywords.push(ruleItr[r].regex); } else if (typeof ruleItr[r].token === "object") { - for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) { + for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) { if (/keyword|support|storage/.test(ruleItr[r].token[a])) { var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a]; completionKeywords.push(rule.substr(1, rule.length - 2)); @@ -22403,7 +22403,7 @@ return /******/ (function(modules) { // webpackBootstrap return this.$keywordList; return completionKeywords.concat(this.$keywordList || []); }; - + this.$createKeywordList = function() { if (!this.$highlightRules) this.getTokenizer(); @@ -22461,7 +22461,7 @@ return /******/ (function(modules) { // webpackBootstrap } exports.applyDelta = function(docLines, delta, doNotValidate) { - + var row = delta.start.row; var startColumn = delta.start.column; var line = docLines[row] || ""; @@ -22502,7 +22502,7 @@ return /******/ (function(modules) { // webpackBootstrap var Anchor = exports.Anchor = function(doc, row, column) { this.$onChange = this.onChange.bind(this); this.attach(doc); - + if (typeof column == "undefined") this.setPosition(row.row, row.column); else @@ -22525,16 +22525,16 @@ return /******/ (function(modules) { // webpackBootstrap if (delta.start.row > this.row) return; - + var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight); this.setPosition(point.row, point.column, true); }; - + function $pointsInOrder(point1, point2, equalPointsInOrder) { var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column; return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter); } - + function $getTransformedPoint(delta, point, moveIfEqual) { var deltaIsInsert = delta.action == "insert"; var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row); @@ -22553,7 +22553,7 @@ return /******/ (function(modules) { // webpackBootstrap column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0) }; } - + return { row: deltaStart.row, column: deltaStart.column @@ -22737,23 +22737,23 @@ return /******/ (function(modules) { // webpackBootstrap this.insert = function(position, text) { if (this.getLength() <= 1) this.$detectNewLine(text); - + return this.insertMergedLines(position, this.$split(text)); }; this.insertInLine = function(position, text) { var start = this.clippedPos(position.row, position.column); var end = this.pos(position.row, position.column + text.length); - + this.applyDelta({ start: start, end: end, action: "insert", lines: [text] }, true); - + return this.clonePos(end); }; - + this.clippedPos = function(row, column) { var length = this.getLength(); if (row === undefined) { @@ -22770,15 +22770,15 @@ return /******/ (function(modules) { // webpackBootstrap column = Math.min(Math.max(column, 0), line.length); return {row: row, column: column}; }; - + this.clonePos = function(pos) { return {row: pos.row, column: pos.column}; }; - + this.pos = function(row, column) { return {row: row, column: column}; }; - + this.$clipPosition = function(position) { var length = this.getLength(); if (position.row >= length) { @@ -22802,21 +22802,21 @@ return /******/ (function(modules) { // webpackBootstrap column = this.$lines[row].length; } this.insertMergedLines({row: row, column: column}, lines); - }; + }; this.insertMergedLines = function(position, lines) { var start = this.clippedPos(position.row, position.column); var end = { row: start.row + lines.length - 1, column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length }; - + this.applyDelta({ start: start, end: end, action: "insert", lines: lines }); - + return this.clonePos(end); }; this.remove = function(range) { @@ -22833,14 +22833,14 @@ return /******/ (function(modules) { // webpackBootstrap this.removeInLine = function(row, startColumn, endColumn) { var start = this.clippedPos(row, startColumn); var end = this.clippedPos(row, endColumn); - + this.applyDelta({ start: start, end: end, action: "remove", lines: this.getLinesForRange({start: start, end: end}) }, true); - + return this.clonePos(start); }; this.removeFullLines = function(firstRow, lastRow) { @@ -22851,10 +22851,10 @@ return /******/ (function(modules) { // webpackBootstrap var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow ); var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 ); var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow ); - var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length ); + var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length ); var range = new Range(startRow, startCol, endRow, endCol); var deletedLines = this.$lines.slice(firstRow, lastRow + 1); - + this.applyDelta({ start: range.start, end: range.end, @@ -22889,7 +22889,7 @@ return /******/ (function(modules) { // webpackBootstrap else { end = range.start; } - + return end; }; this.applyDeltas = function(deltas) { @@ -22908,17 +22908,17 @@ return /******/ (function(modules) { // webpackBootstrap : !Range.comparePoints(delta.start, delta.end)) { return; } - + if (isInsert && delta.lines.length > 20000) this.$splitAndapplyLargeDelta(delta, 20000); applyDelta(this.$lines, delta, doNotValidate); this._signal("change", delta); }; - + this.$splitAndapplyLargeDelta = function(delta, MAX) { var lines = delta.lines; var l = lines.length; - var row = delta.start.row; + var row = delta.start.row; var column = delta.start.column; var from = 0, to = 0; do { @@ -23000,7 +23000,7 @@ return /******/ (function(modules) { // webpackBootstrap var startLine = currentLine; while (self.lines[currentLine]) currentLine++; - + var len = doc.getLength(); var processedLines = 0; self.running = false; @@ -23011,13 +23011,13 @@ return /******/ (function(modules) { // webpackBootstrap currentLine++; } while (self.lines[currentLine]); processedLines ++; - if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { + if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { self.running = setTimeout(self.$worker, 20); break; } } self.currentLine = currentLine; - + if (startLine <= endLine) self.fireUpdateEvent(startLine, endLine); }; @@ -23055,7 +23055,7 @@ return /******/ (function(modules) { // webpackBootstrap this.stop(); this.running = setTimeout(this.$worker, 700); }; - + this.scheduleStart = function() { if (!this.running) this.running = setTimeout(this.$worker, 700); @@ -23133,7 +23133,7 @@ return /******/ (function(modules) { // webpackBootstrap (function() { this.MAX_RANGES = 500; - + this.setRegexp = function(regExp) { if (this.regExp+"" == regExp+"") return; @@ -23319,14 +23319,14 @@ return /******/ (function(modules) { // webpackBootstrap this.split = function(row, column) { var pos = this.getNextFoldTo(row, column); - + if (!pos || pos.kind == "inside") return null; - + var fold = pos.fold; var folds = this.folds; var foldData = this.foldData; - + var i = folds.indexOf(fold); var foldBefore = folds[i - 1]; this.end.row = foldBefore.end.row; @@ -23452,11 +23452,11 @@ return /******/ (function(modules) { // webpackBootstrap this.merge = function() { var removed = []; var list = this.ranges; - + list = list.sort(function(a, b) { return comparePoints(a.start, b.start); }); - + var next = list[0], range; for (var i = 1; i < list.length; i++) { range = next; @@ -23478,7 +23478,7 @@ return /******/ (function(modules) { // webpackBootstrap next = range; i--; } - + this.ranges = list; return removed; @@ -23572,7 +23572,7 @@ return /******/ (function(modules) { // webpackBootstrap if (r.end.column == start.column && this.$insertRight) { continue; } - if (r.end.column == start.column && colDiff > 0 && i < n - 1) { + if (r.end.column == start.column && colDiff > 0 && i < n - 1) { if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column) r.end.column -= colDiff; } @@ -23671,7 +23671,7 @@ return /******/ (function(modules) { // webpackBootstrap return fold; }; - + this.restoreRange = function(range) { return restoreRange(range, this.start); }; @@ -23779,7 +23779,7 @@ return /******/ (function(modules) { // webpackBootstrap this.getAllFolds = function() { var folds = []; var foldLines = this.$foldData; - + for (var i = 0; i < foldLines.length; i++) for (var j = 0; j < foldLines[i].folds.length; j++) folds.push(foldLines[i].folds[j]); @@ -23888,7 +23888,7 @@ return /******/ (function(modules) { // webpackBootstrap var foldData = this.$foldData; var added = false; var fold; - + if (placeholder instanceof Fold) fold = placeholder; else { @@ -23901,7 +23901,7 @@ return /******/ (function(modules) { // webpackBootstrap var startColumn = fold.start.column; var endRow = fold.end.row; var endColumn = fold.end.column; - if (!(startRow < endRow || + if (!(startRow < endRow || startRow == endRow && startColumn <= endColumn - 2)) throw new Error("The range has to be at least 2 characters width"); @@ -23912,7 +23912,7 @@ return /******/ (function(modules) { // webpackBootstrap if (startFold && !startFold.range.isStart(startRow, startColumn)) this.removeFold(startFold); - + if (endFold && !endFold.range.isEnd(endRow, endColumn)) this.removeFold(endFold); var folds = this.getFoldsInRange(fold.range); @@ -24046,7 +24046,7 @@ return /******/ (function(modules) { // webpackBootstrap range = Range.fromPoints(location, location); else range = location; - + folds = this.getFoldsInRangeList(range); if (expandInner) { this.removeFolds(folds); @@ -24201,12 +24201,12 @@ return /******/ (function(modules) { // webpackBootstrap } while (token && re.test(token.type)); iterator.stepForward(); } - + range.start.row = iterator.getCurrentTokenRow(); range.start.column = iterator.getCurrentTokenColumn() + 2; iterator = new TokenIterator(this, row, column); - + if (dir != -1) { do { token = iterator.stepForward(); @@ -24258,12 +24258,12 @@ return /******/ (function(modules) { // webpackBootstrap this.setFoldStyle = function(style) { if (!this.$foldStyles[style]) throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]"); - + if (this.$foldStyle == style) return; this.$foldStyle = style; - + if (style == "manual") this.unfold(); var mode = this.$foldMode; @@ -24274,22 +24274,22 @@ return /******/ (function(modules) { // webpackBootstrap this.$setFolding = function(foldMode) { if (this.$foldMode == foldMode) return; - + this.$foldMode = foldMode; - + this.off('change', this.$updateFoldWidgets); this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets); this._signal("changeAnnotation"); - + if (!foldMode || this.$foldStyle == "manual") { this.foldWidgets = null; return; } - + this.foldWidgets = []; this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle); this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle); - + this.$updateFoldWidgets = this.updateFoldWidgets.bind(this); this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this); this.on('change', this.$updateFoldWidgets); @@ -24330,7 +24330,7 @@ return /******/ (function(modules) { // webpackBootstrap all: e.ctrlKey || e.metaKey, siblings: e.altKey }; - + var range = this.$toggleFoldWidget(row, options); if (!range) { var el = (e.target || e.srcElement); @@ -24338,7 +24338,7 @@ return /******/ (function(modules) { // webpackBootstrap el.className += " ace_invalid"; } }; - + this.$toggleFoldWidget = function(row, options) { if (!this.getFoldWidget) return; @@ -24364,7 +24364,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } } - + if (options.siblings) { var data = this.getParentFoldRangeData(row); if (data.range) { @@ -24376,26 +24376,26 @@ return /******/ (function(modules) { // webpackBootstrap endRow = range ? range.end.row : this.getLength(); this.foldAll(row + 1, endRow, options.all ? 10000 : 0); } else if (range) { - if (options.all) + if (options.all) range.collapseChildren = 10000; this.addFold("...", range); } - + return range; }; - - - + + + this.toggleFoldWidget = function(toggleParent) { var row = this.selection.getCursor().row; row = this.getRowFoldStart(row); var range = this.$toggleFoldWidget(row, {}); - + if (range) return; var data = this.getParentFoldRangeData(row, true); range = data.range || data.firstRange; - + if (range) { row = range.start.row; var fold = this.getFoldAt(row, this.getLine(row).length, 1); @@ -24459,7 +24459,7 @@ return /******/ (function(modules) { // webpackBootstrap else return this.$findOpeningBracket(match[2], position); }; - + this.getBracketRange = function(pos) { var line = this.getLine(pos.row); var before = true, range; @@ -24496,7 +24496,7 @@ return /******/ (function(modules) { // webpackBootstrap } range.cursor = range.start; } - + return range; }; @@ -24519,7 +24519,7 @@ return /******/ (function(modules) { // webpackBootstrap token = iterator.stepForward(); if (!token) return; - + if (!typeRe){ typeRe = new RegExp( "(\\.?" + @@ -24530,9 +24530,9 @@ return /******/ (function(modules) { // webpackBootstrap } var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2; var value = token.value; - + while (true) { - + while (valueIndex >= 0) { var chr = value.charAt(valueIndex); if (chr == openBracket) { @@ -24553,11 +24553,11 @@ return /******/ (function(modules) { // webpackBootstrap if (token == null) break; - + value = token.value; valueIndex = value.length - 1; } - + return null; }; @@ -24609,7 +24609,7 @@ return /******/ (function(modules) { // webpackBootstrap valueIndex = 0; } - + return null; }; } @@ -24836,7 +24836,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.$syncInformUndoManager) this.$syncInformUndoManager(); }; - + this.$defaultUndoManager = { undo: function() {}, redo: function() {}, @@ -25105,7 +25105,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$onChangeMode = function(mode, $isPlaceholder) { if (!$isPlaceholder) this.$modeId = mode.$id; - if (this.$mode === mode) + if (this.$mode === mode) return; this.$mode = mode; @@ -25137,7 +25137,7 @@ return /******/ (function(modules) { // webpackBootstrap this.tokenRe = mode.tokenRe; this.nonTokenRe = mode.nonTokenRe; - + if (!$isPlaceholder) { if (mode.attachToSession) mode.attachToSession(this); @@ -25192,11 +25192,11 @@ return /******/ (function(modules) { // webpackBootstrap }; this.getScreenWidth = function() { this.$computeWidth(); - if (this.lineWidgets) + if (this.lineWidgets) return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth); return this.screenWidth; }; - + this.getLineWidgetMaxWidth = function() { if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth; var width = 0; @@ -25460,7 +25460,7 @@ return /******/ (function(modules) { // webpackBootstrap x.end.row += diff; return x; }); - + var lines = dir == 0 ? this.doc.getLines(firstRow, lastRow) : this.doc.removeFullLines(firstRow, lastRow); @@ -25615,7 +25615,7 @@ return /******/ (function(modules) { // webpackBootstrap var lastRow = end.row; var len = lastRow - firstRow; var removedFolds = null; - + this.$updating = true; if (len != 0) { if (action === "remove") { @@ -25931,7 +25931,7 @@ return /******/ (function(modules) { // webpackBootstrap this.getRowLength = function(row) { if (this.lineWidgets) var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; - else + else h = 0 if (!this.$useWrapMode || !this.$wrapData[row]) { return 1 + h; @@ -26199,7 +26199,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!maxScreenColumn) maxScreenColumn = Infinity; screenColumn = screenColumn || 0; - + var c, column; for (column = 0; column < str.length; column++) { c = str.charAt(column); @@ -26212,11 +26212,11 @@ return /******/ (function(modules) { // webpackBootstrap break; } } - + return [screenColumn, column]; }; }; - + this.destroy = function() { if (this.bgTokenizer) { this.bgTokenizer.setDocument(null); @@ -26301,7 +26301,7 @@ return /******/ (function(modules) { // webpackBootstrap return "off"; }, handlesSet: true - }, + }, wrapMethod: { set: function(val) { val = val == "auto" @@ -26431,12 +26431,12 @@ return /******/ (function(modules) { // webpackBootstrap for (var j = 0; j < len; j++) if (lines[row + j].search(re[j]) == -1) continue outer; - + var startLine = lines[row]; var line = lines[row + len - 1]; var startIndex = startLine.length - startLine.match(re[0])[0].length; var endIndex = line.match(re[len - 1])[0].length; - + if (prevRange && prevRange.end.row === row && prevRange.end.column > startIndex ) { @@ -26467,7 +26467,7 @@ return /******/ (function(modules) { // webpackBootstrap while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row) j--; - + ranges = ranges.slice(i, j + 1); for (i = 0, j = ranges.length; i < j; i++) { ranges[i].start.row += range.start.row; @@ -26490,7 +26490,7 @@ return /******/ (function(modules) { // webpackBootstrap var match = re.exec(input); if (!match || match[0].length != input.length) return null; - + replacement = input.replace(re, replacement); if (options.preserveCase) { replacement = replacement.split(""); @@ -26503,7 +26503,7 @@ return /******/ (function(modules) { // webpackBootstrap } replacement = replacement.join(""); } - + return replacement; }; @@ -26552,7 +26552,7 @@ return /******/ (function(modules) { // webpackBootstrap return true; }; } - + var lineIterator = this.$lineIterator(session, options); return { @@ -26617,7 +26617,7 @@ return /******/ (function(modules) { // webpackBootstrap var start = options.start; if (!start) start = range ? range[backwards ? "end" : "start"] : session.selection.getRange(); - + if (start.start) start = start[skipCurrent != backwards ? "end" : "start"]; @@ -26659,7 +26659,7 @@ return /******/ (function(modules) { // webpackBootstrap if (callback(session.getLine(row), row)) return; }; - + return {forEach: forEach}; }; @@ -26691,7 +26691,7 @@ return /******/ (function(modules) { // webpackBootstrap MultiHashHandler.prototype = HashHandler.prototype; (function() { - + this.addCommand = function(command) { if (this.commands[command.name]) @@ -26734,7 +26734,7 @@ return /******/ (function(modules) { // webpackBootstrap return; if (typeof command == "function") return this.addCommand({exec: command, bindKey: key, name: command.name || key}); - + key.split("|").forEach(function(keyPart) { var chain = ""; if (keyPart.indexOf(" ") != -1) { @@ -26753,7 +26753,7 @@ return /******/ (function(modules) { // webpackBootstrap this._addCommandToBinding(chain + id, command, position); }, this); }; - + function getPosition(command) { return typeof command == "object" && command.bindKey && command.bindKey.position || 0; @@ -26793,7 +26793,7 @@ return /******/ (function(modules) { // webpackBootstrap var command = commands[name]; if (!command) return; - + if (typeof command === "string") return this.bindKey(command, name); @@ -26863,14 +26863,14 @@ return /******/ (function(modules) { // webpackBootstrap data.$keyChain += " " + key; command = this.commandKeyBinding[data.$keyChain] || command; } - + if (command) { if (command == "chainKeys" || command[command.length - 1] == "chainKeys") { data.$keyChain = data.$keyChain || key; return {command: "null"}; } } - + if (data.$keyChain) { if ((!hashId || hashId == 4) && keyString.length == 1) data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input @@ -26879,7 +26879,7 @@ return /******/ (function(modules) { // webpackBootstrap } return {command: command}; }; - + this.getStatusText = function(editor, data) { return data.$keyChain || ""; }; @@ -26918,7 +26918,7 @@ return /******/ (function(modules) { // webpackBootstrap } return false; } - + if (typeof command === "string") command = this.commands[command]; @@ -27094,7 +27094,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { name: "foldOther", bindKey: bindKey("Alt-0", "Command-Option-0"), - exec: function(editor) { + exec: function(editor) { editor.session.foldAll(); editor.session.unfold(editor.selection.getAllRanges()); }, @@ -27127,13 +27127,13 @@ return /******/ (function(modules) { // webpackBootstrap if (editor.selection.isEmpty()) editor.selection.selectWord(); else - editor.findNext(); + editor.findNext(); }, readOnly: true }, { name: "selectOrFindPrevious", bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"), - exec: function(editor) { + exec: function(editor) { if (editor.selection.isEmpty()) editor.selection.selectWord(); else @@ -27506,7 +27506,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { name: "cut_or_delete", bindKey: bindKey("Shift-Delete", null), - exec: function(editor) { + exec: function(editor) { if (editor.selection.isEmpty()) { editor.remove("left"); } else { @@ -27732,13 +27732,13 @@ return /******/ (function(modules) { // webpackBootstrap this.commands.on("exec", this.$historyTracker); this.$initOperationListeners(); - + this._$emitInputEvent = lang.delayedCall(function() { this._signal("input", {}); if (this.session && this.session.bgTokenizer) this.session.bgTokenizer.scheduleStart(); }.bind(this)); - + this.on("change", function(_, _self) { _self._$emitInputEvent.schedule(31); }); @@ -27828,7 +27828,7 @@ return /******/ (function(modules) { // webpackBootstrap if (scrollIntoView == "animate") this.renderer.animateScrolling(this.curOp.scrollTop); } - + this.prevOp = this.curOp; this.curOp = null; } @@ -27919,58 +27919,58 @@ return /******/ (function(modules) { // webpackBootstrap this.$onDocumentChange = this.onDocumentChange.bind(this); session.on("change", this.$onDocumentChange); this.renderer.setSession(session); - + this.$onChangeMode = this.onChangeMode.bind(this); session.on("changeMode", this.$onChangeMode); - + this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this); session.on("tokenizerUpdate", this.$onTokenizerUpdate); - + this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer); session.on("changeTabSize", this.$onChangeTabSize); - + this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this); session.on("changeWrapLimit", this.$onChangeWrapLimit); - + this.$onChangeWrapMode = this.onChangeWrapMode.bind(this); session.on("changeWrapMode", this.$onChangeWrapMode); - + this.$onChangeFold = this.onChangeFold.bind(this); session.on("changeFold", this.$onChangeFold); - + this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); this.session.on("changeFrontMarker", this.$onChangeFrontMarker); - + this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); this.session.on("changeBackMarker", this.$onChangeBackMarker); - + this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); this.session.on("changeBreakpoint", this.$onChangeBreakpoint); - + this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); this.session.on("changeAnnotation", this.$onChangeAnnotation); - + this.$onCursorChange = this.onCursorChange.bind(this); this.session.on("changeOverwrite", this.$onCursorChange); - + this.$onScrollTopChange = this.onScrollTopChange.bind(this); this.session.on("changeScrollTop", this.$onScrollTopChange); - + this.$onScrollLeftChange = this.onScrollLeftChange.bind(this); this.session.on("changeScrollLeft", this.$onScrollLeftChange); - + this.selection = session.getSelection(); this.selection.on("changeCursor", this.$onCursorChange); - + this.$onSelectionChange = this.onSelectionChange.bind(this); this.selection.on("changeSelection", this.$onSelectionChange); - + this.onChangeMode(); - + this.$blockScrolling += 1; this.onCursorChange(); this.$blockScrolling -= 1; - + this.onScrollTopChange(); this.onScrollLeftChange(); this.onSelectionChange(); @@ -27989,9 +27989,9 @@ return /******/ (function(modules) { // webpackBootstrap session: session, oldSession: oldSession }); - + this.curOp = null; - + oldSession && oldSession._signal("changeEditor", {oldEditor: this}); session && session._signal("changeEditor", {editor: this}); }; @@ -28071,35 +28071,35 @@ return /******/ (function(modules) { // webpackBootstrap this.$highlightTagPending = true; setTimeout(function() { self.$highlightTagPending = false; - + var session = self.session; if (!session || !session.bgTokenizer) return; - + var pos = self.getCursorPosition(); var iterator = new TokenIterator(self.session, pos.row, pos.column); var token = iterator.getCurrentToken(); - + if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) { session.removeMarker(session.$tagHighlight); session.$tagHighlight = null; return; } - + if (token.type.indexOf("tag-open") != -1) { token = iterator.stepForward(); if (!token) return; } - + var tag = token.value; var depth = 0; var prevToken = iterator.stepBackward(); - + if (prevToken.value == '<'){ do { prevToken = token; token = iterator.stepForward(); - + if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { if (prevToken.value === '<'){ depth++; @@ -28107,13 +28107,13 @@ return /******/ (function(modules) { // webpackBootstrap depth--; } } - + } while (token && depth >= 0); } else { do { token = prevToken; prevToken = iterator.stepBackward(); - + if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { if (prevToken.value === '<') { depth++; @@ -28124,13 +28124,13 @@ return /******/ (function(modules) { // webpackBootstrap } while (prevToken && depth <= 0); iterator.stepForward(); } - + if (!token) { session.removeMarker(session.$tagHighlight); session.$tagHighlight = null; return; } - + var row = iterator.getCurrentTokenRow(); var column = iterator.getCurrentTokenColumn(); var range = new Range(row, column, row, column+token.value.length); @@ -28138,7 +28138,7 @@ return /******/ (function(modules) { // webpackBootstrap session.removeMarker(session.$tagHighlight); session.$tagHighlight = null; } - + if (range && !session.$tagHighlight) session.$tagHighlight = session.addMarker(range, "ace_bracket", "text"); }, 50); @@ -28350,9 +28350,9 @@ return /******/ (function(modules) { // webpackBootstrap var e = {text: text, event: event}; this.commands.exec("paste", this, e); }; - + this.$handlePaste = function(e) { - if (typeof e == "string") + if (typeof e == "string") e = {text: e}; this._signal("paste", e); var text = e.text; @@ -28361,15 +28361,15 @@ return /******/ (function(modules) { // webpackBootstrap } else { var lines = text.split(/\r\n|\r|\n/); var ranges = this.selection.rangeList.ranges; - + if (lines.length > ranges.length || lines.length < 2 || !lines[1]) return this.commands.exec("insertstring", this, text); - + for (var i = ranges.length; i--;) { var range = ranges[i]; if (!range.isEmpty()) this.session.remove(range); - + this.session.insert(range.start, lines[i]); } } @@ -28394,7 +28394,7 @@ return /******/ (function(modules) { // webpackBootstrap } } - + if (text == "\t") text = this.session.getTabString(); if (!this.selection.isEmpty()) { @@ -28700,7 +28700,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } } - + var line = session.getLine(range.start.row); var position = range.start; var size = session.getTabSize(); @@ -28865,7 +28865,7 @@ return /******/ (function(modules) { // webpackBootstrap var ranges = selection.rangeList.ranges; selection.rangeList.detach(this.session); this.inVirtualSelectionMode = true; - + var diff = 0; var totalDiff = 0; var l = ranges.length; @@ -28894,7 +28894,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!copy) diff = 0; totalDiff += diff; } - + selection.fromOrientedRange(selection.ranges[0]); selection.rangeList.attach(this.session); this.inVirtualSelectionMode = false; @@ -29035,7 +29035,7 @@ return /******/ (function(modules) { // webpackBootstrap "{": "{", "}": "{" }; - + do { if (token.value.match(/[{}()\[\]]/g)) { for (; i < token.value.length && !found; i++) { @@ -29072,14 +29072,14 @@ return /******/ (function(modules) { // webpackBootstrap if (isNaN(depth[token.value])) { depth[token.value] = 0; } - + if (prevToken.value === '<') { depth[token.value]++; } else if (prevToken.value === ' next, row == end), layerConfig, row == end ? 0 : 1, extraStyle); @@ -30020,7 +30020,7 @@ return /******/ (function(modules) { // webpackBootstrap if (height <= 0) return; top = this.$getTop(range.start.row + 1, config); - + var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); stringBuilder.push( @@ -30060,7 +30060,7 @@ return /******/ (function(modules) { // webpackBootstrap "left:0;right:0;", extraStyle || "", "'>" ); }; - + this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; @@ -30129,7 +30129,7 @@ return /******/ (function(modules) { // webpackBootstrap this.getCharacterWidth = function() { return this.$fontMetrics.$characterSize.width || 0; }; - + this.$setFontMetrics = function(measure) { this.$fontMetrics = measure; this.$fontMetrics.on("changeCharacterSize", function(e) { @@ -30507,7 +30507,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!onlyContents) { stringBuilder.push( - "
" @@ -30623,7 +30623,7 @@ return /******/ (function(modules) { // webpackBootstrap this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); - + if (isIE8 === undefined) isIE8 = !("opacity" in this.element.style); @@ -30641,7 +30641,7 @@ return /******/ (function(modules) { // webpackBootstrap }; (function() { - + this.$updateVisibility = function(val) { var cursors = this.cursors; for (var i = cursors.length; i--; ) @@ -30652,7 +30652,7 @@ return /******/ (function(modules) { // webpackBootstrap for (var i = cursors.length; i--; ) cursors[i].style.opacity = val ? "" : "0"; }; - + this.$padding = 0; this.setPadding = function(padding) { @@ -30722,7 +30722,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); } - + update(true); if (!this.isBlinking || !this.blinkInterval || !this.isVisible) @@ -30733,7 +30733,7 @@ return /******/ (function(modules) { // webpackBootstrap dom.addCssClass(this.element, "ace_smooth-blinking"); }.bind(this)); } - + var blink = function(){ this.timeoutId = setTimeout(function() { update(false); @@ -30780,7 +30780,7 @@ return /******/ (function(modules) { // webpackBootstrap } var style = (this.cursors[cursorIndex++] || this.addCursor()).style; - + if (!this.drawCursor) { style.left = pixelPos.left + "px"; style.top = pixelPos.top + "px"; @@ -30798,7 +30798,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$pixelPos = pixelPos; this.restartTimer(); }; - + this.drawCursor = null; this.$setOverwrite = function(overwrite) { @@ -30857,7 +30857,7 @@ return /******/ (function(modules) { // webpackBootstrap var VScrollBar = function(parent, renderer) { ScrollBar.call(this, parent); this.scrollTop = 0; - renderer.$scrollbarWidth = + renderer.$scrollbarWidth = this.width = dom.scrollbarWidth(parent.ownerDocument); this.inner.style.width = this.element.style.width = (this.width || 15) + 5 + "px"; @@ -30995,22 +30995,22 @@ return /******/ (function(modules) { // webpackBootstrap var FontMetrics = exports.FontMetrics = function(parentEl) { this.el = dom.createElement("div"); this.$setMeasureNodeStyles(this.el.style, true); - + this.$main = dom.createElement("div"); this.$setMeasureNodeStyles(this.$main.style); - + this.$measureNode = dom.createElement("div"); this.$setMeasureNodeStyles(this.$measureNode.style); - - + + this.el.appendChild(this.$main); this.el.appendChild(this.$measureNode); parentEl.appendChild(this.el); - + if (!CHAR_COUNT) this.$testFractionalRect(); this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT); - + this.$characterSize = {width: 0, height: 0}; this.checkForSizeChanges(); }; @@ -31018,9 +31018,9 @@ return /******/ (function(modules) { // webpackBootstrap (function() { oop.implement(this, EventEmitter); - + this.$characterSize = {width: 0, height: 0}; - + this.$testFractionalRect = function() { var el = dom.createElement("div"); this.$setMeasureNodeStyles(el.style); @@ -31033,7 +31033,7 @@ return /******/ (function(modules) { // webpackBootstrap CHAR_COUNT = 100; el.parentNode.removeChild(el); }; - + this.$setMeasureNodeStyles = function(style, isRoot) { style.width = style.height = "auto"; style.left = style.top = "0px"; @@ -31070,7 +31070,7 @@ return /******/ (function(modules) { // webpackBootstrap self.checkForSizeChanges(); }, 500); }; - + this.setPolling = function(val) { if (val) { this.$pollSizeChanges(); @@ -31083,7 +31083,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$measureSizes = function() { if (CHAR_COUNT === 50) { var rect = null; - try { + try { rect = this.$measureNode.getBoundingClientRect(); } catch(e) { rect = {width: 0, height:0 }; @@ -31108,7 +31108,7 @@ return /******/ (function(modules) { // webpackBootstrap var rect = this.$main.getBoundingClientRect(); return rect.width / CHAR_COUNT; }; - + this.getCharacterWidth = function(ch) { var w = this.charSizes[ch]; if (w === undefined) { @@ -31555,7 +31555,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$horizScroll = false; this.$vScroll = false; - this.scrollBar = + this.scrollBar = this.scrollBarV = new VScrollBar(this.container, this); this.scrollBarH = new HScrollBar(this.container, this); this.scrollBarV.addEventListener("scroll", function(e) { @@ -31605,7 +31605,7 @@ return /******/ (function(modules) { // webpackBootstrap height : 1, gutterOffset: 1 }; - + this.scrollMargin = { left: 0, right: 0, @@ -31658,7 +31658,7 @@ return /******/ (function(modules) { // webpackBootstrap this.setSession = function(session) { if (this.session) this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode); - + this.session = session; if (session && this.scrollMargin.top && session.getScrollTop() <= 0) session.setScrollTop(-this.scrollMargin.top); @@ -31670,10 +31670,10 @@ return /******/ (function(modules) { // webpackBootstrap this.$textLayer.setSession(session); if (!session) return; - + this.$loop.schedule(this.CHANGE_FULL); this.session.$setFontMetrics(this.$fontMetrics); - + this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); this.onChangeNewLineMode() this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode); @@ -31710,7 +31710,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$loop.schedule(this.CHANGE_TEXT); this.$textLayer.$updateEolChar(); }; - + this.onChangeTabSize = function() { this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER); this.$textLayer.onChangeTabSize(); @@ -31749,7 +31749,7 @@ return /******/ (function(modules) { // webpackBootstrap width = el.clientWidth || el.scrollWidth; var changes = this.$updateCachedSize(force, gutterWidth, width, height); - + if (!this.$size.scrollerHeight || (!width && !height)) return this.resizing = 0; @@ -31765,7 +31765,7 @@ return /******/ (function(modules) { // webpackBootstrap this.resizing = 0; this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null; }; - + this.$updateCachedSize = function(force, gutterWidth, width, height) { height -= (this.$extraHeight || 0); var changes = 0; @@ -31791,24 +31791,24 @@ return /******/ (function(modules) { // webpackBootstrap if (width && (force || size.width != width)) { changes |= this.CHANGE_SIZE; size.width = width; - + if (gutterWidth == null) gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; - + this.gutterWidth = gutterWidth; - - this.scrollBarH.element.style.left = + + this.scrollBarH.element.style.left = this.scroller.style.left = gutterWidth + "px"; - size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); - - this.scrollBarH.element.style.right = + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); + + this.scrollBarH.element.style.right = this.scroller.style.right = this.scrollBarV.getWidth() + "px"; this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"; if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) changes |= this.CHANGE_FULL; } - + size.$dirty = !width || !height; if (changes) @@ -31919,7 +31919,7 @@ return /******/ (function(modules) { // webpackBootstrap var style = this.$printMarginEl.style; style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px"; style.visibility = this.$showPrintMargin ? "visible" : "hidden"; - + if (this.session && this.session.$wrap == -1) this.adjustWrapLimit(); }; @@ -31991,7 +31991,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$loop.schedule(this.CHANGE_FULL); this.$updatePrintMargin(); }; - + this.setScrollMargin = function(top, bottom, left, right) { var sm = this.scrollMargin; sm.top = top|0; @@ -32034,12 +32034,12 @@ return /******/ (function(modules) { // webpackBootstrap this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h); this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left); }; - + this.$frozen = false; this.freeze = function() { this.$frozen = true; }; - + this.unfreeze = function() { this.$frozen = false; }; @@ -32051,8 +32051,8 @@ return /******/ (function(modules) { // webpackBootstrap } if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) { this.$changes |= changes; - return; - } + return; + } if (this.$size.$dirty) { this.$changes |= changes; return this.onResize(true); @@ -32060,7 +32060,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!this.lineHeight) { this.$textLayer.checkForSizeChanges(); } - + this._signal("beforeRender"); var config = this.layerConfig; if (changes & this.CHANGE_FULL || @@ -32152,7 +32152,7 @@ return /******/ (function(modules) { // webpackBootstrap this._signal("afterRender"); }; - + this.$autosize = function() { var height = this.session.getScreenLength() * this.lineHeight; var maxHeight = this.$maxLines * this.lineHeight; @@ -32163,33 +32163,33 @@ return /******/ (function(modules) { // webpackBootstrap if (this.$horizScroll) desiredHeight += this.scrollBarH.getHeight(); var vScroll = height > maxHeight; - + if (desiredHeight != this.desiredHeight || this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { if (vScroll != this.$vScroll) { this.$vScroll = vScroll; this.scrollBarV.setVisible(vScroll); } - + var w = this.container.clientWidth; this.container.style.height = desiredHeight + "px"; this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight); this.desiredHeight = desiredHeight; - + this._signal("autosize"); } }; - + this.$computeLayerConfig = function() { var session = this.session; var size = this.$size; - + var hideScrollbars = size.height <= 2 * this.lineHeight; var screenLines = this.session.getScreenLength(); var maxHeight = screenLines * this.lineHeight; var longestLine = this.$getLongestLine(); - + var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible || size.scrollerWidth - longestLine - 2 * this.$padding < 0); @@ -32204,19 +32204,19 @@ return /******/ (function(modules) { // webpackBootstrap var offset = this.scrollTop % this.lineHeight; var minHeight = size.scrollerHeight + this.lineHeight; - + var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd : 0; maxHeight += scrollPastEnd; - + var sm = this.scrollMargin; this.session.setScrollTop(Math.max(-sm.top, Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom))); - this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft, + this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft, longestLine + 2 * this.$padding - size.scrollerWidth + sm.right))); - + var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible || size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top); var vScrollChanged = vScrollBefore !== vScroll; @@ -32246,7 +32246,7 @@ return /******/ (function(modules) { // webpackBootstrap offset = this.scrollTop - firstRowScreen * lineHeight; var changes = 0; - if (this.layerConfig.width != longestLine) + if (this.layerConfig.width != longestLine) changes = this.CHANGE_H_SCROLL; if (hScrollChanged || vScrollChanged) { changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height); @@ -32254,7 +32254,7 @@ return /******/ (function(modules) { // webpackBootstrap if (vScrollChanged) longestLine = this.$getLongestLine(); } - + this.layerConfig = { width : longestLine, padding : this.$padding, @@ -32342,12 +32342,12 @@ return /******/ (function(modules) { // webpackBootstrap var left = pos.left; var top = pos.top; - + var topMargin = $viewMargin && $viewMargin.top || 0; var bottomMargin = $viewMargin && $viewMargin.bottom || 0; - + var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop; - + if (scrollTop + topMargin > top) { if (offset && scrollTop + topMargin > top + this.lineHeight) top -= offset * this.$size.scrollerHeight; @@ -32432,10 +32432,10 @@ return /******/ (function(modules) { // webpackBootstrap if (!this.$animatedScroll) return; var _self = this; - + if (fromValue == toValue) return; - + if (this.$scrollAnimation) { var oldSteps = this.$scrollAnimation.steps; if (oldSteps.length) { @@ -32444,7 +32444,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } } - + var steps = _self.$calcSteps(fromValue, toValue); this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps}; @@ -32588,7 +32588,7 @@ return /******/ (function(modules) { // webpackBootstrap if (_self.theme) dom.removeCssClass(_self.container, _self.theme.cssClass); - var padding = "padding" in module ? module.padding + var padding = "padding" in module ? module.padding : "padding" in (_self.theme || {}) ? 4 : _self.$padding; if (_self.$padding && padding != _self.$padding) _self.setPadding(padding); @@ -32615,7 +32615,7 @@ return /******/ (function(modules) { // webpackBootstrap this.unsetStyle = function(style) { dom.removeCssClass(this.container, style); }; - + this.setCursorStyle = function(style) { if (this.scroller.style.cursor != style) this.scroller.style.cursor = style; @@ -32656,7 +32656,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$updatePrintMargin(); }, get: function() { - return this.$showPrintMargin && this.$printMarginColumn; + return this.$showPrintMargin && this.$printMarginColumn; } }, showGutter: { @@ -32788,7 +32788,7 @@ return /******/ (function(modules) { // webpackBootstrap this.onMessage = this.onMessage.bind(this); if (acequire.nameToUrl && !acequire.toUrl) acequire.toUrl = acequire.nameToUrl; - + if (config.get("packaged") || !acequire.toUrl) { workerUrl = workerUrl || config.moduleUrl(mod.id, "worker") } else { @@ -32859,7 +32859,7 @@ return /******/ (function(modules) { // webpackBootstrap break; } }; - + this.reportError = function(err) { window.console && console.error && console.error(err); }; @@ -33019,13 +33019,13 @@ return /******/ (function(modules) { // webpackBootstrap this.$onUpdate = this.onUpdate.bind(this); this.doc.on("change", this.$onUpdate); this.$others = others; - + this.$onCursorChange = function() { setTimeout(function() { _self.onCursorChange(); }); }; - + this.$pos = pos; var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1}; this.$undoStackDepth = undoStack.length; @@ -33041,7 +33041,7 @@ return /******/ (function(modules) { // webpackBootstrap var _self = this; var doc = this.doc; var session = this.session; - + this.selectionBefore = session.selection.toJSON(); if (session.selection.inMultiSelectMode) session.selection.toSingleRange(); @@ -33079,7 +33079,7 @@ return /******/ (function(modules) { // webpackBootstrap this.onUpdate = function(delta) { if (this.$updating) return this.updateAnchors(delta); - + var range = delta; if (range.start.row !== range.end.row) return; if (range.start.row !== this.pos.row) return; @@ -33087,9 +33087,9 @@ return /******/ (function(modules) { // webpackBootstrap var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column; var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1; var distanceFromStart = range.start.column - this.pos.column; - + this.updateAnchors(delta); - + if (inMainRange) this.length += lengthDiff; @@ -33108,18 +33108,18 @@ return /******/ (function(modules) { // webpackBootstrap } } } - + this.$updating = false; this.updateMarkers(); }; - + this.updateAnchors = function(delta) { this.pos.onChange(delta); for (var i = this.others.length; i--;) this.others[i].onChange(delta); this.updateMarkers(); }; - + this.updateMarkers = function() { if (this.$updating) return; @@ -33144,7 +33144,7 @@ return /******/ (function(modules) { // webpackBootstrap this.hideOtherMarkers(); this._emit("cursorLeave", event); } - }; + }; this.detach = function() { this.session.removeMarker(this.pos && this.pos.markerId); this.hideOtherMarkers(); @@ -33185,7 +33185,7 @@ return /******/ (function(modules) { // webpackBootstrap var ctrl = ev.ctrlKey; var accel = e.getAccelKey(); var button = e.getButton(); - + if (ctrl && useragent.isMac) button = ev.button; @@ -33193,13 +33193,13 @@ return /******/ (function(modules) { // webpackBootstrap e.editor.textInput.onContextMenu(e.domEvent); return; } - + if (!ctrl && !alt && !accel) { if (button === 0 && e.editor.inMultiSelectMode) e.editor.exitMultiSelectMode(); return; } - + if (button !== 0) return; @@ -33215,11 +33215,11 @@ return /******/ (function(modules) { // webpackBootstrap mouseX = e.clientX; mouseY = e.clientY; }; - + var session = editor.session; var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY); var screenCursor = screenAnchor; - + var selectionMode; if (editor.$mouseHandler.$enableJumpToDef) { if (ctrl && alt || accel && alt) @@ -33235,7 +33235,7 @@ return /******/ (function(modules) { // webpackBootstrap selectionMode = "block"; } } - + if (selectionMode && useragent.isMac && ev.ctrlKey) { editor.$mouseHandler.cancelContextMenu(); } @@ -33250,11 +33250,11 @@ return /******/ (function(modules) { // webpackBootstrap } var oldRange = selection.rangeList.rangeAtPoint(pos); - - + + editor.$blockScrolling++; editor.inVirtualSelectionMode = true; - + if (shift) { oldRange = null; range = selection.ranges[0] || range; @@ -33280,7 +33280,7 @@ return /******/ (function(modules) { // webpackBootstrap } else if (selectionMode == "block") { e.stop(); - editor.inVirtualSelectionMode = true; + editor.inVirtualSelectionMode = true; var initialRange; var rectSel = []; var blockSelect = function() { @@ -33290,7 +33290,7 @@ return /******/ (function(modules) { // webpackBootstrap if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead)) return; screenCursor = newCursor; - + editor.$blockScrolling++; editor.selection.moveToPosition(cursor); editor.renderer.scrollCursorIntoView(); @@ -33310,13 +33310,13 @@ return /******/ (function(modules) { // webpackBootstrap initialRange = selection.toOrientedRange(); editor.addSelectionMarker(initialRange); } - + if (shift) - screenAnchor = session.documentToScreenPosition(selection.lead); + screenAnchor = session.documentToScreenPosition(selection.lead); else selection.moveToPosition(pos); editor.$blockScrolling--; - + screenCursor = {row: -1, column: -1}; var onMouseSelectionEnd = function(e) { @@ -33580,7 +33580,7 @@ return /******/ (function(modules) { // webpackBootstrap var start = range.end, end = range.start; else var start = range.start, end = range.end; - + this.addRange(Range.fromPoints(end, end)); this.addRange(Range.fromPoints(start, start)); return; @@ -33781,7 +33781,7 @@ return /******/ (function(modules) { // webpackBootstrap result = command.multiSelectAction(editor, e.args || {}); } return result; - }; + }; this.forEachSelection = function(cmd, args, options) { if (this.inVirtualSelectionMode) return; @@ -33792,10 +33792,10 @@ return /******/ (function(modules) { // webpackBootstrap var rangeList = selection.rangeList; var ranges = (keepOrder ? selection : rangeList).ranges; var result; - + if (!ranges.length) return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {}); - + var reg = selection._eventRegistry; selection._eventRegistry = {}; @@ -33820,13 +33820,13 @@ return /******/ (function(modules) { // webpackBootstrap this.inVirtualSelectionMode = false; selection._eventRegistry = reg; selection.mergeOverlappingRanges(); - + var anim = this.renderer.$scrollAnimation; this.onCursorChange(); this.onSelectionChange(); if (anim && anim.from == anim.to) this.renderer.animateScrolling(anim.from); - + return result; }; this.exitMultiSelectMode = function() { @@ -33852,7 +33852,7 @@ return /******/ (function(modules) { // webpackBootstrap } return text; }; - + this.$checkMultiselectChange = function(e, anchor) { if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { var range = this.multiSelect.ranges[0]; @@ -33861,7 +33861,7 @@ return /******/ (function(modules) { // webpackBootstrap var pos = anchor == this.multiSelect.anchor ? range.cursor == range.start ? range.end : range.start : range.cursor; - if (pos.row != anchor.row + if (pos.row != anchor.row || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column) this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange()); } @@ -33874,9 +33874,9 @@ return /******/ (function(modules) { // webpackBootstrap ? this.selection.getWordRange() : this.selection.getRange(); options.needle = this.session.getTextRange(range); - } + } this.$search.set(options); - + var ranges = this.$search.findAll(this.session); if (!ranges.length) return 0; @@ -33891,7 +33891,7 @@ return /******/ (function(modules) { // webpackBootstrap selection.addRange(ranges[i], true); if (range && selection.rangeList.rangeAtPoint(range.start)) selection.addRange(range, true); - + this.$blockScrolling -= 1; return ranges.length; @@ -34005,7 +34005,7 @@ return /******/ (function(modules) { // webpackBootstrap return true; row = r.cursor.row; }); - + if (!ranges.length || sameRowRanges.length == ranges.length - 1) { var range = this.selection.getRange(); var fr = range.start.row, lr = range.end.row; @@ -34019,7 +34019,7 @@ return /******/ (function(modules) { // webpackBootstrap do { line = this.session.getLine(fr); } while (/[=:]/.test(line) && --fr > 0); - + if (fr < 0) fr = 0; if (lr >= max) lr = max - 1; } @@ -34473,7 +34473,7 @@ return /******/ (function(modules) { // webpackBootstrap this.measureWidgets = this.measureWidgets.bind(this); this.session._changedWidgets = []; this.$onChangeEditor = this.$onChangeEditor.bind(this); - + this.session.on("change", this.updateOnChange); this.session.on("changeFold", this.updateOnFold); this.session.on("changeEditor", this.$onChangeEditor); @@ -34484,7 +34484,7 @@ return /******/ (function(modules) { // webpackBootstrap var h; if (this.lineWidgets) h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; - else + else h = 0; if (!this.$useWrapMode || !this.$wrapData[row]) { return 1 + h; @@ -34500,12 +34500,12 @@ return /******/ (function(modules) { // webpackBootstrap screenRows += w.rowCount; }); return screenRows; - }; - + }; + this.$onChangeEditor = function(e) { this.attach(e.editor); }; - + this.attach = function(editor) { if (editor && editor.widgetManager && editor.widgetManager != this) editor.widgetManager.detach(); @@ -34515,7 +34515,7 @@ return /******/ (function(modules) { // webpackBootstrap this.detach(); this.editor = editor; - + if (editor) { editor.widgetManager = this; editor.renderer.on("beforeRender", this.measureWidgets); @@ -34526,10 +34526,10 @@ return /******/ (function(modules) { // webpackBootstrap var editor = this.editor; if (!editor) return; - + this.editor = null; editor.widgetManager = null; - + editor.renderer.off("beforeRender", this.measureWidgets); editor.renderer.off("afterRender", this.renderWidgets); var lineWidgets = this.session.lineWidgets; @@ -34566,11 +34566,11 @@ return /******/ (function(modules) { // webpackBootstrap } } }; - + this.updateOnChange = function(delta) { var lineWidgets = this.session.lineWidgets; if (!lineWidgets) return; - + var startRow = delta.start.row; var len = delta.end.row - startRow; @@ -34588,7 +34588,7 @@ return /******/ (function(modules) { // webpackBootstrap this.$updateRows(); } }; - + this.$updateRows = function() { var lineWidgets = this.session.lineWidgets; if (!lineWidgets) return; @@ -34610,7 +34610,7 @@ return /******/ (function(modules) { // webpackBootstrap this.addLineWidget = function(w) { if (!this.session.lineWidgets) this.session.lineWidgets = new Array(this.session.getLength()); - + var old = this.session.lineWidgets[w.row]; if (old) { w.$oldWidget = old; @@ -34619,11 +34619,11 @@ return /******/ (function(modules) { // webpackBootstrap old._inDocument = false; } } - + this.session.lineWidgets[w.row] = w; - + w.session = this.session; - + var renderer = this.editor.renderer; if (w.html && !w.el) { w.el = dom.createElement("div"); @@ -34636,7 +34636,7 @@ return /******/ (function(modules) { // webpackBootstrap renderer.container.appendChild(w.el); w._inDocument = true; } - + if (!w.coverGutter) { w.el.style.zIndex = 3; } @@ -34646,7 +34646,7 @@ return /******/ (function(modules) { // webpackBootstrap if (w.rowCount == null) { w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight; } - + var fold = this.session.getFoldAt(w.row, 0); w.$fold = fold; if (fold) { @@ -34656,15 +34656,15 @@ return /******/ (function(modules) { // webpackBootstrap else w.hidden = true; } - + this.session._emit("changeFold", {data:{start:{row: w.row}}}); - + this.$updateRows(); this.renderWidgets(null, renderer); this.onWidgetChanged(w); return w; }; - + this.removeLineWidget = function(w) { w._inDocument = false; w.session = null; @@ -34692,7 +34692,7 @@ return /******/ (function(modules) { // webpackBootstrap this.session._emit("changeFold", {data:{start:{row: w.row}}}); this.$updateRows(); }; - + this.getWidgetsAtRow = function(row) { var lineWidgets = this.session.lineWidgets; var w = lineWidgets && lineWidgets[row]; @@ -34703,16 +34703,16 @@ return /******/ (function(modules) { // webpackBootstrap } return list; }; - + this.onWidgetChanged = function(w) { this.session._changedWidgets.push(w); this.editor && this.editor.renderer.updateFull(); }; - + this.measureWidgets = function(e, renderer) { var changedWidgets = this.session._changedWidgets; var config = renderer.layerConfig; - + if (!changedWidgets || !changedWidgets.length) return; var min = Infinity; for (var i = 0; i < changedWidgets.length; i++) { @@ -34725,14 +34725,14 @@ return /******/ (function(modules) { // webpackBootstrap w._inDocument = true; renderer.container.appendChild(w.el); } - + w.h = w.el.offsetHeight; - + if (!w.fixedWidth) { w.w = w.el.offsetWidth; w.screenWidth = Math.ceil(w.w / config.characterWidth); } - + var rowCount = w.h / config.lineHeight; if (w.coverLine) { rowCount -= this.session.getRowLineCount(w.row); @@ -34751,7 +34751,7 @@ return /******/ (function(modules) { // webpackBootstrap } this.session._changedWidgets = []; }; - + this.renderWidgets = function(e, renderer) { var config = renderer.layerConfig; var lineWidgets = this.session.lineWidgets; @@ -34759,10 +34759,10 @@ return /******/ (function(modules) { // webpackBootstrap return; var first = Math.min(this.firstRow, config.firstRow); var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length); - + while (first > 0 && !lineWidgets[first]) first--; - + this.firstRow = config.firstRow; this.lastRow = config.lastRow; @@ -34782,16 +34782,16 @@ return /******/ (function(modules) { // webpackBootstrap if (!w.coverLine) top += config.lineHeight * this.session.getRowLineCount(w.row); w.el.style.top = top - config.offset + "px"; - + var left = w.coverGutter ? 0 : renderer.gutterWidth; if (!w.fixedWidth) left -= renderer.scrollLeft; w.el.style.left = left + "px"; - + if (w.fullWidth && w.screenWidth) { w.el.style.minWidth = config.width + 2 * config.padding + "px"; } - + if (w.fixedWidth) { w.el.style.right = renderer.scrollBar.getWidth() + "px"; } else { @@ -34799,7 +34799,7 @@ return /******/ (function(modules) { // webpackBootstrap } } }; - + }).call(LineWidgets.prototype); @@ -34834,16 +34834,16 @@ return /******/ (function(modules) { // webpackBootstrap var annotations = session.getAnnotations().sort(Range.comparePoints); if (!annotations.length) return; - + var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints); if (i < 0) i = -i - 1; - + if (i >= annotations.length) i = dir > 0 ? 0 : annotations.length - 1; else if (i === 0 && dir < 0) i = annotations.length - 1; - + var annotation = annotations[i]; if (!annotation || !dir) return; @@ -34855,8 +34855,8 @@ return /******/ (function(modules) { // webpackBootstrap if (!annotation) return annotations.slice(); } - - + + var matched = []; row = annotation.row; do { @@ -34872,7 +34872,7 @@ return /******/ (function(modules) { // webpackBootstrap session.widgetManager = new LineWidgets(session); session.widgetManager.attach(editor); } - + var pos = editor.getCursorPosition(); var row = pos.row; var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) { @@ -34902,9 +34902,9 @@ return /******/ (function(modules) { // webpackBootstrap } editor.session.unfold(pos.row); editor.selection.moveToPosition(pos); - + var w = { - row: pos.row, + row: pos.row, fixedWidth: true, coverGutter: true, el: dom.createElement("div"), @@ -34913,24 +34913,24 @@ return /******/ (function(modules) { // webpackBootstrap var el = w.el.appendChild(dom.createElement("div")); var arrow = w.el.appendChild(dom.createElement("div")); arrow.className = "error_widget_arrow " + gutterAnno.className; - + var left = editor.renderer.$cursorLayer .getPixelPosition(pos).left; arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px"; - + w.el.className = "error_widget_wrapper"; el.className = "error_widget " + gutterAnno.className; el.innerHTML = gutterAnno.text.join("
"); - + el.appendChild(dom.createElement("div")); - + var kb = function(_, hashId, keyString) { if (hashId === 0 && (keyString === "esc" || keyString === "return")) { w.destroy(); return {command: "null"}; } }; - + w.destroy = function() { if (editor.$mouseHandler.isMousePressed) return; @@ -34941,17 +34941,17 @@ return /******/ (function(modules) { // webpackBootstrap editor.off("mouseup", w.destroy); editor.off("change", w.destroy); }; - + editor.keyBinding.addKeyboardHandler(kb); editor.on("changeSelection", w.destroy); editor.on("changeSession", w.destroy); editor.on("mouseup", w.destroy); editor.on("change", w.destroy); - + editor.session.widgetManager.addLineWidget(w); - + w.el.onmousedown = editor.focus.bind(editor); - + editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight}); }; @@ -35074,7 +35074,7 @@ return /******/ (function(modules) { // webpackBootstrap window.ace[key] = a[key]; }); })(); - + module.exports = window.ace.acequire("ace/ace"); /***/ }, @@ -35183,7 +35183,7 @@ return /******/ (function(modules) { // webpackBootstrap } ] }; - + }; oop.inherits(JsonHighlightRules, TextHighlightRules); @@ -35465,15 +35465,15 @@ return /******/ (function(modules) { // webpackBootstrap var line = session.doc.getLine(cursor.row); var leftChar = line.substring(cursor.column-1, cursor.column); var rightChar = line.substring(cursor.column, cursor.column + 1); - + var token = session.getTokenAt(cursor.row, cursor.column); var rightToken = session.getTokenAt(cursor.row, cursor.column + 1); if (leftChar == "\\" && token && /escape/.test(token.type)) return null; - + var stringBefore = token && /string|escape/.test(token.type); var stringAfter = !rightToken || /string|escape/.test(rightToken.type); - + var pair; if (rightChar == quote) { pair = stringBefore !== stringAfter; @@ -35516,7 +35516,7 @@ return /******/ (function(modules) { // webpackBootstrap }; - + CstyleBehaviour.isSaneInsertion = function(editor, session) { var cursor = editor.getCursorPosition(); var iterator = new TokenIterator(session, cursor.row, cursor.column); @@ -35608,7 +35608,7 @@ return /******/ (function(modules) { // webpackBootstrap oop.inherits(FoldMode, BaseFoldMode); (function() { - + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; @@ -35617,42 +35617,42 @@ return /******/ (function(modules) { // webpackBootstrap this._getFoldWidgetBase = this.getFoldWidget; this.getFoldWidget = function(session, foldStyle, row) { var line = session.getLine(row); - + if (this.singleLineBlockCommentRe.test(line)) { if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) return ""; } - + var fw = this._getFoldWidgetBase(session, foldStyle, row); - + if (!fw && this.startRegionRe.test(line)) return "start"; // lineCommentRegionStart - + return fw; }; this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { var line = session.getLine(row); - + if (this.startRegionRe.test(line)) return this.getCommentRegionBlock(session, line, row); - + var match = line.match(this.foldingStartMarker); if (match) { var i = match.index; if (match[1]) return this.openingBracketBlock(session, match[1], row, i); - + var range = session.getCommentFoldRange(row, i + match[0].length, 1); - + if (range && !range.isMultiLine()) { if (forceMultiline) { range = this.getSectionRange(session, row); } else if (foldStyle != "all") range = null; } - + return range; } @@ -35669,7 +35669,7 @@ return /******/ (function(modules) { // webpackBootstrap return session.getCommentFoldRange(row, i, -1); } }; - + this.getSectionRange = function(session, row) { var line = session.getLine(row); var startIndent = line.search(/\S/); @@ -35686,7 +35686,7 @@ return /******/ (function(modules) { // webpackBootstrap if (startIndent > indent) break; var subRange = this.getFoldWidgetRange(session, "all", row); - + if (subRange) { if (subRange.start.row <= startRow) { break; @@ -35698,14 +35698,14 @@ return /******/ (function(modules) { // webpackBootstrap } endRow = row; } - + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); }; this.getCommentRegionBlock = function(session, line, row) { var startColumn = line.search(/\s*$/); var maxRow = session.getLength(); var startRow = row; - + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; var depth = 1; while (++row < maxRow) { @@ -36003,12 +36003,12 @@ return /******/ (function(modules) { // webpackBootstrap this.searchInput = this.searchBox.querySelector(".ace_search_field"); this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); }; - + this.$init = function() { var sb = this.element; - + this.$initElements(sb); - + var _this = this; event.addListener(sb, "mousedown", function(e) { setTimeout(function(){ @@ -36154,7 +36154,7 @@ return /******/ (function(modules) { // webpackBootstrap this.find(true, true); }; this.findAll = function(){ - var range = this.editor.findAll(this.searchInput.value, { + var range = this.editor.findAll(this.searchInput.value, { regExp: this.regExpOption.checked, caseSensitive: this.caseSensitiveOption.checked, wholeWord: this.wholeWordOption.checked @@ -36168,7 +36168,7 @@ return /******/ (function(modules) { // webpackBootstrap this.replace = function() { if (!this.editor.getReadOnly()) this.editor.replace(this.replaceInput.value); - }; + }; this.replaceAndFindNext = function() { if (!this.editor.getReadOnly()) { this.editor.replace(this.replaceInput.value); @@ -36193,9 +36193,9 @@ return /******/ (function(modules) { // webpackBootstrap if (value) this.searchInput.value = value; - + this.find(false, false, true); - + this.searchInput.focus(); this.searchInput.select(); @@ -36219,7 +36219,7 @@ return /******/ (function(modules) { // webpackBootstrap (function() { ace.acequire(["ace/ext/searchbox"], function() {}); })(); - + /***/ }, /* 70 */ @@ -36230,7 +36230,7 @@ return /******/ (function(modules) { // webpackBootstrap * * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -36241,7 +36241,7 @@ return /******/ (function(modules) { // webpackBootstrap * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE diff --git a/django_netjsonconfig/static/django-netjsonconfig/js/lib/jsonschema-ui.js b/django_netjsonconfig/static/django-netjsonconfig/js/lib/jsonschema-ui.js index 1cad3d9..a708f12 100644 --- a/django_netjsonconfig/static/django-netjsonconfig/js/lib/jsonschema-ui.js +++ b/django_netjsonconfig/static/django-netjsonconfig/js/lib/jsonschema-ui.js @@ -2,8 +2,31 @@ * By Jeremy Dorn - https://github.com/jdorn/json-editor/ * Released under the MIT license **/ -!function(){var a;!function(){var b=!1,c=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/;return a=function(){},a.extend=function a(d){function e(){!b&&this.init&&this.init.apply(this,arguments)}var f=this.prototype;b=!0;var g=new this;b=!1;for(var h in d)g[h]="function"==typeof d[h]&&"function"==typeof f[h]&&c.test(d[h])?function(a,b){return function(){var c=this._super;this._super=f[a];var d=b.apply(this,arguments);return this._super=c,d}}(h,d[h]):d[h];return e.prototype=g,e.prototype.constructor=e,e.extend=a,e},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;c0&&a.length-1 in a){for(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,this.refs[b]||(b=decodeURIComponent(b)),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;ba.minimum:b>=a.minimum,window.math?g=window.math[a.exclusiveMinimum?"larger":"largerEq"](window.math.bignumber(b),window.math.bignumber(a.minimum)):window.Decimal&&(g=new window.Decimal(b)[a.exclusiveMinimum?"gt":"gte"](new window.Decimal(a.minimum))),g||k.push({path:e,property:"minimum",message:this.translate(a.exclusiveMinimum?"error_minimum_excl":"error_minimum_incl",[a.minimum])}))}else if("string"==typeof b)a.maxLength&&(b+"").length>a.maxLength&&k.push({path:e,property:"maxLength",message:this.translate("error_maxLength",[a.maxLength])}),a.minLength&&(b+"").lengtha.maxItems&&k.push({path:e,property:"maxItems",message:this.translate("error_maxItems",[a.maxItems])}),a.minItems&&b.lengtha.maxProperties&&k.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 i=document.createElement(e);i.setAttribute("controls","controls"),this.theme.createMediaLink(b,c,i),this.link_watchers.push(function(b){var d=f(b);c.setAttribute("href",d),c.textContent=a.rel||d,i.setAttribute("src",d)})}else c=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 g&&c&&(g===!0?c.setAttribute("download",""):this.link_watchers.push(function(a){c.setAttribute("download",g(a))})),a.class&&(c.className=c.className+" "+a.class),b},refreshWatchedFieldValues:function(){if(this.watched_values){var a={},b=!1,c=this;if(this.watched){var d,e;for(var f in this.watched)this.watched.hasOwnProperty(f)&&(e=c.jsoneditor.getEditor(this.watched[f]),d=e?e.getValue():null,c.watched_values[f]!==d&&(b=!0),a[f]=d)}return a.self=this.getValue(),this.watched_values.self!==a.self&&(b=!0),this.watched_values=a,b}},getWatchedFieldValues:function(){return this.watched_values},updateHeaderText:function(){if(this.header)if(this.header.children.length){for(var a=0;a-1:!!this.jsoneditor.options.required_by_default},getDisplayText:function(a){var b=[],c={};d(a,function(a,b){b.title&&(c[b.title]=c[b.title]||0,c[b.title]++),b.description&&(c[b.description]=c[b.description]||0,c[b.description]++),b.format&&(c[b.format]=c[b.format]||0,c[b.format]++),b.type&&(c[b.type]=c[b.type]||0,c[b.type]++)}),d(a,function(a,d){var e;e="string"==typeof d?d:d.title&&c[d.title]<=1?d.title:d.format&&c[d.format]<=1?d.format:d.type&&c[d.type]<=1?d.type:d.description&&c[d.description]<=1?d.descripton:d.title?d.title:d.format?d.format:d.type?d.type:d.description?d.description:JSON.stringify(d).length<50?JSON.stringify(d):"type",b.push(e)});var e={};return d(b,function(a,d){e[d]=e[d]||0,e[d]++,c[d]>1&&(b[a]=d+" "+e[d])}),b},getOption:function(a){try{throw"getOption is deprecated"}catch(a){window.console.error(a)}return this.options[a]},showValidationErrors:function(a){}}),f.defaults.editors.null=f.AbstractEditor.extend({getValue:function(){return null},setValue:function(){this.onChange()},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){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a),a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d,this.sceditor_instance?this.sceditor_instance.val(d):this.epiceditor?this.epiceditor.importFile(null,d):this.ace_editor&&this.ace_editor.setValue(d);var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){var a,b=Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);return a="textarea"===this.input_type?6:["text","email"].indexOf(this.input_type)>=0?4:2,Math.min(12,Math.max(b,a))},build:function(){var a=this;if(this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.format=this.schema.format,!this.format&&this.schema.media&&this.schema.media.type&&(this.format=this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,"")),!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.format)if("textarea"===this.format)this.input_type="textarea",this.input=this.theme.getTextareaInput();else if("range"===this.format){this.input_type="range";var b=this.schema.minimum||0,c=this.schema.maximum||Math.max(100,b+1),d=1;this.schema.multipleOf&&(b%this.schema.multipleOf&&(b=Math.ceil(b/this.schema.multipleOf)*this.schema.multipleOf),c%this.schema.multipleOf&&(c=Math.floor(c/this.schema.multipleOf)*this.schema.multipleOf),d=this.schema.multipleOf),this.input=this.theme.getRangeInput(b,c,d)}else["actionscript","batchfile","bbcode","c","c++","cpp","coffee","csharp","css","dart","django","ejs","erlang","golang","groovy","handlebars","haskell","haxe","html","ini","jade","java","javascript","json","less","lisp","lua","makefile","markdown","matlab","mysql","objectivec","pascal","perl","pgsql","php","python","r","ruby","sass","scala","scss","smarty","sql","stylus","svg","twig","vbscript","xml","yaml"].indexOf(this.format)>=0?(this.input_type=this.format,this.source_code=!0,this.input=this.theme.getTextareaInput()):(this.input_type=this.format,this.input=this.theme.getFormInputField(this.input_type));else this.input_type="text",this.input=this.theme.getFormInputField(this.input_type);"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.className+=" compact":this.options.input_width&&(this.input.style.width=this.options.input_width),(this.schema.readOnly||this.schema.readonly||this.schema.template)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),a.schema.template)return void(this.value=a.value);var c=this.value,d=a.sanitize(c);c!==d&&(this.value=d),a.is_dirty=!0,a.refreshValue(),a.onChange(!0)}),this.options.input_height&&(this.input.style.height=this.options.input_height),this.options.expand_height&&(this.adjust_height=function(a){if(a){var b,c=a.offsetHeight;if(a.offsetHeight100);)b++,c++,a.style.height=c+"px";else{for(b=0;a.offsetHeight>=a.scrollHeight+3&&!(b>100);)b++,c--,a.style.height=c+"px";a.style.height=c+1+"px"}}},this.input.addEventListener("keyup",function(b){a.adjust_height(this)}),this.input.addEventListener("change",function(b){a.adjust_height(this)}),this.adjust_height()),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.theme.getFormControl(this.label,this.input,this.description),this.container.appendChild(this.control),window.requestAnimationFrame(function(){a.input.parentNode&&a.afterInputReady(),a.adjust_height&&a.adjust_height(a.input)}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},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,b.options.sceditor_options||{}),window.jQuery(b.input).sceditor(a),b.sceditor_instance=window.jQuery(b.input).sceditor("instance"),b.sceditor_instance.blur(function(){var a=window.jQuery("
"+b.sceditor_instance.val()+"
");window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",a).remove(),b.input.value=a.html(),b.value=b.input.value,b.is_dirty=!0,b.onChange(!0)});else if("markdown"===this.input_type&&window.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.onChange(!0)});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.onChange(!0)})}b.theme.afterInputReady(b.input)},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.sceditor_instance?this.sceditor_instance.destroy():this.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;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];d(a,function(a,d){d.path===b.path&&c.push(d.message)}),c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),f.defaults.editors.number=f.defaults.editors.string.extend({sanitize:function(a){return(a+"").replace(/[^0-9\.\-eE]/g,"")},getNumColumns:function(){return 2},getValue:function(){return 1*this.value}}),f.defaults.editors.integer=f.defaults.editors.number.extend({sanitize:function(a){return a+="",a.replace(/[^0-9\-]/g,"")},getNumColumns:function(){return 2}}),f.defaults.editors.object=f.AbstractEditor.extend({getDefault:function(){return c({},this.schema.default||{})},getChildEditors:function(){return this.editors},register:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].register()},unregister:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].unregister()},getNumColumns:function(){return Math.max(Math.min(12,this.maxwidth),3)},enable:function(){if(this.editjson_button&&(this.editjson_button.disabled=!1),this.addproperty_button&&(this.addproperty_button.disabled=!1),this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].enable()},disable:function(){if(this.editjson_button&&(this.editjson_button.disabled=!0),this.addproperty_button&&(this.addproperty_button.disabled=!0),this.hideEditJSON(),this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].disable()},layoutEditors:function(){var a,b,c=this;if(this.row_container){this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(a,b){var d=c.editors[a].schema.propertyOrder,e=c.editors[b].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e});var e;if("grid"===this.format){var f=[];for(d(this.property_order,function(a,b){var d=c.editors[b];if(!d.property_removed){for(var e=!1,g=d.options.hidden?0:d.options.grid_columns||d.getNumColumns(),h=d.options.hidden?0:d.container.offsetHeight,i=0;ih)&&(e=i);e===!1&&(f.push({width:0,minh:999999,maxh:0,editors:[]}),e=f.length-1),f[e].editors.push({key:b,width:g,height:h}),f[e].width+=g,f[e].minh=Math.min(f[e].minh,h),f[e].maxh=Math.max(f[e].maxh,h)}}),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;h<12&&(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.schema.properties.hasOwnProperty(a)?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0);this.canHaveAdditionalProperties()&&(e=!0);for(a in this.schema.properties)this.schema.properties.hasOwnProperty(a)&&(this.cached_editors[a]||(e=!0,this.addPropertyCheckbox(a)));e?this.canHaveAdditionalProperties()?b?this.addproperty_add.disabled=!1:this.addproperty_add.disabled=!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},isRequired:function(a){return"boolean"==typeof a.schema.required?a.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(a.key)>-1:!!this.jsoneditor.options.required_by_default},setValue:function(a,b){var c=this;a=a||{},("object"!=typeof a||Array.isArray(a))&&(a={}),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)}),d(a,function(a,d){c.cached_editors[a]||(c.addObjectProperty(a),c.editors[a]&&c.editors[a].setValue(d,b))}),this.refreshValue(),this.layoutEditors(),this.onChange()},showValidationErrors:function(a){var b=this,c=[],e=[];d(a,function(a,d){d.path===b.path?c.push(d):e.push(d)}),this.error_holder&&(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))})):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,c){e.rows[a]?e.rows[a].setValue(c,b):e.row_cache[a]?(e.rows[a]=e.row_cache[a],e.rows[a].setValue(c,b),e.rows[a].container.style.display="",e.rows[a].tab&&(e.rows[a].tab.style.display=""),e.rows[a].register()):e.addRow(c,b)});for(var f=a.length;f=this.rows.length;d(this.rows,function(a,c){c.movedown_button&&(a===b.rows.length-1?c.movedown_button.style.display="none":c.movedown_button.style.display=""),c.delete_button&&(e?c.delete_button.style.display="none":c.delete_button.style.display=""),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_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",f=!0)):(e||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",f=!0),e||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(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.collapsed&&f?this.controls.style.display="inline-block":this.controls.style.display="none"}},addRow:function(a,b){var c=this,e=this.rows.length;c.rows[e]=this.getElementEditor(e),c.row_cache[e]=c.rows[e],c.tabs_holder&&(c.rows[e].tab_text=document.createElement("span"),c.rows[e].tab_text.textContent=c.rows[e].getHeaderText(),c.rows[e].tab=c.theme.getTab(c.rows[e].tab_text),c.rows[e].tab.addEventListener("click",function(a){c.active_tab=c.rows[e].tab,c.refreshTabs(),a.preventDefault(),a.stopPropagation()}),c.theme.addTab(c.tabs_holder,c.rows[e].tab));var f=c.rows[e].title_controls||c.rows[e].array_controls;c.hide_delete_buttons||(c.rows[e].delete_button=this.getButton(c.getItemTitle(),"delete",this.translate("button_delete_row_title",[c.getItemTitle()])),c.rows[e].delete_button.className+=" delete",c.rows[e].delete_button.setAttribute("data-i",e),c.rows[e].delete_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i"),e=c.getValue(),f=[],g=null;d(e,function(a,d){return a===b?void(c.rows[a].tab===c.active_tab&&(c.rows[a+1]?g=c.rows[a].tab:a&&(g=c.rows[a-1].tab))):void f.push(d)}),c.setValue(f),g&&(c.active_tab=g,c.refreshTabs()),c.onChange(!0)}),f&&f.appendChild(c.rows[e].delete_button)),e&&!c.hide_move_buttons&&(c.rows[e].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),c.rows[e].moveup_button.className+=" moveup",c.rows[e].moveup_button.setAttribute("data-i",e),c.rows[e].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i");if(!(b<=0)){var d=c.getValue(),e=d[b-1];d[b-1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b-1].tab,c.refreshTabs(),c.onChange(!0)}}),f&&f.appendChild(c.rows[e].moveup_button)),c.hide_move_buttons||(c.rows[e].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),c.rows[e].movedown_button.className+=" movedown",c.rows[e].movedown_button.setAttribute("data-i",e),c.rows[e].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i"),d=c.getValue();if(!(b>=d.length-1)){var e=d[b+1];d[b+1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b+1].tab,c.refreshTabs(),c.onChange(!0); -}}),f&&f.appendChild(c.rows[e].movedown_button)),a&&c.rows[e].setValue(a,b),c.refreshTabs()},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_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",a.translate("button_collapse"))):(a.collapsed=!0,a.row_holder.style.display="none",a.tabs_holder&&(a.tabs_holder.style.display="none"),a.controls.style.display="none",a.panel&&(a.panel.style.display="none"),a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&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",this.translate("button_add_row_title",[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].setValue(a.rows[c].getDefault(),!0),a.rows[c].container.style.display="",a.rows[c].tab&&(a.rows[c].tab.style.display=""),a.rows[c].register()):a.addRow(),a.active_tab=a.rows[c].tab,a.refreshTabs(),a.refreshValue(),a.onChange(!0)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.addEventListener("click",function(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.onChange(!0)}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")),this.remove_all_rows_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.setValue([]),a.onChange(!0)}),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=[];d(a,function(a,d){d.path===b.path?c.push(d):e.push(d)}),this.error_holder&&(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))})):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){c?b.controls_cell.style.display="":b.controls_cell.style.display="none"}),c?this.controls_header_cell.style.display="":this.controls_header_cell.style.display="none";var e=!1;this.value.length?1===this.value.length?(this.table.style.display="",this.remove_all_rows_button.style.display="none",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0)):(this.table.style.display="",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0),b||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",e=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.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),e?this.controls.style.display="":this.controls.style.display="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",this.translate("button_delete_row_title_short")),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.onChange(!0)}),e.appendChild(b.rows[c].delete_button)),c&&!this.hide_move_buttons&&(b.rows[c].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),b.rows[c].moveup_button.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(!(c<=0)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),e.appendChild(b.rows[c].moveup_button)),this.hide_move_buttons||(b.rows[c].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),b.rows[c].movedown_button.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.onChange(!0)}}),e.appendChild(b.rows[c].movedown_button)),a&&b.rows[c].setValue(a)},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.title_controls&&(this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel.style.display="",a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.panel.style.display="none",a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&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",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.addRow(),a.refreshValue(),a.refreshRowButtons(),a.onChange(!0)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation();var c=a.getValue();c.pop(),a.setValue(c),a.onChange(!0)}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")),this.remove_all_rows_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.setValue([]),a.onChange(!0)}),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.onChange())},destroy:function(){this.display_area&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),f.defaults.editors.select=f.AbstractEditor.extend({setValue:function(a,b){a=this.typecast(a||"");var c=a;this.enum_values.indexOf(c)<0&&(c=this.enum_values[0]),this.value!==c&&(this.input.value=this.enum_options[this.enum_values.indexOf(c)],this.select2&&this.select2.select2("val",this.input.value),this.value=c,this.onChange())},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){if(!this.enum_options)return 3;for(var a=this.getTitle().length,b=0;b2||this.enum_options.length&&this.enumSource)){var a=c({},f.plugins.select2);this.schema.options&&this.schema.options.select2_options&&(a=c(a,this.schema.options.select2_options)),this.select2=window.jQuery(this.input).select2(a);var b=this;this.select2.on("select2-blur",function(){b.input.value=b.select2.select2("val"),b.onInputChange()}),this.select2.on("change",function(){b.input.value=b.select2.select2("val"),b.onInputChange()})}else this.select2=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelect2()},onWatchedFieldChange:function(){var a,b;if(this.enumSource){a=this.getWatchedFieldValues();for(var c=[],d=[],e=0;e=2||this.enum_options.length&&this.enumSource)){var b=c({},f.plugins.selectize);this.schema.options&&this.schema.options.selectize_options&&(b=c(b,this.schema.options.selectize_options)),this.selectize=window.jQuery(this.input).selectize(c(b,{create:!0,onChange:function(){a.onInputChange()}}))}else this.selectize=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelectize()},onWatchedFieldChange:function(){var a,b;if(this.enumSource){a=this.getWatchedFieldValues();for(var c=[],d=[],e=0;eType: "+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.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),f.defaults.editors.upload=f.AbstractEditor.extend({getNumColumns:function(){return 4},build:function(){var a=this;if(this.title=this.header=this.label=this.theme.getFormInputLabel(this.getTitle()),this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input),!this.schema.readOnly&&!this.schema.readonly){if(!this.jsoneditor.options.upload)throw"Upload handler required for upload editor";this.uploader=this.theme.getFormInputField("file"),this.uploader.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),this.files&&this.files.length){var c=new FileReader;c.onload=function(b){a.preview_value=b.target.result,a.refreshPreview(),a.onChange(!0),c=null},c.readAsDataURL(this.files[0])}})}var b=this.schema.description;b||(b=""),this.preview=this.theme.getFormInputDescription(b),this.container.appendChild(this.preview),this.control=this.theme.getFormControl(this.label,this.uploader||this.input,this.preview),this.container.appendChild(this.control)},refreshPreview:function(){if(this.last_preview!==this.preview_value&&(this.last_preview=this.preview_value,this.preview.innerHTML="",this.preview_value)){var a=this,b=this.preview_value.match(/^data:([^;,]+)[;,]/);b&&(b=b[1]),b||(b="unknown");var c=this.uploader.files[0];if(this.preview.innerHTML="Type: "+b+", Size: "+c.size+" bytes","image"===b.substr(0,5)){this.preview.innerHTML+="
    ";var d=document.createElement("img");d.style.maxWidth="100%",d.style.maxHeight="100px",d.src=this.preview_value,this.preview.appendChild(d)}this.preview.innerHTML+="
    ";var e=this.getButton("Upload","upload","Upload");this.preview.appendChild(e),e.addEventListener("click",function(b){b.preventDefault(),e.setAttribute("disabled","disabled"),a.theme.removeInputError(a.uploader),a.theme.getProgressBar&&(a.progressBar=a.theme.getProgressBar(),a.preview.appendChild(a.progressBar)),a.jsoneditor.options.upload(a.path,c,{success:function(b){a.setValue(b),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(),a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},failure:function(b){a.theme.addInputError(a.uploader,b),a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},updateProgress:function(b){a.progressBar&&(b?a.theme.updateProgressBar(a.progressBar,b):a.theme.updateProgressBarUnknown(a.progressBar))}})})}},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.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),f.defaults.editors.checkbox=f.AbstractEditor.extend({setValue:function(a,b){this.value=!!a,this.input.checked=this.value,this.onChange()},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){return Math.min(12,Math.max(this.getTitle().length/7,2))},build:function(){var a=this;this.options.compact||(this.label=this.header=this.theme.getCheckboxLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.compact&&(this.container.className+=" compact"),this.input=this.theme.getCheckbox(),this.control=this.theme.getFormControl(this.label,this.input,this.description),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(b){b.preventDefault(),b.stopPropagation(),a.value=this.checked,a.onChange(!0)}),this.container.appendChild(this.control)},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){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.arraySelectize=f.AbstractEditor.extend({build:function(){this.title=this.theme.getFormInputLabel(this.getTitle()),this.title_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.error_holder=document.createElement("div"),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description)),this.input=document.createElement("select"),this.input.setAttribute("multiple","multiple");var a=this.theme.getFormControl(this.title,this.input,this.description);this.container.appendChild(a),this.container.appendChild(this.error_holder),window.jQuery(this.input).selectize({delimiter:!1,createOnBlur:!0,create:!0})},postBuild:function(){var a=this;this.input.selectize.on("change",function(b){a.refreshValue(),a.onChange(!0)})},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},empty:function(a){},setValue:function(a,b){var c=this;a=a||[],Array.isArray(a)||(a=[a]),this.input.selectize.clearOptions(),this.input.selectize.clear(!0),a.forEach(function(a){c.input.selectize.addOption({text:a,value:a})}),this.input.selectize.setValue(a),this.refreshValue(b)},refreshValue:function(a){this.value=this.input.selectize.getValue()},showValidationErrors:function(a){var b=this,c=[],e=[];d(a,function(a,d){d.path===b.path?c.push(d):e.push(d)}),this.error_holder&&(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))})):this.error_holder.style.display="none")}});var g=function(){var a=document.documentElement;return a.matches?"matches":a.webkitMatchesSelector?"webkitMatchesSelector":a.mozMatchesSelector?"mozMatchesSelector":a.msMatchesSelector?"msMatchesSelector":a.oMatchesSelector?"oMatchesSelector":void 0}();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(a,b){},getLink:function(a){var b=document.createElement("a");return b.setAttribute("href","#"),b.appendChild(document.createTextNode(a)),b},disableHeader:function(a){a.style.color="#ccc"},disableLabel:function(a){a.style.color="#ccc"},enableHeader:function(a){a.style.color=""},enableLabel:function(a){a.style.color=""},getFormInputLabel:function(a){var b=document.createElement("label");return b.appendChild(document.createTextNode(a)),b},getCheckboxLabel:function(a){var b=this.getFormInputLabel(a);return b.style.fontWeight="normal",b},getHeader:function(a){var b=document.createElement("h3");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getCheckbox:function(){var a=this.getFormInputField("checkbox");return a.style.display="inline-block",a.style.width="auto",a},getMultiCheckboxHolder:function(a,b,c){var d=document.createElement("div");b&&(b.style.display="block",d.appendChild(b));for(var e in a)a.hasOwnProperty(e)&&(a[e].style.display="inline-block",a[e].style.marginRight="20px",d.appendChild(a[e]));return c&&d.appendChild(c),d},getSelectInput:function(a){var b=document.createElement("select");return a&&this.setSelectOptions(b,a),b},getSwitcher:function(a){var b=this.getSelectInput(a);return b.style.backgroundColor="transparent",b.style.display="inline-block",b.style.fontStyle="italic",b.style.fontWeight="normal",b.style.height="auto",b.style.marginBottom=0,b.style.marginLeft="5px",b.style.padding="0 0 0 3px",b.style.width="auto",b},getSwitcherOptions:function(a){return a.getElementsByTagName("option")},setSwitcherOptions:function(a,b,c){this.setSelectOptions(a,b,c)},setSelectOptions:function(a,b,c){c=c||[],a.innerHTML="";for(var d=0;d'),a.errmsg=a.parentNode.getElementsByClassName("error")[0]),a.errmsg.textContent=b)},removeInputError:function(a){a.errmsg&&(a.group.className=a.group.className.replace(/ error/g,""),a.errmsg.style.display="none")},getProgressBar:function(){var a=document.createElement("div");a.className="progress";var b=document.createElement("span");return b.className="meter",b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.firstChild.style.width="100%")}}),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.foundation6=f.defaults.themes.foundation5.extend({getIndentedPanel:function(){var a=document.createElement("div");return a.className="callout secondary",a},getButtonHolder:function(){var a=document.createElement("div");return a.className="button-group tiny",a.style.marginBottom=0,a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b},getFormControl:function(a,b,c){var d=document.createElement("div");return d.className="form-control",a&&d.appendChild(a),"checkbox"===b.type?a.insertBefore(b,a.firstChild):a?a.appendChild(b):d.appendChild(b), -c&&a.appendChild(c),d},addInputError:function(a,b){if(a.group){if(a.group.className+=" error",a.errmsg)a.errmsg.style.display="",a.className="";else{var c=document.createElement("span");c.className="form-error is-visible",a.group.getElementsByTagName("label")[0].appendChild(c),a.className=a.className+" is-invalid-input",a.errmsg=c}a.errmsg.textContent=b}},removeInputError:function(a){a.errmsg&&(a.className=a.className.replace(/ is-invalid-input/g,""),a.errmsg.parentNode&&a.errmsg.parentNode.removeChild(a.errmsg))}}),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")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),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.defaults.themes.barebones=f.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b},getFormInputDescription:function(a){var b=this._super(a);return b},getIndentedPanel:function(){var a=this._super();return a},getChildEditorHolder:function(){var a=this._super();return a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a},getTable:function(){var a=this._super();return a},addInputError:function(a,b){if(a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),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(){return{compile:function(a){var b=a.match(/{{\s*([a-zA-Z0-9\-_ \.]+)\s*}}/g),c=b&&b.length;if(!c)return function(){return a};for(var d=[],e=function(a){var c,e=b[a].replace(/[{}]+/g,"").trim().split("."),f=e.length;if(f>1){var g;c=function(b){for(g=b,a=0;a=0){if(a.items.enum)return"multiselect";if(f.plugins.selectize.enable&&"string"===a.items.type)return"arraySelectize"}}),f.defaults.resolvers.unshift(function(a){if(a.oneOf||a.anyOf)return"multiple"}),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}(); +!function () { + var a; !function () { var b = !1, c = /xyz/.test(function () { window.postMessage("xyz") }) ? /\b_super\b/ : /.*/; return a = function () { }, a.extend = function a(d) { function e() { !b && this.init && this.init.apply(this, arguments) } var f = this.prototype; b = !0; var g = new this; b = !1; for (var h in d) g[h] = "function" == typeof d[h] && "function" == typeof f[h] && c.test(d[h]) ? function (a, b) { return function () { var c = this._super; this._super = f[a]; var d = b.apply(this, arguments); return this._super = c, d } }(h, d[h]) : d[h]; return e.prototype = g, e.prototype.constructor = e, e.extend = a, e }, 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 < b.length && !window.requestAnimationFrame; ++c)window.requestAnimationFrame = window[b[c] + "RequestAnimationFrame"], window.cancelAnimationFrame = window[b[c] + "CancelAnimationFrame"] || window[b[c] + "CancelRequestAnimationFrame"]; window.requestAnimationFrame || (window.requestAnimationFrame = function (b, c) { var d = (new Date).getTime(), e = Math.max(0, 16 - (d - a)), f = window.setTimeout(function () { b(d + e) }, e); return a = d + e, f }), window.cancelAnimationFrame || (window.cancelAnimationFrame = function (a) { clearTimeout(a) }) }(), function () { Array.isArray || (Array.isArray = function (a) { return "[object Array]" === Object.prototype.toString.call(a) }) }(); var b = function (a) { return !("object" != typeof a || a.nodeType || null !== a && a === a.window || a.constructor && !Object.prototype.hasOwnProperty.call(a.constructor.prototype, "isPrototypeOf")) }, c = function (a) { var d, e, f; for (e = 1; e < arguments.length; e++) { d = arguments[e]; for (f in d) d.hasOwnProperty(f) && (d[f] && b(d[f]) ? (a.hasOwnProperty(f) || (a[f] = {}), c(a[f], d[f])) : a[f] = d[f]) } return a }, d = function (a, b) { if (a && "object" == typeof a) { var c; if (Array.isArray(a) || "number" == typeof a.length && a.length > 0 && a.length - 1 in a) { for (c = 0; c < a.length; c++)if (b(c, a[c]) === !1) return } else if (Object.keys) { var d = Object.keys(a); for (c = 0; c < d.length; c++)if (b(d[c], a[d[c]]) === !1) return } else for (c in a) if (a.hasOwnProperty(c) && b(c, a[c]) === !1) return } }, e = function (a, b) { var c = document.createEvent("HTMLEvents"); c.initEvent(b, !0, !0), a.dispatchEvent(c) }, f = function (a, b) { if (!(a instanceof Element)) throw new Error("element should be an instance of Element"); b = c({}, f.defaults.options, b || {}), this.element = a, this.options = b, this.init() }; f.prototype = { constructor: f, init: function () { var a = this; this.ready = !1; var b = f.defaults.themes[this.options.theme || f.defaults.theme]; if (!b) throw "Unknown theme " + (this.options.theme || f.defaults.theme); this.schema = this.options.schema, this.theme = new b, this.template = this.options.template, this.refs = this.options.refs || {}, this.uuid = 0, this.__data = {}; var c = f.defaults.iconlibs[this.options.iconlib || f.defaults.iconlib]; c && (this.iconlib = new c), this.root_container = this.theme.getContainer(), this.element.appendChild(this.root_container), this.translate = this.options.translate || f.defaults.translate, this._loadExternalRefs(this.schema, function () { a._getDefinitions(a.schema); var b = {}; a.options.custom_validators && (b.custom_validators = a.options.custom_validators), a.validator = new f.Validator(a, null, b); var c = a.getEditorClass(a.schema); a.root = a.createEditor(c, { jsoneditor: a, schema: a.schema, required: !0, container: a.root_container }), a.root.preBuild(), a.root.build(), a.root.postBuild(), a.options.startval && a.root.setValue(a.options.startval), a.validation_results = a.validator.validate(a.root.getValue()), a.root.showValidationErrors(a.validation_results), a.ready = !0, window.requestAnimationFrame(function () { a.ready && (a.validation_results = a.validator.validate(a.root.getValue()), a.root.showValidationErrors(a.validation_results), a.trigger("ready"), a.trigger("change")) }) }) }, getValue: function () { if (!this.ready) throw "JSON Editor not ready yet. Listen for 'ready' event before getting the value"; return this.root.getValue() }, setValue: function (a) { if (!this.ready) throw "JSON Editor not ready yet. Listen for 'ready' event before setting the value"; return this.root.setValue(a), this }, validate: function (a) { if (!this.ready) throw "JSON Editor not ready yet. Listen for 'ready' event before validating"; return 1 === arguments.length ? this.validator.validate(a) : this.validation_results }, destroy: function () { this.destroyed || this.ready && (this.schema = null, this.options = null, this.root.destroy(), this.root = null, this.root_container = null, this.validator = null, this.validation_results = null, this.theme = null, this.iconlib = null, this.template = null, this.__data = null, this.ready = !1, this.element.innerHTML = "", this.destroyed = !0) }, on: function (a, b) { return this.callbacks = this.callbacks || {}, this.callbacks[a] = this.callbacks[a] || [], this.callbacks[a].push(b), this }, off: function (a, b) { if (a && b) { this.callbacks = this.callbacks || {}, this.callbacks[a] = this.callbacks[a] || []; for (var c = [], d = 0; d < this.callbacks[a].length; d++)this.callbacks[a][d] !== b && c.push(this.callbacks[a][d]); this.callbacks[a] = c } else a ? (this.callbacks = this.callbacks || {}, this.callbacks[a] = []) : this.callbacks = {}; return this }, trigger: function (a) { if (this.callbacks && this.callbacks[a] && this.callbacks[a].length) for (var b = 0; b < this.callbacks[a].length; b++)this.callbacks[a][b](); return this }, setOption: function (a, b) { if ("show_errors" !== a) throw "Option " + a + " must be set during instantiation and cannot be changed later"; return this.options.show_errors = b, this.onChange(), this }, getEditorClass: function (a) { var b; if (a = this.expandSchema(a), d(f.defaults.resolvers, function (c, d) { var e = d(a); if (e && f.defaults.editors[e]) return b = e, !1 }), !b) throw "Unknown editor for schema " + JSON.stringify(a); if (!f.defaults.editors[b]) throw "Unknown editor " + b; return f.defaults.editors[b] }, createEditor: function (a, b) { return b = c({}, a.options || {}, b), new a(b) }, onChange: function () { if (this.ready && !this.firing_change) { this.firing_change = !0; var a = this; return window.requestAnimationFrame(function () { a.firing_change = !1, a.ready && (a.validation_results = a.validator.validate(a.root.getValue()), "never" !== a.options.show_errors ? a.root.showValidationErrors(a.validation_results) : a.root.showValidationErrors([]), a.trigger("change")) }), this } }, compileTemplate: function (a, b) { b = b || f.defaults.template; var c; if ("string" == typeof b) { if (!f.defaults.templates[b]) throw "Unknown template engine " + b; if (c = f.defaults.templates[b](), !c) throw "Template engine " + b + " missing required library." } else c = b; if (!c) throw "No template engine set"; if (!c.compile) throw "Invalid template engine set"; return c.compile(a) }, _data: function (a, b, c) { if (3 !== arguments.length) return a.hasAttribute("data-jsoneditor-" + b) ? this.__data[a.getAttribute("data-jsoneditor-" + b)] : null; var d; a.hasAttribute("data-jsoneditor-" + b) ? d = a.getAttribute("data-jsoneditor-" + b) : (d = this.uuid++, a.setAttribute("data-jsoneditor-" + b, d)), this.__data[d] = c }, registerEditor: function (a) { return this.editors = this.editors || {}, this.editors[a.path] = a, this }, unregisterEditor: function (a) { return this.editors = this.editors || {}, this.editors[a.path] = null, this }, getEditor: function (a) { if (this.editors) return this.editors[a] }, watch: function (a, b) { return this.watchlist = this.watchlist || {}, this.watchlist[a] = this.watchlist[a] || [], this.watchlist[a].push(b), this }, unwatch: function (a, b) { if (!this.watchlist || !this.watchlist[a]) return this; if (!b) return this.watchlist[a] = null, this; for (var c = [], d = 0; d < this.watchlist[a].length; d++)this.watchlist[a][d] !== b && c.push(this.watchlist[a][d]); return this.watchlist[a] = c.length ? c : null, this }, notifyWatchers: function (a) { if (!this.watchlist || !this.watchlist[a]) return this; for (var b = 0; b < this.watchlist[a].length; b++)this.watchlist[a][b]() }, isEnabled: function () { return !this.root || this.root.isEnabled() }, enable: function () { this.root.enable() }, disable: function () { this.root.disable() }, _getDefinitions: function (a, b) { if (b = b || "#/definitions/", a.definitions) for (var c in a.definitions) a.definitions.hasOwnProperty(c) && (this.refs[b + c] = a.definitions[c], a.definitions[c].definitions && this._getDefinitions(a.definitions[c], b + c + "/definitions/")) }, _getExternalRefs: function (a) { var b = {}, c = function (a) { for (var c in a) a.hasOwnProperty(c) && (b[c] = !0) }; a.$ref && "object" != typeof a.$ref && "#" !== a.$ref.substr(0, 1) && !this.refs[a.$ref] && (b[a.$ref] = !0); for (var d in a) if (a.hasOwnProperty(d)) if (a[d] && "object" == typeof a[d] && Array.isArray(a[d])) for (var e = 0; e < a[d].length; e++)"object" == typeof a[d][e] && c(this._getExternalRefs(a[d][e])); else a[d] && "object" == typeof a[d] && c(this._getExternalRefs(a[d])); return b }, _loadExternalRefs: function (a, b) { var c = this, e = this._getExternalRefs(a), f = 0, g = 0, h = !1; d(e, function (a) { if (!c.refs[a]) { if (!c.options.ajax) throw "Must set ajax option to true to load external ref " + a; c.refs[a] = "loading", g++; var d = new XMLHttpRequest; d.open("GET", a, !0), d.onreadystatechange = function () { if (4 == d.readyState) { if (200 !== d.status) throw window.console.log(d), "Failed to fetch ref via ajax- " + a; var e; try { e = JSON.parse(d.responseText) } catch (b) { throw window.console.log(b), "Failed to parse external ref " + a } if (!e || "object" != typeof e) throw "External ref does not contain a valid schema - " + a; c.refs[a] = e, c._loadExternalRefs(e, function () { f++, f >= 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, this.refs[b] || (b = decodeURIComponent(b)), 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.allOf.length; b++)f = this.extendSchemas(f, this.expandSchema(a.allOf[b])); delete f.allOf } if (a.extends) { if (Array.isArray(a.extends)) for (b = 0; b < a.extends.length; b++)f = this.extendSchemas(f, this.expandSchema(a.extends[b])); else f = this.extendSchemas(f, this.expandSchema(a.extends)); delete f.extends } if (a.oneOf) { var g = c({}, f); for (delete g.oneOf, b = 0; b < a.oneOf.length; b++)f.oneOf[b] = this.extendSchemas(this.expandSchema(a.oneOf[b]), g) } return this.expandRefs(f) }, extendSchemas: function (a, b) { a = c({}, a), b = c({}, b); var e = this, f = {}; return d(a, function (a, c) { "undefined" != typeof b[a] ? "required" !== a && "defaultProperties" !== a || "object" != typeof c || !Array.isArray(c) ? "type" !== a || "string" != typeof c && !Array.isArray(c) ? "object" == typeof c && Array.isArray(c) ? f[a] = c.filter(function (c) { return b[a].indexOf(c) !== -1 }) : "object" == typeof c && null !== c ? f[a] = e.extendSchemas(c, b[a]) : f[a] = c : ("string" == typeof c && (c = [c]), "string" == typeof b.type && (b.type = [b.type]), b.type && b.type.length ? f.type = c.filter(function (a) { return b.type.indexOf(a) !== -1 }) : f.type = c, 1 === f.type.length && "string" == typeof f.type[0] ? f.type = f.type[0] : 0 === f.type.length && delete f.type) : f[a] = c.concat(b[a]).reduce(function (a, b) { return a.indexOf(b) < 0 && a.push(b), a }, []) : f[a] = c }), d(b, function (b, c) { "undefined" == typeof a[b] && (f[b] = c) }), f } }, f.defaults = { themes: {}, templates: {}, iconlibs: {}, editors: {}, languages: {}, resolvers: [], custom_validators: [] }, f.Validator = a.extend({ init: function (a, b, c) { this.jsoneditor = a, this.schema = b || this.jsoneditor.schema, this.options = c || {}, this.translate = this.jsoneditor.translate || f.defaults.translate }, validate: function (a) { return this._validateSchema(this.schema, a) }, _validateSchema: function (a, b, e) { var g, h, i, j = this, k = [], l = JSON.stringify(b); if (e = e || "root", a = c({}, this.jsoneditor.expandRefs(a)), a.required && a.required === !0) { if ("undefined" == typeof b) return k.push({ path: e, property: "required", message: this.translate("error_notset") }), k } else if ("undefined" == typeof b) { if (!this.jsoneditor.options.required_by_default) return k; k.push({ path: e, property: "required", message: this.translate("error_notset") }) } if (a.enum) { for (g = !1, h = 0; h < a.enum.length; h++)l === JSON.stringify(a.enum[h]) && (g = !0); g || k.push({ path: e, property: "enum", message: this.translate("error_enum") }) } if (a.extends) for (h = 0; h < a.extends.length; h++)k = k.concat(this._validateSchema(a.extends[h], b, e)); if (a.allOf) for (h = 0; h < a.allOf.length; h++)k = k.concat(this._validateSchema(a.allOf[h], b, e)); if (a.anyOf) { for (g = !1, h = 0; h < a.anyOf.length; h++)if (!this._validateSchema(a.anyOf[h], b, e).length) { g = !0; break } g || k.push({ path: e, property: "anyOf", message: this.translate("error_anyOf") }) } if (a.oneOf) { g = 0; var m = []; for (h = 0; h < a.oneOf.length; h++) { var n = this._validateSchema(a.oneOf[h], b, e); for (n.length || g++, i = 0; i < n.length; i++)n[i].path = e + ".oneOf[" + h + "]" + n[i].path.substr(e.length); m = m.concat(n) } 1 !== g && (k.push({ path: e, property: "oneOf", message: this.translate("error_oneOf", [g]) }), k = k.concat(m)) } if (a.not && (this._validateSchema(a.not, b, e).length || k.push({ path: e, property: "not", message: this.translate("error_not") })), a.type) if (Array.isArray(a.type)) { for (g = !1, h = 0; h < a.type.length; h++)if (this._checkType(a.type[h], b)) { g = !0; break } g || k.push({ path: e, property: "type", message: this.translate("error_type_union") }) } else this._checkType(a.type, b) || k.push({ path: e, property: "type", message: this.translate("error_type", [a.type]) }); if (a.disallow) if (Array.isArray(a.disallow)) { for (g = !0, h = 0; h < a.disallow.length; h++)if (this._checkType(a.disallow[h], b)) { g = !1; break } g || k.push({ path: e, property: "disallow", message: this.translate("error_disallow_union") }) } else this._checkType(a.disallow, b) && k.push({ path: e, property: "disallow", message: this.translate("error_disallow", [a.disallow]) }); if ("number" == typeof b) { if (a.multipleOf || a.divisibleBy) { var o = a.multipleOf || a.divisibleBy; g = b / o === Math.floor(b / o), window.math ? g = window.math.mod(window.math.bignumber(b), window.math.bignumber(o)).equals(0) : window.Decimal && (g = new window.Decimal(b).mod(new window.Decimal(o)).equals(0)), g || k.push({ path: e, property: a.multipleOf ? "multipleOf" : "divisibleBy", message: this.translate("error_multipleOf", [o]) }) } a.hasOwnProperty("maximum") && (g = a.exclusiveMaximum ? b < a.maximum : b <= a.maximum, window.math ? g = window.math[a.exclusiveMaximum ? "smaller" : "smallerEq"](window.math.bignumber(b), window.math.bignumber(a.maximum)) : window.Decimal && (g = new window.Decimal(b)[a.exclusiveMaximum ? "lt" : "lte"](new window.Decimal(a.maximum))), g || k.push({ path: e, property: "maximum", message: this.translate(a.exclusiveMaximum ? "error_maximum_excl" : "error_maximum_incl", [a.maximum]) })), a.hasOwnProperty("minimum") && (g = a.exclusiveMinimum ? b > a.minimum : b >= a.minimum, window.math ? g = window.math[a.exclusiveMinimum ? "larger" : "largerEq"](window.math.bignumber(b), window.math.bignumber(a.minimum)) : window.Decimal && (g = new window.Decimal(b)[a.exclusiveMinimum ? "gt" : "gte"](new window.Decimal(a.minimum))), g || k.push({ path: e, property: "minimum", message: this.translate(a.exclusiveMinimum ? "error_minimum_excl" : "error_minimum_incl", [a.minimum]) })) } else if ("string" == typeof b) a.maxLength && (b + "").length > a.maxLength && k.push({ path: e, property: "maxLength", message: this.translate("error_maxLength", [a.maxLength]) }), a.minLength && (b + "").length < a.minLength && k.push({ path: e, property: "minLength", message: this.translate(1 === a.minLength ? "error_notempty" : "error_minLength", [a.minLength]) }), a.pattern && (new RegExp(a.pattern).test(b) || k.push({ path: e, property: "pattern", message: this.translate("error_pattern", [a.pattern]) })); else if ("object" == typeof b && null !== b && Array.isArray(b)) { if (a.items) if (Array.isArray(a.items)) for (h = 0; h < b.length; h++)if (a.items[h]) k = k.concat(this._validateSchema(a.items[h], b[h], e + "." + h)); else { if (a.additionalItems === !0) break; if (!a.additionalItems) { if (a.additionalItems === !1) { k.push({ path: e, property: "additionalItems", message: this.translate("error_additionalItems") }); break } break } k = k.concat(this._validateSchema(a.additionalItems, b[h], e + "." + h)) } else for (h = 0; h < b.length; h++)k = k.concat(this._validateSchema(a.items, b[h], e + "." + h)); if (a.maxItems && b.length > a.maxItems && k.push({ path: e, property: "maxItems", message: this.translate("error_maxItems", [a.maxItems]) }), a.minItems && b.length < a.minItems && k.push({ path: e, property: "minItems", message: this.translate("error_minItems", [a.minItems]) }), a.uniqueItems) { var p = {}; for (h = 0; h < b.length; h++) { if (g = JSON.stringify(b[h]), p[g]) { k.push({ path: e, property: "uniqueItems", message: this.translate("error_uniqueItems") }); break } p[g] = !0 } } } else if ("object" == typeof b && null !== b) { if (a.maxProperties) { g = 0; for (h in b) b.hasOwnProperty(h) && g++; g > a.maxProperties && k.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 < a.minProperties && k.push({ path: e, property: "minProperties", message: this.translate("error_minProperties", [a.minProperties]) }) } if (a.required && Array.isArray(a.required)) for (h = 0; h < a.required.length; h++)"undefined" == typeof b[a.required[h]] && k.push({ path: e, property: "required", message: this.translate("error_required", [a.required[h]]) }); var q = {}; if (a.properties) for (h in a.properties) a.properties.hasOwnProperty(h) && (q[h] = !0, k = k.concat(this._validateSchema(a.properties[h], b[h], e + "." + h))); if (a.patternProperties) for (h in a.patternProperties) if (a.patternProperties.hasOwnProperty(h)) { var r = new RegExp(h); for (i in b) b.hasOwnProperty(i) && r.test(i) && (q[i] = !0, k = k.concat(this._validateSchema(a.patternProperties[h], b[i], e + "." + i))) } if ("undefined" != typeof a.additionalProperties || !this.jsoneditor.options.no_additional_properties || a.oneOf || a.anyOf || (a.additionalProperties = !1), "undefined" != typeof a.additionalProperties) for (h in b) if (b.hasOwnProperty(h) && !q[h]) { if (!a.additionalProperties) { k.push({ path: e, property: "additionalProperties", message: this.translate("error_additional_properties", [h]) }); break } if (a.additionalProperties === !0) break; k = k.concat(this._validateSchema(a.additionalProperties, b[h], e + "." + h)) } if (a.dependencies) for (h in a.dependencies) if (a.dependencies.hasOwnProperty(h) && "undefined" != typeof b[h]) if (Array.isArray(a.dependencies[h])) for (i = 0; i < a.dependencies[h].length; i++)"undefined" == typeof b[a.dependencies[h][i]] && k.push({ path: e, property: "dependencies", message: this.translate("error_dependency", [a.dependencies[h][i]]) }); else k = k.concat(this._validateSchema(a.dependencies[h], b, e)) } return d(f.defaults.custom_validators, function (c, d) { k = k.concat(d.call(j, a, b, e)) }), this.options.custom_validators && d(this.options.custom_validators, function (c, d) { k = k.concat(d.call(j, a, b, e)) }), k }, _checkType: function (a, b) { return "string" == typeof a ? "string" === a ? "string" == typeof b : "number" === a ? "number" == typeof b : "integer" === a ? "number" == typeof b && b === Math.floor(b) : "boolean" === a ? "boolean" == typeof b : "array" === a ? Array.isArray(b) : "object" === a ? null !== b && !Array.isArray(b) && "object" == typeof b : "null" !== a || null === b : !this._validateSchema(a, b).length } }), f.AbstractEditor = a.extend({ onChildEditorChange: function (a) { this.onChange(!0) }, notify: function () { this.jsoneditor.notifyWatchers(this.path) }, change: function () { this.parent ? this.parent.onChildEditorChange(this) : this.jsoneditor.onChange() }, onChange: function (a) { this.notify(), this.watch_listener && this.watch_listener(), a && this.change() }, register: function () { this.jsoneditor.registerEditor(this), this.onChange() }, unregister: function () { this.jsoneditor && this.jsoneditor.unregisterEditor(this) }, getNumColumns: function () { return 12 }, init: function (a) { this.jsoneditor = a.jsoneditor, this.theme = this.jsoneditor.theme, this.template_engine = this.jsoneditor.template, this.iconlib = this.jsoneditor.iconlib, this.translate = this.jsoneditor.translate || f.defaults.translate, this.original_schema = a.schema, this.schema = this.jsoneditor.expandSchema(this.original_schema), this.options = c({}, this.options || {}, a.schema.options || {}, a), a.path || this.schema.id || (this.schema.id = "root"), this.path = a.path || "root", this.formname = a.formname || this.path.replace(/\.([^.]+)/g, "[$1]"), this.jsoneditor.options.form_name_root && (this.formname = this.formname.replace(/^root\[/, this.jsoneditor.options.form_name_root + "[")), this.key = this.path.split(".").pop(), this.parent = a.parent, this.link_watchers = [], a.container && this.setContainer(a.container) }, setContainer: function (a) { this.container = a, this.schema.id && this.container.setAttribute("data-schemaid", this.schema.id), this.schema.type && "string" == typeof this.schema.type && this.container.setAttribute("data-schematype", this.schema.type), this.container.setAttribute("data-schemapath", this.path) }, preBuild: function () { }, build: function () { }, postBuild: function () { this.setupWatchListeners(), this.addLinks(), this.setValue(this.getDefault(), !0), this.updateHeaderText(), this.register(), this.onWatchedFieldChange() }, setupWatchListeners: function () { var a = this; if (this.watched = {}, this.schema.vars && (this.schema.watch = this.schema.vars), this.watched_values = {}, this.watch_listener = function () { a.refreshWatchedFieldValues() && a.onWatchedFieldChange() }, this.register(), this.schema.hasOwnProperty("watch")) { var b, c, d, e, f; for (var g in this.schema.watch) if (this.schema.watch.hasOwnProperty(g)) { if (b = this.schema.watch[g], Array.isArray(b)) { if (b.length < 2) continue; c = [b[0]].concat(b[1].split(".")) } else c = b.split("."), a.theme.closest(a.container, '[data-schemaid="' + c[0] + '"]') || c.unshift("#"); if (d = c.shift(), "#" === d && (d = a.jsoneditor.schema.id || "root"), e = a.theme.closest(a.container, '[data-schemaid="' + d + '"]'), !e) throw "Could not find ancestor node with id " + d; f = e.getAttribute("data-schemapath") + "." + c.join("."), a.jsoneditor.watch(f, a.watch_listener), a.watched[g] = f } } this.schema.headerTemplate && (this.header_template = this.jsoneditor.compileTemplate(this.schema.headerTemplate, this.template_engine)) }, addLinks: function () { if (!this.no_link_holder && (this.link_holder = this.theme.getLinksHolder(), this.container.appendChild(this.link_holder), this.schema.links)) for (var a = 0; a < this.schema.links.length; a++)this.addLink(this.getLink(this.schema.links[a])) }, getButton: function (a, b, c) { var d = "json-editor-btn-" + b; b = this.iconlib ? this.iconlib.getIcon(b) : null, !b && c && (a = c, c = null); var e = this.theme.getButton(a, b, c); return e.className += " " + d + " ", e }, setButtonText: function (a, b, c, d) { return c = this.iconlib ? this.iconlib.getIcon(c) : null, !c && d && (b = d, d = null), this.theme.setButtonText(a, b, c, d) }, addLink: function (a) { this.link_holder && this.link_holder.appendChild(a) }, getLink: function (a) { var b, c, d = a.mediaType || "application/javascript", e = d.split("/")[0], f = this.jsoneditor.compileTemplate(a.href, this.template_engine), g = null; if (a.download && (g = a.download), g && g !== !0 && (g = this.jsoneditor.compileTemplate(g, this.template_engine)), "image" === e) { b = this.theme.getBlockLinkHolder(), c = document.createElement("a"), c.setAttribute("target", "_blank"); var h = document.createElement("img"); this.theme.createImageLink(b, c, h), this.link_watchers.push(function (b) { var d = f(b); c.setAttribute("href", d), c.setAttribute("title", a.rel || d), h.setAttribute("src", d) }) } else if (["audio", "video"].indexOf(e) >= 0) { b = this.theme.getBlockLinkHolder(), c = this.theme.getBlockLink(), c.setAttribute("target", "_blank"); var i = document.createElement(e); i.setAttribute("controls", "controls"), this.theme.createMediaLink(b, c, i), this.link_watchers.push(function (b) { var d = f(b); c.setAttribute("href", d), c.textContent = a.rel || d, i.setAttribute("src", d) }) } else c = 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 g && c && (g === !0 ? c.setAttribute("download", "") : this.link_watchers.push(function (a) { c.setAttribute("download", g(a)) })), a.class && (c.className = c.className + " " + a.class), b }, refreshWatchedFieldValues: function () { if (this.watched_values) { var a = {}, b = !1, c = this; if (this.watched) { var d, e; for (var f in this.watched) this.watched.hasOwnProperty(f) && (e = c.jsoneditor.getEditor(this.watched[f]), d = e ? e.getValue() : null, c.watched_values[f] !== d && (b = !0), a[f] = d) } return a.self = this.getValue(), this.watched_values.self !== a.self && (b = !0), this.watched_values = a, b } }, getWatchedFieldValues: function () { return this.watched_values }, updateHeaderText: function () { if (this.header) if (this.header.children.length) { for (var a = 0; a < this.header.childNodes.length; a++)if (3 === this.header.childNodes[a].nodeType) { this.header.childNodes[a].nodeValue = this.getHeaderText(); break } } else 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; d < this.link_watchers.length; d++)this.link_watchers[d](a) } }, setValue: function (a) { this.value = a }, getValue: function () { return this.value }, refreshValue: function () { }, getChildEditors: function () { return !1 }, destroy: function () { var a = this; this.unregister(this), d(this.watched, function (b, c) { a.jsoneditor.unwatch(c, a.watch_listener) }), this.watched = null, this.watched_values = null, this.watch_listener = null, this.header_text = null, this.header_template = null, this.value = null, this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = null, this.jsoneditor = null, this.schema = null, this.path = null, this.key = null, this.parent = null }, getDefault: function () { if (this.schema.default) return this.schema.default; if (this.schema.enum) return this.schema.enum[0]; var a = this.schema.type || this.schema.oneOf; if (a && Array.isArray(a) && (a = a[0]), a && "object" == typeof a && (a = a.type), a && Array.isArray(a) && (a = a[0]), "string" == typeof a) { if ("number" === a) return 0; if ("boolean" === a) return !1; if ("integer" === a) return 0; if ("string" === a) return ""; if ("object" === a) return {}; if ("array" === a) return [] } return null }, getTitle: function () { return this.schema.title || this.key }, enable: function () { this.disabled = !1 }, disable: function () { this.disabled = !0 }, isEnabled: function () { return !this.disabled }, isRequired: function () { return "boolean" == typeof this.schema.required ? this.schema.required : this.parent && this.parent.schema && Array.isArray(this.parent.schema.required) ? this.parent.schema.required.indexOf(this.key) > -1 : !!this.jsoneditor.options.required_by_default }, getDisplayText: function (a) { var b = [], c = {}; d(a, function (a, b) { b.title && (c[b.title] = c[b.title] || 0, c[b.title]++), b.description && (c[b.description] = c[b.description] || 0, c[b.description]++), b.format && (c[b.format] = c[b.format] || 0, c[b.format]++), b.type && (c[b.type] = c[b.type] || 0, c[b.type]++) }), d(a, function (a, d) { var e; e = "string" == typeof d ? d : d.title && c[d.title] <= 1 ? d.title : d.format && c[d.format] <= 1 ? d.format : d.type && c[d.type] <= 1 ? d.type : d.description && c[d.description] <= 1 ? d.descripton : d.title ? d.title : d.format ? d.format : d.type ? d.type : d.description ? d.description : JSON.stringify(d).length < 50 ? JSON.stringify(d) : "type", b.push(e) }); var e = {}; return d(b, function (a, d) { e[d] = e[d] || 0, e[d]++, c[d] > 1 && (b[a] = d + " " + e[d]) }), b }, getOption: function (a) { try { throw "getOption is deprecated" } catch (a) { window.console.error(a) } return this.options[a] }, showValidationErrors: function (a) { } }), f.defaults.editors.null = f.AbstractEditor.extend({ getValue: function () { return null }, setValue: function () { this.onChange() }, 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) { if ((!this.template || c) && (null === a || "undefined" == typeof a ? a = "" : "object" == typeof a ? a = JSON.stringify(a) : "string" != typeof a && (a = "" + a), a !== this.serialized)) { var d = this.sanitize(a); if (this.input.value !== d) { this.input.value = d, this.sceditor_instance ? this.sceditor_instance.val(d) : this.epiceditor ? this.epiceditor.importFile(null, d) : this.ace_editor && this.ace_editor.setValue(d); var e = c || this.getValue() !== a; this.refreshValue(), b ? this.is_dirty = !1 : "change" === this.jsoneditor.options.show_errors && (this.is_dirty = !0), this.adjust_height && this.adjust_height(this.input), this.onChange(e) } } }, getNumColumns: function () { var a, b = Math.ceil(Math.max(this.getTitle().length, this.schema.maxLength || 0, this.schema.minLength || 0) / 5); return a = "textarea" === this.input_type ? 6 : ["text", "email"].indexOf(this.input_type) >= 0 ? 4 : 2, Math.min(12, Math.max(b, a)) }, build: function () { var a = this; if (this.options.compact || (this.header = this.label = this.theme.getFormInputLabel(this.getTitle())), this.schema.description && (this.description = this.theme.getFormInputDescription(this.schema.description)), this.format = this.schema.format, !this.format && this.schema.media && this.schema.media.type && (this.format = this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g, "")), !this.format && this.options.default_format && (this.format = this.options.default_format), this.options.format && (this.format = this.options.format), this.format) if ("textarea" === this.format) this.input_type = "textarea", this.input = this.theme.getTextareaInput(); else if ("range" === this.format) { this.input_type = "range"; var b = this.schema.minimum || 0, c = this.schema.maximum || Math.max(100, b + 1), d = 1; this.schema.multipleOf && (b % this.schema.multipleOf && (b = Math.ceil(b / this.schema.multipleOf) * this.schema.multipleOf), c % this.schema.multipleOf && (c = Math.floor(c / this.schema.multipleOf) * this.schema.multipleOf), d = this.schema.multipleOf), this.input = this.theme.getRangeInput(b, c, d) } else["actionscript", "batchfile", "bbcode", "c", "c++", "cpp", "coffee", "csharp", "css", "dart", "django", "ejs", "erlang", "golang", "groovy", "handlebars", "haskell", "haxe", "html", "ini", "jade", "java", "javascript", "json", "less", "lisp", "lua", "makefile", "markdown", "matlab", "mysql", "objectivec", "pascal", "perl", "pgsql", "php", "python", "r", "ruby", "sass", "scala", "scss", "smarty", "sql", "stylus", "svg", "twig", "vbscript", "xml", "yaml"].indexOf(this.format) >= 0 ? (this.input_type = this.format, this.source_code = !0, this.input = this.theme.getTextareaInput()) : (this.input_type = this.format, this.input = this.theme.getFormInputField(this.input_type)); else this.input_type = "text", this.input = this.theme.getFormInputField(this.input_type); "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.className += " compact" : this.options.input_width && (this.input.style.width = this.options.input_width), (this.schema.readOnly || this.schema.readonly || this.schema.template) && (this.always_disabled = !0, this.input.disabled = !0), this.input.addEventListener("change", function (b) { if (b.preventDefault(), b.stopPropagation(), a.schema.template) return void (this.value = a.value); var c = this.value, d = a.sanitize(c); c !== d && (this.value = d), a.is_dirty = !0, a.refreshValue(), a.onChange(!0) }), this.options.input_height && (this.input.style.height = this.options.input_height), this.options.expand_height && (this.adjust_height = function (a) { if (a) { var b, c = a.offsetHeight; if (a.offsetHeight < a.scrollHeight) for (b = 0; a.offsetHeight < a.scrollHeight + 3 && !(b > 100);)b++, c++, a.style.height = c + "px"; else { for (b = 0; a.offsetHeight >= a.scrollHeight + 3 && !(b > 100);)b++, c--, a.style.height = c + "px"; a.style.height = c + 1 + "px" } } }, this.input.addEventListener("keyup", function (b) { a.adjust_height(this) }), this.input.addEventListener("change", function (b) { a.adjust_height(this) }), this.adjust_height()), this.format && this.input.setAttribute("data-schemaformat", this.format), this.control = this.theme.getFormControl(this.label, this.input, this.description), this.container.appendChild(this.control), window.requestAnimationFrame(function () { a.input.parentNode && a.afterInputReady(), a.adjust_height && a.adjust_height(a.input) }), this.schema.template ? (this.template = this.jsoneditor.compileTemplate(this.schema.template, this.template_engine), this.refreshValue()) : this.refreshValue() }, 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, b.options.sceditor_options || {}), window.jQuery(b.input).sceditor(a), b.sceditor_instance = window.jQuery(b.input).sceditor("instance"), b.sceditor_instance.blur(function () { var a = window.jQuery("
    " + b.sceditor_instance.val() + "
    "); window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf", a).remove(), b.input.value = a.html(), b.value = b.input.value, b.is_dirty = !0, b.onChange(!0) }); else if ("markdown" === this.input_type && window.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.onChange(!0) }); 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.onChange(!0) }) } b.theme.afterInputReady(b.input) + }, refreshValue: function () { this.value = this.input.value, "string" != typeof this.value && (this.value = ""), this.serialized = this.value }, destroy: function () { this.sceditor_instance ? this.sceditor_instance.destroy() : this.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; this.template && (a = this.getWatchedFieldValues(), this.setValue(this.template(a), !1, !0)), this._super() }, showValidationErrors: function (a) { var b = this; if ("always" === this.jsoneditor.options.show_errors); else if (!this.is_dirty && this.previous_error_setting === this.jsoneditor.options.show_errors) return; this.previous_error_setting = this.jsoneditor.options.show_errors; var c = []; d(a, function (a, d) { d.path === b.path && c.push(d.message) }), c.length ? this.theme.addInputError(this.input, c.join(". ") + ".") : this.theme.removeInputError(this.input) } + }), f.defaults.editors.number = f.defaults.editors.string.extend({ sanitize: function (a) { return (a + "").replace(/[^0-9\.\-eE]/g, "") }, getNumColumns: function () { return 2 }, getValue: function () { return 1 * this.value } }), f.defaults.editors.integer = f.defaults.editors.number.extend({ sanitize: function (a) { return a += "", a.replace(/[^0-9\-]/g, "") }, getNumColumns: function () { return 2 } }), f.defaults.editors.object = f.AbstractEditor.extend({ getDefault: function () { return c({}, this.schema.default || {}) }, getChildEditors: function () { return this.editors }, register: function () { if (this._super(), this.editors) for (var a in this.editors) this.editors.hasOwnProperty(a) && this.editors[a].register() }, unregister: function () { if (this._super(), this.editors) for (var a in this.editors) this.editors.hasOwnProperty(a) && this.editors[a].unregister() }, getNumColumns: function () { return Math.max(Math.min(12, this.maxwidth), 3) }, enable: function () { if (this.editjson_button && (this.editjson_button.disabled = !1), this.addproperty_button && (this.addproperty_button.disabled = !1), this._super(), this.editors) for (var a in this.editors) this.editors.hasOwnProperty(a) && this.editors[a].enable() }, disable: function () { if (this.editjson_button && (this.editjson_button.disabled = !0), this.addproperty_button && (this.addproperty_button.disabled = !0), this.hideEditJSON(), this._super(), this.editors) for (var a in this.editors) this.editors.hasOwnProperty(a) && this.editors[a].disable() }, layoutEditors: function () { var a, b, c = this; if (this.row_container) { this.property_order = Object.keys(this.editors), this.property_order = this.property_order.sort(function (a, b) { var d = c.editors[a].schema.propertyOrder, e = c.editors[b].schema.propertyOrder; return "number" != typeof d && (d = 1e3), "number" != typeof e && (e = 1e3), d - e }); var e; if ("grid" === this.format) { var f = []; for (d(this.property_order, function (a, b) { var d = c.editors[b]; if (!d.property_removed) { for (var e = !1, g = d.options.hidden ? 0 : d.options.grid_columns || d.getNumColumns(), h = d.options.hidden ? 0 : d.container.offsetHeight, i = 0; i < f.length; i++)f[i].width + g <= 12 && (!h || .5 * f[i].minh < h && 2 * f[i].maxh > h) && (e = i); e === !1 && (f.push({ width: 0, minh: 999999, maxh: 0, editors: [] }), e = f.length - 1), f[e].editors.push({ key: b, width: g, height: h }), f[e].width += g, f[e].minh = Math.min(f[e].minh, h), f[e].maxh = Math.max(f[e].maxh, h) } }), a = 0; a < f.length; a++)if (f[a].width < 12) { var g = !1, h = 0; for (b = 0; b < f[a].editors.length; b++)g === !1 ? g = b : f[a].editors[b].width > f[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; h < 12 && (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 < f.length; a++) { var i = this.theme.getGridRow(); for (e.appendChild(i), b = 0; b < f[a].editors.length; b++) { var j = f[a].editors[b].key, k = this.editors[j]; k.options.hidden ? k.container.style.display = "none" : this.theme.setGridColumnSize(k.container, f[a].editors[b].width), i.appendChild(k.container) } } } else e = document.createElement("div"), d(this.property_order, function (a, b) { var d = c.editors[b]; if (!d.property_removed) { var f = c.theme.getGridRow(); e.appendChild(f), d.options.hidden ? d.container.style.display = "none" : c.theme.setGridColumnSize(d.container, 12), f.appendChild(d.container) } }); this.row_container.innerHTML = "", this.row_container.appendChild(e) } }, getPropertySchema: function (a) { var b = this.schema.properties[a] || {}; b = c({}, b); var d = !!this.schema.properties[a]; if (this.schema.patternProperties) for (var e in this.schema.patternProperties) if (this.schema.patternProperties.hasOwnProperty(e)) { var f = new RegExp(e); f.test(a) && (b.allOf = b.allOf || [], b.allOf.push(this.schema.patternProperties[e]), d = !0) } return !d && this.schema.additionalProperties && "object" == typeof this.schema.additionalProperties && (b = c({}, this.schema.additionalProperties)), b }, preBuild: function () { this._super(), this.editors = {}, this.cached_editors = {}; var a = this; if (this.format = this.options.layout || this.options.object_layout || this.schema.format || this.jsoneditor.options.object_layout || "normal", this.schema.properties = this.schema.properties || {}, this.minwidth = 0, this.maxwidth = 0, this.options.table_row) d(this.schema.properties, function (b, c) { var d = a.jsoneditor.getEditorClass(c); a.editors[b] = a.jsoneditor.createEditor(d, { jsoneditor: a.jsoneditor, schema: c, path: a.path + "." + b, parent: a, compact: !0, required: !0 }), a.editors[b].preBuild(); var e = a.editors[b].options.hidden ? 0 : a.editors[b].options.grid_columns || a.editors[b].getNumColumns(); a.minwidth += e, a.maxwidth += e }), this.no_link_holder = !0; else { if (this.options.table) throw "Not supported yet"; this.schema.defaultProperties || (this.jsoneditor.options.display_required_only || this.options.display_required_only ? (this.schema.defaultProperties = [], d(this.schema.properties, function (b, c) { a.isRequired({ key: b, schema: c }) && a.schema.defaultProperties.push(b) })) : a.schema.defaultProperties = Object.keys(a.schema.properties)), a.maxwidth += 1, d(this.schema.defaultProperties, function (b, c) { a.addObjectProperty(c, !0), a.editors[c] && (a.minwidth = Math.max(a.minwidth, a.editors[c].options.grid_columns || a.editors[c].getNumColumns()), a.maxwidth += a.editors[c].options.grid_columns || a.editors[c].getNumColumns()) }) } this.property_order = Object.keys(this.editors), this.property_order = this.property_order.sort(function (b, c) { var d = a.editors[b].schema.propertyOrder, e = a.editors[c].schema.propertyOrder; return "number" != typeof d && (d = 1e3), "number" != typeof e && (e = 1e3), d - e }) }, build: function () { var a = this; if (this.options.table_row) this.editor_holder = this.container, d(this.editors, function (b, c) { var d = a.theme.getTableCell(); a.editor_holder.appendChild(d), c.setContainer(d), c.build(), c.postBuild(), a.editors[b].options.hidden && (d.style.display = "none"), a.editors[b].options.input_width && (d.style.width = a.editors[b].options.input_width) }); else { if (this.options.table) throw "Not supported yet"; this.header = document.createElement("span"), this.header.textContent = this.getTitle(), this.title = this.theme.getHeader(this.header), this.container.appendChild(this.title), this.container.style.position = "relative", this.editjson_holder = this.theme.getModal(), this.editjson_textarea = this.theme.getTextareaInput(), this.editjson_textarea.style.height = "170px", this.editjson_textarea.style.width = "300px", this.editjson_textarea.style.display = "block", this.editjson_save = this.getButton("Save", "save", "Save"), this.editjson_save.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.saveJSON() }), this.editjson_cancel = this.getButton("Cancel", "cancel", "Cancel"), this.editjson_cancel.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.hideEditJSON() }), this.editjson_holder.appendChild(this.editjson_textarea), this.editjson_holder.appendChild(this.editjson_save), this.editjson_holder.appendChild(this.editjson_cancel), this.addproperty_holder = this.theme.getModal(), this.addproperty_list = document.createElement("div"), this.addproperty_list.style.width = "295px", this.addproperty_list.style.maxHeight = "160px", this.addproperty_list.style.padding = "5px 0", this.addproperty_list.style.overflowY = "auto", this.addproperty_list.style.overflowX = "hidden", this.addproperty_list.style.paddingLeft = "5px", this.addproperty_list.setAttribute("class", "property-selector"), this.addproperty_add = this.getButton("add", "add", "add"), this.addproperty_input = this.theme.getFormInputField("text"), this.addproperty_input.setAttribute("placeholder", "Property name..."), this.addproperty_input.style.width = "220px", this.addproperty_input.style.marginBottom = "0", this.addproperty_input.style.display = "inline-block", this.addproperty_add.addEventListener("click", function (b) { if (b.preventDefault(), b.stopPropagation(), a.addproperty_input.value) { if (a.editors[a.addproperty_input.value]) return void window.alert("there is already a property with that name"); a.addObjectProperty(a.addproperty_input.value), a.editors[a.addproperty_input.value] && a.editors[a.addproperty_input.value].disable(), a.onChange(!0) } }), this.addproperty_holder.appendChild(this.addproperty_list), this.addproperty_holder.appendChild(this.addproperty_input), this.addproperty_holder.appendChild(this.addproperty_add); var b = document.createElement("div"); b.style.clear = "both", this.addproperty_holder.appendChild(b), this.schema.description && (this.description = this.theme.getDescription(this.schema.description), this.container.appendChild(this.description)), this.error_holder = document.createElement("div"), this.container.appendChild(this.error_holder), this.editor_holder = this.theme.getIndentedPanel(), this.container.appendChild(this.editor_holder), this.row_container = this.theme.getGridContainer(), this.editor_holder.appendChild(this.row_container), d(this.editors, function (b, c) { var d = a.theme.getGridColumn(); a.row_container.appendChild(d), c.setContainer(d), c.build(), c.postBuild() }), this.title_controls = this.theme.getHeaderButtonHolder(), this.editjson_controls = this.theme.getHeaderButtonHolder(), this.addproperty_controls = this.theme.getHeaderButtonHolder(), this.title.appendChild(this.title_controls), this.title.appendChild(this.editjson_controls), this.title.appendChild(this.addproperty_controls), this.collapsed = !1, this.toggle_button = this.getButton("", "collapse", this.translate("button_collapse")), this.title_controls.appendChild(this.toggle_button), this.toggle_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.collapsed ? (a.editor_holder.style.display = "", a.collapsed = !1, a.setButtonText(a.toggle_button, "", "collapse", a.translate("button_collapse"))) : (a.editor_holder.style.display = "none", a.collapsed = !0, a.setButtonText(a.toggle_button, "", "expand", a.translate("button_expand"))) }), this.options.collapsed && e(this.toggle_button, "click"), this.schema.options && "undefined" != typeof this.schema.options.disable_collapse ? this.schema.options.disable_collapse && (this.toggle_button.style.display = "none") : this.jsoneditor.options.disable_collapse && (this.toggle_button.style.display = "none"), this.editjson_button = this.getButton("JSON", "edit", "Edit JSON"), this.editjson_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.toggleEditJSON() }), this.editjson_controls.appendChild(this.editjson_button), this.editjson_controls.appendChild(this.editjson_holder), this.schema.options && "undefined" != typeof this.schema.options.disable_edit_json ? this.schema.options.disable_edit_json && (this.editjson_button.style.display = "none") : this.jsoneditor.options.disable_edit_json && (this.editjson_button.style.display = "none"), this.addproperty_button = this.getButton("Properties", "edit", "Object Properties"), this.addproperty_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.toggleAddProperty() }), this.addproperty_controls.appendChild(this.addproperty_button), this.addproperty_controls.appendChild(this.addproperty_holder), this.refreshAddProperties() } this.options.table_row ? (this.editor_holder = this.container, d(this.property_order, function (b, c) { a.editor_holder.appendChild(a.editors[c].container) })) : (this.layoutEditors(), this.layoutEditors()) }, showEditJSON: function () { this.editjson_holder && (this.hideAddProperty(), this.editjson_holder.style.left = this.editjson_button.offsetLeft + "px", this.editjson_holder.style.top = this.editjson_button.offsetTop + this.editjson_button.offsetHeight + "px", this.editjson_textarea.value = JSON.stringify(this.getValue(), null, 2), this.disable(), this.editjson_holder.style.display = "", this.editjson_button.disabled = !1, this.editing_json = !0) }, hideEditJSON: function () { this.editjson_holder && this.editing_json && (this.editjson_holder.style.display = "none", this.enable(), this.editing_json = !1) }, saveJSON: function () { if (this.editjson_holder) try { var a = JSON.parse(this.editjson_textarea.value); this.setValue(a), this.hideEditJSON() } catch (a) { throw window.alert("invalid JSON"), a } }, toggleEditJSON: function () { this.editing_json ? this.hideEditJSON() : this.showEditJSON() }, insertPropertyControlUsingPropertyOrder: function (a, b, c) { var d; this.schema.properties[a] && (d = this.schema.properties[a].propertyOrder), "number" != typeof d && (d = 1e3), b.propertyOrder = d; for (var e = 0; e < c.childNodes.length; e++) { var f = c.childNodes[e]; if (b.propertyOrder < f.propertyOrder) { this.addproperty_list.insertBefore(b, f), b = null; break } } b && this.addproperty_list.appendChild(b) }, addPropertyCheckbox: function (a) { var b, c, d, e, f = this; return b = f.theme.getCheckbox(), b.style.width = "auto", d = this.schema.properties[a] && this.schema.properties[a].title ? this.schema.properties[a].title : a, c = f.theme.getCheckboxLabel(d), e = f.theme.getFormControl(c, b), e.style.paddingBottom = e.style.marginBottom = e.style.paddingTop = e.style.marginTop = 0, e.style.height = "auto", this.insertPropertyControlUsingPropertyOrder(a, e, this.addproperty_list), b.checked = a in this.editors, b.addEventListener("change", function () { b.checked ? f.addObjectProperty(a) : f.removeObjectProperty(a), f.onChange(!0) }), f.addproperty_checkboxes[a] = b, b }, showAddProperty: function () { this.addproperty_holder && (this.hideEditJSON(), this.addproperty_holder.style.left = this.addproperty_button.offsetLeft + "px", this.addproperty_holder.style.top = this.addproperty_button.offsetTop + this.addproperty_button.offsetHeight + "px", this.disable(), this.adding_property = !0, this.addproperty_button.disabled = !1, this.addproperty_holder.style.display = "", this.refreshAddProperties()) }, hideAddProperty: function () { this.addproperty_holder && this.adding_property && (this.addproperty_holder.style.display = "none", this.enable(), this.adding_property = !1) }, toggleAddProperty: function () { this.adding_property ? this.hideAddProperty() : this.showAddProperty() }, removeObjectProperty: function (a) { this.editors[a] && (this.editors[a].unregister(), delete this.editors[a], this.refreshValue(), this.layoutEditors()) }, addObjectProperty: function (a, b) { var c = this; if (!this.editors[a]) { if (this.cached_editors[a]) { if (this.editors[a] = this.cached_editors[a], b) return; this.editors[a].register() } else { if (!(this.canHaveAdditionalProperties() || this.schema.properties && this.schema.properties[a])) return; var d = c.getPropertySchema(a), e = c.jsoneditor.getEditorClass(d); if (c.editors[a] = c.jsoneditor.createEditor(e, { jsoneditor: c.jsoneditor, schema: d, path: c.path + "." + a, parent: c }), c.editors[a].preBuild(), !b) { var f = c.theme.getChildEditorHolder(); c.editor_holder.appendChild(f), c.editors[a].setContainer(f), c.editors[a].build(), c.editors[a].postBuild() } c.cached_editors[a] = c.editors[a] } b || (c.refreshValue(), c.layoutEditors()) } }, onChildEditorChange: function (a) { this.refreshValue(), this._super(a) }, canHaveAdditionalProperties: function () { return "boolean" == typeof this.schema.additionalProperties ? this.schema.additionalProperties : !this.jsoneditor.options.no_additional_properties }, destroy: function () { d(this.cached_editors, function (a, b) { b.destroy() }), this.editor_holder && (this.editor_holder.innerHTML = ""), this.title && this.title.parentNode && this.title.parentNode.removeChild(this.title), this.error_holder && this.error_holder.parentNode && this.error_holder.parentNode.removeChild(this.error_holder), this.editors = null, this.cached_editors = null, this.editor_holder && this.editor_holder.parentNode && this.editor_holder.parentNode.removeChild(this.editor_holder), this.editor_holder = null, this._super() }, getValue: function () { var a = this._super(); if (this.jsoneditor.options.remove_empty_properties || this.options.remove_empty_properties) for (var b in a) a.hasOwnProperty(b) && (a[b] || delete a[b]); return a }, refreshValue: function () { this.value = {}; for (var a in this.editors) this.editors.hasOwnProperty(a) && (this.value[a] = this.editors[a].getValue()); this.adding_property && this.refreshAddProperties() }, refreshAddProperties: function () { if (this.options.disable_properties || this.options.disable_properties !== !1 && this.jsoneditor.options.disable_properties) return void (this.addproperty_controls.style.display = "none"); var a, b = !1, c = !1, d = 0, e = !1; for (a in this.editors) this.editors.hasOwnProperty(a) && d++; b = this.canHaveAdditionalProperties() && !("undefined" != typeof this.schema.maxProperties && d >= this.schema.maxProperties), this.addproperty_checkboxes && (this.addproperty_list.innerHTML = ""), this.addproperty_checkboxes = {}; for (a in this.cached_editors) this.cached_editors.hasOwnProperty(a) && (this.addPropertyCheckbox(a), this.isRequired(this.cached_editors[a]) && a in this.editors && (this.addproperty_checkboxes[a].disabled = !0), "undefined" != typeof this.schema.minProperties && d <= this.schema.minProperties ? (this.addproperty_checkboxes[a].disabled = this.addproperty_checkboxes[a].checked, this.addproperty_checkboxes[a].checked || (e = !0)) : a in this.editors ? (e = !0, c = !0) : b || this.schema.properties.hasOwnProperty(a) ? (this.addproperty_checkboxes[a].disabled = !1, e = !0) : this.addproperty_checkboxes[a].disabled = !0); this.canHaveAdditionalProperties() && (e = !0); for (a in this.schema.properties) this.schema.properties.hasOwnProperty(a) && (this.cached_editors[a] || (e = !0, this.addPropertyCheckbox(a))); e ? this.canHaveAdditionalProperties() ? b ? this.addproperty_add.disabled = !1 : this.addproperty_add.disabled = !0 : (this.addproperty_add.style.display = "none", this.addproperty_input.style.display = "none") : (this.hideAddProperty(), this.addproperty_controls.style.display = "none") }, isRequired: function (a) { return "boolean" == typeof a.schema.required ? a.schema.required : Array.isArray(this.schema.required) ? this.schema.required.indexOf(a.key) > -1 : !!this.jsoneditor.options.required_by_default }, setValue: function (a, b) { var c = this; a = a || {}, ("object" != typeof a || Array.isArray(a)) && (a = {}), 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) }), d(a, function (a, d) { c.cached_editors[a] || (c.addObjectProperty(a), c.editors[a] && c.editors[a].setValue(d, b)) }), this.refreshValue(), this.layoutEditors(), this.onChange() }, showValidationErrors: function (a) { var b = this, c = [], e = []; d(a, function (a, d) { d.path === b.path ? c.push(d) : e.push(d) }), this.error_holder && (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)) })) : 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.rows.length; a++)this.rows[a].register() }, unregister: function () { if (this._super(), this.rows) for (var a = 0; a < this.rows.length; a++)this.rows[a].unregister() }, getNumColumns: function () { var a = this.getItemInfo(0); return this.tabs_holder ? Math.max(Math.min(12, a.width + 2), 4) : a.width }, enable: function () { if (this.add_row_button && (this.add_row_button.disabled = !1), this.remove_all_rows_button && (this.remove_all_rows_button.disabled = !1), this.delete_last_row_button && (this.delete_last_row_button.disabled = !1), this.rows) for (var a = 0; a < this.rows.length; a++)this.rows[a].enable(), this.rows[a].moveup_button && (this.rows[a].moveup_button.disabled = !1), this.rows[a].movedown_button && (this.rows[a].movedown_button.disabled = !1), this.rows[a].delete_button && (this.rows[a].delete_button.disabled = !1); this._super() }, disable: function () { if (this.add_row_button && (this.add_row_button.disabled = !0), this.remove_all_rows_button && (this.remove_all_rows_button.disabled = !0), this.delete_last_row_button && (this.delete_last_row_button.disabled = !0), this.rows) for (var a = 0; a < this.rows.length; a++)this.rows[a].disable(), this.rows[a].moveup_button && (this.rows[a].moveup_button.disabled = !0), this.rows[a].movedown_button && (this.rows[a].movedown_button.disabled = !0), this.rows[a].delete_button && (this.rows[a].delete_button.disabled = !0); this._super() }, preBuild: function () { this._super(), this.rows = [], this.row_cache = [], this.hide_delete_buttons = this.options.disable_array_delete || this.jsoneditor.options.disable_array_delete, this.hide_delete_all_rows_buttons = this.hide_delete_buttons || this.options.disable_array_delete_all_rows || this.jsoneditor.options.disable_array_delete_all_rows, this.hide_delete_last_row_buttons = this.hide_delete_buttons || this.options.disable_array_delete_last_row || this.jsoneditor.options.disable_array_delete_last_row, this.hide_move_buttons = this.options.disable_array_reorder || this.jsoneditor.options.disable_array_reorder, this.hide_add_button = this.options.disable_array_add || this.jsoneditor.options.disable_array_add }, build: function () { this.options.compact ? (this.panel = this.theme.getIndentedPanel(), this.container.appendChild(this.panel), this.controls = this.theme.getButtonHolder(), this.panel.appendChild(this.controls), this.row_holder = document.createElement("div"), this.panel.appendChild(this.row_holder)) : (this.header = document.createElement("span"), this.header.textContent = this.getTitle(), this.title = this.theme.getHeader(this.header), this.container.appendChild(this.title), this.title_controls = this.theme.getHeaderButtonHolder(), this.title.appendChild(this.title_controls), this.schema.description && (this.description = this.theme.getDescription(this.schema.description), this.container.appendChild(this.description)), this.error_holder = document.createElement("div"), this.container.appendChild(this.error_holder), "tabs" === this.schema.format ? (this.controls = this.theme.getHeaderButtonHolder(), this.title.appendChild(this.controls), this.tabs_holder = this.theme.getTabHolder(), this.container.appendChild(this.tabs_holder), this.row_holder = this.theme.getTabContentHolder(this.tabs_holder), this.active_tab = null) : (this.panel = this.theme.getIndentedPanel(), this.container.appendChild(this.panel), this.row_holder = document.createElement("div"), this.panel.appendChild(this.row_holder), this.controls = this.theme.getButtonHolder(), this.panel.appendChild(this.controls))), this.addControls() }, onChildEditorChange: function (a) { this.refreshValue(), this.refreshTabs(!0), this._super(a) }, getItemTitle: function () { if (!this.item_title) if (this.schema.items && !Array.isArray(this.schema.items)) { var a = this.jsoneditor.expandRefs(this.schema.items); this.item_title = a.title || "item" } else this.item_title = "item"; return this.item_title }, getItemSchema: function (a) { return Array.isArray(this.schema.items) ? 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.length < this.schema.minItems;)a.push(this.getItemInfo(a.length).default); this.getMax() && a.length > this.getMax() && (a = a.slice(0, this.getMax())); var e = this; d(a, function (a, c) { e.rows[a] ? e.rows[a].setValue(c, b) : e.row_cache[a] ? (e.rows[a] = e.row_cache[a], e.rows[a].setValue(c, b), e.rows[a].container.style.display = "", e.rows[a].tab && (e.rows[a].tab.style.display = ""), e.rows[a].register()) : e.addRow(c, b) }); for (var f = a.length; f < e.rows.length; f++)e.destroyRow(e.rows[f]), e.rows[f] = null; e.rows = e.rows.slice(0, a.length); var g = null; d(e.rows, function (a, b) { if (b.tab === e.active_tab) return g = b.tab, !1 }), !g && e.rows.length && (g = e.rows[0].tab), e.active_tab = g, e.refreshValue(b), e.refreshTabs(!0), e.refreshTabs(), e.onChange() } }, refreshValue: function (a) { var b = this, c = this.value ? this.value.length : 0; if (this.value = [], d(this.rows, function (a, c) { b.value[a] = c.getValue() }), c !== this.value.length || a) { var e = this.schema.minItems && this.schema.minItems >= this.rows.length; d(this.rows, function (a, c) { c.movedown_button && (a === b.rows.length - 1 ? c.movedown_button.style.display = "none" : c.movedown_button.style.display = ""), c.delete_button && (e ? c.delete_button.style.display = "none" : c.delete_button.style.display = ""), 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_last_row_buttons ? this.delete_last_row_button.style.display = "none" : (this.delete_last_row_button.style.display = "", f = !0)) : (e || this.hide_delete_last_row_buttons ? this.delete_last_row_button.style.display = "none" : (this.delete_last_row_button.style.display = "", f = !0), e || this.hide_delete_all_rows_buttons ? this.remove_all_rows_button.style.display = "none" : (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.collapsed && f ? this.controls.style.display = "inline-block" : this.controls.style.display = "none" } }, addRow: function (a, b) { + var c = this, e = this.rows.length; c.rows[e] = this.getElementEditor(e), c.row_cache[e] = c.rows[e], c.tabs_holder && (c.rows[e].tab_text = document.createElement("span"), c.rows[e].tab_text.textContent = c.rows[e].getHeaderText(), c.rows[e].tab = c.theme.getTab(c.rows[e].tab_text), c.rows[e].tab.addEventListener("click", function (a) { c.active_tab = c.rows[e].tab, c.refreshTabs(), a.preventDefault(), a.stopPropagation() }), c.theme.addTab(c.tabs_holder, c.rows[e].tab)); var f = c.rows[e].title_controls || c.rows[e].array_controls; c.hide_delete_buttons || (c.rows[e].delete_button = this.getButton(c.getItemTitle(), "delete", this.translate("button_delete_row_title", [c.getItemTitle()])), c.rows[e].delete_button.className += " delete", c.rows[e].delete_button.setAttribute("data-i", e), c.rows[e].delete_button.addEventListener("click", function (a) { a.preventDefault(), a.stopPropagation(); var b = 1 * this.getAttribute("data-i"), e = c.getValue(), f = [], g = null; d(e, function (a, d) { return a === b ? void (c.rows[a].tab === c.active_tab && (c.rows[a + 1] ? g = c.rows[a].tab : a && (g = c.rows[a - 1].tab))) : void f.push(d) }), c.setValue(f), g && (c.active_tab = g, c.refreshTabs()), c.onChange(!0) }), f && f.appendChild(c.rows[e].delete_button)), e && !c.hide_move_buttons && (c.rows[e].moveup_button = this.getButton("", "moveup", this.translate("button_move_up_title")), c.rows[e].moveup_button.className += " moveup", c.rows[e].moveup_button.setAttribute("data-i", e), c.rows[e].moveup_button.addEventListener("click", function (a) { a.preventDefault(), a.stopPropagation(); var b = 1 * this.getAttribute("data-i"); if (!(b <= 0)) { var d = c.getValue(), e = d[b - 1]; d[b - 1] = d[b], d[b] = e, c.setValue(d), c.active_tab = c.rows[b - 1].tab, c.refreshTabs(), c.onChange(!0) } }), f && f.appendChild(c.rows[e].moveup_button)), c.hide_move_buttons || (c.rows[e].movedown_button = this.getButton("", "movedown", this.translate("button_move_down_title")), c.rows[e].movedown_button.className += " movedown", c.rows[e].movedown_button.setAttribute("data-i", e), c.rows[e].movedown_button.addEventListener("click", function (a) { + a.preventDefault(), a.stopPropagation(); var b = 1 * this.getAttribute("data-i"), d = c.getValue(); if (!(b >= d.length - 1)) { + var e = d[b + 1]; d[b + 1] = d[b], d[b] = e, c.setValue(d), c.active_tab = c.rows[b + 1].tab, c.refreshTabs(), c.onChange(!0); + } + }), f && f.appendChild(c.rows[e].movedown_button)), a && c.rows[e].setValue(a, b), c.refreshTabs() + }, addControls: function () { var a = this; this.collapsed = !1, this.toggle_button = this.getButton("", "collapse", this.translate("button_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", a.translate("button_collapse"))) : (a.collapsed = !0, a.row_holder.style.display = "none", a.tabs_holder && (a.tabs_holder.style.display = "none"), a.controls.style.display = "none", a.panel && (a.panel.style.display = "none"), a.setButtonText(this, "", "expand", a.translate("button_expand"))) }), this.options.collapsed && 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", this.translate("button_add_row_title", [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].setValue(a.rows[c].getDefault(), !0), a.rows[c].container.style.display = "", a.rows[c].tab && (a.rows[c].tab.style.display = ""), a.rows[c].register()) : a.addRow(), a.active_tab = a.rows[c].tab, a.refreshTabs(), a.refreshValue(), a.onChange(!0) }), a.controls.appendChild(this.add_row_button), this.delete_last_row_button = this.getButton(this.translate("button_delete_last", [this.getItemTitle()]), "delete", this.translate("button_delete_last_title", [this.getItemTitle()])), this.delete_last_row_button.addEventListener("click", function (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.onChange(!0) }), a.controls.appendChild(this.delete_last_row_button), this.remove_all_rows_button = this.getButton(this.translate("button_delete_all"), "delete", this.translate("button_delete_all_title")), this.remove_all_rows_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.setValue([]), a.onChange(!0) }), 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 = []; d(a, function (a, d) { d.path === b.path ? c.push(d) : e.push(d) }), this.error_holder && (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)) })) : 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; a < this.rows.length; a++)this.rows[a].register() }, unregister: function () { if (this._super(), this.rows) for (var a = 0; a < this.rows.length; a++)this.rows[a].unregister() }, getNumColumns: function () { return Math.max(Math.min(12, this.width), 3) }, preBuild: function () { var a = this.jsoneditor.expandRefs(this.schema.items || {}); this.item_title = a.title || "row", this.item_default = a.default || null, this.item_has_child_editors = a.properties || a.items, this.width = 12, this._super() }, build: function () { var a = this; this.table = this.theme.getTable(), this.container.appendChild(this.table), this.thead = this.theme.getTableHead(), this.table.appendChild(this.thead), this.header_row = this.theme.getTableRow(), this.thead.appendChild(this.header_row), this.row_holder = this.theme.getTableBody(), this.table.appendChild(this.row_holder); var b = this.getElementEditor(0, !0); if (this.item_default = b.getDefault(), this.width = b.getNumColumns() + 2, this.options.compact ? (this.panel = document.createElement("div"), this.container.appendChild(this.panel)) : (this.title = this.theme.getHeader(this.getTitle()), this.container.appendChild(this.title), this.title_controls = this.theme.getHeaderButtonHolder(), this.title.appendChild(this.title_controls), this.schema.description && (this.description = this.theme.getDescription(this.schema.description), this.container.appendChild(this.description)), this.panel = this.theme.getIndentedPanel(), this.container.appendChild(this.panel), this.error_holder = document.createElement("div"), this.panel.appendChild(this.error_holder)), this.panel.appendChild(this.table), this.controls = this.theme.getButtonHolder(), this.panel.appendChild(this.controls), this.item_has_child_editors) for (var c = b.getChildEditors(), d = b.property_order || Object.keys(c), e = 0; e < d.length; e++) { var f = a.theme.getTableHeaderCell(c[d[e]].getTitle()); c[d[e]].options.hidden && (f.style.display = "none"), a.header_row.appendChild(f) } else a.header_row.appendChild(a.theme.getTableHeaderCell(this.item_title)); b.destroy(), this.row_holder.innerHTML = "", this.controls_header_cell = a.theme.getTableHeaderCell(" "), a.header_row.appendChild(this.controls_header_cell), this.addControls() }, onChildEditorChange: function (a) { this.refreshValue(), this._super() }, getItemDefault: function () { return c({}, { default: this.item_default }).default }, getItemTitle: function () { return this.item_title }, getElementEditor: function (a, b) { var d = c({}, this.schema.items), e = this.jsoneditor.getEditorClass(d, this.jsoneditor), f = this.row_holder.appendChild(this.theme.getTableRow()), g = f; this.item_has_child_editors || (g = this.theme.getTableCell(), f.appendChild(g)); var h = this.jsoneditor.createEditor(e, { jsoneditor: this.jsoneditor, schema: d, container: g, path: this.path + "." + a, parent: this, compact: !0, table_row: !0 }); return h.preBuild(), b || (h.build(), h.postBuild(), h.controls_cell = f.appendChild(this.theme.getTableCell()), h.row = f, h.table_controls = this.theme.getButtonHolder(), h.controls_cell.appendChild(h.table_controls), h.table_controls.style.margin = 0, h.table_controls.style.padding = 0), h }, destroy: function () { this.innerHTML = "", 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.table && this.table.parentNode && this.table.parentNode.removeChild(this.table), this.panel && this.panel.parentNode && this.panel.parentNode.removeChild(this.panel), this.rows = this.title = this.description = this.row_holder = this.table = this.panel = null, this._super() }, setValue: function (a, b) { if (a = a || [], this.schema.minItems) for (; a.length < this.schema.minItems;)a.push(this.getItemDefault()); this.schema.maxItems && a.length > this.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 < f.rows.length; g++) { var h = f.rows[g].container; f.item_has_child_editors || f.rows[g].row.parentNode.removeChild(f.rows[g].row), f.rows[g].destroy(), h.parentNode && h.parentNode.removeChild(h), f.rows[g] = null, e = !0 } f.rows = f.rows.slice(0, a.length), f.refreshValue(), (e || b) && f.refreshRowButtons(), f.onChange() } }, refreshRowButtons: function () { var a = this, b = this.schema.minItems && this.schema.minItems >= 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) { c ? b.controls_cell.style.display = "" : b.controls_cell.style.display = "none" }), c ? this.controls_header_cell.style.display = "" : this.controls_header_cell.style.display = "none"; var e = !1; this.value.length ? 1 === this.value.length ? (this.table.style.display = "", this.remove_all_rows_button.style.display = "none", b || this.hide_delete_last_row_buttons ? this.delete_last_row_button.style.display = "none" : (this.delete_last_row_button.style.display = "", e = !0)) : (this.table.style.display = "", b || this.hide_delete_last_row_buttons ? this.delete_last_row_button.style.display = "none" : (this.delete_last_row_button.style.display = "", e = !0), b || this.hide_delete_all_rows_buttons ? this.remove_all_rows_button.style.display = "none" : (this.remove_all_rows_button.style.display = "", e = !0)) : (this.delete_last_row_button.style.display = "none", this.remove_all_rows_button.style.display = "none", this.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), e ? this.controls.style.display = "" : this.controls.style.display = "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", this.translate("button_delete_row_title_short")), 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.onChange(!0) }), e.appendChild(b.rows[c].delete_button)), c && !this.hide_move_buttons && (b.rows[c].moveup_button = this.getButton("", "moveup", this.translate("button_move_up_title")), b.rows[c].moveup_button.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 (!(c <= 0)) { var d = b.getValue(), e = d[c - 1]; d[c - 1] = d[c], d[c] = e, b.setValue(d), b.onChange(!0) } }), e.appendChild(b.rows[c].moveup_button)), this.hide_move_buttons || (b.rows[c].movedown_button = this.getButton("", "movedown", this.translate("button_move_down_title")), b.rows[c].movedown_button.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.onChange(!0) } }), e.appendChild(b.rows[c].movedown_button)), a && b.rows[c].setValue(a) }, addControls: function () { var a = this; this.collapsed = !1, this.toggle_button = this.getButton("", "collapse", this.translate("button_collapse")), this.title_controls && (this.title_controls.appendChild(this.toggle_button), this.toggle_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.collapsed ? (a.collapsed = !1, a.panel.style.display = "", a.setButtonText(this, "", "collapse", a.translate("button_collapse"))) : (a.collapsed = !0, a.panel.style.display = "none", a.setButtonText(this, "", "expand", a.translate("button_expand"))) }), this.options.collapsed && 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", this.translate("button_add_row_title", [this.getItemTitle()])), this.add_row_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.addRow(), a.refreshValue(), a.refreshRowButtons(), a.onChange(!0) }), a.controls.appendChild(this.add_row_button), this.delete_last_row_button = this.getButton(this.translate("button_delete_last", [this.getItemTitle()]), "delete", this.translate("button_delete_last_title", [this.getItemTitle()])), this.delete_last_row_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(); var c = a.getValue(); c.pop(), a.setValue(c), a.onChange(!0) }), a.controls.appendChild(this.delete_last_row_button), this.remove_all_rows_button = this.getButton(this.translate("button_delete_all"), "delete", this.translate("button_delete_all_title")), this.remove_all_rows_button.addEventListener("click", function (b) { b.preventDefault(), b.stopPropagation(), a.setValue([]), a.onChange(!0) }), a.controls.appendChild(this.remove_all_rows_button) } }), f.defaults.editors.multiple = f.AbstractEditor.extend({ register: function () { if (this.editors) { for (var a = 0; a < this.editors.length; a++)this.editors[a] && this.editors[a].unregister(); this.editors[this.type] && this.editors[this.type].register() } this._super() }, unregister: function () { if (this._super(), this.editors) for (var a = 0; a < this.editors.length; a++)this.editors[a] && this.editors[a].unregister() }, getNumColumns: function () { return this.editors[this.type] ? Math.max(this.editors[this.type].getNumColumns(), 4) : 4 }, enable: function () { if (this.editors) for (var a = 0; a < this.editors.length; a++)this.editors[a] && this.editors[a].enable(); this.switcher.disabled = !1, this._super() }, disable: function () { if (this.editors) for (var a = 0; a < this.editors.length; a++)this.editors[a] && this.editors[a].disable(); this.switcher.disabled = !0, this._super() }, switchEditor: function (a) { var b = this; this.editors[a] || this.buildChildEditor(a); var c = b.getValue(); b.type = a, b.register(), d(b.editors, function (a, d) { d && (b.type === a ? (b.keep_values && d.setValue(c, !0), d.container.style.display = "") : d.container.style.display = "none") }), b.refreshValue(), b.refreshHeaderText() }, buildChildEditor: function (a) { var b = this, d = this.types[a], e = b.theme.getChildEditorHolder(); b.editor_holder.appendChild(e); var f; "string" == typeof d ? (f = c({}, b.schema), f.type = d) : (f = c({}, b.schema, d), f = b.jsoneditor.expandRefs(f), d.required && Array.isArray(d.required) && b.schema.required && Array.isArray(b.schema.required) && (f.required = b.schema.required.concat(d.required))); var g = b.jsoneditor.getEditorClass(f); b.editors[a] = b.jsoneditor.createEditor(g, { jsoneditor: b.jsoneditor, schema: f, container: e, path: b.path, parent: b, required: !0 }), b.editors[a].preBuild(), b.editors[a].build(), b.editors[a].postBuild(), b.editors[a].header && (b.editors[a].header.style.display = "none"), b.editors[a].option = b.switcher_options[a], e.addEventListener("change_header_text", function () { b.refreshHeaderText() }), a !== b.type && (e.style.display = "none") }, preBuild: function () { if (this.types = [], this.type = 0, this.editors = [], this.validators = [], this.keep_values = !0, "undefined" != typeof this.jsoneditor.options.keep_oneof_values && (this.keep_values = this.jsoneditor.options.keep_oneof_values), "undefined" != typeof this.options.keep_oneof_values && (this.keep_values = this.options.keep_oneof_values), this.schema.oneOf) this.oneOf = !0, this.types = this.schema.oneOf, delete this.schema.oneOf; else if (this.schema.anyOf) this.anyOf = !0, this.types = this.schema.anyOf, delete this.schema.anyOf; else { if (this.schema.type && "any" !== this.schema.type) Array.isArray(this.schema.type) ? this.types = this.schema.type : this.types = [this.schema.type]; else if (this.types = ["string", "number", "integer", "boolean", "object", "array", "null"], this.schema.disallow) { var a = this.schema.disallow; "object" == typeof a && Array.isArray(a) || (a = [a]); var b = []; d(this.types, function (c, d) { a.indexOf(d) === -1 && b.push(d) }), this.types = b } delete this.schema.type } this.display_text = this.getDisplayText(this.types) }, build: function () { var a = this, b = this.container; this.header = this.label = this.theme.getFormInputLabel(this.getTitle()), this.container.appendChild(this.header), this.switcher = this.theme.getSwitcher(this.display_text), b.appendChild(this.switcher), this.switcher.addEventListener("change", function (b) { b.preventDefault(), b.stopPropagation(), a.switchEditor(a.display_text.indexOf(this.value)), a.onChange(!0) }), this.editor_holder = document.createElement("div"), b.appendChild(this.editor_holder); var e = {}; a.jsoneditor.options.custom_validators && (e.custom_validators = a.jsoneditor.options.custom_validators), this.switcher_options = this.theme.getSwitcherOptions(this.switcher), d(this.types, function (b, d) { a.editors[b] = !1; var g; "string" == typeof d ? (g = c({}, a.schema), g.type = d) : (g = c({}, a.schema, d), d.required && Array.isArray(d.required) && a.schema.required && Array.isArray(a.schema.required) && (g.required = a.schema.required.concat(d.required))), a.validators[b] = new f.Validator(a.jsoneditor, g, e) }), this.switchEditor(0) }, onChildEditorChange: function (a) { this.editors[this.type] && (this.refreshValue(), this.refreshHeaderText()), this._super() }, refreshHeaderText: function () { var a = this.getDisplayText(this.types); d(this.switcher_options, function (b, c) { c.textContent = a[b] }) }, refreshValue: function () { this.value = this.editors[this.type].getValue() }, setValue: function (a, b) { var c = this; d(this.validators, function (b, d) { if (!d.validate(a).length) return c.type = b, c.switcher.value = c.display_text[b], !1 }), this.switchEditor(this.type), this.editors[this.type].setValue(a, b), this.refreshValue(), c.onChange() }, destroy: function () { d(this.editors, function (a, b) { b && b.destroy() }), this.editor_holder && this.editor_holder.parentNode && this.editor_holder.parentNode.removeChild(this.editor_holder), this.switcher && this.switcher.parentNode && this.switcher.parentNode.removeChild(this.switcher), this._super() }, showValidationErrors: function (a) { var b = this; if (this.oneOf || this.anyOf) { var e = this.oneOf ? "oneOf" : "anyOf"; d(this.editors, function (f, g) { if (g) { var h = b.path + "." + e + "[" + f + "]", i = []; d(a, function (a, d) { if (d.path.substr(0, h.length) === h) { var e = c({}, d); e.path = b.path + e.path.substr(h.length), i.push(e) } }), g.showValidationErrors(i) } }) } else d(this.editors, function (b, c) { c && c.showValidationErrors(a) }) } }), f.defaults.editors.enum = f.AbstractEditor.extend({ getNumColumns: function () { return 4 }, build: function () { this.container, this.title = this.header = this.label = this.theme.getFormInputLabel(this.getTitle()), this.container.appendChild(this.title), this.options.enum_titles = this.options.enum_titles || [], this.enum = this.schema.enum, this.selected = 0, this.select_options = [], this.html_values = []; for (var a = this, b = 0; b < this.enum.length; b++)this.select_options[b] = this.options.enum_titles[b] || "Value " + (b + 1), this.html_values[b] = this.getHTML(this.enum[b]); this.switcher = this.theme.getSwitcher(this.select_options), this.container.appendChild(this.switcher), this.display_area = this.theme.getIndentedPanel(), this.container.appendChild(this.display_area), this.options.hide_display && (this.display_area.style.display = "none"), this.switcher.addEventListener("change", function () { a.selected = a.select_options.indexOf(this.value), a.value = a.enum[a.selected], a.refreshValue(), a.onChange(!0) }), this.value = this.enum[0], this.refreshValue(), 1 === this.enum.length && (this.switcher.style.display = "none") }, refreshValue: function () { var a = this; a.selected = -1; var b = JSON.stringify(this.value); return d(this.enum, function (c, d) { if (b === JSON.stringify(d)) return a.selected = c, !1 }), a.selected < 0 ? void a.setValue(a.enum[0]) : (this.switcher.value = this.select_options[this.selected], void (this.display_area.innerHTML = this.html_values[this.selected])) }, enable: function () { this.always_disabled || (this.switcher.disabled = !1), this._super() }, disable: function () { this.switcher.disabled = !0, this._super() }, getHTML: function (a) { var b = this; if (null === a) return "null"; 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.onChange()) }, destroy: function () { this.display_area && this.display_area.parentNode && this.display_area.parentNode.removeChild(this.display_area), this.title && this.title.parentNode && this.title.parentNode.removeChild(this.title), this.switcher && this.switcher.parentNode && this.switcher.parentNode.removeChild(this.switcher), this._super() } }), f.defaults.editors.select = f.AbstractEditor.extend({ setValue: function (a, b) { a = this.typecast(a || ""); var c = a; this.enum_values.indexOf(c) < 0 && (c = this.enum_values[0]), this.value !== c && (this.input.value = this.enum_options[this.enum_values.indexOf(c)], this.select2 && this.select2.select2("val", this.input.value), this.value = c, this.onChange()) }, register: function () { this._super(), this.input && this.input.setAttribute("name", this.formname) }, unregister: function () { this._super(), this.input && this.input.removeAttribute("name") }, getNumColumns: function () { if (!this.enum_options) return 3; for (var a = this.getTitle().length, b = 0; b < this.enum_options.length; b++)a = Math.max(a, this.enum_options[b].length + 4); return Math.min(12, Math.max(a / 7, 2)) }, typecast: function (a) { return "boolean" === this.schema.type ? !!a : "number" === this.schema.type ? 1 * a : "integer" === this.schema.type ? Math.floor(1 * a) : "" + a }, getValue: function () { return this.value }, preBuild: function () { var a = this; this.input_type = "select", this.enum_options = [], this.enum_values = [], this.enum_display = []; var b; if (this.schema.enum) { var e = this.schema.options && this.schema.options.enum_titles || []; d(this.schema.enum, function (b, c) { a.enum_options[b] = "" + c, a.enum_display[b] = "" + (e[b] || c), a.enum_values[b] = a.typecast(c) }), this.isRequired() || (a.enum_display.unshift(" "), a.enum_options.unshift("undefined"), a.enum_values.unshift(void 0)) } else if ("boolean" === this.schema.type) a.enum_display = this.schema.options && this.schema.options.enum_titles || ["true", "false"], a.enum_options = ["1", ""], a.enum_values = [!0, !1], this.isRequired() || (a.enum_display.unshift(" "), a.enum_options.unshift("undefined"), a.enum_values.unshift(void 0)); else { if (!this.schema.enumSource) throw "'select' editor requires the enum property to be set."; if (this.enumSource = [], this.enum_display = [], this.enum_options = [], this.enum_values = [], Array.isArray(this.schema.enumSource)) for (b = 0; b < this.schema.enumSource.length; b++)"string" == typeof this.schema.enumSource[b] ? this.enumSource[b] = { source: this.schema.enumSource[b] } : Array.isArray(this.schema.enumSource[b]) ? this.enumSource[b] = this.schema.enumSource[b] : this.enumSource[b] = c({}, this.schema.enumSource[b]); else this.schema.enumValue ? this.enumSource = [{ source: this.schema.enumSource, value: this.schema.enumValue }] : this.enumSource = [{ source: this.schema.enumSource }]; for (b = 0; b < this.enumSource.length; b++)this.enumSource[b].value && (this.enumSource[b].value = this.jsoneditor.compileTemplate(this.enumSource[b].value, this.template_engine)), this.enumSource[b].title && (this.enumSource[b].title = this.jsoneditor.compileTemplate(this.enumSource[b].title, this.template_engine)), this.enumSource[b].filter && (this.enumSource[b].filter = this.jsoneditor.compileTemplate(this.enumSource[b].filter, this.template_engine)) } }, build: function () { var a = this; this.options.compact || (this.header = this.label = this.theme.getFormInputLabel(this.getTitle())), this.schema.description && (this.description = this.theme.getFormInputDescription(this.schema.description)), this.options.compact && (this.container.className += " compact"), this.input = this.theme.getSelectInput(this.enum_options), this.theme.setSelectOptions(this.input, this.enum_options, this.enum_display), (this.schema.readOnly || this.schema.readonly) && (this.always_disabled = !0, this.input.disabled = !0), this.input.addEventListener("change", function (b) { b.preventDefault(), b.stopPropagation(), a.onInputChange() }), this.control = this.theme.getFormControl(this.label, this.input, this.description), this.container.appendChild(this.control), this.value = this.enum_values[0] }, onInputChange: function () { var a, b = this.input.value; a = this.enum_options.indexOf(b) === -1 ? this.enum_values[0] : this.enum_values[this.enum_options.indexOf(b)], a !== this.value && (this.value = a, this.onChange(!0)) }, setupSelect2: function () { if (window.jQuery && window.jQuery.fn && window.jQuery.fn.select2 && (this.enum_options.length > 2 || this.enum_options.length && this.enumSource)) { var a = c({}, f.plugins.select2); this.schema.options && this.schema.options.select2_options && (a = c(a, this.schema.options.select2_options)), this.select2 = window.jQuery(this.input).select2(a); var b = this; this.select2.on("select2-blur", function () { b.input.value = b.select2.select2("val"), b.onInputChange() }), this.select2.on("change", function () { b.input.value = b.select2.select2("val"), b.onInputChange() }) } else this.select2 = null }, postBuild: function () { this._super(), this.theme.afterInputReady(this.input), this.setupSelect2() }, onWatchedFieldChange: function () { var a, b; if (this.enumSource) { a = this.getWatchedFieldValues(); for (var c = [], d = [], e = 0; e < this.enumSource.length; e++)if (Array.isArray(this.enumSource[e])) c = c.concat(this.enumSource[e]), d = d.concat(this.enumSource[e]); else { var f = []; if (f = Array.isArray(this.enumSource[e].source) ? this.enumSource[e].source : a[this.enumSource[e].source]) { if (this.enumSource[e].slice && (f = Array.prototype.slice.apply(f, this.enumSource[e].slice)), this.enumSource[e].filter) { var g = []; for (b = 0; b < f.length; b++)this.enumSource[e].filter({ i: b, item: f[b], watched: a }) && g.push(f[b]); f = g } var h = [], i = []; for (b = 0; b < f.length; b++) { var j = f[b]; this.enumSource[e].value ? i[b] = this.enumSource[e].value({ i: b, item: j }) : i[b] = f[b], this.enumSource[e].title ? h[b] = this.enumSource[e].title({ i: b, item: j }) : h[b] = i[b] } c = c.concat(i), d = d.concat(h) } } var k = this.value; this.theme.setSelectOptions(this.input, c, d), this.enum_options = c, this.enum_display = d, this.enum_values = c, this.select2 && this.select2.select2("destroy"), c.indexOf(k) !== -1 ? (this.input.value = k, this.value = k) : (this.input.value = c[0], this.value = c[0] || "", this.parent ? this.parent.onChildEditorChange(this) : this.jsoneditor.onChange(), this.jsoneditor.notifyWatchers(this.path)), this.setupSelect2() } this._super() }, enable: function () { this.always_disabled || (this.input.disabled = !1, this.select2 && this.select2.select2("enable", !0)), this._super() }, disable: function () { this.input.disabled = !0, this.select2 && this.select2.select2("enable", !1), 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.select2 && (this.select2.select2("destroy"), this.select2 = null), this._super() } }), f.defaults.editors.selectize = f.AbstractEditor.extend({ + setValue: function (a, b) { a = this.typecast(a || ""); var c = a; this.enum_values.indexOf(c) < 0 && (c = this.enum_values[0]), this.value !== c && (this.input.value = this.enum_options[this.enum_values.indexOf(c)], this.selectize && this.selectize[0].selectize.addItem(c), this.value = c, this.onChange()) }, register: function () { this._super(), this.input && this.input.setAttribute("name", this.formname) }, unregister: function () { this._super(), this.input && this.input.removeAttribute("name") }, getNumColumns: function () { if (!this.enum_options) return 3; for (var a = this.getTitle().length, b = 0; b < this.enum_options.length; b++)a = Math.max(a, this.enum_options[b].length + 4); return Math.min(12, Math.max(a / 7, 2)) }, typecast: function (a) { return "boolean" === this.schema.type ? !!a : "number" === this.schema.type ? 1 * a : "integer" === this.schema.type ? Math.floor(1 * a) : "" + a }, getValue: function () { return this.value }, preBuild: function () { var a = this; this.input_type = "select", this.enum_options = [], this.enum_values = [], this.enum_display = []; var b; if (this.schema.enum) { var e = this.schema.options && this.schema.options.enum_titles || []; d(this.schema.enum, function (b, c) { a.enum_options[b] = "" + c, a.enum_display[b] = "" + (e[b] || c), a.enum_values[b] = a.typecast(c) }) } else if ("boolean" === this.schema.type) a.enum_display = this.schema.options && this.schema.options.enum_titles || ["true", "false"], a.enum_options = ["1", "0"], a.enum_values = [!0, !1]; else { if (!this.schema.enumSource) throw "'select' editor requires the enum property to be set."; if (this.enumSource = [], this.enum_display = [], this.enum_options = [], this.enum_values = [], Array.isArray(this.schema.enumSource)) for (b = 0; b < this.schema.enumSource.length; b++)"string" == typeof this.schema.enumSource[b] ? this.enumSource[b] = { source: this.schema.enumSource[b] } : Array.isArray(this.schema.enumSource[b]) ? this.enumSource[b] = this.schema.enumSource[b] : this.enumSource[b] = c({}, this.schema.enumSource[b]); else this.schema.enumValue ? this.enumSource = [{ source: this.schema.enumSource, value: this.schema.enumValue }] : this.enumSource = [{ source: this.schema.enumSource }]; for (b = 0; b < this.enumSource.length; b++)this.enumSource[b].value && (this.enumSource[b].value = this.jsoneditor.compileTemplate(this.enumSource[b].value, this.template_engine)), this.enumSource[b].title && (this.enumSource[b].title = this.jsoneditor.compileTemplate(this.enumSource[b].title, this.template_engine)), this.enumSource[b].filter && (this.enumSource[b].filter = this.jsoneditor.compileTemplate(this.enumSource[b].filter, this.template_engine)) } }, build: function () { var a = this; this.options.compact || (this.header = this.label = this.theme.getFormInputLabel(this.getTitle())), this.schema.description && (this.description = this.theme.getFormInputDescription(this.schema.description)), this.options.compact && (this.container.className += " compact"), this.input = this.theme.getSelectInput(this.enum_options), this.theme.setSelectOptions(this.input, this.enum_options, this.enum_display), (this.schema.readOnly || this.schema.readonly) && (this.always_disabled = !0, this.input.disabled = !0), this.input.addEventListener("change", function (b) { b.preventDefault(), b.stopPropagation(), a.onInputChange() }), this.control = this.theme.getFormControl(this.label, this.input, this.description), this.container.appendChild(this.control), this.value = this.enum_values[0] }, onInputChange: function () { var a = this.input.value, b = a; this.enum_options.indexOf(a) === -1 && (b = this.enum_options[0]), this.value = this.enum_values[this.enum_options.indexOf(a)], this.onChange(!0) }, setupSelectize: function () { var a = this; if (window.jQuery && window.jQuery.fn && window.jQuery.fn.selectize && (this.enum_options.length >= 2 || this.enum_options.length && this.enumSource)) { var b = c({}, f.plugins.selectize); this.schema.options && this.schema.options.selectize_options && (b = c(b, this.schema.options.selectize_options)), this.selectize = window.jQuery(this.input).selectize(c(b, { create: !0, onChange: function () { a.onInputChange() } })) } else this.selectize = null }, postBuild: function () { this._super(), this.theme.afterInputReady(this.input), this.setupSelectize() }, onWatchedFieldChange: function () { var a, b; if (this.enumSource) { a = this.getWatchedFieldValues(); for (var c = [], d = [], e = 0; e < this.enumSource.length; e++)if (Array.isArray(this.enumSource[e])) c = c.concat(this.enumSource[e]), d = d.concat(this.enumSource[e]); else if (a[this.enumSource[e].source]) { var f = a[this.enumSource[e].source]; if (this.enumSource[e].slice && (f = Array.prototype.slice.apply(f, this.enumSource[e].slice)), this.enumSource[e].filter) { var g = []; for (b = 0; b < f.length; b++)this.enumSource[e].filter({ i: b, item: f[b] }) && g.push(f[b]); f = g } var h = [], i = []; for (b = 0; b < f.length; b++) { var j = f[b]; this.enumSource[e].value ? i[b] = this.enumSource[e].value({ i: b, item: j }) : i[b] = f[b], this.enumSource[e].title ? h[b] = this.enumSource[e].title({ i: b, item: j }) : h[b] = i[b] } c = c.concat(i), d = d.concat(h) } var k = this.value; this.theme.setSelectOptions(this.input, c, d), this.enum_options = c, this.enum_display = d, this.enum_values = c, c.indexOf(k) !== -1 ? (this.input.value = k, this.value = k) : (this.input.value = c[0], this.value = c[0] || "", this.parent ? this.parent.onChildEditorChange(this) : this.jsoneditor.onChange(), this.jsoneditor.notifyWatchers(this.path)), this.selectize ? this.updateSelectizeOptions(c) : this.setupSelectize(), this._super() } }, updateSelectizeOptions: function (a) { + var b = this.selectize[0].selectize, c = this; b.off(), b.clearOptions(); for (var d in a) b.addOption({ value: a[d], text: a[d] }); b.addItem(this.value), b.on("change", function () { + c.onInputChange(); + }) + }, enable: function () { this.always_disabled || (this.input.disabled = !1, this.selectize && this.selectize[0].selectize.unlock()), this._super() }, disable: function () { this.input.disabled = !0, this.selectize && this.selectize[0].selectize.lock(), 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.selectize && (this.selectize[0].selectize.destroy(), this.selectize = null), this._super() } + }), f.defaults.editors.multiselect = f.AbstractEditor.extend({ preBuild: function () { this._super(); var a; this.select_options = {}, this.select_values = {}; var b = this.jsoneditor.expandRefs(this.schema.items || {}), c = b.enum || [], d = b.options ? b.options.enum_titles || [] : []; for (this.option_keys = [], this.option_titles = [], a = 0; a < c.length; a++)this.sanitize(c[a]) === c[a] && (this.option_keys.push(c[a] + ""), this.option_titles.push((d[a] || c[a]) + ""), this.select_values[c[a] + ""] = c[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.schema.format && this.option_keys.length < 8 || "checkbox" === this.schema.format) { for (this.input_type = "checkboxes", this.inputs = {}, this.controls = {}, a = 0; a < this.option_keys.length; a++) { this.inputs[this.option_keys[a]] = this.theme.getCheckbox(), this.select_options[this.option_keys[a]] = this.inputs[this.option_keys[a]]; var c = this.theme.getCheckboxLabel(this.option_titles[a]); this.controls[this.option_keys[a]] = this.theme.getFormControl(c, this.inputs[this.option_keys[a]]) } this.control = this.theme.getMultiCheckboxHolder(this.controls, this.label, this.description) } else { for (this.input_type = "select", this.input = this.theme.getSelectInput(this.option_keys), this.theme.setSelectOptions(this.input, this.option_keys, this.option_titles), this.input.multiple = !0, this.input.size = Math.min(10, this.option_keys.length), a = 0; a < this.option_keys.length; a++)this.select_options[this.option_keys[a]] = this.input.children[a]; (this.schema.readOnly || this.schema.readonly) && (this.always_disabled = !0, this.input.disabled = !0), this.control = this.theme.getFormControl(this.label, this.input, this.description) } this.container.appendChild(this.control), this.control.addEventListener("change", function (c) { c.preventDefault(), c.stopPropagation(); var d = []; for (a = 0; a < b.option_keys.length; a++)(b.select_options[b.option_keys[a]].selected || b.select_options[b.option_keys[a]].checked) && d.push(b.select_values[b.option_keys[a]]); b.updateValue(d), b.onChange(!0) }) }, setValue: function (a, b) { var c; for (a = a || [], "object" != typeof a ? a = [a] : Array.isArray(a) || (a = []), c = 0; c < a.length; c++)"string" != typeof a[c] && (a[c] += ""); for (c in this.select_options) this.select_options.hasOwnProperty(c) && (this.select_options[c]["select" === this.input_type ? "selected" : "checked"] = a.indexOf(c) !== -1); this.updateValue(a), this.onChange() }, setupSelect2: function () { if (window.jQuery && window.jQuery.fn && window.jQuery.fn.select2) { var a = window.jQuery.extend({}, f.plugins.select2); this.schema.options && this.schema.options.select2_options && (a = c(a, this.schema.options.select2_options)), this.select2 = window.jQuery(this.input).select2(a); var b = this; this.select2.on("select2-blur", function () { var a = b.select2.select2("val"); b.value = a, b.onChange(!0) }) } else this.select2 = null }, onInputChange: function () { this.value = this.input.value, this.onChange(!0) }, postBuild: function () { this._super(), this.setupSelect2() }, register: function () { this._super(), this.input && this.input.setAttribute("name", this.formname) }, unregister: function () { this._super(), this.input && this.input.removeAttribute("name") }, getNumColumns: function () { var a = this.getTitle().length; for (var b in this.select_values) this.select_values.hasOwnProperty(b) && (a = Math.max(a, (this.select_values[b] + "").length + 4)); return Math.min(12, Math.max(a / 7, 2)) }, updateValue: function (a) { for (var b = !1, c = [], d = 0; d < a.length; d++)if (this.select_options[a[d] + ""]) { var e = this.sanitize(this.select_values[a[d]]); c.push(e), e !== a[d] && (b = !0) } else b = !0; return this.value = c, this.select2 && this.select2.select2("val", this.value), b }, sanitize: function (a) { return "number" === this.schema.items.type ? 1 * a : "integer" === this.schema.items.type ? Math.floor(1 * a) : "" + a }, enable: function () { if (!this.always_disabled) { if (this.input) this.input.disabled = !1; else if (this.inputs) for (var a in this.inputs) this.inputs.hasOwnProperty(a) && (this.inputs[a].disabled = !1); this.select2 && this.select2.select2("enable", !0) } this._super() }, disable: function () { if (this.input) this.input.disabled = !0; else if (this.inputs) for (var a in this.inputs) this.inputs.hasOwnProperty(a) && (this.inputs[a].disabled = !0); this.select2 && this.select2.select2("enable", !1), this._super() }, destroy: function () { this.select2 && (this.select2.select2("destroy"), this.select2 = null), this._super() } }), f.defaults.editors.base64 = f.AbstractEditor.extend({ getNumColumns: function () { return 4 }, build: function () { var a = this; if (this.title = this.header = this.label = this.theme.getFormInputLabel(this.getTitle()), this.input = this.theme.getFormInputField("hidden"), this.container.appendChild(this.input), !this.schema.readOnly && !this.schema.readonly) { if (!window.FileReader) throw "FileReader required for base64 editor"; this.uploader = this.theme.getFormInputField("file"), this.uploader.addEventListener("change", function (b) { if (b.preventDefault(), b.stopPropagation(), this.files && this.files.length) { var c = new FileReader; c.onload = function (b) { a.value = b.target.result, a.refreshPreview(), a.onChange(!0), c = null }, c.readAsDataURL(this.files[0]) } }) } this.preview = this.theme.getFormInputDescription(this.schema.description), this.container.appendChild(this.preview), this.control = this.theme.getFormControl(this.label, this.uploader || this.input, this.preview), this.container.appendChild(this.control) }, refreshPreview: function () { if (this.last_preview !== this.value && (this.last_preview = this.value, this.preview.innerHTML = "", this.value)) { var a = this.value.match(/^data:([^;,]+)[;,]/); if (a && (a = a[1]), a) { if (this.preview.innerHTML = "Type: " + 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.onChange()) }, destroy: function () { this.preview && this.preview.parentNode && this.preview.parentNode.removeChild(this.preview), this.title && this.title.parentNode && this.title.parentNode.removeChild(this.title), this.input && this.input.parentNode && this.input.parentNode.removeChild(this.input), this.uploader && this.uploader.parentNode && this.uploader.parentNode.removeChild(this.uploader), this._super() } }), f.defaults.editors.upload = f.AbstractEditor.extend({ getNumColumns: function () { return 4 }, build: function () { var a = this; if (this.title = this.header = this.label = this.theme.getFormInputLabel(this.getTitle()), this.input = this.theme.getFormInputField("hidden"), this.container.appendChild(this.input), !this.schema.readOnly && !this.schema.readonly) { if (!this.jsoneditor.options.upload) throw "Upload handler required for upload editor"; this.uploader = this.theme.getFormInputField("file"), this.uploader.addEventListener("change", function (b) { if (b.preventDefault(), b.stopPropagation(), this.files && this.files.length) { var c = new FileReader; c.onload = function (b) { a.preview_value = b.target.result, a.refreshPreview(), a.onChange(!0), c = null }, c.readAsDataURL(this.files[0]) } }) } var b = this.schema.description; b || (b = ""), this.preview = this.theme.getFormInputDescription(b), this.container.appendChild(this.preview), this.control = this.theme.getFormControl(this.label, this.uploader || this.input, this.preview), this.container.appendChild(this.control) }, refreshPreview: function () { if (this.last_preview !== this.preview_value && (this.last_preview = this.preview_value, this.preview.innerHTML = "", this.preview_value)) { var a = this, b = this.preview_value.match(/^data:([^;,]+)[;,]/); b && (b = b[1]), b || (b = "unknown"); var c = this.uploader.files[0]; if (this.preview.innerHTML = "Type: " + b + ", Size: " + c.size + " bytes", "image" === b.substr(0, 5)) { this.preview.innerHTML += "
    "; var d = document.createElement("img"); d.style.maxWidth = "100%", d.style.maxHeight = "100px", d.src = this.preview_value, this.preview.appendChild(d) } this.preview.innerHTML += "
    "; var e = this.getButton("Upload", "upload", "Upload"); this.preview.appendChild(e), e.addEventListener("click", function (b) { b.preventDefault(), e.setAttribute("disabled", "disabled"), a.theme.removeInputError(a.uploader), a.theme.getProgressBar && (a.progressBar = a.theme.getProgressBar(), a.preview.appendChild(a.progressBar)), a.jsoneditor.options.upload(a.path, c, { success: function (b) { a.setValue(b), a.parent ? a.parent.onChildEditorChange(a) : a.jsoneditor.onChange(), a.progressBar && a.preview.removeChild(a.progressBar), e.removeAttribute("disabled") }, failure: function (b) { a.theme.addInputError(a.uploader, b), a.progressBar && a.preview.removeChild(a.progressBar), e.removeAttribute("disabled") }, updateProgress: function (b) { a.progressBar && (b ? a.theme.updateProgressBar(a.progressBar, b) : a.theme.updateProgressBarUnknown(a.progressBar)) } }) }) } }, 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.onChange()) }, destroy: function () { this.preview && this.preview.parentNode && this.preview.parentNode.removeChild(this.preview), this.title && this.title.parentNode && this.title.parentNode.removeChild(this.title), this.input && this.input.parentNode && this.input.parentNode.removeChild(this.input), this.uploader && this.uploader.parentNode && this.uploader.parentNode.removeChild(this.uploader), this._super() } }), f.defaults.editors.checkbox = f.AbstractEditor.extend({ setValue: function (a, b) { this.value = !!a, this.input.checked = this.value, this.onChange() }, register: function () { this._super(), this.input && this.input.setAttribute("name", this.formname) }, unregister: function () { this._super(), this.input && this.input.removeAttribute("name") }, getNumColumns: function () { return Math.min(12, Math.max(this.getTitle().length / 7, 2)) }, build: function () { var a = this; this.options.compact || (this.label = this.header = this.theme.getCheckboxLabel(this.getTitle())), this.schema.description && (this.description = this.theme.getFormInputDescription(this.schema.description)), this.options.compact && (this.container.className += " compact"), this.input = this.theme.getCheckbox(), this.control = this.theme.getFormControl(this.label, this.input, this.description), (this.schema.readOnly || this.schema.readonly) && (this.always_disabled = !0, this.input.disabled = !0), this.input.addEventListener("change", function (b) { b.preventDefault(), b.stopPropagation(), a.value = this.checked, a.onChange(!0) }), this.container.appendChild(this.control) }, enable: function () { this.always_disabled || (this.input.disabled = !1), this._super() }, disable: function () { 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.arraySelectize = f.AbstractEditor.extend({ build: function () { this.title = this.theme.getFormInputLabel(this.getTitle()), this.title_controls = this.theme.getHeaderButtonHolder(), this.title.appendChild(this.title_controls), this.error_holder = document.createElement("div"), this.schema.description && (this.description = this.theme.getDescription(this.schema.description)), this.input = document.createElement("select"), this.input.setAttribute("multiple", "multiple"); var a = this.theme.getFormControl(this.title, this.input, this.description); this.container.appendChild(a), this.container.appendChild(this.error_holder), window.jQuery(this.input).selectize({ delimiter: !1, createOnBlur: !0, create: !0 }) }, postBuild: function () { var a = this; this.input.selectize.on("change", function (b) { a.refreshValue(), a.onChange(!0) }) }, destroy: function () { this.empty(!0), this.title && this.title.parentNode && this.title.parentNode.removeChild(this.title), this.description && this.description.parentNode && this.description.parentNode.removeChild(this.description), this.input && this.input.parentNode && this.input.parentNode.removeChild(this.input), this._super() }, empty: function (a) { }, setValue: function (a, b) { var c = this; a = a || [], Array.isArray(a) || (a = [a]), this.input.selectize.clearOptions(), this.input.selectize.clear(!0), a.forEach(function (a) { c.input.selectize.addOption({ text: a, value: a }) }), this.input.selectize.setValue(a), this.refreshValue(b) }, refreshValue: function (a) { this.value = this.input.selectize.getValue() }, showValidationErrors: function (a) { var b = this, c = [], e = []; d(a, function (a, d) { d.path === b.path ? c.push(d) : e.push(d) }), this.error_holder && (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)) })) : this.error_holder.style.display = "none") } }); var g = function () { var a = document.documentElement; return a.matches ? "matches" : a.webkitMatchesSelector ? "webkitMatchesSelector" : a.mozMatchesSelector ? "mozMatchesSelector" : a.msMatchesSelector ? "msMatchesSelector" : a.oMatchesSelector ? "oMatchesSelector" : void 0 }(); 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 (a, b) { }, getLink: function (a) { var b = document.createElement("a"); return b.setAttribute("href", "#"), b.appendChild(document.createTextNode(a)), b }, disableHeader: function (a) { a.style.color = "#ccc" }, disableLabel: function (a) { a.style.color = "#ccc" }, enableHeader: function (a) { a.style.color = "" }, enableLabel: function (a) { a.style.color = "" }, getFormInputLabel: function (a) { var b = document.createElement("label"); return b.appendChild(document.createTextNode(a)), b }, getCheckboxLabel: function (a) { var b = this.getFormInputLabel(a); return b.style.fontWeight = "normal", b }, getHeader: function (a) { var b = document.createElement("h3"); return "string" == typeof a ? b.textContent = a : b.appendChild(a), b }, getCheckbox: function () { var a = this.getFormInputField("checkbox"); return a.style.display = "inline-block", a.style.width = "auto", a }, getMultiCheckboxHolder: function (a, b, c) { var d = document.createElement("div"); b && (b.style.display = "block", d.appendChild(b)); for (var e in a) a.hasOwnProperty(e) && (a[e].style.display = "inline-block", a[e].style.marginRight = "20px", d.appendChild(a[e])); return c && d.appendChild(c), d }, getSelectInput: function (a) { var b = document.createElement("select"); return a && this.setSelectOptions(b, a), b }, getSwitcher: function (a) { var b = this.getSelectInput(a); return b.style.backgroundColor = "transparent", b.style.display = "inline-block", b.style.fontStyle = "italic", b.style.fontWeight = "normal", b.style.height = "auto", b.style.marginBottom = 0, b.style.marginLeft = "5px", b.style.padding = "0 0 0 3px", b.style.width = "auto", b }, getSwitcherOptions: function (a) { return a.getElementsByTagName("option") }, setSwitcherOptions: function (a, b, c) { this.setSelectOptions(a, b, c) }, setSelectOptions: function (a, b, c) { c = c || [], a.innerHTML = ""; for (var d = 0; d < b.length; d++) { var e = document.createElement("option"); e.setAttribute("value", b[d]), e.textContent = c[d] || b[d], a.appendChild(e) } }, getTextareaInput: function () { var a = document.createElement("textarea"); return a.style = a.style || {}, a.style.width = "100%", a.style.height = "300px", a.style.boxSizing = "border-box", a }, getRangeInput: function (a, b, c) { var d = this.getFormInputField("range"); return d.setAttribute("min", a), d.setAttribute("max", b), d.setAttribute("step", c), d }, getFormInputField: function (a) { var b = document.createElement("input"); return b.setAttribute("type", a), b }, afterInputReady: function (a) { }, getFormControl: function (a, b, c) { var d = document.createElement("div"); return d.className = "form-control", a && d.appendChild(a), "checkbox" === b.type ? a.insertBefore(b, a.firstChild) : d.appendChild(b), c && d.appendChild(c), d }, getIndentedPanel: function () { var a = document.createElement("div"); return a.style = a.style || {}, a.style.paddingLeft = "10px", a.style.marginLeft = "10px", a.style.borderLeft = "1px solid #ccc", a }, getChildEditorHolder: function () { return document.createElement("div") }, getDescription: function (a) { var b = document.createElement("p"); return b.innerHTML = a, b }, getCheckboxDescription: function (a) { return this.getDescription(a) }, getFormInputDescription: function (a) { return this.getDescription(a) }, getHeaderButtonHolder: function () { return this.getButtonHolder() }, getButtonHolder: function () { return document.createElement("div") }, getButton: function (a, b, c) { var d = document.createElement("button"); return d.type = "button", this.setButtonText(d, a, b, c), d }, setButtonText: function (a, b, c, d) { a.innerHTML = "", c && (a.appendChild(c), a.innerHTML += " "), a.appendChild(document.createTextNode(b)), d && a.setAttribute("title", d) }, getTable: function () { return document.createElement("table") }, getTableRow: function () { return document.createElement("tr") }, getTableHead: function () { return document.createElement("thead") }, getTableBody: function () { return document.createElement("tbody") }, getTableHeaderCell: function (a) { var b = document.createElement("th"); return b.textContent = a, b }, getTableCell: function () { var a = document.createElement("td"); return a }, getErrorMessage: function (a) { var b = document.createElement("p"); return b.style = b.style || {}, b.style.color = "red", b.appendChild(document.createTextNode(a)), b }, addInputError: function (a, b) { }, removeInputError: function (a) { }, addTableRowError: function (a) { }, removeTableRowError: function (a) { }, getTabHolder: function () { var a = document.createElement("div"); return a.innerHTML = "
    ", a }, applyStyles: function (a, b) { a.style = a.style || {}; for (var c in b) b.hasOwnProperty(c) && (a.style[c] = b[c]) }, closest: function (a, b) { for (; a && a !== document;) { if (!a[g]) return !1; if (a[g](b)) return a; a = a.parentNode } return !1 }, getTab: function (a) { var b = document.createElement("div"); return b.appendChild(a), b.style = b.style || {}, this.applyStyles(b, { border: "1px solid #ccc", borderWidth: "1px 0 1px 1px", textAlign: "center", lineHeight: "30px", borderRadius: "5px", borderBottomRightRadius: 0, borderTopRightRadius: 0, fontWeight: "bold", cursor: "pointer" }), b }, getTabContentHolder: function (a) { return a.children[1] }, getTabContent: function () { return this.getIndentedPanel() }, markTabActive: function (a) { this.applyStyles(a, { opacity: 1, background: "white" }) }, markTabInactive: function (a) { this.applyStyles(a, { opacity: .5, background: "" }) }, addTab: function (a, b) { a.children[0].appendChild(b) }, getBlockLink: function () { var a = document.createElement("a"); return a.style.display = "block", a }, getBlockLinkHolder: function () { var a = document.createElement("div"); return a }, getLinksHolder: function () { var a = document.createElement("div"); return a }, createMediaLink: function (a, b, c) { a.appendChild(b), c.style.width = "100%", a.appendChild(c) }, createImageLink: function (a, b, c) { a.appendChild(b), b.appendChild(c) } }), f.defaults.themes.bootstrap2 = f.AbstractTheme.extend({ getRangeInput: function (a, b, c) { return this._super(a, b, c) }, getGridContainer: function () { var a = document.createElement("div"); return a.className = "container-fluid", a }, getGridRow: function () { var a = document.createElement("div"); return a.className = "row-fluid", a }, getFormInputLabel: function (a) { var b = this._super(a); return b.style.display = "inline-block", b.style.fontWeight = "bold", b }, setGridColumnSize: function (a, b) { a.className = "span" + b }, getSelectInput: function (a) { var b = this._super(a); return b.style.width = "auto", b.style.maxWidth = "98%", b }, getFormInputField: function (a) { var b = this._super(a); return b.style.width = "98%", b }, afterInputReady: function (a) { a.controlgroup || (a.controlgroup = this.closest(a, ".control-group"), a.controls = this.closest(a, ".controls"), this.closest(a, ".compact") && (a.controlgroup.className = a.controlgroup.className.replace(/control-group/g, "").replace(/[ ]{2,}/g, " "), a.controls.className = a.controlgroup.className.replace(/controls/g, "").replace(/[ ]{2,}/g, " "), a.style.marginBottom = 0)) }, getIndentedPanel: function () { var a = document.createElement("div"); return a.className = "well well-small", a.style.paddingBottom = 0, a }, getFormInputDescription: function (a) { var b = document.createElement("p"); return b.className = "help-inline", b.textContent = a, b }, getFormControl: function (a, b, c) { var d = document.createElement("div"); d.className = "control-group"; var e = document.createElement("div"); return e.className = "controls", a && "checkbox" === b.getAttribute("type") ? (d.appendChild(e), a.className += " checkbox", a.appendChild(b), e.appendChild(a), e.style.height = "30px") : (a && (a.className += " control-label", d.appendChild(a)), e.appendChild(b), d.appendChild(e)), c && e.appendChild(c), d }, getHeaderButtonHolder: function () { var a = this.getButtonHolder(); return a.style.marginLeft = "10px", a }, getButtonHolder: function () { var a = document.createElement("div"); return a.className = "btn-group", a }, getButton: function (a, b, c) { var d = this._super(a, b, c); return d.className += " btn btn-default", d }, getTable: function () { var a = document.createElement("table"); return a.className = "table table-bordered", a.style.width = "auto", a.style.maxWidth = "none", a }, addInputError: function (a, b) { a.controlgroup && a.controls && (a.controlgroup.className += " error", a.errmsg ? a.errmsg.style.display = "" : (a.errmsg = document.createElement("p"), a.errmsg.className = "help-block errormsg", a.controls.appendChild(a.errmsg)), a.errmsg.textContent = b) }, removeInputError: function (a) { a.errmsg && (a.errmsg.style.display = "none", a.controlgroup.className = a.controlgroup.className.replace(/\s?error/g, "")) }, getTabHolder: function () { var a = document.createElement("div"); return a.className = "tabbable tabs-left", a.innerHTML = "
    ", a }, getTab: function (a) { var b = document.createElement("li"), 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 = "tab-pane active", 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) }, getProgressBar: function () { var a = document.createElement("div"); a.className = "progress"; var b = document.createElement("div"); return b.className = "bar", b.style.width = "0%", a.appendChild(b), a }, updateProgressBar: function (a, b) { a && (a.firstChild.style.width = b + "%") }, updateProgressBarUnknown: function (a) { a && (a.className = "progress progress-striped active", a.firstChild.style.width = "100%") } }), f.defaults.themes.bootstrap3 = f.AbstractTheme.extend({ getSelectInput: function (a) { var b = this._super(a); return b.className += "form-control", b }, setGridColumnSize: function (a, b) { a.className = "col-md-" + b }, afterInputReady: function (a) { a.controlgroup || (a.controlgroup = this.closest(a, ".form-group"), this.closest(a, ".compact") && (a.controlgroup.style.marginBottom = 0)) }, getTextareaInput: function () { var a = document.createElement("textarea"); return a.className = "form-control", a }, getRangeInput: function (a, b, c) { return this._super(a, b, c) }, getFormInputField: function (a) { var b = this._super(a); return "checkbox" !== a && (b.className += "form-control"), b }, getFormControl: function (a, b, c) { var d = document.createElement("div"); return a && "checkbox" === b.type ? (d.className += " checkbox", a.appendChild(b), a.style.fontSize = "14px", d.style.marginTop = "0", d.appendChild(a), b.style.position = "relative", b.style.cssFloat = "left") : (d.className += " form-group", a && (a.className += " control-label", d.appendChild(a)), d.appendChild(b)), c && d.appendChild(c), d }, getIndentedPanel: function () { var a = document.createElement("div"); return a.className = "well well-sm", a.style.paddingBottom = 0, a }, getFormInputDescription: function (a) { var b = document.createElement("p"); return b.className = "help-block", b.innerHTML = a, b }, getHeaderButtonHolder: function () { var a = this.getButtonHolder(); return a.style.marginLeft = "10px", a }, getButtonHolder: function () { var a = document.createElement("div"); return a.className = "btn-group", a }, getButton: function (a, b, c) { var d = this._super(a, b, c); return d.className += "btn btn-default", d }, getTable: function () { var a = document.createElement("table"); return a.className = "table table-bordered", a.style.width = "auto", a.style.maxWidth = "none", a }, addInputError: function (a, b) { a.controlgroup && (a.controlgroup.className += " has-error", a.errmsg ? a.errmsg.style.display = "" : (a.errmsg = document.createElement("p"), a.errmsg.className = "help-block errormsg", a.controlgroup.appendChild(a.errmsg)), a.errmsg.textContent = b) }, removeInputError: function (a) { a.errmsg && (a.errmsg.style.display = "none", a.controlgroup.className = a.controlgroup.className.replace(/\s?has-error/g, "")) }, getTabHolder: function () { var a = document.createElement("div"); return a.innerHTML = "
    ", a.className = "rows", a }, getTab: function (a) { var b = document.createElement("a"); return b.className = "list-group-item", b.setAttribute("href", "#"), b.appendChild(a), b }, markTabActive: function (a) { a.className += " active" }, markTabInactive: function (a) { a.className = a.className.replace(/\s?active/g, "") }, getProgressBar: function () { var a = 0, b = 100, c = 0, d = document.createElement("div"); d.className = "progress"; var e = document.createElement("div"); return e.className = "progress-bar", e.setAttribute("role", "progressbar"), e.setAttribute("aria-valuenow", c), e.setAttribute("aria-valuemin", a), e.setAttribute("aria-valuenax", b), e.innerHTML = c + "%", d.appendChild(e), d }, updateProgressBar: function (a, b) { if (a) { var c = a.firstChild, d = b + "%"; c.setAttribute("aria-valuenow", b), c.style.width = d, c.innerHTML = d } }, updateProgressBarUnknown: function (a) { if (a) { var b = a.firstChild; a.className = "progress progress-striped active", b.removeAttribute("aria-valuenow"), b.style.width = "100%", b.innerHTML = "" } } }), f.defaults.themes.foundation = f.AbstractTheme.extend({ getChildEditorHolder: function () { var a = document.createElement("div"); return a.style.marginBottom = "15px", a }, getSelectInput: function (a) { var b = this._super(a); return b.style.minWidth = "none", b.style.padding = "5px", b.style.marginTop = "3px", b }, getSwitcher: function (a) { var b = this._super(a); return b.style.paddingRight = "8px", b }, afterInputReady: function (a) { this.closest(a, ".compact") && (a.style.marginBottom = 0), a.group = this.closest(a, ".form-control") }, getFormInputLabel: function (a) { var b = this._super(a); return b.style.display = "inline-block", b }, getFormInputField: function (a) { var b = this._super(a); return b.style.width = "100%", b.style.marginBottom = "checkbox" === a ? "0" : "12px", b }, getFormInputDescription: function (a) { var b = document.createElement("p"); return b.textContent = a, b.style.marginTop = "-10px", b.style.fontStyle = "italic", b }, getIndentedPanel: function () { var a = document.createElement("div"); return a.className = "panel", a.style.paddingBottom = 0, a }, getHeaderButtonHolder: function () { var a = this.getButtonHolder(); return a.style.display = "inline-block", a.style.marginLeft = "10px", a.style.verticalAlign = "middle", a }, getButtonHolder: function () { var a = document.createElement("div"); return a.className = "button-group", a }, getButton: function (a, b, c) { var d = this._super(a, b, c); return d.className += " small button", d }, addInputError: function (a, b) { a.group && (a.group.className += " error", a.errmsg ? a.errmsg.style.display = "" : (a.insertAdjacentHTML("afterend", ''), a.errmsg = a.parentNode.getElementsByClassName("error")[0]), a.errmsg.textContent = b) }, removeInputError: function (a) { a.errmsg && (a.group.className = a.group.className.replace(/ error/g, ""), a.errmsg.style.display = "none") }, getProgressBar: function () { var a = document.createElement("div"); a.className = "progress"; var b = document.createElement("span"); return b.className = "meter", b.style.width = "0%", a.appendChild(b), a }, updateProgressBar: function (a, b) { a && (a.firstChild.style.width = b + "%") }, updateProgressBarUnknown: function (a) { a && (a.firstChild.style.width = "100%") } }), 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.foundation6 = f.defaults.themes.foundation5.extend({ + getIndentedPanel: function () { var a = document.createElement("div"); return a.className = "callout secondary", a }, getButtonHolder: function () { var a = document.createElement("div"); return a.className = "button-group tiny", a.style.marginBottom = 0, a }, getFormInputLabel: function (a) { var b = this._super(a); return b.style.display = "block", b }, getFormControl: function (a, b, c) { + var d = document.createElement("div"); return d.className = "form-control", a && d.appendChild(a), "checkbox" === b.type ? a.insertBefore(b, a.firstChild) : a ? a.appendChild(b) : d.appendChild(b), + c && a.appendChild(c), d + }, addInputError: function (a, b) { if (a.group) { if (a.group.className += " error", a.errmsg) a.errmsg.style.display = "", a.className = ""; else { var c = document.createElement("span"); c.className = "form-error is-visible", a.group.getElementsByTagName("label")[0].appendChild(c), a.className = a.className + " is-invalid-input", a.errmsg = c } a.errmsg.textContent = b } }, removeInputError: function (a) { a.errmsg && (a.className = a.className.replace(/ is-invalid-input/g, ""), a.errmsg.parentNode && a.errmsg.parentNode.removeChild(a.errmsg)) } + }), 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") }, getProgressBar: function () { var a = 100, b = 0, c = document.createElement("progress"); return c.setAttribute("max", a), c.setAttribute("value", b), c }, updateProgressBar: function (a, b) { a && a.setAttribute("value", b) }, updateProgressBarUnknown: function (a) { a && a.removeAttribute("value") } }), 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.defaults.themes.barebones = f.AbstractTheme.extend({ getFormInputLabel: function (a) { var b = this._super(a); return b }, getFormInputDescription: function (a) { var b = this._super(a); return b }, getIndentedPanel: function () { var a = this._super(); return a }, getChildEditorHolder: function () { var a = this._super(); return a }, getHeaderButtonHolder: function () { var a = this.getButtonHolder(); return a }, getTable: function () { var a = this._super(); return a }, addInputError: function (a, b) { if (a.errmsg) a.errmsg.style.display = "block"; else { var c = this.closest(a, ".form-control"); a.errmsg = document.createElement("div"), a.errmsg.setAttribute("class", "errmsg"), c.appendChild(a.errmsg) } a.errmsg.innerHTML = "", a.errmsg.appendChild(document.createTextNode(b)) }, removeInputError: function (a) { a.style.borderColor = "", a.errmsg && (a.errmsg.style.display = "none") }, getProgressBar: function () { var a = 100, b = 0, c = document.createElement("progress"); return c.setAttribute("max", a), c.setAttribute("value", b), c }, updateProgressBar: function (a, b) { a && a.setAttribute("value", b) }, updateProgressBarUnknown: function (a) { a && a.removeAttribute("value") } }), 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 () { return { compile: function (a) { var b = a.match(/{{\s*([a-zA-Z0-9\-_ \.]+)\s*}}/g), c = b && b.length; if (!c) return function () { return a }; for (var d = [], e = function (a) { var c, e = b[a].replace(/[{}]+/g, "").trim().split("."), f = e.length; if (f > 1) { var g; c = function (b) { for (g = b, a = 0; a < f && (g = g[e[a]]); a++); return g } } else e = e[0], c = function (a) { return a[e] }; d.push({ s: b[a], r: c }) }, f = 0; f < c; f++)e(f); return function (b) { var e, g = a + ""; for (f = 0; f < c; f++)e = d[f], g = g.replace(e.s, e.r(b)); return g } } } }, 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) } } } }, 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) } } } }, f.defaults.templates.markup = function () { return !(!window.Mark || !window.Mark.up) && { compile: function (a) { return function (b) { return window.Mark.up(a, b) } } } }, f.defaults.templates.mustache = function () { return !!window.Mustache && { compile: function (a) { return function (b) { return window.Mustache.render(a, b) } } } }, 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) } } } }, 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 < b.length; e++)d = d.replace(new RegExp("\\{\\{" + e + "}}", "g"), b[e]); return d }, f.defaults.default_language = "en", f.defaults.language = f.defaults.default_language, f.defaults.languages.en = { error_notset: "Property must be set", error_notempty: "Value required", error_enum: "Value must be one of the enumerated values", error_anyOf: "Value must validate against at least one of the provided schemas", error_oneOf: "Value must validate against exactly one of the provided schemas. It currently validates against {{0}} of the schemas.", error_not: "Value must not validate against the provided schema", error_type_union: "Value must be one of the provided types", error_type: "Value must be of type {{0}}", error_disallow_union: "Value must not be one of the provided disallowed types", error_disallow: "Value must not be of type {{0}}", error_multipleOf: "Value must be a multiple of {{0}}", error_maximum_excl: "Value must be less than {{0}}", error_maximum_incl: "Value must be at most {{0}}", error_minimum_excl: "Value must be greater than {{0}}", error_minimum_incl: "Value must be at least {{0}}", error_maxLength: "Value must be at most {{0}} characters long", error_minLength: "Value must be at least {{0}} characters long", error_pattern: "Value must match the pattern {{0}}", error_additionalItems: "No additional items allowed in this array", error_maxItems: "Value must have at most {{0}} items", error_minItems: "Value must have at least {{0}} items", error_uniqueItems: "Array must have unique items", error_maxProperties: "Object must have at most {{0}} properties", error_minProperties: "Object must have at least {{0}} properties", error_required: "Object is missing the required property '{{0}}'", error_additional_properties: "No additional properties allowed, but property {{0}} is set", error_dependency: "Must have property {{0}}", button_delete_all: "All", button_delete_all_title: "Delete All", button_delete_last: "Last {{0}}", button_delete_last_title: "Delete Last {{0}}", button_add_row_title: "Add {{0}}", button_move_down_title: "Move down", button_move_up_title: "Move up", button_delete_row_title: "Delete {{0}}", button_delete_row_title_short: "Delete", button_collapse: "Collapse", button_expand: "Expand" }, f.plugins = { ace: { theme: "" }, epiceditor: {}, sceditor: {}, select2: {}, selectize: {} }, d(f.defaults.editors, function (a, b) { f.defaults.editors[a].options = b.options || {} }), f.defaults.resolvers.unshift(function (a) { if ("string" != typeof a.type) return "multiple" }), f.defaults.resolvers.unshift(function (a) { if (!a.type && a.properties) return "object" }), f.defaults.resolvers.unshift(function (a) { if ("string" == typeof a.type) return a.type }), f.defaults.resolvers.unshift(function (a) { if ("boolean" === a.type) return "checkbox" === a.format || a.options && a.options.checkbox ? "checkbox" : f.plugins.selectize.enable ? "selectize" : "select" }), f.defaults.resolvers.unshift(function (a) { if ("any" === a.type) return "multiple" }), f.defaults.resolvers.unshift(function (a) { if ("string" === a.type && a.media && "base64" === a.media.binaryEncoding) return "base64" }), f.defaults.resolvers.unshift(function (a) { if ("string" === a.type && "url" === a.format && a.options && a.options.upload === !0 && window.FileReader) return "upload" }), f.defaults.resolvers.unshift(function (a) { if ("array" == a.type && "table" == a.format) return "table" }), f.defaults.resolvers.unshift(function (a) { if (a.enumSource) return f.plugins.selectize.enable ? "selectize" : "select" }), f.defaults.resolvers.unshift(function (a) { if (a.enum) { if ("array" === a.type || "object" === a.type) return "enum"; if ("number" === a.type || "integer" === a.type || "string" === a.type) return f.plugins.selectize.enable ? "selectize" : "select" } }), f.defaults.resolvers.unshift(function (a) { if ("array" === a.type && a.items && !Array.isArray(a.items) && a.uniqueItems && ["string", "number", "integer"].indexOf(a.items.type) >= 0) { if (a.items.enum) return "multiselect"; if (f.plugins.selectize.enable && "string" === a.items.type) return "arraySelectize" } }), f.defaults.resolvers.unshift(function (a) { if (a.oneOf || a.anyOf) return "multiple" }), 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 +}(); diff --git a/django_netjsonconfig/static/django-netjsonconfig/js/lib/utils.js b/django_netjsonconfig/static/django-netjsonconfig/js/lib/utils.js new file mode 100644 index 0000000..a9119ff --- /dev/null +++ b/django_netjsonconfig/static/django-netjsonconfig/js/lib/utils.js @@ -0,0 +1,61 @@ +var cleanedData, + pattern = /^\{\{\s*(\w*)\s*\}\}$/g, + getContext, + evaluateVars, + cleanData, + context_json_valid, + span = document.createElement('span'); + +span.setAttribute('style', 'color:red'); +span.setAttribute('id', 'context-error'); + +getContext = function () { + var context_div = document.querySelectorAll(".field-context, .field-default_values")[0]; + if (context_div && !context_div.querySelector('span')) { + context_div.appendChild(span); + } + return document.querySelectorAll("#id_config-0-context, #id_default_values")[0]; +}; + +// check default_values is valid +context_json_valid = function () { + var json = getContext(); + try { + JSON.parse(json.value); + } catch (e) { + span.innerHTML = "Invalid JSON: " + e.message; + return false; + } + span.innerHTML = ""; + return true; +} + +evaluateVars = function (data, context) { + if (typeof data === 'object') { + Object.keys(data).forEach(function (key) { + data[key] = evaluateVars(data[key], context); + }); + } + if (typeof data === 'string') { + var found_vars = data.match(pattern); + if (found_vars !== null) { + found_vars.forEach(function (element) { + element = element.replace(/^\{\{\s+|\s+\}\}$|^\{\{|\}\}$/g, ''); + if (context.hasOwnProperty(element)) { + data = data.replace(pattern, context[element]); + } + }); + } + } + return data; +}; + +cleanData = function (data) { + var json = getContext(); + if (json && data && context_json_valid()) { + cleanedData = evaluateVars(data, JSON.parse(json.value)); + return cleanedData; + } else { + return data; + } +}; diff --git a/django_netjsonconfig/static/django-netjsonconfig/js/widget.js b/django_netjsonconfig/static/django-netjsonconfig/js/widget.js index 5e2ccd9..9d88980 100644 --- a/django_netjsonconfig/static/django-netjsonconfig/js/widget.js +++ b/django_netjsonconfig/static/django-netjsonconfig/js/widget.js @@ -2,23 +2,23 @@ var inFullScreenMode = false, oldHeight = 0, oldWidth = 0; - var toggleFullScreen = function(){ + var toggleFullScreen = function () { var advanced = $('#advanced_editor'); - if(!inFullScreenMode){ + if (!inFullScreenMode) { // store the old height and width of the editor before going to fullscreen mode in order to be able to restore them oldHeight = advanced.height(); oldWidth = advanced.width(); advanced.addClass('full-screen').height($(window).height()).width(window.outerWidth); $('body').addClass('editor-full'); - $(window).resize(function(){ + $(window).resize(function () { advanced.height($(window).height()).width(window.outerWidth); }); inFullScreenMode = true; advanced.find('.jsoneditor-menu a').show(); advanced.find('.jsoneditor-menu label').show(); - window.scrollTo(0,0); + window.scrollTo(0, 0); } - else{ + else { advanced.removeClass('full-screen').height(oldHeight).width(oldWidth); $('body').removeClass('editor-full'); // unbind all events listened to while going to full screen mode @@ -30,21 +30,21 @@ } }; - var initAdvancedEditor = function(target, data, schema, disableSchema){ + var initAdvancedEditor = function (target, data, schema, disableSchema) { var advanced = $("
    "); $(advanced).insertBefore($(target)); $(target).hide(); // if disableSchema is true, do not validate againsts schema, default is false schema = disableSchema ? {} : schema; var options = { - mode:'code', + mode: 'code', theme: 'ace/theme/tomorrow_night_bright', indentation: 4, - onEditable: function(node){ + onEditable: function (node) { return true; }, - onChange:function() { - $(target).val(editor.getText()); + onChange: function () { + $(target).val(editor.getText()); }, schema: schema }; @@ -63,27 +63,29 @@ .append($(' back to normal mode')) .append(advanced.parents('.field-config').find('#netjsonconfig-hint') .clone(true) - .attr('id','netjsonconfig-hint-advancedmode')); + .attr('id', 'netjsonconfig-hint-advancedmode')); return editor; }; // returns true if JSON is well formed // and valid according to its schema - var isValidJson = function(advanced){ - var valid; - try{ - valid = advanced.validateSchema(advanced.get()); - }catch (e){ + var isValidJson = function (advanced) { + var valid, + cleanedData; + try { + cleanedData = window.cleanData(advanced.get()); + valid = advanced.validateSchema(cleanedData); + } catch (e) { valid = false; } return valid; }; - var alertInvalidJson = function(){ + var alertInvalidJson = function () { alert("The JSON entered is not valid"); }; - var loadUi = function(el, backend, schemas, setInitialValue){ + var loadUi = function (el, backend, schemas, setInitialValue) { var field = $(el), form = field.parents('form').eq(0), value = JSON.parse(field.val()), @@ -95,17 +97,18 @@ editorContainer = $('#' + id), html, editor, options, wrapper, header, getEditorValue, updateRaw, advancedEditor, - $advancedEl; + $advancedEl, + contextField; // inject editor unless already present - if(!editorContainer.length){ - html = '
    '; - html += '

    '+ labelText +'

    '; - html += '
    '; + if (!editorContainer.length) { + html = '
    '; + html += '

    ' + labelText + '

    '; + html += '
    '; html += '
    '; container.hide().after(html); editorContainer = $('#' + id); } - else{ + else { editorContainer.html(''); } @@ -126,16 +129,16 @@ schema: backend ? schemas[backend] : {} }; if (field.attr("data-options") !== undefined) { - $.extend(options, JSON.parse(field.attr("data-options"))); + $.extend(options, JSON.parse(field.attr("data-options"))); } editor = new JSONEditor(document.getElementById(id), options); // initialise advanced json editor here (disable schema validation in VPN admin) advancedEditor = initAdvancedEditor(field, value, options.schema, $('#vpn_form').length === 1); $advancedEl = $('#advanced_editor'); - getEditorValue = function(){ + getEditorValue = function () { return JSON.stringify(editor.getValue(), null, 4); }; - updateRaw = function(){ + updateRaw = function () { field.val(getEditorValue()); }; @@ -148,18 +151,30 @@ editor.on('change', updateRaw); // update raw value before form submit - form.submit(function(e){ + form.submit(function (e) { if ($advancedEl.is(':hidden')) { return; } // only submit the form if the json in the advanced editor is valid - if(!isValidJson(advancedEditor)){ + if (!isValidJson(advancedEditor)) { e.preventDefault(); alertInvalidJson(); } - else{ + else { if (container.is(':hidden')) { updateRaw(); } } }); + // trigger schema-data validation on default values change + contextField = window.getContext(); + if (contextField) { + contextField.addEventListener('change', function () { + window.context_json_valid(); + if (inFullScreenMode) { + advancedEditor.validate(); + } else { + editor.onChange(JSON.parse(field.val())); + } + }); + } // add advanced edit button header = editorContainer.find('> div > h3'); header.find('span:first-child').hide(); // hides editor title @@ -167,39 +182,43 @@ // move advanced mode button in auto-generated UI container.find('.advanced-mode').clone().prependTo(header); // advanced mode button - header.find('.advanced-mode').click(function(){ - // update autogenrated advanced json editor with new data - advancedEditor.set(JSON.parse(field.val())); - wrapper.hide(); - container.show(); - // set the advanced editor container to full screen mode - toggleFullScreen(); + header.find('.advanced-mode').click(function () { + if (!window.context_json_valid()) { + alert('Advanced mode does not work when default value field is invalid JSON!'); + } else { + // update autogenrated advanced json editor with new data + advancedEditor.set(JSON.parse(field.val())); + wrapper.hide(); + container.show(); + // set the advanced editor container to full screen mode + toggleFullScreen(); + } }); // back to normal mode button - $advancedEl.find('.jsoneditor-exit').click(function(){ + $advancedEl.find('.jsoneditor-exit').click(function () { // check if json in advanced mode is valid before coming back to normal mode - if(isValidJson(advancedEditor)){ + if (isValidJson(advancedEditor)) { // update autogenerated UI editor.setValue(JSON.parse(field.val())); toggleFullScreen(); container.hide(); wrapper.show(); } - else{ + else { alertInvalidJson(); } }); // re-enable click on netjsonconfig hint - $advancedEl.find('#netjsonconfig-hint-advancedmode a').click(function(){ + $advancedEl.find('#netjsonconfig-hint-advancedmode a').click(function () { var window_ = window.open($(this).attr('href'), '_blank'); window_.focus(); }); // allow to add object properties by pressing enter - form.on('keypress', '.jsoneditor .modal input[type=text]', function(e){ - if(e.keyCode == 13){ + form.on('keypress', '.jsoneditor .modal input[type=text]', function (e) { + if (e.keyCode == 13) { e.preventDefault(); $(e.target).siblings('input.json-editor-btn-add').trigger('click'); $(e.target).val(''); @@ -207,23 +226,23 @@ }); }; - var bindLoadUi = function(){ - $.getJSON(django._netjsonconfigSchemaUrl, function(schemas){ - $('.jsoneditor-raw').each(function(i, el){ + var bindLoadUi = function () { + $.getJSON(django._netjsonconfigSchemaUrl, function (schemas) { + $('.jsoneditor-raw').each(function (i, el) { var field = $(el), schema = field.attr("data-schema"), schema_selector = field.attr("data-schema-selector"); if (schema !== undefined) { loadUi(el, schema, schemas, true); } else { - if(schema_selector === undefined) { + if (schema_selector === undefined) { schema_selector = '#id_backend, #id_config-0-backend'; } var backend = $(schema_selector); // load first time loadUi(el, backend.val(), schemas, true); // reload when backend is changed - backend.change(function(){ + backend.change(function () { loadUi(el, backend.val(), schemas); }); } @@ -231,7 +250,7 @@ }); }; - $(function() { + $(function () { var add_config = $('#config-group.inline-group .add-row'); // if configuration is admin inline // load it when add button is clicked @@ -251,68 +270,68 @@ var matchKey = (function () { }()); // JSON-Schema Edtor django theme JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ - getContainer: function() { + getContainer: function () { return document.createElement('div'); }, - getFloatRightLinkHolder: function() { + getFloatRightLinkHolder: function () { var el = document.createElement('div'); el.style = el.style || {}; el.style.cssFloat = 'right'; el.style.marginLeft = '10px'; return el; }, - getModal: function() { + getModal: function () { var el = document.createElement('div'); el.className = 'modal'; el.style.display = 'none'; return el; }, - getGridContainer: function() { + getGridContainer: function () { var el = document.createElement('div'); el.className = 'grid-container'; return el; }, - getGridRow: function() { + getGridRow: function () { var el = document.createElement('div'); el.className = 'grid-row'; return el; }, - getGridColumn: function() { + getGridColumn: function () { var el = document.createElement('div'); el.className = 'grid-column'; return el; }, - setGridColumnSize: function(el, size) { + setGridColumnSize: function (el, size) { return el; }, - getLink: function(text) { + getLink: function (text) { var el = document.createElement('a'); el.setAttribute('href', '#'); el.appendChild(document.createTextNode(text)); return el; }, - disableHeader: function(header) { + disableHeader: function (header) { header.style.color = '#ccc'; }, - disableLabel: function(label) { + disableLabel: function (label) { label.style.color = '#ccc'; }, - enableHeader: function(header) { + enableHeader: function (header) { header.style.color = ''; }, - enableLabel: function(label) { + enableLabel: function (label) { label.style.color = ''; }, - getFormInputLabel: function(text) { + getFormInputLabel: function (text) { var el = document.createElement('label'); el.appendChild(document.createTextNode(text)); return el; }, - getCheckboxLabel: function(text) { + getCheckboxLabel: function (text) { var el = this.getFormInputLabel(text); return el; }, - getHeader: function(text) { + getHeader: function (text) { var el = document.createElement('h3'); if (typeof text === "string") { el.textContent = text; @@ -321,13 +340,13 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ } return el; }, - getCheckbox: function() { + getCheckbox: function () { var el = this.getFormInputField('checkbox'); el.style.display = 'inline-block'; el.style.width = 'auto'; return el; }, - getMultiCheckboxHolder: function(controls, label, description) { + getMultiCheckboxHolder: function (controls, label, description) { var el = document.createElement('div'), i; @@ -347,23 +366,23 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ return el; }, - getSelectInput: function(options) { + getSelectInput: function (options) { var select = document.createElement('select'); if (options) { this.setSelectOptions(select, options); } return select; }, - getSwitcher: function(options) { + getSwitcher: function (options) { var switcher = this.getSelectInput(options); switcher.className = 'switcher'; return switcher; }, - getSwitcherOptions: function(switcher) { + getSwitcherOptions: function (switcher) { return switcher.getElementsByTagName('option'); }, - setSwitcherOptions: function(switcher, options, titles) { + setSwitcherOptions: function (switcher, options, titles) { this.setSelectOptions(switcher, options, titles); }, - setSelectOptions: function(select, options, titles) { + setSelectOptions: function (select, options, titles) { titles = titles || []; select.innerHTML = ''; var i, option; @@ -374,28 +393,28 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ select.appendChild(option); } }, - getTextareaInput: function() { + getTextareaInput: function () { var el = document.createElement('textarea'); el.className = 'vLargeTextField'; return el; }, - getRangeInput: function(min, max, step) { + getRangeInput: function (min, max, step) { var el = this.getFormInputField('range'); el.setAttribute('min', min); el.setAttribute('max', max); el.setAttribute('step', step); return el; }, - getFormInputField: function(type) { + getFormInputField: function (type) { var el = document.createElement('input'); el.className = 'vTextField'; el.setAttribute('type', type); return el; }, - afterInputReady: function(input) { + afterInputReady: function (input) { return; }, - getFormControl: function(label, input, description) { + getFormControl: function (label, input, description) { var el = document.createElement('div'); el.className = 'form-row'; if (label) { el.appendChild(label); } @@ -407,39 +426,39 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ if (description) { el.appendChild(description); } return el; }, - getIndentedPanel: function() { + getIndentedPanel: function () { var el = document.createElement('div'); el.className = 'inline-related'; return el; }, - getChildEditorHolder: function() { + getChildEditorHolder: function () { var el = document.createElement('div'); el.className = 'inline-group'; return el; }, - getDescription: function(text) { + getDescription: function (text) { var el = document.createElement('p'); el.className = 'help'; el.innerHTML = text; return el; }, - getCheckboxDescription: function(text) { + getCheckboxDescription: function (text) { return this.getDescription(text); }, - getFormInputDescription: function(text) { + getFormInputDescription: function (text) { return this.getDescription(text); }, - getHeaderButtonHolder: function() { + getHeaderButtonHolder: function () { var el = document.createElement('span'); el.className = 'control'; return el; }, - getButtonHolder: function() { + getButtonHolder: function () { var el = document.createElement('div'); el.className = 'control'; return el; }, - getButton: function(text, icon, title) { + getButton: function (text, icon, title) { var el = document.createElement('input'), className = 'button'; if (text.indexOf('Delete') > -1) { @@ -450,41 +469,41 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ this.setButtonText(el, text, icon, title); return el; }, - setButtonText: function(button, text, icon, title) { + setButtonText: function (button, text, icon, title) { button.value = text; if (title) { button.setAttribute('title', title); } }, - getTable: function() { + getTable: function () { return document.createElement('table'); }, - getTableRow: function() { + getTableRow: function () { return document.createElement('tr'); }, - getTableHead: function() { + getTableHead: function () { return document.createElement('thead'); }, - getTableBody: function() { + getTableBody: function () { return document.createElement('tbody'); }, - getTableHeaderCell: function(text) { + getTableHeaderCell: function (text) { var el = document.createElement('th'); el.textContent = text; return el; }, - getTableCell: function() { + getTableCell: function () { var el = document.createElement('td'); return el; }, - getErrorMessage: function(text) { - var el = document.createElement('p'); - el.style = el.style || {}; - el.style.color = 'red'; - el.appendChild(document.createTextNode(text)); - return el; + getErrorMessage: function (text) { + var el = document.createElement('p'); + el.style = el.style || {}; + el.style.color = 'red'; + el.appendChild(document.createTextNode(text)); + return el; }, - addInputError: function(input, text) { + addInputError: function (input, text) { input.parentNode.className += ' errors'; - if(!input.errmsg) { + if (!input.errmsg) { input.errmsg = document.createElement('li'); var ul = document.createElement('ul'); ul.className = 'errorlist'; @@ -496,19 +515,19 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ } input.errmsg.textContent = text; }, - removeInputError: function(input) { - if(!input.errmsg) { return; } + removeInputError: function (input) { + if (!input.errmsg) { return; } input.errmsg.parentNode.style.display = 'none'; - input.parentNode.className = input.parentNode.className.replace(/\s?errors/g,''); + input.parentNode.className = input.parentNode.className.replace(/\s?errors/g, ''); }, - addTableRowError: function(row) { return; }, - removeTableRowError: function(row) { return; }, - getTabHolder: function() { + addTableRowError: function (row) { return; }, + removeTableRowError: function (row) { return; }, + getTabHolder: function () { var el = document.createElement('div'); el.innerHTML = "
    "; return el; }, - applyStyles: function(el, styles) { + applyStyles: function (el, styles) { el.style = el.style || {}; var i; for (i in styles) { @@ -516,7 +535,7 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ el.style[i] = styles[i]; } }, - closest: function(elem, selector) { + closest: function (elem, selector) { while (elem && elem !== document) { if (matchKey) { if (elem[matchKey](selector)) { @@ -529,7 +548,7 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ } return false; }, - getTab: function(span) { + getTab: function (span) { var el = document.createElement('div'); el.appendChild(span); el.style = el.style || {}; @@ -546,46 +565,46 @@ JSONEditor.defaults.themes.django = JSONEditor.AbstractTheme.extend({ }); return el; }, - getTabContentHolder: function(tab_holder) { + getTabContentHolder: function (tab_holder) { return tab_holder.children[1]; }, - getTabContent: function() { + getTabContent: function () { return this.getIndentedPanel(); }, - markTabActive: function(tab) { + markTabActive: function (tab) { this.applyStyles(tab, { opacity: 1, background: 'white' }); }, - markTabInactive: function(tab) { + markTabInactive: function (tab) { this.applyStyles(tab, { opacity: 0.5, background: '' }); }, - addTab: function(holder, tab) { + addTab: function (holder, tab) { holder.children[0].appendChild(tab); }, - getBlockLink: function() { + getBlockLink: function () { var link = document.createElement('a'); link.style.display = 'block'; return link; }, - getBlockLinkHolder: function() { + getBlockLinkHolder: function () { var el = document.createElement('div'); return el; }, - getLinksHolder: function() { + getLinksHolder: function () { var el = document.createElement('div'); return el; }, - createMediaLink: function(holder, link, media) { + createMediaLink: function (holder, link, media) { holder.appendChild(link); media.style.width = '100%'; holder.appendChild(media); }, - createImageLink: function(holder, link, image) { + createImageLink: function (holder, link, image) { holder.appendChild(link); link.appendChild(image); } diff --git a/django_netjsonconfig/tests/test_admin.py b/django_netjsonconfig/tests/test_admin.py index a2968ce..80c6710 100644 --- a/django_netjsonconfig/tests/test_admin.py +++ b/django_netjsonconfig/tests/test_admin.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import User from django.test import TestCase from django.urls import reverse -from django_x509.models import Ca +from django_x509.models import Ca, Cert from ..models import Config, Device, Template, Vpn from . import CreateConfigMixin, CreateTemplateMixin, TestVpnX509Mixin @@ -21,6 +21,7 @@ class TestAdmin(TestVpnX509Mixin, CreateConfigMixin, CreateTemplateMixin, TestCa fixtures = ['test_templates'] maxDiff = None ca_model = Ca + cert_model = Cert config_model = Config device_model = Device template_model = Template @@ -140,6 +141,33 @@ def test_preview_device_config(self): self.assertContains(response, 'radio0') self.assertContains(response, 'SERIAL012345') + def test_variable_usage(self): + config = { + 'interfaces': [ + { + 'name': 'lo0', + 'type': 'loopback', + 'mac_address': '{{ mac }}', + 'addresses': [ + { + 'family': 'ipv4', + 'proto': 'static', + 'address': '{{ ip }}', + 'mask': 8, + } + ], + } + ] + } + default_values = {'ip': '192.168.56.2', 'mac': '08:00:27:06:72:88'} + t = self._create_template(config=config, default_values=default_values) + path = reverse('admin:django_netjsonconfig_device_add') + params = self._get_device_params() + params.update({'name': 'test-device', 'config-0-templates': str(t.pk)}) + response = self.client.post(path, params) + self.assertNotContains(response, 'errors field-templates', status_code=302) + self.assertEqual(Device.objects.filter(name='test-device').count(), 1) + def test_preview_device_config_empty_id(self): path = reverse('admin:django_netjsonconfig_device_preview') config = json.dumps({'general': {'descripion': 'id: {{ id }}'}}) diff --git a/django_netjsonconfig/tests/test_template.py b/django_netjsonconfig/tests/test_template.py index 3ffca88..2671936 100644 --- a/django_netjsonconfig/tests/test_template.py +++ b/django_netjsonconfig/tests/test_template.py @@ -219,10 +219,7 @@ def test_template_context_var(self): def test_get_context(self): t = self._create_template() - expected = { - 'id': str(t.id), - 'name': t.name, - } + expected = {} expected.update(settings.NETJSONCONFIG_CONTEXT) self.assertEqual(t.get_context(), expected) @@ -263,3 +260,18 @@ def test_duplicate_files_in_template(self): self.assertIn('Invalid configuration triggered by "#/files"', str(e)) else: self.fail('ValidationError not raised!') + + def test_variable_substition(self): + config = {"dns_servers": ["{{dns}}"]} + default_values = {"dns": "4.4.4.4"} + options = { + "name": "test1", + "backend": "netjsonconfig.OpenWrt", + "config": config, + "default_values": default_values, + } + temp = self.template_model(**options) + temp.full_clean() + temp.save() + obj = self.template_model.objects.get(name='test1') + self.assertEqual(obj.name, 'test1') diff --git a/django_netjsonconfig/widgets.py b/django_netjsonconfig/widgets.py index 5fa40a6..76ad12c 100644 --- a/django_netjsonconfig/widgets.py +++ b/django_netjsonconfig/widgets.py @@ -16,6 +16,7 @@ def media(self): js = [ static('{0}/js/{1}'.format(prefix, f)) for f in ( + 'lib/utils.js', 'lib/advanced-mode.js', 'lib/tomorrow_night_bright.js', 'lib/jsonschema-ui.js',