Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2645 from christopheschwyzer/autosave-text
Browse files Browse the repository at this point in the history
BREAKING CM-CR-83 FB-643 Introduce "disableTriggerChangeOnInput" for CM_FormField_Text
  • Loading branch information
Christophe Schwyzer authored Jun 13, 2017
2 parents ba035d4 + b329881 commit 0038905
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 0 additions & 4 deletions library/CM/Form/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ var CM_Form_Example = CM_Form_Abstract.extend({
this.getFields().forEach(function(field) {
field.on('ready', function() {
field.on('change', form.logData.bind(form));

if (field instanceof CM_FormField_Text) {
field.enableTriggerChangeOnInput();
}
});
});

Expand Down
2 changes: 0 additions & 2 deletions library/CM/FormField/Password.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ var CM_FormField_Password = CM_FormField_Text.extend({
},

ready: function() {
this.enableTriggerChangeOnInput();

var self = this;
var visibilityDesired;
this.getForm()
Expand Down
8 changes: 4 additions & 4 deletions library/CM/FormField/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ var CM_FormField_Text = CM_FormField_Abstract.extend({
}
},

/**
* @deprecated No need to call this function anymore. Text field always triggers "change".
*/
enableTriggerChangeOnInput: function() {
disableTriggerChangeOnInput: function() {
this.delegateEvents(
_(this.events).omit('input input')
);
}
});
7 changes: 7 additions & 0 deletions library/CM/FormField/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var CM_FormField_Textarea = CM_FormField_Text.extend({
events: {
'blur [contenteditable]': function() {
this.trigger('blur');
this.triggerChange();
},
'focus [contenteditable]': function() {
this.trigger('focus');
Expand Down Expand Up @@ -87,6 +88,12 @@ var CM_FormField_Textarea = CM_FormField_Text.extend({
this.setValue('');
},

disableTriggerChangeOnInput: function() {
this.delegateEvents(
_(this.events).omit('input [contenteditable]')
);
},

/**
* @param {String} text
* @returns {string}
Expand Down

0 comments on commit 0038905

Please sign in to comment.