Fixed notification dropdown behavior
authorAlexander Ebert <ebert@woltlab.com>
Fri, 28 Nov 2014 12:20:49 +0000 (13:20 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 28 Nov 2014 12:20:49 +0000 (13:20 +0100)
wcfsetup/install/files/js/WCF.User.js

index aa03774b8301781b7fb37415e76772179bc4ded2..cd473f9ef79f4c5a64d380d616e65bba8c9493c3 100644 (file)
@@ -1476,6 +1476,11 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
                                $('<li class="dropdownDivider" />').insertAfter($insertAfter);
                        }
                }
+               
+               var $badge = this._container.find('.badge');
+               if (!$badge.length) {
+                       this._removeMarkAllAsConfirmed();
+               }
        },
        
        /**
@@ -1536,11 +1541,14 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
                        
                        case 'markAllAsConfirmed':
                                this._resetList();
-                       // fall through
+                               
+                               this._updateBadge(0);
+                               this._removeMarkAllAsConfirmed();
+                       break;
+                       
                        case 'getOutstandingNotifications':
                                if (!data.returnValues || !data.returnValues.template) {
-                                       $('#userNotificationsMarkAllAsConfirmed').prev('.dropdownDivider').remove();
-                                       $('#userNotificationsMarkAllAsConfirmed').remove();
+                                       this._removeMarkAllAsConfirmed();
                                }
                                
                                this._super(data, textStatus, jqXHR);
@@ -1559,6 +1567,10 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
                if (this._favico !== null) {
                        this._favico.badge(count);
                }
+               
+               if (count === 0) {
+                       this._removeMarkAllAsConfirmed();
+               }
        },
        
        /**
@@ -1570,9 +1582,17 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
                
                $('<li class="jsDropdownPlaceholder"><span>' + WCF.Language.get('wcf.global.loading') + '</span></li>').prependTo($dropdownMenu);
                
+               // remove double separators
+               $dropdownMenu.children('.dropdownDivider + .dropdownDivider').remove();
+               
                this._didLoad = false;
        },
        
+       _removeMarkAllAsConfirmed: function() {
+               $('#userNotificationsMarkAllAsConfirmed').prev('.dropdownDivider').remove();
+               $('#userNotificationsMarkAllAsConfirmed').remove();
+       },
+       
        /**
         * Updates user notification count.
         *