Skip to content

Commit f46ed33

Browse files
committed
Merge branch 'Reggino-Allow-to-be-wrapped-in-form-tags'
2 parents 3231fac + c018f2c commit f46ed33

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

src/editors/array.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
459459
self.rows[i].delete_button = this.getButton(self.getItemTitle(),'delete','Delete '+self.getItemTitle());
460460
self.rows[i].delete_button.className += ' delete';
461461
self.rows[i].delete_button.setAttribute('data-i',i);
462-
self.rows[i].delete_button.addEventListener('click',function() {
462+
self.rows[i].delete_button.addEventListener('click',function(e) {
463+
e.preventDefault();
464+
e.stopPropagation();
463465
var i = this.getAttribute('data-i')*1;
464466

465467
var value = self.getValue();
@@ -499,7 +501,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
499501
self.rows[i].moveup_button = this.getButton('','moveup','Move up');
500502
self.rows[i].moveup_button.className += ' moveup';
501503
self.rows[i].moveup_button.setAttribute('data-i',i);
502-
self.rows[i].moveup_button.addEventListener('click',function() {
504+
self.rows[i].moveup_button.addEventListener('click',function(e) {
505+
e.preventDefault();
506+
e.stopPropagation();
503507
var i = this.getAttribute('data-i')*1;
504508

505509
if(i<=0) return;
@@ -525,7 +529,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
525529
self.rows[i].movedown_button = this.getButton('','movedown','Move down');
526530
self.rows[i].movedown_button.className += ' movedown';
527531
self.rows[i].movedown_button.setAttribute('data-i',i);
528-
self.rows[i].movedown_button.addEventListener('click',function() {
532+
self.rows[i].movedown_button.addEventListener('click',function(e) {
533+
e.preventDefault();
534+
e.stopPropagation();
529535
var i = this.getAttribute('data-i')*1;
530536

531537
var rows = self.getValue();
@@ -557,7 +563,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
557563
this.title_controls.appendChild(this.toggle_button);
558564
var row_holder_display = self.row_holder.style.display;
559565
var controls_display = self.controls.style.display;
560-
this.toggle_button.addEventListener('click',function() {
566+
this.toggle_button.addEventListener('click',function(e) {
567+
e.preventDefault();
568+
e.stopPropagation();
561569
if(self.collapsed) {
562570
self.collapsed = false;
563571
if(self.panel) self.panel.style.display = '';
@@ -592,7 +600,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
592600
// Add "new row" and "delete last" buttons below editor
593601
this.add_row_button = this.getButton(this.getItemTitle(),'add','Add '+this.getItemTitle());
594602

595-
this.add_row_button.addEventListener('click',function() {
603+
this.add_row_button.addEventListener('click',function(e) {
604+
e.preventDefault();
605+
e.stopPropagation();
596606
var i = self.rows.length;
597607
if(self.row_cache[i]) {
598608
self.rows[i] = self.row_cache[i];
@@ -613,7 +623,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
613623
self.controls.appendChild(this.add_row_button);
614624

615625
this.delete_last_row_button = this.getButton('Last '+this.getItemTitle(),'delete','Delete Last '+this.getItemTitle());
616-
this.delete_last_row_button.addEventListener('click',function() {
626+
this.delete_last_row_button.addEventListener('click',function(e) {
627+
e.preventDefault();
628+
e.stopPropagation();
617629
var rows = self.getValue();
618630

619631
var new_active_tab = null;
@@ -631,7 +643,9 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
631643
self.controls.appendChild(this.delete_last_row_button);
632644

633645
this.remove_all_rows_button = this.getButton('All','delete','Delete All');
634-
this.remove_all_rows_button.addEventListener('click',function() {
646+
this.remove_all_rows_button.addEventListener('click',function(e) {
647+
e.preventDefault();
648+
e.stopPropagation();
635649
self.setValue([]);
636650
if(self.parent) self.parent.onChildEditorChange(self);
637651
else self.jsoneditor.onChange();

src/editors/object.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,15 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
288288
this.editjson_textarea.style.width = '300px';
289289
this.editjson_textarea.style.display = 'block';
290290
this.editjson_save = this.getButton('Save','save','Save');
291-
this.editjson_save.addEventListener('click',function() {
291+
this.editjson_save.addEventListener('click',function(e) {
292+
e.preventDefault();
293+
e.stopPropagation();
292294
self.saveJSON();
293295
});
294296
this.editjson_cancel = this.getButton('Cancel','cancel','Cancel');
295-
this.editjson_cancel.addEventListener('click',function() {
297+
this.editjson_cancel.addEventListener('click',function(e) {
298+
e.preventDefault();
299+
e.stopPropagation();
296300
self.hideEditJSON();
297301
});
298302
this.editjson_holder.appendChild(this.editjson_textarea);
@@ -314,7 +318,9 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
314318
this.addproperty_input.style.width = '220px';
315319
this.addproperty_input.style.marginBottom = '0';
316320
this.addproperty_input.style.display = 'inline-block';
317-
this.addproperty_add.addEventListener('click',function() {
321+
this.addproperty_add.addEventListener('click',function(e) {
322+
e.preventDefault();
323+
e.stopPropagation();
318324
if(self.addproperty_input.value) {
319325
if(self.editors[self.addproperty_input.value]) {
320326
alert('there is already a property with that name');
@@ -375,7 +381,9 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
375381
this.collapsed = false;
376382
this.toggle_button = this.getButton('','collapse','Collapse');
377383
this.title_controls.appendChild(this.toggle_button);
378-
this.toggle_button.addEventListener('click',function() {
384+
this.toggle_button.addEventListener('click',function(e) {
385+
e.preventDefault();
386+
e.stopPropagation();
379387
if(self.collapsed) {
380388
self.editor_holder.style.display = '';
381389
self.collapsed = false;
@@ -403,7 +411,9 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
403411

404412
// Edit JSON Button
405413
this.editjson_button = this.getButton('JSON','edit','Edit JSON');
406-
this.editjson_button.addEventListener('click',function() {
414+
this.editjson_button.addEventListener('click',function(e) {
415+
e.preventDefault();
416+
e.stopPropagation();
407417
self.toggleEditJSON();
408418
});
409419
this.editjson_controls.appendChild(this.editjson_button);
@@ -419,7 +429,9 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
419429

420430
// Object Properties Button
421431
this.addproperty_button = this.getButton('Properties','edit','Object Properties');
422-
this.addproperty_button.addEventListener('click',function() {
432+
this.addproperty_button.addEventListener('click',function(e) {
433+
e.preventDefault();
434+
e.stopPropagation();
423435
self.toggleAddProperty();
424436
});
425437
this.addproperty_controls.appendChild(this.addproperty_button);

src/editors/table.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
330330
self.rows[i].delete_button = this.getButton('','delete','Delete');
331331
self.rows[i].delete_button.className += ' delete';
332332
self.rows[i].delete_button.setAttribute('data-i',i);
333-
self.rows[i].delete_button.addEventListener('click',function() {
333+
self.rows[i].delete_button.addEventListener('click',function(e) {
334+
e.preventDefault();
335+
e.stopPropagation();
334336
var i = this.getAttribute('data-i')*1;
335337

336338
var value = self.getValue();
@@ -353,7 +355,9 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
353355
self.rows[i].moveup_button = this.getButton('','moveup','Move up');
354356
self.rows[i].moveup_button.className += ' moveup';
355357
self.rows[i].moveup_button.setAttribute('data-i',i);
356-
self.rows[i].moveup_button.addEventListener('click',function() {
358+
self.rows[i].moveup_button.addEventListener('click',function(e) {
359+
e.preventDefault();
360+
e.stopPropagation();
357361
var i = this.getAttribute('data-i')*1;
358362

359363
if(i<=0) return;
@@ -373,7 +377,9 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
373377
self.rows[i].movedown_button = this.getButton('','movedown','Move down');
374378
self.rows[i].movedown_button.className += ' movedown';
375379
self.rows[i].movedown_button.setAttribute('data-i',i);
376-
self.rows[i].movedown_button.addEventListener('click',function() {
380+
self.rows[i].movedown_button.addEventListener('click',function(e) {
381+
e.preventDefault();
382+
e.stopPropagation();
377383
var i = this.getAttribute('data-i')*1;
378384
var rows = self.getValue();
379385
if(i>=rows.length-1) return;

0 commit comments

Comments
 (0)