2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2015-02-09 15:57:50 +00:00
|
|
|
var countCharacters = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
|
2014-06-23 20:02:09 +00:00
|
|
|
var el = document.createElement('span'),
|
2015-02-09 15:57:50 +00:00
|
|
|
length,
|
|
|
|
content;
|
|
|
|
|
|
|
|
if (!arr || !arr.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
content = arr[0] || '';
|
|
|
|
length = content.length;
|
2014-06-23 20:02:09 +00:00
|
|
|
|
|
|
|
el.className = 'word-count';
|
2014-10-24 21:09:50 +00:00
|
|
|
|
2014-06-23 20:02:09 +00:00
|
|
|
if (length > 180) {
|
|
|
|
el.style.color = '#E25440';
|
|
|
|
} else {
|
|
|
|
el.style.color = '#9E9D95';
|
|
|
|
}
|
|
|
|
|
|
|
|
el.innerHTML = 200 - length;
|
|
|
|
|
2015-02-09 15:57:50 +00:00
|
|
|
return Ember.String.htmlSafe(el.outerHTML);
|
2014-06-23 20:02:09 +00:00
|
|
|
});
|
|
|
|
|
2014-10-24 21:09:50 +00:00
|
|
|
export default countCharacters;
|