1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/helpers/gh-count-characters.js

24 lines
511 B
JavaScript

import {helper} from 'ember-helper';
import {htmlSafe} from 'ember-string';
export default helper(function (params) {
if (!params || !params.length) {
return;
}
let el = document.createElement('span');
let content = params[0] || '';
let {length} = content;
el.className = 'word-count';
if (length > 180) {
el.style.color = '#E25440';
} else {
el.style.color = '#9E9D95';
}
el.innerHTML = 200 - length;
return htmlSafe(el.outerHTML);
});