Skip to content

Commit

Permalink
update json on paste - Fixes #2114
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Apr 1, 2018
1 parent 6edccc6 commit 4c71967
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions app/core/interfaces/json/interface.js
Expand Up @@ -4,21 +4,21 @@ define(['core/UIView'], function (UIView) {
events: {
'keydown textarea': 'process',
'keyup textarea': 'onKeyUp',
'input textarea': 'onInputChange',
'click .interface_json_example': 'fillWithExample'
},
change: 0,
lastValue: '',
onKeyUp: function (event) {
var value = event.currentTarget.value;

this.validate(event.currentTarget);
this.model.set(this.name, value);
this.updateValue(event.currentTarget.value);
},
onInputChange: function (event) {
this.updateValue(event.currentTarget.value);
},
process: function (event) {
var textarea = event.target;

this.change = textarea.value.length - this.lastValue.length;

var caret = textarea.selectionStart;

var code = event.keyCode;
Expand Down Expand Up @@ -54,8 +54,17 @@ define(['core/UIView'], function (UIView) {
}
},

validate: function (target) {
var value = target.value;
updateValue: function (newValue) {
this.validate(newValue);
this.model.set(this.name, newValue);
},

validate: function (value) {
var target = this.$('#' + this.name).get(0);

if (!value || !target) {
return;
}

if (value.length === 0) {
return target.classList.remove('invalid');
Expand Down Expand Up @@ -161,7 +170,7 @@ define(['core/UIView'], function (UIView) {
},

afterRender: function () {
this.validate(this.$('#' + this.name).get(0));
this.validate(this.model.get(this.name));
}
});
});

0 comments on commit 4c71967

Please sign in to comment.