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