-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.user.js
62 lines (53 loc) · 1.7 KB
/
jquery.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/** @file
*
* A jQuery class/object representing a uniquely identifiable user.
*
* Requires:
* jquery.js
*/
/*jslint nomen:false,laxbreak:true,white:false,onevar:false */
/*global jQuery:false */
(function($) {
/** @brief A single, uniquely identifiable user.
* @param props The properties of this user:
* id: The Unique ID of the user;
* name: The user name;
* fullName: The user's full name;
* avatarUrl: The URL to the user's avatar image;
*/
$.User = function(props) {
var defaults = {
id: null,
name: 'anonymous',
fullName: 'Anonymous',
avatarUrl: 'images/avatar.jpg'
};
return this.init( $.extend(defaults, true, props || {}) );
};
$.User.prototype = {
/** @brief Initialize a new User instance.
* @param props The properties of this note:
* id: The Unique ID of the user;
* name: The user name;
* fullName: The user's full name;
*/
init: function(props) {
this.props = props;
return this;
},
getId: function() { return this.props.id; },
getName: function() { return this.props.name; },
getFullName: function() { return this.props.fullName; },
getAvatarUrl: function() { return this.props.avatarUrl; },
serialize: function() {
return this.props;
},
destroy: function() {
var self = this;
var props = self.props;
delete props.id;
delete props.name;
delete props.fullName;
}
};
}(jQuery));