﻿(function(a){a.effects.puff=function(b){return this.queue(function(){var c=a(this),e=a.effects.setMode(c,b.options.mode||"hide"),g=parseInt(b.options.percent,10)||150,f=g/100,d={height:c.height(),width:c.width()};a.extend(b.options,{fade:true,mode:e,percent:e=="hide"?g:100,from:e=="hide"?d:{height:d.height*f,width:d.width*f}});c.effect("scale",b.options,b.duration,b.callback);c.dequeue()})};a.effects.scale=function(b){return this.queue(function(){var c=a(this),d=a.extend(true,{},b.options),e=a.effects.setMode(c,b.options.mode||"effect"),h=parseInt(b.options.percent,10)||(parseInt(b.options.percent,10)==0?0:e=="hide"?0:100),i=b.options.direction||"both",j=b.options.origin;if(e!="effect"){d.origin=j||["middle","center"];d.restore=true}var f={height:c.height(),width:c.width()};c.from=b.options.from||(e=="show"?{height:0,width:0}:f);var g={y:i!="horizontal"?h/100:1,x:i!="vertical"?h/100:1};c.to={height:f.height*g.y,width:f.width*g.x};if(b.options.fade){if(e=="show"){c.from.opacity=0;c.to.opacity=1}if(e=="hide"){c.from.opacity=1;c.to.opacity=0}}d.from=c.from;d.to=c.to;d.mode=e;c.effect("size",d,b.duration,b.callback);c.dequeue()})};a.effects.size=function(b){return this.queue(function(){var c=a(this),f=["position","top","left","width","height","overflow","opacity"],n=["position","top","left","overflow","opacity"],m=["width","height","overflow"],l=["fontSize"],h=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],g=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=a.effects.setMode(c,b.options.mode||"effect"),k=b.options.restore||false,i=b.options.scale||"both",o=b.options.origin,e={height:c.height(),width:c.width()};c.from=b.options.from||e;c.to=b.options.to||e;if(o){var j=a.effects.getBaseline(o,e);c.from.top=(e.height-c.from.height)*j.y;c.from.left=(e.width-c.from.width)*j.x;c.to.top=(e.height-c.to.height)*j.y;c.to.left=(e.width-c.to.width)*j.x}var d={from:{y:c.from.height/e.height,x:c.from.width/e.width},to:{y:c.to.height/e.height,x:c.to.width/e.width}};if(i=="box"||i=="both"){if(d.from.y!=d.to.y){f=f.concat(h);c.from=a.effects.setTransition(c,h,d.from.y,c.from);c.to=a.effects.setTransition(c,h,d.to.y,c.to)}if(d.from.x!=d.to.x){f=f.concat(g);c.from=a.effects.setTransition(c,g,d.from.x,c.from);c.to=a.effects.setTransition(c,g,d.to.x,c.to)}}if(i=="content"||i=="both")if(d.from.y!=d.to.y){f=f.concat(l);c.from=a.effects.setTransition(c,l,d.from.y,c.from);c.to=a.effects.setTransition(c,l,d.to.y,c.to)}a.effects.save(c,k?f:n);c.show();a.effects.createWrapper(c);c.css("overflow","hidden").css(c.from);if(i=="content"||i=="both"){h=h.concat(["marginTop","marginBottom"]).concat(l);g=g.concat(["marginLeft","marginRight"]);m=f.concat(h).concat(g);c.find("*[width]").each(function(){child=a(this);if(k)a.effects.save(child,m);var c={height:child.height(),width:child.width()};child.from={height:c.height*d.from.y,width:c.width*d.from.x};child.to={height:c.height*d.to.y,width:c.width*d.to.x};if(d.from.y!=d.to.y){child.from=a.effects.setTransition(child,h,d.from.y,child.from);child.to=a.effects.setTransition(child,h,d.to.y,child.to)}if(d.from.x!=d.to.x){child.from=a.effects.setTransition(child,g,d.from.x,child.from);child.to=a.effects.setTransition(child,g,d.to.x,child.to)}child.css(child.from);child.animate(child.to,b.duration,b.options.easing,function(){if(k)a.effects.restore(child,m)})})}c.animate(c.to,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){if(c.to.opacity===0)c.css("opacity",c.from.opacity);if(p=="hide")c.hide();a.effects.restore(c,k?f:n);a.effects.removeWrapper(c);if(b.callback)b.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery)
