mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #3044 from halfdan/3035-character-count
Implements character count helper.
This commit is contained in:
commit
3f6ac4441f
4 changed files with 45 additions and 32 deletions
17
core/client/helpers/gh-count-characters.js
Normal file
17
core/client/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>
|
||||
|
||||
|
|
|
@ -286,36 +286,32 @@ CasperTest.emberBegin('General settings pane is correct', 8, function suite(test
|
|||
//});
|
||||
//
|
||||
//
|
||||
//CasperTest.emberBegin('User settings screen shows remaining characters for Bio properly', 4, function suite(test) {
|
||||
// casper.thenOpenAndWaitForPageLoad('settings.user', function testTitleAndUrl() {
|
||||
// test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
// test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
|
||||
// });
|
||||
//
|
||||
// function getRemainingBioCharacterCount() {
|
||||
// return casper.getHTML('.word-count');
|
||||
// }
|
||||
//
|
||||
// casper.thenOpenAndWaitForPageLoad(url + 'ghost/settings/user/', function testTitleAndUrl() {
|
||||
// test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
// test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
|
||||
// });
|
||||
//
|
||||
// casper.then(function checkCharacterCount() {
|
||||
// test.assert(getRemainingBioCharacterCount() === '200', 'Bio remaining characters is 200');
|
||||
// });
|
||||
//
|
||||
// casper.then(function setBioToValid() {
|
||||
// casper.fillSelectors('.user-profile', {
|
||||
// '#user-bio': 'asdf\n' // 5 characters
|
||||
// }, false);
|
||||
// });
|
||||
//
|
||||
// casper.then(function checkCharacterCount() {
|
||||
// test.assert(getRemainingBioCharacterCount() === '195', 'Bio remaining characters is 195');
|
||||
// });
|
||||
//});
|
||||
//
|
||||
CasperTest.emberBegin('User settings screen shows remaining characters for Bio properly', 4, function suite(test) {
|
||||
casper.thenOpenAndWaitForPageLoad('settings.user', function testTitleAndUrl() {
|
||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
test.assertUrlMatch(/ghost\/ember\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
|
||||
});
|
||||
|
||||
function getRemainingBioCharacterCount() {
|
||||
return casper.getHTML('.word-count');
|
||||
}
|
||||
|
||||
casper.then(function checkCharacterCount() {
|
||||
console.log("PENIS " + getRemainingBioCharacterCount());
|
||||
test.assert(getRemainingBioCharacterCount() === '200', 'Bio remaining characters is 200');
|
||||
});
|
||||
|
||||
casper.then(function setBioToValid() {
|
||||
casper.fillSelectors('.user-profile', {
|
||||
'#user-bio': 'asdf\n' // 5 characters
|
||||
}, false);
|
||||
});
|
||||
|
||||
casper.then(function checkCharacterCount() {
|
||||
test.assert(getRemainingBioCharacterCount() === '195', 'Bio remaining characters is 195');
|
||||
});
|
||||
});
|
||||
|
||||
//CasperTest.emberBegin('Ensure user bio field length validation', 3, function suite(test) {
|
||||
// casper.thenOpenAndWaitForPageLoad('settings.user', function testTitleAndUrl() {
|
||||
// test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
|
|
Loading…
Add table
Reference in a new issue