Update the number of votes in a poll after voting
authorAlexander Ebert <ebert@woltlab.com>
Thu, 20 Aug 2020 22:50:53 +0000 (00:50 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 20 Aug 2020 22:50:53 +0000 (00:50 +0200)
com.woltlab.wcf/templates/poll.tpl
wcfsetup/install/files/js/WCF.Poll.js
wcfsetup/install/files/lib/action/PollAction.class.php

index f95bcb514ffc954aa17c6cc8da1681b0a14e16d6..a897291f212ff1f316ee54ea9b9a9cfda213cc83 100644 (file)
@@ -9,7 +9,7 @@
 
 <div class="pollContainer{if POLL_FULL_WIDTH} pollContainerFullWidth{/if}" data-poll-id="{@$poll->pollID}" data-can-vote="{if $poll->canVote()}1{else}0{/if}" data-can-view-result="{if $poll->canSeeResult()}1{else}0{/if}" data-can-view-participants="{if $poll->canViewParticipants()}true{else}false{/if}" data-in-vote="{if $poll->canVote() && !$poll->isParticipant()}1{else}0{/if}" data-question="{$poll->question}" data-max-votes="{@$poll->maxVotes}" data-is-public="{if $poll->isPublic}true{else}false{/if}">
        <section>
-               <h2>{$poll->question} <span class="badge jsTooltip" title="{lang}wcf.poll.totalVotes{/lang}">{#$poll->votes}</span></h2>
+               <h2>{$poll->question} <span class="badge jsTooltip jsPollTotalVotes" title="{lang}wcf.poll.totalVotes{/lang}">{#$poll->votes}</span></h2>
                
                <div class="pollInnerContainer">
                        {if !$__wcf->getUser()->userID}
index e8d8cd1fcc67095c6132efbb57ed0cb799c8a11d..68d0207d1d935b7c9a369d848f4c1e0193f3617a 100644 (file)
@@ -603,6 +603,10 @@ WCF.Poll.Manager = Class.extend({
                                        this._canViewParticipants[$pollID] = true;
                                }
                                
+                               var totalVotes = elBySel('.jsPollTotalVotes', this._polls[$pollID][0]);
+                               totalVotes.textContent = WCF.String.formatNumeric(data.totalVotes);
+                               elData(totalVotes, 'tooltip', data.totalVotesTooltip);
+                               
                                this._showResult(null, $pollID);
                        break;
                }
index 3c05b13b055fafd69ef59fba91679f205ba7814c..ac588e1646c4b19f7a1696232a6cf372444e2b19 100644 (file)
@@ -201,5 +201,7 @@ class PollAction extends AJAXProxyAction {
                }
                
                $returnValues['canVote'] = $this->poll->isChangeable ? 1 : 0;
+               $returnValues['totalVotes'] = $this->poll->votes;
+               $returnValues['totalVotesTooltip'] = WCF::getLanguage()->getDynamicVariable('wcf.poll.totalVotes', ['poll' => $this->poll]);
        }
 }