MzEffect.js
上传用户:yatiankong
上传日期:2014-05-16
资源大小:5604k
文件大小:29k
源码类别:

Applet

开发平台:

Java

  1. /*---------------------------------------------------------------------------*
  2. |  Subject:    Html Element effect base
  3. |  NameSpace:  System.Web.Forms.MzEffect
  4. |  Author:     meizz
  5. |  Created:    2006-07-07
  6. |  Version:    2006-12-12
  7. |-----------------------------------
  8. |  MSN: huangfr@msn.com QQ:112889082 Copyright (c) meizz
  9. |  http://www.meizz.com/jsframework/ MIT-style license
  10. |  The above copyright notice and this permission notice shall be
  11. |  included in all copies or substantial portions of the Software
  12. *---------------------------------------------------------------------------*/
  13. /*/Interface
  14. Required: initialize() render() finish() restore()
  15. abort() end() cancel() dispose()
  16. op.onbeforestart() op.onbeforeupdate() op.onafterupdate() op.onafterfinish()
  17. /*/
  18. //op{interval, duration, overlap, trend, continual}
  19. function MzEffect()
  20. {
  21.   System.call(this);this.readyState=1;
  22.   this.element=MzElement.check(arguments[0]);
  23.   if(!this.element) return; var t;
  24.   this.terminative=false;  //true for terminate effect
  25.   var op=this.options=System.extend({
  26.     "interval": 10,   //milliseconds
  27.     "duration": 800,  //milliseconds
  28.     "overlap":  false,
  29.     "continual": true,
  30.     "trend": "strengthen" //strengthen|weaken true|false
  31.   },
  32.     arguments[1]||{}
  33.   );
  34.   op["trend"]= ("boolean"==typeof(op["trend"]) && op["trend"]) ||
  35.     ("string"==typeof(op["trend"]) && op["trend"].toLowerCase()=="strengthen");
  36.   //prevent repeated effect
  37.   if(!op.overlap){
  38.   this.attribName = "att_"+ this._className.replace(/W/g, "_");
  39.   if(t=this.element.getAttribute(this.attribName))if(t=Instance(t))t.cancel();
  40.   this.element.setAttribute(this.attribName, this.hashCode, 0);}
  41.   this.beginTime = new Date().getTime();
  42.   this.endTime = this.beginTime + op.duration;
  43.   if(this.initialize) this.initialize();
  44.   if(op.onbeforestart) op.onbeforestart(this); this.readyState=2;
  45.   if(op.continual) this._process();else if(!this.restore){
  46.   this.restore=function(){};this.dispose();}
  47. };
  48. t=MzEffect.Extends(System, "MzEffect");
  49. t._process=function()
  50. {
  51.   var now = new Date().getTime(), me = this, op=this.options;
  52.   if (now>=this.endTime)
  53.   {
  54.     if(this.render) this.render((op.trend==true ? 1 : 0));
  55.     if(this.finish) this.finish(); this.readyState=4;
  56.     if(op.onafterfinish) op.onafterfinish(this);
  57.     this.dispose(); return;
  58.   } if(op){
  59.   var schedule = Math.sqrt((now-this.beginTime)/op.duration);
  60.   if(op.trend!=true) schedule = Math.pow((this.endTime-now)/op.duration, 2);
  61.   this.schedule = schedule;
  62.   if(op.onbeforeupdate) op.onbeforeupdate(this);
  63.   if(this.render)this.render(schedule);
  64.   if(op.onafterupdate)op.onafterupdate(this);if(!this.terminative)
  65.   this.timer=setTimeout(function(){me._process()},op.interval); else
  66.   try{this.element.removeAttribute(this.attribName);}catch(ex){}}
  67.   me.readyState=3; 
  68. };
  69. t.abort=function(){if(this.timer)clearTimeout(this.timer);};
  70. t.end=function()
  71. {
  72.   if(this.readyState==4) return;
  73.   if(this.timer) clearTimeout(this.timer);
  74.   this.endTime = this.beginTime; this._process();
  75. }
  76. t.cancel=function()
  77. {
  78.   this.endTime = this.beginTime;
  79.   if(this.timer)  clearTimeout(this.timer);
  80.   if(this.restore) this.restore();
  81.   this.dispose();
  82. };
  83. t.dispose=function()
  84. {
  85.   this.decontrol(); if(this.element)
  86.   this.element.removeAttribute(this.attribName);
  87.   delete this.timer;
  88.   delete this.element;
  89.   delete this.options;
  90.   delete this.endTime;
  91.   delete this.schedule;
  92.   delete this.beginTime;
  93.   delete this.attribName;
  94.   delete this.terminative;
  95.   if(System.ie) CollectGarbage();
  96. };
  97. MzEffect.formatColor=function(color)
  98. {
  99.   if(/^#[da-z]{6}$/i.test(color)) return color;
  100.   else if(color.indexOf("rgb(")==0)
  101.   {
  102.     var cs=color.substring(4, color.length-1).split(",");
  103.     for(var i=0, color="#"; i<cs.length; i++)
  104.     {
  105.       var s = parseInt(cs[i]).toString(16);
  106.       color+= ("00"+ s).substr(s.length);
  107.     }
  108.     return color;
  109.   }
  110.   return "";
  111. };
  112. /*--====== core effect ======--*/
  113. //op{interval, duration, trend}
  114. MzEffect.Opacity=function(element, op)
  115. {
  116.   op = System.extend({interval: 20}, op||{});
  117.   op.simple = (System.ie && MzBrowser.version<5.5)
  118.     || (MzBrowser.opera  && MzBrowser.version<8.5);
  119.   MzEffect.apply(this, [element, op]);
  120. };
  121. MzEffect.Opacity.Extends(MzEffect, "MzEffect.Opacity").initialize=function()
  122. {
  123.   var op=this.options, obj=this.element, me=this;
  124.   this.render=function(schedule)
  125.   {
  126.     schedule = me.schedule || schedule;
  127.     if(op.simple){me.endTime-=op.duration; return;}
  128.     if(!System.ie)
  129.     {
  130.       obj.style.opacity = schedule;
  131.       obj.style.MozOpacity = schedule;
  132.       obj.style.KHTMLOpacity = schedule;
  133.     }
  134.     else obj.style.filter = "alpha(opacity:"+Math.round(schedule*100)+")";
  135.   };
  136.   if (System.ie)op.originalFilter = obj.style.filter; else
  137.   {
  138.     op.originalOpacity = obj.style.opacity;
  139.     op.originalMozOpacity = obj.style.MozOpacity;
  140.     op.originalKHTMLOpacity = obj.style.KHTMLOpacity;
  141.   }
  142.   this.restore=function()
  143.   {
  144.     if(System.ie) obj.style.filter = op.originalFilter; else
  145.     {
  146.       obj.style.opacity = op.originalOpacity;
  147.       obj.style.MozOpacity = op.originalMozOpacity;
  148.       obj.style.KHTMLOpacity = op.originalKHTMLOpacity;
  149.     }
  150.   };
  151. };
  152. //op{interval, duration, trend}
  153. MzEffect.MoveBy=function(element, x, y, op)
  154. {
  155.   if("undefined"==typeof x || "undefined"==typeof y) return;
  156.   this.offsetX=parseFloat(x);
  157.   this.offsetY=parseFloat(y);
  158.   op=System.extend({duration: 400}, op||{});
  159.   MzEffect.apply(this, [element, op]);
  160. };
  161. MzEffect.MoveBy.Extends(MzEffect, "MzEffect.MoveBy").initialize=function()
  162. {
  163.   var me=this, obj=me.element, op=me.options;
  164.   op.originalTop  = obj.style.top;
  165.   op.originalLeft = obj.style.left;
  166.   op.originalPosition = obj.style.position;
  167.   me.originalY = parseFloat(obj.style.top  || '0');
  168.   me.originalX = parseFloat(obj.style.left || '0');
  169.   if(obj.style.position == "") obj.style.position = "relative";
  170.   this.render=function(schedule)
  171.   {
  172.     schedule = me.schedule || schedule;
  173.     obj.style.left = (me.offsetX * schedule + me.originalX) +"px";
  174.     obj.style.top  = (me.offsetY * schedule + me.originalY) +"px";
  175.   };
  176.   this.setPosition=function(x, y)
  177.   {
  178.     obj.style.top  = y +"px";
  179.     obj.style.left = x +"px";
  180.   };
  181.   this.restore=function()
  182.   {
  183.     obj.style.top  = op.originalTop;
  184.     obj.style.left = op.originalLeft;
  185.     obj.style.position = op.originalPosition;
  186.   };
  187. };
  188. //op{interval, duration, trend}
  189. MzEffect.MoveTo=function(element, x, y, op)
  190. {
  191.   if("undefined"==typeof x || "undefined"==typeof y) return;
  192.   this.x=parseFloat(x);this.y=parseFloat(y);
  193.   op=System.extend({duration: 300}, op||{});
  194.   MzEffect.apply(this, [element, op]);
  195. };
  196. MzEffect.MoveTo.Extends(MzEffect, "MzEffect.MoveTo").initialize=function()
  197. {
  198.   var me=this, obj=me.element, op=me.options;
  199.   op.originalTop  = obj.style.top;
  200.   op.originalLeft = obj.style.left;
  201.   op.originalPosition = obj.style.position;
  202.   me.originalY = parseFloat(obj.style.top  || '0');
  203.   me.originalX = parseFloat(obj.style.left || '0');
  204.   me.offsetX = me.x - me.originalX;
  205.   me.offsetY = me.y - me.originalY;
  206.   if(obj.style.position == "") obj.style.position = "relative";
  207.   this.render=function(schedule)
  208.   {
  209.     schedule = me.schedule || schedule;
  210.     obj.style.left = (me.offsetX * schedule + me.originalX) +"px";
  211.     obj.style.top  = (me.offsetY * schedule + me.originalY) +"px";
  212.   };
  213.   this.setPosition=function(x, y)
  214.   {
  215.     obj.style.top  = y +"px";
  216.     obj.style.left = x +"px";
  217.   };
  218.   this.restore=function()
  219.   {
  220.     obj.style.top  = op.originalTop;
  221.     obj.style.left = op.originalLeft;
  222.     obj.style.position = op.originalPosition;
  223.   };
  224. };
  225. //op{interval, duration, trend, color, beginColor, endColor, finalColor}
  226. function n2h(s){s=parseInt(s).toString(16);return ("00"+ s).substr(s.length);}
  227. MzEffect.Highlight=function(element, op){MzEffect.apply(this, arguments);};
  228. MzEffect.Highlight.Extends(MzEffect, "MzEffect.Highlight").initialize=function()
  229. {
  230.   var op=this.options, obj=this.element, endColor="#FFFFFF";
  231.   if(System.ie) var backColor = (obj.currentStyle||obj.style).backgroundColor;
  232.   else var backColor = obj.getCssValue("background-color");
  233.   op.originalBgColor = obj.style.backgroundColor;
  234.   op.originalColor = obj.style.color;
  235.   if(backColor) endColor = MzEffect.formatColor(backColor);
  236.   op.beginColor = op.beginColor || "#FFFF00";
  237.   op.endColor   = op.endColor || endColor;
  238.   op.finalColor = op.finalColor || obj.style.backgroundColor;
  239.   this.colors_base=[
  240.     parseInt(op.beginColor.substring(1,3),16),
  241.     parseInt(op.beginColor.substring(3,5),16),
  242.     parseInt(op.beginColor.substr(5),16)];
  243.   this.colors_var=[
  244.     parseInt(op.endColor.substring(1,3),16)-this.colors_base[0],
  245.     parseInt(op.endColor.substring(3,5),16)-this.colors_base[1],
  246.     parseInt(op.endColor.substr(5),16)-this.colors_base[2]];
  247.   this.finish=function()
  248.   {
  249.     if(op.color) obj.style.color = op.color;
  250.     obj.style.backgroundColor = op.finalColor;
  251.   };
  252.   this.render=function(schedule)
  253.   {
  254.     schedule = this.schedule || schedule;
  255.     var colors=[
  256.       n2h(Math.round(this.colors_base[0]+(this.colors_var[0]*schedule))),
  257.       n2h(Math.round(this.colors_base[1]+(this.colors_var[1]*schedule))),
  258.       n2h(Math.round(this.colors_base[2]+(this.colors_var[2]*schedule)))];
  259.     obj.style.backgroundColor = "#"+ colors.join("");
  260.   };
  261.   this.restore=function()
  262.   {
  263.     obj.style.color = op.originalColor;
  264.     obj.style.backgroundColor = op.originalBgColor;
  265.   };
  266.   this.dispose=function()
  267.   {
  268.     MzEffect.prototype.dispose.call(this);
  269.     delete this.colors_base;
  270.     delete this.colors_var;
  271.   };
  272. };
  273. MzEffect.Curtain=function(element, op)
  274. {
  275.   op = System.extend(
  276.   {
  277.     direction: "",
  278.     scaleContent: false
  279.   }, op||{});
  280.   MzEffect.apply(this, [element, op]);
  281. }
  282. MzEffect.Curtain.Extends(MzEffect, "MzEffect.Mask").initialize=function()
  283. {
  284.   var me=this, op=me.options, obj=me.element;
  285.   op.direction = op.direction.toLowerCase();
  286.   op.originalWidth  = obj.style.width;
  287.   op.originalHeight = obj.style.height;
  288.   op.originalOverflow = obj.style.overflow;
  289.   op.originalPosition = obj.style.position;
  290.   op.originalVisibility = obj.style.visibility;
  291.   op.originalMarginTop = (obj.currentStyle || obj.style).marginTop;
  292.   op.originalOffsetWidth  = obj.offsetWidth;
  293.   op.originalOffsetHeight = obj.offsetHeight;
  294.   obj.style.overflow = "hidden";
  295.   this.restore=function()
  296.   {
  297.     obj.style.width = op.originalWidth;
  298.     obj.style.height = op.originalHeight;
  299.     obj.style.overflow = op.originalOverflow;
  300.     obj.style.position = op.originalPosition;
  301.     obj.style.marginTop = op.originalMarginTop;
  302.     obj.style.visibility = op.originalVisibility;
  303.   };
  304.   this.finish=function(){this.restore();};
  305.   this.render=function(schedule){};
  306. };
  307. //op{interval, duration, trend, dirction}
  308. MzEffect.Mask=function(element, op)
  309. {
  310.   op=System.extend({direction: "box"}, op||{});
  311.   MzEffect.apply(this, [element, op]);
  312. };
  313. MzEffect.Mask.Extends(MzEffect, "MzEffect.Mask").initialize=function()
  314. {
  315.   var me=this, op=me.options, obj=me.element;
  316.   if (!op.trend && obj.style.display=="none"){me.endTime-=op.duration; return;}
  317.   op.direction = op.direction.toLowerCase();
  318.   if(op.direction=="random")
  319.   {
  320.     var a=["box","center-up-down", "center-right-left", "top", "bottom",
  321.       "left", "right", "top-right", "top-left", "right-top", "left-top"];
  322.     var n=Math.floor(Math.random() * a.length);
  323.     op.direction = (n>=a.length) ? "box" : a[n];
  324.   }
  325.   op.originalTop  = obj.style.top;
  326.   op.originalLeft = obj.style.left;
  327.   op.originalClip = obj.style.clip;
  328.   op.originalWidth= obj.style.width;
  329.   op.originalHeight= obj.style.height;
  330.   if(System.ie) op.originalPosition = (obj.currentStyle || obj.style).position;
  331.   else op.originalPosition = obj.getCssValue("position");
  332.   if (op.trend){op.originalVisibility = obj.style.visibility;
  333.   obj.style.visibility = "hidden"; MzElement.show(obj);}
  334.   op.originalOffsetWidth  = obj.offsetWidth;
  335.   op.originalOffsetHeight = obj.offsetHeight;
  336.   if(System.ie || window.opera)
  337.   {
  338.     obj.style.width = op.originalOffsetWidth +"px";
  339.     obj.style.height= op.originalOffsetHeight+"px";
  340.   }
  341.   else
  342.   {
  343.     obj.style.width = (op.originalOffsetWidth
  344.       - parseInt(obj.style.borderLeftWidth||0)
  345.       - parseInt(obj.style.borderRightWidth||0)) +"px";
  346.     obj.style.height= (op.originalOffsetHeight
  347.       - parseInt(obj.style.borderTopWidth||0)
  348.       - parseInt(obj.style.borderBottomWidth||0)) +"px";
  349.   }
  350.   if (op.trend) obj.style.visibility = op.originalVisibility;
  351.   //for opacity 20070114
  352.   if (System.ie)op.originalFilter = obj.style.filter; else
  353.   {
  354.     op.originalOpacity = obj.style.opacity;
  355.     op.originalMozOpacity = obj.style.MozOpacity;
  356.     op.originalKHTMLOpacity = obj.style.KHTMLOpacity;
  357.   }
  358.   if(op.originalPosition!="absolute")
  359.   {
  360.     obj.style.position = "absolute";
  361.     var input = document.createElement("INPUT");
  362.     input.type="text";   input.style.border="none";
  363.     input.readOnly=true; input.style.fontSize="1px";
  364.     input.style.margin=input.style.padding=0;
  365.     input.id = "MzEffectMaskStuffing"+ this.hashCode;
  366.     input.style.backgroundColor = "transparent";//"red";
  367.     var a=(obj.currentStyle||obj.style).marginLeft ||0;a=a=="auto"?0:parseInt(a);
  368.     var b=(obj.currentStyle||obj.style).marginRight||0;b=b=="auto"?0:parseInt(b);
  369.     input.style.width = (op.originalOffsetWidth  + a + b-(System.ie?2:0)) +"px";
  370.     a=(obj.currentStyle||obj.style).marginTop   ||0;a=a=="auto"?0:parseInt(a);
  371.     b=(obj.currentStyle||obj.style).marginBottom||0;b=b=="auto"?0:parseInt(b);
  372.     input.style.height= (op.originalOffsetHeight + a + b-(System.ie?2:0)) +"px";
  373.     obj.parentNode.insertBefore(input, obj.nextSibling);
  374.   }
  375.   this.restore=function()
  376.   {
  377.     obj.style.clip  = op.originalClip||"rect(auto, auto, auto, auto)";
  378.     obj.style.top   = op.originalTop;
  379.     obj.style.left  = op.originalLeft;
  380.     obj.style.width = op.originalWidth;
  381.     obj.style.height= op.originalHeight;
  382.     obj.style.position = op.originalPosition;
  383.     if(op.originalPosition!="absolute")
  384.       MzElement.remove("MzEffectMaskStuffing"+ this.hashCode);
  385.     if(System.ie) obj.style.filter = op.originalFilter; else
  386.     {
  387.       obj.style.opacity = op.originalOpacity;
  388.       obj.style.MozOpacity = op.originalMozOpacity;
  389.       obj.style.KHTMLOpacity = op.originalKHTMLOpacity;
  390.     }
  391.   };
  392.   this.finish=function(){if(!op.trend)MzElement.hide(obj); me.restore();};
  393.   this.render=function(schedule)
  394.   {
  395.     schedule = me.schedule || schedule;
  396.     if(op.opacity)
  397.     {
  398.       if(!System.ie){obj.style.opacity = schedule;
  399.         obj.style.MozOpacity = schedule; obj.style.KHTMLOpacity = schedule;}
  400.       else obj.style.filter = "alpha(opacity:"+Math.round(schedule*100)+")";
  401.     }
  402.     switch(op.direction)
  403.     {
  404.       case "box":
  405.         var halfW = Math.ceil(op.originalOffsetWidth /2);
  406.         var halfH = Math.ceil(op.originalOffsetHeight/2);
  407.         var right = Math.ceil(halfW * schedule);
  408.         var bottom =Math.ceil(halfH * schedule);
  409.         obj.style.clip = "rect("+ (halfH-bottom) +"px "+ (halfW+right) +"px "+
  410.           (halfH+bottom) +"px "+ (halfW-right) +"px)";
  411.         break;
  412.       case "center-up-down":
  413.       case "center-down-up":
  414.       case "center-top-bottom":
  415.       case "center-bottom-top":
  416.         var halfH = Math.ceil(op.originalOffsetHeight/2);
  417.         var bottom =Math.ceil(halfH * schedule);
  418.         obj.style.clip = "rect("+ (halfH-bottom) +"px "+
  419.           op.originalOffsetWidth +"px "+ (halfH+bottom) +"px 0)";
  420.         break;
  421.       case "center-right-left":
  422.       case "center-left-right":
  423.         var halfW = Math.ceil(op.originalOffsetWidth /2);
  424.         var right = Math.ceil(halfW * schedule);
  425.         obj.style.clip = "rect(0 "+ (halfW+right) +"px "+
  426.           op.originalOffsetHeight +"px "+ (halfW-right) +"px)";
  427.         break;
  428.       case "top":
  429.       case "top-bottom":
  430.         var bottom =op.originalOffsetHeight * schedule +"px";
  431.         obj.style.clip="rect(0 "+ op.originalOffsetWidth +"px "+ bottom +" 0)";
  432.         break;
  433.       case "bottom":
  434.       case "bottom-top":
  435.         var top = op.originalOffsetHeight * (1 - schedule) +"px";
  436.         obj.style.clip = "rect("+ top +" "+ op.originalOffsetWidth +"px "+
  437.           op.originalOffsetHeight +"px 0)";
  438.         break;
  439.       case "left":
  440.       case "left-right":
  441.         var right = op.originalOffsetWidth  * schedule +"px";
  442.         obj.style.clip="rect(0 "+ right +" "+ op.originalOffsetHeight +"px 0)";
  443.         break;
  444.       case "right":
  445.       case "right-left":
  446.         var left =op.originalOffsetWidth  * (1 - schedule) +"px";
  447.         obj.style.clip = "rect(0 "+ op.originalOffsetWidth +"px "+
  448.           op.originalOffsetHeight +"px "+ left +")";
  449.         break;
  450.       case "top-right":
  451.       case "left-bottom":
  452.         var right = op.originalOffsetWidth  * schedule +"px";
  453.         var bottom =op.originalOffsetHeight * schedule +"px";
  454.         obj.style.clip = "rect(0 "+ right +" "+ bottom +" 0)";
  455.         break;
  456.       case "top-left":
  457.       case "right-bottom":
  458.         var bottom = op.originalOffsetHeight * schedule +"px";
  459.         var left =op.originalOffsetWidth  * (1 - schedule) +"px";
  460.         obj.style.clip = "rect(0 "+ op.originalOffsetWidth +"px "+
  461.           bottom +" "+ left +")";
  462.         break;
  463.       case "right-top":
  464.       case "bottom-left":
  465.         var top = op.originalOffsetHeight * (1 - schedule) +"px";
  466.         var left =op.originalOffsetWidth  * (1 - schedule) +"px";
  467.         obj.style.clip = "rect("+ top +" "+ op.originalOffsetWidth +"px "+
  468.           op.originalOffsetHeight +"px "+ left +")";
  469.         break;
  470.       case "left-top":
  471.       case "bottom-right":
  472.         var top = op.originalOffsetHeight * (1 - schedule) +"px";
  473.         var right=op.originalOffsetWidth  * schedule +"px";
  474.         obj.style.clip = "rect("+ top  +" "+ right +" "+
  475.           op.originalOffsetHeight +"px 0)";
  476.         break;
  477.     }
  478.   };
  479. };
  480. //op{interval, duration, trend}
  481. MzEffect.Combo=function(effects, element, op)
  482. {
  483.   this.effects=effects||[];
  484.   if(this.effects.length==0) return;
  485.   MzEffect.apply(this,[element,op]);
  486. };
  487. t=MzEffect.Combo.Extends(MzEffect, "MzEffect.Combo");
  488. t.render=function(schedule)
  489. {
  490.   schedule = this.schedule || schedule;
  491.   for(var i=0; i<this.effects.length; i++)
  492.   {
  493.     var e = this.effects[i];
  494.     if (e.timer) clearTimeout(e.timer);
  495.     e.render(schedule);
  496.   }
  497. };
  498. t.finish=function()
  499. {
  500.   for(var i=0; i<this.effects.length; i++)
  501.   {
  502.     if(this.effects[i].finish) this.effects[i].finish();
  503.     this.effects[i].dispose();
  504.   }
  505. };
  506. t.dispose=function()
  507. {
  508.   for(var i=0; i<this.effects.length; i++) this.effects[i].dispose();
  509.   MzEffect.prototype.dispose.call(this);
  510.   delete this.effects;
  511. };
  512. /*--====== meizz effects ======--*/
  513. MzEffect.Shake=function(element){MzEffect.call(this, element)};
  514. MzEffect.Shake.Extends(MzEffect, "MzEffect.Shake").initialize=function()
  515. {
  516.   var me=this, obj=me.element, os=obj.style;
  517.   var top =os.top, left=os.left, position=os.position;
  518.   this.restore=function(){os.top=top; os.left=left; os.position=position;}
  519.   this._process=function()
  520.   {
  521.     var a=[0, 0];
  522.     if(me._scheduledIndex>=me._scheduledArray.length)
  523.     {
  524.       this._process=function()
  525.       {
  526.         me.restore();
  527.         me.dispose();
  528.         delete me._scheduledIndex;
  529.         delete me._scheduledArray;
  530.       };
  531.     }
  532.     else
  533.     {
  534.       a=me._scheduledArray[me._scheduledIndex];
  535.       me._scheduledIndex++;
  536.     }
  537.     MzEffect.moveBy(obj, a[0], a[1],{
  538.       duration: 40,
  539.       interval: 20,
  540.       onafterfinish: function(e){me._process();}});
  541.   };
  542. };
  543. MzEffect.Shake.prototype._scheduledIndex=0;
  544. MzEffect.Shake.prototype._scheduledArray=
  545. [
  546.    [20, -5]
  547.   ,[-40,-5]
  548.   ,[40, 10]
  549.   ,[-40, 5]
  550.   ,[40, -9]
  551.   ,[-35, 8]
  552.   ,[35, -7]
  553.   ,[-30, 6]
  554.   ,[20, -5]
  555.   ,[-15, 4]
  556.   ,[10, -3]
  557.   ,[-8,  2]
  558.   ,[6,  -1]
  559.   ,[-5,  0]
  560.   ,[3,   0]
  561.   ,[-1,  0]
  562. ];
  563. MzEffect.Appear=function(element, op)
  564. {
  565.   var e=MzElement.check(element);
  566.   if(!e) return; if(System.ie 
  567.     &&!e.style.width
  568.     &&!e.style.height
  569.     &&e.style.position!="absolute"
  570.     &&e.currentStyle
  571.     &&e.currentStyle.position!="absolute"
  572.     &&e.currentStyle.width=="auto"
  573.     &&e.currentStyle.height=="auto")
  574.   { MzElement.show(e); return;}
  575.   op=System.extend(
  576.   {
  577.     onbeforestart: function(e){MzElement.show(e.element);e.render(0.01);},
  578.     onafterfinish: function(e){e.restore();}
  579.   }, op||{});
  580.   return MzEffect.opacity(element, op);
  581. };
  582. MzEffect.Fade=function(element, op)
  583. {
  584.   var e=MzElement.check(element);
  585.   if(!e) return; if(System.ie 
  586.     &&!e.style.width
  587.     &&!e.style.height
  588.     &&e.style.position!="absolute"
  589.     &&e.currentStyle
  590.     &&e.currentStyle.position!="absolute"
  591.     &&e.currentStyle.width=="auto"
  592.     &&e.currentStyle.height=="auto")
  593.   { MzElement.hide(e); return;}
  594.   op=System.extend(
  595.   {
  596.     trend: "weaken",
  597.     onafterfinish: function(e){MzElement.hide(e.element); e.restore();}
  598.   }, op||{});
  599.   return MzEffect.opacity(element, op);
  600. };
  601. //op{loop, interval, dynamic}
  602. MzEffect.Pulsate=function(element, op)
  603. {
  604.   this.element=MzElement.check(element); if(!this.element) return;
  605.   op=this.options=System.extend({loop:5,interval:360,dynamic:true},op||{});
  606.   if(!op.dynamic || op.loop<0 || op.loop>5) op.interval += 160;
  607.   var a=this.attribName = "att_"+ this._className.replace(/W/g, "_");
  608.   if((t=this.element.getAttribute(a)) && (t=Instance(t))){
  609.   System.extend(t.options, this.options); t.times=0; return t;}
  610.   System.call(this);
  611.   this.element.setAttribute(this.attribName, this.hashCode, 0);
  612.   this.timer=null; this.initialize();
  613.   if(op.onbeforestart) op.onbeforestart(this); this.render();
  614. };
  615. t=MzEffect.Pulsate.Extends(System, "MzEffect.Pulsate");
  616. t.times=0;
  617. t.status=true;
  618. t.initialize=function()
  619. {
  620.   var me=this, op=me.options, obj=me.element;
  621.   op.visibility=obj.style.visibility;
  622.   this.render=function()
  623.   {
  624.     if(me.terminative) return me.stop();
  625.     if(op.loop>-1 && me.times>=op.loop) return me.stop();
  626.     if(me.status)
  627.     {
  628.       if(!op.dynamic || op.loop<0 || op.loop>5)
  629.       {
  630.         obj.style.visibility="hidden";
  631.         me.timer = setTimeout(me.render, op.interval);
  632.       }
  633.       else
  634.       {
  635.         MzEffect.fade(obj, {
  636.           interval: 40,
  637.           duration: 160,
  638.           onafterfinish: function(e)
  639.           {
  640.             obj.style.visibility="hidden";
  641.             e.restore();
  642.             me.timer = setTimeout(me.render, op.interval);
  643.           }
  644.         });
  645.       }
  646.     }
  647.     else
  648.     {
  649.       if(!op.dynamic || op.loop<0 || op.loop>5)
  650.       {
  651.         obj.style.visibility="";
  652.         me.timer = setTimeout(me.render, op.interval);
  653.       }
  654.       else
  655.       {
  656.         MzEffect.appear(obj,{
  657.           interval: 40,
  658.           duration: 160,
  659.           onbeforestart: function(e){e.element.style.visibility=""; e.render(0.01);},
  660.           onafterfinish: function(e){e.restore(); me.timer = setTimeout(me.render, op.interval);}
  661.         });
  662.       }
  663.     }
  664.     me.status = !me.status; if(me.status) me.times++;
  665.   };
  666.   this.stop=function()
  667.   {
  668.     obj.style.visibility=op.visibility;
  669.     if(me.finish) me.finish();
  670.     if(op.onafterfinish) op.onafterfinish(me);
  671.     clearTimeout(me.timer);
  672.     me.dispose();
  673.   }
  674.   this.dispose=function()
  675.   {
  676.     me.decontrol(); if(me.element)
  677.     me.element.removeAttribute(me.attribName);
  678.     delete me.state;
  679.     delete me.timer;
  680.     delete me.times;
  681.     delete me.element;
  682.     delete me.options;
  683.   };
  684. };
  685. MzEffect.Pulsate.stop=function(element)
  686. {
  687.   if(element=MzElement.check(element))
  688.   {
  689.     var t = "att_"+ "MzEffect.Pulsate".replace(/W/g, "_");
  690.     if(t=element.getAttribute(t))if(t=Instance(t))t.terminative=true;
  691.   }
  692. }
  693. //op{interval, duration}
  694. MzEffect.BlindDown=function(element, op){MzEffect.apply(this, arguments);};
  695. MzEffect.BlindDown.Extends(MzEffect, "MzEffect.Mask").initialize=function()
  696. {
  697.   var op=this.options, obj=this.element;
  698.   op.height = obj.style.height;
  699.   op.overflow = obj.style.overflow;
  700.   op.visibility = obj.style.visibility;
  701.   obj.style.visibility = "hidden";
  702.   MzElement.show(obj);
  703.   op.offsetHeight = obj.offsetHeight; if(!System.ie){
  704.   var t; if(t=obj.style.paddingTop) t=parseFloat(t);
  705.   if("number"==typeof t) op.offsetHeight -= t;
  706.   var b; if(b=obj.style.paddingBottom) b=parseFloat(b);
  707.   if("number"==typeof b) op.offsetHeight -= b;}
  708.   obj.style.height = "1px"; obj.style.overflow = "hidden";
  709.   setTimeout(function(){obj.style.visibility = op.visibility;}, 10);
  710.   this.finish=this.restore=function()
  711.   {
  712.     obj.style.overflow = op.overflow;
  713.     obj.style.height = op.height;
  714.   };
  715.   this.render=function(schedule)
  716.   {
  717.     schedule = this.schedule || schedule;
  718.     obj.style.height = parseInt(schedule * op.offsetHeight) +"px";
  719.   };
  720. };
  721. //op{interval, duration}
  722. MzEffect.BlindUp=function(element, op)
  723. {
  724.   op = System.extend({trend: "weaken"}, op||{});
  725.   MzEffect.apply(this, [element, op]);
  726. };
  727. MzEffect.BlindUp.Extends(MzEffect, "MzEffect.Mask").initialize=function()
  728. {
  729.   var op=this.options, obj=this.element;
  730.   op.height = obj.style.height;
  731.   op.overflow = obj.style.overflow;
  732.   op.offsetHeight = obj.offsetHeight; if(!System.ie){
  733.   var t; if(t=obj.style.paddingTop) t=parseFloat(t);
  734.   if("number"==typeof t) op.offsetHeight -= t;
  735.   var b; if(b=obj.style.paddingBottom) b=parseFloat(b);
  736.   if("number"==typeof b) op.offsetHeight -= b;}
  737.   obj.style.overflow = "hidden";
  738.   this.finish=function()
  739.   {
  740.     MzElement.hide(obj);
  741.     obj.style.overflow = op.overflow;
  742.     obj.style.height = op.height;
  743.   };
  744.   this.restore=function()
  745.   {
  746.     obj.style.overflow = op.overflow;
  747.     obj.style.height = op.height;
  748.   };
  749.   this.render=function(schedule)
  750.   {
  751.     schedule = this.schedule || schedule;
  752.     if(schedule<=0.05) MzElement.hide(obj);
  753.     obj.style.height = parseInt(schedule * op.offsetHeight) +"px";
  754.   };
  755. };
  756. //op{interval, duration}
  757. MzEffect.SlideUp=function(element, op)
  758. {
  759.   return MzEffect.collapse(element, System.extend(
  760.   {
  761.     onafterupdate: function(e){e.element.scrollTop=e.options.offsetHeight;}
  762.   }, op||{}))
  763. };
  764. //op{interval, duration}
  765. MzEffect.SlideDown=function(element, op)
  766. {
  767.   return MzEffect.expand(element, System.extend(
  768.   {
  769.     onafterupdate: function(e){e.element.scrollTop=e.options.offsetHeight;}
  770.   }, op||{}))
  771. };
  772. //op{interval, duration}
  773. MzEffect.Fall=function(){MzEffect.Curtain.apply(this, arguments);};
  774. MzEffect.Fall.Extends(MzEffect.Curtain).initialize=function()
  775. {
  776.   MzEffect.Curtain.prototype.initialize.call(this);
  777.   var me=this, op=me.options, obj=me.element;
  778.   this.finish=function(){this.hide(9);};
  779.   this.hide=function(n)
  780.   {
  781.     if(n<0){MzElement.hide(obj); me.restore(); return;}
  782.     obj.style.height = "1px"; obj.style.visibility = "hidden";
  783.     obj.style.marginTop=(n/10)*op.originalOffsetHeight + parseFloat(op.originalMarginTop||0) +"px";
  784.     this.timer=setTimeout(function(){me.hide(--n);}, 10);
  785.   }
  786.   this.render=function(schedule)
  787.   {
  788.     schedule = Math.ceil(op.originalOffsetHeight * (this.schedule || schedule));
  789.     obj.style.marginTop = (schedule + parseFloat(op.originalMarginTop||0)) +"px";
  790.     obj.style.height= (op.originalOffsetHeight - schedule) +"px";
  791.   };
  792. };
  793. //op{interval, duration}
  794. MzEffect.Rise=function(){MzEffect.Curtain.apply(this, arguments);};
  795. MzEffect.Rise.Extends(MzEffect.Curtain).initialize=function()
  796. {
  797.   MzEffect.Curtain.prototype.initialize.call(this);
  798.   var me=this, op=me.options, obj=me.element;
  799.   obj.style.height="1px"; MzElement.show(obj);
  800.   op.originalOffsetHeight = obj.offsetHeight;
  801.   obj.style.marginTop = op.originalOffsetHeight + parseFloat(op.originalMarginTop||0);
  802.   this.render=function(schedule)
  803.   {
  804.     schedule = Math.ceil(op.originalOffsetHeight * (this.schedule || schedule));
  805.     obj.style.height = schedule +"px";
  806.     obj.style.marginTop = (op.originalOffsetHeight - schedule + parseFloat(op.originalMarginTop||0)) +"px";
  807.   };
  808. };
  809. //[static method]
  810. MzEffect.opacity  =function(element, op){return new MzEffect.Opacity(element, op);};
  811. MzEffect.moveBy   =function(element, op){return new MzEffect.MoveBy(element, op);};
  812. MzEffect.moveTo   =function(element, op){return new MzEffect.MoveTo(element, op);};
  813. MzEffect.highlight=function(element, op){return new MzEffect.Highlight(element, op);};
  814. MzEffect.mask     =function(element, op){return new MzEffect.Mask(element, op);};
  815. MzEffect.combo    =function(element, op){};
  816. MzEffect.shake    =function(element, op){return new MzEffect.Shake(element, op);};
  817. MzEffect.appear   =function(element, op){return new MzEffect.Appear(element, op);};
  818. MzEffect.fade     =function(element, op){return new MzEffect.Fade(element, op);};
  819. MzEffect.pulsate  =function(element, op){return new MzEffect.Pulsate(element, op);};
  820. MzEffect.expand   =function(element, op){return new MzEffect.BlindDown(element, op);};
  821. MzEffect.collapse =function(element, op){return new MzEffect.BlindUp(element, op);};
  822. MzEffect.remove   =function(element, op){return new MzEffect.Fade(element, System.extend(op||{}, {onafterfinish: function(){MzElement.remove(element)}}));};