1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-12 08:34:08 +02:00

close #3531 added focus handling and removed the badly announced "times" close button from screenreaders

This commit is contained in:
Dirk Ginader
2012-08-01 20:11:16 -07:00
parent c2e899f2a0
commit 6977d35eed
6 changed files with 63 additions and 33 deletions

20
js/bootstrap-modal.js vendored
View File

@@ -69,7 +69,10 @@
that.$element[0].offsetWidth // force reflow
}
that.$element.addClass('in')
that.$element
.addClass('in')
.attr('aria-hidden', false)
.focus()
that.enforceFocus()
@@ -99,7 +102,9 @@
$(document).off('focusin.modal')
this.$element.removeClass('in')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
$.support.transition && this.$element.hasClass('fade') ?
this.hideWithTransition() :
@@ -118,11 +123,11 @@
, escape: function () {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).on('keyup.dismiss.modal', function ( e ) {
this.$element.on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).off('keyup.dismiss.modal')
this.$element.off('keyup.dismiss.modal')
}
}
@@ -222,7 +227,12 @@
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault()
$target.modal(option)
$target
.modal(option)
.one('hide', function () {
$this.focus()
})
})
})