Created
December 16, 2010 16:01
-
-
Save lunr/743566 to your computer and use it in GitHub Desktop.
A simple javascript codeset for a pop-up carousel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var popupCarousel = function() { | |
$('#popupContainer div').hide(); | |
$('#popupContainer div').first().show(); | |
$('a.prev, a.next').css('cursor', 'pointer'); | |
var stor = 0; | |
var maxstor = ($('#popupContainer div').get().length - 1); | |
var lastShownStor = 0; | |
var popups = $('#popupContainer div').get(); | |
$('a.next, a.prev').bind('click', function(el) { | |
el.preventDefault(); | |
if($(this).hasClass('next')) { | |
if(stor < maxstor) | |
stor++; | |
else | |
stor=0; | |
} else { //prev | |
lastShownStor = stor; | |
if(stor > 0) | |
stor--; | |
else | |
stor=maxstor; | |
} | |
for (var i=0; i < popups.length; i++ ) { | |
var popup = popups[i]; | |
if(i != stor){ | |
$(popup).css('display', 'none'); | |
} | |
else{ | |
$(popup).css('display', 'block'); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment