```html_example
<button class="button" type="button" data-toggle="example-dropdown">Toggle Dropdown</button>
-<div class="dropdown-pane" id="example-dropdown" data-dropdown>
- Just some junk that needs to be said. Or not. Your choice.
+<div class="dropdown-pane" id="example-dropdown" data-dropdown data-auto-focus="true">
+ Example form in a dropdown.
+ <form>
+ <div class="row">
+ <div class="medium-6 columns">
+ <label>Name
+ <input type="text" placeholder="Kirk, James T.">
+ </label>
+ </div>
+ <div class="medium-6 columns">
+ <label>Rank
+ <input type="text" placeholder="Captain">
+ </label>
+ </div>
+ </div>
+ </form>
</div>
*/
positionClass: '',
/**
- * Allow the plugin to trap focus to the dropdown pane on open.
+ * Allow the plugin to trap focus to the dropdown pane if opened with keyboard commands.
* @option
* @example false
*/
- trapFocus: false
+ trapFocus: false,
+ /**
+ * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
+ * @option
+ * @example true
+ */
+ autoFocus: false
};
/**
* Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
if(this.options.hover){
this.$anchor.off('mouseenter.zf.dropdown mouseleave.zf.dropdown')
.on('mouseenter.zf.dropdown', function(){
- console.log('hover');
clearTimeout(_this.timeout);
_this.timeOut = setTimeout(function(){
_this.open();
this._setPosition();
this.$element.addClass('is-open')
.attr({'aria-hidden': false});
-
+
+ if(this.options.autoFocus){
+ var $focusable = Foundation.Keyboard.findFocusable(this.$element);
+ if($focusable.length){
+ $focusable.eq(0).focus();
+ }
+ }
/**