From de551fdfe6647e616e3c24ee5d75e7a9f1e7ea62 Mon Sep 17 00:00:00 2001 From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Mon, 2 Nov 2009 07:15:50 +0000 Subject: [PATCH] some refactoring. redistribute payment when Payment Received field changes its value and leaves focus, or when the field is in focus and the enter key is pressed. In the case of the Enter key while in that field, switch focus to the Apply Payment button, so that a subsequent enter press would apply the payment git-svn-id: svn://svn.open-ils.org/ILS/trunk@14718 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/patron/bill2.js | 43 +++++++++++++++++------ Open-ILS/xul/staff_client/server/patron/bill2.xul | 2 +- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.js b/Open-ILS/xul/staff_client/server/patron/bill2.js index 90cf67df8e..9d1856d565 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.js +++ b/Open-ILS/xul/staff_client/server/patron/bill2.js @@ -31,17 +31,7 @@ function my_init() { retrieve_mbts_for_list(); - $('details').addEventListener( - 'command', - handle_details, - false - ); - - $('add').addEventListener( - 'command', - handle_add, - false - ); + event_listeners(); JSAN.use('util.exec'); var exec = new util.exec(20); exec.on_error = function(E) { alert(E); return true; } @@ -75,6 +65,37 @@ function my_init() { } } +function event_listeners() { + $('details').addEventListener( + 'command', + handle_details, + false + ); + + $('add').addEventListener( + 'command', + handle_add, + false + ); + + $('payment').addEventListener( + 'change', + function(ev) { distribute_payment(); }, + false + ); + + $('payment').addEventListener( + 'keypress', + function(ev) { + if (! (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) ) { return; } + distribute_payment(); + $('apply_payment_btn').focus(); + }, + false + ); + +} + function $(id) { return document.getElementById(id); } function default_focus() { diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.xul b/Open-ILS/xul/staff_client/server/patron/bill2.xul index f3911a0d63..7b0eb25487 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill2.xul @@ -110,7 +110,7 @@ <hbox> <checkbox id="annotate_payment" label="&staff.patron.bills_overlay.annotate_payment.label;" accesskey="n" oils_persist="checked" checked="false" oncommand="default_focus();"/> <button label="See Distribution" accesskey="D" oncommand="distribute_payment(); default_focus();"/> - <button label="Apply Payment" accesskey="P"/> + <button id="apply_payment_btn" label="Apply Payment" accesskey="P"/> </hbox> </groupbox> </hbox> -- 2.11.0