]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/dom/dom-base-min.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / dom / dom-base-min.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add("dom-base",function(d){(function(h){var o="nodeType",u="ownerDocument",v="documentElement",g="defaultView",m="parentWindow",s="tagName",k="parentNode",e="firstChild",t="previousSibling",w="nextSibling",l="contains",r="compareDocumentPosition",f="",i=[],y=h.config.doc.documentElement,n=/<([a-z]+)/i,j=function(B,z){var C=h.config.doc.createElement("div"),A=true;C.innerHTML=B;if(!C.firstChild||C.firstChild.tagName!==z.toUpperCase()){A=false;}return A;},p=h.Features.add,q=h.Features.test,x={byId:function(A,z){return x.allById(A,z)[0]||null;},getText:(y.textContent!==undefined)?function(A){var z="";if(A){z=A.textContent;}return z||"";}:function(A){var z="";if(A){z=A.innerText||A.nodeValue;}return z||"";},setText:(y.textContent!==undefined)?function(z,A){if(z){z.textContent=A;}}:function(z,A){if("innerText" in z){z.innerText=A;}else{if("nodeValue" in z){z.nodeValue=A;}}},ancestor:function(A,B,C){var z=null;if(C){z=(!B||B(A))?A:null;}return z||x.elementByAxis(A,k,B,null);},ancestors:function(B,C,D){var A=x.ancestor.apply(x,arguments),z=(A)?[A]:[];while((A=x.ancestor(A,C))){if(A){z.unshift(A);}}return z;},elementByAxis:function(z,C,B,A){while(z&&(z=z[C])){if((A||z[s])&&(!B||B(z))){return z;}}return null;},contains:function(A,B){var z=false;if(!B||!A||!B[o]||!A[o]){z=false;}else{if(A[l]){if(h.UA.opera||B[o]===1){z=A[l](B);}else{z=x._bruteContains(A,B);}}else{if(A[r]){if(A===B||!!(A[r](B)&16)){z=true;}}}}return z;},inDoc:function(B,C){var A=false,z;if(B&&B.nodeType){(C)||(C=B[u]);z=C[v];if(z&&z.contains&&B.tagName){A=z.contains(B);}else{A=x.contains(z,B);}}return A;},allById:function(E,z){z=z||h.config.doc;var A=[],B=[],C,D;if(z.querySelectorAll){B=z.querySelectorAll('[id="'+E+'"]');}else{if(z.all){A=z.all(E);if(A){if(A.nodeName){if(A.id===E){B.push(A);A=i;}else{A=[A];}}if(A.length){for(C=0;D=A[C++];){if(D.id===E||(D.attributes&&D.attributes.id&&D.attributes.id.value===E)){B.push(D);}}}}}else{B=[x._getDoc(z).getElementById(E)];}}return B;},create:function(D,G){if(typeof D==="string"){D=h.Lang.trim(D);}G=G||h.config.doc;var C=n.exec(D),E=x._create,A=x.creators,F=null,B,H,z;if(D!=undefined){if(C&&C[1]){B=A[C[1].toLowerCase()];if(typeof B==="function"){E=B;}else{H=B;}}z=E(D,G,H).childNodes;if(z.length===1){F=z[0].parentNode.removeChild(z[0]);}else{if(z[0]&&z[0].className==="yui3-big-dummy"){if(z.length===2){F=z[0].nextSibling;}else{z[0].parentNode.removeChild(z[0]);F=x._nl2frag(z,G);}}else{F=x._nl2frag(z,G);}}}return F;},_nl2frag:function(A,D){var B=null,C,z;if(A&&(A.push||A.item)&&A[0]){D=D||A[0].ownerDocument;B=D.createDocumentFragment();if(A.item){A=h.Array(A,0,true);}for(C=0,z=A.length;C<z;C++){B.appendChild(A[C]);}}return B;},CUSTOM_ATTRIBUTES:(!y.hasAttribute)?{"for":"htmlFor","class":"className"}:{"htmlFor":"for","className":"class"},setAttribute:function(B,z,C,A){if(B&&z&&B.setAttribute){z=x.CUSTOM_ATTRIBUTES[z]||z;B.setAttribute(z,C,A);}},getAttribute:function(C,z,B){B=(B!==undefined)?B:2;var A="";if(C&&z&&C.getAttribute){z=x.CUSTOM_ATTRIBUTES[z]||z;A=C.getAttribute(z,B);if(A===null){A="";}}return A;},isWindow:function(z){return !!(z&&z.alert&&z.document);},_fragClones:{},_create:function(A,B,z){z=z||"div";var C=x._fragClones[z];if(C){C=C.cloneNode(false);}else{C=x._fragClones[z]=B.createElement(z);}C.innerHTML=A;return C;},_removeChildNodes:function(z){while(z.firstChild){z.removeChild(z.firstChild);}},addHTML:function(G,F,B){var z=G.parentNode,D=0,E,A=F,C;if(F!=undefined){if(F.nodeType){C=F;}else{if(typeof F=="string"||typeof F=="number"){A=C=x.create(F);}else{if(F[0]&&F[0].nodeType){C=h.config.doc.createDocumentFragment();while((E=F[D++])){C.appendChild(E);}}}}}if(B){if(B.nodeType){B.parentNode.insertBefore(C,B);}else{switch(B){case"replace":while(G.firstChild){G.removeChild(G.firstChild);}if(C){G.appendChild(C);}break;case"before":z.insertBefore(C,G);break;case"after":if(G.nextSibling){z.insertBefore(C,G.nextSibling);}else{z.appendChild(C);}break;default:G.appendChild(C);}}}else{if(C){G.appendChild(C);}}return A;},VALUE_SETTERS:{},VALUE_GETTERS:{},getValue:function(B){var A="",z;if(B&&B[s]){z=x.VALUE_GETTERS[B[s].toLowerCase()];if(z){A=z(B);}else{A=B.value;}}if(A===f){A=f;}return(typeof A==="string")?A:"";},setValue:function(z,A){var B;if(z&&z[s]){B=x.VALUE_SETTERS[z[s].toLowerCase()];if(B){B(z,A);}else{z.value=A;}}},siblings:function(C,B){var z=[],A=C;while((A=A[t])){if(A[s]&&(!B||B(A))){z.unshift(A);}}A=C;while((A=A[w])){if(A[s]&&(!B||B(A))){z.push(A);}}return z;},_bruteContains:function(z,A){while(A){if(z===A){return true;}A=A.parentNode;}return false;},_getRegExp:function(A,z){z=z||"";x._regexCache=x._regexCache||{};if(!x._regexCache[A+z]){x._regexCache[A+z]=new RegExp(A,z);}return x._regexCache[A+z];},_getDoc:function(z){var A=h.config.doc;if(z){A=(z[o]===9)?z:z[u]||z.document||h.config.doc;}return A;},_getWin:function(z){var A=x._getDoc(z);return A[g]||A[m]||h.config.win;},_batch:function(z,I,F,E,D,B){I=(typeof I==="string")?x[I]:I;var J,H=Array.prototype.slice.call(arguments,2),C=0,A,G;if(I&&z){while((A=z[C++])){J=J=I.call(x,A,F,E,D,B);if(typeof J!=="undefined"){(G)||(G=[]);G.push(J);}}}return(typeof G!=="undefined")?G:z;},wrap:function(C,A){var B=h.DOM.create(A),z=B.getElementsByTagName("*");if(z.length){B=z[z.length-1];}if(C.parentNode){C.parentNode.replaceChild(B,C);}B.appendChild(C);},unwrap:function(C){var A=C.parentNode,B=A.lastChild,C=A.firstChild,z=C,D;if(A){D=A.parentNode;if(D){while(C!==B){z=C.nextSibling;D.insertBefore(C,A);C=z;}D.replaceChild(B,A);}else{A.removeChild(C);}}},generateID:function(z){var A=z.id;if(!A){A=h.stamp(z);z.id=A;}return A;},creators:{}};p("innerhtml","table",{test:function(){var z=h.config.doc.createElement("table");try{z.innerHTML="<tbody></tbody>";}catch(A){return false;}return(z.firstChild&&z.firstChild.nodeName==="TBODY");}});p("innerhtml-div","tr",{test:function(){return j("<tr></tr>","tr");}});p("innerhtml-div","script",{test:function(){return j("<script><\/script>","script");}});p("value-set","select",{test:function(){var z=h.config.doc.createElement("select");
9 z.innerHTML="<option>1</option><option>2</option>";z.value="2";return(z.value&&z.value==="2");}});(function(D){var E=x.creators,z=x.create,C=/(?:\/(?:thead|tfoot|tbody|caption|col|colgroup)>)+\s*<tbody/,B="<table>",A="</table>";if(!q("innerhtml","table")){E.tbody=function(G,H){var I=z(B+G+A,H),F=I.children.tags("tbody")[0];if(I.children.length>1&&F&&!C.test(G)){F[k].removeChild(F);}return I;};}if(!q("innerhtml-div","script")){E.script=function(F,G){var H=G.createElement("div");H.innerHTML="-"+F;H.removeChild(H[e]);return H;};x.creators.link=x.creators.style=x.creators.script;}if(!q("value-set","select")){x.VALUE_SETTERS.select=function(I,J){for(var G=0,F=I.getElementsByTagName("option"),H;H=F[G++];){if(x.getValue(H)===J){H.selected=true;break;}}};}D.mix(x.VALUE_GETTERS,{button:function(F){return(F.attributes&&F.attributes.value)?F.attributes.value.value:"";}});D.mix(x.VALUE_SETTERS,{button:function(G,H){var F=G.attributes.value;if(!F){F=G[u].createAttribute("value");G.setAttributeNode(F);}F.value=H;}});if(!q("innerhtml-div","tr")){D.mix(E,{option:function(F,G){return z('<select><option class="yui3-big-dummy" selected></option>'+F+"</select>",G);},tr:function(F,G){return z("<tbody>"+F+"</tbody>",G);},td:function(F,G){return z("<tr>"+F+"</tr>",G);},col:function(F,G){return z("<colgroup>"+F+"</colgroup>",G);},tbody:"table"});D.mix(E,{legend:"fieldset",th:E.td,thead:E.tbody,tfoot:E.tbody,caption:E.tbody,colgroup:E.tbody,optgroup:E.option});}D.mix(x.VALUE_GETTERS,{option:function(G){var F=G.attributes;return(F.value&&F.value.specified)?G.value:G.text;},select:function(G){var H=G.value,F=G.options;if(F&&F.length){if(G.multiple){}else{H=x.getValue(F[G.selectedIndex]);}}return H;}});})(h);h.DOM=x;})(d);var b,a,c;d.mix(d.DOM,{hasClass:function(g,f){var e=d.DOM._getRegExp("(?:^|\\s+)"+f+"(?:\\s+|$)");return e.test(g.className);},addClass:function(f,e){if(!d.DOM.hasClass(f,e)){f.className=d.Lang.trim([f.className,e].join(" "));}},removeClass:function(f,e){if(e&&a(f,e)){f.className=d.Lang.trim(f.className.replace(d.DOM._getRegExp("(?:^|\\s+)"+e+"(?:\\s+|$)")," "));if(a(f,e)){c(f,e);}}},replaceClass:function(f,e,g){c(f,e);b(f,g);},toggleClass:function(f,e,g){var h=(g!==undefined)?g:!(a(f,e));if(h){b(f,e);}else{c(f,e);}}});a=d.DOM.hasClass;c=d.DOM.removeClass;b=d.DOM.addClass;d.mix(d.DOM,{setWidth:function(f,e){d.DOM._setSize(f,"width",e);},setHeight:function(f,e){d.DOM._setSize(f,"height",e);},_setSize:function(f,h,g){g=(g>0)?g:0;var e=0;f.style[h]=g+"px";e=(h==="height")?f.offsetHeight:f.offsetWidth;if(e>g){g=g-(e-g);if(g<0){g=0;}f.style[h]=g+"px";}}});},"3.3.0",{requires:["oop"]});