From e227c232fd8067177334be369a584af8497666dc Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 24 Jan 2013 12:02:57 -0500 Subject: [PATCH] LP#1086458: add way to clean up persist_helper event listeners Signed-off-by: Galen Charlton Signed-off-by: Ben Shum --- .../staff_client/chrome/content/OpenILS/global_util.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index 615108fcab..f7abba410d 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -256,6 +256,7 @@ } else { base_key_suffix = ''; } + window.persist_helper_event_listeners = new EventListenerList(); function gen_event_handler(etype,node) { return function(ev) { @@ -408,12 +409,12 @@ } } if (cmd_el) { - cmd_el.addEventListener( + window.persist_helper_event_listeners.add(cmd_el, 'command', gen_event_handler('command',cmd_el), false ); - cmd_el.addEventListener( + window.persist_helper_event_listeners.add(cmd_el, 'oils_persist', gen_oils_persist_handler( base_key, nodes[i] ), false @@ -439,13 +440,13 @@ } } for (var j = 0; j < event_types.length; j++) { - node.addEventListener( + window.persist_helper_event_listeners.add(node, event_types[j], gen_event_handler(event_types[j],node), false ); } - node.addEventListener( + window.persist_helper_event_listeners.add(node, 'oils_persist', gen_oils_persist_handler( base_key, node ), false @@ -457,6 +458,14 @@ } } + function persist_helper_cleanup() { + try { + window.persist_helper_event_listeners.removeAll(); + } catch(E) { + alert('Error in persist_helper_cleanup(): ' + E); + } + } + function getKeys(o) { var keys = []; for (var k in o) keys.push(k); -- 2.11.0