From 5bea275a8fbfb3d788ee3bc10867a9e45b0d9307 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 19 Jan 2013 00:46:32 -0500 Subject: [PATCH] LP#1086458: clean up after event listeners in circ/patron interface Upon window unload, now removes event listeners, both ones explicitly created by the page JavsScript as well as ones created by util.list, util.controller, and persist_helper(). The same approach of defining cleanup fnctions used by unload events can be applied to the rest of the staff client, but this patch focuses on circulation first. Signed-off-by: Galen Charlton Signed-off-by: Ben Shum --- .../xul/staff_client/server/circ/checkout.js | 9 +++- .../xul/staff_client/server/circ/checkout.xul | 13 ++++++ .../server/locale/en-US/patron.properties | 1 + .../server/patron/barcode_entry.xul | 14 +++++- .../xul/staff_client/server/patron/bill2.js | 38 ++++++++++------ .../xul/staff_client/server/patron/bill2.xul | 1 + .../server/patron/bill_cc_info.xul | 1 + .../server/patron/bill_check_info.xul | 1 + .../server/patron/bill_details.js | 18 ++++++-- .../server/patron/bill_details.xul | 1 + .../server/patron/bill_history.js | 24 +++++++--- .../server/patron/bill_history.xul | 1 + .../staff_client/server/patron/bill_wizard.js | 14 +++++- .../server/patron/bill_wizard.xul | 1 + .../xul/staff_client/server/patron/display.js | 39 +++++++++------- .../staff_client/server/patron/display.xul | 11 +++++ .../server/patron/display_horiz.xul | 11 +++++ .../server/patron/edit_standing_penalty.js | 23 +++++++--- .../server/patron/edit_standing_penalty.xul | 1 + .../staff_client/server/patron/hold_cancel.js | 15 ++++++- .../server/patron/hold_cancel.xul | 1 + .../server/patron/hold_details.js | 8 ++++ .../server/patron/hold_details.xul | 1 + .../xul/staff_client/server/patron/holds.js | 10 ++++- .../xul/staff_client/server/patron/holds.xul | 11 +++++ .../staff_client/server/patron/info_group.js | 10 +++++ .../staff_client/server/patron/info_group.xul | 1 + .../staff_client/server/patron/info_notes.xul | 17 ++++++- .../server/patron/info_stat_cats.xul | 1 + .../server/patron/info_surveys.xul | 1 + .../xul/staff_client/server/patron/items.js | 6 +++ .../xul/staff_client/server/patron/items.xul | 11 +++++ .../server/patron/new_standing_penalty.js | 23 +++++++--- .../server/patron/new_standing_penalty.xul | 1 + .../staff_client/server/patron/place_hold.js | 25 +++++++---- .../staff_client/server/patron/place_hold.xul | 1 + .../staff_client/server/patron/search_form.js | 15 +++++-- .../server/patron/search_form.xul | 11 +++++ .../server/patron/search_form_horiz.xul | 11 +++++ .../server/patron/search_result.js | 44 +++++++++++-------- .../server/patron/search_result.xul | 11 +++++ .../xul/staff_client/server/patron/staged.js | 19 ++++++-- .../xul/staff_client/server/patron/staged.xul | 1 + .../server/patron/standing_penalties.js | 22 +++++++--- .../server/patron/standing_penalties.xul | 1 + .../xul/staff_client/server/patron/summary.js | 11 ++++- .../staff_client/server/patron/summary.xul | 14 +++++- .../server/patron/user_buckets.xul | 1 + 48 files changed, 428 insertions(+), 98 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index 9b6089c906..a1231a5b39 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -16,6 +16,7 @@ circ.checkout.prototype = { var obj = this; + obj.event_listeners = new EventListenerList(); obj.patron_id = params.patron_id; obj.auto_override_events = []; @@ -87,7 +88,7 @@ circ.checkout.prototype = { e.appendChild( ml ); ml.setAttribute('id','checkout_menulist'); ml.setAttribute('accesskey',''); - ml.addEventListener( + obj.event_listeners.add(ml, 'command', function(ev) { var tb = obj.controller.view.checkout_barcode_entry_textbox; @@ -269,6 +270,12 @@ circ.checkout.prototype = { }, + 'cleanup' : function() { + var obj = this; + obj.controller.cleanup(); + obj.event_listeners.removeAll(); + }, + 'check_disable' : function() { var obj = this; try { diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.xul b/Open-ILS/xul/staff_client/server/circ/checkout.xul index 75c8a55799..c1ba2ee727 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.xul +++ b/Open-ILS/xul/staff_client/server/circ/checkout.xul @@ -21,6 +21,7 @@ @@ -59,6 +60,18 @@ } } + function my_cleanup() { + try { + g.checkout.cleanup(); + } catch(E) { + try { + g.error.standard_unexpected_error_alert('circ/checkout.xul',E); + } catch(F) { + dump('FIXME: circ/checkout.xul -> ' + E + ' -> ' + F + '\n'); + } + } + } + function default_focus() { try { var x = document.getElementById('checkout_barcode_entry_textbox'); diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index 567a40c06c..cee408d123 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -14,6 +14,7 @@ staff.patron.bill_interface.payment_pending.column_header=Payment Pending staff.patron.bill_cc_info.need_cc_number=You must provide a credit card number staff.patron.bill_cc_info.need_approval_code=You must provide an approval code or an imprint slip number staff.patron.bill_details.my_init.error=bill_details.xul, my_init: +staff.patron.bill_details.my_cleanup.error=bill_details.xul, my_cleanup: staff.patron.bill_details.handle_edit_bill_note.note_dialog.title=Replacement Note staff.patron.bill_details.handle_edit_bill_note.note_dialog.prompt=Enter new note: staff.patron.bill_details.handle_edit_bill_note.failure=Note for selected bills not likely updated. diff --git a/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul b/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul index bd8f0776c4..d2e2405521 100644 --- a/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul +++ b/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul @@ -19,6 +19,7 @@ @@ -42,7 +43,8 @@ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'}); var tb = document.getElementById('barcode_tb'); - tb.addEventListener( + window.barcode_entry_event_listeners = new EventListenerList(); + window.barcode_entry_event_listeners.add(tb, 'keypress', function(ev) { if (ev.keyCode == 13 || ev.keyCode == 77) { @@ -77,6 +79,16 @@ } } + function my_cleanup() { + try { + window.barcode_entry_event_listeners.removeAll(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/barcode_entry.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function submit() { var tb; try { diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.js b/Open-ILS/xul/staff_client/server/patron/bill2.js index 83bf51c8d2..10d6748c76 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.js +++ b/Open-ILS/xul/staff_client/server/patron/bill2.js @@ -14,6 +14,7 @@ function my_init() { g.data.voided_billings = []; g.data.stash('voided_billings'); g.error.sdump('D_TRACE','my_init() for bill2.xul'); + window.bill_event_listeners = new EventListenerList(); document.title = $("patronStrings").getString('staff.patron.bill_history.my_init.current_bills'); @@ -63,45 +64,56 @@ function my_init() { } } +function my_cleanup() { + try { + window.bill_event_listeners.removeAll(); + g.bill_list.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/bill2.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } +} + function event_listeners() { try { - $('details').addEventListener( + window.bill_event_listeners.add($('details'), 'command', handle_details, false ); - $('add').addEventListener( + window.bill_event_listeners.add($('add'), 'command', handle_add, false ); - $('voidall').addEventListener( + window.bill_event_listeners.add($('voidall'), 'command', handle_void_all, false ); - $('refund').addEventListener( + window.bill_event_listeners.add($('refund'), 'command', handle_refund, false ); - $('opac').addEventListener( + window.bill_event_listeners.add($('opac'), 'command', handle_opac, false ); - $('copy_details').addEventListener( + window.bill_event_listeners.add($('copy_details'), 'command', handle_copy_details, false ); - $('payment').addEventListener( + window.bill_event_listeners.add($('payment'), 'change', function(ev) { if ($('payment_type').value == 'credit_payment') { @@ -120,13 +132,13 @@ function event_listeners() { false ); - $('payment').addEventListener( + window.bill_event_listeners.add($('payment'), 'focus', function(ev) { ev.target.select(); }, false ); - $('payment').addEventListener( + window.bill_event_listeners.add($('payment'), 'keypress', function(ev) { if (! (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) ) { return; } @@ -136,7 +148,7 @@ function event_listeners() { false ); - $('bill_patron_btn').addEventListener( + window.bill_event_listeners.add($('bill_patron_btn'), 'command', function() { JSAN.use('util.window'); var win = new util.window(); @@ -154,7 +166,7 @@ function event_listeners() { false ); - $('bill_history_btn').addEventListener( + window.bill_event_listeners.add($('bill_history_btn'), 'command', function() { xulG.display_window.g.patron.right_deck.reset_iframe( @@ -171,7 +183,7 @@ function event_listeners() { false ); - $('convert_change_to_credit').addEventListener( + window.bill_event_listeners.add($('convert_change_to_credit'), 'command', function(ev) { if (ev.target.checked) { @@ -183,7 +195,7 @@ function event_listeners() { false ); - $('apply_payment_btn').addEventListener( + window.bill_event_listeners.add($('apply_payment_btn'), 'command', function(ev) { try { diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.xul b/Open-ILS/xul/staff_client/server/patron/bill2.xul index 51167a5bd3..32f0e0be7a 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill2.xul @@ -22,6 +22,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul b/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul index 36337450e2..8cb4804267 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul @@ -21,6 +21,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/bill_check_info.xul b/Open-ILS/xul/staff_client/server/patron/bill_check_info.xul index 71738ec28e..373a74b8a5 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_check_info.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_check_info.xul @@ -21,6 +21,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index 52c4e061ff..fbb519f603 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -215,6 +215,8 @@ function my_init() { g.mbts_id = xul_param('mbts_id'); + window.bill_details_event_listeners = new EventListenerList(); + retrieve_patron(); retrieve_mbts(); @@ -224,19 +226,19 @@ function my_init() { retrieve_mb(); retrieve_mp(); - $('void').addEventListener( + window.bill_details_event_listeners.add($('void'), 'command', handle_void, false ); - $('edit_bill_note').addEventListener( + window.bill_details_event_listeners.add($('edit_bill_note'), 'command', handle_edit_bill_note, false ); - $('edit_payment_note').addEventListener( + window.bill_details_event_listeners.add($('edit_payment_note'), 'command', handle_edit_payment_note, false @@ -247,6 +249,16 @@ function my_init() { } } +function my_cleanup() { + try { + g.bill_list.cleanup(); + g.payment_list.cleanup(); + window.bill_details_event_listeners.removeAll(); + } catch(E) { + try { g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bill_details.my_cleanup.error'),E); } catch(F) { alert(E); } + } +} + function handle_edit_bill_note() { try { var mb_list = util.functional.map_list(g.bill_list_selection, function(o){return g.mb_list[o].id();}); diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.xul b/Open-ILS/xul/staff_client/server/patron/bill_details.xul index a16d4e7520..2454d35ddc 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.xul @@ -22,6 +22,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.js b/Open-ILS/xul/staff_client/server/patron/bill_history.js index 098a140ed4..e1365cd4be 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.js @@ -237,6 +237,7 @@ function my_init() { g.funcs = []; g.bill_map = {}; g.payments_map = {}; g.patron_id = xul_param('patron_id'); + window.bill_history_event_listeners = new EventListenerList(); init_lists(); @@ -244,31 +245,31 @@ function my_init() { retrieve_mbts_for_list(); - $('details').addEventListener( + window.bill_history_event_listeners.add($('details'), 'command', gen_handle_details('bills'), false ); - $('payments_details').addEventListener( + window.bill_history_event_listeners.add($('payments_details'), 'command', gen_handle_details('payments'), false ); - $('copy_details').addEventListener( + window.bill_history_event_listeners.add($('copy_details'), 'command', gen_handle_copy_details('bills'), false ); - $('copy_details_from_payments').addEventListener( + window.bill_history_event_listeners.add($('copy_details_from_payments'), 'command', gen_handle_copy_details('payments'), false ); - $('add').addEventListener( + window.bill_history_event_listeners.add($('add'), 'command', handle_add, false @@ -284,6 +285,19 @@ function my_init() { } } +function my_cleanup() { + try { + g.bill_list.cleanup(); + g.payments_list.cleanup(); + window.bill_history_event_listeners.removeAll(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/bill_history.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } +} + + function handle_add() { if(g.bill_list_selection.length > 1) var msg = $("patronStrings").getFormattedString('staff.patron.bill_history.handle_add.message_plural', [g.bill_list_selection]); diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.xul b/Open-ILS/xul/staff_client/server/patron/bill_history.xul index 128ce1d27d..9671de1bba 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.xul @@ -22,6 +22,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js index 1dc31471c3..25ef0a978f 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js @@ -116,7 +116,8 @@ function patron_bill_init() { ); ml.setAttribute('id','billing_type'); document.getElementById('menu_placeholder').appendChild(ml); - ml.addEventListener( + window.bill_wizard_event_listeners = new EventListenerList(); + window.bill_wizard_event_listeners.add(ml, 'command', function() { if ( g.OpenILS.data.hash.cbt[ ml.value ] ) { @@ -155,6 +156,17 @@ function patron_bill_init() { } +function patron_bill_cleanup() { + try { + window.bill_wizard_event_listeners.removeAll(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/bill_wizard.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + +} + function patron_bill_finish() { try { var do_not_process_bill = xul_param('do_not_process_bill'); diff --git a/Open-ILS/xul/staff_client/server/patron/bill_wizard.xul b/Open-ILS/xul/staff_client/server/patron/bill_wizard.xul index 126f021ae2..44cb12a923 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_wizard.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_wizard.xul @@ -22,6 +22,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/display.js b/Open-ILS/xul/staff_client/server/patron/display.js index 33fead8acc..74e53fcbb0 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.js +++ b/Open-ILS/xul/staff_client/server/patron/display.js @@ -24,6 +24,7 @@ patron.display.prototype = { var obj = this; + obj.event_listeners = new EventListenerList(); obj.barcode = params['barcode']; obj.id = params['id']; @@ -604,22 +605,22 @@ patron.display.prototype = { } ); - var x = document.getElementById("PatronNavBar_checkout"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_refresh"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_items"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_holds"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_other"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_edit"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_bills"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); - var x = document.getElementById("PatronNavBar_messages"); - x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false); + var make_listener = function(xx) { + return function() { + try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; + } + }; + + + var need_focus_listeners = [ + 'PatronNavBar_checkout', 'PatronNavBar_refresh', 'PatronNavBar_items', 'PatronNavBar_holds', + 'PatronNavBar_other', 'PatronNavBar_edit', 'PatronNavBar_bills', 'PatronNavBar_messages' + ]; + for (var i = 0; i < need_focus_listeners.length; i++) { + var elementID = need_focus_listeners[i]; + var x = document.getElementById(elementID); + obj.event_listeners.add(x, 'focus', make_listener(x), false); + } if (obj.barcode || obj.id) { if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') { @@ -685,6 +686,12 @@ patron.display.prototype = { } }, + 'cleanup' : function( params ) { + var obj = this; + obj.controller.cleanup(); + obj.event_listeners.removeAll(); + }, + 'reset_nav_styling' : function(btn,dont_hide_summary) { try { if (!dont_hide_summary) { dont_hide_summary = false; } diff --git a/Open-ILS/xul/staff_client/server/patron/display.xul b/Open-ILS/xul/staff_client/server/patron/display.xul index e0861dbb89..65a1a740a4 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.xul +++ b/Open-ILS/xul/staff_client/server/patron/display.xul @@ -21,6 +21,7 @@ @@ -62,6 +63,16 @@ } } + function my_cleanup() { + try { + g.patron.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/display.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function default_focus() { setTimeout( function() { diff --git a/Open-ILS/xul/staff_client/server/patron/display_horiz.xul b/Open-ILS/xul/staff_client/server/patron/display_horiz.xul index 1c5383410c..52aa0b699f 100644 --- a/Open-ILS/xul/staff_client/server/patron/display_horiz.xul +++ b/Open-ILS/xul/staff_client/server/patron/display_horiz.xul @@ -21,6 +21,7 @@ @@ -62,6 +63,16 @@ } } + function my_cleanup() { + try { + g.patron.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/display.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function default_focus() { setTimeout( function() { diff --git a/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js b/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js index b2d60fdb64..0ae197b06d 100644 --- a/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js +++ b/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js @@ -48,7 +48,8 @@ function edit_penalty_init() { } /* set widget behavior */ - document.getElementById('csp_menulist').addEventListener( + window.edit_standing_penalty_event_listeners = new EventListenerList(); + window.edit_standing_penalty_event_listeners.add(document.getElementById('csp_menulist'), 'command', function() { document.getElementById('note_btn').checked = false; @@ -57,7 +58,7 @@ function edit_penalty_init() { }, false ); - document.getElementById('note_btn').addEventListener( + window.edit_standing_penalty_event_listeners.add(document.getElementById('note_btn'), 'command', function() { document.getElementById('csp_menulist').setAttribute('label',''); @@ -65,7 +66,7 @@ function edit_penalty_init() { }, false ); - document.getElementById('alert_btn').addEventListener( + window.edit_standing_penalty_event_listeners.add(document.getElementById('alert_btn'), 'command', function() { document.getElementById('csp_menulist').setAttribute('label',''); @@ -73,7 +74,7 @@ function edit_penalty_init() { }, false ); - document.getElementById('block_btn').addEventListener( + window.edit_standing_penalty_event_listeners.add(document.getElementById('block_btn'), 'command', function() { document.getElementById('csp_menulist').setAttribute('label',''); @@ -81,10 +82,10 @@ function edit_penalty_init() { }, false ); - document.getElementById('cancel_btn').addEventListener( + window.edit_standing_penalty_event_listeners.add(document.getElementById('cancel_btn'), 'command', function() { window.close(); }, false ); - document.getElementById('apply_btn').addEventListener( + window.edit_standing_penalty_event_listeners.add(document.getElementById('apply_btn'), 'command', function() { var note = document.getElementById('note_tb').value; @@ -113,6 +114,16 @@ function edit_penalty_init() { } +function edit_penalty_cleanup() { + try { + window.edit_standing_penalty_event_listeners.removeAll(); + } catch(E) { + var err_prefix = 'standing_penalties.js -> penalty_cleanup() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } + +} + function build_penalty_menu() { try { diff --git a/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul b/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul index d27c00152a..771ae57669 100644 --- a/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul +++ b/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul @@ -19,6 +19,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/hold_cancel.js b/Open-ILS/xul/staff_client/server/patron/hold_cancel.js index 4adbcc1855..2f24eafccc 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_cancel.js +++ b/Open-ILS/xul/staff_client/server/patron/hold_cancel.js @@ -25,10 +25,11 @@ function hold_cancel_init() { build_cancel_reason_menu(); /* set widget behavior */ - document.getElementById('cancel_btn').addEventListener( + window.hold_cancel_event_listeners = new EventListenerList(); + window.hold_cancel_event_listeners.add(document.getElementById('cancel_btn'), 'command', function() { window.close(); }, false ); - document.getElementById('apply_btn').addEventListener( + window.hold_cancel_event_listeners.add(document.getElementById('apply_btn'), 'command', function() { var note = document.getElementById('note_tb').value; @@ -49,6 +50,16 @@ function hold_cancel_init() { } +function hold_cancel_cleanup() { + try { + window.hold_cancel_event_listeners.removeAll(); + } catch(E) { + var err_prefix = 'hold_cancel.js -> hold_cancel_cleanup() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } + +} + function build_cancel_reason_menu() { try { diff --git a/Open-ILS/xul/staff_client/server/patron/hold_cancel.xul b/Open-ILS/xul/staff_client/server/patron/hold_cancel.xul index fb3830cc6e..d2da173951 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_cancel.xul +++ b/Open-ILS/xul/staff_client/server/patron/hold_cancel.xul @@ -19,6 +19,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/hold_details.js b/Open-ILS/xul/staff_client/server/patron/hold_details.js index be349113a2..f583094c16 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_details.js +++ b/Open-ILS/xul/staff_client/server/patron/hold_details.js @@ -29,6 +29,14 @@ function my_init() { } } +function my_cleanup() { + try { + g.list.cleanup(); + } catch(E) { + try { g.error.standard_unexpected_error_alert('/xul/server/patron/hold_notices.xul',E); } catch(E) { alert('FIXME: ' + js2JSON(E)); } + } +} + function fetch_and_render_all(do_not_refresh_parent_interface) { try { if (!xulG.ahr_id) { return; } diff --git a/Open-ILS/xul/staff_client/server/patron/hold_details.xul b/Open-ILS/xul/staff_client/server/patron/hold_details.xul index 779b798cf6..245a061011 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_details.xul +++ b/Open-ILS/xul/staff_client/server/patron/hold_details.xul @@ -20,6 +20,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index 9b15aef53e..eaa29c43e8 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -41,6 +41,7 @@ patron.holds.prototype = { var obj = this; dojo.require("openils.Util"); + obj.event_listeners = new EventListenerList(); obj.patron_id = params['patron_id']; obj.patron_barcode = params['patron_barcode']; @@ -1632,6 +1633,13 @@ patron.holds.prototype = { }, + 'cleanup' : function() { + var obj = this; + obj.controller.cleanup(); + obj.list.cleanup(); + obj.event_listeners.removeAll(); + }, + 'determine_hold_interface_type' : function() { var obj = this; if (obj.patron_id) { /*************************************************** PATRON ******************************/ @@ -1825,7 +1833,7 @@ patron.holds.prototype = { var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() ); ml.setAttribute('id','lib_menu'); x.appendChild( ml ); - ml.addEventListener( + obj.event_listeners.add(ml, 'command', function(ev) { obj.filter_lib = ev.target.value; diff --git a/Open-ILS/xul/staff_client/server/patron/holds.xul b/Open-ILS/xul/staff_client/server/patron/holds.xul index f7f03fcc41..47eb367099 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.xul +++ b/Open-ILS/xul/staff_client/server/patron/holds.xul @@ -21,6 +21,7 @@ @@ -65,6 +66,16 @@ } } + function my_cleanup() { + try { + g.holds.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/holds.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function default_focus() { try { document.getElementById('holds_print').focus(); } catch(E) { } } ]]> diff --git a/Open-ILS/xul/staff_client/server/patron/info_group.js b/Open-ILS/xul/staff_client/server/patron/info_group.js index 60f754fbb7..a9407ce657 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_group.js +++ b/Open-ILS/xul/staff_client/server/patron/info_group.js @@ -29,6 +29,16 @@ function my_init() { } } +function my_cleanup() { + try { + list.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/info_group.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } +} + function retrieve_money_summaries() { try { JSAN.use('util.money'); diff --git a/Open-ILS/xul/staff_client/server/patron/info_group.xul b/Open-ILS/xul/staff_client/server/patron/info_group.xul index 9e8777e9d1..388efa27da 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_group.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_group.xul @@ -20,6 +20,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/info_notes.xul b/Open-ILS/xul/staff_client/server/patron/info_notes.xul index 133eec5cf2..ab45e78afa 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_notes.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_notes.xul @@ -20,6 +20,7 @@ @@ -54,6 +55,8 @@ g.new_note = false; + g.info_notes_event_listeners = new EventListenerList(); + refresh(); } catch(E) { @@ -63,6 +66,16 @@ } } + function my_cleanup() { + try { + g.info_notes_event_listeners.removeAll(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/info_notes.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function refresh() { retrieve_notes(); render_notes(); } @@ -124,7 +137,7 @@ btn1.setAttribute('label',$("patronStrings").getString('staff.patron.info_notes.render_notes.btn1.delete_note.label')); btn1.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif"); - btn1.addEventListener( + g.info_notes_event_listeners.add(btn1, 'command', function(id){ return function() { @@ -153,7 +166,7 @@ btn2.setAttribute('label',$("patronStrings").getString('staff.patron.info_notes.render_notes.btn2.print_note.label')); btn2.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif"); - btn2.addEventListener( + g.info_notes_event_listeners.add(btn2, 'command', function(id){ return function() { try { diff --git a/Open-ILS/xul/staff_client/server/patron/info_stat_cats.xul b/Open-ILS/xul/staff_client/server/patron/info_stat_cats.xul index 4318313f66..400aa6753c 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_stat_cats.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_stat_cats.xul @@ -20,6 +20,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/info_surveys.xul b/Open-ILS/xul/staff_client/server/patron/info_surveys.xul index 66231c398e..c0fb29bd23 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_surveys.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_surveys.xul @@ -20,6 +20,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index 65e36b7a65..64d244d179 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -225,6 +225,12 @@ patron.items.prototype = { obj.controller.view.cmd_show_catalog2.setAttribute('disabled','true'); }, + 'cleanup' : function() { + var obj = this; + obj.list.cleanup(); + obj.list2.cleanup(); + }, + 'show_noncats' : function() { var obj = this; var checkout = {}; try { diff --git a/Open-ILS/xul/staff_client/server/patron/items.xul b/Open-ILS/xul/staff_client/server/patron/items.xul index 6faf415104..0c7c537e36 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.xul +++ b/Open-ILS/xul/staff_client/server/patron/items.xul @@ -21,6 +21,7 @@ @@ -58,6 +59,16 @@ } } + function my_cleanup() { + try { + g.items.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/items.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function default_focus() { try { var x = document.getElementById('noncat'); x.focus(); } catch(E) { try { g.error.sdump('D_ERROR','item.xul, default_focus: ' + E); } catch(F) { dump(E); } } } ]]> diff --git a/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js b/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js index ddfd645c84..73c40cba4b 100644 --- a/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js +++ b/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js @@ -30,7 +30,8 @@ function new_penalty_init() { } /* set widget behavior */ - document.getElementById('csp_menulist').addEventListener( + window.new_standing_penalty_event_listeners = new EventListenerList(); + window.new_standing_penalty_event_listeners.add(document.getElementById('csp_menulist'), 'command', function() { document.getElementById('note_btn').checked = false; @@ -39,7 +40,7 @@ function new_penalty_init() { }, false ); - document.getElementById('note_btn').addEventListener( + window.new_standing_penalty_event_listeners.add(document.getElementById('note_btn'), 'command', function() { document.getElementById('csp_menulist').setAttribute('label',''); @@ -47,7 +48,7 @@ function new_penalty_init() { }, false ); - document.getElementById('alert_btn').addEventListener( + window.new_standing_penalty_event_listeners.add(document.getElementById('alert_btn'), 'command', function() { document.getElementById('csp_menulist').setAttribute('label',''); @@ -55,7 +56,7 @@ function new_penalty_init() { }, false ); - document.getElementById('block_btn').addEventListener( + window.new_standing_penalty_event_listeners.add(document.getElementById('block_btn'), 'command', function() { document.getElementById('csp_menulist').setAttribute('label',''); @@ -63,10 +64,10 @@ function new_penalty_init() { }, false ); - document.getElementById('cancel_btn').addEventListener( + window.new_standing_penalty_event_listeners.add(document.getElementById('cancel_btn'), 'command', function() { window.close(); }, false ); - document.getElementById('apply_btn').addEventListener( + window.new_standing_penalty_event_listeners.add(document.getElementById('apply_btn'), 'command', function() { var note = document.getElementById('note_tb').value; @@ -96,6 +97,16 @@ function new_penalty_init() { } +function new_penalty_cleanup() { + try { + window.new_standing_penalty_event_listeners.removeAll(); + } catch(E) { + var err_prefix = 'standing_penalties.js -> penalty_cleanup() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } + +} + function build_penalty_menu() { try { diff --git a/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul b/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul index 7e9271b61a..cef7264189 100644 --- a/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul +++ b/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul @@ -19,6 +19,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/place_hold.js b/Open-ILS/xul/staff_client/server/patron/place_hold.js index 4dd84230f8..62049e78a4 100644 --- a/Open-ILS/xul/staff_client/server/patron/place_hold.js +++ b/Open-ILS/xul/staff_client/server/patron/place_hold.js @@ -20,7 +20,8 @@ function my_init() { populate_hold_usr_textbox(); populate_pickup_lib_menu(); - $('request_btn').addEventListener( + window.place_hold_event_listeners = new EventListenerList(); + window.place_hold_event_listeners.add($('request_btn'), 'command', function(ev) { make_request(copy_ids,false); @@ -35,6 +36,14 @@ function my_init() { } } +function my_cleanup() { + try { + window.place_hold_event_listeners.removeAll(); + } catch(E) { + alert('Error in place_hold.js, my_init(): ' + E); + } +} + function make_request(copy_ids,override) { try { @@ -134,7 +143,7 @@ function handle_failures(failures,failed_targets) { ) ); addCSSClass(err_msg,'click_link'); - err_msg.addEventListener( + window.place_hold_event_listeners.add(err_msg, 'click', function(copy_ids) { return function(ev) { @@ -156,7 +165,7 @@ function handle_failures(failures,failed_targets) { ); err_box.appendChild(retry_btn); - retry_btn.addEventListener( + window.place_hold_event_listeners.add(retry_btn, 'command', function(copy_ids) { return function(ev) { @@ -177,7 +186,7 @@ function handle_failures(failures,failed_targets) { ); err_box.appendChild(override_btn); - override_btn.addEventListener( + window.place_hold_event_listeners.add(override_btn, 'command', function(copy_ids) { return function(ev) { @@ -200,13 +209,13 @@ function handle_failures(failures,failed_targets) { function set_remaining_event_listeners() { try { - $('hold_type_menu').addEventListener( + window.place_hold_event_listeners.add($('hold_type_menu'), 'command', function(ev) { oils_lock_page(); }, false ); - $('cancel_btn').addEventListener( + window.place_hold_event_listeners.add($('cancel_btn'), 'command', function(ev) { xulG.close_tab(); }, false @@ -231,7 +240,7 @@ function populate_hold_usr_textbox() { 'value', patron.util.format_name(au_obj) ); - $('hold_usr_textbox').addEventListener( + window.place_hold_event_listeners.add($('hold_usr_textbox'), 'change', function(ev) { try { @@ -288,7 +297,7 @@ function populate_pickup_lib_menu() { $('pickup_lib_menu_placeholder').appendChild(ml); - ml.addEventListener( + window.place_hold_event_listeners.add(ml, 'command', function(ev) { oils_lock_page(); }, false diff --git a/Open-ILS/xul/staff_client/server/patron/place_hold.xul b/Open-ILS/xul/staff_client/server/patron/place_hold.xul index afa0a5539d..21c59b212a 100644 --- a/Open-ILS/xul/staff_client/server/patron/place_hold.xul +++ b/Open-ILS/xul/staff_client/server/patron/place_hold.xul @@ -19,6 +19,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/search_form.js b/Open-ILS/xul/staff_client/server/patron/search_form.js index 7f589522c6..5fadf55334 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_form.js +++ b/Open-ILS/xul/staff_client/server/patron/search_form.js @@ -13,6 +13,7 @@ patron.search_form.prototype = { 'init' : function( params ) { var obj = this; + obj.event_listeners = new EventListenerList(); // The bulk of params.query is getting parsed/rendered by obj.controller.init below, and will be reconstituted from possibly modified XUL elements upon Submit. // But we're going to let search_limit and search_sort be configurable now by those spawning this interface, and let's assume there are no corresponding widgets for now. @@ -251,7 +252,7 @@ patron.search_form.prototype = { obj.controller.render(); var nl = document.getElementsByTagName('textbox'); for (var i = 0; i < nl.length; i++) { - nl[i].addEventListener('keypress',function(ev){ + obj.event_listeners.add(nl[i], 'keypress', function(ev) { if (ev.target.tagName != 'textbox') return; if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* enter on a mac */) setTimeout( function() { obj.submit(); }, 0); },false); @@ -273,7 +274,7 @@ patron.search_form.prototype = { } ) ); - ml.addEventListener('command', function() { + obj.event_listeners.add(ml, 'command', function() { ml.parentNode.setAttribute('value',ml.value); var file = new util.file('patron_search_prefs.'+obj.OpenILS.data.server_unadorned); util.widgets.save_attributes(file, { 'search_depth_ml' : [ 'value' ], 'inactive' : [ 'value' ] }); @@ -291,7 +292,7 @@ patron.search_form.prototype = { } var cb = obj.controller.view.inactive; - cb.addEventListener('command',function() { + obj.event_listeners.add(cb, 'command',function() { cb.setAttribute('value',cb.checked ? "true" : "false"); var file = new util.file('patron_search_prefs.'+obj.OpenILS.data.server_unadorned); util.widgets.save_attributes(file, { 'search_depth_ml' : [ 'value' ], 'inactive' : [ 'value' ] }); @@ -315,7 +316,7 @@ patron.search_form.prototype = { } ) ); - profile_ml.addEventListener('command', function() { + obj.event_listeners.add(profile_ml, 'command', function() { profile_ml.parentNode.setAttribute('value', profile_ml.value); }, false ); @@ -331,6 +332,12 @@ patron.search_form.prototype = { } }, + 'cleanup' : function() { + var obj = this; + obj.controller.cleanup(); + obj.event_listeners.removeAll(); + }, + 'on_submit' : function(q) { var msg = 'Query = ' + q; this.error.sdump('D_PATRON', msg); diff --git a/Open-ILS/xul/staff_client/server/patron/search_form.xul b/Open-ILS/xul/staff_client/server/patron/search_form.xul index 43a4fde48a..782246908a 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_form.xul +++ b/Open-ILS/xul/staff_client/server/patron/search_form.xul @@ -21,6 +21,7 @@ @@ -68,6 +69,16 @@ } } + function my_cleanup() { + try { + g.search_form.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/search_form.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function default_focus() { setTimeout( function() { diff --git a/Open-ILS/xul/staff_client/server/patron/search_form_horiz.xul b/Open-ILS/xul/staff_client/server/patron/search_form_horiz.xul index 4e8f6afcd6..ed0655bfc7 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_form_horiz.xul +++ b/Open-ILS/xul/staff_client/server/patron/search_form_horiz.xul @@ -21,6 +21,7 @@ @@ -67,6 +68,16 @@ alert(err_msg); } } + + function my_cleanup() { + try { + g.search_form.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/search_form.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } function default_focus() { setTimeout( diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.js b/Open-ILS/xul/staff_client/server/patron/search_result.js index e9e5f4a6c6..8a77a71096 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_result.js +++ b/Open-ILS/xul/staff_client/server/patron/search_result.js @@ -73,6 +73,25 @@ patron.search_result.prototype = { },'mailing_') ); + obj.dblclick_handler = function(ev) { + JSAN.use('util.functional'); + var sel = obj.list.retrieve_selection(); + var list = util.functional.map_list( + sel, + function(o) { return o.getAttribute('retrieve_id'); } + ); + obj.controller.view.cmd_sel_clip.setAttribute('disabled', list.length < 1 ); + if (typeof obj.on_dblclick == 'function') { + obj.on_dblclick(list); + } + if (typeof window.xulG == 'object' && typeof window.xulG.on_dblclick == 'function') { + obj.error.sdump('D_PATRON','patron.search_result: Calling external .on_dblclick()\n'); + window.xulG.on_dblclick(list); + } else { + obj.error.sdump('D_PATRON','patron.search_result: No external .on_dblclick()\n'); + } + }; + obj.list.init( { 'columns' : columns, @@ -101,24 +120,7 @@ patron.search_result.prototype = { } ); }, - 'on_dblclick' : function(ev) { - JSAN.use('util.functional'); - var sel = obj.list.retrieve_selection(); - var list = util.functional.map_list( - sel, - function(o) { return o.getAttribute('retrieve_id'); } - ); - obj.controller.view.cmd_sel_clip.setAttribute('disabled', list.length < 1 ); - if (typeof obj.on_dblclick == 'function') { - obj.on_dblclick(list); - } - if (typeof window.xulG == 'object' && typeof window.xulG.on_dblclick == 'function') { - obj.error.sdump('D_PATRON','patron.search_result: Calling external .on_dblclick()\n'); - window.xulG.on_dblclick(list); - } else { - obj.error.sdump('D_PATRON','patron.search_result: No external .on_dblclick()\n'); - } - }, + 'on_dblclick' : obj.dblclick_handler, 'on_select' : function(ev) { JSAN.use('util.functional'); var sel = obj.list.retrieve_selection(); @@ -184,6 +186,12 @@ patron.search_result.prototype = { if (obj.query) obj.search(obj.query); }, + 'cleanup' : function( params ) { + var obj = this; + obj.controller.cleanup(); + obj.list.cleanup(); + }, + 'search' : function(query) { var obj = this; var search_hash = {}; diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.xul b/Open-ILS/xul/staff_client/server/patron/search_result.xul index 9546380110..658eafc067 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_result.xul +++ b/Open-ILS/xul/staff_client/server/patron/search_result.xul @@ -21,6 +21,7 @@ @@ -63,6 +64,16 @@ } } + function my_cleanup() { + try { + g.search_result.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/search_result.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + ]]> diff --git a/Open-ILS/xul/staff_client/server/patron/staged.js b/Open-ILS/xul/staff_client/server/patron/staged.js index 45e156774a..246a57d161 100644 --- a/Open-ILS/xul/staff_client/server/patron/staged.js +++ b/Open-ILS/xul/staff_client/server/patron/staged.js @@ -33,13 +33,14 @@ function staged_init() { dojo.require('openils.Util'); + window.staged_event_listeners = new EventListenerList(); populate_lib_menu(); init_list(); $('list_actions').appendChild( list.render_list_actions() ); list.set_list_actions(); - $('cmd_cancel').addEventListener('command', gen_event_handler('cancel'), false); - $('cmd_load').addEventListener('command', gen_event_handler('load'), false); - $('cmd_reload').addEventListener('command', function() { populate_list(); }, false); + window.staged_event_listeners.add($('cmd_cancel'), 'command', gen_event_handler('cancel'), false); + window.staged_event_listeners.add($('cmd_load'), 'command', gen_event_handler('load'), false); + window.staged_event_listeners.add($('cmd_reload'), 'command', function() { populate_list(); }, false); populate_list(); default_focus(); @@ -49,6 +50,16 @@ function staged_init() { } } +function staged_cleanup() { + try { + list.cleanup(); + window.staged_event_listeners.removeAll(); + } catch(E) { + var err_prefix = 'staged.js -> staged_cleanup() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } +} + function populate_lib_menu() { try { JSAN.use('util.widgets'); @@ -64,7 +75,7 @@ function populate_lib_menu() { var ml = util.widgets.make_menulist( list_data[0], menu_lib ); ml.setAttribute('id','lib_menu'); x.appendChild( ml ); - ml.addEventListener( + window.staged_event_listeners.add(ml, 'command', function(ev) { menu_lib = ev.target.value; diff --git a/Open-ILS/xul/staff_client/server/patron/staged.xul b/Open-ILS/xul/staff_client/server/patron/staged.xul index f7fb70f2fa..18b31408de 100644 --- a/Open-ILS/xul/staff_client/server/patron/staged.xul +++ b/Open-ILS/xul/staff_client/server/patron/staged.xul @@ -18,6 +18,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js index d36edf4476..7b9f714034 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js @@ -28,12 +28,13 @@ function penalty_init() { init_list(); init_archived_list(); + window.standing_penalties_event_listeners = new EventListenerList(); document.getElementById('date1').year = document.getElementById('date1').year - 1; - document.getElementById('cmd_apply_penalty').addEventListener('command', handle_apply_penalty, false); - document.getElementById('cmd_remove_penalty').addEventListener('command', handle_remove_penalty, false); - document.getElementById('cmd_edit_penalty').addEventListener('command', handle_edit_penalty, false); - document.getElementById('cmd_archive_penalty').addEventListener('command', handle_archive_penalty, false); - document.getElementById('cmd_retrieve_archived_penalties').addEventListener('command', handle_retrieve_archived_penalties, false); + window.standing_penalties_event_listeners.add(document.getElementById('cmd_apply_penalty'), 'command', handle_apply_penalty, false); + window.standing_penalties_event_listeners.add(document.getElementById('cmd_remove_penalty'), 'command', handle_remove_penalty, false); + window.standing_penalties_event_listeners.add(document.getElementById('cmd_edit_penalty'), 'command', handle_edit_penalty, false); + window.standing_penalties_event_listeners.add(document.getElementById('cmd_archive_penalty'), 'command', handle_archive_penalty, false); + window.standing_penalties_event_listeners.add(document.getElementById('cmd_retrieve_archived_penalties'), 'command', handle_retrieve_archived_penalties, false); populate_list(); default_focus(); @@ -43,6 +44,17 @@ function penalty_init() { } } +function penalty_cleanup() { + try { + window.standing_penalties_event_listeners.removeAll(); + list.cleanup(); + archived_list.cleanup(); + } catch(E) { + var err_prefix = 'standing_penalties.js -> penalty_cleanup() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } +} + function init_list() { try { diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul b/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul index a1b5d90ef2..5571298a1d 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul @@ -18,6 +18,7 @@ diff --git a/Open-ILS/xul/staff_client/server/patron/summary.js b/Open-ILS/xul/staff_client/server/patron/summary.js index 0b65cc4cfc..6b73ff905c 100644 --- a/Open-ILS/xul/staff_client/server/patron/summary.js +++ b/Open-ILS/xul/staff_client/server/patron/summary.js @@ -19,6 +19,7 @@ patron.summary.prototype = { 'init' : function( params ) { var obj = this; + obj.event_listeners = new EventListenerList(); obj.barcode = params['barcode']; obj.id = params['id']; @@ -901,7 +902,7 @@ patron.summary.prototype = { var caption = document.getElementById("PatronSummaryContact_caption"); var arrow = document.getAnonymousNodes(caption)[0]; var gb_content = document.getAnonymousNodes(caption.parentNode)[1]; - arrow.addEventListener( + obj.event_listeners.add(arrow, 'click', function() { setTimeout( @@ -930,6 +931,14 @@ patron.summary.prototype = { } }, + 'cleanup' : function() { + var obj = this; + if (typeof obj.group_list != 'undefined') obj.group_list.cleanup(); + if (typeof obj.stat_cat_list != 'undefined') obj.stat_cat_list.cleanup(); + obj.controller.cleanup(); + obj.event_listeners.removeAll(); + }, + 'retrieve' : function() { try { diff --git a/Open-ILS/xul/staff_client/server/patron/summary.xul b/Open-ILS/xul/staff_client/server/patron/summary.xul index cee959b03a..699002889f 100644 --- a/Open-ILS/xul/staff_client/server/patron/summary.xul +++ b/Open-ILS/xul/staff_client/server/patron/summary.xul @@ -20,7 +20,8 @@ @@ -73,6 +74,17 @@ } } + function my_cleanup() { + try { + observer.unregister(); + g.summary.cleanup(); + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:my_init()', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } + } + function export_address(ev) { var action = ev.originalTarget.id; var a; diff --git a/Open-ILS/xul/staff_client/server/patron/user_buckets.xul b/Open-ILS/xul/staff_client/server/patron/user_buckets.xul index 18eb8b6a59..d534d77ee6 100644 --- a/Open-ILS/xul/staff_client/server/patron/user_buckets.xul +++ b/Open-ILS/xul/staff_client/server/patron/user_buckets.xul @@ -19,6 +19,7 @@ -- 2.43.2