mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
df58953778
no issue - updates `gh-trim-focus-input` to extend from `gh-input`/`one-way-input` to get the auto-binding attribute behaviour for passed-in HTML attributes - renames `focus` property to `shouldFocus` so that we're not overriding default DOM functions - fixes signin page issues with missing placeholders and no autofocus
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
/*global device*/
|
|
import Ember from 'ember';
|
|
import GhostInput from 'ghost-admin/components/gh-input';
|
|
|
|
const {computed} = Ember;
|
|
|
|
/**
|
|
* 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
|
|
*/
|
|
const TrimFocusInputComponent = GhostInput.extend({
|
|
|
|
shouldFocus: true,
|
|
|
|
attributeBindings: ['autofocus'],
|
|
|
|
autofocus: computed(function () {
|
|
if (this.get('shouldFocus')) {
|
|
return (device.ios()) ? false : 'autofocus';
|
|
}
|
|
|
|
return false;
|
|
}),
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
},
|
|
|
|
didInsertElement() {
|
|
this._super(...arguments);
|
|
this._focus();
|
|
},
|
|
|
|
sanitizeInput(input) {
|
|
return input.trim();
|
|
},
|
|
|
|
_focus() {
|
|
// Until mobile safari has better support
|
|
// for focusing, we just ignore it
|
|
if (this.get('shouldFocus') && !device.ios()) {
|
|
this.element.focus();
|
|
}
|
|
}
|
|
});
|
|
|
|
export default TrimFocusInputComponent;
|