From 67350e7accfb0b8b0dd3b9b53bdc80b0fdbe2fd1 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Wed, 10 Aug 2011 19:23:54 +0200 Subject: [PATCH] Add some simple javascript for usability. * Ask confirmation before deleting an user * Display the form when clicking on the add bill button * Only show the delete button (for users) on mouse over. --- budget/templates/layout.html | 2 ++ budget/templates/list_bills.html | 42 +++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/budget/templates/layout.html b/budget/templates/layout.html index 19af8ca..9036de3 100644 --- a/budget/templates/layout.html +++ b/budget/templates/layout.html @@ -4,6 +4,8 @@ Account manager + + diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index 19c014d..7e96ca7 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -1,5 +1,41 @@ {% extends "layout.html" %} +{% block js %} +$(document).ready(function(){ + + // display the form when clicking on the "add bill" button + $('#add_bill_button').click(function(){ + $('#add_bill').show(200); + $(this).hide(); + $('#hide_bill_form').show(); + return false; + }); + + // and provide a mechanism to hide it back + $('#hide_bill_form').click(function(){ + $('#add_bill').hide(200); + $(this).hide(); + $('#add_bill_button').show(); + return false; + }); + + // ask for confirmation before removing an user + $('a.remove').each(function(){ + $(this).hide(); + $(this).click(function(){ + return confirm("are you sure?"); + }); + }); + + // display the remove button on mouse over (and hide them per default) + $('.members li').hover(function(){ + $(this).children('a.remove').show(); + }, function(){ + $(this).children('a.remove').hide(); + }); +}); +{% endblock %} + {% block top_menu %}