divscroll-1.js 77 KB

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