From ccd4c9d7b5f90cbbef7f2c9d6b9b3dec615185fc Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 31 Jul 2013 22:28:05 -0700 Subject: fixes #8864 --- js/tooltip.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/tooltip.js b/js/tooltip.js index a954923be..30e3ae140 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -249,6 +249,8 @@ var $tip = this.tip() var e = $.Event('hide.bs.' + this.type) + function complete() { $tip.detach() } + this.$element.trigger(e) if (e.isDefaultPrevented()) return @@ -257,9 +259,9 @@ $.support.transition && this.$tip.hasClass('fade') ? $tip - .one($.support.transition.end, $tip.detach) + .one($.support.transition.end, complete) .emulateTransitionEnd(150) : - $tip.detach() + complete() this.$element.trigger('hidden.bs.' + this.type) -- cgit v1.2.3 From 7a3c61ee33b8a07de20b2d30ed2bcd5fd7649fd6 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 31 Jul 2013 22:57:00 -0700 Subject: fixes #8892 --- js/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/collapse.js b/js/collapse.js index 34ac3c7fa..ab575515d 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -48,7 +48,7 @@ this.$element.trigger(startEvent) if (startEvent.isDefaultPrevented()) return - var actives = this.$parent && this.$parent.find('> .accordion-group > .in') + var actives = this.$parent && this.$parent.find('> .accordion-group > .in') if (actives && actives.length) { var hasData = actives.data('bs.collapse') -- cgit v1.2.3 From f6cec812a6a0a4488fc675bbe7d02cfe7d1f7a2d Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 2 Aug 2013 15:13:12 -0700 Subject: fixes #8957 --- js/button.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/button.js b/js/button.js index ae5602fc2..fc73b555f 100644 --- a/js/button.js +++ b/js/button.js @@ -56,7 +56,9 @@ var $parent = this.$element.closest('[data-toggle="buttons"]') if ($parent.length) { - var $input = this.$element.find('input').prop('checked', !this.$element.hasClass('active')) + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') } -- cgit v1.2.3 From 2b6ec389876fac116ae2a152e47be321632dd9ba Mon Sep 17 00:00:00 2001 From: fat Date: Sun, 4 Aug 2013 17:22:49 -0700 Subject: fixes #8880 --- js/popover.js | 4 ++++ js/tooltip.js | 36 ++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 12 deletions(-) (limited to 'js') diff --git a/js/popover.js b/js/popover.js index b5888b6e4..feee3308d 100644 --- a/js/popover.js +++ b/js/popover.js @@ -75,6 +75,10 @@ o.content) } + Popover.prototype.arrow =function () { + return this.$arrow = this.$arrow || this.tip().find('.arrow') + } + Popover.prototype.tip = function () { if (!this.$tip) this.$tip = $(this.options.template) return this.$tip diff --git a/js/tooltip.js b/js/tooltip.js index 30e3ae140..3f9df0340 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -179,12 +179,9 @@ .addClass(placement) } - var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : - placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : - placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : - /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } + var calculatedOffset = this.getCalcuatedOffset(placement, pos, actualWidth, actualHeight) - this.applyPlacement(tp, placement) + this.applyPlacement(calculatedOffset, placement) this.$element.trigger('shown.bs.' + this.type) } } @@ -196,25 +193,33 @@ var height = $tip[0].offsetHeight // manually read margins because getBoundingClientRect includes difference - offset.top = offset.top + parseInt($tip.css('margin-top'), 10) - offset.left = offset.left + parseInt($tip.css('margin-left'), 10) + var marginTop = parseInt($tip.css('margin-top'), 10) + var marginLeft = parseInt($tip.css('margin-left'), 10) + + // we must check for NaN for ie 8/9 + if (isNaN(marginTop)) marginTop = 0 + if (isNaN(marginLeft)) marginLeft = 0 + + offset.top = offset.top + marginTop + offset.left = offset.left + marginLeft $tip .offset(offset) .addClass('in') + // check to see if placing tip in new offset caused the tip to resize itself var actualWidth = $tip[0].offsetWidth var actualHeight = $tip[0].offsetHeight if (placement == 'top' && actualHeight != height) { replace = true - offset.top = offset.top + height - actualHeight + offset.top = offset.top + height - actualHeight } - if (placement == 'bottom' || placement == 'top') { + if (/bottom|top/.test(placement)) { var delta = 0 - if (offset.left < 0){ + if (offset.left < 0) { delta = offset.left * -2 offset.left = 0 @@ -287,6 +292,13 @@ }, this.$element.offset()) } + Tooltip.prototype.getCalcuatedOffset = function (placement, pos, actualWidth, actualHeight) { + return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : + placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : + placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : + /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } + } + Tooltip.prototype.getTitle = function () { var title var $e = this.$element @@ -302,8 +314,8 @@ return this.$tip = this.$tip || $(this.options.template) } - Tooltip.prototype.arrow =function(){ - return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") + Tooltip.prototype.arrow =function () { + return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow') } Tooltip.prototype.validate = function () { -- cgit v1.2.3 From 180034a4b450fb4a6567d6dbaaeb680905d798c4 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sun, 4 Aug 2013 17:36:08 -0700 Subject: tooltip.js: add missing space --- js/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/tooltip.js b/js/tooltip.js index 3f9df0340..8f2beedce 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -314,7 +314,7 @@ return this.$tip = this.$tip || $(this.options.template) } - Tooltip.prototype.arrow =function () { + Tooltip.prototype.arrow = function () { return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow') } -- cgit v1.2.3 From 700e742a9cfac5e90ff882a5437e95691b090de0 Mon Sep 17 00:00:00 2001 From: Jason Diamond Date: Sun, 4 Aug 2013 23:59:30 -0700 Subject: failing test for dot in data-parent --- js/tests/unit/collapse.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'js') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 73799c75d..11b2cf838 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -126,4 +126,39 @@ $(function () { target3.click() }) + test("should allow dots in data-parent", function () { + $.support.transition = false + stop() + + var accordion = $('
') + .appendTo($('#qunit-fixture')) + + var target1 = $('') + .appendTo(accordion.find('.accordion-group').eq(0)) + + var collapsible1 = $('
') + .appendTo(accordion.find('.accordion-group').eq(0)) + + var target2 = $('') + .appendTo(accordion.find('.accordion-group').eq(1)) + + var collapsible2 = $('
') + .appendTo(accordion.find('.accordion-group').eq(1)) + + var target3 = $('') + .appendTo(accordion.find('.accordion-group').eq(2)) + + var collapsible3 = $('
') + .appendTo(accordion.find('.accordion-group').eq(2)) + .on('show.bs.collapse', function () { + ok(target1.hasClass('collapsed')) + ok(target2.hasClass('collapsed')) + ok(!target3.hasClass('collapsed')) + + start() + }) + + target3.click() + }) + }) -- cgit v1.2.3 From fb57eda26857f1312e4415926135e675895b13e1 Mon Sep 17 00:00:00 2001 From: Jason Diamond Date: Sun, 4 Aug 2013 23:59:57 -0700 Subject: use quotes to allow dots in data-parent --- js/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/collapse.js b/js/collapse.js index ab575515d..b20022a2e 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -169,7 +169,7 @@ var $parent = parent && $(parent) if (!data || !data.transitioning) { - if ($parent) $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed') + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') } -- cgit v1.2.3 From f266595092cd43aead1f6617933554110aeb46ac Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 6 Aug 2013 11:18:12 -0700 Subject: Fixes #9150: Hide popover titles in IE8 Properly hides popover titles in IE8 because apparently it doesn't accept the `:empty` selector. /cc @fat @cvrebert --- js/popover.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/popover.js b/js/popover.js index feee3308d..4d4979247 100644 --- a/js/popover.js +++ b/js/popover.js @@ -58,7 +58,13 @@ $tip.removeClass('fade top bottom left right in') - $tip.find('.popover-title:empty').hide() + // Hide empty titles + // + // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do + // this manually by checking the contents. + if ($tip.find('.popover-title').html() === '') { + $tip.find('.popover-title').hide(); + } } Popover.prototype.hasContent = function () { -- cgit v1.2.3 From f816a18f7980d22de07f6e341551af68c3ba7958 Mon Sep 17 00:00:00 2001 From: Braden Whitten Date: Tue, 6 Aug 2013 17:02:57 -0400 Subject: Fix spacing after '=' Just added a space after a function definition to tidy up the code. --- js/popover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/popover.js b/js/popover.js index 4d4979247..24b85715f 100644 --- a/js/popover.js +++ b/js/popover.js @@ -81,7 +81,7 @@ o.content) } - Popover.prototype.arrow =function () { + Popover.prototype.arrow = function () { return this.$arrow = this.$arrow || this.tip().find('.arrow') } -- cgit v1.2.3 From f86f6ee9555819468467d48387becf80c831d34f Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 8 Aug 2013 13:29:46 -0700 Subject: fix 'Calcuated' typo & run grunt; thanks @FagnerMartinsBrack fixes typo introduced in 2b6ec389876fac116ae2a152e47be321632dd9ba --- js/tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/tooltip.js b/js/tooltip.js index 8f2beedce..cd4ee50ed 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -179,7 +179,7 @@ .addClass(placement) } - var calculatedOffset = this.getCalcuatedOffset(placement, pos, actualWidth, actualHeight) + var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) this.applyPlacement(calculatedOffset, placement) this.$element.trigger('shown.bs.' + this.type) @@ -292,7 +292,7 @@ }, this.$element.offset()) } - Tooltip.prototype.getCalcuatedOffset = function (placement, pos, actualWidth, actualHeight) { + Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : -- cgit v1.2.3 From dbed9da77403337235acb652c3128ebc84672d60 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 9 Aug 2013 00:16:47 -0700 Subject: fixes #6159 --- js/modal.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/modal.js b/js/modal.js index d53cc9eaf..89c705a38 100644 --- a/js/modal.js +++ b/js/modal.js @@ -38,13 +38,13 @@ , show: true } - Modal.prototype.toggle = function () { - return this[!this.isShown ? 'show' : 'hide']() + Modal.prototype.toggle = function (_relatedTarget) { + return this[!this.isShown ? 'show' : 'hide'](_relatedTarget) } - Modal.prototype.show = function () { + Modal.prototype.show = function (_relatedTarget) { var that = this - var e = $.Event('show.bs.modal') + var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) this.$element.trigger(e) @@ -73,13 +73,15 @@ that.enforceFocus() + var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) + transition ? that.$element .one($.support.transition.end, function () { - that.$element.focus().trigger('shown.bs.modal') + that.$element.focus().trigger(e) }) .emulateTransitionEnd(300) : - that.$element.focus().trigger('shown.bs.modal') + that.$element.focus().trigger(e) }) } @@ -192,15 +194,15 @@ var old = $.fn.modal - $.fn.modal = function (option) { + $.fn.modal = function (option, _relatedTarget) { return this.each(function () { var $this = $(this) var data = $this.data('bs.modal') var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) if (!data) $this.data('bs.modal', (data = new Modal(this, options))) - if (typeof option == 'string') data[option]() - else if (options.show) data.show() + if (typeof option == 'string') data[option](_relatedTarget) + else if (options.show) data.show(_relatedTarget) }) } @@ -223,12 +225,12 @@ var $this = $(this) var href = $this.attr('href') var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 - var option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) + var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) e.preventDefault() $target - .modal(option) + .modal(option, this) .one('hide', function () { $this.is(':visible') && $this.focus() }) -- cgit v1.2.3 From a4f0e8d37ab109c3f4476877854d4aea149fb1f2 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 10 Aug 2013 13:35:20 -0700 Subject: fixes #9111 --- js/modal.js | 3 +- js/tests/unit/modal.js | 301 ++++++++++++++++++++++++++----------------------- 2 files changed, 163 insertions(+), 141 deletions(-) (limited to 'js') diff --git a/js/modal.js b/js/modal.js index 89c705a38..ff3de1d94 100644 --- a/js/modal.js +++ b/js/modal.js @@ -103,6 +103,7 @@ this.$element .removeClass('in') .attr('aria-hidden', true) + .off('click.dismiss.modal') $.support.transition && this.$element.hasClass('fade') ? this.$element @@ -155,7 +156,7 @@ this.$backdrop = $('