mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 00:15:11 +03:00
Merge pull request #3044 from halfdan/3035-character-count
Implements character count helper.
This commit is contained in:
commit
5d14267375
17
ghost/admin/helpers/gh-count-characters.js
Normal file
17
ghost/admin/helpers/gh-count-characters.js
Normal 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;
|
@ -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>
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user