/ Published in: JavaScript
                    
                                        
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.
Dependencies:
* yahoo.js
* event.js
                Dependencies:
* yahoo.js
* event.js
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// JScript source code
var Object = function(){
var cfg = new YAHOO.util.Config(this);
element;
initDefaultConfig: function() {
this.cfg.addProperty(
"color",
{
value: "#000000",
handler: setColor
}
);
this.cfg.addProperty(
"width",
{
value: null,
handler: setWidth
}
);
this.cfg.fireQueue();
}
var setColor = function(type, args, obj){
var color = args[0];
YAHOO.util.Dom.setStyle(element, "color", color);
}
var setWidth = function(type, args, obj){
var width = args[0] + "px";
YAHOO.util.Dom.setStyle(element, "width", width);
}
this.init = function(elementId){
element = YAHOO.util.Dom.get(elementId);
initDefaultConfig();
}
};
Comments
 Subscribe to comments
                    Subscribe to comments
                
                