});
}
-/**
- * Namespace for avatar functions.
- */
-WCF.User.Avatar = {};
-
-if (COMPILER_TARGET_DEFAULT) {
- /**
- * Avatar upload function
- *
- * @see WCF.Upload
- */
- WCF.User.Avatar.Upload = WCF.Upload.extend({
- /**
- * user id of avatar owner
- * @var integer
- */
- _userID: 0,
-
- /**
- * Initializes a new WCF.User.Avatar.Upload object.
- *
- * @param integer userID
- */
- init: function (userID) {
- this._super($('#avatarUpload > dd > div'), undefined, 'wcf\\data\\user\\avatar\\UserAvatarAction');
- this._userID = userID || 0;
-
- $('#avatarForm input[type=radio]').change(function () {
- if ($(this).val() == 'custom') {
- $('#avatarUpload > dd > div').show();
- }
- else {
- $('#avatarUpload > dd > div').hide();
- }
- });
- if (!$('#avatarForm input[type=radio][value=custom]:checked').length) {
- $('#avatarUpload > dd > div').hide();
- }
- },
-
- /**
- * @see WCF.Upload._initFile()
- */
- _initFile: function (file) {
- return $('#avatarUpload > dt > img');
- },
-
- /**
- * @see WCF.Upload._success()
- */
- _success: function (uploadID, data) {
- if (data.returnValues.url) {
- this._updateImage(data.returnValues.url);
-
- // hide error
- $('#avatarUpload > dd > .innerError').remove();
-
- // show success message
- var $notification = new WCF.System.Notification(WCF.Language.get('wcf.user.avatar.upload.success'));
- $notification.show();
- }
- else if (data.returnValues.errorType) {
- // show error
- this._getInnerErrorElement().text(WCF.Language.get('wcf.user.avatar.upload.error.' + data.returnValues.errorType));
- }
- },
-
- /**
- * Updates the displayed avatar image.
- *
- * @param string url
- */
- _updateImage: function (url) {
- $('#avatarUpload > dt > img').remove();
- var $image = $('<img src="' + url + '" class="userAvatarImage" alt="" />').css({
- 'height': 'auto',
- 'max-height': '96px',
- 'max-width': '96px',
- 'width': 'auto'
- });
-
- $('#avatarUpload > dt').prepend($image);
-
- WCF.DOMNodeInsertedHandler.execute();
- },
-
- /**
- * Returns the inner error element.
- *
- * @return jQuery
- */
- _getInnerErrorElement: function () {
- var $span = $('#avatarUpload > dd > .innerError');
- if (!$span.length) {
- $span = $('<small class="innerError"></span>');
- $('#avatarUpload > dd').append($span);
- }
-
- return $span;
- },
-
- /**
- * @see WCF.Upload._getParameters()
- */
- _getParameters: function () {
- return {
- userID: this._userID
- };
- }
- });
-}
-else {
- WCF.User.Avatar.Upload = WCF.Upload.extend({
- _userID: 0,
- init: function() {},
- _initFile: function() {},
- _success: function() {},
- _updateImage: function() {},
- _getInnerErrorElement: function() {},
- _getParameters: function() {},
- _name: "",
- _buttonSelector: {},
- _fileListSelector: {},
- _fileUpload: {},
- _className: "",
- _iframe: {},
- _internalFileID: 0,
- _options: {},
- _uploadMatrix: {},
- _supportsAJAXUpload: true,
- _overlay: {},
- _createButton: function() {},
- _insertButton: function() {},
- _removeButton: function() {},
- _upload: function() {},
- _createUploadMatrix: function() {},
- _error: function() {},
- _progress: function() {},
- _showOverlay: function() {},
- _evaluateResponse: function() {},
- _getFilename: function() {}
- });
-}
-
/**
* Generic implementation for grouped user lists.
*