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 $.simpleTicker(); 15 * @cat Plugins/Preload 16 * @author miraoto 17 * 18 * @example $.simpleTicker(); 19 * @desc default setting 20 */ 21(function($) { 22 $.simpleTicker =function(elem, options) { 23 var defaults = { 24 speed : 3000, 25 delay : 10000, 26 easing : 'swing', 27 effectType : 'roll' 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 = $(elem), 44 element = elem; 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 if (element.find(param.li).length > 1) { 79 setInterval(function(){ 80 element.find('.' + param.tickerHook) 81 .animate(param.effect.start.animate,plugin.settings.speed,plugin.settings.easing) 82 .next() 83 .css(param.effect.next.css) 84 .animate(param.effect.next.animate,plugin.settings.speed,plugin.settings.easing) 85 .addClass(param.tickerHook) 86 .end() 87 .appendTo(param.ul) 88 .css(param.effect.end.css) 89 .removeClass(param.tickerHook); 90 },plugin.settings.delay); 91 } 92 }; 93 94 plugin.effect.fade = function() { 95 param.effect = { 96 'init' : { 97 'css' : {display:'block',opacity:'0'}, 98 'animate' : {opacity:'1',zIndex:'98'} 99 }, 100 'start' : { 101 'animate' : {opacity:'0'} 102 }, 103 'next' : { 104 'css' : {display:'block',opacity:'0',zIndex:'99'}, 105 'animate' : {opacity:'1'} 106 }, 107 'end' : { 108 'css' : {display:'none',zIndex:'98'} 109 } 110 }; 111 }; 112 113 plugin.effect.roll = function() { 114 param.effect = { 115 'init' : { 116 'css' : {top:'3em',display:'block',opacity:'0'}, 117 'animate' : {top:'0',opacity:'1',zIndex:'98'} 118 }, 119 'start' : { 120 'animate' : {top:'-3em',opacity:'0'} 121 }, 122 'next' : { 123 'css' : {top:'3em',display:'block',opacity:'0',zIndex:'99'}, 124 'animate' : {top:'0',opacity:'1'} 125 }, 126 'end' : { 127 'css' : {zIndex:'98'} 128 } 129 }; 130 }; 131 132 133 plugin.effect.slide = function() { 134 param.effect = { 135 'init' : { 136 'css' : {left:(200),display:'block',opacity:'0'}, 137 'animate' : {left:'0',opacity:'1',zIndex:'98'} 138 }, 139 'start' : { 140 'animate' : {left:(-(200)),opacity:'0'} 141 }, 142 'next' : { 143 'css' : {left:(param.ulWidth),display:'block',opacity:'0',zIndex:'99'}, 144 'animate' : {left:'0',opacity:'1'} 145 }, 146 'end' : { 147 'css' : {zIndex:'98'} 148 } 149 }; 150 }; 151 152 plugin.init(); 153 }; 154 155 $.fn.simpleTicker = function(options) { 156 return this.each(function() { 157 if (undefined == $(this).data('simpleTicker')) { 158 var plugin = new $.simpleTicker(this, options); 159 $(this).data('simpleTicker', plugin); 160 } 161 }); 162 }; 163})(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.