diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2014-07-12 18:44:16 +0400 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2014-07-12 20:23:39 +0400 |
commit | 43a76e57c9e3d8c53603ef0956b80e9dfcb24931 (patch) | |
tree | 574c4c47cdc67ff2b3d623cec533b9ac12ed2aee /assets/javascripts/bootstrap.js | |
parent | d5625c907168b6311be122b99d89614e02448475 (diff) |
rake convert
Diffstat (limited to 'assets/javascripts/bootstrap.js')
-rw-r--r-- | assets/javascripts/bootstrap.js | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/assets/javascripts/bootstrap.js b/assets/javascripts/bootstrap.js index 30409f48..a7870a9c 100644 --- a/assets/javascripts/bootstrap.js +++ b/assets/javascripts/bootstrap.js @@ -83,7 +83,7 @@ this.$element .removeClass(Affix.RESET) .addClass(affixType) - .trigger($.Event(affixType.replace('affix', 'affixed'))) + .trigger(affixType.replace('affix', 'affixed') + '.bs.affix') if (affix == 'bottom') { this.$element.offset({ @@ -333,15 +333,31 @@ } + // FOCUS SHIM (FOR BUTTON GROUPS) + // ============================== + + function getBtnTarget(target) { + var $target = $(target) + return $target.hasClass('btn') ? $target : $target.parent('.btn') + } + + // BUTTON DATA-API // =============== - $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - Plugin.call($btn, 'toggle') - e.preventDefault() - }) + $(document) + .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + Plugin.call($btn, 'toggle') + e.preventDefault() + }) + .on('focus.bs.button.data-api', '[data-toggle^="button"]', function (e) { + getBtnTarget(e.target).addClass('focus') + }) + .on('blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { + getBtnTarget(e.target).removeClass('focus') + }) }(jQuery); @@ -659,8 +675,7 @@ this.$element .addClass('collapsing') - .removeClass('collapse') - .removeClass('in') + .removeClass('collapse in') this.transitioning = 1 @@ -732,7 +747,7 @@ if (!data || !data.transitioning) { if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed') - $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + $this.toggleClass('collapsed', $target.hasClass('in')) } Plugin.call($target, option) @@ -949,7 +964,7 @@ var $active = container.find('> .active') var transition = callback && $.support.transition - && $active.hasClass('fade') + && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length) function next() { $active @@ -973,7 +988,7 @@ callback && callback() } - transition ? + $active.length && transition ? $active .one('bsTransitionEnd', next) .emulateTransitionEnd(150) : @@ -1389,11 +1404,11 @@ Modal.prototype.escape = function () { if (this.isShown && this.options.keyboard) { - this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { + this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { e.which == 27 && this.hide() }, this)) } else if (!this.isShown) { - this.$element.off('keyup.dismiss.bs.modal') + this.$element.off('keydown.dismiss.bs.modal') } } @@ -1420,7 +1435,7 @@ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') .appendTo(this.$body) - this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { + this.$element.on('mousedown.dismiss.bs.modal', $.proxy(function (e) { if (e.target !== e.currentTarget) return this.options.backdrop == 'static' ? this.$element[0].focus.call(this.$element[0]) @@ -1851,13 +1866,20 @@ Tooltip.prototype.getPosition = function ($element) { $element = $element || this.$element + var el = $element[0] var isBody = el.tagName == 'BODY' - return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, { - scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(), + var isSvg = window.SVGElement && el instanceof window.SVGElement + + var elRect = el.getBoundingClientRect ? el.getBoundingClientRect() : null + var elOffset = isBody ? { top: 0, left: 0 } : $element.offset() + var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } + var outerDims = isSvg ? {} : { width: isBody ? $(window).width() : $element.outerWidth(), height: isBody ? $(window).height() : $element.outerHeight() - }, isBody ? { top: 0, left: 0 } : $element.offset()) + } + + return $.extend({}, elRect, scroll, outerDims, elOffset) } Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { |