jquery.nicescroll.js 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856
  1. /* jquery.nicescroll
  2. -- version 2.9.6
  3. -- copyright 2011-12 InuYaksa*2012
  4. -- licensed under the MIT
  5. --
  6. -- http://areaaperta.com/nicescroll
  7. -- https://github.com/inuyaksa/jquery.nicescroll
  8. --
  9. */
  10. (function(jQuery){
  11. // globals
  12. var domfocus = false;
  13. var mousefocus = false;
  14. var zoomactive = false;
  15. var tabindexcounter = 5000;
  16. var ascrailcounter = 2000;
  17. var $ = jQuery; // sandbox
  18. // http://stackoverflow.com/questions/2161159/get-script-path
  19. function getScriptPath() {
  20. var scripts=document.getElementsByTagName('script');
  21. var path=scripts[scripts.length-1].src.split('?')[0];
  22. return (path.split('/').length>0) ? path.split('/').slice(0,-1).join('/')+'/' : '';
  23. }
  24. var scriptpath = getScriptPath();
  25. // derived by http://blog.joelambert.co.uk/2011/06/01/a-better-settimeoutsetinterval/
  26. var setAnimationFrame = (function(){
  27. return window.requestAnimationFrame ||
  28. window.webkitRequestAnimationFrame ||
  29. window.mozRequestAnimationFrame ||
  30. window.oRequestAnimationFrame ||
  31. window.msRequestAnimationFrame ||
  32. false;
  33. })();
  34. var clearAnimationFrame = (function(){
  35. return window.cancelRequestAnimationFrame ||
  36. window.webkitCancelRequestAnimationFrame ||
  37. window.mozCancelRequestAnimationFrame ||
  38. window.oCancelRequestAnimationFrame ||
  39. window.msCancelRequestAnimationFrame ||
  40. false;
  41. })();
  42. var NiceScrollClass = function(myopt,me) {
  43. var self = this;
  44. this.version = '2.9.6';
  45. this.name = 'nicescroll';
  46. this.me = me;
  47. this.opt = {
  48. doc:$("body"),
  49. win:false,
  50. zindex:9000,
  51. cursoropacitymin:0,
  52. cursoropacitymax:1,
  53. cursorcolor:"#424242",
  54. cursorwidth:"5px",
  55. cursorborder:"1px solid #fff",
  56. cursorborderradius:"5px",
  57. scrollspeed:60,
  58. mousescrollstep:8*5,
  59. touchbehavior:false,
  60. hwacceleration:true,
  61. usetransition:true,
  62. boxzoom:false,
  63. dblclickzoom:true,
  64. gesturezoom:true,
  65. grabcursorenabled:true,
  66. autohidemode:true,
  67. background:"",
  68. iframeautoresize:true,
  69. cursorminheight:20,
  70. preservenativescrolling:true,
  71. railoffset:false,
  72. bouncescroll:false,
  73. spacebarenabled:true,
  74. railpadding:{top:0,right:0,left:0,bottom:0},
  75. disableoutline:true
  76. };
  77. if (myopt||false) {
  78. for(var a in self.opt) {
  79. if (typeof myopt[a] != "undefined") self.opt[a] = myopt[a];
  80. }
  81. }
  82. this.doc = self.opt.doc;
  83. this.iddoc = (this.doc&&this.doc[0])?this.doc[0].id||'':'';
  84. this.ispage = /BODY|HTML/.test((self.opt.win)?self.opt.win[0].nodeName:this.doc[0].nodeName);
  85. this.haswrapper = (self.opt.win!==false);
  86. this.win = self.opt.win||(this.ispage?$(window):this.doc);
  87. this.docscroll = (this.ispage&&!this.haswrapper)?$(window):this.win;
  88. this.body = $("body");
  89. this.iframe = false;
  90. this.isiframe = ((this.doc[0].nodeName == 'IFRAME') && (this.win[0].nodeName == 'IFRAME'));
  91. this.istextarea = (this.win[0].nodeName == 'TEXTAREA');
  92. // Events jump table
  93. this.onmousedown = false;
  94. this.onmouseup = false;
  95. this.onmousemove = false;
  96. this.onmousewheel = false;
  97. this.onkeypress = false;
  98. this.ongesturezoom = false;
  99. this.onclick = false;
  100. // Let's start!
  101. this.view = false;
  102. this.page = false;
  103. this.scroll = {x:0,y:0};
  104. this.scrollratio = {x:0,y:0};
  105. this.cursorheight = 20;
  106. this.scrollvaluemax = 0;
  107. this.scrollmom = false;
  108. do {
  109. this.id = "ascrail"+(ascrailcounter++);
  110. } while (document.getElementById(this.id));
  111. this.rail = false;
  112. this.cursor = false;
  113. this.cursorfreezed = false;
  114. this.zoom = false;
  115. this.zoomactive = false;
  116. this.hasfocus = false;
  117. this.hasmousefocus = false;
  118. this.visibility = true;
  119. this.locked = false;
  120. this.hidden = false; // rails always hidden
  121. this.nativescrollingarea = false;
  122. this.events = []; // event list for unbind
  123. this.saved = {};
  124. this.delaylist = {};
  125. this.synclist = {};
  126. this.lastdelta = 0;
  127. var domtest = document.createElement('DIV');
  128. this.isopera = ("opera" in window);
  129. this.isie = (("all" in document) && ("attachEvent" in domtest) && !this.isopera);
  130. this.isieold = (this.isie && !("msInterpolationMode" in domtest.style)); // IE6 and older
  131. this.isie7 = this.isie&&!this.isieold&&(!("documentMode" in document)||(document.documentMode==7));
  132. this.isie8 = this.isie&&("documentMode" in document)&&(document.documentMode==8);
  133. this.isie9 = this.isie&&("performance" in window)&&(document.documentMode>=9);
  134. this.isie9mobile = /iemobile.9/i.test(navigator.userAgent); //wp 7.1 mango
  135. this.isie7mobile = (!this.isie9mobile&&this.isie7) && /iemobile/i.test(navigator.userAgent); //wp 7.0
  136. this.ismozilla = ("MozAppearance" in domtest.style);
  137. this.ischrome = ("chrome" in window);
  138. this.cantouch = ("ontouchstart" in document.documentElement);
  139. this.hasmstouch = (window.navigator.msPointerEnabled||false); // IE10+ pointer events - EXPERIMENTAL
  140. /* alternative methods to detect touch support */
  141. /* thanks modernizr.github.com/Modernizr/touch.html */
  142. // if (!this.cantouch) this.cantouch = (typeof TouchEvent != "undefined"); // NOT READY -> testing session (false positive on chrome19)
  143. /* */
  144. this.isios = (this.cantouch && /iphone|ipad|ipod/i.test(navigator.platform));
  145. this.isios4 = ((this.isios)&&!("seal" in Object));
  146. if (self.opt.hwacceleration) { // if you dont need dont bother to look for
  147. this.trstyle = (window.opera) ? 'OTransform' : (document.all) ? 'msTransform' : (domtest.style.webkitTransform!==undefined) ? 'webkitTransform' : (domtest.style.MozTransform!==undefined) ? 'MozTransform' : false;
  148. if (this.trstyle && typeof domtest.style[this.trstyle] == "undefined") this.trstyle = false;
  149. this.hastransform = (this.trstyle != false);
  150. if (this.hastransform) {
  151. domtest.style[this.trstyle] = "translate3d(1px,2px,3px)";
  152. this.hastranslate3d = /translate3d/.test(domtest.style[this.trstyle]);
  153. }
  154. this.transitionstyle = false;
  155. this.prefixstyle = '';
  156. this.transitionend = false;
  157. var check = ['transition','webkitTransition','MozTransition','OTransition','msTransition','KhtmlTransition'];
  158. var prefix = ['','-webkit-','-moz-','-o-','-ms-','-khtml-'];
  159. var evs = ['transitionEnd','webkitTransitionEnd','transitionend','oTransitionEnd','msTransitionEnd','KhtmlTransitionEnd'];
  160. for(var a=0;a<check.length;a++) {
  161. if (check[a] in domtest.style) {
  162. this.transitionstyle = check[a];
  163. this.prefixstyle = prefix[a];
  164. this.transitionend = evs[a];
  165. break;
  166. }
  167. }
  168. this.hastransition = (this.transitionstyle);
  169. } else {
  170. this.trstyle = false;
  171. this.hastransform = false;
  172. this.hastranslate3d = false;
  173. this.transitionstyle = false;
  174. this.hastransition = false;
  175. this.transitionend = false;
  176. }
  177. this.cursorgrabvalue = '';
  178. if (self.opt.grabcursorenabled&&self.opt.touchbehavior) { // check grab cursor support
  179. function detectCursorGrab() {
  180. // thank you google for custom cursor!
  181. var lst = ['-moz-grab','-webkit-grab','grab'];
  182. if (self.ischrome||self.isie) lst=[]; // force setting for IE returns false positive and chrome cursor bug
  183. for(var a=0;a<lst.length;a++) {
  184. var p = lst[a];
  185. domtest.style['cursor']=p;
  186. if (domtest.style['cursor']==p) return p;
  187. }
  188. return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize';
  189. }
  190. this.cursorgrabvalue = detectCursorGrab();
  191. }
  192. domtest = null; //memory released
  193. this.ishwscroll = (self.hastransform)&&(self.opt.hwacceleration)&&(self.haswrapper);
  194. this.delayed = function(name,fn,tm) {
  195. var dd = self.delaylist[name];
  196. var nw = (new Date()).getTime();
  197. if (dd&&dd.tt) return false;
  198. if (dd&&dd.last+tm>nw&&!dd.tt) {
  199. self.delaylist[name] = {
  200. last:nw+tm,
  201. tt:setTimeout(function(){self.delaylist[name].tt=0;fn.call();},tm)
  202. }
  203. }
  204. else if (!dd||!dd.tt) {
  205. self.delaylist[name] = {
  206. last:nw,
  207. tt:0
  208. }
  209. setTimeout(function(){fn.call();},0);
  210. }
  211. };
  212. this.requestSync = function() {
  213. if (self.onsync) return;
  214. setAnimationFrame(function(){
  215. self.onsync = false;
  216. for(name in self.synclist){
  217. var fn = self.synclist[name];
  218. if (fn) fn.call(self);
  219. self.synclist[name] = false;
  220. }
  221. });
  222. self.onsync = true;
  223. };
  224. this.synched = function(name,fn) {
  225. self.synclist[name] = fn;
  226. self.requestSync();
  227. };
  228. this.css = function(el,pars) { // save & set
  229. for(var n in pars) {
  230. self.saved.css.push([el,n,el.css(n)]);
  231. el.css(n,pars[n]);
  232. }
  233. };
  234. this.scrollTop = function(val) {
  235. return (typeof val == "undefined") ? self.getScrollTop() : self.setScrollTop(val);
  236. };
  237. // derived by by Dan Pupius www.pupius.net
  238. BezierClass = function(st,ed,spd,p1,p2,p3,p4) {
  239. this.st = st;
  240. this.ed = ed;
  241. this.spd = spd;
  242. this.p1 = p1||0;
  243. this.p2 = p2||1;
  244. this.p3 = p3||0;
  245. this.p4 = p4||1;
  246. this.ts = (new Date()).getTime();
  247. this.df = this.ed-this.st;
  248. };
  249. BezierClass.prototype = {
  250. B2:function(t){ return 3*t*t*(1-t) },
  251. B3:function(t){ return 3*t*(1-t)*(1-t) },
  252. B4:function(t){ return (1-t)*(1-t)*(1-t) },
  253. getNow:function(){
  254. var nw = (new Date()).getTime();
  255. var pc = 1-((nw-this.ts)/this.spd);
  256. var bz = this.B2(pc) + this.B3(pc) + this.B4(pc);
  257. return (pc<0) ? this.ed : this.st+Math.round(this.df*bz);
  258. },
  259. update:function(ed,spd){
  260. this.st = this.getNow();
  261. this.ed = ed;
  262. this.spd = spd;
  263. this.ts = (new Date()).getTime();
  264. this.df = this.ed-this.st;
  265. return this;
  266. }
  267. };
  268. if (this.ishwscroll) {
  269. // hw accelerated scroll
  270. this.doc.translate = {x:0,y:0};
  271. if (this.hastranslate3d) this.doc.css(this.prefixstyle+"backface-visibility","hidden"); // prevent flickering http://stackoverflow.com/questions/3461441/
  272. this.getScrollTop = function(last) {
  273. if (self.timerscroll&&!last) {
  274. return self.timerscroll.bz.getNow();
  275. } else {
  276. return self.doc.translate.y;
  277. }
  278. };
  279. if (document.createEvent) {
  280. this.notifyScrollEvent = function(el) {
  281. var e = document.createEvent("UIEvents");
  282. e.initUIEvent("scroll", false, true, window, 1);
  283. el.dispatchEvent(e);
  284. };
  285. }
  286. else if (document.fireEvent) {
  287. this.notifyScrollEvent = function(el) {
  288. var e = document.createEventObject();
  289. el.fireEvent("onscroll");
  290. e.cancelBubble = true;
  291. };
  292. }
  293. else {
  294. this.notifyScrollEvent = function(el) {}; //NOPE
  295. }
  296. if (this.hastranslate3d) {
  297. this.setScrollTop = function(val,silent) {
  298. self.doc.css(self.trstyle,"translate3d(0px,"+(val*-1)+"px,0px)");
  299. self.doc.translate.y = val;
  300. if (!silent) self.notifyScrollEvent(self.win[0]);
  301. };
  302. } else {
  303. this.setScrollTop = function(val,silent) {
  304. self.doc.css(self.trstyle,"translate(0px,"+(val*-1)+"px)");
  305. self.doc.translate.y = val;
  306. if (!silent) self.notifyScrollEvent(self.win[0]);
  307. };
  308. }
  309. } else {
  310. // native scroll
  311. this.getScrollTop = function() {
  312. return self.docscroll.scrollTop();
  313. };
  314. this.setScrollTop = function(val) {
  315. return self.docscroll.scrollTop(val);
  316. };
  317. }
  318. this.getTarget = function(e) {
  319. if (!e) return false;
  320. if (e.target) return e.target;
  321. if (e.srcElement) return e.srcElement;
  322. return false;
  323. };
  324. this.hasParent = function(e,id) {
  325. if (!e) return false;
  326. var el = e.target||e.srcElement||e||false;
  327. while (el && el.id != id) {
  328. el = el.parentNode||false;
  329. }
  330. return (el!==false);
  331. };
  332. //inspired by http://forum.jquery.com/topic/width-includes-border-width-when-set-to-thin-medium-thick-in-ie
  333. var _convertBorderWidth = {"thin":1,"medium":3,"thick":5};
  334. function getWidthToPixel(dom,prop,chkheight) {
  335. var wd = dom.css(prop);
  336. var px = parseFloat(wd);
  337. if (isNaN(px)) {
  338. px = _convertBorderWidth[wd]||0;
  339. var brd = (px==3) ? ((chkheight)?(self.win.outerHeight() - self.win.innerHeight()):(self.win.outerWidth() - self.win.innerWidth())) : 1; //DON'T TRUST CSS
  340. if (self.isie8&&px) px+=1;
  341. return (brd) ? px : 0;
  342. /*
  343. switch (wd) {
  344. case "thin":
  345. px = (self.isie8) ? 1 : 2;
  346. break;
  347. case "medium":
  348. var brd = (chkheight)?(self.win.outerHeight() - self.win.innerHeight()):(self.win.outerWidth() - self.win.innerWidth()); //DON'T TRUST CSS
  349. px = (brd) ? ((self.isie8) ? 3 : 4) : 0;
  350. break;
  351. case "thick":
  352. px = (self.isie8) ? 5 : 6;
  353. break;
  354. }
  355. */
  356. }
  357. return px;
  358. };
  359. this.updateScrollBar = function(len) {
  360. if (self.ishwscroll) {
  361. self.rail.css({height:self.win.innerHeight()});
  362. } else {
  363. var pos = self.win.offset();
  364. pos.top+= getWidthToPixel(self.win,'border-top-width',true);
  365. // var brd = (self.win.outerWidth() - self.win.innerWidth());
  366. pos.left+= self.win.outerWidth() - getWidthToPixel(self.win,'border-right-width',false) - self.rail.width;
  367. var off = self.opt.railoffset;
  368. if (off) {
  369. if (off.top) pos.top+=off.top;
  370. if (off.left) pos.left+=off.left;
  371. }
  372. self.rail.css({top:pos.top,left:pos.left,height:(len)?len.h:self.win.innerHeight()});
  373. if (self.zoom) self.zoom.css({top:pos.top+1,left:pos.left-20});
  374. }
  375. };
  376. self.hasanimationframe = (setAnimationFrame);
  377. self.hascancelanimationframe = (clearAnimationFrame);
  378. if (!self.hasanimationframe) {
  379. setAnimationFrame=function(fn){return setTimeout(fn,16)}; // 1000/60)};
  380. clearAnimationFrame=clearInterval;
  381. }
  382. else if (!self.hascancelanimationframe) clearAnimationFrame=function(){self.cancelAnimationFrame=true};
  383. this.init = function() {
  384. self.saved.css = [];
  385. if (self.isie7mobile) return true; // SORRY, DO NOT WORK!
  386. // if (self.hasmstouch) $("html").css('-ms-content-zooming','none');
  387. if (self.hasmstouch) self.css((self.ispage)?$("html"):self.win,{'-ms-touch-action':'none'});
  388. if (!self.ispage || (!self.cantouch && !self.isieold && !self.isie9mobile)) {
  389. var cont = self.docscroll;
  390. if (self.ispage) cont = (self.haswrapper)?self.win:self.doc;
  391. if (!self.isie9mobile) self.css(cont,{'overflow-y':'hidden'});
  392. if (self.ispage&&self.isie7&&self.win[0].nodeName=='BODY') self.css($("html"),{'overflow-y':'hidden'}); //IE7 double scrollbar issue
  393. var cursor = $(document.createElement('div'));
  394. cursor.css({
  395. position:"relative",top:0,"float":"right",width:self.opt.cursorwidth,height:"0px",
  396. 'background-color':self.opt.cursorcolor,
  397. border:self.opt.cursorborder,
  398. 'background-clip':'padding-box',
  399. '-webkit-border-radius':self.opt.cursorborderradius,
  400. '-moz-border-radius':self.opt.cursorborderradius,
  401. 'border-radius':self.opt.cursorborderradius
  402. });
  403. cursor.hborder = parseFloat(cursor.outerHeight() - cursor.innerHeight());
  404. self.cursor = cursor;
  405. var rail = $(document.createElement('div'));
  406. rail.attr('id',self.id);
  407. rail.width = Math.max(parseFloat(self.opt.cursorwidth),cursor.outerWidth());
  408. rail.css({width:rail.width+"px",'zIndex':(self.ispage)?self.opt.zindex:self.opt.zindex+2,"background":self.opt.background});
  409. var kp = ["top","bottom","left","right"];
  410. for(var a in kp) {
  411. var v = self.opt.railpadding[a];
  412. if (v) rail.css("padding-"+a,v+"px");
  413. }
  414. rail.append(cursor);
  415. self.rail = rail;
  416. self.rail.drag = false;
  417. var zoom = false;
  418. if (self.opt.boxzoom&&!self.ispage&&!self.isieold) {
  419. zoom = document.createElement('div');
  420. self.bind(zoom,"click",self.doZoom);
  421. self.zoom = $(zoom);
  422. self.zoom.css({"cursor":"pointer",'z-index':self.opt.zindex,'backgroundImage':'url('+scriptpath+'zoomico.png)','height':18,'width':18,'backgroundPosition':'0px 0px'});
  423. if (self.opt.dblclickzoom) self.bind(self.win,"dblclick",self.doZoom);
  424. if (self.cantouch&&self.opt.gesturezoom) {
  425. self.ongesturezoom = function(e) {
  426. if (e.scale>1.5) self.doZoomIn(e);
  427. if (e.scale<0.8) self.doZoomOut(e);
  428. return self.cancelEvent(e);
  429. };
  430. self.bind(self.win,"gestureend",self.ongesturezoom);
  431. }
  432. }
  433. if (self.ispage) {
  434. rail.css({position:"fixed",top:"0px",right:"0px",height:"100%"});
  435. self.body.append(rail);
  436. } else {
  437. if (self.ishwscroll) {
  438. if (self.win.css('position')=='static') self.css(self.win,{'position':'relative'});
  439. var bd = (self.win[0].nodeName == 'HTML') ? self.body : self.win;
  440. if (self.zoom) {
  441. self.zoom.css({position:"absolute",top:1,right:0,"margin-right":rail.width+4});
  442. bd.append(self.zoom);
  443. }
  444. rail.css({position:"absolute",top:0,right:0});
  445. bd.append(rail);
  446. } else {
  447. rail.css({position:"absolute"});
  448. if (self.zoom) self.zoom.css({position:"absolute"});
  449. self.updateScrollBar();
  450. self.body.append(rail);
  451. if (self.zoom) self.body.append(self.zoom);
  452. }
  453. if (self.isios) self.css(self.win,{'-webkit-tap-highlight-color':'rgba(0,0,0,0)','-webkit-touch-callout':'none'}); // prevent grey layer on click
  454. }
  455. if (self.opt.autohidemode===false) {
  456. self.autohidedom = false;
  457. }
  458. else if (self.opt.autohidemode===true) {
  459. self.autohidedom = self.rail;
  460. }
  461. else if (self.opt.autohidemode=="cursor") {
  462. self.autohidedom = self.cursor;
  463. }
  464. if (self.isie9mobile) {
  465. self.scrollmom = {
  466. y:new ScrollMomentumClass(self)
  467. };
  468. self.onmangotouch = function(e) {
  469. var py = self.getScrollTop();
  470. if (py == self.scrollmom.y.lastscrolly) return true;
  471. var df = py-self.mangotouch.sy;
  472. if (df==0) return;
  473. var dr = (df<0)?-1:1;
  474. var tm = (new Date()).getTime();
  475. if (self.mangotouch.lazy) clearTimeout(self.mangotouch.lazy);
  476. if (((tm-self.mangotouch.tm)>60)||(self.mangotouch.dry!=dr)) {
  477. self.scrollmom.y.stop();
  478. self.scrollmom.y.reset(py);
  479. self.mangotouch.sy = py;
  480. self.mangotouch.ly = py;
  481. self.mangotouch.dry = dr;
  482. self.mangotouch.tm = tm;
  483. } else {
  484. self.scrollmom.y.stop();
  485. self.scrollmom.y.update(self.mangotouch.sy-df);
  486. var gap = tm - self.mangotouch.tm;
  487. self.mangotouch.tm = tm;
  488. var px = Math.abs(self.mangotouch.ly-py);
  489. self.mangotouch.ly = py;
  490. if (px>2) {
  491. self.mangotouch.lazy = setTimeout(function(){
  492. self.mangotouch.lazy = false;
  493. self.mangotouch.dry = 0;
  494. self.mangotouch.tm = 0;
  495. self.scrollmom.y.doMomentum(gap);
  496. },80);
  497. }
  498. }
  499. }
  500. var top = self.getScrollTop()
  501. self.mangotouch = {sy:top,ly:top,dry:0,lazy:false,tm:0};
  502. self.bind(self.docscroll,"scroll",self.onmangotouch);
  503. } else {
  504. if (self.cantouch||self.opt.touchbehavior||self.hasmstouch) {
  505. self.scrollmom = {
  506. y:new ScrollMomentumClass(self)
  507. };
  508. self.ontouchstart = function(e) {
  509. if (e.pointerType&&e.pointerType!=2) return false;
  510. if (!self.locked) {
  511. if (self.hasmstouch) {
  512. var tg = (e.target) ? e.target : false;
  513. while (tg) {
  514. var nc = $(tg).getNiceScroll();
  515. if ((nc.length>0)&&(nc[0].me == self.me)) break;
  516. if (nc.length>0) return false;
  517. if ((tg.nodeName=='DIV')&&(tg.id==self.id)) break;
  518. tg = (tg.parentNode) ? tg.parentNode : false;
  519. }
  520. }
  521. self.cancelScroll();
  522. self.rail.drag = {x:e.clientX,y:e.clientY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop(),pt:2};
  523. self.hasmoving = false;
  524. self.lastmouseup = false;
  525. self.scrollmom.y.reset(e.clientY);
  526. if (!self.cantouch&&!self.hasmstouch) {
  527. var tg = self.getTarget(e);
  528. var ip = (tg)?/INPUT|SELECT|TEXTAREA/i.test(tg.nodeName):false;
  529. if (!ip) return self.cancelEvent(e);
  530. if (/SUBMIT|CANCEL|BUTTON/i.test($(tg).attr('type'))) {
  531. pc = {"tg":tg,"click":false};
  532. self.preventclick = pc;
  533. }
  534. }
  535. }
  536. };
  537. self.ontouchend = function(e) {
  538. if (e.pointerType&&e.pointerType!=2) return false;
  539. if (self.rail.drag&&(self.rail.drag.pt==2)) {
  540. self.scrollmom.y.doMomentum();
  541. self.rail.drag = false;
  542. if (self.hasmoving) {
  543. self.hasmoving = false;
  544. self.lastmouseup = true;
  545. self.hideCursor();
  546. if (!self.cantouch) return self.cancelEvent(e);
  547. }
  548. }
  549. };
  550. self.ontouchmove = function(e) {
  551. if (e.pointerType&&e.pointerType!=2) return false;
  552. if (self.rail.drag&&(self.rail.drag.pt==2)) {
  553. if (self.cantouch&&(typeof e.original == "undefined")) return true; // prevent ios "ghost" events by clickable elements
  554. self.hasmoving = true;
  555. if (self.preventclick&&!self.preventclick.click) {
  556. self.preventclick.click = self.preventclick.tg.onclick||false;
  557. self.preventclick.tg.onclick = self.onpreventclick;
  558. }
  559. var fy = e.clientY;
  560. var my = (fy-self.rail.drag.y);
  561. var ny = self.rail.drag.st-my;
  562. if (self.ishwscroll) {
  563. if (ny<0) {
  564. ny = Math.round(ny/2);
  565. fy = 0;
  566. }
  567. else if (ny>self.page.maxh) {
  568. ny = self.page.maxh+Math.round((ny-self.page.maxh)/2);
  569. fy = 0;
  570. }
  571. } else {
  572. if (ny<0) ny=0;
  573. if (ny>self.page.maxh) ny=self.page.maxh;
  574. }
  575. self.synched("touchmove",function(){
  576. if (self.rail.drag&&(self.rail.drag.pt==2)) {
  577. if (self.prepareTransition) self.prepareTransition(0);
  578. self.setScrollTop(ny);
  579. self.showCursor(ny);
  580. self.scrollmom.y.update(fy);
  581. }
  582. });
  583. return self.cancelEvent(e);
  584. }
  585. };
  586. }
  587. if (self.cantouch||self.opt.touchbehavior) {
  588. self.onpreventclick = function(e) {
  589. if (self.preventclick) {
  590. self.preventclick.tg.onclick = self.preventclick.click;
  591. self.preventclick = false;
  592. return self.cancelEvent(e);
  593. }
  594. }
  595. self.onmousedown = self.ontouchstart;
  596. self.onmouseup = self.ontouchend;
  597. self.onclick = (self.isios) ? false : function(e) {
  598. if (self.lastmouseup) {
  599. self.lastmouseup = false;
  600. return self.cancelEvent(e);
  601. } else {
  602. return true;
  603. }
  604. };
  605. self.onmousemove = self.ontouchmove;
  606. if (self.cursorgrabvalue) {
  607. self.css((self.ispage)?self.doc:self.win,{'cursor':self.cursorgrabvalue});
  608. self.css(self.rail,{'cursor':self.cursorgrabvalue});
  609. }
  610. } else {
  611. self.onmousedown = function(e) {
  612. if (self.rail.drag&&self.rail.drag.pt!=1) return;
  613. if (self.locked) return self.cancelEvent(e);
  614. self.cancelScroll();
  615. self.rail.drag = {x:e.clientX,y:e.clientY,sx:self.scroll.x,sy:self.scroll.y,pt:1};
  616. return self.cancelEvent(e);
  617. };
  618. self.onmouseup = function(e) {
  619. if (self.rail.drag) {
  620. if(self.rail.drag.pt!=1)return;
  621. self.rail.drag = false;
  622. return self.cancelEvent(e);
  623. }
  624. };
  625. self.onmousemove = function(e) {
  626. if (self.rail.drag) {
  627. if(self.rail.drag.pt!=1)return;
  628. self.scroll.y = self.rail.drag.sy + (e.clientY-self.rail.drag.y);
  629. if (self.scroll.y<0) self.scroll.y=0;
  630. var my = self.scrollvaluemax;
  631. if (self.scroll.y>my) self.scroll.y=my;
  632. self.synched('mousemove',function(){
  633. if (self.rail.drag&&(self.rail.drag.pt==1)) {
  634. self.showCursor();
  635. self.cursorfreezed = true;
  636. self.doScroll(Math.round(self.scroll.y*self.scrollratio.y));
  637. }
  638. });
  639. return self.cancelEvent(e);
  640. } else {
  641. self.checkarea = true;
  642. }
  643. };
  644. }
  645. if (self.cantouch||self.opt.touchbehavior) {
  646. self.bind(self.win,"mousedown",self.onmousedown);
  647. }
  648. if (self.hasmstouch) {
  649. self.css(self.rail,{'-ms-touch-action':'none'});
  650. self.css(self.cursor,{'-ms-touch-action':'none'});
  651. self.bind(self.win,"MSPointerDown",self.ontouchstart);
  652. self.bind(document,"MSPointerUp",self.ontouchend);
  653. self.bind(document,"MSPointerMove",self.ontouchmove);
  654. self.bind(self.cursor,"MSGestureHold",function(e){e.preventDefault();});
  655. self.bind(self.cursor,"contextmenu",function(e){e.preventDefault();});
  656. }
  657. self.bind(self.cursor,"mousedown",self.onmousedown);
  658. self.bind(self.cursor,"mouseup",function(e) {
  659. if (self.rail.drag&&self.rail.drag.pt==2) return;
  660. self.rail.drag = false;
  661. self.hasmoving = false;
  662. self.hideCursor();
  663. return self.cancelEvent(e);
  664. });
  665. self.bind(document,"mouseup",self.onmouseup);
  666. self.bind(document,"mousemove",self.onmousemove);
  667. if (self.onclick) self.bind(document,"click",self.onclick);
  668. if (!self.cantouch) {
  669. self.rail.mouseenter(function() {
  670. self.showCursor();
  671. self.rail.active = true;
  672. });
  673. self.rail.mouseleave(function() {
  674. self.rail.active = false;
  675. if (!self.rail.drag) self.hideCursor();
  676. });
  677. if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
  678. self.bind(self.rail,"mousewheel",self.onmousewheel);
  679. }
  680. if (self.zoom) {
  681. self.zoom.mouseenter(function() {
  682. self.showCursor();
  683. self.rail.active = true;
  684. });
  685. self.zoom.mouseleave(function() {
  686. self.rail.active = false;
  687. if (!self.rail.drag) self.hideCursor();
  688. });
  689. }
  690. if (!self.ispage&&!self.cantouch&&!(/HTML|BODY/.test(self.win[0].nodeName))) {
  691. if (!self.win.attr("tabindex")) self.win.attr({"tabindex":tabindexcounter++});
  692. if (self.ischrome&&self.opt.disableoutline) self.win.css({"outline":"none"});
  693. self.win.focus(function(e) {
  694. domfocus = (self.getTarget(e)).id||true;
  695. self.hasfocus = true;
  696. self.noticeCursor();
  697. });
  698. self.win.blur(function(e) {
  699. domfocus = false;
  700. self.hasfocus = false;
  701. });
  702. self.win.mouseenter(function(e) {
  703. mousefocus = (self.getTarget(e)).id||true;
  704. self.hasmousefocus = true;
  705. self.noticeCursor();
  706. });
  707. self.win.mouseleave(function() {
  708. mousefocus = false;
  709. self.hasmousefocus = false;
  710. });
  711. };
  712. } // !ie9mobile
  713. //Thanks to http://www.quirksmode.org !!
  714. self.onkeypress = function(e) {
  715. if (self.locked&&self.page.maxh==0) return true;
  716. e = (e) ? e : window.e;
  717. var tg = self.getTarget(e);
  718. if (tg&&/INPUT|TEXTAREA|SELECT|OPTION/.test(tg.nodeName)) {
  719. var tp = tg.getAttribute('type')||tg.type||false;
  720. if ((!tp)||!(/submit|button|cancel/i.tp)) return true;
  721. }
  722. if (self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)) {
  723. var key = e.keyCode;
  724. if (self.locked&&key!=27) return self.cancelEvent(e);
  725. var ret = false;
  726. switch (key) {
  727. case 38:
  728. case 63233: //safari
  729. self.doScrollBy(24*3);
  730. ret = true;
  731. break;
  732. case 40:
  733. case 63235: //safari
  734. self.doScrollBy(-24*3);
  735. ret = true;
  736. break;
  737. case 33:
  738. case 63276: // safari
  739. self.doScrollBy(self.view.h);
  740. ret = true;
  741. break;
  742. case 34:
  743. case 63277: // safari
  744. self.doScrollBy(-self.view.h);
  745. ret = true;
  746. break;
  747. case 36:
  748. case 63273: // safari
  749. self.doScrollTo(0);
  750. ret = true;
  751. break;
  752. case 35:
  753. case 63275: // safari
  754. self.doScrollTo(self.page.maxh);
  755. ret = true;
  756. break;
  757. case 32:
  758. if (self.opt.spacebarenabled) {
  759. self.doScrollBy(-self.view.h);
  760. ret = true;
  761. }
  762. break;
  763. case 27: // ESC
  764. if (self.zoomactive) {
  765. self.doZoom();
  766. ret = true;
  767. }
  768. break;
  769. }
  770. if (ret) return self.cancelEvent(e);
  771. }
  772. };
  773. self.bind(document,(self.isopera)?"keypress":"keydown",self.onkeypress);
  774. self.bind(window,'resize',self.resize);
  775. self.bind(window,'orientationchange',self.resize);
  776. self.bind(window,"load",self.resize);
  777. // Trying a cross-browser implementation - good luck!
  778. self.onAttributeChange = function(e) {
  779. self.lazyResize();
  780. }
  781. if (!self.ispage&&!self.haswrapper) {
  782. // thanks to Filip http://stackoverflow.com/questions/1882224/
  783. if ("WebKitMutationObserver" in window) {
  784. var observer = new WebKitMutationObserver(function(mutations) {
  785. mutations.forEach(self.onAttributeChange);
  786. });
  787. observer.observe(self.win[0],{attributes:true,subtree:false});
  788. } else {
  789. self.bind(self.win,(self.isie&&!self.isie9)?"propertychange":"DOMAttrModified",self.onAttributeChange);
  790. if (self.isie9) self.win[0].attachEvent("onpropertychange",self.onAttributeChange); //IE9 DOMAttrModified bug
  791. }
  792. }
  793. //
  794. if (!self.ispage&&self.opt.boxzoom) self.bind(window,"resize",self.resizeZoom);
  795. if (self.istextarea) self.bind(self.win,"mouseup",self.resize);
  796. self.resize();
  797. }
  798. if (this.doc[0].nodeName == 'IFRAME') {
  799. function oniframeload(e) {
  800. self.iframexd = false;
  801. try {
  802. var doc = 'contentDocument' in this ? this.contentDocument : this.contentWindow.document;
  803. var a = doc.domain;
  804. } catch(e){self.iframexd = true;doc=false};
  805. if (self.iframexd) return true; //cross-domain - I can't manage this
  806. if (self.isiframe) {
  807. self.iframe = {
  808. html:self.doc.contents().find('html')[0],
  809. body:self.doc.contents().find('body')[0]
  810. };
  811. self.getContentSize = function(){
  812. return {
  813. w:Math.max(self.iframe.html.scrollWidth,self.iframe.body.scrollWidth),
  814. h:Math.max(self.iframe.html.scrollHeight,self.iframe.body.scrollHeight)
  815. }
  816. }
  817. self.docscroll = $(this.contentWindow);
  818. }
  819. if (self.opt.iframeautoresize&&!self.isiframe) {
  820. self.win.scrollTop(0); // reset position
  821. self.doc.height(""); //reset height to fix browser bug
  822. var hh=Math.max(doc.getElementsByTagName('html')[0].scrollHeight,doc.body.scrollHeight);
  823. self.doc.height(hh);
  824. }
  825. self.resize();
  826. if (self.isie7) self.css($(doc).find('html'),{'overflow-y':'hidden'});
  827. self.css($(doc.body),{'overflow-y':'hidden'});
  828. if ('contentWindow' in this) {
  829. self.bind(this.contentWindow,"scroll",self.onscroll); //IE8 & minor
  830. } else {
  831. self.bind(doc,"scroll",self.onscroll);
  832. }
  833. self.bind(doc,"mouseup",self.onmouseup);
  834. self.bind(doc,"mousewheel",self.onmousewheel);
  835. self.bind(doc,(self.isopera)?"keypress":"keydown",self.onkeypress);
  836. if (self.cantouch||self.opt.touchbehavior) {
  837. self.bind(doc,"mousedown",self.onmousedown);
  838. if (self.cursorgrabvalue) self.css($(doc.body),{'cursor':self.cursorgrabvalue});
  839. }
  840. self.bind(doc,"mousemove",self.onmousemove);
  841. if (self.zoom) {
  842. if (self.opt.dblclickzoom) self.bind(doc,'dblclick',self.doZoom);
  843. if (self.ongesturezoom) self.bind(doc,"gestureend",self.ongesturezoom);
  844. }
  845. };
  846. if (this.doc[0].readyState&&this.doc[0].readyState=="complete"){
  847. setTimeout(function(){oniframeload.call(self.doc[0],false)},500);
  848. }
  849. self.bind(this.doc,"load",oniframeload);
  850. }
  851. };
  852. this.showCursor = function(py) {
  853. if (self.cursortimeout) {
  854. clearTimeout(self.cursortimeout);
  855. self.cursortimeout = 0;
  856. }
  857. if (!self.rail) return;
  858. if (self.autohidedom) self.autohidedom.stop().css({opacity:self.opt.cursoropacitymax});
  859. if (typeof py != "undefined") {
  860. self.scroll.y = Math.round(py * 1/self.scrollratio.y);
  861. }
  862. self.cursor.css({height:self.cursorheight,top:self.scroll.y});
  863. if (self.zoom) self.zoom.stop().css({opacity:self.opt.cursoropacitymax});
  864. };
  865. this.hideCursor = function(tm) {
  866. if (self.cursortimeout) return;
  867. if (!self.rail) return;
  868. if (!self.autohidedom) return;
  869. self.cursortimeout = setTimeout(function() {
  870. if (!self.rail.active) {
  871. self.autohidedom.stop().animate({opacity:self.opt.cursoropacitymin});
  872. if (self.zoom) self.zoom.stop().animate({opacity:self.opt.cursoropacitymin});
  873. }
  874. self.cursortimeout = 0;
  875. },tm||400);
  876. };
  877. this.noticeCursor = function(tm,py) {
  878. self.showCursor(py);
  879. self.hideCursor(tm);
  880. };
  881. this.getContentSize =
  882. (self.ispage) ?
  883. function(){
  884. return {
  885. w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
  886. h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
  887. }
  888. }
  889. : (self.haswrapper) ?
  890. function(){
  891. return {
  892. w:self.doc.outerWidth()+parseInt(self.win.css('paddingLeft'))+parseInt(self.win.css('paddingRight')),
  893. h:self.doc.outerHeight()+parseInt(self.win.css('paddingTop'))+parseInt(self.win.css('paddingBottom'))
  894. }
  895. }
  896. : function() {
  897. return {
  898. w:self.docscroll[0].scrollWidth,
  899. h:self.docscroll[0].scrollHeight
  900. }
  901. };
  902. this.onResize = function(e,page) {
  903. if (!self.haswrapper&&!self.ispage) {
  904. if (self.win.css('display')=='none') {
  905. if (self.visibility) self.hideRail();
  906. return false;
  907. } else {
  908. if (!self.visibility&&(self.getScrollTop()==0)) self.doScrollTo(Math.floor(self.scroll.y*self.scrollratio.y));
  909. if (!self.hidden&&!self.visibility) self.showRail();
  910. }
  911. }
  912. var premaxh = self.page.maxh;
  913. var premaxw = self.page.maxw;
  914. var preview = {h:self.view.h,w:self.view.w};
  915. self.view = {
  916. w:(self.ispage) ? self.win.width() : parseInt(self.win[0].clientWidth),
  917. h:(self.ispage) ? self.win.height() : parseInt(self.win[0].clientHeight)
  918. };
  919. self.page = (page) ? page : self.getContentSize();
  920. self.page.maxh = Math.max(0,self.page.h - self.view.h);
  921. self.page.maxw = Math.max(0,self.page.w - self.view.w);
  922. if ((self.page.maxh==premaxh)&&(self.page.maxw==premaxw)&&(self.view.w==preview.w)) {
  923. // test position
  924. if (!self.ispage) {
  925. var pos = self.win.offset();
  926. if (self.lastposition) {
  927. var lst = self.lastposition;
  928. if ((lst.top==pos.top)&&(lst.left==pos.left)) return self; //nothing to do
  929. }
  930. self.lastposition = pos;
  931. } else {
  932. return self; //nothing to do
  933. }
  934. }
  935. if (self.page.maxh==0) {
  936. self.hideRail();
  937. self.scrollvaluemax = 0;
  938. self.scroll.y = 0;
  939. self.scrollratio = {x:0,y:0};
  940. self.cursorheight = 0;
  941. self.locked = true;
  942. self.setScrollTop(0);
  943. return false;
  944. }
  945. else if (!self.hidden&&!self.visibility) {
  946. self.showRail();
  947. self.locked = false;
  948. }
  949. if (self.istextarea&&self.win.css('resize')&&self.win.css('resize')!='none') self.view.h-=20;
  950. if (!self.ispage) self.updateScrollBar(self.view);
  951. self.cursorheight = Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
  952. self.cursorheight = Math.max(self.opt.cursorminheight,self.cursorheight);
  953. self.scrollvaluemax = self.view.h-self.cursorheight-self.cursor.hborder;
  954. self.scrollratio = {
  955. x:0,
  956. y:(self.page.maxh/self.scrollvaluemax)
  957. };
  958. var sy = self.getScrollTop();
  959. if (sy>self.page.maxh) {
  960. self.doScroll(self.page.maxh);
  961. } else {
  962. self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
  963. self.noticeCursor();
  964. }
  965. return self;
  966. };
  967. this.resize = this.onResize; // hide internal method -- in future name can change
  968. this.lazyResize = function() {
  969. self.delayed('resize',self.resize,250);
  970. }
  971. this._bind = function(el,name,fn,bubble) { // primitive bind
  972. self.events.push({e:el,n:name,f:fn});
  973. if (el.addEventListener) {
  974. el.addEventListener(name,fn,bubble||false);
  975. }
  976. else if (el.attachEvent) {
  977. el.attachEvent("on"+name,fn);
  978. }
  979. else {
  980. el["on"+name] = fn;
  981. }
  982. };
  983. this.bind = function(dom,name,fn,bubble) { // touch-oriented & fixing jquery bind
  984. var el = ("jquery" in dom) ? dom[0] : dom;
  985. if (el.addEventListener) {
  986. if (self.cantouch && /mouseup|mousedown|mousemove/.test(name)) { // touch device support
  987. var tt=(name=='mousedown')?'touchstart':(name=='mouseup')?'touchend':'touchmove';
  988. self._bind(el,tt,function(e){
  989. if (e.touches) {
  990. if (e.touches.length<2) {var ev=(e.touches.length)?e.touches[0]:e;ev.original=e;fn.call(this,ev);}
  991. }
  992. else if (e.changedTouches) {var ev=e.changedTouches[0];ev.original=e;fn.call(this,ev);} //blackberry
  993. },bubble||false);
  994. }
  995. self._bind(el,name,fn,bubble||false);
  996. if (name=='mousewheel') self._bind(el,"DOMMouseScroll",fn,bubble||false);
  997. if (self.cantouch && name=="mouseup") self._bind(el,"touchcancel",fn,bubble||false);
  998. }
  999. else {
  1000. self._bind(el,name,function(e) {
  1001. e = e||window.event||false;
  1002. if (e) {
  1003. if (e.srcElement) e.target=e.srcElement;
  1004. }
  1005. return ((fn.call(el,e)===false)||bubble===false) ? self.cancelEvent(e) : true;
  1006. });
  1007. }
  1008. };
  1009. this._unbind = function(el,name,fn) { // primitive unbind
  1010. if (el.removeEventListener) {
  1011. el.removeEventListener(name,fn,false);
  1012. }
  1013. else if (el.detachEvent) {
  1014. el.detachEvent('on'+name,fn);
  1015. } else {
  1016. el['on'+name] = false;
  1017. }
  1018. };
  1019. this.unbindAll = function() {
  1020. for(var a=0;a<self.events.length;a++) {
  1021. var r = self.events[a];
  1022. self._unbind(r.e,r.n,r.f);
  1023. }
  1024. };
  1025. // Thanks to http://www.switchonthecode.com !!
  1026. this.cancelEvent = function(e) {
  1027. var e = (e.original) ? e.original : (e) ? e : window.event||false;
  1028. if (!e) return false;
  1029. if(e.preventDefault) e.preventDefault();
  1030. if(e.stopPropagation) e.stopPropagation();
  1031. if(e.preventManipulation) e.preventManipulation(); //IE10
  1032. e.cancelBubble = true;
  1033. e.cancel = true;
  1034. e.returnValue = false;
  1035. return false;
  1036. };
  1037. this.showRail = function() {
  1038. if ((self.page.maxh!=0)&&(self.ispage||self.win.css('display')!='none')) {
  1039. self.visibility = true;
  1040. self.rail.css('display','block');
  1041. }
  1042. return self;
  1043. };
  1044. this.hideRail = function() {
  1045. self.visibility = false;
  1046. self.rail.css('display','none');
  1047. return self;
  1048. };
  1049. this.show = function() {
  1050. self.hidden = false;
  1051. self.locked = false;
  1052. return self.showRail();
  1053. };
  1054. this.hide = function() {
  1055. self.hidden = true;
  1056. self.locked = true;
  1057. return self.hideRail();
  1058. };
  1059. this.remove = function() {
  1060. self.doZoomOut();
  1061. self.unbindAll();
  1062. self.events = [];
  1063. self.rail.remove();
  1064. if (self.zoom) self.zoom.remove();
  1065. self.cursor = false;
  1066. self.rail = false;
  1067. self.zoom = false;
  1068. for(var a=0;a<self.saved.css.length;a++) {
  1069. var d=self.saved.css[a];
  1070. d[0].css(d[1],(typeof d[2]=="undefined") ? '' : d[2]);
  1071. }
  1072. self.saved = false;
  1073. self.me.data('__nicescroll',''); //erase all traces
  1074. return self;
  1075. };
  1076. this.isScrollable = function(e) {
  1077. var dom = (e.target) ? e.target : e;
  1078. while (dom&&dom.nodeName&&!(/BODY|HTML/.test(dom.nodeName))) {
  1079. var dd = $(dom);
  1080. var ov = dd.css('overflowY')||dd.css('overflow')||'';
  1081. if (/scroll|auto/.test(ov)) return (dom.clientHeight!=dom.scrollHeight);
  1082. dom = (dom.parentNode) ? dom.parentNode : false;
  1083. }
  1084. return false;
  1085. };
  1086. this.onmousewheel = function(e) {
  1087. if (self.locked&&self.page.maxh==0) return true;
  1088. if (self.opt.preservenativescrolling&&self.checkarea) {
  1089. self.checkarea = false;
  1090. self.nativescrollingarea = self.isScrollable(e);
  1091. }
  1092. if (self.nativescrollingarea) return true; // this isn't my business
  1093. if (self.locked) return self.cancelEvent(e);
  1094. if (self.rail.drag) return self.cancelEvent(e);
  1095. var delta = 0;
  1096. var delta = e.detail ? e.detail * -1 : e.wheelDelta / 40;
  1097. if (delta) {
  1098. if (self.scrollmom) self.scrollmom.y.stop();
  1099. self.lastdelta += (delta*self.opt.mousescrollstep);
  1100. self.synched("mousewheel",function(){if(!self.rail.drag){var dt=self.lastdelta;self.lastdelta=0;self.doScrollBy(dt)}});
  1101. }
  1102. return self.cancelEvent(e);
  1103. };
  1104. this.stop = function() {
  1105. self.cancelScroll();
  1106. if (self.scrollmon) self.scrollmon.stop();
  1107. self.cursorfreezed = false;
  1108. self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
  1109. self.noticeCursor();
  1110. return self;
  1111. };
  1112. if (self.ishwscroll&&self.hastransition&&self.opt.usetransition) {
  1113. this.prepareTransition = function(dif,trend) {
  1114. var sp = Math.round(self.opt.scrollspeed*10);
  1115. var ex = Math.min(sp,Math.round((dif / 20) * self.opt.scrollspeed));
  1116. var trans = (ex>20) ? self.prefixstyle+'transform '+ex+'ms ease-out 0s' : '';
  1117. if (!self.lasttransitionstyle||self.lasttransitionstyle!=trans) {
  1118. self.lasttransitionstyle = trans;
  1119. self.doc.css(self.transitionstyle,trans);
  1120. }
  1121. return ex;
  1122. };
  1123. this.doScroll = function(y,spd) { //trans
  1124. var sy = self.getScrollTop();
  1125. if (y<0&&sy<=0) return self.noticeCursor();
  1126. else if (y>self.page.maxh&&sy>=self.page.maxh) {
  1127. self.checkContentSize();
  1128. return self.noticeCursor();
  1129. }
  1130. self.newscrolly = y;
  1131. self.newscrollspeed = spd||false;
  1132. if (self.timer) return false;
  1133. if (!self.scrollendtrapped) {
  1134. self.scrollendtrapped = true;
  1135. self.bind(self.doc,self.transitionend,self.onScrollEnd,false); //I have got to do something usefull!!
  1136. }
  1137. self.timer = setTimeout(function(){
  1138. var top = self.getScrollTop();
  1139. var dif = (self.newscrollspeed)?self.newscrollspeed:Math.abs(top-self.newscrolly);
  1140. var ms = self.prepareTransition(dif);
  1141. self.timer = setTimeout(function(){
  1142. if (self.newscrolly<0&&!self.opt.bouncescroll) self.newscrolly = 0
  1143. else if (self.newscrolly>self.page.maxh&&!self.opt.bouncescroll) self.newscrolly = self.page.maxh;
  1144. if (self.newscrolly==self.getScrollTop()) {
  1145. self.timer = 0;
  1146. self.onScrollEnd();
  1147. } else {
  1148. var py = self.getScrollTop();
  1149. if (self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
  1150. if (ms>0) {
  1151. self.timerscroll = {
  1152. ts:(new Date()).getTime(),
  1153. s:self.getScrollTop(),
  1154. e:self.newscrolly,
  1155. sp:ms,
  1156. bz: new BezierClass(py,self.newscrolly,ms,0,1,0,1)
  1157. };
  1158. if (!self.cursorfreezed) self.timerscroll.tm=setInterval(function(){self.showCursor(self.getScrollTop())},60);
  1159. }
  1160. self.setScrollTop(self.newscrolly);
  1161. self.timer = 0;
  1162. }
  1163. // self.noticeCursor();
  1164. },15);
  1165. },self.opt.scrollspeed);
  1166. };
  1167. this.cancelScroll = function() {
  1168. if (!self.scrollendtrapped) return true;
  1169. var py = self.getScrollTop();
  1170. self.scrollendtrapped = false;
  1171. self._unbind(self.doc,self.transitionend,self.onScrollEnd);
  1172. self.prepareTransition(0);
  1173. self.setScrollTop(py); // fire event onscroll
  1174. if (self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
  1175. self.timerscroll = false;
  1176. self.cursorfreezed = false;
  1177. // self.scrollstart = false;
  1178. self.noticeCursor(false,py);
  1179. return self;
  1180. };
  1181. this.onScrollEnd = function() {
  1182. self.scrollendtrapped = false;
  1183. self._unbind(self.doc,self.transitionend,self.onScrollEnd);
  1184. if (self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
  1185. self.timerscroll = false;
  1186. self.cursorfreezed = false;
  1187. var py = self.getScrollTop();
  1188. self.setScrollTop(py); // fire event onscroll
  1189. self.noticeCursor(false,py);
  1190. if (py<0) self.doScroll(0,60)
  1191. else if (py>self.page.maxh) self.doScroll(self.page.maxh,60);
  1192. // else self.checkContentSize();
  1193. };
  1194. } else {
  1195. this.doScroll = function(y) { //no-trans
  1196. if (self.newscrolly==y) return true;
  1197. var py = self.getScrollTop();
  1198. self.newscrolly = y;
  1199. if (!self.bouncescroll) {
  1200. if (self.newscrolly<0) {
  1201. if (self.newspeedy) self.newspeedy.x = 0;
  1202. self.newscrolly = 0;
  1203. }
  1204. else if (self.newscrolly>self.page.maxh) {
  1205. if (self.newspeedy) self.newspeedy.x = self.page.maxh;
  1206. self.newscrolly = self.page.maxh;
  1207. }
  1208. }
  1209. var mg = Math.floor(Math.abs(y-py)/40);
  1210. if (mg>0) {
  1211. var ms = Math.min(10,mg)*100;
  1212. self.bzscroll = (self.bzscroll) ? self.bzscroll.update(y,ms) : new BezierClass(py,y,ms,0,1,0,1);
  1213. } else {
  1214. self.bzscroll = false;
  1215. }
  1216. if (self.timer) return;
  1217. if (py==self.page.maxh&&y>=self.page.maxh) self.checkContentSize();
  1218. var sync = 1;
  1219. function scrolling() {
  1220. if (self.cancelAnimationFrame) return true;
  1221. sync = 1-sync;
  1222. if (sync) return (self.timer = setAnimationFrame(scrolling)||1);
  1223. var sy = self.getScrollTop();
  1224. var sc = (self.bzscroll) ? self.bzscroll.getNow() : self.newscrolly;
  1225. var dr=sc-sy;
  1226. if ((dr<0&&sc<self.newscrolly)||(dr>0&&sc>self.newscrolly)) sc = self.newscrolly;
  1227. self.setScrollTop(sc);
  1228. if (sc == self.newscrolly) {
  1229. // clearAnimationFrame(self.timer);
  1230. self.timer = 0;
  1231. self.cursorfreezed = false;
  1232. self.bzscroll = false;
  1233. if (sc<0) self.doScroll(0);
  1234. else if (sc>self.page.maxh) self.doScroll(self.page.maxh);
  1235. // else self.checkContentSize();
  1236. } else {
  1237. self.timer = setAnimationFrame(scrolling)||1;
  1238. }
  1239. };
  1240. self.cancelAnimationFrame=false;
  1241. self.timer = 1;
  1242. scrolling();
  1243. if (py==self.page.maxh&&y>=py) self.checkContentSize();
  1244. self.noticeCursor();
  1245. };
  1246. this.cancelScroll = function() {
  1247. if (self.timer) clearAnimationFrame(self.timer);
  1248. self.timer = 0;
  1249. self.bzscroll = false;
  1250. return self;
  1251. };
  1252. }
  1253. this.doScrollBy = function(stp,relative) {
  1254. var ny = 0;
  1255. if (relative) {
  1256. ny = Math.floor((self.scroll.y-stp)*self.scrollratio.y)
  1257. } else {
  1258. var sy = (self.timer) ? self.newscrolly : self.getScrollTop(true);
  1259. ny = sy-stp;
  1260. }
  1261. if (self.bouncescroll) {
  1262. var haf = Math.round(self.view.h/2);
  1263. if (ny<-haf) ny=-haf
  1264. else if (ny>(self.page.maxh+haf)) ny = (self.page.maxh+haf);
  1265. }
  1266. self.cursorfreezed = false;
  1267. self.doScroll(ny);
  1268. };
  1269. this.doScrollTo = function(pos,relative) {
  1270. var ny = (relative) ? Math.round(pos*self.scrollratio.y) : pos;
  1271. if (ny<0) ny=0
  1272. else if (ny>self.page.maxh) ny = self.page.maxh;
  1273. self.cursorfreezed = false;
  1274. self.doScroll(pos);
  1275. };
  1276. this.checkContentSize = function() {
  1277. var pg = self.getContentSize();
  1278. if (pg.h!=self.page.h) self.resize(false,pg);
  1279. };
  1280. self.onscroll = function(e) {
  1281. if (self.rail.drag) return;
  1282. if (!self.cursorfreezed) {
  1283. /*
  1284. self.delayed('onscroll',function(){
  1285. self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
  1286. self.noticeCursor();
  1287. },30);
  1288. */
  1289. self.synched('scroll',function(){
  1290. self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
  1291. self.noticeCursor();
  1292. });
  1293. }
  1294. };
  1295. self.bind(self.docscroll,"scroll",self.onscroll);
  1296. this.doZoomIn = function(e) {
  1297. if (self.zoomactive) return;
  1298. self.zoomactive = true;
  1299. self.zoomrestore = {
  1300. style:{}
  1301. };
  1302. var lst = ['position','top','left','zIndex','backgroundColor','marginTop','marginBottom','marginLeft','marginRight'];
  1303. var win = self.win[0].style;
  1304. for(var a in lst) {
  1305. var pp = lst[a];
  1306. self.zoomrestore.style[pp] = (typeof win[pp]!='undefined') ? win[pp] : '';
  1307. }
  1308. self.zoomrestore.style.width = self.win.css('width');
  1309. self.zoomrestore.style.height = self.win.css('height');
  1310. self.zoomrestore.padding = {
  1311. w:self.win.outerWidth()-self.win.width(),
  1312. h:self.win.outerHeight()-self.win.height()
  1313. };
  1314. if (self.isios4) {
  1315. self.zoomrestore.scrollTop = $(window).scrollTop();
  1316. $(window).scrollTop(0);
  1317. }
  1318. self.win.css({
  1319. "position":(self.isios4)?"absolute":"fixed",
  1320. "top":0,
  1321. "left":0,
  1322. "z-index":self.opt.zindex+100,
  1323. "margin":"0px"
  1324. });
  1325. var bkg = self.win.css("backgroundColor");
  1326. if (bkg==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg)) self.win.css("backgroundColor","#fff");
  1327. self.rail.css({"z-index":self.opt.zindex+110});
  1328. self.zoom.css({"z-index":self.opt.zindex+112});
  1329. self.zoom.css('backgroundPosition','0px -18px');
  1330. self.resizeZoom();
  1331. return self.cancelEvent(e);
  1332. };
  1333. this.doZoomOut = function(e) {
  1334. if (!self.zoomactive) return;
  1335. self.zoomactive = false;
  1336. self.win.css("margin","");
  1337. self.win.css(self.zoomrestore.style);
  1338. if (self.isios4) {
  1339. $(window).scrollTop(self.zoomrestore.scrollTop);
  1340. }
  1341. self.rail.css({"z-index":(self.ispage)?self.opt.zindex:self.opt.zindex+2});
  1342. self.zoom.css({"z-index":self.opt.zindex});
  1343. self.zoomrestore = false;
  1344. self.zoom.css('backgroundPosition','0px 0px');
  1345. self.onResize();
  1346. return self.cancelEvent(e);
  1347. };
  1348. this.doZoom = function(e) {
  1349. return (self.zoomactive) ? self.doZoomOut(e) : self.doZoomIn(e);
  1350. };
  1351. this.resizeZoom = function() {
  1352. if (!self.zoomactive) return;
  1353. var py = self.getScrollTop(); //preserve scrolling position
  1354. self.win.css({
  1355. width:$(window).width()-self.zoomrestore.padding.w+"px",
  1356. height:$(window).height()-self.zoomrestore.padding.h+"px"
  1357. });
  1358. self.onResize();
  1359. self.setScrollTop(Math.min(self.page.maxh,py));
  1360. };
  1361. this.init();
  1362. $.nicescroll.push(this);
  1363. };
  1364. // Inspired by the work of Kin Blas
  1365. // http://webpro.host.adobe.com/people/jblas/momentum/includes/jquery.momentum.0.7.js
  1366. var ScrollMomentumClass = function(nc) {
  1367. var self = this;
  1368. this.nc = nc;
  1369. this.lasty = 0;
  1370. this.speedy = 0;
  1371. this.lasttime = 0;
  1372. this.snapy = false;
  1373. this.demuly = 0;
  1374. this.lastscrolly = -1;
  1375. this.chky = 0;
  1376. this.timer = 0;
  1377. this.time = function() {
  1378. return (new Date()).getTime();
  1379. };
  1380. this.reset = function(py) {
  1381. self.stop();
  1382. self.lasttime = self.time();
  1383. self.speedy = 0;
  1384. self.lasty = py;
  1385. self.lastscrolly = -1;
  1386. };
  1387. this.update = function(py) {
  1388. self.lasttime = self.time();
  1389. var dy = py - self.lasty;
  1390. var sy = nc.getScrollTop();
  1391. var newy = sy + dy;
  1392. self.snapy = (newy<0)||(newy>self.nc.page.maxh);
  1393. self.speedy = dy;
  1394. self.lasty = py;
  1395. };
  1396. this.stop = function() {
  1397. if (self.timer) {
  1398. clearTimeout(self.timer);
  1399. self.timer = 0;
  1400. self.lastscrolly = -1;
  1401. }
  1402. };
  1403. this.doSnapy = function(ny) {
  1404. if (ny<0) {
  1405. self.nc.doScroll(0,60);
  1406. }
  1407. else if (ny>self.nc.page.maxh) {
  1408. self.nc.doScroll(self.nc.page.maxh,60);
  1409. }
  1410. };
  1411. this.doMomentum = function(tm) {
  1412. var t = self.time();
  1413. var l = (tm) ? t+tm : self.lasttime;
  1414. self.speedy = Math.min(60,self.speedy);
  1415. var chk = l && (t - l) <= 50;
  1416. var sy = (self.speedy && chk) ? self.speedy : false;
  1417. if (sy) {
  1418. var tm = t-l;
  1419. var pageh = self.nc.page.maxh;
  1420. self.demuly = 0;
  1421. self.lastscrolly = self.nc.getScrollTop();
  1422. self.chky = self.lastscrolly;
  1423. var onscroll = function(){
  1424. // var ny = Math.floor(self.nc.getScrollTop() - (self.speedy*(1-self.demuly)));
  1425. var ny = Math.floor(self.lastscrolly - (self.speedy*(1-self.demuly)));
  1426. if ((ny<0)||(ny>pageh)) {
  1427. self.demuly+=0.08;
  1428. } else {
  1429. self.demuly+=0.01;
  1430. }
  1431. self.lastscrolly = ny;
  1432. self.nc.synched("domomentum",function(){
  1433. var scy = self.nc.getScrollTop();
  1434. if (scy!=self.chky) self.stop();
  1435. self.chky=ny;
  1436. self.nc.setScrollTop(ny);
  1437. if(self.timer) {
  1438. self.nc.showCursor(ny);
  1439. } else {
  1440. self.nc.hideCursor();
  1441. self.doSnapy(ny);
  1442. }
  1443. });
  1444. if(self.demuly<1) {
  1445. self.timer = setTimeout(onscroll,tm);
  1446. } else {
  1447. self.timer = 0;
  1448. // self.nc.hideCursor();
  1449. // self.doSnapy(ny);
  1450. }
  1451. };
  1452. onscroll();
  1453. } else {
  1454. if (self.snapy) {
  1455. self.doSnapy(self.nc.getScrollTop());
  1456. }
  1457. }
  1458. }
  1459. };
  1460. // override jQuery scrollTop
  1461. var _scrollTop = jQuery.fn.scrollTop; // preserve original function
  1462. $.cssHooks.scrollTop = {
  1463. get: function(elem,computed,extra) {
  1464. var nice = $.data(elem,'__nicescroll')||false;
  1465. return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(elem);
  1466. },
  1467. set: function(elem,value) {
  1468. var nice = $.data(elem,'__nicescroll')||false;
  1469. (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call(elem,value);
  1470. return this;
  1471. }
  1472. };
  1473. /* ====================================> TO INSPECT
  1474. $.fx.step["scrollTop"] = function(fx){
  1475. if (fx.start=='') fx.start=$.cssHooks.scrollTop.get(fx.elem);
  1476. $.cssHooks.scrollTop.set(fx.elem,fx.now+fx.unit);
  1477. };
  1478. */
  1479. jQuery.fn.scrollTop = function(value) {
  1480. if (typeof value == "undefined") {
  1481. var nice = (this[0]) ? $.data(this[0],'__nicescroll')||false : false;
  1482. return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(this);
  1483. } else {
  1484. return this.each(function() {
  1485. var nice = $.data(this,'__nicescroll')||false;
  1486. (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call($(this),value);
  1487. });
  1488. }
  1489. }
  1490. var NiceScrollArray = function(doms) {
  1491. var self = this;
  1492. this.length = 0;
  1493. this.name = "nicescrollarray";
  1494. this.each = function(fn) {
  1495. for(var a=0;a<self.length;a++) fn.call(self[a]);
  1496. return self;
  1497. };
  1498. this.push = function(nice) {
  1499. self[self.length]=nice;
  1500. self.length++;
  1501. };
  1502. this.eq = function(idx) {
  1503. return self[idx];
  1504. };
  1505. if (doms) {
  1506. for(a=0;a<doms.length;a++) {
  1507. var nice = $.data(doms[a],'__nicescroll')||false;
  1508. if (nice) {
  1509. this[this.length]=nice;
  1510. this.length++;
  1511. }
  1512. };
  1513. }
  1514. return this;
  1515. };
  1516. function mplex(el,lst,fn) {
  1517. for(var a=0;a<lst.length;a++) fn(el,lst[a]);
  1518. };
  1519. mplex(
  1520. NiceScrollArray.prototype,
  1521. ['show','hide','onResize','resize','remove','stop'],
  1522. function(e,n) {
  1523. e[n] = function(){
  1524. return this.each(function(){
  1525. this[n].call();
  1526. });
  1527. };
  1528. }
  1529. );
  1530. jQuery.fn.getNiceScroll = function(index) {
  1531. if (typeof index == "undefined") {
  1532. return new NiceScrollArray(this);
  1533. } else {
  1534. var nice = $.data(this[index],'__nicescroll')||false;
  1535. return nice;
  1536. }
  1537. };
  1538. jQuery.extend(jQuery.expr[':'], {
  1539. nicescroll: function(a) {
  1540. return ($.data(a,'__nicescroll'))?true:false;
  1541. }
  1542. });
  1543. $.fn.niceScroll = function(wrapper,opt) {
  1544. if (typeof opt=="undefined") {
  1545. if ((typeof wrapper=="object")&&!("jquery" in wrapper)) {
  1546. opt = wrapper;
  1547. wrapper = false;
  1548. }
  1549. }
  1550. var ret = new NiceScrollArray();
  1551. if (typeof opt=="undefined") opt = {};
  1552. if (wrapper||false) {
  1553. opt.doc = $(wrapper);
  1554. opt.win = $(this);
  1555. }
  1556. var docundef = !("doc" in opt);
  1557. if (!docundef&&!("win" in opt)) opt.win = $(this);
  1558. this.each(function() {
  1559. var nice = $(this).data('__nicescroll')||false;
  1560. if (!nice) {
  1561. opt.doc = (docundef) ? $(this) : opt.doc;
  1562. nice = new NiceScrollClass(opt,$(this));
  1563. $(this).data('__nicescroll',nice);
  1564. }
  1565. ret.push(nice);
  1566. });
  1567. return (ret.length==1) ? ret[0] : ret;
  1568. };
  1569. window.NiceScroll = {
  1570. getjQuery:function(){return jQuery}
  1571. };
  1572. if (!$.nicescroll) {
  1573. $.nicescroll = new NiceScrollArray();
  1574. }
  1575. })( jQuery );