1var is_chatscrollactive = 0; 2;(function (factory) 3{ 4 if (typeof define === 'function' && define.amd) 5 { 6 define(['jquery'], factory); 7 } 8 else if (typeof exports === 'object') 9 { 10 factory(require('jquery')); 11 } 12 else 13 { 14 factory(jQuery); 15 } 16} 17(function ($) 18{ 19 "use strict"; 20 21 var pluginName = "tinyscrollbar" 22 , defaults = 23 { 24 axis : 'y' // Vertical or horizontal scrollbar? ( x || y ). 25 , wheel : true // Enable or disable the mousewheel; 26 , wheelSpeed : 20 // How many pixels must the mouswheel scroll at a time. 27 , wheelLock : true // Lock default scrolling window when there is no more content. 28 , scrollInvert : false // Enable invert style scrolling 29 , trackSize : false // Set the size of the scrollbar to auto or a fixed number. 30 , thumbSize : false // Set the size of the thumb to auto or a fixed number 31 } 32 ; 33 function Plugin($container, options) 34 { 35 this.options = $.extend({}, defaults, options); 36 this._defaults = defaults; 37 this._name = pluginName; 38 39 var self = this 40 , $viewport = $container.find(".viewport") 41 , $overview = $container.find(".overview") 42 , $scrollbar = $container.find(".scrollbar") 43 , $track = $scrollbar.find(".track") 44 , $thumb = $scrollbar.find(".thumb") 45 46 , mousePosition = 0 47 48 , isHorizontal = this.options.axis === 'x' 49 , hasTouchEvents = ("ontouchstart" in document.documentElement)
50 , wheelEvent = ("onwheel" in document || document.documentMode >= 9) ? "wheel" : 51 (document.onmousewheel !== undefined ? "mousewheel" : "DOMMouseScroll") 52 53 , sizeLabel = isHorizontal ? "width" : "height" 54 , posiLabel = isHorizontal ? "left" : "top" 55 ; 56 57 this.contentPosition = 0; 58 this.viewportSize = 0; 59 this.contentSize = 0; 60 this.contentRatio = 0; 61 this.trackSize = 0; 62 this.trackRatio = 0; 63 this.thumbSize = 0; 64 this.thumbPosition = 0; 65 66 function initialize() 67 { 68 self.update(); 69 setEvents(); 70 71 return self; 72 } 73 74 this.update = function(scrollTo) 75 { 76 var sizeLabelCap = sizeLabel.charAt(0).toUpperCase() + sizeLabel.slice(1).toLowerCase(); 77 this.viewportSize = $viewport[0]['offset'+ sizeLabelCap]; 78 this.contentSize = $overview[0]['scroll'+ sizeLabelCap]; 79 this.contentRatio = this.viewportSize / this.contentSize; 80 this.trackSize = this.options.trackSize || this.viewportSize; 81 this.thumbSize = Math.min(this.trackSize, Math.max(0, (this.options.thumbSize || (this.trackSize * this.contentRatio)))); 82 this.trackRatio = this.options.thumbSize ? (this.contentSize - this.viewportSize) / (this.trackSize - this.thumbSize) : (this.contentSize / this.trackSize); 83 mousePosition = $track.offset().top; 84 85 $scrollbar.toggleClass("disable", this.contentRatio >= 1); 86 switch (scrollTo) 87 { 88 case "bottom": 89 this.contentPosition = this.contentSize - this.viewportSize; 90 break; 91 92 case "relative": 93 this.contentPosition = Math.min(Math.max(this.contentSize - this.viewportSize, 0), Math.max(0, this.contentPosition)); 94 break; 95 96 default: 97 this.contentPosition = parseInt(scrollTo, 10) || 0; 98 } 99 100 setSize(); 101 102 return self; 103 }; 104 105 function setSize() 106 { 107 $thumb.css(posiLabel, self.contentPosition / self.trackRatio); 108 $overview.css(posiLabel, -self.contentPosition); 109 $scrollbar.css(sizeLabel, self.trackSize); 110 $track.css(sizeLabel, self.trackSize); 111 $thumb.css(sizeLabel, self.thumbSize); 112 } 113 114 function setEvents() 115 { 116 if(hasTouchEvents) 117 { 118 $viewport[0].ontouchstart = function(event) 119 { 120 if(1 === event.touches.length) 121 { 122 event.stopPropagation(); 123 124 start(event.touches[0]); 125 } 126 }; 127 } 128 else 129 { 130 $thumb.bind("mousedown", start); 131 $track.bind("mousedown", drag); 132 } 133 134 $(window).resize(function() 135 { 136 self.update("relative"); 137 }); 138 139 if(self.options.wheel && window.addEventListener) 140 { 141 $container[0].addEventListener(wheelEvent, wheel, false ); 142 } 143 else if(self.options.wheel) 144 { 145 $container[0].onmousewheel = wheel; 146 } 147 } 148 149 function start(event) 150 { 151 $("body").addClass("noSelect"); 152 153 mousePosition = isHorizontal ? event.pageX : event.pageY; 154 self.thumbPosition = parseInt($thumb.css(posiLabel), 10) || 0; 155 156 if(hasTouchEvents) 157 { 158 document.ontouchmove = function(event) 159 { 160 event.preventDefault(); 161 drag(event.touches[0]); 162 }; 163 document.ontouchend = end; 164 } 165 else 166 { 167 $(document).bind("mousemove", drag); 168 $(document).bind("mouseup", end); 169 $thumb.bind("mouseup", end); 170 is_chatscrollactive = 1; 171 } 172 } 173 174 function wheel(event) 175 { 176 if(self.contentRatio < 1) 177 { 178 var evntObj = event || window.event 179 , deltaDir = "delta" + self.options.axis.toUpperCase() 180 , wheelSpeedDelta = -(evntObj[deltaDir] || evntObj.detail || (-1 / 3 * evntObj.wheelDelta)) / 40 181 ; 182 183 self.contentPosition -= wheelSpeedDelta * self.options.wheelSpeed; 184 self.contentPosition = Math.min((self.contentSize - self.viewportSize), Math.max(0, self.contentPosition)); 185 186 $container.trigger("move"); 187 188 $thumb.css(posiLabel, self.contentPosition / self.trackRatio); 189 $overview.css(posiLabel, -self.contentPosition); 190 191 if(self.options.wheelLock || (self.contentPosition !== (self.contentSize - self.viewportSize) && self.contentPosition !== 0)) 192 { 193 evntObj = $.event.fix(evntObj); 194 evntObj.preventDefault(); 195 } 196 } 197 } 198 199 function drag(event) 200 { 201 if(self.contentRatio < 1) 202 { 203 var mousePositionNew = isHorizontal ? event.pageX : event.pageY 204 , thumbPositionDelta = mousePositionNew - mousePosition 205 ; 206 207 if(self.options.scrollInvert && hasTouchEvents) 208 { 209 thumbPositionDelta = mousePosition - mousePositionNew; 210 } 211 212 var thumbPositionNew = Math.min((self.trackSize - self.thumbSize), Math.max(0, self.thumbPosition + thumbPositionDelta)); 213 self.contentPosition = thumbPositionNew * self.trackRatio; 214 215 $container.trigger("move"); 216 217 $thumb.css(posiLabel, thumbPositionNew); 218 $overview.css(posiLabel, -self.contentPosition); 219 } 220 } 221 222 function end() 223 { 224 $("body").removeClass("noSelect"); 225 $(document).unbind("mousemove", drag); 226 $(document).unbind("mouseup", end); 227 $thumb.unbind("mouseup", end); 228 document.ontouchmove = document.ontouchend = null; 229 is_chatscrollactive = 0; 230 } 231 232 return initialize(); 233 } 234 235 $.fn[pluginName] = function(options) 236 { 237 return this.each(function() 238 { 239 if(!$.data(this, "plugin_" + pluginName)) 240 { 241 $.data(this, "plugin_" + pluginName, new Plugin($(this), options)); 242 } 243 }); 244 }; 245}));
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.