* @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
* @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
*/
get:function(el){
varid,nodes,c,i,len,attr;
if(el){
if(el[NODE_TYPE]||el.item){// Node, or NodeList
returnel;
}
if(typeofel==='string'){// id
id=el;
el=document.getElementById(el);
attr=(el)?el.attributes:null;
if(el&&attr&&attr.id&&attr.id.value===id){// IE: avoid false match on "name" attribute
* Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
* @method getX
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
* @return {Number | Array} The X position of the element(s)
*/
getX:function(el){
varf=function(el){
returnY.Dom.getXY(el)[0];
};
returnY.Dom.batch(el,f,Y.Dom,true);
},
/**
* 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).
* @method getY
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
* @return {Number | Array} The Y position of the element(s)
*/
getY:function(el){
varf=function(el){
returnY.Dom.getXY(el)[1];
};
returnY.Dom.batch(el,f,Y.Dom,true);
},
/**
* Set the 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).
* @method setXY
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
* @param {Array} pos 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
* Returns an ID and applies it to the element "el", if provided.
* @method generateId
* @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
* @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
* @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
*/
generateId:function(el,prefix){
prefix=prefix||'yui-gen';
varf=function(el){
if(el&&el.id){// do not override existing ID
returnel.id;
}
varid=prefix+YAHOO.env._id_counter++;
if(el){
if(el[OWNER_DOCUMENT]&&el[OWNER_DOCUMENT].getElementById(id)){// in case one already exists
// use failed id plus prefix to help ensure uniqueness
returnY.Dom.generateId(el,id+prefix);
}
el.id=id;
}
returnid;
};
// batch fails when no element, so just generate and return single ID