remove old readme
[atutor.git] / docs / jscripts / opensocial / enum.js
1 /*
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  *     http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14
15 /**
16  * @fileoverview Representation of an enum.
17  */
18
19
20 /**
21  * @class
22  * Base interface for all enum objects.
23  * This class allows containers to use constants for fields that are usually
24  * have a common set of values.
25  * There are two main ways to use this class.
26  *
27  * <p>
28  * If your gadget just wants to display how much of a smoker someone is,
29  * it can simply use:
30  * </p>
31  *
32  * <pre>html = "This person smokes: " + person.getField('smoker').getValue();</pre>
33  *
34  * <p>
35  * This value field will be correctly set up by the container. This is a place
36  * where the container can even localize the value for the gadget so that it
37  * always shows the right thing.
38  * </p>
39  *
40  * <p>
41  * If your gadget wants to have some logic around the smoker
42  * field it can use:
43  * </p>
44  *
45  * <pre>if (person.getField('smoker').getKey() != "NO") { //gadget logic here }</pre>
46  *
47  * <p class="note">
48  * <b>Note:</b>
49  * The key may be null if the person's smoker field cannot be coerced
50  * into one of the standard enum types.
51  * The value, on the other hand, is never null.
52  * </p>
53  *
54  * @name opensocial.Enum
55  */
56
57
58 /**
59  * Base interface for all enum objects.
60  *
61  * @private
62  * @constructor
63  */
64 opensocial.Enum = function() {};
65
66
67 /**
68  * Use this for logic within your gadget. If they key is null then the value
69  * does not fit in the defined enums.
70  *
71  * @return {String} The enum's key. This should be one of the defined enums
72  *     below.
73  */
74 opensocial.Enum.prototype.getKey = function() {};
75
76
77 /**
78  * The value of this enum. This will be a user displayable string. If the
79  * container supports localization, the string will be localized.
80  *
81  * @return {String} The enum's value.
82  */
83 opensocial.Enum.prototype.getDisplayValue = function() {};
84
85
86 /**
87  * @static
88  * @class
89  * The enum keys used by the smoker field.
90  * <p><b>See also:</b>
91  * <a href="opensocial.Person.Field.html">
92  * opensocial.Person.Field.Smoker</a>
93  * </p>
94  *
95  * @name opensocial.Enum.Smoker
96  */
97 opensocial.Enum.Smoker = {
98   /** 
99    * This field may be used interchangeably with the string 'NO'.
100    * @member opensocial.Enum.Smoker 
101    */
102   NO : 'NO',
103   /** 
104    * This field may be used interchangeably with the string 'YES'.
105    * @member opensocial.Enum.Smoker 
106    */
107   YES : 'YES',
108   /** 
109    * This field may be used interchangeably with the string 'SOCIALLY'.
110    * @member opensocial.Enum.Smoker 
111    */
112   SOCIALLY : 'SOCIALLY',
113   /** 
114    * This field may be used interchangeably with the string 'OCCASIONALLY'.
115    * @member opensocial.Enum.Smoker 
116    */
117   OCCASIONALLY : 'OCCASIONALLY',
118   /** 
119    * This field may be used interchangeably with the string 'REGULARLY'.
120    * @member opensocial.Enum.Smoker 
121    */
122   REGULARLY : 'REGULARLY',
123   /** 
124    * This field may be used interchangeably with the string 'HEAVILY'.
125    * @member opensocial.Enum.Smoker 
126    */
127   HEAVILY : 'HEAVILY',
128   /** 
129    * This field may be used interchangeably with the string 'QUITTING'.
130    * @member opensocial.Enum.Smoker 
131    */
132   QUITTING : 'QUITTING',
133   /** 
134    * This field may be used interchangeably with the string 'QUIT'.
135    * @member opensocial.Enum.Smoker 
136    */
137   QUIT : 'QUIT'
138 };
139
140
141 /**
142  * @static
143  * @class
144  * The enum keys used by the drinker field.
145  * <p><b>See also:</b>
146  * <a href="opensocial.Person.Field.html">
147  * opensocial.Person.Field.Drinker</a>
148  * </p>
149  *
150  * @name opensocial.Enum.Drinker
151  */
152 opensocial.Enum.Drinker = {
153   /** 
154    * This field may be used interchangeably with the string 'NO'.
155    * @member opensocial.Enum.Drinker 
156    */
157   NO : 'NO',
158   /** 
159    * This field may be used interchangeably with the string 'YES'.
160    * @member opensocial.Enum.Drinker 
161    */
162   YES : 'YES',
163   /** 
164    * This field may be used interchangeably with the string 'SOCIALLY'.
165    * @member opensocial.Enum.Drinker 
166    */
167   SOCIALLY : 'SOCIALLY',
168   /** 
169    * This field may be used interchangeably with the string 'OCCASIONALLY'. 
170    * @member opensocial.Enum.Drinker 
171    */
172   OCCASIONALLY : 'OCCASIONALLY',
173   /**
174    * This field may be used interchangeably with the string 'REGULARLY'.  
175    * @member opensocial.Enum.Drinker 
176    */
177   REGULARLY : 'REGULARLY',
178   /** 
179    * This field may be used interchangeably with the string 'HEAVILY'.
180    * @member opensocial.Enum.Drinker 
181    */
182   HEAVILY : 'HEAVILY',
183   /** 
184    * This field may be used interchangeably with the string 'QUITTING'.
185    * @member opensocial.Enum.Drinker 
186    */
187   QUITTING : 'QUITTING',
188   /** 
189    * This field may be used interchangeably with the string 'QUIT'.
190    * @member opensocial.Enum.Drinker 
191    */
192   QUIT : 'QUIT'
193 };
194
195
196 /**
197  * @static
198  * @class
199  * The enum keys used by the gender field.
200  * <p><b>See also:</b>
201  * <a href="opensocial.Person.Field.html">
202  * opensocial.Person.Field.Gender</a>
203  * </p>
204  *
205  * @name opensocial.Enum.Gender
206  */
207 opensocial.Enum.Gender = {
208   /** 
209    * This field may be used interchangeably with the string 'MALE'.
210    * @member opensocial.Enum.Gender 
211    */
212   MALE : 'MALE',
213   /** 
214    * This field may be used interchangeably with the string 'FEMALE'.
215    * @member opensocial.Enum.Gender 
216    */
217   FEMALE : 'FEMALE'
218 };
219
220
221 /**
222  * @static
223  * @class
224  * The enum keys used by the lookingFor field.
225  * <p><b>See also:</b>
226  * <a href="opensocial.Person.Field.html">
227  * opensocial.Person.Field.LookingFor</a>
228  * </p>
229  *
230  * @name opensocial.Enum.LookingFor
231  */
232 opensocial.Enum.LookingFor = {
233   /** 
234    * This field may be used interchangeably with the string 'DATING'.
235    * @member opensocial.Enum.LookingFor 
236    */
237   DATING : 'DATING',
238   /** 
239    * This field may be used interchangeably with the string 'FRIENDS'.
240    * @member opensocial.Enum.LookingFor 
241    */
242   FRIENDS : 'FRIENDS',
243   /** 
244    * This field may be used interchangeably with the string 'RELATIONSHIP'.
245    * @member opensocial.Enum.LookingFor 
246    */
247   RELATIONSHIP : 'RELATIONSHIP',
248   /** 
249    * This field may be used interchangeably with the string 'NETWORKING'.
250    * @member opensocial.Enum.LookingFor 
251    */
252   NETWORKING : 'NETWORKING',
253   /** 
254    * This field may be used interchangeably with the string 'ACTIVITY_PARTNERS'.
255    * @member opensocial.Enum.LookingFor 
256    */
257   ACTIVITY_PARTNERS : 'ACTIVITY_PARTNERS',
258   /** 
259    * This field may be used interchangeably with the string 'RANDOM'.
260    * @member opensocial.Enum.LookingFor 
261    */
262   RANDOM : 'RANDOM'
263 };
264
265
266 /**
267  * @static
268  * @class
269  * The enum keys used by the networkPresence field.
270  * <p><b>See also:</b>
271  * <a href="opensocial.Person.Field.html">
272  * opensocial.Person.Field.NetworkPresence</a>
273  * </p>
274  *
275  * @name opensocial.Enum.Presence
276  */
277 opensocial.Enum.Presence = {
278   /**
279    * The entity or resource is off line.
280    * This field may be used interchangeably with the string 'OFFLINE'.
281    *
282    * @member opensocial.Enum.Presence
283    */
284   OFFLINE : 'OFFLINE',
285   /**
286    * The entity or resource is on line.
287    * This field may be used interchangeably with the string 'ONLINE'.
288    *
289    * @member opensocial.Enum.Presence
290    */
291   ONLINE : 'ONLINE',
292   /**
293    * The entity or resource is temporarily away.
294    * This field may be used interchangeably with the string 'AWAY'.
295    *
296    * @member opensocial.Enum.Presence
297    */
298   AWAY : 'AWAY',
299   /**
300    * The entity or resource is actively interested in chatting.
301    * This field may be used interchangeably with the string 'CHAT'.
302    * @member opensocial.Enum.Presence
303    */
304   CHAT : 'CHAT',
305   /**
306    * The entity or resource is busy (dnd = "Do Not Disturb").
307    * This field may be used interchangeably with the string 'DND'.
308    * @member opensocial.Enum.Presence
309    */
310   DND : 'DND',
311   /**
312    * The entity or resource is away for an extended period
313    * (xa = "eXtended Away").
314    * This field may be used interchangeably with the string 'XA'.
315    * @member opensocial.Enum.Presence
316    */
317   XA : 'XA'
318 };