Merge pull request #3044 from halfdan/3035-character-count

Implements character count helper.
This commit is contained in:
Hannah Wolfe 2014-06-23 22:14:15 +01:00
commit 5d14267375
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}}
<p>
Describe what your blog is about
<span class="word-count">{{gh-count-words description}}</span>
{{gh-count-characters description}}
</p>
</div>

View File

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