aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-04 23:52:04 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-04 23:52:04 +0200
commit1a82ce9f48c69850b63e00217203f3d4dfa6413f (patch)
treecb546908662ee27f4cc96e21d2fab571746cff26 /phpBB
parent1a3a296558f492ea7f740fd33fde96fb923f4242 (diff)
parent20c18d08e985b39d54df920c5c947c449375e661 (diff)
downloadforums-1a82ce9f48c69850b63e00217203f3d4dfa6413f.tar
forums-1a82ce9f48c69850b63e00217203f3d4dfa6413f.tar.gz
forums-1a82ce9f48c69850b63e00217203f3d4dfa6413f.tar.bz2
forums-1a82ce9f48c69850b63e00217203f3d4dfa6413f.tar.xz
forums-1a82ce9f48c69850b63e00217203f3d4dfa6413f.zip
Merge remote-tracking branch 'paybas/ticket/12327' into develop-ascraeus
* paybas/ticket/12327: [ticket/12327] Ajax fix [ticket/12327] Coding style fixes [ticket/12327] Changing poll result-bars width from absolute to relative
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/styles/prosilver/template/ajax.js11
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_body.html2
-rw-r--r--phpBB/viewtopic.php25
3 files changed, 26 insertions, 12 deletions
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index 9688802929..d2a070d11b 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -206,6 +206,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var poll = $('.topic_poll');
var panel = poll.find('.panel');
var results_visible = poll.find('dl:first-child .resultbar').is(':visible');
+ var most_votes = 0;
// Set min-height to prevent the page from jumping when the content changes
var update_panel_height = function (height) {
@@ -227,6 +228,13 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
// If the user can still vote, simply slide down the results
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
}
+
+ // Get the votes count of the highest poll option
+ poll.find('[data-poll-option-id]').each(function() {
+ var option = $(this);
+ var option_id = option.attr('data-poll-option-id');
+ most_votes = (res.vote_counts[option_id] >= most_votes) ? res.vote_counts[option_id] : most_votes;
+ });
// Update the total votes count
poll.find('.poll_total_vote_cnt').html(res.total_votes);
@@ -237,6 +245,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var option_id = option.attr('data-poll-option-id');
var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false;
var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100);
+ var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100);
option.toggleClass('voted', voted);
@@ -246,7 +255,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var new_bar_class = (percent == 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
setTimeout(function () {
- bar.animate({width: percent + '%'}, 500).removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5').addClass(new_bar_class);
+ bar.animate({width: percent_rel + '%'}, 500).removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5').addClass(new_bar_class);
bar.html(res.vote_counts[option_id]);
var percent_txt = (!percent) ? res.NO_VOTES : percent + '%';
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html
index e5fff02753..4e3561c4a2 100644
--- a/phpBB/styles/prosilver/template/viewtopic_body.html
+++ b/phpBB/styles/prosilver/template/viewtopic_body.html
@@ -75,7 +75,7 @@
<dl class="<!-- IF poll_option.POLL_OPTION_VOTED -->voted<!-- ENDIF -->"<!-- IF poll_option.POLL_OPTION_VOTED --> title="{L_POLL_VOTED_OPTION}"<!-- ENDIF --> data-poll-option-id="{poll_option.POLL_OPTION_ID}">
<dt><!-- IF S_CAN_VOTE --><label for="vote_{poll_option.POLL_OPTION_ID}">{poll_option.POLL_OPTION_CAPTION}</label><!-- ELSE -->{poll_option.POLL_OPTION_CAPTION}<!-- ENDIF --></dt>
<!-- IF S_CAN_VOTE --><dd style="width: auto;" class="poll_option_select"><!-- IF S_IS_MULTI_CHOICE --><input type="checkbox" name="vote_id[]" id="vote_{poll_option.POLL_OPTION_ID}" value="{poll_option.POLL_OPTION_ID}"<!-- IF poll_option.POLL_OPTION_VOTED --> checked="checked"<!-- ENDIF --> /><!-- ELSE --><input type="radio" name="vote_id[]" id="vote_{poll_option.POLL_OPTION_ID}" value="{poll_option.POLL_OPTION_ID}"<!-- IF poll_option.POLL_OPTION_VOTED --> checked="checked"<!-- ENDIF --> /><!-- ENDIF --></dd><!-- ENDIF -->
- <dd class="resultbar<!-- IF not S_DISPLAY_RESULTS --> hidden<!-- ENDIF -->"><div class="<!-- IF poll_option.POLL_OPTION_PCT < 20 -->pollbar1<!-- ELSEIF poll_option.POLL_OPTION_PCT < 40 -->pollbar2<!-- ELSEIF poll_option.POLL_OPTION_PCT < 60 -->pollbar3<!-- ELSEIF poll_option.POLL_OPTION_PCT < 80 -->pollbar4<!-- ELSE -->pollbar5<!-- ENDIF -->" style="width:{poll_option.POLL_OPTION_PERCENT};">{poll_option.POLL_OPTION_RESULT}</div></dd>
+ <dd class="resultbar<!-- IF not S_DISPLAY_RESULTS --> hidden<!-- ENDIF -->"><div class="<!-- IF poll_option.POLL_OPTION_PCT < 20 -->pollbar1<!-- ELSEIF poll_option.POLL_OPTION_PCT < 40 -->pollbar2<!-- ELSEIF poll_option.POLL_OPTION_PCT < 60 -->pollbar3<!-- ELSEIF poll_option.POLL_OPTION_PCT < 80 -->pollbar4<!-- ELSE -->pollbar5<!-- ENDIF -->" style="width:{poll_option.POLL_OPTION_PERCENT_REL};">{poll_option.POLL_OPTION_RESULT}</div></dd>
<dd class="poll_option_percent<!-- IF not S_DISPLAY_RESULTS --> hidden<!-- ENDIF -->"><!-- IF poll_option.POLL_OPTION_RESULT == 0 -->{L_NO_VOTES}<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF --></dd>
</dl>
<!-- END poll_option -->
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 61a28940b1..1b7db7958e 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -842,9 +842,11 @@ if (!empty($topic_data['poll_start']))
}
$poll_total = 0;
+ $poll_most = 0;
foreach ($poll_info as $poll_option)
{
$poll_total += $poll_option['poll_option_total'];
+ $poll_most = ($poll_option['poll_option_total'] >= $poll_most) ? $poll_option['poll_option_total'] : $poll_most;
}
$parse_flags = ($poll_info[0]['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
@@ -860,16 +862,19 @@ if (!empty($topic_data['poll_start']))
{
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
$option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
+ $option_pct_rel = ($poll_most > 0) ? $poll_option['poll_option_total'] / $poll_most : 0;
+ $option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100));
$template->assign_block_vars('poll_option', array(
- 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
- 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
- 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
- 'POLL_OPTION_PERCENT' => $option_pct_txt,
- 'POLL_OPTION_PCT' => round($option_pct * 100),
- 'POLL_OPTION_WIDTH' => round($option_pct * 250),
- 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
- );
+ 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
+ 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
+ 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
+ 'POLL_OPTION_PERCENT' => $option_pct_txt,
+ 'POLL_OPTION_PERCENT_REL' => $option_pct_rel_txt,
+ 'POLL_OPTION_PCT' => round($option_pct * 100),
+ 'POLL_OPTION_WIDTH' => round($option_pct * 250),
+ 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
+ ));
}
$poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
@@ -889,8 +894,8 @@ if (!empty($topic_data['poll_start']))
'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false,
'S_POLL_ACTION' => $viewtopic_url,
- 'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll')
- );
+ 'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll',
+ ));
unset($poll_end, $poll_info, $voted_id);
}