|
|
!function(D,j,R,z){"use strict";j=void 0!==j&&j.Math==Math?j:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),D.fn.sidebar=function(C){var k,e=D(this),w=D(j),T=D(R),x=D("html"),S=D("head"),A=e.selector||"",F=(new Date).getTime(),O=[],P=C,E="string"==typeof P,H=[].slice.call(arguments,1),M=j.requestAnimationFrame||j.mozRequestAnimationFrame||j.webkitRequestAnimationFrame||j.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var s,a,e,i,l,c=D.isPlainObject(C)?D.extend(!0,{},D.fn.sidebar.settings,C):D.extend({},D.fn.sidebar.settings),n=c.selector,r=c.className,t=c.namespace,o=c.regExp,d=c.error,u="."+t,f="module-"+t,b=D(this),h=D(c.context),m=b.children(n.sidebar),g=(h.children(n.fixed),h.children(n.pusher)),v=this,p=b.data(f),y={initialize:function(){y.debug("Initializing sidebar",C),y.create.id(),l=y.get.transitionEvent(),c.delaySetup?M(y.setup.layout):y.setup.layout(),M(function(){y.setup.cache()}),y.instantiate()},instantiate:function(){y.verbose("Storing instance of module",y),p=y,b.data(f,y)},create:{id:function(){e=(Math.random().toString(16)+"000000000").substr(2,8),a="."+e,y.verbose("Creating unique id for element",e)}},destroy:function(){y.verbose("Destroying previous module for",b),b.off(u).removeData(f),y.is.ios()&&y.remove.ios(),h.off(a),w.off(a),T.off(a)},event:{clickaway:function(e){var i=0<g.find(e.target).length||g.is(e.target),n=h.is(e.target);i&&(y.verbose("User clicked on dimmed page"),y.hide()),n&&(y.verbose("User clicked on dimmable context (scaled out page)"),y.hide())},touch:function(e){},containScroll:function(e){v.scrollTop<=0&&(v.scrollTop=1),v.scrollTop+v.offsetHeight>=v.scrollHeight&&(v.scrollTop=v.scrollHeight-v.offsetHeight-1)},scroll:function(e){0===D(e.target).closest(n.sidebar).length&&e.preventDefault()}},bind:{clickaway:function(){y.verbose("Adding clickaway events to context",h),c.closable&&h.on("click"+a,y.event.clickaway).on("touchend"+a,y.event.clickaway)},scrollLock:function(){c.scrollLock&&(y.debug("Disabling page scroll"),w.on("DOMMouseScroll"+a,y.event.scroll)),y.verbose("Adding events to contain sidebar scroll"),T.on("touchmove"+a,y.event.touch),b.on("scroll"+u,y.event.containScroll)}},unbind:{clickaway:function(){y.verbose("Removing clickaway events from context",h),h.off(a)},scrollLock:function(){y.verbose("Removing scroll lock from page"),T.off(a),w.off(a),b.off("scroll"+u)}},add:{inlineCSS:function(){var e,i=y.cache.width||b.outerWidth(),n=y.cache.height||b.outerHeight(),t=y.is.rtl(),o=y.get.direction(),r={left:i,right:-i,top:n,bottom:-n};t&&(y.verbose("RTL detected, flipping widths"),r.left=-i,r.right=i),e="<style>","left"===o||"right"===o?(y.debug("Adding CSS rules for animation distance",i),e+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { -webkit-transform: translate3d("+r[o]+"px, 0, 0); transform: translate3d("+r[o]+"px, 0, 0); }"):"top"!==o&&"bottom"!=o||(e+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"px, 0); }"),y.is.ie()&&("left"===o||"right"===o?(y.debug("Adding CSS rules for animation distance",i),e+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d("+r[o]+"px, 0, 0); transform: translate3d("+r[o]+"px, 0, 0); }"):"top"!==o&&"bottom"!=o||(e+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"px, 0); }"),e+=" body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after, body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after { -webkit-transform: translate3d(0px, 0, 0); transform: translate3d(0px, 0, 0); }"),s=D(e+="</style>").appendTo(S),y.debug("Adding sizing css to head",s)}},refresh:function(){y.verbose("Refreshing selector cache"),h=D(c.context),m=h.children(n.sidebar),g=h.children(n.pusher),h.children(n.fixed),y.clear.cach
|