1/*! 2 * liScroll 1.1 updated by @davetayls 3 * 4 * 2007-2009 Gian Carlo Mingati 5 * Dual licensed under the MIT and GPL licenses: 6 * http://www.opensource.org/licenses/mit-license.php 7 * http://www.gnu.org/licenses/gpl.html 8 * 9 * Modified by @realwebcare v1.2.8 10 * T4B News Ticker v1.2.8 - 15 August, 2023 11 * by @realwebcare - https://www.realwebcare.com/ 12 */ 13(function($){ 14 $.fn.liScroll = function(settings) { 15 16 settings = $.extend({ 17 travelocity: 0.05, 18 showControls: false 19 }, settings); 20 21 return this.each(function() { 22 var strip = this, 23 $strip = $(strip); 24 25 $strip.addClass("newsticker") 26 $stripItems = $strip.find("li"); 27 28 var stripWidth = 0, 29 // $mask = $strip.wrap("<div class='ticker-mask'></div>"), 30 $tickercontainer = $('.tickercontainer'), 31 // $tickercontainer = $strip.parent().wrap("<div class='t4bScroll-container'></div>").parent(), 32 paused = false, 33 containerWidth = $strip.parent().parent().width(); //a.k.a. 'mask' width 34 35 var currentItemIndex = function() { 36 var index = 0, 37 currentLeft = parseInt($strip.css("left")), 38 accumulatedWidth = 0; 39 40 if (currentLeft > 0) { 41 return 0; 42 } else { 43 $strip.find("li").each(function(i) { 44 if (currentLeft == (0 - accumulatedWidth)) { 45 index = i; 46 return false; 47 } 48 accumulatedWidth += $(this).width(); 49 if (currentLeft > (0 - accumulatedWidth)) { 50 index = i; 51 return false; 52 } 53 return true; 54 }); 55 } 56 return index; 57 }; 58 59 var next = function() { 60 pause(); 61 var index = currentItemIndex(); 62 if (index >= $stripItems.length - 1) { 63 $strip.css("left", "0px"); 64 } else { 65 var $itm = $stripItems.eq(index + 1); 66 $strip.css("left", (0 - $itm.position().left) + "px"); 67 } 68 }; 69 var pause = function() { 70 $strip.stop(); 71 $tickercontainer 72 .removeClass("t4bScroll-playing") 73 .addClass("t4bScroll-paused"); 74 paused = true; 75 }; 76 var previous = function() { 77 pause(); 78 var index = currentItemIndex(), 79 $itm = null; 80 81 if (index == 0) { 82 $itm = $stripItems.eq($stripItems.length - 1); 83 } else { 84 $itm = $stripItems.eq(index - 1); 85 } 86 $strip.css("left", (0 - $itm.position().left) + "px"); 87 }; 88 var play = function() { 89 var offset = $strip.offset(), 90 residualSpace = offset.left + stripWidth, 91 residualTime = residualSpace / settings.travelocity; 92 93 scrollnews(residualSpace, residualTime); 94 $tickercontainer 95 .addClass("t4bScroll-playing") 96 .removeClass("t4bScroll-paused"); 97 paused = false; 98 }; 99 var togglePlay = function() { 100 if (paused) { 101 play(); 102 } else { 103 pause(); 104 } 105 updatePlayButton(); 106 }; 107 108 var updatePlayButton = function() { 109 if (paused) { 110 $pause.text("Play"); 111 } else { 112 $pause.text("Pause"); 113 } 114 }; 115 116 if (settings.showControls) {
117 var $controlsContainer = $('<div class="t4bScroll-controls"></div>') 118 .appendTo($tickercontainer); 119 120 var $prev = $('<div class="t4bScroll-prev"><</div>') 121 .appendTo($controlsContainer) 122 .click(function() { 123 previous.call($strip); 124 }); 125 126 var $pause = $('<div class="t4bScroll-role">Pause</div>') 127 .appendTo($controlsContainer) 128 .click(function() { 129 togglePlay.call($strip); 130 }); 131 132 var $next = $('<div class="t4bScroll-next">></div>') 133 .appendTo($controlsContainer) 134 .click(function() { 135 next.call($strip); 136 }); 137 138 updatePlayButton(); // Initialize the play button text 139 } 140 141 // calculate full width 142 $strip.width(10000); // temporary width to prevent inline elements wrapping to initial width of ul 143 $stripItems.each(function(i) { 144 stripWidth += $(this).outerWidth(true); 145 }); 146 147 if (settings.showControls) { 148 /* const controlWidth = $controlsContainer.outerWidth(true); 149 stripWidth -= controlWidth; */ 150 $('.ticker-news .tickercontainer .ticker-mask').css('width', '92%'); 151 } 152 153 $strip.width(stripWidth * $stripItems.length); 154 155 /*thanks to Scott Waye*/ 156 var totalTravel = stripWidth + containerWidth, 157 defTiming = totalTravel / settings.travelocity; 158 159 function scrollnews(spazio, tempo) { 160 $strip.animate( 161 { left: '-=' + spazio }, 162 tempo, 163 "linear", 164 function() { 165 $strip.css("left", containerWidth); 166 scrollnews(totalTravel, defTiming); 167 } 168 ); 169 } 170 scrollnews(totalTravel, defTiming); 171 $tickercontainer.addClass("t4bScroll-playing"); 172 /* On Mouse Over */ 173 $strip.hover( 174 function() { 175 $(this).stop(); 176 }, 177 function() { 178 if (!paused) { 179 var offset = $(this).offset(); 180 var residualSpace = offset.left + stripWidth; 181 var residualTime = residualSpace/settings.travelocity; 182 scrollnews(residualSpace, residualTime); 183 } 184 } 185 ); 186 187 $stripItems.hover( 188 function() { 189 if (paused) { 190 var offset = $(this).offset(); 191 var residualSpace = offset.left + stripWidth; 192 var residualTime = residualSpace / settings.travelocity; 193 scrollnews(residualSpace, residualTime); 194 } 195 }, 196 function() { 197 if (paused) { 198 pause(); 199 } 200 } 201 ); 202 }); 203 }; 204})(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.