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:
parent
3cae5a55dd
commit
de53f09f79
3 changed files with 19 additions and 2 deletions
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}}
|
{{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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue