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