Update wizard-char-counter.js.es6
Dieser Commit ist enthalten in:
Ursprung
c4e2f2a4a8
Commit
fa3e2d0c55
1 geänderte Dateien mit 19 neuen und 16 gelöschten Zeilen
|
@ -2,21 +2,24 @@ import { registerUnbound } from "discourse-common/lib/helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import Handlebars from "handlebars";
|
import Handlebars from "handlebars";
|
||||||
|
|
||||||
export default registerUnbound("wizard-char-counter", function (body, maxLength) {
|
export default registerUnbound(
|
||||||
let bodyLength = body ? body.length : 0;
|
"wizard-char-counter",
|
||||||
let finalString;
|
function (body, maxLength) {
|
||||||
|
let bodyLength = body ? body.length : 0;
|
||||||
|
let finalString;
|
||||||
|
|
||||||
if (maxLength) {
|
if (maxLength) {
|
||||||
let isOverMax = bodyLength > maxLength ? "true" : "false";
|
let isOverMax = bodyLength > maxLength ? "true" : "false";
|
||||||
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
|
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
|
||||||
"wizard.x_characters",
|
"wizard.x_characters",
|
||||||
{ count: parseInt(maxLength, 10) }
|
{ count: parseInt(maxLength, 10) }
|
||||||
)}</div>`;
|
)}</div>`;
|
||||||
} else {
|
} else {
|
||||||
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
|
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
|
||||||
count: parseInt(bodyLength, 10),
|
count: parseInt(bodyLength, 10),
|
||||||
})}</div>`;
|
})}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Handlebars.SafeString(finalString);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
return new Handlebars.SafeString(finalString);
|
|
||||||
});
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren