Permalink
Browse files

Added functionality and documentation for autoclose in link dropdowns.

…Closes #5156.
  • Loading branch information...
Jeanie Chung
Jeanie Chung committed Dec 10, 2014
1 parent d6cd764 commit 8563604b8fcf1292956bc4a08677ef3a3fa7c79f
Showing with 30 additions and 0 deletions.
  1. +25 −0 doc/pages/components/dropdown.html
  2. +5 −0 js/foundation/foundation.dropdown.js
@@ -83,6 +83,31 @@ <h3>Directions</h3>
***
<h3>Autoclose</h3>
There is an autoclose option that you can include in the mark up. This is an option that enables the dropdown to close automatically when a link is clicked within the dropdown.
This option is enabled by default, but to disable (keep dropdowns persisting), set the attribute `aria-autoclose` to `false`.
<div class="row">
<div class="large-6 columns">
{{#markdown}}
```html
<a class="button" data-dropdown="autoCloseExample" aria-controls="autoCloseExample" aria-expanded="false">Link Dropdown &raquo;</a>
<ul id="autoCloseExample" class="f-dropdown" data-dropdown-content tabindex="-1" aria-hidden="true" aria-autoclose="false" tabindex="-1">
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
```
{{/markdown}}
</div>
<div class="large-6 columns">
{{> examples_dropdown_autoclose}}
</div>
</div>
***
Available class options:
* `tiny`: Make the dropdown have a max-width of 200px
@@ -77,6 +77,11 @@
})
.on('click.fndtn.dropdown', function (e) {
var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
var links = parent.find('a');
if (links.length > 0 && parent.attr('aria-autoclose') !== "false") {
self.close.call(self, S('[' + self.attr_name() + '-content]'));
}
if (S(e.target).closest('[' + self.attr_name() + ']').length > 0) {
return;

1 comment on commit 8563604

@istrasoft

This comment has been minimized.

Show comment
Hide comment
@istrasoft

istrasoft Dec 13, 2014

Contributor

Very cool to finally have it in standard :) I'll be able to remove my custom changes for that feature.

Contributor

istrasoft commented on 8563604 Dec 13, 2014

Very cool to finally have it in standard :) I'll be able to remove my custom changes for that feature.

Please sign in to comment.