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.
 
 
 

1 lines
8.6 KiB

!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.animate(n.get.transform.down()))},left:function(){n.debug("Flipping left",m),n.is.animating()?n.queue("flip left"):(n.stage.left(),n.animate(n.get.transform.left()))},right:function(){n.debug("Flipping right",m),n.is.animating()?n.queue("flip right"):(n.stage.right(),n.animate(n.get.transform.right()))},over:function(){n.debug("Flipping over",m),n.is.animating()?n.queue("flip over"):(n.stage.behind(),n.animate(n.get.transform.over()))},back:function(){n.debug("Flipping back",m),n.is.animating()?n.queue("flip back"):(n.stage.behind(),n.animate(n.get.transform.back()))}},stage:{above:function(){var a={origin:(l.outerHeight()-m.outerHeight())/2,depth:{active:m.outerHeight()/2,next:l.outerHeight()/2}};n.verbose("Setting the initial animation position as above",m,a),l.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),m.addClass(t.animating).css({display:"block",top:a.origin+"px",transform:"rotateX(90deg) translateZ("+a.depth.next+"px)"})},below:function(){var a={origin:(l.outerHeight()-m.outerHeight())/2,depth:{active:m.outerHeight()/2,next:l.outerHeight()/2}};n.verbose("Setting the initial animation position as below",m,a),l.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),m.addClass(t.animating).css({display:"block",top:a.origin+"px",transform:"rotateX(-90deg) translateZ("+a.depth.next+"px)"})},left:function(){var a={origin:(l.outerWidth()-m.outerWidth())/2,depth:{active:m.outerWidth()/2,next:l.outerWidth()/2}};n.verbose("Setting the initial animation position as left",m,a),l.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),m.addClass(t.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(-90deg) translateZ("+a.depth.next+"px)"})},right:function(){var a={origin:(l.outerWidth()-m.outerWidth())/2,depth:{active:m.outerWidth()/2,next:l.outerWidth()/2}};n.verbose("Setting the initial animation position as left",m,a),l.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),m.addClass(t.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(90deg) translateZ("+a.depth.next+"px)"})},behind:function(){var a={origin:(l.outerWidth()-m.outerWidth())/2,depth:{active:m.outerWidth()/2,next:l.outerWidth()/2}};n.verbose("Setting the initial animation position as behind",m,a),l.css({transform:"rotateY(0deg)"}),m.addClass(t.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(-180deg)"})}},setting:function(b,c){return c===d?p[b]:(a.isPlainObject(b)?a.extend(!0,p,b):p[b]=c,void 0)},internal:function(b,c){return c===d?n[b]:(a.isPlainObject(b)?a.extend(!0,n,b):n[b]=c,void 0)},debug:function(){p.debug&&(p.performance?n.performance.log(arguments):(n.debug=Function.prototype.bind.call(console.info,console,p.name+":"),n.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?n.performance.log(arguments):(n.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),n.verbose.apply(console,arguments)))},error:function(){n.error=Function.prototype.bind.call(console.error,console,p.name+":"),n.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;p.performance&&(b=(new Date).getTime(),d=g||b,c=b-d,g=b,h.push({Element:z,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(n.performance.timer),n.performance.timer=setTimeout(n.performance.display,100)},display:function(){var b=p.name+":",c=0;g=!1,clearTimeout(n.performance.timer),a.each(h,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",o&&(b+=" '"+o+"'"),f.size()>1&&(b+=" ("+f.size()+")"),(console.group!==d||console.table!==d)&&h.length>0&&(console.groupCollapsed(b),console.table?console.table(h):a.each(h,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(b,c,f){var g,h,i;return c=c||k,f=z||f,"string"==typeof b&&A!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(A[e])&&c!=g)A=A[e];else{if(!a.isPlainObject(A[f])||c==g)return A[e]!==d?(h=A[e],!1):A[f]!==d?(h=A[f],!1):(n.error(s.method),!1);A=A[f]}})),a.isFunction(h)?i=h.apply(f,c):h!==d&&(i=h),a.isArray(e)?e.push(i):e!==d?e=[e,i]:i!==d&&(e=i),h}},j?(A===d&&n.initialize(),n.invoke(i)):(A!==d&&n.destroy(),n.initialize())}),e!==d?e:this},a.fn.shape.settings={name:"Shape",debug:!0,verbose:!0,performance:!0,namespace:"shape",beforeChange:function(){},onChange:function(){},useCSS:!0,duration:1e3,easing:"easeInOutQuad",error:{side:"You tried to switch to a side that does not exist.",method:"The method you called is not defined"},className:{css:"css",animating:"animating",hidden:"hidden",active:"active"},selector:{sides:".sides",side:".side"}}}(jQuery,window,document);