diff --git a/ghost/admin/helpers/gh-count-characters.js b/ghost/admin/helpers/gh-count-characters.js new file mode 100644 index 0000000000..b5b22f626d --- /dev/null +++ b/ghost/admin/helpers/gh-count-characters.js @@ -0,0 +1,17 @@ +var countCharacters = Ember.Handlebars.makeBoundHelper(function (content) { + var el = document.createElement('span'), + length = content ? content.length : 0; + + el.className = 'word-count'; + if (length > 180) { + el.style.color = '#E25440'; + } else { + el.style.color = '#9E9D95'; + } + + el.innerHTML = 200 - length; + + return new Ember.Handlebars.SafeString(el.outerHTML); +}); + +export default countCharacters; \ No newline at end of file diff --git a/ghost/admin/templates/settings/general.hbs b/ghost/admin/templates/settings/general.hbs index 7d69486a08..37de9f57f2 100644 --- a/ghost/admin/templates/settings/general.hbs +++ b/ghost/admin/templates/settings/general.hbs @@ -21,7 +21,7 @@ {{textarea id="blog-description" value=description}}

Describe what your blog is about - {{gh-count-words description}} + {{gh-count-characters description}}

diff --git a/ghost/admin/templates/settings/user.hbs b/ghost/admin/templates/settings/user.hbs index bae5157d5f..6bdb515ed5 100644 --- a/ghost/admin/templates/settings/user.hbs +++ b/ghost/admin/templates/settings/user.hbs @@ -56,7 +56,7 @@ {{textarea id="user-bio" value=user.bio}}

Write about you, in 200 characters or less. - {{gh-count-words user.bio}} + {{gh-count-characters user.bio}}