From 4a2d337bf5f329eac1ca16208414ec1ebfe0546e Mon Sep 17 00:00:00 2001 From: fat Date: Mon, 24 Mar 2014 19:15:58 -0700 Subject: fixes #9461 - Make carousel ignore non-items in carousel-inner --- js/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 19e9af1ed..6d6fa0aee 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -48,7 +48,7 @@ Carousel.prototype.getActiveIndex = function () { this.$active = this.$element.find('.item.active') - this.$items = this.$active.parent().children() + this.$items = this.$active.parent().children('.item') return this.$items.index(this.$active) } -- cgit v1.2.3 From 26f6807a3d0f2c72907379087f5f8358c87b030e Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 31 Mar 2014 18:09:24 -0700 Subject: Add comments in carousel.js to clarify that "slid" is not a typo Addresses #13248. --- js/carousel.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 6d6fa0aee..9f063aec0 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -59,7 +59,7 @@ if (pos > (this.$items.length - 1) || pos < 0) return - if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid". not a typo. past tense of "to slide". if (activeIndex == pos) return this.pause().cycle() return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) @@ -113,7 +113,7 @@ if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') - this.$element.one('slid.bs.carousel', function () { + this.$element.one('slid.bs.carousel', function () { // yes, "slid". not a typo. past tense of "to slide". var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) $nextIndicator && $nextIndicator.addClass('active') }) @@ -129,14 +129,14 @@ $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding = false - setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) + setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) // yes, "slid". not a typo. past tense of "to slide". }) .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) } else { $active.removeClass('active') $next.addClass('active') this.sliding = false - this.$element.trigger('slid.bs.carousel') + this.$element.trigger('slid.bs.carousel') // yes, "slid". not a typo. past tense of "to slide". } isCycling && this.cycle() -- cgit v1.2.3 From a9f2b6ce0fb2ac059e30da259f7ae25282803c09 Mon Sep 17 00:00:00 2001 From: Collin Donahue-Oponski Date: Mon, 21 Apr 2014 23:03:33 -0600 Subject: #11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object --- js/carousel.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 9f063aec0..461191389 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -148,9 +148,7 @@ // CAROUSEL PLUGIN DEFINITION // ========================== - var old = $.fn.carousel - - $.fn.carousel = function (option) { + function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('bs.carousel') @@ -164,6 +162,9 @@ }) } + var old = $.fn.carousel + + $.fn.carousel = Plugin $.fn.carousel.Constructor = Carousel @@ -186,7 +187,7 @@ var slideIndex = $this.attr('data-slide-to') if (slideIndex) options.interval = false - $target.carousel(options) + Plugin.call($target, options) if (slideIndex = $this.attr('data-slide-to')) { $target.data('bs.carousel').to(slideIndex) @@ -198,7 +199,7 @@ $(window).on('load', function () { $('[data-ride="carousel"]').each(function () { var $carousel = $(this) - $carousel.carousel($carousel.data()) + Plugin.call($carousel, $carousel.data()) }) }) -- cgit v1.2.3 From 4d0a8e31a46e54bb180eadb2844d1e4a9c7c4e91 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 21 Apr 2014 13:16:57 -0700 Subject: Add direction & relatedTarget properties to slid.bs.carousel event Fixes #13393 --- js/carousel.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 9f063aec0..14a379fbf 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -103,7 +103,8 @@ if ($next.hasClass('active')) return this.sliding = false - var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + var relatedTarget = $next[0] + var e = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) this.$element.trigger(e) if (e.isDefaultPrevented()) return @@ -119,6 +120,7 @@ }) } + var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid". not a typo. past tense of "to slide". if ($.support.transition && this.$element.hasClass('slide')) { $next.addClass(type) $next[0].offsetWidth // force reflow @@ -129,14 +131,14 @@ $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding = false - setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) // yes, "slid". not a typo. past tense of "to slide". + setTimeout(function () { that.$element.trigger(slidEvent) }, 0) }) .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) } else { $active.removeClass('active') $next.addClass('active') this.sliding = false - this.$element.trigger('slid.bs.carousel') // yes, "slid". not a typo. past tense of "to slide". + this.$element.trigger(slidEvent) } isCycling && this.cycle() -- cgit v1.2.3 From 4bd29bfcff4a78d4828396d614139db2f308eb2a Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Fri, 25 Apr 2014 17:48:02 -0700 Subject: change 'slid' comments per @fat's feedback --- js/carousel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 14a379fbf..07df86546 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -59,7 +59,7 @@ if (pos > (this.$items.length - 1) || pos < 0) return - if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid". not a typo. past tense of "to slide". + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" if (activeIndex == pos) return this.pause().cycle() return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) @@ -114,13 +114,13 @@ if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') - this.$element.one('slid.bs.carousel', function () { // yes, "slid". not a typo. past tense of "to slide". + this.$element.one('slid.bs.carousel', function () { // yes, "slid" var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) $nextIndicator && $nextIndicator.addClass('active') }) } - var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid". not a typo. past tense of "to slide". + var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" if ($.support.transition && this.$element.hasClass('slide')) { $next.addClass(type) $next[0].offsetWidth // force reflow -- cgit v1.2.3 From e114727ae94934f0f916eb2b5969b93ae4e408dc Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Fri, 25 Apr 2014 17:50:38 -0700 Subject: Carousel.slide: rename e => slideEvent --- js/carousel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 07df86546..06e3f3731 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -104,9 +104,9 @@ if ($next.hasClass('active')) return this.sliding = false var relatedTarget = $next[0] - var e = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) - this.$element.trigger(e) - if (e.isDefaultPrevented()) return + var slideEvent = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) + this.$element.trigger(slideEvent) + if (slideEvent.isDefaultPrevented()) return this.sliding = true -- cgit v1.2.3 From f219fee07b14ea1d37e197b1d80f5c7a8e3bc186 Mon Sep 17 00:00:00 2001 From: fat Date: Mon, 12 May 2014 21:15:16 -0700 Subject: versions --- js/carousel.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 2beae55e1..2a94a9838 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -28,6 +28,8 @@ .on('mouseleave', $.proxy(this.cycle, this)) } + Carousel.VERSION = '3.1.1' + Carousel.DEFAULTS = { interval: 5000, pause: 'hover', -- cgit v1.2.3 From 7b0acf14d8a7c7c6089035a848cba540ed963f36 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 17 Mar 2014 09:12:55 +0200 Subject: Comply to the new style. --- js/carousel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 2a94a9838..56aa8eb91 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -103,7 +103,7 @@ $next = this.$element.find('.item')[fallback]() } - if ($next.hasClass('active')) return this.sliding = false + if ($next.hasClass('active')) return (this.sliding = false) var relatedTarget = $next[0] var slideEvent = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) @@ -185,7 +185,8 @@ // ================= $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { - var $this = $(this), href + var href + var $this = $(this) var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 var options = $.extend({}, $target.data(), $this.data()) var slideIndex = $this.attr('data-slide-to') -- cgit v1.2.3 From 82fc03f3b6caccd134827a83c346456b920f4ba8 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 22 May 2014 09:48:17 +0300 Subject: carousel.js: remove unneeded variable assignment. `slideIndex` is assigned to the same value a few lines above. --- js/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 56aa8eb91..bda09543f 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -194,7 +194,7 @@ Plugin.call($target, options) - if (slideIndex = $this.attr('data-slide-to')) { + if (slideIndex) { $target.data('bs.carousel').to(slideIndex) } -- cgit v1.2.3 From e2cabe4971927e3dbbbda4c81ae8f74abdee2d15 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 29 May 2014 07:35:22 +0300 Subject: Minor style tweaks. --- js/carousel.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index bda09543f..e2cb67a5e 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -36,7 +36,7 @@ wrap: true } - Carousel.prototype.cycle = function (e) { + Carousel.prototype.cycle = function (e) { e || (this.paused = false) this.interval && clearInterval(this.interval) @@ -106,7 +106,10 @@ if ($next.hasClass('active')) return (this.sliding = false) var relatedTarget = $next[0] - var slideEvent = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) + var slideEvent = $.Event('slide.bs.carousel', { + relatedTarget: relatedTarget, + direction: direction + }) this.$element.trigger(slideEvent) if (slideEvent.isDefaultPrevented()) return @@ -133,7 +136,9 @@ $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding = false - setTimeout(function () { that.$element.trigger(slidEvent) }, 0) + setTimeout(function () { + that.$element.trigger(slidEvent) + }, 0) }) .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) } else { -- cgit v1.2.3 From 5eaedbe09784372f5f0935c871754ec6bcfe1154 Mon Sep 17 00:00:00 2001 From: Katie Zhu Date: Mon, 9 Jun 2014 21:54:31 -0700 Subject: change how carousel indicators activate #12592 --- js/carousel.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index e2cb67a5e..f0117980d 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -48,16 +48,14 @@ return this } - Carousel.prototype.getActiveIndex = function () { - this.$active = this.$element.find('.item.active') - this.$items = this.$active.parent().children('.item') - - return this.$items.index(this.$active) + Carousel.prototype.getItemIndex = function (item) { + this.$items = item.parent().children('.item') + return this.$items.index(item || this.$active) } Carousel.prototype.to = function (pos) { var that = this - var activeIndex = this.getActiveIndex() + var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) if (pos > (this.$items.length - 1) || pos < 0) return @@ -119,10 +117,8 @@ if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') - this.$element.one('slid.bs.carousel', function () { // yes, "slid" - var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) - $nextIndicator && $nextIndicator.addClass('active') - }) + var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) + $nextIndicator && $nextIndicator.addClass('active') } var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" -- cgit v1.2.3 From 1c6fa9010daf0d0c21de9e20fe6ac4dba1788d90 Mon Sep 17 00:00:00 2001 From: Katie Zhu Date: Mon, 9 Jun 2014 22:18:05 -0700 Subject: MD/CommonJS/Globals #12909 --- js/carousel.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index f0117980d..af51cf50d 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -7,7 +7,11 @@ * ======================================================================== */ -+function ($) { +(function (o_o) { + typeof define === 'function' && define.amd ? define(['jquery'], o_o) : + typeof exports === 'object' ? o_o(require('jquery')) : o_o(this.jQuery) +})(function ($) { + 'use strict'; // CAROUSEL CLASS DEFINITION @@ -209,4 +213,4 @@ }) }) -}(jQuery); +}); -- cgit v1.2.3 From a1dad14f448b9885147a5ae05458a4c5f457b43b Mon Sep 17 00:00:00 2001 From: fat Date: Tue, 10 Jun 2014 20:24:19 -0700 Subject: fix #13185 - keyboard support for carousel --- js/carousel.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index af51cf50d..bc4c60ef4 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -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' @@ -40,6 +40,16 @@ 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) -- cgit v1.2.3 From 7f122be0041ff2d4314a196d53d32dc5f295ed02 Mon Sep 17 00:00:00 2001 From: fat Date: Tue, 10 Jun 2014 19:56:08 -0700 Subject: add special transitionend type to test event origin fixes #13430 --- js/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index af51cf50d..dcaccf8d7 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -132,7 +132,7 @@ $active.addClass(direction) $next.addClass(direction) $active - .one($.support.transition.end, function () { + .one('bsTransitionEnd', function () { $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding = false -- cgit v1.2.3 From e9d6756a1ac76a9db31a41e8e03f663bedc41b70 Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Thu, 12 Jun 2014 06:00:02 +0200 Subject: Fix regression of #10038 introduced by #13772 --- js/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index bc4c60ef4..55c0a0130 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -9,7 +9,7 @@ (function (o_o) { typeof define === 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports === 'object' ? o_o(require('jquery')) : o_o(this.jQuery) + typeof exports === 'object' ? o_o(require('jquery')) : o_o(jQuery) })(function ($) { 'use strict'; -- cgit v1.2.3 From 2b302f69eea416bc85e7827b7d7a74d49f879662 Mon Sep 17 00:00:00 2001 From: fat Date: Thu, 12 Jun 2014 11:11:04 -0700 Subject: some changes from #13801 - add strict mode back and == --- js/carousel.js | 348 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 175 insertions(+), 173 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 75842c923..05631f7a3 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -7,220 +7,222 @@ * ======================================================================== */ -(function (o_o) { - typeof define === 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports === 'object' ? o_o(require('jquery')) : o_o(jQuery) -})(function ($) { - - 'use strict'; - - // CAROUSEL CLASS DEFINITION - // ========================= - - var Carousel = function (element, options) { - this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this)) - this.$indicators = this.$element.find('.carousel-indicators') - this.options = options - this.paused = - this.sliding = - this.interval = - this.$active = - this.$items = null - - this.options.pause == 'hover' && this.$element - .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) - .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) - } - - Carousel.VERSION = '3.1.1' - - Carousel.DEFAULTS = { - interval: 5000, - pause: 'hover', - wrap: true - } - - Carousel.prototype.keydown = function (e) { - switch (e.which) { - case 37: this.prev(); break - case 39: this.next(); break - default: return ++function () { 'use strict'; + + (function (o_o) { + typeof define == 'function' && define.amd ? define(['jquery'], o_o) : + typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery) + })(function ($) { + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this)) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) + .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) } - e.preventDefault() - } + Carousel.VERSION = '3.1.1' - Carousel.prototype.cycle = function (e) { - e || (this.paused = false) - - this.interval && clearInterval(this.interval) - - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - - return this - } - - Carousel.prototype.getItemIndex = function (item) { - this.$items = item.parent().children('.item') - return this.$items.index(item || this.$active) - } + Carousel.DEFAULTS = { + interval: 5000, + pause: 'hover', + wrap: true + } - Carousel.prototype.to = function (pos) { - var that = this - var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) + Carousel.prototype.keydown = function (e) { + switch (e.which) { + case 37: this.prev(); break + case 39: this.next(); break + default: return + } - if (pos > (this.$items.length - 1) || pos < 0) return + e.preventDefault() + } - if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" - if (activeIndex == pos) return this.pause().cycle() + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) - return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) - } + this.interval && clearInterval(this.interval) - Carousel.prototype.pause = function (e) { - e || (this.paused = true) + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - if (this.$element.find('.next, .prev').length && $.support.transition) { - this.$element.trigger($.support.transition.end) - this.cycle(true) + return this } - this.interval = clearInterval(this.interval) - - return this - } + Carousel.prototype.getItemIndex = function (item) { + this.$items = item.parent().children('.item') + return this.$items.index(item || this.$active) + } - Carousel.prototype.next = function () { - if (this.sliding) return - return this.slide('next') - } + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) - Carousel.prototype.prev = function () { - if (this.sliding) return - return this.slide('prev') - } + if (pos > (this.$items.length - 1) || pos < 0) return - Carousel.prototype.slide = function (type, next) { - var $active = this.$element.find('.item.active') - var $next = next || $active[type]() - var isCycling = this.interval - var direction = type == 'next' ? 'left' : 'right' - var fallback = type == 'next' ? 'first' : 'last' - var that = this + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" + if (activeIndex == pos) return this.pause().cycle() - if (!$next.length) { - if (!this.options.wrap) return - $next = this.$element.find('.item')[fallback]() + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) } - if ($next.hasClass('active')) return (this.sliding = false) + Carousel.prototype.pause = function (e) { + e || (this.paused = true) - var relatedTarget = $next[0] - var slideEvent = $.Event('slide.bs.carousel', { - relatedTarget: relatedTarget, - direction: direction - }) - this.$element.trigger(slideEvent) - if (slideEvent.isDefaultPrevented()) return + if (this.$element.find('.next, .prev').length && $.support.transition) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } - this.sliding = true + this.interval = clearInterval(this.interval) - isCycling && this.pause() + return this + } - if (this.$indicators.length) { - this.$indicators.find('.active').removeClass('active') - var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) - $nextIndicator && $nextIndicator.addClass('active') + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') } - var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" - if ($.support.transition && this.$element.hasClass('slide')) { - $next.addClass(type) - $next[0].offsetWidth // force reflow - $active.addClass(direction) - $next.addClass(direction) - $active - .one('bsTransitionEnd', function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { - that.$element.trigger(slidEvent) - }, 0) - }) - .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) - } else { - $active.removeClass('active') - $next.addClass('active') - this.sliding = false - this.$element.trigger(slidEvent) + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') } - isCycling && this.cycle() + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + if ($next.hasClass('active')) return (this.sliding = false) + + var relatedTarget = $next[0] + var slideEvent = $.Event('slide.bs.carousel', { + relatedTarget: relatedTarget, + direction: direction + }) + this.$element.trigger(slideEvent) + if (slideEvent.isDefaultPrevented()) return + + this.sliding = true + + isCycling && this.pause() + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) + $nextIndicator && $nextIndicator.addClass('active') + } + + var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" + if ($.support.transition && this.$element.hasClass('slide')) { + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one('bsTransitionEnd', function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { + that.$element.trigger(slidEvent) + }, 0) + }) + .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) + } else { + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger(slidEvent) + } + + isCycling && this.cycle() + + return this + } - return this - } + // CAROUSEL PLUGIN DEFINITION + // ========================== - // CAROUSEL PLUGIN DEFINITION - // ========================== + function Plugin(option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.carousel') - var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) - var action = typeof option == 'string' ? option : options.slide - - if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) - if (typeof option == 'number') data.to(option) - else if (action) data[action]() - else if (options.interval) data.pause().cycle() - }) - } + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } - var old = $.fn.carousel + var old = $.fn.carousel - $.fn.carousel = Plugin - $.fn.carousel.Constructor = Carousel + $.fn.carousel = Plugin + $.fn.carousel.Constructor = Carousel - // CAROUSEL NO CONFLICT - // ==================== + // CAROUSEL NO CONFLICT + // ==================== - $.fn.carousel.noConflict = function () { - $.fn.carousel = old - return this - } + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } - // CAROUSEL DATA-API - // ================= + // CAROUSEL DATA-API + // ================= - $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { - var href - var $this = $(this) - var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - var options = $.extend({}, $target.data(), $this.data()) - var slideIndex = $this.attr('data-slide-to') - if (slideIndex) options.interval = false + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var href + var $this = $(this) + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false - Plugin.call($target, options) + Plugin.call($target, options) - if (slideIndex) { - $target.data('bs.carousel').to(slideIndex) - } + if (slideIndex) { + $target.data('bs.carousel').to(slideIndex) + } - e.preventDefault() - }) + e.preventDefault() + }) - $(window).on('load', function () { - $('[data-ride="carousel"]').each(function () { - var $carousel = $(this) - Plugin.call($carousel, $carousel.data()) + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + Plugin.call($carousel, $carousel.data()) + }) }) + }) -}); +}(); -- cgit v1.2.3 From f071549c8408241b88a95192e477816d2402eb6e Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 22 May 2014 09:00:19 -0700 Subject: fix #13386 --- js/carousel.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 05631f7a3..d3e7e52b4 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -203,6 +203,7 @@ var href var $this = $(this) var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + if (!$target.hasClass('carousel')) return var options = $.extend({}, $target.data(), $this.data()) var slideIndex = $this.attr('data-slide-to') if (slideIndex) options.interval = false -- cgit v1.2.3 From 587451ad9a2b288ed54857c6ac291609a6394c6f Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Thu, 19 Jun 2014 11:41:23 +0200 Subject: Update a few source files to comply to new JSCS rules --- js/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 05631f7a3..7418ec5f5 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -202,7 +202,7 @@ $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { var href var $this = $(this) - var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 var options = $.extend({}, $target.data(), $this.data()) var slideIndex = $this.attr('data-slide-to') if (slideIndex) options.interval = false -- cgit v1.2.3 From c2c19a4d2d45d8ccb5c84d293dea35a94148c9a4 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 23 Jun 2014 11:07:18 -0700 Subject: Revert UMD (#13772 & friends) for now, due to #13812. Will hopefully revert this reversion and land a fully-working version of UMD in v3.3.0. Revert "some changes from #13801 - add strict mode back and ==" This reverts commit 2b302f69eea416bc85e7827b7d7a74d49f879662. Revert "Fix regression of #10038 introduced by #13772" This reverts commit e9d6756a1ac76a9db31a41e8e03f663bedc41b70. Revert "MD/CommonJS/Globals #12909" This reverts commit 1c6fa9010daf0d0c21de9e20fe6ac4dba1788d90. Revert "address #13811" This reverts commit f347d7d955bbb17234b8e12c68efae7d516ce62c. Conflicts: js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/tab.js js/tooltip.js --- js/carousel.js | 344 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 169 insertions(+), 175 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index 7418ec5f5..d7727bcce 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -7,222 +7,216 @@ * ======================================================================== */ -+function () { 'use strict'; - - (function (o_o) { - typeof define == 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery) - })(function ($) { - - // CAROUSEL CLASS DEFINITION - // ========================= - - var Carousel = function (element, options) { - this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this)) - this.$indicators = this.$element.find('.carousel-indicators') - this.options = options - this.paused = - this.sliding = - this.interval = - this.$active = - this.$items = null - - this.options.pause == 'hover' && this.$element - .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) - .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) ++function ($) { + 'use strict'; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this)) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) + .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) + } + + Carousel.VERSION = '3.1.1' + + Carousel.DEFAULTS = { + interval: 5000, + pause: 'hover', + wrap: true + } + + Carousel.prototype.keydown = function (e) { + switch (e.which) { + case 37: this.prev(); break + case 39: this.next(); break + default: return } - Carousel.VERSION = '3.1.1' + e.preventDefault() + } - Carousel.DEFAULTS = { - interval: 5000, - pause: 'hover', - wrap: true - } + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) - Carousel.prototype.keydown = function (e) { - switch (e.which) { - case 37: this.prev(); break - case 39: this.next(); break - default: return - } + this.interval && clearInterval(this.interval) - e.preventDefault() - } + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - Carousel.prototype.cycle = function (e) { - e || (this.paused = false) + return this + } - this.interval && clearInterval(this.interval) + Carousel.prototype.getItemIndex = function (item) { + this.$items = item.parent().children('.item') + return this.$items.index(item || this.$active) + } - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) - return this - } + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } - Carousel.prototype.getItemIndex = function (item) { - this.$items = item.parent().children('.item') - return this.$items.index(item || this.$active) + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition) { + this.$element.trigger($.support.transition.end) + this.cycle(true) } - Carousel.prototype.to = function (pos) { - var that = this - var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } - if (pos > (this.$items.length - 1) || pos < 0) return + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } - if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" - if (activeIndex == pos) return this.pause().cycle() + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this - return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() } - Carousel.prototype.pause = function (e) { - e || (this.paused = true) + if ($next.hasClass('active')) return (this.sliding = false) - if (this.$element.find('.next, .prev').length && $.support.transition) { - this.$element.trigger($.support.transition.end) - this.cycle(true) - } + var relatedTarget = $next[0] + var slideEvent = $.Event('slide.bs.carousel', { + relatedTarget: relatedTarget, + direction: direction + }) + this.$element.trigger(slideEvent) + if (slideEvent.isDefaultPrevented()) return - this.interval = clearInterval(this.interval) + this.sliding = true - return this - } + isCycling && this.pause() - Carousel.prototype.next = function () { - if (this.sliding) return - return this.slide('next') + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) + $nextIndicator && $nextIndicator.addClass('active') } - Carousel.prototype.prev = function () { - if (this.sliding) return - return this.slide('prev') + var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" + if ($.support.transition && this.$element.hasClass('slide')) { + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one('bsTransitionEnd', function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { + that.$element.trigger(slidEvent) + }, 0) + }) + .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) + } else { + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger(slidEvent) } - Carousel.prototype.slide = function (type, next) { - var $active = this.$element.find('.item.active') - var $next = next || $active[type]() - var isCycling = this.interval - var direction = type == 'next' ? 'left' : 'right' - var fallback = type == 'next' ? 'first' : 'last' - var that = this - - if (!$next.length) { - if (!this.options.wrap) return - $next = this.$element.find('.item')[fallback]() - } - - if ($next.hasClass('active')) return (this.sliding = false) - - var relatedTarget = $next[0] - var slideEvent = $.Event('slide.bs.carousel', { - relatedTarget: relatedTarget, - direction: direction - }) - this.$element.trigger(slideEvent) - if (slideEvent.isDefaultPrevented()) return - - this.sliding = true - - isCycling && this.pause() - - if (this.$indicators.length) { - this.$indicators.find('.active').removeClass('active') - var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) - $nextIndicator && $nextIndicator.addClass('active') - } - - var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" - if ($.support.transition && this.$element.hasClass('slide')) { - $next.addClass(type) - $next[0].offsetWidth // force reflow - $active.addClass(direction) - $next.addClass(direction) - $active - .one('bsTransitionEnd', function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { - that.$element.trigger(slidEvent) - }, 0) - }) - .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) - } else { - $active.removeClass('active') - $next.addClass('active') - this.sliding = false - this.$element.trigger(slidEvent) - } - - isCycling && this.cycle() - - return this - } + isCycling && this.cycle() + return this + } - // CAROUSEL PLUGIN DEFINITION - // ========================== - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.carousel') - var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) - var action = typeof option == 'string' ? option : options.slide + // CAROUSEL PLUGIN DEFINITION + // ========================== - if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) - if (typeof option == 'number') data.to(option) - else if (action) data[action]() - else if (options.interval) data.pause().cycle() - }) - } + function Plugin(option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } - var old = $.fn.carousel + var old = $.fn.carousel - $.fn.carousel = Plugin - $.fn.carousel.Constructor = Carousel + $.fn.carousel = Plugin + $.fn.carousel.Constructor = Carousel - // CAROUSEL NO CONFLICT - // ==================== + // CAROUSEL NO CONFLICT + // ==================== - $.fn.carousel.noConflict = function () { - $.fn.carousel = old - return this - } + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } - // CAROUSEL DATA-API - // ================= + // CAROUSEL DATA-API + // ================= - $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { - var href - var $this = $(this) - var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 - var options = $.extend({}, $target.data(), $this.data()) - var slideIndex = $this.attr('data-slide-to') - if (slideIndex) options.interval = false + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var href + var $this = $(this) + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false - Plugin.call($target, options) + Plugin.call($target, options) - if (slideIndex) { - $target.data('bs.carousel').to(slideIndex) - } + if (slideIndex) { + $target.data('bs.carousel').to(slideIndex) + } - e.preventDefault() - }) + e.preventDefault() + }) - $(window).on('load', function () { - $('[data-ride="carousel"]').each(function () { - var $carousel = $(this) - Plugin.call($carousel, $carousel.data()) - }) + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + Plugin.call($carousel, $carousel.data()) }) - }) -}(); +}(jQuery); -- cgit v1.2.3 From ff6b279b3cd37e7e4e6bd93535afd016f6957afc Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 26 Jun 2014 09:13:24 -0700 Subject: bump to v3.2.0 --- js/carousel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/carousel.js') diff --git a/js/carousel.js b/js/carousel.js index eee2d0f84..b7da1ba53 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: carousel.js v3.1.1 + * Bootstrap: carousel.js v3.2.0 * http://getbootstrap.com/javascript/#carousel * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -28,7 +28,7 @@ .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) } - Carousel.VERSION = '3.1.1' + Carousel.VERSION = '3.2.0' Carousel.DEFAULTS = { interval: 5000, -- cgit v1.2.3