1/** 2 * @author Steffen Maechtel <[email protected]> 3 */ 4 5(function ($, document) { 6 7 var ITEM_HEIGHT = 24, 8 BREAK_DURATION = 3000, 9 ANIMATE_DURATION = 400, 10 DIRECTION = 1; 11 12 function slideItems() { 13 var itemCount, currentPosition, maxPosition, nextPosition; 14 15 itemCount = $('.news-ticker .item').length; 16 currentPosition = parseInt($('.news-ticker .items').css('top'), 10) || 0; 17 maxPosition = -1 * ITEM_HEIGHT * (itemCount - 1); 18 19 if (DIRECTION === 1) { 20 if (currentPosition === maxPosition) { 21 DIRECTION = -1; 22 } 23 } else { 24 if (currentPosition === 0) { 25 DIRECTION = 1; 26 } 27 } 28 29 nextPosition = currentPosition - (ITEM_HEIGHT * DIRECTION); 30 31 $('.news-ticker .items').stop(true, true).animate({ 32 top: nextPosition 33 }, ANIMATE_DURATION); 34 } 35 36 $(document).ready(function () { 37 var intervalHandle; 38 39 if ($('.news-ticker').length === 0 || $('.news-ticker .item').length < 2) { 40 return; 41 } 42 43 intervalHandle = window.setInterval(slideItems, BREAK_DURATION); 44 45 $('.news-ticker .items').on('mouseenter', function () { 46 if (intervalHandle) { 47 window.clearInterval(intervalHandle); 48 } 49 }); 50 51 $('.news-ticker .items').on('mouseleave', function () { 52 intervalHandle = window.setInterval(slideItems, BREAK_DURATION); 53 }); 54 }); 55 56}($, document));
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.