Skip to content

Commit 72bfa10

Browse files
yiwenliuyiwenliu
yiwenliu
authored and
yiwenliu
committed
If function disable is called with param always_disabled set to true, update flag always_disabled for any editor
1 parent fc0ea1b commit 72bfa10

11 files changed

+25
-14
lines changed

src/editors/array.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
4646
this._super();
4747
}
4848
},
49-
disable: function() {
49+
disable: function(always_disabled) {
50+
if(always_disabled) this.always_disabled = true;
5051
if(this.add_row_button) this.add_row_button.disabled = true;
5152
if(this.remove_all_rows_button) this.remove_all_rows_button.disabled = true;
5253
if(this.delete_last_row_button) this.delete_last_row_button.disabled = true;
5354

5455
if(this.rows) {
5556
for(var i=0; i<this.rows.length; i++) {
56-
this.rows[i].disable();
57+
this.rows[i].disable(always_disabled);
5758

5859
if(this.rows[i].moveup_button) this.rows[i].moveup_button.disabled = true;
5960
if(this.rows[i].movedown_button) this.rows[i].movedown_button.disabled = true;

src/editors/base64.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ JSONEditor.defaults.editors.base64 = JSONEditor.AbstractEditor.extend({
7272
this._super();
7373
}
7474
},
75-
disable: function() {
75+
disable: function(always_disabled) {
76+
if(always_disabled) this.always_disabled = true;
7677
if(this.uploader) this.uploader.disabled = true;
7778
this._super();
7879
},

src/editors/checkbox.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ JSONEditor.defaults.editors.checkbox = JSONEditor.AbstractEditor.extend({
4848
this._super();
4949
}
5050
},
51-
disable: function() {
51+
disable: function(always_disabled) {
52+
if(always_disabled) this.always_disabled = true;
5253
this.input.disabled = true;
5354
this._super();
5455
},

src/editors/enum.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ JSONEditor.defaults.editors["enum"] = JSONEditor.AbstractEditor.extend({
6767
this._super();
6868
}
6969
},
70-
disable: function() {
70+
disable: function(always_disabled) {
71+
if(always_disabled) this.always_disabled = true;
7172
this.switcher.disabled = true;
7273
this._super();
7374
},

src/editors/multiple.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ JSONEditor.defaults.editors.multiple = JSONEditor.AbstractEditor.extend({
3535
this._super();
3636
}
3737
},
38-
disable: function() {
38+
disable: function(always_disabled) {
39+
if(always_disabled) this.always_disabled = true;
3940
if(this.editors) {
4041
for(var i=0; i<this.editors.length; i++) {
4142
if(!this.editors[i]) continue;
42-
this.editors[i].disable();
43+
this.editors[i].disable(always_disabled);
4344
}
4445
}
4546
this.switcher.disabled = true;

src/editors/multiselect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ JSONEditor.defaults.editors.multiselect = JSONEditor.AbstractEditor.extend({
179179
this._super();
180180
}
181181
},
182-
disable: function() {
182+
disable: function(always_disabled) {
183+
if(always_disabled) this.always_disabled = true;
183184
if(this.input) {
184185
this.input.disabled = true;
185186
}

src/editors/object.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
4040
}
4141
}
4242
},
43-
disable: function() {
43+
disable: function(always_disabled) {
44+
if(always_disabled) this.always_disabled = true;
4445
if(this.editjson_button) this.editjson_button.disabled = true;
4546
if(this.addproperty_button) this.addproperty_button.disabled = true;
4647
this.hideEditJSON();
@@ -49,7 +50,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
4950
if(this.editors) {
5051
for(var i in this.editors) {
5152
if(!this.editors.hasOwnProperty(i)) continue;
52-
this.editors[i].disable();
53+
this.editors[i].disable(always_disabled);
5354
}
5455
}
5556
},

src/editors/select.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
336336
this._super();
337337
}
338338
},
339-
disable: function() {
339+
disable: function(always_disabled) {
340+
if(always_disabled) this.always_disabled = true;
340341
this.input.disabled = true;
341342
if(this.select2) this.select2.select2("enable",false);
342343
this._super();

src/editors/selectize.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ JSONEditor.defaults.editors.selectize = JSONEditor.AbstractEditor.extend({
327327
this._super();
328328
}
329329
},
330-
disable: function() {
330+
disable: function(always_disabled) {
331+
if(always_disabled) this.always_disabled = true;
331332
this.input.disabled = true;
332333
if(this.selectize) {
333334
this.selectize[0].selectize.lock();

src/editors/string.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
280280
this._super();
281281
}
282282
},
283-
disable: function() {
283+
disable: function(always_disabled) {
284+
if(always_disabled) this.always_disabled = true;
284285
this.input.disabled = true;
285286
// TODO: WYSIWYG and Markdown editors
286287
this._super();

src/editors/upload.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ JSONEditor.defaults.editors.upload = JSONEditor.AbstractEditor.extend({
114114
this._super();
115115
}
116116
},
117-
disable: function() {
117+
disable: function(always_disabled) {
118+
if(always_disabled) this.always_disabled = true;
118119
if(this.uploader) this.uploader.disabled = true;
119120
this._super();
120121
},

0 commit comments

Comments
 (0)