Skip to content

Commit

Permalink
Improve "confirm deletion" behaviour
Browse files Browse the repository at this point in the history
Co-authored-by: Glandos <bugs-github@antipoul.fr>
  • Loading branch information
2 people authored and Baptiste Jonglez committed Jul 17, 2021
1 parent dd70836 commit ed9aec9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions ihatemoney/templates/edit_project.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ihatemoney/templates/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit ed9aec9

Please sign in to comment.