]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add new dropdown option to persist hover over pane. 7432/head
authorthiggins <thiggins@thiggins.dev.insightsquared.com>
Mon, 7 Dec 2015 16:13:57 +0000 (16:13 +0000)
committerthiggins <thiggins@thiggins.dev.insightsquared.com>
Mon, 7 Dec 2015 16:13:57 +0000 (16:13 +0000)
This reimplements old v5 default functionality.

js/foundation.dropdown.js

index a4d5e51c68441637c4a8c93659e26144f900eb1c..4233c31aca4737bf1a707e882f0332b198460dc2 100644 (file)
      * @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
       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) {
 
     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){