📄 mootools-beta-1.2b2.js
字号:
var B=this.options.wait;if(B===false){this.options.link="cancel";}},step:function(){var A=$time();if(A<this.time+this.options.duration){var B=this.options.transition((A-this.time)/this.options.duration);this.set(this.compute(this.from,this.to,B));}else{this.set(this.compute(this.from,this.to,1));this.complete();}},set:function(A){return A;},compute:function(C,B,A){return Fx.compute(C,B,A);},check:function(){if(!this.timer){return true;}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.start.bind(this,arguments));return false;}return false;},start:function(B,A){if(!this.check(B,A)){return this;}this.from=B;this.to=A;this.time=0;this.startTimer();this.onStart();return this;},complete:function(){return(!this.stopTimer())?this:this.onComplete();},cancel:function(){return(!this.stopTimer())?this:this.onCancel();},onStart:function(){return this.fireEvent("onStart",this.pass);},onComplete:function(){return this.fireEvent("onComplete",this.pass).callChain();},onCancel:function(){return this.fireEvent("onCancel",this.pass).clearChain();},pause:function(){this.stopTimer();return this;},resume:function(){this.startTimer();return this;},stopTimer:function(){if(!this.timer){return false;}this.time=$time()-this.time;this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer){return false;}this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true;}});Fx.compute=function(C,B,A){return(B-C)*A+C;};Fx.Durations={"short":250,normal:500,"long":1000};Fx.CSS=new Class({Extends:Fx,prepare:function(D,E,B){B=$splat(B);var C=B[1];if(!$chk(C)){B[1]=B[0];B[0]=D.getStyle(E);}var A=B.map(this.parse);return{from:A[0],to:A[1]};},parse:function(A){A=$lambda(A)();A=(typeof A=="string")?A.split(" "):$splat(A);return A.map(function(C){C=String(C);var B=false;Fx.CSS.Parsers.each(function(F,E){if(B){return ;}var D=F.parse(C);if($chk(D)){B={value:D,parser:F};}});B=B||{value:C,parser:Fx.CSS.Parsers.String};return B;});},compute:function(D,C,B){var A=[];(Math.min(D.length,C.length)).times(function(E){A.push({value:D[E].parser.compute(D[E].value,C[E].value,B),parser:D[E].parser});});A.$family={name:"fx:css:value"};return A;},serve:function(C,B){if($type(C)!="fx:css:value"){C=this.parse(C);}var A=[];C.each(function(D){A=A.concat(D.parser.serve(D.value,B));});return A;},render:function(A,C,B){A.setStyle(C,this.serve(B,this.options.unit));},search:function(A){var B={};Array.each(document.styleSheets,function(D,C){var E=D.rules||D.cssRules;Array.each(E,function(G,F){if(!G.style||!G.selectorText||!G.selectorText.test("^"+A+"$")){return ;}Element.Styles.each(function(I,H){if(!G.style[H]||Element.ShortStyles[H]){return ;}I=G.style[H];B[H]=(I.test(/^rgb/))?I.rgbToHex():I;});});});return B;}});Fx.CSS.Parsers=new Hash({Color:{parse:function(A){if(A.match(/^#[0-9a-f]{3,6}$/i)){return A.hexToRgb(true);}return((A=A.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[A[1],A[2],A[3]]:false;},compute:function(C,B,A){return C.map(function(E,D){return Math.round(Fx.compute(C[D],B[D],A));});},serve:function(A){return A.map(Number);}},Number:{parse:function(A){return parseFloat(A);},compute:function(C,B,A){return Fx.compute(C,B,A);},serve:function(B,A){return(A)?B+A:B;}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}});Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(B,C,A){this.element=this.pass=$(B);this.property=C;arguments.callee.parent(A);},set:function(A){this.render(this.element,this.property,A);return this;},start:function(){var A=Array.slice(arguments);if(!this.check(A)){return this;}var B=this.prepare(this.element,this.property,A);return arguments.callee.parent(B.from,B.to);}});Element.Properties.tween={set:function(A){var B=this.retrieve("tween");if(B){B.cancel();}return this.store("tween",new Fx.Tween(this,null,$extend({link:"cancel"},A)));},get:function(C,A){if(A||!this.retrieve("tween")){this.set("tween",A);}var B=this.retrieve("tween");B.property=C;return B;}};Element.implement({tween:function(B){var A=this.get("tween",B);A.start.apply(A,Array.slice(arguments,1));return this;},fade:function(A){var B=this.get("tween","opacity");A=$pick(A,"toggle");switch(A){case"in":B.start(1);break;case"out":B.start(0);break;case"show":B.set(1);break;case"hide":B.set(0);break;case"toggle":B.start((function(){return(this.getStyle("visibility")=="hidden")?1:0;}).bind(this));break;default:B.start.apply(B,arguments);}return this;},highlight:function(C,A){if(!A){var B=this.getStyle("background-color");A=(B=="transparent")?"#ffffff":B;}this.get("tween","background-color").start(C||"#ffff88",A);return this;},effect:function(B,A){return new Fx.Tween(this,B,A);}});Fx.Morph=new Class({Extends:Fx.CSS,initialize:function(B,A){this.element=this.pass=$(B);arguments.callee.parent(A);},set:function(A){if(typeof A=="string"){A=this.search(A);}for(var B in A){this.render(this.element,B,A[B]);}return this;},compute:function(E,D,C){var A={};for(var B in E){A[B]=arguments.callee.parent(E[B],D[B],C);}return A;},start:function(B){if(!this.check(B)){return this;}if(typeof B=="string"){B=this.search(B);}var E={},D={};for(var C in B){var A=this.prepare(this.element,C,B[C]);E[C]=A.from;D[C]=A.to;}return arguments.callee.parent(E,D);}});Element.Properties.morph={set:function(A){var B=this.retrieve("morph");if(B){B.cancel();}return this.store("morph",new Fx.Morph(this,$extend({link:"cancel"},A)));},get:function(A){if(A||!this.retrieve("morph")){this.set("morph",A);}return this.retrieve("morph");}};Element.implement({morph:function(A){this.get("morph").start(A);return this;},effects:function(A){return new Fx.Morph(this,A);}});Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical"},initialize:function(B,A){this.addEvent("onComplete",function(){this.open=(this.wrapper["offset"+this.layout.capitalize()]!=0);if(this.open){this.wrapper.setStyle(this.layout,"auto");if(Browser.Engine.webkit419){this.element.dispose().inject(this.wrapper);}}},true);this.element=this.pass=$(B);arguments.callee.parent(A);var C=this.element.retrieve("wrapper");this.wrapper=C||new Element("div",{styles:$extend(this.element.getStyles("margin","position"),{overflow:"hidden"})}).wraps(this.element);this.element.store("wrapper",this.wrapper).setStyle("margin",0);this.now=[];this.open=true;},vertical:function(){this.margin="margin-top";this.layout="height";this.offset=this.element.offsetHeight;},horizontal:function(){this.margin="margin-left";this.layout="width";this.offset=this.element.offsetWidth;},set:function(A){this.element.setStyle(this.margin,A[0]);this.wrapper.setStyle(this.layout,A[1]);return this;},compute:function(D,C,B){var A=[];(2).times(function(E){A[E]=Fx.compute(D[E],C[E],B);});return A;},start:function(B,E){if(!this.check(B,E)){return this;}this[E||this.options.mode]();var D=this.element.getStyle(this.margin).toInt();var C=this.wrapper.getStyle(this.layout).toInt();var A=[[D,C],[0,this.offset]];var G=[[D,C],[-this.offset,0]];var F;switch(B){case"in":F=A;break;case"out":F=G;break;case"toggle":F=(this.wrapper["offset"+this.layout.capitalize()]==0)?A:G;}return arguments.callee.parent(F[0],F[1]);},slideIn:function(A){return this.start("in",A);},slideOut:function(A){return this.start("out",A);},hide:function(A){this[A||this.options.mode]();this.open=false;return this.set([-this.offset,0]);},show:function(A){this[A||this.options.mode]();this.open=true;return this.set([0,this.offset]);},toggle:function(A){return this.start("toggle",A);}});Element.Properties.slide={set:function(B){var A=this.retrieve("slide");if(A){A.cancel();}return this.store("slide",new Fx.Slide(this,$extend({link:"cancel"},B)));},get:function(A){if(A||!this.retrieve("slide")){this.set("slide",A);}return this.retrieve("slide");}};Element.implement({slide:function(B){B=B||"toggle";var A=this.get("slide");switch(B){case"hide":A.hide();break;case"show":A.show();break;default:A.start(B);}return this;}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(B,A){this.element=this.pass=$(B);arguments.callee.parent(A);var D=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=$(this.element.getDocument().body);}var C=this.element;if(this.options.wheelStops){this.addEvent("onStart",function(){C.addEvent("mousewheel",D);},true);this.addEvent("onComplete",function(){C.removeEvent("mousewheel",D);},true);}},set:function(){var A=Array.flatten(arguments);this.element.scrollTo(A[0],A[1]);},compute:function(D,C,B){var A=[];(2).times(function(E){A.push(Fx.compute(D[E],C[E],B));});return A;},start:function(C,H){if(!this.check(C,H)){return this;}var E=this.element.getSize(),F=this.element.getScrollSize(),B=this.element.getScroll(),D={x:C,y:H};for(var G in D){var A=F[G]-E[G];if($chk(D[G])){D[G]=($type(D[G])=="number")?D[G].limit(0,A):A;}else{D[G]=B[G];}D[G]+=this.options.offset[G];}return arguments.callee.parent([B.x,B.y],[D.x,D.y]);},toTop:function(){return this.start(false,0);},toLeft:function(){return this.start(0,false);},toRight:function(){return this.start("right",false);},toBottom:function(){return this.start(false,"bottom");},toElement:function(B){var A=$(B).getPosition(this.element);return this.start(A.x,A.y);}});(function(){var A=Fx.prototype.initialize;Fx.prototype.initialize=function(B){A.call(this,B);var C=this.options.transition;if(typeof C=="string"&&(C=C.split(":"))){var D=Fx.Transitions;D=D[C[0]]||D[C[0].capitalize()];if(C[1]){D=D["ease"+C[1].capitalize()+(C[2]?C[2].capitalize():"")];}this.options.transition=D;}};})();Fx.Transition=function(B,A){A=$splat(A);return $extend(B,{easeIn:function(C){return B(C,A);},easeOut:function(C){return 1-B(1-C,A);},easeInOut:function(C){return(C<=0.5)?B(2*C,A)/2:(2-B(2*(1-C),A))/2;}});};Fx.Transitions=new Hash({linear:$arguments(0)});Fx.Transitions.extend=function(A){for(var B in A){Fx.Transitions[B]=new Fx.Transition(A[B]);}};Fx.Transitions.extend({Pow:function(B,A){return Math.pow(B,A[0]||6);},Expo:function(A){return Math.pow(2,8*(A-1));},Circ:function(A){return 1-Math.sin(Math.acos(A));},Sine:function(A){return 1-Math.sin((1-A)*Math.PI/2);},Back:function(B,A){A=A[0]||1.618;return Math.pow(B,2)*((A+1)*B-A);},Bounce:function(D){var C;for(var B=0,A=1;1;B+=A,A/=2){if(D>=(7-4*B)/11){C=-Math.pow((11-6*B-11*D)/4,2)+A*A;break;}}return C;},Elastic:function(B,A){return Math.pow(2,10*--B)*Math.cos(20*B*Math.PI*(A[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(B,A){Fx.Transitions[B]=new Fx.Transition(function(C){return Math.pow(C,[A+2]);});});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{},async:true,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},getXHR:function(){return(window.XMLHttpRequest)?new XMLHttpRequest():((window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):false);},initialize:function(A){if(!(this.xhr=this.getXHR())){return ;}this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers).extend({"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"});},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ;}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;},this);if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300));},processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts);},success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("onComplete",arguments).fireEvent("onSuccess",arguments).callChain();},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("onComplete").fireEvent("onFailure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B);return this;},getHeader:function(A){return $try(function(){return this.getResponseHeader(A);},this.xhr)||null;},check:function(){if(!this.running){return true;}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.send.bind(this,arguments));return false;}return false;},send:function(D){if(!this.check(D)){return this;}this.running=true;var E=$type(D);if(E=="string"||E=="element"){D={data:D};}var A=this.options;D=$extend({data:A.data,url:A.url,method:A.method},D);var G=D.data,C=D.url,H=D.method;switch($type(G)){case"element":G=$(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -