Improved behavior for popovers on navigation
authorAlexander Ebert <ebert@woltlab.com>
Thu, 25 Dec 2014 02:00:58 +0000 (03:00 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 25 Dec 2014 02:00:58 +0000 (03:00 +0100)
wcfsetup/install/files/js/WCF.js

index c6b3b060afaa364780bde87abf5c413af3571658..7f7832d3e54ff78d4877ac135ce5f34ac9cfe5f2 100755 (executable)
@@ -9658,6 +9658,11 @@ WCF.Popover = Class.extend({
                
                this._initContainers();
                WCF.DOMNodeInsertedHandler.addCallback('WCF.Popover.'+selector, $.proxy(this._initContainers, this));
+               
+               $(window).on('beforeunload', (function() {
+                       this._cancelPopover = true;
+                       this._hide(true);
+               }).bind(this));
        },
        
        /**
@@ -9684,20 +9689,14 @@ WCF.Popover = Class.extend({
                                $element.hover($.proxy(this._overElement, this), $.proxy(this._out, this));
                                
                                if ($element.is('a') && $element.attr('href')) {
-                                       $element.click($.proxy(this._cancel, this));
+                                       $element.click((function() {
+                                               this._hide(true);
+                                       }).bind(this));
                                }
                        }
                }, this));
        },
        
-       /**
-        * Cancels popovers if link is being clicked
-        */
-       _cancel: function(event) {
-               this._cancelPopover = true;
-               this._hide(true);
-       },
-       
        /**
         * Triggered once an element is being hovered.
         *