vendor: 10,149 bytes, lines 1-287
1(function($) { 2 3 $.fn.extend({ 4 slimScroll: function(options) { 5 6 var defaults = { 7 width : 'auto',height : '250px',size : '7px', color: '#000', position : 'right',distance : '1px', start : 'top', opacity : .4, alwaysVisible : false, disableFadeOut : false, railVisible : false,railColor : '#333', railOpacity : .2, railDraggable : true, railClass : 'slimScrollRail', barClass : 'slimScrollBar', wrapperClass : 'slimScrollDiv', allowPageScroll : false, wheelStep : 20, touchScrollStep : 200,borderRadius: '7px',railBorderRadius : '7px' 8 }; 9 10 var o = $.extend(defaults, options); 11 this.each(function(){ 12 var isOverPanel, isOverBar, isDragg, queueHide, touchDif, 13 barHeight, percentScroll, lastScroll, 14 divS = '<div></div>', 15 minBarHeight = 30, 16 releaseScroll = false; 17 var me = $(this); 18 if (me.parent().hasClass(o.wrapperClass)) 19 { 20 var offset = me.scrollTop(); 21 bar = me.siblings('.' + o.barClass); 22 rail = me.siblings('.' + o.railClass); 23 getBarHeight(); 24 if ($.isPlainObject(options)) 25 { 26 if ( 'height' in options && options.height == 'auto' ) { 27 me.parent().css('height', 'auto'); 28 me.css('height', 'auto'); 29 var height = me.parent().parent().height(); 30 me.parent().css('height', height); 31 me.css('height', height); 32 } else if ('height' in options) { 33 var h = options.height; 34 me.parent().css('height', h); 35 me.css('height', h); 36 } 37 38 if ('scrollTo' in options) 39 { 40 offset = parseInt(o.scrollTo); 41 } 42 else if ('scrollBy' in options) 43 { 44 offset += parseInt(o.scrollBy); 45 } 46 else if ('destroy' in options) 47 { 48 bar.remove(); 49 rail.remove(); 50 me.unwrap(); 51 return; 52 } 53 scrollContent(offset, false, true); 54 } 55 return; 56 } 57 else if ($.isPlainObject(options)) 58 { 59 if ('destroy' in options) 60 { 61 return; 62 } 63 } 64 o.height = (o.height == 'auto') ? me.parent().height() : o.height; 65 var wrapper = $(divS) 66 .addClass(o.wrapperClass) 67 .css({ 68 position: 'relative', 69 overflow: 'hidden', 70 width: o.width, 71 height: o.height 72 }); 73 me.css({ 74 overflow: 'hidden', 75 width: o.width, 76 height: o.height 77 }); 78 var rail = $(divS) 79 .addClass(o.railClass) 80 .css({ 81 width: o.size, 82 height: '100%', 83 position: 'absolute', 84 top: 0, 85 display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none', 86 'border-radius': o.railBorderRadius, 87 background: o.railColor, 88 opacity: o.railOpacity, 89 zIndex: 90 90 }); 91 var bar = $(divS) 92 .addClass(o.barClass) 93 .css({ 94 background: o.color, 95 width: o.size, 96 position: 'absolute', 97 top: 0, 98 opacity: o.opacity, 99 display: o.alwaysVisible ? 'block' : 'none', 100 'border-radius' : o.borderRadius, 101 BorderRadius: o.borderRadius, 102 MozBorderRadius: o.borderRadius, 103 WebkitBorderRadius: o.borderRadius, 104 zIndex: 99 105 }); 106 var posCss = (o.position == 'right') ? { right: o.distance } : { left: o.distance }; 107 rail.css(posCss); 108 bar.css(posCss); 109 me.wrap(wrapper); 110 me.parent().append(bar); 111 me.parent().append(rail); 112 if (o.railDraggable){ 113 bar.bind("mousedown", function(e) { 114 var $doc = $(document); 115 isDragg = true; 116 t = parseFloat(bar.css('top')); 117 pageY = e.pageY; 118 $doc.bind("mousemove.slimscroll", function(e){ 119 currTop = t + e.pageY - pageY; 120 bar.css('top', currTop); 121 scrollContent(0, bar.position().top, false);// scroll content 122 }); 123 $doc.bind("mouseup.slimscroll", function(e) { 124 isDragg = false;hideBar(); 125 $doc.unbind('.slimscroll'); 126 }); 127 return false; 128 }).bind("selectstart.slimscroll", function(e){ 129 e.stopPropagation(); 130 e.preventDefault(); 131 return false; 132 }); 133 } 134 rail.hover(function(){ 135 showBar(); 136 }, function(){ 137 hideBar(); 138 }); 139 bar.hover(function(){ 140 isOverBar = true; 141 }, function(){ 142 isOverBar = false; 143 }); 144 me.hover(function(){ 145 isOverPanel = true; 146 showBar(); 147 hideBar(); 148 }, function(){ 149 isOverPanel = false; 150 hideBar(); 151 }); 152 me.bind('touchstart', function(e,b){ 153 if (e.originalEvent.touches.length) 154 { 155 touchDif = e.originalEvent.touches[0].pageY; 156 } 157 }); 158 me.bind('touchmove', function(e){ 159 if(!releaseScroll) 160 { 161 e.originalEvent.preventDefault(); 162 } 163 if (e.originalEvent.touches.length) 164 { 165 var diff = (touchDif - e.originalEvent.touches[0].pageY) / o.touchScrollStep; 166 scrollContent(diff, true); 167 touchDif = e.originalEvent.touches[0].pageY; 168 } 169 }); 170 getBarHeight(); 171 if (o.start === 'bottom') 172 { 173 bar.css({ top: me.outerHeight() - bar.outerHeight() }); 174 scrollContent(0, true); 175 } 176 else if (o.start !== 'top') 177 { 178 scrollContent($(o.start).position().top, null, true); 179 if (!o.alwaysVisible) { bar.hide(); } 180 } 181 attachWheel(this); 182 183 function _onWheel(e) 184 { 185 if (!isOverPanel) { return; } 186 var e = e || window.event; 187 var delta = 0; 188 if (e.wheelDelta) { delta = -e.wheelDelta/120; } 189 if (e.detail) { delta = e.detail / 3; } 190 var target = e.target || e.srcTarget || e.srcElement; 191 if ($(target).closest('.' + o.wrapperClass).is(me.parent())) { 192 scrollContent(delta, true); 193 } 194 if (e.preventDefault && !releaseScroll) { e.preventDefault(); } 195 if (!releaseScroll) { e.returnValue = false; } 196 } 197 function scrollContent(y, isWheel, isJump) 198 { 199 releaseScroll = false; 200 var delta = y; 201 var maxTop = me.outerHeight() - bar.outerHeight(); 202 if (isWheel) 203 { 204 delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight(); 205 delta = Math.min(Math.max(delta, 0), maxTop); 206 delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta); 207 bar.css({ top: delta + 'px' }); 208 } 209 percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight()); 210 delta = percentScroll * (me[0].scrollHeight - me.outerHeight()); 211 if (isJump) 212 { 213 delta = y; 214 var offsetTop = delta / me[0].scrollHeight * me.outerHeight(); 215 offsetTop = Math.min(Math.max(offsetTop, 0), maxTop); 216 bar.css({ top: offsetTop + 'px' }); 217 } 218 me.scrollTop(delta); 219 me.trigger('slimscrolling', ~~delta); 220 showBar(); 221 hideBar(); 222 } 223 function attachWheel(target) 224 { 225 if (window.addEventListener) 226 { 227 target.addEventListener('DOMMouseScroll', _onWheel, false ); 228 target.addEventListener('mousewheel', _onWheel, false ); 229 } 230 else 231 { 232 document.attachEvent("onmousewheel", _onWheel) 233 } 234 } 235 236 function getBarHeight() 237 { 238 barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight); 239 bar.css({ height: barHeight + 'px' }); 240 var display = barHeight == me.outerHeight() ? 'none' : 'block'; 241 bar.css({ display: display }); 242 } 243 function showBar() 244 { 245 getBarHeight(); 246 clearTimeout(queueHide); 247 if (percentScroll == ~~percentScroll){ 248 releaseScroll = o.allowPageScroll; 249 if (lastScroll != percentScroll) 250 { 251 var msg = (~~percentScroll == 0) ? 'top' : 'bottom'; 252 me.trigger('slimscroll', msg); 253 } 254 } 255 else 256 { 257 releaseScroll = false; 258 } 259 lastScroll = percentScroll; 260 if(barHeight >= me.outerHeight()) { 261 releaseScroll = true; 262 return; 263 } 264 bar.stop(true,true).fadeIn('fast'); 265 if (o.railVisible) { rail.stop(true,true).fadeIn('fast'); } 266 } 267 function hideBar(){ 268 if (!o.alwaysVisible) 269 { 270 queueHide = setTimeout(function(){ 271 if (!(o.disableFadeOut && isOverPanel) && !isOverBar && !isDragg) 272 { 273 bar.fadeOut('slow'); 274 rail.fadeOut('slow'); 275 } 276 }, 1000); 277 } 278 } 279 280 }); 281 return this; 282 } 283 }); 284 $.fn.extend({ 285 slimscroll: $.fn.slimScroll 286 }); 287})(jQuery);
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.