cms/app-client/app/helpers/popularity.js
author ymh <ymh.work@gmail.com>
Wed, 24 Aug 2016 09:46:03 +0200
changeset 263 3deace9204de
parent 176 d1baf7ccecc8
child 468 8fe093d88efe
permissions -rw-r--r--
pass bo_client to ember 2.8, adjust for the hack around the aupac-typeahead bug in 2.8 (c.f. https://github.com/aupac/ember-aupac-typeahead/issues/23)

import Ember from 'ember';

export function popularity([target, minimum, maximum]) {
    var classname = ['not-popular', 'popular', 'very-popular'];
    var interval = ( maximum - minimum ) / classname.length;

    var i = 0;
    while( target > minimum + ( interval * ( i + 1 ) ) ) {
        i ++;
    }

    return classname[i];
}

export default Ember.Helper.helper(popularity);