]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fix #13185 - keyboard support for carousel 13787/head
authorfat <jacobthornton@gmail.com>
Wed, 11 Jun 2014 03:24:19 +0000 (20:24 -0700)
committerfat <jacobthornton@gmail.com>
Wed, 11 Jun 2014 03:35:03 +0000 (20:35 -0700)
js/carousel.js

index af51cf50d54133b7f8610f9b36ec15dcc25edb0b..bc4c60ef4c77c171d7220780561491381cd37012 100644 (file)
@@ -18,7 +18,7 @@
   // =========================
 
   var Carousel = function (element, options) {
-    this.$element    = $(element)
+    this.$element    = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
     this.$indicators = this.$element.find('.carousel-indicators')
     this.options     = options
     this.paused      =
@@ -28,8 +28,8 @@
     this.$items      = null
 
     this.options.pause == 'hover' && this.$element
-      .on('mouseenter', $.proxy(this.pause, this))
-      .on('mouseleave', $.proxy(this.cycle, this))
+      .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
+      .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
   }
 
   Carousel.VERSION  = '3.1.1'
     wrap: true
   }
 
+  Carousel.prototype.keydown = function (e) {
+    switch (e.which) {
+      case 37: this.prev(); break
+      case 39: this.next(); break
+      default: return
+    }
+
+    e.preventDefault()
+  }
+
   Carousel.prototype.cycle = function (e) {
     e || (this.paused = false)