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
diff options
context:
space:
mode:
authorMark Otto <markdotto@gmail.com>2014-10-03 07:10:19 +0400
committerMark Otto <markdotto@gmail.com>2014-10-03 07:10:19 +0400
commite7b5c4c18becb3af36e03157303490fbc32f5434 (patch)
tree89961637b69cb5a9d9043f25121c22738c680933
parent2aedd274f2ab8acb7e1239671747f1b4a79c736d (diff)
parentb702889613295c8d257a3ea2c945a9fbae3973fb (diff)
Merge branch 'master' of github.com:twbs/bootstrap
-rw-r--r--js/carousel.js2
-rw-r--r--js/tests/unit/carousel.js22
2 files changed, 23 insertions, 1 deletions
diff --git a/js/carousel.js b/js/carousel.js
index 65cc7b9129..4c9a1165ce 100644
--- a/js/carousel.js
+++ b/js/carousel.js
@@ -23,7 +23,7 @@
this.$active =
this.$items = null
- this.options.pause == 'hover' && this.$element
+ this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
}
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js
index 3f9e61a349..64d2144628 100644
--- a/js/tests/unit/carousel.js
+++ b/js/tests/unit/carousel.js
@@ -398,4 +398,26 @@ $(function () {
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
})
+
+ test('should only add mouseenter and mouseleave listeners when not on mobile', function () {
+ var isMobile = 'ontouchstart' in document.documentElement
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">'
+ + '<div class="carousel-inner">'
+ + '<div id="first" class="item active">'
+ + '<img alt="">'
+ + '</div>'
+ + '<div id="second" class="item">'
+ + '<img alt="">'
+ + '</div>'
+ + '<div id="third" class="item">'
+ + '<img alt="">'
+ + '</div>'
+ + '</div>'
+ + '</div>'
+ var $template = $(templateHTML).bootstrapCarousel()
+
+ $.each(['mouseover', 'mouseout'], function (i, type) {
+ strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events')
+ })
+ })
})