LP#1086458: add class to manage event listeners

EventListenerList allows one to maintain a list
of event listeners, then remove them all when it's
time to clean up a window.

Usage is:

var list = new EventListenerList();
// attach an event listener
list.add(node, 'command', function(ev) { alert('BOO!'); }, false);
...
// get rid of them
list.removeAll();

Based on an idea by Jason Etheridge.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: add way to clean up persist_helper event listeners

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: add more event listener tracking

util.list and util.controller now have cleanup()
methods that can be invoked to unregister the event
listeners they create.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
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 <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: add missing cleanup call

Thanks to Jason Etheridge for the catch.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: clear util.list lists and trees during cleanup

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: remove references to windows during cleanup

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
move EventListenerList out of global_util.js

So that we can more easily pull it into main.xul (which we also do here)

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: clean up event listener functions

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: add destructor to messagecatalog

Based on patch by Jason Etheridge.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: add destructor to caption binding

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: fix typo

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1086458: move up event listeners in place_hold.js

The preceding two functions need the event listeners to be defined before
use. Move up to prevent errors.

Signed-off-by: Ben Shum <bshum@biblio.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>