From 67f199678c6f764f2812260f42b553b22ec740f8 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Mon, 19 Mar 2012 15:48:57 -0700 Subject: if interval is false, do not autocycle the carousel --- js/bootstrap-carousel.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 8c0723d28..287519900 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -27,7 +27,7 @@ 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)) @@ -37,7 +37,8 @@ Carousel.prototype = { cycle: function () { - this.interval = setInterval($.proxy(this.next, this), this.options.interval) + this.options.interval + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) return this } @@ -129,11 +130,11 @@ 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() }) } -- cgit v1.2.3 From 63bd7cb478500463ac7339667d89792f7108f3c0 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Mon, 19 Mar 2012 21:39:39 -0700 Subject: fix slide logic for ie+ in carousel --- js/bootstrap-carousel.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 287519900..7db5bea33 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -95,13 +95,7 @@ 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')) { $next.addClass(type) $next[0].offsetWidth // force reflow $active.addClass(direction) @@ -113,6 +107,12 @@ that.sliding = false setTimeout(function () { that.$element.trigger('slid') }, 0) }) + } else { + this.$element.trigger('slide') + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') } isCycling && this.cycle() -- cgit v1.2.3 From bccc2cb7191eb54a4d67563625a748d7ecd381d4 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 24 Mar 2012 18:20:09 -0700 Subject: add preventDefault support for all inital event types (show, close, hide, etc.) + fix small bug with scrollspy.last --- js/bootstrap-carousel.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 7db5bea33..8ce7418d2 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -86,6 +86,7 @@ , direction = type == 'next' ? 'left' : 'right' , fallback = type == 'next' ? 'first' : 'last' , that = this + , e = $.Event('slide') this.sliding = true @@ -96,11 +97,12 @@ if ($next.hasClass('active')) return 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(' ')) @@ -108,7 +110,8 @@ setTimeout(function () { that.$element.trigger('slid') }, 0) }) } else { - this.$element.trigger('slide') + this.$element.trigger(e) + if (e.isDefaultPrevented()) return $active.removeClass('active') $next.addClass('active') this.sliding = false -- cgit v1.2.3 From f02d017ffa2f63609db034410979f62fde328816 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 24 Mar 2012 18:59:04 -0700 Subject: return matcher value directly + cleanup first lines of files --- js/bootstrap-carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 8ce7418d2..0c8c5a202 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -18,7 +18,7 @@ * ========================================================== */ -!function( $ ){ +!function ( $ ) { "use strict" -- cgit v1.2.3 From 575f18aaf49abb0289185f6409bee031947ccf69 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Apr 2012 16:29:53 -0700 Subject: add jshint support + a few minor stylistic changes --- js/bootstrap-carousel.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 0c8c5a202..d1c3079e4 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -18,9 +18,10 @@ * ========================================================== */ -!function ( $ ) { +!function ($) { + + "use strict"; // jshint ;_; - "use strict" /* CAROUSEL CLASS DEFINITION * ========================= */ @@ -129,7 +130,7 @@ /* CAROUSEL PLUGIN DEFINITION * ========================== */ - $.fn.carousel = function ( option ) { + $.fn.carousel = function (option) { return this.each(function () { var $this = $(this) , data = $this.data('carousel') @@ -162,4 +163,4 @@ }) }) -}( window.jQuery ); \ No newline at end of file +}(window.jQuery); \ No newline at end of file -- cgit v1.2.3 From 82267d48ffb522ed4c9cb491660f7d1c8a9e0236 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Apr 2012 17:49:51 -0700 Subject: calling pause on a slide should actually pause it - even when hovering --- js/bootstrap-carousel.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index d1c3079e4..90f43a3eb 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -37,8 +37,10 @@ Carousel.prototype = { - cycle: function () { + 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 } @@ -64,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 -- cgit v1.2.3 From 839ef3a030b355d0f0c35d6c9e42ecba8b072036 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 24 Apr 2012 02:19:02 -0700 Subject: 2.0.2 -> 2.0.3 --- js/bootstrap-carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-carousel.js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 90f43a3eb..96e5a8191 100644 --- a/js/bootstrap-carousel.js +++ b/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. -- cgit v1.2.3