- Mobile Reply-as-new fix

- Documentation
This commit is contained in:
nsahler 2013-03-13 16:43:16 -04:00 committed by Robin Ward
parent dc9d54f1c7
commit d398d13aed
3 changed files with 2204 additions and 18 deletions

View File

@ -8,32 +8,75 @@
**/
Discourse.User = Discourse.Model.extend({
/**
Large version of this user's avatar.
@property avatarLarge
@type {String}
**/
avatarLarge: (function() {
return Discourse.Utilities.avatarUrl(this.get('username'), 'large', this.get('avatar_template'));
}).property('username'),
/**
Small version of this user's avatar.
@property avatarSmall
@type {String}
**/
avatarSmall: (function() {
return Discourse.Utilities.avatarUrl(this.get('username'), 'small', this.get('avatar_template'));
return Discourse.Utilities.avatarUrl(this.get('username'), 'small', this.get('avatar_template'));
}).property('username'),
/**
This user's website.
@property websiteName
@type {String}
**/
websiteName: (function() {
return this.get('website').split("/")[2];
}).property('website'),
/**
Path to this user.
@property path
@type {String}
**/
path: (function() {
return "/users/" + (this.get('username_lower'));
}).property('username'),
/**
This user's username in lowercase.
@property username_lower
@type {String}
**/
username_lower: (function() {
return this.get('username').toLowerCase();
}).property('username'),
/**
This user's trust level.
@property trustLevel
@type {Integer}
**/
trustLevel: (function() {
return Discourse.get('site.trust_levels').findProperty('id', this.get('trust_level'));
}).property('trust_level'),
/**
Changes this user's username.
@method changeUsername
@param {String} newUsername The user's new username
@returns Result of ajax call
**/
changeUsername: function(newUsername) {
return $.ajax({
return jQuery.ajax({
url: "/users/" + (this.get('username_lower')) + "/preferences/username",
type: 'PUT',
data: {
@ -42,8 +85,15 @@ Discourse.User = Discourse.Model.extend({
});
},
/**
Changes this user's email address.
@method changeEmail
@param {String} email The user's new email address\
@returns Result of ajax call
**/
changeEmail: function(email) {
return $.ajax({
return jQuery.ajax({
url: "/users/" + (this.get('username_lower')) + "/preferences/email",
type: 'PUT',
data: {
@ -52,13 +102,26 @@ Discourse.User = Discourse.Model.extend({
});
},
copy: function(deep) {
/**
Returns a copy of this user.
@method copy
@returns {User}
**/
copy: function() {
return Discourse.User.create(this.getProperties(Ember.keys(this)));
},
/**
Save's this user's properties over AJAX via a PUT request.
@method save
@param {Function} finished Function called on completion of AJAX call
@returns The result of finished(true) on a success, the result of finished(false) on an error
**/
save: function(finished) {
var _this = this;
return $.ajax("/users/" + this.get('username').toLowerCase(), {
jQuery.ajax("/users/" + this.get('username').toLowerCase(), {
data: this.getProperties('auto_track_topics_after_msecs',
'bio_raw',
'website',
@ -67,23 +130,30 @@ Discourse.User = Discourse.Model.extend({
'email_direct',
'email_private_messages',
'digest_after_days',
'new_topic_duration_minutes',
'new_topic_duration_minutes',
'external_links_in_new_tab',
'enable_quoting'),
type: 'PUT',
success: function() {
success: function() {
Discourse.set('currentUser.enable_quoting', _this.get('enable_quoting'));
Discourse.set('currentUser.external_links_in_new_tab', _this.get('external_links_in_new_tab'));
return finished(true);
return finished(true);
},
error: function() { return finished(false); }
});
},
/**
Changes the password and calls the callback function on AJAX.complete.
@method changePassword
@param {Function} callback Function called on completion of AJAX call
@returns The result of the callback() function on complete
**/
changePassword: function(callback) {
var good;
good = false;
return $.ajax({
jQuery.ajax({
url: '/session/forgot_password',
dataType: 'json',
data: {
@ -102,6 +172,12 @@ Discourse.User = Discourse.Model.extend({
});
},
/**
Filters out this user's stream of user actions by a given filter
@method filterStream
@param {String} filter
**/
filterStream: function(filter) {
if (Discourse.UserAction.statGroups[filter]) {
filter = Discourse.UserAction.statGroups[filter].join(",");
@ -112,11 +188,18 @@ Discourse.User = Discourse.Model.extend({
return this.loadMoreUserActions();
},
/**
Loads a single user action by id.
@method loadUserAction
@param {Integer} id The id of the user action being loaded
@returns A stream of the user's actions containing the action of id
**/
loadUserAction: function(id) {
var stream,
_this = this;
stream = this.get('stream');
return $.ajax({
jQuery.ajax({
url: "/user_actions/" + id + ".json",
dataType: 'json',
cache: 'false',
@ -140,6 +223,13 @@ Discourse.User = Discourse.Model.extend({
});
},
/**
Loads more user actions, and then calls a callback if defined.
@method loadMoreUserActions
@param {String} callback Called after completion, on success of AJAX call, if it is defined
@returns the result of the callback
**/
loadMoreUserActions: function(callback) {
var stream, url,
_this = this;
@ -151,7 +241,7 @@ Discourse.User = Discourse.Model.extend({
url += "&filter=" + (this.get('streamFilter'));
}
return $.ajax({
return jQuery.ajax({
url: url,
dataType: 'json',
cache: 'false',
@ -174,6 +264,12 @@ Discourse.User = Discourse.Model.extend({
});
},
/**
The user's stat count, excluding PMs.
@property statsCountNonPM
@type {Integer}
**/
statsCountNonPM: (function() {
var stats, total;
total = 0;
@ -186,6 +282,12 @@ Discourse.User = Discourse.Model.extend({
return total;
}).property('stats.@each'),
/**
The user's stats, excluding PMs.
@property statsExcludingPms
@type {Array}
**/
statsExcludingPms: (function() {
var r;
r = [];
@ -198,6 +300,12 @@ Discourse.User = Discourse.Model.extend({
return r;
}).property('stats.@each'),
/**
This user's stats, only including PMs.
@property statsPmsOnly
@type {Array}
**/
statsPmsOnly: (function() {
var r;
r = [];
@ -208,6 +316,12 @@ Discourse.User = Discourse.Model.extend({
return r;
}).property('stats.@each'),
/**
Number of items in this user's inbox.
@property inboxCount
@type {Integer}
**/
inboxCount: (function() {
var r;
r = 0;
@ -220,6 +334,12 @@ Discourse.User = Discourse.Model.extend({
return r;
}).property('stats.@each'),
/**
Number of items this user has sent.
@property sentItemsCount
@type {Integer}
**/
sentItemsCount: (function() {
var r;
r = 0;
@ -234,9 +354,15 @@ Discourse.User = Discourse.Model.extend({
});
Discourse.User.reopenClass({
/**
Checks if given username is valid for this email address
@method checkUsername
@param {String} username A username to check
@param {String} email An email address to check
**/
checkUsername: function(username, email) {
return $.ajax({
return jQuery.ajax({
url: '/users/check_username',
type: 'GET',
data: {
@ -246,6 +372,13 @@ Discourse.User.reopenClass({
});
},
/**
Groups the user's statistics
@method groupStats
@param {Array} Given stats
@returns {Object}
**/
groupStats: function(stats) {
var g,
_this = this;
@ -285,10 +418,11 @@ Discourse.User.reopenClass({
},
/**
Find a user by username
Finds a user based on a username
@method find
@param {String} username the username of the user we want to find
@param {String} username The username
@returns a promise that will resolve to the user
**/
find: function(username) {
@ -315,12 +449,23 @@ Discourse.User.reopenClass({
var user = Discourse.User.create(json.user);
user.set('totalItems', count);
return user;
return user;
});
},
/**
Creates a new account over POST
@method createAccount
@param {String} name This user's name
@param {String} email This user's email
@param {String} password This user's password
@param {String} passwordConfirm This user's confirmed password
@param {String} challenge
@returns Result of ajax call
**/
createAccount: function(name, email, password, username, passwordConfirm, challenge) {
return $.ajax({
return jQuery.ajax({
url: '/users',
dataType: 'json',
data: {

View File

@ -100,10 +100,13 @@
.gutter {
.reply-new{
opacity:0;
.discourse-no-touch & {
opacity: 0;
}
transition:opacity 1s linear;
-webkit-transition:opacity 1s linear;
-moz-transition:opacity 1s linear;
}
.reply-new,
.track-link {

File diff suppressed because it is too large Load Diff