PageSourceSearch

https://jun-world.com/data/skin/front/dcoms_junworld_re/js/jquery/vticker/jquery.vticker.js?ts=1708594272

js jun-world.com collected 2026-10-05 07:04:33 UTC 6,512 bytes, 214 lines download raw bytes

1/*
2 Vertical News Ticker 1.14
3
4 Original by: Tadas Juozapaitis ( kasp3rito [eta] gmail (dot) com )
5 http://www.jugbit.com/jquery-vticker-vertical-news-ticker/
6
7 Modified by: Richard Hollis @richhollis - richhollis.co.uk
8 */
9
10(function($){
11
12  var defaults = {
13    speed: 700,
14    pause: 4000,
15    showItems: 1,
16    mousePause: true,
17    height: 0,
18    animate: true,
19    margin: 0,
20    padding: 0,
21    startPaused: false
22  };
23
24  var internal = {
25
26    moveUp: function(state, attribs) {
27      internal.animate(state, attribs, 'up');
28    },
29
30    moveDown: function(state, attribs){
31      internal.animate(state, attribs, 'down');
32    },
33
34    animate: function(state, attribs, dir) {
35      var height = state.itemHeight;
36      var options = state.options;
37      var el = state.element;
38      var obj = el.children('ul');
39      var selector = (dir === 'up') ? 'li:first' : 'li:last';
40      var clone = obj.children(selector).clone(true);
41
42      if(options.height > 0) height = obj.children('li:first').height();
43      height += (options.margin) + (options.padding*2); // adjust for margins & padding
44
45      if(dir==='down') obj.css('top', '-' + height + 'px').prepend(clone);
46
47      if(attribs && attribs.animate) {
48        if(state.animating) return;
49        state.animating = true;
50        var opts = (dir === 'up') ? {top: '-=' + height + 'px'} : {top: 0};
51        obj.animate(opts, options.speed, function() {
52          $(obj).children(selector).remove();
53          $(obj).css('top', '0px');
54          state.animating = false;
55        });
56      } else {
57        obj.children(selector).remove();
58        obj.css('top', '0px');
59      }
60      if(dir==='up') clone.appendTo(obj);
61    },
62
63    nextUsePause: function() {
64      var state = $(this).data('state');
65      var options = state.options;
66      if(state.isPaused || state.itemCount < 2) return;
67      methods.next.call( this, {animate:options.animate} );
68    },
69
70    startInterval: function() {
71      var state = $(this).data('state');
72      var options = state.options;
73      var initThis = this;
74      state.intervalId = setInterval(function(){
75        internal.nextUsePause.call( initThis );
76      }, options.pause);
77    },
78
79    stopInterval: function() {
80      var state = $(this).data('state');
81      if(!state) return;
82      if(state.intervalId) clearInterval(state.intervalId);
83      state.intervalId = undefined;
84    },
85
86    restartInterval: function() {
87      internal.stopInterval.call(this);
88      internal.startInterval.call(this);
89    }
90  };
91
92  var methods = {
93
94    init: function(options) {
95      // if init called second time then stop first, then re-init
96      methods.stop.call(this);
97      // init
98      var defaultsClone = jQuery.extend({}, defaults);
99      var options = $.extend(defaultsClone, options);
100      var el = $(this);
101      var state = {
102        itemCount: el.children('ul').children('li').length,
103        itemHeight: 0,
104        itemMargin: 0,
105        element: el,
106        animating: false,
107        options: options,
108        isPaused: (options.startPaused) ? true : false,
109        pausedByCode: false
110      };
111      $(this).data('state', state);
112
113      el.css({overflow: 'hidden', position: 'relative'})
114          .children('ul').css({position: 'absolute', margin: 0, padding: 0})
115          .children('li').css({margin: options.margin, padding: options.padding});
116
117      if(isNaN(options.height) || options.height === 0)
118      {
119        el.children('ul').children('li').each(function(){
120          var current = $(this);
121          if(current.height() > state.itemHeight)
122            state.itemHeight = current.height();
123        });
124        // set the same height on all child elements
125        el.children('ul').children('li').each(function(){
126          var current = $(this);
127          current.height(state.itemHeight);
128        });
129        // set element to total height
130        var box = (options.margin) + (options.padding * 2);
131        el.height(((state.itemHeight + box) * options.showItems) + options.margin);
132      }
133      else
134      {
135        // set the preferred height
136        el.height(options.height);
137      }
138
139      var initThis = this;
140      if(!options.startPaused) {
141        internal.startInterval.call( initThis );
142      }
143
144      if(options.mousePause)
145      {
146        el.bind("mouseenter", function () {
147          //if the automatic scroll is paused, don't change that.
148          if (state.isPaused === true) return;
149          state.pausedByCode = true;
150          // stop interval
151          internal.stopInterval.call( initThis );
152          methods.pause.call( initThis, true );
153        }).bind("mouseleave", function () {
154          //if the automatic scroll is paused, don't change that.
155          if (state.isPaused === true && !state.pausedByCode) return;
156          state.pausedByCode = false;
157          methods.pause.call(initThis, false);
158          // restart interval
159          internal.startInterval.call( initThis );
160        });
161      }
162    },
163
164    pause: function(pauseState) {
165      var state = $(this).data('state');
166      if(!state) return undefined;
167      if(state.itemCount < 2) return false;
168      state.isPaused = pauseState;
169      if(pauseState) $(this).addClass('paused');
170      else $(this).removeClass('paused');
171    },
172
173    next: function(attribs) {
174      var state = $(this).data('state');
175      if(!state) return undefined;
176      if(state.animating || state.itemCount < 2) return false;
177      internal.restartInterval.call( this );
178      internal.moveUp(state, attribs);
179    },
180
181    prev: function(attribs) {
182      var state = $(this).data('state');
183      if(!state) return undefined;
184      if(state.animating || state.itemCount < 2) return false;
185      internal.restartInterval.call( this );
186      internal.moveDown(state, attribs);
187    },
188
189    stop: function() {
190      var state = $(this).data('state');
191      if(!state) return undefined;
192      internal.stopInterval.call( this );
193    },
194
195    remove: function() {
196      var state = $(this).data('state');
197      if(!state) return undefined;
198      internal.stopInterval.call( this );
199      var el = state.element;
200      el.unbind();
201      el.remove();
202    }
203  };
204
205  $.fn.vTicker = function( method ) {
206    if ( methods[method] ) {
207      return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
208    } else if ( typeof method === 'object' || ! method ) {
209      return methods.init.apply( this, arguments );
210    } else {
211      $.error( 'Method ' +  method + ' does not exist on jQuery.vTicker' );
212    }
213  };
214})(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.