mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-06 05:37:39 +02:00
add support for [data-slide-to] attr on carousel
This commit is contained in:
9
docs/assets/js/bootstrap-carousel.js
vendored
9
docs/assets/js/bootstrap-carousel.js
vendored
@@ -188,11 +188,18 @@
|
|||||||
/* CAROUSEL DATA-API
|
/* CAROUSEL DATA-API
|
||||||
* ================= */
|
* ================= */
|
||||||
|
|
||||||
$(document).on('click.carousel.data-api', '[data-slide]', function (e) {
|
$(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
|
||||||
var $this = $(this), href
|
var $this = $(this), href
|
||||||
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
||||||
, options = $.extend({}, $target.data(), $this.data())
|
, options = $.extend({}, $target.data(), $this.data())
|
||||||
|
, slideIndex
|
||||||
|
|
||||||
$target.carousel(options)
|
$target.carousel(options)
|
||||||
|
|
||||||
|
if (slideIndex = $this.attr('data-slide-to')) {
|
||||||
|
$target.data('carousel').pause().to(slideIndex).cycle()
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
9
docs/assets/js/bootstrap.js
vendored
9
docs/assets/js/bootstrap.js
vendored
@@ -449,11 +449,18 @@
|
|||||||
/* CAROUSEL DATA-API
|
/* CAROUSEL DATA-API
|
||||||
* ================= */
|
* ================= */
|
||||||
|
|
||||||
$(document).on('click.carousel.data-api', '[data-slide]', function (e) {
|
$(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
|
||||||
var $this = $(this), href
|
var $this = $(this), href
|
||||||
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
||||||
, options = $.extend({}, $target.data(), $this.data())
|
, options = $.extend({}, $target.data(), $this.data())
|
||||||
|
, slideIndex
|
||||||
|
|
||||||
$target.carousel(options)
|
$target.carousel(options)
|
||||||
|
|
||||||
|
if (slideIndex = $this.attr('data-slide-to')) {
|
||||||
|
$target.data('carousel').pause().to(slideIndex).cycle()
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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
@@ -1423,9 +1423,9 @@ $('#myCollapsible').on('hidden', function () {
|
|||||||
<div class="bs-docs-example">
|
<div class="bs-docs-example">
|
||||||
<div id="myCarousel" class="carousel slide">
|
<div id="myCarousel" class="carousel slide">
|
||||||
<ol class="carousel-indicators">
|
<ol class="carousel-indicators">
|
||||||
<li class="active"></li>
|
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
||||||
<li></li>
|
<li data-target="#myCarousel" data-slide-to="1"></li>
|
||||||
<li></li>
|
<li data-target="#myCarousel" data-slide-to="2"></li>
|
||||||
</ol>
|
</ol>
|
||||||
<div class="carousel-inner">
|
<div class="carousel-inner">
|
||||||
<div class="item active">
|
<div class="item active">
|
||||||
|
6
docs/templates/pages/javascript.mustache
vendored
6
docs/templates/pages/javascript.mustache
vendored
@@ -1353,9 +1353,9 @@ $('#myCollapsible').on('hidden', function () {
|
|||||||
<div class="bs-docs-example">
|
<div class="bs-docs-example">
|
||||||
<div id="myCarousel" class="carousel slide">
|
<div id="myCarousel" class="carousel slide">
|
||||||
<ol class="carousel-indicators">
|
<ol class="carousel-indicators">
|
||||||
<li class="active"></li>
|
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
||||||
<li></li>
|
<li data-target="#myCarousel" data-slide-to="1"></li>
|
||||||
<li></li>
|
<li data-target="#myCarousel" data-slide-to="2"></li>
|
||||||
</ol>
|
</ol>
|
||||||
<div class="carousel-inner">
|
<div class="carousel-inner">
|
||||||
<div class="item active">
|
<div class="item active">
|
||||||
|
9
js/bootstrap-carousel.js
vendored
9
js/bootstrap-carousel.js
vendored
@@ -188,11 +188,18 @@
|
|||||||
/* CAROUSEL DATA-API
|
/* CAROUSEL DATA-API
|
||||||
* ================= */
|
* ================= */
|
||||||
|
|
||||||
$(document).on('click.carousel.data-api', '[data-slide]', function (e) {
|
$(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
|
||||||
var $this = $(this), href
|
var $this = $(this), href
|
||||||
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
||||||
, options = $.extend({}, $target.data(), $this.data())
|
, options = $.extend({}, $target.data(), $this.data())
|
||||||
|
, slideIndex
|
||||||
|
|
||||||
$target.carousel(options)
|
$target.carousel(options)
|
||||||
|
|
||||||
|
if (slideIndex = $this.attr('data-slide-to')) {
|
||||||
|
$target.data('carousel').pause().to(slideIndex).cycle()
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user