json-editor
Advanced tools
Comparing version 0.7.20 to 0.7.21
{ | ||
"name": "json-editor", | ||
"version": "0.7.20", | ||
"authors": [ | ||
@@ -5,0 +4,0 @@ "Jeremy Dorn <jeremy@jeremydorn.com>" |
@@ -5,3 +5,3 @@ { | ||
"description": "JSON Schema based editor", | ||
"version": "0.7.20", | ||
"version": "0.7.21", | ||
"main": "dist/jsoneditor.js", | ||
@@ -8,0 +8,0 @@ "author": { |
@@ -19,3 +19,3 @@ JSON Editor | ||
JSON Schema has no required dependencies. It only needs a modern browser (tested in Chrome and Firefox). | ||
JSON Editor has no required dependencies. It only needs a modern browser (tested in Chrome and Firefox). | ||
@@ -43,3 +43,3 @@ ### Optional Requirements | ||
The rest of this README contains detailed documentation about every aspect of JSON Editor. | ||
The rest of this README contains detailed documentation about every aspect of JSON Editor. For more under-the-hood documentation, check the wiki. | ||
@@ -956,2 +956,25 @@ ### Initialize | ||
You can also specify a list of static items with a slightly different syntax: | ||
```js+jinja | ||
{ | ||
"enumSource": [{ | ||
// A watched field source | ||
"source": [ | ||
{ | ||
"value": 1, | ||
"title": "One" | ||
}, | ||
{ | ||
"value": 2, | ||
"title": "Two" | ||
} | ||
], | ||
"title": "{{item.title}}", | ||
"value": "{{item.value}}" | ||
}] | ||
] | ||
} | ||
``` | ||
The colors examples used an array of strings directly. Using the verbose form, you can | ||
@@ -958,0 +981,0 @@ also make it work with an array of objects. Here's an example: |
@@ -608,2 +608,3 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({ | ||
self.rows[i] = self.row_cache[i]; | ||
self.rows[i].setValue(self.rows[i].getDefault()); | ||
self.rows[i].container.style.display = ''; | ||
@@ -610,0 +611,0 @@ if(self.rows[i].tab) self.rows[i].tab.style.display = ''; |
@@ -330,2 +330,3 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({ | ||
this.addproperty_list.style.paddingLeft = '5px'; | ||
this.addproperty_list.setAttribute('class', 'property-selector'); | ||
this.addproperty_add = this.getButton('add','add','add'); | ||
@@ -665,3 +666,6 @@ this.addproperty_input = this.theme.getFormInputField('text'); | ||
canHaveAdditionalProperties: function() { | ||
return (this.schema.additionalProperties === true) || !this.jsoneditor.options.no_additional_properties; | ||
if (typeof this.schema.additionalProperties === "boolean") { | ||
return this.schema.additionalProperties; | ||
} | ||
return !this.jsoneditor.options.no_additional_properties; | ||
}, | ||
@@ -668,0 +672,0 @@ destroy: function() { |
@@ -214,53 +214,61 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({ | ||
} | ||
// A watched field | ||
else if(vars[this.enumSource[i].source]) { | ||
var items = vars[this.enumSource[i].source]; | ||
// Only use a predefined part of the array | ||
if(this.enumSource[i].slice) { | ||
items = Array.prototype.slice.apply(items,this.enumSource[i].slice); | ||
else { | ||
var items = []; | ||
// Static list of items | ||
if(Array.isArray(this.enumSource[i].source)) { | ||
items = this.enumSource[i].source; | ||
// A watched field | ||
} else { | ||
items = vars[this.enumSource[i].source]; | ||
} | ||
// Filter the items | ||
if(this.enumSource[i].filter) { | ||
var new_items = []; | ||
for(j=0; j<items.length; j++) { | ||
if(this.enumSource[i].filter({i:j,item:items[j]})) new_items.push(items[j]); | ||
} | ||
items = new_items; | ||
} | ||
var item_titles = []; | ||
var item_values = []; | ||
for(j=0; j<items.length; j++) { | ||
var item = items[j]; | ||
// Rendered value | ||
if(this.enumSource[i].value) { | ||
item_values[j] = this.enumSource[i].value({ | ||
i: j, | ||
item: item | ||
}); | ||
if(items) { | ||
// Only use a predefined part of the array | ||
if(this.enumSource[i].slice) { | ||
items = Array.prototype.slice.apply(items,this.enumSource[i].slice); | ||
} | ||
// Use value directly | ||
else { | ||
item_values[j] = items[j]; | ||
// Filter the items | ||
if(this.enumSource[i].filter) { | ||
var new_items = []; | ||
for(j=0; j<items.length; j++) { | ||
if(this.enumSource[i].filter({i:j,item:items[j]})) new_items.push(items[j]); | ||
} | ||
items = new_items; | ||
} | ||
// Rendered title | ||
if(this.enumSource[i].title) { | ||
item_titles[j] = this.enumSource[i].title({ | ||
i: j, | ||
item: item | ||
}); | ||
var item_titles = []; | ||
var item_values = []; | ||
for(j=0; j<items.length; j++) { | ||
var item = items[j]; | ||
// Rendered value | ||
if(this.enumSource[i].value) { | ||
item_values[j] = this.enumSource[i].value({ | ||
i: j, | ||
item: item | ||
}); | ||
} | ||
// Use value directly | ||
else { | ||
item_values[j] = items[j]; | ||
} | ||
// Rendered title | ||
if(this.enumSource[i].title) { | ||
item_titles[j] = this.enumSource[i].title({ | ||
i: j, | ||
item: item | ||
}); | ||
} | ||
// Use value as the title also | ||
else { | ||
item_titles[j] = item_values[j]; | ||
} | ||
} | ||
// Use value as the title also | ||
else { | ||
item_titles[j] = item_values[j]; | ||
} | ||
// TODO: sort | ||
select_options = select_options.concat(item_values); | ||
select_titles = select_titles.concat(item_titles); | ||
} | ||
// TODO: sort | ||
select_options = select_options.concat(item_values); | ||
select_titles = select_titles.concat(item_titles); | ||
} | ||
@@ -267,0 +275,0 @@ } |
@@ -1,6 +0,6 @@ | ||
/*! JSON Editor v0.7.20 - JSON Schema -> HTML Editor | ||
/*! JSON Editor v0.7.21 - JSON Schema -> HTML Editor | ||
* By Jeremy Dorn - https://github.com/jdorn/json-editor/ | ||
* Released under the MIT license | ||
* | ||
* Date: 2015-06-08 | ||
* Date: 2015-07-03 | ||
*/ | ||
@@ -7,0 +7,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
964294
13698
1191