You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
8.6 KiB

11 years ago
  1. !function(a,b,c,d){a.fn.shape=function(b){var e,f=a(this),g=(new Date).getTime(),h=[],i=arguments[0],j="string"==typeof i,k=[].slice.call(arguments,1);return f.each(function(){var l,m,n,o=f.selector||"",p=a.extend(!0,{},a.fn.shape.settings,b),q=p.namespace,r=p.selector,s=p.error,t=p.className,u="."+q,v="module-"+q,w=a(this),x=w.find(r.sides),y=w.find(r.side),z=this,A=w.data(v);n={initialize:function(){n.verbose("Initializing module for",z),n.set.defaultSide(),n.instantiate()},instantiate:function(){n.verbose("Storing instance of module",n),A=n,w.data(v,A)},destroy:function(){n.verbose("Destroying previous module for",z),w.removeData(v).off(u)},refresh:function(){n.verbose("Refreshing selector cache for",z),w=a(z),x=a(this).find(r.shape),y=a(this).find(r.side)},repaint:function(){n.verbose("Forcing repaint event");var a=x.get(0)||c.createElement("div");a.offsetWidth},animate:function(a,b){n.verbose("Animating box with properties",a),b=b||function(a){n.verbose("Executing animation callback"),a!==d&&a.stopPropagation(),n.reset(),n.set.active()},p.useCSS?n.get.transitionEvent()?(n.verbose("Starting CSS animation"),w.addClass(t.animating),n.set.stageSize(),n.repaint(),w.addClass(t.css),l.addClass(t.hidden),x.css(a).one(n.get.transitionEvent(),b)):b():(n.verbose("Starting javascript animation"),w.addClass(t.animating).removeClass(t.css),n.set.stageSize(),n.repaint(),l.animate({opacity:0},p.duration,p.easing),x.animate(a,p.duration,p.easing,b))},queue:function(a){n.debug("Queueing animation of",a),x.one(n.get.transitionEvent(),function(){n.debug("Executing queued animation"),setTimeout(function(){w.shape(a)},0)})},reset:function(){n.verbose("Animating states reset"),w.removeClass(t.css).removeClass(t.animating).attr("style","").removeAttr("style"),x.attr("style","").removeAttr("style"),y.attr("style","").removeAttr("style").removeClass(t.hidden),m.removeClass(t.animating).attr("style","").removeAttr("style")},is:{animating:function(){return w.hasClass(t.animating)}},get:{transform:{up:function(){var a={y:-((l.outerHeight()-m.outerHeight())/2),z:-(l.outerHeight()/2)};return{transform:"translateY("+a.y+"px) translateZ("+a.z+"px) rotateX(-90deg)"}},down:function(){var a={y:-((l.outerHeight()-m.outerHeight())/2),z:-(l.outerHeight()/2)};return{transform:"translateY("+a.y+"px) translateZ("+a.z+"px) rotateX(90deg)"}},left:function(){var a={x:-((l.outerWidth()-m.outerWidth())/2),z:-(l.outerWidth()/2)};return{transform:"translateX("+a.x+"px) translateZ("+a.z+"px) rotateY(90deg)"}},right:function(){var a={x:-((l.outerWidth()-m.outerWidth())/2),z:-(l.outerWidth()/2)};return{transform:"translateX("+a.x+"px) translateZ("+a.z+"px) rotateY(-90deg)"}},over:function(){var a={x:-((l.outerWidth()-m.outerWidth())/2)};return{transform:"translateX("+a.x+"px) rotateY(180deg)"}},back:function(){var a={x:-((l.outerWidth()-m.outerWidth())/2)};return{transform:"translateX("+a.x+"px) rotateY(-180deg)"}}},transitionEvent:function(){var a,b=c.createElement("element"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in e)if(b.style[a]!==d)return e[a]},nextSide:function(){return l.next(r.side).size()>0?l.next(r.side):w.find(r.side).first()}},set:{defaultSide:function(){l=w.find("."+p.className.active),m=l.next(r.side).size()>0?l.next(r.side):w.find(r.side).first(),n.verbose("Active side set to",l),n.verbose("Next side set to",m)},stageSize:function(){var a={width:m.outerWidth(),height:m.outerHeight()};n.verbose("Resizing stage to fit new content",a),w.css({width:a.width,height:a.height})},nextSide:function(a){m=w.find(a),0===m.size()&&n.error(s.side),n.verbose("Next side manually set to",m)},active:function(){n.verbose("Setting new side to active",m),y.removeClass(t.active),m.addClass(t.active),a.proxy(p.onChange,m)(),n.set.defaultSide()}},flip:{up:function(){n.debug("Flipping up",m),n.is.animating()?n.queue("flip up"):(n.stage.above(),n.animate(n.get.transform.up()))},down:function(){n.debug("Flipping down",m),n.is.animating()?n.queue("flip down"):(n.stage.below(),n.animat