The goog Namespace

goog

Base namespace for the Closure library. Checks to see goog is already defined in the current scope before assigning to prevent clobbering if base.js is loaded more than once.

@const

.DEBUG

The goog.Delay Class

Deprecated. Use goog.async.Delay instead.

A deprecated alias. … more

The goog.Disposable Class

Class that provides the basic implementation for disposable objects. If your class holds one or more references to COM objects, DOM nodes, or other disposable objects, it should extend this class or implement the disposable interface (defined in goog.disposable.IDisposable). … more

.ENABLE_DEBUG_LOADER

The goog.History Class

A history management object. Can be instantiated in user-visible mode (uses the address fragment to manage state) or in hidden mode. This object should be created from a script in the document body before the document has finished loading. To store the hidden states in browsers other than IE, a hidden iframe is used. It must point to a valid html page on the same domain (which can and probably should be blank.) Sample instantiation and usage:

 // Instantiate history to use the address bar for state.
 var h = new goog.History();
 goog.events.listen(h, goog.history.EventType.NAVIGATE, navCallback);
 h.setEnabled(true);

 // Any changes to the location hash will call the following function.
 function navCallback(e) {
   alert('Navigated to state "' + e.token + '"');
 }

 // The history token can also be set from code directly.
 h.setToken('foo');
 
… more

.LOCALE

.NATIVE_ARRAY_PROTOTYPES

The goog.Throttle Class

Deprecated. Use goog.async.Throttle instead.

A deprecated alias. … more

The goog.Timer Class

Class for handling timing events. … more

The goog.Uri Class

This class contains setters and getters for the parts of the URI. The getXyz/setXyz methods return the decoded part -- sogoog.Uri.parse('/foo%20bar').getPath() will return the decoded path, /foo bar. The constructor accepts an optional unparsed, raw URI string. The parser is relaxed, so special characters that aren't escaped but don't cause ambiguities will not cause parse failures. All setters return this and so may be chained, a la goog.Uri.parse('/foo').setFragment('part').toString(). … more

.abstractMethod() {!Function}

When defining a class Foo with an abstract method bar(), you can do: Foo.prototype.bar = goog.abstractMethod Now if a subclass of Foo fails to override bar(), an error will be thrown when bar() is invoked. Note: This does not take the name of the function to override as an argument because that would make it more difficult to obfuscate our JavaScript code.

@throws
{Error} when invoked to indicate the method should be overridden.

.addDependency(relPath, provides, requires)

Adds a dependency from a file to the files it requires.

relPath {string}
The path to the js file.
provides {Array}
An array of strings with the names of the objects this file provides.
requires {Array}
An array of strings with the names of the objects this file requires.

.addSingletonGetter(ctor)

Adds a {@code getInstance} static method that always return the same instance object.

ctor {!Function}
The constructor for the class to add the static method to.

The goog.array Namespace

… more

The goog.asserts Namespace

… more

The goog.async Namespace

… more

.base(me, opt_methodName, var_args)

Call up to the superclass. If this is called from a constructor, then this calls the superclass contructor with arguments 1-N. If this is called from a prototype method, then you must pass the name of the method as the second argument to this function. If you do not, you will get a runtime error. This calls the superclass' method with arguments 2-N. This function only works if you use goog.inherits to express inheritance relationships between your classes. This function is a compiler primitive. At compile-time, the compiler will do macro expansion to remove a lot of the extra overhead that this function introduces. The compiler will also enforce a lot of the assumptions that this function makes, and treat it as a compiler error if you break them.

me {!Object}
Should always be "this".
opt_methodName {*=}
The method name if calling a super method.
var_args {...*}
The rest of the arguments.
returns {*}
The return value of the superclass method.

.basePath {string}

Path for included scripts

.bind(fn, selfObj, var_args)

Partially applies this function to a particular 'this object' and zero or more arguments. The result is a new function with some arguments of the first function pre-filled and the value of |this| 'pre-specified'.

Remaining arguments specified at call-time are appended to the pre- specified ones.

Also see: {@link #partial}.

Usage:

var barMethBound = bind(myFunction, myObj, 'arg1', 'arg2');
 barMethBound('arg3', 'arg4');
fn {Function}
A function to partially apply.
selfObj {Object|undefined}
Specifies the object which |this| should point to when the function is run.
var_args {...*}
Additional arguments that are partially applied to the function.
returns {!Function}
A partially-applied form of the function bind() was invoked as a method of.
@suppress
{deprecated} See above.

The goog.color Namespace

… more

The goog.crypt Namespace

… more

The goog.cssom Namespace

… more

The goog.date Namespace

… more

The goog.db Namespace

… more

The goog.debug Namespace

… more

The goog.demos Namespace

… more

The goog.disposable Namespace

… more

.dispose(obj)

Calls {@code dispose} on the argument if it supports it. If obj is not an object with a dispose() method, this is a no-op.

obj {*}
The object to dispose of.

.disposeAll(var_args)

Calls {@code dispose} on each member of the list that supports it. (If the member is an ArrayLike, then {@code goog.disposeAll()} will be called recursively on each of its members.) If the member is not an object with a {@code dispose()} method, then it is ignored.

var_args {...*}
The list.

The goog.dom Namespace

… more

The goog.ds Namespace

… more

The goog.editor Namespace

… more

The goog.events Namespace

… more

.exportProperty(object, publicName, symbol)

Exports a property unobfuscated into the object's namespace. ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction); ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod);

object {Object}
Object whose static property is being exported.
publicName {string}
Unobfuscated name to export.
symbol {*}
Object the name should point to.

.exportSymbol(publicPath, object, opt_objectToExportTo)

Exposes an unobfuscated global namespace path for the given object. Note that fields of the exported object *will* be obfuscated, unless they are exported in turn via this function or goog.exportProperty

Also handy for making public items that are defined in anonymous closures. ex. goog.exportSymbol('public.path.Foo', Foo); ex. goog.exportSymbol('public.path.Foo.staticFunction', Foo.staticFunction); public.path.Foo.staticFunction(); ex. goog.exportSymbol('public.path.Foo.prototype.myMethod', Foo.prototype.myMethod); new public.path.Foo().myMethod();

publicPath {string}
Unobfuscated name to export.
object {*}
Object the name should point to.
opt_objectToExportTo {Object=}
The object to add the path to; default is |goog.global|.

The goog.format Namespace

… more

The goog.fs Namespace

… more

The goog.functions Namespace

… more

The goog.fx Namespace

… more

The goog.gears Namespace

… more

.getCssName(className, opt_modifier)

Handles strings that are intended to be used as CSS class names. This function works in tandem with

className {string}
The class name.
opt_modifier {string=}
A modifier to be appended to the class name.
returns {string}
The class name or the concatenation of the class name and the modifier.
@see
goog.setCssNameMapping. Without any mapping set, the arguments are simple joined with a hyphen and passed through unaltered. When there is a mapping, there are two possible styles in which these mappings are used. In the BY_PART style, each part (i.e. in between hyphens) of the passed in css name is rewritten according to the map. In the BY_WHOLE style, the full css name is looked up in the map directly. If a rewrite is not specified by the map, the compiler will output a warning. When the mapping is passed to the compiler, it will replace calls to goog.getCssName with the strings from the mapping, e.g. var x = goog.getCssName('foo'); var y = goog.getCssName(this.baseClass, 'active'); becomes: var x= 'foo'; var y = this.baseClass + '-active'; If one argument is passed it will be processed, if two are passed only the modifier will be processed, as it is assumed the first argument was generated as a result of calling goog.getCssName.

.getMsg(str, opt_values)

Abstract implementation of goog.getMsg for use with localized messages.

str {string}
Translatable string, places holders in the form {$foo}.
opt_values {Object=}
Map of place holder name to value.
returns {string}
message with placeholders filled.

.getObjectByName(name, opt_obj)

Returns an object based on its fully qualified external name. If you are using a compilation pass that renames property names beware that using this function will not find renamed properties.

name {string}
The fully qualified name.
opt_obj {Object=}
The object within which to look; default is |goog.global|.
returns {?}
The value (object or primitive) or, if not found, null.

.getUid(obj)

Gets a unique ID for an object. This mutates the object so that further calls with the same object as a parameter returns the same value. The unique ID is guaranteed to be unique across the current session amongst objects that are passed into {@code getUid}. There is no guarantee that the ID is unique or consistent across sessions. It is unsafe to generate unique ID for function prototypes.

obj {Object}
The object to get the unique ID for.
returns {number}
The unique ID for the object.

The goog.global Namespace

Reference to the global context. In most cases this will be 'window'. … more

.globalEval(script)

Evals javascript in the global scope. In IE this uses execScript, other browsers use goog.global.eval. If goog.global.eval does not evaluate in the global scope (for example, in Safari), appends a script tag instead. Throws an exception if neither execScript or eval is defined.

script {string}
JavaScript string.

The goog.graphics Namespace

… more

The goog.history Namespace

… more

The goog.i18n Namespace

… more

.inherits(childCtor, parentCtor)

Inherit the prototype methods from one constructor into another. Usage:

 function ParentClass(a, b) { }
 ParentClass.prototype.foo = function(a) { }

 function ChildClass(a, b, c) {
   goog.base(this, a, b);
 }
 goog.inherits(ChildClass, ParentClass);

 var child = new ChildClass('a', 'b', 'see');
 child.foo(); // works
 
In addition, a superclass' implementation of a method can be invoked as follows:
 ChildClass.prototype.foo = function(a) {
   ChildClass.superClass_.foo.call(this, a);
   // other code
 };
 
childCtor {Function}
Child class.
parentCtor {Function}
Parent class.

.isArray(val)

Returns true if the specified value is an array

val {*}
Variable to test.
returns {boolean}
Whether variable is an array.

.isArrayLike(val)

Returns true if the object looks like an array. To qualify as array like the value needs to be either a NodeList or an object with a Number length property.

val {*}
Variable to test.
returns {boolean}
Whether variable is an array.

.isBoolean(val)

Returns true if the specified value is a boolean

val {*}
Variable to test.
returns {boolean}
Whether variable is boolean.

.isDateLike(val)

Returns true if the object looks like a Date. To qualify as Date-like the value needs to be an object and have a getFullYear() function.

val {*}
Variable to test.
returns {boolean}
Whether variable is a like a Date.

.isDef(val)

Returns true if the specified value is not |undefined|. WARNING: Do not use this to test if an object has a property. Use the in operator instead. Additionally, this function assumes that the global undefined variable has not been redefined.

val {*}
Variable to test.
returns {boolean}
Whether variable is defined.

.isDefAndNotNull(val)

Returns true if the specified value is defined and not null

val {*}
Variable to test.
returns {boolean}
Whether variable is defined and not null.

.isFunction(val)

Returns true if the specified value is a function

val {*}
Variable to test.
returns {boolean}
Whether variable is a function.

.isNull(val)

Returns true if the specified value is |null|

val {*}
Variable to test.
returns {boolean}
Whether variable is null.

.isNumber(val)

Returns true if the specified value is a number

val {*}
Variable to test.
returns {boolean}
Whether variable is a number.

.isObject(val)

Returns true if the specified value is an object. This includes arrays and functions.

val {*}
Variable to test.
returns {boolean}
Whether variable is an object.

.isString(val)

Returns true if the specified value is a string

val {*}
Variable to test.
returns {boolean}
Whether variable is a string.

The goog.iter Namespace

… more

The goog.json Namespace

… more

The goog.labs Namespace

… more

The goog.locale Namespace

… more

The goog.math Namespace

… more

The goog.memoize Namespace

Decorator around functions that caches the inner function's return values. … more

The goog.messaging Namespace

… more

.mixin(target, source)

Copies all the members of a source object to a target object. This method does not work on all browsers for all objects that contain keys such as toString or hasOwnProperty. Use goog.object.extend for this purpose.

target {Object}
Target.
source {Object}
Source.

The goog.module Namespace

… more

The goog.net Namespace

… more

.now

returns {number}
An integer value representing the number of milliseconds between midnight, January 1, 1970 and the current time.

.nullFunction()

Null function used for default values of callbacks, etc.

returns {void}
Nothing.

The goog.object Namespace

… more

The goog.osapi Namespace

… more

.partial(fn, var_args)

Like bind(), except that a 'this object' is not required. Useful when the target function is already bound. Usage: var g = partial(f, arg1, arg2); g(arg3, arg4);

fn {Function}
A function to partially apply.
var_args {...*}
Additional arguments that are partially applied to fn.
returns {!Function}
A partially-applied form of the function bind() was invoked as a method of.

The goog.positioning Namespace

… more

The goog.proto Namespace

… more

The goog.proto2 Namespace

… more

.provide(name)

Creates object stubs for a namespace. The presence of one or more goog.provide() calls indicate that the file defines the given objects/namespaces. Build tools also scan for provide/require statements to discern dependencies, build dependency files (see deps.js), etc.

name {string}
Namespace provided by this file in the form "goog.package.part".
@see
goog.require

The goog.pubsub Namespace

… more

The goog.reflect Namespace

… more

.removeUid(obj)

Removes the unique ID from an object. This is useful if the object was previously mutated using {@code goog.getUid} in which case the mutation is undone.

obj {Object}
The object to remove the unique ID field from.

.require(name)

Implements a system for the dynamic resolution of dependencies that works in parallel with the BUILD system. Note that all calls to goog.require will be stripped by the JSCompiler when the --closure_pass option is used.

name {string}
Namespace to include (as was given in goog.provide()) in the form "goog.package.part".
@see
goog.provide

.scope(fn)

Allow for aliasing within scope functions. This function exists for uncompiled code - in compiled code the calls will be inlined and the aliases applied. In uncompiled code the function is simply run since the aliases as written are valid JavaScript.

fn {function()}
Function to call. This function can contain aliases to namespaces (e.g. "var dom = goog.dom") or classes (e.g. "var Timer = goog.Timer").

.setCssNameMapping(mapping, opt_style)

Sets the map to check when returning a value from goog.getCssName(). Example:

 goog.setCssNameMapping({
   "goog": "a",
   "disabled": "b",
 });

 var x = goog.getCssName('goog');
 // The following evaluates to: "a a-b".
 goog.getCssName('goog') + ' ' + goog.getCssName(x, 'disabled')
 
When declared as a map of string literals to string literals, the JSCompiler will replace all calls to goog.getCssName() using the supplied map if the --closure_pass flag is set.
mapping {!Object}
A map of strings to strings where keys are possible arguments to goog.getCssName() and values are the corresponding values that should be returned.
opt_style {string=}
The style of css name mapping. There are two valid options: 'BY_PART', and 'BY_WHOLE'.
@see
goog.getCssName for a description.

.setTestOnly(opt_message)

Marks that the current file should only be used for testing, and never for live code in production.

opt_message {string=}
Optional message to add to the error that's raised when used in production code.

The goog.silverlight Namespace

… more

The goog.soy Namespace

… more

The goog.spell Namespace

… more

The goog.stats Namespace

… more

The goog.storage Namespace

… more

The goog.string Namespace

… more

The goog.structs Namespace

… more

The goog.style Namespace

… more

The goog.style_test Namespace

… more

The goog.testing Namespace

… more

The goog.text Namespace

… more

The goog.tweak Namespace

… more

.typeOf(value)

This is a "fixed" version of the typeof operator. It differs from the typeof operator in such a way that null returns 'null' and arrays return 'array'.

value {*}
The value to get the type of.
returns {string}
The name of the type.

The goog.ui Namespace

… more

The goog.uri Namespace

… more

The goog.userAgent Namespace

… more

The goog.vec Namespace

… more

The goog.webgl Namespace

… more

The goog.window Namespace

… more