templates: allow to unselect evaluation stars (#88084)
gitea/publik-base-theme/pipeline/head This commit looks good
Details
gitea/publik-base-theme/pipeline/head This commit looks good
Details
This commit is contained in:
parent
dc2f44d7be
commit
c664b256c6
|
@ -14,14 +14,14 @@ div.star-choice {
|
|||
display: inline-block;
|
||||
transition: transform ease 0.2s;
|
||||
}
|
||||
&.selected::before, &:hover::before {
|
||||
&.selected::before, &.selected:hover::before {
|
||||
content: "\f005"; // star
|
||||
color: #ffaa00;
|
||||
}
|
||||
}
|
||||
input[type=radio]:hover + span.star::before,
|
||||
input[type=radio]:focus + span.star::before,
|
||||
span.star:hover::before {
|
||||
span.star.selected:hover::before {
|
||||
transform: scale(1.4);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
|
|
@ -18,14 +18,21 @@
|
|||
$(function() {
|
||||
var $widget = $('[name="{{widget.name}}"]');
|
||||
$widget.parent().find('.star-choice span').on('click', function() {
|
||||
prop_selected = true
|
||||
if ($(this).hasClass('selected')) {
|
||||
$(this).nextAll().removeClass('selected');
|
||||
|
||||
// unselect first star if it is the only one selected
|
||||
if ($(this).data('index') == 1 && ! $(this).next().hasClass('selected')) {
|
||||
$(this).removeClass('selected');
|
||||
prop_selected = false
|
||||
}
|
||||
} else {
|
||||
$(this).prevAll().addClass('selected');
|
||||
$(this).addClass('selected');
|
||||
$(this).nextAll().removeClass('selected');
|
||||
}
|
||||
$widget.find('option[data-index=' + $(this).data('index') + ']').prop('selected', true);
|
||||
$widget.find('option[data-index=' + $(this).data('index') + ']').prop('selected', prop_selected);
|
||||
});
|
||||
$widget.parent().find('.star-choice [data-index=' + $widget.find('option:selected').data('index') + ']').trigger('click');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue