-
Notifications
You must be signed in to change notification settings - Fork 8
/
VoteChartController.js
32 lines (27 loc) · 1.06 KB
/
VoteChartController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
({
maxValue : function (component, selector, dataattr) {
var max=null;
$j(selector).each(function() {
var id = $j(this).data(dataattr);
if ((max===null) || (id > max)) { max = id; }
});
return max;
},
doInit : function(component, event, helper) {
// Hack - see asyncRender comments for ideal approach
setTimeout(function(){
var maxVote = null;
$j('div.progress-bar').each(function() {
var id = $j(this).data('score');
if ((maxVote === null) || (id > maxVote)) { maxVote = id; }
});
$j('div.progress-bar').each(function() {
var actualScore = $j(this).attr('aria-valuenow');
var calcScore = actualScore / maxVote;
calcScore = calcScore * 100;
$j(this).attr('aria-valuemax', maxVote);
$j(this).css('width', calcScore+'%').attr('aria-valuenow', actualScore);
});
}, 500);
}
})