. .
:
- - . (script )?
- subscibeOnce, 'on module (s). , / . , - .
- , . : [] ( ), -, . , .
- :
var TheBase = function(oConfig){
var thisBase = this;
var EVENTS = {
ON_SCRIPTS_LOADED : "onScriptsLoaded"
, ON_SCRIPTS_PROGRESS : "onScriptsProgress"
}
for(var eventName in EVENTS){
thisBase.createEvent(EVENTS[eventName]);
}
var _loader = new YAHOO.util.YUILoader({
base: oConfig.yuiBasePath
,onSuccess:function(o){
thisBase.fireEvent(EVENTS.ON_SCRIPTS_LOADED);
}
,onProgress:function(o){
thisBase.fireEvent(EVENTS.ON_SCRIPTS_PROGRESS,o.name);
}
})
thisBase.loader = _loader;
}
TheBase.prototype = {
subscribeOnce : function(eventName, fnc, context, args){
var that = this;
var handler = function hander(){
fnc.apply(context, arguments);
that.unsubscribe(eventName, handler);
}
this.subscribe(eventName, handler, args, false);
}
}
//
YAHOO.lang.augment(TheBase, YAHOO.util.EventProvider);