Class BehaviorManager
Defined in: BehaviorManager.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Stores, applies, and removes a named set of behaviors.
|
Method Attributes | Method Name and Description |
---|---|
Apply each of the behaviors named as arguments to this function.
|
|
Apply the behaviors that have
apply_on_init true. |
|
Remove all behaviors that are currently applied.
|
|
Remove each of the behaviors named as arguments to this function.
|
|
swapBehaviors(off, on)
Given two behavior names, remove the first one and apply the second
one.
|
Class Detail
BehaviorManager()
Stores, applies, and removes a named set of behaviors. A behavior
is a set of event handlers that need to be connected and then
disconnected repeatedly as a group.
- Parameters:
- {Object} args.behaviors
- object containing the behaviors to be managed, as:
{ behavior_name: { apply_on_init: true if this behavior should be applied when the manager is initialized, apply: function( manager_object, handles_array ) { // required function that returns an array of dojo event handles. for example: return [ dojo.connect(document.body, "mouseup", this, 'rubberExecute' ), dojo.connect(document.body, "mousemove", this, 'rubberMove' ) ]; }, remove: function( manager_object, handles_array ) { // optional function that removes the behavior. by // default dojo.disconnect() is just called on each // of the event handles that were returned by the // apply function } }, ... }
- {Object} args.context Optional, Default: BehaviorManager itself
- context
(i.e.
this
) in which each of the behaviorapply()
andremove()
functions will be called.
Method Detail
applyBehaviors()
Apply each of the behaviors named as arguments to this function.
- Parameters:
- {String} ... Optional
- Zero or more string behavior names to apply.
initialize()
Apply the behaviors that have
apply_on_init
true.
removeAll()
Remove all behaviors that are currently applied.
removeBehaviors()
Remove each of the behaviors named as arguments to this function.
- Parameters:
- {String} ... Optional
- Zero or more string behavior names to remove.
swapBehaviors(off, on)
Given two behavior names, remove the first one and apply the second
one. For convenience.
- Parameters:
- off
- on