/*! 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. * * Version: 1.3.8 * */!function(e){e.fn.extend({slimScroll:function(i){var s=e.extend({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:100,borderRadius:"7px",railBorderRadius:"7px"},i);return this.each((function(){var o,a,r,l,n,c,h,u,p="
",d=30,g=!1,f=e(this);if(f.parent().hasClass(s.wrapperClass)){var b=f.scrollTop();if(C=f.siblings("."+s.barClass),x=f.siblings("."+s.railClass),R(),e.isPlainObject(i)){if("height"in i&&"auto"==i.height){f.parent().css("height","auto"),f.css("height","auto");var v=f.parent().parent().height();f.parent().css("height",v),f.css("height",v)}else if("height"in i){var w=i.height;f.parent().css("height",w),f.css("height",w)}if("scrollTo"in i)b=parseInt(s.scrollTo);else if("scrollBy"in i)b+=parseInt(s.scrollBy);else if("destroy"in i)return C.remove(),x.remove(),void f.unwrap();E(b,!1,!0)}}else if(!e.isPlainObject(i)||!("destroy"in i)){s.height="auto"==s.height?f.parent().height():s.height;var m=e(p).addClass(s.wrapperClass).css({position:"relative",overflow:"hidden",width:s.width,height:s.height});f.css({overflow:"hidden",width:s.width,height:s.height});var y,x=e(p).addClass(s.railClass).css({width:s.size,height:"100%",position:"absolute",top:0,display:s.alwaysVisible&&s.railVisible?"block":"none","border-radius":s.railBorderRadius,background:s.railColor,opacity:s.railOpacity,zIndex:90}),C=e(p).addClass(s.barClass).css({background:s.color,width:s.size,position:"absolute",top:0,opacity:s.opacity,display:s.alwaysVisible?"block":"none","border-radius":s.borderRadius,BorderRadius:s.borderRadius,MozBorderRadius:s.borderRadius,WebkitBorderRadius:s.borderRadius,zIndex:99}),H="right"==s.position?{right:s.distance}:{left:s.distance};x.css(H),C.css(H),f.wrap(m),f.parent().append(C),f.parent().append(x),s.railDraggable&&C.bind("mousedown",(function(i){var s=e(document);return r=!0,t=parseFloat(C.css("top")),pageY=i.pageY,s.bind("mousemove.slimscroll",(function(e){currTop=t+e.pageY-pageY,C.css("top",currTop),E(0,C.position().top,!1)})),s.bind("mouseup.slimscroll",(function(e){r=!1,M(),s.unbind(".slimscroll")})),!1})).bind("selectstart.slimscroll",(function(e){return e.stopPropagation(),e.preventDefault(),!1})),x.hover((function(){D()}),(function(){M()})),C.hover((function(){a=!0}),(function(){a=!1})),f.hover((function(){o=!0,D(),M()}),(function(){o=!1,M()})),f.bind("touchstart",(function(e,t){e.originalEvent.touches.length&&(n=e.originalEvent.touches[0].pageY)})),f.bind("touchmove",(function(e){(g||e.originalEvent.preventDefault(),e.originalEvent.touches.length)&&(E((n-e.originalEvent.touches[0].pageY)/s.touchScrollStep,!0),n=e.originalEvent.touches[0].pageY)})),R(),"bottom"===s.start?(C.css({top:f.outerHeight()-C.outerHeight()}),E(0,!0)):"top"!==s.start&&(E(e(s.start).position().top,null,!0),s.alwaysVisible||C.hide()),y=this,window.addEventListener?(y.addEventListener("DOMMouseScroll",S,!1),y.addEventListener("mousewheel",S,!1)):document.attachEvent("onmousewheel",S)}function S(t){if(o){var i=0;(t=t||window.event).wheelDelta&&(i=-t.wheelDelta/120),t.detail&&(i=t.detail/3);var a=t.target||t.srcTarget||t.srcElement;e(a).closest("."+s.wrapperClass).is(f.parent())&&E(i,!0),t.preventDefault&&!g&&t.preventDefault(),g||(t.returnValue=!1)}}function E(e,t,i){g=!1;var o=e,a=f.outerHeight()-C.outerHeight();if(t&&(o=parseInt(C.css("top"))+e*parseInt(s.wheelStep)/100*C.outerHeight(),o=Math.min(Math.max(o,0),a),o=e>0?Math.ceil(o):Math.floor(o),C.css({top:o+"px"})),o=(h=parseInt(C.css("top"))/(f.outerHeight()-C.outerHeight()))*(f[0].scrollHeight-f.outerHeight()),i){var r=(o=e)/f[0].scrollHeight*f.outerHeight();r=Math.min(Math.max(r,0),a),C.css({top:r+"px"})}f.scrollTop(o),f.trigger("slimscrolling",~~o),D(),M()}function R(){c=Math.max(f.outerHeight()/f[0].scrollHeight*f.outerHeight(),d),C.css({height:c+"px"});var e=c==f.outerHeight()?"none":"block";C.css({display:e})}function D(){if(R(),clearTimeout(l),h==~~h){if(g=s.allowPageScroll,u!=h){var e=0==~~h?"top":"bottom";f.trigger("slimscroll",e)}}else g=!1;u=h,c>=f.outerHeight()?g=!0:(C.stop(!0,!0).fadeIn("fast"),s.railVisible&&x.stop(!0,!0).fadeIn("fast"))}function M(){s.alwaysVisible||(l=setTimeout((function(){s.disableFadeOut&&o||a||r||(C.fadeOut("slow"),x.fadeOut("slow"))}),1e3))}})),this}}),e.fn.extend({slimscroll:e.fn.slimScroll})}(jQuery) ;