Explorar o código

Tickets #2785 - point 2

AntonLV %!s(int64=6) %!d(string=hai) anos
pai
achega
164c4fc37a

+ 27 - 22
inc/js/classes/BxDolVoteReactions.js

@@ -71,42 +71,47 @@ BxDolVoteReactions.prototype.vote = function(oLink, iValue, sReaction, onComplet
 
 BxDolVoteReactions.prototype.onVote = function (oLink, oData, onComplete)
 {
+    var $this = this;
+
     if(oData && oData.code != 0)
         return;
     
     $('#' + this._aHtmlIds['do_popup']).dolPopupHide({});
 
-    oLink = $(oLink);
-    if(!oLink.hasClass(this._sClassDo))
-        oLink = $('#' + this._aHtmlIds['main'] + ' .' + this._sClassDo);
+    oLink = $('.' + this._aHtmlIds['main'] + ' .' + this._sClassDo);
 
     //--- Update Do button.
-    if(oData && oData.label_icon)
-        oLink.find('.sys-action-do-icon .sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
+    oLink.each(function() {
+        if(oData && oData.label_icon)
+            $(this).find('.sys-action-do-icon .sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
 
-    if(oData && oData.label_title) {
-        oLink.attr('title', oData.label_title);
-        oLink.find('.sys-action-do-text').html(oData.label_title);
-    }
+        if(oData && oData.label_title) {
+            $(this).attr('title', oData.label_title);
+            $(this).find('.sys-action-do-text').html(oData.label_title);
+        }
 
-    if(oData && oData.label_click)
-        oLink.attr('onclick', 'javascript:' + oData.label_click)
+        if(oData && oData.label_click)
+            $(this).attr('onclick', 'javascript:' + oData.label_click)
 
-    if(oData && oData.disabled)
-        oLink.removeAttr('onclick').addClass($(oLink).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-vote-disabled');
-    else
-        oLink.toggleClass(this._sClassDoVoted);
+        if(oData && oData.disabled)
+            $(this).removeAttr('onclick').addClass($(this).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-vote-disabled');
+        else
+            $(this).toggleClass($this._sClassDoVoted);
+    });
 
     //--- Update Counter.
     var oCounter = this._getCounter(oLink);
     if(oCounter && oCounter.length > 0) {
-        oCounter.filter('.' + oData.reaction).html(oData.countf).toggleClass('bx-vc-hidden', !oData.count);
+        oCounter.filter('.' + oData.reaction).each(function() {
+            $(this).html(oData.countf).toggleClass('bx-vc-hidden', !oData.count);            
+        });
 
         //--- Update Total.
-        if(oData.total) {
-            oCounter.parents('.' + this._sSP + '-counter-wrapper:first').toggleClass('bx-vc-hidden', !oData.total.count);
-            oCounter.filter('.total-count').html(oData.total.countf).toggleClass('bx-vc-hidden', !oData.total.count);
-        }
+        if(oData.total)
+            oCounter.filter('.total-count').each(function() {
+                $(this).html(oData.total.countf).toggleClass('bx-vc-hidden', !oData.total.count);
+                $(this).parents('.' + $this._sSP + '-counter-wrapper:first').toggleClass('bx-vc-hidden', !oData.total.count);
+            });
     }
 
     if(typeof onComplete == 'function')
@@ -237,8 +242,8 @@ BxDolVoteReactions.prototype._getCounter = function(oElement)
     var oCounter = BxDolVote.prototype._getCounter.call(this, oElement);
     if(oCounter && oCounter.length > 0)
         return oCounter;
-
-    return $('#' + this._aHtmlIds['counter']).find('.' + this._sSP + '-counter');
+//.parent(':visible')
+    return $('.' + this._aHtmlIds['counter']).find('.' + this._sSP + '-counter');
 };
 
 /** @} */

+ 1 - 1
template/scripts/BxBaseVote.php

@@ -235,7 +235,7 @@ class BxBaseVote extends BxDolVote
         return array(
             'style_prefix' => $this->_sStylePrefix,
             'html_id' => $this->_aHtmlIds['main'],
-            'class' => $sClass,
+            'class' => $sClass . ' ' . $this->_aHtmlIds['main'],
             'bx_if:show_vote_data' => array(
                 'condition' => false,
                 'content' => array()

+ 2 - 2
template/scripts/BxBaseVoteReactions.php

@@ -126,7 +126,7 @@ class BxBaseVoteReactions extends BxDolVoteReactions
         return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentCounterWrapper(), array(
             'html_id' => $this->_aHtmlIds['counter'],
             'style_prefix' => $this->_sStylePrefix,
-            'class' => !$bVote && !$bShowCounterEmpty ? 'bx-vc-hidden' : '',
+            'class' => $this->_aHtmlIds['counter'] . (!$bVote && !$bShowCounterEmpty ? ' bx-vc-hidden' : ''),
             'type' => $this->_sType,
             'style' => self::$_sCounterStyleDivided,
             'bx_if:show_link' => array(
@@ -201,7 +201,7 @@ class BxBaseVoteReactions extends BxDolVoteReactions
         return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentCounterWrapper(), array(
             'html_id' => $this->_aHtmlIds['counter'],
             'style_prefix' => $this->_sStylePrefix,
-            'class' => !$bVote && !$bShowCounterEmpty ? 'bx-vc-hidden' : '',
+            'class' => $this->_aHtmlIds['counter'] . (!$bVote && !$bShowCounterEmpty ? ' bx-vc-hidden' : ''),
             'type' => $this->_sType,
             'style' => self::$_sCounterStyleCompound,
             'bx_if:show_link' => array(