// 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');
then
and registering
onFulfilled
and onRejected
callbacks. Once the Promise
resolves, the relevant callbacks are invoked with the fulfillment value or
rejection reason as argument. Callbacks are always invoked in the order they
were registered, even when additional then
calls are made from inside
another callback. A callback is always run asynchronously sometime after the
scope containing the registering then
invocation has returned.
If a Promise is resolved with another Promise, the first Promise will block
until the second is resolved, and then assumes the same result as the second
Promise. This allows Promises to depend on the results of other Promises,
linking together multiple asynchronous operations.
This implementation is compatible with the Promises/A+ specification and
passes that specification's conformance test suite. A Closure Promise may be
resolved with a Promise instance (or sufficiently compatible Promise-like
object) created by other Promise implementations. From the specification,
Promise-like objects are known as "Thenables".
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()
.
![]()
Adds a dependency from a file to the files it requires.
|
code » | ||||
![]()
Adds a
getInstance static method that always returns the same
instance object.
Arguments:
|
code » | ||||
![]()
Call up to the superclass.
If this is called from a constructor, then this calls the superclass
constructor 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.
Arguments:
Returns: *
The return value of the superclass method.
|
code » | ||||
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:
#partial .
Usage:
var barMethBound = bind(myFunction, myObj, 'arg1', 'arg2'); barMethBound('arg3', 'arg4');
Arguments:
Returns: !Function
A partially-applied form of the function bind() was
invoked as a method of.
|
code » | ||||
A pure-JS implementation of goog.bind.
Arguments:
Returns: !Function
A partially-applied form of the function bind() was
invoked as a method of.
|
code » | ||||
A native implementation of goog.bind.
Arguments:
Returns: !Function
A partially-applied form of the function bind() was
invoked as a method of.
|
code » | ||||
![]()
goog.cloneObject is unsafe. Prefer the goog.object methods.
Clones a value. The input may be an Object, Array, or basic type. Objects and
arrays will be cloned recursively.
WARNINGS:
goog.cloneObject does not detect reference loops. Objects that
refer to themselves will cause infinite recursion.
goog.cloneObject is unaware of unique identifiers, and copies
UIDs created by getUid into cloned results.
Arguments:
Returns: *
A clone of the input value.
|
code » | ||||
![]()
Defines a named value. In uncompiled mode, the value is retreived from
CLOSURE_DEFINES or CLOSURE_UNCOMPILED_DEFINES if the object is defined and
has the property specified, and otherwise used the defined defaultValue.
When compiled, the default can be overridden using compiler command-line
options.
|
code » | ||||
![]()
Calls
dispose on the argument if it supports it. If obj is not an
object with a dispose() method, this is a no-op.
Arguments:
|
code » | ||||
![]()
Calls
dispose on each member of the list that supports it. (If the
member is an ArrayLike, then goog.disposeAll() will be called
recursively on each of its members.) If the member is not an object with a
dispose() method, then it is ignored.
Arguments:
|
code » | ||||
![]()
Builds an object structure for the provided namespace path, ensuring that
names that already exist are not overwritten. For example:
"a.b.c" -> a = {};a.b={};a.b.c={};
Used by goog.provide and goog.exportSymbol.
Arguments:
|
code » | ||||
![]()
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);
|
code » | ||||
![]()
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();
Arguments:
|
code » | ||||
![]()
Tries to detect the base path of base.js script that bootstraps Closure.
|
code » | ||||
![]()
Forward declares a symbol. This is an indication to the compiler that the
symbol may be used in the source yet is not required and may not be provided
in compilation.
The most common usage of forward declaration is code that takes a type as a
function parameter but does not need to require it. By forward declaring
instead of requiring, no hard dependency is made, and (if not required
elsewhere) the namespace may never be required and thus, not be pulled
into the JavaScript binary. If it is required elsewhere, it will be type
checked as normal.
Arguments:
|
code » | ||||
Handles strings that are intended to be used as CSS class names.
This function works in tandem with @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.
|
code » | ||||
Use goog.getUid instead.
Adds a hash code field to an object. The hash code is unique for the
given object.
|
code » | ||||
Gets a localized message.
This function is a compiler primitive. If you give the compiler a localized
message bundle, it will replace the string at compile-time with a localized
version, and expand goog.getMsg call to a concatenated string.
Messages must be initialized in the form:
var MSG_NAME = goog.getMsg('Hello {$placeholder}', {'placeholder': 'world'});
|
code » | ||||
Gets a localized message. If the message does not have a translation, gives a
fallback message.
This is useful when introducing a new message that has not yet been
translated into all languages.
This function is a compiler primitive. Must be used in the form:
var x = goog.getMsgWithFallback(MSG_A, MSG_B);
where MSG_A and MSG_B were initialized with goog.getMsg.
|
code » | ||||
![]()
Returns an object based on its fully qualified external name. The object
is not found if null or undefined. If you are using a compilation pass that
renames property names beware that using this function will not find renamed
properties.
Arguments:
Returns: ?
The value (object or primitive) or, if not found, null.
|
code » | ||||
![]()
No description.
|
code » | ||||
Looks at the dependency rules and tries to determine the script file that
fulfills a particular rule.
|
code » | ||||
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
getUid . There is no guarantee that the ID is unique or
consistent across sessions. It is unsafe to generate unique ID for function
prototypes.
|
code » | ||||
![]()
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.
Arguments:
|
code » | ||||
![]()
No description.
|
code » | ||||
![]()
Properties may be explicitly exported to the global scope, but
this should no longer be done in bulk.
Globalizes a whole namespace, such as goog or goog.lang.
Arguments:
|
code » | ||||
Whether the given object is alreay assigned a unique ID.
This does not modify the object.
|
code » | ||||
![]()
Use goog.functions.identity instead.
The identity function. Returns its first argument.
Arguments:
Returns: ?
The first argument. We can't know the type -- just pass it along
without type.
|
code » | ||||
![]()
Imports a script if, and only if, that script hasn't already been imported.
(Must be called at execution time)
Arguments:
|
code » | ||||
Tries to detect whether is in the context of an HTML document.
Returns: boolean
True if it looks like HTML document.
|
code » | ||||
![]()
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(); // This 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 here. }; |
code » | ||||
Returns true if the specified value is an array.
Arguments:
Returns: boolean
Whether variable is an array.
|
code » | ||||
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.
Arguments:
Returns: boolean
Whether variable is an array.
|
code » | ||||
Returns true if the specified value is a boolean.
Arguments:
Returns: boolean
Whether variable is boolean.
|
code » | ||||
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.
Arguments:
Returns: boolean
Whether variable is a like a Date.
|
code » | ||||
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.
Arguments:
Returns: boolean
Whether variable is defined.
|
code » | ||||
Returns true if the specified value is defined and not null.
Arguments:
Returns: boolean
Whether variable is defined and not null.
|
code » | ||||
Returns true if the specified value is a function.
Arguments:
Returns: boolean
Whether variable is a function.
|
code » | ||||
Returns true if the specified value is null.
Arguments:
Returns: boolean
Whether variable is null.
|
code » | ||||
Returns true if the specified value is a number.
Arguments:
Returns: boolean
Whether variable is a number.
|
code » | ||||
Returns true if the specified value is an object. This includes arrays and
functions.
Arguments:
Returns: boolean
Whether variable is an object.
|
code » | ||||
Check if the given name has been goog.provided. This will return false for
names that are available only as implicit namespaces.
|
code » | ||||
Returns true if the specified value is a string.
Arguments:
Returns: boolean
Whether variable is a string.
|
code » | ||||
Decorator around functions that caches the inner function's return values.
To cache parameterless functions, see goog.functions.cacheReturnValue.
Arguments:
Returns: !Function
The wrapped function.
|
code » | ||||
![]()
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.
|
code » | ||||
No description.
Returns: number
An integer value representing the number of milliseconds
between midnight, January 1, 1970 and the current time.
|
code » | ||||
![]()
No description.
|
code » | ||||
![]()
No description.
|
code » | ||||
![]()
No description.
|
code » | ||||
![]()
Null function used for default values of callbacks, etc.
Returns: void
Nothing.
|
code » | ||||
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);
|
code » | ||||
![]()
Creates object stubs for a namespace. The presence of one or more
goog.provide() calls indicate that the file defines the given
objects/namespaces. Provided objects must not be null or undefined.
Build tools also scan for provide/require statements
to discern dependencies, build dependency files (see deps.js), etc.
Arguments:
|
code » | ||||
![]()
Use goog.removeUid instead.
Removes the hash code field from an object.
Arguments:
|
code » | ||||
![]()
Removes the unique ID from an object. This is useful if the object was
previously mutated using
goog.getUid in which case the mutation is
undone.
Arguments:
|
code » | ||||
![]()
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.
Arguments:
|
code » | ||||
![]()
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.
Arguments:
|
code » | ||||
![]()
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.
Arguments:
|
code » | ||||
![]()
Marks that the current file should only be used for testing, and never for
live code in production.
In the case of unit tests, the message may optionally be an exact namespace
for the test (e.g. 'goog.stringTest'). The linter will then ignore the extra
provide (if not explicitly defined in the code).
Arguments:
|
code » | ||||
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'.
Arguments:
Returns: string
The name of the type.
|
code » | ||||
The default implementation of the import function. Writes a script tag to
import the script.
|
code » | ||||
![]()
Resolves dependencies based on the dependencies added using addDependency
and calls importScript_ in the correct order.
|
code » |
![]()
No description.
|
Code » | |
![]()
True if goog.dependencies_ is available.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Name for unique ID property. Initialized in a way to help avoid collisions
with other closure JavaScript on the same page.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
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.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Path for included scripts.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Optional obfuscation style for CSS class names. Should be set to either
'BY_WHOLE' or 'BY_PART' if defined.
|
Code » | |
![]()
Optional map of CSS class names to obfuscated names used with
goog.getCssName().
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
This object is used to keep track of dependencies and other data that is
used for loading scripts.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Indicates whether or not we can call 'eval' directly to eval code in the
global scope. Set to a Boolean by the first call to goog.globalEval (which
empirically tests whether eval works for globals). @see goog.globalEval
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Namespaces implicitly defined by goog.provide. For example,
goog.provide('goog.events.Event') implicitly declares that 'goog' and
'goog.events' must be namespaces.
|
Code » | |
![]()
Object used to keep track of urls that have already been added. This record
allows the prevention of circular dependencies.
|
Code » | |
![]()
All singleton classes that have been instantiated, for testing. Don't read
it directly, use the
goog.testing.singleton module. The compiler
removes this variable if unused.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Counter for UID.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » |