1jQuery(function ($) { 2 $('#ticker').tickerme(); 3}); 4 5(function ($) { 6 $.fn.tickerme = function (options) { 7 var settings = $.extend({}, $.fn.tickerme.defaults, options); 8 9 return this.each(function () { 10 var $ticker = $(this); 11 var items = []; 12 var index = -1; 13 var timer; 14 15 // collect ticker items 16 $ticker.children().each(function (i) { 17 items[i] = $(this).html(); 18 }); 19 20 function showNext() { 21 index = (index + 1) % items.length; 22 if (settings.type === "fade") { 23 $("#news").fadeOut(settings.fade_speed, function () { 24 $("#news").html(items[index]).fadeIn(settings.fade_speed); 25 }); 26 } else { 27 $("#news").html(items[index]); 28 } 29 timer = setTimeout(showNext, settings.duration); 30 } 31 32 // build basic structure 33 var container = ` 34 <div id="ticker_container" style="font-weight:bolder"> 35 <div id="newscontent"><div id="news"></div></div> 36 <div id="controls"> 37 <a href="#" id="pause_trigger">Pause</a> 38 <a href="#" id="play_trigger" style="display:none">Play</a> 39 <a href="#" id="prev_trigger">Prev</a> 40 <a href="#" id="next_trigger">Next</a> 41 </div> 42 </div> 43 `; 44 45 $ticker.hide().after(container); 46 showNext(); 47 48 // controls 49 $("#pause_trigger").click(function () { 50 clearTimeout(timer); 51 $(this).hide(); 52 $("#play_trigger").show(); 53 return false; 54 }); 55 56 $("#play_trigger").click(function () { 57 showNext(); 58 $(this).hide(); 59 $("#pause_trigger").show(); 60 return false; 61 }); 62 63 $("#prev_trigger").click(function () { 64 index = (index === 0) ? items.length - 1 : index - 1; 65 $("#news").html(items[index]).show(); 66 if (settings.auto_stop) $("#pause_trigger").trigger("click"); 67 return false; 68 }); 69 70 $("#next_trigger").click(function () { 71 index = (index === items.length - 1) ? 0 : index + 1; 72 $("#news").html(items[index]).show(); 73 if (settings.auto_stop) $("#pause_trigger").trigger("click"); 74 return false; 75 }); 76 }); 77 }; 78 79 $.fn.tickerme.defaults = { 80 fade_speed: 500, 81 duration: 6000, 82 auto_stop: true, 83 type: "fade" 84 }; 85})(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.