(function (a) { jQuery.fn.extend({ slimScroll: function (b) { var c = { wheelStep: 20, width: "auto", size: "7px", color: "#000", position: "right", distance: "1px", start: "top", opacity: 0.4, alwaysVisible: false, railVisible: false, railColor: "#333", railOpacity: "0.2", railClass: "slimScrollRail", barClass: "slimScrollBar", wrapperClass: "slimScrollDiv", wrapperOverflow: "hidden", pointerClass: null, slimScrollRight: null }; var d = ops = a.extend(c, b); this.each(function () { var H, B, n, v, C, o = "<div></div>", E = 30, A = false, w = parseInt(d.wheelStep), D = d.width, y = d.height, u = d.size, z = d.color, M = d.position, i = d.distance, l = d.start, h = d.opacity, s = d.alwaysVisible, k = d.railVisible, j = d.railColor, x = d.railOpacity, p = d.wrapperOverflow, r = d.pointerClass, t = d.slimScrollRight; var K = a(this); var m = a(o).addClass(d.wrapperClass).css({ position: "relative", overflow: p, width: D, height: y }); K.css({ overflow: "hidden", width: D, height: y }); var e = a(o).addClass(d.railClass).css({ width: u, height: "100%", position: "absolute", top: 0, display: (s && k) ? "block" : "none", "border-radius": u, background: j, opacity: x, zIndex: 999 }); var F = a(o).addClass(d.barClass).css({ background: z, width: u, position: "absolute", top: 0, opacity: h, display: s ? "block" : "none", "border-radius": u, BorderRadius: u, MozBorderRadius: u, WebkitBorderRadius: u, zIndex: 9991 }); var f = (M == "right") ? { right: i} : { left: i }; e.css(f); F.css(f); K.wrap(m); if (r != undefined && r != null && r.length > 0) { a("<div class='" + r + "'></div>").insertBefore(K.parent()) } K.parent().append(F); K.parent().append(e); F.draggable({ axis: "y", containment: "parent", start: function () { n = true }, stop: function () { n = false; q() }, drag: function (N) { G(0, a(this).position().top, false) } }); e.hover(function () { if (K.hasScrollBar()) { g() } }, function () { q() }); F.hover(function () { B = true }, function () { B = false }); K.hover(function () { H = true; if (K.hasScrollBar()) { g(); q() } }, function () { if (K.hasScrollBar()) { H = false; q() } }); var J = function (N) { if (!H) { return } var N = N || window.event; var O = 0; if (N.wheelDelta) { O = -N.wheelDelta / 120 } if (N.detail) { O = N.detail / 3 } G(O, true); if (K.hasScrollBar()) { N.preventDefault() } if (!A && K.hasScrollBar()) { N.returnValue = false } }; var G = function (T, P, N) { var S = T; if (P) { S = F.position().top + T * w; S = Math.max(S, 0); var R = K.outerHeight() - F.outerHeight(); S = Math.min(S, R); F.css({ top: S + "px" }) } var Q = parseInt(F.position().top) / (K.outerHeight() - F.outerHeight()); S = Q * (K[0].scrollHeight - K.outerHeight()); if (N) { S = T; var O = S / K[0].scrollHeight * K.outerHeight(); F.css({ top: O + "px" }) } K.scrollTop(S); if (K.hasScrollBar()) { g() } q() }; var I = function () { if (window.addEventListener) { this.addEventListener("DOMMouseScroll", J, false); this.addEventListener("mousewheel", J, false) } else { document.attachEvent("onmousewheel", J) } }; I(); var L = function () { C = Math.max((K.outerHeight() / K[0].scrollHeight) * K.outerHeight(), E); F.css({ height: C + "px" }) }; L(); var g = function () { L(); clearTimeout(v); if (C >= K.outerHeight()) { A = true; return } F.fadeIn("fast"); if (k) { e.fadeIn("fast") } }; var q = function () { if (!s) { v = setTimeout(function () { if (!B && !n) { F.fadeOut("slow"); e.fadeOut("slow") } }, 1000) } }; if (l == "bottom") { F.css({ top: "auto", bottom: 0 }); G(0, true) } else { if (typeof l == "object") { G(a(l).position().top, null, true); if (!s) { F.hide() } } } }); return this } }); jQuery.fn.extend({ slimscroll: jQuery.fn.slimScroll }) })(jQuery); (function (a) { a.fn.hasScrollBar = function () { return this.get(0).scrollHeight > this.height() } })(jQuery);
