author | ymh <ymh.work@gmail.com> |
Fri, 09 Dec 2016 11:41:15 +0100 | |
changeset 467 | 762fc0eb4946 |
parent 424 | feb0d3e0fef9 |
child 532 | 1190ea937f2d |
permissions | -rw-r--r-- |
393 | 1 |
import Ember from 'ember'; |
2 |
import _ from 'lodash/lodash'; |
|
3 |
||
4 |
export default Ember.Component.extend({ |
|
5 |
||
6 |
colors: Ember.inject.service(), |
|
7 |
filter: Ember.inject.service(), |
|
8 |
||
9 |
tagName: 'li', |
|
10 |
classNameBindings: ['isDisabled:disabled', 'isDark:light-color', 'isHighlighted:highlighted'], |
|
11 |
attributeBindings: ['style', 'title', 'id'], |
|
12 |
||
424
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
13 |
colorScale: null, |
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
14 |
|
393 | 15 |
isDisabled: Ember.computed('range', 'year', 'count', function() { |
16 |
let year = parseInt(this.get('year')); |
|
17 |
let count = this.get('count'); |
|
18 |
return (!_.inRange(year, this.get('range')[0], this.get('range')[1]+1)) || count === 0; |
|
19 |
}), |
|
20 |
||
21 |
isHighlighted: Ember.computed('filter.dateList.[]', function() { |
|
22 |
return _.contains(this.get('filter.dateList'), this.get('year')); |
|
23 |
}), |
|
24 |
isDark: Ember.computed('backgroundColor', 'isDisabled', function() { |
|
25 |
let backgroundColor = this.get('backgroundColor'); |
|
26 |
if(this.get('isDisabled')) { |
|
27 |
return false; |
|
28 |
} |
|
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
393
diff
changeset
|
29 |
return this.get('colors').getPerceptiveLuminance(backgroundColor) >= 0.5; |
393 | 30 |
}), |
31 |
||
424
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
32 |
backgroundColor: Ember.computed('count', function() { |
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
33 |
return this.get('scale')(this.get('count')); |
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
34 |
//return this.get('colors').shadeLinear(this.get('count'), this.get('minCount'), this.get('maxCount')); |
393 | 35 |
}), |
36 |
||
37 |
style: Ember.computed('backgroundColor', 'isDisabled', 'isHighlighted', function() { |
|
38 |
let backgroundColor = this.get('backgroundColor'); |
|
39 |
if(this.get('isDisabled') || this.get('isHighlighted')) { |
|
40 |
return null; |
|
41 |
} |
|
42 |
return Ember.String.htmlSafe(`background-color: ${backgroundColor};`); |
|
43 |
}), |
|
44 |
id: Ember.computed.alias('year'), |
|
45 |
count: Ember.computed('datestats.[]', function() { |
|
46 |
let year = this.get('year'); |
|
47 |
let count = this.get('datestats').get(`${year}`); |
|
48 |
return count?count:0; |
|
49 |
}), |
|
50 |
title: Ember.computed('count', 'isDsabled', function() { |
|
51 |
if(this.get('isDisabled')) { |
|
52 |
return null; |
|
53 |
} |
|
54 |
let year = this.get('year'); |
|
55 |
let count = this.get('count'); |
|
56 |
return `${year} (${count})`; |
|
57 |
}), |
|
58 |
||
59 |
year: null, |
|
60 |
datestats: null, |
|
61 |
range: null, |
|
62 |
}); |