diff --git a/assets/javascripts/discourse/helpers/char-counter.js.es6 b/assets/javascripts/discourse/helpers/char-counter.js.es6 deleted file mode 100644 index a700a432..00000000 --- a/assets/javascripts/discourse/helpers/char-counter.js.es6 +++ /dev/null @@ -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 = `
${bodyLength} / ${I18n.t( - "wizard.x_characters", - { count: parseInt(maxLength, 10) } - )}
`; - } else { - finalString = `
${I18n.t("wizard.x_characters", { - count: parseInt(bodyLength, 10), - })}
`; - } - - return new Handlebars.SafeString(finalString); -}); diff --git a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 new file mode 100644 index 00000000..1e194314 --- /dev/null +++ b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 @@ -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 = `
${bodyLength} / ${I18n.t( + "wizard.x_characters", + { count: parseInt(maxLength, 10) } + )}
`; + } else { + finalString = `
${I18n.t("wizard.x_characters", { + count: parseInt(bodyLength, 10), + })}
`; + } + + return new Handlebars.SafeString(finalString); + } +); diff --git a/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs b/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs index efda8629..a95f9fef 100644 --- a/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs +++ b/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs @@ -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}}