*/
WCF.Style = { };
-/**
- * Converts static user panel items into interactive dropdowns.
- *
- * @deprecated 2.1 - Please use WCF.User.Panel.Interactive instead
- *
- * @param string containerID
- */
-WCF.UserPanel = Class.extend({
- /**
- * target container
- * @var jQuery
- */
- _container: null,
-
- /**
- * initialization state
- * @var boolean
- */
- _didLoad: false,
-
- /**
- * original link element
- * @var jQuery
- */
- _link: null,
-
- /**
- * language variable name for 'no items'
- * @var string
- */
- _noItems: '',
-
- /**
- * reverts to original link if return values are empty
- * @var boolean
- */
- _revertOnEmpty: true,
-
- /**
- * Initializes the WCF.UserPanel class.
- *
- * @param string containerID
- */
- init: function(containerID) {
- this._container = $('#' + containerID);
- this._didLoad = false;
- this._revertOnEmpty = true;
-
- if (this._container.length != 1) {
- console.debug("[WCF.UserPanel] Unable to find container identified by '" + containerID + "', aborting.");
- return;
- }
-
- this._convert();
- },
-
- /**
- * Converts link into an interactive dropdown menu.
- */
- _convert: function() {
- this._container.addClass('dropdown');
- this._link = this._container.children('a').remove();
-
- var $button = $('<a href="' + this._link.attr('href') + '" class="dropdownToggle">' + this._link.html() + '</a>').appendTo(this._container).click($.proxy(this._click, this));
- var $dropdownMenu = $('<ul class="dropdownMenu" />').appendTo(this._container);
- $('<li class="jsDropdownPlaceholder"><span>' + WCF.Language.get('wcf.global.loading') + '</span></li>').appendTo($dropdownMenu);
-
- this._addDefaultItems($dropdownMenu);
-
- this._container.dblclick($.proxy(function() {
- window.location = this._link.attr('href');
- return false;
- }, this));
-
- WCF.Dropdown.initDropdown($button, false);
- },
-
- /**
- * Adds default items to dropdown menu.
- *
- * @param jQuery dropdownMenu
- */
- _addDefaultItems: function(dropdownMenu) { },
-
- /**
- * Adds a dropdown divider.
- *
- * @param jQuery dropdownMenu
- */
- _addDivider: function(dropdownMenu) {
- $('<li class="dropdownDivider" />').appendTo(dropdownMenu);
- },
-
- /**
- * Handles clicks on the dropdown item.
- *
- * @param object event
- */
- _click: function(event) {
- event.preventDefault();
-
- if (this._didLoad) {
- return;
- }
-
- new WCF.Action.Proxy({
- autoSend: true,
- data: this._getParameters(),
- success: $.proxy(this._success, this)
- });
-
- this._didLoad = true;
- },
-
- /**
- * Returns a list of parameters for AJAX request.
- *
- * @return object
- */
- _getParameters: function() {
- return { };
- },
-
- /**
- * Handles successful AJAX requests.
- *
- * @param object data
- * @param string textStatus
- * @param jQuery jqXHR
- */
- _success: function(data, textStatus, jqXHR) {
- var $dropdownMenu = WCF.Dropdown.getDropdownMenu(this._container.wcfIdentify());
- $dropdownMenu.children('.jsDropdownPlaceholder').remove();
-
- if (data.returnValues && data.returnValues.template) {
- $('' + data.returnValues.template).prependTo($dropdownMenu);
-
- // update badge
- this._updateBadge(data.returnValues.totalCount);
-
- this._after($dropdownMenu);
- }
- else {
- $('<li><span>' + WCF.Language.get(this._noItems) + '</span></li>').prependTo($dropdownMenu);
-
- // remove badge
- this._updateBadge(0);
- }
- },
-
- /**
- * Updates badge count.
- *
- * @param integer count
- */
- _updateBadge: function(count) {
- count = parseInt(count) || 0;
-
- if (count) {
- var $badge = this._container.find('.badge');
- if (!$badge.length) {
- $badge = $('<span class="badge badgeUpdate" />').appendTo(this._container.children('.dropdownToggle'));
- $badge.before(' ');
- }
- $badge.html(count);
- }
- else {
- this._container.find('.badge').remove();
- }
- },
-
- /**
- * Execute actions after the dropdown menu has been populated.
- *
- * @param object dropdownMenu
- */
- _after: function(dropdownMenu) { }
-});
-
jQuery.fn.extend({
// shim for 'ui.wcfDialog'
wcfDialog: function(method) {