/*! copyright (c) 2011 piotr rochala (http://rocha.la) * dual licensed under the mit (http://www.opensource.org/licenses/mit-license.php) * and gpl (http://www.opensource.org/licenses/gpl-license.php) licenses. * * improved by keenthemes for metronic theme * version: 1.3.2 * */ !function(e){jquery.fn.extend({slimscroll:function(i){var o={width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysvisible:!1,disablefadeout:!1,railvisible:!1,railcolor:"#333",railopacity:.2,raildraggable:!0,railclass:"slimscrollrail",barclass:"slimscrollbar",wrapperclass:"slimscrolldiv",allowpagescroll:!1,wheelstep:20,touchscrollstep:200,borderradius:"7px",railborderradius:"7px",animate:!0},a=e.extend(o,i);return this.each(function(){function o(t){if(u){var t=t||window.event,i=0;t.wheeldelta&&(i=-t.wheeldelta/120),t.detail&&(i=t.detail/3);var o=t.target||t.srctarget||t.srcelement;e(o).closest("."+a.wrapperclass).is(s.parent())&&r(i,!0),t.preventdefault&&!y&&t.preventdefault(),y||(t.returnvalue=!1)}}function r(e,t,i){y=!1;var o=e,r=s.outerheight()-m.outerheight();if(t&&(o=parseint(m.css("top"))+e*parseint(a.wheelstep)/100*m.outerheight(),o=math.min(math.max(o,0),r),o=e>0?math.ceil(o):math.floor(o),m.css({top:o+"px"})),v=parseint(m.css("top"))/(s.outerheight()-m.outerheight()),o=v*(s[0].scrollheight-s.outerheight()),i){o=e;var s=o/s[0].scrollheight*s.outerheight();s=math.min(math.max(s,0),r),m.css({top:s+"px"})}"scrollto"in a&&a.animate?s.animate({scrolltop:o}):s.scrolltop(o),s.trigger("slimscrolling",~~o),l(),c()}function s(){window.addeventlistener?(this.addeventlistener("dommousescroll",o,!1),this.addeventlistener("mousewheel",o,!1)):document.attachevent("onmousewheel",o)}function n(){f=math.max(s.outerheight()/s[0].scrollheight*s.outerheight(),m),m.css({height:f+"px"});var e=f==s.outerheight()?"none":"block";m.css({display:e})}function l(){if(n(),cleartimeout(p),v==~~v){if(y=a.allowpagescroll,b!=v){var e=0==~~v?"top":"bottom";s.trigger("slimscroll",e)}}else y=!1;return b=v,f>=s.outerheight()?void(y=!0):(m.stop(!0,!0).fadein("fast"),void(a.railvisible&&h.stop(!0,!0).fadein("fast")))}function c(){a.alwaysvisible||(p=settimeout(function(){a.disablefadeout&&u||h||d||(m.fadeout("slow"),h.fadeout("slow"))},1e3))}var u,h,d,p,g,f,v,b,w="
",m=30,y=!1,s=e(this);if("ontouchstart"in window&&window.navigator.mspointerenabled&&s.css("-ms-touch-action","none"),s.parent().hasclass(a.wrapperclass)){var e=s.scrolltop();if(m=s.parent().find("."+a.barclass),h=s.parent().find("."+a.railclass),n(),e.isplainobject(i)){if("height"in i&&"auto"==i.height){s.parent().css("height","auto"),s.css("height","auto");var x=s.parent().parent().height();s.parent().css("height",x),s.css("height",x)}if("scrollto"in i)e=parseint(a.scrollto);else if("scrollby"in i)e+=parseint(a.scrollby);else if("destroy"in i)return m.remove(),h.remove(),void s.unwrap();r(e,!1,!0)}}else{a.height="auto"==i.height?s.parent().height():i.height;var c=e(w).addclass(a.wrapperclass).css({position:"relative",overflow:"hidden",width:a.width,height:a.height});s.css({overflow:"hidden",width:a.width,height:a.height});var h=e(w).addclass(a.railclass).css({width:a.size,height:"100%",position:"absolute",top:0,display:a.alwaysvisible&&a.railvisible?"block":"none","border-radius":a.railborderradius,background:a.railcolor,opacity:a.railopacity,zindex:90}),m=e(w).addclass(a.barclass).css({background:a.color,width:a.size,position:"absolute",top:0,opacity:a.opacity,display:a.alwaysvisible?"block":"none","border-radius":a.borderradius,borderradius:a.borderradius,mozborderradius:a.borderradius,webkitborderradius:a.borderradius,zindex:99}),d="right"==a.position?{right:a.distance}:{left:a.distance};h.css(d),m.css(d),s.wrap(c),s.parent().append(m),s.parent().append(h),a.raildraggable&&m.bind("mousedown",function(i){var o=e(document);return d=!0,t=parsefloat(m.css("top")),pagey=i.pagey,o.bind("mousemove.slimscroll",function(e){currtop=t+e.pagey-pagey,m.css("top",currtop),r(0,m.position().top,!1)}),o.bind("mouseup.slimscroll",function(){d=!1,c(),o.unbind(".slimscroll")}),!1}).bind("selectstart.slimscroll",function(e){return e.stoppropagation(),e.preventdefault(),!1}),"ontouchstart"in window&&window.navigator.mspointerenabled&&(s.bind("mspointerdown",function(e){g=e.originalevent.pagey}),s.bind("mspointermove",function(e){e.originalevent.preventdefault();var t=(g-e.originalevent.pagey)/a.touchscrollstep;r(t,!0),g=e.originalevent.pagey})),h.hover(function(){l()},function(){c()}),m.hover(function(){h=!0},function(){h=!1}),s.hover(function(){u=!0,l(),c()},function(){u=!1,c()}),s.bind("touchstart",function(e){e.originalevent.touches.length&&(g=e.originalevent.touches[0].pagey)}),s.bind("touchmove",function(e){if(y||e.originalevent.preventdefault(),e.originalevent.touches.length){var t=(g-e.originalevent.touches[0].pagey)/a.touchscrollstep;r(t,!0),g=e.originalevent.touches[0].pagey}}),n(),"bottom"===a.start?(m.css({top:s.outerheight()-m.outerheight()}),r(0,!0)):"top"!==a.start&&(r(e(a.start).position().top,null,!0),a.alwaysvisible||m.hide()),s()}}),this}}),jquery.fn.extend({slimscroll:jquery.fn.slimscroll})}(jquery);