Added a visual separator for new notifications
authorAlexander Ebert <ebert@woltlab.com>
Thu, 27 Nov 2014 15:13:37 +0000 (16:13 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 27 Nov 2014 15:13:37 +0000 (16:13 +0100)
wcfsetup/install/files/js/WCF.User.js

index f62c0ed02d3380a1feb1f6d6d9f4fbd1e2b38148..aa03774b8301781b7fb37415e76772179bc4ded2 100644 (file)
@@ -1426,13 +1426,7 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
                                var $dropdownMenu = WCF.Dropdown.getDropdownMenu(this._container.wcfIdentify());
                                
                                // check if there is at least one unconfirmed item
-                               var $count = 0;
-                               $dropdownMenu.children('li.jsNotificationItem').each(function() {
-                                       if (!$(this).data('isConfirmed')) {
-                                               $count++;
-                                       }
-                               });
-                               
+                               var $count = $dropdownMenu.children('li.notificationUnconfirmed').length;
                                if (!$count && $count != $badge.text() && !$dropdownMenu.is(':visible')) {
                                        this._resetList();
                                        
@@ -1451,6 +1445,7 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
        _after: function(dropdownMenu) {
                var $items = WCF.Dropdown.getDropdownMenu(this._container.wcfIdentify()).children('li.jsNotificationItem');
                
+               var $insertAfter = null;
                $items.each((function(index, item) {
                        var $item = $(item);
                        
@@ -1464,12 +1459,23 @@ WCF.Notification.UserPanel = WCF.UserPanel.extend({
                                $markAsConfirmed.click($.proxy(this._markAsConfirmed, this));
                        }
                        
+                       if (!$item.data('isConfirmed')) {
+                               $insertAfter = $item;
+                       }
+                       
                        $item.click(function(event) {
                                if (event.target.tagName !== 'A') {
                                        window.location = $item.data('link');
                                }
                        });
                }).bind(this));
+               
+               if ($insertAfter !== null) {
+                       // check if it is followed by a confirmed item
+                       if ($insertAfter.next('.notificationItem').length) {
+                               $('<li class="dropdownDivider" />').insertAfter($insertAfter);
+                       }
+               }
        },
        
        /**