1(function ($) { 2 $.fn.newsTicker = function(options) { 3 if($(this).length < 1) return this; 4 5 var opt = $.extend(true,{ 6 base : { 7 width : 2100, 8 time : 40000 9 }, 10 itemWidth : "auto", 11 ticker : ".ti_news", 12 tickerClone : "ti_clone", 13 wrapper : ".ti_wrapper", 14 slide : ".ti_slide", 15 content : ".ti_content", 16 17 callbacks : { 18 beforeLoad : function($Ticker){}, 19 onLoad : function($current,$Ticker){}, 20 beforeAnimation : function($old,$current){}, 21 completeAnimation : function($old,$current){}, 22 isPaused : function($current,$Ticker){}, 23 isResumed : function($current,$Ticker){} 24 }, 25 26 core : { 27 _getTime : function(w){ 28 baseMargin=(typeof $contentTickers === "undefined") ? 0 : $contentTickers.first().css("margin-left"); 29 baseMargin=(baseMargin<0)?baseMargin:0; 30 return opt.base.time * (w / (baseMargin + opt.base.width)); 31 }, 32 33 _contentWidth : function($tickers){ 34 var w = 0; 35 if(opt.itemWidth !== "auto" && opt.itemWidth !== 0){ 36 w = $tickers.length * opt.itemWidth; 37 $tickers.width(opt.itemWidth); 38 }else{ 39 $tickers.each(function(){w = w + 20 + $(this).width()}); 40 } 41 return Math.ceil(w+2); 42 } 43 } 44 45 },options); 46 47 $(this).each(function(){ 48 var $Ticker = $(this); 49 50 $Ticker.data("ticker",{ 51 stop:true, 52 animation:null 53 }); 54 55 opt.callbacks.beforeLoad($(this)); 56 57 var $notizieTicker = $Ticker.find(opt.ticker), 58 $wrapperTicker = $Ticker.find(opt.wrapper), 59 $ti_slide = $Ticker.find(opt.slide), 60 $contentTicker = $Ticker.find(opt.content); 61 62 var width_content = opt.core._contentWidth($notizieTicker), 63 wrapper_width = $wrapperTicker.width(), 64 $current, 65 $old = $(); 66 67 if(width_content < wrapper_width){ 68 var x = Math.ceil(wrapper_width/width_content), 69 $clone = $contentTicker.children().clone(); 70 for (var i = 1; i <= x; i++) { 71 $contentTicker.append($clone.clone()); 72 } 73 if(!opt.itemWidth || opt.itemWidth == "auto"){ 74 width_content = width_content*i; 75 }else{ 76 width_content = ($contentTicker.children().length * opt.itemWidth); 77 } 78 } 79 80 if(width_content * 3 > $ti_slide.width()) $ti_slide.width((width_content*3)+100); 81 82 $ti_slide.append($contentTicker.clone().addClass(opt.tickerClone)); 83 $ti_slide.append($contentTicker.clone().addClass(opt.tickerClone)); 84 85 var $contentTickers = $Ticker.find(opt.content); 86 $contentTickers.width(width_content); 87 88 $current = $contentTickers.first(); 89 90 opt.callbacks.onLoad($current,$(this)); 91 92 var animateTicker = function(m){ 93 $ti_slide.append($old); 94 var m = (typeof m == "undefined") ? 0 : m ; 95 $old.css("margin-left",m); 96 97 opt.callbacks.beforeAnimation($old,$current); 98 99 $Ticker.data("stop",false); 100 var tickerAnimation = $current.animate({ 101 "margin-left" : -width_content, 102 },{ 103 easing : "linear", 104 duration : opt.core._getTime(width_content), 105 complete : function(){ 106 $old = $current; 107 $current = $current.next(); 108 opt.callbacks.completeAnimation($old,$current); 109 animateTicker.call($Ticker); 110 } 111 }); 112 $Ticker.data("animation",tickerAnimation); 113 } 114 115 animateTicker.call(this); 116 117 $Ticker[0].pauseTicker = function(){ 118 $Ticker.each(function(){ 119 var _anim = $Ticker.data("animation"), 120 _stop = $Ticker.data("stop"); 121 if(!!_stop || !_anim) return; 122 _anim.stop(); 123 $Ticker.data("stop",true); 124 opt.callbacks.isPaused(); 125 }); 126 } 127 128 $Ticker[0].startTicker = function(){ 129 $Ticker.each(function(){ 130 if(!$Ticker.data("stop")) return; 131 animateTicker($Ticker); 132 $Ticker.data("stop",false); 133 opt.callbacks.isResumed(); 134 }); 135 } 136 }); 137 138 return this; 139 }; 140 141 $.fn.newsTickerPause = function(){ 142 $(this).each(function(){ 143 if("pauseTicker" in $(this)[0]) $(this)[0].pauseTicker(); 144 }); 145 } 146 147 $.fn.newsTickerResume = function(){ 148 $(this).each(function(){ 149 if("startTicker" in $(this)[0]) $(this)[0].startTicker(); 150 }); 151 } 152 153}( 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.