diff options
author | rvelices <rv-github@modusoptimus.com> | 2010-11-30 20:42:03 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2010-11-30 20:42:03 +0000 |
commit | 208a5acddcfebc131af01855edbf7f6cdc903bf7 (patch) | |
tree | d499ce28e88832a3e3f3285463f86427d60c9047 /themes/default/js/rating.js | |
parent | bad80308ea2a987f34b44dca1912010f78f3341a (diff) |
bug 2043: some Javascript errors in default theme (also makes the rating.js script async)
git-svn-id: http://piwigo.org/svn/trunk@7957 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-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 |