PageSourceSearch

https://invest-in-wroclaw.pl/themes/js/vendor/jquery.mCustomScrollbar.js

js invest-in-wroclaw.pl collected 2026-10-02 10:26:38 UTC 40,752 bytes, 1,747 lines download raw bytes

1/* 
2
3== malihu jquery custom scrollbars plugin == 
4
5version: 2.3.2 
6
7author: malihu (http://manos.malihu.gr) 
8
9plugin home: http://manos.malihu.gr/jquery-custom-content-scroller 
10
11*/
12
13(function($){
14
15  var methods={
16
17		init:function(options){
18
19			var defaults={ 
20
21				set_width:false, /*optional element width: boolean, pixels, percentage*/
22
23				set_height:false, /*optional element height: boolean, pixels, percentage*/
24
25				horizontalScroll:false, /*scroll horizontally: boolean*/
26
27				scrollInertia:550, /*scrolling inertia: integer (milliseconds)*/
28
29				scrollEasing:"easeOutCirc", /*scrolling easing: string*/
30
31				mouseWheel:"pixels", /*mousewheel support and velocity: boolean, "auto", integer, "pixels"*/
32
33				mouseWheelPixels:60, /*mousewheel pixels amount: integer*/
34
35				autoDraggerLength:true, /*auto-adjust scrollbar dragger length: boolean*/
36
37				scrollButtons:{ /*scroll buttons*/
38
39					enable:false, /*scroll buttons support: boolean*/
40
41					scrollType:"continuous", /*scroll buttons scrolling type: "continuous", "pixels"*/
42
43					scrollSpeed:20, /*scroll buttons continuous scrolling speed: integer*/
44
45					scrollAmount:40 /*scroll buttons pixels scroll amount: integer (pixels)*/
46
47				},
48
49				advanced:{
50
51					updateOnBrowserResize:true, /*update scrollbars on browser resize (for layouts based on percentages): boolean*/
52
53					updateOnContentResize:false, /*auto-update scrollbars on content resize (for dynamic content): boolean*/
54
55					autoExpandHorizontalScroll:false, /*auto-expand width for horizontal scrolling: boolean*/
56
57					autoScrollOnFocus:true /*auto-scroll on focused elements: boolean*/
58
59				},
60
61				callbacks:{
62
63					onScrollStart:function(){}, /*user custom callback function on scroll start event*/
64
65					onScroll:function(){}, /*user custom callback function on scroll event*/
66
67					onTotalScroll:function(){}, /*user custom callback function on scroll end reached event*/
68
69					onTotalScrollBack:function(){}, /*user custom callback function on scroll begin reached event*/
70
71					onTotalScrollOffset:0, /*scroll end reached offset: integer (pixels)*/
72
73					whileScrolling:false, /*user custom callback function on scrolling event*/
74
75					whileScrollingInterval:30 /*interval for calling whileScrolling callback: integer (milliseconds)*/
76
77				}
78
79			},
80
81			options=$.extend(true,defaults,options);
82
83			/*check for touch device*/
84
85			$(document).data("mCS-is-touch-device",false);
86
87			if(is_touch_device()){
88
89				$(document).data("mCS-is-touch-device",true); 
90
91			}
92
93			function is_touch_device(){
94
95				return !!("ontouchstart" in window) ? 1 : 0;
96
97			}
98
99			return this.each(function(){
100
101				var $this=$(this);
102
103				/*set element width/height, create markup for custom scrollbars, add classes*/
104
105				if(options.set_width){
106
107					$this.css("width",options.set_width);
108
109				}
110
111				if(options.set_height){
112
113					$this.css("height",options.set_height);
114
115				}
116
117				if(!$(document).data("mCustomScrollbar-index")){
118
119					$(document).data("mCustomScrollbar-index","1");
120
121				}else{
122
123					var mCustomScrollbarIndex=parseInt($(document).data("mCustomScrollbar-index"));
124
125					$(document).data("mCustomScrollbar-index",mCustomScrollbarIndex+1);
126
127				}
128
129				$this.wrapInner("<div class='mCustomScrollBox' id='mCSB_"+$(document).data("mCustomScrollbar-index")+"' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />").addClass("mCustomScrollbar _mCS_"+$(document).data("mCustomScrollbar-index"));
130
131				var mCustomScrollBox=$this.children(".mCustomScrollBox");
132
133				if(options.horizontalScroll){
134
135					mCustomScrollBox.addClass("mCSB_horizontal").wrapInner("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />");
136
137					var mCSB_h_wrapper=mCustomScrollBox.children(".mCSB_h_wrapper");
138
139					mCSB_h_wrapper.wrapInner("<div class='mCSB_container' style='position:absolute; left:0;' />").children(".mCSB_container").css({"width":mCSB_h_wrapper.children().outerWidth(),"position":"relative"}).unwrap();
140
141				}else{
142
143					mCustomScrollBox.wrapInner("<div class='mCSB_container' style='position:relative; top:0;' />");
144
145				}
146
147				var mCSB_container=mCustomScrollBox.children(".mCSB_container");
148
149				if($(document).data("mCS-is-touch-device")){
150
151					mCSB_container.addClass("mCS_touch");
152
153				}
154
155				mCSB_container.after("<div class='mCSB_scrollTools' style='position:absolute;'><div class='mCSB_draggerContainer' style='position:relative;'><div class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' style='position:relative;'></div></div><div class='mCSB_draggerRail'></div></div></div>");
156
157				var mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
158
159					mCSB_draggerContainer=mCSB_scrollTools.children(".mCSB_draggerContainer"),
160
161					mCSB_dragger=mCSB_draggerContainer.children(".mCSB_dragger");
162
163				if(options.horizontalScroll){
164
165					mCSB_dragger.data("minDraggerWidth",mCSB_dragger.width());
166
167				}else{
168
169					mCSB_dragger.data("minDraggerHeight",mCSB_dragger.height());
170
171				}
172
173				if(options.scrollButtons.enable){
174
175					if(options.horizontalScroll){
176
177						mCSB_scrollTools.prepend("<a class='mCSB_buttonLeft' style='display:block; position:relative;'></a>").append("<a class='mCSB_buttonRight' style='display:block; position:relative;'></a>");
178
179					}else{
180
181						mCSB_scrollTools.prepend("<a class='mCSB_buttonUp' style='display:block; position:relative;'></a>").append("<a class='mCSB_buttonDown' style='display:block; position:relative;'></a>");
182
183					}
184
185				}
186
187				/*mCustomScrollBox scrollTop and scrollLeft is always 0 to prevent browser focus scrolling*/
188
189				mCustomScrollBox.bind("scroll",function(){
190
191					if(!$this.is(".mCS_disabled")){ /*native focus scrolling for disabled scrollbars*/
192
193						mCustomScrollBox.scrollTop(0).scrollLeft(0);
194
195					}
196
197				});
198
199				/*store options, global vars/states, intervals and update element*/
200
201				$this.data({
202
203					/*init state*/
204
205					"mCS_Init":true,
206
207					/*option parameters*/
208
209					"horizontalScroll":options.horizontalScroll,
210
211					"scrollInertia":options.scrollInertia,
212
213					"scrollEasing":options.scrollEasing,
214
215					"mouseWheel":options.mouseWheel,
216
217					"mouseWheelPixels":options.mouseWheelPixels,
218
219					"autoDraggerLength":options.autoDraggerLength,
220
221					"scrollButtons_enable":options.scrollButtons.enable,
222
223					"scrollButtons_scrollType":options.scrollButtons.scrollType,
224
225					"scrollButtons_scrollSpeed":options.scrollButtons.scrollSpeed,
226
227					"scrollButtons_scrollAmount":options.scrollButtons.scrollAmount,
228
229					"autoExpandHorizontalScroll":options.advanced.autoExpandHorizontalScroll,
230
231					"autoScrollOnFocus":options.advanced.autoScrollOnFocus,
232
233					"onScrollStart_Callback":options.callbacks.onScrollStart,
234
235					"onScroll_Callback":options.callbacks.onScroll,
236
237					"onTotalScroll_Callback":options.callbacks.onTotalScroll,
238
239					"onTotalScrollBack_Callback":options.callbacks.onTotalScrollBack,
240
241					"onTotalScroll_Offset":options.callbacks.onTotalScrollOffset,
242
243					"whileScrolling_Callback":options.callbacks.whileScrolling,
244
245					"whileScrolling_Interval":options.callbacks.whileScrollingInterval,
246
247					/*events binding state*/
248
249					"bindEvent_scrollbar_click":false,
250
251					"bindEvent_mousewheel":false,
252
253					"bindEvent_focusin":false,
254
255					"bindEvent_buttonsContinuous_y":false,
256
257					"bindEvent_buttonsContinuous_x":false,
258
259					"bindEvent_buttonsPixels_y":false,
260
261					"bindEvent_buttonsPixels_x":false,
262
263					"bindEvent_scrollbar_touch":false,
264
265					"bindEvent_content_touch":false,
266
267					/*buttons intervals*/
268
269					"mCSB_buttonScrollRight":false,
270
271					"mCSB_buttonScrollLeft":false,
272
273					"mCSB_buttonScrollDown":false,
274
275					"mCSB_buttonScrollUp":false,
276
277					/*callback intervals*/
278
279					"whileScrolling":false
280
281				}).mCustomScrollbar("update");
282
283				/*detect max-width*/
284
285				if(options.horizontalScroll){
286
287					if($this.css("max-width")!=="none"){
288
289						if(!options.advanced.updateOnContentResize){ /*needs updateOnContentResize*/
290
291							options.advanced.updateOnContentResize=true;
292
293						}
294
295						$this.data({"mCS_maxWidth":parseInt($this.css("max-width")),"mCS_maxWidth_Interval":setInterval(function(){
296
297							if(mCSB_container.outerWidth()>$this.data("mCS_maxWidth")){
298
299								clearInterval($this.data("mCS_maxWidth_Interval"));
300
301								$this.mCustomScrollbar("update");
302
303							}
304
305						},150)});
306
307					}
308
309				}else{
310
311					/*detect max-height*/
312
313					if($this.css("max-height")!=="none"){
314
315						$this.data({"mCS_maxHeight":parseInt($this.css("max-height")),"mCS_maxHeight_Interval":setInterval(function(){
316
317							mCustomScrollBox.css("max-height",$this.data("mCS_maxHeight"));
318
319							if(mCSB_container.outerHeight()>$this.data("mCS_maxHeight")){
320
321								clearInterval($this.data("mCS_maxHeight_Interval"));
322
323								$this.mCustomScrollbar("update");
324
325							}
326
327						},150)});
328
329					}
330
331				}
332
333				/*window resize fn (for layouts based on percentages)*/
334
335				if(options.advanced.updateOnBrowserResize){
336
337					var mCSB_resizeTimeout;
338
339					$(window).resize(function(){
340
341						if(mCSB_resizeTimeout){
342
343							clearTimeout(mCSB_resizeTimeout);
344
345						}
346
347						mCSB_resizeTimeout=setTimeout(function(){
348
349							if(!$this.is(".mCS_disabled") && !$this.is(".mCS_destroyed")){
350
351								$this.mCustomScrollbar("update");
352
353							}
354
355						},150);
356
357					});
358
359				}
360
361				/*content resize fn (for dynamically generated content)*/
362
363				if(options.advanced.updateOnContentResize){
364
365					var mCSB_onContentResize;
366
367					if(options.horizontalScroll){
368
369						var mCSB_containerOldSize=mCSB_container.outerWidth();
370
371					}else{
372
373						var mCSB_containerOldSize=mCSB_container.outerHeight();
374
375					}
376
377					mCSB_onContentResize=setInterval(function(){
378
379						if(options.horizontalScroll){
380
381							if(options.advanced.autoExpandHorizontalScroll){
382
383								mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
384
385							}
386
387							var mCSB_containerNewSize=mCSB_container.outerWidth();
388
389						}else{
390
391							var mCSB_containerNewSize=mCSB_container.outerHeight();
392
393						}
394
395						if(mCSB_containerNewSize!=mCSB_containerOldSize){
396
397							$this.mCustomScrollbar("update");
398
399							mCSB_containerOldSize=mCSB_containerNewSize;
400
401						}
402
403					},300);
404
405				}
406
407			});
408
409		},
410
411		update:function(){
412
413			var $this=$(this),
414
415				mCustomScrollBox=$this.children(".mCustomScrollBox"),
416
417				mCSB_container=mCustomScrollBox.children(".mCSB_container");
418
419			mCSB_container.removeClass("mCS_no_scrollbar");
420
421			$this.removeClass("mCS_disabled mCS_destroyed");
422
423			mCustomScrollBox.scrollTop(0).scrollLeft(0); /*reset scrollTop/scrollLeft to prevent browser focus scrolling*/
424
425			var mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
426
427				mCSB_draggerContainer=mCSB_scrollTools.children(".mCSB_draggerContainer"),
428
429				mCSB_dragger=mCSB_draggerContainer.children(".mCSB_dragger");
430
431			if($this.data("horizontalScroll")){
432
433				var mCSB_buttonLeft=mCSB_scrollTools.children(".mCSB_buttonLeft"),
434
435					mCSB_buttonRight=mCSB_scrollTools.children(".mCSB_buttonRight"),
436
437					mCustomScrollBoxW=mCustomScrollBox.width();
438
439				if($this.data("autoExpandHorizontalScroll")){
440
441					mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
442
443				}
444
445				var mCSB_containerW=mCSB_container.outerWidth();
446
447			}else{
448
449				var mCSB_buttonUp=mCSB_scrollTools.children(".mCSB_buttonUp"),
450
451					mCSB_buttonDown=mCSB_scrollTools.children(".mCSB_buttonDown"),
452
453					mCustomScrollBoxH=mCustomScrollBox.height(),
454
455					mCSB_containerH=mCSB_container.outerHeight();
456
457			}
458
459			if(mCSB_containerH>mCustomScrollBoxH && !$this.data("horizontalScroll")){ /*content needs vertical scrolling*/
460
461				mCSB_scrollTools.css("display","block");
462
463				var mCSB_draggerContainerH=mCSB_draggerContainer.height();
464
465				/*auto adjust scrollbar dragger length analogous to content*/
466
467				if($this.data("autoDraggerLength")){
468
469					var draggerH=Math.round(mCustomScrollBoxH/mCSB_containerH*mCSB_draggerContainerH),
470
471						minDraggerH=mCSB_dragger.data("minDraggerHeight");
472
473					if(draggerH<=minDraggerH){ /*min dragger height*/
474
475						mCSB_dragger.css({"height":minDraggerH});
476
477					}else if(draggerH>=mCSB_draggerContainerH-10){ /*max dragger height*/
478
479						var mCSB_draggerContainerMaxH=mCSB_draggerContainerH-10;
480
481						mCSB_dragger.css({"height":mCSB_draggerContainerMaxH});
482
483					}else{
484
485						mCSB_dragger.css({"height":draggerH});
486
487					}
488
489					mCSB_dragger.children(".mCSB_dragger_bar").css({"line-height":mCSB_dragger.height()+"px"});
490
491				}
492
493				var mCSB_draggerH=mCSB_dragger.height(),
494
495				/*calculate and store scroll amount, add scrolling*/
496
497					scrollAmount=(mCSB_containerH-mCustomScrollBoxH)/(mCSB_draggerContainerH-mCSB_draggerH);
498
499				$this.data("scrollAmount",scrollAmount).mCustomScrollbar("scrolling",mCustomScrollBox,mCSB_container,mCSB_draggerContainer,mCSB_dragger,mCSB_buttonUp,mCSB_buttonDown,mCSB_buttonLeft,mCSB_buttonRight);
500
501				/*scroll*/
502
503				var mCSB_containerP=Math.abs(Math.round(mCSB_container.position().top));
504
505				$this.mCustomScrollbar("scrollTo",mCSB_containerP,{callback:false});
506
507			}else if(mCSB_containerW>mCustomScrollBoxW && $this.data("horizontalScroll")){ /*content needs horizontal scrolling*/
508
509				mCSB_scrollTools.css("display","block");
510
511				var mCSB_draggerContainerW=mCSB_draggerContainer.width();
512
513				/*auto adjust scrollbar dragger length analogous to content*/
514
515				if($this.data("autoDraggerLength")){
516
517					var draggerW=Math.round(mCustomScrollBoxW/mCSB_containerW*mCSB_draggerContainerW),
518
519						minDraggerW=mCSB_dragger.data("minDraggerWidth");
520
521					if(draggerW<=minDraggerW){ /*min dragger height*/
522
523						mCSB_dragger.css({"width":minDraggerW});
524
525					}else if(draggerW>=mCSB_draggerContainerW-10){ /*max dragger height*/
526
527						var mCSB_draggerContainerMaxW=mCSB_draggerContainerW-10;
528
529						mCSB_dragger.css({"width":mCSB_draggerContainerMaxW});
530
531					}else{
532
533						mCSB_dragger.css({"width":draggerW});
534
535					}
536
537				}
538
539				var mCSB_draggerW=mCSB_dragger.width(),
540
541				/*calculate and store scroll amount, add scrolling*/
542
543					scrollAmount=(mCSB_containerW-mCustomScrollBoxW)/(mCSB_draggerContainerW-mCSB_draggerW);
544
545				$this.data("scrollAmount",scrollAmount).mCustomScrollbar("scrolling",mCustomScrollBox,mCSB_container,mCSB_draggerContainer,mCSB_dragger,mCSB_buttonUp,mCSB_buttonDown,mCSB_buttonLeft,mCSB_buttonRight);
546
547				/*scroll*/
548
549				var mCSB_containerP=Math.abs(Math.round(mCSB_container.position().left));
550
551				$this.mCustomScrollbar("scrollTo",mCSB_containerP,{callback:false});
552
553			}else{ /*content does not need scrolling*/
554
555				/*unbind events, reset content position, hide scrollbars, remove classes*/
556
557				mCustomScrollBox.unbind("mousewheel focusin");
558
559				if($this.data("horizontalScroll")){
560
561					mCSB_dragger.add(mCSB_container).css("left",0);
562
563				}else{
564
565					mCSB_dragger.add(mCSB_container).css("top",0);
566
567				}
568
569				mCSB_scrollTools.css("display","none");
570
571				mCSB_container.addClass("mCS_no_scrollbar");
572
573				$this.data({"bindEvent_mousewheel":false,"bindEvent_focusin":false});
574
575			}
576
577		},
578
579		scrolling:function(mCustomScrollBox,mCSB_container,mCSB_draggerContainer,mCSB_dragger,mCSB_buttonUp,mCSB_buttonDown,mCSB_buttonLeft,mCSB_buttonRight){
580
581			var $this=$(this);
582
583			/*while scrolling callback*/
584
585			$this.mCustomScrollbar("callbacks","whileScrolling"); 
586
587			/*drag scrolling*/
588
589			if(!mCSB_dragger.hasClass("ui-draggable")){ /*apply drag function once*/
590
591				if($this.data("horizontalScroll")){
592
593					var draggableAxis="x";
594
595				}else{
596
597					var draggableAxis="y";
598
599				}
600
601				mCSB_dragger.draggable({ 
602
603					axis:draggableAxis,
604
605					containment:"parent",
606
607					drag:function(event,ui){
608
609						$this.mCustomScrollbar("scroll");
610
611						mCSB_dragger.addClass("mCSB_dragger_onDrag");
612
613					},
614
615					stop:function(event,ui){
616
617						mCSB_dragger.removeClass("mCSB_dragger_onDrag");	
618
619					}
620
621				});
622
623			}
624
625			if(!$this.data("bindEvent_scrollbar_click")){ /*bind once*/
626
627				mCSB_draggerContainer.bind("click",function(e){
628
629					if($this.data("horizontalScroll")){
630
631						var mouseCoord=(e.pageX-mCSB_draggerContainer.offset().left);
632
633						if(mouseCoord<mCSB_dragger.position().left || mouseCoord>(mCSB_dragger.position().left+mCSB_dragger.width())){
634
635							var scrollToPos=mouseCoord;
636
637							if(scrollToPos>=mCSB_draggerContainer.width()-mCSB_dragger.width()){ /*max dragger position is bottom*/
638
639								scrollToPos=mCSB_draggerContainer.width()-mCSB_dragger.width();
640
641							}
642
643							mCSB_dragger.css("left",scrollToPos);
644
645							$this.mCustomScrollbar("scroll");
646
647						}
648
649					}else{
650
651						var mouseCoord=(e.pageY-mCSB_draggerContainer.offset().top);
652
653						if(mouseCoord<mCSB_dragger.position().top || mouseCoord>(mCSB_dragger.position().top+mCSB_dragger.height())){
654
655							var scrollToPos=mouseCoord;
656
657							if(scrollToPos>=mCSB_draggerContainer.height()-mCSB_dragger.height()){ /*max dragger position is bottom*/
658
659								scrollToPos=mCSB_draggerContainer.height()-mCSB_dragger.height();
660
661							}
662
663							mCSB_dragger.css("top",scrollToPos);
664
665							$this.mCustomScrollbar("scroll");
666
667						}
668
669					}
670
671				});
672
673				$this.data({"bindEvent_scrollbar_click":true});
674
675			}
676
677			/*mousewheel scrolling*/
678
679			if($this.data("mouseWheel")){
680
681				var mousewheelVel=$this.data("mouseWheel");
682
683				if($this.data("mouseWheel")==="auto"){
684
685					mousewheelVel=8; /*default mousewheel velocity*/
686
687					/*check for safari browser on mac osx to lower mousewheel velocity*/
688
689					var os=navigator.userAgent;
690
691					if(os.indexOf("Mac")!=-1 && os.indexOf("Safari")!=-1 && os.indexOf("AppleWebKit")!=-1 && os.indexOf("Chrome")==-1){ 
692
693						mousewheelVel=1;
694
695					}
696
697				}
698
699				if(!$this.data("bindEvent_mousewheel")){ /*bind once*/
700
701					mCustomScrollBox.bind("mousewheel",function(event,delta){
702
703						event.preventDefault();
704
705						var vel=Math.abs(delta*mousewheelVel);
706
707						if($this.data("horizontalScroll")){
708
709							if($this.data("mouseWheel")==="pixels"){
710
711								if(delta<0){
712
713									delta=-1;
714
715								}else{
716
717									delta=1;
718
719								}
720
721								var scrollTo=Math.abs(Math.round(mCSB_container.position().left))-(delta*$this.data("mouseWheelPixels"));
722
723								$this.mCustomScrollbar("scrollTo",scrollTo);
724
725							}else{
726
727								var posX=mCSB_dragger.position().left-(delta*vel);
728
729								mCSB_dragger.css("left",posX);
730
731								if(mCSB_dragger.position().left<0){
732
733									mCSB_dragger.css("left",0);
734
735								}
736
737								var mCSB_draggerContainerW=mCSB_draggerContainer.width(),
738
739									mCSB_draggerW=mCSB_dragger.width();
740
741								if(mCSB_dragger.position().left>mCSB_draggerContainerW-mCSB_draggerW){
742
743									mCSB_dragger.css("left",mCSB_draggerContainerW-mCSB_draggerW);
744
745								}
746
747								$this.mCustomScrollbar("scroll");
748
749							}
750
751						}else{
752
753							if($this.data("mouseWheel")==="pixels"){
754
755								if(delta<0){
756
757									delta=-1;
758
759								}else{
760
761									delta=1;
762
763								}
764
765								var scrollTo=Math.abs(Math.round(mCSB_container.position().top))-(delta*$this.data("mouseWheelPixels"));
766
767								$this.mCustomScrollbar("scrollTo",scrollTo);
768
769							}else{
770
771								var posY=mCSB_dragger.position().top-(delta*vel);
772
773								mCSB_dragger.css("top",posY);
774
775								if(mCSB_dragger.position().top<0){
776
777									mCSB_dragger.css("top",0);
778
779								}
780
781								var mCSB_draggerContainerH=mCSB_draggerContainer.height(),
782
783									mCSB_draggerH=mCSB_dragger.height();
784
785								if(mCSB_dragger.position().top>mCSB_draggerContainerH-mCSB_draggerH){
786
787									mCSB_dragger.css("top",mCSB_draggerContainerH-mCSB_draggerH);
788
789								}
790
791								$this.mCustomScrollbar("scroll");
792
793							}
794
795						}
796
797					});
798
799					$this.data({"bindEvent_mousewheel":true});
800
801				}
802
803			}
804
805			/*buttons scrolling*/
806
807			if($this.data("scrollButtons_enable")){
808
809				if($this.data("scrollButtons_scrollType")==="pixels"){ /*scroll by pixels*/
810
811					var pixelsScrollTo;
812
813					if($.browser.msie && parseInt($.browser.version)<9){ /*stupid ie8*/
814
815						$this.data("scrollInertia",0);
816
817					}
818
819					if($this.data("horizontalScroll")){
820
821						mCSB_buttonRight.add(mCSB_buttonLeft).unbind("mousedown touchstart onmsgesturestart mouseup mouseout touchend onmsgestureend",mCSB_buttonRight_stop,mCSB_buttonLeft_stop);
822
823						$this.data({"bindEvent_buttonsContinuous_x":false});
824
825						if(!$this.data("bindEvent_buttonsPixels_x")){ /*bind once*/
826
827							/*scroll right*/
828
829							mCSB_buttonRight.bind("click",function(e){
830
831								e.preventDefault();
832
833								if(!mCSB_container.is(":animated")){
834
835									pixelsScrollTo=Math.abs(mCSB_container.position().left)+$this.data("scrollButtons_scrollAmount");
836
837									$this.mCustomScrollbar("scrollTo",pixelsScrollTo);
838
839								}
840
841							});
842
843							/*scroll left*/
844
845							mCSB_buttonLeft.bind("click",function(e){
846
847								e.preventDefault();
848
849								if(!mCSB_container.is(":animated")){
850
851									pixelsScrollTo=Math.abs(mCSB_container.position().left)-$this.data("scrollButtons_scrollAmount");
852
853									if(mCSB_container.position().left>=-$this.data("scrollButtons_scrollAmount")){
854
855										pixelsScrollTo="left";
856
857									}
858
859									$this.mCustomScrollbar("scrollTo",pixelsScrollTo);
860
861								}
862
863							});
864
865							$this.data({"bindEvent_buttonsPixels_x":true});
866
867						}
868
869					}else{
870
871						mCSB_buttonDown.add(mCSB_buttonUp).unbind("mousedown touchstart onmsgesturestart mouseup mouseout touchend onmsgestureend",mCSB_buttonRight_stop,mCSB_buttonLeft_stop);
872
873						$this.data({"bindEvent_buttonsContinuous_y":false});
874
875						if(!$this.data("bindEvent_buttonsPixels_y")){ /*bind once*/
876
877							/*scroll down*/
878
879							mCSB_buttonDown.bind("click",function(e){
880
881								e.preventDefault();
882
883								if(!mCSB_container.is(":animated")){
884
885									pixelsScrollTo=Math.abs(mCSB_container.position().top)+$this.data("scrollButtons_scrollAmount");
886
887									$this.mCustomScrollbar("scrollTo",pixelsScrollTo);
888
889								}
890
891							});
892
893							/*scroll up*/
894
895							mCSB_buttonUp.bind("click",function(e){
896
897								e.preventDefault();
898
899								if(!mCSB_container.is(":animated")){
900
901									pixelsScrollTo=Math.abs(mCSB_container.position().top)-$this.data("scrollButtons_scrollAmount");
902
903									if(mCSB_container.position().top>=-$this.data("scrollButtons_scrollAmount")){
904
905										pixelsScrollTo="top";
906
907									}
908
909									$this.mCustomScrollbar("scrollTo",pixelsScrollTo);
910
911								}
912
913							});
914
915							$this.data({"bindEvent_buttonsPixels_y":true});
916
917						}
918
919					}
920
921				}else{ /*continuous scrolling*/
922
923					if($this.data("horizontalScroll")){
924
925						mCSB_buttonRight.add(mCSB_buttonLeft).unbind("click");
926
927						$this.data({"bindEvent_buttonsPixels_x":false});
928
929						if(!$this.data("bindEvent_buttonsContinuous_x")){ /*bind once*/
930
931							/*scroll right*/
932
933							mCSB_buttonRight.bind("mousedown touchstart onmsgesturestart",function(e){
934
935								e.preventDefault();
936
937								e.stopPropagation();
938
939								$this.data({"mCSB_buttonScrollRight":setInterval(function(){
940
941									var scrollTo=Math.round((Math.abs(Math.round(mCSB_container.position().left))+$this.data("scrollButtons_scrollSpeed"))/$this.data("scrollAmount"));
942
943									$this.mCustomScrollbar("scrollTo",scrollTo,{moveDragger:true});
944
945								},30)});
946
947							});
948
949							var mCSB_buttonRight_stop=function(e){
950
951								e.preventDefault();
952
953								e.stopPropagation();
954
955								clearInterval($this.data("mCSB_buttonScrollRight"));
956
957							}
958
959							mCSB_buttonRight.bind("mouseup touchend onmsgestureend mouseout",mCSB_buttonRight_stop);
960
961							/*scroll left*/
962
963							mCSB_buttonLeft.bind("mousedown touchstart onmsgesturestart",function(e){
964
965								e.preventDefault();
966
967								e.stopPropagation();
968
969								$this.data({"mCSB_buttonScrollLeft":setInterval(function(){
970
971									var scrollTo=Math.round((Math.abs(Math.round(mCSB_container.position().left))-$this.data("scrollButtons_scrollSpeed"))/$this.data("scrollAmount"));
972
973									$this.mCustomScrollbar("scrollTo",scrollTo,{moveDragger:true});
974
975								},30)});
976
977							});	
978
979							var mCSB_buttonLeft_stop=function(e){
980
981								e.preventDefault();
982
983								e.stopPropagation();
984
985								clearInterval($this.data("mCSB_buttonScrollLeft"));
986
987							}
988
989							mCSB_buttonLeft.bind("mouseup touchend onmsgestureend mouseout",mCSB_buttonLeft_stop);
990
991							$this.data({"bindEvent_buttonsContinuous_x":true});
992
993						}
994
995					}else{
996
997						mCSB_buttonDown.add(mCSB_buttonUp).unbind("click");
998
999						$this.data({"bindEvent_buttonsPixels_y":false});
1000
1001						if(!$this.data("bindEvent_buttonsContinuous_y")){ /*bind once*/
1002
1003							/*scroll down*/
1004
1005							mCSB_buttonDown.bind("mousedown touchstart onmsgesturestart",function(e){
1006
1007								e.preventDefault();
1008
1009								e.stopPropagation();
1010
1011								$this.data({"mCSB_buttonScrollDown":setInterval(function(){
1012
1013									var scrollTo=Math.round((Math.abs(Math.round(mCSB_container.position().top))+$this.data("scrollButtons_scrollSpeed"))/$this.data("scrollAmount"));
1014
1015									$this.mCustomScrollbar("scrollTo",scrollTo,{moveDragger:true});
1016
1017								},30)});
1018
1019							});
1020
1021							var mCSB_buttonDown_stop=function(e){
1022
1023								e.preventDefault();
1024
1025								e.stopPropagation();
1026
1027								clearInterval($this.data("mCSB_buttonScrollDown"));
1028
1029							}
1030
1031							mCSB_buttonDown.bind("mouseup touchend onmsgestureend mouseout",mCSB_buttonDown_stop);
1032
1033							/*scroll up*/
1034
1035							mCSB_buttonUp.bind("mousedown touchstart onmsgesturestart",function(e){
1036
1037								e.preventDefault();
1038
1039								e.stopPropagation();
1040
1041								$this.data({"mCSB_buttonScrollUp":setInterval(function(){
1042
1043									var scrollTo=Math.round((Math.abs(Math.round(mCSB_container.position().top))-$this.data("scrollButtons_scrollSpeed"))/$this.data("scrollAmount"));
1044
1045									$this.mCustomScrollbar("scrollTo",scrollTo,{moveDragger:true});
1046
1047								},30)});
1048
1049							});	
1050
1051							var mCSB_buttonUp_stop=function(e){
1052
1053								e.preventDefault();
1054
1055								e.stopPropagation();
1056
1057								clearInterval($this.data("mCSB_buttonScrollUp"));
1058
1059							}
1060
1061							mCSB_buttonUp.bind("mouseup touchend onmsgestureend mouseout",mCSB_buttonUp_stop);
1062
1063							$this.data({"bindEvent_buttonsContinuous_y":true});
1064
1065						}
1066
1067					}
1068
1069				}
1070
1071			}
1072
1073			/*scrolling on element focus (e.g. via TAB key)*/
1074
1075			if($this.data("autoScrollOnFocus")){
1076
1077				if(!$this.data("bindEvent_focusin")){ /*bind once*/
1078
1079					mCustomScrollBox.bind("focusin",function(){
1080
1081						mCustomScrollBox.scrollTop(0).scrollLeft(0);
1082
1083						var focusedElem=$(document.activeElement);
1084
1085						if(focusedElem.is("input,textarea,select,button,a[tabindex],area,object")){
1086
1087							if($this.data("horizontalScroll")){
1088
1089								var mCSB_containerX=mCSB_container.position().left,
1090
1091									focusedElemX=focusedElem.position().left,
1092
1093									mCustomScrollBoxW=mCustomScrollBox.width(),
1094
1095									focusedElemW=focusedElem.outerWidth();
1096
1097								if(mCSB_containerX+focusedElemX>=0 && mCSB_containerX+focusedElemX<=mCustomScrollBoxW-focusedElemW){
1098
1099									/*just focus...*/
1100
1101								}else{ /*scroll, then focus*/
1102
1103									var moveDragger=focusedElemX/$this.data("scrollAmount");
1104
1105									if(moveDragger>=mCSB_draggerContainer.width()-mCSB_dragger.width()){ /*max dragger position is bottom*/
1106
1107										moveDragger=mCSB_draggerContainer.width()-mCSB_dragger.width();
1108
1109									}
1110
1111									mCSB_dragger.css("left",moveDragger);
1112
1113									$this.mCustomScrollbar("scroll");
1114
1115								}
1116
1117							}else{
1118
1119								var mCSB_containerY=mCSB_container.position().top,
1120
1121									focusedElemY=focusedElem.position().top,
1122
1123									mCustomScrollBoxH=mCustomScrollBox.height(),
1124
1125									focusedElemH=focusedElem.outerHeight();
1126
1127								if(mCSB_containerY+focusedElemY>=0 && mCSB_containerY+focusedElemY<=mCustomScrollBoxH-focusedElemH){
1128
1129									/*just focus...*/
1130
1131								}else{ /*scroll, then focus*/
1132
1133									var moveDragger=focusedElemY/$this.data("scrollAmount");
1134
1135									if(moveDragger>=mCSB_draggerContainer.height()-mCSB_dragger.height()){ /*max dragger position is bottom*/
1136
1137										moveDragger=mCSB_draggerContainer.height()-mCSB_dragger.height();
1138
1139									}
1140
1141									mCSB_dragger.css("top",moveDragger);
1142
1143									$this.mCustomScrollbar("scroll");
1144
1145								}
1146
1147							}
1148
1149						}
1150
1151					});
1152
1153					$this.data({"bindEvent_focusin":true});
1154
1155				}
1156
1157			}
1158
1159			/*touch events*/
1160
1161			if($(document).data("mCS-is-touch-device")){
1162
1163				/*scrollbar touch-drag*/
1164
1165				if(!$this.data("bindEvent_scrollbar_touch")){ /*bind once*/
1166
1167					var mCSB_draggerTouchY,
1168
1169						mCSB_draggerTouchX;
1170
1171					mCSB_dragger.bind("touchstart onmsgesturestart",function(e){
1172
1173						e.preventDefault();
1174
1175						e.stopPropagation();
1176
1177						var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0],
1178
1179							elem=$(this),
1180
1181							elemOffset=elem.offset(),
1182
1183							x=touch.pageX-elemOffset.left,
1184
1185							y=touch.pageY-elemOffset.top;
1186
1187						if(x<elem.width() && x>0 && y<elem.height() && y>0){
1188
1189							mCSB_draggerTouchY=y;
1190
1191							mCSB_draggerTouchX=x;
1192
1193						}
1194
1195					});
1196
1197					mCSB_dragger.bind("touchmove onmsgesturechange",function(e){
1198
1199						e.preventDefault();
1200
1201						e.stopPropagation();
1202
1203						var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0],
1204
1205							elem=$(this),
1206
1207							elemOffset=elem.offset(),
1208
1209							x=touch.pageX-elemOffset.left,
1210
1211							y=touch.pageY-elemOffset.top;
1212
1213						if($this.data("horizontalScroll")){
1214
1215							$this.mCustomScrollbar("scrollTo",(mCSB_dragger.position().left-(mCSB_draggerTouchX))+x,{moveDragger:true});
1216
1217						}else{
1218
1219							$this.mCustomScrollbar("scrollTo",(mCSB_dragger.position().top-(mCSB_draggerTouchY))+y,{moveDragger:true});
1220
1221						}
1222
1223					});
1224
1225					$this.data({"bindEvent_scrollbar_touch":true});
1226
1227				}
1228
1229				/*content touch-drag*/
1230
1231				if(!$this.data("bindEvent_content_touch")){ /*bind once*/
1232
1233					var touch,
1234
1235						elem,
1236
1237						elemOffset,
1238
1239						x,
1240
1241						y,
1242
1243						mCSB_containerTouchY,
1244
1245						mCSB_containerTouchX;
1246
1247					mCSB_container.bind("touchstart onmsgesturestart",function(e){
1248
1249						touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
1250
1251						elem=$(this);
1252
1253						elemOffset=elem.offset();
1254
1255						x=touch.pageX-elemOffset.left;
1256
1257						y=touch.pageY-elemOffset.top;
1258
1259						mCSB_containerTouchY=y;
1260
1261						mCSB_containerTouchX=x;
1262
1263					});
1264
1265					mCSB_container.bind("touchmove onmsgesturechange",function(e){
1266
1267						e.preventDefault();
1268
1269						e.stopPropagation();
1270
1271						touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
1272
1273						elem=$(this).parent();
1274
1275						elemOffset=elem.offset();
1276
1277						x=touch.pageX-elemOffset.left;
1278
1279						y=touch.pageY-elemOffset.top;
1280
1281						if($this.data("horizontalScroll")){
1282
1283							$this.mCustomScrollbar("scrollTo",mCSB_containerTouchX-x);
1284
1285						}else{
1286
1287							$this.mCustomScrollbar("scrollTo",mCSB_containerTouchY-y);
1288
1289						}
1290
1291					});
1292
1293					$this.data({"bindEvent_content_touch":true});
1294
1295				}
1296
1297			}
1298
1299		},
1300
1301		scroll:function(bypassCallbacks){
1302
1303			var $this=$(this),
1304
1305				mCSB_dragger=$this.find(".mCSB_dragger"),
1306
1307				mCSB_container=$this.find(".mCSB_container"),
1308
1309				mCustomScrollBox=$this.find(".mCustomScrollBox");
1310
1311			if($this.data("horizontalScroll")){
1312
1313				var draggerX=mCSB_dragger.position().left,
1314
1315					targX=-draggerX*$this.data("scrollAmount"),
1316
1317					thisX=mCSB_container.position().left,
1318
1319					posX=Math.round(thisX-targX);
1320
1321			}else{
1322
1323				var draggerY=mCSB_dragger.position().top,
1324
1325					targY=-draggerY*$this.data("scrollAmo
1325unt"),
1326
1327					thisY=mCSB_container.position().top,
1328
1329					posY=Math.round(thisY-targY);
1330
1331			}
1332
1333			if($.browser.webkit){ /*fix webkit zoom and jquery animate*/
1334
1335				var screenCssPixelRatio=(window.outerWidth-8)/window.innerWidth,
1336
1337					isZoomed=(screenCssPixelRatio<.98 || screenCssPixelRatio>1.02);
1338
1339			}
1340
1341			if($this.data("scrollInertia")===0 || isZoomed){
1342
1343				if(!bypassCallbacks){
1344
1345					$this.mCustomScrollbar("callbacks","onScrollStart"); /*user custom callback functions*/
1346
1347				}
1348
1349				if($this.data("horizontalScroll")){
1350
1351					mCSB_container.css("left",targX);
1352
1353				}else{
1354
1355					mCSB_container.css("top",targY);
1356
1357				}
1358
1359				if(!bypassCallbacks){
1360
1361					/*user custom callback functions*/
1362
1363					if($this.data("whileScrolling")){
1364
1365						$this.data("whileScrolling_Callback").call();
1366
1367					}
1368
1369					$this.mCustomScrollbar("callbacks","onScroll");  
1370
1371				}
1372
1373				$this.data({"mCS_Init":false});
1374
1375			}else{
1376
1377				if(!bypassCallbacks){
1378
1379					$this.mCustomScrollbar("callbacks","onScrollStart"); /*user custom callback functions*/
1380
1381				}
1382
1383				if($this.data("horizontalScroll")){
1384
1385					mCSB_container.stop().animate({left:"-="+posX},$this.data("scrollInertia"),$this.data("scrollEasing"),function(){
1386
1387						if(!bypassCallbacks){
1388
1389							$this.mCustomScrollbar("callbacks","onScroll"); /*user custom callback functions*/
1390
1391						}
1392
1393						$this.data({"mCS_Init":false});
1394
1395					});
1396
1397				}else{
1398
1399					mCSB_container.stop().animate({top:"-="+posY},$this.data("scrollInertia"),$this.data("scrollEasing"),function(){
1400
1401						if(!bypassCallbacks){
1402
1403							$this.mCustomScrollbar("callbacks","onScroll"); /*user custom callback functions*/
1404
1405						}
1406
1407						$this.data({"mCS_Init":false});
1408
1409					});
1410
1411				}
1412
1413			}
1414
1415		},
1416
1417		scrollTo:function(scrollTo,options){
1418
1419			var defaults={
1420
1421				moveDragger:false,
1422
1423				callback:true
1424
1425			},
1426
1427				options=$.extend(defaults,options),
1428
1429				$this=$(this),
1430
1431				scrollToPos,
1432
1433				mCustomScrollBox=$this.find(".mCustomScrollBox"),
1434
1435				mCSB_container=mCustomScrollBox.children(".mCSB_container"),
1436
1437				mCSB_draggerContainer=$this.find(".mCSB_draggerContainer"),
1438
1439				mCSB_dragger=mCSB_draggerContainer.children(".mCSB_dragger"),
1440
1441				targetPos;
1442
1443			if(scrollTo || scrollTo===0){
1444
1445				if(typeof(scrollTo)==="number"){ /*if integer, scroll by number of pixels*/
1446
1447					if(options.moveDragger){ /*scroll dragger*/
1448
1449						scrollToPos=scrollTo;
1450
1451					}else{ /*scroll content by default*/
1452
1453						targetPos=scrollTo;
1454
1455						scrollToPos=Math.round(targetPos/$this.data("scrollAmount"));
1456
1457					}
1458
1459				}else if(typeof(scrollTo)==="string"){ /*if string, scroll by element position*/
1460
1461					var target;
1462
1463					if(scrollTo==="top"){ /*scroll to top*/
1464
1465						target=0;
1466
1467					}else if(scrollTo==="bottom" && !$this.data("horizontalScroll")){ /*scroll to bottom*/
1468
1469						target=mCSB_container.outerHeight()-mCustomScrollBox.height();
1470
1471					}else if(scrollTo==="left"){ /*scroll to left*/
1472
1473						target=0;
1474
1475					}else if(scrollTo==="right" && $this.data("horizontalScroll")){ /*scroll to right*/
1476
1477						target=mCSB_container.outerWidth()-mCustomScrollBox.width();
1478
1479					}else if(scrollTo==="first"){ /*scroll to first element position*/
1480
1481						target=$this.find(".mCSB_container").find(":first");
1482
1483					}else if(scrollTo==="last"){ /*scroll to last element position*/
1484
1485						target=$this.find(".mCSB_container").find(":last");
1486
1487					}else{ /*scroll to element position*/
1488
1489						target=$this.find(scrollTo);
1490
1491					}
1492
1493					if(target.length===1){ /*if such unique element exists, scroll to it*/
1494
1495						if($this.data("horizontalScroll")){
1496
1497							targetPos=target.position().left;
1498
1499						}else{
1500
1501							targetPos=target.position().top;
1502
1503						}
1504
1505						scrollToPos=Math.ceil(targetPos/$this.data("scrollAmount"));
1506
1507					}else{
1508
1509						scrollToPos=target;
1510
1511					}
1512
1513				}
1514
1515				/*scroll to*/
1516
1517				if(scrollToPos<0){
1518
1519					scrollToPos=0;
1520
1521				}
1522
1523				if($this.data("horizontalScroll")){
1524
1525					if(scrollToPos>=mCSB_draggerContainer.width()-mCSB_dragger.width()){ /*max dragger position is bottom*/
1526
1527						scrollToPos=mCSB_draggerContainer.width()-mCSB_dragger.width();
1528
1529					}
1530
1531					mCSB_dragger.css("left",scrollToPos);
1532
1533				}else{
1534
1535					if(scrollToPos>=mCSB_draggerContainer.height()-mCSB_dragger.height()){ /*max dragger position is bottom*/
1536
1537						scrollToPos=mCSB_draggerContainer.height()-mCSB_dragger.height();
1538
1539					}
1540
1541					mCSB_dragger.css("top",scrollToPos);
1542
1543				}
1544
1545				if(options.callback){
1546
1547					$this.mCustomScrollbar("scroll",false);
1548
1549				}else{
1550
1551					$this.mCustomScrollbar("scroll",true);
1552
1553				}
1554
1555			}
1556
1557		},
1558
1559		callbacks:function(callback){
1560
1561			var $this=$(this),
1562
1563				mCustomScrollBox=$this.find(".mCustomScrollBox"),
1564
1565				mCSB_container=$this.find(".mCSB_container");
1566
1567			switch(callback){
1568
1569				/*start scrolling callback*/
1570
1571				case "onScrollStart":
1572
1573					if(!mCSB_container.is(":animated")){
1574
1575						$this.data("onScrollStart_Callback").call();
1576
1577					}
1578
1579					break;
1580
1581				/*end scrolling callback*/
1582
1583				case "onScroll":
1584
1585					if($this.data("horizontalScroll")){
1586
1587						var mCSB_containerX=Math.round(mCSB_container.position().left);
1588
1589						if(mCSB_containerX<0 && mCSB_containerX<=mCustomScrollBox.width()-mCSB_container.outerWidth()+$this.data("onTotalScroll_Offset")){
1590
1591							$this.data("onTotalScroll_Callback").call();
1592
1593						}else if(mCSB_containerX>=-$this.data("onTotalScroll_Offset")){
1594
1595							$this.data("onTotalScrollBack_Callback").call();
1596
1597						}else{
1598
1599							$this.data("onScroll_Callback").call();
1600
1601						}
1602
1603					}else{
1604
1605						var mCSB_containerY=Math.round(mCSB_container.position().top);
1606
1607						if(mCSB_containerY<0 && mCSB_containerY<=mCustomScrollBox.height()-mCSB_container.outerHeight()+$this.data("onTotalScroll_Offset")){
1608
1609							$this.data("onTotalScroll_Callback").call();
1610
1611						}else if(mCSB_containerY>=-$this.data("onTotalScroll_Offset")){
1612
1613							$this.data("onTotalScrollBack_Callback").call();
1614
1615						}else{
1616
1617							$this.data("onScroll_Callback").call();
1618
1619						}
1620
1621					}
1622
1623					break;
1624
1625				/*while scrolling callback*/
1626
1627				case "whileScrolling":
1628
1629					if($this.data("whileScrolling_Callback") && !$this.data("whileScrolling")){
1630
1631						$this.data({"whileScrolling":setInterval(function(){
1632
1633							if(mCSB_container.is(":animated") && !$this.data("mCS_Init")){
1634
1635								$this.data("whileScrolling_Callback").call();
1636
1637							}
1638
1639						},$this.data("whileScrolling_Interval"))});
1640
1641					}
1642
1643					break;
1644
1645			}
1646
1647		},
1648
1649		disable:function(resetScroll){
1650
1651			var $this=$(this),
1652
1653				mCustomScrollBox=$this.children(".mCustomScrollBox"),
1654
1655				mCSB_container=mCustomScrollBox.children(".mCSB_container"),
1656
1657				mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
1658
1659				mCSB_dragger=mCSB_scrollTools.find(".mCSB_dragger");
1660
1661			mCustomScrollBox.unbind("mousewheel focusin");
1662
1663			if(resetScroll){
1664
1665				if($this.data("horizontalScroll")){
1666
1667					mCSB_dragger.add(mCSB_container).css("left",0);
1668
1669				}else{
1670
1671					mCSB_dragger.add(mCSB_container).css("top",0);
1672
1673				}
1674
1675			}
1676
1677			mCSB_scrollTools.css("display","none");
1678
1679			mCSB_container.addClass("mCS_no_scrollbar");
1680
1681			$this.data({"bindEvent_mousewheel":false,"bindEvent_focusin":false}).addClass("mCS_disabled");
1682
1683		},
1684
1685		destroy:function(){
1686
1687			var $this=$(this),
1688
1689				content=$this.find(".mCSB_container").html();
1690
1691			$this.find(".mCustomScrollBox").remove();
1692
1693			$this.html(content).removeClass("mCustomScrollbar _mCS_"+$(document).data("mCustomScrollbar-index")).addClass("mCS_destroyed");
1694
1695		}
1696
1697	}
1698
1699	$.fn.mCustomScrollbar=function(method){
1700
1701		if(methods[method]){
1702
1703			return methods[method].apply(this,Array.prototype.slice.call(arguments,1
1703));
1704
1705		}else if(typeof method==="object" || !method){
1706
1707			return methods.init.apply(this,arguments);
1708
1709		}else{
1710
1711			$.error("Method "+method+" does not exist");
1712
1713		}
1714
1715	};
1716
1717})(jQuery); 
1718
1719/*iOS 6 bug fix 
1720
1721  iOS 6 suffers from a bug that kills timers that are created while a page is scrolling. 
1722
1723  The following fixes that problem by recreating timers after scrolling finishes (with interval correction).*/
1724
1725var iOSVersion=iOSVersion();
1726
1727if(iOSVersion>=6){
1728
1729	(function(h){var a={};var d={};var e=h.setTimeout;var f=h.setInterval;var i=h.clearTimeout;var c=h.clearInterval;if(!h.addEventListener){return false}function j(q,n,l){var p,k=l[0],m=(q===f);function o(){if(k){k.apply(h,arguments);if(!m){delete n[p];k=null}}}l[0]=o;p=q.apply(h,l);n[p]={args:l,created:Date.now(),cb:k,id:p};return p}function b(q,o,k,r,t){var l=k[r];if(!l){return}var m=(q===f);o(l.id);if(!m){var n=l.args[1];var p=Date.now()-l.created;if(p<0){p=0}n-=p;if(n<0){n=0}l.args[1]=n}function s(){if(l.cb){l.cb.apply(h,arguments);if(!m){delete k[r];l.cb=null}}}l.args[0]=s;l.created=Date.now();l.id=q.apply(h,l.args)}h.setTimeout=function(){return j(e,a,arguments)};h.setInterval=function(){return j(f,d,arguments)};h.clearTimeout=function(l){var k=a[l];if(k){delete a[l];i(k.id)}};h.clearInterval=function(l){var k=d[l];if(k){delete d[l];c(k.id)}};var g=h;while(g.location!=g.parent.location){g=g.parent}g.addEventListener("scroll",function(){var k;for(k in a){b(e,i,a,k)}for(k in d){b(f,c,d,k)}})}(window));
1730
1731}
1732
1733function iOSVersion(){
1734
1735	var agent=window.navigator.userAgent,
1736
1737		start=agent.indexOf('OS ');
1738
1739	if((agent.indexOf('iPhone')>-1 || agent.indexOf('iPad')>-1) && start>-1){
1740
1741		return window.Number(agent.substr(start+3,3).replace('_','.'));
1742
1743	}
1744
1745	return 0;
1746
1747}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.