diff options
| author | Steven Bassett <[email protected]> | 2014-05-08 20:19:12 -0700 |
|---|---|---|
| committer | Steven Bassett <[email protected]> | 2014-05-16 10:45:38 -0700 |
| commit | a70da16f6fb8c665f22b78b49a1dff998f1da8a7 (patch) | |
| tree | 1d6316e9dc74efc53646533c94e9dfc2d0f8720f /dist | |
| parent | a40ff40b8fb852af8034b215e2102ca8ff1618e0 (diff) | |
| download | bootstrap-a70da16f6fb8c665f22b78b49a1dff998f1da8a7.tar.xz bootstrap-a70da16f6fb8c665f22b78b49a1dff998f1da8a7.zip | |
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
Diffstat (limited to 'dist')
| -rw-r--r-- | dist/js/bootstrap.js | 12 |
1 files changed, 12 insertions, 0 deletions
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) } |
