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