mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-17 09:52:29 +01:00
Merge pull request #4257 from ginader/modal-accessibility
close #3531 added focus handling and removed the badly announced "times"...
This commit is contained in:
commit
7ec1778103
20
docs/assets/js/bootstrap-modal.js
vendored
20
docs/assets/js/bootstrap-modal.js
vendored
@ -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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
20
docs/assets/js/bootstrap.js
vendored
20
docs/assets/js/bootstrap.js
vendored
@ -793,7 +793,10 @@
|
||||
that.$element[0].offsetWidth // force reflow
|
||||
}
|
||||
|
||||
that.$element.addClass('in')
|
||||
that.$element
|
||||
.addClass('in')
|
||||
.attr('aria-hidden', false)
|
||||
.focus()
|
||||
|
||||
that.enforceFocus()
|
||||
|
||||
@ -823,7 +826,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() :
|
||||
@ -842,11 +847,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')
|
||||
}
|
||||
}
|
||||
|
||||
@ -946,7 +951,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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
2
docs/assets/js/bootstrap.min.js
vendored
2
docs/assets/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
@ -214,9 +214,9 @@ $('#myModal').on('show', function (e) {
|
||||
<h3>Live demo</h3>
|
||||
<p>Toggle a modal via javascript by clicking the button below. It will slide down and fade in from the top of the page.</p>
|
||||
<!-- sample modal content -->
|
||||
<div id="myModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div id="myModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">Modal Heading</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -241,8 +241,8 @@ $('#myModal').on('show', function (e) {
|
||||
<p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" role="button" class="btn" data-dismiss="modal" >Close</a>
|
||||
<a href="#" role="button" class="btn btn-primary">Save changes</a>
|
||||
<button class="btn" data-dismiss="modal" >Close</button>
|
||||
<button class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bs-docs-example" style="padding-bottom: 24px;">
|
||||
@ -253,7 +253,7 @@ $('#myModal').on('show', function (e) {
|
||||
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
|
||||
|
||||
<-- Modal -->
|
||||
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal" id="myModal" tabindex="-1" role="dialog>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h3 id="myModalLabel">Modal header</h3>
|
||||
@ -262,8 +262,8 @@ $('#myModal').on('show', function (e) {
|
||||
<p>One fine body…</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" role="button" class="btn">Close</a>
|
||||
<a href="#" role="button" class="btn btn-primary">Save changes</a>
|
||||
<button class="btn" data-dismiss="modal">Close</button>
|
||||
<button class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</pre>
|
||||
|
20
docs/templates/pages/javascript.mustache
vendored
20
docs/templates/pages/javascript.mustache
vendored
@ -113,7 +113,7 @@ $('#myModal').on('show', function (e) {
|
||||
<div class="bs-docs-example" style="background-color: #f5f5f5;">
|
||||
<div class="modal" style="position: relative; top: auto; left: auto; margin: 0 auto 20px; z-index: 1; max-width: 100%;">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>{{_i}}Modal header{{/i}}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -128,7 +128,7 @@ $('#myModal').on('show', function (e) {
|
||||
<pre class="prettyprint linenums">
|
||||
<div class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">&times;</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
|
||||
<h3>{{_i}}Modal header{{/i}}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -144,9 +144,9 @@ $('#myModal').on('show', function (e) {
|
||||
<h3>{{_i}}Live demo{{/i}}</h3>
|
||||
<p>{{_i}}Toggle a modal via javascript by clicking the button below. It will slide down and fade in from the top of the page.{{/i}}</p>
|
||||
<!-- sample modal content -->
|
||||
<div id="myModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div id="myModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">{{_i}}Modal Heading{{/i}}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -171,8 +171,8 @@ $('#myModal').on('show', function (e) {
|
||||
<p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" role="button" class="btn" data-dismiss="modal" >{{_i}}Close{{/i}}</a>
|
||||
<a href="#" role="button" class="btn btn-primary">{{_i}}Save changes{{/i}}</a>
|
||||
<button class="btn" data-dismiss="modal">{{_i}}Close{{/i}}</button>
|
||||
<button class="btn btn-primary">{{_i}}Save changes{{/i}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bs-docs-example" style="padding-bottom: 24px;">
|
||||
@ -183,17 +183,17 @@ $('#myModal').on('show', function (e) {
|
||||
<a href="#myModal" role="button" class="btn" data-toggle="modal">{{_i}}Launch demo modal{{/i}}</a>
|
||||
|
||||
<-- Modal -->
|
||||
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal" id="myModal" tabindex="-1" role="dialog>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">Modal header</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{{_i}}One fine body…{{/i}}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" role="button" class="btn">{{_i}}Close{{/i}}</a>
|
||||
<a href="#" role="button" class="btn btn-primary">{{_i}}Save changes{{/i}}</a>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">{{_i}}Close{{/i}}</button>
|
||||
<button class="btn btn-primary">{{_i}}Save changes{{/i}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</pre>
|
||||
|
20
js/bootstrap-modal.js
vendored
20
js/bootstrap-modal.js
vendored
@ -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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user