From 630ff4ff7dca4d51474b8b4168e48e60fc858e0c Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Mon, 19 Mar 2012 20:51:20 -0700 Subject: fix collapse bug in ie7+ for initial collapse in --- js/bootstrap-collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 9a364468b..228d2a182 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -74,7 +74,7 @@ [dimension](size || 'auto') [0].offsetWidth - this.$element[size ? 'addClass' : 'removeClass']('collapse') + this.$element[size != null ? 'addClass' : 'removeClass']('collapse') return this } -- cgit v1.2.3 From bce33bbb091e66a58418395188ea50be151f3f8e Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Mon, 19 Mar 2012 21:10:55 -0700 Subject: if parent in collapse, only grab children --- js/bootstrap-collapse.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 228d2a182..2dbf7a761 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -44,7 +44,7 @@ , show: function () { var dimension = this.dimension() , scroll = $.camelCase(['scroll', dimension].join('-')) - , actives = this.$parent && this.$parent.find('.in') + , actives = this.$parent && this.$parent.find('> .accordion-group > .in') , hasData if (actives && actives.length) { @@ -56,7 +56,6 @@ this.$element[dimension](0) this.transition('addClass', 'show', 'shown') this.$element[dimension](this.$element[0][scroll]) - } , hide: function () { -- cgit v1.2.3 From cb8dcfcebfbbd8f2ea26b786b44992f00d35ac30 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 20 Mar 2012 22:43:27 -0700 Subject: if transitioning collapse, don't start new transition --- js/bootstrap-collapse.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 2dbf7a761..16b91eb24 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -42,11 +42,18 @@ } , show: function () { - var dimension = this.dimension() - , scroll = $.camelCase(['scroll', dimension].join('-')) - , actives = this.$parent && this.$parent.find('> .accordion-group > .in') + var dimension + , scroll + , actives , hasData + if (this.transitioning) return + + dimension = this.dimension() + scroll = $.camelCase(['scroll', dimension].join('-')) + actives = this.$parent && this.$parent.find('> .accordion-group > .in') + hasData + if (actives && actives.length) { hasData = actives.data('collapse') actives.collapse('hide') @@ -59,7 +66,9 @@ } , hide: function () { - var dimension = this.dimension() + var dimension + if (this.transitioning) return + dimension = this.dimension() this.reset(this.$element[dimension]()) this.transition('removeClass', 'hide', 'hidden') this.$element[dimension](0) @@ -82,9 +91,12 @@ var that = this , complete = function () { if (startEvent == 'show') that.reset() + that.transitioning = 0 that.$element.trigger(completeEvent) } + this.transitioning = 1 + this.$element .trigger(startEvent) [method]('in') -- 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-collapse.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 16b91eb24..478eea391 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -61,7 +61,7 @@ } this.$element[dimension](0) - this.transition('addClass', 'show', 'shown') + this.transition('addClass', $.Event('show'), 'shown') this.$element[dimension](this.$element[0][scroll]) } @@ -70,7 +70,7 @@ if (this.transitioning) return dimension = this.dimension() this.reset(this.$element[dimension]()) - this.transition('removeClass', 'hide', 'hidden') + this.transition('removeClass', $.Event('hide'), 'hidden') this.$element[dimension](0) } @@ -95,11 +95,13 @@ that.$element.trigger(completeEvent) } + this.$element.trigger(startEvent) + + if (startEvent.isDefaultPrevented()) return + this.transitioning = 1 - this.$element - .trigger(startEvent) - [method]('in') + this.$element[method]('in') $.support.transition && this.$element.hasClass('collapse') ? this.$element.one($.support.transition.end, complete) : -- 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-collapse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 478eea391..9f462e6bc 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -17,7 +17,8 @@ * limitations under the License. * ============================================================ */ -!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-collapse.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 9f462e6bc..30e139cf8 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -18,16 +18,20 @@ * ============================================================ */ -!function ( $ ) { +!function ($) { - "use strict" + "use strict"; // jshint ;_; - var Collapse = function ( element, options ) { - this.$element = $(element) + + /* COLLAPSE PUBLIC CLASS DEFINITION + * ================================ */ + + var Collapse = function (element, options) { + this.$element = $(element) this.options = $.extend({}, $.fn.collapse.defaults, options) - if (this.options["parent"]) { - this.$parent = $(this.options["parent"]) + if (this.options.parent) { + this.$parent = $(this.options.parent) } this.options.toggle && this.toggle() @@ -53,7 +57,6 @@ dimension = this.dimension() scroll = $.camelCase(['scroll', dimension].join('-')) actives = this.$parent && this.$parent.find('> .accordion-group > .in') - hasData if (actives && actives.length) { hasData = actives.data('collapse') @@ -75,7 +78,7 @@ this.$element[dimension](0) } - , reset: function ( size ) { + , reset: function (size) { var dimension = this.dimension() this.$element @@ -83,12 +86,12 @@ [dimension](size || 'auto') [0].offsetWidth - this.$element[size != null ? 'addClass' : 'removeClass']('collapse') + this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') return this } - , transition: function ( method, startEvent, completeEvent ) { + , transition: function (method, startEvent, completeEvent) { var that = this , complete = function () { if (startEvent == 'show') that.reset() @@ -107,18 +110,19 @@ $.support.transition && this.$element.hasClass('collapse') ? this.$element.one($.support.transition.end, complete) : complete() - } + } , toggle: function () { this[this.$element.hasClass('in') ? 'hide' : 'show']() - } + } } - /* COLLAPSIBLE PLUGIN DEFINITION + + /* COLLAPSIBLE PLUGIN DEFINITION * ============================== */ - $.fn.collapse = function ( option ) { + $.fn.collapse = function (option) { return this.each(function () { var $this = $(this) , data = $this.data('collapse') @@ -149,4 +153,4 @@ }) }) -}( window.jQuery ); \ No newline at end of file +}(window.jQuery); \ No newline at end of file -- cgit v1.2.3 From 0b8042656fc52600e18fb1c7f54dbbe8a284e737 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sun, 15 Apr 2012 16:15:32 -0700 Subject: fixes #2941 + whitespace in collapse --- js/bootstrap-collapse.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 30e139cf8..41e097df3 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -60,6 +60,7 @@ if (actives && actives.length) { hasData = actives.data('collapse') + if (hasData && hasData.transitioning) return actives.collapse('hide') hasData || actives.data('collapse', null) } -- 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-collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-collapse.js') diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 41e097df3..4cd412c73 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -1,5 +1,5 @@ /* ============================================================= - * bootstrap-collapse.js v2.0.2 + * bootstrap-collapse.js v2.0.3 * http://twitter.github.com/bootstrap/javascript.html#collapse * ============================================================= * Copyright 2012 Twitter, Inc. -- cgit v1.2.3