mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-18 10:52:19 +01:00
add relatedTarget to carousel slide event
This commit is contained in:
parent
037107480d
commit
806a82ef83
4
docs/assets/js/bootstrap-carousel.js
vendored
4
docs/assets/js/bootstrap-carousel.js
vendored
@ -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
|
||||
|
||||
|
4
docs/assets/js/bootstrap.js
vendored
4
docs/assets/js/bootstrap.js
vendored
@ -334,7 +334,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
|
||||
|
||||
|
2
docs/assets/js/bootstrap.min.js
vendored
2
docs/assets/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
@ -884,7 +884,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
|
||||
<td>html</td>
|
||||
<td>boolean</td>
|
||||
<td>true</td>
|
||||
<td>Insert html into the tooltip. If false, jquery's <code>text</code> method will be used to insert content into the dom. Use text if you're worried about XSS attacks.</td>
|
||||
<td>Insert html into the popover. If false, jquery's <code>text</code> method will be used to insert content into the dom. Use text if you're worried about XSS attacks.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>placement</td>
|
||||
|
4
js/bootstrap-carousel.js
vendored
4
js/bootstrap-carousel.js
vendored
@ -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
|
||||
|
||||
|
16
js/tests/unit/bootstrap-carousel.js
vendored
16
js/tests/unit/bootstrap-carousel.js
vendored
@ -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">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>'
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$(template)
|
||||
.on('slide', function (e) {
|
||||
e.preventDefault();
|
||||
ok(e.relatedTarget);
|
||||
ok($(e.relatedTarget).hasClass('item'));
|
||||
start();
|
||||
})
|
||||
.carousel('next')
|
||||
})
|
||||
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user