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

45 Zeilen
1.005 B
JavaScript

2024-11-22 17:11:51 +01:00
import TextField from "discourse/components/text-field";
import { isLTR, isRTL, siteDir } from "discourse/lib/text-direction";
2024-11-22 17:11:51 +01:00
import computed from "discourse-common/utils/decorators";
import I18n from "I18n";
2018-02-08 05:30:55 +01:00
export default TextField.extend({
attributeBindings: [
"autocorrect",
"autocapitalize",
"autofocus",
"maxLength",
"dir",
],
2018-02-08 05:30:55 +01:00
@computed
dir() {
2022-03-16 12:33:34 +01:00
if (this.siteSettings.support_mixed_text_direction) {
2018-02-08 05:30:55 +01:00
let val = this.value;
if (val) {
return isRTL(val) ? "rtl" : "ltr";
2018-02-08 05:30:55 +01:00
} else {
return siteDir();
}
}
},
keyUp() {
2022-03-16 12:33:34 +01:00
if (this.siteSettings.support_mixed_text_direction) {
2018-02-08 05:30:55 +01:00
let val = this.value;
if (isRTL(val)) {
this.set("dir", "rtl");
2018-02-08 05:30:55 +01:00
} else if (isLTR(val)) {
this.set("dir", "ltr");
2018-02-08 05:30:55 +01:00
} else {
this.set("dir", siteDir());
2018-02-08 05:30:55 +01:00
}
}
},
@computed("placeholderKey")
placeholder(placeholderKey) {
return placeholderKey ? I18n.t(placeholderKey) : "";
},
2018-02-08 05:30:55 +01:00
});