2014-11-30 22:27:09 +03:00
|
|
|
/*global device*/
|
2014-06-23 21:50:28 +04:00
|
|
|
var TrimFocusInput = Ember.TextField.extend({
|
2014-08-08 17:30:51 +04:00
|
|
|
focus: true,
|
|
|
|
|
2014-11-30 22:27:09 +03:00
|
|
|
attributeBindings: ['autofocus'],
|
|
|
|
|
|
|
|
autofocus: Ember.computed(function () {
|
|
|
|
return (device.ios()) ? false : 'autofocus';
|
|
|
|
}),
|
|
|
|
|
2014-06-23 21:50:28 +04:00
|
|
|
setFocus: function () {
|
2014-11-30 22:27:09 +03:00
|
|
|
// This fix is required until Mobile Safari has reliable
|
|
|
|
// autofocus, select() or focus() support
|
|
|
|
if (this.focus && !device.ios()) {
|
2014-08-08 17:30:51 +04:00
|
|
|
this.$().val(this.$().val()).focus();
|
|
|
|
}
|
2014-06-23 21:50:28 +04:00
|
|
|
}.on('didInsertElement'),
|
|
|
|
|
|
|
|
focusOut: function () {
|
|
|
|
var text = this.$().val();
|
|
|
|
|
|
|
|
this.$().val(text.trim());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default TrimFocusInput;
|