Merge remote-tracking branch 'refs/remotes/origin/3.0'
authorAlexander Ebert <ebert@woltlab.com>
Thu, 10 Aug 2017 10:10:37 +0000 (12:10 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 10 Aug 2017 10:10:37 +0000 (12:10 +0200)
# Conflicts:
# wcfsetup/install/files/js/WCF.User.js

1  2 
wcfsetup/install/files/js/WCF.User.js

index aec0ca94305aae75cb44221a72df9c66c0a6a659,46199634f55088b0af6bee5b52787258e5af35a5..8c43314795db46a30c54d744df7ecc2a62f9bbbb
@@@ -312,332 -298,279 +312,333 @@@ if (COMPILER_TARGET_DEFAULT) 
                                        }).bind(this));
                                }
                                
 -                              $outstandingItems.each((function(index, item) {
 -                                      var $item = $(item).addClass('interactiveDropdownItemOutstandingIcon');
 -                                      var $objectID = $item.data('objectID');
 +                              this._dropdown.getItemList().children().each(function (index, item) {
 +                                      var $item = $(item);
 +                                      var $link = $item.data('link');
                                        
 -                                      var $button = $('<div class="interactiveDropdownItemMarkAsRead"><a href="#" title="' + WCF.Language.get('wcf.user.panel.markAsRead') + '" class="jsTooltip"><span class="icon icon16 fa-check" /></a></div>').appendTo($item);
 -                                      $button.click((function(event) {
 -                                              this._markAsRead(event, $objectID);
 +                                      if ($link) {
 +                                              if ($.browser.msie) {
 +                                                      $item.click(function (event) {
 +                                                              if (event.target.tagName !== 'A') {
 +                                                                      window.location = $link;
 +                                                                      
 +                                                                      return false;
 +                                                              }
 +                                                      });
 +                                              }
 +                                              else {
 +                                                      $item.addClass('interactiveDropdownItemShadow');
 +                                                      $('<a href="' + $link + '" class="interactiveDropdownItemShadowLink" />').appendTo($item);
 +                                              }
                                                
 -                                              return false;
 -                                      }).bind(this));
 -                              }).bind(this));
 +                                              if ($item.data('linkReplaceAll')) {
 +                                                      $item.find('> .box48 a:not(.userLink)').prop('href', $link);
 +                                              }
 +                                      }
 +                              });
 +                              
 +                              this._dropdown.rebuildScrollbar();
                        }
                        
 -                      this._dropdown.getItemList().children().each(function(index, item) {
 -                              var $item = $(item);
 -                              var $link = $item.data('link');
 -                              
 -                              if ($link) {
 -                                      if ($.browser.msie) {
 -                                              $item.click(function(event) {
 -                                                      if (event.target.tagName !== 'A') {
 -                                                              window.location = $link;
 -                                                              
 -                                                              return false;
 -                                                      }
 -                                              });
 -                                      }
 -                                      else {
 -                                              $item.addClass('interactiveDropdownItemShadow');
 -                                              $('<a href="' + $link + '" class="interactiveDropdownItemShadowLink" />').appendTo($item);
 -                                      }
 -                                      
 -                                      if ($item.data('linkReplaceAll')) {
 -                                              $item.find('> .box48 a:not(.userLink)').prop('href', $link);
 +                      if (data.returnValues.totalCount !== undefined) {
 +                              this.updateBadge(data.returnValues.totalCount);
 +                      }
 +                      
 +                      if (this._options.enableMarkAsRead) {
 +                              if (data.returnValues.markAsRead) {
 +                                      var $item = this._dropdown.getItemList().children('li[data-object-id=' + data.returnValues.markAsRead + ']');
 +                                      if ($item.length) {
 +                                              $item.removeClass('interactiveDropdownItemOutstanding').data('isRead', true);
 +                                              $item.children('.interactiveDropdownItemMarkAsRead').remove();
                                        }
                                }
 -                      });
 +                              else if (data.returnValues.markAllAsRead) {
 +                                      this.resetItems();
 +                                      this.updateBadge(0);
 +                              }
 +                      }
 +              },
 +              
 +              /**
 +               * Marks an item as read.
 +               *
 +               * @param        object                event
 +               * @param        integer                objectID
 +               */
 +              _markAsRead: function (event, objectID) {
 +                      // override this in your own implementation to mark an item as read
 +              },
 +              
 +              /**
 +               * Marks all items as read.
 +               */
 +              _markAllAsRead: function () {
 +                      // override this in your own implementation to mark all items as read
 +              },
 +              
 +              /**
 +               * Updates the badge's count or removes it if count reaches zero. Passing a negative number is undefined.
 +               *
 +               * @param        integer                count
 +               */
 +              updateBadge: function (count) {
 +                      count = parseInt(count) || 0;
                        
 -                      this._dropdown.rebuildScrollbar();
 -              }
 -              
 -              if (data.returnValues.totalCount !== undefined) {
 -                      this.updateBadge(data.returnValues.totalCount);
 -              }
 -              
 -              if (this._options.enableMarkAsRead) {
 -                      if (data.returnValues.markAsRead) {
 -                              var $item = this._dropdown.getItemList().children('li[data-object-id=' + data.returnValues.markAsRead + ']');
 -                              if ($item.length) {
 -                                      $item.removeClass('interactiveDropdownItemOutstanding').data('isRead', true);
 -                                      $item.children('.interactiveDropdownItemMarkAsRead').remove();
 +                      if (count) {
 +                              if (this._badge === null) {
 +                                      this._badge = $('<span class="badge badgeUpdate" />').appendTo(this._triggerElement.children('a'));
 +                                      this._badge.before(' ');
                                }
 +                              
 +                              this._badge.text(count);
                        }
 -                      else if (data.returnValues.markAllAsRead) {
 -                              this.resetItems();
 -                              this.updateBadge(0);
 +                      else if (this._badge !== null) {
 +                              this._badge.remove();
 +                              this._badge = null;
                        }
 -              }
 -      },
 -      
 -      /**
 -       * Marks an item as read.
 -       * 
 -       * @param       object          event
 -       * @param       integer         objectID
 -       */
 -      _markAsRead: function(event, objectID) {
 -              // override this in your own implementation to mark an item as read
 -      },
 -      
 -      /**
 -       * Marks all items as read.
 -       */
 -      _markAllAsRead: function() {
 -              // override this in your own implementation to mark all items as read
 -      },
 -      
 -      /**
 -       * Updates the badge's count or removes it if count reaches zero. Passing a negative number is undefined.
 -       * 
 -       * @param       integer         count
 -       */
 -      updateBadge: function(count) {
 -              count = parseInt(count) || 0;
 -              
 -              if (count) {
 -                      if (this._badge === null) {
 -                              this._badge = $('<span class="badge badgeUpdate" />').appendTo(this._triggerElement.children('a'));
 -                              this._badge.before(' ');
 +                      
 +                      if (this._options.enableMarkAsRead) {
 +                              if (!count && this._markAllAsReadLink !== null) {
 +                                      this._markAllAsReadLink.remove();
 +                                      this._markAllAsReadLink = null;
 +                              }
                        }
                        
 -                      this._badge.text(count);
 -              }
 -              else if (this._badge !== null) {
 -                      this._badge.remove();
 -                      this._badge = null;
 -              }
 -              
 -              if (this._options.enableMarkAsRead) {
 -                      if (!count && this._markAllAsReadLink !== null) {
 -                              this._markAllAsReadLink.remove();
 -                              this._markAllAsReadLink = null;
 +                      WCF.System.Event.fireEvent('com.woltlab.wcf.userMenu', 'updateBadge', {
 +                              count: count,
 +                              identifier: this._identifier
 +                      });
 +              },
 +              
 +              /**
 +               * Resets the dropdown's inner item list.
 +               */
 +              resetItems: function () {
 +                      // this method could be called from outside, but the dropdown was never
 +                      // toggled and thus never initialized
 +                      if (this._dropdown !== null) {
 +                              this._dropdown.resetItems();
++                              this._loadData = true;
                        }
                }
 -              
 -              WCF.System.Event.fireEvent('com.woltlab.wcf.userMenu', 'updateBadge', {
 -                      count: count,
 -                      identifier: this._identifier
 -              });
 -      },
 -      
 -      /**
 -       * Resets the dropdown's inner item list.
 -       */
 -      resetItems: function() {
 -              // this method could be called from outside, but the dropdown was never
 -              // toggled and thus never initialized
 -              if (this._dropdown !== null) {
 -                      this._dropdown.resetItems();
 -                      this._loadData = true;
 -              }
 -      }
 -});
 -
 -/**
 - * User Panel implementation for user notifications.
 - * 
 - * @see       WCF.User.Panel.Abstract
 - */
 -WCF.User.Panel.Notification = WCF.User.Panel.Abstract.extend({
 -      /**
 -       * favico instance
 -       * @var Favico
 -       */
 -      _favico: null,
 +      });
        
        /**
 -       * @see WCF.User.Panel.Abstract.init()
 +       * User Panel implementation for user notifications.
 +       *
 +       * @see        WCF.User.Panel.Abstract
         */
 -      init: function(options) {
 -              options.enableMarkAsRead = true;
 -              
 -              this._super($('#userNotifications'), 'userNotifications', options);
 +      WCF.User.Panel.Notification = WCF.User.Panel.Abstract.extend({
 +              /**
 +               * favico instance
 +               * @var        Favico
 +               */
 +              _favico: null,
                
 -              try {
 -                      this._favico = new Favico({
 -                              animation: 'none',
 -                              type: 'circle'
 -                      });
 +              /**
 +               * @see        WCF.User.Panel.Abstract.init()
 +               */
 +              init: function (options) {
 +                      options.enableMarkAsRead = true;
                        
 -                      if (this._badge !== null) {
 -                              var $count = parseInt(this._badge.text()) || 0;
 -                              this._favico.badge($count);
 -                      }
 -              }
 -              catch (e) {
 -                      console.debug("[WCF.User.Panel.Notification] Failed to initialized Favico: " + e.message);
 -              }
 -              
 -              WCF.System.PushNotification.addCallback('userNotificationCount', $.proxy(this.updateUserNotificationCount, this));
 -              
 -              require(['EventHandler'], (function(EventHandler) {
 -                      EventHandler.add('com.woltlab.wcf.UserMenuMobile', 'more', (function(data) {
 -                              if (data.identifier === 'com.woltlab.wcf.notifications') {
 -                                      this.toggle();
 +                      this._super($('#userNotifications'), 'userNotifications', options);
 +                      
 +                      try {
 +                              this._favico = new Favico({
 +                                      animation: 'none',
 +                                      type: 'circle'
 +                              });
 +                              
 +                              if (this._badge !== null) {
 +                                      var $count = parseInt(this._badge.text()) || 0;
 +                                      this._favico.badge($count);
                                }
 +                      }
 +                      catch (e) {
 +                              console.debug("[WCF.User.Panel.Notification] Failed to initialized Favico: " + e.message);
 +                      }
 +                      
 +                      WCF.System.PushNotification.addCallback('userNotificationCount', $.proxy(this.updateUserNotificationCount, this));
 +                      
 +                      require(['EventHandler'], (function (EventHandler) {
 +                              EventHandler.add('com.woltlab.wcf.UserMenuMobile', 'more', (function (data) {
 +                                      if (data.identifier === 'com.woltlab.wcf.notifications') {
 +                                              this.toggle();
 +                                      }
 +                              }).bind(this));
                        }).bind(this));
 -              }).bind(this));
 -      },
 -      
 -      /**
 -       * @see WCF.User.Panel.Abstract._initDropdown()
 -       */
 -      _initDropdown: function() {
 -              var $dropdown = this._super();
 +              },
                
 -              $('<li><a href="' + this._options.settingsLink + '" title="' + WCF.Language.get('wcf.user.panel.settings') + '" class="jsTooltip"><span class="icon icon24 fa-cog" /></a></li>').appendTo($dropdown.getLinkList());
 +              /**
 +               * @see        WCF.User.Panel.Abstract._initDropdown()
 +               */
 +              _initDropdown: function () {
 +                      var $dropdown = this._super();
 +                      
 +                      $('<li><a href="' + this._options.settingsLink + '" title="' + WCF.Language.get('wcf.user.panel.settings') + '" class="jsTooltip"><span class="icon icon24 fa-cog" /></a></li>').appendTo($dropdown.getLinkList());
 +                      
 +                      return $dropdown;
 +              },
                
 -              return $dropdown;
 -      },
 -      
 -      /**
 -       * @see WCF.User.Panel.Abstract._load()
 -       */
 -      _load: function() {
 -              this._proxy.setOption('data', {
 -                      actionName: 'getOutstandingNotifications',
 -                      className: 'wcf\\data\\user\\notification\\UserNotificationAction'
 -              });
 -              this._proxy.sendRequest();
 -      },
 -      
 -      /**
 -       * @see WCF.User.Panel.Abstract._markAsRead()
 -       */
 -      _markAsRead: function(event, objectID) {
 -              this._proxy.setOption('data', {
 -                      actionName: 'markAsConfirmed',
 -                      className: 'wcf\\data\\user\\notification\\UserNotificationAction',
 -                      objectIDs: [ objectID ]
 -              });
 -              this._proxy.sendRequest();
 -      },
 -      
 -      /**
 -       * @see WCF.User.Panel.Abstract._markAllAsRead()
 -       */
 -      _markAllAsRead: function(event) {
 -              this._proxy.setOption('data', {
 -                      actionName: 'markAllAsConfirmed',
 -                      className: 'wcf\\data\\user\\notification\\UserNotificationAction'
 -              });
 -              this._proxy.sendRequest();
 -      },
 -      
 -      /**
 -       * @see WCF.User.Panel.Abstract.resetItems()
 -       */
 -      resetItems: function() {
 -              this._super();
 +              /**
 +               * @see        WCF.User.Panel.Abstract._load()
 +               */
 +              _load: function () {
 +                      this._proxy.setOption('data', {
 +                              actionName: 'getOutstandingNotifications',
 +                              className: 'wcf\\data\\user\\notification\\UserNotificationAction'
 +                      });
 +                      this._proxy.sendRequest();
 +              },
                
 -              if (this._markAllAsReadLink) {
 -                      this._markAllAsReadLink.remove();
 -                      this._markAllAsReadLink = null;
 -              }
 -      },
 -      
 -      /**
 -       * @see WCF.User.Panel.Abstract.updateBadge()
 -       */
 -      updateBadge: function(count) {
 -              count = parseInt(count) || 0;
 +              /**
 +               * @see        WCF.User.Panel.Abstract._markAsRead()
 +               */
 +              _markAsRead: function (event, objectID) {
 +                      this._proxy.setOption('data', {
 +                              actionName: 'markAsConfirmed',
 +                              className: 'wcf\\data\\user\\notification\\UserNotificationAction',
 +                              objectIDs: [objectID]
 +                      });
 +                      this._proxy.sendRequest();
 +              },
                
 -              // update data attribute
 -              $('#userNotifications').attr('data-count', count);
 +              /**
 +               * @see        WCF.User.Panel.Abstract._markAllAsRead()
 +               */
 +              _markAllAsRead: function (event) {
 +                      this._proxy.setOption('data', {
 +                              actionName: 'markAllAsConfirmed',
 +                              className: 'wcf\\data\\user\\notification\\UserNotificationAction'
 +                      });
 +                      this._proxy.sendRequest();
 +              },
                
 -              if (this._favico !== null) {
 -                      this._favico.badge(count);
 -              }
 +              /**
 +               * @see        WCF.User.Panel.Abstract.resetItems()
 +               */
 +              resetItems: function () {
 +                      this._super();
 +                      
 +                      if (this._markAllAsReadLink) {
 +                              this._markAllAsReadLink.remove();
 +                              this._markAllAsReadLink = null;
 +                      }
 +              },
                
 -              this._super(count);
 -      },
 +              /**
 +               * @see        WCF.User.Panel.Abstract.updateBadge()
 +               */
 +              updateBadge: function (count) {
 +                      count = parseInt(count) || 0;
 +                      
 +                      // update data attribute
 +                      $('#userNotifications').attr('data-count', count);
 +                      
 +                      if (this._favico !== null) {
 +                              this._favico.badge(count);
 +                      }
 +                      
 +                      this._super(count);
 +              },
 +              
 +              /**
 +               * Updates the badge counter and resets the dropdown's item list.
 +               *
 +               * @param        integer                count
 +               */
 +              updateUserNotificationCount: function (count) {
 +                      if (this._dropdown !== null) {
 +                              this._dropdown.resetItems();
 +                      }
 +                      
 +                      this.updateBadge(count);
 +              }
 +      });
        
        /**
 -       * Updates the badge counter and resets the dropdown's item list.
 -       * 
 -       * @param       integer         count
 +       * User Panel implementation for user menu dropdown.
 +       *
 +       * @see        WCF.User.Panel.Abstract
         */
 -      updateUserNotificationCount: function(count) {
 -              if (this._dropdown !== null) {
 -                      this._dropdown.resetItems();
 +      WCF.User.Panel.UserMenu = WCF.User.Panel.Abstract.extend({
 +              /**
 +               * @see        WCF.User.Panel.Abstract.init()
 +               */
 +              init: function () {
 +                      this._super($('#userMenu'), 'userMenu', {
 +                              pointerOffset: '13px',
 +                              staticDropdown: true
 +                      });
                }
 -              
 -              this.updateBadge(count);
 -      }
 -});
 -
 -/**
 - * User Panel implementation for user menu dropdown.
 - * 
 - * @see       WCF.User.Panel.Abstract
 - */
 -WCF.User.Panel.UserMenu = WCF.User.Panel.Abstract.extend({
 -      /**
 -       * @see WCF.User.Panel.Abstract.init()
 -       */
 -      init: function() {
 -              this._super($('#userMenu'), 'userMenu', {
 -                      pointerOffset: '13px',
 -                      staticDropdown: true
 -              });
 -      }
 -});
 +      });
 +}
 +else {
 +      WCF.User.Panel.Abstract = Class.extend({
 +              _badge: {},
 +              _dropdown: {},
 +              _identifier: "",
 +              _loadData: true,
 +              _markAllAsReadLink: {},
 +              _options: {},
 +              _proxy: {},
 +              _triggerElement: {},
 +              init: function() {},
 +              toggle: function() {},
 +              _dblClick: function() {},
 +              _initDropdown: function() {},
 +              _load: function() {},
 +              _success: function() {},
 +              _markAsRead: function() {},
 +              _markAllAsRead: function() {},
 +              updateBadge: function() {},
 +              resetItems: function() {}
 +      });
 +      
 +      WCF.User.Panel.Notification = WCF.User.Panel.Abstract.extend({
 +              _favico: {},
 +              init: function() {},
 +              _initDropdown: function() {},
 +              _load: function() {},
 +              _markAsRead: function() {},
 +              _markAllAsRead: function() {},
 +              resetItems: function() {},
 +              updateBadge: function() {},
 +              updateUserNotificationCount: function() {},
 +              _badge: {},
 +              _dropdown: {},
 +              _identifier: "",
 +              _loadData: true,
 +              _markAllAsReadLink: {},
 +              _options: {},
 +              _proxy: {},
 +              _triggerElement: {},
 +              toggle: function() {},
 +              _dblClick: function() {},
 +              _success: function() {}
 +      });
 +      
 +      WCF.User.Panel.UserMenu = WCF.User.Panel.Abstract.extend({
 +              init: function() {},
 +              _badge: {},
 +              _dropdown: {},
 +              _identifier: "",
 +              _loadData: true,
 +              _markAllAsReadLink: {},
 +              _options: {},
 +              _proxy: {},
 +              _triggerElement: {},
 +              toggle: function() {},
 +              _dblClick: function() {},
 +              _initDropdown: function() {},
 +              _load: function() {},
 +              _success: function() {},
 +              _markAsRead: function() {},
 +              _markAllAsRead: function() {},
 +              updateBadge: function() {},
 +              resetItems: function() {}
 +      });
 +}
  
  /**
   * Quick login box