@alotool/custom-scrollbar
Version:
Highly customizable custom scrollbar jQuery plugin, featuring vertical/horizontal scrollbars, scrolling momentum, mouse-wheel, keyboard and touch support user defined callbacks etc.
1 lines • 39.6 kB
JavaScript
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e:e(jQuery,window,document)}(function(R){var s,W,a,n,l,i,p,A,L,g,f,c,d,u,h,m,v,x,_,w,S,b,y,C,B,T,k,M,z,r,O,I,D,E,H,P,U,F,q,j,Y,X,N,V,Q,G,J,K,Z,$,t,ee,te,oe,ae,ne,ie,e,o,re;e="function"==typeof define&&define.amd,o="undefined"!=typeof module&&module.exports,re="https:"==document.location.protocol?"https:":"http:",e||(o?require("jquery-mousewheel")(R):R.event.special.mousewheel||R("head").append(decodeURI("%3Cscript src="+re+"//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js%3E%3C/script%3E"))),s="mCustomScrollbar",W="mCS",a=".mCustomScrollbar",n={setTop:0,setLeft:0,axis:"y",scrollbarPosition:"inside",scrollInertia:950,autoDraggerLength:!0,alwaysShowScrollbar:0,snapOffset:0,mouseWheel:{enable:!0,scrollAmount:"auto",axis:"y",deltaFactor:"auto",disableOver:["select","option","keygen","datalist","textarea"]},scrollButtons:{scrollType:"stepless",scrollAmount:"auto"},keyboard:{enable:!0,scrollType:"stepless",scrollAmount:"auto"},contentTouchScroll:25,documentTouchScroll:!0,advanced:{autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",updateOnContentResize:!0,updateOnImageLoad:"auto",autoUpdateTimeout:60},theme:"light",callbacks:{onTotalScrollOffset:0,onTotalScrollBackOffset:0,alwaysTriggerOffsets:!0}},l=0,i={},p=window.attachEvent&&!window.addEventListener?1:0,A=!1,g=["mCSB_dragger_onDrag","mCSB_scrollTools_onDrag","mCS_img_loaded","mCS_disabled","mCS_destroyed","mCS_no_scrollbar","mCS-autoHide","mCS-dir-rtl","mCS_no_scrollbar_y","mCS_no_scrollbar_x","mCS_y_hidden","mCS_x_hidden","mCSB_draggerContainer","mCSB_buttonUp","mCSB_buttonDown","mCSB_buttonLeft","mCSB_buttonRight"],f={init:function(r){var r=R.extend(!0,{},n,r),e=c.call(this);if(r.live){var t=r.liveSelector||this.selector||a,o=R(t);if("off"===r.live)return void u(t);i[t]=setTimeout(function(){o.mCustomScrollbar(r),"once"===r.live&&o.length&&u(t)},500)}else u(t);return r.setWidth=r.set_width||r.setWidth,r.setHeight=r.set_height||r.setHeight,r.axis=r.horizontalScroll?"x":h(r.axis),r.scrollInertia=0<r.scrollInertia&&r.scrollInertia<17?17:r.scrollInertia,"object"!=typeof r.mouseWheel&&1==r.mouseWheel&&(r.mouseWheel={enable:!0,scrollAmount:"auto",axis:"y",preventDefault:!1,deltaFactor:"auto",normalizeDelta:!1,invert:!1}),r.mouseWheel.scrollAmount=r.mouseWheelPixels||r.mouseWheel.scrollAmount,r.mouseWheel.normalizeDelta=r.advanced.normalizeMouseWheelDelta||r.mouseWheel.normalizeDelta,r.scrollButtons.scrollType=m(r.scrollButtons.scrollType),d(r),R(e).each(function(){var e,t,o,a,n,i=R(this);i.data(W)||(i.data(W,{idx:++l,opt:r,scrollRatio:{y:null,x:null},overflowed:null,contentReset:{y:null,x:null},bindEvents:!1,tweenRunning:!1,sequential:{},langDir:i.css("direction"),cbOffsets:null,trigger:null,poll:{size:{o:0,n:0},img:{o:0,n:0},change:{o:0,n:0}}}),t=(e=i.data(W)).opt,o=i.data("mcs-axis"),a=i.data("mcs-scrollbar-position"),n=i.data("mcs-theme"),o&&(t.axis=o),a&&(t.scrollbarPosition=a),n&&(t.theme=n,d(t)),v.call(this),e&&t.callbacks.onCreate&&"function"==typeof t.callbacks.onCreate&&t.callbacks.onCreate.call(this),R("#mCSB_"+e.idx+"_container img:not(."+g[2]+")").addClass(g[2]),f.update.call(null,i))})},update:function(e,r){e=e||c.call(this);return R(e).each(function(){var e,t,o,a,n,i=R(this);i.data(W)&&(t=(e=i.data(W)).opt,n=R("#mCSB_"+e.idx+"_container"),o=R("#mCSB_"+e.idx),a=[R("#mCSB_"+e.idx+"_dragger_vertical"),R("#mCSB_"+e.idx+"_dragger_horizontal")],n.length&&(e.tweenRunning&&J(i),r&&e&&t.callbacks.onBeforeUpdate&&"function"==typeof t.callbacks.onBeforeUpdate&&t.callbacks.onBeforeUpdate.call(this),i.hasClass(g[3])&&i.removeClass(g[3]),i.hasClass(g[4])&&i.removeClass(g[4]),o.css("max-height","none"),o.height()!==i.height()&&o.css("max-height",i.height()),_.call(this),"y"===t.axis||t.advanced.autoExpandHorizontalScroll||n.css("width",x(n)),e.overflowed=C.call(this),M.call(this),t.autoDraggerLength&&S.call(this),b.call(this),T.call(this),n=[Math.abs(n[0].offsetTop),Math.abs(n[0].offsetLeft)],"x"!==t.axis&&(e.overflowed[0]?a[0].height()>a[0].parent().height()?B.call(this):(K(i,n[0].toString(),{dir:"y",dur:0,overwrite:"none"}),e.contentReset.y=null):(B.call(this),"y"===t.axis?k.call(this):"yx"===t.axis&&e.overflowed[1]&&K(i,n[1].toString(),{dir:"x",dur:0,overwrite:"none"}))),"y"!==t.axis&&(e.overflowed[1]?a[1].width()>a[1].parent().width()?B.call(this):(K(i,n[1].toString(),{dir:"x",dur:0,overwrite:"none"}),e.contentReset.x=null):(B.call(this),"x"===t.axis?k.call(this):"yx"===t.axis&&e.overflowed[0]&&K(i,n[0].toString(),{dir:"y",dur:0,overwrite:"none"}))),r&&e&&(2===r&&t.callbacks.onImageLoad&&"function"==typeof t.callbacks.onImageLoad?t.callbacks.onImageLoad.call(this):3===r&&t.callbacks.onSelectorChange&&"function"==typeof t.callbacks.onSelectorChange?t.callbacks.onSelectorChange.call(this):t.callbacks.onUpdate&&"function"==typeof t.callbacks.onUpdate&&t.callbacks.onUpdate.call(this)),G.call(this)))})},scrollTo:function(r,l){if(void 0!==r&&null!=r){var e=c.call(this);return R(e).each(function(){var e,t,o,a,n,i=R(this);i.data(W)&&(e=i.data(W),n={trigger:"external",scrollInertia:(t=e.opt).scrollInertia,scrollEasing:"mcsEaseInOut",moveDragger:!1,timeout:60,callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},o=R.extend(!0,{},n,l),a=V.call(this,r),n=0<o.scrollInertia&&o.scrollInertia<17?17:o.scrollInertia,a[0]=Q.call(this,a[0],"y"),a[1]=Q.call(this,a[1],"x"),o.moveDragger&&(a[0]*=e.scrollRatio.y,a[1]*=e.scrollRatio.x),o.dur=ie()?0:n,setTimeout(function(){null!==a[0]&&void 0!==a[0]&&"x"!==t.axis&&e.overflowed[0]&&(o.dir="y",o.overwrite="all",K(i,a[0].toString(),o)),null!==a[1]&&void 0!==a[1]&&"y"!==t.axis&&e.overflowed[1]&&(o.dir="x",o.overwrite="none",K(i,a[1].toString(),o))},o.timeout))})}},stop:function(){var e=c.call(this);return R(e).each(function(){var e=R(this);e.data(W)&&J(e)})},disable:function(t){var e=c.call(this);return R(e).each(function(){var e=R(this);e.data(W)&&(e.data(W),G.call(this,"remove"),k.call(this),t&&B.call(this),M.call(this,!0),e.addClass(g[3]))})},destroy:function(){var r=c.call(this);return R(r).each(function(){var e,t,o,a,n,i=R(this);i.data(W)&&(t=(e=i.data(W)).opt,o=R("#mCSB_"+e.idx),a=R("#mCSB_"+e.idx+"_container"),n=R(".mCSB_"+e.idx+"_scrollbar"),t.live&&u(t.liveSelector||R(r).selector),G.call(this,"remove"),k.call(this),B.call(this),i.removeData(W),ee(this,"mcs"),n.remove(),a.find("img."+g[2]).removeClass(g[2]),o.replaceWith(a.contents()),i.removeClass(s+" _"+W+"_"+e.idx+" "+g[6]+" "+g[7]+" "+g[5]+" "+g[3]).addClass(g[4]))})}},c=function(){return"object"!=typeof R(this)||R(this).length<1?a:this},d=function(e){e.autoDraggerLength=!(-1<R.inArray(e.theme,["rounded","rounded-dark","rounded-dots","rounded-dots-dark"]))&&e.autoDraggerLength,e.autoExpandScrollbar=!(-1<R.inArray(e.theme,["rounded-dots","rounded-dots-dark","3d","3d-dark","3d-thick","3d-thick-dark","inset","inset-dark","inset-2","inset-2-dark","inset-3","inset-3-dark"]))&&e.autoExpandScrollbar,e.scrollButtons.enable=!(-1<R.inArray(e.theme,["minimal","minimal-dark"]))&&e.scrollButtons.enable,e.autoHideScrollbar=-1<R.inArray(e.theme,["minimal","minimal-dark"])||e.autoHideScrollbar,e.scrollbarPosition=-1<R.inArray(e.theme,["minimal","minimal-dark"])?"outside":e.scrollbarPosition},u=function(e){i[e]&&(clearTimeout(i[e]),ee(i,e))},h=function(e){return"yx"===e||"xy"===e||"auto"===e?"yx":"x"===e||"horizontal"===e?"x":"y"},m=function(e){return"stepped"===e||"pixels"===e||"step"===e||"click"===e?"stepped":"stepless"},v=function(){var e=R(this),t=e.data(W),o=t.opt,a=o.autoExpandScrollbar?" "+g[1]+"_expand":"",n=["<div id='mCSB_"+t.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+t.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+a+"'><div class='"+g[12]+"'><div id='mCSB_"+t.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+t.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+t.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+a+"'><div class='"+g[12]+"'><div id='mCSB_"+t.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],i="yx"===o.axis?"mCSB_vertical_horizontal":"x"===o.axis?"mCSB_horizontal":"mCSB_vertical",r="yx"===o.axis?n[0]+n[1]:"x"===o.axis?n[1]:n[0],l="yx"===o.axis?"<div id='mCSB_"+t.idx+"_container_wrapper' class='mCSB_container_wrapper' />":"",a=o.autoHideScrollbar?" "+g[6]:"",n="x"!==o.axis&&"rtl"===t.langDir?" "+g[7]:"";o.setWidth&&e.css("width",o.setWidth),o.setHeight&&e.css("height",o.setHeight),o.setLeft="y"!==o.axis&&"rtl"===t.langDir?"989999px":o.setLeft,e.addClass(s+" _"+W+"_"+t.idx+a+n).wrapInner("<div id='mCSB_"+t.idx+"' class='mCustomScrollBox mCS-"+o.theme+" "+i+"'><div id='mCSB_"+t.idx+"_container' class='mCSB_container' style='position:relative; top:"+o.setTop+"; left:"+o.setLeft+";' dir='"+t.langDir+"' /></div>");n=R("#mCSB_"+t.idx),i=R("#mCSB_"+t.idx+"_container");"y"===o.axis||o.advanced.autoExpandHorizontalScroll||i.css("width",x(i)),"outside"===o.scrollbarPosition?("static"===e.css("position")&&e.css("position","relative"),e.css("overflow","visible"),n.addClass("mCSB_outside").after(r)):(n.addClass("mCSB_inside").append(r),i.wrap(l)),w.call(this);t=[R("#mCSB_"+t.idx+"_dragger_vertical"),R("#mCSB_"+t.idx+"_dragger_horizontal")];t[0].css("min-height",t[0].height()),t[1].css("min-width",t[1].width())},x=function(e){var t=[e[0].scrollWidth,Math.max.apply(Math,e.children().map(function(){return R(this).outerWidth(!0)}).get())],e=e.parent().width();return e<t[0]?t[0]:e<t[1]?t[1]:"100%"},_=function(){var e=R(this).data(W),t=e.opt,o=R("#mCSB_"+e.idx+"_container");t.advanced.autoExpandHorizontalScroll&&"y"!==t.axis&&(o.css({width:"auto","min-width":0,"overflow-x":"scroll"}),e=Math.ceil(o[0].scrollWidth),3===t.advanced.autoExpandHorizontalScroll||2!==t.advanced.autoExpandHorizontalScroll&&e>o.parent().width()?o.css({width:e,"min-width":"100%","overflow-x":"inherit"}):o.css({"overflow-x":"inherit",position:"absolute"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({width:Math.ceil(o[0].getBoundingClientRect().right+.4)-Math.floor(o[0].getBoundingClientRect().left),"min-width":"100%",position:"relative"}).unwrap())},w=function(){var e=R(this).data(W),t=e.opt,o=R(".mCSB_"+e.idx+"_scrollbar:first"),e=ae(t.scrollButtons.tabindex)?"tabindex='"+t.scrollButtons.tabindex+"'":"",e=["<a href='#' class='"+g[13]+"' "+e+" />","<a href='#' class='"+g[14]+"' "+e+" />","<a href='#' class='"+g[15]+"' "+e+" />","<a href='#' class='"+g[16]+"' "+e+" />"],e=["x"===t.axis?e[2]:e[0],"x"===t.axis?e[3]:e[1],e[2],e[3]];t.scrollButtons.enable&&o.prepend(e[0]).append(e[1]).next(".mCSB_scrollTools").prepend(e[2]).append(e[3])},S=function(){var e=R(this).data(W),t=R("#mCSB_"+e.idx),o=R("#mCSB_"+e.idx+"_container"),a=[R("#mCSB_"+e.idx+"_dragger_vertical"),R("#mCSB_"+e.idx+"_dragger_horizontal")],e=[t.height()/o.outerHeight(!1),t.width()/o.outerWidth(!1)],t=[parseInt(a[0].css("min-height")),Math.round(e[0]*a[0].parent().height()),parseInt(a[1].css("min-width")),Math.round(e[1]*a[1].parent().width())],o=p&&t[1]<t[0]?t[0]:t[1],e=p&&t[3]<t[2]?t[2]:t[3];a[0].css({height:o,"max-height":a[0].parent().height()-10}).find(".mCSB_dragger_bar").css({"line-height":t[0]+"px"}),a[1].css({width:e,"max-width":a[1].parent().width()-10})},b=function(){var e=R(this).data(W),t=R("#mCSB_"+e.idx),o=R("#mCSB_"+e.idx+"_container"),a=[R("#mCSB_"+e.idx+"_dragger_vertical"),R("#mCSB_"+e.idx+"_dragger_horizontal")],t=[o.outerHeight(!1)-t.height(),o.outerWidth(!1)-t.width()],a=[t[0]/(a[0].parent().height()-a[0].height()),t[1]/(a[1].parent().width()-a[1].width())];e.scrollRatio={y:a[0],x:a[1]}},y=function(e,t,o){var a=o?g[0]+"_expanded":"",o=e.closest(".mCSB_scrollTools");"active"===t?(e.toggleClass(g[0]+" "+a),o.toggleClass(g[1]),e[0]._draggable=e[0]._draggable?0:1):e[0]._draggable||("hide"===t?(e.removeClass(g[0]),o.removeClass(g[1])):(e.addClass(g[0]),o.addClass(g[1])))},C=function(){var e=R(this).data(W),t=R("#mCSB_"+e.idx),o=R("#mCSB_"+e.idx+"_container"),a=null==e.overflowed?o.height():o.outerHeight(!1),n=null==e.overflowed?o.width():o.outerWidth(!1),e=o[0].scrollHeight,o=o[0].scrollWidth;return a<e&&(a=e),n<o&&(n=o),[a>t.height(),n>t.width()]},B=function(){var e=R(this),t=e.data(W),o=t.opt,a=R("#mCSB_"+t.idx),n=R("#mCSB_"+t.idx+"_container"),i=[R("#mCSB_"+t.idx+"_dragger_vertical"),R("#mCSB_"+t.idx+"_dragger_horizontal")];J(e),("x"!==o.axis&&!t.overflowed[0]||"y"===o.axis&&t.overflowed[0])&&(i[0].add(n).css("top",0),K(e,"_resetY")),("y"!==o.axis&&!t.overflowed[1]||"x"===o.axis&&t.overflowed[1])&&(o=dx=0,"rtl"===t.langDir&&(o=a.width()-n.outerWidth(!1),dx=Math.abs(o/t.scrollRatio.x)),n.css("left",o),i[1].css("left",dx),K(e,"_resetX"))},T=function(){var t,o=R(this),e=o.data(W),a=e.opt;e.bindEvents||(r.call(this),a.contentTouchScroll&&O.call(this),I.call(this),a.mouseWheel.enable&&function e(){t=setTimeout(function(){R.event.special.mousewheel?(clearTimeout(t),D.call(o[0])):e()},100)}(),F.call(this),j.call(this),a.advanced.autoScrollOnFocus&&q.call(this),a.scrollButtons.enable&&Y.call(this),a.keyboard.enable&&X.call(this),e.bindEvents=!0)},k=function(){var e=R(this),t=e.data(W),o=t.opt,a=W+"_"+t.idx,n=".mCSB_"+t.idx+"_scrollbar",i=R("#mCSB_"+t.idx+",#mCSB_"+t.idx+"_container,#mCSB_"+t.idx+"_container_wrapper,"+n+" ."+g[12]+",#mCSB_"+t.idx+"_dragger_vertical,#mCSB_"+t.idx+"_dragger_horizontal,"+n+">a"),n=R("#mCSB_"+t.idx+"_container");o.advanced.releaseDraggableSelectors&&i.add(R(o.advanced.releaseDraggableSelectors)),o.advanced.extraDraggableSelectors&&i.add(R(o.advanced.extraDraggableSelectors)),t.bindEvents&&(R(document).add(R(!H()||top.document)).unbind("."+a),i.each(function(){R(this).unbind("."+a)}),clearTimeout(e[0]._focusTimeout),ee(e[0],"_focusTimeout"),clearTimeout(t.sequential.step),ee(t.sequential,"step"),clearTimeout(n[0].onCompleteTimeout),ee(n[0],"onCompleteTimeout"),t.bindEvents=!1)},M=function(e){var t=R(this),o=t.data(W),a=o.opt,n=R("#mCSB_"+o.idx+"_container_wrapper"),i=n.length?n:R("#mCSB_"+o.idx+"_container"),r=[R("#mCSB_"+o.idx+"_scrollbar_vertical"),R("#mCSB_"+o.idx+"_scrollbar_horizontal")],n=[r[0].find(".mCSB_dragger"),r[1].find(".mCSB_dragger")];"x"!==a.axis&&(o.overflowed[0]&&!e?(r[0].add(n[0]).add(r[0].children("a")).css("display","block"),i.removeClass(g[8]+" "+g[10])):(a.alwaysShowScrollbar?(2!==a.alwaysShowScrollbar&&n[0].css("display","none"),i.removeClass(g[10])):(r[0].css("display","none"),i.addClass(g[10])),i.addClass(g[8]))),"y"!==a.axis&&(o.overflowed[1]&&!e?(r[1].add(n[1]).add(r[1].children("a")).css("display","block"),i.removeClass(g[9]+" "+g[11])):(a.alwaysShowScrollbar?(2!==a.alwaysShowScrollbar&&n[1].css("display","none"),i.removeClass(g[11])):(r[1].css("display","none"),i.addClass(g[11])),i.addClass(g[9]))),o.overflowed[0]||o.overflowed[1]?t.removeClass(g[5]):t.addClass(g[5])},z=function(e){var t=e.type,o=e.target.ownerDocument!==document&&null!==frameElement?[R(frameElement).offset().top,R(frameElement).offset().left]:null,a=H()&&e.target.ownerDocument!==top.document&&null!==frameElement?[R(e.view.frameElement).offset().top,R(e.view.frameElement).offset().left]:[0,0];switch(t){case"pointerdown":case"MSPointerDown":case"pointermove":case"MSPointerMove":case"pointerup":case"MSPointerUp":return o?[e.originalEvent.pageY-o[0]+a[0],e.originalEvent.pageX-o[1]+a[1],!1]:[e.originalEvent.pageY,e.originalEvent.pageX,!1];case"touchstart":case"touchmove":case"touchend":var n=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],i=e.originalEvent.touches.length||e.originalEvent.changedTouches.length;return e.target.ownerDocument!==document?[n.screenY,n.screenX,1<i]:[n.pageY,n.pageX,1<i];default:return o?[e.pageY-o[0]+a[0],e.pageX-o[1]+a[1],!1]:[e.pageY,e.pageX,!1]}},r=function(){var i,n,r,l=R(this),s=l.data(W),c=s.opt,e=W+"_"+s.idx,d=["mCSB_"+s.idx+"_dragger_vertical","mCSB_"+s.idx+"_dragger_horizontal"],u=R("#mCSB_"+s.idx+"_container"),t=R("#"+d[0]+",#"+d[1]),o=c.advanced.releaseDraggableSelectors?t.add(R(c.advanced.releaseDraggableSelectors)):t,a=c.advanced.extraDraggableSelectors?R(!H()||top.document).add(R(c.advanced.extraDraggableSelectors)):R(!H()||top.document);function f(e,t,o,a){var n;u[0].idleTimer=c.scrollInertia<233?250:0,o=i.attr("id")===d[1]?(n="x",(i[0].offsetLeft-t+a)*s.scrollRatio.x):(n="y",(i[0].offsetTop-e+o)*s.scrollRatio.y),K(l,o.toString(),{dir:n,drag:!0})}t.bind("contextmenu."+e,function(e){e.preventDefault()}).bind("mousedown."+e+" touchstart."+e+" pointerdown."+e+" MSPointerDown."+e,function(e){var t,o,a;e.stopImmediatePropagation(),e.preventDefault(),te(e)&&(A=!0,p&&(document.onselectstart=function(){return!1}),P.call(u,!1),J(l),a=(i=R(this)).offset(),t=z(e)[0]-a.top,o=z(e)[1]-a.left,e=i.height()+a.top,a=i.width()+a.left,t<e&&0<t&&o<a&&0<o&&(n=t,r=o),y(i,"active",c.autoExpandScrollbar))}).bind("touchmove."+e,function(e){e.stopImmediatePropagation(),e.preventDefault();var t=i.offset(),o=z(e)[0]-t.top,t=z(e)[1]-t.left;f(n,r,o,t)}),R(document).add(a).bind("mousemove."+e+" pointermove."+e+" MSPointerMove."+e,function(e){var t,o;i&&(o=i.offset(),t=z(e)[0]-o.top,o=z(e)[1]-o.left,n===t&&r===o||f(n,r,t,o))}).add(o).bind("mouseup."+e+" touchend."+e+" pointerup."+e+" MSPointerUp."+e,function(e){i&&(y(i,"active",c.autoExpandScrollbar),i=null),A=!1,p&&(document.onselectstart=null),P.call(u,!0)})},O=function(){var r,l,s,i,c,d,u,f,h,m,p,g,v=R(this),x=v.data(W),_=x.opt,e=W+"_"+x.idx,w=R("#mCSB_"+x.idx),S=R("#mCSB_"+x.idx+"_container"),b=[R("#mCSB_"+x.idx+"_dragger_vertical"),R("#mCSB_"+x.idx+"_dragger_horizontal")],C=[],y=[],B=0,T="yx"===_.axis?"none":"all",k=[],t=S.find("iframe"),o=["touchstart."+e+" pointerdown."+e+" MSPointerDown."+e,"touchmove."+e+" pointermove."+e+" MSPointerMove."+e,"touchend."+e+" pointerup."+e+" MSPointerUp."+e],M=void 0!==document.body.style.touchAction&&""!==document.body.style.touchAction;function a(e){var t;!oe(e)||A||z(e)[2]?L=0:(g=p=0,r=L=1,v.removeClass("mCS_touch_action"),t=S.offset(),l=z(e)[0]-t.top,s=z(e)[1]-t.left,k=[z(e)[0],z(e)[1]])}function n(e){var t,o,a,n,i;!oe(e)||A||z(e)[2]||(_.documentTouchScroll||e.preventDefault(),e.stopImmediatePropagation(),g&&!p||r&&(u=$(),a=w.offset(),t=z(e)[0]-a.top,o=z(e)[1]-a.left,a="mcsLinearOut",C.push(t),y.push(o),k[2]=Math.abs(z(e)[0]-k[0]),k[3]=Math.abs(z(e)[1]-k[1]),x.overflowed[0]&&(n=b[0].parent().height()-b[0].height(),n=0<l-t&&t-l>-(n*x.scrollRatio.y)&&(2*k[3]<k[2]||"yx"===_.axis)),x.overflowed[1]&&(i=b[1].parent().width()-b[1].width(),i=0<s-o&&o-s>-(i*x.scrollRatio.x)&&(2*k[2]<k[3]||"yx"===_.axis)),n||i?(M||e.preventDefault(),p=1):(g=1,v.addClass("mCS_touch_action")),M&&e.preventDefault(),h="yx"===_.axis?[l-t,s-o]:"x"===_.axis?[null,s-o]:[l-t,null],S[0].idleTimer=250,x.overflowed[0]&&E(h[0],B,a,"y","all",!0),x.overflowed[1]&&E(h[1],B,a,"x",T,!0)))}function O(e){var t;!oe(e)||A||z(e)[2]?L=0:(L=1,e.stopImmediatePropagation(),J(v),d=$(),t=w.offset(),i=z(e)[0]-t.top,c=z(e)[1]-t.left,C=[],y=[])}function I(e){var t,o,a,n;!oe(e)||A||z(e)[2]||(r=0,e.stopImmediatePropagation(),g=p=0,f=$(),a=w.offset(),t=z(e)[0]-a.top,n=z(e)[1]-a.left,30<f-u||(o="mcsEaseOut",a=(e=(m=1e3/(f-d))<2.5)?[C[C.length-2],y[y.length-2]]:[0,0],f=e?[t-a[0],n-a[1]]:[t-i,n-c],n=[Math.abs(f[0]),Math.abs(f[1])],m=e?[Math.abs(f[0]/4),Math.abs(f[1]/4)]:[m,m],e=[Math.abs(S[0].offsetTop)-f[0]*D(n[0]/m[0],m[0]),Math.abs(S[0].offsetLeft)-f[1]*D(n[1]/m[1],m[1])],h="yx"===_.axis?[e[0],e[1]]:"x"===_.axis?[null,e[1]]:[e[0],null],m=[4*n[0]+_.scrollInertia,4*n[1]+_.scrollInertia],e=parseInt(_.contentTouchScroll)||0,h[0]=e<n[0]?h[0]:0,h[1]=e<n[1]?h[1]:0,x.overflowed[0]&&E(h[0],m[0],o,"y",T,!1),x.overflowed[1]&&E(h[1],m[1],o,"x",T,!1)))}function D(e,t){var o=[1.5*t,2*t,t/1.5,t/2];return 90<e?4<t?o[0]:o[3]:60<e?3<t?o[3]:o[2]:30<e?8<t?o[1]:6<t?o[0]:4<t?t:o[2]:8<t?t:o[3]}function E(e,t,o,a,n,i){e&&K(v,e.toString(),{dur:t,scrollEasing:o,dir:a,overwrite:n,drag:i})}S.bind(o[0],function(e){a(e)}).bind(o[1],function(e){n(e)}),w.bind(o[0],function(e){O(e)}).bind(o[2],function(e){I(e)}),t.length&&t.each(function(){R(this).bind("load",function(){H(this)&&R(this.contentDocument||this.contentWindow.document).bind(o[0],function(e){a(e),O(e)}).bind(o[1],function(e){n(e)}).bind(o[2],function(e){I(e)})})})},I=function(){var a,n=R(this),i=n.data(W),r=i.opt,l=i.sequential,e=W+"_"+i.idx,s=R("#mCSB_"+i.idx+"_container"),c=s.parent();function d(e,t,o){l.type=o&&a?"stepped":"stepless",l.scrollAmount=10,N(n,e,t,"mcsLinearOut",o?60:null)}s.bind("mousedown."+e,function(e){L||a||(a=1,A=!0)}).add(document).bind("mousemove."+e,function(e){var t,o;!L&&a&&(window.getSelection?window.getSelection().toString():document.selection&&"Control"!=document.selection.type&&document.selection.createRange().text)&&(o=s.offset(),t=z(e)[0]-o.top+s[0].offsetTop,o=z(e)[1]-o.left+s[0].offsetLeft,0<t&&t<c.height()&&0<o&&o<c.width()?l.step&&d("off",null,"stepped"):("x"!==r.axis&&i.overflowed[0]&&(t<0?d("on",38):t>c.height()&&d("on",40)),"y"!==r.axis&&i.overflowed[1]&&(o<0?d("on",37):o>c.width()&&d("on",39))))}).bind("mouseup."+e+" dragend."+e,function(e){L||(a&&(a=0,d("off",null)),A=!1)})},D=function(){var d,u,f,e,h,m,t;function o(e,t){var o,a,n,i,r,l,s,c;J(d),U(d,e.target)||(o="auto"!==f.mouseWheel.deltaFactor?parseInt(f.mouseWheel.deltaFactor):!(p&&e.deltaFactor<100)&&e.deltaFactor||100,a=f.scrollInertia,t="x"===f.axis||"x"===f.mouseWheel.axis?(n="x",i=[Math.round(o*u.scrollRatio.x),parseInt(f.mouseWheel.scrollAmount)],r="auto"!==f.mouseWheel.scrollAmount?i[1]:i[0]>=h.width()?.9*h.width():i[0],l=Math.abs(R("#mCSB_"+u.idx+"_container")[0].offsetLeft),s=m[1][0].offsetLeft,c=m[1].parent().width()-m[1].width(),"y"===f.mouseWheel.axis?e.deltaY||t:e.deltaX):(n="y",i=[Math.round(o*u.scrollRatio.y),parseInt(f.mouseWheel.scrollAmount)],r="auto"!==f.mouseWheel.scrollAmount?i[1]:i[0]>=h.height()?.9*h.height():i[0],l=Math.abs(R("#mCSB_"+u.idx+"_container")[0].offsetTop),s=m[0][0].offsetTop,c=m[0].parent().height()-m[0].height(),e.deltaY||t),"y"===n&&!u.overflowed[0]||"x"===n&&!u.overflowed[1]||((f.mouseWheel.invert||e.webkitDirectionInvertedFromDevice)&&(t=-t),f.mouseWheel.normalizeDelta&&(t=t<0?-1:1),(0<t&&0!==s||t<0&&s!==c||f.mouseWheel.preventDefault)&&(e.stopImmediatePropagation(),e.preventDefault()),e.deltaFactor<5&&!f.mouseWheel.normalizeDelta&&(r=e.deltaFactor,a=17),K(d,(l-t*r).toString(),{dir:n,dur:a})))}R(this).data(W)&&(d=R(this),u=d.data(W),f=u.opt,e=W+"_"+u.idx,h=R("#mCSB_"+u.idx),m=[R("#mCSB_"+u.idx+"_dragger_vertical"),R("#mCSB_"+u.idx+"_dragger_horizontal")],(t=R("#mCSB_"+u.idx+"_container").find("iframe")).length&&t.each(function(){R(this).bind("load",function(){H(this)&&R(this.contentDocument||this.contentWindow.document).bind("mousewheel."+e,function(e,t){o(e,t)})})}),h.bind("mousewheel."+e,function(e,t){o(e,t)}))},E=new Object,H=function(e){var t=!1,o=!1,a=null;if(void 0===e?o="#empty":void 0!==R(e).attr("id")&&(o=R(e).attr("id")),!1!==o&&void 0!==E[o])return E[o];if(e){try{a=(e.contentDocument||e.contentWindow.document).body.innerHTML}catch(e){}t=null!==a}else{try{a=top.document.body.innerHTML}catch(e){}t=null!==a}return!1!==o&&(E[o]=t),t},P=function(e){var t=this.find("iframe");t.length&&(e=e?"auto":"none",t.css("pointer-events",e))},U=function(e,t){var o=t.nodeName.toLowerCase(),e=e.data(W).opt.mouseWheel.disableOver;return-1<R.inArray(o,e)&&!(-1<R.inArray(o,["select","textarea"])&&!R(t).is(":focus"))},F=function(){var r,l=R(this),s=l.data(W),e=W+"_"+s.idx,c=R("#mCSB_"+s.idx+"_container"),d=c.parent();R(".mCSB_"+s.idx+"_scrollbar ."+g[12]).bind("mousedown."+e+" touchstart."+e+" pointerdown."+e+" MSPointerDown."+e,function(e){A=!0,R(e.target).hasClass("mCSB_dragger")||(r=1)}).bind("touchend."+e+" pointerup."+e+" MSPointerUp."+e,function(e){A=!1}).bind("click."+e,function(e){if(r&&(r=0,R(e.target).hasClass(g[12])||R(e.target).hasClass("mCSB_draggerRail"))){J(l);var t=R(this),o=t.find(".mCSB_dragger");if(0<t.parent(".mCSB_scrollTools_horizontal").length){if(!s.overflowed[1])return;var a="x",n=e.pageX>o.offset().left?-1:1,i=Math.abs(c[0].offsetLeft)-n*(.9*d.width())}else{if(!s.overflowed[0])return;a="y",n=e.pageY>o.offset().top?-1:1,i=Math.abs(c[0].offsetTop)-n*(.9*d.height())}K(l,i.toString(),{dir:a,scrollEasing:"mcsEaseInOut"})}})},q=function(){var n=R(this),e=n.data(W),i=e.opt,t=W+"_"+e.idx,r=R("#mCSB_"+e.idx+"_container"),l=r.parent();r.bind("focusin."+t,function(e){var a=R(document.activeElement),t=r.find(".mCustomScrollBox").length;a.is(i.advanced.autoScrollOnFocus)&&(J(n),clearTimeout(n[0]._focusTimeout),n[0]._focusTimer=t?17*t:0,n[0]._focusTimeout=setTimeout(function(){var e=[ne(a)[0],ne(a)[1]],t=[r[0].offsetTop,r[0].offsetLeft],o=[0<=t[0]+e[0]&&t[0]+e[0]<l.height()-a.outerHeight(!1),0<=t[1]+e[1]&&t[0]+e[1]<l.width()-a.outerWidth(!1)],t="yx"!==i.axis||o[0]||o[1]?"all":"none";"x"===i.axis||o[0]||K(n,e[0].toString(),{dir:"y",scrollEasing:"mcsEaseInOut",overwrite:t,dur:0}),"y"===i.axis||o[1]||K(n,e[1].toString(),{dir:"x",scrollEasing:"mcsEaseInOut",overwrite:t,dur:0})},n[0]._focusTimer))})},j=function(){var t=R(this).data(W),e=W+"_"+t.idx,o=R("#mCSB_"+t.idx+"_container").parent();o.bind("scroll."+e,function(e){0===o.scrollTop()&&0===o.scrollLeft()||R(".mCSB_"+t.idx+"_scrollbar").css("visibility","hidden")})},Y=function(){var a=R(this),n=a.data(W),i=n.opt,r=n.sequential,e=W+"_"+n.idx,t=".mCSB_"+n.idx+"_scrollbar";R(t+">a").bind("contextmenu."+e,function(e){e.preventDefault()}).bind("mousedown."+e+" touchstart."+e+" pointerdown."+e+" MSPointerDown."+e+" mouseup."+e+" touchend."+e+" pointerup."+e+" MSPointerUp."+e+" mouseout."+e+" pointerout."+e+" MSPointerOut."+e+" click."+e,function(e){if(e.preventDefault(),te(e)){var t=R(this).attr("class");switch(r.type=i.scrollButtons.scrollType,e.type){case"mousedown":case"touchstart":case"pointerdown":case"MSPointerDown":if("stepped"===r.type)return;A=!0,n.tweenRunning=!1,o("on",t);break;case"mouseup":case"touchend":case"pointerup":case"MSPointerUp":case"mouseout":case"pointerout":case"MSPointerOut":if("stepped"===r.type)return;A=!1,r.dir&&o("off",t);break;case"click":if("stepped"!==r.type||n.tweenRunning)return;o("on",t)}}function o(e,t){r.scrollAmount=i.scrollButtons.scrollAmount,N(a,e,t)}})},X=function(){var r=R(this),l=r.data(W),s=l.opt,c=l.sequential,e=W+"_"+l.idx,t=R("#mCSB_"+l.idx),d=R("#mCSB_"+l.idx+"_container"),u=d.parent(),f="input,textarea,select,datalist,keygen,[contenteditable='true']",o=d.find("iframe"),a=["blur."+e+" keydown."+e+" keyup."+e];function n(e){switch(e.type){case"blur":l.tweenRunning&&c.dir&&i("off",null);break;case"keydown":case"keyup":var t,o,a=e.keyCode||e.which,n="on";if("x"!==s.axis&&(38===a||40===a)||"y"!==s.axis&&(37===a||39===a)){if((38===a||40===a)&&!l.overflowed[0]||(37===a||39===a)&&!l.overflowed[1])return;"keyup"===e.type&&(n="off"),R(document.activeElement).is(f)||(e.preventDefault(),e.stopImmediatePropagation(),i(n,a))}else 33===a||34===a?((l.overflowed[0]||l.overflowed[1])&&(e.preventDefault(),e.stopImmediatePropagation()),"keyup"===e.type&&(J(r),o=34===a?-1:1,o="x"===s.axis||"yx"===s.axis&&l.overflowed[1]&&!l.overflowed[0]?(t="x",Math.abs(d[0].offsetLeft)-o*(.9*u.width())):(t="y",Math.abs(d[0].offsetTop)-o*(.9*u.height())),K(r,o.toString(),{dir:t,scrollEasing:"mcsEaseInOut"}))):35!==a&&36!==a||R(document.activeElement).is(f)||((l.overflowed[0]||l.overflowed[1])&&(e.preventDefault(),e.stopImmediatePropagation()),"keyup"===e.type&&(o="x"===s.axis||"yx"===s.axis&&l.overflowed[1]&&!l.overflowed[0]?(t="x",35===a?Math.abs(u.width()-d.outerWidth(!1)):0):(t="y",35===a?Math.abs(u.height()-d.outerHeight(!1)):0),K(r,o.toString(),{dir:t,scrollEasing:"mcsEaseInOut"})))}function i(e,t){c.type=s.keyboard.scrollType,c.scrollAmount=s.keyboard.scrollAmount,"stepped"===c.type&&l.tweenRunning||N(r,e,t)}}o.length&&o.each(function(){R(this).bind("load",function(){H(this)&&R(this.contentDocument||this.contentWindow.document).bind(a[0],function(e){n(e)})})}),t.attr("tabindex","0").bind(a[0],function(e){n(e)})},N=function(r,e,t,l,s){var c=r.data(W),d=c.opt,u=c.sequential,f=R("#mCSB_"+c.idx+"_container"),o="stepped"===u.type,h=d.scrollInertia<26?26:d.scrollInertia,m=d.scrollInertia<1?17:d.scrollInertia;switch(e){case"on":if(u.dir=[t===g[16]||t===g[15]||39===t||37===t?"x":"y",t===g[13]||t===g[15]||38===t||37===t?-1:1],J(r),ae(t)&&"stepped"===u.type)return;p(o);break;case"off":clearTimeout(u.step),ee(u,"step"),J(r),(o||c.tweenRunning&&u.dir)&&p(!0)}function p(e){d.snapAmount&&(u.scrollAmount=d.snapAmount instanceof Array?"x"===u.dir[0]?d.snapAmount[1]:d.snapAmount[0]:d.snapAmount);var t="stepped"!==u.type,o=s||(e?t?h/1.5:m:1e3/60),a=e?t?7.5:40:2.5,n=[Math.abs(f[0].offsetTop),Math.abs(f[0].offsetLeft)],i=[10<c.scrollRatio.y?10:c.scrollRatio.y,10<c.scrollRatio.x?10:c.scrollRatio.x],i="x"===u.dir[0]?n[1]+u.dir[1]*(i[1]*a):n[0]+u.dir[1]*(i[0]*a),a="x"===u.dir[0]?n[1]+u.dir[1]*parseInt(u.scrollAmount):n[0]+u.dir[1]*parseInt(u.scrollAmount),a="auto"!==u.scrollAmount?a:i,i=l||(e?t?"mcsLinearOut":"mcsEaseInOut":"mcsLinear"),t=!!e;e&&o<17&&(a="x"===u.dir[0]?n[1]:n[0]),K(r,a.toString(),{dir:u.dir[0],scrollEasing:i,dur:o,onComplete:t}),e?u.dir=!1:(clearTimeout(u.step),u.step=setTimeout(function(){p()},o))}},V=function(e){var t=R(this).data(W).opt,o=[];return"function"==typeof e&&(e=e()),e instanceof Array?o=1<e.length?[e[0],e[1]]:"x"===t.axis?[null,e[0]]:[e[0],null]:(o[0]=e.y||(e.x||"x"===t.axis?null:e),o[1]=e.x||(e.y||"y"===t.axis?null:e)),"function"==typeof o[0]&&(o[0]=o[0]()),"function"==typeof o[1]&&(o[1]=o[1]()),o},Q=function(e,t){if(null!=e&&void 0!==e){var o=R(this),a=o.data(W),n=a.opt,i=R("#mCSB_"+a.idx+"_container"),r=i.parent(),a=typeof e,l="x"===(t=t||("x"===n.axis?"x":"y"))?i.outerWidth(!1)-r.width():i.outerHeight(!1)-r.height(),s="x"===t?i[0].offsetLeft:i[0].offsetTop,c="x"===t?"left":"top";switch(a){case"function":return e();case"object":return(u=e.jquery?e:R(e)).length?"x"===t?ne(u)[1]:ne(u)[0]:void 0;case"string":case"number":if(ae(e))return Math.abs(e);if(-1!==e.indexOf("%"))return Math.abs(l*parseInt(e)/100);if(-1!==e.indexOf("-="))return Math.abs(s-parseInt(e.split("-=")[1]));if(-1!==e.indexOf("+=")){var d=s+parseInt(e.split("+=")[1]);return 0<=d?0:Math.abs(d)}if(-1!==e.indexOf("px")&&ae(e.split("px")[0]))return Math.abs(e.split("px")[0]);if("top"===e||"left"===e)return 0;if("bottom"===e)return Math.abs(r.height()-i.outerHeight(!1));if("right"===e)return Math.abs(r.width()-i.outerWidth(!1));if("first"!==e&&"last"!==e)return R(e).length?"x"===t?ne(R(e))[1]:ne(R(e))[0]:(i.css(c,e),void f.update.call(null,o[0]));var u=i.find(":"+e);return"x"===t?ne(u)[1]:ne(u)[0]}}},G=function(e){var t=R(this),o=t.data(W),a=o.opt,n=R("#mCSB_"+o.idx+"_container");if(e)return clearTimeout(n[0].autoUpdate),void ee(n[0],"autoUpdate");function i(e){var t,o,a;R(e).hasClass(g[2])?l():((t=new Image).onload=(o=t,a=function(){this.onload=null,R(e).addClass(g[2]),l(2)},function(){return a.apply(o,arguments)}),t.src=e.src)}function r(){!0===a.advanced.updateOnSelectorChange&&(a.advanced.updateOnSelectorChange="*");var e=0,t=n.find(a.advanced.updateOnSelectorChange);return a.advanced.updateOnSelectorChange&&0<t.length&&t.each(function(){e+=this.offsetHeight+this.offsetWidth}),e}function l(e){clearTimeout(n[0].autoUpdate),f.update.call(null,t[0],e)}!function e(){clearTimeout(n[0].autoUpdate);if(0===t.parents("html").length)return void(t=null);n[0].autoUpdate=setTimeout(function(){return a.advanced.updateOnSelectorChange&&(o.poll.change.n=r(),o.poll.change.n!==o.poll.change.o)?(o.poll.change.o=o.poll.change.n,void l(3)):a.advanced.updateOnContentResize&&(o.poll.size.n=t[0].scrollHeight+t[0].scrollWidth+n[0].offsetHeight+t[0].offsetHeight+t[0].offsetWidth,o.poll.size.n!==o.poll.size.o)?(o.poll.size.o=o.poll.size.n,void l(1)):!a.advanced.updateOnImageLoad||"auto"===a.advanced.updateOnImageLoad&&"y"===a.axis||(o.poll.img.n=n.find("img").length,o.poll.img.n===o.poll.img.o)?void((a.advanced.updateOnSelectorChange||a.advanced.updateOnContentResize||a.advanced.updateOnImageLoad)&&e()):(o.poll.img.o=o.poll.img.n,void n.find("img").each(function(){i(this)}))},a.advanced.autoUpdateTimeout)}()},J=function(e){e=e.data(W);R("#mCSB_"+e.idx+"_container,#mCSB_"+e.idx+"_container_wrapper,#mCSB_"+e.idx+"_dragger_vertical,#mCSB_"+e.idx+"_dragger_horizontal").each(function(){t.call(this)})},K=function(n,e,i){var t,o=n.data(W),a=o.opt,r={trigger:"internal",dir:"y",scrollEasing:"mcsEaseOut",drag:!1,dur:a.scrollInertia,overwrite:"all",callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},l=[(i=R.extend(r,i)).dur,i.drag?0:i.dur],s=R("#mCSB_"+o.idx),c=R("#mCSB_"+o.idx+"_container"),d=c.parent(),u=a.callbacks.onTotalScrollOffset?V.call(n,a.callbacks.onTotalScrollOffset):[0,0],f=a.callbacks.onTotalScrollBackOffset?V.call(n,a.callbacks.onTotalScrollBackOffset):[0,0];if(o.trigger=i.trigger,0===d.scrollTop()&&0===d.scrollLeft()||(R(".mCSB_"+o.idx+"_scrollbar").css("visibility","visible"),d.scrollTop(0).scrollLeft(0)),"_resetY"!==e||o.contentReset.y||(b("onOverflowYNone")&&a.callbacks.onOverflowYNone.call(n[0]),o.contentReset.y=1),"_resetX"!==e||o.contentReset.x||(b("onOverflowXNone")&&a.callbacks.onOverflowXNone.call(n[0]),o.contentReset.x=1),"_resetY"!==e&&"_resetX"!==e){switch(!o.contentReset.y&&n[0].mcs||!o.overflowed[0]||(b("onOverflowY")&&a.callbacks.onOverflowY.call(n[0]),o.contentReset.x=null),!o.contentReset.x&&n[0].mcs||!o.overflowed[1]||(b("onOverflowX")&&a.callbacks.onOverflowX.call(n[0]),o.contentReset.x=null),a.snapAmount&&(t=a.snapAmount instanceof Array?"x"===i.dir?a.snapAmount[1]:a.snapAmount[0]:a.snapAmount,r=e,d=t,t=a.snapOffset,e=Math.round(r/d)*d-t),i.dir){case"x":var h=R("#mCSB_"+o.idx+"_dragger_horizontal"),m="left",p=c[0].offsetLeft,g=[s.width()-c.outerWidth(!1),h.parent().width()-h.width()],v=[e,0===e?0:e/o.scrollRatio.x],x=u[1],_=f[1],w=0<x?x/o.scrollRatio.x:0,S=0<_?_/o.scrollRatio.x:0;break;case"y":h=R("#mCSB_"+o.idx+"_dragger_vertical"),m="top",p=c[0].offsetTop,g=[s.height()-c.outerHeight(!1),h.parent().height()-h.height()],v=[e,0===e?0:e/o.scrollRatio.y],x=u[0],_=f[0],w=0<x?x/o.scrollRatio.y:0,S=0<_?_/o.scrollRatio.y:0}v[1]<0||0===v[0]&&0===v[1]?v=[0,0]:v[1]>=g[1]?v=[g[0],g[1]]:v[0]=-v[0],n[0].mcs||(C(),b("onInit")&&a.callbacks.onInit.call(n[0])),clearTimeout(c[0].onCompleteTimeout),Z(h[0],m,Math.round(v[1]),l[1],i.scrollEasing),!o.tweenRunning&&(0===p&&0<=v[0]||p===g[0]&&v[0]<=g[0])||Z(c[0],m,Math.round(v[0]),l[0],i.scrollEasing,i.overwrite,{onStart:function(){i.callbacks&&i.onStart&&!o.tweenRunning&&(b("onScrollStart")&&(C(),a.callbacks.onScrollStart.call(n[0])),o.tweenRunning=!0,y(h),o.cbOffsets=[a.callbacks.alwaysTriggerOffsets||p>=g[0]+x,a.callbacks.alwaysTriggerOffsets||p<=-_])},onUpdate:function(){i.callbacks&&i.onUpdate&&b("whileScrolling")&&(C(),a.callbacks.whileScrolling.call(n[0]))},onComplete:function(){var e;i.callbacks&&i.onComplete&&("yx"===a.axis&&clearTimeout(c[0].onCompleteTimeout),e=c[0].idleTimer||0,c[0].onCompleteTimeout=setTimeout(function(){b("onScroll")&&(C(),a.callbacks.onScroll.call(n[0])),b("onTotalScroll")&&v[1]>=g[1]-w&&o.cbOffsets[0]&&(C(),a.callbacks.onTotalScroll.call(n[0])),b("onTotalScrollBack")&&v[1]<=S&&o.cbOffsets[1]&&(C(),a.callbacks.onTotalScrollBack.call(n[0])),o.tweenRunning=!1,c[0].idleTimer=0,y(h,"hide")},e))}})}function b(e){return o&&a.callbacks[e]&&"function"==typeof a.callbacks[e]}function C(){var e=[c[0].offsetTop,c[0].offsetLeft],t=[h[0].offsetTop,h[0].offsetLeft],o=[c.outerHeight(!1),c.outerWidth(!1)],a=[s.height(),s.width()];n[0].mcs={content:c,top:e[0],left:e[1],draggerTop:t[0],draggerLeft:t[1],topPct:Math.round(100*Math.abs(e[0])/(Math.abs(o[0])-a[0])),leftPct:Math.round(100*Math.abs(e[1])/(Math.abs(o[1])-a[1])),direction:i.dir}}},Z=function(e,t,o,a,n,i,r){e._mTween||(e._mTween={top:{},left:{}});var l,s,c=(r=r||{}).onStart||function(){},d=r.onUpdate||function(){},u=r.onComplete||function(){},f=$(),h=0,m=e.offsetTop,p=e.style,g=e._mTween[t];"left"===t&&(m=e.offsetLeft);var v=o-m;function x(){g.stop||(h||c.call(),h=$()-f,_(),h>=g.time&&(g.time=h>g.time?h+l-(h-g.time):h+l-1,g.time<h+1&&(g.time=h+1)),g.time<a?g.id=s(x):u.call())}function _(){0<a?(g.currVal=function(e,t,o,a,n){switch(n){case"linear":case"mcsLinear":return o*e/a+t;case"mcsLinearOut":return e/=a,e--,o*Math.sqrt(1-e*e)+t;case"easeInOutSmooth":return(e/=a/2)<1?o/2*e*e+t:-o/2*(--e*(e-2)-1)+t;case"easeInOutStrong":return(e/=a/2)<1?o/2*Math.pow(2,10*(e-1))+t:(e--,o/2*(2-Math.pow(2,-10*e))+t);case"easeInOut":case"mcsEaseInOut":return(e/=a/2)<1?o/2*e*e*e+t:o/2*((e-=2)*e*e+2)+t;case"easeOutSmooth":return e/=a,-o*(--e*e*e*e-1)+t;case"easeOutStrong":return o*(1-Math.pow(2,-10*e/a))+t;case"easeOut":case"mcsEaseOut":default:var i=(e/=a)*e,r=i*e;return t+o*(.499999999999997*r*i+-2.5*i*i+5.5*r+-6.5*i+4*e)}}(g.time,m,v,a,n),p[t]=Math.round(g.currVal)+"px"):p[t]=o+"px",d.call()}g.stop=0,"none"===i||null!=g.id&&(window.requestAnimationFrame?window.cancelAnimationFrame(g.id):clearTimeout(g.id),g.id=null),l=1e3/60,g.time=h+l,s=window.requestAnimationFrame||function(e){return _(),setTimeout(e,.01)},g.id=s(x)},$=function(){return window.performance&&window.performance.now?window.performance.now():window.performance&&window.performance.webkitNow?window.performance.webkitNow():Date.now?Date.now():(new Date).getTime()},t=function(){var e=this;e._mTween||(e._mTween={top:{},left:{}});for(var t=["top","left"],o=0;o<t.length;o++){var a=t[o];e._mTween[a].id&&(window.requestAnimationFrame?window.cancelAnimationFrame(e._mTween[a].id):clearTimeout(e._mTween[a].id),e._mTween[a].id=null,e._mTween[a].stop=1)}},ee=function(t,o){try{delete t[o]}catch(e){t[o]=null}},te=function(e){return!(e.which&&1!==e.which)},oe=function(e){e=e.originalEvent.pointerType;return!(e&&"touch"!==e&&2!==e)},ae=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},ne=function(e){var t=e.parents(".mCSB_container");return[e.offset().top-t.offset().top,e.offset().left-t.offset().left]},ie=function(){var e=function(){var e=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var t=0;t<e.length;t++)if(e[t]+"Hidden"in document)return e[t]+"Hidden";return null}();return!!e&&document[e]},R.fn[s]=function(e){return f[e]?f[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void R.error("Method "+e+" does not exist"):f.init.apply(this,arguments)},R[s]=function(e){return f[e]?f[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void R.error("Method "+e+" does not exist"):f.init.apply(this,arguments)},R[s].defaults=n,window[s]=!0,R(window).bind("load",function(){R(a)[s](),R.extend(R.expr[":"],{mcsInView:R.expr[":"].mcsInView||function(e){var t=R(e),o=t.parents(".mCSB_container");if(o.length)return e=o.parent(),0<=(o=[o[0].offsetTop,o[0].offsetLeft])[0]+ne(t)[0]&&o[0]+ne(t)[0]<e.height()-t.outerHeight(!1)&&0<=o[1]+ne(t)[1]&&o[1]+ne(t)[1]<e.width()-t.outerWidth(!1)},mcsInSight:R.expr[":"].mcsInSight||function(e,t,o){var a=R(e),n=a.parents(".mCSB_container"),e="exact"===o[3]?[[1,0],[1,0]]:[[.9,.1],[.6,.4]];if(n.length)return o=[a.outerHeight(!1),a.outerWidth(!1)],a=[n[0].offsetTop+ne(a)[0],n[0].offsetLeft+ne(a)[1]],n=[n.parent()[0].offsetHeight,n.parent()[0].offsetWidth],a[0]-n[0]*(e=[o[0]<n[0]?e[0]:e[1],o[1]<n[1]?e[0]:e[1]])[0][0]<0&&0<=a[0]+o[0]-n[0]*e[0][1]&&a[1]-n[1]*e[1][0]<0&&0<=a[1]+o[1]-n[1]*e[1][1]},mcsOverflow:R.expr[":"].mcsOverflow||function(e){e=R(e).data(W);if(e)return e.overflowed[0]||e.overflowed[1]}})})});