Index: openacs-4/packages/ajaxhelper/www/resources/yui/event/event-debug.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/yui/event/event-debug.js,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ajaxhelper/www/resources/yui/event/event-debug.js 25 Dec 2006 16:40:02 -0000 1.2
+++ openacs-4/packages/ajaxhelper/www/resources/yui/event/event-debug.js 8 Sep 2007 14:22:05 -0000 1.3
@@ -1,1795 +1,2350 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-
-/**
- * The CustomEvent class lets you define events for your application
- * that can be subscribed to by one or more independent component.
- *
- * @param {String} type The type of event, which is passed to the callback
- * when the event fires
- * @param {Object} oScope The context the event will fire from. "this" will
- * refer to this object in the callback. Default value:
- * the window object. The listener can override this.
- * @param {boolean} silent pass true to prevent the event from writing to
- * the debugsystem
- * @param {int} signature the signature that the custom event subscriber
- * will receive. YAHOO.util.CustomEvent.LIST or
- * YAHOO.util.CustomEvent.FLAT. The default is
- * YAHOO.util.CustomEvent.LIST.
- * @namespace YAHOO.util
- * @class CustomEvent
- * @constructor
- */
-YAHOO.util.CustomEvent = function(type, oScope, silent, signature) {
-
- /**
- * The type of event, returned to subscribers when the event fires
- * @property type
- * @type string
- */
- this.type = type;
-
- /**
- * The scope the the event will fire from by default. Defaults to the window
- * obj
- * @property scope
- * @type object
- */
- this.scope = oScope || window;
-
- /**
- * By default all custom events are logged in the debug build, set silent
- * to true to disable debug outpu for this event.
- * @property silent
- * @type boolean
- */
- this.silent = silent;
-
- /**
- * Custom events support two styles of arguments provided to the event
- * subscribers.
- *
- *
YAHOO.util.CustomEvent.LIST:
- *
- *
param1: event name
- *
param2: array of arguments sent to fire
- *
param3: a custom object supplied by the subscriber
- *
- *
- *
YAHOO.util.CustomEvent.FLAT
- *
- *
param1: the first argument passed to fire. If you need to
- * pass multiple parameters, use and array or object literal
- *
param2: a custom object supplied by the subscriber
- *
- *
- *
- * @property signature
- * @type int
- */
- this.signature = signature || YAHOO.util.CustomEvent.LIST;
-
- /**
- * The subscribers to this event
- * @property subscribers
- * @type Subscriber[]
- */
- this.subscribers = [];
-
- if (!this.silent) {
- YAHOO.log( "Creating " + this, "info", "Event" );
- }
-
- var onsubscribeType = "_YUICEOnSubscribe";
-
- // Only add subscribe events for events that are not generated by
- // CustomEvent
- if (type !== onsubscribeType) {
-
- /**
- * Custom events provide a custom event that fires whenever there is
- * a new subscriber to the event. This provides an opportunity to
- * handle the case where there is a non-repeating event that has
- * already fired has a new subscriber.
- *
- * @event subscribeEvent
- * @type YAHOO.util.CustomEvent
- * @param {Function} fn The function to execute
- * @param {Object} obj An object to be passed along when the event
- * fires
- * @param {boolean|Object} override If true, the obj passed in becomes
- * the execution scope of the listener.
- * if an object, that object becomes the
- * the execution scope.
- */
- this.subscribeEvent =
- new YAHOO.util.CustomEvent(onsubscribeType, this, true);
-
- }
-};
-
-/**
- * Subscriber listener sigature constant. The LIST type returns three
- * parameters: the event type, the array of args passed to fire, and
- * the optional custom object
- * @property YAHOO.util.CustomEvent.LIST
- * @static
- * @type int
- */
-YAHOO.util.CustomEvent.LIST = 0;
-
-/**
- * Subscriber listener sigature constant. The FLAT type returns two
- * parameters: the first argument passed to fire and the optional
- * custom object
- * @property YAHOO.util.CustomEvent.FLAT
- * @static
- * @type int
- */
-YAHOO.util.CustomEvent.FLAT = 1;
-
-YAHOO.util.CustomEvent.prototype = {
-
- /**
- * Subscribes the caller to this event
- * @method subscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj An object to be passed along when the event
- * fires
- * @param {boolean|Object} override If true, the obj passed in becomes
- * the execution scope of the listener.
- * if an object, that object becomes the
- * the execution scope.
- */
- subscribe: function(fn, obj, override) {
- if (this.subscribeEvent) {
- this.subscribeEvent.fire(fn, obj, override);
- }
-
- this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
- },
-
- /**
- * Unsubscribes the caller from this event
- * @method unsubscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj The custom object passed to subscribe (optional)
- * @return {boolean} True if the subscriber was found and detached.
- */
- unsubscribe: function(fn, obj) {
- var found = false;
- for (var i=0, len=this.subscribers.length; i
- *
The type of event
- *
All of the arguments fire() was executed with as an array
- *
The custom object (if any) that was passed into the subscribe()
- * method
- *
- * @method fire
- * @param {Object*} arguments an arbitrary set of parameters to pass to
- * the handler.
- * @return {boolean} false if one of the subscribers returned false,
- * true otherwise
- */
- fire: function() {
- var len=this.subscribers.length;
- if (!len && this.silent) {
- return true;
- }
-
- var args=[], ret=true, i;
-
- for (i=0; i" + (i+1) + ": " + s,
- "info", "Event" );
- }
-
- var scope = s.getScope(this.scope);
-
- if (this.signature == YAHOO.util.CustomEvent.FLAT) {
- var param = null;
- if (args.length > 0) {
- param = args[0];
- }
- ret = s.fn.call(scope, param, s.obj);
- } else {
- ret = s.fn.call(scope, this.type, args, s.obj);
- }
- if (false === ret) {
- if (!this.silent) {
- YAHOO.log("Event cancelled, subscriber " + i +
- " of " + len);
- }
-
- //break;
- return false;
- }
- }
- }
-
- return true;
- },
-
- /**
- * Removes all listeners
- * @method unsubscribeAll
- */
- unsubscribeAll: function() {
- for (var i=0, len=this.subscribers.length; i= 0) {
- cacheItem = listeners[index];
- }
-
- if (!el || !cacheItem) {
- // this.logger.debug("cached listener not found");
- return false;
- }
-
- // this.logger.debug("Removing handler: " + el + ", " + sType);
-
- if (this.useLegacyEvent(el, sType)) {
- var legacyIndex = this.getLegacyIndex(el, sType);
- var llist = legacyHandlers[legacyIndex];
- if (llist) {
- for (i=0, len=llist.length; i 0);
- }
-
- // onAvailable
- var notAvail = [];
- for (var i=0,len=onAvailStack.length; i 0) {
- for (var i=0,len=listeners.length; i 0) {
- j = listeners.length;
- while (j) {
- index = j-1;
- l = listeners[index];
- if (l) {
- EU.removeListener(l[EU.EL], l[EU.TYPE],
- l[EU.FN], index);
- }
- j = j - 1;
- }
- l=null;
-
- EU.clearCache();
- }
-
- for (i=0,len=legacyEvents.length; i
- *
- * scope: defines the default execution scope. If not defined
- * the default scope will be this instance.
- *
- *
- * silent: if true, the custom event will not generate log messages.
- * This is false by default.
- *
- *
- * onSubscribeCallback: specifies a callback to execute when the
- * event has a new subscriber. This will fire immediately for
- * each queued subscriber if any exist prior to the creation of
- * the event.
- *
- *
- *
- * @return {CustomEvent} the custom event
- *
- */
- createEvent: function(p_type, p_config) {
-
- this.__yui_events = this.__yui_events || {};
- var opts = p_config || {};
- var events = this.__yui_events;
-
- if (events[p_type]) {
- YAHOO.log("EventProvider: error, event already exists");
- } else {
-
- var scope = opts.scope || this;
- var silent = opts.silent || null;
-
- var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
- YAHOO.util.CustomEvent.FLAT);
- events[p_type] = ce;
-
- if (opts.onSubscribeCallback) {
- ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
- }
-
- this.__yui_subscribers = this.__yui_subscribers || {};
- var qs = this.__yui_subscribers[p_type];
-
- if (qs) {
- for (var i=0; i
- *
The first argument fire() was executed with
- *
The custom object (if any) that was passed into the subscribe()
- * method
- *
- * @method fireEvent
- * @param p_type {string} the type, or name of the event
- * @param arguments {Object*} an arbitrary set of parameters to pass to
- * the handler.
- * @return {boolean} the return value from CustomEvent.fire, or null if
- * the custom event does not exist.
- */
- fireEvent: function(p_type, arg1, arg2, etc) {
-
- this.__yui_events = this.__yui_events || {};
- var ce = this.__yui_events[p_type];
-
- if (ce) {
- var args = [];
- for (var i=1; i
+ *
YAHOO.util.CustomEvent.LIST:
+ *
+ *
param1: event name
+ *
param2: array of arguments sent to fire
+ *
param3: a custom object supplied by the subscriber
+ *
+ *
+ *
YAHOO.util.CustomEvent.FLAT
+ *
+ *
param1: the first argument passed to fire. If you need to
+ * pass multiple parameters, use and array or object literal
+ *
param2: a custom object supplied by the subscriber
+ *
+ *
+ *
+ * @property signature
+ * @type int
+ */
+ this.signature = signature || YAHOO.util.CustomEvent.LIST;
+
+ /**
+ * The subscribers to this event
+ * @property subscribers
+ * @type Subscriber[]
+ */
+ this.subscribers = [];
+
+ if (!this.silent) {
+ YAHOO.log( "Creating " + this, "info", "Event" );
+ }
+
+ var onsubscribeType = "_YUICEOnSubscribe";
+
+ // Only add subscribe events for events that are not generated by
+ // CustomEvent
+ if (type !== onsubscribeType) {
+
+ /**
+ * Custom events provide a custom event that fires whenever there is
+ * a new subscriber to the event. This provides an opportunity to
+ * handle the case where there is a non-repeating event that has
+ * already fired has a new subscriber.
+ *
+ * @event subscribeEvent
+ * @type YAHOO.util.CustomEvent
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
+ * fires
+ * @param {boolean|Object} override If true, the obj passed in becomes
+ * the execution scope of the listener.
+ * if an object, that object becomes the
+ * the execution scope.
+ */
+ this.subscribeEvent =
+ new YAHOO.util.CustomEvent(onsubscribeType, this, true);
+
+ }
+};
+
+/**
+ * Subscriber listener sigature constant. The LIST type returns three
+ * parameters: the event type, the array of args passed to fire, and
+ * the optional custom object
+ * @property YAHOO.util.CustomEvent.LIST
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.LIST = 0;
+
+/**
+ * Subscriber listener sigature constant. The FLAT type returns two
+ * parameters: the first argument passed to fire and the optional
+ * custom object
+ * @property YAHOO.util.CustomEvent.FLAT
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.FLAT = 1;
+
+YAHOO.util.CustomEvent.prototype = {
+
+ /**
+ * Subscribes the caller to this event
+ * @method subscribe
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
+ * fires
+ * @param {boolean|Object} override If true, the obj passed in becomes
+ * the execution scope of the listener.
+ * if an object, that object becomes the
+ * the execution scope.
+ */
+ subscribe: function(fn, obj, override) {
+
+ if (!fn) {
+throw new Error("Invalid callback for subscriber to '" + this.type + "'");
+ }
+
+ if (this.subscribeEvent) {
+ this.subscribeEvent.fire(fn, obj, override);
+ }
+
+ this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
+ },
+
+ /**
+ * Unsubscribes subscribers.
+ * @method unsubscribe
+ * @param {Function} fn The subscribed function to remove, if not supplied
+ * all will be removed
+ * @param {Object} obj The custom object passed to subscribe. This is
+ * optional, but if supplied will be used to
+ * disambiguate multiple listeners that are the same
+ * (e.g., you subscribe many object using a function
+ * that lives on the prototype)
+ * @return {boolean} True if the subscriber was found and detached.
+ */
+ unsubscribe: function(fn, obj) {
+
+ if (!fn) {
+ return this.unsubscribeAll();
+ }
+
+ var found = false;
+ for (var i=0, len=this.subscribers.length; i
+ *
The type of event
+ *
All of the arguments fire() was executed with as an array
+ *
The custom object (if any) that was passed into the subscribe()
+ * method
+ *
+ * @method fire
+ * @param {Object*} arguments an arbitrary set of parameters to pass to
+ * the handler.
+ * @return {boolean} false if one of the subscribers returned false,
+ * true otherwise
+ */
+ fire: function() {
+ var len=this.subscribers.length;
+ if (!len && this.silent) {
+ return true;
+ }
+
+ var args=[], ret=true, i, rebuild=false;
+
+ for (i=0; i" + (i+1) + ": " + s,
+ "info", "Event" );
+ }
+
+ var scope = s.getScope(this.scope);
+
+ if (this.signature == YAHOO.util.CustomEvent.FLAT) {
+ var param = null;
+ if (args.length > 0) {
+ param = args[0];
+ }
+ ret = s.fn.call(scope, param, s.obj);
+ } else {
+ ret = s.fn.call(scope, this.type, args, s.obj);
+ }
+ if (false === ret) {
+ if (!this.silent) {
+ YAHOO.log("Event cancelled, subscriber " + i +
+ " of " + len, "info", "Event");
+ }
+
+ //break;
+ return false;
+ }
+ }
+ }
+
+ if (rebuild) {
+ var newlist=[],subs=this.subscribers;
+ for (i=0,len=subs.length; iThe callback is executed with a single parameter:
+ * the custom object parameter, if provided.
+ *
+ * @method onAvailable
+ *
+ * @param {string} p_id the id of the element to look for.
+ * @param {function} p_fn what to execute when the element is found.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean|object} p_override If set to true, p_fn will execute
+ * in the scope of p_obj, if set to an object it
+ * will execute in the scope of that object
+ *
+ * @static
+ */
+ onAvailable: function(p_id, p_fn, p_obj, p_override) {
+ onAvailStack.push( { id: p_id,
+ fn: p_fn,
+ obj: p_obj,
+ override: p_override,
+ checkReady: false } );
+ retryCount = this.POLL_RETRYS;
+ this.startInterval();
+ },
+
+ /**
+ * Executes the supplied callback when the DOM is first usable. This
+ * will execute immediately if called after the DOMReady event has
+ * fired. @todo the DOMContentReady event does not fire when the
+ * script is dynamically injected into the page. This means the
+ * DOMReady custom event will never fire in FireFox or Opera when the
+ * library is injected. It _will_ fire in Safari, and the IE
+ * implementation would allow for us to fire it if the defered script
+ * is not available. We want this to behave the same in all browsers.
+ * Is there a way to identify when the script has been injected
+ * instead of included inline? Is there a way to know whether the
+ * window onload event has fired without having had a listener attached
+ * to it when it did so?
+ *
+ *
The callback is a CustomEvent, so the signature is:
+ *
type , args , customobject
+ *
For DOMReady events, there are no fire argments, so the
+ * signature is:
+ *
"DOMReady", [], obj
+ *
+ *
+ * @method onDOMReady
+ *
+ * @param {function} p_fn what to execute when the element is found.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean|object} p_scope If set to true, p_fn will execute
+ * in the scope of p_obj, if set to an object it
+ * will execute in the scope of that object
+ *
+ * @static
+ */
+ onDOMReady: function(p_fn, p_obj, p_override) {
+ if (DOMReady) {
+ setTimeout(function() {
+ var s = window;
+ if (p_override) {
+ if (p_override === true) {
+ s = p_obj;
+ } else {
+ s = p_override;
+ }
+ }
+ p_fn.call(s, "DOMReady", [], p_obj);
+ }, 0);
+ } else {
+ this.DOMReadyEvent.subscribe(p_fn, p_obj, p_override);
+ }
+ },
+
+ /**
+ * Works the same way as onAvailable, but additionally checks the
+ * state of sibling elements to determine if the content of the
+ * available element is safe to modify.
+ *
+ *
The callback is executed with a single parameter:
+ * the custom object parameter, if provided.
+ *
+ * @method onContentReady
+ *
+ * @param {string} p_id the id of the element to look for.
+ * @param {function} p_fn what to execute when the element is ready.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean|object} p_override If set to true, p_fn will execute
+ * in the scope of p_obj. If an object, p_fn will
+ * exectute in the scope of that object
+ *
+ * @static
+ */
+ onContentReady: function(p_id, p_fn, p_obj, p_override) {
+ onAvailStack.push( { id: p_id,
+ fn: p_fn,
+ obj: p_obj,
+ override: p_override,
+ checkReady: true } );
+
+ retryCount = this.POLL_RETRYS;
+ this.startInterval();
+ },
+
+ /**
+ * Appends an event handler
+ *
+ * @method addListener
+ *
+ * @param {String|HTMLElement|Array|NodeList} el An id, an element
+ * reference, or a collection of ids and/or elements to assign the
+ * listener to.
+ * @param {String} sType The type of event to append
+ * @param {Function} fn The method the event invokes
+ * @param {Object} obj An arbitrary object that will be
+ * passed as a parameter to the handler
+ * @param {Boolean|object} override If true, the obj passed in becomes
+ * the execution scope of the listener. If an
+ * object, this object becomes the execution
+ * scope.
+ * @return {Boolean} True if the action was successful or defered,
+ * false if one or more of the elements
+ * could not have the listener attached,
+ * or if the operation throws an exception.
+ * @static
+ */
+ addListener: function(el, sType, fn, obj, override) {
+
+ if (!fn || !fn.call) {
+// throw new TypeError(sType + " addListener call failed, callback undefined");
+YAHOO.log(sType + " addListener call failed, invalid callback", "error", "Event");
+ return false;
+ }
+
+ // The el argument can be an array of elements or element ids.
+ if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i= 0) {
+ cacheItem = listeners[index];
+ }
+
+ if (!el || !cacheItem) {
+ // this.logger.debug("cached listener not found");
+ return false;
+ }
+
+ // this.logger.debug("Removing handler: " + el + ", " + sType);
+
+ if (this.useLegacyEvent(el, sType)) {
+ var legacyIndex = this.getLegacyIndex(el, sType);
+ var llist = legacyHandlers[legacyIndex];
+ if (llist) {
+ for (i=0, len=llist.length; i 0);
+ }
+
+ // onAvailable
+ var notAvail = [];
+
+ var executeItem = function (el, item) {
+ var scope = el;
+ if (item.override) {
+ if (item.override === true) {
+ scope = item.obj;
+ } else {
+ scope = item.override;
+ }
+ }
+ item.fn.call(scope, item.obj);
+ };
+
+ var i,len,item,el;
+
+ // onAvailable
+ for (i=0,len=onAvailStack.length; i 0) {
+ for (var i=0,len=searchList.length; i 0) {
+ j = listeners.length;
+ while (j) {
+ index = j-1;
+ l = listeners[index];
+ if (l) {
+ EU.removeListener(l[EU.EL], l[EU.TYPE], l[EU.FN], index);
+ }
+ j = j - 1;
+ }
+ l=null;
+
+ EU.clearCache();
+ }
+
+ for (i=0,len=legacyEvents.length; i<'+'/script>');
+ el=document.getElementById("_yui_eu_dr");
+ }
+
+
+ if (el) {
+ el.onreadystatechange = function() {
+ //YAHOO.log(";comp-" + this.readyState + ";");
+ if ("complete" === this.readyState) {
+ this.parentNode.removeChild(this);
+ YAHOO.util.Event._ready();
+ }
+ };
+ } else {
+ // The library was likely injected into the page
+ // rendering onDOMReady unreliable
+ // YAHOO.util.Event._ready();
+ }
+
+ el=null;
+
+
+ // Safari: The document's readyState in Safari currently will
+ // change to loaded/complete before images are loaded.
+ //} else if (EU.webkit) {
+ } else if (EU.webkit) {
+
+ EU._drwatch = setInterval(function(){
+ var rs=document.readyState;
+ if ("loaded" == rs || "complete" == rs) {
+ clearInterval(EU._drwatch);
+ EU._drwatch = null;
+ EU._ready();
+ }
+ }, EU.POLL_INTERVAL);
+
+ // FireFox and Opera: These browsers provide a event for this
+ // moment.
+ } else {
+
+ // @todo will this fire when the library is injected?
+
+ EU._simpleAdd(document, "DOMContentLoaded", EU._ready);
+
+ }
+ /////////////////////////////////////////////////////////////
+
+
+ EU._simpleAdd(window, "load", EU._load);
+ EU._simpleAdd(window, "unload", EU._unload);
+ EU._tryPreloadAttach();
+ })();
+
+}
+/**
+ * EventProvider is designed to be used with YAHOO.augment to wrap
+ * CustomEvents in an interface that allows events to be subscribed to
+ * and fired by name. This makes it possible for implementing code to
+ * subscribe to an event that either has not been created yet, or will
+ * not be created at all.
+ *
+ * @Class EventProvider
+ */
+YAHOO.util.EventProvider = function() { };
+
+YAHOO.util.EventProvider.prototype = {
+
+ /**
+ * Private storage of custom events
+ * @property __yui_events
+ * @type Object[]
+ * @private
+ */
+ __yui_events: null,
+
+ /**
+ * Private storage of custom event subscribers
+ * @property __yui_subscribers
+ * @type Object[]
+ * @private
+ */
+ __yui_subscribers: null,
+
+ /**
+ * Subscribe to a CustomEvent by event type
+ *
+ * @method subscribe
+ * @param p_type {string} the type, or name of the event
+ * @param p_fn {function} the function to exectute when the event fires
+ * @param p_obj {Object} An object to be passed along when the event
+ * fires
+ * @param p_override {boolean} If true, the obj passed in becomes the
+ * execution scope of the listener
+ */
+ subscribe: function(p_type, p_fn, p_obj, p_override) {
+
+ this.__yui_events = this.__yui_events || {};
+ var ce = this.__yui_events[p_type];
+
+ if (ce) {
+ ce.subscribe(p_fn, p_obj, p_override);
+ } else {
+ this.__yui_subscribers = this.__yui_subscribers || {};
+ var subs = this.__yui_subscribers;
+ if (!subs[p_type]) {
+ subs[p_type] = [];
+ }
+ subs[p_type].push(
+ { fn: p_fn, obj: p_obj, override: p_override } );
+ }
+ },
+
+ /**
+ * Unsubscribes one or more listeners the from the specified event
+ * @method unsubscribe
+ * @param p_type {string} The type, or name of the event. If the type
+ * is not specified, it will attempt to remove
+ * the listener from all hosted events.
+ * @param p_fn {Function} The subscribed function to unsubscribe, if not
+ * supplied, all subscribers will be removed.
+ * @param p_obj {Object} The custom object passed to subscribe. This is
+ * optional, but if supplied will be used to
+ * disambiguate multiple listeners that are the same
+ * (e.g., you subscribe many object using a function
+ * that lives on the prototype)
+ * @return {boolean} true if the subscriber was found and detached.
+ */
+ unsubscribe: function(p_type, p_fn, p_obj) {
+ this.__yui_events = this.__yui_events || {};
+ var evts = this.__yui_events;
+ if (p_type) {
+ var ce = evts[p_type];
+ if (ce) {
+ return ce.unsubscribe(p_fn, p_obj);
+ }
+ } else {
+ for (var i in evts) {
+ var ret = true;
+ if (YAHOO.lang.hasOwnProperty(evts, i)) {
+ ret = ret && evts[i].unsubscribe(p_fn, p_obj);
+ }
+ }
+ return ret;
+ }
+
+ return false;
+ },
+
+ /**
+ * Removes all listeners from the specified event. If the event type
+ * is not specified, all listeners from all hosted custom events will
+ * be removed.
+ * @method unsubscribeAll
+ * @param p_type {string} The type, or name of the event
+ */
+ unsubscribeAll: function(p_type) {
+ return this.unsubscribe(p_type);
+ },
+
+ /**
+ * Creates a new custom event of the specified type. If a custom event
+ * by that name already exists, it will not be re-created. In either
+ * case the custom event is returned.
+ *
+ * @method createEvent
+ *
+ * @param p_type {string} the type, or name of the event
+ * @param p_config {object} optional config params. Valid properties are:
+ *
+ *
+ *
+ * scope: defines the default execution scope. If not defined
+ * the default scope will be this instance.
+ *
+ *
+ * silent: if true, the custom event will not generate log messages.
+ * This is false by default.
+ *
+ *
+ * onSubscribeCallback: specifies a callback to execute when the
+ * event has a new subscriber. This will fire immediately for
+ * each queued subscriber if any exist prior to the creation of
+ * the event.
+ *
+ *
+ *
+ * @return {CustomEvent} the custom event
+ *
+ */
+ createEvent: function(p_type, p_config) {
+
+ this.__yui_events = this.__yui_events || {};
+ var opts = p_config || {};
+ var events = this.__yui_events;
+
+ if (events[p_type]) {
+YAHOO.log("EventProvider createEvent skipped: '"+p_type+"' already exists");
+ } else {
+
+ var scope = opts.scope || this;
+ var silent = (opts.silent);
+
+ var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
+ YAHOO.util.CustomEvent.FLAT);
+ events[p_type] = ce;
+
+ if (opts.onSubscribeCallback) {
+ ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
+ }
+
+ this.__yui_subscribers = this.__yui_subscribers || {};
+ var qs = this.__yui_subscribers[p_type];
+
+ if (qs) {
+ for (var i=0; i
+ *
The first argument fire() was executed with
+ *
The custom object (if any) that was passed into the subscribe()
+ * method
+ *
+ * If the custom event has not been explicitly created, it will be
+ * created now with the default config, scoped to the host object
+ * @method fireEvent
+ * @param p_type {string} the type, or name of the event
+ * @param arguments {Object*} an arbitrary set of parameters to pass to
+ * the handler.
+ * @return {boolean} the return value from CustomEvent.fire
+ *
+ */
+ fireEvent: function(p_type, arg1, arg2, etc) {
+
+ this.__yui_events = this.__yui_events || {};
+ var ce = this.__yui_events[p_type];
+
+ if (!ce) {
+YAHOO.log(p_type + "event fired before it was created.");
+ return null;
+ }
+
+ var args = [];
+ for (var i=1; i