wizard-text-field.js.es6 938 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* eslint no-undef: 0 */
  2. import computed from "ember-addons/ember-computed-decorators";
  3. import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction";
  4. export default Ember.TextField.extend({
  5. attributeBindings: ['autocorrect', 'autocapitalize', 'autofocus', 'maxLength', 'dir'],
  6. @computed
  7. dir() {
  8. if (Wizard.SiteSettings.support_mixed_text_direction) {
  9. let val = this.value;
  10. if (val) {
  11. return isRTL(val) ? 'rtl' : 'ltr';
  12. } else {
  13. return siteDir();
  14. }
  15. }
  16. },
  17. keyUp() {
  18. if (Wizard.SiteSettings.support_mixed_text_direction) {
  19. let val = this.value;
  20. if (isRTL(val)) {
  21. this.set('dir', 'rtl');
  22. } else if (isLTR(val)) {
  23. this.set('dir', 'ltr');
  24. } else {
  25. this.set('dir', siteDir());
  26. }
  27. }
  28. },
  29. @computed("placeholderKey")
  30. placeholder(placeholderKey) {
  31. return placeholderKey ? I18n.t(placeholderKey) : "";
  32. }
  33. });