mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-01 10:42:24 +02:00
Improve "confirm deletion" behaviour
* add the event listener only once, instead of every time the form is clicked * use a standard button by default, so that the second state with a "danger" button is more visible * reset confirmation button to original state when losing focus Co-authored-by: Glandos <bugs-github@antipoul.fr>
This commit is contained in:
parent
da49012d58
commit
439282356c
2 changed files with 15 additions and 11 deletions
|
@ -2,16 +2,20 @@
|
|||
|
||||
{% block js %}
|
||||
|
||||
$('#delete-project').click(function(){
|
||||
var link = $(this).find('button');
|
||||
link.click(function(){
|
||||
if ($(this).hasClass("confirm")){
|
||||
return true;
|
||||
}
|
||||
$(this).html("{{_("Are you sure?")}}");
|
||||
$(this).addClass("confirm");
|
||||
return false;
|
||||
});
|
||||
let link = $('#delete-project').find('button');
|
||||
let deleteOriginalHTML = link.html();
|
||||
link.click(function() {
|
||||
if (link.hasClass("confirm")){
|
||||
return true;
|
||||
}
|
||||
link.html("{{_("Are you sure?")}}");
|
||||
link.addClass("confirm btn-danger");
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#delete-project').focusout(function() {
|
||||
link.removeClass("confirm btn-danger");
|
||||
link.html(deleteOriginalHTML);
|
||||
});
|
||||
|
||||
$('.custom-file-input').on('change', function(event) {
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
{{ form.hidden_tag() }}
|
||||
{{ input(form.password) }}
|
||||
<div class="actions">
|
||||
<button class="btn btn-danger">{{ _("Delete project") }}</button>
|
||||
<button class="btn btn-primary">{{ _("Delete project") }}</button>
|
||||
</div>
|
||||
|
||||
{% endmacro %}
|
||||
|
|
Loading…
Reference in a new issue