jquery.nicescroll.min.js 61 KB

12
  1. /* nicescroll v3.7.2 InuYaksa - MIT - https://nicescroll.areaaperta.com */
  2. !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";var o=!1,t=!1,r=0,i=2e3,n=0,s=e,l=s(window),a=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||!1}(),c=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||!1}();if(a)window.cancelAnimationFrame||(c=function(e){});else{var d=0;a=function(e,o){var t=(new Date).getTime(),r=Math.max(0,16-(t-d)),i=window.setTimeout(function(){e(t+r)},r);return d=t+r,i},c=function(e){window.clearTimeout(e)}}var u=window.MutationObserver||window.WebKitMutationObserver||!1,h=Date.now||function(){return(new Date).getTime()},p={zindex:"auto",cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"6px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:24,touchbehavior:!1,emulatetouch:!1,hwacceleration:!0,usetransition:!0,boxzoom:!1,dblclickzoom:!0,gesturezoom:!0,grabcursorenabled:!0,autohidemode:!0,background:"",iframeautoresize:!0,cursorminheight:32,preservenativescrolling:!0,railoffset:!1,railhoffset:!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:"auto",cursordragontouch:!1,oneaxismousemode:"auto",scriptpath:function(){var e=document.currentScript||function(){var e=document.getElementsByTagName("script");return!!e.length&&e[e.length-1]}(),o=e?e.src.split("?")[0]:"";return o.split("/").length>0?o.split("/").slice(0,-1).join("/")+"/":""}(),preventmultitouchscrolling:!0,disablemutationobserver:!1,enableobserver:!0,scrollbarid:!1},m=!1,f=function(){if(m)return m;var e=document.createElement("DIV"),o=e.style,t=navigator.userAgent,r=navigator.platform,i={};return i.haspointerlock="pointerLockElement"in document||"webkitPointerLockElement"in document||"mozPointerLockElement"in document,i.isopera="opera"in window,i.isopera12=i.isopera&&"getUserMedia"in navigator,i.isoperamini="[object OperaMini]"===Object.prototype.toString.call(window.operamini),i.isie="all"in document&&"attachEvent"in e&&!i.isopera,i.isieold=i.isie&&!("msInterpolationMode"in o),i.isie7=i.isie&&!i.isieold&&(!("documentMode"in document)||7===document.documentMode),i.isie8=i.isie&&"documentMode"in document&&8===document.documentMode,i.isie9=i.isie&&"performance"in window&&9===document.documentMode,i.isie10=i.isie&&"performance"in window&&10===document.documentMode,i.isie11="msRequestFullscreen"in e&&document.documentMode>=11,i.ismsedge="msCredentials"in window,i.ismozilla="MozAppearance"in o,i.iswebkit=!i.ismsedge&&"WebkitAppearance"in o,i.ischrome=i.iswebkit&&"chrome"in window,i.ischrome38=i.ischrome&&"touchAction"in o,i.ischrome22=!i.ischrome38&&i.ischrome&&i.haspointerlock,i.ischrome26=!i.ischrome38&&i.ischrome&&"transition"in o,i.cantouch="ontouchstart"in document.documentElement||"ontouchstart"in window,i.hasw3ctouch=(window.PointerEvent||!1)&&(navigator.MaxTouchPoints>0||navigator.msMaxTouchPoints>0),i.hasmstouch=!i.hasw3ctouch&&(window.MSPointerEvent||!1),i.ismac=/^mac$/i.test(r),i.isios=i.cantouch&&/iphone|ipad|ipod/i.test(r),i.isios4=i.isios&&!("seal"in Object),i.isios7=i.isios&&"webkitHidden"in document,i.isios8=i.isios&&"hidden"in document,i.isios10=i.isios&&window.Proxy,i.isandroid=/android/i.test(t),i.haseventlistener="addEventListener"in e,i.trstyle=!1,i.hastransform=!1,i.hastranslate3d=!1,i.transitionstyle=!1,i.hastransition=!1,i.transitionend=!1,i.trstyle="transform",i.hastransform="transform"in o||function(){for(var e=["msTransform","webkitTransform","MozTransform","OTransform"],t=0,r=e.length;t<r;t++)if(void 0!==o[e[t]]){i.trstyle=e[t];break}i.hastransform=!!i.trstyle}(),i.hastransform&&(o[i.trstyle]="translate3d(1px,2px,3px)",i.hastranslate3d=/translate3d/.test(o[i.trstyle])),i.transitionstyle="transition",i.prefixstyle="",i.transitionend="transitionend",i.hastransition="transition"in o||function(){i.transitionend=!1;for(var e=["webkitTransition","msTransition","MozTransition","OTransition","OTransition","KhtmlTransition"],t=["-webkit-","-ms-","-moz-","-o-","-o","-khtml-"],r=["webkitTransitionEnd","msTransitionEnd","transitionend","otransitionend","oTransitionEnd","KhtmlTransitionEnd"],n=0,s=e.length;n<s;n++)if(e[n]in o){i.transitionstyle=e[n],i.prefixstyle=t[n],i.transitionend=r[n];break}i.ischrome26&&(i.prefixstyle=t[1]),i.hastransition=i.transitionstyle}(),i.cursorgrabvalue=function(){var e=["grab","-webkit-grab","-moz-grab"];(i.ischrome&&!i.ischrome38||i.isie)&&(e=[]);for(var t=0,r=e.length;t<r;t++){var n=e[t];if(o.cursor=n,o.cursor==n)return n}return"url(https://cdnjs.cloudflare.com/ajax/libs/slider-pro/1.3.0/css/images/openhand.cur),n-resize"}(),i.hasmousecapture="setCapture"in e,i.hasMutationObserver=!1!==u,e=null,m=i,i},g=function(e,d){function m(){var e=x.doc.css(M.trstyle);return!(!e||"matrix"!=e.substr(0,6))&&e.replace(/^.*\((.*)\)$/g,"$1").replace(/px/g,"").split(/, +/)}function g(){var e=x.win;if("zIndex"in e)return e.zIndex();for(;e.length>0;){if(9==e[0].nodeType)return!1;var o=e.css("zIndex");if(!isNaN(o)&&0!=o)return parseInt(o);e=e.parent()}return!1}function v(e,o,t){var r=e.css(o),i=parseFloat(r);if(isNaN(i)){var n=3==(i=N[r]||0)?t?x.win.outerHeight()-x.win.innerHeight():x.win.outerWidth()-x.win.innerWidth():1;return x.isie8&&i&&(i+=1),n?i:0}return i}function b(e,o,t,r){x._bind(e,o,function(r){var i={original:r=r||window.event,target:r.target||r.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"==r.type?0:1,deltaX:0,deltaZ:0,preventDefault:function(){return r.preventDefault?r.preventDefault():r.returnValue=!1,!1},stopImmediatePropagation:function(){r.stopImmediatePropagation?r.stopImmediatePropagation():r.cancelBubble=!0}};return"mousewheel"==o?(r.wheelDeltaX&&(i.deltaX=-.025*r.wheelDeltaX),r.wheelDeltaY&&(i.deltaY=-.025*r.wheelDeltaY),!i.deltaY&&!i.deltaX&&(i.deltaY=-.025*r.wheelDelta)):i.deltaY=r.detail,t.call(e,i)},r)}function y(e,o,t){var r,i;if(0==e.deltaMode?(r=-Math.floor(e.deltaX*(x.opt.mousescrollstep/54)),i=-Math.floor(e.deltaY*(x.opt.mousescrollstep/54))):1==e.deltaMode&&(r=-Math.floor(e.deltaX*x.opt.mousescrollstep),i=-Math.floor(e.deltaY*x.opt.mousescrollstep)),o&&x.opt.oneaxismousemode&&0===r&&i&&(r=i,i=0,t&&(r<0?x.getScrollLeft()>=x.page.maxw:x.getScrollLeft()<=0)&&(i=r,r=0)),x.isrtlmode&&(r=-r),r){if(x.scrollmom)x.scrollmom.stop();else if(r<0){if(x.getScrollLeft()>=x.page.maxw)return!0}else if(x.getScrollLeft()<=0)return!0;x.lastdeltax+=r,x.debounced("mousewheelx",function(){var e=x.lastdeltax;x.lastdeltax=0,x.rail.drag||x.doScrollLeftBy(e)},15)}if(i){if(x.opt.nativeparentscrolling&&t&&!x.ispage&&!x.zoomactive)if(i<0){if(x.getScrollTop()>=x.page.maxh)return!0}else if(x.getScrollTop()<=0)return!0;x.scrollmom&&x.scrollmom.stop(),x.lastdeltay+=i,x.synched("mousewheely",function(){var e=x.lastdeltay;x.lastdeltay=0,x.rail.drag||x.doScrollBy(e)},15)}return e.stopImmediatePropagation(),e.preventDefault()}var x=this;this.version="3.7.2",this.name="nicescroll",this.me=d;var S=s("body");if(this.opt={doc:S,win:!1},s.extend(this.opt,p),this.opt.snapbackspeed=80,e)for(var z in x.opt)void 0!==e[z]&&(x.opt[z]=e[z]);if(x.opt.disablemutationobserver&&(u=!1),this.doc=x.opt.doc,this.iddoc=this.doc&&this.doc[0]?this.doc[0].id||"":"",this.ispage=/^BODY|HTML/.test(x.opt.win?x.opt.win[0].nodeName:this.doc[0].nodeName),this.haswrapper=!1!==x.opt.win,this.win=x.opt.win||(this.ispage?l:this.doc),this.docscroll=this.ispage&&!this.haswrapper?l:this.win,this.body=S,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"!=x.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,"auto"==this.opt.rtlmode){var k=this.win[0]==window?this.body:this.win,T=k.css("writing-mode")||k.css("-webkit-writing-mode")||k.css("-ms-writing-mode")||k.css("-moz-writing-mode");"horizontal-tb"==T||"lr-tb"==T||""==T?(this.isrtlmode="rtl"==k.css("direction"),this.isvertical=!1):(this.isrtlmode="vertical-rl"==T||"tb"==T||"tb-rl"==T||"rl-tb"==T,this.isvertical="vertical-rl"==T||"tb"==T||"tb-rl"==T)}else this.isrtlmode=!0===this.opt.rtlmode,this.isvertical=!1;if(this.scrollrunning=!1,this.scrollmom=!1,this.observer=!1,this.observerremover=!1,this.observerbody=!1,!1===x.opt.scrollbarid)do{this.id="ascrail"+i++}while(document.getElementById(this.id));else this.id=x.opt.scrollbarid;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.railslocked=!1,this.locked=!1,this.hidden=!1,this.cursoractive=!0,this.wheelprevented=!1,this.overflowx=x.opt.overflowx,this.overflowy=x.opt.overflowy,this.nativescrollingarea=!1,this.checkarea=0,this.events=[],this.saved={},this.delaylist={},this.synclist={},this.lastdeltax=0,this.lastdeltay=0,this.detected=f();var M=s.extend({},this.detected);this.canhwscroll=M.hastransform&&x.opt.hwacceleration,this.ishwscroll=this.canhwscroll&&x.haswrapper,this.isrtlmode?this.isvertical?this.hasreversehr=!(M.iswebkit||M.isie||M.isie11):this.hasreversehr=!(M.iswebkit||M.isie&&!M.isie10&&!M.isie11):this.hasreversehr=!1,this.istouchcapable=!1,M.cantouch||!M.hasw3ctouch&&!M.hasmstouch?!M.cantouch||M.isios||M.isandroid||!M.iswebkit&&!M.ismozilla||(this.istouchcapable=!0):this.istouchcapable=!0,x.opt.enablemouselockapi||(M.hasmousecapture=!1,M.haspointerlock=!1),this.debounced=function(e,o,t){x&&(x.delaylist[e]||!1||(x.delaylist[e]={h:a(function(){x.delaylist[e].fn.call(x),x.delaylist[e]=!1},t)},o.call(x)),x.delaylist[e].fn=o)};var E=!1;this.synched=function(e,o){return x.synclist[e]=o,function(){E||(a(function(){if(x){E=!1;for(var e in x.synclist){var o=x.synclist[e];o&&o.call(x),x.synclist[e]=!1}}}),E=!0)}(),e},this.unsynched=function(e){x.synclist[e]&&(x.synclist[e]=!1)},this.css=function(e,o){for(var t in o)x.saved.css.push([e,t,e.css(t)]),e.css(t,o[t])},this.scrollTop=function(e){return void 0===e?x.getScrollTop():x.setScrollTop(e)},this.scrollLeft=function(e){return void 0===e?x.getScrollLeft():x.setScrollLeft(e)};var L=function(e,o,t,r,i,n,s){this.st=e,this.ed=o,this.spd=t,this.p1=r||0,this.p2=i||1,this.p3=n||0,this.p4=s||1,this.ts=h(),this.df=this.ed-this.st};if(L.prototype={B2:function(e){return 3*e*e*(1-e)},B3:function(e){return 3*e*(1-e)*(1-e)},B4:function(e){return(1-e)*(1-e)*(1-e)},getNow:function(){var e=1-(h()-this.ts)/this.spd,o=this.B2(e)+this.B3(e)+this.B4(e);return e<0?this.ed:this.st+Math.round(this.df*o)},update:function(e,o){return this.st=this.getNow(),this.ed=e,this.spd=o,this.ts=h(),this.df=this.ed-this.st,this}},this.ishwscroll){this.doc.translate={x:0,y:0,tx:"0px",ty:"0px"},M.hastranslate3d&&M.isios&&this.doc.css("-webkit-backface-visibility","hidden"),this.getScrollTop=function(e){if(!e){var o=m();if(o)return 16==o.length?-o[13]:-o[5];if(x.timerscroll&&x.timerscroll.bz)return x.timerscroll.bz.getNow()}return x.doc.translate.y},this.getScrollLeft=function(e){if(!e){var o=m();if(o)return 16==o.length?-o[12]:-o[4];if(x.timerscroll&&x.timerscroll.bh)return x.timerscroll.bh.getNow()}return x.doc.translate.x},this.notifyScrollEvent=function(e){var o=document.createEvent("UIEvents");o.initUIEvent("scroll",!1,!0,window,1),o.niceevent=!0,e.dispatchEvent(o)};var C=this.isrtlmode?1:-1;M.hastranslate3d&&x.opt.enabletranslate3d?(this.setScrollTop=function(e,o){x.doc.translate.y=e,x.doc.translate.ty=-1*e+"px",x.doc.css(M.trstyle,"translate3d("+x.doc.translate.tx+","+x.doc.translate.ty+",0)"),o||x.notifyScrollEvent(x.win[0])},this.setScrollLeft=function(e,o){x.doc.translate.x=e,x.doc.translate.tx=e*C+"px",x.doc.css(M.trstyle,"translate3d("+x.doc.translate.tx+","+x.doc.translate.ty+",0)"),o||x.notifyScrollEvent(x.win[0])}):(this.setScrollTop=function(e,o){x.doc.translate.y=e,x.doc.translate.ty=-1*e+"px",x.doc.css(M.trstyle,"translate("+x.doc.translate.tx+","+x.doc.translate.ty+")"),o||x.notifyScrollEvent(x.win[0])},this.setScrollLeft=function(e,o){x.doc.translate.x=e,x.doc.translate.tx=e*C+"px",x.doc.css(M.trstyle,"translate("+x.doc.translate.tx+","+x.doc.translate.ty+")"),o||x.notifyScrollEvent(x.win[0])})}else this.getScrollTop=function(){return x.docscroll.scrollTop()},this.setScrollTop=function(e){return setTimeout(function(){x&&x.docscroll.scrollTop(e)},1)},this.getScrollLeft=function(){return x.hasreversehr?x.detected.ismozilla?x.page.maxw-Math.abs(x.docscroll.scrollLeft()):x.page.maxw-x.docscroll.scrollLeft():x.docscroll.scrollLeft()},this.setScrollLeft=function(e){return setTimeout(function(){if(x)return x.hasreversehr&&(e=x.detected.ismozilla?-(x.page.maxw-e):x.page.maxw-e),x.docscroll.scrollLeft(e)},1)};this.getTarget=function(e){return!!e&&(e.target?e.target:!!e.srcElement&&e.srcElement)},this.hasParent=function(e,o){if(!e)return!1;for(var t=e.target||e.srcElement||e||!1;t&&t.id!=o;)t=t.parentNode||!1;return!1!==t};var N={thin:1,medium:3,thick:5};this.getDocumentScrollOffset=function(){return{top:window.pageYOffset||document.documentElement.scrollTop,left:window.pageXOffset||document.documentElement.scrollLeft}},this.getOffset=function(){if(x.isfixed){var e=x.win.offset(),o=x.getDocumentScrollOffset();return e.top-=o.top,e.left-=o.left,e}var t=x.win.offset();if(!x.viewport)return t;var r=x.viewport.offset();return{top:t.top-r.top,left:t.left-r.left}},this.updateScrollBar=function(e){var o,t;if(x.ishwscroll)x.rail.css({height:x.win.innerHeight()-(x.opt.railpadding.top+x.opt.railpadding.bottom)}),x.railh&&x.railh.css({width:x.win.innerWidth()-(x.opt.railpadding.left+x.opt.railpadding.right)});else{var r=x.getOffset();if(o={top:r.top,left:r.left-(x.opt.railpadding.left+x.opt.railpadding.right)},o.top+=v(x.win,"border-top-width",!0),o.left+=x.rail.align?x.win.outerWidth()-v(x.win,"border-right-width")-x.rail.width:v(x.win,"border-left-width"),(t=x.opt.railoffset)&&(t.top&&(o.top+=t.top),t.left&&(o.left+=t.left)),x.railslocked||x.rail.css({top:o.top,left:o.left,height:(e?e.h:x.win.innerHeight())-(x.opt.railpadding.top+x.opt.railpadding.bottom)}),x.zoom&&x.zoom.css({top:o.top+1,left:1==x.rail.align?o.left-20:o.left+x.rail.width+4}),x.railh&&!x.railslocked){o={top:r.top,left:r.left},(t=x.opt.railhoffset)&&(t.top&&(o.top+=t.top),t.left&&(o.left+=t.left));var i=x.railh.align?o.top+v(x.win,"border-top-width",!0)+x.win.innerHeight()-x.railh.height:o.top+v(x.win,"border-top-width",!0),n=o.left+v(x.win,"border-left-width");x.railh.css({top:i-(x.opt.railpadding.top+x.opt.railpadding.bottom),left:n,width:x.railh.width})}}},this.doRailClick=function(e,o,t){var r,i,n,s;x.railslocked||(x.cancelEvent(e),"pageY"in e||(e.pageX=e.clientX+document.documentElement.scrollLeft,e.pageY=e.clientY+document.documentElement.scrollTop),o?(r=t?x.doScrollLeft:x.doScrollTop)(n=t?(e.pageX-x.railh.offset().left-x.cursorwidth/2)*x.scrollratio.x:(e.pageY-x.rail.offset().top-x.cursorheight/2)*x.scrollratio.y):(r=t?x.doScrollLeftBy:x.doScrollBy,n=t?x.scroll.x:x.scroll.y,s=t?e.pageX-x.railh.offset().left:e.pageY-x.rail.offset().top,i=t?x.view.w:x.view.h,r(n>=s?i:-i)))},x.hasanimationframe="requestAnimationFrame"in window,x.hascancelanimationframe="cancelAnimationFrame"in window,this.init=function(){if(x.saved.css=[],M.isoperamini)return!0;if(M.isandroid&&!("hidden"in document))return!0;x.opt.emulatetouch=x.opt.emulatetouch||x.opt.touchbehavior;var e={"overflow-y":"hidden"};if((M.isie11||M.isie10)&&(e["-ms-overflow-style"]="none"),x.zindex="auto",x.ispage||"auto"!=x.opt.zindex?x.zindex=x.opt.zindex:x.zindex=g()||"auto",!x.ispage&&"auto"!=x.zindex&&x.zindex>n&&(n=x.zindex),x.isie&&0==x.zindex&&"auto"==x.opt.zindex&&(x.zindex="auto"),!x.ispage||!M.cantouch&&!M.isieold){var i=x.docscroll;x.ispage&&(i=x.haswrapper?x.win:x.doc),x.css(i,e),x.ispage&&(M.isie11||M.isie)&&x.css(s("html"),e),!M.isios||x.ispage||x.haswrapper||x.css(S,{"-webkit-overflow-scrolling":"touch"});var a=s(document.createElement("div"));a.css({position:"relative",top:0,float:"right",width:x.opt.cursorwidth,height:0,"background-color":x.opt.cursorcolor,border:x.opt.cursorborder,"background-clip":"padding-box","-webkit-border-radius":x.opt.cursorborderradius,"-moz-border-radius":x.opt.cursorborderradius,"border-radius":x.opt.cursorborderradius}),a.addClass("nicescroll-cursors"),x.cursor=a;var c=s(document.createElement("div"));c.attr("id",x.id),c.addClass("nicescroll-rails nicescroll-rails-vr");var d,h,p=["left","right","top","bottom"];for(var m in p)h=p[m],(d=x.opt.railpadding[h])?c.css("padding-"+h,d+"px"):x.opt.railpadding[h]=0;c.append(a),c.width=Math.max(parseFloat(x.opt.cursorwidth),a.outerWidth()),c.css({width:c.width+"px",zIndex:x.zindex,background:x.opt.background,cursor:"default"}),c.visibility=!0,c.scrollable=!0,c.align="left"==x.opt.railalign?0:1,x.rail=c,x.rail.drag=!1;var f=!1;!x.opt.boxzoom||x.ispage||M.isieold||(f=document.createElement("div"),x.bind(f,"click",x.doZoom),x.bind(f,"mouseenter",function(){x.zoom.css("opacity",x.opt.cursoropacitymax)}),x.bind(f,"mouseleave",function(){x.zoom.css("opacity",x.opt.cursoropacitymin)}),x.zoom=s(f),x.zoom.css({cursor:"pointer",zIndex:x.zindex,backgroundImage:"url("+x.opt.scriptpath+"zoomico.png)",height:18,width:18,backgroundPosition:"0 0"}),x.opt.dblclickzoom&&x.bind(x.win,"dblclick",x.doZoom),M.cantouch&&x.opt.gesturezoom&&(x.ongesturezoom=function(e){return e.scale>1.5&&x.doZoomIn(e),e.scale<.8&&x.doZoomOut(e),x.cancelEvent(e)},x.bind(x.win,"gestureend",x.ongesturezoom))),x.railh=!1;var v;if(x.opt.horizrailenabled&&(x.css(i,{overflowX:"hidden"}),(a=s(document.createElement("div"))).css({position:"absolute",top:0,height:x.opt.cursorwidth,width:0,backgroundColor:x.opt.cursorcolor,border:x.opt.cursorborder,backgroundClip:"padding-box","-webkit-border-radius":x.opt.cursorborderradius,"-moz-border-radius":x.opt.cursorborderradius,"border-radius":x.opt.cursorborderradius}),M.isieold&&a.css("overflow","hidden"),a.addClass("nicescroll-cursors"),x.cursorh=a,(v=s(document.createElement("div"))).attr("id",x.id+"-hr"),v.addClass("nicescroll-rails nicescroll-rails-hr"),v.height=Math.max(parseFloat(x.opt.cursorwidth),a.outerHeight()),v.css({height:v.height+"px",zIndex:x.zindex,background:x.opt.background}),v.append(a),v.visibility=!0,v.scrollable=!0,v.align="top"==x.opt.railvalign?0:1,x.railh=v,x.railh.drag=!1),x.ispage)c.css({position:"fixed",top:0,height:"100%"}),c.align?c.css({right:0}):c.css({left:0}),x.body.append(c),x.railh&&(v.css({position:"fixed",left:0,width:"100%"}),v.align?v.css({bottom:0}):v.css({top:0}),x.body.append(v));else{if(x.ishwscroll){"static"==x.win.css("position")&&x.css(x.win,{position:"relative"});var b="HTML"==x.win[0].nodeName?x.body:x.win;s(b).scrollTop(0).scrollLeft(0),x.zoom&&(x.zoom.css({position:"absolute",top:1,right:0,"margin-right":c.width+4}),b.append(x.zoom)),c.css({position:"absolute",top:0}),c.align?c.css({right:0}):c.css({left:0}),b.append(c),v&&(v.css({position:"absolute",left:0,bottom:0}),v.align?v.css({bottom:0}):v.css({top:0}),b.append(v))}else{x.isfixed="fixed"==x.win.css("position");var y=x.isfixed?"fixed":"absolute";x.isfixed||(x.viewport=x.getViewport(x.win[0])),x.viewport&&(x.body=x.viewport,0==/fixed|absolute/.test(x.viewport.css("position"))&&x.css(x.viewport,{position:"relative"})),c.css({position:y}),x.zoom&&x.zoom.css({position:y}),x.updateScrollBar(),x.body.append(c),x.zoom&&x.body.append(x.zoom),x.railh&&(v.css({position:y}),x.body.append(v))}M.isios&&x.css(x.win,{"-webkit-tap-highlight-color":"rgba(0,0,0,0)","-webkit-touch-callout":"none"}),M.isie&&x.opt.disableoutline&&x.win.attr("hideFocus","true"),M.iswebkit&&x.opt.disableoutline&&x.win.css("outline","none")}if(!1===x.opt.autohidemode?(x.autohidedom=!1,x.rail.css({opacity:x.opt.cursoropacitymax}),x.railh&&x.railh.css({opacity:x.opt.cursoropacitymax})):!0===x.opt.autohidemode||"leave"===x.opt.autohidemode?(x.autohidedom=s().add(x.rail),M.isie8&&(x.autohidedom=x.autohidedom.add(x.cursor)),x.railh&&(x.autohidedom=x.autohidedom.add(x.railh)),x.railh&&M.isie8&&(x.autohidedom=x.autohidedom.add(x.cursorh))):"scroll"==x.opt.autohidemode?(x.autohidedom=s().add(x.rail),x.railh&&(x.autohidedom=x.autohidedom.add(x.railh))):"cursor"==x.opt.autohidemode?(x.autohidedom=s().add(x.cursor),x.railh&&(x.autohidedom=x.autohidedom.add(x.cursorh))):"hidden"==x.opt.autohidemode&&(x.autohidedom=!1,x.hide(),x.railslocked=!1),M.cantouch||x.istouchcapable||x.opt.emulatetouch||M.hasmstouch){x.scrollmom=new w(x),x.ontouchstart=function(e){if(e.pointerType&&2!=e.pointerType&&"touch"!=e.pointerType)return!1;if(x.hasmoving=!1,!x.railslocked){var o;if(M.hasmstouch)for(o=!!e.target&&e.target;o;){var t=s(o).getNiceScroll();if(t.length>0&&t[0].me==x.me)break;if(t.length>0)return!1;if("DIV"==o.nodeName&&o.id==x.id)break;o=!!o.parentNode&&o.parentNode}if(e.stopPropagation(),x.cancelScroll(),(o=x.getTarget(e))&&/INPUT/i.test(o.nodeName)&&/range/i.test(o.type))return x.stopPropagation(e);if(!("clientX"in e)&&"changedTouches"in e&&(e.clientX=e.changedTouches[0].clientX,e.clientY=e.changedTouches[0].clientY),x.forcescreen){var r=e;(e={original:e.original?e.original:e}).clientX=r.screenX,e.clientY=r.screenY}if(x.rail.drag={x:e.clientX,y:e.clientY,sx:x.scroll.x,sy:x.scroll.y,st:x.getScrollTop(),sl:x.getScrollLeft(),pt:2,dl:!1,tg:o},x.ispage||!x.opt.directionlockdeadzone)x.rail.drag.dl="f";else{var i={w:l.width(),h:l.height()},n={w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},a=Math.max(0,n.h-i.h),c=Math.max(0,n.w-i.w);!x.rail.scrollable&&x.railh.scrollable?x.rail.drag.ck=a>0&&"v":x.rail.scrollable&&!x.railh.scrollable?x.rail.drag.ck=c>0&&"h":x.rail.drag.ck=!1,x.rail.drag.ck||(x.rail.drag.dl="f")}if(x.opt.emulatetouch&&x.isiframe&&M.isie){var d=x.win.position();x.rail.drag.x+=d.left,x.rail.drag.y+=d.top}if(x.hasmoving=!1,x.lastmouseup=!1,x.scrollmom.reset(e.clientX,e.clientY),!M.cantouch&&!this.istouchcapable&&!e.pointerType){if(!(!!o&&/INPUT|SELECT|BUTTON|TEXTAREA/i.test(o.nodeName)))return!x.ispage&&M.hasmousecapture&&o.setCapture(),x.opt.emulatetouch?(o.onclick&&!o._onclick&&(o._onclick=o.onclick,o.onclick=function(e){if(x.hasmoving)return!1;o._onclick.call(this,e)}),x.cancelEvent(e)):x.stopPropagation(e);/SUBMIT|CANCEL|BUTTON/i.test(s(o).attr("type"))&&(x.preventclick={tg:o,click:!1})}}},x.ontouchend=function(e){if(!x.rail.drag)return!0;if(2==x.rail.drag.pt){if(e.pointerType&&2!=e.pointerType&&"touch"!=e.pointerType)return!1;if(x.rail.drag=!1,x.hasmoving&&(x.scrollmom.doMomentum(),x.lastmouseup=!0,x.hideCursor(),M.hasmousecapture&&document.releaseCapture(),!M.cantouch))return x.cancelEvent(e)}else if(1==x.rail.drag.pt)return x.onmouseup(e)};var z=x.opt.emulatetouch&&x.isiframe&&!M.hasmousecapture;x.ontouchmove=function(e,o){if(!x.rail.drag)return!1;if(e.targetTouches&&x.opt.preventmultitouchscrolling&&e.targetTouches.length>1)return!1;if(e.pointerType&&2!=e.pointerType&&"touch"!=e.pointerType)return!1;if(2==x.rail.drag.pt){if("changedTouches"in e&&(e.clientX=e.changedTouches[0].clientX,e.clientY=e.changedTouches[0].clientY),x.rail.drag.y===e.clientY&&x.rail.drag.x===e.clientX)return!1;x.hasmoving||x.triggerScrollStart(e.clientX,e.clientY,0,0,0),x.hasmoving=!0,x.preventclick&&!x.preventclick.click&&(x.preventclick.click=x.preventclick.tg.onclick||!1,x.preventclick.tg.onclick=x.onpreventclick);var t,r;if(r=t=0,z&&!o){var i=x.win.position();r=-i.left,t=-i.top}var n=e.clientY+t,s=n-x.rail.drag.y,l=e.clientX+r,a=l-x.rail.drag.x,c=x.rail.drag.st-s;x.ishwscroll&&x.opt.bouncescroll?c<0?c=Math.round(c/2):c>x.page.maxh&&(c=x.page.maxh+Math.round((c-x.page.maxh)/2)):(c<0&&(c=0,n=0),c>x.page.maxh&&(c=x.page.maxh,n=0));var d;x.railh&&x.railh.scrollable&&(d=x.isrtlmode?a-x.rail.drag.sl:x.rail.drag.sl-a,x.ishwscroll&&x.opt.bouncescroll?d<0?d=Math.round(d/2):d>x.page.maxw&&(d=x.page.maxw+Math.round((d-x.page.maxw)/2)):(d<0&&(d=0,l=0),d>x.page.maxw&&(d=x.page.maxw,l=0)));var u=!1;if(x.rail.drag.dl)u=!0,"v"==x.rail.drag.dl?d=x.rail.drag.sl:"h"==x.rail.drag.dl&&(c=x.rail.drag.st);else{var h=Math.abs(s),p=Math.abs(a),m=x.opt.directionlockdeadzone;if("v"==x.rail.drag.ck){if(h>m&&p<=.3*h)return x.rail.drag=!1,!0;p>m&&(x.rail.drag.dl="f",S.scrollTop(S.scrollTop()))}else if("h"==x.rail.drag.ck){if(p>m&&h<=.3*p)return x.rail.drag=!1,!0;h>m&&(x.rail.drag.dl="f",S.scrollLeft(S.scrollLeft()))}}if(x.synched("touchmove",function(){x.rail.drag&&2==x.rail.drag.pt&&(x.prepareTransition&&x.prepareTransition(0),x.rail.scrollable&&x.setScrollTop(c),x.scrollmom.update(l,n),x.railh&&x.railh.scrollable?(x.setScrollLeft(d),x.showCursor(c,d)):x.showCursor(c),M.isie10&&document.selection.clear())}),M.ischrome&&x.istouchcapable&&(u=!1),u)return x.cancelEvent(e)}else if(1==x.rail.drag.pt)return x.onmousemove(e)},x.ontouchstartCursor=function(e,o){if(!x.rail.drag||3==x.rail.drag.pt){if(x.locked)return x.cancelEvent(e);x.cancelScroll(),x.rail.drag={x:e.touches[0].clientX,y:e.touches[0].clientY,sx:x.scroll.x,sy:x.scroll.y,pt:3,hr:!!o};var t=x.getTarget(e);return!x.ispage&&M.hasmousecapture&&t.setCapture(),x.isiframe&&!M.hasmousecapture&&(x.saved.csspointerevents=x.doc.css("pointer-events"),x.css(x.doc,{"pointer-events":"none"})),x.cancelEvent(e)}},x.ontouchendCursor=function(e){if(x.rail.drag){if(M.hasmousecapture&&document.releaseCapture(),x.isiframe&&!M.hasmousecapture&&x.doc.css("pointer-events",x.saved.csspointerevents),3!=x.rail.drag.pt)return;return x.rail.drag=!1,x.cancelEvent(e)}},x.ontouchmoveCursor=function(e){if(x.rail.drag){if(3!=x.rail.drag.pt)return;if(x.cursorfreezed=!0,x.rail.drag.hr){x.scroll.x=x.rail.drag.sx+(e.touches[0].clientX-x.rail.drag.x),x.scroll.x<0&&(x.scroll.x=0);var o=x.scrollvaluemaxw;x.scroll.x>o&&(x.scroll.x=o)}else{x.scroll.y=x.rail.drag.sy+(e.touches[0].clientY-x.rail.drag.y),x.scroll.y<0&&(x.scroll.y=0);var t=x.scrollvaluemax;x.scroll.y>t&&(x.scroll.y=t)}return x.synched("touchmove",function(){x.rail.drag&&3==x.rail.drag.pt&&(x.showCursor(),x.rail.drag.hr?x.doScrollLeft(Math.round(x.scroll.x*x.scrollratio.x),x.opt.cursordragspeed):x.doScrollTop(Math.round(x.scroll.y*x.scrollratio.y),x.opt.cursordragspeed))}),x.cancelEvent(e)}}}if(x.onmousedown=function(e,o){if(!x.rail.drag||1==x.rail.drag.pt){if(x.railslocked)return x.cancelEvent(e);x.cancelScroll(),x.rail.drag={x:e.clientX,y:e.clientY,sx:x.scroll.x,sy:x.scroll.y,pt:1,hr:o||!1};var t=x.getTarget(e);return!x.ispage&&M.hasmousecapture&&t.setCapture(),x.isiframe&&!M.hasmousecapture&&(x.saved.csspointerevents=x.doc.css("pointer-events"),x.css(x.doc,{"pointer-events":"none"})),x.hasmoving=!1,x.cancelEvent(e)}},x.onmouseup=function(e){if(x.rail.drag)return 1!=x.rail.drag.pt||(M.hasmousecapture&&document.releaseCapture(),x.isiframe&&!M.hasmousecapture&&x.doc.css("pointer-events",x.saved.csspointerevents),x.rail.drag=!1,x.hasmoving&&x.triggerScrollEnd(),x.cancelEvent(e))},x.onmousemove=function(e){if(x.rail.drag){if(1!==x.rail.drag.pt)return;if(M.ischrome&&0===e.which)return x.onmouseup(e);if(x.cursorfreezed=!0,x.hasmoving=!0,x.rail.drag.hr){x.scroll.x=x.rail.drag.sx+(e.clientX-x.rail.drag.x),x.scroll.x<0&&(x.scroll.x=0);var o=x.scrollvaluemaxw;x.scroll.x>o&&(x.scroll.x=o)}else{x.scroll.y=x.rail.drag.sy+(e.clientY-x.rail.drag.y),x.scroll.y<0&&(x.scroll.y=0);var t=x.scrollvaluemax;x.scroll.y>t&&(x.scroll.y=t)}return x.synched("mousemove",function(){x.rail.drag&&1==x.rail.drag.pt&&(x.showCursor(),x.rail.drag.hr?x.hasreversehr?x.doScrollLeft(x.scrollvaluemaxw-Math.round(x.scroll.x*x.scrollratio.x),x.opt.cursordragspeed):x.doScrollLeft(Math.round(x.scroll.x*x.scrollratio.x),x.opt.cursordragspeed):x.doScrollTop(Math.round(x.scroll.y*x.scrollratio.y),x.opt.cursordragspeed))}),x.cancelEvent(e)}x.checkarea=0},M.cantouch||x.opt.emulatetouch)x.onpreventclick=function(e){if(x.preventclick)return x.preventclick.tg.onclick=x.preventclick.click,x.preventclick=!1,x.cancelEvent(e)},x.onclick=!M.isios&&function(e){return!x.lastmouseup||(x.lastmouseup=!1,x.cancelEvent(e))},x.opt.grabcursorenabled&&M.cursorgrabvalue&&(x.css(x.ispage?x.doc:x.win,{cursor:M.cursorgrabvalue}),x.css(x.rail,{cursor:M.cursorgrabvalue}));else{var k=function(e){if(x.selectiondrag){if(e){var o=x.win.outerHeight(),t=e.pageY-x.selectiondrag.top;t>0&&t<o&&(t=0),t>=o&&(t-=o),x.selectiondrag.df=t}if(0!=x.selectiondrag.df){var r=2*-Math.floor(x.selectiondrag.df/6);x.doScrollBy(r),x.debounced("doselectionscroll",function(){k()},50)}}};"getSelection"in document?x.hasTextSelected=function(){return document.getSelection().rangeCount>0}:"selection"in document?x.hasTextSelected=function(){return"None"!=document.selection.type}:x.hasTextSelected=function(){return!1},x.onselectionstart=function(e){x.ispage||(x.selectiondrag=x.win.offset())},x.onselectionend=function(e){x.selectiondrag=!1},x.onselectiondrag=function(e){x.selectiondrag&&x.hasTextSelected()&&x.debounced("selectionscroll",function(){k(e)},250)}}if(M.hasw3ctouch?(x.css(x.ispage?s("html"):x.win,{"touch-action":"none"}),x.css(x.rail,{"touch-action":"none"}),x.css(x.cursor,{"touch-action":"none"}),x.bind(x.win,"pointerdown",x.ontouchstart),x.bind(document,"pointerup",x.ontouchend),x.bind(document,"pointermove",x.ontouchmove)):M.hasmstouch?(x.css(x.ispage?s("html"):x.win,{"-ms-touch-action":"none"}),x.css(x.rail,{"-ms-touch-action":"none"}),x.css(x.cursor,{"-ms-touch-action":"none"}),x.bind(x.win,"MSPointerDown",x.ontouchstart),x.bind(document,"MSPointerUp",x.ontouchend),x.bind(document,"MSPointerMove",x.ontouchmove),x.bind(x.cursor,"MSGestureHold",function(e){e.preventDefault()}),x.bind(x.cursor,"contextmenu",function(e){e.preventDefault()})):M.cantouch&&(x.bind(x.win,"touchstart",x.ontouchstart,!1,!0),x.bind(document,"touchend",x.ontouchend,!1,!0),x.bind(document,"touchcancel",x.ontouchend,!1,!0),x.bind(document,"touchmove",x.ontouchmove,!1,!0)),x.opt.emulatetouch&&(x.bind(x.win,"mousedown",x.ontouchstart,!1,!0),x.bind(document,"mouseup",x.ontouchend,!1,!0),x.bind(document,"mousemove",x.ontouchmove,!1,!0)),(x.opt.cursordragontouch||!M.cantouch&&!x.opt.emulatetouch)&&(x.rail.css({cursor:"default"}),x.railh&&x.railh.css({cursor:"default"}),x.jqbind(x.rail,"mouseenter",function(){if(!x.ispage&&!x.win.is(":visible"))return!1;x.canshowonmouseevent&&x.showCursor(),x.rail.active=!0}),x.jqbind(x.rail,"mouseleave",function(){x.rail.active=!1,x.rail.drag||x.hideCursor()}),x.opt.sensitiverail&&(x.bind(x.rail,"click",function(e){x.doRailClick(e,!1,!1)}),x.bind(x.rail,"dblclick",function(e){x.doRailClick(e,!0,!1)}),x.bind(x.cursor,"click",function(e){x.cancelEvent(e)}),x.bind(x.cursor,"dblclick",function(e){x.cancelEvent(e)})),x.railh&&(x.jqbind(x.railh,"mouseenter",function(){if(!x.ispage&&!x.win.is(":visible"))return!1;x.canshowonmouseevent&&x.showCursor(),x.rail.active=!0}),x.jqbind(x.railh,"mouseleave",function(){x.rail.active=!1,x.rail.drag||x.hideCursor()}),x.opt.sensitiverail&&(x.bind(x.railh,"click",function(e){x.doRailClick(e,!1,!0)}),x.bind(x.railh,"dblclick",function(e){x.doRailClick(e,!0,!0)}),x.bind(x.cursorh,"click",function(e){x.cancelEvent(e)}),x.bind(x.cursorh,"dblclick",function(e){x.cancelEvent(e)})))),x.opt.cursordragontouch&&(this.istouchcapable||M.cantouch)&&(x.bind(x.cursor,"touchstart",x.ontouchstartCursor),x.bind(x.cursor,"touchmove",x.ontouchmoveCursor),x.bind(x.cursor,"touchend",x.ontouchendCursor),x.cursorh&&x.bind(x.cursorh,"touchstart",function(e){x.ontouchstartCursor(e,!0)}),x.cursorh&&x.bind(x.cursorh,"touchmove",x.ontouchmoveCursor),x.cursorh&&x.bind(x.cursorh,"touchend",x.ontouchendCursor)),M.cantouch||x.opt.emulatetouch?(x.bind(M.hasmousecapture?x.win:document,"mouseup",x.ontouchend),x.onclick&&x.bind(document,"click",x.onclick),x.opt.cursordragontouch?(x.bind(x.cursor,"mousedown",x.onmousedown),x.bind(x.cursor,"mouseup",x.onmouseup),x.cursorh&&x.bind(x.cursorh,"mousedown",function(e){x.onmousedown(e,!0)}),x.cursorh&&x.bind(x.cursorh,"mouseup",x.onmouseup)):(x.bind(x.rail,"mousedown",function(e){e.preventDefault()}),x.railh&&x.bind(x.railh,"mousedown",function(e){e.preventDefault()}))):(x.bind(M.hasmousecapture?x.win:document,"mouseup",x.onmouseup),x.bind(document,"mousemove",x.onmousemove),x.onclick&&x.bind(document,"click",x.onclick),x.bind(x.cursor,"mousedown",x.onmousedown),x.bind(x.cursor,"mouseup",x.onmouseup),x.railh&&(x.bind(x.cursorh,"mousedown",function(e){x.onmousedown(e,!0)}),x.bind(x.cursorh,"mouseup",x.onmouseup)),!x.ispage&&x.opt.enablescrollonselection&&(x.bind(x.win[0],"mousedown",x.onselectionstart),x.bind(document,"mouseup",x.onselectionend),x.bind(x.cursor,"mouseup",x.onselectionend),x.cursorh&&x.bind(x.cursorh,"mouseup",x.onselectionend),x.bind(document,"mousemove",x.onselectiondrag)),x.zoom&&(x.jqbind(x.zoom,"mouseenter",function(){x.canshowonmouseevent&&x.showCursor(),x.rail.active=!0}),x.jqbind(x.zoom,"mouseleave",function(){x.rail.active=!1,x.rail.drag||x.hideCursor()}))),x.opt.enablemousewheel&&(x.isiframe||x.mousewheel(M.isie&&x.ispage?document:x.win,x.onmousewheel),x.mousewheel(x.rail,x.onmousewheel),x.railh&&x.mousewheel(x.railh,x.onmousewheelhr)),x.ispage||M.cantouch||/HTML|^BODY/.test(x.win[0].nodeName)||(x.win.attr("tabindex")||x.win.attr({tabindex:++r}),x.bind(x.win,"focus",function(e){o=x.getTarget(e).id||!0,x.hasfocus=!0,x.canshowonmouseevent&&x.noticeCursor()}),x.bind(x.win,"blur",function(e){o=!1,x.hasfocus=!1}),x.bind(x.win,"mouseenter",function(e){t=x.getTarget(e).id||!0,x.hasmousefocus=!0,x.canshowonmouseevent&&x.noticeCursor()}),x.bind(x.win,"mouseleave",function(e){t=!1,x.hasmousefocus=!1,x.rail.drag||x.hideCursor()})),x.onkeypress=function(e){if(x.railslocked&&0==x.page.maxh)return!0;e=e||window.e;var r=x.getTarget(e);if(r&&/INPUT|TEXTAREA|SELECT|OPTION/.test(r.nodeName)&&(!(r.getAttribute("type")||r.type||!1)||!/submit|button|cancel/i.tp))return!0;if(s(r).attr("contenteditable"))return!0;if(x.hasfocus||x.hasmousefocus&&!o||x.ispage&&!o&&!t){var i=e.keyCode;if(x.railslocked&&27!=i)return x.cancelEvent(e);var n=e.ctrlKey||!1,l=e.shiftKey||!1,a=!1;switch(i){case 38:case 63233:x.doScrollBy(72),a=!0;break;case 40:case 63235:x.doScrollBy(-72),a=!0;break;case 37:case 63232:x.railh&&(n?x.doScrollLeft(0):x.doScrollLeftBy(72),a=!0);break;case 39:case 63234:x.railh&&(n?x.doScrollLeft(x.page.maxw):x.doScrollLeftBy(-72),a=!0);break;case 33:case 63276:x.doScrollBy(x.view.h),a=!0;break;case 34:case 63277:x.doScrollBy(-x.view.h),a=!0;break;case 36:case 63273:x.railh&&n?x.doScrollPos(0,0):x.doScrollTo(0),a=!0;break;case 35:case 63275:x.railh&&n?x.doScrollPos(x.page.maxw,x.page.maxh):x.doScrollTo(x.page.maxh),a=!0;break;case 32:x.opt.spacebarenabled&&(l?x.doScrollBy(x.view.h):x.doScrollBy(-x.view.h),a=!0);break;case 27:x.zoomactive&&(x.doZoom(),a=!0)}if(a)return x.cancelEvent(e)}},x.opt.enablekeyboard&&x.bind(document,M.isopera&&!M.isopera12?"keypress":"keydown",x.onkeypress),x.bind(document,"keydown",function(e){(e.ctrlKey||!1)&&(x.wheelprevented=!0)}),x.bind(document,"keyup",function(e){e.ctrlKey||!1||(x.wheelprevented=!1)}),x.bind(window,"blur",function(e){x.wheelprevented=!1}),x.bind(window,"resize",x.lazyResize),x.bind(window,"orientationchange",x.lazyResize),x.bind(window,"load",x.lazyResize),M.ischrome&&!x.ispage&&!x.haswrapper){var T=x.win.attr("style"),E=parseFloat(x.win.css("width"))+1;x.win.css("width",E),x.synched("chromefix",function(){x.win.attr("style",T)})}x.onAttributeChange=function(e){x.lazyResize(x.isieold?250:30)},x.opt.enableobserver&&(x.isie11||!1===u||(x.observerbody=new u(function(e){if(e.forEach(function(e){if("attributes"==e.type)return S.hasClass("modal-open")&&S.hasClass("modal-dialog")&&!s.contains(s(".modal-dialog")[0],x.doc[0])?x.hide():x.show()}),x.me.clientWidth!=x.page.width||x.me.clientHeight!=x.page.height)return x.lazyResize(30)}),x.observerbody.observe(document.body,{childList:!0,subtree:!0,characterData:!1,attributes:!0,attributeFilter:["class"]})),x.ispage||x.haswrapper||(!1!==u?(x.observer=new u(function(e){e.forEach(x.onAttributeChange)}),x.observer.observe(x.win[0],{childList:!0,characterData:!1,attributes:!0,subtree:!1}),x.observerremover=new u(function(e){e.forEach(function(e){if(e.removedNodes.length>0)for(var o in e.removedNodes)if(x&&e.removedNodes[o]==x.win[0])return x.remove()})}),x.observerremover.observe(x.win[0].parentNode,{childList:!0,characterData:!1,attributes:!1,subtree:!1})):(x.bind(x.win,M.isie&&!M.isie9?"propertychange":"DOMAttrModified",x.onAttributeChange),M.isie9&&x.win[0].attachEvent("onpropertychange",x.onAttributeChange),x.bind(x.win,"DOMNodeRemoved",function(e){e.target==x.win[0]&&x.remove()})))),!x.ispage&&x.opt.boxzoom&&x.bind(window,"resize",x.resizeZoom),x.istextarea&&(x.bind(x.win,"keydown",x.lazyResize),x.bind(x.win,"mouseup",x.lazyResize)),x.lazyResize(30)}if("IFRAME"==this.doc[0].nodeName){var L=function(){x.iframexd=!1;var o;try{(o="contentDocument"in this?this.contentDocument:this.contentWindow.document).domain}catch(e){x.iframexd=!0,o=!1}if(x.iframexd)return"console"in window&&console.log("NiceScroll error: policy restriced iframe"),!0;if(x.forcescreen=!0,x.isiframe&&(x.iframe={doc:s(o),html:x.doc.contents().find("html")[0],body:x.doc.contents().find("body")[0]},x.getContentSize=function(){return{w:Math.max(x.iframe.html.scrollWidth,x.iframe.body.scrollWidth),h:Math.max(x.iframe.html.scrollHeight,x.iframe.body.scrollHeight)}},x.docscroll=s(x.iframe.body)),!M.isios&&x.opt.iframeautoresize&&!x.isiframe){x.win.scrollTop(0),x.doc.height("");var t=Math.max(o.getElementsByTagName("html")[0].scrollHeight,o.body.scrollHeight);x.doc.height(t)}x.lazyResize(30),x.css(s(x.iframe.body),e),M.isios&&x.haswrapper&&x.css(s(o.body),{"-webkit-transform":"translate3d(0,0,0)"}),"contentWindow"in this?x.bind(this.contentWindow,"scroll",x.onscroll):x.bind(o,"scroll",x.onscroll),x.opt.enablemousewheel&&x.mousewheel(o,x.onmousewheel),x.opt.enablekeyboard&&x.bind(o,M.isopera?"keypress":"keydown",x.onkeypress),M.cantouch?(x.bind(o,"touchstart",x.ontouchstart),x.bind(o,"touchmove",x.ontouchmove)):x.opt.emulatetouch&&(x.bind(o,"mousedown",x.ontouchstart),x.bind(o,"mousemove",function(e){return x.ontouchmove(e,!0)}),x.opt.grabcursorenabled&&M.cursorgrabvalue&&x.css(s(o.body),{cursor:M.cursorgrabvalue})),x.bind(o,"mouseup",x.ontouchend),x.zoom&&(x.opt.dblclickzoom&&x.bind(o,"dblclick",x.doZoom),x.ongesturezoom&&x.bind(o,"gestureend",x.ongesturezoom))};this.doc[0].readyState&&"complete"==this.doc[0].readyState&&setTimeout(function(){L.call(x.doc[0],!1)},500),x.bind(this.doc,"load",L)}},this.showCursor=function(e,o){if(x.cursortimeout&&(clearTimeout(x.cursortimeout),x.cursortimeout=0),x.rail){if(x.autohidedom&&(x.autohidedom.stop().css({opacity:x.opt.cursoropacitymax}),x.cursoractive=!0),x.rail.drag&&1==x.rail.drag.pt||(void 0!==e&&!1!==e&&(x.scroll.y=Math.round(1*e/x.scrollratio.y)),void 0!==o&&(x.scroll.x=Math.round(1*o/x.scrollratio.x))),x.cursor.css({height:x.cursorheight,top:x.scroll.y}),x.cursorh){var t=x.hasreversehr?x.scrollvaluemaxw-x.scroll.x:x.scroll.x;!x.rail.align&&x.rail.visibility?x.cursorh.css({width:x.cursorwidth,left:t+x.rail.width}):x.cursorh.css({width:x.cursorwidth,left:t}),x.cursoractive=!0}x.zoom&&x.zoom.stop().css({opacity:x.opt.cursoropacitymax})}},this.hideCursor=function(e){x.cursortimeout||x.rail&&x.autohidedom&&(x.hasmousefocus&&"leave"==x.opt.autohidemode||(x.cursortimeout=setTimeout(function(){x.rail.active&&x.showonmouseevent||(x.autohidedom.stop().animate({opacity:x.opt.cursoropacitymin}),x.zoom&&x.zoom.stop().animate({opacity:x.opt.cursoropacitymin}),x.cursoractive=!1),x.cursortimeout=0},e||x.opt.hidecursordelay)))},this.noticeCursor=function(e,o,t){x.showCursor(o,t),x.rail.active||x.hideCursor(e)},this.getContentSize=x.ispage?function(){return{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}}:x.haswrapper?function(){return{w:x.doc[0].offsetWidth,h:x.doc[0].offsetHeight}}:function(){return{w:x.docscroll[0].scrollWidth,h:x.docscroll[0].scrollHeight}},this.onResize=function(e,o){if(!x||!x.win)return!1;if(!x.haswrapper&&!x.ispage){if("none"==x.win.css("display"))return x.visibility&&x.hideRail().hideRailHr(),!1;x.hidden||x.visibility||x.showRail().showRailHr()}var t=x.page.maxh,r=x.page.maxw,i={h:x.view.h,w:x.view.w};if(x.view={w:x.ispage?x.win.width():x.win[0].clientWidth,h:x.ispage?x.win.height():x.win[0].clientHeight},x.page=o||x.getContentSize(),x.page.maxh=Math.max(0,x.page.h-x.view.h),x.page.maxw=Math.max(0,x.page.w-x.view.w),x.page.maxh==t&&x.page.maxw==r&&x.view.w==i.w&&x.view.h==i.h){if(x.ispage)return x;var n=x.win.offset();if(x.lastposition){var s=x.lastposition;if(s.top==n.top&&s.left==n.left)return x}x.lastposition=n}return 0===x.page.maxh?(x.hideRail(),x.scrollvaluemax=0,x.scroll.y=0,x.scrollratio.y=0,x.cursorheight=0,x.setScrollTop(0),x.rail&&(x.rail.scrollable=!1)):(x.page.maxh-=x.opt.railpadding.top+x.opt.railpadding.bottom,x.rail.scrollable=!0),0===x.page.maxw?(x.hideRailHr(),x.scrollvaluemaxw=0,x.scroll.x=0,x.scrollratio.x=0,x.cursorwidth=0,x.setScrollLeft(0),x.railh&&(x.railh.scrollable=!1)):(x.page.maxw-=x.opt.railpadding.left+x.opt.railpadding.right,x.railh&&(x.railh.scrollable=x.opt.horizrailenabled)),x.railslocked=x.locked||0===x.page.maxh&&0===x.page.maxw,x.railslocked?(x.ispage||x.updateScrollBar(x.view),!1):(x.hidden||x.visibility?!x.railh||x.hidden||x.railh.visibility||x.showRailHr():x.showRail().showRailHr(),x.istextarea&&x.win.css("resize")&&"none"!=x.win.css("resize")&&(x.view.h-=20),x.cursorheight=Math.min(x.view.h,Math.round(x.view.h*(x.view.h/x.page.h))),x.cursorheight=x.opt.cursorfixedheight?x.opt.cursorfixedheight:Math.max(x.opt.cursorminheight,x.cursorheight),x.cursorwidth=Math.min(x.view.w,Math.round(x.view.w*(x.view.w/x.page.w))),x.cursorwidth=x.opt.cursorfixedheight?x.opt.cursorfixedheight:Math.max(x.opt.cursorminheight,x.cursorwidth),x.scrollvaluemax=x.view.h-x.cursorheight-(x.opt.railpadding.top+x.opt.railpadding.bottom),x.railh&&(x.railh.width=x.page.maxh>0?x.view.w-x.rail.width:x.view.w,x.scrollvaluemaxw=x.railh.width-x.cursorwidth-(x.opt.railpadding.left+x.opt.railpadding.right)),x.ispage||x.updateScrollBar(x.view),x.scrollratio={x:x.page.maxw/x.scrollvaluemaxw,y:x.page.maxh/x.scrollvaluemax},x.getScrollTop()>x.page.maxh?x.doScrollTop(x.page.maxh):(x.scroll.y=Math.round(x.getScrollTop()*(1/x.scrollratio.y)),x.scroll.x=Math.round(x.getScrollLeft()*(1/x.scrollratio.x)),x.cursoractive&&x.noticeCursor()),x.scroll.y&&0==x.getScrollTop()&&x.doScrollTo(Math.floor(x.scroll.y*x.scrollratio.y)),x)},this.resize=x.onResize,this.hlazyresize=0,this.lazyResize=function(e){return x.haswrapper||x.hide(),x.hlazyresize&&clearTimeout(x.hlazyresize),x.hlazyresize=setTimeout(function(){x&&(x.resize(),x.show())},240),x},this.jqbind=function(e,o,t){x.events.push({e:e,n:o,f:t,q:!0}),s(e).bind(o,t)},this.mousewheel=function(e,o,t){var r="jquery"in e?e[0]:e;if("onwheel"in document.createElement("div"))x._bind(r,"wheel",o,t||!1);else{var i=void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";b(r,i,o,t||!1),"DOMMouseScroll"==i&&b(r,"MozMousePixelScroll",o,t||!1)}};var P=!1;if(M.haseventlistener){try{var R=Object.defineProperty({},"passive",{get:function(){P=!0}});window.addEventListener("test",null,R)}catch(e){}this.cancelEvent=function(e){return!!e&&((e=e.original?e.original:e).cancelable&&e.preventDefault(),e.stopPropagation(),e.preventManipulation&&e.preventManipulation(),!1)},this.stopPropagation=function(e){return!!e&&((e=e.original?e.original:e).stopPropagation(),!1)}}else Event.prototype.preventDefault=function(){this.returnValue=!1},Event.prototype.stopPropagation=function(){this.cancelBubble=!0},window.constructor.prototype.addEventListener=document.constructor.prototype.addEventListener=Element.prototype.addEventListener=function(e,o,t){this.attachEvent("on"+e,o)},window.constructor.prototype.removeEventListener=document.constructor.prototype.removeEventListener=Element.prototype.removeEventListener=function(e,o,t){this.detachEvent("on"+e,o)},this.cancelEvent=function(e){return!!(e=window.event||!1)&&(e.cancelBubble=!0,e.cancel=!0,e.returnValue=!1,!1)},this.stopPropagation=function(e){return!!(e=window.event||!1)&&(e.cancelBubble=!0,!1)};this.bind=function(e,o,t,r,i){var n="jquery"in e?e[0]:e;x._bind(n,o,t,r||!1,i||!1)},this._bind=function(e,o,t,r,i){x.events.push({e:e,n:o,f:t,b:r,q:!1}),P&&i?e.addEventListener(o,t,{passive:!1,capture:r}):e.addEventListener(o,t,r||!1)},this._unbind=function(e,o,t,r){e.removeEventListener(o,t,r)},this.unbindAll=function(){for(var e=0;e<x.events.length;e++){var o=x.events[e];o.q?o.e.unbind(o.n,o.f):x._unbind(o.e,o.n,o.f,o.b)}},this.showRail=function(){return 0==x.page.maxh||!x.ispage&&"none"==x.win.css("display")||(x.visibility=!0,x.rail.visibility=!0,x.rail.css("display","block")),x},this.showRailHr=function(){return x.railh?(0==x.page.maxw||!x.ispage&&"none"==x.win.css("display")||(x.railh.visibility=!0,x.railh.css("display","block")),x):x},this.hideRail=function(){return x.visibility=!1,x.rail.visibility=!1,x.rail.css("display","none"),x},this.hideRailHr=function(){return x.railh?(x.railh.visibility=!1,x.railh.css("display","none"),x):x},this.show=function(){return x.hidden=!1,x.railslocked=!1,x.showRail().showRailHr()},this.hide=function(){return x.hidden=!0,x.railslocked=!0,x.hideRail().hideRailHr()},this.toggle=function(){return x.hidden?x.show():x.hide()},this.remove=function(){x.stop(),x.cursortimeout&&clearTimeout(x.cursortimeout);for(var e in x.delaylist)x.delaylist[e]&&c(x.delaylist[e].h);x.doZoomOut(),x.unbindAll(),M.isie9&&x.win[0].detachEvent("onpropertychange",x.onAttributeChange),!1!==x.observer&&x.observer.disconnect(),!1!==x.observerremover&&x.observerremover.disconnect(),!1!==x.observerbody&&x.observerbody.disconnect(),x.events=null,x.cursor&&x.cursor.remove(),x.cursorh&&x.cursorh.remove(),x.rail&&x.rail.remove(),x.railh&&x.railh.remove(),x.zoom&&x.zoom.remove();for(var o=0;o<x.saved.css.length;o++){var t=x.saved.css[o];t[0].css(t[1],void 0===t[2]?"":t[2])}x.saved=!1,x.me.data("__nicescroll","");var r=s.nicescroll;r.each(function(e){if(this&&this.id===x.id){delete r[e];for(var o=++e;o<r.length;o++,e++)r[e]=r[o];--r.length&&delete r[r.length]}});for(var i in x)x[i]=null,delete x[i];x=null},this.scrollstart=function(e){return this.onscrollstart=e,x},this.scrollend=function(e){return this.onscrollend=e,x},this.scrollcancel=function(e){return this.onscrollcancel=e,x},this.zoomin=function(e){return this.onzoomin=e,x},this.zoomout=function(e){return this.onzoomout=e,x},this.isScrollable=function(e){var o=e.target?e.target:e;if("OPTION"==o.nodeName)return!0;for(;o&&1==o.nodeType&&o!==this.me[0]&&!/^BODY|HTML/.test(o.nodeName);){var t=s(o),r=t.css("overflowY")||t.css("overflowX")||t.css("overflow")||"";if(/scroll|auto/.test(r))return o.clientHeight!=o.scrollHeight;o=!!o.parentNode&&o.parentNode}return!1},this.getViewport=function(e){for(var o=!(!e||!e.parentNode)&&e.parentNode;o&&1==o.nodeType&&!/^BODY|HTML/.test(o.nodeName);){var t=s(o);if(/fixed|absolute/.test(t.css("position")))return t;var r=t.css("overflowY")||t.css("overflowX")||t.css("overflow")||"";if(/scroll|auto/.test(r)&&o.clientHeight!=o.scrollHeight)return t;if(t.getNiceScroll().length>0)return t;o=!!o.parentNode&&o.parentNode}return!1},this.triggerScrollStart=function(e,o,t,r,i){var n={type:"scrollstart",current:{x:e,y:o},request:{x:t,y:r},end:{x:x.newscrollx,y:x.newscrolly},speed:i};x.onscrollstart.call(x,n)},this.triggerScrollEnd=function(){if(x.onscrollend){var e=x.getScrollLeft(),o=x.getScrollTop(),t={type:"scrollend",current:{x:e,y:o},end:{x:e,y:o}};x.onscrollend.call(x,t)}},this.onmousewheel=function(e){if(!x.wheelprevented){if(x.railslocked)return x.debounced("checkunlock",x.resize,250),!0;if(x.rail.drag)return x.cancelEvent(e);if("auto"===x.opt.oneaxismousemode&&0!==e.deltaX&&(x.opt.oneaxismousemode=!1),x.opt.oneaxismousemode&&0===e.deltaX&&!x.rail.scrollable)return!x.railh||!x.railh.scrollable||x.onmousewheelhr(e);var o=h(),t=!1;if(x.opt.preservenativescrolling&&x.checkarea+600<o&&(x.nativescrollingarea=x.isScrollable(e),t=!0),x.checkarea=o,x.nativescrollingarea)return!0;var r=y(e,!1,t);return r&&(x.checkarea=0),r}},this.onmousewheelhr=function(e){if(!x.wheelprevented){if(x.railslocked||!x.railh.scrollable)return!0;if(x.rail.drag)return x.cancelEvent(e);var o=h(),t=!1;return x.opt.preservenativescrolling&&x.checkarea+600<o&&(x.nativescrollingarea=x.isScrollable(e),t=!0),x.checkarea=o,!!x.nativescrollingarea||(x.railslocked?x.cancelEvent(e):y(e,!0,t))}},this.stop=function(){return x.cancelScroll(),x.scrollmon&&x.scrollmon.stop(),x.cursorfreezed=!1,x.scroll.y=Math.round(x.getScrollTop()*(1/x.scrollratio.y)),x.noticeCursor(),x},this.getTransitionSpeed=function(e){var o=Math.round(10*x.opt.scrollspeed),t=Math.min(o,Math.round(e/20*x.opt.scrollspeed));return t>20?t:0},x.opt.smoothscroll?x.ishwscroll&&M.hastransition&&x.opt.usetransition&&x.opt.smoothscroll?(this.prepareTransition=function(e,o){var t=o?e>20?e:0:x.getTransitionSpeed(e),r=t?M.prefixstyle+"transform "+t+"ms ease-out":"";return x.lasttransitionstyle&&x.lasttransitionstyle==r||(x.lasttransitionstyle=r,x.doc.css(M.transitionstyle,r)),t},this.doScrollLeft=function(e,o){var t=x.scrollrunning?x.newscrolly:x.getScrollTop();x.doScrollPos(e,t,o)},this.doScrollTop=function(e,o){var t=x.scrollrunning?x.newscrollx:x.getScrollLeft();x.doScrollPos(t,e,o)},this.doScrollPos=function(e,o,t){var r=x.getScrollTop(),i=x.getScrollLeft();return((x.newscrolly-r)*(o-r)<0||(x.newscrollx-i)*(e-i)<0)&&x.cancelScroll(),0==x.opt.bouncescroll&&(o<0?o=0:o>x.page.maxh&&(o=x.page.maxh),e<0?e=0:e>x.page.maxw&&(e=x.page.maxw)),(!x.scrollrunning||e!=x.newscrollx||o!=x.newscrolly)&&(x.newscrolly=o,x.newscrollx=e,x.newscrollspeed=t||!1,!x.timer&&void(x.timer=setTimeout(function(){var t=x.getScrollTop(),r=x.getScrollLeft(),i={};i.x=e-r,i.y=o-t,i.px=r,i.py=t;var n=Math.round(Math.sqrt(Math.pow(i.x,2)+Math.pow(i.y,2))),s=x.newscrollspeed&&x.newscrollspeed>1?x.newscrollspeed:x.getTransitionSpeed(n);if(x.newscrollspeed&&x.newscrollspeed<=1&&(s*=x.newscrollspeed),x.prepareTransition(s,!0),x.timerscroll&&x.timerscroll.tm&&clearInterval(x.timerscroll.tm),s>0){!x.scrollrunning&&x.onscrollstart&&x.triggerScrollStart(r,t,e,o,s),M.transitionend?x.scrollendtrapped||(x.scrollendtrapped=!0,x.bind(x.doc,M.transitionend,x.onScrollTransitionEnd,!1)):(x.scrollendtrapped&&clearTimeout(x.scrollendtrapped),x.scrollendtrapped=setTimeout(x.onScrollTransitionEnd,s));var l=t,a=r;x.timerscroll={bz:new L(l,x.newscrolly,s,0,0,.58,1),bh:new L(a,x.newscrollx,s,0,0,.58,1)},x.cursorfreezed||(x.timerscroll.tm=setInterval(function(){x.showCursor(x.getScrollTop(),x.getScrollLeft())},60))}x.synched("doScroll-set",function(){x.timer=0,x.scrollendtrapped&&(x.scrollrunning=!0),x.setScrollTop(x.newscrolly),x.setScrollLeft(x.newscrollx),x.scrollendtrapped||x.onScrollTransitionEnd()})},50)))},this.cancelScroll=function(){if(!x.scrollendtrapped)return!0;var e=x.getScrollTop(),o=x.getScrollLeft();return x.scrollrunning=!1,M.transitionend||clearTimeout(M.transitionend),x.scrollendtrapped=!1,x._unbind(x.doc[0],M.transitionend,x.onScrollTransitionEnd),x.prepareTransition(0),x.setScrollTop(e),x.railh&&x.setScrollLeft(o),x.timerscroll&&x.timerscroll.tm&&clearInterval(x.timerscroll.tm),x.timerscroll=!1,x.cursorfreezed=!1,x.showCursor(e,o),x},this.onScrollTransitionEnd=function(){x.scrollendtrapped&&x._unbind(x.doc[0],M.transitionend,x.onScrollTransitionEnd),x.scrollendtrapped=!1,x.prepareTransition(0),x.timerscroll&&x.timerscroll.tm&&clearInterval(x.timerscroll.tm),x.timerscroll=!1;var e=x.getScrollTop(),o=x.getScrollLeft();if(x.setScrollTop(e),x.railh&&x.setScrollLeft(o),x.noticeCursor(!1,e,o),x.cursorfreezed=!1,e<0?e=0:e>x.page.maxh&&(e=x.page.maxh),o<0?o=0:o>x.page.maxw&&(o=x.page.maxw),e!=x.newscrolly||o!=x.newscrollx)return x.doScrollPos(o,e,x.opt.snapbackspeed);x.onscrollend&&x.scrollrunning&&x.triggerScrollEnd(),x.scrollrunning=!1}):(this.doScrollLeft=function(e,o){var t=x.scrollrunning?x.newscrolly:x.getScrollTop();x.doScrollPos(e,t,o)},this.doScrollTop=function(e,o){var t=x.scrollrunning?x.newscrollx:x.getScrollLeft();x.doScrollPos(t,e,o)},this.doScrollPos=function(e,o,t){function r(){if(x.cancelAnimationFrame)return!0;if(x.scrollrunning=!0,h=1-h)return x.timer=a(r)||1;var e,o,t=0,i=o=x.getScrollTop();x.dst.ay?(((s=(i=x.bzscroll?x.dst.py+x.bzscroll.getNow()*x.dst.ay:x.newscrolly)-o)<0&&i<x.newscrolly||s>0&&i>x.newscrolly)&&(i=x.newscrolly),x.setScrollTop(i),i==x.newscrolly&&(t=1)):t=1;var n=e=x.getScrollLeft();if(x.dst.ax){var s=(n=x.bzscroll?x.dst.px+x.bzscroll.getNow()*x.dst.ax:x.newscrollx)-e;(s<0&&n<x.newscrollx||s>0&&n>x.newscrollx)&&(n=x.newscrollx),x.setScrollLeft(n),n==x.newscrollx&&(t+=1)}else t+=1;2==t?(x.timer=0,x.cursorfreezed=!1,x.bzscroll=!1,x.scrollrunning=!1,i<0?i=0:i>x.page.maxh&&(i=Math.max(0,x.page.maxh)),n<0?n=0:n>x.page.maxw&&(n=x.page.maxw),n!=x.newscrollx||i!=x.newscrolly?x.doScrollPos(n,i):x.onscrollend&&x.triggerScrollEnd()):x.timer=a(r)||1}var o=void 0===o||!1===o?x.getScrollTop(!0):o;if(x.timer&&x.newscrolly==o&&x.newscrollx==e)return!0;x.timer&&c(x.timer),x.timer=0;var i=x.getScrollTop(),n=x.getScrollLeft();((x.newscrolly-i)*(o-i)<0||(x.newscrollx-n)*(e-n)<0)&&x.cancelScroll(),x.newscrolly=o,x.newscrollx=e,x.bouncescroll&&x.rail.visibility||(x.newscrolly<0?x.newscrolly=0:x.newscrolly>x.page.maxh&&(x.newscrolly=x.page.maxh)),x.bouncescroll&&x.railh.visibility||(x.newscrollx<0?x.newscrollx=0:x.newscrollx>x.page.maxw&&(x.newscrollx=x.page.maxw)),x.dst={},x.dst.x=e-n,x.dst.y=o-i,x.dst.px=n,x.dst.py=i;var s=Math.round(Math.sqrt(Math.pow(x.dst.x,2)+Math.pow(x.dst.y,2)));x.dst.ax=x.dst.x/s,x.dst.ay=x.dst.y/s;var l=0,d=s;0==x.dst.x?(l=i,d=o,x.dst.ay=1,x.dst.py=0):0==x.dst.y&&(l=n,d=e,x.dst.ax=1,x.dst.px=0);var u=x.getTransitionSpeed(s);if(t&&t<=1&&(u*=t),x.bzscroll=u>0&&(x.bzscroll?x.bzscroll.update(d,u):new L(l,d,u,0,1,0,1)),!x.timer){(i==x.page.maxh&&o>=x.page.maxh||n==x.page.maxw&&e>=x.page.maxw)&&x.checkContentSize();var h=1;x.cancelAnimationFrame=!1,x.timer=1,x.onscrollstart&&!x.scrollrunning&&x.triggerScrollStart(n,i,e,o,u),r(),(i==x.page.maxh&&o>=i||n==x.page.maxw&&e>=n)&&x.checkContentSize(),x.noticeCursor()}},this.cancelScroll=function(){return x.timer&&c(x.timer),x.timer=0,x.bzscroll=!1,x.scrollrunning=!1,x}):(this.doScrollLeft=function(e,o){var t=x.getScrollTop();x.doScrollPos(e,t,o)},this.doScrollTop=function(e,o){var t=x.getScrollLeft();x.doScrollPos(t,e,o)},this.doScrollPos=function(e,o,t){var r=e>x.page.maxw?x.page.maxw:e;r<0&&(r=0);var i=o>x.page.maxh?x.page.maxh:o;i<0&&(i=0),x.synched("scroll",function(){x.setScrollTop(i),x.setScrollLeft(r)})},this.cancelScroll=function(){}),this.doScrollBy=function(e,o){var t=0;if(t=o?Math.floor((x.scroll.y-e)*x.scrollratio.y):(x.timer?x.newscrolly:x.getScrollTop(!0))-e,x.bouncescroll){var r=Math.round(x.view.h/2);t<-r?t=-r:t>x.page.maxh+r&&(t=x.page.maxh+r)}x.cursorfreezed=!1;var i=x.getScrollTop(!0);return t<0&&i<=0?x.noticeCursor():t>x.page.maxh&&i>=x.page.maxh?(x.checkContentSize(),x.noticeCursor()):void x.doScrollTop(t)},this.doScrollLeftBy=function(e,o){var t=0;if(t=o?Math.floor((x.scroll.x-e)*x.scrollratio.x):(x.timer?x.newscrollx:x.getScrollLeft(!0))-e,x.bouncescroll){var r=Math.round(x.view.w/2);t<-r?t=-r:t>x.page.maxw+r&&(t=x.page.maxw+r)}x.cursorfreezed=!1;var i=x.getScrollLeft(!0);return t<0&&i<=0?x.noticeCursor():t>x.page.maxw&&i>=x.page.maxw?x.noticeCursor():void x.doScrollLeft(t)},this.doScrollTo=function(e,o){var t=o?Math.round(e*x.scrollratio.y):e;t<0?t=0:t>x.page.maxh&&(t=x.page.maxh),x.cursorfreezed=!1,x.doScrollTop(e)},this.checkContentSize=function(){var e=x.getContentSize();e.h==x.page.h&&e.w==x.page.w||x.resize(!1,e)},x.onscroll=function(e){x.rail.drag||x.cursorfreezed||x.synched("scroll",function(){x.scroll.y=Math.round(x.getScrollTop()*(1/x.scrollratio.y)),x.railh&&(x.scroll.x=Math.round(x.getScrollLeft()*(1/x.scrollratio.x))),x.noticeCursor()})},x.bind(x.docscroll,"scroll",x.onscroll),this.doZoomIn=function(e){if(!x.zoomactive){x.zoomactive=!0,x.zoomrestore={style:{}};var o=["position","top","left","zIndex","backgroundColor","marginTop","marginBottom","marginLeft","marginRight"],t=x.win[0].style;for(var r in o){var i=o[r];x.zoomrestore.style[i]=void 0!==t[i]?t[i]:""}x.zoomrestore.style.width=x.win.css("width"),x.zoomrestore.style.height=x.win.css("height"),x.zoomrestore.padding={w:x.win.outerWidth()-x.win.width(),h:x.win.outerHeight()-x.win.height()},M.isios4&&(x.zoomrestore.scrollTop=l.scrollTop(),l.scrollTop(0)),x.win.css({position:M.isios4?"absolute":"fixed",top:0,left:0,zIndex:n+100,margin:0});var s=x.win.css("backgroundColor");return(""==s||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(s))&&x.win.css("backgroundColor","#fff"),x.rail.css({zIndex:n+101}),x.zoom.css({zIndex:n+102}),x.zoom.css("backgroundPosition","0 -18px"),x.resizeZoom(),x.onzoomin&&x.onzoomin.call(x),x.cancelEvent(e)}},this.doZoomOut=function(e){if(x.zoomactive)return x.zoomactive=!1,x.win.css("margin",""),x.win.css(x.zoomrestore.style),M.isios4&&l.scrollTop(x.zoomrestore.scrollTop),x.rail.css({"z-index":x.zindex}),x.zoom.css({"z-index":x.zindex}),x.zoomrestore=!1,x.zoom.css("backgroundPosition","0 0"),x.onResize(),x.onzoomout&&x.onzoomout.call(x),x.cancelEvent(e)},this.doZoom=function(e){return x.zoomactive?x.doZoomOut(e):x.doZoomIn(e)},this.resizeZoom=function(){if(x.zoomactive){var e=x.getScrollTop();x.win.css({width:l.width()-x.zoomrestore.padding.w+"px",height:l.height()-x.zoomrestore.padding.h+"px"}),x.onResize(),x.setScrollTop(Math.min(x.page.maxh,e))}},this.init(),s.nicescroll.push(this)},w=function(e){var o=this;this.nc=e,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.reset=function(e,t){o.stop(),o.steptime=0,o.lasttime=h(),o.speedx=0,o.speedy=0,o.lastx=e,o.lasty=t,o.lastscrollx=-1,o.lastscrolly=-1},this.update=function(e,t){var r=h();o.steptime=r-o.lasttime,o.lasttime=r;var i=t-o.lasty,n=e-o.lastx,s=o.nc.getScrollTop()+i,l=o.nc.getScrollLeft()+n;o.snapx=l<0||l>o.nc.page.maxw,o.snapy=s<0||s>o.nc.page.maxh,o.speedx=n,o.speedy=i,o.lastx=e,o.lasty=t},this.stop=function(){o.nc.unsynched("domomentum2d"),o.timer&&clearTimeout(o.timer),o.timer=0,o.lastscrollx=-1,o.lastscrolly=-1},this.doSnapy=function(e,t){var r=!1;t<0?(t=0,r=!0):t>o.nc.page.maxh&&(t=o.nc.page.maxh,r=!0),e<0?(e=0,r=!0):e>o.nc.page.maxw&&(e=o.nc.page.maxw,r=!0),r?o.nc.doScrollPos(e,t,o.nc.opt.snapbackspeed):o.nc.triggerScrollEnd()},this.doMomentum=function(e){var t=h(),r=e?t+e:o.lasttime,i=o.nc.getScrollLeft(),n=o.nc.getScrollTop(),s=o.nc.page.maxh,l=o.nc.page.maxw;o.speedx=l>0?Math.min(60,o.speedx):0,o.speedy=s>0?Math.min(60,o.speedy):0;var a=r&&t-r<=60;(n<0||n>s||i<0||i>l)&&(a=!1);var c=!(!o.speedy||!a)&&o.speedy,d=!(!o.speedx||!a)&&o.speedx;if(c||d){var u=Math.max(16,o.steptime);if(u>50){var p=u/50;o.speedx*=p,o.speedy*=p,u=50}o.demulxy=0,o.lastscrollx=o.nc.getScrollLeft(),o.chkx=o.lastscrollx,o.lastscrolly=o.nc.getScrollTop(),o.chky=o.lastscrolly;var m=o.lastscrollx,f=o.lastscrolly,g=function(){var e=h()-t>600?.04:.02;o.speedx&&(m=Math.floor(o.lastscrollx-o.speedx*(1-o.demulxy)),o.lastscrollx=m,(m<0||m>l)&&(e=.1)),o.speedy&&(f=Math.floor(o.lastscrolly-o.speedy*(1-o.demulxy)),o.lastscrolly=f,(f<0||f>s)&&(e=.1)),o.demulxy=Math.min(1,o.demulxy+e),o.nc.synched("domomentum2d",function(){if(o.speedx){o.nc.getScrollLeft();o.chkx=m,o.nc.setScrollLeft(m)}if(o.speedy){o.nc.getScrollTop();o.chky=f,o.nc.setScrollTop(f)}o.timer||(o.nc.hideCursor(),o.doSnapy(m,f))}),o.demulxy<1?o.timer=setTimeout(g,u):(o.stop(),o.nc.hideCursor(),o.doSnapy(m,f))};g()}else o.doSnapy(o.nc.getScrollLeft(),o.nc.getScrollTop())}},v=e.fn.scrollTop;e.cssHooks.pageYOffset={get:function(e,o,t){var r=s.data(e,"__nicescroll")||!1;return r&&r.ishwscroll?r.getScrollTop():v.call(e)},set:function(e,o){var t=s.data(e,"__nicescroll")||!1;return t&&t.ishwscroll?t.setScrollTop(parseInt(o)):v.call(e,o),this}},e.fn.scrollTop=function(e){if(void 0===e){var o=!!this[0]&&(s.data(this[0],"__nicescroll")||!1);return o&&o.ishwscroll?o.getScrollTop():v.call(this)}return this.each(function(){var o=s.data(this,"__nicescroll")||!1;o&&o.ishwscroll?o.setScrollTop(parseInt(e)):v.call(s(this),e)})};var b=e.fn.scrollLeft;s.cssHooks.pageXOffset={get:function(e,o,t){var r=s.data(e,"__nicescroll")||!1;return r&&r.ishwscroll?r.getScrollLeft():b.call(e)},set:function(e,o){var t=s.data(e,"__nicescroll")||!1;return t&&t.ishwscroll?t.setScrollLeft(parseInt(o)):b.call(e,o),this}},e.fn.scrollLeft=function(e){if(void 0===e){var o=!!this[0]&&(s.data(this[0],"__nicescroll")||!1);return o&&o.ishwscroll?o.getScrollLeft():b.call(this)}return this.each(function(){var o=s.data(this,"__nicescroll")||!1;o&&o.ishwscroll?o.setScrollLeft(parseInt(e)):b.call(s(this),e)})};var y=function(e){var o=this;if(this.length=0,this.name="nicescrollarray",this.each=function(e){return s.each(o,e),o},this.push=function(e){o[o.length]=e,o.length++},this.eq=function(e){return o[e]},e)for(var t=0;t<e.length;t++){var r=s.data(e[t],"__nicescroll")||!1;r&&(this[this.length]=r,this.length++)}return this};!function(e,o,t){for(var r=0,i=o.length;r<i;r++)t(e,o[r])}(y.prototype,["show","hide","toggle","onResize","resize","remove","stop","doScrollPos"],function(e,o){e[o]=function(){var e=arguments;return this.each(function(){this[o].apply(this,e)})}}),e.fn.getNiceScroll=function(e){return void 0===e?new y(this):this[e]&&s.data(this[e],"__nicescroll")||!1},e.expr[":"].nicescroll=function(e){return void 0!==s.data(e,"__nicescroll")},s.fn.niceScroll=function(e,o){void 0!==o||"object"!=typeof e||"jquery"in e||(o=e,e=!1);var t=new y;return this.each(function(){var r=s(this),i=s.extend({},o);if(e){var n=s(e);i.doc=n.length>1?s(e,r):n,i.win=r}!("doc"in i)||"win"in i||(i.win=r);var l=r.data("__nicescroll")||!1;l||(i.doc=i.doc||r,l=new g(i,r),r.data("__nicescroll",l)),t.push(l)}),1===t.length?t[0]:t},window.NiceScroll={getjQuery:function(){return e}},s.nicescroll||(s.nicescroll=new y,s.nicescroll.options=p)});