diff options
| author | Mark Otto <[email protected]> | 2013-08-06 18:29:54 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2013-08-06 18:29:54 -0700 |
| commit | 402dbfb6171e18aa44e19429e796169f02b0adf7 (patch) | |
| tree | aeb0cef7cc1b04988307a0ef79b07fbe2d7d197c /js | |
| parent | 7e19b6b02ccd5417a6c2d3d418c08219773f1112 (diff) | |
| parent | 41bdd1a4823feb8b46b2fccfeec3e9c5057a0665 (diff) | |
| download | bootstrap-402dbfb6171e18aa44e19429e796169f02b0adf7.tar.xz bootstrap-402dbfb6171e18aa44e19429e796169f02b0adf7.zip | |
Merge branch '3.0.0-wip' into bs3_theme
Conflicts:
dist/css/bootstrap.min.css
Diffstat (limited to 'js')
| -rw-r--r-- | js/button.js | 4 | ||||
| -rw-r--r-- | js/collapse.js | 2 | ||||
| -rw-r--r-- | js/popover.js | 12 | ||||
| -rw-r--r-- | js/tooltip.js | 42 |
4 files changed, 43 insertions, 17 deletions
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') } 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') diff --git a/js/popover.js b/js/popover.js index b5888b6e4..24b85715f 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 () { @@ -75,6 +81,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 a954923be..8f2beedce 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 @@ -249,6 +254,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 +264,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) @@ -285,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 @@ -300,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 () { |
