Blocking clicks on user panel items when it has just opened
authorAlexander Ebert <ebert@woltlab.com>
Sun, 17 Jul 2016 13:22:18 +0000 (15:22 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 17 Jul 2016 13:22:18 +0000 (15:22 +0200)
wcfsetup/install/files/js/WCF.User.js

index 080c56bec486de644cb22c96a54030e04e748078..97dc371dc3099ea6e713c7d715c6d15d7b324ebe 100644 (file)
@@ -182,13 +182,31 @@ WCF.User.Panel.Abstract = Class.extend({
                        success: $.proxy(this._success, this)
                });
                
-               this._triggerElement.click($.proxy(this.toggle, this));
+               var timerBlockClick = null;
+               this._triggerElement[0].addEventListener(WCF_CLICK_EVENT, (function(event) {
+                       event.preventDefault();
+                       
+                       if ($.browser.mobile) {
+                               this.toggle();
+                       }
+                       else if (this._dropdown.isOpen() && timerBlockClick === null) {
+                               this.toggle();
+                       }
+               }).bind(this));
+               
+               //this._triggerElement.click($.proxy(this.toggle, this));
                
                var timer = null;
                this._triggerElement.hover(
                        (function() {
                                if (this._dropdown === null || !this._dropdown.isOpen()) {
-                                       timer = window.setTimeout(this.toggle.bind(this, undefined, true), 300);
+                                       timer = window.setTimeout((function() {
+                                               timerBlockClick = window.setTimeout(function() {
+                                                       timerBlockClick = null;
+                                               }, 300);
+                                               
+                                               this.toggle(undefined, true);
+                                       }).bind(this), 300);
                                }
                        }).bind(this),
                        function() {