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