0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-28 10:24:19 +01:00

add additional carousel test

This commit is contained in:
Jacob Thornton 2013-07-23 18:56:00 -07:00
parent 68e87183a0
commit faa00629c4
3 changed files with 9 additions and 3 deletions

View File

@ -422,7 +422,7 @@
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.carousel')
var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option)
var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
var action = typeof option == 'string' ? option : options.slide
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))

File diff suppressed because one or more lines are too long

View File

@ -57,7 +57,7 @@ $(function () {
.carousel('next')
})
test("should set interval from data attribute", 3,function () {
test("should set interval from data attribute", 4, function () {
var template = $('<div id="myCarousel" class="carousel slide"> <div class="carousel-inner"> <div class="item active"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}First Thumbnail label{{/i}}</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> </div> <div class="item"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}Second Thumbnail label{{/i}}</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> </div> <div class="item"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}Third Thumbnail label{{/i}}</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> </div> </div> <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a> <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a> </div>');
template.attr("data-interval", 1814);
@ -77,5 +77,11 @@ $(function () {
$('[data-slide]').first().click();
ok($('#myCarousel').data('bs.carousel').options.interval == 1814, "attributes should be read only on intitialization");
$('#myCarousel').remove();
template.attr("data-interval", false);
template.appendTo("body");
$('#myCarousel').carousel(1);
ok($('#myCarousel').data('bs.carousel').options.interval === false, "data attribute has higher priority than default options");
$('#myCarousel').remove();
})
})