summaryrefslogtreecommitdiff
path: root/assets/js/bootstrap-carousel.js
diff options
context:
space:
mode:
authorThomas Park <thomas@thomaspark.me>2012-05-03 13:48:57 -0400
committerThomas Park <thomas@thomaspark.me>2012-05-03 13:48:57 -0400
commit0f0a0f9f8a57dc9e22839b2706ced578755518ef (patch)
tree9f6f2a702f46602a438a280ace67b268a0ed1911 /assets/js/bootstrap-carousel.js
parent1e104e46ac4ac608705cc4b81fa092d178de3b91 (diff)
index: updated site itself to 2.0.3
Diffstat (limited to 'assets/js/bootstrap-carousel.js')
-rwxr-xr-xassets/js/bootstrap-carousel.js46
1 files changed, 27 insertions, 19 deletions
diff --git a/assets/js/bootstrap-carousel.js b/assets/js/bootstrap-carousel.js
index 8c0723d2..96e5a819 100755
--- a/assets/js/bootstrap-carousel.js
+++ b/assets/js/bootstrap-carousel.js
@@ -1,5 +1,5 @@
/* ==========================================================
- * bootstrap-carousel.js v2.0.2
+ * bootstrap-carousel.js v2.0.3
* http://twitter.github.com/bootstrap/javascript.html#carousel
* ==========================================================
* Copyright 2012 Twitter, Inc.
@@ -18,16 +18,17 @@
* ========================================================== */
-!function( $ ){
+!function ($) {
+
+ "use strict"; // jshint ;_;
- "use strict"
/* CAROUSEL CLASS DEFINITION
* ========================= */
var Carousel = function (element, options) {
this.$element = $(element)
- this.options = $.extend({}, $.fn.carousel.defaults, options)
+ this.options = options
this.options.slide && this.slide(this.options.slide)
this.options.pause == 'hover' && this.$element
.on('mouseenter', $.proxy(this.pause, this))
@@ -36,8 +37,11 @@
Carousel.prototype = {
- cycle: function () {
- this.interval = setInterval($.proxy(this.next, this), this.options.interval)
+ cycle: function (e) {
+ if (!e) this.paused = false
+ this.options.interval
+ && !this.paused
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
@@ -62,7 +66,8 @@
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
}
- , pause: function () {
+ , pause: function (e) {
+ if (!e) this.paused = true
clearInterval(this.interval)
this.interval = null
return this
@@ -85,6 +90,7 @@
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
+ , e = $.Event('slide')
this.sliding = true
@@ -94,24 +100,26 @@
if ($next.hasClass('active')) return
- if (!$.support.transition && this.$element.hasClass('slide')) {
- this.$element.trigger('slide')
- $active.removeClass('active')
- $next.addClass('active')
- this.sliding = false
- this.$element.trigger('slid')
- } else {
+ if ($.support.transition && this.$element.hasClass('slide')) {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
$next.addClass(type)
$next[0].offsetWidth // force reflow
$active.addClass(direction)
$next.addClass(direction)
- this.$element.trigger('slide')
this.$element.one($.support.transition.end, function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
that.sliding = false
setTimeout(function () { that.$element.trigger('slid') }, 0)
})
+ } else {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+ $active.removeClass('active')
+ $next.addClass('active')
+ this.sliding = false
+ this.$element.trigger('slid')
}
isCycling && this.cycle()
@@ -125,15 +133,15 @@
/* CAROUSEL PLUGIN DEFINITION
* ========================== */
- $.fn.carousel = function ( option ) {
+ $.fn.carousel = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('carousel')
- , options = typeof option == 'object' && option
+ , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
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 data.cycle()
+ else if (options.interval) data.cycle()
})
}
@@ -158,4 +166,4 @@
})
})
-}( window.jQuery ); \ No newline at end of file
+}(window.jQuery); \ No newline at end of file