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