AJS_fx.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. AJS.fx={_shades:{0:"ffffff",1:"ffffee",2:"ffffdd",3:"ffffcc",4:"ffffbb",5:"ffffaa",6:"ffff99"},highlight:function(_1,_2){
  2. var _3=new AJS.fx.Base();
  3. _3.elm=AJS.$(_1);
  4. _3.options.duration=600;
  5. _3.setOptions(_2);
  6. AJS.update(_3,{increase:function(){
  7. if(this.now==7){
  8. _1.style.backgroundColor="#fff";
  9. }else{
  10. _1.style.backgroundColor="#"+AJS.fx._shades[Math.floor(this.now)];
  11. }
  12. }});
  13. return _3.custom(6,0);
  14. },fadeIn:function(_4,_5){
  15. _5=_5||{};
  16. if(!_5.from){
  17. _5.from=0;
  18. AJS.setOpacity(_4,0);
  19. }
  20. if(!_5.to){
  21. _5.to=1;
  22. }
  23. var s=new AJS.fx.Style(_4,"opacity",_5);
  24. return s.custom(_5.from,_5.to);
  25. },fadeOut:function(_7,_8){
  26. _8=_8||{};
  27. if(!_8.from){
  28. _8.from=1;
  29. }
  30. if(!_8.to){
  31. _8.to=0;
  32. }
  33. _8.duration=300;
  34. var s=new AJS.fx.Style(_7,"opacity",_8);
  35. return s.custom(_8.from,_8.to);
  36. },setWidth:function(_a,_b){
  37. var s=new AJS.fx.Style(_a,"width",_b);
  38. return s.custom(_b.from,_b.to);
  39. },setHeight:function(_d,_e){
  40. var s=new AJS.fx.Style(_d,"height",_e);
  41. return s.custom(_e.from,_e.to);
  42. }};
  43. AJS.fx.Base=new AJS.Class({init:function(_10){
  44. this.options={onStart:function(){
  45. },onComplete:function(){
  46. },transition:AJS.fx.Transitions.sineInOut,duration:500,wait:true,fps:50};
  47. AJS.update(this.options,_10);
  48. AJS.bindMethods(this);
  49. },setOptions:function(_11){
  50. AJS.update(this.options,_11);
  51. },step:function(){
  52. var _12=new Date().getTime();
  53. if(_12<this.time+this.options.duration){
  54. this.cTime=_12-this.time;
  55. this.setNow();
  56. }else{
  57. setTimeout(AJS.$b(this.options.onComplete,this,[this.elm]),10);
  58. this.clearTimer();
  59. this.now=this.to;
  60. }
  61. this.increase();
  62. },setNow:function(){
  63. this.now=this.compute(this.from,this.to);
  64. },compute:function(_13,to){
  65. var _15=to-_13;
  66. return this.options.transition(this.cTime,_13,_15,this.options.duration);
  67. },clearTimer:function(){
  68. clearInterval(this.timer);
  69. this.timer=null;
  70. return this;
  71. },_start:function(_16,to){
  72. if(!this.options.wait){
  73. this.clearTimer();
  74. }
  75. if(this.timer){
  76. return;
  77. }
  78. setTimeout(AJS.$p(this.options.onStart,this.elm),10);
  79. this.from=_16;
  80. this.to=to;
  81. this.time=new Date().getTime();
  82. this.timer=setInterval(this.step,Math.round(1000/this.options.fps));
  83. return this;
  84. },custom:function(_18,to){
  85. return this._start(_18,to);
  86. },set:function(to){
  87. this.now=to;
  88. this.increase();
  89. return this;
  90. },setStyle:function(elm,_1c,val){
  91. if(this.property=="opacity"){
  92. AJS.setOpacity(elm,val);
  93. }else{
  94. AJS.setStyle(elm,_1c,val);
  95. }
  96. }});
  97. AJS.fx.Style=AJS.fx.Base.extend({init:function(elm,_1f,_20){
  98. this.parent();
  99. this.elm=elm;
  100. this.setOptions(_20);
  101. this.property=_1f;
  102. },increase:function(){
  103. this.setStyle(this.elm,this.property,this.now);
  104. }});
  105. AJS.fx.Styles=AJS.fx.Base.extend({init:function(elm,_22){
  106. this.parent();
  107. this.elm=AJS.$(elm);
  108. this.setOptions(_22);
  109. this.now={};
  110. },setNow:function(){
  111. for(p in this.from){
  112. this.now[p]=this.compute(this.from[p],this.to[p]);
  113. }
  114. },custom:function(obj){
  115. if(this.timer&&this.options.wait){
  116. return;
  117. }
  118. var _24={};
  119. var to={};
  120. for(p in obj){
  121. _24[p]=obj[p][0];
  122. to[p]=obj[p][1];
  123. }
  124. return this._start(_24,to);
  125. },increase:function(){
  126. for(var p in this.now){
  127. this.setStyle(this.elm,p,this.now[p]);
  128. }
  129. }});
  130. AJS.fx.Transitions={linear:function(t,b,c,d){
  131. return c*t/d+b;
  132. },sineInOut:function(t,b,c,d){
  133. return -c/2*(Math.cos(Math.PI*t/d)-1)+b;
  134. }};
  135. script_loaded=true;
  136. script_loaded=true;