0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00
discourse-custom-wizard/assets/javascripts/wizard/components/wizard-text-field.js.es6

40 Zeilen
982 B
Text

/* eslint no-undef: 0 */
2020-03-21 18:30:11 +01:00
import computed from "discourse-common/utils/decorators";
2018-02-08 05:30:55 +01:00
import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction";
import WizardI18n from "../lib/wizard-i18n";
2018-02-08 05:30:55 +01:00
export default Ember.TextField.extend({
attributeBindings: ['autocorrect', 'autocapitalize', 'autofocus', 'maxLength', 'dir'],
@computed
dir() {
if (Wizard.SiteSettings.support_mixed_text_direction) {
let val = this.value;
if (val) {
return isRTL(val) ? 'rtl' : 'ltr';
} else {
return siteDir();
}
}
},
keyUp() {
if (Wizard.SiteSettings.support_mixed_text_direction) {
let val = this.value;
if (isRTL(val)) {
this.set('dir', 'rtl');
} else if (isLTR(val)) {
this.set('dir', 'ltr');
} else {
this.set('dir', siteDir());
}
}
},
@computed("placeholderKey")
placeholder(placeholderKey) {
return placeholderKey ? WizardI18n(placeholderKey) : "";
2018-02-08 05:30:55 +01:00
}
});