// The last argument supplied to use can be a load complete callback // YUI().use('*'); // bind everything available // use loader to expand dependencies and sort the // requirements if it is available. // loader.allowRollup = false; // YUI.Env.loaders[Y.config._sig] = loader; // process each requirement and any additional requirements // the module metadata specifies // loader = new Y.Loader(config); // loader.attaching = args; // server side loader service * Returns the namespace specified and creates it if it doesn't exist * YUI.namespace("property.package"); * YUI.namespace("YAHOO.property.package"); * Either of the above would create YUI.property, then * YUI.property.package (YAHOO is scrubbed out, this is * to remain compatible with YUI2) * Be careful when naming packages. Reserved words may work in some browsers * and not others. For instance, the following will fail in Safari: * YUI.namespace("really.long.nested.namespace"); * This fails because "long" is a future reserved word in ECMAScript * @param {string*} arguments 1-n namespaces to create * @return {object} A reference to the last namespace object created for (i=
0; i<a.
length; i=i+
1) {
d = (
"" + a[i]).
split(
".");
for (j=(d[
0] ==
"YAHOO") ?
1 :
0; j<d.
length; j=j+
1) {
// this is replaced if the log module is included * Report an error. The reporting mechanism is controled by * the 'throwFail' configuration attribute. If throwFail is * not specified, the message is written to the Logger, otherwise * @param msg {string} the error message * @param e {Error} Optional JS error that was caught. If supplied * and throwFail is specified, this error will be re-thrown. * @return {YUI} this YUI instance * Generate an id that is unique among all YUI instances * @param pre {string} optional guid prefix * @return {string} the guid * Returns a guid associated with an object. If the object * does not have one, a new one is created unless readOnly * @param o The object to stamp * @param readOnly {boolean} if true, a valid guid will only * be returned if the object has one assigned to it. * @return {string} The object's guid or null // IE generates its own unique ID for dom nodes // The uniqueID property of a document node returns a new ID uid = (
typeof o ===
'string') ? o : o.
_yuid;
// inheritance utilities are not available yet // set up the environment // setTimeout(function() { YUI._attach(['yui-base']); }, 0); // add a window load event at load time so we can capture // the case where it fires before dynamic loading is // Support the CommonJS method for exporting our single global * The config object contains all of the configuration options for * the YUI instance. This object is supplied by the implementer * when instantiating a YUI instance. Some properties have default * values if they are not supplied by the implementer. This should * not be updated directly because some values are cached. Use * applyConfig() to update the config object on a YUI instance that * has already been configured. * Allows the YUI seed file to fetch the loader component and library * metadata to dynamically load additional dependencies. * Log to the browser console if debug is on and the browser has a * @property useBrowserConsole * A hash of log sources that should be logged. If specified, only log messages from these sources will be logged. * A hash of log sources that should be not be logged. If specified, * all sources are logged if not on this list. * Set to true if the yui seed file was dynamically loaded in * order to bootstrap components relying on the window load event * and the 'domready' custom event. * If throwFail is set, Y.error will generate or re-throw a JS Error. * Otherwise the failure is logged. * The window/frame that this instance should operate in. * @default the window hosting YUI * The document associated with the 'win' configuration. * @default the document hosting YUI * A list of modules that defines the YUI core (overrides the default). * A list of languages in order of preference. This list is matched against * the list of available languages in modules that the YUI instance uses to * determine the best possible localization of language sensitive modules. * Languages are represented using BCP 47 language tags, such as "en-GB" for * English as used in the United Kingdom, or "zh-Hans-CN" for simplified * Chinese as used in China. The list can be provided as a comma-separated * The default date format * @deprecated use configuration in DataType.Date.format() instead * @deprecated use config.lang instead * The default interval when polling in milliseconds. * The number of dynamic nodes to insert by default before * automatically removing them. This applies to script nodes * because remove the node will not make the evaluated script * unavailable. Dynamic CSS is not auto purged, because removing * a linked style sheet will also remove the style definitions. * @property purgethreshold * The default interval when polling in milliseconds. * @property windowResizeDelay * Base directory for dynamic loading * The secure base dir (not implemented) * The root path to prepend to module path for the combo service. Ex: 3.0.0b1/build/ * A filter to apply to result urls. This filter will modify the default * path for all modules. The default path for the YUI library is the * minified version of the files (e.g., event-min.js). The filter property * can be a predefined filter or a custom filter. The valid predefined * <dd>Selects the debug versions of the library (e.g., event-debug.js). * This option will automatically include the Logger widget</dd> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> * You can also define a custom filter, which must be an object literal * containing a search expression and a replace string: * 'searchExp': "-min\\.js", * The 'skin' config let's you configure application level skin * customizations. It contains the following attributes which * can be specified to override the defaults: * // The default skin, which is automatically applied if not * // overriden by a component-specific skin definition. * // Change this in to apply a different skin globally * // This is combined with the loader base property to get * // the default root directory for a skin. * // Any component-specific overrides can be specified here, * // making it possible to load different skins for different * // components. It is possible to load more than one skin * // for a given component as well. * slider: ['capsule', 'round'] * Hash of per-component filter specification. If specified for a given component, * this overrides the filter config * Use the YUI combo service to reduce the number of http connections * required to load your dependencies. Turning this off will * disable combo handling for YUI and all module groups configured * @default true if 'base' is not supplied, false if it is. * A list of modules that should never be dynamically loaded * A list of modules that should always be loaded when required, even if already * Node or id for a node that should be used as the insertion point for new nodes * Object literal containing attributes to add to dynamically loaded script nodes. * Object literal containing attributes to add to dynamically loaded link nodes. * @property cssAttributes * Number of milliseconds before a timeout occurs when dynamically * loading nodes. If not set, there is no timeout. * Callback for the 'CSSComplete' event. When dynamically loading YUI * components with CSS, this property fires when the CSS is finished * loading but script loading is still ongoing. This provides an * opportunity to enhance the presentation of a loading page a little * bit before the entire loading process is done. * A hash of module definitions to add to the list of YUI components. * These components can then be dynamically loaded side by side with * YUI via the use() method. This is a hash, the key is the module * name, and the value is an object literal specifying the metdata * for the module. * See Loader.addModule for the supported module * metadata fields. Also @see groups, which provides a way to * configure the base and combo spec for a set of modules. * requires: ['node'], * requires: ['mymod1'], * A hash of module group definitions. It for each group you * can specify a list of modules and the base path and * combo spec to use when dynamically loading the modules. @see * @see modules for the details about the modules part of the * // specify whether or not this group has a combo service * // the base path for non-combo paths * // the path to the combo service * // a fragment to prepend to the path attribute when * // when building combo urls * // the module definitions * requires: ['yui2_yde'] * The loader 'path' attribute to the loader itself. This is combined * with the 'base' attribute to dynamically load the loader component * when boostrapping with the get utility alone. * Specifies whether or not YUI().use(...) will attempt to load CSS * resources at all. Any truthy value will cause CSS dependencies * to load when fetching script. The special value 'force' will * cause CSS dependencies to be loaded even if no script is needed. * The default gallery version to build gallery module urls * The default YUI 2 version to build yui2 module urls. This is for * intrinsic YUI 2 support via the 2in3 project. Also @see the '2in3' * config for pulling different revisions of the wrapped YUI 2 * The 2in3 project is a deployment of the various versions of YUI 2 * deployed as first-class YUI 3 modules. Eventually, the wrapper * for the modules will change (but the underlying YUI 2 code will * be the same), and you can select a particular version of * the wrapper modules via this config. * Alternative console log function for use in environments without * a supported native console. The function is executed in the * A callback to execute when Y.error is called. It receives the * error message and an javascript error object if Y.error was * executed because a javascript error was caught. The function * is executed in the YUI instance context. * The parameter defaults for the remote loader service. * Requires the rls submodule. The properties that are * m: comma separated list of module requirements. This * must be the param name even for custom implemetations. * v: the version of YUI to load. Defaults to the version * of YUI that is being used. * gv: the version of the gallery to load (@see the gallery config) * env: comma separated list of modules already on the page. * this must be the param name even for custom implemetations. * lang: the languages supported on the page (@see the lang config) * '2in3v': the version of the 2in3 wrapper to use (@see the 2in3 config). * '2v': the version of yui2 to use in the yui 2in3 wrappers (@see the yui2 config) * filt: a filter def to apply to the urls (@see the filter config). * filts: a list of custom filters to apply per module (@see the filters config). * tests: this is a map of conditional module test function id keys with the values * of 1 if the test passes, 0 if not. This must be the name of the querystring * param in custom templates. * The base path to the remote loader service * The template to use for building the querystring portion * of the remote loader service url. The default is determined * by the rls config -- each property that has a value will be * ex: m={m}&v={v}&env={env}&lang={lang}&filt={filt}&tests={tests} * Configure the instance to use a remote loader service instead of YUI.
add(
'yui-base',
function(Y) {
* The YUI module contains the components required for building the YUI seed file. * This includes the script loading mechanism, a simple queue, and the core utilities for the library. * Provides the language utilites and extensions used by the library '[object RegExp]' :
REGEX,
'[object Array]' :
ARRAY,
SUBREGEX = /\{\s*([^\|\}]+?)\s*(?:\|([^\}]*))?\s*\}/g;
* Determines whether or not the provided item is an array. * Returns false for array-like collections such as the * function arguments collection or HTMLElement collection * will return false. You can use @see Array.test if you * @param o The object to test * @return {boolean} true if o is an array * Determines whether or not the provided item is a boolean * @param o The object to test * @return {boolean} true if o is a boolean * Determines whether or not the provided item is a function * Note: Internet Explorer thinks certain functions are objects: * var obj = document.createElement("object"); * Y.Lang.isFunction(obj.getAttribute) // reports false in IE * var input = document.createElement("input"); // append to body * Y.Lang.isFunction(input.focus) // reports false in IE * You will have to implement additional tests if these functions * @param o The object to test * @return {boolean} true if o is a function * Determines whether or not the supplied item is a date instance * @param o The object to test * @return {boolean} true if o is a date // return o instanceof Date; * Determines whether or not the provided item is null * @param o The object to test * @return {boolean} true if o is null * Determines whether or not the provided item is a legal number * @param o The object to test * @return {boolean} true if o is a number * Determines whether or not the provided item is of type object * @param o The object to test * @param failfn {boolean} fail if the input is a function * @return {boolean} true if o is an object * Determines whether or not the provided item is a string * @param o The object to test * @return {boolean} true if o is a string * Determines whether or not the provided item is undefined * @param o The object to test * @return {boolean} true if o is undefined * Returns a string without any leading or trailing whitespace. If * the input is not a string, the input will be returned untouched. * @param s {string} the string to trim * @return {string} the trimmed string * A convenience method for detecting a legitimate non-null value. * @param o The item to test * Returns a string representing the type of the item passed in. * typeof HTMLElementCollection returns function in Safari, but * Y.type() reports object, which could be a good thing -- * but it actually caused the logic in Y.Lang.isObject to fail. * @param o the item to test * @return {string} the detected type * Lightweight version of @see Y.substitute... it uses the same template * structure as Y.substitute, but doesn't support recursion, auto-object L.
sub =
function (s, o) {
* The YUI module contains the components required for building the YUI seed file. * This includes the script loading mechanism, a simple queue, and the core utilities for the library. * Adds the following array utilities to the YUI instance. Additional * array helpers can be found in the collection component. * Y.Array(o) returns an array: * - Arrays are return unmodified unless the start position is specified. * - "Array-like" collections (@see Array.test) are converted to arrays * - For everything else, a new array is created with the input as the sole item * - The start position is used if the input is or is like an array to return * a subset of the collection. * @TODO this will not automatically convert elements that are also collections * such as forms and selects. Passing true as the third param will * @param o the item to arrayify * @param i {int} if an array or array-like, this is the start index * @param arraylike {boolean} if true, it forces the array-like fork. This * can be used to avoid multiple Array.test calls. * @return {Array} the resulting array // IE errors when trying to slice HTMLElement collections * Evaluates the input to determine if it is an array, array-like, or * something else. This is used to handle the arguments collection * available within functions, and HTMLElement collections * @todo current implementation (intenionally) will not implicitly * handle html elements that are array-like (forms, selects, etc). * @return {int} a number indicating the results: * 0: Not an array or an array-like collection * 2: array-like collection. // indexed, but no tagName (element) or alert (window), or functions without apply/call (Safari HTMLElementCollection bug) * Executes the supplied function on each item in the array. * @param a {Array} the array to iterate * @param f {Function} the function to execute on each item. The * function receives three arguments: the value, the index, the full array. * @param o Optional context object * @return {YUI} the YUI instance var l = (a && a.
length) ||
0, i;
for (i =
0; i < l; i=i+
1) {
f.
call(o || Y, a[i], i, a);
* Returns an object using the first array as keys, and * the second as values. If the second array is not * provided the value is set to true for each. * @param k {Array} keyset * @param v {Array} optional valueset * @return {object} the hash o[k[i]] = (
vl &&
vl > i) ? v[i] :
true;
* Returns the index of the first item in the array * that contains the specified value, -1 if the * @param a {Array} the array to search * @param val the value to search for * @return {int} the index of the item that contains the value or -1 for (
var i=
0; i<a.
length; i=i+
1) {
* Numeric sort convenience function. * Y.ArrayAssert.itemsAreEqual([1, 2, 3], [3, 1, 2].sort(Y.Array.numericSort)); * Executes the supplied function on each item in the array. * Returning true from the processing function will stop the * processing of the remaining * @param a {Array} the array to iterate * @param f {Function} the function to execute on each item. The function * receives three arguments: the value, the index, the full array. * @param o Optional context object * @return {boolean} true if the function returns true on * any of the items in the array if (f.
call(o, a[i], i, a)) {
* The YUI module contains the components required for building the YUI seed file. * This includes the script loading mechanism, a simple queue, and the core utilities for the library. * A simple FIFO queue. Items are added to the Queue with add(1..n items) and * @param item* {MIXED} 0..n items to seed the queue * The collection of enqueued items * Get the next item in the queue. FIFO support * @return {MIXED} the next item in the queue * Get the last in the queue. LIFO support * @return {MIXED} the last item in the queue * Add 0..n items to the end of the queue * @param item* {MIXED} 0..n items * Returns the current number of queued items * The YUI module contains the components required for building the YUI seed file. * This includes the script loading mechanism, a simple queue, and the core utilities for the library. * IE will not enumerate native functions in a derived object even if the * function was overridden. This is a workaround for specific functions * we care about on the Object prototype. * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * Returns a new object containing all of the properties of * all the supplied objects. The properties from later objects * will overwrite those in earlier objects. Passing in a * single object will create a shallow copy of it. For a deep * @param arguments {Object*} the objects to merge * @return {object} the new merged object * Applies the supplier's properties to the receiver. By default * all prototype and static propertes on the supplier are applied * to the corresponding spot on the receiver. By default all * properties are applied, and a property that is already on the * reciever will not be overwritten. The default behavior can * be modified by supplying the appropriate parameters. * @TODO add constants for the modes * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * @param ov {boolean} if true, properties already on the receiver * will be overwritten if found on the supplier. * @param wl {string[]} a whitelist. If supplied, only properties in * this list will be applied to the receiver. * @param {int} mode what should be copies, and to where * default(0): object to object * 1: prototype to prototype (old augment) * 2: prototype to prototype and object props (new augment) * @return {object} the augmented object case 1:
// proto to proto case 2:
// object to object and proto to proto case 3:
// proto to static case 4:
// static to proto default:
// object to object is what happens below // Maybe don't even need this wl && wl.length check anymore?? for (i =
0, l =
wl.
length; i < l; ++i) {
}
else if (
ov || !(p
in r)) {
// if (s.hasOwnProperty(i) && !(i in FROZEN)) { // check white list if it was supplied // if the receiver has this property, it is an object, // and merge is specified, merge the two objects. Y.
mix(r[i], s[i],
ov,
wl,
0,
true);
// recursive // otherwise apply the property only if overwrite // is specified or the receiver doesn't have one. }
else if (
ov || !(i
in r)) {
// if merge is specified and the receiver is an array, * Returns a wrapper for a function which caches the * return value of that function, keyed off of the combined * @param source {function} the function to memoize * @param cache an optional cache seed * @param refetch if supplied, this value is tested against the cached * value. If the values are equal, the wrapped function is executed again. * @return {Function} the wrapped function * The YUI module contains the components required for building the YUI seed file. * This includes the script loading mechanism, a simple queue, and the core utilities for the library. * Adds the following Object utilities to the YUI instance * Y.Object(o) returns a new object based upon the supplied object. * @TODO Use native Object.create() when available * @param o the supplier object * @return {Object} the new object // return Object.prototype.hasOwnProperty.call(o, k); * Extracts the keys, values, or size from an object * @param what what to extract (0: keys, 1: values, 2: size) * @return {boolean|Array} the extracted info * Returns an array containing the object's keys * @TODO use native Object.keys() if available * @return {string[]} the keys * Returns an array containing the object's values * @TODO use native Object.values() if available * @return {Array} the values * Returns the size of an object * @TODO use native Object.size() if available * Returns true if the object contains a given key * @param k the key to query * @return {boolean} true if the object contains the key * Returns true if the object contains a given value * @param v the value to query * @return {boolean} true if the object contains the value * Determines whether or not the property was added * to the object instance. Returns false if the property is not present * in the object, or was inherited from the prototype. * @param o {any} The object being testing * @param p {string} the property to look for * @return {boolean} true if the object has the property on the instance * Executes a function on each item. The function * receives the value, the key, and the object * as parameters (in that order). * @param o the object to iterate * @param f {Function} the function to execute on each item. The function * receives three arguments: the value, the the key, the full object. * @param c the execution context * @param proto {boolean} include proto * @return {YUI} the YUI instance * Executes a function on each item, but halts if the * function returns true. The function * receives the value, the key, and the object * as paramters (in that order). * @param o the object to iterate * @param f {Function} the function to execute on each item. The function * receives three arguments: the value, the the key, the full object. * @param c the execution context * @param proto {boolean} include proto * @return {boolean} true if any execution of the function returns true, false otherwise if (f.
call(s, o[i], i, o)) {
* Retrieves the sub value at the provided path, * from the value object provided. * @param o The object from which to extract the property value * @param path {Array} A path array, specifying the object traversal path * from which to obtain the sub value. * @return {Any} The value stored in the path, undefined if not found, * undefined if the source is not an object. Returns the source object * if an empty path is provided. * Sets the sub-attribute value at the provided path on the * value object. Returns the modified value object, or * undefined if the path is invalid. * @param o The object on which to set the sub value. * @param path {Array} A path array, specifying the object traversal path * at which to set the sub value. * @param val {Any} The new value for the sub-attribute. * @return {Object} The modified object, with the new sub value set, or * undefined, if the path was invalid. * Returns true if the object has no properties of its own * @return {boolean} true if the object is empty * The YUI module contains the components required for building the YUI seed file. * This includes the script loading mechanism, a simple queue, and the core utilities for the library. * YUI user agent detection. * Do not fork for a browser if it can be avoided. Use feature detection when * you can. Use the user agent as a last resort. UA stores a version * number for the browser engine, 0 otherwise. This value may or may not map * to the version number of the browser using the engine. The value is * presented as a float so that it can easily be used for boolean evaluation * as well as for looking for a particular range of versions. Because of this, * some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9 return (c++ ==
1) ?
'' :
'.';
* Internet Explorer version number or 0. Example: 6 * Opera version number or 0. Example: 9.2 * Gecko engine revision number. Will evaluate to 1 if Gecko * is detected but the revision could not be found. Other browsers * will be 0. Example: 1.8 * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7 * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8 * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81 * AppleWebKit version. KHTML browsers that are not WebKit browsers * will evaluate to 1, other browsers 0. Example: 418.9 * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the * latest available for Mac OSX 10.3. * Safari 2.0.2: 416 <-- hasOwnProperty introduced * Safari 2.0.4: 418 <-- preventDefault fixed * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run * different versions of webkit * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been * updated, but not updated * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG * and many major issues fixed). * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic update * from 2.x via the 10.4.11 OS patch * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event. * yahoo.com user agent hack removed. * Chrome will be detected as webkit, but this property will also * be populated with the Chrome version number * The mobile property will be set to a string containing any relevant * user agent information when a modern mobile browser is detected. * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series * devices with the WebKit-based browser, and Opera Mini. * Adobe AIR version number or 0. Only populated if webkit is detected. * Detects Apple iPad's OS version * Detects Apple iPhone's OS version * Detects Apples iPod's OS version * General truthy check for iPad, iPhone or iPod * Detects Googles Android OS version * Google Caja version number or 0. * Set to true if the page appears to be in SSL * The operating system. Currently only detecting windows or macintosh // Modern KHTML browsers should qualify as Safari X-Grade // Modern WebKit browsers are at least X-Grade o.
mobile =
"Apple";
// iPhone or iPod Touch o.
mobile = m[
0];
// Nokia N-series, Android, webOS, ex: NokiaN95 o.
air = m[
0];
// Adobe AIR 1.0 or better if (!o.
webkit) {
// not webkit // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) o.
mobile = m[
0];
// ex: Opera Mini/2.0.4509/1316 }
else {
// not opera or webkit }
else {
// not opera, webkit, or ie o.
gecko=
1;
// Gecko detected, look for revision * Provides a mechanism to fetch remote resources and * insert them into a document. * Fetches and inserts one or more script or link nodes into the document * hash of queues to manage multiple requests * queue index used to generate transaction ids * interal property used to prevent multiple simultaneous purge * Generates an HTML element, this is not appended to a document * @param type {string} the type of element * @param attr {string} the attributes * @param win {Window} optional window to create the element in * @return {HTMLElement} the generated node * @param url {string} the url for the css file * @param win {Window} optional window to create the node in * @param attributes optional attributes collection to apply to the new node * @return {HTMLElement} the generated node * Generates a script node * @param url {string} the url for the script file * @param win {Window} optional window to create the node in * @param attributes optional attributes collection to apply to the new node * @return {HTMLElement} the generated node * Returns the data payload for callback functions * The transaction is finished * @param id {string} the id of the request * The request failed, execute fail handler with whatever * was accomplished. There isn't a failure case at the * moment unless you count aborted transactions * @param id {string} the id of the request // execute failure callback * The request is complete, so executing the requester's callback * @param id {string} the id of the request msg =
"transaction " +
id +
" was aborted";
// execute success callback * @param id {string} the id of the request _end(
id,
'timeout',
'timeout');
* Loads the next item for a given request * @param id {string} the id of the request * @param loaded {string} the url that was just loaded, if any msg =
"transaction " +
id +
" was aborted";
// This is the first pass: make sure the url is an array // if the url is undefined, this is probably a trailing comma problem in IE // q.timer = L.later(q.timeout, q, _timeout, id); if (q.
type ===
"script") {
// track this node's load progress // add the node to the queue so we can return it to the user supplied callback // add it to the head or insert it before 'insertBefore'. Work around IE // bug if there is a base tag. // FireFox does not support the onload event for link nodes, so there is // no way to make the css requests synchronous. This means that the css // rules in multiple files could be applied out of order in this browser // if a later request returns before an earlier one. Safari too. * Removes processed queues and corresponding nodes * Saves the state for the request and begins loading * @param type {string} the type of node to insert * @param url {string} the url to load * @param opts the hash of options for this request (
type ===
"script") ?
true :
false;
* Detects when a node has been loaded. In the case of * script nodes, this does not guarantee that contained * script is ready to use. * @param type {string} the type of node to track * @param n {HTMLElement} the node to track * @param id {string} the id of the request * @param url {string} the url that is being loaded * @param win {Window} the targeted window * @param qlength the number of remaining items in the queue, * @param trackfn {Function} function to execute when finished // IE supports the readystatechange event for script and css nodes // Opera only for script nodes. Opera support onload for script // nodes, but this doesn't fire when there is a load failure. // The onreadystatechange appears to be a better way to respond // to both success and failure. if (
"loaded" ===
rs ||
"complete" ===
rs) {
// webkit prior to 3.x is no longer supported // Safari 3.x supports the load event for script nodes (DOM2) // FireFox and Opera support onload (but not DOM2 in FF) handlers for // script nodes. Opera, but not FF, supports the onload event for link * Removes the nodes for the specified queue * The number of request required before an automatic purge. * Can be configured via the 'purgethreshold' config * Called by the the helper for detecting script load in Safari * @param id {string} the transaction id * @param o {string|object} Either the tId or the object returned from * Fetches and inserts one or more script nodes into the head * of the current document or the document in a specified window. * @param url {string|string[]} the url or urls to the script(s) * @param opts {object} Options: * callback to execute when the script(s) are finished loading * The callback receives an object back with the following * <dd>the window the script(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * <dd>A function that, when executed, will remove the nodes * that were inserted</dd> * callback to execute when a timeout occurs. * The callback receives an object back with the following * <dd>the window the script(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * <dd>A function that, when executed, will remove the nodes * that were inserted</dd> * <dd>a function that executes when the transaction finishes, regardless of the exit path</dd> * callback to execute when the script load operation fails * The callback receives an object back with the following * <dd>the window the script(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * inserted successfully</dd> * <dd>A function that, when executed, will remove any nodes * that were inserted</dd> * <dd>the execution context for the callbacks</dd> * <dd>a window other than the one the utility occupies</dd> * setting to true will let the utilities cleanup routine purge * <dt>purgethreshold</dt> * The number of transaction before autopurge should be initiated * data that is supplied to the callback when the script(s) are * <dd>node or node id that will become the new node's nextSibling. If this * is not specified, nodes will be inserted before a base tag should it exist. * Otherwise, the nodes will be appended to the end of the document head.</dd> * <dd>Node charset, default utf-8 (deprecated, use the attributes config)</dd> * <dd>An object literal containing additional attributes to add to the link tags</dd> * <dd>Number of milliseconds to wait before aborting and firing the timeout event</dd> * Y.Get.script( * onSuccess: function(o) { * this.log("won't cause error because Y is the context"); * }, * onFailure: function(o) { * }, * onTimeout: function(o) { * }, * data: "foo", * timeout: 10000, // 10 second timeout * context: Y, // make the YUI instance * // win: otherframe // target another window/frame * autopurge: true // allow the utility to choose when to remove the nodes * purgetheshold: 1 // purge previous transaction before next transaction * @return {tId: string} an object containing info about the transaction * Fetches and inserts one or more css link nodes into the * head of the current document or the document in a specified * @param url {string} the url or urls to the css file(s) * callback to execute when the css file(s) are finished loading * The callback receives an object back with the following * <dd>the window the link nodes(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * <dd>A function that, when executed, will remove the nodes * that were inserted</dd> * <dd>the execution context for the callbacks</dd> * <dd>a window other than the one the utility occupies</dd> * data that is supplied to the callbacks when the nodes(s) are * <dd>node or node id that will become the new node's nextSibling</dd> * <dd>Node charset, default utf-8 (deprecated, use the attributes config)</dd> * <dd>An object literal containing additional attributes to add to the link tags</dd> * insertBefore: 'custom-styles' // nodes will be inserted before the specified node * @return {tId: string} an object containing info about the transaction YUI.
add(
'features',
function(Y) {
// results[k] = Y.Features.test(cat, k, args); // Y.Features.add("load", "1", {}); // Y.Features.test("load", "1"); "trigger":
"history-hash" },
'@VERSION@' ,{
requires:[
'yui-base']});
* Implentation for building the remote loader service url. * @param what {Array} the requested modules m:
1,
// required in the template env:
1,
// required in the template tests:
1 // required in the template // console.log('rls_tmpl: ' + s); },
'@VERSION@' ,{
requires:[
'yui-base',
'get',
'features']});
YUI.
add(
'intl-base',
function(Y) {
* The Intl utility provides a central location for managing sets of localized resources (strings and formatting patterns). * Returns the language among those available that * best matches the preferred language list, using the Lookup * If none of the available languages meets the user's preferences, * Extended language ranges are not supported. * @param {String[] | String} preferredLanguages The list of preferred languages * in descending preference order, represented as BCP 47 language * tags. A string array or a comma-separated list. * @param {String[]} availableLanguages The list of languages * that the application supports, represented as BCP 47 language * @return {String} The available language that best matches the * preferred language list, or "". // check whether the list of available languages contains language; if so return it // check the fallback sequence for one language // one-character subtags get cut along with the following subtag // nothing available for this language },
'@VERSION@' ,{
requires:[
'yui-base']});
YUI.
add(
'yui-log',
function(Y) {
* Provides console log capability and exposes a custom event for * console implementations. * If the 'debug' config is true, a 'yui:log' event will be * dispatched, which the Console widget and anything else * can consume. If the 'useBrowserConsole' config is true, it will * write to the browser console if available. YUI-specific log * messages will only be present in the -debug versions of the * JS files. The build system is supposed to remove log statements * from the raw and minified versions of the files. * @param {String} msg The message to log. * @param {String} cat The log category for the message. Default * categories are "info", "warn", "error", time". * Custom categories can be used as well. (opt) * @param {String} src The source of the the message (opt) * @param {boolean} silent If true, the log event won't fire * @return {YUI} YUI instance // suppress log message if the config is off or the event stack // or the event call stack contains a consumer of the yui:log event * Write a system message. This message will be preserved in the * minified and raw versions of the YUI files, unlike log statements. * @param {String} msg The message to log. * @param {String} cat The log category for the message. Default * categories are "info", "warn", "error", time". * Custom categories can be used as well. (opt) * @param {String} src The source of the the message (opt) * @param {boolean} silent If true, the log event won't fire * @return {YUI} YUI instance },
'@VERSION@' ,{
requires:[
'yui-base']});
YUI.
add(
'yui-later',
function(Y) {
* Executes the supplied function in the context of the supplied * object 'when' milliseconds later. Executes the function a * single time unless periodic is set to true. * @param when {int} the number of milliseconds to wait until the fn * @param o the context object. * @param fn {Function|String} the function to execute or the name of * the method in the 'o' object to execute. * @param data [Array] data that is provided to the function. This accepts * either a single item or an array. If an array is provided, the * function is executed with one parameter for each array item. If * you need to pass a single array parameter, it needs to be wrapped in * @param periodic {boolean} if true, executes continuously at supplied * interval until canceled. * @return {object} a timer object. Call the cancel() method on this object to },
'@VERSION@' ,{
requires:[
'yui-base']});
YUI.
add(
'yui-throttle',
function(Y) {
* @submodule yui-throttle * Throttles a call to a method based on the time between calls. * @param fn {function} The function call to throttle. * @param ms {int} The number of milliseconds to throttle the method call. Can set * globally with Y.config.throttleTime or by call. Passing a -1 will disable the throttle. Defaults to 150 * @return {function} Returns a wrapped function that calls fn throttled. // We added the redundant definition to later for backwards compatibility. // I don't think we need to do the same thing here // Y.Lang.throttle = throttle; },
'@VERSION@' ,{
requires:[
'yui-base']});
YUI.
add(
'yui',
function(Y){},
'@VERSION@' ,{
use:[
'yui-base',
'get',
'features',
'rls',
'intl-base',
'yui-log',
'yui-later',
'yui-throttle']});
* Supplies object inheritance and manipulation utilities. This adds * additional functionaity to what is provided in yui-base, and the * methods are applied directly to the YUI instance. This module * is required for most YUI components. if (o && o[
action] && o !== Y) {
return A[
action](Y.
Array(o,
0,
true), f, c);
* The following methods are added to the YUI instance * Applies prototype properties from the supplier to the receiver. * The receiver can be a constructor or an instance. * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * @param ov {boolean} if true, properties already on the receiver * will be overwritten if found on the supplier. * @param wl {string[]} a whitelist. If supplied, only properties in * this list will be applied to the receiver. * @param args {Array | Any} arg or arguments to apply to the supplier * constructor when initializing. * @return {object} the augmented object * @todo constructor optional? * @todo understanding what an instance is augmented with * @TODO best practices for overriding sequestered methods. // working on a class, so apply constructor infrastructure // sequester all of the functions in the supplier and replace with // one that will restore all of them. // overwrite the prototype with all of the sequestered functions, // but only if it hasn't been overridden // apply the original sequestered function if ((!
wl || (k
in wl)) && (
ov || !(k
in this))) {
// sequester the function // replace the sequestered function with a function that will // restore all sequestered functions and exectue the constructor. // augmenting an instance, so apply the constructor immediately * Applies object properties from the supplier to the receiver. If * the target has the property, and the property is an object, the target * object will be augmented with the supplier's value. If the property * is an array, the suppliers value will be appended to the target. * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * @param ov {boolean} if true, properties already on the receiver * will be overwritten if found on the supplier. * @param wl {string[]} a whitelist. If supplied, only properties in * this list will be applied to the receiver. * @return the extended object return Y.
mix(r, s,
ov,
wl,
0,
true);
* Utility to set up the prototype, constructor and superclass properties to * support an inheritance strategy that can chain constructors and methods. * Static members will not be inherited. * @param {Function} r the object to modify * @param {Function} s the object to inherit * @param {Object} px prototype properties to add/override * @return the extended object Y.
error(
"extend failed, verify dependencies");
// assign constructor property // add prototype overrides * Executes the supplied function for each item in * a collection. Supports arrays, objects, and * @param o the object to iterate * @param f the function to execute. This function * receives the value, key, and object as parameters * @param proto if true, prototype properties are * @return {YUI} the YUI instance * Executes the supplied function for each item in * a collection. The operation stops if the function * returns true. Supports arrays, objects, and * @param o the object to iterate * @param f the function to execute. This function * receives the value, key, and object as parameters * @param proto if true, prototype properties are * @return {boolean} true if the function ever returns true, false otherwise * Deep obj/array copy. Function clones are actually * wrappers around the original function. * Array-like objects are treated as arrays. * Primitives are returned untouched. Optionally, a * function can be provided to handle other data types, * filter keys, validate values, etc. * @param safe {boolean} if true, objects will not have prototype * items from the source. If false, they will. In this case, the * original is initially protected, but the clone is not completely immune * from changes to the source object prototype. Also, cloned prototype * items that are deleted from the clone will result in the value * of the source prototype being exposed. If operating on a non-safe * clone, items should be nulled out rather than deleted. * @param f optional function to apply to each item in a collection; * it will be executed prior to applying the value to * the new object. Return false to prevent the copy. * @param c optional execution context for f * @param owner Owner object passed when clone is iterating an * object. Used to set up context for cloned functions. * @return {Array|Object} the cloned object // @TODO cloning YUI instances doesn't currently work // return new RegExp(o.source); // if we do this we need to set the flags too // o2 = Y.bind(o, owner); // #2528250 only one clone of a given object should be created. o2 = (
safe) ? {} : Y.
Object(o);
// #2528250 don't try to clone element properties if (!f || (f.
call(c ||
this, v, k,
this, o) !==
false)) {
// } else if (o[k] === o) { * Returns a function that will execute the supplied function in the * supplied object's context, optionally adding any additional * supplied parameters to the beginning of the arguments collection the * supplied to the function. * @param f {Function|String} the function to bind, or a function name * to execute on the context object * @param c the execution context * @param args* 0..n arguments to include before the arguments the * function is executed with. * @return {function} the wrapped function Y.
bind =
function(f, c) {
* Returns a function that will execute the supplied function in the * supplied object's context, optionally adding any additional * supplied parameters to the end of the arguments the function * @param f {Function|String} the function to bind, or a function name * to execute on the context object * @param c the execution context * @param args* 0..n arguments to append to the end of arguments collection * supplied to the function * @return {function} the wrapped function Y.
rbind =
function(f, c) {
YUI.
add(
'dom-base',
function(Y) {
* The DOM utility provides a cross-browser abtraction layer * normalizing DOM tasks, and adds extra helper functionality * for other common tasks. * Provides DOM helper methods. * Returns the HTMLElement with the given ID (Wrapper for document.getElementById). * @param {String} id the id attribute * @param {Object} doc optional The document to search. Defaults to current document * @return {HTMLElement | null} The HTMLElement with the id, or null if none found. // handle dupe IDs and IE name collision * Returns the text content of the HTMLElement. * @param {HTMLElement} element The html element. * @return {String} The text content of the element (includes text of any descending elements). * Sets the text content of the HTMLElement. * @param {HTMLElement} element The html element. * @param {String} content The content to add. * Finds the previous sibling of the element. * @deprecated Use elementByAxis * @param {HTMLElement} element The html element. * @param {Function} fn optional An optional boolean test to apply. * The optional function is passed the current DOM node being tested as its only argument. * If no function is given, the first sibling is returned. * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes. * @return {HTMLElement | null} The matching DOM node or null if none found. * Finds the next sibling of the element. * @deprecated Use elementByAxis * @param {HTMLElement} element The html element. * @param {Function} fn optional An optional boolean test to apply. * The optional function is passed the current DOM node being tested as its only argument. * If no function is given, the first sibling is returned. * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes. * @return {HTMLElement | null} The matching DOM node or null if none found. * Finds the ancestor of the element. * @deprecated Use elementByAxis * @param {HTMLElement} element The html element. * @param {Function} fn optional An optional boolean test to apply. * The optional function is passed the current DOM node being tested as its only argument. * If no function is given, the parentNode is returned. * @param {Boolean} testSelf optional Whether or not to include the element in the scan * @return {HTMLElement | null} The matching DOM node or null if none found. * Searches the element by the given axis for the first matching element. * @param {HTMLElement} element The html element. * @param {String} axis The axis to search (parentNode, nextSibling, previousSibling). * @param {Function} fn optional An optional boolean test to apply. * @param {Boolean} all optional Whether all node types should be returned, or just element nodes. * The optional function is passed the current HTMLElement being tested as its only argument. * If no function is given, the first element is returned. * @return {HTMLElement | null} The matching element or null if none found. * Determines whether or not one HTMLElement is or contains another HTMLElement. * @param {HTMLElement} element The containing html element. * @param {HTMLElement} needle The html element that may be contained. * @return {Boolean} Whether or not the element is or contains the needle. * Determines whether or not the HTMLElement is part of the document. * @param {HTMLElement} element The containing html element. * @param {HTMLElement} doc optional The document to check. * @return {Boolean} Whether or not the element is attached to the document. // contains only works with HTML_ELEMENT for (i =
0;
node =
nodes[i++];) {
// check for a match * Creates a new dom node using the provided markup string. * @param {String} html The markup used to create the element * @param {HTMLDocument} doc An optional document context * @return {HTMLElement|DocumentFragment} returns a single HTMLElement * when creating one node, and a documentFragment when creating if (
typeof html ===
'string') {
if (
typeof custom[m[
1]] ===
'function') {
if (
nodes.
length ===
1) {
// return single node, breaking parentNode ref from "fragment" }
else if (
nodes[
0] &&
nodes[
0].
className ===
'yui3-big-dummy') {
// using dummy node to preserve some attributes (e.g. OPTION not selected) }
else {
// return multiple nodes as a fragment if (
nodes.
item) {
// convert live list to static array }
// else inline with log for minification * Provides a normalized attribute interface. * @param {String | HTMLElement} el The target element for the attribute. * @param {String} attr The attribute to set. * @param {String} val The value of the attribute. * Provides a normalized attribute interface. * @param {String | HTMLElement} el The target element for the attribute. * @param {String} attr The attribute to get. * @return {String} The current value of the attribute. ret =
'';
// per DOM spec * Inserts content in a node at the given location * @param {HTMLElement} node The node to insert into * @param {String | HTMLElement} content The content to be inserted * @param {String | HTMLElement} where Where to insert the content * If no "where" is given, content is appended to the node * Possible values for "where" * <dd>The element to insert before</dd> * <dd>Replaces the existing HTML</dd> * <dd>Inserts before the existing HTML</dd> * <dd>Inserts content before the node</dd> * <dd>Inserts content after the node</dd> }
else {
// create from string and cache if (
where.
nodeType) {
// insert regardless of relationship to node // TODO: check if node.contains(where)? if (
newNode) {
// allow empty content to clear node var ret =
'',
// TODO: return null? // workaround for IE8 JSON stringify bug // which converts empty string values to null return (
typeof ret ===
'string') ?
ret :
'';
* Brute force version of contains. * Used for browsers without contains support for non-HTMLElement Nodes (textNodes, etc). * @param {HTMLElement} element The containing html element. * @param {HTMLElement} needle The html element that may be contained. * @return {Boolean} Whether or not the element is or contains the needle. * Memoizes dynamic regular expressions to boost runtime performance. * @param {String} str The string to convert to a regular expression. * @param {String} flags optional An optinal string of flags. * @return {RegExp} An instance of RegExp * returns the appropriate document. * @param {HTMLElement} element optional Target element. * @return {Object} The document for the given element or the default document. * returns the appropriate window. * @param {HTMLElement} element optional Target element. * @return {Object} The window for the given element or the default window. // IE adds TBODY when creating TABLE elements (which may share this impl) // IE: node.value changes the button text, which should be handled via innerHTML return create(
'<select><option class="yui3-big-dummy" selected></option>' +
html +
'</select>',
doc);
// TODO: implement multipe select * Determines whether a DOM element has the given className. * @param {HTMLElement} element The DOM element. * @param {String} className the class name to search for * @return {Boolean} Whether or not the element has the given class. * Adds a class name to a given DOM element. * @param {HTMLElement} element The DOM element. * @param {String} className the class name to add to the class attribute * Removes a class name from a given element. * @param {HTMLElement} element The DOM element. * @param {String} className the class name to remove from the class attribute * Replace a class with another class for a given element. * If no oldClassName is present, the newClassName is simply added. * @param {HTMLElement} element The DOM element * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name * If the className exists on the node it is removed, if it doesn't exist it is added. * @param {HTMLElement} element The DOM element * @param {String} className the class name to be toggled * @param {Boolean} addClass optional boolean to indicate whether class * should be added or removed regardless of current state * Sets the width of the element to the given size, regardless * of box model, border, padding, etc. * @param {HTMLElement} element The DOM element. * @param {String|Int} size The pixel height to size to * Sets the height of the element to the given size, regardless * of box model, border, padding, etc. * @param {HTMLElement} element The DOM element. * @param {String|Int} size The pixel height to size to YUI.
add(
'dom-style',
function(Y) {
* Add style management functionality to DOM. * Sets a style property for a given element. * @param {HTMLElement} An HTMLElement to apply the style to. * @param {String} att The style property to set. * @param {String|Number} val The value. if (
val ===
null ||
val ===
'') {
// normalize unsetting * Returns the current style value for the given property. * @param {HTMLElement} An HTMLElement to get the style from. * @param {String} att The style property to get. if (
val ===
'') {
// TODO: is empty string sufficient? * Sets multiple style properties. * @param {HTMLElement} node An HTMLElement to apply the styles to. * @param {Object} hash An object literal of property:value pairs. * Returns the computed style for the given node. * @method getComputedStyle * @param {HTMLElement} An HTMLElement to get the style from. * @param {String} att The style property to get. * @return {String} The computed value of the style property. // normalize reserved word float alternatives ("cssFloat" or "styleFloat") // fix opera computedStyle default color unit (convert to rgb) // safari converts transparent to rgba(), others use "transparent" if (
val ===
'rgba(0, 0, 0, 0)') {
if (
attr ===
'left' ||
attr ===
'top') {
if (
isNaN(
xy[
0]) ) {
// in case of 'auto' if (
isNaN(
xy[
0]) ) {
// default to offset value if (
isNaN(
xy[
1]) ) {
// in case of 'auto' if (
isNaN(
xy[
1]) ) {
// default to offset value re_RGB: /^
rgb\(([
0-
9]+)\s*,\s*([
0-
9]+)\s*,\s*([
0-
9]+)\)$/i,
re_hex: /^#?([
0-
9A-F]{
2})([
0-
9A-F]{
2})([
0-
9A-F]{
2})$/i,
},
'@VERSION@' ,{
requires:[
'dom-base']});
YUI.
add(
'dom-screen',
function(Y) {
* Adds position and region management functionality to DOM. // TODO: does caption matter? * Returns the inner height of the viewport (exludes scrollbar). * @return {Number} The current height of the viewport. * Returns the inner width of the viewport (exludes scrollbar). * @return {Number} The current width of the viewport. * @return {Number} The current height of the document. * @return {Number} The current width of the document. * Amount page has been scroll horizontally * @return {Number} The current amount the screen is scrolled horizontally. * Amount page has been scroll vertically * @return {Number} The current amount the screen is scrolled vertically. * Gets the current position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @param element The target element * @return {Array} The XY position of the element // inline inDoc check for perf return function(
node) {
// manually calculate by crawling up offsetParents //Calculate the Top and Left border sizes (assumes pixels) // TODO: refactor with !! or just falsey // TODO: worth refactoring for TOP/LEFT only? // account for any scrolled ancestors //Firefox does something funky with borders when overflow is not visible. //Fix FIXED position -- add scrollbars }(),
// NOTE: Executing for loadtime branching * Gets the current X position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @param element The target element * @return {Int} The X position of the element * Gets the current Y position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @param element The target element * @return {Int} The Y position of the element * Set the position of an html element in page coordinates. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @param element The target element * @param {Array} xy Contains X & Y values for new position (coordinates are page-based) * @param {Boolean} noRetry By default we try and set the position a second time if the first fails if (
pos ==
'static') {
// default to relative * Set the X position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @param element The target element * @param {Int} x The X values for new position (coordinates are page-based) * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @param element The target element * @param {Int} y The Y values for new position (coordinates are page-based) * @description Swap the xy position with another node * @param {Node} node The node to swap with * @param {Node} otherNode The other node to swap with if (
mode !=
'CSS1Compat') {
// Quirks * Returns an Object literal containing the following about this element: (top, right, bottom, left) * @param {HTMLElement} element The DOM element. @return {Object} Object literal containing the following about this element: (top, right, bottom, left) * Find the intersect information for the passes nodes. * @param {HTMLElement} element The first element * @param {HTMLElement | Object} element2 The element or region to check the interect with * @param {Object} altRegion An object literal containing the region for the first element if we already have the data (for performance i.e. DragDrop) @return {Object} Object literal containing the following intersection data: (top, right, bottom, left, area, yoff, xoff, inRegion) * Check if any part of this node is in the passed region * @param {Object} node2 The node to get the region from or an Object literal of the region * $param {Boolean} all Should all of the node be inside the region * @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop) * @return {Boolean} True if in region, false if not. * Check if any part of this element is in the viewport * @method inViewportRegion * @param {HTMLElement} element The DOM element. * @param {Boolean} all Should all of the node be inside the region * @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop) * @return {Boolean} True if in region, false if not. * Returns an Object literal containing the following about the visible region of viewport: (top, right, bottom, left) * @return {Object} Object literal containing the following about the visible region of the viewport: (top, right, bottom, left) },
'@VERSION@' ,{
requires:[
'dom-base',
'dom-style',
'event-base']});
YUI.
add(
'selector-native',
function(Y) {
* The selector-native module provides support for native querySelector * @submodule selector-native * Provides support for using CSS selectors to query the DOM Y.
namespace(
'Selector');
// allow native module to standalone * Retrieves a set of nodes based on a given CSS selector. * @param {string} selector The CSS Selector to test the node against. * @param {HTMLElement} root optional An HTMLElement to start the query from. Defaults to Y.config.doc * @param {Boolean} firstOnly optional Whether or not to return only the first match. * @return {Array} An array of nodes that match the given selector. // split group into seperate queries if (!
firstOnly) {
// coerce DOM Collection to Array // allows element scoped queries to begin with combinator // e.g. query('> p', document.body) === query('body > p') // enforce for element scoping }
catch(e) {
// fallback to brute if available // we need a root if off-doc }
else {
// only use frag when no parent to query for (i =
0; (
group =
groups[i++]);) {
// TODO: off-dom test * A convenience function to emulate Y.Node's aNode.ancestor(selector). * @param {HTMLElement} element An HTMLElement to start the query from. * @param {String} selector The CSS selector to test the node against. * @return {HTMLElement} The ancestor node matching the selector, or null. * @param {Boolean} testSelf optional Whether or not to include the element in the scan },
'@VERSION@' ,{
requires:[
'dom-base']});
YUI.
add(
'selector-css2',
function(Y) {
* The selector module provides helper methods allowing CSS2 Selectors to be used with DOM elements. * @submodule selector-css2 * Provides helper methods for collecting and filtering DOM elements. pseudos: /:([\-\w]+(?:\(?:[
'"]?(.+)['"]?\)))*/i * Mapping of shorthand tokens to corresponding attribute selector '\\#(-?[_a-z]+[-\\w]*)': '[id=$1]', '\\.(-?[_a-z]+[-\\w]*)': '[className~=$1]' * List of operators and corresponding boolean functions. * These functions are passed the attribute and the current node's value of the attribute. '': function(node, attr) { return Y.DOM.getAttribute(node, attr) !== ''; }, // Just test for existence of attribute //'=': '^{val}$', // equality '~=': '(?:^|\\s+){val}(?:\\s+|$)', // space-delimited '|=': '^{val}-?' // optional hyphen-delimited 'first-child': function(node) { return Y.Selector._children(node[PARENT_NODE])[0] === node; _bruteQuery: function(selector, root, firstOnly) { tokens = Selector._tokenize(selector), token = tokens[tokens.length - 1], rootDoc = Y.DOM._getDoc(root), // if we have an initial ID, set to root when in document if (tokens[0] && rootDoc === root && rootDoc.getElementById(id)) { root = rootDoc.getElementById(id); className = token.className; tagName = token.tagName || '*'; if (root.getElementsByTagName) { // non-IE lacks DOM api on doc frags // try ID first, unless no root.all && root not in document // (root.all works off document, but not getElementById) // TODO: move to allById? if (id && (root.all || (root.nodeType === 9 || Y.DOM.inDoc(root)))) { nodes = Y.DOM.allById(id, root); nodes = root.getElementsByClassName(className); } else { // default to tagName nodes = root.getElementsByTagName(tagName); } else { // brute getElementsByTagName('*') if (child.tagName) { // only collect HTMLElements child = child.nextSilbing || child.firstChild; ret = Selector._filterNodes(nodes, tokens, firstOnly); _filterNodes: function(nodes, tokens, firstOnly) { getters = Y.Selector.getters, for (i = 0; (tmpNode = node = nodes[i++]);) { while (tmpNode && tmpNode.tagName) { while ((test = tests[--j])) { value = getters[test[0]](tmpNode, test[0]); value = tmpNode[test[0]]; // use getAttribute for non-standard attributes if (value === undefined && tmpNode.getAttribute) { value = tmpNode.getAttribute(test[0]); if ((operator === '=' && value !== test[2]) || // fast path for equality (typeof operator !== 'string' && // protect against String.test monkey-patch (Moo) operator.test && !operator.test(value)) || // regex test (!operator.test && // protect against RegExp as function (webkit) typeof operator === 'function' && !operator(tmpNode, test[0]))) { // function test // skip non element nodes or non-matching tags if ((tmpNode = tmpNode[path])) { (token.tagName && token.tagName !== tmpNode.tagName)) n--; // move to next token // now that we've passed the test, move up the tree by combinator if (!pass && (combinator = token.combinator)) { // skip non element nodes while (tmpNode && !tmpNode.tagName) { if (combinator.direct) { // one pass only } else { // success if we made it this far }// while (tmpNode = node = nodes[++i]); re: /^\[(-?[a-z]+[\w\-]*)+([~\|\^\$\*!=]=?)?['"]?([^\]]*?)[
'"]?\]/i, fn: function(match, token) { var operator = match[2] || '', operators = Y.Selector.operators, // add prefiltering for ID and CLASS if ((match[1] === 'id' && operator === '=
') || Y.config.doc.documentElement.getElementsByClassName && (operator === '~=
' || operator === '=
'))) { token.prefilter = match[1]; token[match[1]] = match[3]; if (operator in operators) { test = operators[operator]; if (typeof test === 'string') { match[3] = match[3].replace(Y.Selector._reRegExpTokens, '\\
$1'); test = Y.DOM._getRegExp(test.replace('{
val}
', match[3])); if (!token.last || token.prefilter !== match[1]) { re: /^((?:-?[_a-z]+[\w-]*)|\*)/i, fn: function(match, token) { var tag = match[1].toUpperCase(); if (tag !== '*
' && (!token.last || token.prefilter)) { return [TAG_NAME, '=
', tag]; fn: function(match, token) { re: /^:([\-\w]+)(?:\(['"]?(.+)['"]?\))*/i,
if (
test) {
// reorder match array }
else {
// selector token not supported (possibly missing CSS3 module) Break selector into token units per simple selector. Combinator is attached to the previous token. tokens = [],
// array of tokens found =
false,
// whether or not any matches were found this pass match,
// the regex match Search for selector patterns, store, and strip them from the selector string until no patterns match (invalid selector) or we run out of chars. Multiple attributes and pseudos are allowed, in any order. 'form:first-child[type=button]:not(button)[lang|=en]' found =
false;
// reset after full pass if (
test ===
false) {
// selector not supported // IE wants class with native queries },
'@VERSION@' ,{
requires:[
'selector-native']});
YUI.
add(
'selector',
function(Y){},
'@VERSION@' ,{
use:[
'selector-native',
'selector-css2']});
YUI.
add(
'dom',
function(Y){},
'@VERSION@' ,{
use:[
'dom-base',
'dom-style',
'dom-screen',
'selector']});
YUI.
add(
'event-custom-base',
function(Y) {
* Custom event engine, DOM event listener abstraction layer, synthetic DOM * Custom event engine, DOM event listener abstraction layer, synthetic DOM * @submodule event-custom-base * Allows for the insertion of methods that are executed before or after * Cache of objects touched by the utility * Execute the supplied method before the specified function * @param fn {Function} the function to execute * @param obj the object hosting the method to displace * @param sFn {string} the name of the method to displace * @param c The execution context for fn * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return {string} handle for the subscription * Execute the supplied method after the specified function * @param fn {Function} the function to execute * @param obj the object hosting the method to displace * @param sFn {string} the name of the method to displace * @param c The execution context for fn * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return {string} handle for the subscription * Execute the supplied method after the specified function * @param when {string} before or after * @param fn {Function} the function to execute * @param obj the object hosting the method to displace * @param sFn {string} the name of the method to displace * @param c The execution context for fn * @return {string} handle for the subscription // create a map entry for the obj if it doesn't exist // create a map entry for the method if it doesn't exist // re-route the method to our wrapper * Detach a before or after subscription * @param handle {string} the subscription handle ////////////////////////////////////////////////////////////////////////// * Wrapper for a displaced method with aop enabled * @param obj The object to operate on * @param sFn The name of the method to displace * Register a aop subscriber * @param sid {string} the subscriber id * @param fn {Function} the function to execute * @param when {string} when to execute the function * Unregister a aop subscriber * @param sid {string} the subscriber id * @param fn {Function} the function to execute * @param when {string} when to execute the function * Execute the wrapped method // execute after methods. // Stop processing if a Halt object is returned // Check for a new return value ////////////////////////////////////////////////////////////////////////// * Return an AlterArgs object when you want to change the arguments that * were passed into the function. An example would be a service that scrubs * out illegal characters prior to executing the core business logic. * Return an AlterReturn object when you want to change the result returned * from the core method to the caller * Return a Halt object when you want to terminate the execution * of all subsequent subscribers as well as the wrapped method * if it has not exectued yet. * Return a Prevent object when you want to prevent the wrapped function * from executing, but want the remaining listeners to execute * Return an Error object when you want to terminate the execution * of all subsequent method calls. * @deprecated use Y.Do.Halt or Y.Do.Prevent ////////////////////////////////////////////////////////////////////////// // Y["Event"] && Y.Event.addListener(window, "unload", Y.Do._unload, Y.Do); * Custom event engine, DOM event listener abstraction layer, synthetic DOM * @submodule event-custom-base * Return value from all subscribe operations * @param evt {CustomEvent} the custom event * @param sub {Subscriber} the subscriber // var onsubscribeType = "_event:onsub", Y.
Array.
each(
this.
evt,
function(h) {
* Detaches this subscriber * Monitor the event state for the subscribed event. The first parameter * is what should be monitored, the rest are the normal parameters when * subscribing to an event. * @param what {string} what to monitor ('attach', 'detach', 'publish') * @return {EventHandle} return value from the monitor event subscription * 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 * @param o configuration object // if (arguments.length > 2) { // this.log('CustomEvent context and silent are now in the config', 'warn', 'Event'); * The type of event, returned to subscribers when the event fires * The context the the event will fire from by default. Defaults to the YUI * Monitor when an event is attached or detached. // this.monitored = false; * If 0, this event does not broadcast. If 1, the YUI instance is notified * every time this event fires. If 2, the YUI instance and the YUI global * (if event is enabled on the global) are notified every time this event * By default all custom events are logged in the debug build, set silent * to true to disable debug outpu for this event. * Specifies whether this event should be queued when the host is actively * processing an event. This will effect exectution order of the callbacks * for the various events. // this.queuable = false; * The subscribers to this event * This event has fired if true * An array containing the arguments the custom event * This event should only fire one time if true, and if * it has fired, any new subscribers should be notified // this.fireOnce = false; * fireOnce listeners will fire syncronously unless async * Flag for stopPropagation that is modified during fire() * 1 means to stop propagation to bubble targets. 2 means * to also stop additional subscribers on this target. * Flag for preventDefault that is modified during fire(). * if it is not 0, the default behavior for this event * Specifies the host for this custom event. This is used * to enable event bubbling * The default function to execute after event listeners * have fire, but only if the default action was not // this.defaultFn = null; * The function to execute if a subscriber calls * stopPropagation or stopImmediatePropagation // this.stoppedFn = null; * The function to execute if a subscriber calls // this.preventedFn = null; * Specifies whether or not this event's default function * can be cancelled by a subscriber by executing preventDefault() * Specifies whether or not a subscriber can stop the event propagation * via stopPropagation(), stopImmediatePropagation(), or halt() * Events can only bubble if emitFacade is true. * Supports multiple options for listener signatures in order to // this.hasSubscribers = false; // this.hasAfters = false; * If set to true, the custom event will deliver an EventFacade object * that is similar to a DOM event object. // this.emitFacade = false; // this.log("Creating " + this.type); return (
when ==
'after') ? a : s;
* Monitor the event state for the subscribed event. The first parameter * is what should be monitored, the rest are the normal parameters when * subscribing to an event. * @param what {string} what to monitor ('detach', 'attach', 'publish') * @return {EventHandle} return value from the monitor event subscription * Get all of the subscribers to this event and any sibling event * @return {Array} first item is the on subscribers, second the after * Apply configuration properties. Only applies the CONFIG whitelist * @param o hash of properties to apply * @param force {boolean} if true, properties that exist on the event this.
log(
"Invalid callback for CE: " +
this.
type);
* @param {Function} fn The function to execute * @return {EventHandle} Unsubscribe handle * @param {Function} fn The function to execute * @param context {object} optional execution context. * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return {EventHandle} An object with a detach method to detch the handler(s) * Listen for this event after the normal subscribers have been notified and * the default behavior has been applied. If a normal subscriber prevents the * default behavior, it also prevents after listeners from firing. * @param {Function} fn The function to execute * @param context {object} optional execution context. * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return {EventHandle} handle Unsubscribe handle * @param {Function} fn The subscribed function to remove, if not supplied * @param {Object} context The context object passed to subscribe. * @return {int} returns the number of subscribers unsubscribed if (s && (!
fn ||
fn === s.
fn)) {
* @param {Function} fn The subscribed function to remove, if not supplied * @param {Object} context The context object passed to subscribe. * @return {int|undefined} returns the number of subscribers unsubscribed * Notify a single subscriber * @param s {Subscriber} the subscriber * @param args {Array} the arguments array to apply to the listener this.
log(
this.
type +
" cancelled by subscriber");
* Logger abstraction to centralize the application of the silent flag * @param msg {string} message to log * @param cat {string} log category * Notifies the subscribers. The callback functions will be executed * from the context specified when the event was created, and with the * <li>The type of event</li> * <li>All of the arguments fire() was executed with as an array</li> * <li>The custom object (if any) that was passed into the subscribe() * @param {Object*} arguments an arbitrary set of parameters to pass to * @return {boolean} false if one of the subscribers returned false, this.
log(
'fireOnce event: ' +
this.
type +
' already fired');
// this doesn't happen if the event isn't published // this.host._monitor('fire', this.type, args); // this._procSubs(Y.merge(this.subscribers, this.afters), args); return this.
stopped ?
false :
true;
// Requires the event-custom-complex module for full funcitonality. * @return {int} The number of listeners unsubscribed * @deprecated use detachAll * @return {int} The number of listeners unsubscribed * @param subscriber object ///////////////////////////////////////////////////////////////////// * Stores the subscriber information to be used when the event fires. * @param {Function} fn The wrapped function to execute * @param {Object} context The value of the keyword 'this' in the listener * @param {Array} args* 0..n additional arguments to supply the listener * The callback that will be execute when the event fires * This is wrapped by Y.rbind if obj was supplied. * Optional 'this' keyword for the listener * Additional arguments to propagate to the subscriber * Custom events for a given fire transaction. * This listener only reacts to the event once * Executes the subscriber. * @param args {Array} Arguments array for the subscriber * @param ce {CustomEvent} The custom event that sent the notification // only catch errors if we will not re-throw them. * Returns true if the fn and obj match this objects properties. * Used by the unsubscribe method to match the right subscriber. * @param {Function} fn the function to execute * @param {Object} context optional 'this' keyword for the listener * @return {boolean} true if the supplied arguments match this * subscriber's signature. * Custom event engine, DOM event listener abstraction layer, synthetic DOM * @submodule event-custom-base * EventTarget provides the implementation for any object to * publish, subscribe and fire to custom events, and also * alows other EventTargets to target the object with events * sourced from the other object. * EventTarget is designed to be used with Y.augment to wrap * EventCustom in an interface that allows events to be listened 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 * @param opts a configuration object * @config emitFacade {boolean} if true, all events will emit event * facade payloads by default (default false) * @config prefix {string} the prefix to apply to non-prefixed event names * @config chain {boolean} if true, on/after/detach return the host to allow * chaining, otherwise they return an EventHandle (default false) * If the instance has a prefix attribute and the * event type is not prefixed, the instance prefix is * applied to the supplied type. * Returns an array with the detach key (if provided), * and the prefixed event name from _getType * Y.on('detachcategory| menu:click', fn) // detach category, full type with instance prefix, is this an after listener, short type * Listen to a custom event hosted by this object one time. * This is the equivalent to <code>on</code> except the * listener is immediatelly detached when it is executed. * @param type {string} The type of the event * @param fn {Function} The callback * @param context {object} optional execution context. * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return the event target or a detach handle per 'chain' config * Subscribe to a custom event hosted by this object * @param type {string} The type of the event * @param fn {Function} The callback * @param context {object} optional execution context. * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return the event target or a detach handle per 'chain' config // full name, args, detachcategory, after // extra redirection so we catch adaptor events too. take a look at this. if (
this instanceof YUI) {
}
else if (n
instanceof Node) {
// Captures both DOM events and event plugins. // check for the existance of an event adaptor * Detach one or more listeners the from the specified event * @param type {string|Object} Either the handle to the subscriber or the * type of event. If the type * is not specified, it will attempt to remove * the listener from all hosted events. * @param fn {Function} The subscribed function to unsubscribe, if not * supplied, all subscribers will be removed. * @param context {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 {EventTarget} the host // detachAll disabled on the Y instance. if (!
type && (
this !== Y)) {
// If this is an event handle, use it to detach // extra redirection so we catch adaptor events too. take a look at this. // The YUI instance handles DOM events and adaptors if (
this instanceof YUI) {
// use the adaptor specific detach code if * Removes all listeners from the specified event. If the event type * is not specified, all listeners from all hosted custom events will * @param type {string} The type, or name of the event * Removes all listeners from the specified event. If the event type * is not specified, all listeners from all hosted custom events will * @param type {string} The type, or name of the event * @deprecated use detachAll * 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. * @param type {string} the type, or name of the event * @param opts {object} optional config params. Valid properties are: * 'broadcast': whether or not the YUI instance and YUI global are notified when the event is fired (false) * 'bubbles': whether or not this event bubbles (true) * Events can only bubble if emitFacade is true. * 'context': the default execution context for the listeners (this) * 'defaultFn': the default function to execute when this event fires if preventDefault was not called * 'emitFacade': whether or not this event emits a facade (false) * 'prefix': the prefix for this targets events, e.g., 'menu' in 'menu:click' * 'fireOnce': if an event is configured to fire once, new subscribers after * the fire will be notified immediately. * 'async': fireOnce event listeners will fire synchronously if the event has already * fired unless async is true. * 'preventable': whether or not preventDefault() has an effect (true) * 'preventedFn': a function that is executed when preventDefault is called * 'queuable': whether or not this event can be queued during bubbling (false) * 'silent': if silent is true, debug messages are not provided for this event. * 'stoppedFn': a function that is executed when stopPropagation is called * 'monitored': specifies whether or not this event should send notifications about * when the event has been attached, detached, or published. * 'type': the event type (valid option if not provided as the first parameter to publish) * @return {CustomEvent} the custom event // ce.log("publish applying new config to published event: '"+type+"' exists", 'info', 'event'); // make sure we turn the broadcast flag off if this // event was published as a result of bubbling // if (opts instanceof Y.CustomEvent) { // events[type].broadcast = false; * This is the entry point for the event monitoring system. * You can monitor 'attach', 'detach', 'fire', and 'publish'. * When configured, these events generate an event. click -> * click_attach, click_detach, click_publish -- these can * be subscribed to like other events to monitor the event * system. Inividual published events can have monitoring * turned on or off (publish can't be turned off before it * it published) by setting the events 'monitor' config. * Fire a custom event by name. The callback functions will be executed * from the context specified when the event was created, and with the * If the custom event object hasn't been created, then the event hasn't * been published and it has no subscribers. For performance sake, we * immediate exit in this case. This means the event won't bubble, so * if the intention is that a bubble target be notified, the event must * be published on this object first. * The first argument is the event type, and any additional arguments are * passed to the listeners as parameters. If the first of these is an * object literal, and the event is configured to emit an event facade, * that object is mixed into the event facade and the facade is provided * in place of the original object. * @param type {String|Object} The type of the event, or an object that contains * @param arguments {Object*} an arbitrary set of parameters to pass to * the handler. If the first of these is an object literal and the event is * configured to emit an event facade, the event facade will replace that * parameter after the properties the object literal contains are copied to * @return {EventTarget} the event host // this event has not been published or subscribed to // otherwise there is nothing to be done // delegate to *:type events if there are subscribers // console.log("GOT ONE: " + type); // ret = ce2.fire.apply(ce2, a); * Returns the custom event of the provided type has been created, a * @param type {string} the type, or name of the event * @param prefixed {string} if true, the type is prefixed already * @return {CustomEvent} the custom event or null * Subscribe to a custom event hosted by this object. The * supplied callback will execute after any listeners add * via the subscribe method, and after the default function, * if configured for the event, has executed. * @param type {string} The type of the event * @param fn {Function} The callback * @param context {object} optional execution context. * @param arg* {mixed} 0..n additional arguments to supply to the subscriber * @return the event target or a detach handle per 'chain' config // YArray.each(a[0], function(v) { * 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, 0-n arguments * callback, object (method host), methodName, context, 0-n arguments // make Y an event target * Hosts YUI page level events. This is where events bubble to * when the broadcast config is set to 2. This property is * only available if the custom event module is loaded. // @TODO implement a global namespace function on Y.Global? * <code>YUI</code>'s <code>on</code> method is a unified interface for subscribing to * most events exposed by YUI. This includes custom events, DOM events, and * function events. <code>detach</code> is also provided to remove listeners * serviced by this function. * The signature that <code>on</code> accepts varies depending on the type * of event being consumed. Refer to the specific methods that will * service a specific request for additional information about subscribing * <li>Custom events. These events are defined by various * modules in the library. This type of event is delegated to * <code>EventTarget</code>'s <code>on</code> method. * <li>The type of the event</li> * <li>The callback to execute</li> * <li>An optional context object</li> * <li>0..n additional arguments to supply the callback.</li> * <code>Y.on('drag:drophit', function() { // start work });</code> * <li>DOM events. These are moments reported by the browser related * to browser functionality and user interaction. * This type of event is delegated to <code>Event</code>'s * <code>attach</code> method. * <li>The type of the event</li> * <li>The callback to execute</li> * <li>The specification for the Node(s) to attach the listener * to. This can be a selector, collections, or Node/Element * <li>An optional context object</li> * <li>0..n additional arguments to supply the callback.</li> * <code>Y.on('click', function(e) { // something was clicked }, '#someelement');</code> * <li>Function events. These events can be used to react before or after a * function is executed. This type of event is delegated to <code>Event.Do</code>'s * <code>before</code> method. * <li>The callback to execute</li> * <li>The object that has the function that will be listened for.</li> * <li>The name of the function to listen for.</li> * <li>An optional context object</li> * <li>0..n additional arguments to supply the callback.</li> * Example <code>Y.on(function(arg1, arg2, etc) { // obj.methodname was executed }, obj 'methodname');</code> * <code>on</code> corresponds to the moment before any default behavior of * the event. <code>after</code> works the same way, but these listeners * execute after the event's default behavior. <code>before</code> is an * alias for <code>on</code>. * @param type event type (this parameter does not apply for function events) * @param context optionally change the value of 'this' in the callback * @param args* 0..n additional arguments to pass to the callback. * @return the event target or a detach handle per 'chain' config * Listen for an event one time. Equivalent to <code>on</code>, except that * the listener is immediately detached when executed. * @param type event type (this parameter does not apply for function events) * @param context optionally change the value of 'this' in the callback * @param args* 0..n additional arguments to pass to the callback. * @return the event target or a detach handle per 'chain' config * after() is a unified interface for subscribing to * most events exposed by YUI. This includes custom events, * DOM events, and AOP events. This works the same way as * the on() function, only it operates after any default * behavior for the event has executed. @see <code>on</code> for more * @param type event type (this parameter does not apply for function events) * @param context optionally change the value of 'this' in the callback * @param args* 0..n additional arguments to pass to the callback. * @return the event target or a detach handle per 'chain' config * DOM event listener abstraction layer // Unlike most of the library, this code has to be executed as soon as it is // introduced into the page -- and it should only be executed one time // regardless of the number of instances that use it. // Internet Explorer: use the doScroll() method on the root element. This isolates what // appears to be a safe moment to manipulate the DOM prior to when the document's readyState // suggests it is safe to do so. }
else {
// FireFox, Opera, Safari 3+ provide an event for this moment.YUI.
add(
'event-base',
function(Y) {
* DOM event listener abstraction layer * The domready event fires at the moment the browser's DOM is * usable. In most cases, this is before images are fully * downloaded, allowing you to provide a more responsive user * In YUI 3, domready subscribers will be notified immediately if * that moment has already passed when the subscription is created. * One exception is if the yui.js file is dynamically injected into * the page. If this is done, you must tell the YUI instance that * you did this in order for DOMReady (and window load events) to * fire normally. That configuration option is 'injected' -- set * it to true if the yui.js script is not included inline. * This method is part of the 'event-ready' module, which is a // console.log('DOMReady already fired', 'info', 'event'); // console.log('setting up before listener', 'info', 'event'); // console.log('env: ' + YUI.Env.windowLoaded, 'info', 'event'); * Custom event engine, DOM event listener abstraction layer, synthetic DOM * Wraps a DOM event, properties requiring browser abstraction are * fixed here. Provids a security layer when required. * @param ev {Event} the DOM event * @param currentTarget {HTMLElement} the element the listener was attached to * @param wrapper {Event.Custom} the custom event wrapper for this DOM event * @TODO constants? LEFTBUTTON, MIDDLEBUTTON, RIGHTBUTTON, keys // "button" : 1, // we supply // "bubbles" : 1, // needed? // "cancelable" : 1, // needed? // "charCode" : 1, // we supply // "currentTarget" : 1, // we supply detail : 1, // not fully implemented // "height" : 1, // needed? // "initEvent" : 1, // need the init events? // "layerX" : 1, // needed? // "layerY" : 1, // needed? // "modifiers" : 1, // needed? // "offsetX" : 1, // needed? // "offsetY" : 1, // needed? // "preventDefault" : 1, // we supply // "reason" : 1, // IE proprietary // "returnValue" : 1, // needed? // "srcUrn" : 1, // IE proprietary // "srcFilter" : 1, IE proprietary // "stopPropagation" : 1, // we supply // "timeStamp" : 1, // needed? // "which" : 1, // we supply // "width" : 1, // needed? * webkit key remapping required for Safari < 3.1 25:
9,
// SHIFT-TAB (Safari provides a different key code in // this case, even though the shiftKey modifier is set) * Returns a wrapped node. Intended to be used on event targets, * so it will return the node's parent if the target is a text * If accessing a property of the node throws an error, this is * probably the anonymous div wrapper Gecko adds inside text * nodes. This likely will only occur when attempting to access * the relatedTarget. In this case, we now return null because * the anonymous div is completely useless and we do not know * what the related target was because we can't even get to * the element's parent node. // provide a single event with browser abstractions resolved // include all properties for both browers? // include only DOM2 spec properties? // provide browser-specific facade? ////////////////////////////////////////////////////// if ((
'clientX' in e) && (!x) && (
0 !== x)) {
* The X location of the event on the page (including scroll) * The Y location of the event on the page (including scroll) ////////////////////////////////////////////////////// * The keyCode for key events. Uses charCode if keyCode is not available * The charCode for key events. Same as keyCode ////////////////////////////////////////////////////// * The button that was pushed. * The button that was pushed. Same as button. ////////////////////////////////////////////////////// * Node reference for the targeted element * Node reference for the element that the listener was attached to. if (e.
type ==
"mouseout") {
}
else if (e.
type ==
"mouseover") {
* Node reference to the relatedTarget * Number representing the direction and velocity of the movement of the mousewheel. * Negative is down, the higher the number, the faster. Applies to the mousewheel event. if (e.
type ==
"mousewheel" || e.
type ==
"DOMMouseScroll") {
////////////////////////////////////////////////////// * Stops the propagation to the next bubble target * @method stopPropagation * Stops the propagation to the next bubble target and * prevents any additional listeners from being exectued * @method stopImmediatePropagation * Prevents the event's default behavior * @param returnValue {string} sets the returnValue of the event to this value * (rather than the default false value). This can be used to add a customized * confirmation query to the beforeunload event). * Stops the event propagation and prevents the default * @param immediate {boolean} if true additional listeners * on the current target will not be executed * DOM event listener abstraction layer * The event utility provides functions to add and remove event listeners, * event cleansing. It also tries to automatically remove listeners it * registers during the unload event. * True after the onload event has fired * @property _loadComplete * The number of times to poll after window.onload. This number is * increased if additional late-bound handlers are requested after * Custom event wrappers for DOM events. Key is * 'event:' + Element uid stamp + event type * Custom event wrapper map DOM events. Key is * Element uid stamp. Each item is a hash of custom event * wrappers as provided in the _wrappers collection. This * provides the infrastructure for getListeners. * The number of times we should look for elements that are not * in the DOM at the time the event is requested after the document * has been loaded. The default is 1000@amp;40 ms, so it will poll * for 40 seconds or until all outstanding handlers are bound * (whichever comes first). * The poll interval in milliseconds * @property POLL_INTERVAL * These errors are suppressed, the method returns false, and this property * document readystate poll handle * True when the document is initially usable * Executes the supplied callback when the item with the supplied * id is found. This is meant to be used to execute behavior as * soon as possible as the page loads. If you use this after the * initial page load it will poll for a fixed time for the element. * The number of times it will poll and the frequency are * configurable. By default it will poll for 10 seconds. * <p>The callback is executed with a single parameter: * the custom object parameter, if provided.</p> * @param {string||string[]} id the id of the element, or an array * @param {function} fn what to execute when the element is found. * @param {object} p_obj an optional object to be passed back as * @param {boolean|object} p_override If set to true, fn will execute * in the context of p_obj, if set to an object it * will execute in the context of that object * @param checkContent {boolean} check child node readiness (onContentReady) * @deprecated Use Y.on("available") for (i=
0; i<a.
length; i=i+
1) {
// We want the first test to be immediate, but async // set by the event system for lazy DOM listeners // otherwise try to remove the onAvailable listener(s) for (i =
0; i < a.
length; i++) {
* 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. * <p>The callback is executed with a single parameter: * the custom object parameter, if provided.</p> * @param {string} id the id of the element to look for. * @param {function} fn what to execute when the element is ready. * @param {object} p_obj an optional object to be passed back as * @param {boolean|object} p_override If set to true, fn will execute * in the context of p_obj. If an object, fn will * exectute in the context of that object * @deprecated Use Y.on("contentready") * @param {String} type The type of event to append * @param {Function} fn The method the event invokes * @param {String|HTMLElement|Array|NodeList} el An id, an element * reference, or a collection of ids and/or elements to assign the * @param {Object} context optional context object * @param {Boolean|object} args 0..n arguments to pass to the callback * @return {EventHandle} an object to that can be used to detach the listener // for later removeListener calls // window load happens once // throw new TypeError(type + " attach call failed, callback undefined"); // The el argument can be an array of elements or element ids. // return (handles.length === 1) ? handles[0] : handles; // If the el argument is a string, we assume it is // actually the id of the element. If the page is loaded // we convert el to the actual element, otherwise we // defer attaching the event until the element is // oEl = (compat) ? Y.DOM.byId(el) : Y.Selector.query(el); // Not found = defer adding the event until the element is available // Element should be an html element or node // if the load is complete, fire immediately. // all subscribers, including the current one // set context to the Node if not specified // ret = cewrapper.on.apply(cewrapper, trimmedArgs); * Removes an event listener. Supports the signature the event was bound * with, but the preferred way to remove listeners is using the handle * that is returned when using Y.on * @param {String} type the type of event to remove. * @param {Function} fn the method the event invokes. If fn is * undefined, then all event handlers for the type of event are * @param {String|HTMLElement|Array|NodeList|EventHandle} el An * event handle, an id, an element reference, or a collection * of ids and/or elements to remove the listener from. * @return {boolean} true if the unbind was successful, false otherwise. // The el argument can be a string if (
typeof el ==
"string") {
// el = (compat) ? Y.DOM.byId(el) : Y.all(el); // return Event.detach.apply(Event, args); // The el argument can be an array of elements or element ids. * Finds the event in the window object, the caller's arguments, or * in the arguments of another method in the callstack. This is * executed automatically for events registered through the event * manager, so the implementer should not normally need to execute * @param {Event} e the event parameter from the handler * @param {HTMLElement} el the element the listener was attached to * @return {Event} the event * Generates an unique ID for the element if it does not already * @param el the element to create the id for * @return {string} the resulting id of the element * We want to be able to use getElementsByTagName as a collection * to attach a group of events to. Unfortunately, different * browsers return different types of collections. This function * tests to determine if the object is array-like. It will also * fail if the object is an array, but is empty. * @method _isValidCollection * @param o the object to test * @return {boolean} true if the object is array-like and populated * @deprecated was not meant to be used directly * hook up any deferred listeners // Just in case DOMReady did not go off for some reason // Available elements may not have been detected before the // window load event fires. Try to find them now so that the // the user is more likely to get the onAvailable notifications // before the window load notification * Polling function that runs before the onload event fires, * attempting to attach to DOM Nodes as soon as they are // Hold off if DOMReady has not fired and check current // readyState to protect against the IE operation aborted // keep trying until after the page is loaded. We need to // check the page load state prior to trying to bind the // elements so that we can be certain all elements have been // el = (item.compat) ? Y.DOM.byId(item.id) : Y.one(item.id); // el = (item.compat) ? Y.DOM.byId(item.id) : Y.one(item.id); // The element is available, but not necessarily ready // @todo should we test parentNode.nextSibling? // we may need to strip the nulled out items here * Removes all listeners attached to the given element via addListener. * Optionally, the node's children can also be purged. * Optionally, you can specify a specific type of event to remove. * @param {HTMLElement} el the element to purge * @param {boolean} recurse recursively purge this element's children * as well. Use with caution. * @param {string} type optional type of listener to purge. If * left out, all listeners will be removed // var oEl = (Y.Lang.isString(el)) ? Y.one(el) : el, * Returns all listeners attached to the given element via addListener. * Optionally, you can specify a specific type of event to return. * @param el {HTMLElement|string} the element or element id to inspect * @param type {string} optional type of listener to return. If * left out, all listeners will be returned * @return {Y.Custom.Event} the custom event wrapper for the DOM event(s) // look for synthetic events // get native events as well * Removes all listeners registered by pe.event. Called * automatically during the unload event. * Adds a DOM event directly without the caching, cleanup, context adj, etc * @param {HTMLElement} el the element to bind the handler to * @param {string} type the type of event handler * @param {function} fn the callback to invoke * @param {boolen} capture capture or bubble phase * @param {HTMLElement} el the element to bind the handler to * @param {string} type the type of event handler * @param {function} fn the callback to invoke * @param {boolen} capture capture or bubble phase * DOM event listener abstraction layer * Executes the callback as soon as the specified element * is detected in the DOM. * @param type {string} 'available' * @param fn {function} the callback function to execute. * @param el {string|HTMLElement|collection} the element(s) to attach * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle * 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) * @param type {string} 'contentready' * @param fn {function} the callback function to execute. * @param el {string|HTMLElement|collection} the element(s) to attach * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle },
'@VERSION@' ,{
requires:[
'event-custom-base']});
YUI.
add(
'pluginhost',
function(Y) {
* Provides the augmentable PluginHost interface, which can be added to any class. * An augmentable class, which provides the augmented class with the ability to host plugins. * It adds <a href="#method_plug">plug</a> and <a href="#method_unplug">unplug</a> methods to the augmented class, which can * be used to add or remove plugins from instances of the class. * <p>Plugins can also be added through the constructor configuration object passed to the host class' constructor using * the "plugins" property. Supported values for the "plugins" property are those defined by the <a href="#method_plug">plug</a> method. * For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host): * var o = new Overlay({plugins: [ AnimPlugin, {fn:IOPlugin, cfg:{section:"header"}}]}); * Plug.Host's protected <a href="#method_initPlugins">_initPlugins</a> and <a href="#method_destroyPlugins">_destroyPlugins</a> * methods should be invoked by the host class at the appropriate point in the host's lifecyle. * Adds a plugin to the host object. This will instantiate the * plugin and attach it to the configured namespace on the host object. * @param p {Function | Object |Array} Accepts the plugin class, or an * object with a "fn" property specifying the plugin class and * a "cfg" property specifying the configuration for the Plugin. * Additionally an Array can also be passed in, with the above function or * object values, allowing the user to add multiple plugins in a single call. * @param config (Optional) If the first argument is the plugin class, the second argument * can be the configuration for the plugin. * @return {Base} A reference to the host object * Removes a plugin from the host object. This will destroy the * plugin instance and delete the namepsace from the host object. * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided, * all registered plugins are unplugged. * @return {Base} A reference to the host object * Determines if a plugin has plugged into this host. * @param {String} ns The plugin's namespace * @return {boolean} returns true, if the plugin has been plugged into this host, false otherwise. * Initializes static plugins registered on the host (using the * Base.plug static method) and any plugins passed to the * instance through the "plugins" configuration property. * @param {Config} config The configuration object with property name/value pairs. * Unplugs and destroys all plugins on the host * @method _destroyPlugins * Private method used to instantiate and attach plugins to the host * @param {Function} PluginClass The plugin class to instantiate * @param {Object} config The configuration object for the plugin * Unplugs and destroys a plugin already instantiated with the host. * @param {String | Function} plugin The namespace for the plugin, or a plugin class with the static NS property defined. * Registers plugins to be instantiated at the class level (plugins * which should be plugged into every instance of the class by default). * @method Plugin.Host.plug * @param {Function} hostClass The host class on which to register the plugins * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined) * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin // Cannot plug into Base, since Plugins derive from Base [ will cause infinite recurrsion ] * Unregisters any class level plugins which have been registered by the host class, or any * other class in the hierarchy. * @method Plugin.Host.unplug * @param {Function} hostClass The host class from which to unregister the plugins * @param {Function | Array} plugin The plugin class, or an array of plugin classes },
'@VERSION@' ,{
requires:[
'yui-base']});
YUI.
add(
'node-base',
function(Y) {
* The Node Utility provides a DOM-like interface for interacting with DOM nodes. * The Node class provides a wrapper for manipulating DOM Nodes. * Node properties can be accessed via the set/get methods. * Use Y.get() to retrieve Node instances. * <strong>NOTE:</strong> Node properties are accessed using * the <code>set</code> and <code>get</code> methods. * @param {DOMNode} node the DOM node to be mapped to the Node instance. node[
UID] =
null;
// unset existing uid to prevent collision (via clone or hack) if (!
uid) {
// stamp failed; likely IE non-HTMLElement * The underlying DOM node bound to the Y.Node instance ret = (
typeof fn ===
'string') ?
* The name of the component * The pattern used to identify ARIA attributes * List of events that route to DOM events // Add custom event adaptors to this list. This will make it so // that delegate, key, available, contentready, etc all will // be available through Node.on * A list of Node instances that have been created * Retrieves the DOM node bound to a Node instance * @param {Y.Node || HTMLNode} node The Node instance or an HTMLNode * @return {HTMLNode} The DOM node bound to the Node instance. If a DOM node is passed * as the node argument, it is simply returned. * Checks Node return values and wraps DOM Nodes as Y.Node instances * and DOM Collections / Arrays as Y.NodeList instances. * Other return values just pass thru. If undefined is returned (e.g. no return) * then the Node instance is returned for chainability. * @param {any} node The Node instance or an HTMLNode * @return {Y.Node | Y.NodeList | any} Depends on what is returned from the DOM node. if (
node &&
val) {
// only truthy values are risky if (
typeof val ===
'object' ||
typeof val ===
'function') {
// safari nodeList === function }
else if (
val ===
null) {
val =
null;
// IE: DOM null not the same as null * Adds methods to the Y.Node prototype, routing through scrubVal. * @param {String} name The name of the method to add * @param {Function} fn The function that becomes the method * @param {Object} context An optional context to call the method with * (defaults to the Node instance) * @return {any} Depends on what is returned from the DOM node. if (
name &&
fn &&
typeof fn ===
'function') {
* Imports utility methods to be added as Y.Node methods. * @param {Object} host The object that contains the method to import. * @param {String} name The name of the method to import * @param {String} altName An optional name to use in place of the host name * @param {Object} context An optional context to call the method with if (
typeof name ===
'string') {
* Returns a single Node instance bound to the node or the * first element matching the given selector. Returns null if no match found. * <strong>Note:</strong> For chaining purposes you may want to * use <code>Y.all</code>, which returns a NodeList when no match is found. * @param {String | HTMLElement} node a node or Selector * @return {Y.Node | null} a Node instance or null if no match found. if (
typeof node ===
'string') {
}
else if (
node.
indexOf(
'win') ===
0) {
// win OR window return node;
// NOTE: return * Returns a single Node instance bound to the node or the * first element matching the given selector. * @param {String | HTMLElement} node a node or Selector * @param {Y.Node || HTMLElement} doc an optional document to scan. Defaults to Y.config.doc. * Creates a new dom node using the provided markup string. * @param {String} html The markup used to create the element * @param {HTMLDocument} doc An optional document context * @return {Node} A Node instance bound to a DOM node or fragment * Static collection of configuration attributes for special handling * Allows for getting and setting the text of an element. * Formatting is preserved and special characters are treated literally. * Returns a NodeList instance of all HTMLElement children. * Flat data store for off-DOM usage * The default setter for DOM properties * Called with instance context (this === the Node instance) * @param {any} val The value to be set * @return {any} The value // only allow when defined on node * The default getter for DOM properties * Called with instance context (this === the Node instance) * @return {any} The current value // Basic prototype augment - no lazy constructor invocation. * The method called when outputting Node instances as strings * @return {String} A string representation of the Node instance var str =
this[
UID] +
': not bound to a node',
* Returns an attribute value on the Node instance. * Unless pre-configured (via Node.ATTRS), get hands * off to the underlying DOM node. Only valid * @param {String} attr The attribute * @return {any} The current value of the attribute if (
this.
_getAttr) {
// use Attribute imple }
else if (
val ===
null) {
val =
null;
// IE: DOM null is not true null (even though they ===) * @param {String} attr The attribute * @return {any} The current value of the attribute * Sets an attribute on the Node instance. * Unless pre-configured (via Node.ATTRS), set hands * off to the underlying DOM node. Only valid * To set custom attributes use setAttribute. * @param {String} attr The attribute to be set. * @param {any} val The value to set the attribute to. if (
this.
_setAttr) {
// use Attribute imple }
else {
// use setters inline * Sets multiple attributes. * @param {Object} attrMap an object of name/value pairs to set }
else {
// use setters inline * Returns an object containing the values for the requested attributes. * @param {Array} attrs an array of attributes to get values * @return {Object} An object with attribute name/value pairs. }
else {
// use setters inline * Creates a new Node using the provided markup string. * @param {String} html The markup used to create the element * @param {HTMLDocument} doc An optional document context * @return {Node} A Node instance bound to a DOM node or fragment * Compares nodes to determine if they match. * Node instances can be compared to each other and/or HTMLElements. * @param {HTMLElement | Node} refNode The reference node to compare to the node. * @return {Boolean} True if the nodes match, false if they do not. * Determines whether the node is appended to the document. * @param {Node|HTMLElement} doc optional An optional document to check against. * Defaults to current document. * @return {Boolean} Whether or not this node is appended to the document. * Returns the nearest ancestor that passes the test applied by supplied boolean method. * @param {String | Function} fn A selector string or boolean method for testing elements. * @param {Boolean} testSelf optional Whether or not to include the element in the scan * If a function is used, it receives the current node being tested as the only argument. * @return {Node} The matching Node instance or null if not found * Returns the previous matching sibling. * Returns the nearest element node sibling if no method provided. * @param {String | Function} fn A selector or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * @return {Node} Node instance or null if not found * Returns the next matching sibling. * Returns the nearest element node sibling if no method provided. * @param {String | Function} fn A selector or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * @return {Node} Node instance or null if not found * Returns all matching siblings. * Returns all siblings if no method provided. * @param {String | Function} fn A selector or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * @return {NodeList} NodeList instance bound to found siblings * Retrieves a Node instance of nodes based on the given CSS selector. * @param {string} selector The CSS selector to test against. * @return {Node} A Node instance for the matching HTMLElement. * Retrieves a Node instance of nodes based on the given CSS selector. * @param {string} selector The CSS selector to test against. * @return {Node} A Node instance for the matching HTMLElement. * Retrieves a nodeList based on the given CSS selector. * @param {string} selector The CSS selector to test against. * Retrieves a nodeList based on the given CSS selector. * @param {string} selector The CSS selector to test against. * Test if the supplied node matches the supplied selector. * @param {string} selector The CSS selector to test against. * @return {boolean} Whether or not the node matches the selector. * Removes the node from its parent. * Shortcut for myNode.get('parentNode').removeChild(myNode); * Replace the node with the other node. This is a DOM update only * and does not change the node bound to the Node instance. * Shortcut for myNode.get('parentNode').replaceChild(newNode, myNode); * @param {Y.Node || HTMLNode} newNode Node to be inserted * Removes event listeners from the node and (optionally) its subtree * @param {Boolean} recurse (optional) Whether or not to remove listeners from the * @param {String} type (optional) Only remove listeners of the specified type * Nulls internal node references, removes any plugins and event listeners * @param {Boolean} recursivePurge (optional) Whether or not to remove listeners from the * node's subtree (default is false) if (
this.
unplug) {
// may not be a PluginHost * Invokes a method on the Node instance * @param {String} method The name of the method to invoke * @param {Any} a, b, c, etc. Arguments to invoke the method with. * @return Whatever the underly method returns. * DOM Nodes and Collections return values if (a && a
instanceof Y_Node) {
if (b && b
instanceof Y_Node) {
* Applies the given function to each Node in the NodeList. * @deprecated Use NodeList * @param {Function} fn The function to apply * @param {Object} context optional An optional context to apply the function with * Default context is the NodeList instance * Retrieves the Node instance at the given index. * @deprecated Use NodeList * @param {Number} index The index of the target Node. * @return {Node} The Node instance at the given index. * Returns the current number of items in the Node. * @deprecated Use NodeList * @return {Int} The number of items in the Node. return this.
_node ?
1 :
0;
* Inserts the content before the reference node. * @param {String | Y.Node | HTMLElement} content The content to insert * @param {Int | Y.Node | HTMLElement | String} where The position to insert at. * Possible "where" arguments * <dd>The Node to insert before</dd> * <dd>The element to insert before</dd> * <dd>The index of the child element to insert before</dd> * <dd>Replaces the existing HTML</dd> * <dd>Inserts before the existing HTML</dd> * <dd>Inserts content before the node</dd> * <dd>Inserts content after the node</dd> if (
typeof where ===
'number') {
// allow index return this;
// NOTE: early return * Inserts the content as the firstChild of the node. * @param {String | Y.Node | HTMLElement} content The content to insert * Inserts the content as the lastChild of the node. * @param {String | Y.Node | HTMLElement} content The content to insert * Replaces the node's current content with the content. * @param {String | Y.Node | HTMLElement} content The content to insert }
else if (
content.
_nodes) {
// convert DOMNodeList to documentFragment * @description Swap DOM locations with the given node. * This does not change which DOM node each Node instance refers to. * @param {Node} otherNode The node to swap with * @description Retrieves arbitrary data stored on a Node instance. * This is not stored with the DOM node. * @param {string} name Optional name of the data field to retrieve. * If no name is given, all data is returned. * @return {any | Object} Whatever is stored at the given field, * or an object hash of all fields. * @description Stores arbitrary data on a Node instance. * This is not stored with the DOM node. * @param {string} name The name of the field to set. If no name * is given, name is treated as the data and overrides any existing data. * @param {any} val The value to be assigned to the field. * @description Clears stored data. * @param {string} name The name of the field to clear. If no name * is given, all data is cleared.. String(
node[
method]).
indexOf(
'function') ===
1));
// IE reports as object, prepends space * The NodeList module provides support for managing collections of Nodes. * The NodeList class provides a wrapper for manipulating DOM NodeLists. * NodeList properties can be accessed via the set/get methods. * Use Y.all() to retrieve NodeList instances. if (
typeof nodes ===
'string') {
// selector query }
else if (
nodes[
0]
instanceof Y.
Node) {
// allow array of Y.Nodes }
else {
// array of domNodes or domNodeList (no mixed array of Y.Node/domNodes) * The underlying array of DOM nodes bound to the Y.NodeList instance * Retrieves the DOM nodes bound to a NodeList instance * @method NodeList.getDOMNodes * @param {Y.NodeList} node The NodeList instance * @return {Array} The array of DOM nodes bound to the NodeList // TODO: remove tmp pointer if (
typeof name ===
'string') {
* Retrieves the Node instance at the given index. * @param {Number} index The index of the target Node. * @return {Node} The Node instance at the given index. * Applies the given function to each Node in the NodeList. * @param {Function} fn The function to apply. It receives 3 arguments: * the current node instance, the node's index, and the NodeList instance * @param {Object} context optional An optional context to apply the function with * Default context is the current Node instance * Executes the function once for each node until a true value is returned. * @param {Function} fn The function to apply. It receives 3 arguments: * the current node instance, the node's index, and the NodeList instance * @param {Object} context optional An optional context to execute the function from. * Default context is the current Node instance * @return {Boolean} Whether or not the function returned true for any node. * Creates a documenFragment from the nodes bound to the NodeList instance * @return Node a Node instance bound to the documentFragment * Returns the index of the node in the NodeList instance * or -1 if the node isn't found. * @param {Y.Node || DOMNode} node the node to search for * @return {Int} the index of the node value or -1 if not found * Filters the NodeList instance down to only nodes matching the given selector. * @param {String} selector The selector to filter against * @return {NodeList} NodeList containing the updated collection * Creates a new NodeList containing all nodes at every n indices, where * remainder n % index equals r. * @param {Int} n The offset to use (return every nth node) * @param {Int} r An optional remainder to use with the modulus operation (defaults to zero) * @return {NodeList} NodeList containing the updated collection * Creates a new NodeList containing all nodes at odd indices * @return {NodeList} NodeList containing the updated collection * Creates a new NodeList containing all nodes at even indices * (zero-based index), including zero. * @return {NodeList} NodeList containing the updated collection * Reruns the initial query, when created using a selector query // map to Y.on/after signature (type, fn, nodes, context, arg1, arg2, etc) if (
args.
length <
2) {
// type only (event hash) just add nodes args[
3] =
context ||
this;
// default to NodeList instance as context * Applies an event listener to each Node bound to the NodeList. * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {Object} Returns an event handle that can later be use to detach(). * Applies an event listener to each Node bound to the NodeList. * The handler is called only after all on() handlers are called * and the event is not prevented. * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {Object} Returns an event handle that can later be use to detach(). * Returns the current number of items in the NodeList. * @return {Int} The number of items in the NodeList. * Determines if the instance is bound to any nodes * @return {Boolean} Whether or not the NodeList is bound to any nodes * Called on each Node instance * Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance // one-off implementation to convert array of Nodes to NodeList // e.g. Y.all('input').get('parentNode'); /** Called on each Node instance if (!
isNodeList) {
// convert array of Nodes to NodeList * Passes through to DOM method. * @param {HTMLElement | Node} node Node to be inserted * @param {HTMLElement | Node} refNode Node to be replaced * @return {Node} The replaced node * Passes through to DOM method. * @param {HTMLElement | Node} node Node to be appended * @return {Node} The appended node * Passes through to DOM method. * @param {HTMLElement | Node} newNode Node to be appended * @param {HTMLElement | Node} refNode Node to be inserted before * @return {Node} The inserted node * Passes through to DOM method. * @param {HTMLElement | Node} node Node to be removed * @return {Node} The removed node * Passes through to DOM method. * @return {Boolean} Whether or not the node has any childNodes * Passes through to DOM method. * @param {Boolean} deep Whether or not to perform a deep clone, which includes * @return {Node} The clone * Passes through to DOM method. * @param {String} attribute The attribute to test for * @return {Boolean} Whether or not the attribute is present * Passes through to DOM method. * @method removeAttribute * @param {String} attribute The attribute to be removed * Passes through to DOM method. * Passes through to DOM method. * @method getElementsByTagName * @param {String} tagName The tagName to collect * @return {NodeList} A NodeList representing the HTMLCollection * Passes through to DOM method. * Passes through to DOM method. * Passes through to DOM method. * Only valid on FORM elements * Passes through to DOM method. * Only valid on FORM elements * Passes through to DOM method. * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy. * @param {Node | HTMLElement} needle The possible node or descendent * @return {Boolean} Whether or not this node is the needle its ancestor * Allows setting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @param {string} name The attribute name * @param {string} value The value to set * Allows getting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @param {string} name The attribute name * @return {string} The attribute value * Allows setting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @param {string} name The attribute name * @param {string} value The value to set * Allows getting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @param {string} name The attribute name * @return {string} The attribute value * Allows for removing attributes on DOM nodes. * This passes through to the DOM node, allowing for custom attributes. * @method removeAttribute * @param {string} name The attribute to remove * Determines whether each node has the given className. * @param {String} className the class name to search for * @return {Array} An array of booleans for each node bound to the NodeList. * Adds a class name to each node. * @param {String} className the class name to add to the node's class attribute * Removes a class name from each node. * @param {String} className the class name to remove from the node's class attribute * Replace a class with another class for each node. * If no oldClassName is present, the newClassName is simply added. * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name * If the className exists on the node it is removed, if it doesn't exist it is added. * @param {String} className the class name to be toggled * Determines whether each node has the given className. * @param {String} className the class name to search for * @return {Array} An array of booleans for each node bound to the NodeList. * Adds a class name to each node. * @param {String} className the class name to add to the node's class attribute * Removes a class name from each node. * @param {String} className the class name to remove from the node's class attribute * Replace a class with another class for each node. * If no oldClassName is present, the newClassName is simply added. * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name * If the className exists on the node it is removed, if it doesn't exist it is added. * @param {String} className the class name to be toggled if (
this.
get(
'value') !==
"") {
// IE < 8 fails to populate specified when set in HTML // IE throws error when setting input.type = 'hidden', // input.setAttribute('type', 'hidden') and input.attributes.type.value = 'hidden' try {
// IE errors when changing the type from "hidden' _bypassProxy:
true // don't update DOM when using with Attribute // IE: elements collection is also FORM node which trips up scrubVal. return this.
all(
'input, textarea, button, select');
},
'@VERSION@' ,{
requires:[
'dom-base',
'selector-css2',
'event-base']});
YUI.
add(
'node-style',
function(Y) {
* Extended Node interface for managing node styles. * Returns the style's current value. * @param {String} attr The style attribute to retrieve. * @return {String} The current value of the style property for the element. * Returns the computed value for the given style property. * @method getComputedStyle * @param {String} attr The style attribute to retrieve. * @return {String} The computed value of the style property for the element. * Sets a style property of the node. * @param {String} attr The style attribute to set. * @param {String|Number} val The value. * Sets multiple style properties on the node. * @param {Object} hash An object literal of property:value pairs. * Returns an array of values for each node. * @param {String} attr The style attribute to retrieve. * @return {Array} The current values of the style property for the element. * Returns an array of the computed value for each node. * @method getComputedStyle * @see Node.getComputedStyle * @param {String} attr The style attribute to retrieve. * @return {Array} The computed values for each node. * Sets a style property on each node. * @param {String} attr The style attribute to set. * @param {String|Number} val The value. * Sets multiple style properties on each node. * @param {Object} hash An object literal of property:value pairs. },
'@VERSION@' ,{
requires:[
'dom-style',
'node-base']});
YUI.
add(
'node-screen',
function(Y) {
* Extended Node interface for managing regions and screen positioning. * Adds support for positioning elements and normalizes window size and scroll detection. // these are all "safe" returns, no wrapping required * Returns the inner width of the viewport (exludes scrollbar). * Returns the inner height of the viewport (exludes scrollbar). * Amount page has been scroll vertically * Amount page has been scroll horizontally if (
'scrollLeft' in node) {
if (
'scrollTop' in node) {
* Gets the current position of the node in page coordinates. * @return {Array} The XY position of the node * Set the position of the node in page coordinates, regardless of how the node is positioned. * @param {Array} xy Contains X & Y values for new position (coordinates are page-based) * Gets the current position of the node in page coordinates. * @return {Int} The X position of the node * Set the position of the node in page coordinates, regardless of how the node is positioned. * @param {Int} x X value for new position (coordinates are page-based) * Gets the current position of the node in page coordinates. * @return {Int} The Y position of the node * Set the position of the node in page coordinates, regardless of how the node is positioned. * @param {Int} y Y value for new position (coordinates are page-based) * Swaps the XY position of this node with another node. * @param {Y.Node || HTMLElement} otherNode The node to swap with. * Returns a region object for the node * Returns a region object for the node's viewport // these need special treatment to extract 2nd node arg * Compares the intersection of the node with another node or region * @param {Node|Object} node2 The node or region to compare with. * @param {Object} altRegion An alternate region to use (rather than this node's). * @return {Object} An object representing the intersection of the regions. if (
node2 instanceof Y.
Node) {
// might be a region object * Determines whether or not the node is within the giving region. * @param {Node|Object} node2 The node or region to compare with. * @param {Boolean} all Whether or not all of the node must be in the region. * @param {Object} altRegion An alternate region to use (rather than this node's). * @return {Object} An object representing the intersection of the regions. if (
node2 instanceof Y.
Node) {
// might be a region object },
'@VERSION@' ,{
requires:[
'dom-screen']});
YUI.
add(
'node-pluginhost',
function(Y) {
* Registers plugins to be instantiated at the class level (plugins * which should be plugged into every instance of Node by default). * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined) * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin * Unregisters any class level plugins which have been registered by the Node * @param {Function | Array} plugin The plugin class, or an array of plugin classes // doesn't use NodeList.importMethod because we need real Nodes (not tmpNode) },
'@VERSION@' ,{
requires:[
'node-base',
'pluginhost']});
YUI.
add(
'node-event-delegate',
function(Y) {
* Functionality to make the node a delegated event container * @submodule node-event-delegate * <p>Sets up a delegation listener for an event occurring inside the Node. * The delegated event will be verified against a supplied selector or * filtering function to test if the event references at least one node that * should trigger the subscription callback.</p> * <p>Selector string filters will trigger the callback if the event originated * from a node that matches it or is contained in a node that matches it. * Function filters are called for each Node up the parent axis to the * subscribing container node, and receive at each level the Node and the event * object. The function should return true (or a truthy value) if that Node * should trigger the subscription callback. Note, it is possible for filters * to match multiple Nodes for a single event. In this case, the delegate * callback will be executed for each matching Node.</p> * <p>For each matching Node, the callback will be executed with its 'this' * object set to the Node matched by the filter (unless a specific context was * provided during subscription), and the provided event's * <code>currentTarget</code> will also be set to the matching Node. The * containing Node from which the subscription was originally made can be * referenced as <code>e.container</code>. * @param type {String} the event type to delegate * @param fn {Function} the callback function to execute. This function * will be provided the event object for the delegated event. * @param spec {String|Function} a selector that must match the target of the * event or a function to test target and its parents for a match * @param context {Object} optional argument that specifies what 'this' refers to. * @param args* {any} 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle },
'@VERSION@' ,{
requires:[
'node-base',
'event-delegate']});
YUI.
add(
'node',
function(Y){},
'@VERSION@' ,{
requires:[
'dom',
'event-base',
'event-delegate',
'pluginhost'],
use:[
'node-base',
'node-style',
'node-screen',
'node-pluginhost',
'node-event-delegate'],
skinnable:
false});
YUI.
add(
'event-delegate',
function(Y) {
* Adds event delegation support to the library. * @submodule event-delegate * <p>Sets up event delegation on a container element. The delegated event * will use a supplied selector or filtering function to test if the event * references at least one node that should trigger the subscription * <p>Selector string filters will trigger the callback if the event originated * from a node that matches it or is contained in a node that matches it. * Function filters are called for each Node up the parent axis to the * subscribing container node, and receive at each level the Node and the event * object. The function should return true (or a truthy value) if that Node * should trigger the subscription callback. Note, it is possible for filters * to match multiple Nodes for a single event. In this case, the delegate * callback will be executed for each matching Node.</p> * <p>For each matching Node, the callback will be executed with its 'this' * object set to the Node matched by the filter (unless a specific context was * provided during subscription), and the provided event's * <code>currentTarget</code> will also be set to the matching Node. The * containing Node from which the subscription was originally made can be * referenced as <code>e.container</code>. * @param type {String} the event type to delegate * @param fn {Function} the callback function to execute. This function * will be provided the event object for the delegated event. * @param el {String|node} the element that is the delegation container * @param spec {string|Function} a selector that must match the target of the * event or a function to test target and its parents for a match * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle handle = Y.
on(
'available',
function () {
* Overrides the <code>_notify</code> method on the normal DOM subscription to inject the filtering logic and only proceed in the case of a match. * @method delegate.notifySub * @param thisObj {Object} default 'this' object for the callback * @param args {Array} arguments passed to the event's <code>fire()</code> * @param ce {CustomEvent} the custom event managing the DOM subscriptions for * the subscribed event on the subscribing node. * @return {Boolean} false if the event was stopped // Preserve args for other subscribers // Only notify subs if the event occurred on a targeted element // Support multiple matches up the the container subtree // New facade to avoid corrupting facade sent to direct subs if (
ret ===
false) {
// stop further notifications * <p>Compiles a selector string into a filter function to identify whether * Nodes along the parent axis of an event's target should trigger event * <p>This function is memoized, so previously compiled filter functions are * returned if the same selector string is provided.</p> * <p>This function may be useful when defining synthetic events for delegate * @method delegate.compileFilter * @param selector {String} the selector string to base the filtration on * Walks up the parent axis of an event's target, and tests each element * against a supplied filter function. If any Nodes satisfy the filter, the * delegated callback will be triggered for each. * @method delegate._applyFilter * @param filter {Function} boolean function to test for inclusion in event * @param args {Array} the arguments that would be passed to subscribers * @return {Node|Node[]|undefined} The Node or Nodes that satisfy the filter // passing target as the first arg rather than leaving well enough alone // making 'this' in the filter function refer to the target. This is to // support bound filter functions. // filter(target, e, extra args...) - this === target * Sets up event delegation on a container element. The delegated event * will use a supplied filter to test if the callback should be executed. * This filter can be either a selector string or a function that returns * a Node to use as the currentTarget for the event. * The event object for the delegated event is supplied to the callback * function. It is modified slightly in order to support all properties * that may be needed for event delegation. 'currentTarget' is set to * the element that matched the selector string filter or the Node returned * from the filter function. 'container' is set to the element that the * listener is delegated from (this normally would be the 'currentTarget'). * Filter functions will be called with the arguments that would be passed to * the callback function, including the event object as the first parameter. * The function should return false (or a falsey value) if the success criteria * aren't met, and the Node to use as the event's currentTarget and 'this' * @param type {string} the event type to delegate * @param fn {function} the callback function to execute. This function * will be provided the event object for the delegated event. * @param el {string|node} the element that is the delegation container * @param filter {string|function} a selector that must match the target of the * event or a function that returns a Node or false. * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle },
'@VERSION@' ,{
requires:[
'node-base']});
YUI.
add(
'io-base',
function(Y) {
* Base IO functionality. Provides basic XHR transport support. * The io class is a utility that brokers HTTP requests through a simplified * interface. Specifically, it allows JavaScript to make HTTP requests to * a resource without a page reload. The underlying transport for making * same-domain requests is the XMLHttpRequest object. YUI.io can also use * Flash, if specified as a transport, for cross-domain requests. * @description This event is fired by YUI.io when a transaction is initiated. * @description This event is fired by YUI.io when a transaction is complete. * Response status and data are accessible, if available. * @description This event is fired by YUI.io when a transaction is complete, and * the HTTP status resolves to HTTP2xx. * @description This event is fired by YUI.io when a transaction is complete, and * the HTTP status resolves to HTTP4xx, 5xx and above. * @description This event signifies the end of the transaction lifecycle. The * transaction transport is destroyed. //-------------------------------------- //-------------------------------------- * @description A transaction counter that increments for each transaction. * @property transactionId * @description Object of default HTTP headers to be initialized and sent 'X-Requested-With' :
'XMLHttpRequest' * @description Object that stores timeout values for any transaction with * a defined "timeout" configuration property. //-------------------------------------- //-------------------------------------- * @description Method that creates the XMLHttpRequest transport * @description Method that increments _transactionId for each transaction. * @description Method that creates a unique transaction object for each * @param {number} c - configuration object subset to determine if * the transaction is an XDR or file upload, * requiring an alternate transport. * @param {number} i - transaction id if (c.
use ===
'native') {
// IE, when using XMLHttpRequest as an ActiveX Object, will throw // a "Type Mismatch" error if the event handler is set to "null". * @description Method for creating and subscribing transaction events. * @param {string} e - event to be published * @param {object} c - configuration data subset for event subscription. * @description Fires event "io:start" and creates, fires a * transaction-specific start event, if config.on.start is * @param {number} id - transaction id * @param {object} c - configuration object for the transaction. * @description Fires event "io:complete" and creates, fires a * transaction-specific "complete" event, if config.on.complete is * @param {object} o - transaction object. * @param {object} c - configuration object for the transaction. * @description Fires event "io:end" and creates, fires a * transaction-specific "end" event, if config.on.end is * @param {object} o - transaction object. * @param {object} c - configuration object for the transaction. * @description Fires event "io:success" and creates, fires a * transaction-specific "success" event, if config.on.success is * @param {object} o - transaction object. * @param {object} c - configuration object for the transaction. * @description Fires event "io:failure" and creates, fires a * transaction-specific "failure" event, if config.on.failure is * @param {object} o - transaction object. * @param {object} c - configuration object for the transaction. * @description Resends an XDR transaction, using the Flash tranport, * if the native transport fails. * @param {object} o - Transaction object generated by _create(). * @param {string} uri - qualified path to transaction resource. * @param {object} c - configuration object for the transaction. // If the original request included serialized form data and // additional data are defined in configuration.data, it must // be reset to prevent data duplication. * @description Method that concatenates string data for HTTP GET transactions. * @param {string} s - URI or root data. * @param {string} d - data to be concatenated onto URI. s += ((s.
indexOf(
'?') == -
1) ?
'?' :
'&') + d;
* @description Method that stores default client headers for all transactions. * If a label is passed with no value argument, the header will be deleted. * @param {string} l - HTTP header * @param {string} v - HTTP header value * @description Method that sets all HTTP headers to be sent in a transaction. * @param {object} o - XHR instance for the specific transaction. * @param {object} h - HTTP headers for the specific transaction, as defined * in the configuration object passed to YUI.io(). // Configuration headers will supersede io preset headers, * @description Terminates a transaction due to an explicit abort or * @param {object} o - Transaction object generated by _create(). * @param {string} s - Identifies timed out or aborted transaction. * @description Starts timeout count if the configuration object * has a defined timeout property. * @param {object} o - Transaction object generated by _create(). * @param {object} t - Timeout in milliseconds. * @description Clears the timeout interval started by _startTimeout(). * @param {number} id - Transaction id. * @description Method that determines if a transaction response qualifies * as success or failure, based on the response HTTP status code, and * fires the appropriate success or failure events. * @method _handleResponse * @param {object} o - Transaction object generated by _create(). * @param {object} c - Configuration object passed to io(). // IE reports HTTP 204 as HTTP 1223. * @description Event handler bound to onreadystatechange. * @param {object} o - Transaction object generated by _create(). * @param {object} c - Configuration object passed to YUI.io(). * @description Method for requesting a transaction. _io() is implemented as * yui.io(). Each transaction may include a configuration object. Its * method: HTTP method verb (e.g., GET or POST). If this property is not * not defined, the default value will be GET. * data: This is the name-value string that will be sent as the transaction * data. If the request is HTTP GET, the data become part of * querystring. If HTTP POST, the data are sent in the message body. * xdr: Defines the transport to be used for cross-domain requests. By * setting this property, the transaction will use the specified * transport instead of XMLHttpRequest. * use: Specify the transport to be used: 'flash' and 'native' * dataType: Set the value to 'XML' if that is the expected * form: This is a defined object used to process HTML form as data. The * id: Node object or id of HTML form. * useDisabled: Boolean value to allow disabled HTML form field * values to be sent as part of the data. * on: This is a defined object used to create and handle specific * events during a transaction lifecycle. These events will fire in * addition to the global io events. The events are: * start - This event is fired when a request is sent to a resource. * complete - This event fires when the transaction is complete. * success - This event fires when the response status resolves to * failure - This event fires when the response status resolves to * HTTP 4xx, 5xx; and, for all transaction exceptions, * including aborted transactions and transaction timeouts. * end - This even is fired at the conclusion of the transaction * lifecycle, after a success or failure resolution. * start: function(id, arguments){}, * complete: function(id, responseobject, arguments){}, * success: function(id, responseobject, arguments){}, * failure: function(id, responseobject, arguments){}, * end: function(id, arguments){} * Each property can reference a function or be written as an * sync: To enable synchronous transactions, set the configuration property * "sync" to true; the default behavior is false. Synchronous * transactions are limited to same-domain requests only. * context: Object reference for all defined transaction event handlers * when it is implemented as a method of a base object. Defining * "context" will set the reference of "this," used in the * event handlers, to the context value. In the case where * different event handlers all have different contexts, * use Y.bind() to set the execution context, bypassing this * headers: This is a defined object of client headers, as many as. * desired for the transaction. The object pattern is: * timeout: This value, defined as milliseconds, is a time threshold for the * transaction. When this threshold is reached, and the transaction's * Complete event has not yet fired, the transaction will be aborted. * arguments: Object, array, string, or number passed to all registered * event handlers. This value is available as the second * argument in the "start" and "abort" event handlers; and, it is * the third argument in the "complete", "success", and "failure" * @param {string} uri - qualified path to transaction resource. * @param {object} c - configuration object for the transaction. * @param {number} i - transaction id, if already set. var f, o, d, m, r, s,
oD, a, j,
//To serialize an object into a key-value string, add the //QueryString module to the YUI instance's 'use' method. // This is a file upload transaction, calling // upload() in io-upload-iframe. // Serialize HTML form data. if (m ===
'POST' || m ===
'PUT') {
if (c.
data && m ===
'GET') {
if (c.
data && m ===
'POST') {
o.c.
open(m,
uri, s ?
false :
true);
// Will work only in browsers that implement the // Cross-Origin Resource Sharing draft. // This exception is usually thrown by browsers // that do not support native XDR transactions. // Using "null" with HTTP POST will result in a request // with no Content-Length header defined. a = [
'status',
'statusText',
'responseText',
'responseXML'];
for (j =
0; j <
4; j++) {
// This exception is usually thrown by browsers // that do not support native XDR transactions. // If config.timeout is defined, and the request is standard XHR, // initialize timeout polling. //-------------------------------------- // Begin public interface definition //-------------------------------------- * @description Method that stores default client headers for all transactions. * If a label is passed with no value argument, the header will be deleted. * This is the interface for _setHeader(). * @param {string} l - HTTP header * @param {string} v - HTTP header value * @description Method for requesting a transaction. This * is the interface for _io(). * @param {string} uri - qualified path to transaction resource. * @param {object} c - configuration object for the transaction. },
'@VERSION@' ,{
optional:[
'querystring-stringify-simple'],
requires:[
'event-custom-base']});
YUI.
add(
'json-parse',
function(Y) {
* <p>The JSON module adds support for serializing JavaScript objects into * JSON strings and parsing JavaScript objects from strings in JSON format.</p> * <p>The JSON namespace is added to your YUI instance including static methods * Y.JSON.parse(..) and Y.JSON.stringify(..).</p> * <p>The functionality and method signatures follow the ECMAScript 5 * specification. In browsers with native JSON support, the native * implementation is used.</p> * <p>The <code>json</code> module is a rollup of <code>json-parse</code> and * <code>json-stringify</code>.</p> * <p>As their names suggest, <code>json-parse</code> adds support for parsing * JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing * JavaScript data into JSON strings (Y.JSON.stringify). You may choose to * include either of the submodules individually if you don't need the * complementary functionality, or include the rollup for both.</p> * Provides Y.JSON.parse method to accept JSON strings and return native // All internals kept private for security reasons * Alias to native browser implementation of the JSON object if available. // Create an indirect reference to eval to allow for minification * Replace certain Unicode characters that JavaScript may handle incorrectly * during eval--either by deleting them or treating them as line * endings--with escape sequences. * IMPORTANT NOTE: This regex will be used to modify the input if a match is * @property _UNICODE_EXCEPTIONS * First step in the safety evaluation. Regex used to replace all escape * sequences (i.e. "\\", etc) with '@' characters (a non-JSON character). _ESCAPES = /\\(?:[
"\\\/bfnrt]|u[0-9a-fA-F]{4})/g, * Second step in the safety evaluation. Regex used to replace all simple * values with ']' characters. _VALUES = /"[^
"\\\n\r]*"|
true|
false|
null|-?\d+(?:\.\d*)?(?:[
eE][+\-]?\d+)?/g,
* Third step in the safety evaluation. Regex used to remove all open * square brackets following a colon, comma, or at the beginning of the * Final step in the safety evaluation. Regex used to test the string left * after all previous replacements for invalid characters. * Replaces specific unicode characters with their appropriate \unnnn * format. Some browsers ignore certain characters during eval. * @method escapeException * @param c {String} Unicode character * @return {String} the \unnnn escapement of the character * Traverses nested objects, applying a reviver function to each (key,value) * from the scope if the key:value's containing object. The value returned * from the function will replace the original value in the key:value pair. * If the value returned is undefined, the key will be omitted from the * @param data {MIXED} Any JavaScript data * @param reviver {Function} filter or mutation function * @return {MIXED} The results of the filtered data * Parse a JSON string, returning the native JavaScript representation. * @param s {string} JSON string data * @param reviver {function} (optional) function(k,v) passed each key value * pair of object literals, allowing pruning or altering values * @return {MIXED} the native JavaScript representation of the JSON string // JavaScript implementation in lieu of native browser support. Based on // Replace certain Unicode characters that are otherwise handled // incorrectly by some browser implementations. // NOTE: This modifies the input if such characters are found! // Test for any remaining invalid characters // Eval the text into a JavaScript data structure, apply any // reviver function, and return if (
typeof s !==
'string') {
return k ===
"ok" ?
true : v;
// Double check basic functionality. This is mainly to catch early broken // implementations of the JSON API in Firefox 3.1 beta1 and beta2 * Leverage native JSON parse if the browser has a native implementation. * In general, this is a good idea. See the Known Issues section in the * JSON user guide for caveats. The default value is true for browsers with * @property useNativeParse YUI.
add(
'transition-native',
function(Y) {
* The Native Transition Utility provides an API wrapper for CSS transitions. * It is also the base module for the timer-based transition module. * Provides the base Transition class. The "transition" method is added to Node, * and is how Transition should be used. * @submodule transition-native * A class for constructing transition instances. * Adds the "transition" method to Node. anim.
_count =
0;
// track number of animated properties if (
typeof val ===
'function') {
// take control if another transition owns this property * Starts or an animation. type:
'transition:start',
// preserve existing transitions // run transitions mapped to this instance // only one native end event per node setTimeout(
function() {
// IE: allow previous update to finish if (
typeof value ===
'string') {
* Animate one or more css properties to a given value. Requires the "transition" module. * Y.one('#demo').transition({ * duration: 1, // in seconds, default is 0.5 * easing: 'ease-out', // default is 'ease' * delay: '1', // delay start for 1 second, default is 0 * opacity: { // per property * @param {Object} config An object containing one or more style properties, a duration and an easing. * @param {Function} callback A function to run after the transition has completed. * Animate one or more css properties to a given value. Requires the "transition" module. * Y.all('.demo').transition({ * duration: 1, // in seconds, default is 0.5 * easing: 'ease-out', // default is 'ease' * delay: '1', // delay start for 1 second, default is 0 * opacity: { // per property * @param {Object} config An object containing one or more style properties, a duration and an easing. * @param {Function} callback A function to run after the transition has completed. The callback fires * once per item in the NodeList. },
'@VERSION@' ,{
requires:[
'node-base']});
YUI.
add(
'transition-timer',
function(Y) {
* The Transition Utility provides an API for creating advanced transitions. * Provides the base Transition class, for animating numeric properties. * @submodule transition-timer // only allow supported properties if (
typeof easing ===
'string') {
* Regex of properties that should use the default unit. * @property RE_DEFAULT_UNIT * The default unit to use with properties that pass the RE_DEFAULT_UNIT test. * Time in milliseconds passed to setInterval for frame processing * Bucket for custom getters and setters * The default setter to use when setting object properties. * @property DEFAULT_SETTER * The default getter to use when getting object properties. * @property DEFAULT_GETTER * Called per Interval to handle each animation frame. x = (((A*t) + B)*t + C)*t + D,
y = (((E*t) + F)*t + G)*t + H;
ease: [
0.25,
0,
1,
0.25],
'ease-in': [
0.42,
0,
1,
1],
'ease-out': [
0,
0,
0.58,
1],
'ease-in-out': [
0.42,
0,
0.58,
1]
},
'@VERSION@' ,{
requires:[
'transition-native',
'node-style']});
YUI.
add(
'transition',
function(Y){},
'@VERSION@' ,{
use:[
'transition-native',
'transition-timer']});
YUI.
add(
'selector-css3',
function(Y) {
* The selector css3 module provides support for css3 selectors. * @submodule selector-css3 an+b = get every _a_th node starting at the _b_th 0n+b = no repeat ("0" and "n" may both be omitted (together) , e.g. "0n+1" or "1", not "0+1"), return only the _b_th element 1n+b = get every element starting from b ("1" may may be omitted, e.g. "1n+0" or "n+0" or "n") an+0 = get every _a_th element, "0" may be omitted var a =
parseInt(
RegExp.
$1,
10),
// include every _a_ elements (zero means no repeat, just first _a_) b =
parseInt(
RegExp.
$4,
10) ||
0,
// start scan from element _b_ a =
2;
// always every other a = (n) ?
1 :
0;
// start from the first or no repeat if (a ===
0) {
// just the first 'nth-last-child':
function(
node,
expr) {
'nth-last-of-type':
function(
node,
expr) {
'last-child':
function(
node) {
'first-of-type':
function(
node) {
'last-of-type':
function(
node) {
'only-child':
function(
node) {
'only-of-type':
function(
node) {
'empty':
function(
node) {
'checked':
function(
node) {
'^=':
'^{val}',
// Match starts with value '$=':
'{val}$',
// Match ends with value '*=':
'{val}' // Match contains value as substring },
'@VERSION@' ,{
requires:[
'dom-base',
'selector-native',
'selector-css2']});
YUI.
add(
'dom-style-ie',
function(Y) {
// TODO: unit-less lineHeight (e.g. 1.22) width: [
'Left',
'Right'],
offset =
'offset' +
capped,
// "offsetWidth", "offsetTop", etc. pixel =
'pixel' +
capped,
// "pixelWidth", "pixelTop", etc. // IE pixelWidth incorrect for percent // manually compute by subtracting padding and border from offset size // NOTE: clientWidth/Height (size minus border) is 0 when current === AUTO so offsetHeight is used // reverting to auto from auto causes position stacking issues (old impl) if (
mode !==
'BackCompat') {
}
else {
// use style.pixelWidth, etc. to convert to pixels // need to map style.width to currentStyle (no currentStyle.pixelWidth) }
else {
// otherwise no border (default is "medium") // use pixelRight to convert to px //fontSize: getPixelFont, // use alpha filter for IE opacity try {
// will error if no DXImageTransform try {
// make sure its in the document if (
val ===
'') {
// normalize inline style behavior if (
typeof style[
FILTER] ==
'string') {
// in case not appended }
catch(e) {
// IE throws error on invalid style set; trap common cases// TODO: top, right, bottom, left },
'@VERSION@' ,{
requires:[
'dom-style']});
YUI.
add(
'simpleyui',
function(Y) {
},
'@VERSION@' ,{
use:[
'yui',
'oop',
'dom',
'event-custom-base',
'event-base',
'pluginhost',
'node',
'event-delegate',
'io-base',
'json-parse',
'transition',
'selector-css3',
'dom-style-ie']});