scrollbar-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzljY2JkMGVlNjY4NWU2MzgwYzY0ZGQ2OGNiNDg4YWJkODRlOTNhMw==
5
+ data.tar.gz: !binary |-
6
+ MGFhZDNhMTFhMzBmMTBjNDEwNzRlYTFhOTI1NzhiNzg0ODUzYzNhOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZjE5ZGY3YzE4ZWQ5MzNlYjA1M2I0NGZlMTY3YmY3ZDU2MmI5NmRkZTlkZjA3
10
+ ZTVkYTc2Mzk1MWE2Y2U1ZjgyOWEyYjY3MWI3ZTFmMDNhMDdmZTIyOWQ1ZDZj
11
+ YzA2Njc3OTgzYTA1MzNiNDcyMjk5YmIxOWMzYWViNTAzNDdlNzk=
12
+ data.tar.gz: !binary |-
13
+ M2FkMDE0YzZlNDEzZmY5NDVmYWIxNzgzZGU5NTViZGQyMzlhMzRlNWExNTU0
14
+ OTQ3MmVjNzBlOWQ1MGM2MmI0MWQyN2IzNTViZGI0Yzc4MGM1NWYyMDgwZDE1
15
+ OTdiMWFkZDY2M2MxOWQ1N2VkYWQxMzUzYjFjNzkyZjU1MjQ1ZmQ=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in scrollbar-rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 producao02
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ # scrollbar-rails
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,7 @@
1
+ /*!
2
+ Colorbox v1.5.9 - 2014-04-25
3
+ jQuery lightbox and modal window plugin
4
+ (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox
5
+ license: http://www.opensource.org/licenses/mit-license.php
6
+ */
7
+ (function(t,e,i){function n(i,n,o){var r=e.createElement(i);return n&&(r.id=Z+n),o&&(r.style.cssText=o),t(r)}function o(){return i.innerHeight?i.innerHeight:t(i).height()}function r(e,i){i!==Object(i)&&(i={}),this.cache={},this.el=e,this.value=function(e){var n;return void 0===this.cache[e]&&(n=t(this.el).attr("data-cbox-"+e),void 0!==n?this.cache[e]=n:void 0!==i[e]?this.cache[e]=i[e]:void 0!==X[e]&&(this.cache[e]=X[e])),this.cache[e]},this.get=function(e){var i=this.value(e);return t.isFunction(i)?i.call(this.el,this):i}}function h(t){var e=W.length,i=(z+t)%e;return 0>i?e+i:i}function a(t,e){return Math.round((/%/.test(t)?("x"===e?E.width():o())/100:1)*parseInt(t,10))}function s(t,e){return t.get("photo")||t.get("photoRegex").test(e)}function l(t,e){return t.get("retinaUrl")&&i.devicePixelRatio>1?e.replace(t.get("photoRegex"),t.get("retinaSuffix")):e}function d(t){"contains"in x[0]&&!x[0].contains(t.target)&&t.target!==v[0]&&(t.stopPropagation(),x.focus())}function c(t){c.str!==t&&(x.add(v).removeClass(c.str).addClass(t),c.str=t)}function g(e){z=0,e&&e!==!1?(W=t("."+te).filter(function(){var i=t.data(this,Y),n=new r(this,i);return n.get("rel")===e}),z=W.index(_.el),-1===z&&(W=W.add(_.el),z=W.length-1)):W=t(_.el)}function u(i){t(e).trigger(i),ae.triggerHandler(i)}function f(i){var o;if(!G){if(o=t(i).data("colorbox"),_=new r(i,o),g(_.get("rel")),!$){$=q=!0,c(_.get("className")),x.css({visibility:"hidden",display:"block",opacity:""}),L=n(se,"LoadedContent","width:0; height:0; overflow:hidden; visibility:hidden"),b.css({width:"",height:""}).append(L),D=T.height()+k.height()+b.outerHeight(!0)-b.height(),j=C.width()+H.width()+b.outerWidth(!0)-b.width(),A=L.outerHeight(!0),N=L.outerWidth(!0);var h=a(_.get("initialWidth"),"x"),s=a(_.get("initialHeight"),"y"),l=_.get("maxWidth"),f=_.get("maxHeight");_.w=(l!==!1?Math.min(h,a(l,"x")):h)-N-j,_.h=(f!==!1?Math.min(s,a(f,"y")):s)-A-D,L.css({width:"",height:_.h}),J.position(),u(ee),_.get("onOpen"),O.add(I).hide(),x.focus(),_.get("trapFocus")&&e.addEventListener&&(e.addEventListener("focus",d,!0),ae.one(re,function(){e.removeEventListener("focus",d,!0)})),_.get("returnFocus")&&ae.one(re,function(){t(_.el).focus()})}v.css({opacity:parseFloat(_.get("opacity"))||"",cursor:_.get("overlayClose")?"pointer":"",visibility:"visible"}).show(),_.get("closeButton")?B.html(_.get("close")).appendTo(b):B.appendTo("<div/>"),w()}}function p(){!x&&e.body&&(V=!1,E=t(i),x=n(se).attr({id:Y,"class":t.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),v=n(se,"Overlay").hide(),S=t([n(se,"LoadingOverlay")[0],n(se,"LoadingGraphic")[0]]),y=n(se,"Wrapper"),b=n(se,"Content").append(I=n(se,"Title"),R=n(se,"Current"),P=t('<button type="button"/>').attr({id:Z+"Previous"}),K=t('<button type="button"/>').attr({id:Z+"Next"}),F=n("button","Slideshow"),S),B=t('<button type="button"/>').attr({id:Z+"Close"}),y.append(n(se).append(n(se,"TopLeft"),T=n(se,"TopCenter"),n(se,"TopRight")),n(se,!1,"clear:left").append(C=n(se,"MiddleLeft"),b,H=n(se,"MiddleRight")),n(se,!1,"clear:left").append(n(se,"BottomLeft"),k=n(se,"BottomCenter"),n(se,"BottomRight"))).find("div div").css({"float":"left"}),M=n(se,!1,"position:absolute; width:9999px; visibility:hidden; display:none; max-width:none;"),O=K.add(P).add(R).add(F),t(e.body).append(v,x.append(y,M)))}function m(){function i(t){t.which>1||t.shiftKey||t.altKey||t.metaKey||t.ctrlKey||(t.preventDefault(),f(this))}return x?(V||(V=!0,K.click(function(){J.next()}),P.click(function(){J.prev()}),B.click(function(){J.close()}),v.click(function(){_.get("overlayClose")&&J.close()}),t(e).bind("keydown."+Z,function(t){var e=t.keyCode;$&&_.get("escKey")&&27===e&&(t.preventDefault(),J.close()),$&&_.get("arrowKey")&&W[1]&&!t.altKey&&(37===e?(t.preventDefault(),P.click()):39===e&&(t.preventDefault(),K.click()))}),t.isFunction(t.fn.on)?t(e).on("click."+Z,"."+te,i):t("."+te).live("click."+Z,i)),!0):!1}function w(){var e,o,r,h=J.prep,d=++le;if(q=!0,U=!1,u(he),u(ie),_.get("onLoad"),_.h=_.get("height")?a(_.get("height"),"y")-A-D:_.get("innerHeight")&&a(_.get("innerHeight"),"y"),_.w=_.get("width")?a(_.get("width"),"x")-N-j:_.get("innerWidth")&&a(_.get("innerWidth"),"x"),_.mw=_.w,_.mh=_.h,_.get("maxWidth")&&(_.mw=a(_.get("maxWidth"),"x")-N-j,_.mw=_.w&&_.w<_.mw?_.w:_.mw),_.get("maxHeight")&&(_.mh=a(_.get("maxHeight"),"y")-A-D,_.mh=_.h&&_.h<_.mh?_.h:_.mh),e=_.get("href"),Q=setTimeout(function(){S.show()},100),_.get("inline")){var c=t(e);r=t("<div>").hide().insertBefore(c),ae.one(he,function(){r.replaceWith(c)}),h(c)}else _.get("iframe")?h(" "):_.get("html")?h(_.get("html")):s(_,e)?(e=l(_,e),U=new Image,t(U).addClass(Z+"Photo").bind("error",function(){h(n(se,"Error").html(_.get("imgError")))}).one("load",function(){d===le&&setTimeout(function(){var e;t.each(["alt","longdesc","aria-describedby"],function(e,i){var n=t(_.el).attr(i)||t(_.el).attr("data-"+i);n&&U.setAttribute(i,n)}),_.get("retinaImage")&&i.devicePixelRatio>1&&(U.height=U.height/i.devicePixelRatio,U.width=U.width/i.devicePixelRatio),_.get("scalePhotos")&&(o=function(){U.height-=U.height*e,U.width-=U.width*e},_.mw&&U.width>_.mw&&(e=(U.width-_.mw)/U.width,o()),_.mh&&U.height>_.mh&&(e=(U.height-_.mh)/U.height,o())),_.h&&(U.style.marginTop=Math.max(_.mh-U.height,0)/2+"px"),W[1]&&(_.get("loop")||W[z+1])&&(U.style.cursor="pointer",U.onclick=function(){J.next()}),U.style.width=U.width+"px",U.style.height=U.height+"px",h(U)},1)}),U.src=e):e&&M.load(e,_.get("data"),function(e,i){d===le&&h("error"===i?n(se,"Error").html(_.get("xhrError")):t(this).contents())})}var v,x,y,b,T,C,H,k,W,E,L,M,S,I,R,F,K,P,B,O,_,D,j,A,N,z,U,$,q,G,Q,J,V,X={html:!1,photo:!1,iframe:!1,inline:!1,transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,opacity:.9,preloading:!0,className:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0,fastIframe:!0,open:!1,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",returnFocus:!0,trapFocus:!0,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,rel:function(){return this.rel},href:function(){return t(this).attr("href")},title:function(){return this.title}},Y="colorbox",Z="cbox",te=Z+"Element",ee=Z+"_open",ie=Z+"_load",ne=Z+"_complete",oe=Z+"_cleanup",re=Z+"_closed",he=Z+"_purge",ae=t("<a/>"),se="div",le=0,de={},ce=function(){function t(){clearTimeout(h)}function e(){(_.get("loop")||W[z+1])&&(t(),h=setTimeout(J.next,_.get("slideshowSpeed")))}function i(){F.html(_.get("slideshowStop")).unbind(s).one(s,n),ae.bind(ne,e).bind(ie,t),x.removeClass(a+"off").addClass(a+"on")}function n(){t(),ae.unbind(ne,e).unbind(ie,t),F.html(_.get("slideshowStart")).unbind(s).one(s,function(){J.next(),i()}),x.removeClass(a+"on").addClass(a+"off")}function o(){r=!1,F.hide(),t(),ae.unbind(ne,e).unbind(ie,t),x.removeClass(a+"off "+a+"on")}var r,h,a=Z+"Slideshow_",s="click."+Z;return function(){r?_.get("slideshow")||(ae.unbind(oe,o),o()):_.get("slideshow")&&W[1]&&(r=!0,ae.one(oe,o),_.get("slideshowAuto")?i():n(),F.show())}}();t.colorbox||(t(p),J=t.fn[Y]=t[Y]=function(e,i){var n,o=this;if(e=e||{},t.isFunction(o))o=t("<a/>"),e.open=!0;else if(!o[0])return o;return o[0]?(p(),m()&&(i&&(e.onComplete=i),o.each(function(){var i=t.data(this,Y)||{};t.data(this,Y,t.extend(i,e))}).addClass(te),n=new r(o[0],e),n.get("open")&&f(o[0])),o):o},J.position=function(e,i){function n(){T[0].style.width=k[0].style.width=b[0].style.width=parseInt(x[0].style.width,10)-j+"px",b[0].style.height=C[0].style.height=H[0].style.height=parseInt(x[0].style.height,10)-D+"px"}var r,h,s,l=0,d=0,c=x.offset();if(E.unbind("resize."+Z),x.css({top:-9e4,left:-9e4}),h=E.scrollTop(),s=E.scrollLeft(),_.get("fixed")?(c.top-=h,c.left-=s,x.css({position:"fixed"})):(l=h,d=s,x.css({position:"absolute"})),d+=_.get("right")!==!1?Math.max(E.width()-_.w-N-j-a(_.get("right"),"x"),0):_.get("left")!==!1?a(_.get("left"),"x"):Math.round(Math.max(E.width()-_.w-N-j,0)/2),l+=_.get("bottom")!==!1?Math.max(o()-_.h-A-D-a(_.get("bottom"),"y"),0):_.get("top")!==!1?a(_.get("top"),"y"):Math.round(Math.max(o()-_.h-A-D,0)/2),x.css({top:c.top,left:c.left,visibility:"visible"}),y[0].style.width=y[0].style.height="9999px",r={width:_.w+N+j,height:_.h+A+D,top:l,left:d},e){var g=0;t.each(r,function(t){return r[t]!==de[t]?(g=e,void 0):void 0}),e=g}de=r,e||x.css(r),x.dequeue().animate(r,{duration:e||0,complete:function(){n(),q=!1,y[0].style.width=_.w+N+j+"px",y[0].style.height=_.h+A+D+"px",_.get("reposition")&&setTimeout(function(){E.bind("resize."+Z,J.position)},1),i&&i()},step:n})},J.resize=function(t){var e;$&&(t=t||{},t.width&&(_.w=a(t.width,"x")-N-j),t.innerWidth&&(_.w=a(t.innerWidth,"x")),L.css({width:_.w}),t.height&&(_.h=a(t.height,"y")-A-D),t.innerHeight&&(_.h=a(t.innerHeight,"y")),t.innerHeight||t.height||(e=L.scrollTop(),L.css({height:"auto"}),_.h=L.height()),L.css({height:_.h}),e&&L.scrollTop(e),J.position("none"===_.get("transition")?0:_.get("speed")))},J.prep=function(i){function o(){return _.w=_.w||L.width(),_.w=_.mw&&_.mw<_.w?_.mw:_.w,_.w}function a(){return _.h=_.h||L.height(),_.h=_.mh&&_.mh<_.h?_.mh:_.h,_.h}if($){var d,g="none"===_.get("transition")?0:_.get("speed");L.remove(),L=n(se,"LoadedContent").append(i),L.hide().appendTo(M.show()).css({width:o(),overflow:_.get("scrolling")?"auto":"hidden"}).css({height:a()}).prependTo(b),M.hide(),t(U).css({"float":"none"}),c(_.get("className")),d=function(){function i(){t.support.opacity===!1&&x[0].style.removeAttribute("filter")}var n,o,a=W.length;$&&(o=function(){clearTimeout(Q),S.hide(),u(ne),_.get("onComplete")},I.html(_.get("title")).show(),L.show(),a>1?("string"==typeof _.get("current")&&R.html(_.get("current").replace("{current}",z+1).replace("{total}",a)).show(),K[_.get("loop")||a-1>z?"show":"hide"]().html(_.get("next")),P[_.get("loop")||z?"show":"hide"]().html(_.get("previous")),ce(),_.get("preloading")&&t.each([h(-1),h(1)],function(){var i,n=W[this],o=new r(n,t.data(n,Y)),h=o.get("href");h&&s(o,h)&&(h=l(o,h),i=e.createElement("img"),i.src=h)})):O.hide(),_.get("iframe")?(n=e.createElement("iframe"),"frameBorder"in n&&(n.frameBorder=0),"allowTransparency"in n&&(n.allowTransparency="true"),_.get("scrolling")||(n.scrolling="no"),t(n).attr({src:_.get("href"),name:(new Date).getTime(),"class":Z+"Iframe",allowFullScreen:!0}).one("load",o).appendTo(L),ae.one(he,function(){n.src="//about:blank"}),_.get("fastIframe")&&t(n).trigger("load")):o(),"fade"===_.get("transition")?x.fadeTo(g,1,i):i())},"fade"===_.get("transition")?x.fadeTo(g,0,function(){J.position(0,d)}):J.position(g,d)}},J.next=function(){!q&&W[1]&&(_.get("loop")||W[z+1])&&(z=h(1),f(W[z]))},J.prev=function(){!q&&W[1]&&(_.get("loop")||z)&&(z=h(-1),f(W[z]))},J.close=function(){$&&!G&&(G=!0,$=!1,u(oe),_.get("onCleanup"),E.unbind("."+Z),v.fadeTo(_.get("fadeOut")||0,0),x.stop().fadeTo(_.get("fadeOut")||0,0,function(){x.hide(),v.hide(),u(he),L.remove(),setTimeout(function(){G=!1,u(re),_.get("onClosed")},1)}))},J.remove=function(){x&&(x.stop(),t.colorbox.close(),x.stop().remove(),v.remove(),G=!1,x=null,t("."+te).removeData(Y).removeClass(te),t(e).unbind("click."+Z))},J.element=function(){return t(_.el)},J.settings=X)})(jQuery,document,window);
@@ -0,0 +1,4 @@
1
+ /* == jquery mousewheel plugin == Version: 3.1.11, License: MIT License (MIT) */
2
+ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.11",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
3
+ /* == malihu jquery custom scrollbar plugin == Version: 3.0.2, License: MIT License (MIT) */
4
+ (function(h,l,m,d){var e="mCustomScrollbar",a="mCS",k=".mCustomScrollbar",f={setWidth:false,setHeight:false,setTop:0,setLeft:0,axis:"y",scrollbarPosition:"inside",scrollInertia:950,autoDraggerLength:true,autoHideScrollbar:false,autoExpandScrollbar:false,alwaysShowScrollbar:0,snapAmount:null,snapOffset:0,mouseWheel:{enable:true,scrollAmount:"auto",axis:"y",preventDefault:false,deltaFactor:"auto",normalizeDelta:false,invert:false,disableOver:["select","option","keygen","datalist","textarea"]},scrollButtons:{enable:false,scrollType:"stepless",scrollAmount:"auto"},keyboard:{enable:true,scrollType:"stepless",scrollAmount:"auto"},contentTouchScroll:25,advanced:{autoExpandHorizontalScroll:false,autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",updateOnContentResize:true,updateOnImageLoad:true,updateOnSelectorChange:false},theme:"light",callbacks:{onScrollStart:false,onScroll:false,onTotalScroll:false,onTotalScrollBack:false,whileScrolling:false,onTotalScrollOffset:0,onTotalScrollBackOffset:0,alwaysTriggerOffsets:true},live:false,liveSelector:null},j=0,o={},c=function(p){if(o[p]){clearTimeout(o[p]);g._delete.call(null,o[p])}},i=(l.attachEvent&&!l.addEventListener)?1:0,n=false,b={init:function(q){var q=h.extend(true,{},f,q),p=g._selector.call(this);if(q.live){var s=q.liveSelector||this.selector||k,r=h(s);if(q.live==="off"){c(s);return}o[s]=setTimeout(function(){r.mCustomScrollbar(q);if(q.live==="once"&&r.length){c(s)}},500)}else{c(s)}q.setWidth=(q.set_width)?q.set_width:q.setWidth;q.setHeight=(q.set_height)?q.set_height:q.setHeight;q.axis=(q.horizontalScroll)?"x":g._findAxis.call(null,q.axis);q.scrollInertia=q.scrollInertia<17?17:q.scrollInertia;if(typeof q.mouseWheel!=="object"&&q.mouseWheel==true){q.mouseWheel={enable:true,scrollAmount:"auto",axis:"y",preventDefault:false,deltaFactor:"auto",normalizeDelta:false,invert:false}}q.mouseWheel.scrollAmount=!q.mouseWheelPixels?q.mouseWheel.scrollAmount:q.mouseWheelPixels;q.mouseWheel.normalizeDelta=!q.advanced.normalizeMouseWheelDelta?q.mouseWheel.normalizeDelta:q.advanced.normalizeMouseWheelDelta;q.scrollButtons.scrollType=g._findScrollButtonsType.call(null,q.scrollButtons.scrollType);g._theme.call(null,q);return h(p).each(function(){var u=h(this);if(!u.data(a)){u.data(a,{idx:++j,opt:q,scrollRatio:{y:null,x:null},overflowed:null,bindEvents:false,tweenRunning:false,sequential:{},langDir:u.css("direction"),cbOffsets:null,trigger:null});var w=u.data(a).opt,v=u.data("mcs-axis"),t=u.data("mcs-scrollbar-position"),x=u.data("mcs-theme");if(v){w.axis=v}if(t){w.scrollbarPosition=t}if(x){w.theme=x;g._theme.call(null,w)}g._pluginMarkup.call(this);b.update.call(null,u)}})},update:function(q){var p=q||g._selector.call(this);return h(p).each(function(){var t=h(this);if(t.data(a)){var v=t.data(a),u=v.opt,r=h("#mCSB_"+v.idx+"_container"),s=[h("#mCSB_"+v.idx+"_dragger_vertical"),h("#mCSB_"+v.idx+"_dragger_horizontal")];if(!r.length){return}if(v.tweenRunning){g._stop.call(null,t)}if(t.hasClass("mCS_disabled")){t.removeClass("mCS_disabled")}if(t.hasClass("mCS_destroyed")){t.removeClass("mCS_destroyed")}g._maxHeight.call(this);g._expandContentHorizontally.call(this);if(u.axis!=="y"&&!u.advanced.autoExpandHorizontalScroll){r.css("width",g._contentWidth(r.children()))}v.overflowed=g._overflowed.call(this);g._scrollbarVisibility.call(this);if(u.autoDraggerLength){g._setDraggerLength.call(this)}g._scrollRatio.call(this);g._bindEvents.call(this);var w=[Math.abs(r[0].offsetTop),Math.abs(r[0].offsetLeft)];if(u.axis!=="x"){if(!v.overflowed[0]){g._resetContentPosition.call(this);if(u.axis==="y"){g._unbindEvents.call(this)}else{if(u.axis==="yx"&&v.overflowed[1]){g._scrollTo.call(this,t,w[1].toString(),{dir:"x",dur:0,overwrite:"none"})}}}else{if(s[0].height()>s[0].parent().height()){g._resetContentPosition.call(this)}else{g._scrollTo.call(this,t,w[0].toString(),{dir:"y",dur:0,overwrite:"none"})}}}if(u.axis!=="y"){if(!v.overflowed[1]){g._resetContentPosition.call(this);if(u.axis==="x"){g._unbindEvents.call(this)}else{if(u.axis==="yx"&&v.overflowed[0]){g._scrollTo.call(this,t,w[0].toString(),{dir:"y",dur:0,overwrite:"none"})}}}else{if(s[1].width()>s[1].parent().width()){g._resetContentPosition.call(this)}else{g._scrollTo.call(this,t,w[1].toString(),{dir:"x",dur:0,overwrite:"none"})}}}g._autoUpdate.call(this)}})},scrollTo:function(r,q){if(typeof r=="undefined"||r==null){return}var p=g._selector.call(this);return h(p).each(function(){var u=h(this);if(u.data(a)){var x=u.data(a),w=x.opt,v={trigger:"external",scrollInertia:w.scrollInertia,scrollEasing:"mcsEaseInOut",moveDragger:false,callbacks:true,onStart:true,onUpdate:true,onComplete:true},s=h.extend(true,{},v,q),y=g._arr.call(this,r),t=s.scrollInertia<17?17:s.scrollInertia;y[0]=g._to.call(this,y[0],"y");y[1]=g._to.call(this,y[1],"x");if(s.moveDragger){y[0]*=x.scrollRatio.y;y[1]*=x.scrollRatio.x}s.dur=t;setTimeout(function(){if(y[0]!==null&&typeof y[0]!=="undefined"&&w.axis!=="x"&&x.overflowed[0]){s.dir="y";s.overwrite="all";g._scrollTo.call(this,u,y[0].toString(),s)}if(y[1]!==null&&typeof y[1]!=="undefined"&&w.axis!=="y"&&x.overflowed[1]){s.dir="x";s.overwrite="none";g._scrollTo.call(this,u,y[1].toString(),s)}},60)}})},stop:function(){var p=g._selector.call(this);return h(p).each(function(){var q=h(this);if(q.data(a)){g._stop.call(null,q)}})},disable:function(q){var p=g._selector.call(this);return h(p).each(function(){var r=h(this);if(r.data(a)){var t=r.data(a),s=t.opt;g._autoUpdate.call(this,"remove");g._unbindEvents.call(this);if(q){g._resetContentPosition.call(this)}g._scrollbarVisibility.call(this,true);r.addClass("mCS_disabled")}})},destroy:function(){var p=g._selector.call(this);return h(p).each(function(){var s=h(this);if(s.data(a)){var u=s.data(a),t=u.opt,q=h("#mCSB_"+u.idx),r=h("#mCSB_"+u.idx+"_container"),v=h(".mCSB_"+u.idx+"_scrollbar");if(t.live){c(p)}g._autoUpdate.call(this,"remove");g._unbindEvents.call(this);g._resetContentPosition.call(this);s.removeData(a);g._delete.call(null,this.mcs);v.remove();q.replaceWith(r.contents());s.removeClass(e+" _"+a+"_"+u.idx+" mCS-autoHide mCS-dir-rtl mCS_no_scrollbar mCS_disabled").addClass("mCS_destroyed")}})}},g={_selector:function(){return(typeof h(this)!=="object"||h(this).length<1)?k:this},_theme:function(s){var r=["rounded","rounded-dark","rounded-dots","rounded-dots-dark"],q=["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"],p=["minimal","minimal-dark"],u=["minimal","minimal-dark"],t=["minimal","minimal-dark"];s.autoDraggerLength=h.inArray(s.theme,r)>-1?false:s.autoDraggerLength;s.autoExpandScrollbar=h.inArray(s.theme,q)>-1?false:s.autoExpandScrollbar;s.scrollButtons.enable=h.inArray(s.theme,p)>-1?false:s.scrollButtons.enable;s.autoHideScrollbar=h.inArray(s.theme,u)>-1?true:s.autoHideScrollbar;s.scrollbarPosition=h.inArray(s.theme,t)>-1?"outside":s.scrollbarPosition},_findAxis:function(p){return(p==="yx"||p==="xy"||p==="auto")?"yx":(p==="x"||p==="horizontal")?"x":"y"},_findScrollButtonsType:function(p){return(p==="stepped"||p==="pixels"||p==="step"||p==="click")?"stepped":"stepless"},_pluginMarkup:function(){var y=h(this),x=y.data(a),r=x.opt,t=r.autoExpandScrollbar?" mCSB_scrollTools_onDrag_expand":"",B=["<div id='mCSB_"+x.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+x.idx+"_scrollbar mCS-"+r.theme+" mCSB_scrollTools_vertical"+t+"'><div class='mCSB_draggerContainer'><div id='mCSB_"+x.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+x.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+x.idx+"_scrollbar mCS-"+r.theme+" mCSB_scrollTools_horizontal"+t+"'><div class='mCSB_draggerContainer'><div id='mCSB_"+x.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],u=r.axis==="yx"?"mCSB_vertical_horizontal":r.axis==="x"?"mCSB_horizontal":"mCSB_vertical",w=r.axis==="yx"?B[0]+B[1]:r.axis==="x"?B[1]:B[0],v=r.axis==="yx"?"<div id='mCSB_"+x.idx+"_container_wrapper' class='mCSB_container_wrapper' />":"",s=r.autoHideScrollbar?" mCS-autoHide":"",p=(r.axis!=="x"&&x.langDir==="rtl")?" mCS-dir-rtl":"";if(r.setWidth){y.css("width",r.setWidth)}if(r.setHeight){y.css("height",r.setHeight)}r.setLeft=(r.axis!=="y"&&x.langDir==="rtl")?"989999px":r.setLeft;y.addClass(e+" _"+a+"_"+x.idx+s+p).wrapInner("<div id='mCSB_"+x.idx+"' class='mCustomScrollBox mCS-"+r.theme+" "+u+"'><div id='mCSB_"+x.idx+"_container' class='mCSB_container' style='position:relative; top:"+r.setTop+"; left:"+r.setLeft+";' dir="+x.langDir+" /></div>");var q=h("#mCSB_"+x.idx),z=h("#mCSB_"+x.idx+"_container");if(r.axis!=="y"&&!r.advanced.autoExpandHorizontalScroll){z.css("width",g._contentWidth(z.children()))}if(r.scrollbarPosition==="outside"){if(y.css("position")==="static"){y.css("position","relative")}y.css("overflow","visible");q.addClass("mCSB_outside").after(w)}else{q.addClass("mCSB_inside").append(w);z.wrap(v)}g._scrollButtons.call(this);var A=[h("#mCSB_"+x.idx+"_dragger_vertical"),h("#mCSB_"+x.idx+"_dragger_horizontal")];A[0].css("min-height",A[0].height());A[1].css("min-width",A[1].width())},_contentWidth:function(p){return Math.max.apply(Math,p.map(function(){return h(this).outerWidth(true)}).get())},_expandContentHorizontally:function(){var q=h(this),s=q.data(a),r=s.opt,p=h("#mCSB_"+s.idx+"_container");if(r.advanced.autoExpandHorizontalScroll&&r.axis!=="y"){p.css({position:"absolute",width:"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({width:(Math.ceil(p[0].getBoundingClientRect().right+0.4)-Math.floor(p[0].getBoundingClientRect().left)),position:"relative"}).unwrap()}},_scrollButtons:function(){var s=h(this),u=s.data(a),t=u.opt,q=h(".mCSB_"+u.idx+"_scrollbar:first"),r=["<a href='#' class='mCSB_buttonUp' oncontextmenu='return false;' />","<a href='#' class='mCSB_buttonDown' oncontextmenu='return false;' />","<a href='#' class='mCSB_buttonLeft' oncontextmenu='return false;' />","<a href='#' class='mCSB_buttonRight' oncontextmenu='return false;' />"],p=[(t.axis==="x"?r[2]:r[0]),(t.axis==="x"?r[3]:r[1]),r[2],r[3]];if(t.scrollButtons.enable){q.prepend(p[0]).append(p[1]).next(".mCSB_scrollTools").prepend(p[2]).append(p[3])}},_maxHeight:function(){var t=h(this),w=t.data(a),v=w.opt,r=h("#mCSB_"+w.idx),q=t.css("max-height"),s=q.indexOf("%")!==-1,p=t.css("box-sizing");if(q!=="none"){var u=s?t.parent().height()*parseInt(q)/100:parseInt(q);if(p==="border-box"){u-=((t.innerHeight()-t.height())+(t.outerHeight()-t.innerHeight()))}r.css("max-height",Math.round(u))}},_setDraggerLength:function(){var u=h(this),s=u.data(a),p=h("#mCSB_"+s.idx),v=h("#mCSB_"+s.idx+"_container"),y=[h("#mCSB_"+s.idx+"_dragger_vertical"),h("#mCSB_"+s.idx+"_dragger_horizontal")],t=[p.height()/v.outerHeight(false),p.width()/v.outerWidth(false)],q=[parseInt(y[0].css("min-height")),Math.round(t[0]*y[0].parent().height()),parseInt(y[1].css("min-width")),Math.round(t[1]*y[1].parent().width())],r=i&&(q[1]<q[0])?q[0]:q[1],x=i&&(q[3]<q[2])?q[2]:q[3];y[0].css({height:r,"max-height":(y[0].parent().height()-10)}).find(".mCSB_dragger_bar").css({"line-height":q[0]+"px"});y[1].css({width:x,"max-width":(y[1].parent().width()-10)})},_scrollRatio:function(){var t=h(this),v=t.data(a),q=h("#mCSB_"+v.idx),r=h("#mCSB_"+v.idx+"_container"),s=[h("#mCSB_"+v.idx+"_dragger_vertical"),h("#mCSB_"+v.idx+"_dragger_horizontal")],u=[r.outerHeight(false)-q.height(),r.outerWidth(false)-q.width()],p=[u[0]/(s[0].parent().height()-s[0].height()),u[1]/(s[1].parent().width()-s[1].width())];v.scrollRatio={y:p[0],x:p[1]}},_onDragClasses:function(r,t,q){var s=q?"mCSB_dragger_onDrag_expanded":"",p=["mCSB_dragger_onDrag","mCSB_scrollTools_onDrag"],u=r.closest(".mCSB_scrollTools");if(t==="active"){r.toggleClass(p[0]+" "+s);u.toggleClass(p[1]);r[0]._draggable=r[0]._draggable?0:1}else{if(!r[0]._draggable){if(t==="hide"){r.removeClass(p[0]);u.removeClass(p[1])}else{r.addClass(p[0]);u.addClass(p[1])}}}},_overflowed:function(){var t=h(this),u=t.data(a),q=h("#mCSB_"+u.idx),s=h("#mCSB_"+u.idx+"_container"),r=u.overflowed==null?s.height():s.outerHeight(false),p=u.overflowed==null?s.width():s.outerWidth(false);return[r>q.height(),p>q.width()]},_resetContentPosition:function(){var t=h(this),v=t.data(a),u=v.opt,q=h("#mCSB_"+v.idx),r=h("#mCSB_"+v.idx+"_container"),s=[h("#mCSB_"+v.idx+"_dragger_vertical"),h("#mCSB_"+v.idx+"_dragger_horizontal")];g._stop(t);if((u.axis!=="x"&&!v.overflowed[0])||(u.axis==="y"&&v.overflowed[0])){s[0].add(r).css("top",0)}if((u.axis!=="y"&&!v.overflowed[1])||(u.axis==="x"&&v.overflowed[1])){var p=dx=0;if(v.langDir==="rtl"){p=q.width()-r.outerWidth(false);dx=Math.abs(p/v.scrollRatio.x)}r.css("left",p);s[1].css("left",dx)}},_bindEvents:function(){var r=h(this),t=r.data(a),s=t.opt;if(!t.bindEvents){g._draggable.call(this);if(s.contentTouchScroll){g._contentDraggable.call(this)}if(s.mouseWheel.enable){function q(){p=setTimeout(function(){if(!h.event.special.mousewheel){q()}else{clearTimeout(p);g._mousewheel.call(r[0])}},1000)}var p;q()}g._draggerRail.call(this);g._wrapperScroll.call(this);if(s.advanced.autoScrollOnFocus){g._focus.call(this)}if(s.scrollButtons.enable){g._buttons.call(this)}if(s.keyboard.enable){g._keyboard.call(this)}t.bindEvents=true}},_unbindEvents:function(){var s=h(this),t=s.data(a),p=a+"_"+t.idx,u=".mCSB_"+t.idx+"_scrollbar",r=h("#mCSB_"+t.idx+",#mCSB_"+t.idx+"_container,#mCSB_"+t.idx+"_container_wrapper,"+u+" .mCSB_draggerContainer,#mCSB_"+t.idx+"_dragger_vertical,#mCSB_"+t.idx+"_dragger_horizontal,"+u+">a"),q=h("#mCSB_"+t.idx+"_container");if(t.bindEvents){h(m).unbind("."+p);r.each(function(){h(this).unbind("."+p)});clearTimeout(s[0]._focusTimeout);g._delete.call(null,s[0]._focusTimeout);clearTimeout(t.sequential.step);g._delete.call(null,t.sequential.step);clearTimeout(q[0].onCompleteTimeout);g._delete.call(null,q[0].onCompleteTimeout);t.bindEvents=false}},_scrollbarVisibility:function(q){var t=h(this),v=t.data(a),u=v.opt,p=h("#mCSB_"+v.idx+"_container_wrapper"),r=p.length?p:h("#mCSB_"+v.idx+"_container"),w=[h("#mCSB_"+v.idx+"_scrollbar_vertical"),h("#mCSB_"+v.idx+"_scrollbar_horizontal")],s=[w[0].find(".mCSB_dragger"),w[1].find(".mCSB_dragger")];if(u.axis!=="x"){if(v.overflowed[0]&&!q){w[0].add(s[0]).add(w[0].children("a")).css("display","block");r.removeClass("mCS_no_scrollbar_y mCS_y_hidden")}else{if(u.alwaysShowScrollbar){if(u.alwaysShowScrollbar!==2){s[0].add(w[0].children("a")).css("display","none")}r.removeClass("mCS_y_hidden")}else{w[0].css("display","none");r.addClass("mCS_y_hidden")}r.addClass("mCS_no_scrollbar_y")}}if(u.axis!=="y"){if(v.overflowed[1]&&!q){w[1].add(s[1]).add(w[1].children("a")).css("display","block");r.removeClass("mCS_no_scrollbar_x mCS_x_hidden")}else{if(u.alwaysShowScrollbar){if(u.alwaysShowScrollbar!==2){s[1].add(w[1].children("a")).css("display","none")}r.removeClass("mCS_x_hidden")}else{w[1].css("display","none");r.addClass("mCS_x_hidden")}r.addClass("mCS_no_scrollbar_x")}}if(!v.overflowed[0]&&!v.overflowed[1]){t.addClass("mCS_no_scrollbar")}else{t.removeClass("mCS_no_scrollbar")}},_coordinates:function(q){var p=q.type;switch(p){case"pointerdown":case"MSPointerDown":case"pointermove":case"MSPointerMove":case"pointerup":case"MSPointerUp":return[q.originalEvent.pageY,q.originalEvent.pageX];break;case"touchstart":case"touchmove":case"touchend":var r=q.originalEvent.touches[0]||q.originalEvent.changedTouches[0];return[r.pageY,r.pageX];break;default:return[q.pageY,q.pageX]}},_draggable:function(){var u=h(this),s=u.data(a),p=s.opt,r=a+"_"+s.idx,t=["mCSB_"+s.idx+"_dragger_vertical","mCSB_"+s.idx+"_dragger_horizontal"],v=h("#mCSB_"+s.idx+"_container"),w=h("#"+t[0]+",#"+t[1]),A,y,z;w.bind("mousedown."+r+" touchstart."+r+" pointerdown."+r+" MSPointerDown."+r,function(E){E.stopImmediatePropagation();E.preventDefault();if(!g._mouseBtnLeft(E)){return}n=true;if(i){m.onselectstart=function(){return false}}x(false);g._stop(u);A=h(this);var F=A.offset(),G=g._coordinates(E)[0]-F.top,B=g._coordinates(E)[1]-F.left,D=A.height()+F.top,C=A.width()+F.left;if(G<D&&G>0&&B<C&&B>0){y=G;z=B}g._onDragClasses(A,"active",p.autoExpandScrollbar)}).bind("touchmove."+r,function(C){C.stopImmediatePropagation();C.preventDefault();var D=A.offset(),E=g._coordinates(C)[0]-D.top,B=g._coordinates(C)[1]-D.left;q(y,z,E,B)});h(m).bind("mousemove."+r+" pointermove."+r+" MSPointerMove."+r,function(C){if(A){var D=A.offset(),E=g._coordinates(C)[0]-D.top,B=g._coordinates(C)[1]-D.left;if(y===E){return}q(y,z,E,B)}}).add(w).bind("mouseup."+r+" touchend."+r+" pointerup."+r+" MSPointerUp."+r,function(B){if(A){g._onDragClasses(A,"active",p.autoExpandScrollbar);A=null}n=false;if(i){m.onselectstart=null}x(true)});function x(B){var C=v.find("iframe");if(!C.length){return}var D=!B?"none":"auto";C.css("pointer-events",D)}function q(D,E,G,B){v[0].idleTimer=p.scrollInertia<233?250:0;if(A.attr("id")===t[1]){var C="x",F=((A[0].offsetLeft-E)+B)*s.scrollRatio.x}else{var C="y",F=((A[0].offsetTop-D)+G)*s.scrollRatio.y}g._scrollTo(u,F.toString(),{dir:C,drag:true})}},_contentDraggable:function(){var y=h(this),K=y.data(a),I=K.opt,F=a+"_"+K.idx,v=h("#mCSB_"+K.idx),z=h("#mCSB_"+K.idx+"_container"),w=[h("#mCSB_"+K.idx+"_dragger_vertical"),h("#mCSB_"+K.idx+"_dragger_horizontal")],E,G,L,M,C=[],D=[],H,A,u,t,J,x,r=0,q,s=I.axis==="yx"?"none":"all";z.bind("touchstart."+F+" pointerdown."+F+" MSPointerDown."+F,function(N){if(!g._pointerTouch(N)||n){return}var O=z.offset();E=g._coordinates(N)[0]-O.top;G=g._coordinates(N)[1]-O.left}).bind("touchmove."+F+" pointermove."+F+" MSPointerMove."+F,function(Q){if(!g._pointerTouch(Q)||n){return}Q.stopImmediatePropagation();A=g._getTime();var P=v.offset(),S=g._coordinates(Q)[0]-P.top,U=g._coordinates(Q)[1]-P.left,R="mcsLinearOut";C.push(S);D.push(U);if(K.overflowed[0]){var O=w[0].parent().height()-w[0].height(),T=((E-S)>0&&(S-E)>-(O*K.scrollRatio.y))}if(K.overflowed[1]){var N=w[1].parent().width()-w[1].width(),V=((G-U)>0&&(U-G)>-(N*K.scrollRatio.x))}if(T||V){Q.preventDefault()}x=I.axis==="yx"?[(E-S),(G-U)]:I.axis==="x"?[null,(G-U)]:[(E-S),null];z[0].idleTimer=250;if(K.overflowed[0]){B(x[0],r,R,"y","all",true)}if(K.overflowed[1]){B(x[1],r,R,"x",s,true)}});v.bind("touchstart."+F+" pointerdown."+F+" MSPointerDown."+F,function(N){if(!g._pointerTouch(N)||n){return}N.stopImmediatePropagation();g._stop(y);H=g._getTime();var O=v.offset();L=g._coordinates(N)[0]-O.top;M=g._coordinates(N)[1]-O.left;C=[];D=[]}).bind("touchend."+F+" pointerup."+F+" MSPointerUp."+F,function(P){if(!g._pointerTouch(P)||n){return}P.stopImmediatePropagation();u=g._getTime();var N=v.offset(),T=g._coordinates(P)[0]-N.top,V=g._coordinates(P)[1]-N.left;if((u-A)>30){return}J=1000/(u-H);var Q="mcsEaseOut",R=J<2.5,W=R?[C[C.length-2],D[D.length-2]]:[0,0];t=R?[(T-W[0]),(V-W[1])]:[T-L,V-M];var O=[Math.abs(t[0]),Math.abs(t[1])];J=R?[Math.abs(t[0]/4),Math.abs(t[1]/4)]:[J,J];var U=[Math.abs(z[0].offsetTop)-(t[0]*p((O[0]/J[0]),J[0])),Math.abs(z[0].offsetLeft)-(t[1]*p((O[1]/J[1]),J[1]))];x=I.axis==="yx"?[U[0],U[1]]:I.axis==="x"?[null,U[1]]:[U[0],null];q=[(O[0]*4)+I.scrollInertia,(O[1]*4)+I.scrollInertia];var S=parseInt(I.contentTouchScroll)||0;x[0]=O[0]>S?x[0]:0;x[1]=O[1]>S?x[1]:0;if(K.overflowed[0]){B(x[0],q[0],Q,"y",s,false)}if(K.overflowed[1]){B(x[1],q[1],Q,"x",s,false)}});function p(P,N){var O=[N*1.5,N*2,N/1.5,N/2];if(P>90){return N>4?O[0]:O[3]}else{if(P>60){return N>3?O[3]:O[2]}else{if(P>30){return N>8?O[1]:N>6?O[0]:N>4?N:O[2]}else{return N>8?N:O[3]}}}}function B(P,R,S,O,N,Q){if(!P){return}g._scrollTo(y,P.toString(),{dur:R,scrollEasing:S,dir:O,overwrite:N,drag:Q})}},_mousewheel:function(){var s=h(this),u=s.data(a),t=u.opt,q=a+"_"+u.idx,p=h("#mCSB_"+u.idx),r=[h("#mCSB_"+u.idx+"_dragger_vertical"),h("#mCSB_"+u.idx+"_dragger_horizontal")];p.bind("mousewheel."+q,function(z,D){g._stop(s);if(g._disableMousewheel(s,z.target)){return}var B=t.mouseWheel.deltaFactor!=="auto"?parseInt(t.mouseWheel.deltaFactor):(i&&z.deltaFactor<100)?100:z.deltaFactor<40?40:z.deltaFactor||100;if(t.axis==="x"||t.mouseWheel.axis==="x"){var w="x",C=[Math.round(B*u.scrollRatio.x),parseInt(t.mouseWheel.scrollAmount)],y=t.mouseWheel.scrollAmount!=="auto"?C[1]:C[0]>=p.width()?p.width()*0.9:C[0],E=Math.abs(h("#mCSB_"+u.idx+"_container")[0].offsetLeft),A=r[1][0].offsetLeft,x=r[1].parent().width()-r[1].width(),v=z.deltaX||z.deltaY||D}else{var w="y",C=[Math.round(B*u.scrollRatio.y),parseInt(t.mouseWheel.scrollAmount)],y=t.mouseWheel.scrollAmount!=="auto"?C[1]:C[0]>=p.height()?p.height()*0.9:C[0],E=Math.abs(h("#mCSB_"+u.idx+"_container")[0].offsetTop),A=r[0][0].offsetTop,x=r[0].parent().height()-r[0].height(),v=z.deltaY||D}if((w==="y"&&!u.overflowed[0])||(w==="x"&&!u.overflowed[1])){return}if(t.mouseWheel.invert){v=-v}if(t.mouseWheel.normalizeDelta){v=v<0?-1:1}if((v>0&&A!==0)||(v<0&&A!==x)||t.mouseWheel.preventDefault){z.stopImmediatePropagation();z.preventDefault()}g._scrollTo(s,(E-(v*y)).toString(),{dir:w})})},_disableMousewheel:function(r,t){var p=t.nodeName.toLowerCase(),q=r.data(a).opt.mouseWheel.disableOver,s=["select","textarea"];return h.inArray(p,q)>-1&&!(h.inArray(p,s)>-1&&!h(t).is(":focus"))},_draggerRail:function(){var s=h(this),t=s.data(a),q=a+"_"+t.idx,r=h("#mCSB_"+t.idx+"_container"),u=r.parent(),p=h(".mCSB_"+t.idx+"_scrollbar .mCSB_draggerContainer");p.bind("touchstart."+q+" pointerdown."+q+" MSPointerDown."+q,function(v){n=true}).bind("touchend."+q+" pointerup."+q+" MSPointerUp."+q,function(v){n=false}).bind("click."+q,function(z){if(h(z.target).hasClass("mCSB_draggerContainer")||h(z.target).hasClass("mCSB_draggerRail")){g._stop(s);var w=h(this),y=w.find(".mCSB_dragger");if(w.parent(".mCSB_scrollTools_horizontal").length>0){if(!t.overflowed[1]){return}var v="x",x=z.pageX>y.offset().left?-1:1,A=Math.abs(r[0].offsetLeft)-(x*(u.width()*0.9))}else{if(!t.overflowed[0]){return}var v="y",x=z.pageY>y.offset().top?-1:1,A=Math.abs(r[0].offsetTop)-(x*(u.height()*0.9))}g._scrollTo(s,A.toString(),{dir:v,scrollEasing:"mcsEaseInOut"})}})},_focus:function(){var r=h(this),t=r.data(a),s=t.opt,p=a+"_"+t.idx,q=h("#mCSB_"+t.idx+"_container"),u=q.parent();q.bind("focusin."+p,function(x){var w=h(m.activeElement),y=q.find(".mCustomScrollBox").length,v=0;if(!w.is(s.advanced.autoScrollOnFocus)){return}g._stop(r);clearTimeout(r[0]._focusTimeout);r[0]._focusTimer=y?(v+17)*y:0;r[0]._focusTimeout=setTimeout(function(){var C=[w.offset().top-q.offset().top,w.offset().left-q.offset().left],B=[q[0].offsetTop,q[0].offsetLeft],z=[(B[0]+C[0]>=0&&B[0]+C[0]<u.height()-w.outerHeight(false)),(B[1]+C[1]>=0&&B[0]+C[1]<u.width()-w.outerWidth(false))],A=(s.axis==="yx"&&!z[0]&&!z[1])?"none":"all";if(s.axis!=="x"&&!z[0]){g._scrollTo(r,C[0].toString(),{dir:"y",scrollEasing:"mcsEaseInOut",overwrite:A,dur:v})}if(s.axis!=="y"&&!z[1]){g._scrollTo(r,C[1].toString(),{dir:"x",scrollEasing:"mcsEaseInOut",overwrite:A,dur:v})}},r[0]._focusTimer)})},_wrapperScroll:function(){var q=h(this),r=q.data(a),p=a+"_"+r.idx,s=h("#mCSB_"+r.idx+"_container").parent();s.bind("scroll."+p,function(t){s.scrollTop(0).scrollLeft(0)})},_buttons:function(){var u=h(this),w=u.data(a),v=w.opt,p=w.sequential,r=a+"_"+w.idx,t=h("#mCSB_"+w.idx+"_container"),s=".mCSB_"+w.idx+"_scrollbar",q=h(s+">a");q.bind("mousedown."+r+" touchstart."+r+" pointerdown."+r+" MSPointerDown."+r+" mouseup."+r+" touchend."+r+" pointerup."+r+" MSPointerUp."+r+" mouseout."+r+" pointerout."+r+" MSPointerOut."+r+" click."+r,function(z){z.preventDefault();if(!g._mouseBtnLeft(z)){return}var y=h(this).attr("class");p.type=v.scrollButtons.scrollType;switch(z.type){case"mousedown":case"touchstart":case"pointerdown":case"MSPointerDown":if(p.type==="stepped"){return}n=true;w.tweenRunning=false;x("on",y);break;case"mouseup":case"touchend":case"pointerup":case"MSPointerUp":case"mouseout":case"pointerout":case"MSPointerOut":if(p.type==="stepped"){return}n=false;if(p.dir){x("off",y)}break;case"click":if(p.type!=="stepped"||w.tweenRunning){return}x("on",y);break}function x(A,B){p.scrollAmount=v.snapAmount||v.scrollButtons.scrollAmount;g._sequentialScroll.call(this,u,A,B)}})},_keyboard:function(){var u=h(this),t=u.data(a),q=t.opt,x=t.sequential,s=a+"_"+t.idx,r=h("#mCSB_"+t.idx),w=h("#mCSB_"+t.idx+"_container"),p=w.parent(),v="input,textarea,select,datalist,keygen,[contenteditable='true']";r.attr("tabindex","0").bind("blur."+s+" keydown."+s+" keyup."+s,function(D){switch(D.type){case"blur":if(t.tweenRunning&&x.dir){y("off",null)}break;case"keydown":case"keyup":var A=D.keyCode?D.keyCode:D.which,B="on";if((q.axis!=="x"&&(A===38||A===40))||(q.axis!=="y"&&(A===37||A===39))){if(((A===38||A===40)&&!t.overflowed[0])||((A===37||A===39)&&!t.overflowed[1])){return}if(D.type==="keyup"){B="off"}if(!h(m.activeElement).is(v)){D.preventDefault();D.stopImmediatePropagation();y(B,A)}}else{if(A===33||A===34){if(t.overflowed[0]||t.overflowed[1]){D.preventDefault();D.stopImmediatePropagation()}if(D.type==="keyup"){g._stop(u);var C=A===34?-1:1;if(q.axis==="x"||(q.axis==="yx"&&t.overflowed[1]&&!t.overflowed[0])){var z="x",E=Math.abs(w[0].offsetLeft)-(C*(p.width()*0.9))}else{var z="y",E=Math.abs(w[0].offsetTop)-(C*(p.height()*0.9))}g._scrollTo(u,E.toString(),{dir:z,scrollEasing:"mcsEaseInOut"})}}else{if(A===35||A===36){if(!h(m.activeElement).is(v)){if(t.overflowed[0]||t.overflowed[1]){D.preventDefault();D.stopImmediatePropagation()}if(D.type==="keyup"){if(q.axis==="x"||(q.axis==="yx"&&t.overflowed[1]&&!t.overflowed[0])){var z="x",E=A===35?Math.abs(p.width()-w.outerWidth(false)):0}else{var z="y",E=A===35?Math.abs(p.height()-w.outerHeight(false)):0}g._scrollTo(u,E.toString(),{dir:z,scrollEasing:"mcsEaseInOut"})}}}}}break}function y(F,G){x.type=q.keyboard.scrollType;x.scrollAmount=q.snapAmount||q.keyboard.scrollAmount;if(x.type==="stepped"&&t.tweenRunning){return}g._sequentialScroll.call(this,u,F,G)}})},_sequentialScroll:function(r,u,s){var w=r.data(a),q=w.opt,y=w.sequential,x=h("#mCSB_"+w.idx+"_container"),p=y.type==="stepped"?true:false;switch(u){case"on":y.dir=[(s==="mCSB_buttonRight"||s==="mCSB_buttonLeft"||s===39||s===37?"x":"y"),(s==="mCSB_buttonUp"||s==="mCSB_buttonLeft"||s===38||s===37?-1:1)];g._stop(r);if(g._isNumeric(s)&&y.type==="stepped"){return}t(p);break;case"off":v();if(p||(w.tweenRunning&&y.dir)){t(true)}break}function t(z){var F=y.type!=="stepped",J=!z?1000/60:F?q.scrollInertia/1.5:q.scrollInertia,B=!z?2.5:F?7.5:40,I=[Math.abs(x[0].offsetTop),Math.abs(x[0].offsetLeft)],E=[w.scrollRatio.y>10?10:w.scrollRatio.y,w.scrollRatio.x>10?10:w.scrollRatio.x],C=y.dir[0]==="x"?I[1]+(y.dir[1]*(E[1]*B)):I[0]+(y.dir[1]*(E[0]*B)),H=y.dir[0]==="x"?I[1]+(y.dir[1]*parseInt(y.scrollAmount)):I[0]+(y.dir[1]*parseInt(y.scrollAmount)),G=y.scrollAmount!=="auto"?H:C,D=!z?"mcsLinear":F?"mcsLinearOut":"mcsEaseInOut",A=!z?false:true;if(z&&J<17){G=y.dir[0]==="x"?I[1]:I[0]}g._scrollTo(r,G.toString(),{dir:y.dir[0],scrollEasing:D,dur:J,onComplete:A});if(z){y.dir=false;return}clearTimeout(y.step);y.step=setTimeout(function(){t()},J)}function v(){clearTimeout(y.step);g._stop(r)}},_arr:function(r){var q=h(this).data(a).opt,p=[];if(typeof r==="function"){r=r()}if(!(r instanceof Array)){p[0]=r.y?r.y:r.x||q.axis==="x"?null:r;p[1]=r.x?r.x:r.y||q.axis==="y"?null:r}else{p=r.length>1?[r[0],r[1]]:q.axis==="x"?[null,r[0]]:[r[0],null]}if(typeof p[0]==="function"){p[0]=p[0]()}if(typeof p[1]==="function"){p[1]=p[1]()}return p},_to:function(v,w){if(v==null||typeof v=="undefined"){return}var C=h(this),B=C.data(a),u=B.opt,D=h("#mCSB_"+B.idx+"_container"),r=D.parent(),F=typeof v;if(!w){w=u.axis==="x"?"x":"y"}var q=w==="x"?D.outerWidth(false):D.outerHeight(false),x=w==="x"?D.offset().left:D.offset().top,E=w==="x"?D[0].offsetLeft:D[0].offsetTop,z=w==="x"?"left":"top";switch(F){case"function":return v();break;case"object":if(v.nodeType){var A=w==="x"?h(v).offset().left:h(v).offset().top}else{if(v.jquery){if(!v.length){return}var A=w==="x"?v.offset().left:v.offset().top}}return A-x;break;case"string":case"number":if(g._isNumeric.call(null,v)){return Math.abs(v)}else{if(v.indexOf("%")!==-1){return Math.abs(q*parseInt(v)/100)}else{if(v.indexOf("-=")!==-1){return Math.abs(E-parseInt(v.split("-=")[1]))}else{if(v.indexOf("+=")!==-1){var s=(E+parseInt(v.split("+=")[1]));return s>=0?0:Math.abs(s)}else{if(v.indexOf("px")!==-1&&g._isNumeric.call(null,v.split("px")[0])){return Math.abs(v.split("px")[0])}else{if(v==="top"||v==="left"){return 0}else{if(v==="bottom"){return Math.abs(r.height()-D.outerHeight(false))}else{if(v==="right"){return Math.abs(r.width()-D.outerWidth(false))}else{if(v==="first"||v==="last"){var y=D.find(":"+v),A=w==="x"?h(y).offset().left:h(y).offset().top;return A-x}else{if(h(v).length){var A=w==="x"?h(v).offset().left:h(v).offset().top;return A-x}else{D.css(z,v);b.update.call(null,C[0]);return}}}}}}}}}}break}},_autoUpdate:function(q){var t=h(this),F=t.data(a),z=F.opt,v=h("#mCSB_"+F.idx+"_container");if(q){clearTimeout(v[0].autoUpdate);g._delete.call(null,v[0].autoUpdate);return}var s=v.parent(),p=[h("#mCSB_"+F.idx+"_scrollbar_vertical"),h("#mCSB_"+F.idx+"_scrollbar_horizontal")],D=function(){return[p[0].is(":visible")?p[0].outerHeight(true):0,p[1].is(":visible")?p[1].outerWidth(true):0]},E=y(),x,u=[v.outerHeight(false),v.outerWidth(false),s.height(),s.width(),D()[0],D()[1]],H,B=G(),w;C();function C(){clearTimeout(v[0].autoUpdate);v[0].autoUpdate=setTimeout(function(){if(z.advanced.updateOnSelectorChange){x=y();if(x!==E){r();E=x;return}}if(z.advanced.updateOnContentResize){H=[v.outerHeight(false),v.outerWidth(false),s.height(),s.width(),D()[0],D()[1]];if(H[0]!==u[0]||H[1]!==u[1]||H[2]!==u[2]||H[3]!==u[3]||H[4]!==u[4]||H[5]!==u[5]){r();u=H}}if(z.advanced.updateOnImageLoad){w=G();if(w!==B){v.find("img").each(function(){A(this.src)});B=w}}if(z.advanced.updateOnSelectorChange||z.advanced.updateOnContentResize||z.advanced.updateOnImageLoad){C()}},60)}function G(){var I=0;if(z.advanced.updateOnImageLoad){I=v.find("img").length}return I}function A(L){var I=new Image();function K(M,N){return function(){return N.apply(M,arguments)}}function J(){this.onload=null;r()}I.onload=K(I,J);I.src=L}function y(){if(z.advanced.updateOnSelectorChange===true){z.advanced.updateOnSelectorChange="*"}var I=0,J=v.find(z.advanced.updateOnSelectorChange);if(z.advanced.updateOnSelectorChange&&J.length>0){J.each(function(){I+=h(this).height()+h(this).width()})}return I}function r(){clearTimeout(v[0].autoUpdate);b.update.call(null,t[0])}},_snapAmount:function(r,p,q){return(Math.round(r/p)*p-q)},_stop:function(p){var r=p.data(a),q=h("#mCSB_"+r.idx+"_container,#mCSB_"+r.idx+"_container_wrapper,#mCSB_"+r.idx+"_dragger_vertical,#mCSB_"+r.idx+"_dragger_horizontal");q.each(function(){g._stopTween.call(this)})},_scrollTo:function(q,s,u){var I=q.data(a),E=I.opt,D={trigger:"internal",dir:"y",scrollEasing:"mcsEaseOut",drag:false,dur:E.scrollInertia,overwrite:"all",callbacks:true,onStart:true,onUpdate:true,onComplete:true},u=h.extend(D,u),G=[u.dur,(u.drag?0:u.dur)],v=h("#mCSB_"+I.idx),B=h("#mCSB_"+I.idx+"_container"),K=E.callbacks.onTotalScrollOffset?g._arr.call(q,E.callbacks.onTotalScrollOffset):[0,0],p=E.callbacks.onTotalScrollBackOffset?g._arr.call(q,E.callbacks.onTotalScrollBackOffset):[0,0];I.trigger=u.trigger;if(E.snapAmount){s=g._snapAmount(s,E.snapAmount,E.snapOffset)}switch(u.dir){case"x":var x=h("#mCSB_"+I.idx+"_dragger_horizontal"),z="left",C=B[0].offsetLeft,H=[v.width()-B.outerWidth(false),x.parent().width()-x.width()],r=[s,(s/I.scrollRatio.x)],L=K[1],J=p[1],A=L>0?L/I.scrollRatio.x:0,w=J>0?J/I.scrollRatio.x:0;break;case"y":var x=h("#mCSB_"+I.idx+"_dragger_vertical"),z="top",C=B[0].offsetTop,H=[v.height()-B.outerHeight(false),x.parent().height()-x.height()],r=[s,(s/I.scrollRatio.y)],L=K[0],J=p[0],A=L>0?L/I.scrollRatio.y:0,w=J>0?J/I.scrollRatio.y:0;break}if(r[1]<0){r=[0,0]}else{if(r[1]>=H[1]){r=[H[0],H[1]]}else{r[0]=-r[0]}}clearTimeout(B[0].onCompleteTimeout);if(!I.tweenRunning&&((C===0&&r[0]>=0)||(C===H[0]&&r[0]<=H[0]))){return}g._tweenTo.call(null,x[0],z,Math.round(r[1]),G[1],u.scrollEasing);g._tweenTo.call(null,B[0],z,Math.round(r[0]),G[0],u.scrollEasing,u.overwrite,{onStart:function(){if(u.callbacks&&u.onStart&&!I.tweenRunning){if(t("onScrollStart")){F();E.callbacks.onScrollStart.call(q[0])}I.tweenRunning=true;g._onDragClasses(x);I.cbOffsets=y()}},onUpdate:function(){if(u.callbacks&&u.onUpdate){if(t("whileScrolling")){F();E.callbacks.whileScrolling.call(q[0])}}},onComplete:function(){if(u.callbacks&&u.onComplete){if(E.axis==="yx"){clearTimeout(B[0].onCompleteTimeout)}var M=B[0].idleTimer||0;B[0].onCompleteTimeout=setTimeout(function(){if(t("onScroll")){F();E.callbacks.onScroll.call(q[0])}if(t("onTotalScroll")&&r[1]>=H[1]-A&&I.cbOffsets[0]){F();E.callbacks.onTotalScroll.call(q[0])}if(t("onTotalScrollBack")&&r[1]<=w&&I.cbOffsets[1]){F();E.callbacks.onTotalScrollBack.call(q[0])}I.tweenRunning=false;B[0].idleTimer=0;g._onDragClasses(x,"hide")},M)}}});function t(M){return I&&E.callbacks[M]&&typeof E.callbacks[M]==="function"}function y(){return[E.callbacks.alwaysTriggerOffsets||C>=H[0]+L,E.callbacks.alwaysTriggerOffsets||C<=-J]}function F(){var O=[B[0].offsetTop,B[0].offsetLeft],P=[x[0].offsetTop,x[0].offsetLeft],M=[B.outerHeight(false),B.outerWidth(false)],N=[v.height(),v.width()];q[0].mcs={content:B,top:O[0],left:O[1],draggerTop:P[0],draggerLeft:P[1],topPct:Math.round((100*Math.abs(O[0]))/(Math.abs(M[0])-N[0])),leftPct:Math.round((100*Math.abs(O[1]))/(Math.abs(M[1])-N[1])),direction:u.dir}}},_tweenTo:function(r,u,s,q,A,t,J){var J=J||{},G=J.onStart||function(){},B=J.onUpdate||function(){},H=J.onComplete||function(){},z=g._getTime(),x,v=0,D=r.offsetTop,E=r.style;if(u==="left"){D=r.offsetLeft}var y=s-D;r._mcsstop=0;if(t!=="none"){C()}p();function I(){if(r._mcsstop){return}if(!v){G.call()}v=g._getTime()-z;F();if(v>=r._mcstime){r._mcstime=(v>r._mcstime)?v+x-(v-r._mcstime):v+x-1;if(r._mcstime<v+1){r._mcstime=v+1}}if(r._mcstime<q){r._mcsid=_request(I)}else{H.call()}}function F(){if(q>0){r._mcscurrVal=w(r._mcstime,D,y,q,A);E[u]=Math.round(r._mcscurrVal)+"px"}else{E[u]=s+"px"}B.call()}function p(){x=1000/60;r._mcstime=v+x;_request=(!l.requestAnimationFrame)?function(K){F();return setTimeout(K,0.01)}:l.requestAnimationFrame;r._mcsid=_request(I)}function C(){if(r._mcsid==null){return}if(!l.requestAnimationFrame){clearTimeout(r._mcsid)}else{l.cancelAnimationFrame(r._mcsid)}r._mcsid=null}function w(M,L,Q,P,N){switch(N){case"linear":case"mcsLinear":return Q*M/P+L;break;case"mcsLinearOut":M/=P;M--;return Q*Math.sqrt(1-M*M)+L;break;case"easeInOutSmooth":M/=P/2;if(M<1){return Q/2*M*M+L}M--;return -Q/2*(M*(M-2)-1)+L;break;case"easeInOutStrong":M/=P/2;if(M<1){return Q/2*Math.pow(2,10*(M-1))+L}M--;return Q/2*(-Math.pow(2,-10*M)+2)+L;break;case"easeInOut":case"mcsEaseInOut":M/=P/2;if(M<1){return Q/2*M*M*M+L}M-=2;return Q/2*(M*M*M+2)+L;break;case"easeOutSmooth":M/=P;M--;return -Q*(M*M*M*M-1)+L;break;case"easeOutStrong":return Q*(-Math.pow(2,-10*M/P)+1)+L;break;case"easeOut":case"mcsEaseOut":default:var O=(M/=P)*M,K=O*M;return L+Q*(0.499999999999997*K*O+-2.5*O*O+5.5*K+-6.5*O+4*M)}}},_getTime:function(){if(l.performance&&l.performance.now){return l.performance.now()}else{if(l.performance&&l.performance.webkitNow){return l.performance.webkitNow()}else{if(Date.now){return Date.now()}else{return new Date().getTime()}}}},_stopTween:function(){var p=this;if(p._mcsid==null){return}if(!l.requestAnimationFrame){clearTimeout(p._mcsid)}else{l.cancelAnimationFrame(p._mcsid)}p._mcsid=null;p._mcsstop=1},_delete:function(r){try{delete r}catch(q){r=null}},_mouseBtnLeft:function(p){return !(p.which&&p.which!==1)},_pointerTouch:function(q){var p=q.originalEvent.pointerType;return !(p&&p!=="touch"&&p!==2)},_isNumeric:function(p){return !isNaN(parseFloat(p))&&isFinite(p)}};h.fn[e]=function(p){if(b[p]){return b[p].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof p==="object"||!p){return b.init.apply(this,arguments)}else{h.error("Method "+p+" does not exist")}}};h[e]=function(p){if(b[p]){return b[p].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof p==="object"||!p){return b.init.apply(this,arguments)}else{h.error("Method "+p+" does not exist")}}};h[e].defaults=f;l[e]=true;h(l).load(function(){h(k)[e]()})})(jQuery,window,document);
@@ -0,0 +1,2086 @@
1
+ /*
2
+ == malihu jquery custom scrollbar plugin ==
3
+ Version: 3.0.2
4
+ Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
5
+ Author: malihu
6
+ Author URI: http://manos.malihu.gr
7
+ License: MIT License (MIT)
8
+ */
9
+
10
+ /*
11
+ Copyright 2010 Manos Malihutsakis (email: manos@malihu.gr)
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in
21
+ all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
+ THE SOFTWARE.
30
+ */
31
+
32
+ /*
33
+ The code below is fairly long, fully commented and should be normally used in development.
34
+ For production, use either the minified jquery.mCustomScrollbar.min.js script or
35
+ the production-ready jquery.mCustomScrollbar.concat.min.js which contains the plugin
36
+ and dependencies (minified).
37
+ */
38
+
39
+ ;(function($,window,document,undefined){
40
+
41
+ /*
42
+ ----------------------------------------
43
+ PLUGIN NAMESPACE, PREFIX, DEFAULT SELECTOR(S)
44
+ ----------------------------------------
45
+ */
46
+
47
+ var pluginNS="mCustomScrollbar",
48
+ pluginPfx="mCS",
49
+ defaultSelector=".mCustomScrollbar",
50
+
51
+
52
+
53
+
54
+
55
+ /*
56
+ ----------------------------------------
57
+ DEFAULT OPTIONS
58
+ ----------------------------------------
59
+ */
60
+
61
+ defaults={
62
+ /*
63
+ set element/content width programmatically
64
+ values: boolean, pixels, percentage
65
+ */
66
+ setWidth:false,
67
+ /*
68
+ set element/content height programmatically
69
+ values: boolean, pixels, percentage
70
+ */
71
+ setHeight:false,
72
+ /*
73
+ set the initial css top property of content
74
+ values: string (e.g. "-100px", "10%" etc.)
75
+ */
76
+ setTop:0,
77
+ /*
78
+ set the initial css left property of content
79
+ values: string (e.g. "-100px", "10%" etc.)
80
+ */
81
+ setLeft:0,
82
+ /*
83
+ scrollbar axis (vertical and/or horizontal scrollbars)
84
+ values (string): "y", "x", "yx"
85
+ */
86
+ axis:"y",
87
+ /*
88
+ position of scrollbar relative to content
89
+ values (string): "inside", "outside" ("outside" requires elements with position:relative)
90
+ */
91
+ scrollbarPosition:"inside",
92
+ /*
93
+ scrolling inertia
94
+ values: integer (milliseconds)
95
+ */
96
+ scrollInertia:950,
97
+ /*
98
+ auto-adjust scrollbar dragger length
99
+ values: boolean
100
+ */
101
+ autoDraggerLength:true,
102
+ /*
103
+ auto-hide scrollbar when idle
104
+ values: boolean
105
+ */
106
+ autoHideScrollbar:false,
107
+ /*
108
+ auto-expands scrollbar on mouse-over and dragging
109
+ */
110
+ autoExpandScrollbar:false,
111
+ /*
112
+ always show scrollbar, even when there's nothing to scroll
113
+ values: integer (0=disable, 1=always show dragger rail, 2=always show dragger rail, dragger and buttons), boolean
114
+ */
115
+ alwaysShowScrollbar:0,
116
+ /*
117
+ scrolling always snaps to a multiple of this number in pixels
118
+ values: integer
119
+ */
120
+ snapAmount:null,
121
+ /*
122
+ when snapping, snap with this number in pixels as an offset
123
+ values: integer
124
+ */
125
+ snapOffset:0,
126
+ /*
127
+ mouse-wheel scrolling
128
+ */
129
+ mouseWheel:{
130
+ /*
131
+ enable mouse-wheel scrolling
132
+ values: boolean
133
+ */
134
+ enable:true,
135
+ /*
136
+ scrolling amount in pixels
137
+ values: "auto", integer
138
+ */
139
+ scrollAmount:"auto",
140
+ /*
141
+ mouse-wheel scrolling axis
142
+ the default scrolling direction when both vertical and horizontal scrollbars are present
143
+ values (string): "y", "x"
144
+ */
145
+ axis:"y",
146
+ /*
147
+ prevent the default behaviour which automatically scrolls the parent element(s)
148
+ when end of scrolling is reached
149
+ values: boolean
150
+ */
151
+ preventDefault:false,
152
+ /*
153
+ the reported mouse-wheel delta value. The number of lines (translated to pixels) one wheel notch scrolls.
154
+ values: "auto", integer
155
+ "auto" uses the default OS/browser value
156
+ */
157
+ deltaFactor:"auto",
158
+ /*
159
+ normalize mouse-wheel delta to -1 or 1 (disables mouse-wheel acceleration)
160
+ values: boolean
161
+ */
162
+ normalizeDelta:false,
163
+ /*
164
+ invert mouse-wheel scrolling direction
165
+ values: boolean
166
+ */
167
+ invert:false,
168
+ /*
169
+ the tags that disable mouse-wheel when cursor is over them
170
+ */
171
+ disableOver:["select","option","keygen","datalist","textarea"]
172
+ },
173
+ /*
174
+ scrollbar buttons
175
+ */
176
+ scrollButtons:{
177
+ /*
178
+ enable scrollbar buttons
179
+ values: boolean
180
+ */
181
+ enable:false,
182
+ /*
183
+ scrollbar buttons scrolling type
184
+ values (string): "stepless", "stepped"
185
+ */
186
+ scrollType:"stepless",
187
+ /*
188
+ scrolling amount in pixels
189
+ values: "auto", integer
190
+ */
191
+ scrollAmount:"auto"
192
+ },
193
+ /*
194
+ keyboard scrolling
195
+ */
196
+ keyboard:{
197
+ /*
198
+ enable scrolling via keyboard
199
+ values: boolean
200
+ */
201
+ enable:true,
202
+ /*
203
+ keyboard scrolling type
204
+ values (string): "stepless", "stepped"
205
+ */
206
+ scrollType:"stepless",
207
+ /*
208
+ scrolling amount in pixels
209
+ values: "auto", integer
210
+ */
211
+ scrollAmount:"auto"
212
+ },
213
+ /*
214
+ enable content touch-swipe scrolling
215
+ values: boolean, integer, string (number)
216
+ integer values define the axis-specific minimum amount required for scrolling momentum
217
+ */
218
+ contentTouchScroll:25,
219
+ /*
220
+ advanced option parameters
221
+ */
222
+ advanced:{
223
+ /*
224
+ auto-expand content horizontally (for "x" or "yx" axis)
225
+ values: boolean
226
+ */
227
+ autoExpandHorizontalScroll:false,
228
+ /*
229
+ auto-scroll to elements with focus
230
+ */
231
+ autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",
232
+ /*
233
+ auto-update scrollbars on content, element or viewport resize
234
+ should be true for fluid layouts/elements, adding/removing content dynamically, hiding/showing elements, content with images etc.
235
+ values: boolean
236
+ */
237
+ updateOnContentResize:true,
238
+ /*
239
+ auto-update scrollbars each time each image inside the element is fully loaded
240
+ values: boolean
241
+ */
242
+ updateOnImageLoad:true,
243
+ /*
244
+ auto-update scrollbars based on the amount and size changes of specific selectors
245
+ useful when you need to update the scrollbar(s) automatically, each time a type of element is added, removed or changes its size
246
+ values: boolean, string (e.g. "ul li" will auto-update scrollbars each time list-items inside the element are changed)
247
+ a value of true (boolean) will auto-update scrollbars each time any element is changed
248
+ */
249
+ updateOnSelectorChange:false
250
+ },
251
+ /*
252
+ scrollbar theme
253
+ values: string
254
+ ready-to-use themes: "light", "dark", "light-2", "dark-2", "light-3", "dark-3", "light-thick", "dark-thick", "light-thin", "dark-thin",
255
+ "rounded", "rounded-dark", "rounded-dots", "rounded-dots-dark", "3d", "3d-dark", "3d-thick", "3d-thick-dark", "minimal", "minimal-dark",
256
+ "inset", "inset-dark", "inset-2", "inset-2-dark", "inset-3", "inset-3-dark"
257
+ */
258
+ theme:"light",
259
+ /*
260
+ user defined callback functions
261
+ */
262
+ callbacks:{
263
+ /*
264
+ function to call when a scroll event starts
265
+ values (function): function(){}
266
+ */
267
+ onScrollStart:false,
268
+ /*
269
+ function to call when a scroll event is complete
270
+ values (function): function(){}
271
+ */
272
+ onScroll:false,
273
+ /*
274
+ function to call when a scroll event is complete and content is scrolled all the way to the end (bottom/right)
275
+ values (function): function(){}
276
+ */
277
+ onTotalScroll:false,
278
+ /*
279
+ function to call when a scroll event is complete and content is scrolled back to the beginning (top/left)
280
+ values (function): function(){}
281
+ */
282
+ onTotalScrollBack:false,
283
+ /*
284
+ function to call when a scroll event is running
285
+ values (function): function(){}
286
+ */
287
+ whileScrolling:false,
288
+ /*
289
+ onTotalScroll offset value
290
+ values: integer (pixels)
291
+ */
292
+ onTotalScrollOffset:0,
293
+ /*
294
+ onTotalScrollBack offset value
295
+ values: integer (pixels)
296
+ */
297
+ onTotalScrollBackOffset:0,
298
+ /*
299
+ callback offsets will trigger even if content is already scrolled to the end or beginning
300
+ values: boolean
301
+ */
302
+ alwaysTriggerOffsets:true
303
+ },
304
+ /*
305
+ add scrollbar(s) on all elements matching the current selector, now and in the future
306
+ values: boolean, string
307
+ string values: "on" (enable), "once" (disable after first invocation), "off" (disable)
308
+ */
309
+ live:false,
310
+ /*
311
+ the matching set of elements (instead of the current selector) to add scrollbar(s), now and in the future
312
+ values: string (selector)
313
+ */
314
+ liveSelector:null
315
+ },
316
+
317
+
318
+
319
+
320
+
321
+ /*
322
+ ----------------------------------------
323
+ VARS, CONSTANTS
324
+ ----------------------------------------
325
+ */
326
+
327
+ totalInstances=0, /* plugin instances amount */
328
+ liveTimers={}, /* live option timers */
329
+ /* live option timers removal */
330
+ removeLiveTimers=function(selector){
331
+ if(liveTimers[selector]){
332
+ clearTimeout(liveTimers[selector]);
333
+ functions._delete.call(null,liveTimers[selector]);
334
+ }
335
+ },
336
+ oldIE=(window.attachEvent && !window.addEventListener) ? 1 : 0, /* detect IE < 9 */
337
+ touchActive=false, /* global touch state (for touch and pointer events) */
338
+
339
+
340
+
341
+
342
+
343
+ /*
344
+ ----------------------------------------
345
+ METHODS
346
+ ----------------------------------------
347
+ */
348
+
349
+ methods={
350
+
351
+ /*
352
+ plugin initialization method
353
+ creates the scrollbar(s), plugin data object and options
354
+ ----------------------------------------
355
+ */
356
+
357
+ init:function(options){
358
+
359
+ var options=$.extend(true,{},defaults,options),
360
+ selector=functions._selector.call(this); /* validate selector */
361
+
362
+ /*
363
+ if live option is enabled, monitor for elements matching the current selector and
364
+ apply scrollbar(s) when found (now and in the future)
365
+ */
366
+ if(options.live){
367
+ var liveSelector=options.liveSelector || this.selector || defaultSelector, /* live selector(s) */
368
+ $liveSelector=$(liveSelector); /* live selector(s) as jquery object */
369
+ if(options.live==="off"){
370
+ /*
371
+ disable live if requested
372
+ usage: $(selector).mCustomScrollbar({live:"off"});
373
+ */
374
+ removeLiveTimers(liveSelector);
375
+ return;
376
+ }
377
+ liveTimers[liveSelector]=setTimeout(function(){
378
+ /* call mCustomScrollbar fn on live selector(s) every half-second */
379
+ $liveSelector.mCustomScrollbar(options);
380
+ if(options.live==="once" && $liveSelector.length){
381
+ /* disable live after first invocation */
382
+ removeLiveTimers(liveSelector);
383
+ }
384
+ },500);
385
+ }else{
386
+ removeLiveTimers(liveSelector);
387
+ }
388
+
389
+ /* options backward compatibility (for versions < 3.0.0) and normalization */
390
+ options.setWidth=(options.set_width) ? options.set_width : options.setWidth;
391
+ options.setHeight=(options.set_height) ? options.set_height : options.setHeight;
392
+ options.axis=(options.horizontalScroll) ? "x" : functions._findAxis.call(null,options.axis);
393
+ options.scrollInertia=options.scrollInertia<17 ? 17 : options.scrollInertia;
394
+ if(typeof options.mouseWheel!=="object" && options.mouseWheel==true){ /* old school mouseWheel option (non-object) */
395
+ options.mouseWheel={enable:true,scrollAmount:"auto",axis:"y",preventDefault:false,deltaFactor:"auto",normalizeDelta:false,invert:false}
396
+ }
397
+ options.mouseWheel.scrollAmount=!options.mouseWheelPixels ? options.mouseWheel.scrollAmount : options.mouseWheelPixels;
398
+ options.mouseWheel.normalizeDelta=!options.advanced.normalizeMouseWheelDelta ? options.mouseWheel.normalizeDelta : options.advanced.normalizeMouseWheelDelta;
399
+ options.scrollButtons.scrollType=functions._findScrollButtonsType.call(null,options.scrollButtons.scrollType);
400
+
401
+ functions._theme.call(null,options); /* theme-specific options */
402
+
403
+ /* plugin constructor */
404
+ return $(selector).each(function(){
405
+
406
+ var $this=$(this);
407
+
408
+ if(!$this.data(pluginPfx)){ /* prevent multiple instantiations */
409
+
410
+ /* store options and create objects in jquery data */
411
+ $this.data(pluginPfx,{
412
+ idx:++totalInstances, /* instance index */
413
+ opt:options, /* options */
414
+ scrollRatio:{y:null,x:null}, /* scrollbar to content ratio */
415
+ overflowed:null, /* overflowed axis */
416
+ bindEvents:false, /* object to check if events are bound */
417
+ tweenRunning:false, /* object to check if tween is running */
418
+ sequential:{}, /* sequential scrolling object */
419
+ langDir:$this.css("direction"), /* detect/store direction (ltr or rtl) */
420
+ cbOffsets:null, /* object to check whether callback offsets always trigger */
421
+ /*
422
+ object to check how scrolling events where last triggered
423
+ "internal" (default - triggered by this script), "external" (triggered by other scripts, e.g. via scrollTo method)
424
+ usage: object.data("mCS").trigger
425
+ */
426
+ trigger:null
427
+ });
428
+
429
+ /* HTML data attributes */
430
+ var o=$this.data(pluginPfx).opt,
431
+ htmlDataAxis=$this.data("mcs-axis"),htmlDataSbPos=$this.data("mcs-scrollbar-position"),htmlDataTheme=$this.data("mcs-theme");
432
+ if(htmlDataAxis){o.axis=htmlDataAxis;} /* usage example: data-mcs-axis="y" */
433
+ if(htmlDataSbPos){o.scrollbarPosition=htmlDataSbPos;} /* usage example: data-mcs-scrollbar-position="outside" */
434
+ if(htmlDataTheme){ /* usage example: data-mcs-theme="minimal" */
435
+ o.theme=htmlDataTheme;
436
+ functions._theme.call(null,o); /* theme-specific options */
437
+ }
438
+
439
+ functions._pluginMarkup.call(this); /* add plugin markup */
440
+
441
+ methods.update.call(null,$this); /* call the update method */
442
+
443
+ }
444
+
445
+ });
446
+
447
+ },
448
+ /* ---------------------------------------- */
449
+
450
+
451
+
452
+ /*
453
+ plugin update method
454
+ updates content and scrollbar(s) values, events and status
455
+ ----------------------------------------
456
+ usage: $(selector).mCustomScrollbar("update");
457
+ */
458
+
459
+ update:function(el){
460
+
461
+ var selector=el || functions._selector.call(this); /* validate selector */
462
+
463
+ return $(selector).each(function(){
464
+
465
+ var $this=$(this);
466
+
467
+ if($this.data(pluginPfx)){ /* check if plugin has initialized */
468
+
469
+ var d=$this.data(pluginPfx),o=d.opt,
470
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
471
+ mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
472
+
473
+ if(!mCSB_container.length){return;}
474
+
475
+ if(d.tweenRunning){functions._stop.call(null,$this);} /* stop any running tweens while updating */
476
+
477
+ /* if element was disabled or destroyed, remove class(es) */
478
+ if($this.hasClass("mCS_disabled")){$this.removeClass("mCS_disabled");}
479
+ if($this.hasClass("mCS_destroyed")){$this.removeClass("mCS_destroyed");}
480
+
481
+ functions._maxHeight.call(this); /* detect/set css max-height value */
482
+
483
+ functions._expandContentHorizontally.call(this); /* expand content horizontally */
484
+
485
+ if(o.axis!=="y" && !o.advanced.autoExpandHorizontalScroll){
486
+ mCSB_container.css("width",functions._contentWidth(mCSB_container.children()));
487
+ }
488
+
489
+ d.overflowed=functions._overflowed.call(this); /* determine if scrolling is required */
490
+
491
+ functions._scrollbarVisibility.call(this); /* show/hide scrollbar(s) */
492
+
493
+ /* auto-adjust scrollbar dragger length analogous to content */
494
+ if(o.autoDraggerLength){functions._setDraggerLength.call(this);}
495
+
496
+ functions._scrollRatio.call(this); /* calculate and store scrollbar to content ratio */
497
+
498
+ functions._bindEvents.call(this); /* bind scrollbar events */
499
+
500
+ /* reset scrolling position and/or events */
501
+ var to=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)];
502
+ if(o.axis!=="x"){ /* y/yx axis */
503
+ if(!d.overflowed[0]){ /* y scrolling is not required */
504
+ functions._resetContentPosition.call(this); /* reset content position */
505
+ if(o.axis==="y"){
506
+ functions._unbindEvents.call(this);
507
+ }else if(o.axis==="yx" && d.overflowed[1]){
508
+ functions._scrollTo.call(this,$this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
509
+ }
510
+ }else if(mCSB_dragger[0].height()>mCSB_dragger[0].parent().height()){
511
+ functions._resetContentPosition.call(this); /* reset content position */
512
+ }else{ /* y scrolling is required */
513
+ functions._scrollTo.call(this,$this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
514
+ }
515
+ }
516
+ if(o.axis!=="y"){ /* x/yx axis */
517
+ if(!d.overflowed[1]){ /* x scrolling is not required */
518
+ functions._resetContentPosition.call(this); /* reset content position */
519
+ if(o.axis==="x"){
520
+ functions._unbindEvents.call(this);
521
+ }else if(o.axis==="yx" && d.overflowed[0]){
522
+ functions._scrollTo.call(this,$this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
523
+ }
524
+ }else if(mCSB_dragger[1].width()>mCSB_dragger[1].parent().width()){
525
+ functions._resetContentPosition.call(this); /* reset content position */
526
+ }else{ /* x scrolling is required */
527
+ functions._scrollTo.call(this,$this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
528
+ }
529
+ }
530
+
531
+ functions._autoUpdate.call(this); /* initialize automatic updating (for dynamic content, fluid layouts etc.) */
532
+
533
+ }
534
+
535
+ });
536
+
537
+ },
538
+ /* ---------------------------------------- */
539
+
540
+
541
+
542
+ /*
543
+ plugin scrollTo method
544
+ triggers a scrolling event to a specific value
545
+ ----------------------------------------
546
+ usage: $(selector).mCustomScrollbar("scrollTo",value,options);
547
+ */
548
+
549
+ scrollTo:function(val,options){
550
+
551
+ /* prevent silly things like $(selector).mCustomScrollbar("scrollTo",undefined); */
552
+ if(typeof val=="undefined" || val==null){return;}
553
+
554
+ var selector=functions._selector.call(this); /* validate selector */
555
+
556
+ return $(selector).each(function(){
557
+
558
+ var $this=$(this);
559
+
560
+ if($this.data(pluginPfx)){ /* check if plugin has initialized */
561
+
562
+ var d=$this.data(pluginPfx),o=d.opt,
563
+ /* method default options */
564
+ methodDefaults={
565
+ trigger:"external", /* method is by default triggered externally (e.g. from other scripts) */
566
+ scrollInertia:o.scrollInertia, /* scrolling inertia (animation duration) */
567
+ scrollEasing:"mcsEaseInOut", /* animation easing */
568
+ moveDragger:false, /* move dragger instead of content */
569
+ callbacks:true, /* enable/disable callbacks */
570
+ onStart:true,
571
+ onUpdate:true,
572
+ onComplete:true
573
+ },
574
+ methodOptions=$.extend(true,{},methodDefaults,options),
575
+ to=functions._arr.call(this,val),dur=methodOptions.scrollInertia < 17 ? 17 : methodOptions.scrollInertia;
576
+
577
+ /* translate yx values to actual scroll-to positions */
578
+ to[0]=functions._to.call(this,to[0],"y");
579
+ to[1]=functions._to.call(this,to[1],"x");
580
+
581
+ /*
582
+ check if scroll-to value moves the dragger instead of content.
583
+ Only pixel values apply on dragger (e.g. 100, "100px", "-=100" etc.)
584
+ */
585
+ if(methodOptions.moveDragger){
586
+ to[0]*=d.scrollRatio.y;
587
+ to[1]*=d.scrollRatio.x;
588
+ }
589
+
590
+ methodOptions.dur=dur;
591
+
592
+ setTimeout(function(){
593
+ /* do the scrolling */
594
+ if(to[0]!==null && typeof to[0]!=="undefined" && o.axis!=="x" && d.overflowed[0]){ /* scroll y */
595
+ methodOptions.dir="y";
596
+ methodOptions.overwrite="all";
597
+ functions._scrollTo.call(this,$this,to[0].toString(),methodOptions);
598
+ }
599
+ if(to[1]!==null && typeof to[1]!=="undefined" && o.axis!=="y" && d.overflowed[1]){ /* scroll x */
600
+ methodOptions.dir="x";
601
+ methodOptions.overwrite="none";
602
+ functions._scrollTo.call(this,$this,to[1].toString(),methodOptions);
603
+ }
604
+ },60);
605
+
606
+ }
607
+
608
+ });
609
+
610
+ },
611
+ /* ---------------------------------------- */
612
+
613
+
614
+
615
+ /*
616
+ plugin stop method
617
+ stops scrolling animation
618
+ ----------------------------------------
619
+ usage: $(selector).mCustomScrollbar("stop");
620
+ */
621
+ stop:function(){
622
+
623
+ var selector=functions._selector.call(this); /* validate selector */
624
+
625
+ return $(selector).each(function(){
626
+
627
+ var $this=$(this);
628
+
629
+ if($this.data(pluginPfx)){ /* check if plugin has initialized */
630
+
631
+ functions._stop.call(null,$this);
632
+
633
+ }
634
+
635
+ });
636
+
637
+ },
638
+ /* ---------------------------------------- */
639
+
640
+
641
+
642
+ /*
643
+ plugin disable method
644
+ temporarily disables the scrollbar(s)
645
+ ----------------------------------------
646
+ usage: $(selector).mCustomScrollbar("disable",reset);
647
+ reset (boolean): resets content position to 0
648
+ */
649
+ disable:function(r){
650
+
651
+ var selector=functions._selector.call(this); /* validate selector */
652
+
653
+ return $(selector).each(function(){
654
+
655
+ var $this=$(this);
656
+
657
+ if($this.data(pluginPfx)){ /* check if plugin has initialized */
658
+
659
+ var d=$this.data(pluginPfx),o=d.opt;
660
+
661
+ functions._autoUpdate.call(this,"remove"); /* remove automatic updating */
662
+
663
+ functions._unbindEvents.call(this); /* unbind events */
664
+
665
+ if(r){functions._resetContentPosition.call(this);} /* reset content position */
666
+
667
+ functions._scrollbarVisibility.call(this,true); /* show/hide scrollbar(s) */
668
+
669
+ $this.addClass("mCS_disabled"); /* add disable class */
670
+
671
+ }
672
+
673
+ });
674
+
675
+ },
676
+ /* ---------------------------------------- */
677
+
678
+
679
+
680
+ /*
681
+ plugin destroy method
682
+ completely removes the scrollbar(s) and returns the element to its original state
683
+ ----------------------------------------
684
+ usage: $(selector).mCustomScrollbar("destroy");
685
+ */
686
+ destroy:function(){
687
+
688
+ var selector=functions._selector.call(this); /* validate selector */
689
+
690
+ return $(selector).each(function(){
691
+
692
+ var $this=$(this);
693
+
694
+ if($this.data(pluginPfx)){ /* check if plugin has initialized */
695
+
696
+ var d=$this.data(pluginPfx),o=d.opt,
697
+ mCustomScrollBox=$("#mCSB_"+d.idx),
698
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
699
+ scrollbar=$(".mCSB_"+d.idx+"_scrollbar");
700
+
701
+ if(o.live){removeLiveTimers(selector);} /* remove live timer */
702
+
703
+ functions._autoUpdate.call(this,"remove"); /* remove automatic updating */
704
+
705
+ functions._unbindEvents.call(this); /* unbind events */
706
+
707
+ functions._resetContentPosition.call(this); /* reset content position */
708
+
709
+ $this.removeData(pluginPfx); /* remove plugin data object */
710
+
711
+ functions._delete.call(null,this.mcs); /* delete callbacks object */
712
+
713
+ /* remove plugin markup */
714
+ scrollbar.remove(); /* remove scrollbar(s) first (those can be either inside or outside plugin's inner wrapper) */
715
+ mCustomScrollBox.replaceWith(mCSB_container.contents()); /* replace plugin's inner wrapper with the original content */
716
+ /* remove plugin classes from the element and add destroy class */
717
+ $this.removeClass(pluginNS+" _"+pluginPfx+"_"+d.idx+" mCS-autoHide mCS-dir-rtl mCS_no_scrollbar mCS_disabled").addClass("mCS_destroyed");
718
+
719
+ }
720
+
721
+ });
722
+
723
+ }
724
+ /* ---------------------------------------- */
725
+
726
+ },
727
+
728
+
729
+
730
+
731
+
732
+ /*
733
+ ----------------------------------------
734
+ FUNCTIONS
735
+ ----------------------------------------
736
+ */
737
+
738
+ functions={
739
+
740
+ /* validates selector (if selector is invalid or undefined uses the default one) */
741
+ _selector:function(){
742
+ return (typeof $(this)!=="object" || $(this).length<1) ? defaultSelector : this;
743
+ },
744
+ /* -------------------- */
745
+
746
+ /* changes options according to theme */
747
+ _theme:function(obj){
748
+ var fixedSizeScrollbarThemes=["rounded","rounded-dark","rounded-dots","rounded-dots-dark"],
749
+ nonExpandedScrollbarThemes=["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"],
750
+ disabledScrollButtonsThemes=["minimal","minimal-dark"],
751
+ enabledAutoHideScrollbarThemes=["minimal","minimal-dark"],
752
+ scrollbarPositionOutsideThemes=["minimal","minimal-dark"];
753
+ obj.autoDraggerLength=$.inArray(obj.theme,fixedSizeScrollbarThemes) > -1 ? false : obj.autoDraggerLength;
754
+ obj.autoExpandScrollbar=$.inArray(obj.theme,nonExpandedScrollbarThemes) > -1 ? false : obj.autoExpandScrollbar;
755
+ obj.scrollButtons.enable=$.inArray(obj.theme,disabledScrollButtonsThemes) > -1 ? false : obj.scrollButtons.enable;
756
+ obj.autoHideScrollbar=$.inArray(obj.theme,enabledAutoHideScrollbarThemes) > -1 ? true : obj.autoHideScrollbar;
757
+ obj.scrollbarPosition=$.inArray(obj.theme,scrollbarPositionOutsideThemes) > -1 ? "outside" : obj.scrollbarPosition;
758
+ },
759
+ /* -------------------- */
760
+
761
+
762
+ /* normalizes axis option to valid values: "y", "x", "yx" */
763
+ _findAxis:function(val){
764
+ return (val==="yx" || val==="xy" || val==="auto") ? "yx" : (val==="x" || val==="horizontal") ? "x" : "y";
765
+ },
766
+ /* -------------------- */
767
+
768
+
769
+ /* normalizes scrollButtons.scrollType option to valid values: "stepless", "stepped" */
770
+ _findScrollButtonsType:function(val){
771
+ return (val==="stepped" || val==="pixels" || val==="step" || val==="click") ? "stepped" : "stepless";
772
+ },
773
+ /* -------------------- */
774
+
775
+
776
+ /* generates plugin markup */
777
+ _pluginMarkup:function(){
778
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
779
+ expandClass=o.autoExpandScrollbar ? " mCSB_scrollTools_onDrag_expand" : "",
780
+ scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='mCSB_draggerContainer'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='mCSB_draggerContainer'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
781
+ wrapperClass=o.axis==="yx" ? "mCSB_vertical_horizontal" : o.axis==="x" ? "mCSB_horizontal" : "mCSB_vertical",
782
+ scrollbars=o.axis==="yx" ? scrollbar[0]+scrollbar[1] : o.axis==="x" ? scrollbar[1] : scrollbar[0],
783
+ contentWrapper=o.axis==="yx" ? "<div id='mCSB_"+d.idx+"_container_wrapper' class='mCSB_container_wrapper' />" : "",
784
+ autoHideClass=o.autoHideScrollbar ? " mCS-autoHide" : "",
785
+ scrollbarDirClass=(o.axis!=="x" && d.langDir==="rtl") ? " mCS-dir-rtl" : "";
786
+ if(o.setWidth){$this.css("width",o.setWidth);} /* set element width */
787
+ if(o.setHeight){$this.css("height",o.setHeight);} /* set element height */
788
+ o.setLeft=(o.axis!=="y" && d.langDir==="rtl") ? "989999px" : o.setLeft; /* adjust left position for rtl direction */
789
+ $this.addClass(pluginNS+" _"+pluginPfx+"_"+d.idx+autoHideClass+scrollbarDirClass).wrapInner("<div id='mCSB_"+d.idx+"' class='mCustomScrollBox mCS-"+o.theme+" "+wrapperClass+"'><div id='mCSB_"+d.idx+"_container' class='mCSB_container' style='position:relative; top:"+o.setTop+"; left:"+o.setLeft+";' dir="+d.langDir+" /></div>");
790
+ var mCustomScrollBox=$("#mCSB_"+d.idx),
791
+ mCSB_container=$("#mCSB_"+d.idx+"_container");
792
+ if(o.axis!=="y" && !o.advanced.autoExpandHorizontalScroll){
793
+ mCSB_container.css("width",functions._contentWidth(mCSB_container.children()));
794
+ }
795
+ if(o.scrollbarPosition==="outside"){
796
+ if($this.css("position")==="static"){ /* requires elements with non-static position */
797
+ $this.css("position","relative");
798
+ }
799
+ $this.css("overflow","visible");
800
+ mCustomScrollBox.addClass("mCSB_outside").after(scrollbars);
801
+ }else{
802
+ mCustomScrollBox.addClass("mCSB_inside").append(scrollbars);
803
+ mCSB_container.wrap(contentWrapper);
804
+ }
805
+ functions._scrollButtons.call(this); /* add scrollbar buttons */
806
+ /* minimum dragger length */
807
+ var mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
808
+ mCSB_dragger[0].css("min-height",mCSB_dragger[0].height());
809
+ mCSB_dragger[1].css("min-width",mCSB_dragger[1].width());
810
+ },
811
+ /* -------------------- */
812
+
813
+
814
+ /* calculates content width */
815
+ _contentWidth:function(el){
816
+ return Math.max.apply(Math,el.map(function(){return $(this).outerWidth(true);}).get());
817
+ },
818
+ /* -------------------- */
819
+
820
+
821
+ /* expands content horizontally */
822
+ _expandContentHorizontally:function(){
823
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
824
+ mCSB_container=$("#mCSB_"+d.idx+"_container");
825
+ if(o.advanced.autoExpandHorizontalScroll && o.axis!=="y"){
826
+ /*
827
+ wrap content with an infinite width div and set its position to absolute and width to auto.
828
+ Setting width to auto before calculating the actual width is important!
829
+ We must let the browser set the width as browser zoom values are impossible to calculate.
830
+ */
831
+ mCSB_container.css({"position":"absolute","width":"auto"})
832
+ .wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />")
833
+ .css({ /* set actual width, original position and un-wrap */
834
+ /*
835
+ get the exact width (with decimals) and then round-up.
836
+ Using jquery outerWidth() will round the width value which will mess up with inner elements that have non-integer width
837
+ */
838
+ "width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),
839
+ "position":"relative"
840
+ }).unwrap();
841
+ }
842
+ },
843
+ /* -------------------- */
844
+
845
+
846
+ /* adds scrollbar buttons */
847
+ _scrollButtons:function(){
848
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
849
+ mCSB_scrollTools=$(".mCSB_"+d.idx+"_scrollbar:first"),
850
+ btnHTML=[
851
+ "<a href='#' class='mCSB_buttonUp' oncontextmenu='return false;' />","<a href='#' class='mCSB_buttonDown' oncontextmenu='return false;' />",
852
+ "<a href='#' class='mCSB_buttonLeft' oncontextmenu='return false;' />","<a href='#' class='mCSB_buttonRight' oncontextmenu='return false;' />"
853
+ ],
854
+ btn=[(o.axis==="x" ? btnHTML[2] : btnHTML[0]),(o.axis==="x" ? btnHTML[3] : btnHTML[1]),btnHTML[2],btnHTML[3]];
855
+ if(o.scrollButtons.enable){
856
+ mCSB_scrollTools.prepend(btn[0]).append(btn[1]).next(".mCSB_scrollTools").prepend(btn[2]).append(btn[3]);
857
+ }
858
+ },
859
+ /* -------------------- */
860
+
861
+
862
+ /* detects/sets css max-height value */
863
+ _maxHeight:function(){
864
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
865
+ mCustomScrollBox=$("#mCSB_"+d.idx),
866
+ mh=$this.css("max-height"),pct=mh.indexOf("%")!==-1,
867
+ bs=$this.css("box-sizing");
868
+ if(mh!=="none"){
869
+ var val=pct ? $this.parent().height()*parseInt(mh)/100 : parseInt(mh);
870
+ /* if element's css box-sizing is "border-box", subtract any paddings and/or borders from max-height value */
871
+ if(bs==="border-box"){val-=(($this.innerHeight()-$this.height())+($this.outerHeight()-$this.innerHeight()));}
872
+ mCustomScrollBox.css("max-height",Math.round(val));
873
+ }
874
+ },
875
+ /* -------------------- */
876
+
877
+
878
+ /* auto-adjusts scrollbar dragger length */
879
+ _setDraggerLength:function(){
880
+ var $this=$(this),d=$this.data(pluginPfx),
881
+ mCustomScrollBox=$("#mCSB_"+d.idx),
882
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
883
+ mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
884
+ ratio=[mCustomScrollBox.height()/mCSB_container.outerHeight(false),mCustomScrollBox.width()/mCSB_container.outerWidth(false)],
885
+ l=[
886
+ parseInt(mCSB_dragger[0].css("min-height")),Math.round(ratio[0]*mCSB_dragger[0].parent().height()),
887
+ parseInt(mCSB_dragger[1].css("min-width")),Math.round(ratio[1]*mCSB_dragger[1].parent().width())
888
+ ],
889
+ h=oldIE && (l[1]<l[0]) ? l[0] : l[1],w=oldIE && (l[3]<l[2]) ? l[2] : l[3];
890
+ mCSB_dragger[0].css({
891
+ "height":h,"max-height":(mCSB_dragger[0].parent().height()-10)
892
+ }).find(".mCSB_dragger_bar").css({"line-height":l[0]+"px"});
893
+ mCSB_dragger[1].css({
894
+ "width":w,"max-width":(mCSB_dragger[1].parent().width()-10)
895
+ });
896
+ },
897
+ /* -------------------- */
898
+
899
+
900
+ /* calculates scrollbar to content ratio */
901
+ _scrollRatio:function(){
902
+ var $this=$(this),d=$this.data(pluginPfx),
903
+ mCustomScrollBox=$("#mCSB_"+d.idx),
904
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
905
+ mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
906
+ scrollAmount=[mCSB_container.outerHeight(false)-mCustomScrollBox.height(),mCSB_container.outerWidth(false)-mCustomScrollBox.width()],
907
+ ratio=[
908
+ scrollAmount[0]/(mCSB_dragger[0].parent().height()-mCSB_dragger[0].height()),
909
+ scrollAmount[1]/(mCSB_dragger[1].parent().width()-mCSB_dragger[1].width())
910
+ ];
911
+ d.scrollRatio={y:ratio[0],x:ratio[1]};
912
+ },
913
+ /* -------------------- */
914
+
915
+
916
+ /* toggles scrolling classes */
917
+ _onDragClasses:function(el,action,xpnd){
918
+ var expandClass=xpnd ? "mCSB_dragger_onDrag_expanded" : "",classes=["mCSB_dragger_onDrag","mCSB_scrollTools_onDrag"],
919
+ scrollbar=el.closest(".mCSB_scrollTools");
920
+ if(action==="active"){
921
+ el.toggleClass(classes[0]+" "+expandClass); scrollbar.toggleClass(classes[1]);
922
+ el[0]._draggable=el[0]._draggable ? 0 : 1;
923
+ }else{
924
+ if(!el[0]._draggable){
925
+ if(action==="hide"){
926
+ el.removeClass(classes[0]); scrollbar.removeClass(classes[1]);
927
+ }else{
928
+ el.addClass(classes[0]); scrollbar.addClass(classes[1]);
929
+ }
930
+ }
931
+ }
932
+ },
933
+ /* -------------------- */
934
+
935
+
936
+ /* checks if content overflows its container to determine if scrolling is required */
937
+ _overflowed:function(){
938
+ var $this=$(this),d=$this.data(pluginPfx),
939
+ mCustomScrollBox=$("#mCSB_"+d.idx),
940
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
941
+ contentHeight=d.overflowed==null ? mCSB_container.height() : mCSB_container.outerHeight(false),
942
+ contentWidth=d.overflowed==null ? mCSB_container.width() : mCSB_container.outerWidth(false);
943
+ return [contentHeight>mCustomScrollBox.height(),contentWidth>mCustomScrollBox.width()];
944
+ },
945
+ /* -------------------- */
946
+
947
+
948
+ /* resets content position to 0 */
949
+ _resetContentPosition:function(){
950
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
951
+ mCustomScrollBox=$("#mCSB_"+d.idx),
952
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
953
+ mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
954
+ functions._stop($this); /* stop any current scrolling before resetting */
955
+ if((o.axis!=="x" && !d.overflowed[0]) || (o.axis==="y" && d.overflowed[0])){mCSB_dragger[0].add(mCSB_container).css("top",0);} /* reset y */
956
+ if((o.axis!=="y" && !d.overflowed[1]) || (o.axis==="x" && d.overflowed[1])){ /* reset x */
957
+ var cx=dx=0;
958
+ if(d.langDir==="rtl"){ /* adjust left position for rtl direction */
959
+ cx=mCustomScrollBox.width()-mCSB_container.outerWidth(false);
960
+ dx=Math.abs(cx/d.scrollRatio.x);
961
+ }
962
+ mCSB_container.css("left",cx);
963
+ mCSB_dragger[1].css("left",dx);
964
+ }
965
+ },
966
+ /* -------------------- */
967
+
968
+
969
+ /* binds scrollbar events */
970
+ _bindEvents:function(){
971
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt;
972
+ if(!d.bindEvents){ /* check if events are already bound */
973
+ functions._draggable.call(this);
974
+ if(o.contentTouchScroll){functions._contentDraggable.call(this);}
975
+ if(o.mouseWheel.enable){ /* bind mousewheel fn when plugin is available */
976
+ function _mwt(){
977
+ mousewheelTimeout=setTimeout(function(){
978
+ if(!$.event.special.mousewheel){
979
+ _mwt();
980
+ }else{
981
+ clearTimeout(mousewheelTimeout);
982
+ functions._mousewheel.call($this[0]);
983
+ }
984
+ },1000);
985
+ }
986
+ var mousewheelTimeout;
987
+ _mwt();
988
+ }
989
+ functions._draggerRail.call(this);
990
+ functions._wrapperScroll.call(this);
991
+ if(o.advanced.autoScrollOnFocus){functions._focus.call(this);}
992
+ if(o.scrollButtons.enable){functions._buttons.call(this);}
993
+ if(o.keyboard.enable){functions._keyboard.call(this);}
994
+ d.bindEvents=true;
995
+ }
996
+ },
997
+ /* -------------------- */
998
+
999
+
1000
+ /* unbinds scrollbar events */
1001
+ _unbindEvents:function(){
1002
+ var $this=$(this),d=$this.data(pluginPfx),
1003
+ namespace=pluginPfx+"_"+d.idx,
1004
+ sb=".mCSB_"+d.idx+"_scrollbar",
1005
+ sel=$("#mCSB_"+d.idx+",#mCSB_"+d.idx+"_container,#mCSB_"+d.idx+"_container_wrapper,"+sb+" .mCSB_draggerContainer,#mCSB_"+d.idx+"_dragger_vertical,#mCSB_"+d.idx+"_dragger_horizontal,"+sb+">a"),
1006
+ mCSB_container=$("#mCSB_"+d.idx+"_container");
1007
+ if(d.bindEvents){ /* check if events are bound */
1008
+ /* unbind namespaced events from document/selectors */
1009
+ $(document).unbind("."+namespace);
1010
+ sel.each(function(){
1011
+ $(this).unbind("."+namespace);
1012
+ });
1013
+ /* clear and delete timeouts/objects */
1014
+ clearTimeout($this[0]._focusTimeout); functions._delete.call(null,$this[0]._focusTimeout);
1015
+ clearTimeout(d.sequential.step); functions._delete.call(null,d.sequential.step);
1016
+ clearTimeout(mCSB_container[0].onCompleteTimeout); functions._delete.call(null,mCSB_container[0].onCompleteTimeout);
1017
+ d.bindEvents=false;
1018
+ }
1019
+ },
1020
+ /* -------------------- */
1021
+
1022
+
1023
+ /* toggles scrollbar visibility */
1024
+ _scrollbarVisibility:function(disabled){
1025
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1026
+ contentWrapper=$("#mCSB_"+d.idx+"_container_wrapper"),
1027
+ content=contentWrapper.length ? contentWrapper : $("#mCSB_"+d.idx+"_container"),
1028
+ scrollbar=[$("#mCSB_"+d.idx+"_scrollbar_vertical"),$("#mCSB_"+d.idx+"_scrollbar_horizontal")],
1029
+ mCSB_dragger=[scrollbar[0].find(".mCSB_dragger"),scrollbar[1].find(".mCSB_dragger")];
1030
+ if(o.axis!=="x"){
1031
+ if(d.overflowed[0] && !disabled){
1032
+ scrollbar[0].add(mCSB_dragger[0]).add(scrollbar[0].children("a")).css("display","block");
1033
+ content.removeClass("mCS_no_scrollbar_y mCS_y_hidden");
1034
+ }else{
1035
+ if(o.alwaysShowScrollbar){
1036
+ if(o.alwaysShowScrollbar!==2){mCSB_dragger[0].add(scrollbar[0].children("a")).css("display","none");}
1037
+ content.removeClass("mCS_y_hidden");
1038
+ }else{
1039
+ scrollbar[0].css("display","none");
1040
+ content.addClass("mCS_y_hidden");
1041
+ }
1042
+ content.addClass("mCS_no_scrollbar_y");
1043
+ }
1044
+ }
1045
+ if(o.axis!=="y"){
1046
+ if(d.overflowed[1] && !disabled){
1047
+ scrollbar[1].add(mCSB_dragger[1]).add(scrollbar[1].children("a")).css("display","block");
1048
+ content.removeClass("mCS_no_scrollbar_x mCS_x_hidden");
1049
+ }else{
1050
+ if(o.alwaysShowScrollbar){
1051
+ if(o.alwaysShowScrollbar!==2){mCSB_dragger[1].add(scrollbar[1].children("a")).css("display","none");}
1052
+ content.removeClass("mCS_x_hidden");
1053
+ }else{
1054
+ scrollbar[1].css("display","none");
1055
+ content.addClass("mCS_x_hidden");
1056
+ }
1057
+ content.addClass("mCS_no_scrollbar_x");
1058
+ }
1059
+ }
1060
+ if(!d.overflowed[0] && !d.overflowed[1]){
1061
+ $this.addClass("mCS_no_scrollbar");
1062
+ }else{
1063
+ $this.removeClass("mCS_no_scrollbar");
1064
+ }
1065
+ },
1066
+ /* -------------------- */
1067
+
1068
+
1069
+ /* returns input coordinates of pointer, touch and mouse events (relative to document) */
1070
+ _coordinates:function(e){
1071
+ var t=e.type;
1072
+ switch(t){
1073
+ case "pointerdown": case "MSPointerDown": case "pointermove": case "MSPointerMove": case "pointerup": case "MSPointerUp":
1074
+ return [e.originalEvent.pageY,e.originalEvent.pageX];
1075
+ break;
1076
+ case "touchstart": case "touchmove": case "touchend":
1077
+ var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
1078
+ return [touch.pageY,touch.pageX];
1079
+ break;
1080
+ default:
1081
+ return [e.pageY,e.pageX];
1082
+ }
1083
+ },
1084
+ /* -------------------- */
1085
+
1086
+
1087
+ /*
1088
+ SCROLLBAR DRAG EVENTS
1089
+ scrolls content via scrollbar dragging
1090
+ */
1091
+ _draggable:function(){
1092
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1093
+ namespace=pluginPfx+"_"+d.idx,
1094
+ draggerId=["mCSB_"+d.idx+"_dragger_vertical","mCSB_"+d.idx+"_dragger_horizontal"],
1095
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1096
+ mCSB_dragger=$("#"+draggerId[0]+",#"+draggerId[1]),
1097
+ draggable,dragY,dragX;
1098
+ mCSB_dragger.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
1099
+ e.stopImmediatePropagation();
1100
+ e.preventDefault();
1101
+ if(!functions._mouseBtnLeft(e)){return;} /* left mouse button only */
1102
+ touchActive=true;
1103
+ if(oldIE){document.onselectstart=function(){return false;}} /* disable text selection for IE < 9 */
1104
+ _iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
1105
+ functions._stop($this);
1106
+ draggable=$(this);
1107
+ var offset=draggable.offset(),y=functions._coordinates(e)[0]-offset.top,x=functions._coordinates(e)[1]-offset.left,
1108
+ h=draggable.height()+offset.top,w=draggable.width()+offset.left;
1109
+ if(y<h && y>0 && x<w && x>0){
1110
+ dragY=y;
1111
+ dragX=x;
1112
+ }
1113
+ functions._onDragClasses(draggable,"active",o.autoExpandScrollbar);
1114
+ }).bind("touchmove."+namespace,function(e){
1115
+ e.stopImmediatePropagation();
1116
+ e.preventDefault();
1117
+ var offset=draggable.offset(),y=functions._coordinates(e)[0]-offset.top,x=functions._coordinates(e)[1]-offset.left;
1118
+ _drag(dragY,dragX,y,x);
1119
+ });
1120
+ $(document).bind("mousemove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace,function(e){
1121
+ if(draggable){
1122
+ var offset=draggable.offset(),y=functions._coordinates(e)[0]-offset.top,x=functions._coordinates(e)[1]-offset.left;
1123
+ if(dragY===y){return;} /* has it really moved? */
1124
+ _drag(dragY,dragX,y,x);
1125
+ }
1126
+ }).add(mCSB_dragger).bind("mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
1127
+ if(draggable){
1128
+ functions._onDragClasses(draggable,"active",o.autoExpandScrollbar);
1129
+ draggable=null;
1130
+ }
1131
+ touchActive=false;
1132
+ if(oldIE){document.onselectstart=null;} /* enable text selection for IE < 9 */
1133
+ _iframe(true); /* enable iframes events */
1134
+ });
1135
+ function _iframe(evt){
1136
+ var el=mCSB_container.find("iframe");
1137
+ if(!el.length){return;} /* check if content contains iframes */
1138
+ var val=!evt ? "none" : "auto";
1139
+ el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */
1140
+ }
1141
+ function _drag(dragY,dragX,y,x){
1142
+ mCSB_container[0].idleTimer=o.scrollInertia<233 ? 250 : 0;
1143
+ if(draggable.attr("id")===draggerId[1]){
1144
+ var dir="x",to=((draggable[0].offsetLeft-dragX)+x)*d.scrollRatio.x;
1145
+ }else{
1146
+ var dir="y",to=((draggable[0].offsetTop-dragY)+y)*d.scrollRatio.y;
1147
+ }
1148
+ functions._scrollTo($this,to.toString(),{dir:dir,drag:true});
1149
+ }
1150
+ },
1151
+ /* -------------------- */
1152
+
1153
+
1154
+ /*
1155
+ TOUCH SWIPE EVENTS
1156
+ scrolls content via touch swipe
1157
+ Emulates the native touch-swipe scrolling with momentum found in iOS, Android and WP devices
1158
+ */
1159
+ _contentDraggable:function(){
1160
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1161
+ namespace=pluginPfx+"_"+d.idx,
1162
+ mCustomScrollBox=$("#mCSB_"+d.idx),
1163
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1164
+ mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
1165
+ dragY,dragX,touchStartY,touchStartX,touchMoveY=[],touchMoveX=[],startTime,runningTime,endTime,distance,speed,amount,
1166
+ durA=0,durB,overwrite=o.axis==="yx" ? "none" : "all";
1167
+ mCSB_container.bind("touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
1168
+ if(!functions._pointerTouch(e) || touchActive){return;}
1169
+ var offset=mCSB_container.offset();
1170
+ dragY=functions._coordinates(e)[0]-offset.top;
1171
+ dragX=functions._coordinates(e)[1]-offset.left;
1172
+ }).bind("touchmove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace,function(e){
1173
+ if(!functions._pointerTouch(e) || touchActive){return;}
1174
+ e.stopImmediatePropagation();
1175
+ runningTime=functions._getTime();
1176
+ var offset=mCustomScrollBox.offset(),y=functions._coordinates(e)[0]-offset.top,x=functions._coordinates(e)[1]-offset.left,
1177
+ easing="mcsLinearOut";
1178
+ touchMoveY.push(y);
1179
+ touchMoveX.push(x);
1180
+ if(d.overflowed[0]){
1181
+ var limit=mCSB_dragger[0].parent().height()-mCSB_dragger[0].height(),
1182
+ prevent=((dragY-y)>0 && (y-dragY)>-(limit*d.scrollRatio.y));
1183
+ }
1184
+ if(d.overflowed[1]){
1185
+ var limitX=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(),
1186
+ preventX=((dragX-x)>0 && (x-dragX)>-(limitX*d.scrollRatio.x));
1187
+ }
1188
+ if(prevent || preventX){e.preventDefault();} /* prevent native document scrolling */
1189
+ amount=o.axis==="yx" ? [(dragY-y),(dragX-x)] : o.axis==="x" ? [null,(dragX-x)] : [(dragY-y),null];
1190
+ mCSB_container[0].idleTimer=250;
1191
+ if(d.overflowed[0]){_drag(amount[0],durA,easing,"y","all",true);}
1192
+ if(d.overflowed[1]){_drag(amount[1],durA,easing,"x",overwrite,true);}
1193
+ });
1194
+ mCustomScrollBox.bind("touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
1195
+ if(!functions._pointerTouch(e) || touchActive){return;}
1196
+ e.stopImmediatePropagation();
1197
+ functions._stop($this);
1198
+ startTime=functions._getTime();
1199
+ var offset=mCustomScrollBox.offset();
1200
+ touchStartY=functions._coordinates(e)[0]-offset.top;
1201
+ touchStartX=functions._coordinates(e)[1]-offset.left;
1202
+ touchMoveY=[]; touchMoveX=[];
1203
+ }).bind("touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
1204
+ if(!functions._pointerTouch(e) || touchActive){return;}
1205
+ e.stopImmediatePropagation();
1206
+ endTime=functions._getTime();
1207
+ var offset=mCustomScrollBox.offset(),y=functions._coordinates(e)[0]-offset.top,x=functions._coordinates(e)[1]-offset.left;
1208
+ if((endTime-runningTime)>30){return;}
1209
+ speed=1000/(endTime-startTime);
1210
+ var easing="mcsEaseOut",slow=speed<2.5,
1211
+ diff=slow ? [touchMoveY[touchMoveY.length-2],touchMoveX[touchMoveX.length-2]] : [0,0];
1212
+ distance=slow ? [(y-diff[0]),(x-diff[1])] : [y-touchStartY,x-touchStartX];
1213
+ var absDistance=[Math.abs(distance[0]),Math.abs(distance[1])];
1214
+ speed=slow ? [Math.abs(distance[0]/4),Math.abs(distance[1]/4)] : [speed,speed];
1215
+ var a=[
1216
+ Math.abs(mCSB_container[0].offsetTop)-(distance[0]*_m((absDistance[0]/speed[0]),speed[0])),
1217
+ Math.abs(mCSB_container[0].offsetLeft)-(distance[1]*_m((absDistance[1]/speed[1]),speed[1]))
1218
+ ];
1219
+ amount=o.axis==="yx" ? [a[0],a[1]] : o.axis==="x" ? [null,a[1]] : [a[0],null];
1220
+ durB=[(absDistance[0]*4)+o.scrollInertia,(absDistance[1]*4)+o.scrollInertia];
1221
+ var md=parseInt(o.contentTouchScroll) || 0; /* absolute minimum distance required */
1222
+ amount[0]=absDistance[0]>md ? amount[0] : 0;
1223
+ amount[1]=absDistance[1]>md ? amount[1] : 0;
1224
+ if(d.overflowed[0]){_drag(amount[0],durB[0],easing,"y",overwrite,false);}
1225
+ if(d.overflowed[1]){_drag(amount[1],durB[1],easing,"x",overwrite,false);}
1226
+ });
1227
+ function _m(ds,s){
1228
+ var r=[s*1.5,s*2,s/1.5,s/2];
1229
+ if(ds>90){
1230
+ return s>4 ? r[0] : r[3];
1231
+ }else if(ds>60){
1232
+ return s>3 ? r[3] : r[2];
1233
+ }else if(ds>30){
1234
+ return s>8 ? r[1] : s>6 ? r[0] : s>4 ? s : r[2];
1235
+ }else{
1236
+ return s>8 ? s : r[3];
1237
+ }
1238
+ }
1239
+ function _drag(amount,dur,easing,dir,overwrite,drag){
1240
+ if(!amount){return;}
1241
+ functions._scrollTo($this,amount.toString(),{dur:dur,scrollEasing:easing,dir:dir,overwrite:overwrite,drag:drag});
1242
+ }
1243
+ },
1244
+ /* -------------------- */
1245
+
1246
+
1247
+ /*
1248
+ MOUSE WHEEL EVENT
1249
+ scrolls content via mouse-wheel
1250
+ via mouse-wheel plugin (https://github.com/brandonaaron/jquery-mousewheel)
1251
+ */
1252
+ _mousewheel:function(){
1253
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1254
+ namespace=pluginPfx+"_"+d.idx,
1255
+ mCustomScrollBox=$("#mCSB_"+d.idx),
1256
+ mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
1257
+ mCustomScrollBox.bind("mousewheel."+namespace,function(e,delta){
1258
+ functions._stop($this);
1259
+ if(functions._disableMousewheel($this,e.target)){return;} /* disables mouse-wheel when hovering specific elements */
1260
+ var deltaFactor=o.mouseWheel.deltaFactor!=="auto" ? parseInt(o.mouseWheel.deltaFactor) : (oldIE && e.deltaFactor<100) ? 100 : e.deltaFactor<40 ? 40 : e.deltaFactor || 100;
1261
+ if(o.axis==="x" || o.mouseWheel.axis==="x"){
1262
+ var dir="x",
1263
+ px=[Math.round(deltaFactor*d.scrollRatio.x),parseInt(o.mouseWheel.scrollAmount)],
1264
+ amount=o.mouseWheel.scrollAmount!=="auto" ? px[1] : px[0]>=mCustomScrollBox.width() ? mCustomScrollBox.width()*0.9 : px[0],
1265
+ contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetLeft),
1266
+ draggerPos=mCSB_dragger[1][0].offsetLeft,
1267
+ limit=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(),
1268
+ dlt=e.deltaX || e.deltaY || delta;
1269
+ }else{
1270
+ var dir="y",
1271
+ px=[Math.round(deltaFactor*d.scrollRatio.y),parseInt(o.mouseWheel.scrollAmount)],
1272
+ amount=o.mouseWheel.scrollAmount!=="auto" ? px[1] : px[0]>=mCustomScrollBox.height() ? mCustomScrollBox.height()*0.9 : px[0],
1273
+ contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetTop),
1274
+ draggerPos=mCSB_dragger[0][0].offsetTop,
1275
+ limit=mCSB_dragger[0].parent().height()-mCSB_dragger[0].height(),
1276
+ dlt=e.deltaY || delta;
1277
+ }
1278
+ if((dir==="y" && !d.overflowed[0]) || (dir==="x" && !d.overflowed[1])){return;}
1279
+ if(o.mouseWheel.invert){dlt=-dlt;}
1280
+ if(o.mouseWheel.normalizeDelta){dlt=dlt<0 ? -1 : 1;}
1281
+ if((dlt>0 && draggerPos!==0) || (dlt<0 && draggerPos!==limit) || o.mouseWheel.preventDefault){
1282
+ e.stopImmediatePropagation();
1283
+ e.preventDefault();
1284
+ }
1285
+ functions._scrollTo($this,(contentPos-(dlt*amount)).toString(),{dir:dir});
1286
+ });
1287
+ },
1288
+ /* -------------------- */
1289
+
1290
+
1291
+ /* disables mouse-wheel when hovering specific elements like select, datalist etc. */
1292
+ _disableMousewheel:function(el,target){
1293
+ var tag=target.nodeName.toLowerCase(),
1294
+ tags=el.data(pluginPfx).opt.mouseWheel.disableOver,
1295
+ /* elements that require focus */
1296
+ focusTags=["select","textarea"];
1297
+ return $.inArray(tag,tags) > -1 && !($.inArray(tag,focusTags) > -1 && !$(target).is(":focus"));
1298
+ },
1299
+ /* -------------------- */
1300
+
1301
+
1302
+ /*
1303
+ DRAGGER RAIL CLICK EVENT
1304
+ scrolls content via dragger rail
1305
+ */
1306
+ _draggerRail:function(){
1307
+ var $this=$(this),d=$this.data(pluginPfx),
1308
+ namespace=pluginPfx+"_"+d.idx,
1309
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1310
+ wrapper=mCSB_container.parent(),
1311
+ mCSB_draggerContainer=$(".mCSB_"+d.idx+"_scrollbar .mCSB_draggerContainer");
1312
+ mCSB_draggerContainer.bind("touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
1313
+ touchActive=true;
1314
+ }).bind("touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
1315
+ touchActive=false;
1316
+ }).bind("click."+namespace,function(e){
1317
+ if($(e.target).hasClass("mCSB_draggerContainer") || $(e.target).hasClass("mCSB_draggerRail")){
1318
+ functions._stop($this);
1319
+ var el=$(this),mCSB_dragger=el.find(".mCSB_dragger");
1320
+ if(el.parent(".mCSB_scrollTools_horizontal").length>0){
1321
+ if(!d.overflowed[1]){return;}
1322
+ var dir="x",
1323
+ clickDir=e.pageX>mCSB_dragger.offset().left ? -1 : 1,
1324
+ to=Math.abs(mCSB_container[0].offsetLeft)-(clickDir*(wrapper.width()*0.9));
1325
+ }else{
1326
+ if(!d.overflowed[0]){return;}
1327
+ var dir="y",
1328
+ clickDir=e.pageY>mCSB_dragger.offset().top ? -1 : 1,
1329
+ to=Math.abs(mCSB_container[0].offsetTop)-(clickDir*(wrapper.height()*0.9));
1330
+ }
1331
+ functions._scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
1332
+ }
1333
+ });
1334
+ },
1335
+ /* -------------------- */
1336
+
1337
+
1338
+ /*
1339
+ FOCUS EVENT
1340
+ scrolls content via element focus (e.g. clicking an input, pressing TAB key etc.)
1341
+ */
1342
+ _focus:function(){
1343
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1344
+ namespace=pluginPfx+"_"+d.idx,
1345
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1346
+ wrapper=mCSB_container.parent();
1347
+ mCSB_container.bind("focusin."+namespace,function(e){
1348
+ var el=$(document.activeElement),
1349
+ nested=mCSB_container.find(".mCustomScrollBox").length,
1350
+ dur=0;
1351
+ if(!el.is(o.advanced.autoScrollOnFocus)){return;}
1352
+ functions._stop($this);
1353
+ clearTimeout($this[0]._focusTimeout);
1354
+ $this[0]._focusTimer=nested ? (dur+17)*nested : 0;
1355
+ $this[0]._focusTimeout=setTimeout(function(){
1356
+ var to=[el.offset().top-mCSB_container.offset().top,el.offset().left-mCSB_container.offset().left],
1357
+ contentPos=[mCSB_container[0].offsetTop,mCSB_container[0].offsetLeft],
1358
+ isVisible=[
1359
+ (contentPos[0]+to[0]>=0 && contentPos[0]+to[0]<wrapper.height()-el.outerHeight(false)),
1360
+ (contentPos[1]+to[1]>=0 && contentPos[0]+to[1]<wrapper.width()-el.outerWidth(false))
1361
+ ],
1362
+ overwrite=(o.axis==="yx" && !isVisible[0] && !isVisible[1]) ? "none" : "all";
1363
+ if(o.axis!=="x" && !isVisible[0]){
1364
+ functions._scrollTo($this,to[0].toString(),{dir:"y",scrollEasing:"mcsEaseInOut",overwrite:overwrite,dur:dur});
1365
+ }
1366
+ if(o.axis!=="y" && !isVisible[1]){
1367
+ functions._scrollTo($this,to[1].toString(),{dir:"x",scrollEasing:"mcsEaseInOut",overwrite:overwrite,dur:dur});
1368
+ }
1369
+ },$this[0]._focusTimer);
1370
+ });
1371
+ },
1372
+ /* -------------------- */
1373
+
1374
+
1375
+ /* sets content wrapper scrollTop/scrollLeft always to 0 */
1376
+ _wrapperScroll:function(){
1377
+ var $this=$(this),d=$this.data(pluginPfx),
1378
+ namespace=pluginPfx+"_"+d.idx,
1379
+ wrapper=$("#mCSB_"+d.idx+"_container").parent();
1380
+ wrapper.bind("scroll."+namespace,function(e){
1381
+ wrapper.scrollTop(0).scrollLeft(0);
1382
+ });
1383
+ },
1384
+ /* -------------------- */
1385
+
1386
+
1387
+ /*
1388
+ BUTTONS EVENTS
1389
+ scrolls content via up, down, left and right buttons
1390
+ */
1391
+ _buttons:function(){
1392
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
1393
+ namespace=pluginPfx+"_"+d.idx,
1394
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1395
+ sel=".mCSB_"+d.idx+"_scrollbar",
1396
+ btn=$(sel+">a");
1397
+ btn.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
1398
+ e.preventDefault();
1399
+ if(!functions._mouseBtnLeft(e)){return;} /* left mouse button only */
1400
+ var btnClass=$(this).attr("class");
1401
+ seq.type=o.scrollButtons.scrollType;
1402
+ switch(e.type){
1403
+ case "mousedown": case "touchstart": case "pointerdown": case "MSPointerDown":
1404
+ if(seq.type==="stepped"){return;}
1405
+ touchActive=true;
1406
+ d.tweenRunning=false;
1407
+ _seq("on",btnClass);
1408
+ break;
1409
+ case "mouseup": case "touchend": case "pointerup": case "MSPointerUp":
1410
+ case "mouseout": case "pointerout": case "MSPointerOut":
1411
+ if(seq.type==="stepped"){return;}
1412
+ touchActive=false;
1413
+ if(seq.dir){_seq("off",btnClass);}
1414
+ break;
1415
+ case "click":
1416
+ if(seq.type!=="stepped" || d.tweenRunning){return;}
1417
+ _seq("on",btnClass);
1418
+ break;
1419
+ }
1420
+ function _seq(a,c){
1421
+ seq.scrollAmount=o.snapAmount || o.scrollButtons.scrollAmount;
1422
+ functions._sequentialScroll.call(this,$this,a,c);
1423
+ }
1424
+ });
1425
+ },
1426
+ /* -------------------- */
1427
+
1428
+
1429
+ /*
1430
+ KEYBOARD EVENTS
1431
+ scrolls content via keyboard
1432
+ Keys: up arrow, down arrow, left arrow, right arrow, PgUp, PgDn, Home, End
1433
+ */
1434
+ _keyboard:function(){
1435
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
1436
+ namespace=pluginPfx+"_"+d.idx,
1437
+ mCustomScrollBox=$("#mCSB_"+d.idx),
1438
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1439
+ wrapper=mCSB_container.parent(),
1440
+ editables="input,textarea,select,datalist,keygen,[contenteditable='true']";
1441
+ mCustomScrollBox.attr("tabindex","0").bind("blur."+namespace+" keydown."+namespace+" keyup."+namespace,function(e){
1442
+ switch(e.type){
1443
+ case "blur":
1444
+ if(d.tweenRunning && seq.dir){_seq("off",null);}
1445
+ break;
1446
+ case "keydown": case "keyup":
1447
+ var code=e.keyCode ? e.keyCode : e.which,action="on";
1448
+ if((o.axis!=="x" && (code===38 || code===40)) || (o.axis!=="y" && (code===37 || code===39))){
1449
+ /* up (38), down (40), left (37), right (39) arrows */
1450
+ if(((code===38 || code===40) && !d.overflowed[0]) || ((code===37 || code===39) && !d.overflowed[1])){return;}
1451
+ if(e.type==="keyup"){action="off";}
1452
+ if(!$(document.activeElement).is(editables)){
1453
+ e.preventDefault();
1454
+ e.stopImmediatePropagation();
1455
+ _seq(action,code);
1456
+ }
1457
+ }else if(code===33 || code===34){
1458
+ /* PgUp (33), PgDn (34) */
1459
+ if(d.overflowed[0] || d.overflowed[1]){
1460
+ e.preventDefault();
1461
+ e.stopImmediatePropagation();
1462
+ }
1463
+ if(e.type==="keyup"){
1464
+ functions._stop($this);
1465
+ var keyboardDir=code===34 ? -1 : 1;
1466
+ if(o.axis==="x" || (o.axis==="yx" && d.overflowed[1] && !d.overflowed[0])){
1467
+ var dir="x",to=Math.abs(mCSB_container[0].offsetLeft)-(keyboardDir*(wrapper.width()*0.9));
1468
+ }else{
1469
+ var dir="y",to=Math.abs(mCSB_container[0].offsetTop)-(keyboardDir*(wrapper.height()*0.9));
1470
+ }
1471
+ functions._scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
1472
+ }
1473
+ }else if(code===35 || code===36){
1474
+ /* End (35), Home (36) */
1475
+ if(!$(document.activeElement).is(editables)){
1476
+ if(d.overflowed[0] || d.overflowed[1]){
1477
+ e.preventDefault();
1478
+ e.stopImmediatePropagation();
1479
+ }
1480
+ if(e.type==="keyup"){
1481
+ if(o.axis==="x" || (o.axis==="yx" && d.overflowed[1] && !d.overflowed[0])){
1482
+ var dir="x",to=code===35 ? Math.abs(wrapper.width()-mCSB_container.outerWidth(false)) : 0;
1483
+ }else{
1484
+ var dir="y",to=code===35 ? Math.abs(wrapper.height()-mCSB_container.outerHeight(false)) : 0;
1485
+ }
1486
+ functions._scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
1487
+ }
1488
+ }
1489
+ }
1490
+ break;
1491
+ }
1492
+ function _seq(a,c){
1493
+ seq.type=o.keyboard.scrollType;
1494
+ seq.scrollAmount=o.snapAmount || o.keyboard.scrollAmount;
1495
+ if(seq.type==="stepped" && d.tweenRunning){return;}
1496
+ functions._sequentialScroll.call(this,$this,a,c);
1497
+ }
1498
+ });
1499
+ },
1500
+ /* -------------------- */
1501
+
1502
+
1503
+ /* scrolls content sequentially (used when scrolling via buttons, keyboard arrows etc.) */
1504
+ _sequentialScroll:function(el,action,trigger){
1505
+ var d=el.data(pluginPfx),o=d.opt,seq=d.sequential,
1506
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1507
+ once=seq.type==="stepped" ? true : false;
1508
+ switch(action){
1509
+ case "on":
1510
+ seq.dir=[
1511
+ (trigger==="mCSB_buttonRight" || trigger==="mCSB_buttonLeft" || trigger===39 || trigger===37 ? "x" : "y"),
1512
+ (trigger==="mCSB_buttonUp" || trigger==="mCSB_buttonLeft" || trigger===38 || trigger===37 ? -1 : 1)
1513
+ ];
1514
+ functions._stop(el);
1515
+ if(functions._isNumeric(trigger) && seq.type==="stepped"){return;}
1516
+ _start(once);
1517
+ break;
1518
+ case "off":
1519
+ _stop();
1520
+ if(once || (d.tweenRunning && seq.dir)){
1521
+ _start(true);
1522
+ }
1523
+ break;
1524
+ }
1525
+ /* starts sequence */
1526
+ function _start(once){
1527
+ var c=seq.type!=="stepped", /* continuous scrolling */
1528
+ t=!once ? 1000/60 : c ? o.scrollInertia/1.5 : o.scrollInertia, /* timer */
1529
+ m=!once ? 2.5 : c ? 7.5 : 40, /* multiplier */
1530
+ contentPos=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)],
1531
+ ratio=[d.scrollRatio.y>10 ? 10 : d.scrollRatio.y,d.scrollRatio.x>10 ? 10 : d.scrollRatio.x],
1532
+ amount=seq.dir[0]==="x" ? contentPos[1]+(seq.dir[1]*(ratio[1]*m)) : contentPos[0]+(seq.dir[1]*(ratio[0]*m)),
1533
+ px=seq.dir[0]==="x" ? contentPos[1]+(seq.dir[1]*parseInt(seq.scrollAmount)) : contentPos[0]+(seq.dir[1]*parseInt(seq.scrollAmount)),
1534
+ to=seq.scrollAmount!=="auto" ? px : amount,
1535
+ easing=!once ? "mcsLinear" : c ? "mcsLinearOut" : "mcsEaseInOut",
1536
+ onComplete=!once ? false : true;
1537
+ if(once && t<17){
1538
+ to=seq.dir[0]==="x" ? contentPos[1] : contentPos[0];
1539
+ }
1540
+ functions._scrollTo(el,to.toString(),{dir:seq.dir[0],scrollEasing:easing,dur:t,onComplete:onComplete});
1541
+ if(once){
1542
+ seq.dir=false;
1543
+ return;
1544
+ }
1545
+ clearTimeout(seq.step);
1546
+ seq.step=setTimeout(function(){
1547
+ _start();
1548
+ },t);
1549
+ }
1550
+ /* stops sequence */
1551
+ function _stop(){
1552
+ clearTimeout(seq.step);
1553
+ functions._stop(el);
1554
+ }
1555
+ },
1556
+ /* -------------------- */
1557
+
1558
+
1559
+ /* returns a yx array from value */
1560
+ _arr:function(val){
1561
+ var o=$(this).data(pluginPfx).opt,vals=[];
1562
+ if(typeof val==="function"){val=val();} /* check if the value is a single anonymous function */
1563
+ /* check if value is object or array, its length and create an array with yx values */
1564
+ if(!(val instanceof Array)){ /* object value (e.g. {y:"100",x:"100"}, 100 etc.) */
1565
+ vals[0]=val.y ? val.y : val.x || o.axis==="x" ? null : val;
1566
+ vals[1]=val.x ? val.x : val.y || o.axis==="y" ? null : val;
1567
+ }else{ /* array value (e.g. [100,100]) */
1568
+ vals=val.length>1 ? [val[0],val[1]] : o.axis==="x" ? [null,val[0]] : [val[0],null];
1569
+ }
1570
+ /* check if array values are anonymous functions */
1571
+ if(typeof vals[0]==="function"){vals[0]=vals[0]();}
1572
+ if(typeof vals[1]==="function"){vals[1]=vals[1]();}
1573
+ return vals;
1574
+ },
1575
+ /* -------------------- */
1576
+
1577
+
1578
+ /* translates values (e.g. "top", 100, "100px", "#id") to actual scroll-to positions */
1579
+ _to:function(val,dir){
1580
+ if(val==null || typeof val=="undefined"){return;}
1581
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1582
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1583
+ wrapper=mCSB_container.parent(),
1584
+ t=typeof val;
1585
+ if(!dir){dir=o.axis==="x" ? "x" : "y";}
1586
+ var contentLength=dir==="x" ? mCSB_container.outerWidth(false) : mCSB_container.outerHeight(false),
1587
+ contentOffset=dir==="x" ? mCSB_container.offset().left : mCSB_container.offset().top,
1588
+ contentPos=dir==="x" ? mCSB_container[0].offsetLeft : mCSB_container[0].offsetTop,
1589
+ cssProp=dir==="x" ? "left" : "top";
1590
+ switch(t){
1591
+ case "function": /* this currently is not used. Consider removing it */
1592
+ return val();
1593
+ break;
1594
+ case "object":
1595
+ if(val.nodeType){ /* DOM */
1596
+ var objOffset=dir==="x" ? $(val).offset().left : $(val).offset().top;
1597
+ }else if(val.jquery){ /* jquery object */
1598
+ if(!val.length){return;}
1599
+ var objOffset=dir==="x" ? val.offset().left : val.offset().top;
1600
+ }
1601
+ return objOffset-contentOffset;
1602
+ break;
1603
+ case "string": case "number":
1604
+ if(functions._isNumeric.call(null,val)){ /* numeric value */
1605
+ return Math.abs(val);
1606
+ }else if(val.indexOf("%")!==-1){ /* percentage value */
1607
+ return Math.abs(contentLength*parseInt(val)/100);
1608
+ }else if(val.indexOf("-=")!==-1){ /* decrease value */
1609
+ return Math.abs(contentPos-parseInt(val.split("-=")[1]));
1610
+ }else if(val.indexOf("+=")!==-1){ /* inrease value */
1611
+ var p=(contentPos+parseInt(val.split("+=")[1]));
1612
+ return p>=0 ? 0 : Math.abs(p);
1613
+ }else if(val.indexOf("px")!==-1 && functions._isNumeric.call(null,val.split("px")[0])){ /* pixels string value (e.g. "100px") */
1614
+ return Math.abs(val.split("px")[0]);
1615
+ }else{
1616
+ if(val==="top" || val==="left"){ /* special strings */
1617
+ return 0;
1618
+ }else if(val==="bottom"){
1619
+ return Math.abs(wrapper.height()-mCSB_container.outerHeight(false));
1620
+ }else if(val==="right"){
1621
+ return Math.abs(wrapper.width()-mCSB_container.outerWidth(false));
1622
+ }else if(val==="first" || val==="last"){
1623
+ var obj=mCSB_container.find(":"+val),
1624
+ objOffset=dir==="x" ? $(obj).offset().left : $(obj).offset().top;
1625
+ return objOffset-contentOffset;
1626
+ }else{
1627
+ if($(val).length){ /* jquery selector */
1628
+ var objOffset=dir==="x" ? $(val).offset().left : $(val).offset().top;
1629
+ return objOffset-contentOffset;
1630
+ }else{ /* other values (e.g. "100em") */
1631
+ mCSB_container.css(cssProp,val);
1632
+ methods.update.call(null,$this[0]);
1633
+ return;
1634
+ }
1635
+ }
1636
+ }
1637
+ break;
1638
+ }
1639
+ },
1640
+ /* -------------------- */
1641
+
1642
+
1643
+ /* calls the update method automatically */
1644
+ _autoUpdate:function(rem){
1645
+ var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
1646
+ mCSB_container=$("#mCSB_"+d.idx+"_container");
1647
+ if(rem){
1648
+ /*
1649
+ removes autoUpdate timer
1650
+ usage: functions._autoUpdate.call(this,"remove");
1651
+ */
1652
+ clearTimeout(mCSB_container[0].autoUpdate);
1653
+ functions._delete.call(null,mCSB_container[0].autoUpdate);
1654
+ return;
1655
+ }
1656
+ var wrapper=mCSB_container.parent(),
1657
+ scrollbar=[$("#mCSB_"+d.idx+"_scrollbar_vertical"),$("#mCSB_"+d.idx+"_scrollbar_horizontal")],
1658
+ scrollbarSize=function(){return [
1659
+ scrollbar[0].is(":visible") ? scrollbar[0].outerHeight(true) : 0, /* returns y-scrollbar height */
1660
+ scrollbar[1].is(":visible") ? scrollbar[1].outerWidth(true) : 0 /* returns x-scrollbar width */
1661
+ ]},
1662
+ oldSelSize=sizesSum(),newSelSize,
1663
+ os=[mCSB_container.outerHeight(false),mCSB_container.outerWidth(false),wrapper.height(),wrapper.width(),scrollbarSize()[0],scrollbarSize()[1]],ns,
1664
+ oldImgsLen=imgSum(),newImgsLen;
1665
+ upd();
1666
+ function upd(){
1667
+ clearTimeout(mCSB_container[0].autoUpdate);
1668
+ mCSB_container[0].autoUpdate=setTimeout(function(){
1669
+ /* update on specific selector(s) length and size change */
1670
+ if(o.advanced.updateOnSelectorChange){
1671
+ newSelSize=sizesSum();
1672
+ if(newSelSize!==oldSelSize){
1673
+ doUpd();
1674
+ oldSelSize=newSelSize;
1675
+ return;
1676
+ }
1677
+ }
1678
+ /* update on main element and scrollbar size changes */
1679
+ if(o.advanced.updateOnContentResize){
1680
+ ns=[mCSB_container.outerHeight(false),mCSB_container.outerWidth(false),wrapper.height(),wrapper.width(),scrollbarSize()[0],scrollbarSize()[1]];
1681
+ if(ns[0]!==os[0] || ns[1]!==os[1] || ns[2]!==os[2] || ns[3]!==os[3] || ns[4]!==os[4] || ns[5]!==os[5]){
1682
+ doUpd();
1683
+ os=ns;
1684
+ }
1685
+ }
1686
+ /* update on image load */
1687
+ if(o.advanced.updateOnImageLoad){
1688
+ newImgsLen=imgSum();
1689
+ if(newImgsLen!==oldImgsLen){
1690
+ mCSB_container.find("img").each(function(){
1691
+ imgLoader(this.src);
1692
+ });
1693
+ oldImgsLen=newImgsLen;
1694
+ }
1695
+ }
1696
+ if(o.advanced.updateOnSelectorChange || o.advanced.updateOnContentResize || o.advanced.updateOnImageLoad){upd();}
1697
+ },60);
1698
+ }
1699
+ /* returns images amount */
1700
+ function imgSum(){
1701
+ var total=0
1702
+ if(o.advanced.updateOnImageLoad){total=mCSB_container.find("img").length;}
1703
+ return total;
1704
+ }
1705
+ /* a tiny image loader */
1706
+ function imgLoader(src){
1707
+ var img=new Image();
1708
+ function createDelegate(contextObject,delegateMethod){
1709
+ return function(){return delegateMethod.apply(contextObject,arguments);}
1710
+ }
1711
+ function imgOnLoad(){
1712
+ this.onload=null;
1713
+ doUpd();
1714
+ }
1715
+ img.onload=createDelegate(img,imgOnLoad);
1716
+ img.src=src;
1717
+ }
1718
+ /* returns the total height and width sum of all elements matching the selector */
1719
+ function sizesSum(){
1720
+ if(o.advanced.updateOnSelectorChange===true){o.advanced.updateOnSelectorChange="*";}
1721
+ var total=0,sel=mCSB_container.find(o.advanced.updateOnSelectorChange);
1722
+ if(o.advanced.updateOnSelectorChange && sel.length>0){sel.each(function(){total+=$(this).height()+$(this).width();});}
1723
+ return total;
1724
+ }
1725
+ /* calls the update method */
1726
+ function doUpd(){
1727
+ clearTimeout(mCSB_container[0].autoUpdate);
1728
+ methods.update.call(null,$this[0]);
1729
+ }
1730
+ },
1731
+ /* -------------------- */
1732
+
1733
+
1734
+ /* snaps scrolling to a multiple of a pixels number */
1735
+ _snapAmount:function(to,amount,offset){
1736
+ return (Math.round(to/amount)*amount-offset);
1737
+ },
1738
+ /* -------------------- */
1739
+
1740
+
1741
+ /* stops content and scrollbar animations */
1742
+ _stop:function(el){
1743
+ var d=el.data(pluginPfx),
1744
+ sel=$("#mCSB_"+d.idx+"_container,#mCSB_"+d.idx+"_container_wrapper,#mCSB_"+d.idx+"_dragger_vertical,#mCSB_"+d.idx+"_dragger_horizontal");
1745
+ sel.each(function(){
1746
+ functions._stopTween.call(this);
1747
+ });
1748
+ },
1749
+ /* -------------------- */
1750
+
1751
+
1752
+ /*
1753
+ ANIMATES CONTENT
1754
+ This is where the actual scrolling happens
1755
+ */
1756
+ _scrollTo:function(el,to,options){
1757
+ var d=el.data(pluginPfx),o=d.opt,
1758
+ defaults={
1759
+ trigger:"internal",
1760
+ dir:"y",
1761
+ scrollEasing:"mcsEaseOut",
1762
+ drag:false,
1763
+ dur:o.scrollInertia,
1764
+ overwrite:"all",
1765
+ callbacks:true,
1766
+ onStart:true,
1767
+ onUpdate:true,
1768
+ onComplete:true
1769
+ },
1770
+ options=$.extend(defaults,options),
1771
+ dur=[options.dur,(options.drag ? 0 : options.dur)],
1772
+ mCustomScrollBox=$("#mCSB_"+d.idx),
1773
+ mCSB_container=$("#mCSB_"+d.idx+"_container"),
1774
+ totalScrollOffsets=o.callbacks.onTotalScrollOffset ? functions._arr.call(el,o.callbacks.onTotalScrollOffset) : [0,0],
1775
+ totalScrollBackOffsets=o.callbacks.onTotalScrollBackOffset ? functions._arr.call(el,o.callbacks.onTotalScrollBackOffset) : [0,0];
1776
+ d.trigger=options.trigger;
1777
+ if(o.snapAmount){to=functions._snapAmount(to,o.snapAmount,o.snapOffset);} /* scrolling snapping */
1778
+ switch(options.dir){
1779
+ case "x":
1780
+ var mCSB_dragger=$("#mCSB_"+d.idx+"_dragger_horizontal"),
1781
+ property="left",
1782
+ contentPos=mCSB_container[0].offsetLeft,
1783
+ limit=[
1784
+ mCustomScrollBox.width()-mCSB_container.outerWidth(false),
1785
+ mCSB_dragger.parent().width()-mCSB_dragger.width()
1786
+ ],
1787
+ scrollTo=[to,(to/d.scrollRatio.x)],
1788
+ tso=totalScrollOffsets[1],
1789
+ tsbo=totalScrollBackOffsets[1],
1790
+ totalScrollOffset=tso>0 ? tso/d.scrollRatio.x : 0,
1791
+ totalScrollBackOffset=tsbo>0 ? tsbo/d.scrollRatio.x : 0;
1792
+ break;
1793
+ case "y":
1794
+ var mCSB_dragger=$("#mCSB_"+d.idx+"_dragger_vertical"),
1795
+ property="top",
1796
+ contentPos=mCSB_container[0].offsetTop,
1797
+ limit=[
1798
+ mCustomScrollBox.height()-mCSB_container.outerHeight(false),
1799
+ mCSB_dragger.parent().height()-mCSB_dragger.height()
1800
+ ],
1801
+ scrollTo=[to,(to/d.scrollRatio.y)],
1802
+ tso=totalScrollOffsets[0],
1803
+ tsbo=totalScrollBackOffsets[0],
1804
+ totalScrollOffset=tso>0 ? tso/d.scrollRatio.y : 0,
1805
+ totalScrollBackOffset=tsbo>0 ? tsbo/d.scrollRatio.y : 0;
1806
+ break;
1807
+ }
1808
+ if(scrollTo[1]<0){
1809
+ scrollTo=[0,0];
1810
+ }else if(scrollTo[1]>=limit[1]){
1811
+ scrollTo=[limit[0],limit[1]];
1812
+ }else{
1813
+ scrollTo[0]=-scrollTo[0];
1814
+ }
1815
+ clearTimeout(mCSB_container[0].onCompleteTimeout);
1816
+ if(!d.tweenRunning && ((contentPos===0 && scrollTo[0]>=0) || (contentPos===limit[0] && scrollTo[0]<=limit[0]))){return;}
1817
+ functions._tweenTo.call(null,mCSB_dragger[0],property,Math.round(scrollTo[1]),dur[1],options.scrollEasing);
1818
+ functions._tweenTo.call(null,mCSB_container[0],property,Math.round(scrollTo[0]),dur[0],options.scrollEasing,options.overwrite,{
1819
+ onStart:function(){
1820
+ if(options.callbacks && options.onStart && !d.tweenRunning){
1821
+ /* callbacks: onScrollStart */
1822
+ if(_cb("onScrollStart")){_mcs(); o.callbacks.onScrollStart.call(el[0]);}
1823
+ d.tweenRunning=true;
1824
+ functions._onDragClasses(mCSB_dragger);
1825
+ d.cbOffsets=_cbOffsets();
1826
+ }
1827
+ },onUpdate:function(){
1828
+ if(options.callbacks && options.onUpdate){
1829
+ /* callbacks: whileScrolling */
1830
+ if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
1831
+ }
1832
+ },onComplete:function(){
1833
+ if(options.callbacks && options.onComplete){
1834
+ if(o.axis==="yx"){clearTimeout(mCSB_container[0].onCompleteTimeout);}
1835
+ var t=mCSB_container[0].idleTimer || 0;
1836
+ mCSB_container[0].onCompleteTimeout=setTimeout(function(){
1837
+ /* callbacks: onScroll, onTotalScroll, onTotalScrollBack */
1838
+ if(_cb("onScroll")){_mcs(); o.callbacks.onScroll.call(el[0]);}
1839
+ if(_cb("onTotalScroll") && scrollTo[1]>=limit[1]-totalScrollOffset && d.cbOffsets[0]){_mcs(); o.callbacks.onTotalScroll.call(el[0]);}
1840
+ if(_cb("onTotalScrollBack") && scrollTo[1]<=totalScrollBackOffset && d.cbOffsets[1]){_mcs(); o.callbacks.onTotalScrollBack.call(el[0]);}
1841
+ d.tweenRunning=false;
1842
+ mCSB_container[0].idleTimer=0;
1843
+ functions._onDragClasses(mCSB_dragger,"hide");
1844
+ },t);
1845
+ }
1846
+ }
1847
+ });
1848
+ /* checks if callback function exists */
1849
+ function _cb(cb){
1850
+ return d && o.callbacks[cb] && typeof o.callbacks[cb]==="function";
1851
+ }
1852
+ /* checks whether callback offsets always trigger */
1853
+ function _cbOffsets(){
1854
+ return [o.callbacks.alwaysTriggerOffsets || contentPos>=limit[0]+tso,o.callbacks.alwaysTriggerOffsets || contentPos<=-tsbo];
1855
+ }
1856
+ /*
1857
+ populates object with useful values for the user
1858
+ values:
1859
+ content: this.mcs.content
1860
+ content top position: this.mcs.top
1861
+ content left position: this.mcs.left
1862
+ dragger top position: this.mcs.draggerTop
1863
+ dragger left position: this.mcs.draggerLeft
1864
+ scrolling y percentage: this.mcs.topPct
1865
+ scrolling x percentage: this.mcs.leftPct
1866
+ scrolling direction: this.mcs.direction
1867
+ */
1868
+ function _mcs(){
1869
+ var cp=[mCSB_container[0].offsetTop,mCSB_container[0].offsetLeft], /* content position */
1870
+ dp=[mCSB_dragger[0].offsetTop,mCSB_dragger[0].offsetLeft], /* dragger position */
1871
+ cl=[mCSB_container.outerHeight(false),mCSB_container.outerWidth(false)], /* content length */
1872
+ pl=[mCustomScrollBox.height(),mCustomScrollBox.width()]; /* content parent length */
1873
+ el[0].mcs={
1874
+ content:mCSB_container, /* original content wrapper as jquery object */
1875
+ top:cp[0],left:cp[1],draggerTop:dp[0],draggerLeft:dp[1],
1876
+ topPct:Math.round((100*Math.abs(cp[0]))/(Math.abs(cl[0])-pl[0])),leftPct:Math.round((100*Math.abs(cp[1]))/(Math.abs(cl[1])-pl[1])),
1877
+ direction:options.dir
1878
+ };
1879
+ /*
1880
+ this refers to the original element containing the scrollbar(s)
1881
+ usage: this.mcs.top, this.mcs.leftPct etc.
1882
+ */
1883
+ }
1884
+ },
1885
+ /* -------------------- */
1886
+
1887
+
1888
+ /*
1889
+ CUSTOM JAVASCRIPT ANIMATION TWEEN
1890
+ Lighter and faster than jquery animate() and css transitions
1891
+ Animates top/left properties and includes easings
1892
+ */
1893
+ _tweenTo:function(el,prop,to,duration,easing,overwrite,callbacks){
1894
+ var callbacks=callbacks || {},
1895
+ onStart=callbacks.onStart || function(){},onUpdate=callbacks.onUpdate || function(){},onComplete=callbacks.onComplete || function(){},
1896
+ startTime=functions._getTime(),_delay,progress=0,from=el.offsetTop,elStyle=el.style;
1897
+ if(prop==="left"){from=el.offsetLeft;}
1898
+ var diff=to-from;
1899
+ el._mcsstop=0;
1900
+ if(overwrite!=="none"){_cancelTween();}
1901
+ _startTween();
1902
+ function _step(){
1903
+ if(el._mcsstop){return;}
1904
+ if(!progress){onStart.call();}
1905
+ progress=functions._getTime()-startTime;
1906
+ _tween();
1907
+ if(progress>=el._mcstime){
1908
+ el._mcstime=(progress>el._mcstime) ? progress+_delay-(progress- el._mcstime) : progress+_delay-1;
1909
+ if(el._mcstime<progress+1){el._mcstime=progress+1;}
1910
+ }
1911
+ if(el._mcstime<duration){el._mcsid=_request(_step);}else{onComplete.call();}
1912
+ }
1913
+ function _tween(){
1914
+ if(duration>0){
1915
+ el._mcscurrVal=_ease(el._mcstime,from,diff,duration,easing);
1916
+ elStyle[prop]=Math.round(el._mcscurrVal)+"px";
1917
+ }else{
1918
+ elStyle[prop]=to+"px";
1919
+ }
1920
+ onUpdate.call();
1921
+ }
1922
+ function _startTween(){
1923
+ _delay=1000/60;
1924
+ el._mcstime=progress+_delay;
1925
+ _request=(!window.requestAnimationFrame) ? function(f){_tween(); return setTimeout(f,0.01);} : window.requestAnimationFrame;
1926
+ el._mcsid=_request(_step);
1927
+ }
1928
+ function _cancelTween(){
1929
+ if(el._mcsid==null){return;}
1930
+ if(!window.requestAnimationFrame){clearTimeout(el._mcsid);
1931
+ }else{window.cancelAnimationFrame(el._mcsid);}
1932
+ el._mcsid=null;
1933
+ }
1934
+ function _ease(t,b,c,d,type){
1935
+ switch(type){
1936
+ case "linear": case "mcsLinear":
1937
+ return c*t/d + b;
1938
+ break;
1939
+ case "mcsLinearOut":
1940
+ t/=d; t--; return c * Math.sqrt(1 - t*t) + b;
1941
+ break;
1942
+ case "easeInOutSmooth":
1943
+ t/=d/2;
1944
+ if(t<1) return c/2*t*t + b;
1945
+ t--;
1946
+ return -c/2 * (t*(t-2) - 1) + b;
1947
+ break;
1948
+ case "easeInOutStrong":
1949
+ t/=d/2;
1950
+ if(t<1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
1951
+ t--;
1952
+ return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
1953
+ break;
1954
+ case "easeInOut": case "mcsEaseInOut":
1955
+ t/=d/2;
1956
+ if(t<1) return c/2*t*t*t + b;
1957
+ t-=2;
1958
+ return c/2*(t*t*t + 2) + b;
1959
+ break;
1960
+ case "easeOutSmooth":
1961
+ t/=d; t--;
1962
+ return -c * (t*t*t*t - 1) + b;
1963
+ break;
1964
+ case "easeOutStrong":
1965
+ return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b;
1966
+ break;
1967
+ case "easeOut": case "mcsEaseOut": default:
1968
+ var ts=(t/=d)*t,tc=ts*t;
1969
+ return b+c*(0.499999999999997*tc*ts + -2.5*ts*ts + 5.5*tc + -6.5*ts + 4*t);
1970
+ }
1971
+ }
1972
+ },
1973
+ /* -------------------- */
1974
+
1975
+
1976
+ /* returns current time */
1977
+ _getTime:function(){
1978
+ if(window.performance && window.performance.now){
1979
+ return window.performance.now();
1980
+ }else{
1981
+ if(window.performance && window.performance.webkitNow){
1982
+ return window.performance.webkitNow();
1983
+ }else{
1984
+ if(Date.now){return Date.now();}else{return new Date().getTime();}
1985
+ }
1986
+ }
1987
+ },
1988
+ /* -------------------- */
1989
+
1990
+
1991
+ /* stops a tween */
1992
+ _stopTween:function(){
1993
+ var el=this;
1994
+ if(el._mcsid==null){return;}
1995
+ if(!window.requestAnimationFrame){clearTimeout(el._mcsid);
1996
+ }else{window.cancelAnimationFrame(el._mcsid);}
1997
+ el._mcsid=null;
1998
+ el._mcsstop=1;
1999
+ },
2000
+ /* -------------------- */
2001
+
2002
+
2003
+ /* deletes a property (avoiding the exception thrown by IE) */
2004
+ _delete:function(p){
2005
+ try{delete p;}catch(e){p=null;}
2006
+ },
2007
+ /* -------------------- */
2008
+
2009
+
2010
+ /* detects left mouse button */
2011
+ _mouseBtnLeft:function(e){
2012
+ return !(e.which && e.which!==1);
2013
+ },
2014
+ /* -------------------- */
2015
+
2016
+
2017
+ /* detects if pointer type event is touch */
2018
+ _pointerTouch:function(e){
2019
+ var t=e.originalEvent.pointerType;
2020
+ return !(t && t!=="touch" && t!==2);
2021
+ },
2022
+ /* -------------------- */
2023
+
2024
+
2025
+ /* checks if value is numeric */
2026
+ _isNumeric:function(val){
2027
+ return !isNaN(parseFloat(val)) && isFinite(val);
2028
+ }
2029
+ /* -------------------- */
2030
+
2031
+ };
2032
+
2033
+
2034
+
2035
+
2036
+
2037
+ /*
2038
+ ----------------------------------------
2039
+ PLUGIN SETUP
2040
+ ----------------------------------------
2041
+ */
2042
+
2043
+ /* plugin dependencies */
2044
+ var _dlp=("https:"==document.location.protocol) ? "https:" : "http:"; /* dependency location protocol */
2045
+ /* load jquery-mousewheel plugin (via CDN) if it's not present (works when mCustomScrollbar fn is called on window load) */
2046
+ $.event.special.mousewheel || $("head").append(decodeURI("%3Cscript src="+_dlp+"//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.11/jquery.mousewheel.min.js%3E%3C/script%3E"));
2047
+
2048
+ /* plugin constructor functions */
2049
+ $.fn[pluginNS]=function(method){ /* usage: $(selector).mCustomScrollbar(); */
2050
+ if(methods[method]){
2051
+ return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
2052
+ }else if(typeof method==="object" || !method){
2053
+ return methods.init.apply(this,arguments);
2054
+ }else{
2055
+ $.error("Method "+method+" does not exist");
2056
+ }
2057
+ };
2058
+ $[pluginNS]=function(method){ /* usage: $.mCustomScrollbar(); */
2059
+ if(methods[method]){
2060
+ return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
2061
+ }else if(typeof method==="object" || !method){
2062
+ return methods.init.apply(this,arguments);
2063
+ }else{
2064
+ $.error("Method "+method+" does not exist");
2065
+ }
2066
+ };
2067
+
2068
+ /*
2069
+ allow setting plugin default options.
2070
+ usage: $.mCustomScrollbar.defaults.scrollInertia=500;
2071
+ to apply any changed default options on default selectors (below), use inside document ready fn
2072
+ e.g.: $(document).ready(function(){ $.mCustomScrollbar.defaults.scrollInertia=500; });
2073
+ */
2074
+ $[pluginNS].defaults=defaults;
2075
+
2076
+ /*
2077
+ add window object (window.mCustomScrollbar)
2078
+ usage: if(window.mCustomScrollbar){console.log("custom scrollbar plugin loaded");}
2079
+ */
2080
+ window[pluginNS]=true;
2081
+
2082
+ $(window).load(function(){
2083
+ $(defaultSelector)[pluginNS](); /* add scrollbars automatically on default selector */
2084
+ });
2085
+
2086
+ })(jQuery,window,document);