From: Nicolas Coden Date: Wed, 14 Dec 2016 17:40:46 +0000 (+0100) Subject: Use jQuery data instead of this to save delay X-Git-Tag: v6.3.0~6^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9443%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Use jQuery data instead of this to save delay It allow to destroy the saved datas more easily. --- diff --git a/js/foundation.dropdownMenu.js b/js/foundation.dropdownMenu.js index 61f7cc149..661eed9a9 100644 --- a/js/foundation.dropdownMenu.js +++ b/js/foundation.dropdownMenu.js @@ -118,21 +118,22 @@ class DropdownMenu { hasSub = $elem.hasClass(parClass); if (hasSub) { - clearTimeout(this.delay); - this.delay = setTimeout(function() { + clearTimeout($elem.data('_delay')); + $elem.data('_delay', setTimeout(function() { _this._show($elem.children('.is-dropdown-submenu')); - }, _this.options.hoverDelay); + }, _this.options.hoverDelay)); } }).on('mouseleave.zf.dropdownmenu', function(e) { var $elem = $(this), + elemStore = Foundation.ElemStore(this).store, hasSub = $elem.hasClass(parClass); if (hasSub && _this.options.autoclose) { if ($elem.attr('data-is-click') === 'true' && _this.options.clickOpen) { return false; } - clearTimeout(this.delay); - this.delay = setTimeout(function() { + clearTimeout($elem.data('_delay')); + $elem.data('_delay', setTimeout(function() { _this._hide($elem); - }, _this.options.closingTime); + }, _this.options.closingTime)); } }); }