Skip to content

Commit

Permalink
Only allow one dropdown at a time. Automatically close all others whe…
Browse files Browse the repository at this point in the history
…n opening a new one, so we prevent overlap
  • Loading branch information
nesl247 committed Dec 27, 2013
1 parent 7e6e92e commit ff21a94
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/foundation/foundation.dropdown.js
Expand Up @@ -28,12 +28,16 @@
var settings = $(this).data('dropdown-init') || self.settings;
e.preventDefault();

self.closeall.call(self);

if (!settings.is_hover || Modernizr.touch) self.toggle($(this));
})
.on('mouseenter.fndtn.dropdown', '[data-dropdown], [data-dropdown-content]', function (e) {
var $this = $(this);
clearTimeout(self.timeout);

self.closeall.call(self);

if ($this.data('dropdown')) {
var dropdown = $('#' + $this.data('dropdown')),
target = $this;
Expand Down Expand Up @@ -99,6 +103,13 @@
});
},

closeall: function() {
var self = this;
$.each($('[data-dropdown-content]'), function() {
self.close.call(self, $(this))
});
},

open: function (dropdown, target) {
this
.css(dropdown
Expand Down

0 comments on commit ff21a94

Please sign in to comment.