Debian Codegraph @

contrib/externs/api/gadgets/opensocial.js

raw symbols SCIP
1 /*
2 * Copyright 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /**
18 * @fileoverview Externs file for OpenSocial gadget libraries. Legacy API based
19 * on the {@code _IG_...} is not supported here.
20 * Note this may not be comprehensive.
21 *
22 * @see http://code.google.com/apis/gadgets/docs/reference/
23 * @see http://incubator.apache.org/shindig/shindig-1.1.x/shindig-features/jsdoc
24 * @externs
25 */
26
27 // Root namespace for gadget related functionality.
28 var gadgets = {};
29
30
31 // Namespace providing operations for getting information about and modifying
32 // the window the gadget is placed in.
33 gadgets.window = {};
34
35 /**
36 * @param {number=} opt_height The new height for the gadget.
37 */
38 gadgets.window.adjustHeight = function(opt_height) {};
39
40 /**
41 * @return {Object} Dimensions for the viewport.
42 */
43 gadgets.window.getViewportDimensions = function() {};
44
45 /**
46 * @param {string} title The new title for the gadget.
47 */
48 gadgets.window.setTitle = function(title) {};
49
50 /**
51 * Calculate inner content height is hard and different between
52 * browsers rendering in Strict vs. Quirks mode. We use a combination of
53 * three properties within document.body and document.documentElement:
54 * - scrollHeight
55 * - offsetHeight
56 * - clientHeight
57 * These values differ significantly between browsers and rendering modes.
58 * But there are patterns. It just takes a lot of time and persistence
59 * to figure out.
60 * @return {number} Height of current window.
61 */
62 gadgets.window.getHeight = function() {};
63
64 // Namespace providing operations for making remote procedure calls for
65 // gadget-to-container, container-to-gadget and gadget-to-gadget communication.
66 gadgets.rpc = {};
67
68 /**
69 * Exported constant used by transports.
70 * @type {string}
71 */
72 gadgets.rpc.ACK;
73
74 /**
75 * @param {?string} targetId The id of the target gadget, null for container.
76 * @param {string} serviceName The RPC service to call.
77 * @param {!Function=} opt_callback Function called when the RPC
78 * completes.
79 * @param {...*} var_args Variable arguments that are passed to the RPC handler.
80 */
81 gadgets.rpc.call = function(targetId, serviceName, opt_callback, var_args) {};
82
83 /**
84 * Force RPC utilities to fallback to secure mechanisms for type=URL gadgets.
85 */
86 gadgets.rpc.forceParentVerifiable = function() {};
87
88 /**
89 * @return {string} The RPC relay mechanism.
90 */
91 gadgets.rpc.getRelayChannel = function() {};
92
93 /**
94 * @param {string} targetId The frame ID to get the relay for.
95 * @return {string} The relay URL of the given gadget (or container).
96 */
97 gadgets.rpc.getRelayUrl = function(targetId) {};
98
99 /**
100 * Global init for RPC code.
101 */
102 gadgets.rpc.init = function() {};
103
104 /**
105 * Receives and processes an RPC request. (Not to be used directly.)
106 * Only used by IFPC.
107 * @param {Array.<string>} fragment An RPC request fragment encoded as
108 * an array. The first 4 elements are target id, source id & call id,
109 * total packet number, packet id. The last element stores the actual
110 * JSON-encoded and URI escaped packet data.
111 */
112 gadgets.rpc.receive = function(fragment) {};
113
114 /**
115 * @param {string} serviceName The RPC service to register a handler for.
116 * @param {!Function} handler Handler for an RPC call, return
117 * value will be sent back to the caller.
118 */
119 gadgets.rpc.register = function(serviceName, handler) {};
120
121 /**
122 * @param {!Function} handler Handler for unknown RPC calls,
123 * return value will be sent back to the caller.
124 */
125 gadgets.rpc.registerDefault = function(handler) {};
126
127 /**
128 * Helper method to retrieve the auth token for a given gadget.
129 * @param {string} targetId Name of the target frame.
130 * @return {string} The authentication token registered for this
131 * target id.
132 */
133 gadgets.rpc.getAuthToken = function(targetId) {};
134
135 /**
136 * Helper method returning a canonicalized protocol://host[:port] for
137 * a given input URL, provided as a string. Used to compute convenient
138 * relay URLs and to determine whether a call is coming from the same
139 * domain as its receiver (bypassing the try/catch capability detection
140 * flow, thereby obviating Firebug and other tools reporting an exception).
141 * @param {string} url Base URL to canonicalize.
142 * @return {string} The canonicalized URL.
143 */
144 gadgets.rpc.getOrigin = function(url) {};
145
146 /**
147 * Helper method returning a canonicalized protocol://host[:port] for
148 * the relay URL of a given target frame.
149 * @param {string} id Name of the target frame.
150 * @return {string} The canonicalized URL.
151 */
152 gadgets.rpc.getTargetOrigin = function(id) {};
153
154 /**
155 * Sets the auth token of a target frame.
156 * @param {string} targetId Name of the target frame.
157 * @param {string} token The authentication token to use for all calls to or
158 * from this target id.
159 */
160 gadgets.rpc.setAuthToken = function(targetId, token) {};
161
162 /**
163 * Sets the relay URL of a target frame.
164 * @param {string} targetId The id of the target gadget.
165 * @param {string} url Full relay URL of the target frame.
166 * @param {boolean=} opt_useLegacy True if this relay needs the legacy IFPC
167 * wire format.
168 */
169 gadgets.rpc.setRelayUrl = function(targetId, url, opt_useLegacy) {};
170
171 /**
172 * Setups the gadgets.rpc library to communicate with the receiver. This method
173 * replaces setAuthToken and setRelayUrl.
174 * @param {string} targetId The id of the target gadget.
175 * @param {string=} opt_receiverUrl Full relay URL of the target frame.
176 * @param {boolean=} opt_authToken null The authentication token to use for all
177 * calls to or from this target id.
178 */
179 gadgets.rpc.setupReceiver = function(targetId, opt_receiverUrl, opt_authToken) {};
180
181 /**
182 * @param {string} serviceName The RPC service to unregister the handler for.
183 */
184 gadgets.rpc.unregister = function(serviceName) {};
185
186 /**
187 * Unregisters the default service handler. Future unknown RPC
188 * calls will fail silently.
189 */
190 gadgets.rpc.unregisterDefault = function() {};
191
192 /**
193 * Class providing access to user preferences, module dimensions, and messages.
194 * @param {string=} opt_moduleId An optional module ID to get preferences for.
195 * @constructor
196 */
197 gadgets.Prefs = function(opt_moduleId) {};
198
199 /**
200 * @param {string} key The user preference key.
201 * @return {Array.<string>} The array value of the preference.
202 */
203 gadgets.Prefs.prototype.getArray = function(key) {};
204
205 /**
206 * @param {string} key The user preference key.
207 * @return {boolean} The boolean value of the preference.
208 */
209 gadgets.Prefs.prototype.getBool = function(key) {};
210
211 /**
212 * @param {string} key The user preference key.
213 * @return {number} The float value of the preference.
214 */
215 gadgets.Prefs.prototype.getFloat = function(key) {};
216
217 /**
218 * @param {string} key The user preference key.
219 * @return {number} The int value of the preference.
220 */
221 gadgets.Prefs.prototype.getInt = function(key) {};
222
223 /**
224 * @param {string} key The user preference key.
225 * @return {string} The string value of the preference.
226 */
227 gadgets.Prefs.prototype.getString = function(key) {};
228
229 /**
230 * @return {string} The country code.
231 */
232 gadgets.Prefs.prototype.getCountry = function() {};
233
234 /**
235 * @return {string} The language code.
236 */
237 gadgets.Prefs.prototype.getLang = function() {};
238
239 /**
240 * @return {number} The module's id.
241 */
242 gadgets.Prefs.prototype.getModuleId = function() {};
243
244 /**
245 * @param {string} key The message key.
246 * @return {string} The unformatted message.
247 */
248 gadgets.Prefs.prototype.getMsg = function(key) {};
249
250 /**
251 * @param {string} key The preference key.
252 * @param {string|number} value The preference value.
253 */
254 gadgets.Prefs.prototype.set = function(key, value) {};
255
256 /**
257 * @param {string} key The preference key.
258 * @param {Array.<string>} array The preference array.
259 */
260 gadgets.Prefs.prototype.setArray = function(key, array) {};
261
262
263 // Namespace for embedding flash content in gadgets.
264 gadgets.flash = {};
265
266 /**
267 * @return {boolean} Injects the cached Flash file into the DOM tree.
268 */
269 gadgets.flash.embedCachedFlash = function() {};
270
271 /**
272 * @return {number} The major version of Flash Player or 0 if Flash is not
273 * supported.
274 */
275 gadgets.flash.getMajorVersion = function() {};
276
277 /**
278 * @param {string} url The URL of the flash to embed.
279 * @param {string|Element} container The ID or object reference to the
280 * existing HTML container.
281 * @param {number} minVersion The minimum version required.
282 * @param {Object=} opt_params An optional object that may contain any valid
283 * HTML parameters that will be passed to the Flash movie.
284 * @return {boolean} Whether the function call completes successfully.
285 */
286 gadgets.flash.embedFlash = function(
287 url, container, minVersion, opt_params) {};
288
289 // Namespace for retrieving content from remote servers via the gadgets proxy.
290 gadgets.io = {};
291
292 /**
293 * Gets the proxy version of the passed-in URL.
294 *
295 * @param {string} url The URL to get the proxy URL for
296 * @param {Object=} opt_params Optional Parameter Object.
297 * The following properties are supported:
298 * .REFRESH_INTERVAL The number of seconds that this
299 * content should be cached. Defaults to 3600.
300 *
301 * @return {string} The proxied version of the URL
302 */
303 gadgets.io.getProxyUrl = function(url, opt_params) {};
304
305 /**
306 * @param {string} url The URL to request data from.
307 * @param {Function} callback The callback function.
308 * @param {Object=} opt_params Optional map of parameters sent on request, see
309 * gadgets.io.RequestParameters.
310 */
311 gadgets.io.makeRequest = function(url, callback, opt_params) {};
312
313 /**
314 * Converts an input object into a URL-encoded data string. (key=value&...).
315 * @param {Object} fields The post fields you wish to encode.
316 * @return {string} The processed post data; this includes a trailing
317 * ampersand (&).
318 */
319 gadgets.io.encodeValues = function(fields) {};
320
321 /**
322 * Enumeration of request parameters.
323 * @enum {string}
324 */
325 gadgets.io.RequestParameters = {};
326 gadgets.io.RequestParameters.AUTHORIZATION;
327 gadgets.io.RequestParameters.CONTENT_TYPE;
328 gadgets.io.RequestParameters.GET_SUMMARIES;
329 gadgets.io.RequestParameters.HEADERS;
330 gadgets.io.RequestParameters.METHOD;
331 gadgets.io.RequestParameters.NUM_ENTRIES;
332 gadgets.io.RequestParameters.OAUTH_REQUEST_TOKEN;
333 gadgets.io.RequestParameters.OAUTH_REQUEST_TOKEN_SECRET;
334 gadgets.io.RequestParameters.OAUTH_SERVICE_NAME;
335 gadgets.io.RequestParameters.OAUTH_TOKEN_NAME;
336 gadgets.io.RequestParameters.OAUTH_USE_TOKEN;
337 gadgets.io.RequestParameters.POST_DATA;
338 gadgets.io.RequestParameters.REFRESH_INTERVAL;
339
340 /**
341 * Enumeration of content types that can be specified in
342 * {@link gadgets.io.RequestParameters.AUTHORIZATION}
343 * @enum {string}
344 */
345 gadgets.io.AuthorizationType = {};
346 gadgets.io.AuthorizationType.NONE;
347 gadgets.io.AuthorizationType.OAUTH;
348 gadgets.io.AuthorizationType.SIGNED;
349
350 /**
351 * Enumeration of content types that can be specified in
352 * {@link gadgets.io.RequestParameters.CONTENT_TYPE}
353 * @enum {string}
354 */
355 gadgets.io.ContentType = {};
356 gadgets.io.ContentType.DOM;
357 gadgets.io.ContentType.FEED;
358 gadgets.io.ContentType.JSON;
359 gadgets.io.ContentType.TEXT;
360
361 /**
362 * Enumeration of content types that can be specified in
363 * {@link gadgets.io.RequestParameters.METHOD}
364 * @enum {string}
365 */
366 gadgets.io.MethodType = {};
367 gadgets.io.MethodType.DELETE;
368 gadgets.io.MethodType.GET;
369 gadgets.io.MethodType.HEAD;
370 gadgets.io.MethodType.POST;
371 gadgets.io.MethodType.PUT;
372
373 /**
374 * This is the response object that is passed to the callback of
375 * gadgets.io.makeRequest. It is never explicitly called "ResponseObject" in the
376 * documentation, but the documentation does refer to an object that is passed
377 * to the callback. This is that object.
378 * @see http://wiki.opensocial.org/index.php?title=Gadgets.io_(v0.9)#gadgets.io.makeRequest
379 */
380 gadgets.io.ResponseObject = {};
381 /**@type {Object}*/ gadgets.io.ResponseObject.data;
382 /**@type {Array.<string>}*/ gadgets.io.ResponseObject.errors;
383 /**@type {Object}*/ gadgets.io.ResponseObject.headers;
384 /**@type {number}*/ gadgets.io.ResponseObject.rc;
385 /**@type {string}*/ gadgets.io.ResponseObject.text;
386 /**@type {string}*/ gadgets.io.ResponseObject.oauthApprovalUrl;
387 /**@type {string}*/ gadgets.io.ResponseObject.oauthError;
388 /**@type {string}*/ gadgets.io.ResponseObject.oauthErrorText;
389
390 // Namespace for views
391 gadgets.views = {};
392
393 /**
394 * Returns the current view.
395 * @return {gadgets.views.View} The current view.
396 */
397 gadgets.views.getCurrentView = function() {};
398
399 /**
400 * Get parameters passed into the view
401 * @return {Object} Map string -> string of parameters passed in.
402 */
403 gadgets.views.getParams = function() {};
404
405 /**
406 * @return {Object} Map<gadgets.views.ViewType, String, gadgets.views.View>
407 * A map of all the supported views. Keys each gadgets.view.View by its name.
408 */
409 gadgets.views.getSupportedViews = function() {};
410
411 /**
412 * @param {gadgets.views.View|string} view The view to navigate to.
413 * @param {Object=} opt_params Map.<String, String>: Parameters to pass to the
414 * gadget after it has been navigated to on the surface.
415 * @param {string=} opt_ownerId The ID of the owner of the page to navigate to;
416 * defaults to the current owner.
417 */
418 gadgets.views.requestNavigateTo = function(view, opt_params, opt_ownerId) {};
419
420 /**
421 * @constructor
422 */
423 gadgets.views.View = function() {};
424
425 /**
426 * @return {string} Returns the name of this view.
427 */
428 gadgets.views.View.prototype.getName = function() {}
429
430 /**
431 * @return {boolean} True if the gadget is the only visible gadget; otherwise,
432 * false.
433 */
434 gadgets.views.View.prototype.isOnlyVisibleGadget = function() {};
435
436 // Namespace for utilities.
437 gadgets.util = {};
438
439 /**
440 * Escapes the input using HTML entities to make it safer.
441 * @param {string} str The string to escape.
442 * @return {string} The escaped string.
443 */
444 gadgets.util.escapeString = function(str) {};
445
446 /**
447 * Reverses escapeString
448 * @param {string} str The string to unescape.
449 * @return {string} The unescaped string.
450 */
451 gadgets.util.unescapeString = function(str) {};
452
453 /**
454 * Returns the parameters for a feature.
455 * @param {string} feature The feature name.
456 * @return {Object} Parameters for the feature or null.
457 */
458 gadgets.util.getFeatureParameters = function(feature) {};
459
460 /**
461 * Returns whether the specified feature is supported.
462 * @param {string} feature The feature name.
463 * @return {boolean} Whether the feature is supported.
464 */
465 gadgets.util.hasFeature = function(feature) {};
466
467 /**
468 * Registers a function to be called when the gadget loads.
469 * @param {function()} fn The function to call.
470 */
471 gadgets.util.registerOnLoadHandler = function(fn) {};
472
473 /**
474 * Parses the current document's location and returns an object representing
475 * the parameters in the query string.
476 * @param {string=} opt_url Optional URL whose parameters to parse.
477 * Defaults to window's current URL.
478 * @return {Object} Parameters from the query string.
479 */
480 gadgets.util.getUrlParameters = function(opt_url) {};
481
482 /**
483 * Creates a closure that is suitable for passing as a callback.
484 * Any number of arguments may be passed to the callback;
485 * they will be received in the order they are passed in.
486 *
487 * @param {Object} scope The execution scope; may be null if there is no
488 * need to associate a specific instance of an object with this
489 * callback
490 * @param {Function} callback The callback to invoke when this is run;
491 * any arguments passed in will be passed after your initial arguments
492 * @param {...*} var_args Initial arguments to be passed to the callback
493 * @returns {Function} The closure.
494 */
495 gadgets.util.makeClosure = function(scope, callback, var_args) {};
496
497 /**
498 * Attach an event listener to given DOM element (Not a gadget standard)
499 *
500 * @param {Object} elem DOM element on which to attach event.
501 * @param {string} eventName Event type to listen for.
502 * @param {function()} callback Invoked when specified event occurs.
503 * @param {boolean} useCapture If true, initiates capture.
504 */
505 gadgets.util.attachBrowserEvent = function(
506 elem, eventName, callback, useCapture) {};
507
508 //Namespace for JSON processing.
509 gadgets.json = {};
510
511 /**
512 * Convert a JSON object into a string.
513 * @param {Object} json
514 * @return {String} The JSON as a string
515 */
516 gadgets.json.stringify = function(json) {};
517
518 /**
519 * Convert a string into a JSON object.
520 * Uses safe RegEx match before parsing.
521 * @param {string} s The string
522 * @return {Object} The JSON
523 */
524 gadgets.json.parse = function(s) {};
525
526 //Namespace for config.
527 gadgets.config = {};
528
529 /**
530 * Registers a configurable component and its configuration parameters.
531 * Multiple callbacks may be registered for a single component if needed.
532 *
533 * @param {string} component The name of the component to register. Should
534 * be the same as the fully qualified name of the <Require> feature or
535 * the name of a fully qualified JavaScript object reference
536 * (e.g. "gadgets.io").
537 * @param {Object=} opt_validators Mapping of option name to validation
538 * functions that take the form function(data) {return isValid(data);}
539 * @param {Function=} opt_callback A function to be invoked when a
540 * configuration is registered. If passed, this function will be invoked
541 * immediately after a call to init has been made. Do not assume that
542 * dependent libraries have been configured until after init is
543 * complete. If you rely on this, it is better to defer calling
544 * dependent libraries until you can be sure that configuration is
545 * complete. Takes the form function(config), where config will be
546 * all registered config data for all components. This allows your
547 * component to read configuration from other components.
548 * @param {boolean=} opt_callOnUpdate Whether the callback shall be call
549 * on gadgets.config.update() as well.
550 */
551 gadgets.config.register = function(component, opt_validators, opt_callback,
552 opt_callOnUpdate) {};
553
554 /**
555 * Retrieves configuration data on demand.
556 *
557 * @param {string=} opt_component The component to fetch. If not provided
558 * all configuration will be returned.
559 * @return {Object} The requested configuration, or an empty object if no
560 * configuration has been registered for that component.
561 */
562 gadgets.config.get = function(opt_component) {};
563
564 /**
565 * Initializes the configuration.
566 *
567 * @param {Object} config The full set of configuration data.
568 * @param {Boolean=} opt_noValidation True if you want to skip validation.
569 */
570 gadgets.config.init = function(config, opt_noValidation) {};
571
572
573 /**
574 * Creates an HTML or XHTML element.
575 * @param {string} tagName The type of element to construct.
576 * @return {Element} The newly constructed element.
577 */
578 gadgets.util.createElement = function(tagName) {};
579
580
581 /**
582 * Creates an HTML or XHTML iframe element with attributes.
583 * @param {Object=} opt_attribs Optional set of attributes to attach. The
584 * only working attributes are spelled the same way in XHTML attribute
585 * naming (most strict, all-lower-case), HTML attribute naming (less strict,
586 * case-insensitive), and JavaScript property naming (some properties named
587 * incompatibly with XHTML/HTML).
588 * @return {Element} The DOM node representing body.
589 */
590 gadgets.util.createIframeElement = function(opt_attribs) {};
591
592
593 /**
594 * Gets the HTML or XHTML body element.
595 * @return {Element} The DOM node representing body.
596 */
597 gadgets.util.getBodyElement = function() {};
598