I have already been using this for a long time, using a Javascript method in the footer, but I thought it might be interesting to others (and perhaps inclusion into the core some day).
Code: Select all
<!-- IF S_HAS_POLL and S_DISPLAY_RESULTS -->
var maxperc = 0;
$("dd.poll_option_percent").each(function() {
var perc = parseFloat($(this).html());
maxperc = ( perc > maxperc ? perc : maxperc );
})
if (maxperc !== 0) {
$("fieldset.polls > dl").each(function() {
if($(this).is("[data-poll-option-id]")) {
var perc = parseFloat($("dd.poll_option_percent", this).html());
if (perc == maxperc) {
$(this).addClass("winner");
}
perc = Math.round(perc / maxperc * 100);
$("dd.resultbar > div", this).css("width", perc+"%");
}
})
}
<!-- ENDIF -->