diff options
Diffstat (limited to 'budget/templates')
| -rw-r--r-- | budget/templates/list_bills.html | 89 |
1 files changed, 22 insertions, 67 deletions
diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index 3b33fb8..e62a3bc 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -39,70 +39,25 @@ $('#hide-bill-form').click(hide_form); $('#cancel-form').click(hide_form); - - var tr_id; - var id; - - // display the remove button on mouse over (and hide them per default) - $('.balance tr').hover(function() - { - tr_id = $(this).attr('id'); - var index = tr_id.lastIndexOf("-"); - id = tr_id.substring(index+1); - var action = $(this).attr('action'); - - var x = $(this).offset().left; - var y = $(this).offset().top; - var width = $(this).width(); - var height = $(this).height(); - - $('#overlay').css({ "left":x+"px", "top":y+"px", "width":width+"px", "height":height+"px", "line-height":height+"px" }).show(); - - if(!$(this).hasClass("confirm")) - { - $('#overlay').html(""); - if (action == 'delete') - { - $('#overlay-delete').css({ "left":(x+width/2-16)+"px", "top":(y+height/2-16)+"px" }).show(); - } - else if (action == 'reactivate') - { - $('#overlay-reactivate').css({ "left":(x+width/2-16)+"px", "top":(y+height/2-16)+"px" }).show(); - } - } - else - { - var url = "{{ url_for('.remove_member', member_id=id) }}"; - url = url.substring(0, url.lastIndexOf('/'))+id+url.substring(url.lastIndexOf('/')); - $('#overlay').html("<a href='"+url+"' >{{_("you sure?")}}</a>"); - } - }); - - // show confirm message before actually removing the member - $('#overlay-delete').click(function () - { - $('#'+tr_id).addClass("confirm"); - var url = "{{ url_for('.remove_member', member_id=id) }}"; - url = url.substring(0, url.lastIndexOf('/'))+id+url.substring(url.lastIndexOf('/')); - $('#overlay').html("<a href='"+url+"' >{{_("you sure?")}}</a>"); + // ask for confirmation before removing an user + $('.action').each(function(){ $(this).hide(); + var link = $(this).find('a'); + link.click(function(){ + if ($(this).hasClass("confirm")){ + return true; + } + $(this).html("{{_("you sure?")}}"); + $(this).addClass("confirm"); + return false; + }); }); - // re-create reactivation url from hover-ed item and call it - $('#overlay-reactivate').click(function () - { - var url = "{{ url_for('.reactivate', member_id=id) }}"; - url = url.substring(0, url.lastIndexOf('/'))+id+url.substring(url.lastIndexOf('/')); - $(location).attr('href', url); - }); - - $('#overlay').hover(function() - { - }, function() - { - $('#overlay').hide(); - $('#overlay-delete').hide(); - $('#overlay-reactivate').hide(); + // display the remove button on mouse over (and hide them per default) + $('.balance tr').hover(function(){ + $(this).find('.action').show(); + }, function(){ + $(this).find('.action').hide(); }); $.datepicker.setDefaults({'dateFormat': 'yy-mm-dd'}); @@ -143,15 +98,17 @@ <td class="balance-value {% if balance[member.id] > 0 %}positive{% elif balance[member.id] < 0 %}negative{% endif %}"> {% if balance[member.id] > 0 %}+{% endif %}{{ balance[member.id] }} </td> + {% if member.activated %} + <td class="action delete"> <a href="{{ url_for(".remove_member", member_id=member.id) }}">{{ _("delete") }}</a></td> + {% else %} + <td class="action reactivate"> <a href="{{ url_for(".reactivate", member_id=member.id) }}">{{ _("reactivate") }}</a></td> + {% endif %} </tr> {% endfor %} </table> </div> </div> - <div id="overlay"></div> - <img id="overlay-delete" title="{{ _("delete") }}" src="{{ url_for("static", filename="delete.png") }}"> - <img id="overlay-reactivate" title="{{ _("reactivate") }}" src="{{ url_for("static", filename="refresh.png") }}"> {% endblock %} {% block content %} @@ -176,7 +133,7 @@ <td>{{ "%0.2f"|format(bill.amount) }} ({{ "%0.2f"|format(bill.pay_each()) }} {{ _("each") }})</td> <td class="bill-actions"> <a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}"> - <img src="{{ url_for("static", filename="pen.png") }}" /> + <img src="{{ url_for("static", filename="edit.png") }}" /> </a> <a class="delete" href="{{ url_for(".delete_bill", bill_id=bill.id) }}" title="{{ _("delete") }}"> <img src="{{ url_for("static", filename="delete.png") }}" /> @@ -190,8 +147,6 @@ {% else %} <p>{{ _("Nothing to list yet. You probably want to") }} <a id="empty-new-bill" href="{{ url_for(".add_bill") }}">{{ _("add a bill") }}</a> ?</p> {% endif %} - - </div> <script> $("#sidebar").height( window.innerHeight-40 ); |
