Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
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 { registerUnbound } from "discourse-common/lib/helpers";
|
||||||
import I18n from "I18n";
|
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 bodyLength = body ? body.length : 0;
|
||||||
let characterString = bodyLength == 1 ? 'wizard.character' : 'wizard.characters';
|
let length = maxLength || bodyLength;
|
||||||
let finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
|
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);
|
return new Handlebars.SafeString(finalString);
|
||||||
});
|
});
|
||||||
|
|
Laden …
In neuem Issue referenzieren