Merge branch 'main' into field_focus_fix
Dieser Commit ist enthalten in:
Commit
6429bff31a
3 geänderte Dateien mit 26 neuen und 23 gelöschten Zeilen
|
@ -1,22 +0,0 @@
|
|||
import { registerUnbound } from "discourse-common/lib/helpers";
|
||||
import I18n from "I18n";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
export default registerUnbound("char-counter", function (body, maxLength) {
|
||||
let bodyLength = body ? body.length : 0;
|
||||
let finalString;
|
||||
|
||||
if (maxLength) {
|
||||
let isOverMax = bodyLength > maxLength ? "true" : "false";
|
||||
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
|
||||
"wizard.x_characters",
|
||||
{ count: parseInt(maxLength, 10) }
|
||||
)}</div>`;
|
||||
} else {
|
||||
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
|
||||
count: parseInt(bodyLength, 10),
|
||||
})}</div>`;
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString(finalString);
|
||||
});
|
25
assets/javascripts/discourse/helpers/wizard-char-counter.js.es6
Normale Datei
25
assets/javascripts/discourse/helpers/wizard-char-counter.js.es6
Normale Datei
|
@ -0,0 +1,25 @@
|
|||
import { registerUnbound } from "discourse-common/lib/helpers";
|
||||
import I18n from "I18n";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
export default registerUnbound(
|
||||
"wizard-char-counter",
|
||||
function (body, maxLength) {
|
||||
let bodyLength = body ? body.length : 0;
|
||||
let finalString;
|
||||
|
||||
if (maxLength) {
|
||||
let isOverMax = bodyLength > maxLength ? "true" : "false";
|
||||
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
|
||||
"wizard.x_characters",
|
||||
{ count: parseInt(maxLength, 10) }
|
||||
)}</div>`;
|
||||
} else {
|
||||
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
|
||||
count: parseInt(bodyLength, 10),
|
||||
})}</div>`;
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString(finalString);
|
||||
}
|
||||
);
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
{{#if field.char_counter}}
|
||||
{{#if textType}}
|
||||
{{char-counter field.value field.max_length}}
|
||||
{{wizard-char-counter field.value field.max_length}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
|
Laden …
In neuem Issue referenzieren