Print Friendly

# Class YAHOO.ext.EventManager

Package: | YAHOO.ext
Class: | EventManager
Extends: | Object
Defined In: | EventManager.js

Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides several useful events directly. See YAHOO.ext.EventObject for more details on normalized event objects.
This class is a singleton and cannot be created directly.

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---
| addListener(`Object element`, `String eventName`, `Function fn`, `Object scope`, `boolean override`) : Function | EventManager
Appends an event handler
| on(`Object element`, `String eventName`, `Function fn`, `Object scope`, `boolean override`) : Function | EventManager
Appends an event handler (shorthand for addListener)
| onDocumentReady(`Function fn`, `Object scope`, `boolean override`) : void | EventManager
Fires when the document is ready (before onload and before images are loaded)
| onWindowResize(`Function fn`, `Object scope`, `boolean override`) : void | EventManager
Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and...
| removeListener(`Object element`, `String eventName`, `Function wrappedFn`) : Boolean | EventManager
Removes an event handler
| removeResizeListener(`Function fn`, `Object scope`) : void | EventManager
Removes the passed window resize listener.
| wrap(`Function fn`, `Object scope`, `boolean override`) : Function | EventManager
Places a simple wrapper around an event handler to override the browser event object with a YAHOO.ext.EventObject

## Public Events

This class has no public events.

## Method Details

### addListener

`public function addListener(`Object element`, `String eventName`, `Function fn`, `Object scope`, `boolean override`)`
Appends an event handler
Parameters:

- `element` : Object
  The html element to assign the event to
- `eventName` : String
  The type of event to append
- `fn` : Function
  The method the event invokes
- `scope` : Object
  An object that becomes the scope of the handler
- `override` : boolean
  If true, the obj passed in becomes the execution scope of the listener

Returns:

- `Function`
  The wrapper function created (to be used to remove the listener if necessary)

This method is defined by EventManager.

### on

`public function on(`Object element`, `String eventName`, `Function fn`, `Object scope`, `boolean override`)`
Appends an event handler (shorthand for addListener)
Parameters:

- `element` : Object
  The html element to assign the event to
- `eventName` : String
  The type of event to append
- `fn` : Function
  The method the event invokes
- `scope` : Object
  An arbitrary object that will be passed as a parameter to the handler
- `override` : boolean
  If true, the obj passed in becomes the execution scope of the listener

Returns:

- `Function`
  The wrapper function created (to be used to remove the listener if necessary)

This method is defined by EventManager.

### onDocumentReady

`public function onDocumentReady(`Function fn`, `Object scope`, `boolean override`)`
Fires when the document is ready (before onload and before images are loaded)
Parameters:

- `fn` : Function
  The method the event invokes
- `scope` : Object
  An object that becomes the scope of the handler
- `override` : boolean
  If true, the obj passed in becomes the execution scope of the listener

Returns:

- `void`

This method is defined by EventManager.

### onWindowResize

`public function onWindowResize(`Function fn`, `Object scope`, `boolean override`)`
Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
Parameters:

- `fn` : Function
  The method the event invokes
- `scope` : Object
  An object that becomes the scope of the handler
- `override` : boolean
  If true, the obj passed in becomes the execution scope of the listener

Returns:

- `void`

This method is defined by EventManager.

### removeListener

`public function removeListener(`Object element`, `String eventName`, `Function wrappedFn`)`
Removes an event handler
Parameters:

- `element` : Object
  The html element to remove the event from
- `eventName` : String
  The type of event to append
- `wrappedFn` : Function
  The wrapper method returned when adding the listener

Returns:

- `Boolean`
  True if a listener was actually removed

This method is defined by EventManager.

### removeResizeListener

`public function removeResizeListener(`Function fn`, `Object scope`)`
Removes the passed window resize listener.
Parameters:

- `fn` : Function
  The method the event invokes
- `scope` : Object
  The scope of handler

Returns:

- `void`

This method is defined by EventManager.

### wrap

`public function wrap(`Function fn`, `Object scope`, `boolean override`)`
Places a simple wrapper around an event handler to override the browser event object with a YAHOO.ext.EventObject
Parameters:

- `fn` : Function
  The method the event invokes
- `scope` : Object
  An object that becomes the scope of the handler
- `override` : boolean
  If true, the obj passed in becomes the execution scope of the listener

Returns:

- `Function`
  The wrapped function

This method is defined by EventManager.

Copyright © 2006 Jack Slocum. All rights reserved.