Print Friendly

# Class YAHOO.util.Config

Package: | YAHOO.util
Class: | Config
Extends: | Object
Defined In: | container_core.js

Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.

## Public Properties

Property | Defined By
--- | ---
| owner : Object | Config
Object reference to the owner of this Config Object
| queueInProgress : Boolean | Config
Boolean flag that specifies whether a queue is currently being executed

## Public Methods

Method | Defined By
--- | ---
| Config(`Object owner`) | Config
| addProperty(`String key`, `Object propertyObject`) : void | Config
Adds a property to the Config Object's private config hash.
| alreadySubscribed<static>(`YAHOO.util.CustomEvent evt`, `Function fn`, `Object obj`) : Boolean | Config
<static> Checks to determine if a particular function/Object pair are already subscribed to the specified Custo...
| applyConfig(`Object userConfig`, `Boolean init`) : void | Config
Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property eve...
| checkBoolean(`Object val`) : Boolean | Config
Validates that the value passed in is a Boolean.
| checkNumber(`Object val`) : Boolean | Config
Validates that the value passed in is a number.
| fireQueue() : void | Config
Fires the normalized list of queued property change events
| getConfig() : Object | Config
Returns a key-value configuration map of the values currently set in the Config Object.
| getProperty(`String key`) : Object | Config
Returns the value of specified property.
| init(`Object owner`) : void | Config
Initializes the configuration Object and all of its local members.
| outputEventQueue() : String | Config
Returns a string representation of the Config object's current CustomEvent queue
| queueProperty(`String key`, `String value`) : Boolean | Config
Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is mov...
| refireEvent(`String key`) : void | Config
Fires the event for a property using the property's current value.
| refresh() : void | Config
Refires the events for all configuration properties using their current values.
| resetProperty(`String key`) : Boolean | Config
Resets the specified property's value to its initial value.
| setProperty(`String key`, `String value`, `Boolean silent`) : Boolean | Config
Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
| subscribeToConfigEvent(`String key`, `Function handler`, `Object obj`, `Boolean override`) : Boolean | Config
Subscribes an external handler to the change event for any given property.
| toString() : String | Config
Returns a string representation of the Config object
| unsubscribeFromConfigEvent(`String key`, `Function handler`, `Object obj`) : Boolean | Config
Unsubscribes an external handler from the change event for any given property.

## Public Events

Event | Defined By
--- | ---
| configChangedEvent : () | Config
Object reference to the owner of this Config Object

## Property Details

### owner

`public Object owner`
Object reference to the owner of this Config Object
This property is defined by Config.

### queueInProgress

`public Boolean queueInProgress`
Boolean flag that specifies whether a queue is currently being executed
This property is defined by Config.

## Constructor Details

### Config

`public function Config(`Object owner`)`
Parameters:

- `owner` : Object
  The owner Object to which this Config Object belongs

## Method Details

### addProperty

`public function addProperty(`String key`, `Object propertyObject`)`
Adds a property to the Config Object's private config hash.
Parameters:

- `key` : String
  The configuration property's name
- `propertyObject` : Object
  The Object containing all of this property's arguments

Returns:

- `void`

This method is defined by Config.

### alreadySubscribed<static>

`public function alreadySubscribed<static>(`YAHOO.util.CustomEvent evt`, `Function fn`, `Object obj`)`
<static> Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent
Parameters:

- `evt` : YAHOO.util.CustomEvent
  The CustomEvent for which to check the subscriptions
- `fn` : Function
  The function to look for in the subscribers list
- `obj` : Object
  The execution scope Object for the subscription

Returns:

- `Boolean`
  true, if the function/Object pair is already subscribed to the CustomEvent passed in

This method is defined by Config.

### applyConfig

`public function applyConfig(`Object userConfig`, `Boolean init`)`
Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. Although the values will be set, fireQueue() must be called for their associated events to execute.
Parameters:

- `userConfig` : Object
  The configuration Object literal
- `init` : Boolean
  When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.

Returns:

- `void`

This method is defined by Config.

### checkBoolean

`public function checkBoolean(`Object val`)`
Validates that the value passed in is a Boolean.
Parameters:

- `val` : Object
  The value to validate

Returns:

- `Boolean`
  true, if the value is valid

This method is defined by Config.

### checkNumber

`public function checkNumber(`Object val`)`
Validates that the value passed in is a number.
Parameters:

- `val` : Object
  The value to validate

Returns:

- `Boolean`
  true, if the value is valid

This method is defined by Config.

### fireQueue

`public function fireQueue()`
Fires the normalized list of queued property change events
Parameters:

- None.

Returns:

- `void`

This method is defined by Config.

### getConfig

`public function getConfig()`
Returns a key-value configuration map of the values currently set in the Config Object.
Parameters:

- None.

Returns:

- `Object`
  The current config, represented in a key-value map

This method is defined by Config.

### getProperty

`public function getProperty(`String key`)`
Returns the value of specified property.
Parameters:

- `key` : String
  The name of the property

Returns:

- `Object`
  The value of the specified property

This method is defined by Config.

### init

`public function init(`Object owner`)`
Initializes the configuration Object and all of its local members.
Parameters:

- `owner` : Object
  The owner Object to which this Config Object belongs

Returns:

- `void`

This method is defined by Config.

### outputEventQueue

`public function outputEventQueue()`
Returns a string representation of the Config object's current CustomEvent queue
Parameters:

- None.

Returns:

- `String`
  The string list of CustomEvents currently queued for execution

This method is defined by Config.

### queueProperty

`public function queueProperty(`String key`, `String value`)`
Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is moved from its current position to the end of the queue.
Parameters:

- `key` : String
  The name of the property
- `value` : String
  The value to set the property to

Returns:

- `Boolean`
  true, if the set was successful, false if it failed.

This method is defined by Config.

### refireEvent

`public function refireEvent(`String key`)`
Fires the event for a property using the property's current value.
Parameters:

- `key` : String
  The name of the property

Returns:

- `void`

This method is defined by Config.

### refresh

`public function refresh()`
Refires the events for all configuration properties using their current values.
Parameters:

- None.

Returns:

- `void`

This method is defined by Config.

### resetProperty

`public function resetProperty(`String key`)`
Resets the specified property's value to its initial value.
Parameters:

- `key` : String
  The name of the property

Returns:

- `Boolean`
  True is the property was reset, false if not

This method is defined by Config.

### setProperty

`public function setProperty(`String key`, `String value`, `Boolean silent`)`
Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
Parameters:

- `key` : String
  The name of the property
- `value` : String
  The value to set the property to
- `silent` : Boolean
  Whether the value should be set silently, without firing the property event.

Returns:

- `Boolean`
  True, if the set was successful, false if it failed.

This method is defined by Config.

### subscribeToConfigEvent

`public function subscribeToConfigEvent(`String key`, `Function handler`, `Object obj`, `Boolean override`)`
Subscribes an external handler to the change event for any given property.
Parameters:

- `key` : String
  The property name
- `handler` : Function
  The handler function to use subscribe to the property's event
- `obj` : Object
  The Object to use for scoping the event handler (see CustomEvent documentation)
- `override` : Boolean
  Optional. If true, will override "this" within the handler to map to the scope Object passed into the method.

Returns:

- `Boolean`
  True, if the subscription was successful, otherwise false.

This method is defined by Config.

### toString

`public function toString()`
Returns a string representation of the Config object
Parameters:

- None.

Returns:

- `String`
  The Config object in string format.

This method is defined by Config.

### unsubscribeFromConfigEvent

`public function unsubscribeFromConfigEvent(`String key`, `Function handler`, `Object obj`)`
Unsubscribes an external handler from the change event for any given property.
Parameters:

- `key` : String
  The property name
- `handler` : Function
  The handler function to use subscribe to the property's event
- `obj` : Object
  The Object to use for scoping the event handler (see CustomEvent documentation)

Returns:

- `Boolean`
  True, if the unsubscription was successful, otherwise false.

This method is defined by Config.

## Event Details

### configChangedEvent

`public event configChangedEvent`
Object reference to the owner of this Config Object
Subscribers will be called with the following parameters:

- None.

This event is defined by Config.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.