Ghost/ghost/admin/app/helpers/gh-count-characters.js
Aileen Nowak 67ded0c8ed 🎨 User profile settings page layout updates (#695)
closes TryGhost/Ghost#7134

Overhaul of the user settings page to make it more consistent with other settings panels.
The hardly readable validation for user "Full Name" is redundant as well, as the input field for it now has the same styles as the other input fields.
2017-05-17 13:24:31 +01:00

32 lines
743 B
JavaScript

import {helper} from 'ember-helper';
import {htmlSafe} from 'ember-string';
export function countCharacters(params) {
if (!params || !params.length) {
return;
}
let el = document.createElement('span');
let content = params[0] || '';
// convert to array so that we get accurate symbol counts for multibyte chars
// this will still count emoji+modifer as two chars
let {length} = Array.from(content);
el.className = 'word-count';
if (length > 180) {
el.style.color = '#f05230';
} else {
el.style.color = '#738a94';
}
el.innerHTML = 200 - length;
return htmlSafe(el.outerHTML);
}
export default helper(function (params) {
return countCharacters(params);
});