JSFiddle - React, Tailwind, and code Playground
by Neal
HTML
<div id="wdgt_articles_rotator_main">
<img src="/img/../phpThumb/phpThumb.php?src=../img/uploads/articles/article52056009_810826.jpg&w=500&h=232&aoe=1&zc=1" alt="featured image" class="photo photo1" height="232" width="500" /><img src="/img/../phpThumb/phpThumb.php?src=../img/uploads/articles/article52049741_885546.jpg&w=500&h=232&aoe=1&zc=1" class="photo photo2" height="232" width="500" style="display:none;" />
<div class="thumbs">
<div class='border'></div>
<img src="/img/arrow_featuredThumbnail.png" alt="arrow" height="28" width="14" class="arrow" />
<a href="javascript: wdgt_rotator_showArticle("#wdgt_articles_rotator_main", 0, true);" class="thumb0 thumb at"><img src="/img/../phpThumb/phpThumb.php?src=../img/uploads/articles/article52056009_810826.jpg&w=99&h=46&aoe=1&zc=1" height="46" width="99" /></a>
<a href="javascript: wdgt_rotator_showArticle("#wdgt_articles_rotator_main", 1, true);" class="thumb1 thumb"><img src="/img/../phpThumb/phpThumb.php?src=../img/uploads/articles/article52049741_885546.jpg&w=99&h=46&aoe=1&zc=1" height="46" width="99" /></a>
<a href="javascript: wdgt_rotator_showArticle("#wdgt_articles_rotator_main", 2, true);" class="thumb2 thumb"><img src="/img/../phpThumb/phpThumb.php?src=../img/uploads/articles/article51592762_923100.jpg&w=99&h=46&aoe=1&zc=1" height="46" width="99" /></a>
<a href="javascript: wdgt_rotator_showArticle("#wdgt_articles_rotator_main", 3, true);" class="thumb3 thumb"><img src="/img/../phpThumb/phpThumb.php?src=../img/uploads/articles/article52057668_597736.jpg&w=99&h=46&aoe=1&zc=1" height="46" width="99" /></a>
</div>
<div class="textArea"></div>
<div class="text">
<h2><a href="/articles/view/302">Test Title 1234</a></h2>
<span class="subtitle">subtitle blah blah blah <a href="/articles/view/302">read more</a></span>
</div>
</div>
CSS
#wdgt_articles_rotator_main { width: 610px; height: 234px; padding: 8px 10px; background-color: #000; -moz-box-shadow: 0px 0px 4px #333; -webkit-box-shadow: 0px 0px 4px #333; box-shadow: 0px 0px 4px #333; background-image: url('../../img/bg_blackBox_lrg_horizontal.jpg'); background-repeat: repeat-x; background-position: top left; position: relative; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; -khtml-border-radius: 8px; } #wdgt_articles_rotator_main .photo { width: 500px; height: 232px; border: 1px solid #4d4d4d; -moz-box-shadow: 0px 0px 0px #333; -webkit-box-shadow: 0px 0px 0px #333; box-shadow: 0px 0px 0px #333; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px; -khtml-border-radius: 6px; } #wdgt_articles_rotator_main .photo1 { float: left; margin-right: 7px; } #wdgt_articles_rotator_main .photo2 { /* used for the fade */ position: absolute; top: 8px; left: 10px; } #wdgt_articles_rotator_main .thumbs { float: left; position: relative; width: 101px; } #wdgt_articles_rotator_main .thumb { width: 99px; height: 46px; display: block; } #wdgt_articles_rotator_main .banner { position: absolute; top: -5px; left: -5px; } #wdgt_articles_rotator_main .arrow { position: absolute; top: 10px; left: -14px; z-index: 200; } #wdgt_articles_rotator_main .text { color: #DDD; position: absolute; left: 22px; bottom: 10px; width: 480px; height: 60px; line-height: 1.4em; } #wdgt_articles_rotator_main .text a:link, #wdgt_articles_rotator_main .text a:visited { color: white;...
JavaScript
$(document).ready(function() {
if ($('#wdgt_articles_rotator_main').length > 0) { //only set the code to start the rotator if it exists
var wdgt_rotator_timeout = setTimeout(wdgt_rotator_timeoutFunction, 8000);
}
});
//timeout function used for controlling the automated scrolling of the widget rotator
var wdgt_rotator_thumb_clicked = false;
function wdgt_rotator_timeoutFunction() {
if (!wdgt_rotator_thumb_clicked) {
wdgt_rotator_showArticle('#wdgt_articles_rotator_main', wdgt_rotator_currentThumb + 1);
}
}
var wdgt_rotator_currentThumb = 0;
var wdgt_rotator_interval;
function wdgt_rotator_showArticle(e, thumbNum, clk) {
var animateDone = false;
if (clk == true) wdgt_rotator_thumb_clicked = true; //if a thumb was actually clicked on, it stops the auto scroll
if (thumbNum > (wdgt_rotator_numThumbs - 1)) thumbNum = 0;
wdgt_rotator_currentThumb = thumbNum;
var newSrc = '/phpThumb/phpThumb.php?src=../img/uploads/articles/' + wgt_rotator_articles[thumbNum]['photo'] + '&w=500&h=232&aoe=1&zc=1';
$(e + ' h2 a').html(wgt_rotator_articles[thumbNum]['title']);
$(e + ' h2 a').attr('href', '/articles/view/' + wgt_rotator_articles[thumbNum]['id']); //changes title link
$(e + ' .subtitle').html(wgt_rotator_articles[thumbNum]['subtitle'] + ' <a href="/articles/view/' + wgt_rotator_articles[thumbNum]['id'] + '">read more</a>');
$(e + ' .photo2').attr('src', newSrc); //changes image
$(e + ' .photo2').fadeIn(300, function() {
$(e + ' .photo1').attr('src', newSrc);
$(e + ' .photo2').delay(50).fadeOut(300); //don't actually need fade, but hide makes it flash, and can't be delayed
});
$(e + ' .thumb').removeClass('at');
$(e + ' .thumb' + thumbNum).addClass('at');
var thumbPos = $(e + ' .thumb' + thumbNum).position();
$(e + ' .arrow').animate({
top: thumbPos.top + 10
}, function(){
if(animateDone){
wdgt_rotator_timeout =...