📄 mootools-beta-1.2b2.js
字号:
},get:function(){return this.style.cssText;},erase:function(){this.style.cssText="";}};Element.Properties.value={get:function(){switch(Element.get(this,"tag")){case"select":var A=[];Array.each(this.options,function(B){if(B.selected){A.push(B.value);}});return(this.multiple)?A:A[0];case"input":if(["checkbox","radio"].contains(this.type)&&!this.checked){return false;}default:return $pick(this.value,false);}}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase();}};Element.Properties.html={set:function(){return this.innerHTML=Array.flatten(arguments).join("");}};Element.implement({getText:function(){return this.get("text");},setText:function(A){return this.set("text",A);},setHTML:function(){return this.set("html",arguments);},getHTML:function(){return this.get("html");},getTag:function(){return this.get("tag");}});Native.implement([Element,Window,Document],{addListener:function(B,A){if(this.addEventListener){this.addEventListener(B,A,false);}else{this.attachEvent("on"+B,A);}return this;},removeListener:function(B,A){if(this.removeEventListener){this.removeEventListener(B,A,false);}else{this.detachEvent("on"+B,A);}return this;},retrieve:function(B,A){var D=Element.Storage.get(this.uid);var C=D[B];if($defined(A)&&!$defined(C)){C=D[B]=A;}return $pick(C);},store:function(B,A){var C=Element.Storage.get(this.uid);C[B]=A;return this;},eliminate:function(A){var B=Element.Storage.get(this.uid);delete B[A];return this;}});Element.Attributes=new Hash({Props:{html:"innerHTML","class":"className","for":"htmlFor",text:(Browser.Engine.trident)?"innerText":"textContent"},Bools:["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"],Camels:["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]});(function(B){var C=B.Bools,A=B.Camels;B.Bools=C=C.associate(C);Hash.extend(Hash.merge(B.Props,C),A.associate(A.map(function(D){return D.toLowerCase();})));B.remove("Camels");})(Element.Attributes);var Garbage={Elements:{},ignored:{object:1,embed:1,OBJECT:1,EMBED:1},collect:function(A){if(A.$attributes){return true;}if(Garbage.ignored[A.tagName]){return false;}Garbage.Elements[A.uid]=A;A.$attributes={};return true;},trash:function(C){for(var A=C.length,B;A--;A){Garbage.kill(C[A]);}},kill:function(A){if(!A||!A.$attributes){return ;}delete Garbage.Elements[A.uid];if(A.retrieve("events")){A.removeEvents();}for(var B in A.$attributes){A.$attributes[B]=null;}if(Browser.Engine.trident){for(var C in Element.Prototype){A[C]=null;}}A.$attributes=A.uid=null;},empty:function(){for(var A in Garbage.Elements){Garbage.kill(Garbage.Elements[A]);}}};window.addListener("beforeunload",function(){window.addListener("unload",Garbage.empty);if(Browser.Engine.trident){window.addListener("unload",CollectGarbage);}});Element.Properties.events={set:function(A){this.addEvents(A);}};Native.implement([Element,Window,Document],{addEvent:function(E,G){var H=this.retrieve("events",{});H[E]=H[E]||{keys:[],values:[]};if(H[E].keys.contains(G)){return this;}H[E].keys.push(G);var F=E,A=Element.Events.get(E),C=G,I=this;if(A){if(A.onAdd){A.onAdd.call(this,G);}if(A.condition){C=function(J){if(A.condition.call(this,J)){return G.call(this,J);}return false;};}F=A.base||F;}var D=function(){return G.call(I);};var B=Element.NativeEvents[F]||0;if(B){if(B==2){D=function(J){J=new Event(J,I.getWindow());if(C.call(I,J)===false){J.stop();}};}this.addListener(F,D);}H[E].values.push(D);return this;},removeEvent:function(D,C){var B=this.retrieve("events");if(!B||!B[D]){return this;}var G=B[D].keys.indexOf(C);if(G==-1){return this;}var A=B[D].keys.splice(G,1)[0];var F=B[D].values.splice(G,1)[0];var E=Element.Events.get(D);if(E){if(E.onRemove){E.onRemove.call(this,C);}D=E.base||D;}return(Element.NativeEvents[D])?this.removeListener(D,F):this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},removeEvents:function(B){var A=this.retrieve("events");if(!A){return this;}if(!B){for(var C in A){this.removeEvents(C);}A=null;}else{if(A[B]){while(A[B].keys[0]){this.removeEvent(B,A[B].keys[0]);}A[B]=null;}}return this;},fireEvent:function(D,B,A){var C=this.retrieve("events");if(!C||!C[D]){return this;}C[D].keys.each(function(E){E.create({bind:this,delay:A,arguments:B})();},this);return this;},cloneEvents:function(D,A){D=$(D);var C=D.retrieve("events");if(!C){return this;}if(!A){for(var B in C){this.cloneEvents(D,B);}}else{if(C[A]){C[A].keys.each(function(E){this.addEvent(A,E);},this);}}return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:1,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1};(function(){var A=function(B){var C=B.relatedTarget;if(!C){return true;}return($type(this)!="document"&&C!=this&&C.prefix!="xul"&&!this.hasChild(C));};Element.Events=new Hash({mouseenter:{base:"mouseover",condition:A},mouseleave:{base:"mouseout",condition:A},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}});})();Element.Properties.styles={set:function(A){this.setStyles(A);}};Element.Properties.opacity={set:function(A,B){if(!B){if(A==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden";}}else{if(this.style.visibility!="visible"){this.style.visibility="visible";}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(Browser.Engine.trident){this.style.filter=(A==1)?"":"alpha(opacity="+A*100+")";}this.style.opacity=A;this.store("opacity",A);},get:function(){return this.retrieve("opacity",1);}};Element.implement({setOpacity:function(A){return this.set("opacity",A,true);},getOpacity:function(){return this.get("opacity");},setStyle:function(B,A){switch(B){case"opacity":return this.set("opacity",parseFloat(A));case"float":B=(Browser.Engine.trident)?"styleFloat":"cssFloat";}B=B.camelCase();if($type(A)!="string"){var C=(Element.Styles.get(B)||"@").split(" ");A=$splat(A).map(function(E,D){if(!C[D]){return"";}return($type(E)=="number")?C[D].replace("@",Math.round(E)):E;}).join(" ");}else{if(A==String(Number(A))){A=Math.round(A);}}this.style[B]=A;return this;},getStyle:function(G){switch(G){case"opacity":return this.get("opacity");case"float":G=(Browser.Engine.trident)?"styleFloat":"cssFloat";}G=G.camelCase();var A=this.style[G];if(!$chk(A)){A=[];for(var F in Element.ShortStyles){if(G!=F){continue;}for(var E in Element.ShortStyles[F]){A.push(this.getStyle(E));}return A.join(" ");}A=this.getComputedStyle(G);}if(A){A=String(A);var C=A.match(/rgba?\([\d\s,]+\)/);if(C){A=A.replace(C[0],C[0].rgbToHex());}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(A)))){if(G.test(/^(height|width)$/)){var B=(G=="width")?["left","right"]:["top","bottom"],D=0;B.each(function(H){D+=this.getStyle("border-"+H+"-width").toInt()+this.getStyle("padding-"+H).toInt();},this);return this["offset"+G.capitalize()]-D+"px";}if(Browser.Engine.presto&&String(A).test("px")){return A;}if(G.test(/(border(.+)Width|margin|padding)/)){return"0px";}}return A;},setStyles:function(B){for(var A in B){this.setStyle(A,B[A]);}return this;},getStyles:function(){var A={};Array.each(arguments,function(B){A[B]=this.getStyle(B);},this);return A;}});Element.Styles=new Hash({width:"@px",height:"@px",left:"@px",top:"@px",bottom:"@px",right:"@px",maxWidth:"@px",maxHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"});Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(G){var F=Element.ShortStyles;var B=Element.Styles;["margin","padding"].each(function(H){var I=H+G;F[H][I]=B[I]="@px";});var E="border"+G;F.border[E]=B[E]="@px @ rgb(@, @, @)";var D=E+"Width",A=E+"Style",C=E+"Color";F[E]={};F.borderWidth[D]=F[E][D]=B[D]="@px";F.borderStyle[A]=F[E][A]=B[A]="@";F.borderColor[C]=F[E][C]=B[C]="rgb(@, @, @)";});(function(){function A(B){return B.tagName.toLowerCase()=="body";}Element.implement({positioned:function(){if(A(this)){return true;}return(Element.getComputedStyle(this,"position")!="static");},getOffsetParent:function(){if(A(this)){return null;}if(!Browser.Engine.trident){return $(this.offsetParent);}var B=this;while((B=B.parentNode)){if(Element.positioned(B)){return $(B);}}return null;},getSize:function(){if(A(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight};},getScrollSize:function(){if(A(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(A(this)){return this.getWindow().getScroll();}return{x:this.scrollLeft,y:this.scrollTop};},scrollTo:function(B,C){if(A(this)){return this.getWindow().scrollTo(B,C);}this.scrollLeft=B;this.scrollTop=C;return this;},getPosition:function(D){if(A(this)){return{x:0,y:0};}var C=this,B={x:0,y:0};while(C){B.x+=C.offsetLeft;B.y+=C.offsetTop;C=C.offsetParent;}var E=(D)?$(D).getPosition():{x:0,y:0};return{x:B.x-E.x,y:B.y-E.y};},getCoordinates:function(D){if(A(this)){return this.getWindow().getCoordinates();}var B=this.getPosition(D),C=this.getSize();var E={top:B.y,left:B.x,width:C.x,height:C.y};E.right=E.left+E.width;E.bottom=E.top+E.height;return E;},getRelativePosition:function(){return this.getPosition(this.getOffsetParent());},computePosition:function(B){return{left:B.x-(this.getComputedStyle("margin-left").toInt()||0),top:B.y-(this.getComputedStyle("margin-top").toInt()||0)};},position:function(B){return this.setStyles(this.computePosition(B));}});})();Native.implement([Window,Document],{getSize:function(){var A=this.getDocument().body,B=this.getDocument().documentElement;if(Browser.Engine.webkit419){return{x:this.innerWidth,y:this.innerHeight};}return{x:B.clientWidth,y:B.clientHeight};},getScroll:function(){var A=this.getDocument().documentElement;return{x:$pick(this.pageXOffset,A.scrollLeft),y:$pick(this.pageYOffset,A.scrollTop)};},getScrollSize:function(){var B=this.getDocument().documentElement,A=this.getDocument().body;if(Browser.Engine.trident){return{x:Math.max(B.clientWidth,B.scrollWidth),y:Math.max(B.clientHeight,B.scrollHeight)};}if(Browser.Engine.webkit){return{x:A.scrollWidth,y:A.scrollHeight};}return{x:B.scrollWidth,y:B.scrollHeight};},getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var A=this.getSize();return{top:0,left:0,height:A.y,width:A.x,bottom:A.y,right:A.x};}});Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y;},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x;},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Element,Document],{getElements:function(N,M){var J={};N=N.split(",");var A=[],H=N.length;var B=(H>1);for(var I=0;I<H;I++){var E=N[I],K=[],G=[];E=E.trim().replace(Selectors.sRegExp,function(P){if(P.charAt(2)){P=P.trim();}G.push(P.charAt(0));return":)"+P.charAt(1);}).split(":)");for(var F=0,D=E.length;F<D;F++){var C=Selectors.parse(E[F]);if(!C){return[];}var O=Selectors.Method.getParam(K,G[F-1]||false,this,C,J);if(!O){break;}K=O;}var L=Selectors.Method.getItems(K,this);A=(B)?A.concat(L):L;}return new Elements(A,{ddup:B,cash:!M});}});Window.implement({$E:function(A){return this.document.getElement(A);}});var Selectors={regExp:(/:([^-:(]+)[^:(]*(?:\((["']?)(.*?)\2\))?|\[(\w+)(?:([!*^$~|]?=)(["']?)(.*?)\6)?\]|\.[\w-]+|#[\w-]+|\w+|\*/g),sRegExp:(/\s*([+>~\s])[a-zA-Z#.*\s]/g)};Selectors.parse=function(A){var B={tag:"*",id:null,classes:[],attributes:[],pseudos:[]};A=A.replace(Selectors.regExp,function(E){switch(E.charAt(0)){case".":B.classes.push(E.slice(1));break;case"#":B.id=E.slice(1);break;case"[":B.attributes.push([arguments[4],arguments[5],arguments[7]]);break;case":":var D=Selectors.Pseudo.get(arguments[1]);if(!D){B.attributes.push([arguments[1],arguments[3]?"=":"",arguments[3]]);break;}var C={name:arguments[1],parser:D,argument:(D.parser)?D.parser(arguments[3]):arguments[3]};B.pseudos.push(C);break;default:B.tag=E;}return"";});return B;};Selectors.Pseudo=new Hash;Selectors.XPath={getParam:function(B,G,D,H){var A="";switch(G){case" ":A+="//";break;case">":A+="/";break;case"+":A+="/following-sibling::*[1]/self::";break;case"~":A+="/following-sibling::";break;}A+=(D.namespaceURI)?"xhtml:"+H.tag:H.tag;var C;for(C=H.pseudos.length;C--;C){var F=H.pseudos[C];if(F.parser&&F.parser.xpath){A+=F.parser.xpath(F.argument);}else{A+=($chk(F.argument))?"[@"+F.name+'="'+F.argument+'"]':"[@"+F.name+"]";}}if(H.id){A+='[@id="'+H.id+'"]';}for(C=H.classes.length;C--;C){A+='[contains(concat(" ", @class, " "), " '+H.classes[C]+' ")]';}for(C=H.attributes.length;C--;C){var E=H.attributes[C];switch(E[1]){case"=":A+="[@"+E[0]+'="'+E[2]+'"]';break;case"*=":A+="[contains(@"+E[0]+', "'+E[2]+'")]';break;case"^=":A+="[starts-with(@"+E[0]+', "'+E[2]+'")]';break;case"$=":A+="[substring(@"+E[0]+", string-length(@"+E[0]+") - "+E[2].length+' + 1) = "'+E[2]+'"]';break;case"!=":A+="[@"+E[0]+'!="'+E[2]+'"]';break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -