mirror of
https://github.com/twbs/bootstrap.git
synced 2025-07-31 19:00:23 +02:00
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
This commit is contained in:
@@ -150,7 +150,11 @@
|
||||
|
||||
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')
|
||||
|
||||
@@ -273,6 +277,8 @@
|
||||
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)
|
||||
@@ -364,6 +370,12 @@
|
||||
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user