1(function($){ 2 var settings; 3 4 $.fn.calendarList = function(options) { 5 var defaults = { 6 displayLimit: 4, 7 fadeDelay: 1, // Time in seconds for an event to fade 8 wait: 4 // Time in seconds between event scrolls 9 }; 10 11 settings = $.extend({}, defaults, options); 12 13 // Turn seconds into milliseconds 14 settings.wait *= 1000; 15 settings.fadeDelay *= 1000; 16 17 this.each(function() { 18 var $list = $(this), 19 items = [], 20 currentItem = settings.displayLimit, 21 total = 0, 22 intervalID = 0; 23 24 // Cache all the list items into an array 25 $list.find('> li').each(function () { 26 items.push('<li class="clearfix">' + $(this).html() + '</li>'); 27 }); 28 total = items.length; 29 30 // Chomp the list down to limit li elements 31 $list.find('> li').filter(':gt(' + (settings.displayLimit - 1) + ')').remove(); 32 33 // Add some extra padding along the bottom for the CSS drop shadow effect. 34 $list.wrap('<div class="listWrapper" />').parent().css('height', $list.height()); 35 36 // If there aren't enough items to overflow the display limit, leave - no scrolling required. 37 if (total <= settings.displayLimit) return false; 38 39 // Setup the hover effect on the list items 40 $list.find('> li').each(function () { 41 $(this).hover(function() { 42 clearInterval(intervalID); 43 }, function() { 44 intervalID = setTimeout(displayNextItem, settings.fadeDelay); 45 }); 46 }); 47 48 function displayNextItem() { 49 50 // No need to animate the list if it isn't visible (added code to include being inside of a Twitter Bootstrap "collapse" widget) 51 if (!$list.is(':visible') || $list.closest('.collapse').height() === 0) { 52 // Keep the timer going though in case it does become visible. 53 intervalID = setTimeout(displayNextItem, settings.wait); 54 return false; 55 } 56 57 // Insert a new item with opacity set to zero and the hover effect 58 var $insert = $(items[currentItem]) 59 .css('opacity', 0) 60 .hover(function() { 61 clearInterval(intervalID); 62 }, function() { 63 intervalID = setTimeout(displayNextItem, settings.fadeDelay); 64 }) 65 .appendTo($list); 66 67 var $li = $list.find('> li:first'); 68 $li.animate({ 69 'opacity': 0, 70 'margin-top': -($li.outerHeight(true)) 71 }, settings.fadeDelay, function() { 72 $(this).remove(); 73 }); 74 $insert.animate({'opacity': 1}, settings.fadeDelay); 75 76 currentItem++; 77 if (currentItem >= total) currentItem = 0; 78 79 intervalID = setTimeout(displayNextItem, settings.wait); 80 } 81 82 intervalID = setTimeout(displayNextItem, settings.wait); 83 84 }); 85 86 // returns the jQuery object to allow for chainability. 87 return this; 88 } 89 90})(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.