PageSourceSearch

https://vanilla-sugar.net/js/jquery.simpleTicker.js

js vanilla-sugar.net collected 2026-10-04 17:28:23 UTC 4,190 bytes, 162 lines download raw bytes

1/**
2 * jQuery simple Ticker plugin
3 *
4 * Copyright (c) 2012 miraoto
5 * Dual licensed under the MIT and GPL licenses:
6 * http://www.opensource.org/licenses/mit-license.php
7 * http://www.gnu.org/licenses/gpl.html
8 *
9 */
10
11/**
12 * ticker plugin
13 *
14 * @name $.simpleTiecker();
15 * @cat Plugins/Preload
16 * @author miraoto
17 *
18 * @example $.simpleTiecker();
19 * @desc default setting
20 */
21(function($) {
22  $.simpleTicker =function(element, options) {
23    var defaults = {
24      speed : 2000,
25      delay : 6000,
26      easing : 'swing',
27      effectType : 'slide'
28    }
29
30    var param = {
31      'ul' : '',
32      'li' : '',
33      'initList' : '',
34      'ulWidth'  : '',
35      'liHeight' : '',
36      'tickerHook' : 'tickerHook',
37      'effect' : {}
38    }
39
40    var plugin = this;
41        plugin.settings = {}
42
43    var $element = $(element),
44        element = element;
45
46    plugin.init = function() {
47      plugin.settings = $.extend({}, defaults, options);
48      param.ul = element.children('ul');
49      param.li = element.find('li');
50      param.initList = element.find('li:first');
51      param.ulWidth  = param.ul.width();
52      param.liHeight = param.li.height();
53
54      element.css({height:(param.liHeight)});
55      param.li.css({top:'0',left:'0',position:'absolute'});
56
57      //dispatch
58      switch (plugin.settings.effectType) {
59        case 'fade':
60          plugin.effect.fade();
61          break;
62        case 'roll':
63          plugin.effect.roll();
64          break;
65        case 'slide':
66          plugin.effect.slide();
67          break;
68      }
69      plugin.effect.exec();
70    }
71
72    plugin.effect = {};
73
74    plugin.effect.exec = function() {
75      param.initList.css(param.effect.init.css)
76                    .animate(param.effect.init.animate,plugin.settings.speed,plugin.settings.easing)
77                    .addClass(param.tickerHook);
78      setInterval(function(){
79        element.find('.' + param.tickerHook)
80               .animate(param.effect.start.animate,plugin.settings.speed,plugin.settings.easing)
81               .next()
82               .css(param.effect.next.css)
83               .animate(param.effect.next.animate,plugin.settings.speed,plugin.settings.easing)
84               .addClass(param.tickerHook)
85               .end()
86               .appendTo(param.ul)
87               .css(param.effect.end.css)
88               .removeClass(param.tickerHook);
89      },plugin.settings.delay);
90    }
91
92    plugin.effect.fade = function() {
93      param.effect = {
94        'init' : {
95          'css' : {display:'block',opacity:'0'},
96          'animate' : {opacity:'1',zIndex:'98'}
97        },
98        'start' : {
99          'animate' : {opacity:'0'}
100        },
101        'next' : {
102          'css' : {display:'block',opacity:'0',zIndex:'99'},
103          'animate' : {opacity:'1'}
104        },
105        'end' : {
106          'css' : {display:'none',zIndex:'98'}
107        }
108      }
109    }
110
111    plugin.effect.roll = function() {
112      param.effect = {
113        'init' : {
114          'css' : {top:'3em',display:'block',opacity:'0'},
115          'animate' : {top:'0',opacity:'1',zIndex:'98'}
116        },
117        'start' : {
118          'animate' : {top:'-3em',opacity:'0'}
119        },
120        'next' : {
121          'css' : {top:'3em',display:'block',opacity:'0',zIndex:'99'},
122          'animate' : {top:'0',opacity:'1'}
123        },
124        'end' : {
125          'css' : {zIndex:'98'}
126        }
127      }
128    }
129  
130
131    plugin.effect.slide = function() {
132      param.effect = {
133        'init' : {
134          'css' : {left:(200),display:'block',opacity:'0'},
135          'animate' : {left:'0',opacity:'1',zIndex:'98'}
136        },
137        'start' : {
138          'animate' : {left:(-(200)),opacity:'0'}
139        },
140        'next' : {
141          'css' : {left:(param.ulWidth),display:'block',opacity:'0',zIndex:'99'},
142          'animate' : {left:'0',opacity:'1'}
143        },
144        'end' : {
145          'css' : {zIndex:'98'}
146        }
147      }
148    }
149
150    plugin.init();
151  }
152
153  $.fn.simpleTicker = function(options) {
154    return this.each(function() {
155      if (undefined == $(this).data('simpleTicker')) {
156        var plugin = new $.simpleTiecker(this, options);
157        $(this).data('simpleTicker', plugin);
158      }
159    });
160  }
161})(jQuery);
162

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.