2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2015-08-19 12:55:40 +01:00
|
|
|
|
|
|
|
export default Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
|
2014-09-18 23:42:07 +00:00
|
|
|
var el = document.createElement('span'),
|
2015-02-09 15:57:50 +00:00
|
|
|
content,
|
|
|
|
maxCharacters,
|
|
|
|
length;
|
|
|
|
|
|
|
|
if (!arr || arr.length < 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
content = arr[0] || '';
|
|
|
|
maxCharacters = arr[1];
|
|
|
|
length = content.length;
|
2014-09-18 23:42:07 +00:00
|
|
|
|
|
|
|
el.className = 'word-count';
|
2014-10-24 21:09:50 +00:00
|
|
|
|
2014-09-18 23:42:07 +00:00
|
|
|
if (length > maxCharacters) {
|
|
|
|
el.style.color = '#E25440';
|
|
|
|
} else {
|
2014-09-21 18:56:30 +00:00
|
|
|
el.style.color = '#9FBB58';
|
2014-09-18 23:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
el.innerHTML = length;
|
|
|
|
|
2015-02-09 15:57:50 +00:00
|
|
|
return Ember.String.htmlSafe(el.outerHTML);
|
2014-09-18 23:42:07 +00:00
|
|
|
});
|