cms/app-client/app/helpers/is-indeterminate.js
author ymh <ymh.work@gmail.com>
Sat, 06 Aug 2016 21:29:33 +0700
changeset 261 02e2396bcbbc
parent 245 c9dd78a43b07
child 392 4fbe94af93e8
permissions -rw-r--r--
Migrate to ember 2.7 + correct jquery null context error + declare shim for popcorn (instead of silencing the JSHint error)
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 isIndeterminate(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 && filter.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(isIndeterminate);