Advertisement
Guest User

jquery.nicescroll.min.js

a guest
Jul 3rd, 2018
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 108.29 KB | None | 0 0
  1. (function(f) {
  2.     "function" === typeof define && define.amd ? define(["jquery"], f) : f(jQuery)
  3. })(function(f) {
  4.     var y = !1,
  5.         D = !1,
  6.         N = 0,
  7.         O = 2E3,
  8.         x = 0,
  9.         H = ["webkit", "ms", "moz", "o"],
  10.         s = window.requestAnimationFrame || !1,
  11.         t = window.cancelAnimationFrame || !1;
  12.     if (!s)
  13.         for (var P in H) {
  14.             var E = H[P];
  15.             s || (s = window[E + "RequestAnimationFrame"]);
  16.             t || (t = window[E + "CancelAnimationFrame"] || window[E + "CancelRequestAnimationFrame"])
  17.         }
  18.     var v = window.MutationObserver || window.WebKitMutationObserver || !1,
  19.         I = {
  20.             zindex: "auto",
  21.             cursoropacitymin: 0,
  22.             cursoropacitymax: 1,
  23.             cursorcolor: "#424242",
  24.             cursorwidth: "5px",
  25.             cursorborder: "1px solid #fff",
  26.             cursorborderradius: "5px",
  27.             scrollspeed: 60,
  28.             mousescrollstep: 24,
  29.             touchbehavior: !1,
  30.             hwacceleration: !0,
  31.             usetransition: !0,
  32.             boxzoom: !1,
  33.             dblclickzoom: !0,
  34.             gesturezoom: !0,
  35.             grabcursorenabled: !0,
  36.             autohidemode: !0,
  37.             background: "",
  38.             iframeautoresize: !0,
  39.             cursorminheight: 32,
  40.             preservenativescrolling: !0,
  41.             railoffset: !1,
  42.             railhoffset: !1,
  43.             bouncescroll: !0,
  44.             spacebarenabled: !0,
  45.             railpadding: {
  46.                 top: 0,
  47.                 right: 0,
  48.                 left: 0,
  49.                 bottom: 0
  50.             },
  51.             disableoutline: !0,
  52.             horizrailenabled: !0,
  53.             railalign: "right",
  54.             railvalign: "bottom",
  55.             enabletranslate3d: !0,
  56.             enablemousewheel: !0,
  57.             enablekeyboard: !0,
  58.             smoothscroll: !0,
  59.             sensitiverail: !0,
  60.             enablemouselockapi: !0,
  61.             cursorfixedheight: !1,
  62.             directionlockdeadzone: 6,
  63.             hidecursordelay: 400,
  64.             nativeparentscrolling: !0,
  65.             enablescrollonselection: !0,
  66.             overflowx: !0,
  67.             overflowy: !0,
  68.             cursordragspeed: .3,
  69.             rtlmode: "auto",
  70.             cursordragontouch: !1,
  71.             oneaxismousemode: "auto",
  72.             scriptpath: function() {
  73.                 var f = document.getElementsByTagName("script"),
  74.                     f = f[f.length - 1].src.split("?")[0];
  75.                 return 0 < f.split("/").length ? f.split("/").slice(0, -1).join("/") + "/" : ""
  76.             }(),
  77.             preventmultitouchscrolling: !0
  78.         },
  79.         F = !1,
  80.         Q = function() {
  81.             if (F) return F;
  82.             var f = document.createElement("DIV"),
  83.                 c = f.style,
  84.                 h = navigator.userAgent,
  85.                 m = navigator.platform,
  86.                 d = {
  87.                     haspointerlock: "pointerLockElement" in document || "webkitPointerLockElement" in document || "mozPointerLockElement" in document
  88.                 };
  89.             d.isopera = "opera" in window;
  90.             d.isopera12 = d.isopera && "getUserMedia" in navigator;
  91.             d.isoperamini = "[object OperaMini]" === Object.prototype.toString.call(window.operamini);
  92.             d.isie = "all" in document && "attachEvent" in f && !d.isopera;
  93.             d.isieold = d.isie && !("msInterpolationMode" in c);
  94.             d.isie7 = d.isie && !d.isieold && (!("documentMode" in document) || 7 == document.documentMode);
  95.             d.isie8 = d.isie && "documentMode" in document && 8 == document.documentMode;
  96.             d.isie9 = d.isie && "performance" in window && 9 <= document.documentMode;
  97.             d.isie10 = d.isie && "performance" in window && 10 == document.documentMode;
  98.             d.isie11 = "msRequestFullscreen" in f && 11 <= document.documentMode;
  99.             d.isie9mobile = /iemobile.9/i.test(h);
  100.             d.isie9mobile && (d.isie9 = !1);
  101.             d.isie7mobile = !d.isie9mobile && d.isie7 && /iemobile/i.test(h);
  102.             d.ismozilla = "MozAppearance" in c;
  103.             d.iswebkit = "WebkitAppearance" in c;
  104.             d.ischrome = "chrome" in window;
  105.             d.ischrome22 = d.ischrome && d.haspointerlock;
  106.             d.ischrome26 = d.ischrome && "transition" in c;
  107.             d.cantouch = "ontouchstart" in document.documentElement || "ontouchstart" in window;
  108.             d.hasmstouch = window.MSPointerEvent || !1;
  109.             d.hasw3ctouch = window.PointerEvent || !1;
  110.             d.ismac = /^mac$/i.test(m);
  111.             d.isios = d.cantouch && /iphone|ipad|ipod/i.test(m);
  112.             d.isios4 = d.isios && !("seal" in Object);
  113.             d.isios7 = d.isios && "webkitHidden" in document;
  114.             d.isandroid = /android/i.test(h);
  115.             d.haseventlistener = "addEventListener" in f;
  116.             d.trstyle = !1;
  117.             d.hastransform = !1;
  118.             d.hastranslate3d = !1;
  119.             d.transitionstyle = !1;
  120.             d.hastransition = !1;
  121.             d.transitionend = !1;
  122.             m = ["transform", "msTransform", "webkitTransform", "MozTransform", "OTransform"];
  123.             for (h = 0; h < m.length; h++)
  124.                 if ("undefined" != typeof c[m[h]]) {
  125.                     d.trstyle = m[h];
  126.                     break
  127.                 }
  128.             d.hastransform = !!d.trstyle;
  129.             d.hastransform && (c[d.trstyle] = "translate3d(1px,2px,3px)", d.hastranslate3d = /translate3d/.test(c[d.trstyle]));
  130.             d.transitionstyle = !1;
  131.             d.prefixstyle = "";
  132.             d.transitionend = !1;
  133.             for (var m = "transition webkitTransition msTransition MozTransition OTransition OTransition KhtmlTransition".split(" "), n = " -webkit- -ms- -moz- -o- -o -khtml-".split(" "), p = "transitionend webkitTransitionEnd msTransitionEnd transitionend otransitionend oTransitionEnd KhtmlTransitionEnd".split(" "), h = 0; h < m.length; h++)
  134.                 if (m[h] in c) {
  135.                     d.transitionstyle = m[h];
  136.                     d.prefixstyle = n[h];
  137.                     d.transitionend = p[h];
  138.                     break
  139.                 }
  140.             d.ischrome26 && (d.prefixstyle = n[1]);
  141.             d.hastransition = d.transitionstyle;
  142.             a: {
  143.                 h = ["-webkit-grab", "-moz-grab", "grab"];
  144.                 if (d.ischrome && !d.ischrome22 || d.isie) h = [];
  145.                 for (m = 0; m < h.length; m++)
  146.                     if (n = h[m], c.cursor = n, c.cursor == n) {
  147.                         c = n;
  148.                         break a
  149.                     }
  150.                 c = "url(//mail.google.com/mail/images/2/openhand.cur),n-resize"
  151.             }
  152.             d.cursorgrabvalue = c;
  153.             d.hasmousecapture = "setCapture" in f;
  154.             d.hasMutationObserver = !1 !== v;
  155.             return F = d
  156.         },
  157.         R = function(k, c) {
  158.             function h() {
  159.                 var b = a.doc.css(e.trstyle);
  160.                 return b && "matrix" == b.substr(0, 6) ? b.replace(/^.*\((.*)\)$/g, "$1").replace(/px/g, "").split(/, +/) : !1
  161.             }
  162.  
  163.             function m() {
  164.                 var b = a.win;
  165.                 if ("zIndex" in b) return b.zIndex();
  166.                 for (; 0 < b.length && 9 != b[0].nodeType;) {
  167.                     var g = b.css("zIndex");
  168.                     if (!isNaN(g) && 0 != g) return parseInt(g);
  169.                     b = b.parent()
  170.                 }
  171.                 return !1
  172.             }
  173.  
  174.             function d(b, g, q) {
  175.                 g = b.css(g);
  176.                 b = parseFloat(g);
  177.                 return isNaN(b) ? (b = w[g] || 0, q = 3 == b ? q ? a.win.outerHeight() - a.win.innerHeight() : a.win.outerWidth() - a.win.innerWidth() : 1, a.isie8 && b && (b += 1), q ? b : 0) : b
  178.             }
  179.  
  180.             function n(b, g, q, c) {
  181.                 a._bind(b, g, function(a) {
  182.                     a = a ? a : window.event;
  183.                     var c = {
  184.                         original: a,
  185.                         target: a.target || a.srcElement,
  186.                         type: "wheel",
  187.                         deltaMode: "MozMousePixelScroll" == a.type ? 0 : 1,
  188.                         deltaX: 0,
  189.                         deltaZ: 0,
  190.                         preventDefault: function() {
  191.                             a.preventDefault ? a.preventDefault() : a.returnValue = !1;
  192.                             return !1
  193.                         },
  194.                         stopImmediatePropagation: function() {
  195.                             a.stopImmediatePropagation ? a.stopImmediatePropagation() : a.cancelBubble = !0
  196.                         }
  197.                     };
  198.                     "mousewheel" == g ? (c.deltaY = -.025 * a.wheelDelta, a.wheelDeltaX && (c.deltaX = -.025 * a.wheelDeltaX)) : c.deltaY = a.detail;
  199.                     return q.call(b, c)
  200.                 }, c)
  201.             }
  202.  
  203.             function p(b, g, c) {
  204.                 var d, e;
  205.                 0 == b.deltaMode ? (d = -Math.floor(a.opt.mousescrollstep / 54 * b.deltaX), e = -Math.floor(a.opt.mousescrollstep / 54 * b.deltaY)) : 1 == b.deltaMode && (d = -Math.floor(b.deltaX * a.opt.mousescrollstep), e = -Math.floor(b.deltaY * a.opt.mousescrollstep));
  206.                 g && a.opt.oneaxismousemode && 0 == d && e && (d = e, e = 0, c && (0 > d ? a.getScrollLeft() >= a.page.maxw : 0 >= a.getScrollLeft()) && (e = d, d = 0));
  207.                 d && (a.scrollmom && a.scrollmom.stop(), a.lastdeltax += d, a.debounced("mousewheelx", function() {
  208.                     var b = a.lastdeltax;
  209.                     a.lastdeltax = 0;
  210.                     a.rail.drag || a.doScrollLeftBy(b)
  211.                 }, 15));
  212.                 if (e) {
  213.                     if (a.opt.nativeparentscrolling && c && !a.ispage && !a.zoomactive)
  214.                         if (0 > e) {
  215.                             if (a.getScrollTop() >= a.page.maxh) return !0
  216.                         } else if (0 >= a.getScrollTop()) return !0;
  217.                     a.scrollmom && a.scrollmom.stop();
  218.                     a.lastdeltay += e;
  219.                     a.debounced("mousewheely", function() {
  220.                         var b = a.lastdeltay;
  221.                         a.lastdeltay = 0;
  222.                         a.rail.drag || a.doScrollBy(b)
  223.                     }, 15)
  224.                 }
  225.                 b.stopImmediatePropagation();
  226.                 return b.preventDefault()
  227.             }
  228.             var a = this;
  229.             this.version = "3.6.0";
  230.             this.name = "nicescroll";
  231.             this.me = c;
  232.             this.opt = {
  233.                 doc: f("body"),
  234.                 win: !1
  235.             };
  236.             f.extend(this.opt, I);
  237.             this.opt.snapbackspeed = 80;
  238.             if (k)
  239.                 for (var G in a.opt) "undefined" != typeof k[G] && (a.opt[G] = k[G]);
  240.             this.iddoc = (this.doc = a.opt.doc) && this.doc[0] ? this.doc[0].id || "" : "";
  241.             this.ispage = /^BODY|HTML/.test(a.opt.win ? a.opt.win[0].nodeName : this.doc[0].nodeName);
  242.             this.haswrapper = !1 !== a.opt.win;
  243.             this.win = a.opt.win || (this.ispage ? f(window) : this.doc);
  244.             this.docscroll = this.ispage && !this.haswrapper ? f(window) : this.win;
  245.             this.body = f("body");
  246.             this.iframe = this.isfixed = this.viewport = !1;
  247.             this.isiframe = "IFRAME" == this.doc[0].nodeName && "IFRAME" == this.win[0].nodeName;
  248.             this.istextarea = "TEXTAREA" == this.win[0].nodeName;
  249.             this.forcescreen = !1;
  250.             this.canshowonmouseevent = "scroll" != a.opt.autohidemode;
  251.             this.page = this.view = this.onzoomout = this.onzoomin = this.onscrollcancel = this.onscrollend = this.onscrollstart = this.onclick = this.ongesturezoom = this.onkeypress = this.onmousewheel = this.onmousemove = this.onmouseup = this.onmousedown = !1;
  252.             this.scroll = {
  253.                 x: 0,
  254.                 y: 0
  255.             };
  256.             this.scrollratio = {
  257.                 x: 0,
  258.                 y: 0
  259.             };
  260.             this.cursorheight = 20;
  261.             this.scrollvaluemax = 0;
  262.             this.isrtlmode = "auto" == this.opt.rtlmode ? "rtl" == (this.win[0] == window ? this.body : this.win).css("direction") : !0 === this.opt.rtlmode;
  263.             this.observerbody = this.observerremover = this.observer = this.scrollmom = this.scrollrunning = !1;
  264.             do this.id = "ascrail" + O++; while (document.getElementById(this.id));
  265.             this.hasmousefocus = this.hasfocus = this.zoomactive = this.zoom = this.selectiondrag = this.cursorfreezed = this.cursor = this.rail = !1;
  266.             this.visibility = !0;
  267.             this.hidden = this.locked = this.railslocked = !1;
  268.             this.cursoractive = !0;
  269.             this.wheelprevented = !1;
  270.             this.overflowx = a.opt.overflowx;
  271.             this.overflowy = a.opt.overflowy;
  272.             this.nativescrollingarea = !1;
  273.             this.checkarea = 0;
  274.             this.events = [];
  275.             this.saved = {};
  276.             this.delaylist = {};
  277.             this.synclist = {};
  278.             this.lastdeltay = this.lastdeltax = 0;
  279.             this.detected = Q();
  280.             var e = f.extend({}, this.detected);
  281.             this.ishwscroll = (this.canhwscroll = e.hastransform && a.opt.hwacceleration) && a.haswrapper;
  282.             this.hasreversehr = this.isrtlmode && !e.iswebkit;
  283.             this.istouchcapable = !1;
  284.             !e.cantouch || e.isios || e.isandroid || !e.iswebkit && !e.ismozilla || (this.istouchcapable = !0, e.cantouch = !1);
  285.             a.opt.enablemouselockapi || (e.hasmousecapture = !1, e.haspointerlock = !1);
  286.             this.debounced = function(b, g, c) {
  287.                 var d = a.delaylist[b];
  288.                 a.delaylist[b] = g;
  289.                 d || setTimeout(function() {
  290.                     var g = a.delaylist[b];
  291.                     a.delaylist[b] = !1;
  292.                     g.call(a)
  293.                 }, c)
  294.             };
  295.             var r = !1;
  296.             this.synched = function(b, g) {
  297.                 a.synclist[b] = g;
  298.                 (function() {
  299.                     r || (s(function() {
  300.                         r = !1;
  301.                         for (var b in a.synclist) {
  302.                             var g = a.synclist[b];
  303.                             g && g.call(a);
  304.                             a.synclist[b] = !1
  305.                         }
  306.                     }), r = !0)
  307.                 })();
  308.                 return b
  309.             };
  310.             this.unsynched = function(b) {
  311.                 a.synclist[b] && (a.synclist[b] = !1)
  312.             };
  313.             this.css = function(b, g) {
  314.                 for (var c in g) a.saved.css.push([b, c, b.css(c)]), b.css(c, g[c])
  315.             };
  316.             this.scrollTop = function(b) {
  317.                 return "undefined" == typeof b ? a.getScrollTop() : a.setScrollTop(b)
  318.             };
  319.             this.scrollLeft = function(b) {
  320.                 return "undefined" == typeof b ? a.getScrollLeft() : a.setScrollLeft(b)
  321.             };
  322.             var A = function(a, g, c, d, e, f, h) {
  323.                 this.st = a;
  324.                 this.ed = g;
  325.                 this.spd = c;
  326.                 this.p1 = d || 0;
  327.                 this.p2 = e || 1;
  328.                 this.p3 = f || 0;
  329.                 this.p4 = h || 1;
  330.                 this.ts = (new Date).getTime();
  331.                 this.df = this.ed - this.st
  332.             };
  333.             A.prototype = {
  334.                 B2: function(a) {
  335.                     return 3 * a * a * (1 - a)
  336.                 },
  337.                 B3: function(a) {
  338.                     return 3 * a * (1 - a) * (1 - a)
  339.                 },
  340.                 B4: function(a) {
  341.                     return (1 - a) * (1 - a) * (1 - a)
  342.                 },
  343.                 getNow: function() {
  344.                     var a = 1 - ((new Date).getTime() - this.ts) / this.spd,
  345.                         g = this.B2(a) + this.B3(a) + this.B4(a);
  346.                     return 0 > a ? this.ed : this.st + Math.round(this.df * g)
  347.                 },
  348.                 update: function(a, g) {
  349.                     this.st = this.getNow();
  350.                     this.ed = a;
  351.                     this.spd = g;
  352.                     this.ts = (new Date).getTime();
  353.                     this.df = this.ed - this.st;
  354.                     return this
  355.                 }
  356.             };
  357.             if (this.ishwscroll) {
  358.                 this.doc.translate = {
  359.                     x: 0,
  360.                     y: 0,
  361.                     tx: "0px",
  362.                     ty: "0px"
  363.                 };
  364.                 e.hastranslate3d && e.isios && this.doc.css("-webkit-backface-visibility", "hidden");
  365.                 this.getScrollTop = function(b) {
  366.                     if (!b) {
  367.                         if (b = h()) return 16 == b.length ? -b[13] : -b[5];
  368.                         if (a.timerscroll && a.timerscroll.bz) return a.timerscroll.bz.getNow()
  369.                     }
  370.                     return a.doc.translate.y
  371.                 };
  372.                 this.getScrollLeft = function(b) {
  373.                     if (!b) {
  374.                         if (b = h()) return 16 == b.length ? -b[12] : -b[4];
  375.                         if (a.timerscroll && a.timerscroll.bh) return a.timerscroll.bh.getNow()
  376.                     }
  377.                     return a.doc.translate.x
  378.                 };
  379.                 this.notifyScrollEvent = function(a) {
  380.                     var g = document.createEvent("UIEvents");
  381.                     g.initUIEvent("scroll", !1, !0, window, 1);
  382.                     g.niceevent = !0;
  383.                     a.dispatchEvent(g)
  384.                 };
  385.                 var K = this.isrtlmode ? 1 : -1;
  386.                 e.hastranslate3d && a.opt.enabletranslate3d ? (this.setScrollTop = function(b, g) {
  387.                     a.doc.translate.y = b;
  388.                     a.doc.translate.ty = -1 * b + "px";
  389.                     a.doc.css(e.trstyle, "translate3d(" + a.doc.translate.tx + "," + a.doc.translate.ty + ",0px)");
  390.                     g || a.notifyScrollEvent(a.win[0])
  391.                 }, this.setScrollLeft = function(b, g) {
  392.                     a.doc.translate.x = b;
  393.                     a.doc.translate.tx = b * K + "px";
  394.                     a.doc.css(e.trstyle, "translate3d(" + a.doc.translate.tx + "," + a.doc.translate.ty + ",0px)");
  395.                     g || a.notifyScrollEvent(a.win[0])
  396.                 }) : (this.setScrollTop = function(b, g) {
  397.                     a.doc.translate.y = b;
  398.                     a.doc.translate.ty = -1 * b + "px";
  399.                     a.doc.css(e.trstyle, "translate(" + a.doc.translate.tx + "," + a.doc.translate.ty + ")");
  400.                     g || a.notifyScrollEvent(a.win[0])
  401.                 }, this.setScrollLeft = function(b, g) {
  402.                     a.doc.translate.x = b;
  403.                     a.doc.translate.tx = b * K + "px";
  404.                     a.doc.css(e.trstyle, "translate(" + a.doc.translate.tx + "," + a.doc.translate.ty + ")");
  405.                     g || a.notifyScrollEvent(a.win[0])
  406.                 })
  407.             } else this.getScrollTop = function() {
  408.                 return a.docscroll.scrollTop()
  409.             }, this.setScrollTop = function(b) {
  410.                 return a.docscroll.scrollTop(b)
  411.             }, this.getScrollLeft = function() {
  412.                 return a.detected.ismozilla && a.isrtlmode ? Math.abs(a.docscroll.scrollLeft()) : a.docscroll.scrollLeft()
  413.             }, this.setScrollLeft = function(b) {
  414.                 return a.docscroll.scrollLeft(a.detected.ismozilla && a.isrtlmode ? -b : b)
  415.             };
  416.             this.getTarget = function(a) {
  417.                 return a ? a.target ? a.target : a.srcElement ? a.srcElement : !1 : !1
  418.             };
  419.             this.hasParent = function(a, g) {
  420.                 if (!a) return !1;
  421.                 for (var c = a.target || a.srcElement || a || !1; c && c.id != g;) c = c.parentNode || !1;
  422.                 return !1 !== c
  423.             };
  424.             var w = {
  425.                 thin: 1,
  426.                 medium: 3,
  427.                 thick: 5
  428.             };
  429.             this.getDocumentScrollOffset = function() {
  430.                 return {
  431.                     top: window.pageYOffset || document.documentElement.scrollTop,
  432.                     left: window.pageXOffset || document.documentElement.scrollLeft
  433.                 }
  434.             };
  435.             this.getOffset = function() {
  436.                 if (a.isfixed) {
  437.                     var b = a.win.offset(),
  438.                         g = a.getDocumentScrollOffset();
  439.                     b.top -= g.top;
  440.                     b.left -= g.left;
  441.                     return b
  442.                 }
  443.                 b = a.win.offset();
  444.                 if (!a.viewport) return b;
  445.                 g = a.viewport.offset();
  446.                 return {
  447.                     top: b.top - g.top,
  448.                     left: b.left - g.left
  449.                 }
  450.             };
  451.             this.updateScrollBar = function(b) {
  452.                 if (a.ishwscroll) a.rail.css({
  453.                     height: a.win.innerHeight() - (a.opt.railpadding.top + a.opt.railpadding.bottom)
  454.                 }), a.railh && a.railh.css({
  455.                     width: a.win.innerWidth() - (a.opt.railpadding.left + a.opt.railpadding.right)
  456.                 });
  457.                 else {
  458.                     var g = a.getOffset(),
  459.                         c = g.top,
  460.                         e = g.left - (a.opt.railpadding.left + a.opt.railpadding.right),
  461.                         c = c + d(a.win, "border-top-width", !0),
  462.                         e = e + (a.rail.align ? a.win.outerWidth() - d(a.win, "border-right-width") - a.rail.width : d(a.win, "border-left-width")),
  463.                         f = a.opt.railoffset;
  464.                     f && (f.top && (c += f.top), a.rail.align && f.left && (e += f.left));
  465.                     a.railslocked || a.rail.css({
  466.                         top: c,
  467.                         left: e,
  468.                         height: (b ? b.h : a.win.innerHeight()) - (a.opt.railpadding.top + a.opt.railpadding.bottom)
  469.                     });
  470.                     a.zoom && a.zoom.css({
  471.                         top: c + 1,
  472.                         left: 1 == a.rail.align ? e - 20 : e + a.rail.width + 4
  473.                     });
  474.                     if (a.railh && !a.railslocked) {
  475.                         c = g.top;
  476.                         e = g.left;
  477.                         if (f = a.opt.railhoffset) f.top && (c += f.top), f.left && (e += f.left);
  478.                         b = a.railh.align ? c + d(a.win, "border-top-width", !0) + a.win.innerHeight() - a.railh.height : c + d(a.win, "border-top-width", !0);
  479.                         e += d(a.win, "border-left-width");
  480.                         a.railh.css({
  481.                             top: b - (a.opt.railpadding.top + a.opt.railpadding.bottom),
  482.                             left: e,
  483.                             width: a.railh.width
  484.                         })
  485.                     }
  486.                 }
  487.             };
  488.             this.doRailClick = function(b, g, c) {
  489.                 var e;
  490.                 a.railslocked || (a.cancelEvent(b), g ? (g = c ? a.doScrollLeft : a.doScrollTop, e = c ? (b.pageX - a.railh.offset().left - a.cursorwidth / 2) * a.scrollratio.x : (b.pageY - a.rail.offset().top - a.cursorheight / 2) * a.scrollratio.y, g(e)) : (g = c ? a.doScrollLeftBy : a.doScrollBy, e = c ? a.scroll.x : a.scroll.y, b = c ? b.pageX - a.railh.offset().left : b.pageY - a.rail.offset().top, c = c ? a.view.w : a.view.h, g(e >= b ? c : -c)))
  491.             };
  492.             a.hasanimationframe = s;
  493.             a.hascancelanimationframe = t;
  494.             a.hasanimationframe ? a.hascancelanimationframe || (t = function() {
  495.                 a.cancelAnimationFrame = !0
  496.             }) : (s = function(a) {
  497.                 return setTimeout(a, 15 - Math.floor(+new Date / 1E3) % 16)
  498.             }, t = clearInterval);
  499.             this.init = function() {
  500.                 a.saved.css = [];
  501.                 if (e.isie7mobile || e.isoperamini) return !0;
  502.                 e.hasmstouch && a.css(a.ispage ? f("html") : a.win, {
  503.                     "-ms-touch-action": "none"
  504.                 });
  505.                 a.zindex = "auto";
  506.                 a.zindex = a.ispage || "auto" != a.opt.zindex ? a.opt.zindex : m() || "auto";
  507.                 !a.ispage && "auto" != a.zindex && a.zindex > x && (x = a.zindex);
  508.                 a.isie && 0 == a.zindex && "auto" == a.opt.zindex && (a.zindex = "auto");
  509.                 if (!a.ispage || !e.cantouch && !e.isieold && !e.isie9mobile) {
  510.                     var b = a.docscroll;
  511.                     a.ispage && (b = a.haswrapper ? a.win : a.doc);
  512.                     e.isie9mobile || a.css(b, {
  513.                         "overflow-y": "hidden"
  514.                     });
  515.                     a.ispage && e.isie7 && ("BODY" == a.doc[0].nodeName ? a.css(f("html"), {
  516.                         "overflow-y": "hidden"
  517.                     }) : "HTML" == a.doc[0].nodeName && a.css(f("body"), {
  518.                         "overflow-y": "hidden"
  519.                     }));
  520.                     !e.isios || a.ispage || a.haswrapper || a.css(f("body"), {
  521.                         "-webkit-overflow-scrolling": "touch"
  522.                     });
  523.                     var g = f(document.createElement("div"));
  524.                     g.css({
  525.                         position: "relative",
  526.                         top: 0,
  527.                         "float": "right",
  528.                         width: a.opt.cursorwidth,
  529.                         height: "0px",
  530.                         "background-color": a.opt.cursorcolor,
  531.                         border: a.opt.cursorborder,
  532.                         "background-clip": "padding-box",
  533.                         "-webkit-border-radius": a.opt.cursorborderradius,
  534.                         "-moz-border-radius": a.opt.cursorborderradius,
  535.                         "border-radius": a.opt.cursorborderradius
  536.                     });
  537.                     g.hborder = parseFloat(g.outerHeight() - g.innerHeight());
  538.                     g.addClass("nicescroll-cursors");
  539.                     a.cursor = g;
  540.                     var c = f(document.createElement("div"));
  541.                     c.attr("id", a.id);
  542.                     c.addClass("nicescroll-rails nicescroll-rails-vr");
  543.                     var d, h, k = ["left", "right", "top", "bottom"],
  544.                         J;
  545.                     for (J in k) h = k[J], (d = a.opt.railpadding[h]) ? c.css("padding-" + h, d + "px") : a.opt.railpadding[h] = 0;
  546.                     c.append(g);
  547.                     c.width = Math.max(parseFloat(a.opt.cursorwidth), g.outerWidth());
  548.                     c.css({
  549.                         width: c.width + "px",
  550.                         zIndex: a.zindex,
  551.                         background: a.opt.background,
  552.                         cursor: "default"
  553.                     });
  554.                     c.visibility = !0;
  555.                     c.scrollable = !0;
  556.                     c.align = "left" == a.opt.railalign ? 0 : 1;
  557.                     a.rail = c;
  558.                     g = a.rail.drag = !1;
  559.                     !a.opt.boxzoom || a.ispage || e.isieold || (g = document.createElement("div"), a.bind(g, "click", a.doZoom), a.bind(g, "mouseenter", function() {
  560.                         a.zoom.css("opacity", a.opt.cursoropacitymax)
  561.                     }), a.bind(g, "mouseleave", function() {
  562.                         a.zoom.css("opacity", a.opt.cursoropacitymin)
  563.                     }), a.zoom = f(g), a.zoom.css({
  564.                         cursor: "pointer",
  565.                         "z-index": a.zindex,
  566.                         backgroundImage: "url(" + a.opt.scriptpath + "zoomico.png)",
  567.                         height: 18,
  568.                         width: 18,
  569.                         backgroundPosition: "0px 0px"
  570.                     }), a.opt.dblclickzoom && a.bind(a.win, "dblclick", a.doZoom), e.cantouch && a.opt.gesturezoom && (a.ongesturezoom = function(b) {
  571.                         1.5 < b.scale && a.doZoomIn(b);
  572.                         .8 > b.scale && a.doZoomOut(b);
  573.                         return a.cancelEvent(b)
  574.                     }, a.bind(a.win, "gestureend", a.ongesturezoom)));
  575.                     a.railh = !1;
  576.                     var l;
  577.                     a.opt.horizrailenabled && (a.css(b, {
  578.                         "overflow-x": "hidden"
  579.                     }), g = f(document.createElement("div")), g.css({
  580.                         position: "absolute",
  581.                         top: 0,
  582.                         height: a.opt.cursorwidth,
  583.                         width: "0px",
  584.                         "background-color": a.opt.cursorcolor,
  585.                         border: a.opt.cursorborder,
  586.                         "background-clip": "padding-box",
  587.                         "-webkit-border-radius": a.opt.cursorborderradius,
  588.                         "-moz-border-radius": a.opt.cursorborderradius,
  589.                         "border-radius": a.opt.cursorborderradius
  590.                     }), e.isieold && g.css({
  591.                         overflow: "hidden"
  592.                     }), g.wborder = parseFloat(g.outerWidth() - g.innerWidth()), g.addClass("nicescroll-cursors"), a.cursorh = g, l = f(document.createElement("div")), l.attr("id", a.id + "-hr"), l.addClass("nicescroll-rails nicescroll-rails-hr"), l.height = Math.max(parseFloat(a.opt.cursorwidth), g.outerHeight()), l.css({
  593.                         height: l.height + "px",
  594.                         zIndex: a.zindex,
  595.                         background: a.opt.background
  596.                     }), l.append(g), l.visibility = !0, l.scrollable = !0, l.align = "top" == a.opt.railvalign ? 0 : 1, a.railh = l, a.railh.drag = !1);
  597.                     a.ispage ? (c.css({
  598.                         position: "fixed",
  599.                         top: "0px",
  600.                         height: "100%"
  601.                     }), c.align ? c.css({
  602.                         right: "0px"
  603.                     }) : c.css({
  604.                         left: "0px"
  605.                     }), a.body.append(c), a.railh && (l.css({
  606.                         position: "fixed",
  607.                         left: "0px",
  608.                         width: "100%"
  609.                     }), l.align ? l.css({
  610.                         bottom: "0px"
  611.                     }) : l.css({
  612.                         top: "0px"
  613.                     }), a.body.append(l))) : (a.ishwscroll ? ("static" == a.win.css("position") && a.css(a.win, {
  614.                         position: "relative"
  615.                     }), b = "HTML" == a.win[0].nodeName ? a.body : a.win, f(b).scrollTop(0).scrollLeft(0), a.zoom && (a.zoom.css({
  616.                         position: "absolute",
  617.                         top: 1,
  618.                         right: 0,
  619.                         "margin-right": c.width + 4
  620.                     }), b.append(a.zoom)), c.css({
  621.                         position: "absolute",
  622.                         top: 0
  623.                     }), c.align ? c.css({
  624.                         right: 0
  625.                     }) : c.css({
  626.                         left: 0
  627.                     }), b.append(c), l && (l.css({
  628.                         position: "absolute",
  629.                         left: 0,
  630.                         bottom: 0
  631.                     }), l.align ? l.css({
  632.                         bottom: 0
  633.                     }) : l.css({
  634.                         top: 0
  635.                     }), b.append(l))) : (a.isfixed = "fixed" == a.win.css("position"), b = a.isfixed ? "fixed" : "absolute", a.isfixed || (a.viewport = a.getViewport(a.win[0])), a.viewport && (a.body = a.viewport, 0 == /fixed|absolute/.test(a.viewport.css("position")) && a.css(a.viewport, {
  636.                         position: "relative"
  637.                     })), c.css({
  638.                         position: b
  639.                     }), a.zoom && a.zoom.css({
  640.                         position: b
  641.                     }), a.updateScrollBar(), a.body.append(c), a.zoom && a.body.append(a.zoom), a.railh && (l.css({
  642.                         position: b
  643.                     }), a.body.append(l))), e.isios && a.css(a.win, {
  644.                         "-webkit-tap-highlight-color": "rgba(0,0,0,0)",
  645.                         "-webkit-touch-callout": "none"
  646.                     }), e.isie && a.opt.disableoutline && a.win.attr("hideFocus", "true"), e.iswebkit && a.opt.disableoutline && a.win.css({
  647.                         outline: "none"
  648.                     }));
  649.                     !1 === a.opt.autohidemode ? (a.autohidedom = !1, a.rail.css({
  650.                         opacity: a.opt.cursoropacitymax
  651.                     }), a.railh && a.railh.css({
  652.                         opacity: a.opt.cursoropacitymax
  653.                     })) : !0 === a.opt.autohidemode || "leave" === a.opt.autohidemode ? (a.autohidedom = f().add(a.rail), e.isie8 && (a.autohidedom = a.autohidedom.add(a.cursor)), a.railh && (a.autohidedom = a.autohidedom.add(a.railh)), a.railh && e.isie8 && (a.autohidedom = a.autohidedom.add(a.cursorh))) : "scroll" == a.opt.autohidemode ? (a.autohidedom = f().add(a.rail), a.railh && (a.autohidedom = a.autohidedom.add(a.railh))) : "cursor" == a.opt.autohidemode ? (a.autohidedom = f().add(a.cursor), a.railh && (a.autohidedom = a.autohidedom.add(a.cursorh))) : "hidden" == a.opt.autohidemode && (a.autohidedom = !1, a.hide(), a.railslocked = !1);
  654.                     if (e.isie9mobile) a.scrollmom = new L(a), a.onmangotouch = function() {
  655.                         var b = a.getScrollTop(),
  656.                             c = a.getScrollLeft();
  657.                         if (b == a.scrollmom.lastscrolly && c == a.scrollmom.lastscrollx) return !0;
  658.                         var g = b - a.mangotouch.sy,
  659.                             e = c - a.mangotouch.sx;
  660.                         if (0 != Math.round(Math.sqrt(Math.pow(e, 2) + Math.pow(g, 2)))) {
  661.                             var d = 0 > g ? -1 : 1,
  662.                                 f = 0 > e ? -1 : 1,
  663.                                 q = +new Date;
  664.                             a.mangotouch.lazy && clearTimeout(a.mangotouch.lazy);
  665.                             80 < q - a.mangotouch.tm || a.mangotouch.dry != d || a.mangotouch.drx != f ? (a.scrollmom.stop(), a.scrollmom.reset(c, b), a.mangotouch.sy = b, a.mangotouch.ly = b, a.mangotouch.sx = c, a.mangotouch.lx = c, a.mangotouch.dry = d, a.mangotouch.drx = f, a.mangotouch.tm = q) : (a.scrollmom.stop(), a.scrollmom.update(a.mangotouch.sx - e, a.mangotouch.sy - g), a.mangotouch.tm = q, g = Math.max(Math.abs(a.mangotouch.ly - b), Math.abs(a.mangotouch.lx - c)), a.mangotouch.ly = b, a.mangotouch.lx = c, 2 < g && (a.mangotouch.lazy = setTimeout(function() {
  666.                                 a.mangotouch.lazy = !1;
  667.                                 a.mangotouch.dry = 0;
  668.                                 a.mangotouch.drx = 0;
  669.                                 a.mangotouch.tm = 0;
  670.                                 a.scrollmom.doMomentum(30)
  671.                             }, 100)))
  672.                         }
  673.                     }, c = a.getScrollTop(), l = a.getScrollLeft(), a.mangotouch = {
  674.                         sy: c,
  675.                         ly: c,
  676.                         dry: 0,
  677.                         sx: l,
  678.                         lx: l,
  679.                         drx: 0,
  680.                         lazy: !1,
  681.                         tm: 0
  682.                     }, a.bind(a.docscroll, "scroll", a.onmangotouch);
  683.                     else {
  684.                         if (e.cantouch || a.istouchcapable || a.opt.touchbehavior || e.hasmstouch) {
  685.                             a.scrollmom = new L(a);
  686.                             a.ontouchstart = function(b) {
  687.                                 if (b.pointerType && 2 != b.pointerType && "touch" != b.pointerType) return !1;
  688.                                 a.hasmoving = !1;
  689.                                 if (!a.railslocked) {
  690.                                     var c;
  691.                                     if (e.hasmstouch)
  692.                                         for (c = b.target ? b.target : !1; c;) {
  693.                                             var g = f(c).getNiceScroll();
  694.                                             if (0 < g.length && g[0].me == a.me) break;
  695.                                             if (0 < g.length) return !1;
  696.                                             if ("DIV" == c.nodeName && c.id == a.id) break;
  697.                                             c = c.parentNode ? c.parentNode : !1
  698.                                         }
  699.                                     a.cancelScroll();
  700.                                     if ((c = a.getTarget(b)) && /INPUT/i.test(c.nodeName) && /range/i.test(c.type)) return a.stopPropagation(b);
  701.                                     !("clientX" in b) && "changedTouches" in b && (b.clientX = b.changedTouches[0].clientX, b.clientY = b.changedTouches[0].clientY);
  702.                                     a.forcescreen && (g = b, b = {
  703.                                         original: b.original ? b.original : b
  704.                                     }, b.clientX = g.screenX, b.clientY = g.screenY);
  705.                                     a.rail.drag = {
  706.                                         x: b.clientX,
  707.                                         y: b.clientY,
  708.                                         sx: a.scroll.x,
  709.                                         sy: a.scroll.y,
  710.                                         st: a.getScrollTop(),
  711.                                         sl: a.getScrollLeft(),
  712.                                         pt: 2,
  713.                                         dl: !1
  714.                                     };
  715.                                     if (a.ispage || !a.opt.directionlockdeadzone) a.rail.drag.dl = "f";
  716.                                     else {
  717.                                         var g = f(window).width(),
  718.                                             d = f(window).height(),
  719.                                             q = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
  720.                                             h = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
  721.                                             d = Math.max(0, h - d),
  722.                                             g = Math.max(0, q - g);
  723.                                         a.rail.drag.ck = !a.rail.scrollable && a.railh.scrollable ? 0 < d ? "v" : !1 : a.rail.scrollable && !a.railh.scrollable ? 0 < g ? "h" : !1 : !1;
  724.                                         a.rail.drag.ck || (a.rail.drag.dl = "f")
  725.                                     }
  726.                                     a.opt.touchbehavior && a.isiframe && e.isie && (g = a.win.position(), a.rail.drag.x += g.left, a.rail.drag.y += g.top);
  727.                                     a.hasmoving = !1;
  728.                                     a.lastmouseup = !1;
  729.                                     a.scrollmom.reset(b.clientX, b.clientY);
  730.                                     if (!e.cantouch && !this.istouchcapable && !b.pointerType) {
  731.                                         if (!c || !/INPUT|SELECT|TEXTAREA/i.test(c.nodeName)) return !a.ispage && e.hasmousecapture && c.setCapture(), a.opt.touchbehavior ? (c.onclick && !c._onclick && (c._onclick = c.onclick, c.onclick = function(b) {
  732.                                             if (a.hasmoving) return !1;
  733.                                             c._onclick.call(this, b)
  734.                                         }), a.cancelEvent(b)) : a.stopPropagation(b);
  735.                                         /SUBMIT|CANCEL|BUTTON/i.test(f(c).attr("type")) && (pc = {
  736.                                             tg: c,
  737.                                             click: !1
  738.                                         }, a.preventclick = pc)
  739.                                     }
  740.                                 }
  741.                             };
  742.                             a.ontouchend = function(b) {
  743.                                 if (!a.rail.drag) return !0;
  744.                                 if (2 == a.rail.drag.pt) {
  745.                                     if (b.pointerType && 2 != b.pointerType && "touch" != b.pointerType) return !1;
  746.                                     a.scrollmom.doMomentum();
  747.                                     a.rail.drag = !1;
  748.                                     if (a.hasmoving && (a.lastmouseup = !0, a.hideCursor(), e.hasmousecapture && document.releaseCapture(), !e.cantouch)) return a.cancelEvent(b)
  749.                                 } else if (1 == a.rail.drag.pt) return a.onmouseup(b)
  750.                             };
  751.                             var n = a.opt.touchbehavior && a.isiframe && !e.hasmousecapture;
  752.                             a.ontouchmove = function(b, c) {
  753.                                 if (!a.rail.drag || b.targetTouches && a.opt.preventmultitouchscrolling && 1 < b.targetTouches.length || b.pointerType && 2 != b.pointerType && "touch" != b.pointerType) return !1;
  754.                                 if (2 == a.rail.drag.pt) {
  755.                                     if (e.cantouch && e.isios && "undefined" == typeof b.original) return !0;
  756.                                     a.hasmoving = !0;
  757.                                     a.preventclick && !a.preventclick.click && (a.preventclick.click = a.preventclick.tg.onclick || !1, a.preventclick.tg.onclick = a.onpreventclick);
  758.                                     b = f.extend({
  759.                                         original: b
  760.                                     }, b);
  761.                                     "changedTouches" in b && (b.clientX = b.changedTouches[0].clientX, b.clientY = b.changedTouches[0].clientY);
  762.                                     if (a.forcescreen) {
  763.                                         var g = b;
  764.                                         b = {
  765.                                             original: b.original ? b.original : b
  766.                                         };
  767.                                         b.clientX = g.screenX;
  768.                                         b.clientY = g.screenY
  769.                                     }
  770.                                     var d, g = d = 0;
  771.                                     n && !c && (d = a.win.position(), g = -d.left, d = -d.top);
  772.                                     var q = b.clientY + d;
  773.                                     d = q - a.rail.drag.y;
  774.                                     var h = b.clientX + g,
  775.                                         u = h - a.rail.drag.x,
  776.                                         k = a.rail.drag.st - d;
  777.                                     a.ishwscroll && a.opt.bouncescroll ? 0 > k ? k = Math.round(k / 2) : k > a.page.maxh && (k = a.page.maxh + Math.round((k - a.page.maxh) / 2)) : (0 > k && (q = k = 0), k > a.page.maxh && (k = a.page.maxh, q = 0));
  778.                                     var l;
  779.                                     a.railh && a.railh.scrollable && (l = a.isrtlmode ? u - a.rail.drag.sl : a.rail.drag.sl - u, a.ishwscroll && a.opt.bouncescroll ? 0 > l ? l = Math.round(l / 2) : l > a.page.maxw && (l = a.page.maxw + Math.round((l - a.page.maxw) / 2)) : (0 > l && (h = l = 0), l > a.page.maxw && (l = a.page.maxw, h = 0)));
  780.                                     g = !1;
  781.                                     if (a.rail.drag.dl) g = !0, "v" == a.rail.drag.dl ? l = a.rail.drag.sl : "h" == a.rail.drag.dl && (k = a.rail.drag.st);
  782.                                     else {
  783.                                         d = Math.abs(d);
  784.                                         var u = Math.abs(u),
  785.                                             z = a.opt.directionlockdeadzone;
  786.                                         if ("v" == a.rail.drag.ck) {
  787.                                             if (d > z && u <= .3 * d) return a.rail.drag = !1, !0;
  788.                                             u > z && (a.rail.drag.dl = "f", f("body").scrollTop(f("body").scrollTop()))
  789.                                         } else if ("h" == a.rail.drag.ck) {
  790.                                             if (u > z && d <= .3 * u) return a.rail.drag = !1, !0;
  791.                                             d > z && (a.rail.drag.dl = "f", f("body").scrollLeft(f("body").scrollLeft()))
  792.                                         }
  793.                                     }
  794.                                     a.synched("touchmove", function() {
  795.                                         a.rail.drag && 2 == a.rail.drag.pt && (a.prepareTransition && a.prepareTransition(0), a.rail.scrollable && a.setScrollTop(k), a.scrollmom.update(h, q), a.railh && a.railh.scrollable ? (a.setScrollLeft(l), a.showCursor(k, l)) : a.showCursor(k), e.isie10 && document.selection.clear())
  796.                                     });
  797.                                     e.ischrome && a.istouchcapable && (g = !1);
  798.                                     if (g) return a.cancelEvent(b)
  799.                                 } else if (1 == a.rail.drag.pt) return a.onmousemove(b)
  800.                             }
  801.                         }
  802.                         a.onmousedown = function(b, c) {
  803.                             if (!a.rail.drag || 1 == a.rail.drag.pt) {
  804.                                 if (a.railslocked) return a.cancelEvent(b);
  805.                                 a.cancelScroll();
  806.                                 a.rail.drag = {
  807.                                     x: b.clientX,
  808.                                     y: b.clientY,
  809.                                     sx: a.scroll.x,
  810.                                     sy: a.scroll.y,
  811.                                     pt: 1,
  812.                                     hr: !!c
  813.                                 };
  814.                                 var g = a.getTarget(b);
  815.                                 !a.ispage && e.hasmousecapture && g.setCapture();
  816.                                 a.isiframe && !e.hasmousecapture && (a.saved.csspointerevents = a.doc.css("pointer-events"), a.css(a.doc, {
  817.                                     "pointer-events": "none"
  818.                                 }));
  819.                                 a.hasmoving = !1;
  820.                                 return a.cancelEvent(b)
  821.                             }
  822.                         };
  823.                         a.onmouseup = function(b) {
  824.                             if (a.rail.drag) {
  825.                                 if (1 != a.rail.drag.pt) return !0;
  826.                                 e.hasmousecapture && document.releaseCapture();
  827.                                 a.isiframe && !e.hasmousecapture && a.doc.css("pointer-events", a.saved.csspointerevents);
  828.                                 a.rail.drag = !1;
  829.                                 a.hasmoving && a.triggerScrollEnd();
  830.                                 return a.cancelEvent(b)
  831.                             }
  832.                         };
  833.                         a.onmousemove = function(b) {
  834.                             if (a.rail.drag && 1 == a.rail.drag.pt) {
  835.                                 if (e.ischrome && 0 == b.which) return a.onmouseup(b);
  836.                                 a.cursorfreezed = !0;
  837.                                 a.hasmoving = !0;
  838.                                 if (a.rail.drag.hr) {
  839.                                     a.scroll.x = a.rail.drag.sx + (b.clientX - a.rail.drag.x);
  840.                                     0 > a.scroll.x && (a.scroll.x = 0);
  841.                                     var c = a.scrollvaluemaxw;
  842.                                     a.scroll.x > c && (a.scroll.x = c)
  843.                                 } else a.scroll.y = a.rail.drag.sy + (b.clientY - a.rail.drag.y), 0 > a.scroll.y && (a.scroll.y = 0), c = a.scrollvaluemax, a.scroll.y > c && (a.scroll.y = c);
  844.                                 a.synched("mousemove", function() {
  845.                                     a.rail.drag && 1 == a.rail.drag.pt && (a.showCursor(), a.rail.drag.hr ? a.hasreversehr ? a.doScrollLeft(a.scrollvaluemaxw - Math.round(a.scroll.x * a.scrollratio.x), a.opt.cursordragspeed) : a.doScrollLeft(Math.round(a.scroll.x * a.scrollratio.x), a.opt.cursordragspeed) : a.doScrollTop(Math.round(a.scroll.y * a.scrollratio.y), a.opt.cursordragspeed))
  846.                                 });
  847.                                 return a.cancelEvent(b)
  848.                             }
  849.                         };
  850.                         if (e.cantouch || a.opt.touchbehavior) a.onpreventclick = function(b) {
  851.                             if (a.preventclick) return a.preventclick.tg.onclick = a.preventclick.click, a.preventclick = !1, a.cancelEvent(b)
  852.                         }, a.bind(a.win, "mousedown", a.ontouchstart), a.onclick = e.isios ? !1 : function(b) {
  853.                             return a.lastmouseup ? (a.lastmouseup = !1, a.cancelEvent(b)) : !0
  854.                         }, a.opt.grabcursorenabled && e.cursorgrabvalue && (a.css(a.ispage ? a.doc : a.win, {
  855.                             cursor: e.cursorgrabvalue
  856.                         }), a.css(a.rail, {
  857.                             cursor: e.cursorgrabvalue
  858.                         }));
  859.                         else {
  860.                             var p = function(b) {
  861.                                 if (a.selectiondrag) {
  862.                                     if (b) {
  863.                                         var c = a.win.outerHeight();
  864.                                         b = b.pageY - a.selectiondrag.top;
  865.                                         0 < b && b < c && (b = 0);
  866.                                         b >= c && (b -= c);
  867.                                         a.selectiondrag.df = b
  868.                                     }
  869.                                     0 != a.selectiondrag.df && (a.doScrollBy(2 * -Math.floor(a.selectiondrag.df / 6)), a.debounced("doselectionscroll", function() {
  870.                                         p()
  871.                                     }, 50))
  872.                                 }
  873.                             };
  874.                             a.hasTextSelected = "getSelection" in document ? function() {
  875.                                 return 0 < document.getSelection().rangeCount
  876.                             } : "selection" in document ? function() {
  877.                                 return "None" != document.selection.type
  878.                             } : function() {
  879.                                 return !1
  880.                             };
  881.                             a.onselectionstart = function(b) {
  882.                                 a.ispage || (a.selectiondrag = a.win.offset())
  883.                             };
  884.                             a.onselectionend = function(b) {
  885.                                 a.selectiondrag = !1
  886.                             };
  887.                             a.onselectiondrag = function(b) {
  888.                                 a.selectiondrag && a.hasTextSelected() && a.debounced("selectionscroll", function() {
  889.                                     p(b)
  890.                                 }, 250)
  891.                             }
  892.                         }
  893.                         e.hasw3ctouch ? (a.css(a.rail, {
  894.                             "touch-action": "none"
  895.                         }), a.css(a.cursor, {
  896.                             "touch-action": "none"
  897.                         }), a.bind(a.win, "pointerdown", a.ontouchstart), a.bind(document, "pointerup", a.ontouchend), a.bind(document, "pointermove", a.ontouchmove)) : e.hasmstouch ? (a.css(a.rail, {
  898.                             "-ms-touch-action": "none"
  899.                         }), a.css(a.cursor, {
  900.                             "-ms-touch-action": "none"
  901.                         }), a.bind(a.win, "MSPointerDown", a.ontouchstart), a.bind(document, "MSPointerUp", a.ontouchend), a.bind(document, "MSPointerMove", a.ontouchmove), a.bind(a.cursor, "MSGestureHold", function(a) {
  902.                             a.preventDefault()
  903.                         }), a.bind(a.cursor, "contextmenu", function(a) {
  904.                             a.preventDefault()
  905.                         })) : this.istouchcapable && (a.bind(a.win, "touchstart", a.ontouchstart), a.bind(document, "touchend", a.ontouchend), a.bind(document, "touchcancel", a.ontouchend), a.bind(document, "touchmove", a.ontouchmove));
  906.                         if (a.opt.cursordragontouch || !e.cantouch && !a.opt.touchbehavior) a.rail.css({
  907.                             cursor: "default"
  908.                         }), a.railh && a.railh.css({
  909.                             cursor: "default"
  910.                         }), a.jqbind(a.rail, "mouseenter", function() {
  911.                             if (!a.ispage && !a.win.is(":visible")) return !1;
  912.                             a.canshowonmouseevent && a.showCursor();
  913.                             a.rail.active = !0
  914.                         }), a.jqbind(a.rail, "mouseleave", function() {
  915.                             a.rail.active = !1;
  916.                             a.rail.drag || a.hideCursor()
  917.                         }), a.opt.sensitiverail && (a.bind(a.rail, "click", function(b) {
  918.                             a.doRailClick(b, !1, !1)
  919.                         }), a.bind(a.rail, "dblclick", function(b) {
  920.                             a.doRailClick(b, !0, !1)
  921.                         }), a.bind(a.cursor, "click", function(b) {
  922.                             a.cancelEvent(b)
  923.                         }), a.bind(a.cursor, "dblclick", function(b) {
  924.                             a.cancelEvent(b)
  925.                         })), a.railh && (a.jqbind(a.railh, "mouseenter", function() {
  926.                             if (!a.ispage && !a.win.is(":visible")) return !1;
  927.                             a.canshowonmouseevent && a.showCursor();
  928.                             a.rail.active = !0
  929.                         }), a.jqbind(a.railh, "mouseleave", function() {
  930.                             a.rail.active = !1;
  931.                             a.rail.drag || a.hideCursor()
  932.                         }), a.opt.sensitiverail && (a.bind(a.railh, "click", function(b) {
  933.                             a.doRailClick(b, !1, !0)
  934.                         }), a.bind(a.railh, "dblclick", function(b) {
  935.                             a.doRailClick(b, !0, !0)
  936.                         }), a.bind(a.cursorh, "click", function(b) {
  937.                             a.cancelEvent(b)
  938.                         }), a.bind(a.cursorh, "dblclick", function(b) {
  939.                             a.cancelEvent(b)
  940.                         })));
  941.                         e.cantouch || a.opt.touchbehavior ? (a.bind(e.hasmousecapture ? a.win : document, "mouseup", a.ontouchend), a.bind(document, "mousemove", a.ontouchmove), a.onclick && a.bind(document, "click", a.onclick), a.opt.cursordragontouch && (a.bind(a.cursor, "mousedown", a.onmousedown), a.bind(a.cursor, "mouseup", a.onmouseup), a.cursorh && a.bind(a.cursorh, "mousedown", function(b) {
  942.                             a.onmousedown(b, !0)
  943.                         }), a.cursorh && a.bind(a.cursorh, "mouseup", a.onmouseup))) : (a.bind(e.hasmousecapture ? a.win : document, "mouseup", a.onmouseup), a.bind(document, "mousemove", a.onmousemove), a.onclick && a.bind(document, "click", a.onclick), a.bind(a.cursor, "mousedown", a.onmousedown), a.bind(a.cursor, "mouseup", a.onmouseup), a.railh && (a.bind(a.cursorh, "mousedown", function(b) {
  944.                             a.onmousedown(b, !0)
  945.                         }), a.bind(a.cursorh, "mouseup", a.onmouseup)), !a.ispage && a.opt.enablescrollonselection && (a.bind(a.win[0], "mousedown", a.onselectionstart), a.bind(document, "mouseup", a.onselectionend), a.bind(a.cursor, "mouseup", a.onselectionend), a.cursorh && a.bind(a.cursorh, "mouseup", a.onselectionend), a.bind(document, "mousemove", a.onselectiondrag)), a.zoom && (a.jqbind(a.zoom, "mouseenter", function() {
  946.                             a.canshowonmouseevent && a.showCursor();
  947.                             a.rail.active = !0
  948.                         }), a.jqbind(a.zoom, "mouseleave", function() {
  949.                             a.rail.active = !1;
  950.                             a.rail.drag || a.hideCursor()
  951.                         })));
  952.                         a.opt.enablemousewheel && (a.isiframe || a.bind(e.isie && a.ispage ? document : a.win, "mousewheel", a.onmousewheel), a.bind(a.rail, "mousewheel", a.onmousewheel), a.railh && a.bind(a.railh, "mousewheel", a.onmousewheelhr));
  953.                         a.ispage || e.cantouch || /HTML|^BODY/.test(a.win[0].nodeName) || (a.win.attr("tabindex") || a.win.attr({
  954.                             tabindex: N++
  955.                         }), a.jqbind(a.win, "focus", function(b) {
  956.                             y = a.getTarget(b).id || !0;
  957.                             a.hasfocus = !0;
  958.                             a.canshowonmouseevent && a.noticeCursor()
  959.                         }), a.jqbind(a.win, "blur", function(b) {
  960.                             y = !1;
  961.                             a.hasfocus = !1
  962.                         }), a.jqbind(a.win, "mouseenter", function(b) {
  963.                             D = a.getTarget(b).id || !0;
  964.                             a.hasmousefocus = !0;
  965.                             a.canshowonmouseevent && a.noticeCursor()
  966.                         }), a.jqbind(a.win, "mouseleave", function() {
  967.                             D = !1;
  968.                             a.hasmousefocus = !1;
  969.                             a.rail.drag || a.hideCursor()
  970.                         }))
  971.                     }
  972.                     a.onkeypress = function(b) {
  973.                         if (a.railslocked && 0 == a.page.maxh) return !0;
  974.                         b = b ? b : window.e;
  975.                         var c = a.getTarget(b);
  976.                         if (c && /INPUT|TEXTAREA|SELECT|OPTION/.test(c.nodeName) && (!c.getAttribute("type") && !c.type || !/submit|button|cancel/i.tp) || f(c).attr("contenteditable")) return !0;
  977.                         if (a.hasfocus || a.hasmousefocus && !y || a.ispage && !y && !D) {
  978.                             c = b.keyCode;
  979.                             if (a.railslocked && 27 != c) return a.cancelEvent(b);
  980.                             var g = b.ctrlKey || !1,
  981.                                 d = b.shiftKey || !1,
  982.                                 e = !1;
  983.                             switch (c) {
  984.                                 case 38:
  985.                                 case 63233:
  986.                                     a.doScrollBy(72);
  987.                                     e = !0;
  988.                                     break;
  989.                                 case 40:
  990.                                 case 63235:
  991.                                     a.doScrollBy(-72);
  992.                                     e = !0;
  993.                                     break;
  994.                                 case 37:
  995.                                 case 63232:
  996.                                     a.railh && (g ? a.doScrollLeft(0) : a.doScrollLeftBy(72), e = !0);
  997.                                     break;
  998.                                 case 39:
  999.                                 case 63234:
  1000.                                     a.railh && (g ? a.doScrollLeft(a.page.maxw) : a.doScrollLeftBy(-72), e = !0);
  1001.                                     break;
  1002.                                 case 33:
  1003.                                 case 63276:
  1004.                                     a.doScrollBy(a.view.h);
  1005.                                     e = !0;
  1006.                                     break;
  1007.                                 case 34:
  1008.                                 case 63277:
  1009.                                     a.doScrollBy(-a.view.h);
  1010.                                     e = !0;
  1011.                                     break;
  1012.                                 case 36:
  1013.                                 case 63273:
  1014.                                     a.railh && g ? a.doScrollPos(0, 0) : a.doScrollTo(0);
  1015.                                     e = !0;
  1016.                                     break;
  1017.                                 case 35:
  1018.                                 case 63275:
  1019.                                     a.railh && g ? a.doScrollPos(a.page.maxw, a.page.maxh) : a.doScrollTo(a.page.maxh);
  1020.                                     e = !0;
  1021.                                     break;
  1022.                                 case 32:
  1023.                                     a.opt.spacebarenabled && (d ? a.doScrollBy(a.view.h) : a.doScrollBy(-a.view.h), e = !0);
  1024.                                     break;
  1025.                                 case 27:
  1026.                                     a.zoomactive && (a.doZoom(), e = !0)
  1027.                             }
  1028.                             if (e) return a.cancelEvent(b)
  1029.                         }
  1030.                     };
  1031.                     a.opt.enablekeyboard && a.bind(document, e.isopera && !e.isopera12 ? "keypress" : "keydown", a.onkeypress);
  1032.                     a.bind(document, "keydown", function(b) {
  1033.                         b.ctrlKey && (a.wheelprevented = !0)
  1034.                     });
  1035.                     a.bind(document, "keyup", function(b) {
  1036.                         b.ctrlKey || (a.wheelprevented = !1)
  1037.                     });
  1038.                     a.bind(window, "blur", function(b) {
  1039.                         a.wheelprevented = !1
  1040.                     });
  1041.                     a.bind(window, "resize", a.lazyResize);
  1042.                     a.bind(window, "orientationchange", a.lazyResize);
  1043.                     a.bind(window, "load", a.lazyResize);
  1044.                     if (e.ischrome && !a.ispage && !a.haswrapper) {
  1045.                         var r = a.win.attr("style"),
  1046.                             c = parseFloat(a.win.css("width")) + 1;
  1047.                         a.win.css("width", c);
  1048.                         a.synched("chromefix", function() {
  1049.                             a.win.attr("style", r)
  1050.                         })
  1051.                     }
  1052.                     a.onAttributeChange = function(b) {
  1053.                         a.lazyResize(a.isieold ? 250 : 30)
  1054.                     };
  1055.                     !1 !== v && (a.observerbody = new v(function(b) {
  1056.                         b.forEach(function(b) {
  1057.                             if ("attributes" == b.type) return f("body").hasClass("modal-open") ? a.hide() : a.show()
  1058.                         });
  1059.                         if (document.body.scrollHeight != a.page.maxh) return a.lazyResize(30)
  1060.                     }), a.observerbody.observe(document.body, {
  1061.                         childList: !0,
  1062.                         subtree: !0,
  1063.                         characterData: !1,
  1064.                         attributes: !0,
  1065.                         attributeFilter: ["class"]
  1066.                     }));
  1067.                     a.ispage || a.haswrapper || (!1 !== v ? (a.observer = new v(function(b) {
  1068.                         b.forEach(a.onAttributeChange)
  1069.                     }), a.observer.observe(a.win[0], {
  1070.                         childList: !0,
  1071.                         characterData: !1,
  1072.                         attributes: !0,
  1073.                         subtree: !1
  1074.                     }), a.observerremover = new v(function(b) {
  1075.                         b.forEach(function(b) {
  1076.                             if (0 < b.removedNodes.length)
  1077.                                 for (var c in b.removedNodes)
  1078.                                     if (a && b.removedNodes[c] == a.win[0]) return a.remove()
  1079.                         })
  1080.                     }), a.observerremover.observe(a.win[0].parentNode, {
  1081.                         childList: !0,
  1082.                         characterData: !1,
  1083.                         attributes: !1,
  1084.                         subtree: !1
  1085.                     })) : (a.bind(a.win, e.isie && !e.isie9 ? "propertychange" : "DOMAttrModified", a.onAttributeChange), e.isie9 && a.win[0].attachEvent("onpropertychange", a.onAttributeChange), a.bind(a.win, "DOMNodeRemoved", function(b) {
  1086.                         b.target == a.win[0] && a.remove()
  1087.                     })));
  1088.                     !a.ispage && a.opt.boxzoom && a.bind(window, "resize", a.resizeZoom);
  1089.                     a.istextarea && a.bind(a.win, "mouseup", a.lazyResize);
  1090.                     a.lazyResize(30)
  1091.                 }
  1092.                 if ("IFRAME" == this.doc[0].nodeName) {
  1093.                     var M = function() {
  1094.                         a.iframexd = !1;
  1095.                         var b;
  1096.                         try {
  1097.                             b = "contentDocument" in this ? this.contentDocument : this.contentWindow.document
  1098.                         } catch (c) {
  1099.                             a.iframexd = !0, b = !1
  1100.                         }
  1101.                         if (a.iframexd) return "console" in window && console.log("NiceScroll error: policy restriced iframe"), !0;
  1102.                         a.forcescreen = !0;
  1103.                         a.isiframe && (a.iframe = {
  1104.                             doc: f(b),
  1105.                             html: a.doc.contents().find("html")[0],
  1106.                             body: a.doc.contents().find("body")[0]
  1107.                         }, a.getContentSize = function() {
  1108.                             return {
  1109.                                 w: Math.max(a.iframe.html.scrollWidth, a.iframe.body.scrollWidth),
  1110.                                 h: Math.max(a.iframe.html.scrollHeight, a.iframe.body.scrollHeight)
  1111.                             }
  1112.                         }, a.docscroll = f(a.iframe.body));
  1113.                         if (!e.isios && a.opt.iframeautoresize && !a.isiframe) {
  1114.                             a.win.scrollTop(0);
  1115.                             a.doc.height("");
  1116.                             var g = Math.max(b.getElementsByTagName("html")[0].scrollHeight, b.body.scrollHeight);
  1117.                             a.doc.height(g)
  1118.                         }
  1119.                         a.lazyResize(30);
  1120.                         e.isie7 && a.css(f(a.iframe.html), {
  1121.                             "overflow-y": "hidden"
  1122.                         });
  1123.                         a.css(f(a.iframe.body), {
  1124.                             "overflow-y": "hidden"
  1125.                         });
  1126.                         e.isios && a.haswrapper && a.css(f(b.body), {
  1127.                             "-webkit-transform": "translate3d(0,0,0)"
  1128.                         });
  1129.                         "contentWindow" in this ? a.bind(this.contentWindow, "scroll", a.onscroll) : a.bind(b, "scroll", a.onscroll);
  1130.                         a.opt.enablemousewheel && a.bind(b, "mousewheel", a.onmousewheel);
  1131.                         a.opt.enablekeyboard && a.bind(b, e.isopera ? "keypress" : "keydown", a.onkeypress);
  1132.                         if (e.cantouch || a.opt.touchbehavior) a.bind(b, "mousedown", a.ontouchstart), a.bind(b, "mousemove", function(b) {
  1133.                             return a.ontouchmove(b, !0)
  1134.                         }), a.opt.grabcursorenabled && e.cursorgrabvalue && a.css(f(b.body), {
  1135.                             cursor: e.cursorgrabvalue
  1136.                         });
  1137.                         a.bind(b, "mouseup", a.ontouchend);
  1138.                         a.zoom && (a.opt.dblclickzoom && a.bind(b, "dblclick", a.doZoom), a.ongesturezoom && a.bind(b, "gestureend", a.ongesturezoom))
  1139.                     };
  1140.                     this.doc[0].readyState && "complete" == this.doc[0].readyState && setTimeout(function() {
  1141.                         M.call(a.doc[0], !1)
  1142.                     }, 500);
  1143.                     a.bind(this.doc, "load", M)
  1144.                 }
  1145.             };
  1146.             this.showCursor = function(b, c) {
  1147.                 a.cursortimeout && (clearTimeout(a.cursortimeout), a.cursortimeout = 0);
  1148.                 if (a.rail) {
  1149.                     a.autohidedom && (a.autohidedom.stop().css({
  1150.                         opacity: a.opt.cursoropacitymax
  1151.                     }), a.cursoractive = !0);
  1152.                     a.rail.drag && 1 == a.rail.drag.pt || ("undefined" != typeof b && !1 !== b && (a.scroll.y = Math.round(1 * b / a.scrollratio.y)), "undefined" != typeof c && (a.scroll.x = Math.round(1 * c / a.scrollratio.x)));
  1153.                     a.cursor.css({
  1154.                         height: a.cursorheight,
  1155.                         top: a.scroll.y
  1156.                     });
  1157.                     if (a.cursorh) {
  1158.                         var d = a.hasreversehr ? a.scrollvaluemaxw - a.scroll.x : a.scroll.x;
  1159.                         !a.rail.align && a.rail.visibility ? a.cursorh.css({
  1160.                             width: a.cursorwidth,
  1161.                             left: d + a.rail.width
  1162.                         }) : a.cursorh.css({
  1163.                             width: a.cursorwidth,
  1164.                             left: d
  1165.                         });
  1166.                         a.cursoractive = !0
  1167.                     }
  1168.                     a.zoom && a.zoom.stop().css({
  1169.                         opacity: a.opt.cursoropacitymax
  1170.                     })
  1171.                 }
  1172.             };
  1173.             this.hideCursor = function(b) {
  1174.                 a.cursortimeout || !a.rail || !a.autohidedom || a.hasmousefocus && "leave" == a.opt.autohidemode || (a.cursortimeout = setTimeout(function() {
  1175.                     a.rail.active && a.showonmouseevent || (a.autohidedom.stop().animate({
  1176.                         opacity: a.opt.cursoropacitymin
  1177.                     }), a.zoom && a.zoom.stop().animate({
  1178.                         opacity: a.opt.cursoropacitymin
  1179.                     }), a.cursoractive = !1);
  1180.                     a.cursortimeout = 0
  1181.                 }, b || a.opt.hidecursordelay))
  1182.             };
  1183.             this.noticeCursor = function(b, c, d) {
  1184.                 a.showCursor(c, d);
  1185.                 a.rail.active || a.hideCursor(b)
  1186.             };
  1187.             this.getContentSize = a.ispage ? function() {
  1188.                 return {
  1189.                     w: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
  1190.                     h: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight)
  1191.                 }
  1192.             } : a.haswrapper ? function() {
  1193.                 return {
  1194.                     w: a.doc.outerWidth() + parseInt(a.win.css("paddingLeft")) + parseInt(a.win.css("paddingRight")),
  1195.                     h: a.doc.outerHeight() + parseInt(a.win.css("paddingTop")) + parseInt(a.win.css("paddingBottom"))
  1196.                 }
  1197.             } : function() {
  1198.                 return {
  1199.                     w: a.docscroll[0].scrollWidth,
  1200.                     h: a.docscroll[0].scrollHeight
  1201.                 }
  1202.             };
  1203.             this.onResize = function(b, c) {
  1204.                 if (!a || !a.win) return !1;
  1205.                 if (!a.haswrapper && !a.ispage) {
  1206.                     if ("none" == a.win.css("display")) return a.visibility && a.hideRail().hideRailHr(), !1;
  1207.                     a.hidden || a.visibility || a.showRail().showRailHr()
  1208.                 }
  1209.                 var d = a.page.maxh,
  1210.                     e = a.page.maxw,
  1211.                     f = a.view.h,
  1212.                     h = a.view.w;
  1213.                 a.view = {
  1214.                     w: a.ispage ? a.win.width() : parseInt(a.win[0].clientWidth),
  1215.                     h: a.ispage ? a.win.height() : parseInt(a.win[0].clientHeight)
  1216.                 };
  1217.                 a.page = c ? c : a.getContentSize();
  1218.                 a.page.maxh = Math.max(0, a.page.h - a.view.h);
  1219.                 a.page.maxw = Math.max(0, a.page.w - a.view.w);
  1220.                 if (a.page.maxh == d && a.page.maxw == e && a.view.w == h && a.view.h == f) {
  1221.                     if (a.ispage) return a;
  1222.                     d = a.win.offset();
  1223.                     if (a.lastposition && (e = a.lastposition, e.top == d.top && e.left == d.left)) return a;
  1224.                     a.lastposition = d
  1225.                 }
  1226.                 0 == a.page.maxh ? (a.hideRail(), a.scrollvaluemax = 0, a.scroll.y = 0, a.scrollratio.y = 0, a.cursorheight = 0, a.setScrollTop(0), a.rail.scrollable = !1) : (a.page.maxh -= a.opt.railpadding.top + a.opt.railpadding.bottom, a.rail.scrollable = !0);
  1227.                 0 == a.page.maxw ? (a.hideRailHr(), a.scrollvaluemaxw = 0, a.scroll.x = 0, a.scrollratio.x = 0, a.cursorwidth = 0, a.setScrollLeft(0), a.railh.scrollable = !1) : (a.page.maxw -= a.opt.railpadding.left + a.opt.railpadding.right, a.railh.scrollable = !0);
  1228.                 a.railslocked = a.locked || 0 == a.page.maxh && 0 == a.page.maxw;
  1229.                 if (a.railslocked) return a.ispage || a.updateScrollBar(a.view), !1;
  1230.                 a.hidden || a.visibility ? a.hidden || a.railh.visibility || a.showRailHr() : a.showRail().showRailHr();
  1231.                 a.istextarea && a.win.css("resize") && "none" != a.win.css("resize") && (a.view.h -= 20);
  1232.                 a.cursorheight = Math.min(a.view.h, Math.round(a.view.h / a.page.h * a.view.h));
  1233.                 a.cursorheight = a.opt.cursorfixedheight ? a.opt.cursorfixedheight : Math.max(a.opt.cursorminheight, a.cursorheight);
  1234.                 a.cursorwidth = Math.min(a.view.w, Math.round(a.view.w / a.page.w * a.view.w));
  1235.                 a.cursorwidth = a.opt.cursorfixedheight ? a.opt.cursorfixedheight : Math.max(a.opt.cursorminheight, a.cursorwidth);
  1236.                 a.scrollvaluemax = a.view.h - a.cursorheight - a.cursor.hborder - (a.opt.railpadding.top + a.opt.railpadding.bottom);
  1237.                 a.railh && (a.railh.width = 0 < a.page.maxh ? a.view.w - a.rail.width : a.view.w, a.scrollvaluemaxw = a.railh.width - a.cursorwidth - a.cursorh.wborder - (a.opt.railpadding.left + a.opt.railpadding.right));
  1238.                 a.ispage || a.updateScrollBar(a.view);
  1239.                 a.scrollratio = {
  1240.                     x: a.page.maxw / a.scrollvaluemaxw,
  1241.                     y: a.page.maxh / a.scrollvaluemax
  1242.                 };
  1243.                 a.getScrollTop() > a.page.maxh ? a.doScrollTop(a.page.maxh) : (a.scroll.y = Math.round(a.getScrollTop() * (1 / a.scrollratio.y)), a.scroll.x = Math.round(a.getScrollLeft() * (1 / a.scrollratio.x)), a.cursoractive && a.noticeCursor());
  1244.                 a.scroll.y && 0 == a.getScrollTop() && a.doScrollTo(Math.floor(a.scroll.y * a.scrollratio.y));
  1245.                 return a
  1246.             };
  1247.             this.resize = a.onResize;
  1248.             this.lazyResize = function(b) {
  1249.                 b = isNaN(b) ? 30 : b;
  1250.                 a.debounced("resize", a.resize, b);
  1251.                 return a
  1252.             };
  1253.             this.jqbind = function(b, c, d) {
  1254.                 a.events.push({
  1255.                     e: b,
  1256.                     n: c,
  1257.                     f: d,
  1258.                     q: !0
  1259.                 });
  1260.                 f(b).bind(c, d)
  1261.             };
  1262.             this.bind = function(b, c, d, f) {
  1263.                 var h = "jquery" in b ? b[0] : b;
  1264.                 "mousewheel" == c ? window.addEventListener || "onwheel" in document ? a._bind(h, "wheel", d, f || !1) : (b = "undefined" != typeof document.onmousewheel ? "mousewheel" : "DOMMouseScroll", n(h, b, d, f || !1), "DOMMouseScroll" == b && n(h, "MozMousePixelScroll", d, f || !1)) : h.addEventListener ? (e.cantouch && /mouseup|mousedown|mousemove/.test(c) && a._bind(h, "mousedown" == c ? "touchstart" : "mouseup" == c ? "touchend" : "touchmove", function(a) {
  1265.                     if (a.touches) {
  1266.                         if (2 > a.touches.length) {
  1267.                             var b = a.touches.length ? a.touches[0] : a;
  1268.                             b.original = a;
  1269.                             d.call(this, b)
  1270.                         }
  1271.                     } else a.changedTouches && (b = a.changedTouches[0], b.original = a, d.call(this, b))
  1272.                 }, f || !1), a._bind(h, c, d, f || !1), e.cantouch && "mouseup" == c && a._bind(h, "touchcancel", d, f || !1)) : a._bind(h, c, function(b) {
  1273.                     (b = b || window.event || !1) && b.srcElement && (b.target = b.srcElement);
  1274.                     "pageY" in b || (b.pageX = b.clientX + document.documentElement.scrollLeft, b.pageY = b.clientY + document.documentElement.scrollTop);
  1275.                     return !1 === d.call(h, b) || !1 === f ? a.cancelEvent(b) : !0
  1276.                 })
  1277.             };
  1278.             e.haseventlistener ? (this._bind = function(b, c, d, e) {
  1279.                 a.events.push({
  1280.                     e: b,
  1281.                     n: c,
  1282.                     f: d,
  1283.                     b: e,
  1284.                     q: !1
  1285.                 });
  1286.                 b.addEventListener(c, d, e || !1)
  1287.             }, this.cancelEvent = function(a) {
  1288.                 if (!a) return !1;
  1289.                 a = a.original ? a.original : a;
  1290.                 a.preventDefault();
  1291.                 a.stopPropagation();
  1292.                 a.preventManipulation && a.preventManipulation();
  1293.                 return !1
  1294.             }, this.stopPropagation = function(a) {
  1295.                 if (!a) return !1;
  1296.                 a = a.original ? a.original : a;
  1297.                 a.stopPropagation();
  1298.                 return !1
  1299.             }, this._unbind = function(a, c, d, e) {
  1300.                 a.removeEventListener(c, d, e)
  1301.             }) : (this._bind = function(b, c, d, e) {
  1302.                 a.events.push({
  1303.                     e: b,
  1304.                     n: c,
  1305.                     f: d,
  1306.                     b: e,
  1307.                     q: !1
  1308.                 });
  1309.                 b.attachEvent ? b.attachEvent("on" + c, d) : b["on" + c] = d
  1310.             }, this.cancelEvent = function(a) {
  1311.                 a = window.event || !1;
  1312.                 if (!a) return !1;
  1313.                 a.cancelBubble = !0;
  1314.                 a.cancel = !0;
  1315.                 return a.returnValue = !1
  1316.             }, this.stopPropagation = function(a) {
  1317.                 a = window.event || !1;
  1318.                 if (!a) return !1;
  1319.                 a.cancelBubble = !0;
  1320.                 return !1
  1321.             }, this._unbind = function(a, c, d, e) {
  1322.                 a.detachEvent ? a.detachEvent("on" + c, d) : a["on" + c] = !1
  1323.             });
  1324.             this.unbindAll = function() {
  1325.                 for (var b = 0; b < a.events.length; b++) {
  1326.                     var c = a.events[b];
  1327.                     c.q ? c.e.unbind(c.n, c.f) : a._unbind(c.e, c.n, c.f, c.b)
  1328.                 }
  1329.             };
  1330.             this.showRail = function() {
  1331.                 0 == a.page.maxh || !a.ispage && "none" == a.win.css("display") || (a.visibility = !0, a.rail.visibility = !0, a.rail.css("display", "block"));
  1332.                 return a
  1333.             };
  1334.             this.showRailHr = function() {
  1335.                 if (!a.railh) return a;
  1336.                 0 == a.page.maxw || !a.ispage && "none" == a.win.css("display") || (a.railh.visibility = !0, a.railh.css("display", "block"));
  1337.                 return a
  1338.             };
  1339.             this.hideRail = function() {
  1340.                 a.visibility = !1;
  1341.                 a.rail.visibility = !1;
  1342.                 a.rail.css("display", "none");
  1343.                 return a
  1344.             };
  1345.             this.hideRailHr = function() {
  1346.                 if (!a.railh) return a;
  1347.                 a.railh.visibility = !1;
  1348.                 a.railh.css("display", "none");
  1349.                 return a
  1350.             };
  1351.             this.show = function() {
  1352.                 a.hidden = !1;
  1353.                 a.railslocked = !1;
  1354.                 return a.showRail().showRailHr()
  1355.             };
  1356.             this.hide = function() {
  1357.                 a.hidden = !0;
  1358.                 a.railslocked = !0;
  1359.                 return a.hideRail().hideRailHr()
  1360.             };
  1361.             this.toggle = function() {
  1362.                 return a.hidden ? a.show() : a.hide()
  1363.             };
  1364.             this.remove = function() {
  1365.                 a.stop();
  1366.                 a.cursortimeout && clearTimeout(a.cursortimeout);
  1367.                 a.doZoomOut();
  1368.                 a.unbindAll();
  1369.                 e.isie9 && a.win[0].detachEvent("onpropertychange", a.onAttributeChange);
  1370.                 !1 !== a.observer && a.observer.disconnect();
  1371.                 !1 !== a.observerremover && a.observerremover.disconnect();
  1372.                 !1 !== a.observerbody && a.observerbody.disconnect();
  1373.                 a.events = null;
  1374.                 a.cursor && a.cursor.remove();
  1375.                 a.cursorh && a.cursorh.remove();
  1376.                 a.rail && a.rail.remove();
  1377.                 a.railh && a.railh.remove();
  1378.                 a.zoom && a.zoom.remove();
  1379.                 for (var b = 0; b < a.saved.css.length; b++) {
  1380.                     var c = a.saved.css[b];
  1381.                     c[0].css(c[1], "undefined" == typeof c[2] ? "" : c[2])
  1382.                 }
  1383.                 a.saved = !1;
  1384.                 a.me.data("__nicescroll", "");
  1385.                 var d = f.nicescroll;
  1386.                 d.each(function(b) {
  1387.                     if (this && this.id === a.id) {
  1388.                         delete d[b];
  1389.                         for (var c = ++b; c < d.length; c++, b++) d[b] = d[c];
  1390.                         d.length--;
  1391.                         d.length && delete d[d.length]
  1392.                     }
  1393.                 });
  1394.                 for (var h in a) a[h] = null, delete a[h];
  1395.                 a = null
  1396.             };
  1397.             this.scrollstart = function(b) {
  1398.                 this.onscrollstart = b;
  1399.                 return a
  1400.             };
  1401.             this.scrollend = function(b) {
  1402.                 this.onscrollend = b;
  1403.                 return a
  1404.             };
  1405.             this.scrollcancel = function(b) {
  1406.                 this.onscrollcancel = b;
  1407.                 return a
  1408.             };
  1409.             this.zoomin = function(b) {
  1410.                 this.onzoomin = b;
  1411.                 return a
  1412.             };
  1413.             this.zoomout = function(b) {
  1414.                 this.onzoomout = b;
  1415.                 return a
  1416.             };
  1417.             this.isScrollable = function(a) {
  1418.                 a = a.target ? a.target : a;
  1419.                 if ("OPTION" == a.nodeName) return !0;
  1420.                 for (; a && 1 == a.nodeType && !/^BODY|HTML/.test(a.nodeName);) {
  1421.                     var c = f(a),
  1422.                         c = c.css("overflowY") || c.css("overflowX") || c.css("overflow") || "";
  1423.                     if (/scroll|auto/.test(c)) return a.clientHeight != a.scrollHeight;
  1424.                     a = a.parentNode ? a.parentNode : !1
  1425.                 }
  1426.                 return !1
  1427.             };
  1428.             this.getViewport = function(a) {
  1429.                 for (a = a && a.parentNode ? a.parentNode : !1; a && 1 == a.nodeType && !/^BODY|HTML/.test(a.nodeName);) {
  1430.                     var c = f(a);
  1431.                     if (/fixed|absolute/.test(c.css("position"))) return c;
  1432.                     var d = c.css("overflowY") || c.css("overflowX") || c.css("overflow") || "";
  1433.                     if (/scroll|auto/.test(d) && a.clientHeight != a.scrollHeight || 0 < c.getNiceScroll().length) return c;
  1434.                     a = a.parentNode ? a.parentNode : !1
  1435.                 }
  1436.                 return !1
  1437.             };
  1438.             this.triggerScrollEnd = function() {
  1439.                 if (a.onscrollend) {
  1440.                     var b = a.getScrollLeft(),
  1441.                         c = a.getScrollTop();
  1442.                     a.onscrollend.call(a, {
  1443.                         type: "scrollend",
  1444.                         current: {
  1445.                             x: b,
  1446.                             y: c
  1447.                         },
  1448.                         end: {
  1449.                             x: b,
  1450.                             y: c
  1451.                         }
  1452.                     })
  1453.                 }
  1454.             };
  1455.             this.onmousewheel = function(b) {
  1456.                 if (!a.wheelprevented) {
  1457.                     if (a.railslocked) return a.debounced("checkunlock", a.resize, 250), !0;
  1458.                     if (a.rail.drag) return a.cancelEvent(b);
  1459.                     "auto" == a.opt.oneaxismousemode && 0 != b.deltaX && (a.opt.oneaxismousemode = !1);
  1460.                     if (a.opt.oneaxismousemode && 0 == b.deltaX && !a.rail.scrollable) return a.railh && a.railh.scrollable ? a.onmousewheelhr(b) : !0;
  1461.                     var c = +new Date,
  1462.                         d = !1;
  1463.                     a.opt.preservenativescrolling && a.checkarea + 600 < c && (a.nativescrollingarea = a.isScrollable(b), d = !0);
  1464.                     a.checkarea = c;
  1465.                     if (a.nativescrollingarea) return !0;
  1466.                     if (b = p(b, !1, d)) a.checkarea = 0;
  1467.                     return b
  1468.                 }
  1469.             };
  1470.             this.onmousewheelhr = function(b) {
  1471.                 if (!a.wheelprevented) {
  1472.                     if (a.railslocked || !a.railh.scrollable) return !0;
  1473.                     if (a.rail.drag) return a.cancelEvent(b);
  1474.                     var c = +new Date,
  1475.                         d = !1;
  1476.                     a.opt.preservenativescrolling && a.checkarea + 600 < c && (a.nativescrollingarea = a.isScrollable(b), d = !0);
  1477.                     a.checkarea = c;
  1478.                     return a.nativescrollingarea ? !0 : a.railslocked ? a.cancelEvent(b) : p(b, !0, d)
  1479.                 }
  1480.             };
  1481.             this.stop = function() {
  1482.                 a.cancelScroll();
  1483.                 a.scrollmon && a.scrollmon.stop();
  1484.                 a.cursorfreezed = !1;
  1485.                 a.scroll.y = Math.round(a.getScrollTop() * (1 / a.scrollratio.y));
  1486.                 a.noticeCursor();
  1487.                 return a
  1488.             };
  1489.             this.getTransitionSpeed = function(b) {
  1490.                 var c = Math.round(10 * a.opt.scrollspeed);
  1491.                 b = Math.min(c, Math.round(b / 20 * a.opt.scrollspeed));
  1492.                 return 20 < b ? b : 0
  1493.             };
  1494.             a.opt.smoothscroll ? a.ishwscroll && e.hastransition && a.opt.usetransition && a.opt.smoothscroll ? (this.prepareTransition = function(b, c) {
  1495.                 var d = c ? 20 < b ? b : 0 : a.getTransitionSpeed(b),
  1496.                     f = d ? e.prefixstyle + "transform " + d + "ms ease-out" : "";
  1497.                 a.lasttransitionstyle && a.lasttransitionstyle == f || (a.lasttransitionstyle = f, a.doc.css(e.transitionstyle, f));
  1498.                 return d
  1499.             }, this.doScrollLeft = function(b, c) {
  1500.                 var d = a.scrollrunning ? a.newscrolly : a.getScrollTop();
  1501.                 a.doScrollPos(b, d, c)
  1502.             }, this.doScrollTop = function(b, c) {
  1503.                 var d = a.scrollrunning ? a.newscrollx : a.getScrollLeft();
  1504.                 a.doScrollPos(d, b, c)
  1505.             }, this.doScrollPos = function(b, c, d) {
  1506.                 var f = a.getScrollTop(),
  1507.                     h = a.getScrollLeft();
  1508.                 (0 > (a.newscrolly - f) * (c - f) || 0 > (a.newscrollx - h) * (b - h)) && a.cancelScroll();
  1509.                 0 == a.opt.bouncescroll && (0 > c ? c = 0 : c > a.page.maxh && (c = a.page.maxh), 0 > b ? b = 0 : b > a.page.maxw && (b = a.page.maxw));
  1510.                 if (a.scrollrunning && b == a.newscrollx && c == a.newscrolly) return !1;
  1511.                 a.newscrolly = c;
  1512.                 a.newscrollx = b;
  1513.                 a.newscrollspeed = d || !1;
  1514.                 if (a.timer) return !1;
  1515.                 a.timer = setTimeout(function() {
  1516.                     var d = a.getScrollTop(),
  1517.                         f = a.getScrollLeft(),
  1518.                         h, k;
  1519.                     h = b - f;
  1520.                     k = c - d;
  1521.                     h = Math.round(Math.sqrt(Math.pow(h, 2) + Math.pow(k, 2)));
  1522.                     h = a.newscrollspeed && 1 < a.newscrollspeed ? a.newscrollspeed : a.getTransitionSpeed(h);
  1523.                     a.newscrollspeed && 1 >= a.newscrollspeed && (h *= a.newscrollspeed);
  1524.                     a.prepareTransition(h, !0);
  1525.                     a.timerscroll && a.timerscroll.tm && clearInterval(a.timerscroll.tm);
  1526.                     0 < h && (!a.scrollrunning && a.onscrollstart && a.onscrollstart.call(a, {
  1527.                         type: "scrollstart",
  1528.                         current: {
  1529.                             x: f,
  1530.                             y: d
  1531.                         },
  1532.                         request: {
  1533.                             x: b,
  1534.                             y: c
  1535.                         },
  1536.                         end: {
  1537.                             x: a.newscrollx,
  1538.                             y: a.newscrolly
  1539.                         },
  1540.                         speed: h
  1541.                     }), e.transitionend ? a.scrollendtrapped || (a.scrollendtrapped = !0, a.bind(a.doc, e.transitionend, a.onScrollTransitionEnd, !1)) : (a.scrollendtrapped && clearTimeout(a.scrollendtrapped), a.scrollendtrapped = setTimeout(a.onScrollTransitionEnd, h)), a.timerscroll = {
  1542.                         bz: new A(d, a.newscrolly, h, 0, 0, .58, 1),
  1543.                         bh: new A(f, a.newscrollx, h, 0, 0, .58, 1)
  1544.                     }, a.cursorfreezed || (a.timerscroll.tm = setInterval(function() {
  1545.                         a.showCursor(a.getScrollTop(), a.getScrollLeft())
  1546.                     }, 60)));
  1547.                     a.synched("doScroll-set", function() {
  1548.                         a.timer = 0;
  1549.                         a.scrollendtrapped && (a.scrollrunning = !0);
  1550.                         a.setScrollTop(a.newscrolly);
  1551.                         a.setScrollLeft(a.newscrollx);
  1552.                         if (!a.scrollendtrapped) a.onScrollTransitionEnd()
  1553.                     })
  1554.                 }, 50)
  1555.             }, this.cancelScroll = function() {
  1556.                 if (!a.scrollendtrapped) return !0;
  1557.                 var b = a.getScrollTop(),
  1558.                     c = a.getScrollLeft();
  1559.                 a.scrollrunning = !1;
  1560.                 e.transitionend || clearTimeout(e.transitionend);
  1561.                 a.scrollendtrapped = !1;
  1562.                 a._unbind(a.doc[0], e.transitionend, a.onScrollTransitionEnd);
  1563.                 a.prepareTransition(0);
  1564.                 a.setScrollTop(b);
  1565.                 a.railh && a.setScrollLeft(c);
  1566.                 a.timerscroll && a.timerscroll.tm && clearInterval(a.timerscroll.tm);
  1567.                 a.timerscroll = !1;
  1568.                 a.cursorfreezed = !1;
  1569.                 a.showCursor(b, c);
  1570.                 return a
  1571.             }, this.onScrollTransitionEnd = function() {
  1572.                 a.scrollendtrapped && a._unbind(a.doc[0], e.transitionend, a.onScrollTransitionEnd);
  1573.                 a.scrollendtrapped = !1;
  1574.                 a.prepareTransition(0);
  1575.                 a.timerscroll && a.timerscroll.tm && clearInterval(a.timerscroll.tm);
  1576.                 a.timerscroll = !1;
  1577.                 var b = a.getScrollTop(),
  1578.                     c = a.getScrollLeft();
  1579.                 a.setScrollTop(b);
  1580.                 a.railh && a.setScrollLeft(c);
  1581.                 a.noticeCursor(!1, b, c);
  1582.                 a.cursorfreezed = !1;
  1583.                 0 > b ? b = 0 : b > a.page.maxh && (b = a.page.maxh);
  1584.                 0 > c ? c = 0 : c > a.page.maxw && (c = a.page.maxw);
  1585.                 if (b != a.newscrolly || c != a.newscrollx) return a.doScrollPos(c, b, a.opt.snapbackspeed);
  1586.                 a.onscrollend && a.scrollrunning && a.triggerScrollEnd();
  1587.                 a.scrollrunning = !1
  1588.             }) : (this.doScrollLeft = function(b, c) {
  1589.                 var d = a.scrollrunning ? a.newscrolly : a.getScrollTop();
  1590.                 a.doScrollPos(b, d, c)
  1591.             }, this.doScrollTop = function(b, c) {
  1592.                 var d = a.scrollrunning ? a.newscrollx : a.getScrollLeft();
  1593.                 a.doScrollPos(d, b, c)
  1594.             }, this.doScrollPos = function(b, c, d) {
  1595.                 function e() {
  1596.                     if (a.cancelAnimationFrame) return !0;
  1597.                     a.scrollrunning = !0;
  1598.                     if (n = 1 - n) return a.timer = s(e) || 1;
  1599.                     var b = 0,
  1600.                         c, d, g = d = a.getScrollTop();
  1601.                     if (a.dst.ay) {
  1602.                         g = a.bzscroll ? a.dst.py + a.bzscroll.getNow() * a.dst.ay : a.newscrolly;
  1603.                         c = g - d;
  1604.                         if (0 > c && g < a.newscrolly || 0 < c && g > a.newscrolly) g = a.newscrolly;
  1605.                         a.setScrollTop(g);
  1606.                         g == a.newscrolly && (b = 1)
  1607.                     } else b = 1;
  1608.                     d = c = a.getScrollLeft();
  1609.                     if (a.dst.ax) {
  1610.                         d = a.bzscroll ? a.dst.px + a.bzscroll.getNow() * a.dst.ax : a.newscrollx;
  1611.                         c = d - c;
  1612.                         if (0 > c && d < a.newscrollx || 0 < c && d > a.newscrollx) d = a.newscrollx;
  1613.                         a.setScrollLeft(d);
  1614.                         d == a.newscrollx && (b += 1)
  1615.                     } else b += 1;
  1616.                     2 == b ? (a.timer = 0, a.cursorfreezed = !1, a.bzscroll = !1, a.scrollrunning = !1, 0 > g ? g = 0 : g > a.page.maxh && (g = a.page.maxh), 0 > d ? d = 0 : d > a.page.maxw && (d = a.page.maxw), d != a.newscrollx || g != a.newscrolly ? a.doScrollPos(d, g) : a.onscrollend && a.triggerScrollEnd()) : a.timer = s(e) || 1
  1617.                 }
  1618.                 c = "undefined" == typeof c || !1 === c ? a.getScrollTop(!0) : c;
  1619.                 if (a.timer && a.newscrolly == c && a.newscrollx == b) return !0;
  1620.                 a.timer && t(a.timer);
  1621.                 a.timer = 0;
  1622.                 var f = a.getScrollTop(),
  1623.                     h = a.getScrollLeft();
  1624.                 (0 > (a.newscrolly - f) * (c - f) || 0 > (a.newscrollx - h) * (b - h)) && a.cancelScroll();
  1625.                 a.newscrolly = c;
  1626.                 a.newscrollx = b;
  1627.                 a.bouncescroll && a.rail.visibility || (0 > a.newscrolly ? a.newscrolly = 0 : a.newscrolly > a.page.maxh && (a.newscrolly = a.page.maxh));
  1628.                 a.bouncescroll && a.railh.visibility || (0 > a.newscrollx ? a.newscrollx = 0 : a.newscrollx > a.page.maxw && (a.newscrollx = a.page.maxw));
  1629.                 a.dst = {};
  1630.                 a.dst.x = b - h;
  1631.                 a.dst.y = c - f;
  1632.                 a.dst.px = h;
  1633.                 a.dst.py = f;
  1634.                 var k = Math.round(Math.sqrt(Math.pow(a.dst.x, 2) + Math.pow(a.dst.y, 2)));
  1635.                 a.dst.ax = a.dst.x / k;
  1636.                 a.dst.ay = a.dst.y / k;
  1637.                 var l = 0,
  1638.                     m = k;
  1639.                 0 == a.dst.x ? (l = f, m = c, a.dst.ay = 1, a.dst.py = 0) : 0 == a.dst.y && (l = h, m = b, a.dst.ax = 1, a.dst.px = 0);
  1640.                 k = a.getTransitionSpeed(k);
  1641.                 d && 1 >= d && (k *= d);
  1642.                 a.bzscroll = 0 < k ? a.bzscroll ? a.bzscroll.update(m, k) : new A(l, m, k, 0, 1, 0, 1) : !1;
  1643.                 if (!a.timer) {
  1644.                     (f == a.page.maxh && c >= a.page.maxh || h == a.page.maxw && b >= a.page.maxw) && a.checkContentSize();
  1645.                     var n = 1;
  1646.                     a.cancelAnimationFrame = !1;
  1647.                     a.timer = 1;
  1648.                     a.onscrollstart && !a.scrollrunning && a.onscrollstart.call(a, {
  1649.                         type: "scrollstart",
  1650.                         current: {
  1651.                             x: h,
  1652.                             y: f
  1653.                         },
  1654.                         request: {
  1655.                             x: b,
  1656.                             y: c
  1657.                         },
  1658.                         end: {
  1659.                             x: a.newscrollx,
  1660.                             y: a.newscrolly
  1661.                         },
  1662.                         speed: k
  1663.                     });
  1664.                     e();
  1665.                     (f == a.page.maxh && c >= f || h == a.page.maxw && b >= h) && a.checkContentSize();
  1666.                     a.noticeCursor()
  1667.                 }
  1668.             }, this.cancelScroll = function() {
  1669.                 a.timer && t(a.timer);
  1670.                 a.timer = 0;
  1671.                 a.bzscroll = !1;
  1672.                 a.scrollrunning = !1;
  1673.                 return a
  1674.             }) : (this.doScrollLeft = function(b, c) {
  1675.                 var d = a.getScrollTop();
  1676.                 a.doScrollPos(b, d, c)
  1677.             }, this.doScrollTop = function(b, c) {
  1678.                 var d = a.getScrollLeft();
  1679.                 a.doScrollPos(d, b, c)
  1680.             }, this.doScrollPos = function(b, c, d) {
  1681.                 var e = b > a.page.maxw ? a.page.maxw : b;
  1682.                 0 > e && (e = 0);
  1683.                 var f = c > a.page.maxh ? a.page.maxh : c;
  1684.                 0 > f && (f = 0);
  1685.                 a.synched("scroll", function() {
  1686.                     a.setScrollTop(f);
  1687.                     a.setScrollLeft(e)
  1688.                 })
  1689.             }, this.cancelScroll = function() {});
  1690.             this.doScrollBy = function(b, c) {
  1691.                 var d = 0,
  1692.                     d = c ? Math.floor((a.scroll.y - b) * a.scrollratio.y) : (a.timer ? a.newscrolly : a.getScrollTop(!0)) - b;
  1693.                 if (a.bouncescroll) {
  1694.                     var e = Math.round(a.view.h / 2);
  1695.                     d < -e ? d = -e : d > a.page.maxh + e && (d = a.page.maxh + e)
  1696.                 }
  1697.                 a.cursorfreezed = !1;
  1698.                 e = a.getScrollTop(!0);
  1699.                 if (0 > d && 0 >= e) return a.noticeCursor();
  1700.                 if (d > a.page.maxh && e >= a.page.maxh) return a.checkContentSize(), a.noticeCursor();
  1701.                 a.doScrollTop(d)
  1702.             };
  1703.             this.doScrollLeftBy = function(b, c) {
  1704.                 var d = 0,
  1705.                     d = c ? Math.floor((a.scroll.x - b) * a.scrollratio.x) : (a.timer ? a.newscrollx : a.getScrollLeft(!0)) - b;
  1706.                 if (a.bouncescroll) {
  1707.                     var e = Math.round(a.view.w / 2);
  1708.                     d < -e ? d = -e : d > a.page.maxw + e && (d = a.page.maxw + e)
  1709.                 }
  1710.                 a.cursorfreezed = !1;
  1711.                 e = a.getScrollLeft(!0);
  1712.                 if (0 > d && 0 >= e || d > a.page.maxw && e >= a.page.maxw) return a.noticeCursor();
  1713.                 a.doScrollLeft(d)
  1714.             };
  1715.             this.doScrollTo = function(b, c) {
  1716.                 c && Math.round(b * a.scrollratio.y);
  1717.                 a.cursorfreezed = !1;
  1718.                 a.doScrollTop(b)
  1719.             };
  1720.             this.checkContentSize = function() {
  1721.                 var b = a.getContentSize();
  1722.                 b.h == a.page.h && b.w == a.page.w || a.resize(!1, b)
  1723.             };
  1724.             a.onscroll = function(b) {
  1725.                 a.rail.drag || a.cursorfreezed || a.synched("scroll", function() {
  1726.                     a.scroll.y = Math.round(a.getScrollTop() * (1 / a.scrollratio.y));
  1727.                     a.railh && (a.scroll.x = Math.round(a.getScrollLeft() * (1 / a.scrollratio.x)));
  1728.                     a.noticeCursor()
  1729.                 })
  1730.             };
  1731.             a.bind(a.docscroll, "scroll", a.onscroll);
  1732.             this.doZoomIn = function(b) {
  1733.                 if (!a.zoomactive) {
  1734.                     a.zoomactive = !0;
  1735.                     a.zoomrestore = {
  1736.                         style: {}
  1737.                     };
  1738.                     var c = "position top left zIndex backgroundColor marginTop marginBottom marginLeft marginRight".split(" "),
  1739.                         d = a.win[0].style,
  1740.                         h;
  1741.                     for (h in c) {
  1742.                         var k = c[h];
  1743.                         a.zoomrestore.style[k] = "undefined" != typeof d[k] ? d[k] : ""
  1744.                     }
  1745.                     a.zoomrestore.style.width = a.win.css("width");
  1746.                     a.zoomrestore.style.height = a.win.css("height");
  1747.                     a.zoomrestore.padding = {
  1748.                         w: a.win.outerWidth() - a.win.width(),
  1749.                         h: a.win.outerHeight() - a.win.height()
  1750.                     };
  1751.                     e.isios4 && (a.zoomrestore.scrollTop = f(window).scrollTop(), f(window).scrollTop(0));
  1752.                     a.win.css({
  1753.                         position: e.isios4 ? "absolute" : "fixed",
  1754.                         top: 0,
  1755.                         left: 0,
  1756.                         "z-index": x + 100,
  1757.                         margin: "0px"
  1758.                     });
  1759.                     c = a.win.css("backgroundColor");
  1760.                     ("" == c || /transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(c)) && a.win.css("backgroundColor", "#fff");
  1761.                     a.rail.css({
  1762.                         "z-index": x + 101
  1763.                     });
  1764.                     a.zoom.css({
  1765.                         "z-index": x + 102
  1766.                     });
  1767.                     a.zoom.css("backgroundPosition", "0px -18px");
  1768.                     a.resizeZoom();
  1769.                     a.onzoomin && a.onzoomin.call(a);
  1770.                     return a.cancelEvent(b)
  1771.                 }
  1772.             };
  1773.             this.doZoomOut = function(b) {
  1774.                 if (a.zoomactive) return a.zoomactive = !1, a.win.css("margin", ""), a.win.css(a.zoomrestore.style), e.isios4 && f(window).scrollTop(a.zoomrestore.scrollTop), a.rail.css({
  1775.                     "z-index": a.zindex
  1776.                 }), a.zoom.css({
  1777.                     "z-index": a.zindex
  1778.                 }), a.zoomrestore = !1, a.zoom.css("backgroundPosition", "0px 0px"), a.onResize(), a.onzoomout && a.onzoomout.call(a), a.cancelEvent(b)
  1779.             };
  1780.             this.doZoom = function(b) {
  1781.                 return a.zoomactive ? a.doZoomOut(b) : a.doZoomIn(b)
  1782.             };
  1783.             this.resizeZoom = function() {
  1784.                 if (a.zoomactive) {
  1785.                     var b = a.getScrollTop();
  1786.                     a.win.css({
  1787.                         width: f(window).width() - a.zoomrestore.padding.w + "px",
  1788.                         height: f(window).height() - a.zoomrestore.padding.h + "px"
  1789.                     });
  1790.                     a.onResize();
  1791.                     a.setScrollTop(Math.min(a.page.maxh, b))
  1792.                 }
  1793.             };
  1794.             this.init();
  1795.             f.nicescroll.push(this)
  1796.         },
  1797.         L = function(f) {
  1798.             var c = this;
  1799.             this.nc = f;
  1800.             this.steptime = this.lasttime = this.speedy = this.speedx = this.lasty = this.lastx = 0;
  1801.             this.snapy = this.snapx = !1;
  1802.             this.demuly = this.demulx = 0;
  1803.             this.lastscrolly = this.lastscrollx = -1;
  1804.             this.timer = this.chky = this.chkx = 0;
  1805.             this.time = function() {
  1806.                 return +new Date
  1807.             };
  1808.             this.reset = function(f, k) {
  1809.                 c.stop();
  1810.                 var d = c.time();
  1811.                 c.steptime = 0;
  1812.                 c.lasttime = d;
  1813.                 c.speedx = 0;
  1814.                 c.speedy = 0;
  1815.                 c.lastx = f;
  1816.                 c.lasty = k;
  1817.                 c.lastscrollx = -1;
  1818.                 c.lastscrolly = -1
  1819.             };
  1820.             this.update = function(f, k) {
  1821.                 var d = c.time();
  1822.                 c.steptime = d - c.lasttime;
  1823.                 c.lasttime = d;
  1824.                 var d = k - c.lasty,
  1825.                     n = f - c.lastx,
  1826.                     p = c.nc.getScrollTop(),
  1827.                     a = c.nc.getScrollLeft(),
  1828.                     p = p + d,
  1829.                     a = a + n;
  1830.                 c.snapx = 0 > a || a > c.nc.page.maxw;
  1831.                 c.snapy = 0 > p || p > c.nc.page.maxh;
  1832.                 c.speedx = n;
  1833.                 c.speedy = d;
  1834.                 c.lastx = f;
  1835.                 c.lasty = k
  1836.             };
  1837.             this.stop = function() {
  1838.                 c.nc.unsynched("domomentum2d");
  1839.                 c.timer && clearTimeout(c.timer);
  1840.                 c.timer = 0;
  1841.                 c.lastscrollx = -1;
  1842.                 c.lastscrolly = -1
  1843.             };
  1844.             this.doSnapy = function(f, k) {
  1845.                 var d = !1;
  1846.                 0 > k ? (k = 0, d = !0) : k > c.nc.page.maxh && (k = c.nc.page.maxh, d = !0);
  1847.                 0 > f ? (f = 0, d = !0) : f > c.nc.page.maxw && (f = c.nc.page.maxw, d = !0);
  1848.                 d ? c.nc.doScrollPos(f, k, c.nc.opt.snapbackspeed) : c.nc.triggerScrollEnd()
  1849.             };
  1850.             this.doMomentum = function(f) {
  1851.                 var k = c.time(),
  1852.                     d = f ? k + f : c.lasttime;
  1853.                 f = c.nc.getScrollLeft();
  1854.                 var n = c.nc.getScrollTop(),
  1855.                     p = c.nc.page.maxh,
  1856.                     a = c.nc.page.maxw;
  1857.                 c.speedx = 0 < a ? Math.min(60, c.speedx) : 0;
  1858.                 c.speedy = 0 < p ? Math.min(60, c.speedy) : 0;
  1859.                 d = d && 60 >= k - d;
  1860.                 if (0 > n || n > p || 0 > f || f > a) d = !1;
  1861.                 f = c.speedx && d ? c.speedx : !1;
  1862.                 if (c.speedy && d && c.speedy || f) {
  1863.                     var s = Math.max(16, c.steptime);
  1864.                     50 < s && (f = s / 50, c.speedx *= f, c.speedy *= f, s = 50);
  1865.                     c.demulxy = 0;
  1866.                     c.lastscrollx = c.nc.getScrollLeft();
  1867.                     c.chkx = c.lastscrollx;
  1868.                     c.lastscrolly = c.nc.getScrollTop();
  1869.                     c.chky = c.lastscrolly;
  1870.                     var e = c.lastscrollx,
  1871.                         r = c.lastscrolly,
  1872.                         t = function() {
  1873.                             var d = 600 < c.time() - k ? .04 : .02;
  1874.                             c.speedx && (e = Math.floor(c.lastscrollx - c.speedx * (1 - c.demulxy)), c.lastscrollx = e, 0 > e || e > a) && (d = .1);
  1875.                             c.speedy && (r = Math.floor(c.lastscrolly - c.speedy * (1 - c.demulxy)), c.lastscrolly = r, 0 > r || r > p) && (d = .1);
  1876.                             c.demulxy = Math.min(1, c.demulxy + d);
  1877.                             c.nc.synched("domomentum2d", function() {
  1878.                                 c.speedx && (c.nc.getScrollLeft() != c.chkx && c.stop(), c.chkx = e, c.nc.setScrollLeft(e));
  1879.                                 c.speedy && (c.nc.getScrollTop() != c.chky && c.stop(), c.chky = r, c.nc.setScrollTop(r));
  1880.                                 c.timer || (c.nc.hideCursor(), c.doSnapy(e, r))
  1881.                             });
  1882.                             1 > c.demulxy ? c.timer = setTimeout(t, s) : (c.stop(), c.nc.hideCursor(), c.doSnapy(e, r))
  1883.                         };
  1884.                     t()
  1885.                 } else c.doSnapy(c.nc.getScrollLeft(), c.nc.getScrollTop())
  1886.             }
  1887.         },
  1888.         w = f.fn.scrollTop;
  1889.     f.cssHooks.pageYOffset = {
  1890.         get: function(k, c, h) {
  1891.             return (c = f.data(k, "__nicescroll") || !1) && c.ishwscroll ? c.getScrollTop() : w.call(k)
  1892.         },
  1893.         set: function(k, c) {
  1894.             var h = f.data(k, "__nicescroll") || !1;
  1895.             h && h.ishwscroll ? h.setScrollTop(parseInt(c)) : w.call(k, c);
  1896.             return this
  1897.         }
  1898.     };
  1899.     f.fn.scrollTop = function(k) {
  1900.         if ("undefined" == typeof k) {
  1901.             var c = this[0] ? f.data(this[0], "__nicescroll") || !1 : !1;
  1902.             return c && c.ishwscroll ? c.getScrollTop() : w.call(this)
  1903.         }
  1904.         return this.each(function() {
  1905.             var c = f.data(this, "__nicescroll") || !1;
  1906.             c && c.ishwscroll ? c.setScrollTop(parseInt(k)) : w.call(f(this), k)
  1907.         })
  1908.     };
  1909.     var B = f.fn.scrollLeft;
  1910.     f.cssHooks.pageXOffset = {
  1911.         get: function(k, c, h) {
  1912.             return (c = f.data(k, "__nicescroll") || !1) && c.ishwscroll ? c.getScrollLeft() : B.call(k)
  1913.         },
  1914.         set: function(k, c) {
  1915.             var h = f.data(k, "__nicescroll") || !1;
  1916.             h && h.ishwscroll ? h.setScrollLeft(parseInt(c)) : B.call(k, c);
  1917.             return this
  1918.         }
  1919.     };
  1920.     f.fn.scrollLeft = function(k) {
  1921.         if ("undefined" == typeof k) {
  1922.             var c = this[0] ? f.data(this[0], "__nicescroll") || !1 : !1;
  1923.             return c && c.ishwscroll ? c.getScrollLeft() : B.call(this)
  1924.         }
  1925.         return this.each(function() {
  1926.             var c = f.data(this, "__nicescroll") || !1;
  1927.             c && c.ishwscroll ? c.setScrollLeft(parseInt(k)) : B.call(f(this), k)
  1928.         })
  1929.     };
  1930.     var C = function(k) {
  1931.         var c = this;
  1932.         this.length = 0;
  1933.         this.name = "nicescrollarray";
  1934.         this.each = function(d) {
  1935.             for (var f = 0, h = 0; f < c.length; f++) d.call(c[f], h++);
  1936.             return c
  1937.         };
  1938.         this.push = function(d) {
  1939.             c[c.length] = d;
  1940.             c.length++
  1941.         };
  1942.         this.eq = function(d) {
  1943.             return c[d]
  1944.         };
  1945.         if (k)
  1946.             for (var h = 0; h < k.length; h++) {
  1947.                 var m = f.data(k[h], "__nicescroll") || !1;
  1948.                 m && (this[this.length] = m, this.length++)
  1949.             }
  1950.         return this
  1951.     };
  1952.     (function(f, c, h) {
  1953.         for (var m = 0; m < c.length; m++) h(f, c[m])
  1954.     })(C.prototype, "show hide toggle onResize resize remove stop doScrollPos".split(" "), function(f, c) {
  1955.         f[c] = function() {
  1956.             var f = arguments;
  1957.             return this.each(function() {
  1958.                 this[c].apply(this, f)
  1959.             })
  1960.         }
  1961.     });
  1962.     f.fn.getNiceScroll = function(k) {
  1963.         return "undefined" == typeof k ? new C(this) : this[k] && f.data(this[k], "__nicescroll") || !1
  1964.     };
  1965.     f.extend(f.expr[":"], {
  1966.         nicescroll: function(k) {
  1967.             return f.data(k, "__nicescroll") ? !0 : !1
  1968.         }
  1969.     });
  1970.     f.fn.niceScroll = function(k, c) {
  1971.         "undefined" != typeof c || "object" != typeof k || "jquery" in k || (c = k, k = !1);
  1972.         c = f.extend({}, c);
  1973.         var h = new C;
  1974.         "undefined" == typeof c && (c = {});
  1975.         k && (c.doc = f(k), c.win = f(this));
  1976.         var m = !("doc" in c);
  1977.         m || "win" in c || (c.win = f(this));
  1978.         this.each(function() {
  1979.             var d = f(this).data("__nicescroll") || !1;
  1980.             d || (c.doc = m ? f(this) : c.doc, d = new R(c, f(this)), f(this).data("__nicescroll", d));
  1981.             h.push(d)
  1982.         });
  1983.         return 1 == h.length ? h[0] : h
  1984.     };
  1985.     window.NiceScroll = {
  1986.         getjQuery: function() {
  1987.             return f
  1988.         }
  1989.     };
  1990.     f.nicescroll || (f.nicescroll = new C, f.nicescroll.options = I)
  1991. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement