2016-06-20 17:20:25 +03:00
|
|
|
import GhostInput from 'ghost-admin/components/gh-input';
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2016-06-18 14:44:23 +03:00
|
|
|
/**
|
|
|
|
* This doesn't override the OneWayInput component because
|
|
|
|
* we need finer control. It borrows
|
|
|
|
* parts from both the OneWayInput component and Ember's default
|
|
|
|
* input component
|
|
|
|
*/
|
2016-06-20 17:20:25 +03:00
|
|
|
const TrimFocusInputComponent = GhostInput.extend({
|
2016-06-18 14:44:23 +03:00
|
|
|
|
2016-06-20 17:20:25 +03:00
|
|
|
shouldFocus: true,
|
2016-06-18 14:44:23 +03:00
|
|
|
|
2017-01-23 15:03:05 +03:00
|
|
|
focusOut(event) {
|
|
|
|
this._trimInput(event.target.value);
|
|
|
|
},
|
|
|
|
|
|
|
|
_trimInput(value) {
|
|
|
|
if (value && typeof value.trim === 'function') {
|
|
|
|
value = value.trim();
|
2016-07-22 16:36:50 +03:00
|
|
|
}
|
2017-01-23 15:03:05 +03:00
|
|
|
|
|
|
|
this._processNewValue(value);
|
2015-12-15 14:09:34 +03:00
|
|
|
}
|
2014-06-23 21:50:28 +04:00
|
|
|
});
|
2016-06-18 14:44:23 +03:00
|
|
|
|
|
|
|
export default TrimFocusInputComponent;
|