Sith/pedagogy/templates/pedagogy/starlist.jinja

50 lines
1.6 KiB
Django/Jinja
Raw Normal View History

2019-07-01 16:51:32 +00:00
<div>
<style>
2019-07-05 10:31:49 +00:00
.checked {
2019-07-01 16:51:32 +00:00
color : orange;
}
2019-07-05 10:31:49 +00:00
.unchecked {
2019-07-01 16:51:32 +00:00
color : gray;
}
2019-07-05 10:31:49 +00:00
.star input[type="radio"] {
2019-07-01 16:51:32 +00:00
display : none;
}
2019-07-05 10:31:49 +00:00
.star {
2019-07-01 16:51:32 +00:00
display: inline;
}
2019-07-05 10:31:49 +00:00
2019-07-01 16:51:32 +00:00
</style>
2019-07-05 10:31:49 +00:00
<label class="star">
<input type="radio" name="{{ widget.name }}" value="-1" onclick='
var stars = document.getElementsByClassName("{{ widget.name }}");
for (var i = 0; i < stars.length; i++){
var attrs = stars[i].getAttribute("class");
attrs = attrs.replace("unchecked", "");
attrs = attrs.replace("checked", "");
stars[i].setAttribute("class", attrs + " unchecked");
}
' checked>
<span class="fa fa-times-circle"> {{ translations.do_not_vote }}</span>
</label>
{% for i in number_of_stars %}
2019-07-01 16:51:32 +00:00
<label class="star">
<input type="radio" name="{{ widget.name }}" value="{{ forloop.counter0 }}" onclick='
var stars = document.getElementsByClassName("{{ widget.name }}");
2019-07-05 10:31:49 +00:00
for (var i = 0; i < stars.length; i++){
2019-07-01 16:51:32 +00:00
var attrs = stars[i].getAttribute("class");
attrs = attrs.replace("unchecked", "");
attrs = attrs.replace("checked", "");
if (i > {{ forloop.counter0 }}){
stars[i].setAttribute("class", attrs + " unchecked");
} else {
stars[i].setAttribute("class", attrs + " checked");
}
}
'>
<i class="{{ widget.name }} fa fa-star unchecked"></i>
</label>
{% endfor %}
</div>