2016-06-30 13:21:47 +03:00
|
|
|
import {helper} from 'ember-helper';
|
|
|
|
import {htmlSafe} from 'ember-string';
|
2015-08-19 14:55:40 +03:00
|
|
|
|
2016-06-30 13:21:47 +03:00
|
|
|
export default helper(function (params) {
|
2015-09-03 14:06:50 +03:00
|
|
|
if (!params || params.length < 2) {
|
2015-02-09 18:57:50 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
let el = document.createElement('span');
|
|
|
|
let [content, maxCharacters] = params;
|
|
|
|
let length;
|
|
|
|
|
|
|
|
content = content || '';
|
2015-02-09 18:57:50 +03:00
|
|
|
length = content.length;
|
2014-09-19 03:42:07 +04:00
|
|
|
|
|
|
|
el.className = 'word-count';
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-09-19 03:42:07 +04:00
|
|
|
if (length > maxCharacters) {
|
|
|
|
el.style.color = '#E25440';
|
|
|
|
} else {
|
2014-09-21 22:56:30 +04:00
|
|
|
el.style.color = '#9FBB58';
|
2014-09-19 03:42:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
el.innerHTML = length;
|
|
|
|
|
2016-06-11 19:52:36 +03:00
|
|
|
return htmlSafe(el.outerHTML);
|
2014-09-19 03:42:07 +04:00
|
|
|
});
|