0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Implements character count helper.

closes #3035
- New character count helper
- Re-add casper test for bio count
- Change settings.general and settings.user to show character count
This commit is contained in:
Fabian Becker 2014-06-23 20:02:09 +00:00
parent 3cae5a55dd
commit de53f09f79
3 changed files with 19 additions and 2 deletions

View file

@ -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;

View file

@ -21,7 +21,7 @@
{{textarea id="blog-description" value=description}} {{textarea id="blog-description" value=description}}
<p> <p>
Describe what your blog is about Describe what your blog is about
<span class="word-count">{{gh-count-words description}}</span> {{gh-count-characters description}}
</p> </p>
</div> </div>

View file

@ -56,7 +56,7 @@
{{textarea id="user-bio" value=user.bio}} {{textarea id="user-bio" value=user.bio}}
<p> <p>
Write about you, in 200 characters or less. Write about you, in 200 characters or less.
<span class="word-count">{{gh-count-words user.bio}}</span> {{gh-count-characters user.bio}}
</p> </p>
</div> </div>