1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
!function(e,t,i,n){"use strict";t=void 0!==t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.shape=function(n){var a,o=e(this),r=(e("body"),(new Date).getTime()),s=[],d=arguments[0],l="string"==typeof d,u=[].slice.call(arguments,1),c=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return o.each(function(){var t,g,f,m=o.selector||"",h=e.isPlainObject(n)?e.extend(!0,{},e.fn.shape.settings,n):e.extend({},e.fn.shape.settings),p=h.namespace,v=h.selector,b=h.error,x=h.className,y="."+p,S="module-"+p,w=e(this),C=w.find(v.sides),z=w.find(v.side),W=!1,F=this,H=w.data(S);f={initialize:function(){f.verbose("Initializing module for",F),f.set.defaultSide(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),H=f,w.data(S,H)},destroy:function(){f.verbose("Destroying previous module for",F),w.removeData(S).off(y)},refresh:function(){f.verbose("Refreshing selector cache for",F),w=e(F),C=e(this).find(v.shape),z=e(this).find(v.side)},repaint:function(){f.verbose("Forcing repaint event");var e=C[0]||i.createElement("div");e.offsetWidth},animate:function(e,i){f.verbose("Animating box with properties",e),i=i||function(e){f.verbose("Executing animation callback"),void 0!==e&&e.stopPropagation(),f.reset(),f.set.active()},h.beforeChange.call(g[0]),f.get.transitionEvent()?(f.verbose("Starting CSS animation"),w.addClass(x.animating),C.css(e).one(f.get.transitionEvent(),i),f.set.duration(h.duration),c(function(){w.addClass(x.animating),t.addClass(x.hidden)})):i()},queue:function(e){f.debug("Queueing animation of",e),C.one(f.get.transitionEvent(),function(){f.debug("Executing queued animation"),setTimeout(function(){w.shape(e)},0)})},reset:function(){f.verbose("Animating states reset"),w.removeClass(x.animating).attr("style","").removeAttr("style"),C.attr("style","").removeAttr("style"),z.attr("style","").removeAttr("style").removeClass(x.hidden),g.removeClass(x.animating).attr("style","").removeAttr("style")},is:{complete:function(){return z.filter("."+x.active)[0]==g[0]},animating:function(){return w.hasClass(x.animating)}},set:{defaultSide:function(){t=w.find("."+h.className.active),g=t.next(v.side).length>0?t.next(v.side):w.find(v.side).first(),W=!1,f.verbose("Active side set to",t),f.verbose("Next side set to",g)},duration:function(e){e=e||h.duration,e="number"==typeof e?e+"ms":e,f.verbose("Setting animation duration",e),(h.duration||0===h.duration)&&C.add(z).css({"-webkit-transition-duration":e,"-moz-transition-duration":e,"-ms-transition-duration":e,"-o-transition-duration":e,"transition-duration":e})},currentStageSize:function(){var e=w.find("."+h.className.active),t=e.outerWidth(!0),i=e.outerHeight(!0);w.css({width:t,height:i})},stageSize:function(){var e=w.clone().addClass(x.loading),t=e.find("."+h.className.active),i=W?e.find(v.side).eq(W):t.next(v.side).length>0?t.next(v.side):e.find(v.side).first(),n="next"==h.width?i.outerWidth(!0):"initial"==h.width?w.width():h.width,a="next"==h.height?i.outerHeight(!0):"initial"==h.height?w.height():h.height;t.removeClass(x.active),i.addClass(x.active),e.insertAfter(w),e.remove(),"auto"!=h.width&&(w.css("width",n+h.jitter),f.verbose("Specifying width during animation",n)),"auto"!=h.height&&(w.css("height",a+h.jitter),f.verbose("Specifying height during animation",a))},nextSide:function(e){W=e,g=z.filter(e),W=z.index(g),0===g.length&&(f.set.defaultSide(),f.error(b.side)),f.verbose("Next side manually set to",g)},active:function(){f.verbose("Setting new side to active",g),z.removeClass(x.active),g.addClass(x.active),h.onChange.call(g[0]),f.set.defaultSide()}},flip:{up:function(){if(f.is.complete()&&!f.is.animating()&&!h.allowRepeats)return void f.debug("Side already visible",g);if(f.is.animating())f.queue("flip up");else{f.debug("Flipping up",g);var e=f.get.transform.up();f.set.stageSize(),f.stage.above(),f.animate(e)}},down:function(){if(f.is.complete()&&!f.is.animating()&&!h.allowRepeats)return void f.debug("Side already visible",g);i
|