vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js in twitter-bootstrap-rails-2.1.1 vs vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js in twitter-bootstrap-rails-2.1.2
- old
+ new
@@ -1,7 +1,7 @@
/* ==========================================================
- * bootstrap-carousel.js v2.0.4
+ * bootstrap-carousel.js v2.1.0
* http://twitter.github.com/bootstrap/javascript.html#carousel
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,11 +44,11 @@
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
, to: function (pos) {
- var $active = this.$element.find('.active')
+ var $active = this.$element.find('.item.active')
, children = $active.parent().children()
, activePos = children.index($active)
, that = this
if (pos > (children.length - 1) || pos < 0) return
@@ -66,10 +66,14 @@
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
}
, pause: function (e) {
if (!e) this.paused = true
+ if (this.$element.find('.next, .prev').length && $.support.transition.end) {
+ this.$element.trigger($.support.transition.end)
+ this.cycle()
+ }
clearInterval(this.interval)
this.interval = null
return this
}
@@ -82,17 +86,19 @@
if (this.sliding) return
return this.slide('prev')
}
, slide: function (type, next) {
- var $active = this.$element.find('.active')
+ var $active = this.$element.find('.item.active')
, $next = next || $active[type]()
, isCycling = this.interval
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
- , e = $.Event('slide')
+ , e = $.Event('slide', {
+ relatedTarget: $next[0]
+ })
this.sliding = true
isCycling && this.pause()
@@ -136,12 +142,13 @@
$.fn.carousel = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('carousel')
, options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
+ , action = typeof option == 'string' ? option : options.slide
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
if (typeof option == 'number') data.to(option)
- else if (typeof option == 'string' || (option = options.slide)) data[option]()
+ else if (action) data[action]()
else if (options.interval) data.cycle()
})
}
$.fn.carousel.defaults = {
\ No newline at end of file