cms/app-client/app/helpers/popularity.js
author ymh <ymh.work@gmail.com>
Sat, 10 Jun 2017 17:57:34 +0200
changeset 533 a557802f2b12
parent 468 8fe093d88efe
permissions -rw-r--r--
Make guzzle client use the proxy configuration when injected by the ioc
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'];
468
8fe093d88efe correct min, max calculations when theme list change
ymh <ymh.work@gmail.com>
parents: 176
diff changeset
     5
    var interval = ( maximum + 1 - minimum ) / classname.length;
176
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     6
468
8fe093d88efe correct min, max calculations when theme list change
ymh <ymh.work@gmail.com>
parents: 176
diff changeset
     7
    var i = Math.floor((target-minimum)/interval);
176
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     8
d1baf7ccecc8 Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     9
    return classname[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
export default Ember.Helper.helper(popularity);