Adds javascript for half star ratings
This commit is contained in:
parent
0be53f9133
commit
daf42a30da
|
@ -14,6 +14,9 @@ let StatusCache = new class {
|
||||||
'submit',
|
'submit',
|
||||||
this.submitStatus.bind(this))
|
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();
|
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 New Issue