|
1 |
| -/*! JSON Editor v0.7.12 - JSON Schema -> HTML Editor |
| 1 | +/*! JSON Editor v0.7.13 - JSON Schema -> HTML Editor |
2 | 2 | * By Jeremy Dorn - https://github.com/jdorn/json-editor/
|
3 | 3 | * Released under the MIT license
|
4 | 4 | *
|
5 |
| - * Date: 2014-10-05 |
| 5 | + * Date: 2014-11-11 |
6 | 6 | */
|
7 | 7 |
|
8 | 8 | /**
|
@@ -253,6 +253,7 @@ JSONEditor.prototype = {
|
253 | 253 |
|
254 | 254 | // Fire ready event asynchronously
|
255 | 255 | window.requestAnimationFrame(function() {
|
| 256 | + if(!self.ready) return; |
256 | 257 | self.validation_results = self.validator.validate(self.root.getValue());
|
257 | 258 | self.root.showValidationErrors(self.validation_results);
|
258 | 259 | self.trigger('ready');
|
@@ -389,7 +390,8 @@ JSONEditor.prototype = {
|
389 | 390 |
|
390 | 391 | window.requestAnimationFrame(function() {
|
391 | 392 | self.firing_change = false;
|
392 |
| - |
| 393 | + if(!self.ready) return; |
| 394 | + |
393 | 395 | // Validate and cache results
|
394 | 396 | self.validation_results = self.validator.validate(self.root.getValue());
|
395 | 397 |
|
@@ -2677,19 +2679,40 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
|
2677 | 2679 | if(this.editing_json) this.hideEditJSON();
|
2678 | 2680 | else this.showEditJSON();
|
2679 | 2681 | },
|
| 2682 | + insertPropertyControlUsingPropertyOrder: function (property, control, container) { |
| 2683 | + var propertyOrder = this.schema.properties[property].propertyOrder; |
| 2684 | + if (typeof propertyOrder !== "number") propertyOrder = 1000; |
| 2685 | + control.propertyOrder = propertyOrder; |
| 2686 | + |
| 2687 | + for (var i = 0; i < container.childNodes.length; i++) { |
| 2688 | + var child = container.childNodes[i]; |
| 2689 | + if (control.propertyOrder < child.propertyOrder) { |
| 2690 | + this.addproperty_list.insertBefore(control, child); |
| 2691 | + control = null; |
| 2692 | + break; |
| 2693 | + } |
| 2694 | + } |
| 2695 | + if (control) { |
| 2696 | + this.addproperty_list.appendChild(control); |
| 2697 | + } |
| 2698 | + }, |
2680 | 2699 | addPropertyCheckbox: function(key) {
|
2681 | 2700 | var self = this;
|
2682 |
| - var checkbox, label, control; |
2683 |
| - |
| 2701 | + var checkbox, label, labelText, control; |
| 2702 | + |
2684 | 2703 | checkbox = self.theme.getCheckbox();
|
2685 | 2704 | checkbox.style.width = 'auto';
|
2686 |
| - label = self.theme.getCheckboxLabel(key); |
| 2705 | + |
| 2706 | + labelText = this.schema.properties[key].title ? this.schema.properties[key].title : key; |
| 2707 | + label = self.theme.getCheckboxLabel(labelText); |
| 2708 | + |
2687 | 2709 | control = self.theme.getFormControl(label,checkbox);
|
2688 | 2710 | control.style.paddingBottom = control.style.marginBottom = control.style.paddingTop = control.style.marginTop = 0;
|
2689 | 2711 | control.style.height = 'auto';
|
2690 | 2712 | //control.style.overflowY = 'hidden';
|
2691 |
| - self.addproperty_list.appendChild(control); |
2692 |
| - |
| 2713 | + |
| 2714 | + this.insertPropertyControlUsingPropertyOrder(key, control, this.addproperty_list); |
| 2715 | + |
2693 | 2716 | checkbox.checked = key in this.editors;
|
2694 | 2717 | checkbox.addEventListener('change',function() {
|
2695 | 2718 | if(checkbox.checked) {
|
@@ -2797,7 +2820,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
|
2797 | 2820 | this._super(editor);
|
2798 | 2821 | },
|
2799 | 2822 | canHaveAdditionalProperties: function() {
|
2800 |
| - return this.schema.additionalProperties !== false && !this.jsoneditor.options.no_additional_properties; |
| 2823 | + return (this.schema.additionalProperties === true) || !this.jsoneditor.options.no_additional_properties; |
2801 | 2824 | },
|
2802 | 2825 | destroy: function() {
|
2803 | 2826 | $each(this.cached_editors, function(i,el) {
|
@@ -2837,7 +2860,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
|
2837 | 2860 | if(this.adding_property) this.refreshAddProperties();
|
2838 | 2861 | },
|
2839 | 2862 | refreshAddProperties: function() {
|
2840 |
| - if(this.options.disable_properties || this.jsoneditor.options.disable_properties) { |
| 2863 | + if(this.options.disable_properties || (this.options.disable_properties !== false && this.jsoneditor.options.disable_properties)) { |
2841 | 2864 | this.addproperty_controls.style.display = 'none';
|
2842 | 2865 | return;
|
2843 | 2866 | }
|
@@ -2897,7 +2920,6 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
|
2897 | 2920 | if(this.cached_editors[i]) continue;
|
2898 | 2921 | show_modal = true;
|
2899 | 2922 | this.addPropertyCheckbox(i);
|
2900 |
| - this.addproperty_checkboxes[i].disabled = !can_add; |
2901 | 2923 | }
|
2902 | 2924 |
|
2903 | 2925 | // If no editors can be added or removed, hide the modal button
|
@@ -6050,8 +6072,8 @@ JSONEditor.defaults.themes.foundation = JSONEditor.AbstractTheme.extend({
|
6050 | 6072 | input.group.className += ' error';
|
6051 | 6073 |
|
6052 | 6074 | if(!input.errmsg) {
|
6053 |
| - input.insertAdjacentHTML('afterend','<small class="errormsg"></small>'); |
6054 |
| - input.errmsg = input.parentNode.getElementsByClassName('errormsg')[0]; |
| 6075 | + input.insertAdjacentHTML('afterend','<small class="error"></small>'); |
| 6076 | + input.errmsg = input.parentNode.getElementsByClassName('error')[0]; |
6055 | 6077 | }
|
6056 | 6078 | else {
|
6057 | 6079 | input.errmsg.style.display = '';
|
|
0 commit comments