/*! 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.0 * */ (function(f){jquery.fn.extend({slimscroll:function(h){var a=f.extend({width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:0.4,alwaysvisible:!1,disablefadeout:!1,railvisible:!1,railcolor:"#333",railopacity:0.2,raildraggable:!0,railclass:"slimscrollrail",barclass:"slimscrollbar",wrapperclass:"slimscrolldiv",allowpagescroll:!1,wheelstep:20,touchscrollstep:200,borderradius:"7px",railborderradius:"7px"},h);this.each(function(){function r(d){if(s){d=d|| window.event;var c=0;d.wheeldelta&&(c=-d.wheeldelta/120);d.detail&&(c=d.detail/3);f(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,f,h){k=!1;var e=d,g=b.outerheight()-c.outerheight();f&&(e=parseint(c.css("top"))+d*parseint(a.wheelstep)/100*c.outerheight(),e=math.min(math.max(e,0),g),e=0=b.outerheight()?k=!0:(c.stop(!0,!0).fadein("fast"),a.railvisible&&g.stop(!0,!0).fadein("fast"))}function p(){a.alwaysvisible||(a=settimeout(function(){a.disablefadeout&&s||(x||y)||(c.fadeout("slow"),g.fadeout("slow"))},1e3))}var s,x,y,a,z,u,l,b,d=30,k=!1,b=f(this);if(b.parent().hasclass(a.wrapperclass)){var n=b.scrolltop(), c=b.parent().find("."+a.barclass),g=b.parent().find("."+a.railclass);w();if(f.isplainobject(h)){if("height"in h&&"auto"==h.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 h)n=parseint(a.scrollto);else if("scrollby"in h)n+=parseint(a.scrollby);else if("destroy"in h){c.remove();g.remove();b.unwrap();return}m(n,!1,!0)}}else{a.height="auto"==a.height?b.parent().height():a.height;n=f("
").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 g=f("
").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=f("
").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};g.css(q);c.css(q);b.wrap(n);b.parent().append(c);b.parent().append(g);a.raildraggable&&c.bind("mousedown",function(a){var b=f(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});g.hover(function(){v()},function(){p()});c.hover(function(){x=!0},function(){x=!1});b.hover(function(){s=!0;v();p()},function(){s=!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(f(a.start).position().top,null,!0),a.alwaysvisible||c.hide());c()}});return this}});jquery.fn.extend({slimscroll:jquery.fn.slimscroll})})(jquery);