📄 effects.js
字号:
Effect.MoveBy=function(_30,_31,_32){return new Effect.Move(_30,Object.extend({x:_32,y:_31},arguments[3]||{}));};Effect.Scale=Class.create();Object.extend(Object.extend(Effect.Scale.prototype,Effect.Base.prototype),{initialize:function(_33,_34){this.element=$(_33);if(!this.element){throw (Effect._elNotExistErr);}var _35=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_34},arguments[2]||{});this.start(_35);},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each(function(k){this.originalStyle[k]=this.element.style[k];}.bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var _37=this.element.getStyle("font-size")||"100%";["em","px","%","pt"].each(function(_38){if(_37.indexOf(_38)>0){this.fontSize=parseFloat(_37);this.fontSizeType=_38;}}.bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth];}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth];}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];}},update:function(_39){var _3a=(this.options.scaleFrom/100)+(this.factor*_39);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*_3a+this.fontSizeType});}this.setDimensions(this.dims[0]*_3a,this.dims[1]*_3a);},finish:function(_3b){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle);}},setDimensions:function(_3c,_3d){var d={};if(this.options.scaleX){d.width=Math.round(_3d)+"px";}if(this.options.scaleY){d.height=Math.round(_3c)+"px";}if(this.options.scaleFromCenter){var _3f=(_3c-this.dims[0])/2;var _40=(_3d-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){d.top=this.originalTop-_3f+"px";}if(this.options.scaleX){d.left=this.originalLeft-_40+"px";}}else{if(this.options.scaleY){d.top=-_3f+"px";}if(this.options.scaleX){d.left=-_40+"px";}}}this.element.setStyle(d);}});Effect.Highlight=Class.create();Object.extend(Object.extend(Effect.Highlight.prototype,Effect.Base.prototype),{initialize:function(_41){this.element=$(_41);if(!this.element){throw (Effect._elNotExistErr);}var _42=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(_42);},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();return;}this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"});}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff");}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("background-color");}this._base=$R(0,2).map(function(i){return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16);}.bind(this));this._delta=$R(0,2).map(function(i){return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i];}.bind(this));},update:function(_45){this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(m,v,i){return m+(Math.round(this._base[i]+(this._delta[i]*_45)).toColorPart());}.bind(this))});},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}));}});Effect.ScrollTo=Class.create();Object.extend(Object.extend(Effect.ScrollTo.prototype,Effect.Base.prototype),{initialize:function(_49){this.element=$(_49);this.start(arguments[1]||{});},setup:function(){Position.prepare();var _4a=Position.cumulativeOffset(this.element);if(this.options.offset){_4a[1]+=this.options.offset;}var max=window.innerHeight?window.height-window.innerHeight:document.body.scrollHeight-(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight);this.scrollStart=Position.deltaY;this.delta=(_4a[1]>max?max:_4a[1])-this.scrollStart;},update:function(_4c){Position.prepare();window.scrollTo(Position.deltaX,this.scrollStart+(_4c*this.delta));}});Effect.Fade=function(_4d){_4d=$(_4d);var _4e=_4d.getInlineOpacity();var _4f=Object.extend({from:_4d.getOpacity()||1,to:0,afterFinishInternal:function(_50){if(_50.options.to!=0){return;}_50.element.hide().setStyle({opacity:_4e});}},arguments[1]||{});return new Effect.Opacity(_4d,_4f);};Effect.Appear=function(_51){_51=$(_51);var _52=Object.extend({from:(_51.getStyle("display")=="none"?0:_51.getOpacity()||0),to:1,afterFinishInternal:function(_53){_53.element.forceRerendering();},beforeSetup:function(_54){_54.element.setOpacity(_54.options.from).show();}},arguments[1]||{});return new Effect.Opacity(_51,_52);};Effect.Puff=function(_55){_55=$(_55);var _56={opacity:_55.getInlineOpacity(),position:_55.getStyle("position"),top:_55.style.top,left:_55.style.left,width:_55.style.width,height:_55.style.height};return new Effect.Parallel([new Effect.Scale(_55,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(_55,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(_57){Position.absolutize(_57.effects[0].element);},afterFinishInternal:function(_58){_58.effects[0].element.hide().setStyle(_56);}},arguments[1]||{}));};Effect.BlindUp=function(_59){_59=$(_59);_59.makeClipping();return new Effect.Scale(_59,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_5a){_5a.element.hide().undoClipping();}},arguments[1]||{}));};Effect.BlindDown=function(_5b){_5b=$(_5b);var _5c=_5b.getDimensions();return new Effect.Scale(_5b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_5c.height,originalWidth:_5c.width},restoreAfterFinish:true,afterSetup:function(_5d){_5d.element.makeClipping().setStyle({height:"0px"}).show();},afterFinishInternal:function(_5e){_5e.element.undoClipping();}},arguments[1]||{}));};Effect.SwitchOff=function(_5f){_5f=$(_5f);var _60=_5f.getInlineOpacity();return new Effect.Appear(_5f,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(_61){new Effect.Scale(_61.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(_62){_62.element.makePositioned().makeClipping();},afterFinishInternal:function(_63){_63.element.hide().undoClipping().undoPositioned().setStyle({opacity:_60});}});}},arguments[1]||{}));};Effect.DropOut=function(_64){_64=$(_64);var _65={top:_64.getStyle("top"),left:_64.getStyle("left"),opacity:_64.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(_64,{x:0,y:100,sync:true}),new Effect.Opacity(_64,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(_66){_66.effects[0].element.makePositioned();},afterFinishInternal:function(_67){_67.effects[0].element.hide().undoPositioned().setStyle(_65);}},arguments[1]||{}));};Effect.SlideDown=function(_68){_68=$(_68).cleanWhitespace();var _69=_68.down().getStyle("bottom");var _6a=_68.getDimensions();return new Effect.Scale(_68,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:_6a.height,originalWidth:_6a.width},restoreAfterFinish:true,afterSetup:function(_6b){_6b.element.makePositioned();_6b.element.down().makePositioned();if(window.opera){_6b.element.setStyle({top:""});}_6b.element.makeClipping().setStyle({height:"0px"}).show();},afterUpdateInternal:function(_6c){_6c.element.down().setStyle({bottom:(_6c.dims[0]-_6c.element.clientHeight)+"px"});},afterFinishInternal:function(_6d){_6d.element.undoClipping().undoPositioned();_6d.element.down().undoPositioned().setStyle({bottom:_69});}},arguments[1]||{}));};Effect.SlideUp=function(_6e){_6e=$(_6e).cleanWhitespace();var _6f=_6e.down().getStyle("bottom");return new Effect.Scale(_6e,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(_70){_70.element.makePositioned();_70.element.down().makePositioned();if(window.opera){_70.element.setStyle({top:""});}_70.element.makeClipping().show();},afterUpdateInternal:function(_71){_71.element.down().setStyle({bottom:(_71.dims[0]-_71.element.clientHeight)+"px"});},afterFinishInternal:function(_72){_72.element.hide().undoClipping().undoPositioned().setStyle({bottom:_6f});_72.element.down().undoPositioned();}},arguments[1]||{}));};Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle "+"borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth "+"borderRightColor borderRightStyle borderRightWidth borderSpacing "+"borderTopColor borderTopStyle borderTopWidth bottom clip color "+"fontSize fontWeight height left letterSpacing lineHeight "+"marginBottom marginLeft marginRight marginTop markerOffset maxHeight "+"maxWidth minHeight minWidth opacity outlineColor outlineOffset "+"outlineWidth paddingBottom paddingLeft paddingRight paddingTop "+"right textIndent top width wordSpacing zIndex");Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.prototype.parseStyle=function(){var _73=Element.extend(document.createElement("div"));_73.innerHTML="<div style=\""+this+"\"></div>";var _74=_73.down().style,_75=$H();Element.CSS_PROPERTIES.each(function(_76){if(_74[_76]){_75[_76]=_74[_76];}});if(/MSIE/.test(navigator.userAgent)&&!window.opera&&this.indexOf("opacity")>-1){_75.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];}return _75;};["setOpacity","getOpacity","getInlineOpacity","forceRerendering"].each(function(f){Element.Methods[f]=Element[f];});Element.addMethods();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -