event.js revision 873d065534cc0dc422a278a6c6651f4663d99b7c
(function() {
/**
* Custom event engine, DOM event listener abstraction layer, synthetic DOM
* events.
* @module event
*/
CAPTURE = "capture_",
Y.Env.eventAdaptors = {
/**
* Adds a DOM focus listener. Uses the focusin event in IE,
* and the capture phase otherwise so that
* the event propagates properly.
* @for YUI
* @event focus
*/
focus: {
on: function() {
},
detach: function() {
}
},
/**
* Adds a DOM focus listener. Uses the focusout event in IE,
* and the capture phase otherwise so that
* the event propagates properly.
* @for YUI
* @event blur
*/
blur: {
on: function() {
},
detach: function() {
}
},
/**
* Executes the callback as soon as the specified element
* is detected in the DOM.
* @for YUI
* @event available
*/
available: {
}
},
/**
* Executes the callback as soon as the specified element
* is detected in the DOM with a nextSibling property
* (indicating that the element's children are available)
* @for YUI
* @event contentready
*/
contentready: {
}
},
/**
* Add a key listener. The listener will only be notified if the
* keystroke detected meets the supplied specification. The
* spec consists of the key event type, followed by a colon,
* followed by zero or more comma separated key codes, followed
* by zero or more modifiers delimited by a plus sign. Ex:
* press:12,65+shift+ctrl
* @event key
* @param fn {string} the function to execute
* @param id {string} the element(s) to bind
* @param spec {string} the keyCode and modifier specification
* @param o optional context object
* @param args 0..n additional arguments that should be provided
* to the listener.
*/
key: {
}
// parse spec ([key event type]:[criteria])
// key event type: 'down', 'up', or 'press'
// list of key codes optionally followed by modifiers
// the name of the custom event that will be created for the spec
a = Y.Array(arguments, 0, true);
// subscribe spec validator to the DOM event
// Y.log('keylistener: ' + e.keyCode);
// pass this section if any supplied keyCode
// is found
// Y.log('passed: ' + crit);
passed = true;
} else {
failed = true;
// Y.log('failed: ' + crit);
}
// only check modifier if no keyCode was specified
// or the keyCode check was successful. pass only
// if every modifier passes
// Y.log(crit + ": " + passed);
}
}
// fire spec custom event if spec if met
if (passed) {
}
}, id);
// subscribe supplied listener to custom event for spec validator
// remove element and spec.
a[0] = ename;
}
}
};
/**
* Attach an event listener, either to a DOM object
* or to an Event.Target.
* @param type {string} the event type
* @param f {Function} the function to execute
* @param o the Event.Target or element to attach to
* @param context Optional execution context
* @param args* 0..n additional arguments to append
* to the signature provided when the event fires.
* @method on
* @for YUI
* @return {Event.Handle} a handle object for
* unsubscribing to this event.
*/
} else {
} else {
}
}
};
/**
* Detach an event listener (either a custom event or a
* DOM event
* @method detach
* @param type the type of event, or a Event.Handle to
* for the subscription. If the Event.Handle is passed
* in, the other parameters are not used.
* @param f {Function} the subscribed function
* @param o the object or element the listener is subscribed
* to.
* @method detach
* @return {YUI} the YUI instance
*/
} else {
} else {
}
}
};
/**
* Executes the callback before a DOM event, custom event
* or method. If the first argument is a function, it
* is assumed the target is a method. For DOM and custom
* events, this is an alias for Y.on.
*
* For DOM and custom events:
* type, callback, context, 1-n arguments
*
* For methods:
* callback, object (method host), methodName, context, 1-n arguments
*
* @method before
* @return unsubscribe handle
*/
} else {
}
};
/**
* Executes the callback after a DOM event, custom event
* or method. If the first argument is a function, it
* is assumed the target is a method.
*
* For DOM and custom events:
* type, callback, context, 1-n arguments
*
* For methods:
* callback, object (method host), methodName, context, 1-n arguments
*
* @method after
* @return {Event.Handle} unsubscribe handle
*/
} else {
}
};
})();