/*! 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.3 * */ (function(e){e.fn.extend({slimscroll:function(g){var a=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:200,borderradius:"7px",railborderradius:"7px"},g);this.each(function(){function u(d){if(r){d=d||window.event; var c=0;d.wheeldelta&&(c=-d.wheeldelta/120);d.detail&&(c=d.detail/3);e(d.target||d.srctarget||d.srcelement).closest("."+a.wrapperclass).is(b.parent())&&m(c,!0);d.preventdefault&&!k&&d.preventdefault();k||(d.returnvalue=!1)}}function m(d,e,g){k=!1;var f=d,h=b.outerheight()-c.outerheight();e&&(f=parseint(c.css("top"))+d*parseint(a.wheelstep)/100*c.outerheight(),f=math.min(math.max(f,0),h),f=0=b.outerheight()?k=!0:(c.stop(!0,!0).fadein("fast"),a.railvisible&&h.stop(!0,!0).fadein("fast"))}function p(){a.alwaysvisible||(a=settimeout(function(){a.disablefadeout&&r||x||y||(c.fadeout("slow"),h.fadeout("slow"))},1e3))}var r,x,y,a,z,s,l,b,k=!1,b=e(this);if(b.parent().hasclass(a.wrapperclass)){var n=b.scrolltop(),c=b.parent().find("."+a.barclass),h=b.parent().find("."+a.railclass); w();if(e.isplainobject(g)){if("height"in g&&"auto"==g.height){b.parent().css("height","auto");b.css("height","auto");var q=b.parent().parent().height();b.parent().css("height",q);b.css("height",q)}if("scrollto"in g)n=parseint(a.scrollto);else if("scrollby"in g)n+=parseint(a.scrollby);else if("destroy"in g){c.remove();h.remove();b.unwrap();return}m(n,!1,!0)}}else if(!(e.isplainobject(g)&&"destroy"in g)){a.height="auto"==a.height?b.parent().height():a.height;n=e("
").addclass(a.wrapperclass).css({position:"relative", overflow:"hidden",width:a.width,height:a.height});b.css({overflow:"hidden",width:a.width,height:a.height});var h=e("
").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}),c=e("
").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}),q="right"==a.position?{right:a.distance}:{left:a.distance};h.css(q);c.css(q);b.wrap(n);b.parent().append(c);b.parent().append(h);a.raildraggable&&c.bind("mousedown",function(a){var b=e(document);y=!0;t=parsefloat(c.css("top"));pagey=a.pagey;b.bind("mousemove.slimscroll",function(a){currtop=t+a.pagey-pagey;c.css("top",currtop);m(0,c.position().top,!1)}); b.bind("mouseup.slimscroll",function(a){y=!1;p();b.unbind(".slimscroll")});return!1}).bind("selectstart.slimscroll",function(a){a.stoppropagation();a.preventdefault();return!1});h.hover(function(){v()},function(){p()});c.hover(function(){x=!0},function(){x=!1});b.hover(function(){r=!0;v();p()},function(){r=!1;p()});b.bind("touchstart",function(a,b){a.originalevent.touches.length&&(z=a.originalevent.touches[0].pagey)});b.bind("touchmove",function(b){k||b.originalevent.preventdefault();b.originalevent.touches.length&& (m((z-b.originalevent.touches[0].pagey)/a.touchscrollstep,!0),z=b.originalevent.touches[0].pagey)});w();"bottom"===a.start?(c.css({top:b.outerheight()-c.outerheight()}),m(0,!0)):"top"!==a.start&&(m(e(a.start).position().top,null,!0),a.alwaysvisible||c.hide());c()}});return this}});e.fn.extend({slimscroll:e.fn.slimscroll})})(jquery);