2018-03-06 04:38:33 +01:00
|
|
|
/* 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";
|
2020-11-26 06:45:30 +01:00
|
|
|
import WizardI18n from "../lib/wizard-i18n";
|
2018-02-08 05:30:55 +01:00
|
|
|
|
|
|
|
export default Ember.TextField.extend({
|
2021-03-28 11:06:49 +02:00
|
|
|
attributeBindings: [
|
|
|
|
"autocorrect",
|
|
|
|
"autocapitalize",
|
|
|
|
"autofocus",
|
|
|
|
"maxLength",
|
|
|
|
"dir",
|
|
|
|
],
|
2018-02-08 05:30:55 +01:00
|
|
|
|
|
|
|
@computed
|
|
|
|
dir() {
|
|
|
|
if (Wizard.SiteSettings.support_mixed_text_direction) {
|
|
|
|
let val = this.value;
|
|
|
|
if (val) {
|
2021-03-28 11:06:49 +02:00
|
|
|
return isRTL(val) ? "rtl" : "ltr";
|
2018-02-08 05:30:55 +01:00
|
|
|
} else {
|
|
|
|
return siteDir();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
keyUp() {
|
|
|
|
if (Wizard.SiteSettings.support_mixed_text_direction) {
|
|
|
|
let val = this.value;
|
|
|
|
if (isRTL(val)) {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("dir", "rtl");
|
2018-02-08 05:30:55 +01:00
|
|
|
} else if (isLTR(val)) {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("dir", "ltr");
|
2018-02-08 05:30:55 +01:00
|
|
|
} else {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("dir", siteDir());
|
2018-02-08 05:30:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed("placeholderKey")
|
|
|
|
placeholder(placeholderKey) {
|
2020-11-26 06:45:30 +01:00
|
|
|
return placeholderKey ? WizardI18n(placeholderKey) : "";
|
2021-03-28 11:06:49 +02:00
|
|
|
},
|
2018-02-08 05:30:55 +01:00
|
|
|
});
|