mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-22 23:18:08 +00:00
Adds javascript for half star ratings
This commit is contained in:
parent
0be53f9133
commit
daf42a30da
1 changed files with 22 additions and 0 deletions
|
@ -14,6 +14,9 @@ let StatusCache = new class {
|
|||
'submit',
|
||||
this.submitStatus.bind(this))
|
||||
);
|
||||
|
||||
document.querySelectorAll('.form-rate-stars label.icon')
|
||||
.forEach(button => button.addEventListener('click', this.toggleStar.bind(this)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,5 +201,24 @@ let StatusCache = new class {
|
|||
menu.click();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reveal half-stars
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
toggleStar(event) {
|
||||
const label = event.currentTarget;
|
||||
let wholeStar = document.getElementById(label.getAttribute("for"));
|
||||
|
||||
if (wholeStar.checked) {
|
||||
event.preventDefault();
|
||||
let halfStar = document.getElementById(label.dataset.forHalf);
|
||||
|
||||
wholeStar.checked = null;
|
||||
halfStar.checked = "checked";
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
|
|
Loading…
Reference in a new issue