forked from inuyaksa/jquery.nicescroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.nicescroll.min.js
2 lines (2 loc) · 56.2 KB
/
jquery.nicescroll.min.js
1
2
!function(a){function i(){var a=document.getElementsByTagName("script"),b=a[a.length-1].src.split("?")[0];return b.split("/").length>0?b.split("/").slice(0,-1).join("/")+"/":""}function w(a,b,c){for(var d=0;d<b.length;d++)c(a,b[d])}var b=!1,c=!1,e=5e3,f=2e3,g=0,h=a,j=i();Array.prototype.forEach||(Array.prototype.forEach=function(a,b){for(var c=0,d=this.length;d>c;++c)a.call(b,this[c],c,this)});var k=["ms","moz","webkit","o"],l=window.requestAnimationFrame||!1,m=window.cancelAnimationFrame||!1;k.forEach(function(a){l||(l=window[a+"RequestAnimationFrame"]),m||(m=window[a+"CancelAnimationFrame"]||window[a+"CancelRequestAnimationFrame"])});var n=window.MutationObserver||window.WebKitMutationObserver||!1,o={zindex:"auto",cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:24,touchbehavior:!1,hwacceleration:!0,usetransition:!0,boxzoom:!1,dblclickzoom:!0,gesturezoom:!0,grabcursorenabled:!0,autohidemode:!0,background:"",iframeautoresize:!0,cursorminheight:32,preservenativescrolling:!0,railoffset:!1,bouncescroll:!0,spacebarenabled:!0,railpadding:{top:0,right:0,left:0,bottom:0},disableoutline:!0,horizrailenabled:!0,railalign:"right",railvalign:"bottom",enabletranslate3d:!0,enablemousewheel:!0,enablekeyboard:!0,smoothscroll:!0,sensitiverail:!0,enablemouselockapi:!0,cursorfixedheight:!1,directionlockdeadzone:6,hidecursordelay:400,nativeparentscrolling:!0,enablescrollonselection:!0,overflowx:!0,overflowy:!0,cursordragspeed:.3,rtlmode:!1,cursordragontouch:!1},p=!1,q=function(){function g(){var c=["-moz-grab","-webkit-grab","grab"];(b.ischrome&&!b.ischrome22||b.isie)&&(c=[]);for(var d=0;d<c.length;d++){var e=c[d];if(a.style.cursor=e,a.style.cursor==e)return e}return"url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize"}if(p)return p;var a=document.createElement("DIV"),b={};b.haspointerlock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,b.isopera="opera"in window,b.isopera12=b.isopera&&"getUserMedia"in navigator,b.isie="all"in document&&"attachEvent"in a&&!b.isopera,b.isieold=b.isie&&!("msInterpolationMode"in a.style),b.isie7=!(!b.isie||b.isieold||"documentMode"in document&&7!=document.documentMode),b.isie8=b.isie&&"documentMode"in document&&8==document.documentMode,b.isie9=b.isie&&"performance"in window&&document.documentMode>=9,b.isie10=b.isie&&"performance"in window&&document.documentMode>=10,b.isie9mobile=/iemobile.9/i.test(navigator.userAgent),b.isie9mobile&&(b.isie9=!1),b.isie7mobile=!b.isie9mobile&&b.isie7&&/iemobile/i.test(navigator.userAgent),b.ismozilla="MozAppearance"in a.style,b.iswebkit="WebkitAppearance"in a.style,b.ischrome="chrome"in window,b.ischrome22=b.ischrome&&b.haspointerlock,b.ischrome26=b.ischrome&&"transition"in a.style,b.cantouch="ontouchstart"in document.documentElement||"ontouchstart"in window,b.hasmstouch=window.navigator.msPointerEnabled||!1,b.ismac=/^mac$/i.test(navigator.platform),b.isios=b.cantouch&&/iphone|ipad|ipod/i.test(navigator.platform),b.isios4=b.isios&&!("seal"in Object),b.isandroid=/android/i.test(navigator.userAgent),b.trstyle=!1,b.hastransform=!1,b.hastranslate3d=!1,b.transitionstyle=!1,b.hastransition=!1,b.transitionend=!1;for(var c=["transform","msTransform","webkitTransform","MozTransform","OTransform"],d=0;d<c.length;d++)if("undefined"!=typeof a.style[c[d]]){b.trstyle=c[d];break}b.hastransform=0!=b.trstyle,b.hastransform&&(a.style[b.trstyle]="translate3d(1px,2px,3px)",b.hastranslate3d=/translate3d/.test(a.style[b.trstyle])),b.transitionstyle=!1,b.prefixstyle="",b.transitionend=!1;for(var c=["transition","webkitTransition","MozTransition","OTransition","OTransition","msTransition","KhtmlTransition"],e=["","-webkit-","-moz-","-o-","-o","-ms-","-khtml-"],f=["transitionend","webkitTransitionEnd","transitionend","otransitionend","oTransitionEnd","msTransitionEnd","KhtmlTransitionEnd"],d=0;d<c.length;d++)if(c[d]in a.style){b.transitionstyle=c[d],b.prefixstyle=e[d],b.transitionend=f[d];break}return b.ischrome26&&(b.prefixstyle=e[1]),b.hastransition=b.transitionstyle,b.cursorgrabvalue=g(),b.hasmousecapture="setCapture"in a,b.hasMutationObserver=n!==!1,a=null,p=b,b},r=function(a,d){function t(){var a=i.win;if("zIndex"in a)return a.zIndex();for(;a.length>0;){if(9==a[0].nodeType)return!1;var b=a.css("zIndex");if(!isNaN(b)&&0!=b)return parseInt(b);a=a.parent()}return!1}function v(a,b,c){var d=a.css(b),e=parseFloat(d);if(isNaN(e)){e=u[d]||0;var f=3==e?c?i.win.outerHeight()-i.win.innerHeight():i.win.outerWidth()-i.win.innerWidth():1;return i.isie8&&e&&(e+=1),f?e:0}return e}function w(a,b,c,d){i._bind(a,b,function(d){var d=d?d:window.event,e={original:d,target:d.target||d.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"==d.type?0:1,deltaX:0,deltaZ:0,preventDefault:function(){return d.preventDefault?d.preventDefault():d.returnValue=!1,!1},stopImmediatePropagation:function(){d.stopImmediatePropagation?d.stopImmediatePropagation():d.cancelBubble=!0}};return"mousewheel"==b?(e.deltaY=-1/40*d.wheelDelta,d.wheelDeltaX&&(e.deltaX=-1/40*d.wheelDeltaX)):e.deltaY=d.detail,c.call(a,e)},d)}function x(a,b,c){var d,e;if(0==a.deltaMode?(d=-Math.floor(a.deltaX*(i.opt.mousescrollstep/54)),e=-Math.floor(a.deltaY*(i.opt.mousescrollstep/54))):1==a.deltaMode&&(d=-Math.floor(a.deltaX*i.opt.mousescrollstep),e=-Math.floor(a.deltaY*i.opt.mousescrollstep)),b&&0==d&&e&&(d=e,e=0),d&&(i.scrollmom&&i.scrollmom.stop(),i.lastdeltax+=d,i.debounced("mousewheelx",function(){var a=i.lastdeltax;i.lastdeltax=0,i.rail.drag||i.doScrollLeftBy(a)},120)),e){if(i.opt.nativeparentscrolling&&c&&!i.ispage&&!i.zoomactive)if(0>e){if(i.getScrollTop()>=i.page.maxh)return!0}else if(i.getScrollTop()<=0)return!0;i.scrollmom&&i.scrollmom.stop(),i.lastdeltay+=e,i.debounced("mousewheely",function(){var a=i.lastdeltay;i.lastdeltay=0,i.rail.drag||i.doScrollBy(a)},120)}return a.stopImmediatePropagation(),a.preventDefault()}var i=this;if(this.version="3.4.0",this.name="nicescroll",this.me=d,this.opt={doc:h("body"),win:!1},h.extend(this.opt,o),this.opt.snapbackspeed=80,a)for(var k in i.opt)"undefined"!=typeof a[k]&&(i.opt[k]=a[k]);this.doc=i.opt.doc,this.iddoc=this.doc&&this.doc[0]?this.doc[0].id||"":"",this.ispage=/BODY|HTML/.test(i.opt.win?i.opt.win[0].nodeName:this.doc[0].nodeName),this.haswrapper=i.opt.win!==!1,this.win=i.opt.win||(this.ispage?h(window):this.doc),this.docscroll=this.ispage&&!this.haswrapper?h(window):this.win,this.body=h("body"),this.viewport=!1,this.isfixed=!1,this.iframe=!1,this.isiframe="IFRAME"==this.doc[0].nodeName&&"IFRAME"==this.win[0].nodeName,this.istextarea="TEXTAREA"==this.win[0].nodeName,this.forcescreen=!1,this.canshowonmouseevent="scroll"!=i.opt.autohidemode,this.onmousedown=!1,this.onmouseup=!1,this.onmousemove=!1,this.onmousewheel=!1,this.onkeypress=!1,this.ongesturezoom=!1,this.onclick=!1,this.onscrollstart=!1,this.onscrollend=!1,this.onscrollcancel=!1,this.onzoomin=!1,this.onzoomout=!1,this.view=!1,this.page=!1,this.scroll={x:0,y:0},this.scrollratio={x:0,y:0},this.cursorheight=20,this.scrollvaluemax=0,this.checkrtlmode=!1,this.scrollrunning=!1,this.scrollmom=!1,this.observer=!1,this.observerremover=!1;do this.id="ascrail"+f++;while(document.getElementById(this.id));this.rail=!1,this.cursor=!1,this.cursorfreezed=!1,this.selectiondrag=!1,this.zoom=!1,this.zoomactive=!1,this.hasfocus=!1,this.hasmousefocus=!1,this.visibility=!0,this.locked=!1,this.hidden=!1,this.cursoractive=!0,this.overflowx=i.opt.overflowx,this.overflowy=i.opt.overflowy,this.nativescrollingarea=!1,this.checkarea=0,this.events=[],this.saved={},this.delaylist={},this.synclist={},this.lastdeltax=0,this.lastdeltay=0,this.detected=q();var p=h.extend({},this.detected);this.canhwscroll=p.hastransform&&i.opt.hwacceleration,this.ishwscroll=this.canhwscroll&&i.haswrapper,this.istouchcapable=!1,p.cantouch&&p.ischrome&&!p.isios&&!p.isandroid&&(this.istouchcapable=!0,p.cantouch=!1),p.cantouch&&p.ismozilla&&!p.isios&&(this.istouchcapable=!0,p.cantouch=!1),i.opt.enablemouselockapi||(p.hasmousecapture=!1,p.haspointerlock=!1),this.delayed=function(a,b,c,d){var e=i.delaylist[a],f=(new Date).getTime();return!d&&e&&e.tt?!1:(e&&e.tt&&clearTimeout(e.tt),e&&e.last+c>f&&!e.tt?i.delaylist[a]={last:f+c,tt:setTimeout(function(){i.delaylist[a].tt=0,b.call()},c)}:e&&e.tt||(i.delaylist[a]={last:f,tt:0},setTimeout(function(){b.call()},0)),void 0)},this.debounced=function(a,b,c){var d=i.delaylist[a];(new Date).getTime(),i.delaylist[a]=b,d||setTimeout(function(){var b=i.delaylist[a];i.delaylist[a]=!1,b.call()},c)},this.synched=function(a,b){function c(){i.onsync||(l(function(){i.onsync=!1;for(a in i.synclist){var b=i.synclist[a];b&&b.call(i),i.synclist[a]=!1}}),i.onsync=!0)}return i.synclist[a]=b,c(),a},this.unsynched=function(a){i.synclist[a]&&(i.synclist[a]=!1)},this.css=function(a,b){for(var c in b)i.saved.css.push([a,c,a.css(c)]),a.css(c,b[c])},this.scrollTop=function(a){return"undefined"==typeof a?i.getScrollTop():i.setScrollTop(a)},this.scrollLeft=function(a){return"undefined"==typeof a?i.getScrollLeft():i.setScrollLeft(a)};var r=function(a,b,c,d,e,f,g){this.st=a,this.ed=b,this.spd=c,this.p1=d||0,this.p2=e||1,this.p3=f||0,this.p4=g||1,this.ts=(new Date).getTime(),this.df=this.ed-this.st};r.prototype={B2:function(a){return 3*a*a*(1-a)},B3:function(a){return 3*a*(1-a)*(1-a)},B4:function(a){return(1-a)*(1-a)*(1-a)},getNow:function(){var a=(new Date).getTime(),b=1-(a-this.ts)/this.spd,c=this.B2(b)+this.B3(b)+this.B4(b);return 0>b?this.ed:this.st+Math.round(this.df*c)},update:function(a,b){return this.st=this.getNow(),this.ed=a,this.spd=b,this.ts=(new Date).getTime(),this.df=this.ed-this.st,this}},this.ishwscroll?(this.doc.translate={x:0,y:0,tx:"0px",ty:"0px"},p.hastranslate3d&&p.isios&&this.doc.css("-webkit-backface-visibility","hidden"),this.getMatrixValues=function(){var a=i.doc.css(p.trstyle);return a&&"matrix"==a.substr(0,6)?a.replace(/^.*\((.*)\)$/g,"$1").replace(/px/g,"").split(/, +/):!1},this.getScrollTop=function(a){if(!a){var b=this.getMatrixValues();if(b)return 16==b.length?-b[13]:-b[5];if(i.timerscroll&&i.timerscroll.bz)return i.timerscroll.bz.getNow()}return i.doc.translate.y},this.getScrollLeft=function(a){if(!a){var b=this.getMatrixValues();if(b)return 16==b.length?-b[12]:-b[4];if(i.timerscroll&&i.timerscroll.bh)return i.timerscroll.bh.getNow()}return i.doc.translate.x},this.notifyScrollEvent=document.createEvent?function(a){var b=document.createEvent("UIEvents");b.initUIEvent("scroll",!1,!0,window,1),a.dispatchEvent(b)}:document.fireEvent?function(a){var b=document.createEventObject();a.fireEvent("onscroll"),b.cancelBubble=!0}:function(){},p.hastranslate3d&&i.opt.enabletranslate3d?(this.setScrollTop=function(a,b){i.doc.translate.y=a,i.doc.translate.ty=-1*a+"px",i.doc.css(p.trstyle,"translate3d("+i.doc.translate.tx+","+i.doc.translate.ty+",0px)"),b||i.notifyScrollEvent(i.win[0])},this.setScrollLeft=function(a,b){i.doc.translate.x=a,i.doc.translate.tx=-1*a+"px",i.doc.css(p.trstyle,"translate3d("+i.doc.translate.tx+","+i.doc.translate.ty+",0px)"),b||i.notifyScrollEvent(i.win[0])}):(this.setScrollTop=function(a,b){i.doc.translate.y=a,i.doc.translate.ty=-1*a+"px",i.doc.css(p.trstyle,"translate("+i.doc.translate.tx+","+i.doc.translate.ty+")"),b||i.notifyScrollEvent(i.win[0])},this.setScrollLeft=function(a,b){i.doc.translate.x=a,i.doc.translate.tx=-1*a+"px",i.doc.css(p.trstyle,"translate("+i.doc.translate.tx+","+i.doc.translate.ty+")"),b||i.notifyScrollEvent(i.win[0])})):(this.getScrollTop=function(){return i.docscroll.scrollTop()},this.setScrollTop=function(a){return i.docscroll.scrollTop(a)},this.getScrollLeft=function(){return i.docscroll.scrollLeft()},this.setScrollLeft=function(a){return i.docscroll.scrollLeft(a)}),this.getTarget=function(a){return a?a.target?a.target:a.srcElement?a.srcElement:!1:!1},this.hasParent=function(a,b){if(!a)return!1;for(var c=a.target||a.srcElement||a||!1;c&&c.id!=b;)c=c.parentNode||!1;return c!==!1};var u={thin:1,medium:3,thick:5};this.getOffset=function(){if(i.isfixed)return{top:parseFloat(i.win.css("top")),left:parseFloat(i.win.css("left"))};if(!i.viewport)return i.win.offset();var a=i.win.offset(),b=i.viewport.offset();return{top:a.top-b.top+i.viewport.scrollTop(),left:a.left-b.left+i.viewport.scrollLeft()}},this.updateScrollBar=function(a){if(i.ishwscroll)i.rail.css({height:i.win.innerHeight()}),i.railh&&i.railh.css({width:i.win.innerWidth()});else{var b=i.getOffset(),c={top:b.top,left:b.left};c.top+=v(i.win,"border-top-width",!0),(i.win.outerWidth()-i.win.innerWidth())/2,c.left+=i.rail.align?i.win.outerWidth()-v(i.win,"border-right-width")-i.rail.width:v(i.win,"border-left-width");var e=i.opt.railoffset;if(e&&(e.top&&(c.top+=e.top),i.rail.align&&e.left&&(c.left+=e.left)),i.locked||i.rail.css({top:c.top,left:c.left,height:a?a.h:i.win.innerHeight()}),i.zoom&&i.zoom.css({top:c.top+1,left:1==i.rail.align?c.left-20:c.left+i.rail.width+4}),i.railh&&!i.locked){var c={top:b.top,left:b.left},f=i.railh.align?c.top+v(i.win,"border-top-width",!0)+i.win.innerHeight()-i.railh.height:c.top+v(i.win,"border-top-width",!0),g=c.left+v(i.win,"border-left-width");i.railh.css({top:f,left:g,width:i.railh.width})}}},this.doRailClick=function(a,b,c){var d,e,f,g;i.locked||(i.cancelEvent(a),b?(d=c?i.doScrollLeft:i.doScrollTop,f=c?(a.pageX-i.railh.offset().left-i.cursorwidth/2)*i.scrollratio.x:(a.pageY-i.rail.offset().top-i.cursorheight/2)*i.scrollratio.y,d(f)):(d=c?i.doScrollLeftBy:i.doScrollBy,f=c?i.scroll.x:i.scroll.y,g=c?a.pageX-i.railh.offset().left:a.pageY-i.rail.offset().top,e=c?i.view.w:i.view.h,f>=g?d(e):d(-e)))},i.hasanimationframe=l,i.hascancelanimationframe=m,i.hasanimationframe?i.hascancelanimationframe||(m=function(){i.cancelAnimationFrame=!0}):(l=function(a){return setTimeout(a,15-Math.floor(+new Date/1e3)%16)},m=clearInterval),this.init=function(){if(i.saved.css=[],p.isie7mobile)return!0;if(p.hasmstouch&&i.css(i.ispage?h("html"):i.win,{"-ms-touch-action":"none"}),i.zindex="auto",i.zindex=i.ispage||"auto"!=i.opt.zindex?i.opt.zindex:t()||"auto",i.ispage||"auto"==i.zindex||i.zindex>g&&(g=i.zindex),i.isie&&0==i.zindex&&"auto"==i.opt.zindex&&(i.zindex="auto"),!i.ispage||!p.cantouch&&!p.isieold&&!p.isie9mobile){var a=i.docscroll;i.ispage&&(a=i.haswrapper?i.win:i.doc),p.isie9mobile||i.css(a,{"overflow-y":"hidden"}),i.ispage&&p.isie7&&("BODY"==i.doc[0].nodeName?i.css(h("html"),{"overflow-y":"hidden"}):"HTML"==i.doc[0].nodeName&&i.css(h("body"),{"overflow-y":"hidden"})),!p.isios||i.ispage||i.haswrapper||i.css(h("body"),{"-webkit-overflow-scrolling":"touch"});var d=h(document.createElement("div"));d.css({position:"relative",top:0,"float":"right",width:i.opt.cursorwidth,height:"0px","background-color":i.opt.cursorcolor,border:i.opt.cursorborder,"background-clip":"padding-box","-webkit-border-radius":i.opt.cursorborderradius,"-moz-border-radius":i.opt.cursorborderradius,"border-radius":i.opt.cursorborderradius}),d.hborder=parseFloat(d.outerHeight()-d.innerHeight()),i.cursor=d;var f=h(document.createElement("div"));f.attr("id",i.id),f.addClass("nicescroll-rails");var k,l,m=["left","right"];for(var o in m)l=m[o],k=i.opt.railpadding[l],k?f.css("padding-"+l,k+"px"):i.opt.railpadding[l]=0;f.append(d),f.width=Math.max(parseFloat(i.opt.cursorwidth),d.outerWidth())+i.opt.railpadding.left+i.opt.railpadding.right,f.css({width:f.width+"px",zIndex:i.zindex,background:i.opt.background,cursor:"default"}),f.visibility=!0,f.scrollable=!0,f.align="left"==i.opt.railalign?0:1,i.rail=f,i.rail.drag=!1;var q=!1;if(!i.opt.boxzoom||i.ispage||p.isieold||(q=document.createElement("div"),i.bind(q,"click",i.doZoom),i.zoom=h(q),i.zoom.css({cursor:"pointer","z-index":i.zindex,backgroundImage:"url("+j+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),i.opt.dblclickzoom&&i.bind(i.win,"dblclick",i.doZoom),p.cantouch&&i.opt.gesturezoom&&(i.ongesturezoom=function(a){return a.scale>1.5&&i.doZoomIn(a),a.scale<.8&&i.doZoomOut(a),i.cancelEvent(a)},i.bind(i.win,"gestureend",i.ongesturezoom))),i.railh=!1,i.opt.horizrailenabled){i.css(a,{"overflow-x":"hidden"});var d=h(document.createElement("div"));d.css({position:"relative",top:0,height:i.opt.cursorwidth,width:"0px","background-color":i.opt.cursorcolor,border:i.opt.cursorborder,"background-clip":"padding-box","-webkit-border-radius":i.opt.cursorborderradius,"-moz-border-radius":i.opt.cursorborderradius,"border-radius":i.opt.cursorborderradius}),d.wborder=parseFloat(d.outerWidth()-d.innerWidth()),i.cursorh=d;var r=h(document.createElement("div"));r.attr("id",i.id+"-hr"),r.addClass("nicescroll-rails"),r.height=Math.max(parseFloat(i.opt.cursorwidth),d.outerHeight()),r.css({height:r.height+"px",zIndex:i.zindex,background:i.opt.background}),r.append(d),r.visibility=!0,r.scrollable=!0,r.align="top"==i.opt.railvalign?0:1,i.railh=r,i.railh.drag=!1}if(i.ispage)f.css({position:"fixed",top:"0px",height:"100%"}),f.align?f.css({right:"0px"}):f.css({left:"0px"}),i.body.append(f),i.railh&&(r.css({position:"fixed",left:"0px",width:"100%"}),r.align?r.css({bottom:"0px"}):r.css({top:"0px"}),i.body.append(r));else{if(i.ishwscroll){"static"==i.win.css("position")&&i.css(i.win,{position:"relative"});var u="HTML"==i.win[0].nodeName?i.body:i.win;i.zoom&&(i.zoom.css({position:"absolute",top:1,right:0,"margin-right":f.width+4}),u.append(i.zoom)),f.css({position:"absolute",top:0}),f.align?f.css({right:0}):f.css({left:0}),u.append(f),r&&(r.css({position:"absolute",left:0,bottom:0}),r.align?r.css({bottom:0}):r.css({top:0}),u.append(r))}else{i.isfixed="fixed"==i.win.css("position");var v=i.isfixed?"fixed":"absolute";i.isfixed||(i.viewport=i.getViewport(i.win[0])),i.viewport&&(i.body=i.viewport,0==/relative|absolute/.test(i.viewport.css("position"))&&i.css(i.viewport,{position:"relative"})),f.css({position:v}),i.zoom&&i.zoom.css({position:v}),i.updateScrollBar(),i.body.append(f),i.zoom&&i.body.append(i.zoom),i.railh&&(r.css({position:v}),i.body.append(r))}p.isios&&i.css(i.win,{"-webkit-tap-highlight-color":"rgba(0,0,0,0)","-webkit-touch-callout":"none"}),p.isie&&i.opt.disableoutline&&i.win.attr("hideFocus","true"),p.iswebkit&&i.opt.disableoutline&&i.win.css({outline:"none"})}if(i.opt.autohidemode===!1?(i.autohidedom=!1,i.rail.css({opacity:i.opt.cursoropacitymax}),i.railh&&i.railh.css({opacity:i.opt.cursoropacitymax})):i.opt.autohidemode===!0?(i.autohidedom=h().add(i.rail),p.isie8&&(i.autohidedom=i.autohidedom.add(i.cursor)),i.railh&&(i.autohidedom=i.autohidedom.add(i.railh)),i.railh&&p.isie8&&(i.autohidedom=i.autohidedom.add(i.cursorh))):"scroll"==i.opt.autohidemode?(i.autohidedom=h().add(i.rail),i.railh&&(i.autohidedom=i.autohidedom.add(i.railh))):"cursor"==i.opt.autohidemode?(i.autohidedom=h().add(i.cursor),i.railh&&(i.autohidedom=i.autohidedom.add(i.cursorh))):"hidden"==i.opt.autohidemode&&(i.autohidedom=!1,i.hide(),i.locked=!1),p.isie9mobile){i.scrollmom=new s(i),i.onmangotouch=function(){var b=i.getScrollTop(),c=i.getScrollLeft();if(b==i.scrollmom.lastscrolly&&c==i.scrollmom.lastscrollx)return!0;var d=b-i.mangotouch.sy,e=c-i.mangotouch.sx,f=Math.round(Math.sqrt(Math.pow(e,2)+Math.pow(d,2)));if(0!=f){var g=0>d?-1:1,h=0>e?-1:1,j=+new Date;if(i.mangotouch.lazy&&clearTimeout(i.mangotouch.lazy),j-i.mangotouch.tm>80||i.mangotouch.dry!=g||i.mangotouch.drx!=h)i.scrollmom.stop(),i.scrollmom.reset(c,b),i.mangotouch.sy=b,i.mangotouch.ly=b,i.mangotouch.sx=c,i.mangotouch.lx=c,i.mangotouch.dry=g,i.mangotouch.drx=h,i.mangotouch.tm=j;else{i.scrollmom.stop(),i.scrollmom.update(i.mangotouch.sx-e,i.mangotouch.sy-d),j-i.mangotouch.tm,i.mangotouch.tm=j;var l=Math.max(Math.abs(i.mangotouch.ly-b),Math.abs(i.mangotouch.lx-c));i.mangotouch.ly=b,i.mangotouch.lx=c,l>2&&(i.mangotouch.lazy=setTimeout(function(){i.mangotouch.lazy=!1,i.mangotouch.dry=0,i.mangotouch.drx=0,i.mangotouch.tm=0,i.scrollmom.doMomentum(30)},100))}}};var w=i.getScrollTop(),x=i.getScrollLeft();i.mangotouch={sy:w,ly:w,dry:0,sx:x,lx:x,drx:0,lazy:!1,tm:0},i.bind(i.docscroll,"scroll",i.onmangotouch)}else{if(p.cantouch||i.istouchcapable||i.opt.touchbehavior||p.hasmstouch){i.scrollmom=new s(i),i.ontouchstart=function(a){if(a.pointerType&&2!=a.pointerType)return!1;if(!i.locked){if(p.hasmstouch)for(var b=a.target?a.target:!1;b;){var c=h(b).getNiceScroll();if(c.length>0&&c[0].me==i.me)break;if(c.length>0)return!1;if("DIV"==b.nodeName&&b.id==i.id)break;b=b.parentNode?b.parentNode:!1}i.cancelScroll();var b=i.getTarget(a);if(b){var d=/INPUT/i.test(b.nodeName)&&/range/i.test(b.type);if(d)return i.stopPropagation(a)}if(!("clientX"in a)&&"changedTouches"in a&&(a.clientX=a.changedTouches[0].clientX,a.clientY=a.changedTouches[0].clientY),i.forcescreen){var e=a,a={original:a.original?a.original:a};a.clientX=e.screenX,a.clientY=e.screenY}if(i.rail.drag={x:a.clientX,y:a.clientY,sx:i.scroll.x,sy:i.scroll.y,st:i.getScrollTop(),sl:i.getScrollLeft(),pt:2,dl:!1},i.ispage||!i.opt.directionlockdeadzone)i.rail.drag.dl="f";else{var f={w:h(window).width(),h:h(window).height()},g={w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},j=Math.max(0,g.h-f.h),k=Math.max(0,g.w-f.w);i.rail.drag.ck=!i.rail.scrollable&&i.railh.scrollable?j>0?"v":!1:i.rail.scrollable&&!i.railh.scrollable?k>0?"h":!1:!1,i.rail.drag.ck||(i.rail.drag.dl="f")}if(i.opt.touchbehavior&&i.isiframe&&p.isie){var l=i.win.position();i.rail.drag.x+=l.left,i.rail.drag.y+=l.top}if(i.hasmoving=!1,i.lastmouseup=!1,i.scrollmom.reset(a.clientX,a.clientY),!p.cantouch&&!this.istouchcapable&&!p.hasmstouch){var m=b?/INPUT|SELECT|TEXTAREA/i.test(b.nodeName):!1;if(!m)return!i.ispage&&p.hasmousecapture&&b.setCapture(),i.cancelEvent(a);/SUBMIT|CANCEL|BUTTON/i.test(h(b).attr("type"))&&(pc={tg:b,click:!1},i.preventclick=pc)}}},i.ontouchend=function(a){return a.pointerType&&2!=a.pointerType?!1:i.rail.drag&&2==i.rail.drag.pt&&(i.scrollmom.doMomentum(),i.rail.drag=!1,i.hasmoving&&(i.hasmoving=!1,i.lastmouseup=!0,i.hideCursor(),p.hasmousecapture&&document.releaseCapture(),!p.cantouch))?i.cancelEvent(a):void 0};var y=i.opt.touchbehavior&&i.isiframe&&!p.hasmousecapture;i.ontouchmove=function(a,b){if(a.pointerType&&2!=a.pointerType)return!1;if(i.rail.drag&&2==i.rail.drag.pt){if(p.cantouch&&"undefined"==typeof a.original)return!0;i.hasmoving=!0,i.preventclick&&!i.preventclick.click&&(i.preventclick.click=i.preventclick.tg.onclick||!1,i.preventclick.tg.onclick=i.onpreventclick);var c=h.extend({original:a},a);if(a=c,"changedTouches"in a&&(a.clientX=a.changedTouches[0].clientX,a.clientY=a.changedTouches[0].clientY),i.forcescreen){var d=a,a={original:a.original?a.original:a};a.clientX=d.screenX,a.clientY=d.screenY}var e=ofy=0;if(y&&!b){var f=i.win.position();e=-f.left,ofy=-f.top}var g=a.clientY+ofy,j=g-i.rail.drag.y,k=a.clientX+e,l=k-i.rail.drag.x,m=i.rail.drag.st-j;if(i.ishwscroll&&i.opt.bouncescroll?0>m?m=Math.round(m/2):m>i.page.maxh&&(m=i.page.maxh+Math.round((m-i.page.maxh)/2)):(0>m&&(m=0,g=0),m>i.page.maxh&&(m=i.page.maxh,g=0)),i.railh&&i.railh.scrollable){var n=i.rail.drag.sl-l;i.ishwscroll&&i.opt.bouncescroll?0>n?n=Math.round(n/2):n>i.page.maxw&&(n=i.page.maxw+Math.round((n-i.page.maxw)/2)):(0>n&&(n=0,k=0),n>i.page.maxw&&(n=i.page.maxw,k=0))}var o=!1;if(i.rail.drag.dl)o=!0,"v"==i.rail.drag.dl?n=i.rail.drag.sl:"h"==i.rail.drag.dl&&(m=i.rail.drag.st);else{var q=Math.abs(j),r=Math.abs(l),s=i.opt.directionlockdeadzone;if("v"==i.rail.drag.ck){if(q>s&&.3*q>=r)return i.rail.drag=!1,!0;r>s&&(i.rail.drag.dl="f",h("body").scrollTop(h("body").scrollTop()))}else if("h"==i.rail.drag.ck){if(r>s&&.3*az>=q)return i.rail.drag=!1,!0;q>s&&(i.rail.drag.dl="f",h("body").scrollLeft(h("body").scrollLeft()))}}if(i.synched("touchmove",function(){i.rail.drag&&2==i.rail.drag.pt&&(i.prepareTransition&&i.prepareTransition(0),i.rail.scrollable&&i.setScrollTop(m),i.scrollmom.update(k,g),i.railh&&i.railh.scrollable?(i.setScrollLeft(n),i.showCursor(m,n)):i.showCursor(m),p.isie10&&document.selection.clear())}),p.ischrome&&i.istouchcapable&&(o=!1),o)return i.cancelEvent(a)}}}i.onmousedown=function(a,b){if(!i.rail.drag||1==i.rail.drag.pt){if(i.locked)return i.cancelEvent(a);i.cancelScroll(),i.rail.drag={x:a.clientX,y:a.clientY,sx:i.scroll.x,sy:i.scroll.y,pt:1,hr:!!b};var c=i.getTarget(a);return!i.ispage&&p.hasmousecapture&&c.setCapture(),i.isiframe&&!p.hasmousecapture&&(i.saved.csspointerevents=i.doc.css("pointer-events"),i.css(i.doc,{"pointer-events":"none"})),i.cancelEvent(a)}},i.onmouseup=function(a){if(i.rail.drag){if(p.hasmousecapture&&document.releaseCapture(),i.isiframe&&!p.hasmousecapture&&i.doc.css("pointer-events",i.saved.csspointerevents),1!=i.rail.drag.pt)return;return i.rail.drag=!1,i.cancelEvent(a)}},i.onmousemove=function(a){if(i.rail.drag){if(1!=i.rail.drag.pt)return;if(p.ischrome&&0==a.which)return i.onmouseup(a);if(i.cursorfreezed=!0,i.rail.drag.hr){i.scroll.x=i.rail.drag.sx+(a.clientX-i.rail.drag.x),i.scroll.x<0&&(i.scroll.x=0);var b=i.scrollvaluemaxw;i.scroll.x>b&&(i.scroll.x=b)}else{i.scroll.y=i.rail.drag.sy+(a.clientY-i.rail.drag.y),i.scroll.y<0&&(i.scroll.y=0);var c=i.scrollvaluemax;i.scroll.y>c&&(i.scroll.y=c)}return i.synched("mousemove",function(){i.rail.drag&&1==i.rail.drag.pt&&(i.showCursor(),i.rail.drag.hr?i.doScrollLeft(Math.round(i.scroll.x*i.scrollratio.x),i.opt.cursordragspeed):i.doScrollTop(Math.round(i.scroll.y*i.scrollratio.y),i.opt.cursordragspeed))}),i.cancelEvent(a)}},p.cantouch||i.opt.touchbehavior?(i.onpreventclick=function(a){return i.preventclick?(i.preventclick.tg.onclick=i.preventclick.click,i.preventclick=!1,i.cancelEvent(a)):void 0},i.bind(i.win,"mousedown",i.ontouchstart),i.onclick=p.isios?!1:function(a){return i.lastmouseup?(i.lastmouseup=!1,i.cancelEvent(a)):!0},i.opt.grabcursorenabled&&p.cursorgrabvalue&&(i.css(i.ispage?i.doc:i.win,{cursor:p.cursorgrabvalue}),i.css(i.rail,{cursor:p.cursorgrabvalue}))):(this.checkSelectionScroll=function(a){if(i.selectiondrag){if(a){var b=i.win.outerHeight(),c=a.pageY-i.selectiondrag.top;c>0&&b>c&&(c=0),c>=b&&(c-=b),i.selectiondrag.df=c}if(0!=i.selectiondrag.df){var d=2*-Math.floor(i.selectiondrag.df/6);i.doScrollBy(d),i.debounced("doselectionscroll",function(){this.checkSelectionScroll()},50)}}},i.hasTextSelected="getSelection"in document?function(){return document.getSelection().rangeCount>0}:"selection"in document?function(){return"None"!=document.selection.type}:function(){return!1},i.onselectionstart=function(){i.ispage||(i.selectiondrag=i.win.offset())},i.onselectionend=function(){i.selectiondrag=!1},i.onselectiondrag=function(a){i.selectiondrag&&i.hasTextSelected()&&i.debounced("selectionscroll",function(){this.checkSelectionScroll(a)},250)}),p.hasmstouch&&(i.css(i.rail,{"-ms-touch-action":"none"}),i.css(i.cursor,{"-ms-touch-action":"none"}),i.bind(i.win,"MSPointerDown",i.ontouchstart),i.bind(document,"MSPointerUp",i.ontouchend),i.bind(document,"MSPointerMove",i.ontouchmove),i.bind(i.cursor,"MSGestureHold",function(a){a.preventDefault()}),i.bind(i.cursor,"contextmenu",function(a){a.preventDefault()})),this.istouchcapable&&(i.bind(i.win,"touchstart",i.ontouchstart),i.bind(document,"touchend",i.ontouchend),i.bind(document,"touchcancel",i.ontouchend),i.bind(document,"touchmove",i.ontouchmove)),i.bind(i.cursor,"mousedown",i.onmousedown),i.bind(i.cursor,"mouseup",i.onmouseup),i.railh&&(i.bind(i.cursorh,"mousedown",function(a){i.onmousedown(a,!0)}),i.bind(i.cursorh,"mouseup",function(a){return i.rail.drag&&2==i.rail.drag.pt?void 0:(i.rail.drag=!1,i.hasmoving=!1,i.hideCursor(),p.hasmousecapture&&document.releaseCapture(),i.cancelEvent(a))})),(i.opt.cursordragontouch||!p.cantouch&&!i.opt.touchbehavior)&&(i.rail.css({cursor:"default"}),i.railh&&i.railh.css({cursor:"default"}),i.jqbind(i.rail,"mouseenter",function(){i.canshowonmouseevent&&i.showCursor(),i.rail.active=!0}),i.jqbind(i.rail,"mouseleave",function(){i.rail.active=!1,i.rail.drag||i.hideCursor()}),i.opt.sensitiverail&&(i.bind(i.rail,"click",function(a){i.doRailClick(a,!1,!1)}),i.bind(i.rail,"dblclick",function(a){i.doRailClick(a,!0,!1)}),i.bind(i.cursor,"click",function(a){i.cancelEvent(a)}),i.bind(i.cursor,"dblclick",function(a){i.cancelEvent(a)})),i.railh&&(i.jqbind(i.railh,"mouseenter",function(){i.canshowonmouseevent&&i.showCursor(),i.rail.active=!0}),i.jqbind(i.railh,"mouseleave",function(){i.rail.active=!1,i.rail.drag||i.hideCursor()}),i.opt.sensitiverail&&(i.bind(i.railh,"click",function(a){i.doRailClick(a,!1,!0)}),i.bind(i.railh,"dblclick",function(a){i.doRailClick(a,!0,!0)}),i.bind(i.cursorh,"click",function(a){i.cancelEvent(a)}),i.bind(i.cursorh,"dblclick",function(a){i.cancelEvent(a)})))),p.cantouch||i.opt.touchbehavior?(i.bind(p.hasmousecapture?i.win:document,"mouseup",i.ontouchend),i.bind(document,"mousemove",i.ontouchmove),i.onclick&&i.bind(document,"click",i.onclick),i.opt.cursordragontouch&&(i.bind(i.cursor,"mousedown",i.onmousedown),i.bind(i.cursor,"mousemove",i.onmousemove),i.cursorh&&i.bind(i.cursorh,"mousedown",i.onmousedown),i.cursorh&&i.bind(i.cursorh,"mousemove",i.onmousemove))):(i.bind(p.hasmousecapture?i.win:document,"mouseup",i.onmouseup),i.bind(document,"mousemove",i.onmousemove),i.onclick&&i.bind(document,"click",i.onclick),!i.ispage&&i.opt.enablescrollonselection&&(i.bind(i.win[0],"mousedown",i.onselectionstart),i.bind(document,"mouseup",i.onselectionend),i.bind(i.cursor,"mouseup",i.onselectionend),i.cursorh&&i.bind(i.cursorh,"mouseup",i.onselectionend),i.bind(document,"mousemove",i.onselectiondrag)),i.zoom&&(i.jqbind(i.zoom,"mouseenter",function(){i.canshowonmouseevent&&i.showCursor(),i.rail.active=!0}),i.jqbind(i.zoom,"mouseleave",function(){i.rail.active=!1,i.rail.drag||i.hideCursor()}))),i.opt.enablemousewheel&&(i.isiframe||i.bind(p.isie&&i.ispage?document:i.docscroll,"mousewheel",i.onmousewheel),i.bind(i.rail,"mousewheel",i.onmousewheel),i.railh&&i.bind(i.railh,"mousewheel",i.onmousewheelhr)),i.ispage||p.cantouch||/HTML|BODY/.test(i.win[0].nodeName)||(i.win.attr("tabindex")||i.win.attr({tabindex:e++}),i.jqbind(i.win,"focus",function(a){b=i.getTarget(a).id||!0,i.hasfocus=!0,i.canshowonmouseevent&&i.noticeCursor()}),i.jqbind(i.win,"blur",function(){b=!1,i.hasfocus=!1}),i.jqbind(i.win,"mouseenter",function(a){c=i.getTarget(a).id||!0,i.hasmousefocus=!0,i.canshowonmouseevent&&i.noticeCursor()}),i.jqbind(i.win,"mouseleave",function(){c=!1,i.hasmousefocus=!1}))}if(i.onkeypress=function(a){if(i.locked&&0==i.page.maxh)return!0;a=a?a:window.e;var d=i.getTarget(a);if(d&&/INPUT|TEXTAREA|SELECT|OPTION/.test(d.nodeName)){var e=d.getAttribute("type")||d.type||!1;if(!e||!/submit|button|cancel/i.tp)return!0}if(i.hasfocus||i.hasmousefocus&&!b||i.ispage&&!b&&!c){var f=a.keyCode;if(i.locked&&27!=f)return i.cancelEvent(a);var g=a.ctrlKey||!1,h=a.shiftKey||!1,j=!1;switch(f){case 38:case 63233:i.doScrollBy(72),j=!0;break;case 40:case 63235:i.doScrollBy(-72),j=!0;break;case 37:case 63232:i.railh&&(g?i.doScrollLeft(0):i.doScrollLeftBy(72),j=!0);break;case 39:case 63234:i.railh&&(g?i.doScrollLeft(i.page.maxw):i.doScrollLeftBy(-72),j=!0);break;case 33:case 63276:i.doScrollBy(i.view.h),j=!0;break;case 34:case 63277:i.doScrollBy(-i.view.h),j=!0;break;case 36:case 63273:i.railh&&g?i.doScrollPos(0,0):i.doScrollTo(0),j=!0;break;case 35:case 63275:i.railh&&g?i.doScrollPos(i.page.maxw,i.page.maxh):i.doScrollTo(i.page.maxh),j=!0;break;case 32:i.opt.spacebarenabled&&(h?i.doScrollBy(i.view.h):i.doScrollBy(-i.view.h),j=!0);break;case 27:i.zoomactive&&(i.doZoom(),j=!0)}if(j)return i.cancelEvent(a)}},i.opt.enablekeyboard&&i.bind(document,p.isopera&&!p.isopera12?"keypress":"keydown",i.onkeypress),i.bind(window,"resize",i.lazyResize),i.bind(window,"orientationchange",i.lazyResize),i.bind(window,"load",i.lazyResize),p.ischrome&&!i.ispage&&!i.haswrapper){var z=i.win.attr("style"),A=parseFloat(i.win.css("width"))+1;i.win.css("width",A),i.synched("chromefix",function(){i.win.attr("style",z)})}i.onAttributeChange=function(){i.lazyResize(250)},i.ispage||i.haswrapper||(n!==!1?(i.observer=new n(function(a){a.forEach(i.onAttributeChange)}),i.observer.observe(i.win[0],{childList:!0,characterData:!1,attributes:!0,subtree:!1}),i.observerremover=new n(function(a){a.forEach(function(a){if(a.removedNodes.length>0)for(var b in a.removedNodes)if(a.removedNodes[b]==i.win[0])return i.remove()
})}),i.observerremover.observe(i.win[0].parentNode,{childList:!0,characterData:!1,attributes:!1,subtree:!1})):(i.bind(i.win,p.isie&&!p.isie9?"propertychange":"DOMAttrModified",i.onAttributeChange),p.isie9&&i.win[0].attachEvent("onpropertychange",i.onAttributeChange),i.bind(i.win,"DOMNodeRemoved",function(a){a.target==i.win[0]&&i.remove()}))),!i.ispage&&i.opt.boxzoom&&i.bind(window,"resize",i.resizeZoom),i.istextarea&&i.bind(i.win,"mouseup",i.lazyResize),i.checkrtlmode=!0,i.lazyResize(30)}"IFRAME"==this.doc[0].nodeName&&(this.oniframeload=function(){i.iframexd=!1;try{var b="contentDocument"in this?this.contentDocument:this.contentWindow.document;b.domain}catch(a){i.iframexd=!0,b=!1}if(i.iframexd)return"console"in window&&console.log("NiceScroll error: policy restriced iframe"),!0;if(i.forcescreen=!0,i.isiframe&&(i.iframe={doc:h(b),html:i.doc.contents().find("html")[0],body:i.doc.contents().find("body")[0]},i.getContentSize=function(){return{w:Math.max(i.iframe.html.scrollWidth,i.iframe.body.scrollWidth),h:Math.max(i.iframe.html.scrollHeight,i.iframe.body.scrollHeight)}},i.docscroll=h(i.iframe.body)),!p.isios&&i.opt.iframeautoresize&&!i.isiframe){i.win.scrollTop(0),i.doc.height("");var d=Math.max(b.getElementsByTagName("html")[0].scrollHeight,b.body.scrollHeight);i.doc.height(d)}i.lazyResize(30),p.isie7&&i.css(h(i.iframe.html),{"overflow-y":"hidden"}),i.css(h(i.iframe.body),{"overflow-y":"hidden"}),"contentWindow"in this?i.bind(this.contentWindow,"scroll",i.onscroll):i.bind(b,"scroll",i.onscroll),i.opt.enablemousewheel&&i.bind(b,"mousewheel",i.onmousewheel),i.opt.enablekeyboard&&i.bind(b,p.isopera?"keypress":"keydown",i.onkeypress),(p.cantouch||i.opt.touchbehavior)&&(i.bind(b,"mousedown",i.onmousedown),i.bind(b,"mousemove",function(a){i.onmousemove(a,!0)}),i.opt.grabcursorenabled&&p.cursorgrabvalue&&i.css(h(b.body),{cursor:p.cursorgrabvalue})),i.bind(b,"mouseup",i.onmouseup),i.zoom&&(i.opt.dblclickzoom&&i.bind(b,"dblclick",i.doZoom),i.ongesturezoom&&i.bind(b,"gestureend",i.ongesturezoom))},this.doc[0].readyState&&"complete"==this.doc[0].readyState&&setTimeout(function(){this.oniframeload.call(i.doc[0],!1)},500),i.bind(this.doc,"load",this.oniframeload))},this.showCursor=function(a,b){i.cursortimeout&&(clearTimeout(i.cursortimeout),i.cursortimeout=0),i.rail&&(i.autohidedom&&(i.autohidedom.stop().css({opacity:i.opt.cursoropacitymax}),i.cursoractive=!0),i.rail.drag&&1==i.rail.drag.pt||("undefined"!=typeof a&&a!==!1&&(i.scroll.y=Math.round(1*a/i.scrollratio.y)),"undefined"!=typeof b&&(i.scroll.x=Math.round(1*b/i.scrollratio.x))),i.cursor.css({height:i.cursorheight,top:i.scroll.y}),i.cursorh&&(!i.rail.align&&i.rail.visibility?i.cursorh.css({width:i.cursorwidth,left:i.scroll.x+i.rail.width}):i.cursorh.css({width:i.cursorwidth,left:i.scroll.x}),i.cursoractive=!0),i.zoom&&i.zoom.stop().css({opacity:i.opt.cursoropacitymax}))},this.hideCursor=function(a){i.cursortimeout||i.rail&&i.autohidedom&&(i.cursortimeout=setTimeout(function(){i.rail.active&&i.showonmouseevent||(i.autohidedom.stop().animate({opacity:i.opt.cursoropacitymin}),i.zoom&&i.zoom.stop().animate({opacity:i.opt.cursoropacitymin}),i.cursoractive=!1),i.cursortimeout=0},a||i.opt.hidecursordelay))},this.noticeCursor=function(a,b,c){i.showCursor(b,c),i.rail.active||i.hideCursor(a)},this.getContentSize=i.ispage?function(){return{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}}:i.haswrapper?function(){return{w:i.doc.outerWidth()+parseInt(i.win.css("paddingLeft"))+parseInt(i.win.css("paddingRight")),h:i.doc.outerHeight()+parseInt(i.win.css("paddingTop"))+parseInt(i.win.css("paddingBottom"))}}:function(){return{w:i.docscroll[0].scrollWidth,h:i.docscroll[0].scrollHeight}},this.onResize=function(a,b){if(!i.win)return!1;if(!i.haswrapper&&!i.ispage){if("none"==i.win.css("display"))return i.visibility&&i.hideRail().hideRailHr(),!1;i.hidden||i.visibility||i.showRail().showRailHr()}var c=i.page.maxh,d=i.page.maxw,e={h:i.view.h,w:i.view.w};if(i.view={w:i.ispage?i.win.width():parseInt(i.win[0].clientWidth),h:i.ispage?i.win.height():parseInt(i.win[0].clientHeight)},i.page=b?b:i.getContentSize(),i.page.maxh=Math.max(0,i.page.h-i.view.h),i.page.maxw=Math.max(0,i.page.w-i.view.w),i.page.maxh==c&&i.page.maxw==d&&i.view.w==e.w){if(i.ispage)return i;var f=i.win.offset();if(i.lastposition){var g=i.lastposition;if(g.top==f.top&&g.left==f.left)return i}i.lastposition=f}if(0==i.page.maxh?(i.hideRail(),i.scrollvaluemax=0,i.scroll.y=0,i.scrollratio.y=0,i.cursorheight=0,i.setScrollTop(0),i.rail.scrollable=!1):i.rail.scrollable=!0,0==i.page.maxw?(i.hideRailHr(),i.scrollvaluemaxw=0,i.scroll.x=0,i.scrollratio.x=0,i.cursorwidth=0,i.setScrollLeft(0),i.railh.scrollable=!1):i.railh.scrollable=!0,i.locked=0==i.page.maxh&&0==i.page.maxw,i.locked)return i.ispage||i.updateScrollBar(i.view),!1;i.hidden||i.visibility?i.hidden||i.railh.visibility||i.showRailHr():i.showRail().showRailHr(),i.istextarea&&i.win.css("resize")&&"none"!=i.win.css("resize")&&(i.view.h-=20),i.cursorheight=Math.min(i.view.h,Math.round(i.view.h*(i.view.h/i.page.h))),i.cursorheight=i.opt.cursorfixedheight?i.opt.cursorfixedheight:Math.max(i.opt.cursorminheight,i.cursorheight),i.cursorwidth=Math.min(i.view.w,Math.round(i.view.w*(i.view.w/i.page.w))),i.cursorwidth=i.opt.cursorfixedheight?i.opt.cursorfixedheight:Math.max(i.opt.cursorminheight,i.cursorwidth),i.scrollvaluemax=i.view.h-i.cursorheight-i.cursor.hborder,i.railh&&(i.railh.width=i.page.maxh>0?i.view.w-i.rail.width:i.view.w,i.scrollvaluemaxw=i.railh.width-i.cursorwidth-i.cursorh.wborder),i.checkrtlmode&&i.railh&&(i.checkrtlmode=!1,i.opt.rtlmode&&0==i.scroll.x&&i.setScrollLeft(i.page.maxw)),i.ispage||i.updateScrollBar(i.view),i.scrollratio={x:i.page.maxw/i.scrollvaluemaxw,y:i.page.maxh/i.scrollvaluemax};var h=i.getScrollTop();return h>i.page.maxh?i.doScrollTop(i.page.maxh):(i.scroll.y=Math.round(i.getScrollTop()*(1/i.scrollratio.y)),i.scroll.x=Math.round(i.getScrollLeft()*(1/i.scrollratio.x)),i.cursoractive&&i.noticeCursor()),i.scroll.y&&0==i.getScrollTop()&&i.doScrollTo(Math.floor(i.scroll.y*i.scrollratio.y)),i},this.resize=i.onResize,this.lazyResize=function(a){return a=isNaN(a)?30:a,i.delayed("resize",i.resize,a),i},this._bind=function(a,b,c,d){i.events.push({e:a,n:b,f:c,b:d,q:!1}),a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c},this.jqbind=function(a,b,c){i.events.push({e:a,n:b,f:c,q:!0}),h(a).bind(b,c)},this.bind=function(a,b,c,d){var e="jquery"in a?a[0]:a;if("mousewheel"==b)if("onwheel"in i.win)i._bind(e,"wheel",c,d||!1);else{var f="undefined"!=typeof document.onmousewheel?"mousewheel":"DOMMouseScroll";w(e,f,c,d||!1),"DOMMouseScroll"==f&&w(e,"MozMousePixelScroll",c,d||!1)}else if(e.addEventListener){if(p.cantouch&&/mouseup|mousedown|mousemove/.test(b)){var g="mousedown"==b?"touchstart":"mouseup"==b?"touchend":"touchmove";i._bind(e,g,function(a){if(a.touches){if(a.touches.length<2){var b=a.touches.length?a.touches[0]:a;b.original=a,c.call(this,b)}}else if(a.changedTouches){var b=a.changedTouches[0];b.original=a,c.call(this,b)}},d||!1)}i._bind(e,b,c,d||!1),p.cantouch&&"mouseup"==b&&i._bind(e,"touchcancel",c,d||!1)}else i._bind(e,b,function(a){return a=a||window.event||!1,a&&a.srcElement&&(a.target=a.srcElement),"pageY"in a||(a.pageX=a.clientX+document.documentElement.scrollLeft,a.pageY=a.clientY+document.documentElement.scrollTop),c.call(e,a)===!1||d===!1?i.cancelEvent(a):!0})},this._unbind=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=!1},this.unbindAll=function(){for(var a=0;a<i.events.length;a++){var b=i.events[a];b.q?b.e.unbind(b.n,b.f):i._unbind(b.e,b.n,b.f,b.b)}},this.cancelEvent=function(a){var a=a.original?a.original:a?a:window.event||!1;return a?(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.preventManipulation&&a.preventManipulation(),a.cancelBubble=!0,a.cancel=!0,a.returnValue=!1,!1):!1},this.stopPropagation=function(a){var a=a.original?a.original:a?a:window.event||!1;return a?a.stopPropagation?a.stopPropagation():(a.cancelBubble&&(a.cancelBubble=!0),!1):!1},this.showRail=function(){return 0==i.page.maxh||!i.ispage&&"none"==i.win.css("display")||(i.visibility=!0,i.rail.visibility=!0,i.rail.css("display","block")),i},this.showRailHr=function(){return i.railh?(0==i.page.maxw||!i.ispage&&"none"==i.win.css("display")||(i.railh.visibility=!0,i.railh.css("display","block")),i):i},this.hideRail=function(){return i.visibility=!1,i.rail.visibility=!1,i.rail.css("display","none"),i},this.hideRailHr=function(){return i.railh?(i.railh.visibility=!1,i.railh.css("display","none"),i):i},this.show=function(){return i.hidden=!1,i.locked=!1,i.showRail().showRailHr()},this.hide=function(){return i.hidden=!0,i.locked=!0,i.hideRail().hideRailHr()},this.toggle=function(){return i.hidden?i.show():i.hide()},this.remove=function(){i.stop(),i.cursortimeout&&clearTimeout(i.cursortimeout),i.doZoomOut(),i.unbindAll(),i.observer!==!1&&i.observer.disconnect(),i.observerremover!==!1&&i.observerremover.disconnect(),i.events=[],i.cursor&&(i.cursor.remove(),i.cursor=null),i.cursorh&&(i.cursorh.remove(),i.cursorh=null),i.rail&&(i.rail.remove(),i.rail=null),i.railh&&(i.railh.remove(),i.railh=null),i.zoom&&(i.zoom.remove(),i.zoom=null);for(var a=0;a<i.saved.css.length;a++){var b=i.saved.css[a];b[0].css(b[1],"undefined"==typeof b[2]?"":b[2])}return i.saved=!1,i.me.data("__nicescroll",""),i.me=null,i.doc=null,i.docscroll=null,i.win=null,i},this.scrollstart=function(a){return this.onscrollstart=a,i},this.scrollend=function(a){return this.onscrollend=a,i},this.scrollcancel=function(a){return this.onscrollcancel=a,i},this.zoomin=function(a){return this.onzoomin=a,i},this.zoomout=function(a){return this.onzoomout=a,i},this.isScrollable=function(a){var b=a.target?a.target:a;if("OPTION"==b.nodeName)return!0;for(;b&&1==b.nodeType&&!/BODY|HTML/.test(b.nodeName);){var c=h(b),d=c.css("overflowY")||c.css("overflowX")||c.css("overflow")||"";if(/scroll|auto/.test(d))return b.clientHeight!=b.scrollHeight;b=b.parentNode?b.parentNode:!1}return!1},this.getViewport=function(a){for(var b=a&&a.parentNode?a.parentNode:!1;b&&1==b.nodeType&&!/BODY|HTML/.test(b.nodeName);){var c=h(b),d=c.css("overflowY")||c.css("overflowX")||c.css("overflow")||"";if(/scroll|auto/.test(d)&&b.clientHeight!=b.scrollHeight)return c;if(c.getNiceScroll().length>0)return c;b=b.parentNode?b.parentNode:!1}return!1},this.onmousewheel=function(a){if(i.locked)return!0;if(i.rail.drag)return i.cancelEvent(a);if(!i.rail.scrollable)return i.railh&&i.railh.scrollable?i.onmousewheelhr(a):!0;var b=+new Date,c=!1;if(i.opt.preservenativescrolling&&i.checkarea+600<b&&(i.nativescrollingarea=i.isScrollable(a),c=!0),i.checkarea=b,i.nativescrollingarea)return!0;var d=x(a,!1,c);return d&&(i.checkarea=0),d},this.onmousewheelhr=function(a){if(i.locked||!i.railh.scrollable)return!0;if(i.rail.drag)return i.cancelEvent(a);var b=+new Date,c=!1;return i.opt.preservenativescrolling&&i.checkarea+600<b&&(i.nativescrollingarea=i.isScrollable(a),c=!0),i.checkarea=b,i.nativescrollingarea?!0:i.locked?i.cancelEvent(a):x(a,!0,c)},this.stop=function(){return i.cancelScroll(),i.scrollmon&&i.scrollmon.stop(),i.cursorfreezed=!1,i.scroll.y=Math.round(i.getScrollTop()*(1/i.scrollratio.y)),i.noticeCursor(),i},this.getTransitionSpeed=function(a){var b=Math.round(10*i.opt.scrollspeed),c=Math.min(b,Math.round(a/20*i.opt.scrollspeed));return c>20?c:0},i.opt.smoothscroll?i.ishwscroll&&p.hastransition&&i.opt.usetransition?(this.prepareTransition=function(a,b){var c=b?a>20?a:0:i.getTransitionSpeed(a),d=c?p.prefixstyle+"transform "+c+"ms ease-out":"";return i.lasttransitionstyle&&i.lasttransitionstyle==d||(i.lasttransitionstyle=d,i.doc.css(p.transitionstyle,d)),c},this.doScrollLeft=function(a,b){var c=i.scrollrunning?i.newscrolly:i.getScrollTop();i.doScrollPos(a,c,b)},this.doScrollTop=function(a,b){var c=i.scrollrunning?i.newscrollx:i.getScrollLeft();i.doScrollPos(c,a,b)},this.doScrollPos=function(a,b,c){var d=i.getScrollTop(),e=i.getScrollLeft();return((i.newscrolly-d)*(b-d)<0||(i.newscrollx-e)*(a-e)<0)&&i.cancelScroll(),0==i.opt.bouncescroll&&(0>b?b=0:b>i.page.maxh&&(b=i.page.maxh),0>a?a=0:a>i.page.maxw&&(a=i.page.maxw)),i.scrollrunning&&a==i.newscrollx&&b==i.newscrolly?!1:(i.newscrolly=b,i.newscrollx=a,i.newscrollspeed=c||!1,i.timer?!1:(i.timer=setTimeout(function(){var c=i.getScrollTop(),d=i.getScrollLeft(),e={};e.x=a-d,e.y=b-c,e.px=d,e.py=c;var f=Math.round(Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))),g=i.newscrollspeed&&i.newscrollspeed>1?i.newscrollspeed:i.getTransitionSpeed(f);if(i.newscrollspeed&&i.newscrollspeed<=1&&(g*=i.newscrollspeed),i.prepareTransition(g,!0),i.timerscroll&&i.timerscroll.tm&&clearInterval(i.timerscroll.tm),g>0){if(!i.scrollrunning&&i.onscrollstart){var h={type:"scrollstart",current:{x:d,y:c},request:{x:a,y:b},end:{x:i.newscrollx,y:i.newscrolly},speed:g};i.onscrollstart.call(i,h)}p.transitionend?i.scrollendtrapped||(i.scrollendtrapped=!0,i.bind(i.doc,p.transitionend,i.onScrollEnd,!1)):(i.scrollendtrapped&&clearTimeout(i.scrollendtrapped),i.scrollendtrapped=setTimeout(i.onScrollEnd,g));var j=c,k=d;i.timerscroll={bz:new r(j,i.newscrolly,g,0,0,.58,1),bh:new r(k,i.newscrollx,g,0,0,.58,1)},i.cursorfreezed||(i.timerscroll.tm=setInterval(function(){i.showCursor(i.getScrollTop(),i.getScrollLeft())},60))}i.synched("doScroll-set",function(){i.timer=0,i.scrollendtrapped&&(i.scrollrunning=!0),i.setScrollTop(i.newscrolly),i.setScrollLeft(i.newscrollx),i.scrollendtrapped||i.onScrollEnd()})},50),void 0))},this.cancelScroll=function(){if(!i.scrollendtrapped)return!0;var a=i.getScrollTop(),b=i.getScrollLeft();return i.scrollrunning=!1,p.transitionend||clearTimeout(p.transitionend),i.scrollendtrapped=!1,i._unbind(i.doc,p.transitionend,i.onScrollEnd),i.prepareTransition(0),i.setScrollTop(a),i.railh&&i.setScrollLeft(b),i.timerscroll&&i.timerscroll.tm&&clearInterval(i.timerscroll.tm),i.timerscroll=!1,i.cursorfreezed=!1,i.showCursor(a,b),i},this.onScrollEnd=function(){i.scrollendtrapped&&i._unbind(i.doc,p.transitionend,i.onScrollEnd),i.scrollendtrapped=!1,i.prepareTransition(0),i.timerscroll&&i.timerscroll.tm&&clearInterval(i.timerscroll.tm),i.timerscroll=!1;var a=i.getScrollTop(),b=i.getScrollLeft();if(i.setScrollTop(a),i.railh&&i.setScrollLeft(b),i.noticeCursor(!1,a,b),i.cursorfreezed=!1,0>a?a=0:a>i.page.maxh&&(a=i.page.maxh),0>b?b=0:b>i.page.maxw&&(b=i.page.maxw),a!=i.newscrolly||b!=i.newscrollx)return i.doScrollPos(b,a,i.opt.snapbackspeed);if(i.onscrollend&&i.scrollrunning){var c={type:"scrollend",current:{x:b,y:a},end:{x:i.newscrollx,y:i.newscrolly}};i.onscrollend.call(i,c)}i.scrollrunning=!1}):(this.doScrollLeft=function(a,b){var c=i.scrollrunning?i.newscrolly:i.getScrollTop();i.doScrollPos(a,c,b)},this.doScrollTop=function(a,b){var c=i.scrollrunning?i.newscrollx:i.getScrollLeft();i.doScrollPos(c,a,b)},this.doScrollPos=function(a,b,c){function n(){if(i.cancelAnimationFrame)return!0;if(i.scrollrunning=!0,k=1-k)return i.timer=l(n)||1;var a=0,b=i.getScrollTop(),c=b;if(i.dst.ay){c=i.bzscroll?i.dst.py+i.bzscroll.getNow()*i.dst.ay:i.newscrolly;var d=c-b;(0>d&&c<i.newscrolly||d>0&&c>i.newscrolly)&&(c=i.newscrolly),i.setScrollTop(c),c==i.newscrolly&&(a=1)}else a=1;var e=i.getScrollLeft(),f=e;if(i.dst.ax){f=i.bzscroll?i.dst.px+i.bzscroll.getNow()*i.dst.ax:i.newscrollx;var d=f-e;(0>d&&f<i.newscrollx||d>0&&f>i.newscrollx)&&(f=i.newscrollx),i.setScrollLeft(f),f==i.newscrollx&&(a+=1)}else a+=1;if(2==a){if(i.timer=0,i.cursorfreezed=!1,i.bzscroll=!1,i.scrollrunning=!1,0>c?c=0:c>i.page.maxh&&(c=i.page.maxh),0>f?f=0:f>i.page.maxw&&(f=i.page.maxw),f!=i.newscrollx||c!=i.newscrolly)i.doScrollPos(f,c);else if(i.onscrollend){var g={type:"scrollend",current:{x:e,y:b},end:{x:i.newscrollx,y:i.newscrolly}};i.onscrollend.call(i,g)}}else i.timer=l(n)||1}var b="undefined"==typeof b||b===!1?i.getScrollTop(!0):b;if(i.timer&&i.newscrolly==b&&i.newscrollx==a)return!0;i.timer&&m(i.timer),i.timer=0;var d=i.getScrollTop(),e=i.getScrollLeft();((i.newscrolly-d)*(b-d)<0||(i.newscrollx-e)*(a-e)<0)&&i.cancelScroll(),i.newscrolly=b,i.newscrollx=a,i.bouncescroll&&i.rail.visibility||(i.newscrolly<0?i.newscrolly=0:i.newscrolly>i.page.maxh&&(i.newscrolly=i.page.maxh)),i.bouncescroll&&i.railh.visibility||(i.newscrollx<0?i.newscrollx=0:i.newscrollx>i.page.maxw&&(i.newscrollx=i.page.maxw)),i.dst={},i.dst.x=a-e,i.dst.y=b-d,i.dst.px=e,i.dst.py=d;var f=Math.round(Math.sqrt(Math.pow(i.dst.x,2)+Math.pow(i.dst.y,2)));i.dst.ax=i.dst.x/f,i.dst.ay=i.dst.y/f;var g=0,h=f;0==i.dst.x?(g=d,h=b,i.dst.ay=1,i.dst.py=0):0==i.dst.y&&(g=e,h=a,i.dst.ax=1,i.dst.px=0);var j=i.getTransitionSpeed(f);if(c&&1>=c&&(j*=c),i.bzscroll=j>0?i.bzscroll?i.bzscroll.update(h,j):new r(g,h,j,0,1,0,1):!1,!i.timer){(d==i.page.maxh&&b>=i.page.maxh||e==i.page.maxw&&a>=i.page.maxw)&&i.checkContentSize();var k=1;if(i.cancelAnimationFrame=!1,i.timer=1,i.onscrollstart&&!i.scrollrunning){var o={type:"scrollstart",current:{x:e,y:d},request:{x:a,y:b},end:{x:i.newscrollx,y:i.newscrolly},speed:j};i.onscrollstart.call(i,o)}n(),(d==i.page.maxh&&b>=d||e==i.page.maxw&&a>=e)&&i.checkContentSize(),i.noticeCursor()}},this.cancelScroll=function(){return i.timer&&m(i.timer),i.timer=0,i.bzscroll=!1,i.scrollrunning=!1,i}):(this.doScrollLeft=function(a,b){var c=i.getScrollTop();i.doScrollPos(a,c,b)},this.doScrollTop=function(a,b){var c=i.getScrollLeft();i.doScrollPos(c,a,b)},this.doScrollPos=function(a,b){var d=a>i.page.maxw?i.page.maxw:a;0>d&&(d=0);var e=b>i.page.maxh?i.page.maxh:b;0>e&&(e=0),i.synched("scroll",function(){i.setScrollTop(e),i.setScrollLeft(d)})},this.cancelScroll=function(){}),this.doScrollBy=function(a,b){var c=0;if(b)c=Math.floor((i.scroll.y-a)*i.scrollratio.y);else{var d=i.timer?i.newscrolly:i.getScrollTop(!0);c=d-a}if(i.bouncescroll){var e=Math.round(i.view.h/2);-e>c?c=-e:c>i.page.maxh+e&&(c=i.page.maxh+e)}return i.cursorfreezed=!1,py=i.getScrollTop(!0),0>c&&0>=py?i.noticeCursor():c>i.page.maxh&&py>=i.page.maxh?(i.checkContentSize(),i.noticeCursor()):(i.doScrollTop(c),void 0)},this.doScrollLeftBy=function(a,b){var c=0;if(b)c=Math.floor((i.scroll.x-a)*i.scrollratio.x);else{var d=i.timer?i.newscrollx:i.getScrollLeft(!0);c=d-a}if(i.bouncescroll){var e=Math.round(i.view.w/2);-e>c?c=-e:c>i.page.maxw+e&&(c=i.page.maxw+e)}return i.cursorfreezed=!1,px=i.getScrollLeft(!0),0>c&&0>=px?i.noticeCursor():c>i.page.maxw&&px>=i.page.maxw?i.noticeCursor():(i.doScrollLeft(c),void 0)},this.doScrollTo=function(a,b){var c=b?Math.round(a*i.scrollratio.y):a;0>c?c=0:c>i.page.maxh&&(c=i.page.maxh),i.cursorfreezed=!1,i.doScrollTop(a)},this.checkContentSize=function(){var a=i.getContentSize();(a.h!=i.page.h||a.w!=i.page.w)&&i.resize(!1,a)},i.onscroll=function(){i.rail.drag||i.cursorfreezed||i.synched("scroll",function(){i.scroll.y=Math.round(i.getScrollTop()*(1/i.scrollratio.y)),i.railh&&(i.scroll.x=Math.round(i.getScrollLeft()*(1/i.scrollratio.x))),i.noticeCursor()})},i.bind(i.docscroll,"scroll",i.onscroll),this.doZoomIn=function(a){if(!i.zoomactive){i.zoomactive=!0,i.zoomrestore={style:{}};var b=["position","top","left","zIndex","backgroundColor","marginTop","marginBottom","marginLeft","marginRight"],c=i.win[0].style;for(var d in b){var e=b[d];i.zoomrestore.style[e]="undefined"!=typeof c[e]?c[e]:""}i.zoomrestore.style.width=i.win.css("width"),i.zoomrestore.style.height=i.win.css("height"),i.zoomrestore.padding={w:i.win.outerWidth()-i.win.width(),h:i.win.outerHeight()-i.win.height()},p.isios4&&(i.zoomrestore.scrollTop=h(window).scrollTop(),h(window).scrollTop(0)),i.win.css({position:p.isios4?"absolute":"fixed",top:0,left:0,"z-index":g+100,margin:"0px"});var f=i.win.css("backgroundColor");return(""==f||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(f))&&i.win.css("backgroundColor","#fff"),i.rail.css({"z-index":g+101}),i.zoom.css({"z-index":g+102}),i.zoom.css("backgroundPosition","0px -18px"),i.resizeZoom(),i.onzoomin&&i.onzoomin.call(i),i.cancelEvent(a)}},this.doZoomOut=function(a){return i.zoomactive?(i.zoomactive=!1,i.win.css("margin",""),i.win.css(i.zoomrestore.style),p.isios4&&h(window).scrollTop(i.zoomrestore.scrollTop),i.rail.css({"z-index":i.zindex}),i.zoom.css({"z-index":i.zindex}),i.zoomrestore=!1,i.zoom.css("backgroundPosition","0px 0px"),i.onResize(),i.onzoomout&&i.onzoomout.call(i),i.cancelEvent(a)):void 0},this.doZoom=function(a){return i.zoomactive?i.doZoomOut(a):i.doZoomIn(a)},this.resizeZoom=function(){if(i.zoomactive){var a=i.getScrollTop();i.win.css({width:h(window).width()-i.zoomrestore.padding.w+"px",height:h(window).height()-i.zoomrestore.padding.h+"px"}),i.onResize(),i.setScrollTop(Math.min(i.page.maxh,a))}},this.init(),h.nicescroll.push(this)},s=function(a){var b=this;this.nc=a,this.lastx=0,this.lasty=0,this.speedx=0,this.speedy=0,this.lasttime=0,this.steptime=0,this.snapx=!1,this.snapy=!1,this.demulx=0,this.demuly=0,this.lastscrollx=-1,this.lastscrolly=-1,this.chkx=0,this.chky=0,this.timer=0,this.time=function(){return+new Date},this.reset=function(a,c){b.stop();var d=b.time();b.steptime=0,b.lasttime=d,b.speedx=0,b.speedy=0,b.lastx=a,b.lasty=c,b.lastscrollx=-1,b.lastscrolly=-1},this.update=function(a,c){var d=b.time();b.steptime=d-b.lasttime,b.lasttime=d;var e=c-b.lasty,f=a-b.lastx,g=b.nc.getScrollTop(),h=b.nc.getScrollLeft(),i=g+e,j=h+f;b.snapx=0>j||j>b.nc.page.maxw,b.snapy=0>i||i>b.nc.page.maxh,b.speedx=f,b.speedy=e,b.lastx=a,b.lasty=c},this.stop=function(){b.nc.unsynched("domomentum2d"),b.timer&&clearTimeout(b.timer),b.timer=0,b.lastscrollx=-1,b.lastscrolly=-1},this.doSnapy=function(a,c){var d=!1;0>c?(c=0,d=!0):c>b.nc.page.maxh&&(c=b.nc.page.maxh,d=!0),0>a?(a=0,d=!0):a>b.nc.page.maxw&&(a=b.nc.page.maxw,d=!0),d&&b.nc.doScrollPos(a,c,b.nc.opt.snapbackspeed)},this.doMomentum=function(a){var c=b.time(),d=a?c+a:b.lasttime,e=b.nc.getScrollLeft(),f=b.nc.getScrollTop(),g=b.nc.page.maxh,h=b.nc.page.maxw;b.speedx=h>0?Math.min(60,b.speedx):0,b.speedy=g>0?Math.min(60,b.speedy):0;var i=d&&50>=c-d;(0>f||f>g||0>e||e>h)&&(i=!1);var j=b.speedy&&i?b.speedy:!1,k=b.speedx&&i?b.speedx:!1;if(j||k){var l=Math.max(16,b.steptime);if(l>50){var m=l/50;b.speedx*=m,b.speedy*=m,l=50}b.demulxy=0,b.lastscrollx=b.nc.getScrollLeft(),b.chkx=b.lastscrollx,b.lastscrolly=b.nc.getScrollTop(),b.chky=b.lastscrolly;var n=b.lastscrollx,o=b.lastscrolly,p=function(){var a=b.time()-c>600?.04:.02;b.speedx&&(n=Math.floor(b.lastscrollx-b.speedx*(1-b.demulxy)),b.lastscrollx=n,(0>n||n>h)&&(a=.1)),b.speedy&&(o=Math.floor(b.lastscrolly-b.speedy*(1-b.demulxy)),b.lastscrolly=o,(0>o||o>g)&&(a=.1)),b.demulxy=Math.min(1,b.demulxy+a),b.nc.synched("domomentum2d",function(){if(b.speedx){var a=b.nc.getScrollLeft();a!=b.chkx&&b.stop(),b.chkx=n,b.nc.setScrollLeft(n)}if(b.speedy){var c=b.nc.getScrollTop();c!=b.chky&&b.stop(),b.chky=o,b.nc.setScrollTop(o)}b.timer||(b.nc.hideCursor(),b.doSnapy(n,o))}),b.demulxy<1?b.timer=setTimeout(p,l):(b.stop(),b.nc.hideCursor(),b.doSnapy(n,o))};p()}else b.doSnapy(b.nc.getScrollLeft(),b.nc.getScrollTop())}},t=a.fn.scrollTop;a.cssHooks.pageYOffset={get:function(a){var d=h.data(a,"__nicescroll")||!1;return d&&d.ishwscroll?d.getScrollTop():t.call(a)},set:function(a,b){var c=h.data(a,"__nicescroll")||!1;return c&&c.ishwscroll?c.setScrollTop(parseInt(b)):t.call(a,b),this}},a.fn.scrollTop=function(a){if("undefined"==typeof a){var b=this[0]?h.data(this[0],"__nicescroll")||!1:!1;return b&&b.ishwscroll?b.getScrollTop():t.call(this)}return this.each(function(){var b=h.data(this,"__nicescroll")||!1;b&&b.ishwscroll?b.setScrollTop(parseInt(a)):t.call(h(this),a)})};var u=a.fn.scrollLeft;h.cssHooks.pageXOffset={get:function(a){var d=h.data(a,"__nicescroll")||!1;return d&&d.ishwscroll?d.getScrollLeft():u.call(a)},set:function(a,b){var c=h.data(a,"__nicescroll")||!1;return c&&c.ishwscroll?c.setScrollLeft(parseInt(b)):u.call(a,b),this}},a.fn.scrollLeft=function(a){if("undefined"==typeof a){var b=this[0]?h.data(this[0],"__nicescroll")||!1:!1;return b&&b.ishwscroll?b.getScrollLeft():u.call(this)}return this.each(function(){var b=h.data(this,"__nicescroll")||!1;b&&b.ishwscroll?b.setScrollLeft(parseInt(a)):u.call(h(this),a)})};var v=function(a){var b=this;if(this.length=0,this.name="nicescrollarray",this.each=function(a){for(var c=0;c<b.length;c++)a.call(b[c]);return b},this.push=function(a){b[b.length]=a,b.length++},this.eq=function(a){return b[a]},a)for(var c=0;c<a.length;c++){var d=h.data(a[c],"__nicescroll")||!1;d&&(this[this.length]=d,this.length++)}return this};w(v.prototype,["show","hide","toggle","onResize","resize","remove","stop","doScrollPos"],function(a,b){a[b]=function(){var a=arguments;return this.each(function(){this[b].apply(this,a)})}}),a.fn.getNiceScroll=function(a){if("undefined"==typeof a)return new v(this);var b=h.data(this[a],"__nicescroll")||!1;return b},a.extend(a.expr[":"],{nicescroll:function(a){return h.data(a,"__nicescroll")?!0:!1}}),h.fn.niceScroll=function(a,b){"undefined"==typeof b&&("object"!=typeof a||"jquery"in a||(b=a,a=!1));var c=new v;"undefined"==typeof b&&(b={}),a&&(b.doc=h(a),b.win=h(this));var d=!("doc"in b);return d||"win"in b||(b.win=h(this)),this.each(function(){var a=h(this).data("__nicescroll")||!1;a||(b.doc=d?h(this):b.doc,a=new r(b,h(this)),h(this).data("__nicescroll",a)),c.push(a)}),1==c.length?c[0]:c},window.NiceScroll={getjQuery:function(){return a}},h.nicescroll||(h.nicescroll=new v,h.nicescroll.options=o)}(jQuery);