jquery.nicescroll.js 92 KB

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