Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/editors/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,32 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
}
},
enable: function() {
if(this.add_row_button) this.add_row_button.disabled = false;
if(this.remove_all_rows_button) this.remove_all_rows_button.disabled = false;
if(this.delete_last_row_button) this.delete_last_row_button.disabled = false;

if(this.rows) {
for(var i=0; i<this.rows.length; i++) {
this.rows[i].enable();

if(this.rows[i].moveup_button) this.rows[i].moveup_button.disabled = false;
if(this.rows[i].movedown_button) this.rows[i].movedown_button.disabled = false;
if(this.rows[i].delete_button) this.rows[i].delete_button.disabled = false;
if(!this.always_disabled) {
if(this.add_row_button) this.add_row_button.disabled = false;
if(this.remove_all_rows_button) this.remove_all_rows_button.disabled = false;
if(this.delete_last_row_button) this.delete_last_row_button.disabled = false;

if(this.rows) {
for(var i=0; i<this.rows.length; i++) {
this.rows[i].enable();

if(this.rows[i].moveup_button) this.rows[i].moveup_button.disabled = false;
if(this.rows[i].movedown_button) this.rows[i].movedown_button.disabled = false;
if(this.rows[i].delete_button) this.rows[i].delete_button.disabled = false;
}
}
this._super();
}
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
if(this.add_row_button) this.add_row_button.disabled = true;
if(this.remove_all_rows_button) this.remove_all_rows_button.disabled = true;
if(this.delete_last_row_button) this.delete_last_row_button.disabled = true;

if(this.rows) {
for(var i=0; i<this.rows.length; i++) {
this.rows[i].disable();
this.rows[i].disable(always_disabled);

if(this.rows[i].moveup_button) this.rows[i].moveup_button.disabled = true;
if(this.rows[i].movedown_button) this.rows[i].movedown_button.disabled = true;
Expand Down
9 changes: 6 additions & 3 deletions src/editors/base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ JSONEditor.defaults.editors.base64 = JSONEditor.AbstractEditor.extend({
}
},
enable: function() {
if(this.uploader) this.uploader.disabled = false;
this._super();
if(!this.always_disabled) {
if(this.uploader) this.uploader.disabled = false;
this._super();
}
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
if(this.uploader) this.uploader.disabled = true;
this._super();
},
Expand Down
5 changes: 3 additions & 2 deletions src/editors/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ JSONEditor.defaults.editors.checkbox = JSONEditor.AbstractEditor.extend({
enable: function() {
if(!this.always_disabled) {
this.input.disabled = false;
this._super();
}
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
this.input.disabled = true;
this._super();
},
Expand Down
9 changes: 6 additions & 3 deletions src/editors/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ JSONEditor.defaults.editors["enum"] = JSONEditor.AbstractEditor.extend({
this.display_area.innerHTML = this.html_values[this.selected];
},
enable: function() {
if(!this.always_disabled) this.switcher.disabled = false;
this._super();
if(!this.always_disabled) {
this.switcher.disabled = false;
this._super();
}
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
this.switcher.disabled = true;
this._super();
},
Expand Down
19 changes: 11 additions & 8 deletions src/editors/multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ JSONEditor.defaults.editors.multiple = JSONEditor.AbstractEditor.extend({
return Math.max(this.editors[this.type].getNumColumns(),4);
},
enable: function() {
if(this.editors) {
for(var i=0; i<this.editors.length; i++) {
if(!this.editors[i]) continue;
this.editors[i].enable();
if(!this.always_disabled) {
if(this.editors) {
for(var i=0; i<this.editors.length; i++) {
if(!this.editors[i]) continue;
this.editors[i].enable();
}
}
this.switcher.disabled = false;
this._super();
}
this.switcher.disabled = false;
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
if(this.editors) {
for(var i=0; i<this.editors.length; i++) {
if(!this.editors[i]) continue;
this.editors[i].disable();
this.editors[i].disable(always_disabled);
}
}
this.switcher.disabled = true;
Expand Down
5 changes: 3 additions & 2 deletions src/editors/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,11 @@ JSONEditor.defaults.editors.multiselect = JSONEditor.AbstractEditor.extend({
}
}
if(this.select2) this.select2.select2("enable",true);
this._super();
}
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
if(this.input) {
this.input.disabled = true;
}
Expand Down
23 changes: 13 additions & 10 deletions src/editors/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
return Math.max(Math.min(12,this.maxwidth),3);
},
enable: function() {
if(this.editjson_button) this.editjson_button.disabled = false;
if(this.addproperty_button) this.addproperty_button.disabled = false;

this._super();
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
this.editors[i].enable();
if(!this.always_disabled) {
if(this.editjson_button) this.editjson_button.disabled = false;
if(this.addproperty_button) this.addproperty_button.disabled = false;

this._super();
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
this.editors[i].enable();
}
}
}
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
if(this.editjson_button) this.editjson_button.disabled = true;
if(this.addproperty_button) this.addproperty_button.disabled = true;
this.hideEditJSON();
Expand All @@ -47,7 +50,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
if(this.editors) {
for(var i in this.editors) {
if(!this.editors.hasOwnProperty(i)) continue;
this.editors[i].disable();
this.editors[i].disable(always_disabled);
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/editors/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,11 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
if(!this.always_disabled) {
this.input.disabled = false;
if(this.select2) this.select2.select2("enable",true);
this._super();
}
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
this.input.disabled = true;
if(this.select2) this.select2.select2("enable",false);
this._super();
Expand Down
5 changes: 3 additions & 2 deletions src/editors/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,11 @@ JSONEditor.defaults.editors.selectize = JSONEditor.AbstractEditor.extend({
if(this.selectize) {
this.selectize[0].selectize.unlock();
}
this._super();
}
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
this.input.disabled = true;
if(this.selectize) {
this.selectize[0].selectize.lock();
Expand Down
5 changes: 3 additions & 2 deletions src/editors/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,11 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
if(!this.always_disabled) {
this.input.disabled = false;
// TODO: WYSIWYG and Markdown editors
this._super();
}
this._super();
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
this.input.disabled = true;
// TODO: WYSIWYG and Markdown editors
this._super();
Expand Down
9 changes: 6 additions & 3 deletions src/editors/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ JSONEditor.defaults.editors.upload = JSONEditor.AbstractEditor.extend({
});
},
enable: function() {
if(this.uploader) this.uploader.disabled = false;
this._super();
if(!this.always_disabled) {
if(this.uploader) this.uploader.disabled = false;
this._super();
}
},
disable: function() {
disable: function(always_disabled) {
if(always_disabled) this.always_disabled = true;
if(this.uploader) this.uploader.disabled = true;
this._super();
},
Expand Down