PageSourceSearch

http://panmunjomtour.com/js/jquery.scrollbox.js

js panmunjomtour.com collected 2026-09-25 01:03:19 UTC 5,732 bytes, 178 lines download raw bytes

1/*!
2 * jQuery Scrollbox
3 * (c) 2009-2013 Hunter Wu <[email protected]>
4 * MIT Licensed.
5 *
6 * http://github.com/wmh/jquery-scrollbox
7 */
8
9(function($) {
10
11$.fn.scrollbox = function(config) {
12  //default config
13  var defConfig = {
14    linear: false,          // Scroll method
15           // Start delay (in seconds)
16    delay: 6,               // Delay after each scroll event (in seconds)
17    step: 5,                // Distance of each single step (in pixels)
18    speed: 32,              // Delay after each single step (in milliseconds)
19    switchItems: 1,         // Items to switch after each scroll event
20    direction: 'vertical',
21    distance: 'auto',
22    autoPlay: true,
23    onMouseOverPause: true,
24    paused: false,
25    queue: null
26  };
27  config = $.extend(defConfig, config);
28  config.scrollOffset = config.direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
29  if (config.queue) {
30    config.queue = $('#' + config.queue);
31  }
32
33  return this.each(function() {
34    var container = $(this),
35        containerUL,
36        scrollingId = null,
37        nextScrollId = null,
38        paused = false,
39        backward,
40        forward,
41        resetClock,
42        scrollForward,
43        scrollBackward;
44
45    if (config.onMouseOverPause) {
46      container.bind('mouseover', function() { paused = true; });
47      container.bind('mouseout', function() { paused = false; });
48    }
49    containerUL = container.children('ul:first-child');
50
51    scrollForward = function() {
52      if (paused) {
53        return;
54      }
55      var curLi,
56          i,
57          newScrollOffset,
58          scrollDistance,
59          theStep;
60
61      curLi = containerUL.children('li:first-child');
62
63      scrollDistance = config.distance !== 'auto' ? config.distance :
64        config.direction === 'vertical' ? curLi.height() : curLi.width();
65
66      // offset
67      if (!config.linear) {
68        theStep = Math.max(3, parseInt((scrollDistance - container[0][config.scrollOffset]) * 0.3, 10));
69        newScrollOffset = Math.min(container[0][config.scrollOffset] + theStep, scrollDistance);
70      } else {
71        newScrollOffset = Math.min(container[0][config.scrollOffset] + config.step, scrollDistance);
72      }
73      container[0][config.scrollOffset] = newScrollOffset;
74
75      if (newScrollOffset >= scrollDistance) {
76        for (i = 0; i < config.switchItems; i++) {
77          if (config.queue && config.queue.find('li').length > 0) {
78            containerUL.append(config.queue.find('li')[0]);
79            containerUL.children('li:first-child').remove();
80          } else {
81            containerUL.append(containerUL.children('li:first-child'));
82          }
83        }
84        container[0][config.scrollOffset] = 0;
85        clearInterval(scrollingId);
86        if (config.autoPlay) {
87          nextScrollId = setTimeout(forward, config.delay * 1000);
88        }
89      }
90    };
91
92    // Backward
93    // 1. If forwarding, then reverse
94    // 2. If stoping, then backward once
95    scrollBackward = function() {
96      if (paused) {
97        return;
98      }
99      var curLi,
100          i,
101          liLen,
102          newScrollOffset,
103          scrollDistance,
104          theStep;
105
106      // init
107      if (container[0][config.scrollOffset] === 0) {
108        liLen = containerUL.children('li').length;
109        for (i = 0; i < config.switchItems; i++) {
110          containerUL.children('li:last-child').insertBefore(containerUL.children('li:first-child'));
111        }
112
113        curLi = container.children('li:first-child');
114        scrollDistance = config.distance !== 'auto' ?
115            config.distance :
116            config.direction === 'vertical' ? curLi.height() : curLi.width();
117        container[0][config.scrollOffset] = scrollDistance;
118      }
119
120      // new offset
121      if (!config.linear) {
122        theStep = Math.max(3, parseInt(container[0][config.scrollOffset] * 0.3, 10));
123        newScrollOffset = Math.max(container[0][config.scrollOffset] - theStep, 0);
124      } else {
125        newScrollOffset = Math.max(container[0][config.scrollOffset] - config.step, 0);
126      }
127      container[0][config.scrollOffset] = newScrollOffset;
128
129      if (newScrollOffset === 0) {
130        clearInterval(scrollingId);
131        if (config.autoPlay) {
132          nextScrollId = setTimeout(forward, config.delay * 1000);
133        }
134      }
135    };
136
137    forward = function() {
138      clearInterval(scrollingId);
139      scrollingId = setInterval(scrollForward, config.speed);
140    };
141
142    backward = function() {
143      clearInterval(scrollingId);
144      scrollingId = setInterval(scrollBackward, config.speed);
145    };
146
147    resetClock = function(delay) {
148      config.delay = delay || config.delay;
149      clearTimeout(nextScrollId);
150      if (config.autoPlay) {
151        nextScrollId = setTimeout(forward, config.delay * 1000);
152      }
153    };
154
155    if (config.autoPlay) {
156      nextScrollId = setTimeout(forward, config.startDelay * 1000);
157    }
158
159    // bind events for container
160    container.bind('resetClock', function(delay) { resetClock(delay); });
161    container.bind('forward', function() { clearTimeout(nextScrollId); forward(); });
162    container.bind('backward', function() { clearTimeout(nextScrollId); backward(); });
163    container.bind('speedUp', function(speed) {
164      if (typeof speed === 'undefined') {
165        speed = Math.max(1, parseInt(config.speed / 2, 10));
166      }
167      config.speed = speed;
168    });
169    container.bind('speedDown', function(speed) {
170      if (typeof speed === 'undefined') {
171        speed = config.speed * 2;
172      }
173      config.speed = speed;
174    });
175  });
176};
177
178}(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.