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)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
176
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     1
import Ember from 'ember';
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     2
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     3
export function popularity([target, minimum, maximum]) {
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     4
    var classname = ['not-popular', 'popular', 'very-popular'];
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     5
    var interval = ( maximum - minimum ) / classname.length;
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     6
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     7
    var i = 0;
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     8
    while( target > minimum + ( interval * ( i + 1 ) ) ) {
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     9
        i ++;
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    10
    }
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    11
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    12
    return classname[i];
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    13
}
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    14
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    15
export default Ember.Helper.helper(popularity);