js/foundation/foundation.dropdown.js in zurb-foundation-4.3.1 vs js/foundation/foundation.dropdown.js in zurb-foundation-4.3.2

- old
+ new

@@ -4,11 +4,11 @@ 'use strict'; Foundation.libs.dropdown = { name : 'dropdown', - version : '4.3.0', + version : '4.3.2', settings : { activeClass: 'open', is_hover: false, opened: function(){}, @@ -58,14 +58,16 @@ .on('closed.fndtn.dropdown', '[data-dropdown-content]', this.settings.closed); $(document).on('click.fndtn.dropdown', function (e) { var parent = $(e.target).closest('[data-dropdown-content]'); - if ($(e.target).data('dropdown')) { + if ($(e.target).data('dropdown') || $(e.target).parent().data('dropdown')) { return; } - if (parent.length > 0 && ($(e.target).is('[data-dropdown-content]') || $.contains(parent.first()[0], e.target))) { + if (!($(e.target).data('revealId')) && + (parent.length > 0 && ($(e.target).is('[data-dropdown-content]') || + $.contains(parent.first()[0], e.target)))) { e.stopPropagation(); return; } self.close.call(self, $('[data-dropdown-content]')); @@ -97,10 +99,14 @@ dropdown.trigger('opened'); }, toggle : function (target) { var dropdown = $('#' + target.data('dropdown')); + if (dropdown.length === 0) { + // No dropdown found, not continuing + return; + } this.close.call(this, $('[data-dropdown-content]').not(dropdown)); if (dropdown.hasClass(this.settings.activeClass)) { this.close.call(this, dropdown); @@ -131,15 +137,15 @@ if (this.small()) { dropdown.css({ position : 'absolute', width: '95%', - left: '2.5%', 'max-width': 'none', top: position.top + this.outerHeight(target) }); + dropdown.css(Foundation.rtl ? 'right':'left', '2.5%'); } else { - if (!Foundation.rtl && $(window).width() > this.outerWidth(dropdown) + target.offset().left) { + if (!Foundation.rtl && $(window).width() > this.outerWidth(dropdown) + target.offset().left && !this.data_options(target).align_right) { var left = position.left; if (dropdown.hasClass('right')) { dropdown.removeClass('right'); } } else {