1// vioma news ticker 2jQuery.fn.ticker = function(settings) { 3 settings = jQuery.extend( 4 { 5 travelocity: 0.01, 6 speed:2, 7 stoppable:false, 8 delay:1 9 }, 10 settings 11 ); 12 13 return this.each( 14 function(){ 15 var tickerWidth = 20; 16 var tickerList = jQuery( this ); 17 var stop = false; 18 19 jQuery( '#newsticker' ).css( 'position', 'relative' ); 20 21 // div.mask um ul packen 22 tickerList.wrap( '<div class="mask"></div>' ); 23 24 var container = jQuery( document.createElement( 'div' ) ) 25 .attr( 'id', tickerList.parent().parent().attr( 'id' ) + '-container' ) 26 .css( 'overflow', 'hidden' ); 27 28 tickerList.parent().wrap( container ); 29 30 var tickerParentWidth = tickerList.parent().parent().width(); 31 32 // warum auch immer, der ie moechte noch eine node hoeher gehen.. 33 if ( typeof jQuery.browser != 'undefined' ) { 34 if( jQuery.browser.msie ) { 35 tickerParentWidth = tickerList.parent().parent().parent().width(); 36 } 37 } 38 39 tickerList 40 .width( tickerList.parent().width() ) 41 .css({ 42 'margin': '0px', 43 'list-style': 'none' 44 }) 45 .parent() 46 .css({ 47 'margin': '0px', 48 'position': 'absolute', 49 'white-space': 'nowrap', 50 'left': tickerParentWidth, 51 'padding': ' 0px', 52 'position': 'absolute', 53 'height': tickerList.height(), 54 'padding': tickerList.css( 'padding-top' ) + 'px 0px ' + tickerList.css( 'padding-bottom' ) + 'px 0px', 55 'margin': tickerList.css( 'margin-top' ) + 'px 0px ' + tickerList.css( 'margin-bottom' ) + 'px 0px' 56 } ) 57 .parent() 58 .css({ 59 'position': 'relative', 60 'height': tickerList.height() 61 }); 62 63 tickerList 64 .find( 'li' ) 65 .css( 'height', tickerList.height() ) 66 .find( 'span' ) 67 .each(function( i ){ 68 if ( typeof this == 'object' ) { 69 tickerWidth += parseInt( jQuery( this, i ).css({ 'float': 'left', 'padding-right': '10px' }).width() ) + 20; 70 } 71 }) 72 .end() 73 .bind( 'mouseenter', function(){ 74 if( settings.stoppable ) stop = true; 75 }) 76 .bind( 'mouseleave', function(){ 77 var offset = jQuery( this ).offset(); 78 var residualSpace = offset.left + tickerList.parent().width(); 79 var residualTime = residualSpace / settings.travelocity; 80 if( settings.stoppable ) stop = false; 81 newsticker_scroll( residualSpace, residualTime ); 82 }) 83 .each(function( i ){ 84 if ( typeof this == 'object' ) { 85 jQuery( this, i ).width( tickerWidth ); 86 } 87 }); 88 89 var totalWidth = ( tickerWidth * settings.delay ) + tickerParentWidth; 90 91 function newsticker_scroll( ){ 92 var tickerParentList = tickerList.parent(); 93 var left = parseInt( tickerParentList.css( 'left' ), 10 ); 94 95 if ( left < tickerWidth * -1 ) { 96 left = tickerList.width(); 97 } 98 99 if( !stop ){ 100 window.setTimeout(function(){ 101 tickerParentList.css( 'left', left - 2 ) 102 newsticker_scroll(); 103 }, 100 / settings.speed ); 104 } 105 } 106 107 tickerList 108 .css( 'width', totalWidth ) 109 .css( 'visibility', 'visible' ); 110 111 newsticker_scroll( ); 112 } 113 ); 114};
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.