id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	state
2518	Base control: Automatically cancels the registration of listeners and destroys events.	jorix	jorix	"This ticket is an improved management of events and listeners in controls. With these modifications in controls no needs to add properties to store instances of events for call “un” methods at controls destruction.

New features:
 * The new addListener method keeps the pairs of events and their eventListeners in a array. And calls the “on” events method for the listeners.
 * Allows setting the listener only active if the control is active. Using option “whenActive” to true. 
 * New “removeListeners” method calls “un” method of events and destroys it if autoDestroy option is set to true. This occurs only when events have no listeners. 
 * The method “removeListeners” is called in destroys controls.

It has opened two tickets to implement the methods activate and deactivate in Attribution and MousePosition controls using the new method benefits addListeners. See it in #2519 and #2520.

Attachments:
 * Patch of control.js with these new features.
 * Examples of using the new methods in:
   * Simple in: LayerSwitcher control.
   * More complex use in: PanZoomBar control.
 
The tests were passed successfully for all controls in: IE8, FF36 and CH4. (except for PanZoom.html test in FF36 that fails both with and without the patch, see #2510)

SVN Revision Number: 10094 
"	feature	closed	minor	2.10 Release	Control	SVN	duplicate			
