From a70da16f6fb8c665f22b78b49a1dff998f1da8a7 Mon Sep 17 00:00:00 2001 From: Steven Bassett Date: Thu, 8 May 2014 20:19:12 -0700 Subject: Adds aria described by to tooltip plugin for accessibility Generates a unique id for tooltip and adds [aria-describedby] to the element it is called on. Resolves issue #13480 - set up test - linted the code styles - passed the tests - integrated feedback from @cvrebert --- dist/js/bootstrap.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'dist/js/bootstrap.js') diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index ea770c956..eb7f7ca0b 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -1233,7 +1233,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re var $tip = this.tip() + var tipId = this.getUID(this.type) + this.setContent() + $tip.attr('id', tipId) + this.$element.attr('aria-describedby', tipId) if (this.options.animation) $tip.addClass('fade') @@ -1356,6 +1360,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re var $tip = this.tip() var e = $.Event('hide.bs.' + this.type) + this.$element.removeAttr('aria-describedby') + function complete() { if (that.hoverState != 'in') $tip.detach() that.$element.trigger('hidden.bs.' + that.type) @@ -1447,6 +1453,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re return title } + Tooltip.prototype.getUID = function (prefix) { + do prefix += ~~(Math.random() * 1000000) + while (document.getElementById(prefix)) + return prefix + } + Tooltip.prototype.tip = function () { return this.$tip = this.$tip || $(this.options.template) } -- cgit v1.2.3 From 8e568a8e3652e48e6af23c1aedce2b63dbd2fa9e Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Fri, 23 May 2014 15:49:13 -0700 Subject: grunt dist --- dist/js/bootstrap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'dist/js/bootstrap.js') diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index f6654d9db..bee010d75 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -1253,6 +1253,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re .detach() .css({ top: 0, left: 0, display: 'block' }) .addClass(placement) + .data('bs.' + this.type, this) this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) @@ -1722,7 +1723,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re ScrollSpy.prototype.process = function () { var scrollTop = this.$scrollElement.scrollTop() + this.options.offset var scrollHeight = this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight) - var maxScroll = scrollHeight - this.$scrollElement.height() + var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height() var offsets = this.offsets var targets = this.targets var activeTarget = this.activeTarget -- cgit v1.2.3 From 03a8949d7c7937dd56da0802acbbded1ee27152f Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 22 May 2014 09:38:57 +0300 Subject: Run `grunt`. --- dist/js/bootstrap.js | 53 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'dist/js/bootstrap.js') diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index bee010d75..7f0ea76a8 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -42,7 +42,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re // http://blog.alexmaccaw.com/css-transitions $.fn.emulateTransitionEnd = function (duration) { - var called = false, $el = this + var called = false + var $el = this $(this).one($.support.transition.end, function () { called = true }) var callback = function () { if (!called) $($el).trigger($.support.transition.end) } setTimeout(callback, duration) @@ -297,7 +298,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re wrap: true } - Carousel.prototype.cycle = function (e) { + Carousel.prototype.cycle = function (e) { e || (this.paused = false) this.interval && clearInterval(this.interval) @@ -364,10 +365,13 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re $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 }) + var slideEvent = $.Event('slide.bs.carousel', { + relatedTarget: relatedTarget, + direction: direction + }) this.$element.trigger(slideEvent) if (slideEvent.isDefaultPrevented()) return @@ -394,7 +398,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re $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 { @@ -446,7 +452,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re // ================= $(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') @@ -454,7 +461,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re Plugin.call($target, options) - if (slideIndex = $this.attr('data-slide-to')) { + if (slideIndex) { $target.data('bs.carousel').to(slideIndex) } @@ -631,7 +638,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re // ================= $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { - var $this = $(this), href + var href + var $this = $(this) var target = $this.attr('data-target') || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 @@ -993,7 +1001,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re } else if (!this.isShown && this.$backdrop) { this.$backdrop.removeClass('in') - var callbackRemove = function() { + var callbackRemove = function () { that.removeBackdrop() callback && callback() } @@ -1013,8 +1021,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar() } - Modal.prototype.setScrollbar = function () { - var bodyPad = parseInt(this.$body.css('padding-right') || 0) + Modal.prototype.setScrollbar = function () { + var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) } @@ -1282,7 +1290,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re this.applyPlacement(calculatedOffset, placement) this.hoverState = null - var complete = function() { + var complete = function () { that.$element.trigger('shown.bs.' + that.type) } @@ -1387,7 +1395,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re Tooltip.prototype.fixTitle = function () { var $e = this.$element - if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { + if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') { $e.attr('data-original-title', $e.attr('title') || '').attr('title', '') } } @@ -1404,7 +1412,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(), width: isBody ? $(window).width() : $element.outerWidth(), height: isBody ? $(window).height() : $element.outerHeight() - }, isBody ? {top: 0, left: 0} : $element.offset()) + }, isBody ? { top: 0, left: 0 } : $element.offset()) } Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { @@ -1461,11 +1469,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re } Tooltip.prototype.tip = function () { - return this.$tip = this.$tip || $(this.options.template) + return (this.$tip = this.$tip || $(this.options.template)) } Tooltip.prototype.arrow = function () { - return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow') + return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')) } Tooltip.prototype.validate = function () { @@ -1612,7 +1620,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re } Popover.prototype.arrow = function () { - return this.$arrow = this.$arrow || this.tip().find('.arrow') + return (this.$arrow = this.$arrow || this.tip().find('.arrow')) } Popover.prototype.tip = function () { @@ -1697,7 +1705,6 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re this.offsets = $([]) this.targets = $([]) - var self = this this.$body @@ -1711,7 +1718,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re return ($href && $href.length && $href.is(':visible') - && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null + && [[$href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null }) .sort(function (a, b) { return a[0] - b[0] }) .each(function () { @@ -1741,7 +1748,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re activeTarget != targets[i] && scrollTop >= offsets[i] && (!offsets[i + 1] || scrollTop <= offsets[i + 1]) - && this.activate( targets[i] ) + && this.activate(targets[i]) } } @@ -1905,7 +1912,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re // TAB PLUGIN DEFINITION // ===================== - function Plugin( option ) { + function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('bs.tab') @@ -2028,7 +2035,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re .trigger($.Event(affixType.replace('affix', 'affixed'))) if (affix == 'bottom') { - this.$element.offset({ top: scrollHeight - this.$element.height() - offsetBottom }) + this.$element.offset({ + top: scrollHeight - this.$element.height() - offsetBottom + }) } } -- cgit v1.2.3 From 1e3b93804fa88d247d8708529fb44b28d73fd91f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sun, 8 Jun 2014 11:18:59 -0700 Subject: grunt --- dist/js/bootstrap.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'dist/js/bootstrap.js') diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 7f0ea76a8..0068a0f09 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -1081,10 +1081,13 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re if ($this.is('a')) e.preventDefault() - Plugin.call($target, option, this) - $target.one('hide.bs.modal', function () { - $this.is(':visible') && $this.trigger('focus') + $target.one('show.bs.modal', function (showEvent) { + if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown + $target.one('hidden.bs.modal', function () { + $this.is(':visible') && $this.trigger('focus') + }) }) + Plugin.call($target, option, this) }) }(jQuery); @@ -1236,8 +1239,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re if (this.hasContent() && this.enabled) { this.$element.trigger(e) - if (e.isDefaultPrevented()) return - var that = this; + var inDom = $.contains(document.documentElement, this.$element[0]) + if (e.isDefaultPrevented() || !inDom) return + var that = this var $tip = this.tip() @@ -1676,20 +1680,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re // ========================== function ScrollSpy(element, options) { - var href var process = $.proxy(this.process, this) - this.$element = $(element).is('body') ? $(window) : $(element) this.$body = $('body') - this.$scrollElement = this.$element.on('scroll.bs.scrollspy', process) + this.$scrollElement = $(element).is('body') ? $(window) : $(element) this.options = $.extend({}, ScrollSpy.DEFAULTS, options) - this.selector = (this.options.target - || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - || '') + ' .nav li > a' - this.offsets = $([]) - this.targets = $([]) + this.selector = (this.options.target || '') + ' .nav li > a' + this.offsets = [] + this.targets = [] this.activeTarget = null + this.$scrollElement.on('scroll.bs.scrollspy', process) this.refresh() this.process() } @@ -1701,10 +1702,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re } ScrollSpy.prototype.refresh = function () { - var offsetMethod = this.$element[0] == window ? 'offset' : 'position' + var offsetMethod = 'offset' + var offsetBase = 0 + + if (!$.isWindow(this.$scrollElement[0])) { + offsetMethod = 'position' + offsetBase = this.$scrollElement.scrollTop() + } + + this.offsets = [] + this.targets = [] - this.offsets = $([]) - this.targets = $([]) var self = this this.$body @@ -1718,7 +1726,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re return ($href && $href.length && $href.is(':visible') - && [[$href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null + && [[$href[offsetMethod]().top + offsetBase, href]]) || null }) .sort(function (a, b) { return a[0] - b[0] }) .each(function () { @@ -1737,7 +1745,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re var i if (scrollTop >= maxScroll) { - return activeTarget != (i = targets.last()[0]) && this.activate(i) + return activeTarget != (i = targets[targets.length - 1]) && this.activate(i) } if (activeTarget && scrollTop <= offsets[0]) { -- cgit v1.2.3