author | ymh <ymh.work@gmail.com> |
Tue, 13 Dec 2016 23:30:54 +0100 | |
changeset 473 | 1b8b29c0e95c |
parent 468 | 8fe093d88efe |
permissions | -rw-r--r-- |
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); |