Created
December 27, 2011 03:11
-
-
Save rjcorwin/1522618 to your computer and use it in GitHub Desktop.
Turn lists of images into jCarousels.
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
$(function() { | |
var contentArea = '#content-area'; | |
// Look at all unordered lists and label them as allImages if appropriate | |
$(contentArea + ' ul').each(function(index) { | |
var list = this; | |
$(this).children('li').each(function(index) { | |
// @todo Someone could make this test more bullet proof. | |
if($(this).html().substr(0, 4) != "<img") { | |
list.isNotCarousel = true; | |
} | |
}); | |
if(list.isNotCarousel == null) { | |
$(this).wrapAll("<div class='jCarouselLite-" + index + "' />"); | |
$(this).before("<button class='prev-" + index + "'><<</button>"); | |
$(this).after("<button class='next-" + index + "'>>></button>"); | |
// Transform those lists into jCarousels | |
$(".jCarouselLite-" + index).jCarouselLite({ | |
btnNext: ".next-" + index, | |
btnPrev: ".prev-" + index | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment