From fe90becc3e7129d6635cbb4ed9f5db6561e8c98c Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 13 Aug 2014 15:35:43 +0200 Subject: [PATCH] Update mooRatings-1.1.js If we select an already full star then we empty it and the following stars --- Source/mooRatings-1.1.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/mooRatings-1.1.js b/Source/mooRatings-1.1.js index 4d45c14..7b8210d 100644 --- a/Source/mooRatings-1.1.js +++ b/Source/mooRatings-1.1.js @@ -145,16 +145,24 @@ var mooRatings = new Class({ // get the current selected rating star var current = this.container.getElement('a[title=ui-rating-value-' + rating + ']'); if (current){ + //if the current star is already full, empty it and the next stars + if (current.get('class').indexOf('ui-rating-full') > -1){ + current.set('class', 'ui-rating-star ui-rating-empty'); + current.getAllNext() + .set('class', 'ui-rating-star ui-rating-empty'); + } + else { // highlight current and previous stars in yellow - current.set('class', 'ui-rating-star ui-rating-full') - .getAllPrevious() - .set('class', 'ui-rating-star ui-rating-full'); - - // remove highlight from higher ratings - current.getAllNext() - .set('class', 'ui-rating-star ui-rating-empty'); + current.set('class', 'ui-rating-star ui-rating-full') + .getAllPrevious() + .set('class', 'ui-rating-star ui-rating-full'); + + // remove highlight from higher ratings + current.getAllNext() + .set('class', 'ui-rating-star ui-rating-empty'); + } } // synchronize the rate with the selectbox this.selectBox.set('value', rating); } -}); \ No newline at end of file +});