sudoslider
Version:
An extremely versitile content-slider
140 lines (133 loc) • 4.62 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sudo Slider | Thumbnails and captions with multiple slides</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="STYLESHEET" type="text/css" href="../css/style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/jquery.sudoSlider.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var auto = true;
var autostopped = false;
var ajaxImages = [
'../images/01.jpg',
'../images/02.jpg',
'../images/03.jpg',
'../images/04.jpg',
'../images/05.jpg'
];
var imagesText = [
'Caption text 1',
'Caption text 2',
'Caption text 3',
'Caption text 4',
'Caption text 5'
];
var currentSlide = 1;
var sudoSlider = $("#slider").sudoSlider({
ajax: ajaxImages,
slideCount: 2,
continuous: true,
numeric: true,
auto: true,
resumePause: 3000,
preloadAjax: true,
ajaxLoad: function (t) {
var $img = $(this).children();
var url = $img.attr('src');
var width = ($img.width() / $img.height()) * 37;
$('.controls li a span').eq(t - 1).html('<img src="' + url + '" width="' + width + '" height="28" />');
// Captions
$(this)
.css("position", "relative")
.append('<div class="caption" >' + imagesText[t - 1] + '</div>');
},
beforeAnimation: function (t) {
var numberOfSlides = sudoSlider.getValue("totalSlides");
// Only hiding the slides that are currently not vissible.
sudoSlider.children().children().not(sudoSlider.getSlide(currentSlide)).not(sudoSlider.getSlide(currentSlide + 1)).find(".caption").hide();
},
afterAnimation: function (t) {
currentSlide = t;
sudoSlider.getSlide(t).add(sudoSlider.getSlide(t + 1)).children('.caption').slideDown(400);
}
})
.mouseenter(function () {
// Pause on mouseEnter
auto = sudoSlider.getValue('autoAnimation');
if (auto) {
sudoSlider.stopAuto();
}
else {
autostopped = true;
}
})
.mouseleave(function () {
if (!autostopped) {
sudoSlider.startAuto();
}
});
sudoSlider.goToSlide(1);
});
</script>
<style>
#slider li, #slider img {
width:348px;height:121px; /* The height rule is only for IE, all other browsers know what to do!. */
}
.nextBtn, .prevBtn {
top:23px;
}
.caption {
position:absolute;
bottom:0;
left:0;
width:348px;
height:25px;
text-align:center;
color:black;
background:white;
background:transparent;
background:rgba(255,255,255,0.7);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#a3ffffff,endColorstr=#a3ffffff);
zoom: 1;
}
</style>
</head>
<body>
<div id="container">
<h1>Sudo Slider jQuery Plugin - Thumbnails and captions with multiple slides</h1>
<div style="position:relative;">
<div id="slider">
</div>
</div>
<h3>Usage: See the source code. </h3>
</div>
<div style="width:728px;height:90px;margin:0 auto;">
<script type="text/javascript">
<!--
google_ad_client = "pub-8170632875475442";
/* Sudo Slider, lang horisontal */
google_ad_slot = "0149025622";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<script type="text/javascript">
/* Google Analytics, please remove
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20484420-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
/* */
</script>
</body>
</html>