divscroll.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743
  1. (function(F) {
  2. var G = false;
  3. var H = false;
  4. var I = false;
  5. var J = 5000;
  6. var K = 2000;
  7. var $ = F;
  8. function getScriptPath() {
  9. var a = document.getElementsByTagName('script');
  10. var b = a[a.length - 1].src.split('?')[0];
  11. return (b.split('/').length > 0) ? b.split('/').slice(0, -1).join('/') + '/': ''
  12. }
  13. var L = getScriptPath();
  14. var M = (function() {
  15. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || false
  16. })();
  17. var N = (function() {
  18. return window.cancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || false
  19. })();
  20. var O = false;
  21. var P = function() {
  22. if (O) return O;
  23. var c = document.createElement('DIV');
  24. var d = {};
  25. d.haspointerlock = "pointerLockElement" in document || "mozPointerLockElement" in document || "webkitPointerLockElement" in document;
  26. d.isopera = ("opera" in window);
  27. d.isopera12 = (d.isopera && ("getUserMedia" in navigator));
  28. d.isie = (("all" in document) && ("attachEvent" in c) && !d.isopera);
  29. d.isieold = (d.isie && !("msInterpolationMode" in c.style));
  30. d.isie7 = d.isie && !d.isieold && (!("documentMode" in document) || (document.documentMode == 7));
  31. d.isie8 = d.isie && ("documentMode" in document) && (document.documentMode == 8);
  32. d.isie9 = d.isie && ("performance" in window) && (document.documentMode >= 9);
  33. d.isie10 = d.isie && ("performance" in window) && (document.documentMode >= 10);
  34. d.isie9mobile = /iemobile.9/i.test(navigator.userAgent);
  35. if (d.isie9mobile) d.isie9 = false;
  36. d.isie7mobile = (!d.isie9mobile && d.isie7) && /iemobile/i.test(navigator.userAgent);
  37. d.ismozilla = ("MozAppearance" in c.style);
  38. d.iswebkit = ("WebkitAppearance" in c.style);
  39. d.ischrome = ("chrome" in window);
  40. d.ischrome22 = (d.ischrome && d.haspointerlock);
  41. d.cantouch = ("ontouchstart" in document.documentElement) || ("ontouchstart" in window);
  42. d.hasmstouch = (window.navigator.msPointerEnabled || false);
  43. d.ismac = /^mac$/i.test(navigator.platform);
  44. d.isios = (d.cantouch && /iphone|ipad|ipod/i.test(navigator.platform));
  45. d.isios4 = ((d.isios) && !("seal" in Object));
  46. d.isandroid = (/android/i.test(navigator.userAgent));
  47. d.trstyle = false;
  48. d.hastransform = false;
  49. d.hastranslate3d = false;
  50. d.transitionstyle = false;
  51. d.hastransition = false;
  52. d.transitionend = false;
  53. var e = ['transform', 'msTransform', 'webkitTransform', 'MozTransform', 'OTransform'];
  54. for (var a = 0; a < e.length; a++) {
  55. if (typeof c.style[e[a]] != "undefined") {
  56. d.trstyle = e[a];
  57. break
  58. }
  59. }
  60. d.hastransform = (d.trstyle != false);
  61. if (d.hastransform) {
  62. c.style[d.trstyle] = "translate3d(1px,2px,3px)";
  63. d.hastranslate3d = /translate3d/.test(c.style[d.trstyle])
  64. }
  65. d.transitionstyle = false;
  66. d.prefixstyle = '';
  67. d.transitionend = false;
  68. var e = ['transition', 'webkitTransition', 'MozTransition', 'OTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
  69. var f = ['', '-webkit-', '-moz-', '-o-', '-o', '-ms-', '-khtml-'];
  70. var g = ['transitionend', 'webkitTransitionEnd', 'transitionend', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'KhtmlTransitionEnd'];
  71. for (var a = 0; a < e.length; a++) {
  72. if (e[a] in c.style) {
  73. d.transitionstyle = e[a];
  74. d.prefixstyle = f[a];
  75. d.transitionend = g[a];
  76. break
  77. }
  78. }
  79. d.hastransition = (d.transitionstyle);
  80. function detectCursorGrab() {
  81. var b = ['-moz-grab', '-webkit-grab', 'grab'];
  82. if ((d.ischrome && !d.ischrome22) || d.isie) b = [];
  83. for (var a = 0; a < b.length; a++) {
  84. var p = b[a];
  85. c.style['cursor'] = p;
  86. if (c.style['cursor'] == p) return p
  87. }
  88. return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize'
  89. }
  90. d.cursorgrabvalue = detectCursorGrab();
  91. d.hasmousecapture = ("setCapture" in c);
  92. c = null;
  93. O = d;
  94. return d
  95. };
  96. var Q = function(A, B) {
  97. var C = this;
  98. this.version = '3.1.4';
  99. this.name = 'nicescroll';
  100. C.me = B;
  101. this.opt = {
  102. doc: $("body"),
  103. win: false,
  104. zindex: 0,
  105. cursoropacitymin: 0,
  106. cursoropacitymax: 1,
  107. cursorcolor: "#424242",
  108. cursorwidth: "5px",
  109. cursorborder: "1px solid #fff",
  110. cursorborderradius: "5px",
  111. scrollspeed: 60,
  112. mousescrollstep: 8 * 3,
  113. touchbehavior: false,
  114. hwacceleration: true,
  115. usetransition: true,
  116. boxzoom: false,
  117. dblclickzoom: true,
  118. gesturezoom: true,
  119. grabcursorenabled: true,
  120. autohidemode: true,
  121. background: "",
  122. iframeautoresize: true,
  123. cursorminheight: 32,
  124. preservenativescrolling: true,
  125. railoffset: false,
  126. bouncescroll: true,
  127. spacebarenabled: true,
  128. railpadding: {
  129. top: 0,
  130. right: 0,
  131. left: 0,
  132. bottom: 0
  133. },
  134. disableoutline: true,
  135. horizrailenabled: true,
  136. railalign: "right",
  137. railvalign: "bottom",
  138. enabletranslate3d: true,
  139. enablemousewheel: true,
  140. enablekeyboard: true,
  141. smoothscroll: true,
  142. sensitiverail: true,
  143. enablemouselockapi: true,
  144. cursorfixedheight: false
  145. };
  146. this.opt.snapbackspeed = 80;
  147. if (A || false) {
  148. for (var a in C.opt) {
  149. if (typeof A[a] != "undefined") C.opt[a] = A[a]
  150. }
  151. }
  152. this.doc = C.opt.doc;
  153. this.iddoc = (this.doc && this.doc[0]) ? this.doc[0].id || '': '';
  154. this.ispage = /BODY|HTML/.test((C.opt.win) ? C.opt.win[0].nodeName: this.doc[0].nodeName);
  155. this.haswrapper = (C.opt.win !== false);
  156. this.win = C.opt.win || (this.ispage ? $(window) : this.doc);
  157. this.docscroll = (this.ispage && !this.haswrapper) ? $(window) : this.win;
  158. this.body = $("body");
  159. this.viewport = false;
  160. this.isfixed = false;
  161. this.iframe = false;
  162. this.isiframe = ((this.doc[0].nodeName == 'IFRAME') && (this.win[0].nodeName == 'IFRAME'));
  163. this.istextarea = (this.win[0].nodeName == 'TEXTAREA');
  164. this.forcescreen = false;
  165. this.canshowonmouseevent = (C.opt.autohidemode != "scroll");
  166. this.onmousedown = false;
  167. this.onmouseup = false;
  168. this.onmousemove = false;
  169. this.onmousewheel = false;
  170. this.onkeypress = false;
  171. this.ongesturezoom = false;
  172. this.onclick = false;
  173. this.onscrollstart = false;
  174. this.onscrollend = false;
  175. this.onscrollcancel = false;
  176. this.onzoomin = false;
  177. this.onzoomout = false;
  178. this.view = false;
  179. this.page = false;
  180. this.scroll = {
  181. x: 0,
  182. y: 0
  183. };
  184. this.scrollratio = {
  185. x: 0,
  186. y: 0
  187. };
  188. this.cursorheight = 20;
  189. this.scrollvaluemax = 0;
  190. this.scrollrunning = false;
  191. this.scrollmom = false;
  192. this.observer = false;
  193. do {
  194. this.id = "ascrail" + (K++)
  195. } while ( document . getElementById ( this . id ));
  196. this.rail = false;
  197. this.cursor = false;
  198. this.cursorfreezed = false;
  199. this.zoom = false;
  200. this.zoomactive = false;
  201. this.hasfocus = false;
  202. this.hasmousefocus = false;
  203. this.visibility = true;
  204. this.locked = false;
  205. this.hidden = false;
  206. this.cursoractive = true;
  207. this.nativescrollingarea = false;
  208. this.events = [];
  209. this.saved = {};
  210. this.delaylist = {};
  211. this.synclist = {};
  212. this.lastdeltax = 0;
  213. this.lastdeltay = 0;
  214. this.detected = P();
  215. var D = $.extend({},
  216. this.detected);
  217. this.canhwscroll = (D.hastransform && C.opt.hwacceleration);
  218. this.ishwscroll = (this.canhwscroll && C.haswrapper);
  219. this.istouchcapable = false;
  220. if (D.cantouch && D.ischrome && !D.isios && !D.isandroid) {
  221. this.istouchcapable = true;
  222. D.cantouch = false
  223. }
  224. if (D.cantouch && D.ismozilla && !D.isios) {
  225. this.istouchcapable = true;
  226. D.cantouch = false
  227. }
  228. if (!C.opt.enablemouselockapi) {
  229. D.hasmousecapture = false;
  230. D.haspointerlock = false
  231. }
  232. this.delayed = function(a, b, c, d) {
  233. var e = C.delaylist[a];
  234. var f = (new Date()).getTime();
  235. if (!d && e && e.tt) return false;
  236. if (e && e.tt) clearTimeout(e.tt);
  237. if (e && e.last + c > f && !e.tt) {
  238. C.delaylist[a] = {
  239. last: f + c,
  240. tt: setTimeout(function() {
  241. C.delaylist[a].tt = 0;
  242. b.call()
  243. },
  244. c)
  245. }
  246. } else if (!e || !e.tt) {
  247. C.delaylist[a] = {
  248. last: f,
  249. tt: 0
  250. };
  251. setTimeout(function() {
  252. b.call()
  253. },
  254. 0)
  255. }
  256. };
  257. this.synched = function(b, c) {
  258. function requestSync() {
  259. if (C.onsync) return;
  260. M(function() {
  261. C.onsync = false;
  262. for (b in C.synclist) {
  263. var a = C.synclist[b];
  264. if (a) a.call(C);
  265. C.synclist[b] = false
  266. }
  267. });
  268. C.onsync = true
  269. };
  270. C.synclist[b] = c;
  271. requestSync();
  272. return b
  273. };
  274. this.unsynched = function(a) {
  275. if (C.synclist[a]) C.synclist[a] = false
  276. };
  277. this.css = function(a, b) {
  278. for (var n in b) {
  279. C.saved.css.push([a, n, a.css(n)]);
  280. a.css(n, b[n])
  281. }
  282. };
  283. this.scrollTop = function(a) {
  284. return (typeof a == "undefined") ? C.getScrollTop() : C.setScrollTop(a)
  285. };
  286. this.scrollLeft = function(a) {
  287. return (typeof a == "undefined") ? C.getScrollLeft() : C.setScrollLeft(a)
  288. };
  289. BezierClass = function(a, b, c, d, e, f, g) {
  290. this.st = a;
  291. this.ed = b;
  292. this.spd = c;
  293. this.p1 = d || 0;
  294. this.p2 = e || 1;
  295. this.p3 = f || 0;
  296. this.p4 = g || 1;
  297. this.ts = (new Date()).getTime();
  298. this.df = this.ed - this.st
  299. };
  300. BezierClass.prototype = {
  301. B2: function(t) {
  302. return 3 * t * t * (1 - t)
  303. },
  304. B3: function(t) {
  305. return 3 * t * (1 - t) * (1 - t)
  306. },
  307. B4: function(t) {
  308. return (1 - t) * (1 - t) * (1 - t)
  309. },
  310. getNow: function() {
  311. var a = (new Date()).getTime();
  312. var b = 1 - ((a - this.ts) / this.spd);
  313. var c = this.B2(b) + this.B3(b) + this.B4(b);
  314. return (b < 0) ? this.ed: this.st + Math.round(this.df * c)
  315. },
  316. update: function(a, b) {
  317. this.st = this.getNow();
  318. this.ed = a;
  319. this.spd = b;
  320. this.ts = (new Date()).getTime();
  321. this.df = this.ed - this.st;
  322. return this
  323. }
  324. };
  325. if (this.ishwscroll) {
  326. this.doc.translate = {
  327. x: 0,
  328. y: 0,
  329. tx: "0px",
  330. ty: "0px"
  331. };
  332. if (D.hastranslate3d && D.isios) this.doc.css("-webkit-backface-visibility", "hidden");
  333. function getMatrixValues() {
  334. var a = C.doc.css(D.trstyle);
  335. if (a && (a.substr(0, 6) == "matrix")) {
  336. return a.replace(/^.*\((.*)\)$/g, "$1").replace(/px/g, '').split(/, +/)
  337. }
  338. return false
  339. }
  340. this.getScrollTop = function(a) {
  341. if (!a) {
  342. var b = getMatrixValues();
  343. if (b) return (b.length == 16) ? -b[13] : -b[5];
  344. if (C.timerscroll && C.timerscroll.bz) return C.timerscroll.bz.getNow()
  345. }
  346. return C.doc.translate.y
  347. };
  348. this.getScrollLeft = function(a) {
  349. if (!a) {
  350. var b = getMatrixValues();
  351. if (b) return (b.length == 16) ? -b[12] : -b[4];
  352. if (C.timerscroll && C.timerscroll.bh) return C.timerscroll.bh.getNow()
  353. }
  354. return C.doc.translate.x
  355. };
  356. if (document.createEvent) {
  357. this.notifyScrollEvent = function(a) {
  358. var e = document.createEvent("UIEvents");
  359. e.initUIEvent("scroll", false, true, window, 1);
  360. a.dispatchEvent(e)
  361. }
  362. } else if (document.fireEvent) {
  363. this.notifyScrollEvent = function(a) {
  364. var e = document.createEventObject();
  365. a.fireEvent("onscroll");
  366. e.cancelBubble = true
  367. }
  368. } else {
  369. this.notifyScrollEvent = function(a, b) {}
  370. }
  371. if (D.hastranslate3d && C.opt.enabletranslate3d) {
  372. this.setScrollTop = function(a, b) {
  373. C.doc.translate.y = a;
  374. C.doc.translate.ty = (a * -1) + "px";
  375. C.doc.css(D.trstyle, "translate3d(" + C.doc.translate.tx + "," + C.doc.translate.ty + ",0px)");
  376. if (!b) C.notifyScrollEvent(C.win[0])
  377. };
  378. this.setScrollLeft = function(a, b) {
  379. C.doc.translate.x = a;
  380. C.doc.translate.tx = (a * -1) + "px";
  381. C.doc.css(D.trstyle, "translate3d(" + C.doc.translate.tx + "," + C.doc.translate.ty + ",0px)");
  382. if (!b) C.notifyScrollEvent(C.win[0])
  383. }
  384. } else {
  385. this.setScrollTop = function(a, b) {
  386. C.doc.translate.y = a;
  387. C.doc.translate.ty = (a * -1) + "px";
  388. C.doc.css(D.trstyle, "translate(" + C.doc.translate.tx + "," + C.doc.translate.ty + ")");
  389. if (!b) C.notifyScrollEvent(C.win[0])
  390. };
  391. this.setScrollLeft = function(a, b) {
  392. C.doc.translate.x = a;
  393. C.doc.translate.tx = (a * -1) + "px";
  394. C.doc.css(D.trstyle, "translate(" + C.doc.translate.tx + "," + C.doc.translate.ty + ")");
  395. if (!b) C.notifyScrollEvent(C.win[0])
  396. }
  397. }
  398. } else {
  399. this.getScrollTop = function() {
  400. return C.docscroll.scrollTop()
  401. };
  402. this.setScrollTop = function(a) {
  403. return C.docscroll.scrollTop(a)
  404. };
  405. this.getScrollLeft = function() {
  406. return C.docscroll.scrollLeft()
  407. };
  408. this.setScrollLeft = function(a) {
  409. return C.docscroll.scrollLeft(a)
  410. }
  411. }
  412. this.getTarget = function(e) {
  413. if (!e) return false;
  414. if (e.target) return e.target;
  415. if (e.srcElement) return e.srcElement;
  416. return false
  417. };
  418. this.hasParent = function(e, a) {
  419. if (!e) return false;
  420. var b = e.target || e.srcElement || e || false;
  421. while (b && b.id != a) {
  422. b = b.parentNode || false
  423. }
  424. return (b !== false)
  425. };
  426. var E = {
  427. "thin": 1,
  428. "medium": 3,
  429. "thick": 5
  430. };
  431. function getWidthToPixel(a, b, c) {
  432. var d = a.css(b);
  433. var e = parseFloat(d);
  434. if (isNaN(e)) {
  435. e = E[d] || 0;
  436. var f = (e == 3) ? ((c) ? (C.win.outerHeight() - C.win.innerHeight()) : (C.win.outerWidth() - C.win.innerWidth())) : 1;
  437. if (C.isie8 && e) e += 1;
  438. return (f) ? e: 0
  439. }
  440. return e
  441. };
  442. this.getOffset = function() {
  443. if (C.isfixed) return {
  444. top: parseFloat(C.win.css('top')),
  445. left: parseFloat(C.win.css('left'))
  446. };
  447. if (!C.viewport) return C.win.offset();
  448. var a = C.win.offset();
  449. var b = C.viewport.offset();
  450. return {
  451. top: a.top - b.top + C.viewport.scrollTop(),
  452. left: a.left - b.left + C.viewport.scrollLeft()
  453. }
  454. };
  455. this.updateScrollBar = function(a) {
  456. if (C.ishwscroll) {
  457. C.rail.css({
  458. height: C.win.innerHeight()
  459. });
  460. if (C.railh) C.railh.css({
  461. width: C.win.innerWidth()
  462. })
  463. } else {
  464. var b = C.getOffset();
  465. var c = {
  466. top: b.top,
  467. left: b.left
  468. };
  469. c.top += getWidthToPixel(C.win, 'border-top-width', true);
  470. var d = (C.win.outerWidth() - C.win.innerWidth()) / 2;
  471. c.left += (C.rail.align) ? C.win.outerWidth() - getWidthToPixel(C.win, 'border-right-width') - C.rail.width: getWidthToPixel(C.win, 'border-left-width');
  472. var e = C.opt.railoffset;
  473. if (e) {
  474. if (e.top) c.top += e.top;
  475. if (C.rail.align && e.left) c.left += e.left
  476. }
  477. if (!C.locked) C.rail.css({
  478. top: c.top,
  479. left: c.left,
  480. height: (a) ? a.h: C.win.innerHeight()
  481. });
  482. if (C.zoom) {
  483. C.zoom.css({
  484. top: c.top + 1,
  485. left: (C.rail.align == 1) ? c.left - 20 : c.left + C.rail.width + 4
  486. })
  487. }
  488. if (C.railh && !C.locked) {
  489. var c = {
  490. top: b.top,
  491. left: b.left
  492. };
  493. var y = (C.railh.align) ? c.top + getWidthToPixel(C.win, 'border-top-width', true) + C.win.innerHeight() - C.railh.height: c.top + getWidthToPixel(C.win, 'border-top-width', true);
  494. var x = c.left + getWidthToPixel(C.win, 'border-left-width');
  495. C.railh.css({
  496. top: y,
  497. left: x,
  498. width: C.railh.width
  499. })
  500. }
  501. }
  502. };
  503. this.doRailClick = function(e, a, b) {
  504. var c, pg, cur, pos;
  505. if (C.rail.drag && C.rail.drag.pt != 1) return;
  506. if (C.locked) return;
  507. if (C.rail.drag) return;
  508. C.cancelScroll();
  509. C.cancelEvent(e);
  510. if (a) {
  511. c = (b) ? C.doScrollLeft: C.doScrollTop;
  512. cur = (b) ? ((e.pageX - C.railh.offset().left - (C.cursorwidth / 2)) * C.scrollratio.x) : ((e.pageY - C.rail.offset().top - (C.cursorheight / 2)) * C.scrollratio.y);
  513. c(cur)
  514. } else {
  515. c = (b) ? C.doScrollLeftBy: C.doScrollBy;
  516. cur = (b) ? C.scroll.x: C.scroll.y;
  517. pos = (b) ? e.pageX - C.railh.offset().left: e.pageY - C.rail.offset().top;
  518. pg = (b) ? C.view.w: C.view.h; (cur >= pos) ? c(pg) : c( - pg)
  519. }
  520. };
  521. C.hasanimationframe = (M);
  522. C.hascancelanimationframe = (N);
  523. if (!C.hasanimationframe) {
  524. M = function(a) {
  525. return setTimeout(a, 16)
  526. };
  527. N = clearInterval
  528. } else if (!C.hascancelanimationframe) N = function() {
  529. C.cancelAnimationFrame = true
  530. };
  531. this.init = function() {
  532. C.saved.css = [];
  533. if (D.isie7mobile) return true;
  534. if (D.hasmstouch) C.css((C.ispage) ? $("html") : C.win, {
  535. '-ms-touch-action': 'none'
  536. });
  537. if (!C.ispage || (!D.cantouch && !D.isieold && !D.isie9mobile)) {
  538. var m = C.docscroll;
  539. if (C.ispage) m = (C.haswrapper) ? C.win: C.doc;
  540. if (!D.isie9mobile) C.css(m, {
  541. 'overflow-y': 'hidden'
  542. });
  543. if (C.ispage && D.isie7) {
  544. if (C.doc[0].nodeName == 'BODY') C.css($("html"), {
  545. 'overflow-y': 'hidden'
  546. });
  547. else if (C.doc[0].nodeName == 'HTML') C.css($("body"), {
  548. 'overflow-y': 'hidden'
  549. })
  550. }
  551. if (D.isios && !C.ispage && !C.haswrapper) C.css($("body"), {
  552. "-webkit-overflow-scrolling": "touch"
  553. });
  554. var o = $(document.createElement('div'));
  555. o.css({
  556. position: "relative",
  557. top: 0,
  558. "float": "right",
  559. width: C.opt.cursorwidth,
  560. height: "0px",
  561. 'background-color': C.opt.cursorcolor,
  562. border: C.opt.cursorborder,
  563. 'background-clip': 'padding-box',
  564. '-webkit-border-radius': C.opt.cursorborderradius,
  565. '-moz-border-radius': C.opt.cursorborderradius,
  566. 'border-radius': C.opt.cursorborderradius
  567. });
  568. o.hborder = parseFloat(o.outerHeight() - o.innerHeight());
  569. C.cursor = o;
  570. var p = $(document.createElement('div'));
  571. p.attr('id', C.id);
  572. var v, a, kp = ["left", "right"];
  573. for (var n in kp) {
  574. a = kp[n];
  575. v = C.opt.railpadding[a]; (v) ? p.css("padding-" + a, v + "px") : C.opt.railpadding[a] = 0
  576. }
  577. p.append(o);
  578. p.width = Math.max(parseFloat(C.opt.cursorwidth), o.outerWidth()) + C.opt.railpadding['left'] + C.opt.railpadding['right'];
  579. p.css({
  580. width: p.width + "px",
  581. 'zIndex': (C.ispage) ? C.opt.zindex: C.opt.zindex + 2,
  582. "background": C.opt.background
  583. });
  584. p.visibility = true;
  585. p.scrollable = true;
  586. p.align = (C.opt.railalign == "left") ? 0 : 1;
  587. C.rail = p;
  588. C.rail.drag = false;
  589. var q = false;
  590. if (C.opt.boxzoom && !C.ispage && !D.isieold) {
  591. q = document.createElement('div');
  592. C.bind(q, "click", C.doZoom);
  593. C.zoom = $(q);
  594. C.zoom.css({
  595. "cursor": "pointer",
  596. 'z-index': C.opt.zindex,
  597. 'backgroundImage': 'url(' + L + 'zoomico_wev8.png)',
  598. 'height': 18,
  599. 'width': 18,
  600. 'backgroundPosition': '0px 0px'
  601. });
  602. if (C.opt.dblclickzoom) C.bind(C.win, "dblclick", C.doZoom);
  603. if (D.cantouch && C.opt.gesturezoom) {
  604. C.ongesturezoom = function(e) {
  605. if (e.scale > 1.5) C.doZoomIn(e);
  606. if (e.scale < 0.8) C.doZoomOut(e);
  607. return C.cancelEvent(e)
  608. };
  609. C.bind(C.win, "gestureend", C.ongesturezoom)
  610. }
  611. };
  612. C.railh = false;
  613. if (C.opt.horizrailenabled) {
  614. C.css(m, {
  615. 'overflow-x': 'hidden'
  616. });
  617. var o = $(document.createElement('div'));
  618. o.css({
  619. position: "relative",
  620. top: 0,
  621. height: C.opt.cursorwidth,
  622. width: "0px",
  623. 'background-color': C.opt.cursorcolor,
  624. border: C.opt.cursorborder,
  625. 'background-clip': 'padding-box',
  626. '-webkit-border-radius': C.opt.cursorborderradius,
  627. '-moz-border-radius': C.opt.cursorborderradius,
  628. 'border-radius': C.opt.cursorborderradius
  629. });
  630. o.wborder = parseFloat(o.outerWidth() - o.innerWidth());
  631. C.cursorh = o;
  632. var r = $(document.createElement('div'));
  633. r.attr('id', C.id + '-hr');
  634. r.height = 1 + Math.max(parseFloat(C.opt.cursorwidth), o.outerHeight());
  635. r.css({
  636. height: r.height + "px",
  637. 'zIndex': (C.ispage) ? C.opt.zindex: C.opt.zindex + 2,
  638. "background": C.opt.background
  639. });
  640. r.append(o);
  641. r.visibility = true;
  642. r.scrollable = true;
  643. r.align = (C.opt.railvalign == "top") ? 0 : 1;
  644. C.railh = r;
  645. C.railh.drag = false
  646. }
  647. if (C.ispage) {
  648. p.css({
  649. position: "fixed",
  650. top: "0px",
  651. height: "100%"
  652. }); (p.align) ? p.css({
  653. right: "0px"
  654. }) : p.css({
  655. left: "0px"
  656. });
  657. C.body.append(p);
  658. if (C.railh) {
  659. r.css({
  660. position: "fixed",
  661. left: "0px",
  662. width: "100%"
  663. }); (r.align) ? r.css({
  664. bottom: "0px"
  665. }) : r.css({
  666. top: "0px"
  667. });
  668. C.body.append(r)
  669. }
  670. } else {
  671. if (C.ishwscroll) {
  672. if (C.win.css('position') == 'static') C.css(C.win, {
  673. 'position': 'relative'
  674. });
  675. var s = (C.win[0].nodeName == 'HTML') ? C.body: C.win;
  676. if (C.zoom) {
  677. C.zoom.css({
  678. position: "absolute",
  679. top: 1,
  680. right: 0,
  681. "margin-right": p.width + 4
  682. });
  683. s.append(C.zoom)
  684. }
  685. p.css({
  686. position: "absolute",
  687. top: 0
  688. }); (p.align) ? p.css({
  689. right: 0
  690. }) : p.css({
  691. left: 0
  692. });
  693. s.append(p);
  694. if (r) {
  695. r.css({
  696. position: "absolute",
  697. left: 0,
  698. bottom: 0
  699. }); (r.align) ? r.css({
  700. bottom: 0
  701. }) : r.css({
  702. top: 0
  703. });
  704. s.append(r)
  705. }
  706. } else {
  707. C.isfixed = (C.win.css("position") == "fixed");
  708. var t = (C.isfixed) ? "fixed": "absolute";
  709. if (!C.isfixed) C.viewport = C.getViewport(C.win[0]);
  710. if (C.viewport) C.body = C.viewport;
  711. p.css({
  712. position: t
  713. });
  714. if (C.zoom) C.zoom.css({
  715. position: t
  716. });
  717. C.updateScrollBar();
  718. C.body.append(p);
  719. if (C.zoom) C.body.append(C.zoom);
  720. if (C.railh) {
  721. r.css({
  722. position: t
  723. });
  724. C.body.append(r)
  725. }
  726. }
  727. if (D.isios) C.css(C.win, {
  728. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  729. '-webkit-touch-callout': 'none'
  730. });
  731. if (D.isie && C.opt.disableoutline) C.win.attr("hideFocus", "true");
  732. if (D.iswebkit && C.opt.disableoutline) C.win.css({
  733. "outline": "none"
  734. })
  735. }
  736. if (C.opt.autohidemode === false) {
  737. C.autohidedom = false;
  738. C.rail.css({
  739. opacity: C.opt.cursoropacitymax
  740. });
  741. if (C.railh) C.railh.css({
  742. opacity: C.opt.cursoropacitymax
  743. })
  744. } else if (C.opt.autohidemode === true) {
  745. C.autohidedom = $().add(C.rail);
  746. if (C.railh) C.autohidedom = C.autohidedom.add(C.railh)
  747. } else if (C.opt.autohidemode == "scroll") {
  748. C.autohidedom = $().add(C.rail);
  749. if (C.railh) C.autohidedom = C.autohidedom.add(C.railh)
  750. } else if (C.opt.autohidemode == "cursor") {
  751. C.autohidedom = $().add(C.cursor);
  752. if (C.railh) C.autohidedom = C.autohidedom.add(C.railh.cursor)
  753. } else if (C.opt.autohidemode == "hidden") {
  754. C.autohidedom = false;
  755. C.hide();
  756. C.locked = false
  757. }
  758. if (D.isie9mobile) {
  759. C.scrollmom = new R(C);
  760. C.onmangotouch = function(e) {
  761. var a = C.getScrollTop();
  762. var b = C.getScrollLeft();
  763. if ((a == C.scrollmom.lastscrolly) && (b == C.scrollmom.lastscrollx)) return true;
  764. var c = a - C.mangotouch.sy;
  765. var d = b - C.mangotouch.sx;
  766. var f = Math.round(Math.sqrt(Math.pow(d, 2) + Math.pow(c, 2)));
  767. if (f == 0) return;
  768. var g = (c < 0) ? -1 : 1;
  769. var h = (d < 0) ? -1 : 1;
  770. var i = +new Date();
  771. if (C.mangotouch.lazy) clearTimeout(C.mangotouch.lazy);
  772. if (((i - C.mangotouch.tm) > 80) || (C.mangotouch.dry != g) || (C.mangotouch.drx != h)) {
  773. C.scrollmom.stop();
  774. C.scrollmom.reset(b, a);
  775. C.mangotouch.sy = a;
  776. C.mangotouch.ly = a;
  777. C.mangotouch.sx = b;
  778. C.mangotouch.lx = b;
  779. C.mangotouch.dry = g;
  780. C.mangotouch.drx = h;
  781. C.mangotouch.tm = i
  782. } else {
  783. C.scrollmom.stop();
  784. C.scrollmom.update(C.mangotouch.sx - d, C.mangotouch.sy - c);
  785. var j = i - C.mangotouch.tm;
  786. C.mangotouch.tm = i;
  787. var k = Math.max(Math.abs(C.mangotouch.ly - a), Math.abs(C.mangotouch.lx - b));
  788. C.mangotouch.ly = a;
  789. C.mangotouch.lx = b;
  790. if (k > 2) {
  791. C.mangotouch.lazy = setTimeout(function() {
  792. C.mangotouch.lazy = false;
  793. C.mangotouch.dry = 0;
  794. C.mangotouch.drx = 0;
  795. C.mangotouch.tm = 0;
  796. C.scrollmom.doMomentum(30)
  797. },
  798. 100)
  799. }
  800. }
  801. };
  802. var u = C.getScrollTop();
  803. var w = C.getScrollLeft();
  804. C.mangotouch = {
  805. sy: u,
  806. ly: u,
  807. dry: 0,
  808. sx: w,
  809. lx: w,
  810. drx: 0,
  811. lazy: false,
  812. tm: 0
  813. };
  814. C.bind(C.docscroll, "scroll", C.onmangotouch)
  815. } else {
  816. if (D.cantouch || C.istouchcapable || C.opt.touchbehavior || D.hasmstouch) {
  817. C.scrollmom = new R(C);
  818. C.ontouchstart = function(e) {
  819. if (e.pointerType && e.pointerType != 2) return false;
  820. if (!C.locked) {
  821. if (D.hasmstouch) {
  822. var a = (e.target) ? e.target: false;
  823. while (a) {
  824. var b = $(a).getNiceScroll();
  825. if ((b.length > 0) && (b[0].me == C.me)) break;
  826. if (b.length > 0) return false;
  827. if ((a.nodeName == 'DIV') && (a.id == C.id)) break;
  828. a = (a.parentNode) ? a.parentNode: false
  829. }
  830. }
  831. C.cancelScroll();
  832. var a = C.getTarget(e);
  833. if (a) {
  834. var c = (/INPUT/i.test(a.nodeName)) && (/range/i.test(a.type));
  835. if (c) return C.stopPropagation(e)
  836. }
  837. if (! ("clientX" in e) && ("changedTouches" in e)) {
  838. e.clientX = e.changedTouches[0].clientX;
  839. e.clientY = e.changedTouches[0].clientY
  840. }
  841. if (C.forcescreen) {
  842. var d = e;
  843. var e = {
  844. "original": (e.original) ? e.original: e
  845. };
  846. e.clientX = d.screenX;
  847. e.clientY = d.screenY
  848. }
  849. C.rail.drag = {
  850. x: e.clientX,
  851. y: e.clientY,
  852. sx: C.scroll.x,
  853. sy: C.scroll.y,
  854. st: C.getScrollTop(),
  855. sl: C.getScrollLeft(),
  856. pt: 2
  857. };
  858. if (C.opt.touchbehavior && C.isiframe && D.isie) {
  859. var f = C.win.position();
  860. C.rail.drag.x += f.left;
  861. C.rail.drag.y += f.top
  862. }
  863. C.hasmoving = false;
  864. C.lastmouseup = false;
  865. C.scrollmom.reset(e.clientX, e.clientY);
  866. if (!D.cantouch && !this.istouchcapable && !D.hasmstouch) {
  867. var g = (a) ? /INPUT|SELECT|TEXTAREA/i.test(a.nodeName) : false;
  868. if (!g) {
  869. if (!C.ispage && D.hasmousecapture) a.setCapture();
  870. return C.cancelEvent(e)
  871. }
  872. if (/SUBMIT|CANCEL|BUTTON/i.test($(a).attr('type'))) {
  873. pc = {
  874. "tg": a,
  875. "click": false
  876. };
  877. C.preventclick = pc
  878. }
  879. }
  880. }
  881. };
  882. C.ontouchend = function(e) {
  883. if (e.pointerType && e.pointerType != 2) return false;
  884. if (C.rail.drag && (C.rail.drag.pt == 2)) {
  885. C.scrollmom.doMomentum();
  886. C.rail.drag = false;
  887. if (C.hasmoving) {
  888. C.hasmoving = false;
  889. C.lastmouseup = true;
  890. C.hideCursor();
  891. if (D.hasmousecapture) document.releaseCapture();
  892. if (!D.cantouch) return C.cancelEvent(e)
  893. }
  894. }
  895. };
  896. var x = (C.opt.touchbehavior && C.isiframe && !D.hasmousecapture);
  897. C.ontouchmove = function(e, a) {
  898. if (e.pointerType && e.pointerType != 2) return false;
  899. if (C.rail.drag && (C.rail.drag.pt == 2)) {
  900. if (D.cantouch && (typeof e.original == "undefined")) return true;
  901. C.hasmoving = true;
  902. if (C.preventclick && !C.preventclick.click) {
  903. C.preventclick.click = C.preventclick.tg.onclick || false;
  904. C.preventclick.tg.onclick = C.onpreventclick
  905. }
  906. var b = $.extend({
  907. "original": e
  908. },
  909. e);
  910. e = b;
  911. if (("changedTouches" in e)) {
  912. e.clientX = e.changedTouches[0].clientX;
  913. e.clientY = e.changedTouches[0].clientY
  914. }
  915. if (C.forcescreen) {
  916. var c = e;
  917. var e = {
  918. "original": (e.original) ? e.original: e
  919. };
  920. e.clientX = c.screenX;
  921. e.clientY = c.screenY
  922. }
  923. var d = ofy = 0;
  924. if (x && !a) {
  925. var f = C.win.position();
  926. d = -f.left;
  927. ofy = -f.top
  928. }
  929. var g = e.clientY + ofy;
  930. var h = (g - C.rail.drag.y);
  931. var i = C.rail.drag.st - h;
  932. if (C.ishwscroll && C.opt.bouncescroll) {
  933. if (i < 0) {
  934. i = Math.round(i / 2)
  935. } else if (i > C.page.maxh) {
  936. i = C.page.maxh + Math.round((i - C.page.maxh) / 2)
  937. }
  938. } else {
  939. if (i < 0) {
  940. i = 0;
  941. g = 0
  942. }
  943. if (i > C.page.maxh) {
  944. i = C.page.maxh;
  945. g = 0
  946. }
  947. }
  948. var j = e.clientX + d;
  949. if (C.railh && C.railh.scrollable) {
  950. var k = (j - C.rail.drag.x);
  951. var l = C.rail.drag.sl - k;
  952. if (C.ishwscroll && C.opt.bouncescroll) {
  953. if (l < 0) {
  954. l = Math.round(l / 2)
  955. } else if (l > C.page.maxw) {
  956. l = C.page.maxw + Math.round((l - C.page.maxw) / 2)
  957. }
  958. } else {
  959. if (l < 0) {
  960. l = 0;
  961. j = 0
  962. }
  963. if (l > C.page.maxw) {
  964. l = C.page.maxw;
  965. j = 0
  966. }
  967. }
  968. }
  969. C.synched("touchmove",
  970. function() {
  971. try {
  972. if (C.me.is(":visible") === false) return
  973. } catch(e) {}
  974. if (C.rail.drag && (C.rail.drag.pt == 2)) {
  975. if (C.prepareTransition) C.prepareTransition(0);
  976. if (C.rail.scrollable) C.setScrollTop(i);
  977. C.scrollmom.update(j, g);
  978. if (C.railh && C.railh.scrollable) {
  979. C.setScrollLeft(l);
  980. C.showCursor(i, l)
  981. } else {
  982. C.showCursor(i)
  983. }
  984. if (D.isie10) document.selection.clear()
  985. }
  986. });
  987. if (!D.ischrome && !C.istouchcapable) return C.cancelEvent(e)
  988. }
  989. }
  990. }
  991. if (D.cantouch || C.opt.touchbehavior) {
  992. C.onpreventclick = function(e) {
  993. if (C.preventclick) {
  994. C.preventclick.tg.onclick = C.preventclick.click;
  995. C.preventclick = false;
  996. return C.cancelEvent(e)
  997. }
  998. };
  999. C.onmousedown = C.ontouchstart;
  1000. C.onmouseup = C.ontouchend;
  1001. C.onclick = (D.isios) ? false: function(e) {
  1002. if (C.lastmouseup) {
  1003. C.lastmouseup = false;
  1004. return C.cancelEvent(e)
  1005. } else {
  1006. return true
  1007. }
  1008. };
  1009. C.onmousemove = C.ontouchmove;
  1010. if (D.cursorgrabvalue) {
  1011. C.css((C.ispage) ? C.doc: C.win, {
  1012. 'cursor': D.cursorgrabvalue
  1013. });
  1014. C.css(C.rail, {
  1015. 'cursor': D.cursorgrabvalue
  1016. })
  1017. }
  1018. } else {
  1019. C.onmousedown = function(e, a) {
  1020. if (C.rail.drag && C.rail.drag.pt != 1) return;
  1021. if (C.locked) return C.cancelEvent(e);
  1022. C.cancelScroll();
  1023. C.rail.drag = {
  1024. x: e.clientX,
  1025. y: e.clientY,
  1026. sx: C.scroll.x,
  1027. sy: C.scroll.y,
  1028. pt: 1,
  1029. hr: ( !! a)
  1030. };
  1031. var b = C.getTarget(e);
  1032. if (!C.ispage && D.hasmousecapture) b.setCapture();
  1033. if (C.isiframe && !D.hasmousecapture) {
  1034. C.saved["csspointerevents"] = C.doc.css("pointer-events");
  1035. C.css(C.doc, {
  1036. "pointer-events": "none"
  1037. })
  1038. }
  1039. return C.cancelEvent(e)
  1040. };
  1041. C.onmouseup = function(e) {
  1042. if (C.rail.drag) {
  1043. if (D.hasmousecapture) document.releaseCapture();
  1044. if (C.isiframe && !D.hasmousecapture) C.doc.css("pointer-events", C.saved["csspointerevents"]);
  1045. if (C.rail.drag.pt != 1) return;
  1046. C.rail.drag = false;
  1047. return C.cancelEvent(e)
  1048. }
  1049. };
  1050. C.onmousemove = function(e) {
  1051. if (C.rail.drag) {
  1052. if (C.rail.drag.pt != 1) return;
  1053. if (D.ischrome && e.which == 0) return C.onmouseup(e);
  1054. C.cursorfreezed = true;
  1055. if (C.rail.drag.hr) {
  1056. C.scroll.x = C.rail.drag.sx + (e.clientX - C.rail.drag.x);
  1057. if (C.scroll.x < 0) C.scroll.x = 0;
  1058. var a = C.scrollvaluemaxw;
  1059. if (C.scroll.x > a) C.scroll.x = a
  1060. } else {
  1061. C.scroll.y = C.rail.drag.sy + (e.clientY - C.rail.drag.y);
  1062. if (C.scroll.y < 0) C.scroll.y = 0;
  1063. var b = C.scrollvaluemax;
  1064. if (C.scroll.y > b) C.scroll.y = b
  1065. }
  1066. C.synched('mousemove',
  1067. function() {
  1068. try {
  1069. if (C.me.is(":visible") === false) return
  1070. } catch(e) {}
  1071. if (C.rail.drag && (C.rail.drag.pt == 1)) {
  1072. C.showCursor();
  1073. if (C.rail.drag.hr) C.doScrollLeft(Math.round(C.scroll.x * C.scrollratio.x));
  1074. else C.doScrollTop(Math.round(C.scroll.y * C.scrollratio.y))
  1075. }
  1076. });
  1077. return C.cancelEvent(e)
  1078. } else {
  1079. C.checkarea = true
  1080. }
  1081. }
  1082. }
  1083. if (D.cantouch || C.opt.touchbehavior) {
  1084. C.bind(C.win, "mousedown", C.onmousedown)
  1085. }
  1086. if (D.hasmstouch) {
  1087. C.css(C.rail, {
  1088. '-ms-touch-action': 'none'
  1089. });
  1090. C.css(C.cursor, {
  1091. '-ms-touch-action': 'none'
  1092. });
  1093. C.bind(C.win, "MSPointerDown", C.ontouchstart);
  1094. C.bind(document, "MSPointerUp", C.ontouchend);
  1095. C.bind(document, "MSPointerMove", C.ontouchmove);
  1096. C.bind(C.cursor, "MSGestureHold",
  1097. function(e) {
  1098. e.preventDefault()
  1099. });
  1100. C.bind(C.cursor, "contextmenu",
  1101. function(e) {
  1102. e.preventDefault()
  1103. })
  1104. }
  1105. if (this.istouchcapable) {
  1106. C.bind(C.win, "touchstart", C.ontouchstart);
  1107. C.bind(document, "touchend", C.ontouchend);
  1108. C.bind(document, "touchcancel", C.ontouchend);
  1109. C.bind(document, "touchmove", C.ontouchmove)
  1110. }
  1111. C.bind(C.cursor, "mousedown", C.onmousedown);
  1112. C.bind(C.cursor, "mouseup", C.onmouseup);
  1113. if (C.railh) {
  1114. C.bind(C.cursorh, "mousedown",
  1115. function(e) {
  1116. C.onmousedown(e, true)
  1117. });
  1118. C.bind(C.cursorh, "mouseup",
  1119. function(e) {
  1120. if (C.rail.drag && C.rail.drag.pt == 2) return;
  1121. C.rail.drag = false;
  1122. C.hasmoving = false;
  1123. C.hideCursor();
  1124. if (D.hasmousecapture) document.releaseCapture();
  1125. return C.cancelEvent(e)
  1126. })
  1127. }
  1128. C.bind(document, "mouseup", C.onmouseup);
  1129. if (D.hasmousecapture) C.bind(C.win, "mouseup", C.onmouseup);
  1130. C.bind(document, "mousemove", C.onmousemove);
  1131. if (C.onclick) C.bind(document, "click", C.onclick);
  1132. if (!D.cantouch && !C.opt.touchbehavior) {
  1133. C.jqbind(C.rail, "mouseenter",
  1134. function() {
  1135. try {
  1136. if (C.me.is(":visible") === false) return
  1137. } catch(e) {}
  1138. if (C.canshowonmouseevent) C.showCursor();
  1139. C.rail.active = true
  1140. });
  1141. C.jqbind(C.rail, "mouseleave",
  1142. function() {
  1143. C.rail.active = false;
  1144. if (!C.rail.drag) C.hideCursor()
  1145. });
  1146. if (C.opt.sensitiverail) {
  1147. C.bind(C.rail, "click",
  1148. function(e) {
  1149. C.doRailClick(e, false, false)
  1150. });
  1151. C.bind(C.rail, "dblclick",
  1152. function(e) {
  1153. C.doRailClick(e, true, false)
  1154. });
  1155. C.bind(C.cursor, "click",
  1156. function(e) {
  1157. C.cancelEvent(e)
  1158. });
  1159. C.bind(C.cursor, "dblclick",
  1160. function(e) {
  1161. C.cancelEvent(e)
  1162. })
  1163. }
  1164. if (C.railh) {
  1165. C.jqbind(C.railh, "mouseenter",
  1166. function() {
  1167. try {
  1168. if (C.me.is(":visible") === false) return
  1169. } catch(e) {}
  1170. if (C.canshowonmouseevent) C.showCursor();
  1171. C.rail.active = true
  1172. });
  1173. C.jqbind(C.railh, "mouseleave",
  1174. function() {
  1175. C.rail.active = false;
  1176. if (!C.rail.drag) C.hideCursor()
  1177. });
  1178. if (C.opt.sensitiverail) {
  1179. C.bind(C.railh, "click",
  1180. function(e) {
  1181. C.doRailClick(e, false, true)
  1182. });
  1183. C.bind(C.railh, "dblclick",
  1184. function(e) {
  1185. C.doRailClick(e, true, true)
  1186. });
  1187. C.bind(C.cursorh, "click",
  1188. function(e) {
  1189. C.cancelEvent(e)
  1190. });
  1191. C.bind(C.cursorh, "dblclick",
  1192. function(e) {
  1193. C.cancelEvent(e)
  1194. })
  1195. }
  1196. }
  1197. if (C.zoom) {
  1198. C.jqbind(C.zoom, "mouseenter",
  1199. function() {
  1200. try {
  1201. if (C.me.is(":visible") === false) return
  1202. } catch(e) {}
  1203. if (C.canshowonmouseevent) C.showCursor();
  1204. C.rail.active = true
  1205. });
  1206. C.jqbind(C.zoom, "mouseleave",
  1207. function() {
  1208. C.rail.active = false;
  1209. if (!C.rail.drag) C.hideCursor()
  1210. })
  1211. }
  1212. }
  1213. if (C.opt.enablemousewheel) {
  1214. if (!C.isiframe) C.bind((D.isie && C.ispage) ? document: C.docscroll, "mousewheel", C.onmousewheel);
  1215. C.bind(C.rail, "mousewheel", C.onmousewheel);
  1216. if (C.railh) C.bind(C.railh, "mousewheel", C.onmousewheelhr)
  1217. }
  1218. if (!C.ispage && !D.cantouch && !(/HTML|BODY/.test(C.win[0].nodeName))) {
  1219. if (!C.win.attr("tabindex")) C.win.attr({
  1220. "tabindex": J++
  1221. });
  1222. C.jqbind(C.win, "focus",
  1223. function(e) {
  1224. try {
  1225. if (C.me.is(":visible") === false) return
  1226. } catch(e) {}
  1227. G = (C.getTarget(e)).id || true;
  1228. C.hasfocus = true;
  1229. if (C.canshowonmouseevent) C.noticeCursor()
  1230. });
  1231. C.jqbind(C.win, "blur",
  1232. function(e) {
  1233. G = false;
  1234. C.hasfocus = false
  1235. });
  1236. C.jqbind(C.win, "mouseenter",
  1237. function(e) {
  1238. try {
  1239. if (C.me.is(":visible") === false) return
  1240. } catch(e) {}
  1241. H = (C.getTarget(e)).id || true;
  1242. C.hasmousefocus = true;
  1243. if (C.canshowonmouseevent) C.noticeCursor()
  1244. });
  1245. C.jqbind(C.win, "mouseleave",
  1246. function() {
  1247. H = false;
  1248. C.hasmousefocus = false
  1249. })
  1250. }
  1251. }
  1252. C.onkeypress = function(e) {
  1253. if (C.locked && C.page.maxh == 0) return true;
  1254. e = (e) ? e: window.e;
  1255. var a = C.getTarget(e);
  1256. if (a && /INPUT|TEXTAREA|SELECT|OPTION/.test(a.nodeName)) {
  1257. var b = a.getAttribute('type') || a.type || false;
  1258. if ((!b) || !(/submit|button|cancel/i.tp)) return true
  1259. }
  1260. if (C.hasfocus || (C.hasmousefocus && !G) || (C.ispage && !G && !H)) {
  1261. var c = e.keyCode;
  1262. if (C.locked && c != 27) return C.cancelEvent(e);
  1263. var d = e.ctrlKey || false;
  1264. var f = e.shiftKey || false;
  1265. var g = false;
  1266. switch (c) {
  1267. case 38:
  1268. case 63233:
  1269. C.doScrollBy(24 * 3);
  1270. g = true;
  1271. break;
  1272. case 40:
  1273. case 63235:
  1274. C.doScrollBy( - 24 * 3);
  1275. g = true;
  1276. break;
  1277. case 37:
  1278. case 63232:
  1279. if (C.railh) { (d) ? C.doScrollLeft(0) : C.doScrollLeftBy(24 * 3);
  1280. g = true
  1281. }
  1282. break;
  1283. case 39:
  1284. case 63234:
  1285. if (C.railh) { (d) ? C.doScrollLeft(C.page.maxw) : C.doScrollLeftBy( - 24 * 3);
  1286. g = true
  1287. }
  1288. break;
  1289. case 33:
  1290. case 63276:
  1291. C.doScrollBy(C.view.h);
  1292. g = true;
  1293. break;
  1294. case 34:
  1295. case 63277:
  1296. C.doScrollBy( - C.view.h);
  1297. g = true;
  1298. break;
  1299. case 36:
  1300. case 63273:
  1301. (C.railh && d) ? C.doScrollPos(0, 0) : C.doScrollTo(0);
  1302. g = true;
  1303. break;
  1304. case 35:
  1305. case 63275:
  1306. (C.railh && d) ? C.doScrollPos(C.page.maxw, C.page.maxh) : C.doScrollTo(C.page.maxh);
  1307. g = true;
  1308. break;
  1309. case 32:
  1310. if (C.opt.spacebarenabled) { (f) ? C.doScrollBy(C.view.h) : C.doScrollBy( - C.view.h);
  1311. g = true
  1312. }
  1313. break;
  1314. case 27:
  1315. if (C.zoomactive) {
  1316. C.doZoom();
  1317. g = true
  1318. }
  1319. break
  1320. }
  1321. if (g) return C.cancelEvent(e)
  1322. }
  1323. };
  1324. if (C.opt.enablekeyboard) C.bind(document, (D.isopera && !D.isopera12) ? "keypress": "keydown", C.onkeypress);
  1325. C.bind(window, 'resize', C.resize);
  1326. C.bind(window, 'orientationchange', C.resize);
  1327. C.bind(window, "load", C.resize);
  1328. if (D.ischrome && !C.ispage && !C.haswrapper) {
  1329. var y = C.win.attr("style");
  1330. var z = parseFloat(C.win.css("width")) + 1;
  1331. C.win.css('width', z);
  1332. C.synched("chromefix",
  1333. function() {
  1334. C.win.attr("style", y)
  1335. })
  1336. }
  1337. C.onAttributeChange = function(e) {
  1338. C.lazyResize()
  1339. };
  1340. if (!C.ispage && !C.haswrapper) {
  1341. if ("WebKitMutationObserver" in window) {
  1342. C.observer = new WebKitMutationObserver(function(a) {
  1343. a.forEach(C.onAttributeChange)
  1344. });
  1345. C.observer.observe(C.win[0], {
  1346. attributes: true,
  1347. subtree: false
  1348. })
  1349. } else {
  1350. C.bind(C.win, (D.isie && !D.isie9) ? "propertychange": "DOMAttrModified", C.onAttributeChange);
  1351. if (D.isie9) C.win[0].attachEvent("onpropertychange", C.onAttributeChange)
  1352. }
  1353. }
  1354. if (!C.ispage && C.opt.boxzoom) C.bind(window, "resize", C.resizeZoom);
  1355. if (C.istextarea) C.bind(C.win, "mouseup", C.resize);
  1356. C.resize()
  1357. }
  1358. if (this.doc[0].nodeName == 'IFRAME') {
  1359. function oniframeload(e) {
  1360. C.iframexd = false;
  1361. try {
  1362. var b = 'contentDocument' in this ? this.contentDocument: this.contentWindow.document;
  1363. var a = b.domain
  1364. } catch(e) {
  1365. C.iframexd = true;
  1366. b = false
  1367. };
  1368. if (C.iframexd) {
  1369. if ("console" in window) console.log('NiceScroll error: policy restriced iframe');
  1370. return true
  1371. }
  1372. C.forcescreen = true;
  1373. if (C.isiframe) {
  1374. C.iframe = {
  1375. "doc": $(b),
  1376. "html": C.doc.contents().find('html')[0],
  1377. "body": C.doc.contents().find('body')[0]
  1378. };
  1379. C.getContentSize = function() {
  1380. return {
  1381. w: Math.max(C.iframe.html.scrollWidth, C.iframe.body.scrollWidth),
  1382. h: Math.max(C.iframe.html.scrollHeight, C.iframe.body.scrollHeight)
  1383. }
  1384. };
  1385. C.docscroll = $(C.iframe.body)
  1386. }
  1387. if (!D.isios && C.opt.iframeautoresize && !C.isiframe) {
  1388. C.win.scrollTop(0);
  1389. C.doc.height("");
  1390. var c = Math.max(b.getElementsByTagName('html')[0].scrollHeight, b.body.scrollHeight);
  1391. C.doc.height(c)
  1392. }
  1393. C.resize();
  1394. if (D.isie7) C.css($(C.iframe.html), {
  1395. 'overflow-y': 'hidden'
  1396. });
  1397. C.css($(C.iframe.body), {
  1398. 'overflow-y': 'hidden'
  1399. });
  1400. if ('contentWindow' in this) {
  1401. C.bind(this.contentWindow, "scroll", C.onscroll)
  1402. } else {
  1403. C.bind(b, "scroll", C.onscroll)
  1404. }
  1405. if (C.opt.enablemousewheel) {
  1406. C.bind(b, "mousewheel", C.onmousewheel)
  1407. }
  1408. if (C.opt.enablekeyboard) C.bind(b, (D.isopera) ? "keypress": "keydown", C.onkeypress);
  1409. if (D.cantouch || C.opt.touchbehavior) {
  1410. C.bind(b, "mousedown", C.onmousedown);
  1411. C.bind(b, "mousemove",
  1412. function(e) {
  1413. C.onmousemove(e, true)
  1414. });
  1415. if (D.cursorgrabvalue) C.css($(b.body), {
  1416. 'cursor': D.cursorgrabvalue
  1417. })
  1418. }
  1419. C.bind(b, "mouseup", C.onmouseup);
  1420. if (C.zoom) {
  1421. if (C.opt.dblclickzoom) C.bind(b, 'dblclick', C.doZoom);
  1422. if (C.ongesturezoom) C.bind(b, "gestureend", C.ongesturezoom)
  1423. }
  1424. };
  1425. if (this.doc[0].readyState && this.doc[0].readyState == "complete") {
  1426. setTimeout(function() {
  1427. oniframeload.call(C.doc[0], false)
  1428. },
  1429. 500)
  1430. }
  1431. C.bind(this.doc, "load", oniframeload)
  1432. }
  1433. };
  1434. this.showCursor = function(a, b) {
  1435. if (C.cursortimeout) {
  1436. clearTimeout(C.cursortimeout);
  1437. C.cursortimeout = 0
  1438. }
  1439. if (!C.rail) return;
  1440. try {
  1441. var c = C.me.offset().top;
  1442. if (C.me.scrollParent && C.me.scrollParent().length > 0) {
  1443. if (C.rail.parent().get(0).tagName != "BODY") {
  1444. c = c - C.me.scrollParent().offset().top;
  1445. c = c + C.me.scrollParent().offset().scrollTop()
  1446. }
  1447. }
  1448. if (C.rail.parent().get(0).tagName != "BODY") {
  1449. c = c - F(".e8_boxhead").height()
  1450. }
  1451. C.rail.css("top", c);
  1452. if (!C.rail.data("__resize")) {
  1453. C.resize();
  1454. C.rail.data("__resize", true)
  1455. }
  1456. } catch(e) {
  1457. if (window.console) console.log(e, "jquery.nicescroll.js#showCursor")
  1458. }
  1459. if (C.autohidedom) {
  1460. C.autohidedom.stop().css({
  1461. opacity: C.opt.cursoropacitymax
  1462. });
  1463. C.cursoractive = true
  1464. }
  1465. if ((typeof a != "undefined") && (a !== false)) {
  1466. C.scroll.y = Math.round(a * 1 / C.scrollratio.y)
  1467. }
  1468. if (typeof b != "undefined") {
  1469. C.scroll.x = Math.round(b * 1 / C.scrollratio.x)
  1470. }
  1471. C.cursor.css({
  1472. height: C.cursorheight,
  1473. top: C.scroll.y
  1474. });
  1475. if (C.cursorh) { (!C.rail.align && C.rail.visibility) ? C.cursorh.css({
  1476. width: C.cursorwidth,
  1477. left: C.scroll.x + C.rail.width
  1478. }) : C.cursorh.css({
  1479. width: C.cursorwidth,
  1480. left: C.scroll.x
  1481. });
  1482. C.cursoractive = true
  1483. }
  1484. if (C.zoom) C.zoom.stop().css({
  1485. opacity: C.opt.cursoropacitymax
  1486. })
  1487. };
  1488. this.hideCursor = function(a) {
  1489. if (C.cursortimeout) return;
  1490. if (!C.rail) return;
  1491. if (!C.autohidedom) return;
  1492. if (a) {
  1493. C.cursortimeout = setTimeout(function() {
  1494. if (!C.rail.active || !C.showonmouseevent) {
  1495. C.autohidedom.stop().animate({
  1496. opacity: C.opt.cursoropacitymin
  1497. });
  1498. if (C.zoom) C.zoom.stop().animate({
  1499. opacity: C.opt.cursoropacitymin
  1500. });
  1501. C.cursoractive = false
  1502. }
  1503. C.cursortimeout = 0
  1504. },
  1505. a || 400)
  1506. } else {
  1507. if (!C.rail.active || !C.showonmouseevent) {
  1508. C.autohidedom.stop().animate({
  1509. opacity: C.opt.cursoropacitymin
  1510. });
  1511. if (C.zoom) C.zoom.stop().animate({
  1512. opacity: C.opt.cursoropacitymin
  1513. });
  1514. C.cursoractive = false
  1515. }
  1516. C.cursortimeout = 0
  1517. }
  1518. };
  1519. this.noticeCursor = function(a, b, c) {
  1520. C.showCursor(b, c);
  1521. if (!C.rail.active) C.hideCursor(a)
  1522. };
  1523. this.getContentSize = (C.ispage) ?
  1524. function() {
  1525. return {
  1526. w: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
  1527. h: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight)
  1528. }
  1529. }: (C.haswrapper) ?
  1530. function() {
  1531. return {
  1532. w: C.doc.outerWidth() + parseInt(C.win.css('paddingLeft')) + parseInt(C.win.css('paddingRight')),
  1533. h: C.doc.outerHeight() + parseInt(C.win.css('paddingTop')) + parseInt(C.win.css('paddingBottom'))
  1534. }
  1535. }: function() {
  1536. return {
  1537. w: C.docscroll[0].scrollWidth,
  1538. h: C.docscroll[0].scrollHeight
  1539. }
  1540. };
  1541. this.onResize = function(e, a) {
  1542. try {
  1543. if (C.me.is(":visible") === false) return
  1544. } catch(e) {}
  1545. if (!C.win) return false;
  1546. if (!C.haswrapper && !C.ispage) {
  1547. if (C.win.css('display') == 'none') {
  1548. if (C.visibility) C.hideRail().hideRailHr();
  1549. return false
  1550. } else {
  1551. if (!C.hidden && !C.visibility) C.showRail().showRailHr()
  1552. }
  1553. }
  1554. var b = C.page.maxh;
  1555. var c = C.page.maxw;
  1556. var d = {
  1557. h: C.view.h,
  1558. w: C.view.w
  1559. };
  1560. C.view = {
  1561. w: (C.ispage) ? C.win.width() : parseInt(C.win[0].clientWidth),
  1562. h: (C.ispage) ? C.win.height() : parseInt(C.win[0].clientHeight)
  1563. };
  1564. C.page = (a) ? a: C.getContentSize();
  1565. C.page.maxh = Math.max(0, C.page.h - C.view.h);
  1566. C.page.maxw = Math.max(0, C.page.w - C.view.w);
  1567. if ((C.page.maxh == b) && (C.page.maxw == c) && (C.view.w == d.w)) {
  1568. if (!C.ispage) {
  1569. var f = C.win.offset();
  1570. if (C.lastposition) {
  1571. var g = C.lastposition;
  1572. if ((g.top == f.top) && (g.left == f.left)) return C
  1573. }
  1574. C.lastposition = f
  1575. } else {
  1576. return C
  1577. }
  1578. }
  1579. if (C.page.maxh == 0) {
  1580. C.hideRail();
  1581. C.scrollvaluemax = 0;
  1582. C.scroll.y = 0;
  1583. C.scrollratio.y = 0;
  1584. C.cursorheight = 0;
  1585. C.setScrollTop(0);
  1586. C.rail.scrollable = false
  1587. } else {
  1588. C.rail.scrollable = true
  1589. }
  1590. if (C.page.maxw == 0) {
  1591. C.hideRailHr();
  1592. C.scrollvaluemaxw = 0;
  1593. C.scroll.x = 0;
  1594. C.scrollratio.x = 0;
  1595. C.cursorwidth = 0;
  1596. C.setScrollLeft(0);
  1597. C.railh.scrollable = false
  1598. } else {
  1599. C.railh.scrollable = true
  1600. }
  1601. C.locked = (C.page.maxh == 0) && (C.page.maxw == 0);
  1602. if (C.locked) {
  1603. if (!C.ispage) C.updateScrollBar(C.view);
  1604. return false
  1605. }
  1606. if (!C.hidden && !C.visibility) {
  1607. C.showRail().showRailHr()
  1608. } else if (!C.hidden && !C.railh.visibility) C.showRailHr();
  1609. if (C.istextarea && C.win.css('resize') && C.win.css('resize') != 'none') C.view.h -= 20;
  1610. if (!C.ispage) C.updateScrollBar(C.view);
  1611. C.cursorheight = Math.min(C.view.h, Math.round(C.view.h * (C.view.h / C.page.h)));
  1612. C.cursorheight = (C.opt.cursorfixedheight) ? C.opt.cursorfixedheight: Math.max(C.opt.cursorminheight, C.cursorheight);
  1613. C.cursorwidth = Math.min(C.view.w, Math.round(C.view.w * (C.view.w / C.page.w)));
  1614. C.cursorwidth = (C.opt.cursorfixedheight) ? C.opt.cursorfixedheight: Math.max(C.opt.cursorminheight, C.cursorwidth);
  1615. C.scrollvaluemax = C.view.h - C.cursorheight - C.cursor.hborder;
  1616. if (C.railh) {
  1617. C.railh.width = (C.page.maxh > 0) ? (C.view.w - C.rail.width) : C.view.w;
  1618. C.scrollvaluemaxw = C.railh.width - C.cursorwidth - C.cursorh.wborder
  1619. }
  1620. C.scrollratio = {
  1621. x: (C.page.maxw / C.scrollvaluemaxw),
  1622. y: (C.page.maxh / C.scrollvaluemax)
  1623. };
  1624. var h = C.getScrollTop();
  1625. if (h > C.page.maxh) {
  1626. C.doScrollTop(C.page.maxh)
  1627. } else {
  1628. C.scroll.y = Math.round(C.getScrollTop() * (1 / C.scrollratio.y));
  1629. C.scroll.x = Math.round(C.getScrollLeft() * (1 / C.scrollratio.x));
  1630. if (C.cursoractive) C.noticeCursor()
  1631. }
  1632. if (C.scroll.y && (C.getScrollTop() == 0)) C.doScrollTo(Math.floor(C.scroll.y * C.scrollratio.y));
  1633. return C
  1634. };
  1635. this.resize = function() {
  1636. C.delayed('resize', C.onResize, 30);
  1637. return C
  1638. };
  1639. this.lazyResize = function() {
  1640. C.delayed('resize', C.resize, 250)
  1641. };
  1642. this._bind = function(a, b, c, d) {
  1643. C.events.push({
  1644. e: a,
  1645. n: b,
  1646. f: c,
  1647. b: d,
  1648. q: false
  1649. });
  1650. if (a.addEventListener) {
  1651. a.addEventListener(b, c, d || false)
  1652. } else if (a.attachEvent) {
  1653. a.attachEvent("on" + b, c)
  1654. } else {
  1655. a["on" + b] = c
  1656. }
  1657. };
  1658. this.jqbind = function(a, b, c) {
  1659. C.events.push({
  1660. e: a,
  1661. n: b,
  1662. f: c,
  1663. q: true
  1664. });
  1665. $(a).bind(b, c)
  1666. };
  1667. this.bind = function(b, c, d, f) {
  1668. var g = ("jquery" in b) ? b[0] : b;
  1669. if (g.addEventListener) {
  1670. if (D.cantouch && /mouseup|mousedown|mousemove/.test(c)) {
  1671. var h = (c == 'mousedown') ? 'touchstart': (c == 'mouseup') ? 'touchend': 'touchmove';
  1672. C._bind(g, h,
  1673. function(e) {
  1674. if (e.touches) {
  1675. if (e.touches.length < 2) {
  1676. var a = (e.touches.length) ? e.touches[0] : e;
  1677. a.original = e;
  1678. d.call(this, a)
  1679. }
  1680. } else if (e.changedTouches) {
  1681. var a = e.changedTouches[0];
  1682. a.original = e;
  1683. d.call(this, a)
  1684. }
  1685. },
  1686. f || false)
  1687. }
  1688. C._bind(g, c, d, f || false);
  1689. if (c == 'mousewheel') C._bind(g, "DOMMouseScroll", d, f || false);
  1690. if (D.cantouch && c == "mouseup") C._bind(g, "touchcancel", d, f || false)
  1691. } else {
  1692. C._bind(g, c,
  1693. function(e) {
  1694. e = e || window.event || false;
  1695. if (e) {
  1696. if (e.srcElement) e.target = e.srcElement
  1697. }
  1698. return ((d.call(g, e) === false) || f === false) ? C.cancelEvent(e) : true
  1699. })
  1700. }
  1701. };
  1702. this._unbind = function(a, b, c, d) {
  1703. if (a.removeEventListener) {
  1704. a.removeEventListener(b, c, d)
  1705. } else if (a.detachEvent) {
  1706. a.detachEvent('on' + b, c)
  1707. } else {
  1708. a['on' + b] = false
  1709. }
  1710. };
  1711. this.unbindAll = function() {
  1712. for (var a = 0; a < C.events.length; a++) {
  1713. var r = C.events[a]; (r.q) ? r.e.unbind(r.n, r.f) : C._unbind(r.e, r.n, r.f, r.b)
  1714. }
  1715. };
  1716. this.cancelEvent = function(e) {
  1717. var e = (e.original) ? e.original: (e) ? e: window.event || false;
  1718. if (!e) return false;
  1719. if (e.preventDefault) e.preventDefault();
  1720. if (e.stopPropagation) e.stopPropagation();
  1721. if (e.preventManipulation) e.preventManipulation();
  1722. e.cancelBubble = true;
  1723. e.cancel = true;
  1724. e.returnValue = false;
  1725. return false
  1726. };
  1727. this.stopPropagation = function(e) {
  1728. var e = (e.original) ? e.original: (e) ? e: window.event || false;
  1729. if (!e) return false;
  1730. if (e.stopPropagation) return e.stopPropagation();
  1731. if (e.cancelBubble) e.cancelBubble = true;
  1732. return false
  1733. };
  1734. this.showRail = function() {
  1735. if ((C.page.maxh != 0) && (C.ispage || C.win.css('display') != 'none')) {
  1736. C.visibility = true;
  1737. C.rail.visibility = true;
  1738. C.rail.css('display', 'block')
  1739. }
  1740. return C
  1741. };
  1742. this.showRailHr = function() {
  1743. if (!C.railh) return C;
  1744. if ((C.page.maxw != 0) && (C.ispage || C.win.css('display') != 'none')) {
  1745. C.railh.visibility = true;
  1746. C.railh.css('display', 'block')
  1747. }
  1748. return C
  1749. };
  1750. this.hideRail = function() {
  1751. C.visibility = false;
  1752. C.rail.visibility = false;
  1753. C.rail.css('display', 'none');
  1754. return C
  1755. };
  1756. this.hideRailHr = function() {
  1757. if (!C.railh) return C;
  1758. C.railh.visibility = false;
  1759. C.railh.css('display', 'none');
  1760. return C
  1761. };
  1762. this.show = function() {
  1763. C.hidden = false;
  1764. C.locked = false;
  1765. return C.showRail().showRailHr()
  1766. };
  1767. this.hide = function() {
  1768. C.hidden = true;
  1769. C.locked = true;
  1770. return C.hideRail().hideRailHr()
  1771. };
  1772. this.toggle = function() {
  1773. return (C.hidden) ? C.show() : C.hide()
  1774. };
  1775. this.remove = function() {
  1776. C.stop();
  1777. if (C.cursortimeout) clearTimeout(C.cursortimeout);
  1778. C.doZoomOut();
  1779. C.unbindAll();
  1780. if (C.observer !== false) C.observer.disconnect();
  1781. C.events = [];
  1782. if (C.cursor) {
  1783. C.cursor.remove();
  1784. C.cursor = null
  1785. }
  1786. if (C.cursorh) {
  1787. C.cursorh.remove();
  1788. C.cursorh = null
  1789. }
  1790. if (C.rail) {
  1791. C.rail.remove();
  1792. C.rail = null
  1793. }
  1794. if (C.railh) {
  1795. C.railh.remove();
  1796. C.railh = null
  1797. }
  1798. if (C.zoom) {
  1799. C.zoom.remove();
  1800. C.zoom = null
  1801. }
  1802. for (var a = 0; a < C.saved.css.length; a++) {
  1803. var d = C.saved.css[a];
  1804. d[0].css(d[1], (typeof d[2] == "undefined") ? '': d[2])
  1805. }
  1806. C.saved = false;
  1807. C.me.data('__nicescroll', '');
  1808. C.me = null;
  1809. C.doc = null;
  1810. C.docscroll = null;
  1811. C.win = null;
  1812. return C
  1813. };
  1814. this.scrollstart = function(a) {
  1815. this.onscrollstart = a;
  1816. return C
  1817. };
  1818. this.scrollend = function(a) {
  1819. this.onscrollend = a;
  1820. return C
  1821. };
  1822. this.scrollcancel = function(a) {
  1823. this.onscrollcancel = a;
  1824. return C
  1825. };
  1826. this.zoomin = function(a) {
  1827. this.onzoomin = a;
  1828. return C
  1829. };
  1830. this.zoomout = function(a) {
  1831. this.onzoomout = a;
  1832. return C
  1833. };
  1834. this.isScrollable = function(e) {
  1835. var a = (e.target) ? e.target: e;
  1836. while (a && (a.nodeType == 1) && !(/BODY|HTML/.test(a.nodeName))) {
  1837. var b = $(a);
  1838. var c = b.css('overflowY') || b.css('overflowX') || b.css('overflow') || '';
  1839. if (/scroll|auto/.test(c)) return (a.clientHeight != a.scrollHeight);
  1840. a = (a.parentNode) ? a.parentNode: false
  1841. }
  1842. return false
  1843. };
  1844. this.getViewport = function(a) {
  1845. var b = (a && a.parentNode) ? a.parentNode: false;
  1846. while (b && (b.nodeType == 1) && !(/BODY|HTML/.test(b.nodeName))) {
  1847. var c = $(b);
  1848. var d = c.css('overflowY') || c.css('overflowX') || c.css('overflow') || '';
  1849. if ((/scroll|auto/.test(d)) && (b.clientHeight != b.scrollHeight)) return c;
  1850. if (c.getNiceScroll().length > 0) return c;
  1851. b = (b.parentNode) ? b.parentNode: false
  1852. }
  1853. return false
  1854. };
  1855. function execScrollWheel(e, b) {
  1856. var c = 0;
  1857. var d = 0;
  1858. var f = 1;
  1859. if ("wheelDeltaY" in e) {
  1860. f = C.opt.mousescrollstep / (16 * 3);
  1861. c = Math.floor(e.wheelDeltaX * f);
  1862. d = Math.floor(e.wheelDeltaY * f);
  1863. if (d < 0) d = d + 1;
  1864. if (b && (c == 0) && d) {
  1865. c = d;
  1866. d = 0
  1867. }
  1868. } else {
  1869. var g = e.detail ? e.detail * -1 : e.wheelDelta / 40;
  1870. if (g) { (b) ? c = Math.floor(g * C.opt.mousescrollstep) : d = Math.floor(g * C.opt.mousescrollstep)
  1871. }
  1872. }
  1873. if (c) {
  1874. if (C.scrollmom) {
  1875. C.scrollmom.stop()
  1876. }
  1877. C.lastdeltax += c;
  1878. C.synched("mousewheelx",
  1879. function() {
  1880. var a = C.lastdeltax;
  1881. C.lastdeltax = 0;
  1882. if (!C.rail.drag) {
  1883. C.doScrollLeftBy(a)
  1884. }
  1885. })
  1886. }
  1887. if (d) {
  1888. if (C.scrollmom) {
  1889. C.scrollmom.stop()
  1890. }
  1891. C.lastdeltay += d;
  1892. C.synched("mousewheely",
  1893. function() {
  1894. var a = C.lastdeltay;
  1895. C.lastdeltay = 0;
  1896. if (!C.rail.drag) {
  1897. C.doScrollBy(a)
  1898. }
  1899. })
  1900. }
  1901. };
  1902. this.onmousewheel = function(e) {
  1903. if (C.locked) return true;
  1904. if (!C.rail.scrollable) {
  1905. if (C.railh && C.railh.scrollable) {
  1906. return C.onmousewheelhr(e)
  1907. } else {
  1908. return true
  1909. }
  1910. }
  1911. if (C.opt.preservenativescrolling && C.checkarea) {
  1912. C.checkarea = false;
  1913. C.nativescrollingarea = C.isScrollable(e)
  1914. }
  1915. if (C.nativescrollingarea) return true;
  1916. if (C.locked) return C.cancelEvent(e);
  1917. if (C.rail.drag) return C.cancelEvent(e);
  1918. execScrollWheel(e, false);
  1919. return C.cancelEvent(e)
  1920. };
  1921. this.onmousewheelhr = function(e) {
  1922. if (C.locked || !C.railh.scrollable) return true;
  1923. if (C.opt.preservenativescrolling && C.checkarea) {
  1924. C.checkarea = false;
  1925. C.nativescrollingarea = C.isScrollable(e)
  1926. }
  1927. if (C.nativescrollingarea) return true;
  1928. if (C.locked) return C.cancelEvent(e);
  1929. if (C.rail.drag) return C.cancelEvent(e);
  1930. execScrollWheel(e, true);
  1931. return C.cancelEvent(e)
  1932. };
  1933. this.stop = function() {
  1934. try {
  1935. if (C.me.is(":visible") === false) return
  1936. } catch(e) {}
  1937. C.cancelScroll();
  1938. if (C.scrollmon) C.scrollmon.stop();
  1939. C.cursorfreezed = false;
  1940. C.scroll.y = Math.round(C.getScrollTop() * (1 / C.scrollratio.y));
  1941. C.noticeCursor();
  1942. return C
  1943. };
  1944. this.getTransitionSpeed = function(a) {
  1945. var b = Math.round(C.opt.scrollspeed * 10);
  1946. var c = Math.min(b, Math.round((a / 20) * C.opt.scrollspeed));
  1947. return (c > 20) ? c: 0
  1948. };
  1949. if (!C.opt.smoothscroll) {
  1950. this.doScrollLeft = function(x, a) {
  1951. var y = C.getScrollTop();
  1952. C.doScrollPos(x, y, a)
  1953. };
  1954. this.doScrollTop = function(y, a) {
  1955. var x = C.getScrollLeft();
  1956. C.doScrollPos(x, y, a)
  1957. };
  1958. this.doScrollPos = function(x, y, a) {
  1959. var b = (x > C.page.maxw) ? C.page.maxw: x;
  1960. if (b < 0) b = 0;
  1961. var c = (y > C.page.maxh) ? C.page.maxh: y;
  1962. if (c < 0) c = 0;
  1963. C.synched('scroll',
  1964. function() {
  1965. C.setScrollTop(c);
  1966. C.setScrollLeft(b)
  1967. })
  1968. };
  1969. this.cancelScroll = function() {}
  1970. } else if (C.ishwscroll && D.hastransition && C.opt.usetransition) {
  1971. this.prepareTransition = function(a, b) {
  1972. var c = (b) ? ((a > 20) ? a: 0) : C.getTransitionSpeed(a);
  1973. var d = (c) ? D.prefixstyle + 'transform ' + c + 'ms ease-out': '';
  1974. if (!C.lasttransitionstyle || C.lasttransitionstyle != d) {
  1975. C.lasttransitionstyle = d;
  1976. C.doc.css(D.transitionstyle, d)
  1977. }
  1978. return c
  1979. };
  1980. this.doScrollLeft = function(x, a) {
  1981. var y = (C.scrollrunning) ? C.newscrolly: C.getScrollTop();
  1982. C.doScrollPos(x, y, a)
  1983. };
  1984. this.doScrollTop = function(y, a) {
  1985. var x = (C.scrollrunning) ? C.newscrollx: C.getScrollLeft();
  1986. C.doScrollPos(x, y, a)
  1987. };
  1988. this.doScrollPos = function(x, y, k) {
  1989. var l = C.getScrollTop();
  1990. var m = C.getScrollLeft();
  1991. if (((C.newscrolly - l) * (y - l) < 0) || ((C.newscrollx - m) * (x - m) < 0)) C.cancelScroll();
  1992. if (C.opt.bouncescroll == false) {
  1993. if (y < 0) y = 0;
  1994. else if (y > C.page.maxh) y = C.page.maxh;
  1995. if (x < 0) x = 0;
  1996. else if (x > C.page.maxw) x = C.page.maxw
  1997. }
  1998. if (x == C.newscrollx && y == C.newscrolly) return false;
  1999. C.newscrolly = y;
  2000. C.newscrollx = x;
  2001. C.newscrollspeed = k || false;
  2002. if (C.timer) return false;
  2003. C.timer = setTimeout(function() {
  2004. var a = C.getScrollTop();
  2005. var b = C.getScrollLeft();
  2006. var c = {};
  2007. c.x = x - b;
  2008. c.y = y - a;
  2009. c.px = b;
  2010. c.py = a;
  2011. var d = Math.round(Math.sqrt(Math.pow(c.x, 2) + Math.pow(c.y, 2)));
  2012. var f = (C.newscrollspeed) ? C.newscrollspeed: d;
  2013. var g = C.prepareTransition(f);
  2014. if (C.timerscroll && C.timerscroll.tm) clearInterval(C.timerscroll.tm);
  2015. if (g > 0) {
  2016. if (!C.scrollrunning && C.onscrollstart) {
  2017. var h = {
  2018. "type": "scrollstart",
  2019. "current": {
  2020. "x": b,
  2021. "y": a
  2022. },
  2023. "request": {
  2024. "x": x,
  2025. "y": y
  2026. },
  2027. "end": {
  2028. "x": C.newscrollx,
  2029. "y": C.newscrolly
  2030. },
  2031. "speed": g
  2032. };
  2033. C.onscrollstart.call(C, h)
  2034. }
  2035. if (D.transitionend) {
  2036. if (!C.scrollendtrapped) {
  2037. C.scrollendtrapped = true;
  2038. C.bind(C.doc, D.transitionend, C.onScrollEnd, false)
  2039. }
  2040. } else {
  2041. if (C.scrollendtrapped) clearTimeout(C.scrollendtrapped);
  2042. C.scrollendtrapped = setTimeout(C.onScrollEnd, g)
  2043. }
  2044. var i = a;
  2045. var j = b;
  2046. C.timerscroll = {
  2047. bz: new BezierClass(i, C.newscrolly, g, 0, 0, 0.58, 1),
  2048. bh: new BezierClass(j, C.newscrollx, g, 0, 0, 0.58, 1)
  2049. };
  2050. if (!C.cursorfreezed) C.timerscroll.tm = setInterval(function() {
  2051. try {
  2052. if (C.me.is(":visible") === false) return
  2053. } catch(e) {}
  2054. C.showCursor(C.getScrollTop(), C.getScrollLeft())
  2055. },
  2056. 60)
  2057. }
  2058. C.synched("doScroll-set",
  2059. function() {
  2060. C.timer = 0;
  2061. if (C.scrollendtrapped) C.scrollrunning = true;
  2062. C.setScrollTop(C.newscrolly);
  2063. C.setScrollLeft(C.newscrollx);
  2064. if (!C.scrollendtrapped) C.onScrollEnd()
  2065. })
  2066. },
  2067. 50)
  2068. };
  2069. this.cancelScroll = function() {
  2070. try {
  2071. if (C.me.is(":visible") === false) return
  2072. } catch(e) {}
  2073. if (!C.scrollendtrapped) return true;
  2074. var a = C.getScrollTop();
  2075. var b = C.getScrollLeft();
  2076. C.scrollrunning = false;
  2077. if (!D.transitionend) clearTimeout(D.transitionend);
  2078. C.scrollendtrapped = false;
  2079. C._unbind(C.doc, D.transitionend, C.onScrollEnd);
  2080. C.prepareTransition(0);
  2081. C.setScrollTop(a);
  2082. if (C.railh) C.setScrollLeft(b);
  2083. if (C.timerscroll && C.timerscroll.tm) clearInterval(C.timerscroll.tm);
  2084. C.timerscroll = false;
  2085. C.cursorfreezed = false;
  2086. C.showCursor(a, b);
  2087. return C
  2088. };
  2089. this.onScrollEnd = function() {
  2090. try {
  2091. if (C.me.is(":visible") === false) return
  2092. } catch(e) {};
  2093. if (C.scrollendtrapped) C._unbind(C.doc, D.transitionend, C.onScrollEnd);
  2094. C.scrollendtrapped = false;
  2095. C.prepareTransition(0);
  2096. if (C.timerscroll && C.timerscroll.tm) clearInterval(C.timerscroll.tm);
  2097. C.timerscroll = false;
  2098. var a = C.getScrollTop();
  2099. var b = C.getScrollLeft();
  2100. C.setScrollTop(a);
  2101. if (C.railh) C.setScrollLeft(b);
  2102. C.noticeCursor(false, a, b);
  2103. C.cursorfreezed = false;
  2104. if (a < 0) a = 0;
  2105. else if (a > C.page.maxh) a = C.page.maxh;
  2106. if (b < 0) b = 0;
  2107. else if (b > C.page.maxw) b = C.page.maxw;
  2108. if ((a != C.newscrolly) || (b != C.newscrollx)) return C.doScrollPos(b, a, C.opt.snapbackspeed);
  2109. if (C.onscrollend && C.scrollrunning) {
  2110. var c = {
  2111. "type": "scrollend",
  2112. "current": {
  2113. "x": b,
  2114. "y": a
  2115. },
  2116. "end": {
  2117. "x": C.newscrollx,
  2118. "y": C.newscrolly
  2119. }
  2120. };
  2121. C.onscrollend.call(C, c)
  2122. }
  2123. C.scrollrunning = false
  2124. }
  2125. } else {
  2126. this.doScrollLeft = function(x) {
  2127. var y = (C.scrollrunning) ? C.newscrolly: C.getScrollTop();
  2128. C.doScrollPos(x, y)
  2129. };
  2130. this.doScrollTop = function(y) {
  2131. var x = (C.scrollrunning) ? C.newscrollx: C.getScrollLeft();
  2132. C.doScrollPos(x, y)
  2133. };
  2134. this.doScrollPos = function(x, y) {
  2135. var y = ((typeof y == "undefined") || (y === false)) ? C.getScrollTop(true) : y;
  2136. if ((C.timer) && (C.newscrolly == y) && (C.newscrollx == x)) return true;
  2137. if (C.timer) N(C.timer);
  2138. C.timer = 0;
  2139. var g = C.getScrollTop();
  2140. var h = C.getScrollLeft();
  2141. if (((C.newscrolly - g) * (y - g) < 0) || ((C.newscrollx - h) * (x - h) < 0)) C.cancelScroll();
  2142. C.newscrolly = y;
  2143. C.newscrollx = x;
  2144. if (!C.bouncescroll || !C.rail.visibility) {
  2145. if (C.newscrolly < 0) {
  2146. C.newscrolly = 0
  2147. } else if (C.newscrolly > C.page.maxh) {
  2148. C.newscrolly = C.page.maxh
  2149. }
  2150. }
  2151. if (!C.bouncescroll || !C.railh.visibility) {
  2152. if (C.newscrollx < 0) {
  2153. C.newscrollx = 0
  2154. } else if (C.newscrollx > C.page.maxw) {
  2155. C.newscrollx = C.page.maxw
  2156. }
  2157. }
  2158. C.dst = {};
  2159. C.dst.x = x - h;
  2160. C.dst.y = y - g;
  2161. C.dst.px = h;
  2162. C.dst.py = g;
  2163. var i = Math.round(Math.sqrt(Math.pow(C.dst.x, 2) + Math.pow(C.dst.y, 2)));
  2164. C.dst.ax = C.dst.x / i;
  2165. C.dst.ay = C.dst.y / i;
  2166. var j = 0;
  2167. var k = i;
  2168. if (C.dst.x == 0) {
  2169. j = g;
  2170. k = y;
  2171. C.dst.ay = 1;
  2172. C.dst.py = 0
  2173. } else if (C.dst.y == 0) {
  2174. j = h;
  2175. k = x;
  2176. C.dst.ax = 1;
  2177. C.dst.px = 0
  2178. }
  2179. var l = C.getTransitionSpeed(i);
  2180. if (l > 0) {
  2181. C.bzscroll = (C.bzscroll) ? C.bzscroll.update(k, l) : new BezierClass(j, k, l, 0, 1, 0, 1)
  2182. } else {
  2183. C.bzscroll = false
  2184. }
  2185. if (C.timer) return;
  2186. if ((g == C.page.maxh && y >= C.page.maxh) || (h == C.page.maxw && x >= C.page.maxw)) C.checkContentSize();
  2187. var m = 1;
  2188. function scrolling() {
  2189. try {
  2190. if (C.me.is(":visible") === false) return
  2191. } catch(e) {}
  2192. if (C.cancelAnimationFrame) return true;
  2193. C.scrollrunning = true;
  2194. m = 1 - m;
  2195. if (m) return (C.timer = M(scrolling) || 1);
  2196. var a = 0;
  2197. var b = sy = C.getScrollTop();
  2198. if (C.dst.ay) {
  2199. b = (C.bzscroll) ? C.dst.py + (C.bzscroll.getNow() * C.dst.ay) : C.newscrolly;
  2200. var c = b - sy;
  2201. if ((c < 0 && b < C.newscrolly) || (c > 0 && b > C.newscrolly)) b = C.newscrolly;
  2202. C.setScrollTop(b);
  2203. if (b == C.newscrolly) a = 1
  2204. } else {
  2205. a = 1
  2206. }
  2207. var d = sx = C.getScrollLeft();
  2208. if (C.dst.ax) {
  2209. d = (C.bzscroll) ? C.dst.px + (C.bzscroll.getNow() * C.dst.ax) : C.newscrollx;
  2210. var c = d - sx;
  2211. if ((c < 0 && d < C.newscrollx) || (c > 0 && d > C.newscrollx)) d = C.newscrollx;
  2212. C.setScrollLeft(d);
  2213. if (d == C.newscrollx) a += 1
  2214. } else {
  2215. a += 1
  2216. }
  2217. if (a == 2) {
  2218. C.timer = 0;
  2219. C.cursorfreezed = false;
  2220. C.bzscroll = false;
  2221. C.scrollrunning = false;
  2222. if (b < 0) b = 0;
  2223. else if (b > C.page.maxh) b = C.page.maxh;
  2224. if (d < 0) d = 0;
  2225. else if (d > C.page.maxw) d = C.page.maxw;
  2226. if ((d != C.newscrollx) || (b != C.newscrolly)) C.doScrollPos(d, b);
  2227. else {
  2228. if (C.onscrollend) {
  2229. var f = {
  2230. "type": "scrollend",
  2231. "current": {
  2232. "x": sx,
  2233. "y": sy
  2234. },
  2235. "end": {
  2236. "x": C.newscrollx,
  2237. "y": C.newscrolly
  2238. }
  2239. };
  2240. C.onscrollend.call(C, f)
  2241. }
  2242. }
  2243. } else {
  2244. C.timer = M(scrolling) || 1
  2245. }
  2246. };
  2247. C.cancelAnimationFrame = false;
  2248. C.timer = 1;
  2249. if (C.onscrollstart && !C.scrollrunning) {
  2250. var n = {
  2251. "type": "scrollstart",
  2252. "current": {
  2253. "x": h,
  2254. "y": g
  2255. },
  2256. "request": {
  2257. "x": x,
  2258. "y": y
  2259. },
  2260. "end": {
  2261. "x": C.newscrollx,
  2262. "y": C.newscrolly
  2263. },
  2264. "speed": l
  2265. };
  2266. C.onscrollstart.call(C, n)
  2267. }
  2268. scrolling();
  2269. if ((g == C.page.maxh && y >= g) || (h == C.page.maxw && x >= h)) C.checkContentSize();
  2270. C.noticeCursor()
  2271. };
  2272. this.cancelScroll = function() {
  2273. if (C.timer) N(C.timer);
  2274. C.timer = 0;
  2275. C.bzscroll = false;
  2276. C.scrollrunning = false;
  2277. return C
  2278. }
  2279. };
  2280. this.doScrollBy = function(a, b) {
  2281. try {
  2282. if (C.me.is(":visible") === false) return
  2283. } catch(e) {};
  2284. var c = 0;
  2285. if (b) {
  2286. c = Math.floor((C.scroll.y - a) * C.scrollratio.y)
  2287. } else {
  2288. var d = (C.timer) ? C.newscrolly: C.getScrollTop(true);
  2289. c = d - a
  2290. }
  2291. if (C.bouncescroll) {
  2292. var f = Math.round(C.view.h / 2);
  2293. if (c < -f) c = -f;
  2294. else if (c > (C.page.maxh + f)) c = (C.page.maxh + f)
  2295. }
  2296. C.cursorfreezed = false;
  2297. py = C.getScrollTop(true);
  2298. if (c < 0 && py <= 0) return C.noticeCursor();
  2299. else if (c > C.page.maxh && py >= C.page.maxh) {
  2300. C.checkContentSize();
  2301. return C.noticeCursor()
  2302. }
  2303. C.doScrollTop(c)
  2304. };
  2305. this.doScrollLeftBy = function(a, b) {
  2306. try {
  2307. if (C.me.is(":visible") === false) return
  2308. } catch(e) {};
  2309. var c = 0;
  2310. if (b) {
  2311. c = Math.floor((C.scroll.x - a) * C.scrollratio.x)
  2312. } else {
  2313. var d = (C.timer) ? C.newscrollx: C.getScrollLeft(true);
  2314. c = d - a
  2315. }
  2316. if (C.bouncescroll) {
  2317. var f = Math.round(C.view.w / 2);
  2318. if (c < -f) c = -f;
  2319. else if (c > (C.page.maxw + f)) c = (C.page.maxw + f)
  2320. }
  2321. C.cursorfreezed = false;
  2322. px = C.getScrollLeft(true);
  2323. if (c < 0 && px <= 0) return C.noticeCursor();
  2324. else if (c > C.page.maxw && px >= C.page.maxw) return C.noticeCursor();
  2325. C.doScrollLeft(c)
  2326. };
  2327. this.doScrollTo = function(a, b) {
  2328. var c = (b) ? Math.round(a * C.scrollratio.y) : a;
  2329. if (c < 0) c = 0;
  2330. else if (c > C.page.maxh) c = C.page.maxh;
  2331. C.cursorfreezed = false;
  2332. C.doScrollTop(a)
  2333. };
  2334. this.checkContentSize = function() {
  2335. var a = C.getContentSize();
  2336. if ((a.h != C.page.h) || (a.w != C.page.w)) C.resize(false, a)
  2337. };
  2338. C.onscroll = function(e) {
  2339. try {
  2340. if (C.me.is(":visible") === false) return
  2341. } catch(e) {};
  2342. if (C.rail.drag) return;
  2343. if (!C.cursorfreezed) {
  2344. C.synched('scroll',
  2345. function() {
  2346. C.scroll.y = Math.round(C.getScrollTop() * (1 / C.scrollratio.y));
  2347. if (C.railh) C.scroll.x = Math.round(C.getScrollLeft() * (1 / C.scrollratio.x));
  2348. C.noticeCursor()
  2349. })
  2350. }
  2351. };
  2352. C.bind(C.docscroll, "scroll", C.onscroll);
  2353. this.doZoomIn = function(e) {
  2354. if (C.zoomactive) return;
  2355. C.zoomactive = true;
  2356. C.zoomrestore = {
  2357. style: {}
  2358. };
  2359. var b = ['position', 'top', 'left', 'zIndex', 'backgroundColor', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight'];
  2360. var c = C.win[0].style;
  2361. for (var a in b) {
  2362. var d = b[a];
  2363. C.zoomrestore.style[d] = (typeof c[d] != 'undefined') ? c[d] : ''
  2364. }
  2365. C.zoomrestore.style.width = C.win.css('width');
  2366. C.zoomrestore.style.height = C.win.css('height');
  2367. C.zoomrestore.padding = {
  2368. w: C.win.outerWidth() - C.win.width(),
  2369. h: C.win.outerHeight() - C.win.height()
  2370. };
  2371. if (D.isios4) {
  2372. C.zoomrestore.scrollTop = $(window).scrollTop();
  2373. $(window).scrollTop(0)
  2374. }
  2375. C.win.css({
  2376. "position": (D.isios4) ? "absolute": "fixed",
  2377. "top": 0,
  2378. "left": 0,
  2379. "z-index": C.opt.zindex + 100,
  2380. "margin": "0px"
  2381. });
  2382. var f = C.win.css("backgroundColor");
  2383. if (f == "" || /transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(f)) C.win.css("backgroundColor", "#fff");
  2384. C.rail.css({
  2385. "z-index": C.opt.zindex + 110
  2386. });
  2387. C.zoom.css({
  2388. "z-index": C.opt.zindex + 112
  2389. });
  2390. C.zoom.css('backgroundPosition', '0px -18px');
  2391. C.resizeZoom();
  2392. if (C.onzoomin) C.onzoomin.call(C);
  2393. return C.cancelEvent(e)
  2394. };
  2395. this.doZoomOut = function(e) {
  2396. if (!C.zoomactive) return;
  2397. C.zoomactive = false;
  2398. C.win.css("margin", "");
  2399. C.win.css(C.zoomrestore.style);
  2400. if (D.isios4) {
  2401. $(window).scrollTop(C.zoomrestore.scrollTop)
  2402. }
  2403. C.rail.css({
  2404. "z-index": (C.ispage) ? C.opt.zindex: C.opt.zindex + 2
  2405. });
  2406. C.zoom.css({
  2407. "z-index": C.opt.zindex
  2408. });
  2409. C.zoomrestore = false;
  2410. C.zoom.css('backgroundPosition', '0px 0px');
  2411. C.onResize();
  2412. if (C.onzoomout) C.onzoomout.call(C);
  2413. return C.cancelEvent(e)
  2414. };
  2415. this.doZoom = function(e) {
  2416. return (C.zoomactive) ? C.doZoomOut(e) : C.doZoomIn(e)
  2417. };
  2418. this.resizeZoom = function() {
  2419. if (!C.zoomactive) return;
  2420. var a = C.getScrollTop();
  2421. C.win.css({
  2422. width: $(window).width() - C.zoomrestore.padding.w + "px",
  2423. height: $(window).height() - C.zoomrestore.padding.h + "px"
  2424. });
  2425. C.onResize();
  2426. console.log(a);
  2427. C.setScrollTop(Math.min(C.page.maxh, a))
  2428. };
  2429. this.init();
  2430. $.nicescroll.push(this)
  2431. };
  2432. var R = function(r) {
  2433. var s = this;
  2434. this.nc = r;
  2435. this.lastx = 0;
  2436. this.lasty = 0;
  2437. this.speedx = 0;
  2438. this.speedy = 0;
  2439. this.lasttime = 0;
  2440. this.steptime = 0;
  2441. this.snapx = false;
  2442. this.snapy = false;
  2443. this.demulx = 0;
  2444. this.demuly = 0;
  2445. this.lastscrollx = -1;
  2446. this.lastscrolly = -1;
  2447. this.chkx = 0;
  2448. this.chky = 0;
  2449. this.timer = 0;
  2450. this.time = function() {
  2451. return + new Date()
  2452. };
  2453. this.reset = function(a, b) {
  2454. s.stop();
  2455. var c = s.time();
  2456. s.steptime = 0;
  2457. s.lasttime = c;
  2458. s.speedx = 0;
  2459. s.speedy = 0;
  2460. s.lastx = a;
  2461. s.lasty = b;
  2462. s.lastscrollx = -1;
  2463. s.lastscrolly = -1
  2464. };
  2465. this.update = function(a, b) {
  2466. var c = s.time();
  2467. s.steptime = c - s.lasttime;
  2468. s.lasttime = c;
  2469. var d = b - s.lasty;
  2470. var e = a - s.lastx;
  2471. var f = s.nc.getScrollTop();
  2472. var g = s.nc.getScrollLeft();
  2473. var h = f + d;
  2474. var i = g + e;
  2475. s.snapx = (i < 0) || (i > s.nc.page.maxw);
  2476. s.snapy = (h < 0) || (h > s.nc.page.maxh);
  2477. s.speedx = e;
  2478. s.speedy = d;
  2479. s.lastx = a;
  2480. s.lasty = b
  2481. };
  2482. this.stop = function() {
  2483. s.nc.unsynched("domomentum2d");
  2484. if (s.timer) clearTimeout(s.timer);
  2485. s.timer = 0;
  2486. s.lastscrollx = -1;
  2487. s.lastscrolly = -1
  2488. };
  2489. this.doSnapy = function(a, b) {
  2490. var c = false;
  2491. if (b < 0) {
  2492. b = 0;
  2493. c = true
  2494. } else if (b > s.nc.page.maxh) {
  2495. b = s.nc.page.maxh;
  2496. c = true
  2497. }
  2498. if (a < 0) {
  2499. a = 0;
  2500. c = true
  2501. } else if (a > s.nc.page.maxw) {
  2502. a = s.nc.page.maxw;
  2503. c = true
  2504. }
  2505. if (c) s.nc.doScrollPos(a, b, s.nc.opt.snapbackspeed)
  2506. };
  2507. this.doMomentum = function(d) {
  2508. var t = s.time();
  2509. var l = (d) ? t + d: s.lasttime;
  2510. var e = s.nc.getScrollLeft();
  2511. var f = s.nc.getScrollTop();
  2512. var g = s.nc.page.maxh;
  2513. var h = s.nc.page.maxw;
  2514. s.speedx = (h > 0) ? Math.min(60, s.speedx) : 0;
  2515. s.speedy = (g > 0) ? Math.min(60, s.speedy) : 0;
  2516. var i = l && (t - l) <= 50;
  2517. if ((f < 0) || (f > g) || (e < 0) || (e > h)) i = false;
  2518. var j = (s.speedy && i) ? s.speedy: false;
  2519. var k = (s.speedx && i) ? s.speedx: false;
  2520. if (j || k) {
  2521. var m = Math.max(16, s.steptime);
  2522. if (m > 50) {
  2523. var n = m / 50;
  2524. s.speedx *= n;
  2525. s.speedy *= n;
  2526. m = 50
  2527. }
  2528. s.demulxy = 0;
  2529. s.lastscrollx = s.nc.getScrollLeft();
  2530. s.chkx = s.lastscrollx;
  2531. s.lastscrolly = s.nc.getScrollTop();
  2532. s.chky = s.lastscrolly;
  2533. var o = s.lastscrollx;
  2534. var p = s.lastscrolly;
  2535. var q = function() {
  2536. var c = ((s.time() - t) > 600) ? 0.04 : 0.02;
  2537. if (s.speedx) {
  2538. o = Math.floor(s.lastscrollx - (s.speedx * (1 - s.demulxy)));
  2539. s.lastscrollx = o;
  2540. if ((o < 0) || (o > h)) c = 0.10
  2541. }
  2542. if (s.speedy) {
  2543. p = Math.floor(s.lastscrolly - (s.speedy * (1 - s.demulxy)));
  2544. s.lastscrolly = p;
  2545. if ((p < 0) || (p > g)) c = 0.10
  2546. }
  2547. s.demulxy = Math.min(1, s.demulxy + c);
  2548. s.nc.synched("domomentum2d",
  2549. function() {
  2550. if (s.speedx) {
  2551. var a = s.nc.getScrollLeft();
  2552. if (a != s.chkx) s.stop();
  2553. s.chkx = o;
  2554. s.nc.setScrollLeft(o)
  2555. }
  2556. if (s.speedy) {
  2557. var b = s.nc.getScrollTop();
  2558. if (b != s.chky) s.stop();
  2559. s.chky = p;
  2560. s.nc.setScrollTop(p)
  2561. }
  2562. if (!s.timer) {
  2563. s.nc.hideCursor();
  2564. s.doSnapy(o, p)
  2565. }
  2566. });
  2567. if (s.demulxy < 1) {
  2568. s.timer = setTimeout(q, m)
  2569. } else {
  2570. s.stop();
  2571. s.nc.hideCursor();
  2572. s.doSnapy(o, p)
  2573. }
  2574. };
  2575. q()
  2576. } else {
  2577. s.doSnapy(s.nc.getScrollLeft(), s.nc.getScrollTop())
  2578. }
  2579. }
  2580. };
  2581. var S = F.fn.scrollTop;
  2582. $.cssHooks["pageYOffset"] = {
  2583. get: function(a, b, c) {
  2584. var d = $.data(a, '__nicescroll') || false;
  2585. return (d && d.ishwscroll) ? d.getScrollTop() : S.call(a)
  2586. },
  2587. set: function(a, b) {
  2588. var c = $.data(a, '__nicescroll') || false; (c && c.ishwscroll) ? c.setScrollTop(parseInt(b)) : S.call(a, b);
  2589. return this
  2590. }
  2591. };
  2592. F.fn.scrollTop = function(b) {
  2593. if (typeof b == "undefined") {
  2594. var c = (this[0]) ? $.data(this[0], '__nicescroll') || false: false;
  2595. return (c && c.ishwscroll) ? c.getScrollTop() : S.call(this)
  2596. } else {
  2597. return this.each(function() {
  2598. var a = $.data(this, '__nicescroll') || false; (a && a.ishwscroll) ? a.setScrollTop(parseInt(b)) : S.call($(this), b)
  2599. })
  2600. }
  2601. };
  2602. var T = F.fn.scrollLeft;
  2603. $.cssHooks.pageXOffset = {
  2604. get: function(a, b, c) {
  2605. var d = $.data(a, '__nicescroll') || false;
  2606. return (d && d.ishwscroll) ? d.getScrollLeft() : T.call(a)
  2607. },
  2608. set: function(a, b) {
  2609. var c = $.data(a, '__nicescroll') || false; (c && c.ishwscroll) ? c.setScrollLeft(parseInt(b)) : T.call(a, b);
  2610. return this
  2611. }
  2612. };
  2613. F.fn.scrollLeft = function(b) {
  2614. if (typeof b == "undefined") {
  2615. var c = (this[0]) ? $.data(this[0], '__nicescroll') || false: false;
  2616. return (c && c.ishwscroll) ? c.getScrollLeft() : T.call(this)
  2617. } else {
  2618. return this.each(function() {
  2619. var a = $.data(this, '__nicescroll') || false; (a && a.ishwscroll) ? a.setScrollLeft(parseInt(b)) : T.call($(this), b)
  2620. })
  2621. }
  2622. };
  2623. var U = function(c) {
  2624. var d = this;
  2625. this.length = 0;
  2626. this.name = "nicescrollarray";
  2627. this.each = function(b) {
  2628. for (var a = 0; a < d.length; a++) b.call(d[a]);
  2629. return d
  2630. };
  2631. this.push = function(a) {
  2632. d[d.length] = a;
  2633. d.length++
  2634. };
  2635. this.eq = function(a) {
  2636. return d[a]
  2637. };
  2638. if (c) {
  2639. for (a = 0; a < c.length; a++) {
  2640. var e = $.data(c[a], '__nicescroll') || false;
  2641. if (e) {
  2642. this[this.length] = e;
  2643. this.length++
  2644. }
  2645. }
  2646. }
  2647. return this
  2648. };
  2649. function mplex(b, c, d) {
  2650. for (var a = 0; a < c.length; a++) d(b, c[a])
  2651. };
  2652. mplex(U.prototype, ['show', 'hide', 'toggle', 'onResize', 'resize', 'remove', 'stop', 'doScrollPos'],
  2653. function(e, n) {
  2654. e[n] = function() {
  2655. var a = arguments;
  2656. return this.each(function() {
  2657. this[n].apply(this, a)
  2658. })
  2659. }
  2660. });
  2661. F.fn.getNiceScroll = function(a) {
  2662. if (typeof a == "undefined") {
  2663. return new U(this)
  2664. } else {
  2665. var b = $.data(this[a], '__nicescroll') || false;
  2666. return b
  2667. }
  2668. };
  2669. F.extend(F.expr[':'], {
  2670. nicescroll: function(a) {
  2671. return ($.data(a, '__nicescroll')) ? true: false
  2672. }
  2673. });
  2674. $.fn.niceScroll = function(b, c) {
  2675. if (typeof c == "undefined") {
  2676. if ((typeof b == "object") && !("jquery" in b)) {
  2677. c = b;
  2678. b = false
  2679. }
  2680. }
  2681. var d = new U();
  2682. if (typeof c == "undefined") c = {};
  2683. if (b || false) {
  2684. c.doc = $(b);
  2685. c.win = $(this)
  2686. }
  2687. var e = !("doc" in c);
  2688. if (!e && !("win" in c)) c.win = $(this);
  2689. this.each(function() {
  2690. var a = $(this).data('__nicescroll') || false;
  2691. if (!a) {
  2692. c.doc = (e) ? $(this) : c.doc;
  2693. a = new Q(c, $(this));
  2694. $(this).data('__nicescroll', a)
  2695. }
  2696. d.push(a)
  2697. });
  2698. return (d.length == 1) ? d[0] : d
  2699. };
  2700. window.NiceScroll = {
  2701. getjQuery: function() {
  2702. return F
  2703. }
  2704. };
  2705. if (!$.nicescroll) {
  2706. $.nicescroll = new U()
  2707. }
  2708. })(jQuery); (function($) {
  2709. $.fn.perfectScrollbar = function(a) {
  2710. if (a === "update" || a === "resize") {
  2711. $(this).getNiceScroll().resize();
  2712. return
  2713. } else if (a === "getScrollObj") {
  2714. return $(this).getNiceScroll()
  2715. } else if (a === "getScrollTop") {
  2716. var b = $(this).getNiceScroll().eq(0);
  2717. return b.getScrollTop()
  2718. } else if (a === "hide") {
  2719. $(this).getNiceScroll().hide()
  2720. } else if (a === "show") {
  2721. $(this).getNiceScroll().show()
  2722. } else if (a === "toggle") {
  2723. $(this).getNiceScroll().toggle()
  2724. } else if (a === "remove" || a === "destroy") {
  2725. $(this).getNiceScroll().remove()
  2726. } else if (a === "stop") {
  2727. $(this).getNiceScroll().stop()
  2728. } else if (a === "doScrollPos") {
  2729. $(this).getNiceScroll().doScrollPos()
  2730. }
  2731. a = jQuery.extend({
  2732. cursorwidth: 5,
  2733. cursorborder: "none",
  2734. cursorcolor: "#999",
  2735. hidecursordelay: 0,
  2736. zindex: 3,
  2737. horizrailenabled: false
  2738. },
  2739. a);
  2740. return $(this).niceScroll(a)
  2741. }
  2742. })(jQuery);