2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2015-08-19 14:55:40 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {Helper} = Ember;
|
2015-02-09 18:57:50 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
export default Helper.helper(function (params) {
|
2015-09-03 14:06:50 +03:00
|
|
|
if (!params || !params.length) {
|
2015-02-09 18:57:50 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
let el = document.createElement('span');
|
|
|
|
let content = params[0] || '';
|
|
|
|
let {length} = content;
|
2014-06-24 00:02:09 +04:00
|
|
|
|
|
|
|
el.className = 'word-count';
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-06-24 00:02:09 +04:00
|
|
|
if (length > 180) {
|
|
|
|
el.style.color = '#E25440';
|
|
|
|
} else {
|
|
|
|
el.style.color = '#9E9D95';
|
|
|
|
}
|
|
|
|
|
|
|
|
el.innerHTML = 200 - length;
|
|
|
|
|
2015-02-09 18:57:50 +03:00
|
|
|
return Ember.String.htmlSafe(el.outerHTML);
|
2014-06-24 00:02:09 +04:00
|
|
|
});
|