0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

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>
{{/if}}
{{#if textType}}
{{char-counter field.value}}
{{/if}}
{{#if field.errorDescription}}
<div class='field-error-description'>{{{field.errorDescription}}}</div>
{{/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."
reset: "Reset this wizard."
step_not_permitted: "You're not permitted to view this step."
characters: "Characters"
character: "Character"
wizard_composer:
show_preview: "Preview Post"