1
0
Fork 0

FEATURE: text length counter for text type fields

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-01-08 12:20:57 +05:30
Ursprung 7389afe239
Commit 10f80709c2
4 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,9 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n";
export default registerUnbound("char-counter", function(body) {
let bodyLength = body ? body.length : 0;
let characterString = bodyLength == 1 ? 'wizard.character' : 'wizard.characters';
let finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
return new Handlebars.SafeString(finalString);
});

Datei anzeigen

@ -16,6 +16,10 @@
</div> </div>
{{/if}} {{/if}}
{{#if textType}}
{{char-counter field.value}}
{{/if}}
{{#if field.errorDescription}} {{#if field.errorDescription}}
<div class='field-error-description'>{{{field.errorDescription}}}</div> <div class='field-error-description'>{{{field.errorDescription}}}</div>
{{/if}} {{/if}}

Datei anzeigen

@ -80,3 +80,7 @@ textarea {
} }
} }
.body-length {
text-align: right;
font-weight: bold;
}

Datei anzeigen

@ -469,6 +469,8 @@ en:
requires_login: "You need to be logged in to access this wizard." requires_login: "You need to be logged in to access this wizard."
reset: "Reset this wizard." reset: "Reset this wizard."
step_not_permitted: "You're not permitted to view this step." step_not_permitted: "You're not permitted to view this step."
characters: "Characters"
character: "Character"
wizard_composer: wizard_composer:
show_preview: "Preview Post" show_preview: "Preview Post"