📄 mootools-beta-1.2b2.js
字号:
A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type;var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.match(/DOMMouseScroll|mousewheel/)){var I=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}else{if(J.test(/key/)){var B=A.which||A.keyCode;var L=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111;if(D>0&&D<13){L="f"+D;}}L=L||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){var H={x:A.pageX||A.clientX+F.document.documentElement.scrollLeft,y:A.pageY||A.clientY+F.document.documentElement.scrollTop};var C={x:A.pageX?A.pageX-F.pageXOffset:A.clientX,y:A.pageY?A.pageY-F.pageYOffset:A.clientY};var E=(A.which==3)||(A.button==2);var K=null;if(J.match(/over|out/)){switch(J){case"mouseover":K=A.relatedTarget||A.fromElement;break;case"mouseout":K=A.relatedTarget||A.toElement;}if((function(){while(K&&K.nodeType==3){K=K.parentNode;}}).create({attempt:Browser.Engine.gecko})()===false){K=false;}}}}}return $extend(this,{event:A,type:J,page:H,client:C,rightClick:E,wheel:I,relatedTarget:K,target:G,code:B,key:L,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey});}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault();},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault();}else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(){for(var D in this){this[D]=$unlink(this[D]);}this.parent=null;["Implements","Extends"].each(function(E){if(!this[E]){return ;}Class[E](this,this[E]);delete this[E];},this);this.constructor=A;var C=(arguments[0]!==$empty&&this.initialize)?this.initialize.apply(this,arguments):this;if(this.options&&this.options.initialize){this.options.initialize.call(this);}return C;};$extend(A,this);A.constructor=Class;A.prototype=B;return A;}});Class.implement({implement:function(){Class.Implements(this.prototype,Array.slice(arguments));return this;}});Class.Implements=function(A,B){$splat(B).each(function(C){$extend(A,($type(C)=="class")?new C($empty):C);});};Class.Extends=function(C,A){A=new A($empty);for(var E in A){var B=A[E];var D=C[E];C[E]=(function(G,H){if($defined(H)&&G!=H){var F=$type(H);if(F!=$type(G)){return H;}switch(F){case"function":return function(){H.parent=C.parent=G.bind(this);var I=H.apply(this,arguments);C.parent=H.parent;return I;};case"object":return $merge(G,H);default:return H;}}return G;})(B,D);}};Class.prototype.extend=function(A){A.Extends=this;return new Class(A);};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments);return this;},callChain:function(){if(this.$chain&&this.$chain.length){this.$chain.shift().apply(this,arguments);}return this;},clearChain:function(){if(this.$chain){this.$chain.empty();}return this;}});var Events=new Class({addEvent:function(C,B,A){if(B!=$empty){this.$events=this.$events||{};this.$events[C]=this.$events[C]||[];this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,arguments:B})();},this);return this;},removeEvent:function(B,A){if(!this.$events||!this.$events[B]){return this;}if(!A.internal){this.$events[B].remove(A);}return this;},removeEvents:function(C){for(var D in this.$events){if(C&&C!=D){continue;}var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]);}}return this;}});var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue;}this.addEvent(A,this.options[A]);delete this.options[A];}return this;}});Document.implement({newElement:function(A,B){if(Browser.Engine.trident&&B){["name","type","checked"].each(function(C){if(!B[C]){return ;}A+=" "+C+'="'+B[C]+'"';if(C!="checked"){delete B[C];}});A="<"+A+">";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A);},getDocument:function(){return this;},getWindow:function(){return this.defaultView||this.parentWindow;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(A,B){var C=Element.Constructors.get(A);if(C){return C(B);}if(typeof A=="string"){return document.newElement(A,B);}return $(A).set(B);},afterImplement:function(A,B){if(!Array[A]){Elements.implement(A,Elements.multi(A));}Element.Prototype[A]=B;}});Element.Prototype={$family:{name:"element"}};Element.Constructors=new Hash;var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){Native.UID++;var E=Array.link(arguments,{properties:Object.type,iframe:$defined});var C=E.properties||{};var B=$(E.iframe)||false;var D=C.onload||$empty;delete C.onload;C.id=C.name=$pick(C.id,C.name,B.id,B.name,"IFrame_"+Native.UID);((B=B||new Element("iframe"))).set(C);var A=function(){var F=$try(function(){return B.contentWindow.location.host;});if(F&&F==window.location.host){B.window=B.contentWindow;var H=new Window(B.window);var G=new Document(B.window.document);$extend(H.Element.prototype,Element.Prototype);}D.call(B.contentWindow);};(!window.frames[C.id])?B.addListener("load",A):A();return B;}});var Elements=new Native({initialize:function(F,B){B=$extend({ddup:true,cash:true},B);F=F||[];if(B.ddup||B.cash){var G={};var E=[];for(var C=0,A=F.length;C<A;C++){var D=$.element(F[C],!B.cash);if(B.ddup){if(G[D.uid]){continue;}G[D.uid]=true;}E.push(D);}F=E;}return(B.cash)?$extend(F,this):F;}});Elements.implement({filterBy:function(A){if(!A){return this;}return new Elements(this.filter((typeof A=="string")?function(B){return B.match(A);}:A));}});Elements.multi=function(A){return function(){var B=[];var F=true;for(var D=0,C=this.length;D<C;D++){var E=this[D][A].apply(this[D],arguments);B.push(E);if(F){F=($type(E)=="element");}}return(F)?new Elements(B):B;};};Window.implement({$:function(B,C){if(B&&B.$attributes){return B;}var A=$type(B);return($[A])?$[A](B,C,this.document):null;},$$:function(A){if(arguments.length==1&&typeof A=="string"){return this.document.getElements(A);}var F=[];var C=Array.flatten(arguments);for(var D=0,B=C.length;D<B;D++){var E=C[D];switch($type(E)){case"element":E=[E];break;case"string":E=this.document.getElements(E,true);break;default:E=false;}if(E){F.extend(E);}}return new Elements(F);},getDocument:function(){return this.document;},getWindow:function(){return this;}});$.string=function(C,A,B){C=B.getElementById(C);return(C)?$.element(C,A):null;};$.element=function(A,B){A.uid=A.uid||[Native.UID++];if(!B&&Garbage.collect(A)&&!A.$family){$extend(A,Element.Prototype);}return A;};$.textnode=$.window=$.document=$arguments(0);$.number=function(A){return Garbage.Elements[A]||null;};Native.implement([Element,Document],{getElement:function(A,B){return $(this.getElements(A,true)[0]||null,B);},getElements:function(A,D){A=A.split(",");var C=[];var B=(A.length>1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D});}});Element.Storage={get:function(A){return(this[A]=this[A]||{});}};Element.Inserters=new Hash({before:function(B,A){if(A.parentNode){A.parentNode.insertBefore(B,A);}},after:function(B,A){if(!A.parentNode){return ;}var C=A.nextSibling;(C)?A.parentNode.insertBefore(B,C):A.parentNode.appendChild(B);},bottom:function(B,A){A.appendChild(B);},top:function(B,A){var C=A.firstChild;(C)?A.insertBefore(B,C):A.appendChild(B);}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(C,B){var A=B.capitalize();Element.implement("inject"+A,function(D){Element.Inserters[B](this,$(D,true));return this;});Element.implement("grab"+A,function(D){Element.Inserters[B]($(D,true),this);return this;});});Element.implement({getDocument:function(){return this.ownerDocument;},getWindow:function(){return this.ownerDocument.getWindow();},getElementById:function(D,C){var B=this.ownerDocument.getElementById(D);if(!B){return null;}for(var A=B.parentNode;A!=this;A=A.parentNode){if(!A){return null;}}return $.element(B,C);},set:function(D,B){switch($type(D)){case"object":for(var C in D){this.set(C,D[C]);}break;case"string":var A=Element.Properties.get(D);(A&&A.set)?A.set.apply(this,Array.slice(arguments,1)):this.setProperty(D,B);}return this;},get:function(B){var A=Element.Properties.get(B);return(A&&A.get)?A.get.apply(this,Array.slice(arguments,1)):this.getProperty(B);},erase:function(B){var A=Element.Properties.get(B);(A&&A.erase)?A.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(B);return this;},match:function(A){return(!A||Element.get(this,"tag")==A);},inject:function(B,A){Element.Inserters.get(A||"bottom")(this,$(B,true));return this;},wraps:function(B,A){B=$(B,true);return this.replaces(B).grab(B);},grab:function(B,A){Element.Inserters.get(A||"bottom")($(B,true),this);return this;},appendText:function(B,A){return this.grab(this.getDocument().newTextNode(B),A);},adopt:function(){Array.flatten(arguments).each(function(A){this.appendChild($(A,true));},this);return this;},dispose:function(){return this.parentNode.removeChild(this);},clone:function(B){var A=new Element("div").grab(this.cloneNode(B!==false));Array.each(A.getElementsByTagName("*"),function(C){if(C.id){C.removeAttribute("id");}});return new Element("div").set("html",A.innerHTML).getFirst();},replaces:function(A){A=$(A,true);A.parentNode.replaceChild(this,A);return this;},hasClass:function(A){return this.className.contains(A," ");},addClass:function(A){if(!this.hasClass(A)){this.className=(this.className+" "+A).clean();}return this;},removeClass:function(A){this.className=this.className.replace(new RegExp("(^|\\s)"+A+"(?:\\s|$)"),"$1").clean();return this;},toggleClass:function(A){return this.hasClass(A)?this.removeClass(A):this.addClass(A);},getComputedStyle:function(C){var A=null;if(this.currentStyle){A=this.currentStyle[C.camelCase()];}else{var B=this.getWindow().getComputedStyle(this,null);if(B){A=B.getPropertyValue([C.hyphenate()]);}}return A;},empty:function(){var A=$A(this.getElementsByTagName("*"));A.each(function(B){$try(Element.prototype.dispose,B);});Garbage.trash(A);$try(Element.prototype.set,this,["html",""]);return this;},destroy:function(){Garbage.kill(this.empty().dispose());return null;},toQueryString:function(){var A=[];this.getElements("input, select, textarea",true).each(function(D){var B=D.name,C=D.type,E=Element.get(D,"value");if(E===false||!B||D.disabled){return ;}$splat(E).each(function(F){A.push(B+"="+encodeURIComponent(F));});});return A.join("&");},getProperty:function(C){var B=Element.Attributes,A=B.Props[C];var D=(A)?this[A]:this.getAttribute(C);return(B.Bools[C])?!!D:D;},getProperties:function(){var A=$A(arguments);return A.map(function(B){return this.getProperty(B);},this).associate(A);},setProperty:function(D,E){var C=Element.Attributes,B=C.Props[D],A=$defined(E);if(B&&C.Bools[D]){E=(E||!A)?true:false;}else{if(!A){return this.removeProperty(D);}}(B)?this[B]=E:this.setAttribute(D,E);return this;},setProperties:function(A){for(var B in A){this.setProperty(B,A[B]);}return this;},removeProperty:function(D){var C=Element.Attributes,B=C.Props[D],A=(B&&C.Bools[D]);(B)?this[B]=(A)?false:"":this.removeAttribute(D);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this;}});(function(){var A=function(D,B,I,C,F,H){var E=D[I||B];var G=[];while(E){if(E.nodeType==1&&Element.match(E,C)){G.push(E);if(!F){break;}}E=E[B];}return(F)?new Elements(G,{ddup:false,cash:!H}):$(G[0],H);};Element.implement({getPrevious:function(B,C){return A(this,"previousSibling",null,B,false,C);},getAllPrevious:function(B,C){return A(this,"previousSibling",null,B,true,C);},getNext:function(B,C){return A(this,"nextSibling",null,B,false,C);},getAllNext:function(B,C){return A(this,"nextSibling",null,B,true,C);},getFirst:function(B,C){return A(this,"nextSibling","firstChild",B,false,C);},getLast:function(B,C){return A(this,"previousSibling","lastChild",B,false,C);},getParent:function(B,C){return A(this,"parentNode",null,B,false,C);},getParents:function(B,C){return A(this,"parentNode",null,B,true,C);},getChildren:function(B,C){return A(this,"nextSibling","firstChild",B,true,C);},hasChild:function(B){if(!(B=$(B,true))){return false;}return Element.getParents(B,this.get("tag"),true).contains(this);}});})();Element.alias("dispose","remove").alias("getLast","getLastChild");Element.Properties=new Hash;Element.Properties.style={set:function(A){this.style.cssText=A;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -