PageSourceSearch

https://akimbocore.com/wp-content/themes/vice/js/jquery.slimScroll.js?ver=1.3

js akimbocore.com collected 2026-10-03 23:17:27 UTC 14,050 bytes, 489 lines download raw bytes

vendor: 14,050 bytes, lines 1-489
1/*! Copyright (c) 2011 Piotr Rochala (http://rocha.la)
2 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4 *
5 * Version: 1.3.3
6 *
7 */
8(function($) {
9
10  $.fn.extend({
11    slimScroll: function(options) {
12
13      var defaults = {
14
15        // width in pixels of the visible scroll area
16        width : 'auto',
17
18        // height in pixels of the visible scroll area
19        height : '250px',
20
21        // width in pixels of the scrollbar and rail
22        size : '7px',
23
24        // scrollbar color, accepts any hex/color value
25        color: '#000',
26
27        // scrollbar position - left/right
28        position : 'right',
29
30        // distance in pixels between the side edge and the scrollbar
31        distance : '1px',
32
33        // default scroll position on load - top / bottom / $('selector')
34        start : 'top',
35
36        // sets scrollbar opacity
37        opacity : .4,
38
39        // enables always-on mode for the scrollbar
40        alwaysVisible : false,
41
42        // check if we should hide the scrollbar when user is hovering over
43        disableFadeOut : false,
44
45        // sets visibility of the rail
46        railVisible : false,
47
48        // sets rail color
49        railColor : '#333',
50
51        // sets rail opacity
52        railOpacity : .2,
53
54        // whether  we should use jQuery UI Draggable to enable bar dragging
55        railDraggable : true,
56
57        // defautlt CSS class of the slimscroll rail
58        railClass : 'slimScrollRail',
59
60        // defautlt CSS class of the slimscroll bar
61        barClass : 'slimScrollBar',
62
63        // defautlt CSS class of the slimscroll wrapper
64        wrapperClass : 'slimScrollDiv',
65
66        // check if mousewheel should scroll the window if we reach top/bottom
67        allowPageScroll : false,
68
69        // scroll amount applied to each mouse wheel step
70        wheelStep : 20,
71
72        // scroll amount applied when user is using gestures
73        touchScrollStep : 200,
74
75        // sets border radius
76        borderRadius: '7px',
77
78        // sets border radius of the rail
79        railBorderRadius : '7px'
80      };
81
82      var o = $.extend(defaults, options);
83
84      // do it for every element that matches selector
85      this.each(function(){
86
87      var isOverPanel, isOverBar, isDragg, queueHide, touchDif,
88        barHeight, percentScroll, lastScroll,
89        divS = '<div></div>',
90        minBarHeight = 30,
91        releaseScroll = false;
92
93        // used in event handlers and for better minification
94        var me = $(this);
95
96        // ensure we are not binding it again
97        if (me.parent().hasClass(o.wrapperClass))
98        {
99            // start from last bar position
100            var offset = me.scrollTop();
101
102            // find bar and rail
103            bar = me.parent().find('.' + o.barClass);
104            rail = me.parent().find('.' + o.railClass);
105
106            getBarHeight();
107
108            // check if we should scroll existing instance
109            if ($.isPlainObject(options))
110            {
111              // Pass height: auto to an existing slimscroll object to force a resize after contents have changed
112              if ( 'height' in options && options.height == 'auto' ) {
113                me.parent().css('height', 'auto');
114                me.css('height', 'auto');
115                var height = me.parent().parent().height();
116                me.parent().css('height', height);
117                me.css('height', height);
118              }
119
120              if ('scrollTo' in options)
121              {
122                // jump to a static point
123                offset = parseInt(o.scrollTo);
124              }
125              else if ('scrollBy' in options)
126              {
127                // jump by value pixels
128                offset += parseInt(o.scrollBy);
129              }
130              else if ('destroy' in options)
131              {
132                // remove slimscroll elements
133                bar.remove();
134                rail.remove();
135                me.unwrap();
136                removeWheel();
137                return;
138              }
139
140              // scroll content by the given offset
141              scrollContent(offset, false, true);
142            }
143
144            return;
145        }
146        else if ($.isPlainObject(options))
147        {
148            if ('destroy' in options)
149            {
150            	return;
151            }
152        }
153
154        // optionally set height to the parent's height
155        o.height = (o.height == 'auto') ? me.parent().height() : o.height;
156
157        // wrap content
158        var wrapper = $(divS)
159          .addClass(o.wrapperClass)
160          .css({
161            position: 'relative',
162            overflow: 'hidden',
163            width: o.width,
164            height: o.height
165          });
166
167        // update style for the div
168        me.css({
169          overflow: 'hidden',
170          width: o.width,
171          height: o.height
172        });
173
174        // create scrollbar rail
175        var rail = $(divS)
176          .addClass(o.railClass)
177          .css({
178            width: o.size,
179            height: '100%',
180            position: 'absolute',
181            top: 0,
182            display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none',
183            'border-radius': o.railBorderRadius,
184            background: o.railColor,
185            opacity: o.railOpacity,
186            zIndex: 90
187          });
188
189        // create scrollbar
190        var bar = $(divS)
191          .addClass(o.barClass)
192          .css({
193            background: o.color,
194            width: o.size,
195            position: 'absolute',
196            top: 0,
197            opacity: o.opacity,
198            display: o.alwaysVisible ? 'block' : 'none',
199            'border-radius' : o.borderRadius,
200            BorderRadius: o.borderRadius,
201            MozBorderRadius: o.borderRadius,
202            WebkitBorderRadius: o.borderRadius,
203            zIndex: 99
204          });
205
206        // set position
207        var posCss = (o.position == 'right') ? { right: o.distance } : { left: o.distance };
208        rail.css(posCss);
209        bar.css(posCss);
210
211        // wrap it
212        me.wrap(wrapper);
213
214        // append to parent div
215        me.parent().append(bar);
216        me.parent().append(rail);
217
218        // make it draggable and no longer dependent on the jqueryUI
219        if (o.railDraggable){
220          bar.bind("mousedown", function(e) {
221            var $doc = $(document);
222            isDragg = true;
223            t = parseFloat(bar.css('top'));
224            pageY = e.pageY;
225
226            $doc.bind("mousemove.slimscroll", function(e){
227              currTop = t + e.pageY - pageY;
228              bar.css('top', currTop);
229              scrollContent(0, bar.position().top, false);// scroll content
230            });
231
232            $doc.bind("mouseup.slimscroll", function(e) {
233              isDragg = false;hideBar();
234              $doc.unbind('.slimscroll');
235            });
236            return false;
237          }).bind("selectstart.slimscroll", function(e){
238            e.stopPropagation();
239            e.preventDefault();
240            return false;
241          });
242        }
243
244        // on rail over
245        rail.hover(function(){
246          showBar();
247        }, function(){
248          hideBar();
249        });
250
251        // on bar over
252        bar.hover(function(){
253          isOverBar = true;
254        }, function(){
255          isOverBar = false;
256        });
257
258        // show on parent mouseover
259        me.hover(function(){
260          isOverPanel = true;
261          showBar();
262          hideBar();
263        }, function(){
264          isOverPanel = false;
265          hideBar();
266        });
267
268        // support for mobile
269        me.bind('touchstart', function(e,b){
270          if (e.originalEvent.touches.length)
271          {
272            // record where touch started
273            touchDif = e.originalEvent.touches[0].pageY;
274          }
275        });
276
277        me.bind('touchmove', function(e){
278          // prevent scrolling the page if necessary
279          if(!releaseScroll)
280          {
281  		      e.originalEvent.preventDefault();
282		      }
283          if (e.originalEvent.touches.length)
284          {
285            // see how far user swiped
286            var diff = (touchDif - e.originalEvent.touches[0].pageY) / o.touchScrollStep;
287            // scroll content
288            scrollContent(diff, true);
289            touchDif = e.originalEvent.touches[0].pageY;
290          }
291        });
292
293        // set up initial height
294        getBarHeight();
295
296        // check start position
297        if (o.start === 'bottom')
298        {
299          // scroll content to bottom
300          bar.css({ top: me.outerHeight() - bar.outerHeight() });
301          scrollContent(0, true);
302        }
303        else if (o.start !== 'top')
304        {
305          // assume jQuery selector
306          scrollContent($(o.start).position().top, null, true);
307
308          // make sure bar stays hidden
309          if (!o.alwaysVisible) { bar.hide(); }
310        }
311
312        // attach scroll events
313        attachWheel();
314
315        function _onWheel(e)
316        {
317          // use mouse wheel only when mouse is over
318          if (!isOverPanel) { return; }
319
320          var e = e || window.event;
321
322          var delta = 0;
323          if (e.wheelDelta) { delta = -e.wheelDelta/120; }
324          if (e.detail) { delta = e.detail / 3; }
325
326          var target = e.target || e.srcTarget || e.srcElement;
327          if ($(target).closest('.' + o.wrapperClass).is(me.parent())) {
328            // scroll content
329            scrollContent(delta, true);
330          }
331
332          // stop window scroll
333          if (e.preventDefault && !releaseScroll) { e.preventDefault(); }
334          if (!releaseScroll) { e.returnValue = false; }
335        }
336
337        function scrollContent(y, isWheel, isJump)
338        {
339          releaseScroll = false;
340          var delta = y;
341          var maxTop = me.outerHeight() - bar.outerHeight();
342
343          if (isWheel)
344          {
345            // move bar with mouse wheel
346            delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight();
347
348            // move bar, make sure it doesn't go out
349            delta = Math.min(Math.max(delta, 0), maxTop);
350
351            // if scrolling down, make sure a fractional change to the
352            // scroll position isn't rounded away when the scrollbar's CSS is set
353            // this flooring of delta would happened automatically when
354            // bar.css is set below, but we floor here for clarity
355            delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta);
356
357            // scroll the scrollbar
358            bar.css({ top: delta + 'px' });
359          }
360
361          // calculate actual scroll amount
362          percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight());
363          delta = percentScroll * (me[0].scrollHeight - me.outerHeight());
364
365          if (isJump)
366          {
367            delta = y;
368            var offsetTop = delta / me[0].scrollHeight * me.outerHeight();
369            offsetTop = Math.min(Math.max(offsetTop, 0), maxTop);
370            bar.css({ top: offsetTop + 'px' });
371          }
372
373          // scroll content
374          me.scrollTop(delta);
375
376          // fire scrolling event
377          me.trigger('slimscrolling', ~~delta);
378
379          // ensure bar is visible
380          showBar();
381
382          // trigger hide when scroll is stopped
383          hideBar();
384        }
385
386        function attachWheel()
387        {
388          if (window.addEventListener)
389          {
390            this.addEventListener('DOMMouseScroll', _onWheel, false );
391            this.addEventListener('mousewheel', _onWheel, false );
392
393
394          }
395          else
396          {
397            document.attachEvent("onmousewheel", _onWheel)
398          }
399        }
400
401
402        function removeWheel()
403        {
404          if (window.addEventListener)
405          {
406            this.removeEventListener('DOMMouseScroll', _onWheel, false );
407            this.removeEventListener('mousewheel', _onWheel, false );
408
409
410          }
411          else
412          {
413            document.detachEvent("onmousewheel", _onWheel);
414          }
415        }
416
417        function getBarHeight()
418        {
419          // calculate scrollbar height and make sure it is not too small
420          barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);
421          bar.css({ height: barHeight + 'px' });
422
423          // hide scrollbar if content is not long enough
424          var display = barHeight == me.outerHeight() ? 'none' : 'block';
425          bar.css({ display: display });
426        }
427
428        function showBar()
429        {
430          // recalculate bar height
431          getBarHeight();
432          clearTimeout(queueHide);
433
434          // when bar reached top or bottom
435          if (percentScroll == ~~percentScroll)
436          {
437            //release wheel
438            releaseScroll = o.allowPageScroll;
439
440            // publish approporiate event
441            if (lastScroll != percentScroll)
442            {
443                var msg = (~~percentScroll == 0) ? 'top' : 'bottom';
444                me.trigger('slimscroll', msg);
445            }
446          }
447          else
448          {
449            releaseScroll = false;
450          }
451          lastScroll = percentScroll;
452
453          // show only when required
454          if(barHeight >= me.outerHeight()) {
455            //allow window scroll
456            releaseScroll = true;
457            return;
458          }
459          bar.stop(true,true).fadeIn('fast');
460          if (o.railVisible) { rail.stop(true,true).fadeIn('fast'); }
461        }
462
463        function hideBar()
464        {
465          // only hide when options allow it
466          if (!o.alwaysVisible)
467          {
468            queueHide = setTimeout(function(){
469              if (!(o.disableFadeOut && isOverPanel) && !isOverBar && !isDragg)
470              {
471                bar.fadeOut('slow');
472                rail.fadeOut('slow');
473              }
474            }, 1000);
475          }
476        }
477
478      });
479
480      // maintain chainability
481      return this;
482    }
483  });
484
485  $.fn.extend({
486    slimscroll: $.fn.slimScroll
487  });
488
489})(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.