diff --git a/fedireads/static/format.css b/fedireads/static/format.css index c90d2b70..6c56653e 100644 --- a/fedireads/static/format.css +++ b/fedireads/static/format.css @@ -321,6 +321,7 @@ button .icon { } .rate-stars .icon { cursor: pointer; + color: goldenrod; } .rate-stars form { display: inline; @@ -331,7 +332,12 @@ button .icon { border: none; padding: 0; margin: 0; - color: goldenrod; +} +.rate-stars:hover .icon:before { + content: '\e9d9'; +} +.rate-stars form:hover ~ form .icon:before{ + content: '\e9d7'; } .review-form .rate-stars:hover .icon:before { @@ -340,10 +346,6 @@ button .icon { .review-form .rate-stars label { display: inline; } -.review-form .rate-stars form:hover ~ form .icon:before{ - content: '\e9d7'; -} - .review-form .rate-stars input + .icon:before { content: '\e9d9'; } diff --git a/fedireads/static/js/shared.js b/fedireads/static/js/shared.js index 1859c4af..ee6fccca 100644 --- a/fedireads/static/js/shared.js +++ b/fedireads/static/js/shared.js @@ -37,6 +37,17 @@ function reply(e) { return true; } +function rate(e) { + e.preventDefault(); + ajaxPost(e.target); + rating = e.target.value; + var stars = e.target.parentElement.getElementsByClassName('icon'); + for (var i = 0; i < stars.length ; i++) { + stars[i].className = rating < i ? 'icon icon-star-full' : 'icon icon-star-empty'; + } + return true; +} + function tabChange(e) { e.preventDefault(); var target = e.target.parentElement; diff --git a/fedireads/templates/snippets/rate_action.html b/fedireads/templates/snippets/rate_action.html index cc7b6e47..cd5006a7 100644 --- a/fedireads/templates/snippets/rate_action.html +++ b/fedireads/templates/snippets/rate_action.html @@ -2,7 +2,7 @@ Leave a rating
{% for i in '12345'|make_list %} -
+ {% csrf_token %}