aboutsummaryrefslogtreecommitdiff
path: root/js/tooltip.js
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2014-05-23 14:11:15 -0700
committerChris Rebert <[email protected]>2014-05-23 14:11:15 -0700
commitef6225491729ee3ec3804250e3dddb69cc95fba0 (patch)
tree78ccf7531d9dc79343ac370bc36a2e763f42d858 /js/tooltip.js
parent66bc4d1c677cf83032c4b40563630910c911aca9 (diff)
parenta70da16f6fb8c665f22b78b49a1dff998f1da8a7 (diff)
downloadbootstrap-ef6225491729ee3ec3804250e3dddb69cc95fba0.tar.xz
bootstrap-ef6225491729ee3ec3804250e3dddb69cc95fba0.zip
Merge pull request #13557 from bassettsj/aria-describedby-tooltip-13480
Aria describedby tooltip: #13480
Diffstat (limited to 'js/tooltip.js')
-rw-r--r--js/tooltip.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/js/tooltip.js b/js/tooltip.js
index d985f96e3..936424830 100644
--- a/js/tooltip.js
+++ b/js/tooltip.js
@@ -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)
}