0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Merge branch 'dropdown-aria' of git://github.com/mckramer/bootstrap into mckramer-dropdown-aria

Conflicts:
	docs/_includes/js/dropdowns.html
This commit is contained in:
fat 2014-07-21 22:44:35 -07:00
commit 4775c9296a
2 changed files with 18 additions and 10 deletions

View File

@ -20,7 +20,7 @@
<div class="collapse navbar-collapse bs-example-js-navbar-collapse"> <div class="collapse navbar-collapse bs-example-js-navbar-collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="dropdown"> <li class="dropdown">
<button id="drop1" type="button" class="dropdown-toggle" data-toggle="dropdown"> <button id="drop1" type="button" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown Dropdown
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -33,7 +33,7 @@
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">
<button id="drop2" type="button" class="dropdown-toggle" data-toggle="dropdown"> <button id="drop2" type="button" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown 2 Dropdown 2
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -48,7 +48,7 @@
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li id="fat-menu" class="dropdown"> <li id="fat-menu" class="dropdown">
<button id="drop3" type="button" class="dropdown-toggle" data-toggle="dropdown"> <button id="drop3" type="button" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown 3 Dropdown 3
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -71,7 +71,7 @@
<ul class="nav nav-pills" role="tablist"> <ul class="nav nav-pills" role="tablist">
<li role="presentation" class="active"><a href="#">Regular link</a></li> <li role="presentation" class="active"><a href="#">Regular link</a></li>
<li role="presentation" class="dropdown"> <li role="presentation" class="dropdown">
<button id="drop4" type="button" data-toggle="dropdown"> <button id="drop4" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown Dropdown
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -84,7 +84,7 @@
</ul> </ul>
</li> </li>
<li role="presentation" class="dropdown"> <li role="presentation" class="dropdown">
<button id="drop5" type="button" data-toggle="dropdown"> <button id="drop5" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown 2 Dropdown 2
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -97,7 +97,7 @@
</ul> </ul>
</li> </li>
<li role="presentation" class="dropdown"> <li role="presentation" class="dropdown">
<button id="drop6" type="button" data-toggle="dropdown"> <button id="drop6" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown 3 Dropdown 3
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -122,7 +122,7 @@
<p>Add <code>data-toggle="dropdown"</code> to a link or button to toggle a dropdown.</p> <p>Add <code>data-toggle="dropdown"</code> to a link or button to toggle a dropdown.</p>
{% highlight html %} {% highlight html %}
<div class="dropdown"> <div class="dropdown">
<button id="dLabel" type="button" data-toggle="dropdown"> <button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown trigger Dropdown trigger
<span class="caret"></span> <span class="caret"></span>
</button> </button>
@ -134,7 +134,7 @@
<p>To keep URLs intact with link buttons, use the <code>data-target</code> attribute instead of <code>href="#"</code>.</p> <p>To keep URLs intact with link buttons, use the <code>data-target</code> attribute instead of <code>href="#"</code>.</p>
{% highlight html %} {% highlight html %}
<div class="dropdown"> <div class="dropdown">
<a id="dLabel" data-target="#" href="http://example.com" type="button" data-toggle="dropdown"> <a id="dLabel" data-target="#" href="http://example.com" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown trigger Dropdown trigger
<span class="caret"></span> <span class="caret"></span>
</a> </a>

View File

@ -42,7 +42,9 @@
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$this.trigger('focus') $this
.trigger('focus')
.attr('aria-expanded', 'true')
$parent $parent
.toggleClass('open') .toggleClass('open')
@ -88,11 +90,17 @@
if (e && e.which === 3) return if (e && e.which === 3) return
$(backdrop).remove() $(backdrop).remove()
$(toggle).each(function () { $(toggle).each(function () {
var $parent = getParent($(this)) var $this = $(this)
var $parent = getParent($this)
var relatedTarget = { relatedTarget: this } var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return if (!$parent.hasClass('open')) return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$this.attr('aria-expanded', 'false')
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget) $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
}) })
} }