cms/app-client/app/helpers/is-checked.js
author Chloe Laisne <chloe.laisne@gmail.com>
Tue, 16 Aug 2016 00:16:08 +0200
changeset 254 a7cf2887e993
parent 245 c9dd78a43b07
child 392 4fbe94af93e8
permissions -rw-r--r--
Hide/Show video CSS
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
244
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     1
import Ember from 'ember';
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     2
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     3
export function isChecked(params) {
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     4
    var dates = params[0];
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     5
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     6
    var decade = [];
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     7
    var next = params[1] + 10;
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     8
    while(params[1] < next) {
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     9
        decade.push(params[1]);
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    10
        params[1] ++;
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    11
    }
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    12
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    13
    var filter = decade.filter(function(date){ return dates.indexOf(date) > -1; });
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    14
    if(filter.length === decade.length) {
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 244
diff changeset
    15
        return true;
244
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    16
    }
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    17
    return false;
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    18
}
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    19
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    20
export default Ember.Helper.helper(isChecked);