Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 02:30:28 +01:00
0602e59d70
- Fix failing test - Handle deprecations - Fix typos
44 Zeilen
1.005 B
JavaScript
44 Zeilen
1.005 B
JavaScript
import computed from "discourse-common/utils/decorators";
|
|
import { isLTR, isRTL, siteDir } from "discourse/lib/text-direction";
|
|
import I18n from "I18n";
|
|
import TextField from "discourse/components/text-field";
|
|
|
|
export default TextField.extend({
|
|
attributeBindings: [
|
|
"autocorrect",
|
|
"autocapitalize",
|
|
"autofocus",
|
|
"maxLength",
|
|
"dir",
|
|
],
|
|
|
|
@computed
|
|
dir() {
|
|
if (this.siteSettings.support_mixed_text_direction) {
|
|
let val = this.value;
|
|
if (val) {
|
|
return isRTL(val) ? "rtl" : "ltr";
|
|
} else {
|
|
return siteDir();
|
|
}
|
|
}
|
|
},
|
|
|
|
keyUp() {
|
|
if (this.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 ? I18n.t(placeholderKey) : "";
|
|
},
|
|
});
|