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
9.0 KiB
1 lines
9.0 KiB
!function(a,b,c,d){a.fn.shape=function(b){var e,f=a(this),g=a("body"),h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);return f.each(function(){var m,n,o,p=f.selector||"",q=a.extend(!0,{},a.fn.shape.settings,b),r=q.namespace,s=q.selector,t=q.error,u=q.className,v="."+r,w="module-"+r,x=a(this),y=x.find(s.sides),z=x.find(s.side),A=!1,B=this,C=x.data(w);o={initialize:function(){o.verbose("Initializing module for",B),o.set.defaultSide(),o.instantiate()},instantiate:function(){o.verbose("Storing instance of module",o),C=o,x.data(w,C)},destroy:function(){o.verbose("Destroying previous module for",B),x.removeData(w).off(v)},refresh:function(){o.verbose("Refreshing selector cache for",B),x=a(B),y=a(this).find(s.shape),z=a(this).find(s.side)},repaint:function(){o.verbose("Forcing repaint event");var a=y.get(0)||c.createElement("div");a.offsetWidth},animate:function(b,c){o.verbose("Animating box with properties",b),c=c||function(a){o.verbose("Executing animation callback"),a!==d&&a.stopPropagation(),o.reset(),o.set.active()},a.proxy(q.beforeChange,n[0])(),o.get.transitionEvent()?(o.verbose("Starting CSS animation"),x.addClass(u.animating),o.repaint(),x.addClass(u.animating),m.addClass(u.hidden),y.css(b).one(o.get.transitionEvent(),c),o.set.duration(q.duration)):c()},queue:function(a){o.debug("Queueing animation of",a),y.one(o.get.transitionEvent(),function(){o.debug("Executing queued animation"),setTimeout(function(){x.shape(a)},0)})},reset:function(){o.verbose("Animating states reset"),x.removeClass(u.animating).attr("style","").removeAttr("style"),y.attr("style","").removeAttr("style"),z.attr("style","").removeAttr("style").removeClass(u.hidden),n.removeClass(u.animating).attr("style","").removeAttr("style")},is:{animating:function(){return x.hasClass(u.animating)}},set:{defaultSide:function(){m=x.find("."+q.className.active),n=m.next(s.side).size()>0?m.next(s.side):x.find(s.side).first(),A=!1,o.verbose("Active side set to",m),o.verbose("Next side set to",n)},duration:function(a){a=a||q.duration,a="number"==typeof a?a+"ms":a,o.verbose("Setting animation duration",a),y.add(z).css({"-webkit-transition-duration":a,"-moz-transition-duration":a,"-ms-transition-duration":a,"-o-transition-duration":a,"transition-duration":a})},stageSize:function(){var a=x.clone().addClass(u.loading),b=a.find("."+q.className.active),c=A?a.find(A):b.next(s.side).size()>0?b.next(s.side):a.find(s.side).first(),d={};b.removeClass(u.active),c.addClass(u.active),a.prependTo(g),d={width:c.outerWidth(),height:c.outerHeight()},a.remove(),x.css(d),o.verbose("Resizing stage to fit new content",d)},nextSide:function(a){A=a,n=x.find(a),0===n.size()&&o.error(t.side),o.verbose("Next side manually set to",n)},active:function(){o.verbose("Setting new side to active",n),z.removeClass(u.active),n.addClass(u.active),a.proxy(q.onChange,n[0])(),o.set.defaultSide()}},flip:{up:function(){o.debug("Flipping up",n),o.is.animating()?o.queue("flip up"):(o.set.stageSize(),o.stage.above(),o.animate(o.get.transform.up()))},down:function(){o.debug("Flipping down",n),o.is.animating()?o.queue("flip down"):(o.set.stageSize(),o.stage.below(),o.animate(o.get.transform.down()))},left:function(){o.debug("Flipping left",n),o.is.animating()?o.queue("flip left"):(o.set.stageSize(),o.stage.left(),o.animate(o.get.transform.left()))},right:function(){o.debug("Flipping right",n),o.is.animating()?o.queue("flip right"):(o.set.stageSize(),o.stage.right(),o.animate(o.get.transform.right()))},over:function(){o.debug("Flipping over",n),o.is.animating()?o.queue("flip over"):(o.set.stageSize(),o.stage.behind(),o.animate(o.get.transform.over()))},back:function(){o.debug("Flipping back",n),o.is.animating()?o.queue("flip back"):(o.set.stageSize(),o.stage.behind(),o.animate(o.get.transform.back()))}},get:{transform:{up:function(){var a={y:-((m.outerHeight()-n.outerHeight())/2),z:-(m.outerHeight()/2)};return{transform:"translateY("+a.y+"px) translateZ("+a.z+"px) rotateX(-90deg)"}},down:function(){var a={y:-((m.outerHeight()-n.outerHeight())/2),z:-(m.outerHeight()/2)};return{transform:"translateY("+a.y+"px) translateZ("+a.z+"px) rotateX(90deg)"}},left:function(){var a={x:-((m.outerWidth()-n.outerWidth())/2),z:-(m.outerWidth()/2)};return{transform:"translateX("+a.x+"px) translateZ("+a.z+"px) rotateY(90deg)"}},right:function(){var a={x:-((m.outerWidth()-n.outerWidth())/2),z:-(m.outerWidth()/2)};return{transform:"translateX("+a.x+"px) translateZ("+a.z+"px) rotateY(-90deg)"}},over:function(){var a={x:-((m.outerWidth()-n.outerWidth())/2)};return{transform:"translateX("+a.x+"px) rotateY(180deg)"}},back:function(){var a={x:-((m.outerWidth()-n.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 m.next(s.side).size()>0?m.next(s.side):x.find(s.side).first()}},stage:{above:function(){var a={origin:(m.outerHeight()-n.outerHeight())/2,depth:{active:n.outerHeight()/2,next:m.outerHeight()/2}};o.verbose("Setting the initial animation position as above",n,a),m.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),n.addClass(u.animating).css({display:"block",top:a.origin+"px",transform:"rotateX(90deg) translateZ("+a.depth.next+"px)"})},below:function(){var a={origin:(m.outerHeight()-n.outerHeight())/2,depth:{active:n.outerHeight()/2,next:m.outerHeight()/2}};o.verbose("Setting the initial animation position as below",n,a),m.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),n.addClass(u.animating).css({display:"block",top:a.origin+"px",transform:"rotateX(-90deg) translateZ("+a.depth.next+"px)"})},left:function(){var a={origin:(m.outerWidth()-n.outerWidth())/2,depth:{active:n.outerWidth()/2,next:m.outerWidth()/2}};o.verbose("Setting the initial animation position as left",n,a),m.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),n.addClass(u.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(-90deg) translateZ("+a.depth.next+"px)"})},right:function(){var a={origin:(m.outerWidth()-n.outerWidth())/2,depth:{active:n.outerWidth()/2,next:m.outerWidth()/2}};o.verbose("Setting the initial animation position as left",n,a),m.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),n.addClass(u.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(90deg) translateZ("+a.depth.next+"px)"})},behind:function(){var a={origin:(m.outerWidth()-n.outerWidth())/2,depth:{active:n.outerWidth()/2,next:m.outerWidth()/2}};o.verbose("Setting the initial animation position as behind",n,a),m.css({transform:"rotateY(0deg)"}),n.addClass(u.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(-180deg)"})}},setting:function(b,c){if(a.isPlainObject(b))a.extend(!0,q,b);else{if(c===d)return q[b];q[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,o,b);else{if(c===d)return o[b];o[b]=c}},debug:function(){q.debug&&(q.performance?o.performance.log(arguments):(o.debug=Function.prototype.bind.call(console.info,console,q.name+":"),o.debug.apply(console,arguments)))},verbose:function(){q.verbose&&q.debug&&(q.performance?o.performance.log(arguments):(o.verbose=Function.prototype.bind.call(console.info,console,q.name+":"),o.verbose.apply(console,arguments)))},error:function(){o.error=Function.prototype.bind.call(console.error,console,q.name+":"),o.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;q.performance&&(b=(new Date).getTime(),d=h||b,c=b-d,h=b,i.push({Element:B,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(o.performance.timer),o.performance.timer=setTimeout(o.performance.display,100)},display:function(){var b=q.name+":",c=0;h=!1,clearTimeout(o.performance.timer),a.each(i,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",p&&(b+=" '"+p+"'"),f.size()>1&&(b+=" ("+f.size()+")"),(console.group!==d||console.table!==d)&&i.length>0&&(console.groupCollapsed(b),console.table?console.table(i):a.each(i,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),i=[]}},invoke:function(b,c,f){var g,h,i;return c=c||l,f=B||f,"string"==typeof b&&C!==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(C[e])&&c!=g)C=C[e];else{if(!a.isPlainObject(C[f])||c==g)return C[e]!==d?(h=C[e],!1):C[f]!==d?(h=C[f],!1):(o.error(t.method),!1);C=C[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}},k?(C===d&&o.initialize(),o.invoke(j)):(C!==d&&o.destroy(),o.initialize())}),e!==d?e:this},a.fn.shape.settings={name:"Shape",debug:!0,verbose:!0,performance:!0,namespace:"shape",beforeChange:function(){},onChange:function(){},duration:700,error:{side:"You tried to switch to a side that does not exist.",method:"The method you called is not defined"},className:{animating:"animating",hidden:"hidden",loading:"loading",active:"active"},selector:{sides:".sides",side:".side"}}}(jQuery,window,document);
|