AntonLV 6 年之前
父节点
当前提交
02e66b158d

+ 3 - 3
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -389,14 +389,14 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         $aTmplVarsAnswers = array();
         foreach($aAnswers as $aAnswer) {
             $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_POLL_ANSWERS'], $aAnswer['id']);
+            $aVotesParams = array('show_counter_empty' => true, 'show_counter_in_brackets' => false, 'dynamic_mode' => $bDynamic);
 
             $fPercent = $iTotal > 0 ? 100 * (float)$aAnswer['votes']/$iTotal : 0;
             $aTmplVarsAnswers[] = array(
                 'title' => bx_process_output($aAnswer['title']),
                 'width' => (int)round($fPercent) . '%',
-                'votes' => $oVotes->getCounter(array('show_counter_empty' => true, 'show_counter_in_brackets' => false)),
-                'percent' => _t($CNF['T']['txt_poll_answer_vote_percent'], $iTotal > 0 ? round($fPercent, 2) : 0),
-                'js_code' => $oVotes->getJsScript($bDynamic)
+                'votes' => $oVotes->getCounter($aVotesParams),
+                'percent' => _t($CNF['T']['txt_poll_answer_vote_percent'], $iTotal > 0 ? round($fPercent, 2) : 0)
             );
         }
 

+ 0 - 1
modules/base/text/template/poll_item_results.html

@@ -6,7 +6,6 @@
                 <div class="bx-base-text-prg-bar bx-def-round-corners" style="width:__width__">&nbsp;</div>
                 <div class="bx-base-text-prg-text bx-def-padding-left bx-def-font-middle bx-def-font-grayed">__votes__&nbsp;__percent__</div>
             </div>
-            __js_code__
         </div>
     </bx_repeat:answers>
 </div>

+ 2 - 3
template/scripts/BxBaseVote.php

@@ -66,7 +66,7 @@ class BxBaseVote extends BxDolVote
 
         $bDynamicMode = isset($aParams['dynamic_mode']) && (bool)$aParams['dynamic_mode'] === true;
 
-        $aParams = array(
+        $sCode = "if(window['" . $sJsObjName . "'] == undefined) var " . $sJsObjName . " = new " . $sJsObjClass . "(" . json_encode(array(
             'sObjName' => $sJsObjName,
             'sSystem' => $this->getSystemName(),
             'iAuthorId' => $this->_getAuthorId(),
@@ -75,8 +75,7 @@ class BxBaseVote extends BxDolVote
             'sStylePrefix' => $this->_sStylePrefix,
             'aHtmlIds' => $this->_aHtmlIds,
             'aRequestParams' => $this->_prepareRequestParamsData($aParams)
-        );
-        $sCode = "if(window['" . $sJsObjName . "'] == undefined) var " . $sJsObjName . " = new " . $sJsObjClass . "(" . json_encode($aParams) . ");";
+        )) . ");";
 
         return $this->_oTemplate->_wrapInTagJsCode($sCode);
     }