|
|
(function(a,b,c,d){a.fn.origami=function(b){var h,c=a(this),e=a.extend(!0,{},a.fn.origami.settings,b),f=arguments[0],g=[].slice.call(arguments,1);return c.each(function(){var j,k,t,b=a(this),c=b.find(e.selector.box),i=b.find(e.selector.side),m=(b.selector||"",this),n=b.data("module-"+e.namespace),o="string"==typeof f,p="transitionend msTransitionEnd oTransitionEnd",q=e.namespace,s=(e.metadata,e.className);t={initialize:function(){t.verbose("Initializing module for",m),t.set.defaultSide(),b.data("module-"+q,t)},destroy:function(){t.verbose("Destroying previous module for",m),b.off("."+q)},refresh:function(){t.verbose("Refreshing selector cache for",m),b=a(m),c=a(this).find(e.selector.box),i=a(this).find(e.selector.side)},repaint:function(){b.get(0).offsetWidth},animate:function(a){t.verbose("Animating box with properties",a);var d=function(){t.reset(),t.set.active()};e.useCSS?(t.verbose("Using CSS transitions to animate"),b.addClass(s.animating),t.set.stageSize(),t.repaint(),b.addClass(s.css),j.addClass(s.hidden),c.css(a).one(p,d)):(t.verbose("Using javascript to animate"),b.addClass(s.animating).removeClass(s.css),t.set.stageSize(),t.repaint(),j.animate({opacity:0},e.duration,e.easing),c.animate(a,e.duration,e.easing,d))},reset:function(){t.verbose("Animating states reset"),b.removeClass(s.css).removeClass(s.animating).removeAttr("style"),c.removeAttr("style"),i.removeAttr("style").removeClass(s.hidden),k.removeClass(s.animating).removeAttr("style")},set:{defaultSide:function(){j=b.find("."+e.className.active),k=j.next(e.selector.side).size()>0?j.next(e.selector.side):b.find(e.selector.side).first(),t.verbose("Active side set to",j),t.verbose("Next side set to",k)},stageSize:function(){b.css({width:k.outerWidth(),height:k.outerHeight()})},nextSide:function(a){k=b.find(a),t.verbose("Next side manually set to",k)},active:function(){t.verbose("Setting new side to active",k),i.removeClass(s.active),k.addClass(s.active),t.set.defaultSide()}},getTransform:{up:function(){var a={y:-((j.outerHeight()-k.outerHeight())/2),z:-(j.outerHeight()/2)};return{transform:"translateY("+a.y+"px) translateZ("+a.z+"px) rotateX(-90deg)"}},down:function(){var a={y:-((j.outerHeight()-k.outerHeight())/2),z:-(j.outerHeight()/2)};return{transform:"translateY("+a.y+"px) translateZ("+a.z+"px) rotateX(90deg)"}},left:function(){var a={x:-((j.outerWidth()-k.outerWidth())/2),z:-(j.outerWidth()/2)};return{transform:"translateX("+a.x+"px) translateZ("+a.z+"px) rotateY(90deg)"}},right:function(){var a={x:-((j.outerWidth()-k.outerWidth())/2),z:-(j.outerWidth()/2)};return{transform:"translateX("+a.x+"px) translateZ("+a.z+"px) rotateY(-90deg)"}}},stage:{above:function(){var a={origin:(j.outerHeight()-k.outerHeight())/2,depth:{active:k.outerHeight()/2,next:j.outerHeight()/2}};t.verbose("Setting the initial animation position as above",k,a),j.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),k.addClass(s.animating).css({display:"block",top:a.origin+"px",transform:"rotateX(90deg) translateZ("+a.depth.next+"px)"})},below:function(){var a={origin:(j.outerHeight()-k.outerHeight())/2,depth:{active:k.outerHeight()/2,next:j.outerHeight()/2}};t.verbose("Setting the initial animation position as below",k,a),j.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),k.addClass(s.animating).css({display:"block",top:a.origin+"px",transform:"rotateX(-90deg) translateZ("+a.depth.next+"px)"})},left:function(){var a={origin:(j.outerWidth()-k.outerWidth())/2,depth:{active:k.outerWidth()/2,next:j.outerWidth()/2}};t.verbose("Setting the initial animation position as left",k,a),j.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),k.addClass(s.animating).css({display:"block",left:a.origin+"px",transform:"rotateY(-90deg) translateZ("+a.depth.next+"px)"})},right:function(){var a={origin:(j.outerWidth()-k.outerWidth())/2,depth:{active:k.outerWidth()/2,next:j.outerWidth()/2}};t.verbose("Setting the initial animation position as left",k,a),j.css({transform:"rotateY(0deg) translateZ("+a.depth.active+"px)"}),k.addClass(s.animating).css({display:"block
|