function DexComponent(userConfig, defaultConfig) { // This holds our event registry. this.registry = {}; this.debug = false; //console.log("Instantiating dex component..."); // Instantiate from another component if (userConfig instanceof DexComponent) { this.config = getConfig(userConfig.config, defaultConfig); } else { this.config = getConfig(userConfig, defaultConfig); //console.dir(this.config); } } DexComponent.prototype.attr = function(name, value) { if (arguments.length == 1) { return this.config[name]; } else if (arguments.length == 2) { this.config[name] = value; } return this; }; DexComponent.prototype.dump = function(message) { console.log("========================"); if (arguments.length == 1) { console.log(message); console.log("========================"); } console.log("=== CONFIG ==="); console.dir(this.config); console.log("=== REGISTRY ==="); console.dir(this.registry); }; DexComponent.prototype.addListener = function(eventType, target, method) { var targets; if (this.debug) { console.log("REGISTERING TARGET: " + eventType + "="+ target); } if (!this.registry.hasOwnProperty(eventType)) { this.registry[eventType] = []; } this.registry[eventType].push({ target : target, method : method }); //console.log("this.registry"); //console.dir(eventthis.registry); }; DexComponent.prototype.notify = function(event) { var targets; if (this.debug) { console.log("notify: " + event.type); } if (!this.registry.hasOwnProperty(event.type)) { return; } event.source = this; targets = this.registry[event.type]; //console.log("TARGETS: " + targets.length); //console.dir(targets); for (var i=0; i