From: thiggins Date: Mon, 7 Dec 2015 16:13:57 +0000 (+0000) Subject: Add new dropdown option to persist hover over pane. X-Git-Tag: v6.0.6~56^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7432%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Add new dropdown option to persist hover over pane. This reimplements old v5 default functionality. --- diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index a4d5e51c6..4233c31ac 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -40,6 +40,12 @@ * @example false */ hover: false, + /** + * Don't close dropdown when hovering over dropdown pane + * @option + * @example true + */ + hoverPane: false, /** * Number of pixels between the dropdown pane and the triggering element on open. * @option @@ -199,17 +205,29 @@ this.$anchor.off('mouseenter.zf.dropdown mouseleave.zf.dropdown') .on('mouseenter.zf.dropdown', function(){ clearTimeout(_this.timeout); - _this.timeOut = setTimeout(function(){ + _this.timeout = setTimeout(function(){ _this.open(); _this.$anchor.data('hover', true); }, _this.options.hoverDelay); }).on('mouseleave.zf.dropdown', function(){ clearTimeout(_this.timeout); - _this.timeOut = setTimeout(function(){ + _this.timeout = setTimeout(function(){ _this.close(); _this.$anchor.data('hover', false); }, _this.options.hoverDelay); }); + if(this.options.hoverPane){ + this.$element.off('mouseenter.zf.dropdown mouseleave.zf.dropdown') + .on('mouseenter.zf.dropdown', function(){ + clearTimeout(_this.timeout); + }).on('mouseleave.zf.dropdown', function(){ + clearTimeout(_this.timeout); + _this.timeout = setTimeout(function(){ + _this.close(); + _this.$anchor.data('hover', false); + }, _this.options.hoverDelay); + }); + } } this.$anchor.add(this.$element).on('keydown.zf.dropdown', function(e) { @@ -266,7 +284,7 @@ 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){