updated char counter logic
Dieser Commit ist enthalten in:
Ursprung
4f70aea729
Commit
f27ca60d24
1 geänderte Dateien mit 10 neuen und 3 gelöschten Zeilen
|
@ -1,9 +1,16 @@
|
|||
import { registerUnbound } from "discourse-common/lib/helpers";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default registerUnbound("char-counter", function(body) {
|
||||
export default registerUnbound("char-counter", function(body, maxLength) {
|
||||
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>`;
|
||||
let length = maxLength || bodyLength;
|
||||
let characterString = length == 1 ? 'wizard.character' : 'wizard.characters';
|
||||
let finalString;
|
||||
|
||||
if(maxLength) {
|
||||
finalString = `<div class="body-length">${bodyLength} / ${maxLength} ${ I18n.t(characterString)}</div>`;
|
||||
} else {
|
||||
finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
|
||||
}
|
||||
return new Handlebars.SafeString(finalString);
|
||||
});
|
||||
|
|
Laden …
In neuem Issue referenzieren