diff options
Diffstat (limited to 'themes/default/js/rating.js')
-rw-r--r-- | themes/default/js/rating.js | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/themes/default/js/rating.js b/themes/default/js/rating.js index f0f838c72..668aed930 100644 --- a/themes/default/js/rating.js +++ b/themes/default/js/rating.js @@ -2,7 +2,7 @@ var gRatingOptions, gRatingButtons, gUserRating; function makeNiceRatingForm(options) { - gRatingOptions = options || {}; + gRatingOptions = options; var form = document.getElementById('rateForm'); if (!form) return; //? template changed @@ -36,14 +36,11 @@ function makeNiceRatingForm(options) rateButton.parentNode.removeChild(rateButton.previousSibling); pwgAddEventListener(rateButton, "click", updateRating); - pwgAddEventListener(rateButton, "mouseout", resetRatingStarDisplay); - pwgAddEventListener(rateButton, "mouseover", updateRatingStarDisplayEvt); + pwgAddEventListener(rateButton, "mouseout", function() {updateRatingStarDisplay( gUserRating );}); + pwgAddEventListener(rateButton, "mouseover", function(e) { + updateRatingStarDisplay( e.target ? e.target.initialRateValue : e.srcElement.initialRateValue); + }); } - resetRatingStarDisplay(); -} - -function resetRatingStarDisplay() -{ updateRatingStarDisplay( gUserRating ); } @@ -53,12 +50,6 @@ function updateRatingStarDisplay(userRating) gRatingButtons[i].className = (userRating!=="" && userRating>=gRatingButtons[i].initialRateValue ) ? "rateButtonStarFull" : "rateButtonStarEmpty"; } -function updateRatingStarDisplayEvt(e) -{ - updateRatingStarDisplay( - e.target ? e.target.initialRateValue : e.srcElement.initialRateValue); -} - function updateRating(e) { var rateButton = e.target || e.srcElement; @@ -89,4 +80,17 @@ function updateRating(e) } ); return false; -}
\ No newline at end of file +} + +(function() { +if (typeof _pwgRatingAutoQueue!="undefined" && _pwgRatingAutoQueue.length) +{ + for (var i=0; i<_pwgRatingAutoQueue.length; i++) + makeNiceRatingForm(_pwgRatingAutoQueue[i]); +} +_pwgRatingAutoQueue = { + push: function(opts) { + makeNiceRatingForm(opts); + } +} +})();
\ No newline at end of file |