Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJacob Thornton <jacobthornton@gmail.com>2012-06-03 05:06:00 +0400
committerJacob Thornton <jacobthornton@gmail.com>2012-06-03 05:06:00 +0400
commit806a82ef8326e9a7b9b21fce91b827f478298519 (patch)
treed03df9899bcd8f5afbeb74b476a09508d0c65cef /js
parent037107480de9dd11095553ee409cbc748b5c7a68 (diff)
add relatedTarget to carousel slide event
Diffstat (limited to 'js')
-rw-r--r--js/bootstrap-carousel.js4
-rw-r--r--js/tests/unit/bootstrap-carousel.js16
2 files changed, 18 insertions, 2 deletions
diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js
index 551de58911..1a82374cc2 100644
--- a/js/bootstrap-carousel.js
+++ b/js/bootstrap-carousel.js
@@ -90,7 +90,9 @@
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
- , e = $.Event('slide')
+ , e = $.Event('slide', {
+ relatedTarget: $next[0]
+ })
this.sliding = true
diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js
index 92c23e227c..4c93c7b18c 100644
--- a/js/tests/unit/bootstrap-carousel.js
+++ b/js/tests/unit/bootstrap-carousel.js
@@ -12,7 +12,7 @@ $(function () {
test("should not fire sliden when slide is prevented", function () {
$.support.transition = false
- stop();
+ stop()
$('<div class="carousel"/>')
.bind('slide', function (e) {
e.preventDefault();
@@ -25,4 +25,18 @@ $(function () {
.carousel('next')
})
+ test("should fire slide event with relatedTarget", function () {
+ var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img src="assets/img/bootstrap-mdo-sfmoma-01.jpg" 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 src="assets/img/bootstrap-mdo-sfmoma-02.jpg" 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 src="assets/img/bootstrap-mdo-sfmoma-03.jpg" 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>'
+ $.support.transition = false
+ stop()
+ $(template)
+ .on('slide', function (e) {
+ e.preventDefault();
+ ok(e.relatedTarget);
+ ok($(e.relatedTarget).hasClass('item'));
+ start();
+ })
+ .carousel('next')
+ })
+
}) \ No newline at end of file