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.4 KiB

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