From e3e62a4ae3cf3c74d115bad88071f67427fe9697 Mon Sep 17 00:00:00 2001
From: Rhsy 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). Disposes of the object. If the object hasn't already been disposed of, calls
+{@link #disposeInternal}. Classes that extend {@code goog.Disposable} should
+override {@link #disposeInternal} in order to delete references to COM
+objects, DOM nodes, and other disposable objects. Reentrant. Deletes or nulls out any references to COM objects, DOM nodes, or other
+disposable objects. Classes that extend {@code goog.Disposable} should
+override this method.
+Not reentrant. To avoid calling it twice, it must only be called from the
+subclass' {@code disposeInternal} method. Everywhere else the public
+{@code dispose} method must be used.
+For example:
+ Associates a disposable object with this object so that they will be disposed
+together. Clears the registry of undisposed objects but doesn't dispose of them. 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:
+
+Class goog.Disposable
Instance Method Summary dispose()
disposeInternal()
+mypackage.MyClass = function() {
+goog.base(this);
+// Constructor logic specific to MyClass.
+...
+};
+goog.inherits(mypackage.MyClass, goog.Disposable);
+
+mypackage.MyClass.prototype.disposeInternal = function() {
+goog.base(this, 'disposeInternal');
+// Dispose logic specific to MyClass.
+...
+};
+
isDisposed() ⇒ boolean
registerDisposable(?goog.disposable.IDisposable disposable)
\ No newline at end of file
diff --git a/docs/goog/History.html b/docs/goog/History.html
new file mode 100644
index 0000000..a5cb367
--- /dev/null
+++ b/docs/goog/History.html
@@ -0,0 +1,94 @@
+Static Method Summary clearUndisposedObjects()
getUndisposedObjects() ⇒ !Array
Class goog.History
+// 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');
+
Instance Method Summary | |
check_(boolean isNavigation) Checks the state of the document fragment and the iframe title to detect +navigation changes. If {@code goog.History.HAS_ONHASHCHANGE} is +{@code false}, then this runs approximately twenty times per second. | |
disposeInternal() Unattach listeners from this object. Classes that extend EventTarget may +need to override this method in order to remove references to DOM Elements +and additional listeners, it should be something like this: + +MyClass.prototype.disposeInternal = function() { +MyClass.superClass_.disposeInternal.call(this); +// Dispose logic for MyClass +}; + | |
getIframeToken_() ⇒ ?string Return the current state string from the hidden iframe. On internet explorer, +this is stored as a string in the document body. Other browsers use the +location hash of the hidden iframe. + +Older versions of webkit cannot access the iframe location, so always return +null in that case. | |
getLocationFragment_(?Window win) ⇒ string Gets the location fragment for the current URL. We don't use location.hash +directly as the browser helpfully urlDecodes the string for us which can +corrupt the tokens. For example, if we want to store: label/%2Froot it would +be returned as label//root. | |
getToken() ⇒ string | |
onDocumentLoaded() Callback for the window onload event in IE. This is necessary to read the +value of the hidden input after restoring a history session. The value of +input elements is not viewable until after window onload for some reason (the +iframe state is similarly unavailable during the loading phase.) If +setEnabled is called before the iframe has completed loading, the history +object will actually be enabled at this point. | |
onHashChange_(?goog.events.BrowserEvent e) Handles HTML5 onhashchange events on browsers where it is supported. +This is very similar to {@link #check_}, except that it is not executed +continuously. It is only used when {@code goog.History.HAS_ONHASHCHANGE} is +true. | |
onShow_(?goog.events.BrowserEvent e) Handler for the Gecko pageshow event. Restarts the history object so that the +correct state can be restored in the hash or iframe. | |
operaDefibrillator_() Opera cancels all outstanding timeouts and intervals after any rapid +succession of navigation events, including the interval used to detect +navigation events. This function restarts the interval so that navigation can +continue. Ideally, only events which would be likely to cause a navigation +change (mousedown and keydown) would be bound to this function. Since Opera +seems to ignore keydown events while the alt key is pressed (such as +alt-left or right arrow), this function is also bound to the much more +frequent mousemove event. This way, when the update loop freezes, it will +unstick itself as the user wiggles the mouse in frustration. | |
replaceToken(string token, string= opt_title) Replaces the current history state without affecting the rest of the history +stack. | |
setEnabled(boolean enable) Starts or stops the History polling loop. When enabled, the History object +will immediately fire an event for the current location. The caller can set +up event listeners between the call to the constructor and the call to +setEnabled. + +On IE, actual startup may be delayed until the iframe and hidden input +element have been loaded and can be polled. This behavior is transparent to +the caller. | |
setHash_(string token, boolean= opt_replace) Sets or replaces the URL fragment. The token does not need to be URL encoded +according to the URL specification, though certain characters (like newline) +are automatically stripped. + +If opt_replace is not set, non-IE browsers will append a new entry to the +history list. Setting the hash does not affect the history stack in IE +(unless there is a pre-existing named anchor for that hash.) + +Older versions of Webkit cannot query the location hash, but it still can be +set. If we detect one of these versions, always replace instead of creating +new history entries. + +window.location.replace replaces the current state from the history stack. +http://www.whatwg.org/specs/web-apps/current-work/#dom-location-replace +http://www.whatwg.org/specs/web-apps/current-work/#replacement-enabled | |
setHistoryState_(string token, boolean replace, string= opt_title) Sets the history state. When user visible states are used, the URL fragment +will be set to the provided token. Setting opt_replace to true will cause the +navigation to occur, but will replace the current history entry without +affecting the length of the stack. | |
setIframeToken_(string token, boolean= opt_replace, string= opt_title) Sets the hidden iframe state. On IE, this is accomplished by writing a new +document into the iframe. In Firefox, the iframe's URL fragment stores the +state instead. + +Older versions of webkit cannot set the iframe, so ignore those browsers. | |
setLongerPolling_(boolean longerPolling) Sets if the history oject should use longer intervals when polling. | |
setToken(string token, string= opt_title) Sets the history state. When user visible states are used, the URL fragment +will be set to the provided token. Sometimes it is necessary to set the +history token before the document title has changed, in this case IE's +history drop down can be out of sync with the token. To get around this +problem, the app can pass in a title to use with the hidden iframe. | |
update_(string token, boolean isNavigation) Updates the current history state with a given token. Called after a change +to the location or the iframe state is detected by poll_. |
Class for handling timing events.
extends goog.events.EventTargetInstance Method Summary | |
dispatchTick() Dispatches the TICK event. This is its own method so subclasses can override. | |
disposeInternal() Unattach listeners from this object. Classes that extend EventTarget may +need to override this method in order to remove references to DOM Elements +and additional listeners, it should be something like this: + +MyClass.prototype.disposeInternal = function() { +MyClass.superClass_.disposeInternal.call(this); +// Dispose logic for MyClass +}; + | |
getInterval() ⇒ number Gets the interval of the timer. | |
setInterval(number interval) Sets the interval of the timer. | |
start() Starts the timer. | |
stop() Stops the timer. | |
tick_() Callback for the setTimeout used by the timer |
Static Method Summary | |
callOnce(?Function listener, number= opt_delay, ?Object= opt_handler) ⇒ number Calls the given function once, after the optional pause. + +The function is always called asynchronously, even if the delay is 0. This +is a common trick to schedule a function to run after a batch of browser +event processing. | |
clear(?number timerId) Clears a timeout initiated by callOnce |
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()
.
Instance Method Summary | |
clone() ⇒ !goog.Uri Clones the URI instance. | |
enforceReadOnly() Checks if this Uri has been marked as read only, and if so, throws an error. +This should be called whenever any modifying function is called. | |
getDecodedQuery() ⇒ string | |
getDomain() ⇒ string | |
getEncodedQuery() ⇒ string | |
getFragment() ⇒ string | |
getIgnoreCase() ⇒ boolean | |
getParameterValue(string paramName) ⇒ <Any Type> Returns the first value for a given cgi parameter or undefined if the given +parameter name does not appear in the query string. | |
getParameterValues(string name) ⇒ ?Array Returns the values for a given cgi parameter as a list of decoded +query parameter values. | |
getPath() ⇒ string | |
getPort() ⇒ ?number | |
getQuery() ⇒ string | |
getQueryData() ⇒ ?goog.Uri.QueryData Returns the query data. | |
getScheme() ⇒ string | |
getUserInfo() ⇒ string | |
hasDomain() ⇒ boolean | |
hasFragment() ⇒ boolean | |
hasPath() ⇒ boolean | |
hasPort() ⇒ boolean | |
hasQuery() ⇒ boolean | |
hasSameDomainAs(?goog.Uri uri2) ⇒ boolean Returns true if this has the same domain as that of uri2. | |
hasScheme() ⇒ boolean | |
hasUserInfo() ⇒ boolean | |
isReadOnly() ⇒ boolean | |
makeUnique() ⇒ !goog.Uri Adds a random parameter to the Uri. | |
removeParameter(string key) ⇒ !goog.Uri Removes the named query parameter. | |
resolve(?goog.Uri relativeUri) ⇒ !goog.Uri Resolves a relative url string to a this base uri.
+
+There are several kinds of relative urls: | |
setDomain(string newDomain, boolean= opt_decode) ⇒ !goog.Uri Sets the domain. | |
setFragment(string newFragment, boolean= opt_decode) ⇒ !goog.Uri Sets the URI fragment. | |
setIgnoreCase(boolean ignoreCase) ⇒ !goog.Uri Sets whether to ignore case. +NOTE: If there are already key/value pairs in the QueryData, and +ignoreCase_ is set to false, the keys will all be lower-cased. | |
setParameterValue(string key, <Any Type> value) ⇒ !goog.Uri Sets the value of the named query parameters, clearing previous values for +that key. | |
setParameterValues(string key, <Any Type> values) ⇒ !goog.Uri Sets the values of the named query parameters, clearing previous values for
+that key. Not new values will currently be moved to the end of the query
+string.
+
+So, | |
setPath(string newPath, boolean= opt_decode) ⇒ !goog.Uri Sets the path. | |
setPort(<Any Type> newPort) ⇒ !goog.Uri Sets the port number. | |
setQuery(string newQuery, boolean= opt_decode) ⇒ !goog.Uri Sets the URI query. | |
setQueryData((goog.Uri.QueryData|null|string|undefined) queryData, boolean= opt_decode) ⇒ !goog.Uri Sets the query data. | |
setReadOnly(boolean isReadOnly) ⇒ !goog.Uri Sets whether Uri is read only. If this goog.Uri is read-only, +enforceReadOnly_ will be called at the start of any function that may modify +this Uri. | |
setScheme(string newScheme, boolean= opt_decode) ⇒ !goog.Uri Sets the scheme/protocol. | |
setUserInfo(string newUserInfo, boolean= opt_decode) ⇒ !goog.Uri Sets the userInfo. | |
toString() ⇒ string |
Static Method Summary | |
create(?string= opt_scheme, ?string= opt_userInfo, ?string= opt_domain, ?number= opt_port, ?string= opt_path, (goog.Uri.QueryData|null|string=) opt_query, ?string= opt_fragment, boolean= opt_ignoreCase) ⇒ !goog.Uri Creates a new goog.Uri object from unencoded parts. | |
decodeOrEmpty_((string|undefined) val) ⇒ string Decodes a value or returns the empty string if it isn't defined or empty. | |
encodeChar_(string ch) ⇒ string Converts a character in [\01-\177] to its unicode character equivalent. | |
encodeSpecialChars_(<Any Type> unescapedPart, ?RegExp extra) ⇒ ?string If unescapedPart is non null, then escapes any characters in it that aren't +valid characters in a url and also escapes any special characters that +appear in extra. | |
encodeString_(<Any Type> unescapedPart) ⇒ ?string URI encode a string, or return null if it's not a string. | |
haveSameDomain(string uri1String, string uri2String) ⇒ boolean Checks whether two URIs have the same domain. | |
parse(<Any Type> uri, boolean= opt_ignoreCase) ⇒ !goog.Uri Creates a uri from the string form. Basically an alias of new goog.Uri(). +If a Uri object is passed to parse then it will return a clone of the object. | |
removeDotSegments(string path) ⇒ string Removes dot segments in given path component, as described in +RFC 3986, section 5.2.4. | |
resolve(<Any Type> base, <Any Type> rel) ⇒ !goog.Uri Resolves a relative Uri against a base Uri, accepting both strings and +Uri objects. |
Class used to represent URI query parameters. It is essentially a hash of +name-value pairs, though a name can be present more than once. + +Has the same interface as the collections in goog.structs.
Instance Method Summary | |
add(string key, <Any Type> value) ⇒ !goog.Uri.QueryData Adds a key value pair. | |
clear() Clears the parameters. | |
clone() ⇒ !goog.Uri.QueryData Clone the query data instance. | |
containsKey(string key) ⇒ boolean Whether there is a parameter with the given name | |
containsValue(<Any Type> value) ⇒ boolean Whether there is a parameter with the given value. | |
ensureKeyMapInitialized_() If the underlying key map is not yet initialized, it parses the +query string and fills the map with parsed data. | |
extend((Object|goog.Uri.QueryData|goog.structs.Map|null|undefined) var_args) Extends a query data object with another query data or map like object. This +operates 'in-place', it does not create a new QueryData object. | |
filterKeys(?Array.<string> keys) ⇒ !goog.Uri.QueryData Removes all keys that are not in the provided list. (Modifies this object.) | |
get(string key, <Any Type> opt_default) ⇒ <Any Type> Returns the first value associated with the key. If the query data has no +such key this will return undefined or the optional default. | |
getCount() ⇒ ?number | |
getKeyName_(<Any Type> arg) ⇒ string Helper function to get the key name from a JavaScript object. Converts +the object to a string, and to lower case if necessary. | |
getKeys() ⇒ ?Array Returns all the keys of the parameters. If a key is used multiple times +it will be included multiple times in the returned array | |
getValues(string= opt_key) ⇒ ?Array Returns all the values of the parameters with the given name. If the query +data has no such key this will return an empty array. If no key is given +all values wil be returned. | |
invalidateCache_() Invalidate the cache. | |
isEmpty() ⇒ boolean | |
remove(string key) ⇒ boolean Removes all the params with the given key. | |
set(string key, <Any Type> value) ⇒ !goog.Uri.QueryData Sets a key value pair and removes all other keys with the same value. | |
setIgnoreCase(boolean ignoreCase) Ignore case in parameter names. +NOTE: If there are already key/value pairs in the QueryData, and +ignoreCase_ is set to false, the keys will all be lower-cased. | |
setValues(string key, ?Array values) Sets the values for a key, if the key has already got values defined, this +will override the existing values then remove any left over | |
toDecodedString() ⇒ string | |
toString() ⇒ string |
Static Method Summary | |
createFromKeysValues(?Array.<string> keys, ?Array values, ?goog.Uri= opt_uri, boolean= opt_ignoreCase) ⇒ !goog.Uri.QueryData Creates a new query data instance from parallel arrays of parameter names +and values. Allows for duplicate parameter names. Throws an error if the +lengths of the arrays differ. | |
createFromMap((Object|goog.structs.Map) map, ?goog.Uri= opt_uri, boolean= opt_ignoreCase) ⇒ !goog.Uri.QueryData Creates a new query data instance from a map of names and values. |
Function Summary | |
appendKeyValuePairs_(string key, ?goog.uri.utils.QueryValue value, !Array pairs) Appends key=value pairs to an array, supporting multi-valued objects. | |
appendParam(string uri, string key, <Any Type> value) ⇒ string Appends a single URI parameter. + +Repeated calls to this can exhibit quadratic behavior in IE6 due to the +way string append works, though it should be limited given the 2kb limit. | |
appendParams(string uri, (goog.uri.utils.QueryArray|goog.uri.utils.QueryValue|null|string|undefined) var_args) ⇒ string Appends URI parameters to an existing URI. + +The variable arguments may contain alternating keys and values. Keys are +assumed to be already URI encoded. The values should not be URI-encoded, +and will instead be encoded by this function. + +appendParams('http://www.foo.com?existing=true', +'key1', 'value1', +'key2', 'value?willBeEncoded', +'key3', ['valueA', 'valueB', 'valueC'], +'key4', null); +result: 'http://www.foo.com?existing=true&' + +'key1=value1&' + +'key2=value%3FwillBeEncoded&' + +'key3=valueA&key3=valueB&key3=valueC' ++ +A single call to this function will not exhibit quadratic behavior in IE, +whereas multiple repeated calls may, although the effect is limited by +fact that URL's generally can't exceed 2kb. | |
appendParamsFromMap(string uri, ?Object map) ⇒ string Appends query parameters from a map. | |
appendPath(string baseUri, string path) ⇒ string Generates a URI path using a given URI and a path with checks to +prevent consecutive "//". The baseUri passed in must not contain +query or fragment identifiers. The path to append may not contain query or +fragment identifiers. | |
appendQueryData_(!Array buffer) ⇒ string Appends a URI and query data in a string buffer with special preconditions. + +Internal implementation utility, performing very few object allocations. | |
assertNoFragmentsOrQueries_(string uri) Asserts that there are no fragment or query identifiers, only in uncompiled +mode. | |
buildFromEncodedParts(?string= opt_scheme, ?string= opt_userInfo, ?string= opt_domain, (null|number|string=) opt_port, ?string= opt_path, ?string= opt_queryData, ?string= opt_fragment) ⇒ string Builds a URI string from already-encoded parts. + +No encoding is performed. Any component may be omitted as either null or +undefined. | |
buildQueryData(?goog.uri.utils.QueryArray keysAndValues, number= opt_startIndex) ⇒ string Builds a query data string from a sequence of alternating keys and values. +Currently generates "&key&" for empty args. | |
buildQueryDataBufferFromMap_(!Array buffer, ?Object map) ⇒ !Array Builds a buffer of query data from a map. | |
buildQueryDataBuffer_(!Array buffer, (Arguments|goog.uri.utils.QueryArray|null) keysAndValues, number= opt_startIndex) ⇒ !Array Builds a buffer of query data from a sequence of alternating keys and values. | |
buildQueryDataFromMap(?Object map) ⇒ string Builds a query data string from a map. +Currently generates "&key&" for empty args. | |
decodeIfPossible_(?string uri) ⇒ ?string | |
findParam_(string uri, number startIndex, string keyEncoded, number hashOrEndIndex) ⇒ number Finds the next instance of a query parameter with the specified name. + +Does not instantiate any objects. | |
getComponentByIndex_(?goog.uri.utils.ComponentIndex componentIndex, string uri) ⇒ ?string Gets a URI component by index. + +It is preferred to use the getPathEncoded() variety of functions ahead, +since they are more readable. | |
getDomain(string uri) ⇒ ?string | |
getDomainEncoded(string uri) ⇒ ?string | |
getEffectiveScheme(string uri) ⇒ string Gets the effective scheme for the URL. If the URL is relative then the +scheme is derived from the page's location. | |
getFragment(string uri) ⇒ ?string | |
getFragmentEncoded(string uri) ⇒ ?string | |
getHost(string uri) ⇒ string Extracts everything up to the port of the URI. | |
getParamValue(string uri, string keyEncoded) ⇒ ?string Gets the first value of a query parameter. | |
getParamValues(string uri, string keyEncoded) ⇒ !Array Gets all values of a query parameter. | |
getPath(string uri) ⇒ ?string | |
getPathAndAfter(string uri) ⇒ string Extracts the path of the URL and everything after. | |
getPathEncoded(string uri) ⇒ ?string | |
getPort(string uri) ⇒ ?number | |
getQueryData(string uri) ⇒ ?string | |
getScheme(string uri) ⇒ ?string | |
getUserInfo(string uri) ⇒ ?string | |
getUserInfoEncoded(string uri) ⇒ ?string | |
hasParam(string uri, string keyEncoded) ⇒ boolean Determines if the URI contains a specific key. + +Performs no object instantiations. | |
haveSameDomain(string uri1, string uri2) ⇒ boolean Ensures that two URI's have the exact same domain, scheme, and port. + +Unlike the version in goog.Uri, this checks protocol, and therefore is +suitable for checking against the browser's same-origin policy. | |
makeUnique(string uri) ⇒ string Sets the zx parameter of a URI to a random value. | |
removeFragment(string uri) ⇒ string Gets the URI with the fragment identifier removed. | |
removeParam(string uri, string keyEncoded) ⇒ string Removes all instances of a query parameter. | |
setFragmentEncoded(string uri, ?string fragment) ⇒ string | |
setParam(string uri, string keyEncoded, <Any Type> value) ⇒ string Replaces all existing definitions of a parameter with a single definition. + +Repeated calls to this can exhibit quadratic behavior due to the need to +find existing instances and reconstruct the string, though it should be +limited given the 2kb limit. Consider using appendParams to append multiple +parameters in bulk. | |
split(string uri) ⇒ !Array Splits a URI into its component parts. + +Each component can be accessed via the component indices; for example: + +goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA]; + |
Function Summary | |
binaryInsert(?Array array, <Any Type> value, ?Function= opt_compareFn) ⇒ boolean Inserts a value into a sorted array. The array is not modified if the +value is already present. | |
binaryRemove(?Array array, <Any Type> value, ?Function= opt_compareFn) ⇒ boolean Removes a value from a sorted array. | |
binarySearch(?goog.array.ArrayLike arr, <Any Type> target, ?Function= opt_compareFn) ⇒ number Searches the specified array for the specified target using the binary
+search algorithm. If no opt_compareFn is specified, elements are compared
+using | |
binarySearch_(?goog.array.ArrayLike arr, ?Function compareFn, boolean isEvaluator, <Any Type> opt_target, ?Object= opt_selfObj) ⇒ number Implementation of a binary search algorithm which knows how to use both +comparison functions and evaluators. If an evaluator is provided, will call +the evaluator with the given optional data object, conforming to the +interface defined in binarySelect. Otherwise, if a comparison function is +provided, will call the comparison function against the given data object. + +This implementation purposefully does not use goog.bind or goog.partial for +performance reasons. + +Runtime: O(log n) | |
binarySelect(?goog.array.ArrayLike arr, ?Function evaluator, ?Object= opt_obj) ⇒ number Selects an index in the specified array using the binary search algorithm. +The evaluator receives an element and determines whether the desired index +is before, at, or after it. The evaluator must be consistent (formally, +goog.array.map(goog.array.map(arr, evaluator, opt_obj), goog.math.sign) +must be monotonically non-increasing). + +Runtime: O(log n) | |
bucket(?Array array, ?Function sorter) ⇒ !Object Splits an array into disjoint buckets according to a splitting function. | |
clear(?goog.array.ArrayLike arr) Clears the array. | |
clone(?goog.array.ArrayLike arr) ⇒ !Array Does a shallow copy of an array. | |
compare(?goog.array.ArrayLike arr1, ?goog.array.ArrayLike arr2, ?Function= opt_equalsFn) ⇒ boolean | |
compare3(!goog.array.ArrayLike arr1, !goog.array.ArrayLike arr2, function (*, *): number= opt_compareFn) ⇒ number 3-way array compare function. | |
concat(<Any Type> var_args) ⇒ !Array Returns a new array that is the result of joining the arguments. If arrays +are passed then their items are added, however, if non-arrays are passed they +will be added to the return array as is. + +Note that ArrayLike objects will be added as is, rather than having their +items added. + +goog.array.concat([1, 2], [3, 4]) -> [1, 2, 3, 4] +goog.array.concat(0, [1, 2]) -> [0, 1, 2] +goog.array.concat([1, 2], null) -> [1, 2, null] + +There is bug in all current versions of IE (6, 7 and 8) where arrays created +in an iframe become corrupted soon (not immediately) after the iframe is +destroyed. This is common if loading data via goog.net.IframeIo, for example. +This corruption only affects the concat method which will start throwing +Catastrophic Errors (#-2147418113). + +See http://endoflow.com/scratch/corrupted-arrays.html for a test case. + +Internally goog.array should use this, so that all methods will continue to +work on these broken array objects. | |
contains(?goog.array.ArrayLike arr, <Any Type> obj) ⇒ boolean Whether the array contains the given object. | |
defaultCompare(<Any Type> a, <Any Type> b) ⇒ number Compares its two arguments for order, using the built in < and > +operators. | |
defaultCompareEquality(<Any Type> a, <Any Type> b) ⇒ boolean Compares its two arguments for equality, using the built in === operator. | |
equals(?goog.array.ArrayLike arr1, ?goog.array.ArrayLike arr2, ?Function= opt_equalsFn) ⇒ boolean Compares two arrays for equality. Two arrays are considered equal if they +have the same length and their corresponding elements are equal according to +the comparison function. | |
extend(?Array arr1, <Any Type> var_args) Extends an array with another array, element, or "array like" object. +This function operates 'in-place', it does not create a new Array. + +Example: +var a = []; +goog.array.extend(a, [0, 1]); +a; // [0, 1] +goog.array.extend(a, 2); +a; // [0, 1, 2] | |
find(?goog.array.ArrayLike arr, ?Function f, ?Object= opt_obj) ⇒ <Any Type> Search an array for the first element that satisfies a given condition and +return that element. | |
findIndex(?goog.array.ArrayLike arr, ?Function f, ?Object= opt_obj) ⇒ number Search an array for the first element that satisfies a given condition and +return its index. | |
findIndexRight(?goog.array.ArrayLike arr, ?Function f, ?Object= opt_obj) ⇒ number Search an array (in reverse order) for the last element that satisfies a +given condition and return its index. | |
findRight(?goog.array.ArrayLike arr, ?Function f, ?Object= opt_obj) ⇒ <Any Type> Search an array (in reverse order) for the last element that satisfies a +given condition and return that element. | |
flatten(<Any Type> var_args) ⇒ !Array Returns an array consisting of every argument with all arrays +expanded in-place recursively. | |
forEachRight(?goog.array.ArrayLike arr, ?Function f, ?Object= opt_obj) Calls a function for each element in an array, starting from the last +element rather than the first. | |
insert(?Array arr, <Any Type> obj) Pushes an item into an array, if it's not already in the array. | |
insertArrayAt(?goog.array.ArrayLike arr, ?goog.array.ArrayLike elementsToAdd, number= opt_i) Inserts at the given index of the array, all elements of another array. | |
insertAt(?goog.array.ArrayLike arr, <Any Type> obj, number= opt_i) Inserts an object at the given index of the array. | |
insertBefore(?Array arr, <Any Type> obj, <Any Type> opt_obj2) Inserts an object into an array before a specified object. | |
isEmpty(?goog.array.ArrayLike arr) ⇒ boolean Whether the array is empty. | |
isSorted(!Array arr, ?Function= opt_compareFn, boolean= opt_strict) ⇒ boolean Tells if the array is sorted. | |
peek(?goog.array.ArrayLike array) ⇒ <Any Type> Returns the last element in an array without removing it. | |
reduce(?goog.array.ArrayLike arr, ?Function f, <Any Type> val, ?Object= opt_obj) ⇒ <Any Type> Passes every element of an array into a function and accumulates the result. + +See {@link http://tinyurl.com/developer-mozilla-org-array-reduce} + +For example: +var a = [1, 2, 3, 4]; +goog.array.reduce(a, function(r, v, i, arr) {return r + v;}, 0); +returns 10 | |
reduceRight(?goog.array.ArrayLike arr, ?Function f, <Any Type> val, ?Object= opt_obj) ⇒ <Any Type> Passes every element of an array into a function and accumulates the result, +starting from the last element and working towards the first. + +See {@link http://tinyurl.com/developer-mozilla-org-array-reduceright} + +For example: +var a = ['a', 'b', 'c']; +goog.array.reduceRight(a, function(r, v, i, arr) {return r + v;}, ''); +returns 'cba' | |
remove(?goog.array.ArrayLike arr, <Any Type> obj) ⇒ boolean Removes the first occurrence of a particular value from an array. | |
removeAt(?goog.array.ArrayLike arr, number i) ⇒ boolean Removes from an array the element at index i | |
removeDuplicates(?goog.array.ArrayLike arr, ?Array= opt_rv) Removes all duplicates from an array (retaining only the first +occurrence of each array element). This function modifies the +array in place and doesn't change the order of the non-duplicate items. + +For objects, duplicates are identified as having the same unique ID as +defined by {@link goog.getUid}. + +Runtime: N, +Worstcase space: 2N (no dupes) | |
removeIf(?goog.array.ArrayLike arr, ?Function f, ?Object= opt_obj) ⇒ boolean Removes the first value that satisfies the given condition. | |
repeat(<Any Type> value, number n) ⇒ !Array Returns an array consisting of the given value repeated N times. | |
rotate(!Array array, number n) ⇒ !Array Rotates an array in-place. After calling this method, the element at +index i will be the element previously at index (i - n) % +array.length, for all values of i between 0 and array.length - 1, +inclusive. + +For example, suppose list comprises [t, a, n, k, s]. After invoking +rotate(array, 1) (or rotate(array, -4)), array will comprise [s, t, a, n, k]. | |
shuffle(!Array arr, ?Function= opt_randFn) Shuffles the values in the specified array using the Fisher-Yates in-place +shuffle (also known as the Knuth Shuffle). By default, calls Math.random() +and so resets the state of that random number generator. Similarly, may reset +the state of the any other specified random number generator. + +Runtime: O(n) | |
slice(?goog.array.ArrayLike arr, number start, number= opt_end) ⇒ !Array Returns a new array from a segment of an array. This is a generic version of +Array slice. This means that it might work on other objects similar to +arrays, such as the arguments object. | |
sort(?Array arr, ?Function= opt_compareFn) Sorts the specified array into ascending order. If no opt_compareFn is
+specified, elements are compared using
+ | |
sortObjectsByKey(?Array.<(Object|null)> arr, string key, ?Function= opt_compareFn) Sorts an array of objects by the specified object key and compare
+function. If no compare function is provided, the key values are
+compared in ascending order using | |
splice(?goog.array.ArrayLike arr, (number|undefined) index, number howMany, <Any Type> var_args) ⇒ !Array Adds or removes elements from an array. This is a generic version of Array +splice. This means that it might work on other objects similar to arrays, +such as the arguments object. | |
stableSort(?Array arr, function (*, *): number= opt_compareFn) Sorts the specified array into ascending order in a stable way. If no
+opt_compareFn is specified, elements are compared using
+ | |
toArray(?goog.array.ArrayLike object) ⇒ !Array Converts an object to an array. | |
zip((goog.array.ArrayLike|undefined) var_args) ⇒ !Array Creates a new array for which the element at position i is an array of the +ith element of the provided arrays. The returned array will only be as long +as the shortest array provided; additional values are ignored. For example, +the result of zipping [1, 2] and [3, 4, 5] is [[1,3], [2, 4]]. + +This is similar to the zip() function in Python. See {@link +http://docs.python.org/library/functions.html#zip} |
Function Summary | |
assert(<Any Type> condition, string= opt_message, <Any Type> var_args) ⇒ <Any Type> Checks if the condition evaluates to true if goog.asserts.ENABLE_ASSERTS is +true. | |
assertArray(<Any Type> value, string= opt_message, <Any Type> var_args) ⇒ !Array Checks if the value is an Array if goog.asserts.ENABLE_ASSERTS is true. | |
assertBoolean(<Any Type> value, string= opt_message, <Any Type> var_args) ⇒ boolean Checks if the value is a boolean if goog.asserts.ENABLE_ASSERTS is true. | |
assertFunction(<Any Type> value, string= opt_message, <Any Type> var_args) ⇒ !Function Checks if the value is a function if goog.asserts.ENABLE_ASSERTS is true. | |
assertInstanceof(<Any Type> value, !Function type, string= opt_message, <Any Type> var_args) Checks if the value is an instance of the user-defined type if +goog.asserts.ENABLE_ASSERTS is true. | |
assertNumber(<Any Type> value, string= opt_message, <Any Type> var_args) ⇒ number Checks if the value is a number if goog.asserts.ENABLE_ASSERTS is true. | |
assertObject(<Any Type> value, string= opt_message, <Any Type> var_args) ⇒ !Object Checks if the value is an Object if goog.asserts.ENABLE_ASSERTS is true. | |
assertString(<Any Type> value, string= opt_message, <Any Type> var_args) ⇒ string Checks if the value is a string if goog.asserts.ENABLE_ASSERTS is true. | |
doAssertFailure_(string defaultMessage, ?Array.<*> defaultArgs, (string|undefined) givenMessage, ?Array.<*> givenArgs) Throws an exception with the given message and "Assertion failed" prefixed +onto it. | |
fail(string= opt_message, <Any Type> var_args) Fails if goog.asserts.ENABLE_ASSERTS is true. This function is useful in case +when we want to add a check in the unreachable area like switch-case +statement: + + +switch(type) { +case FOO: doSomething(); break; +case BAR: doSomethingElse(); break; +default: goog.assert.fail('Unrecognized type: ' + type); +// We have only 2 types - "default:" section is unreachable code. +} + |
Error object for failed assertions.
extends goog.debug.Error \ No newline at end of file diff --git a/docs/goog/debug.html b/docs/goog/debug.html new file mode 100644 index 0000000..a12a84e --- /dev/null +++ b/docs/goog/debug.html @@ -0,0 +1,12 @@ +Function Summary | |
catchErrors(function ((Object|null)): ? logFunc, boolean= opt_cancel, ?Object= opt_target) Catches onerror events fired by windows and similar objects. | |
deepExpose(<Any Type> obj, boolean= opt_showFn) ⇒ string Creates a string representing a given primitive or object, and for an +object, all its properties and nested objects. WARNING: If an object is +given, it and all its nested objects will be modified. To detect reference +cycles, this method identifies objects using goog.getUid() which mutates the +object. | |
enhanceError((Error|null|string) err, string= opt_message) ⇒ ?Error Converts an object to an Error if it's a String, +adds a stacktrace if there isn't one, +and optionally adds an extra message. | |
expose((Object|null|undefined) obj, boolean= opt_showFn) ⇒ string Creates a string representing an object and all its properties. | |
exposeArray(?Array arr) ⇒ string Recursively outputs a nested array as a string. | |
exposeException(?Object err, ?Function= opt_fn) ⇒ string Exposes an exception that has been caught by a try...catch and outputs the +error with a stack trace. | |
getFunctionName(?Function fn) ⇒ string Gets a function name | |
getStacktrace(?Function= opt_fn) ⇒ string Gets the current stack trace, either starting from the caller or starting +from a specified function that's currently on the call stack. | |
getStacktraceHelper_(?Function fn, ?Array visited) ⇒ string Private helper for getStacktrace(). | |
getStacktraceSimple(number= opt_depth) ⇒ string Gets the current stack trace. Simple and iterative - doesn't worry about +catching circular references or getting the args. | |
makeWhitespaceVisible(string string) ⇒ string Makes whitespace visible by replacing it with printable characters. +This is useful in finding diffrences between the expected and the actual +output strings of a testcase. | |
normalizeErrorObject(?Object err) ⇒ ?Object Normalizes the error/exception object between browsers. | |
setFunctionResolver(function ((Function|null)): string resolver) Set a custom function name resolver. |
Base class for custom error objects.
extends Error \ No newline at end of file diff --git a/docs/goog/debug/LogBuffer.html b/docs/goog/debug/LogBuffer.html new file mode 100644 index 0000000..9936b4d --- /dev/null +++ b/docs/goog/debug/LogBuffer.html @@ -0,0 +1,2 @@ +Creates the log buffer.
Instance Method Summary | |
addRecord(?goog.debug.Logger.Level level, string msg, string loggerName) ⇒ !goog.debug.LogRecord Adds a log record to the buffer, possibly overwriting the oldest record. | |
clear() Removes all buffered log records. | |
forEachRecord(function (goog.debug.LogRecord): ? func) Calls the given function for each buffered log record, starting with the +oldest one. |
Static Method Summary | |
getInstance() ⇒ !goog.debug.LogBuffer A static method that always returns the same instance of LogBuffer. | |
isBufferingEnabled() ⇒ boolean |
LogRecord objects are used to pass logging requests between +the logging framework and individual log Handlers.
Instance Method Summary | |
getException() ⇒ ?Object Get the exception that is part of the log record. | |
getExceptionText() ⇒ ?string Get the exception text that is part of the log record. | |
getLevel() ⇒ ?goog.debug.Logger.Level Get the logging message level, for example Level.SEVERE. | |
getLoggerName() ⇒ string Get the source Logger's name. | |
getMessage() ⇒ string Get the "raw" log message, before localization or formatting. | |
getMillis() ⇒ number Get event time in milliseconds since 1970. | |
getSequenceNumber() ⇒ number Get the sequence number. + +Sequence numbers are normally assigned in the LogRecord +constructor, which assigns unique sequence numbers to +each new LogRecord in increasing order. | |
reset(?goog.debug.Logger.Level level, string msg, string loggerName, number= opt_time, number= opt_sequenceNumber) Sets all fields of the log record. | |
setException(?Object exception) Set the exception that is part of the log record. | |
setExceptionText(string text) Set the exception text that is part of the log record. | |
setLevel(?goog.debug.Logger.Level level) Set the logging message level, for example Level.SEVERE. | |
setLoggerName(string loggerName) Get the source Logger's name. | |
setMessage(string msg) Set the "raw" log message, before localization or formatting. | |
setMillis(number time) Set event time in milliseconds since 1970. |
The Logger is an object used for logging debug messages. Loggers are +normally named, using a hierarchical dot-separated namespace. Logger names +can be arbitrary strings, but they should normally be based on the package +name or class name of the logged component, such as goog.net.BrowserChannel. + +The Logger object is loosely based on the java class +java.util.logging.Logger. It supports different levels of filtering for +different loggers. + +The logger object should never be instantiated by application code. It +should always use the goog.debug.Logger.getLogger function.
Instance Method Summary | |
addChild_(string name, ?goog.debug.Logger logger) Adds a child to this logger. This is used for setting up the logger tree. | |
addHandler(?Function handler) Adds a handler to the logger. This doesn't use the event system because +we want to be able to add logging to the event system. | |
callPublish_(?goog.debug.LogRecord logRecord) Calls the handlers for publish. | |
config(string msg, ?Error= opt_exception) Log a message at the Logger.Level.CONFIG level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
doLogRecord_(?goog.debug.LogRecord logRecord) Log a LogRecord. | |
fine(string msg, ?Error= opt_exception) Log a message at the Logger.Level.FINE level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
finer(string msg, ?Error= opt_exception) Log a message at the Logger.Level.FINER level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
finest(string msg, ?Error= opt_exception) Log a message at the Logger.Level.FINEST level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
getChildren() ⇒ !Object Returns the children of this logger as a map of the child name to the logger. | |
getEffectiveLevel() ⇒ ?goog.debug.Logger.Level Returns the effective level of the logger based on its ancestors' levels. | |
getLevel() ⇒ ?goog.debug.Logger.Level Gets the log level specifying which message levels will be logged by this +logger. Message levels lower than this value will be discarded. +The level value Level.OFF can be used to turn off logging. If the level +is null, it means that this node should inherit its level from its nearest +ancestor with a specific (non-null) level value. | |
getLogRecord(?goog.debug.Logger.Level level, string msg, ?Object= opt_exception) ⇒ !goog.debug.LogRecord Creates a new log record and adds the exception (if present) to it. | |
getName() ⇒ string Gets the name of this logger. | |
getParent() ⇒ ?goog.debug.Logger Returns the parent of this logger. | |
info(string msg, ?Error= opt_exception) Log a message at the Logger.Level.INFO level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
isLoggable(?goog.debug.Logger.Level level) ⇒ boolean Check if a message of the given level would actually be logged by this +logger. This check is based on the Loggers effective level, which may be +inherited from its parent. | |
log(?goog.debug.Logger.Level level, string msg, ?Object= opt_exception) Log a message. If the logger is currently enabled for the +given message level then the given message is forwarded to all the +registered output Handler objects. | |
logRecord(?goog.debug.LogRecord logRecord) Log a LogRecord. If the logger is currently enabled for the +given message level then the given message is forwarded to all the +registered output Handler objects. | |
removeHandler(?Function handler) ⇒ boolean Removes a handler from the logger. This doesn't use the event system because +we want to be able to add logging to the event system. | |
setLevel(?goog.debug.Logger.Level level) Set the log level specifying which message levels will be logged by this +logger. Message levels lower than this value will be discarded. +The level value Level.OFF can be used to turn off logging. If the new level +is null, it means that this node should inherit its level from its nearest +ancestor with a specific (non-null) level value. | |
setParent_(?goog.debug.Logger parent) Sets the parent of this logger. This is used for setting up the logger tree. | |
severe(string msg, ?Error= opt_exception) Log a message at the Logger.Level.SEVERE level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
shout(string msg, ?Error= opt_exception) Log a message at the Logger.Level.SHOUT level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. | |
warning(string msg, ?Error= opt_exception) Log a message at the Logger.Level.WARNING level. +If the logger is currently enabled for the given message level then the +given message is forwarded to all the registered output Handler objects. |
Static Method Summary | |
getLogger(string name) ⇒ !goog.debug.Logger Find or create a logger for a named subsystem. If a logger has already been +created with the given name it is returned. Otherwise a new logger is +created. If a new logger is created its log level will be configured based +on the LogManager configuration and it will configured to also send logging +output to its parent's handlers. It will be registered in the LogManager +global namespace. | |
logToProfilers(string msg) Logs a message to profiling tools, if available. +{@see http://code.google.com/webtoolkit/speedtracer/logging-api.html} +{@see http://msdn.microsoft.com/en-us/library/dd433074(VS.85).aspx} |
The Level class defines a set of standard logging levels that +can be used to control logging output. The logging Level objects +are ordered and are specified by ordered integers. Enabling logging +at a given level also enables logging at all higher levels. +
+Clients should normally use the predefined Level constants such +as Level.SEVERE. +
+The levels in descending order are: +
Instance Method Summary | |
toString() ⇒ string |
Static Method Summary | |
createPredefinedLevelsCache_() Creates the predefined levels cache and populates it. | |
getPredefinedLevel(string name) ⇒ ?goog.debug.Logger.Level Gets the predefined level with the given name. | |
getPredefinedLevelByValue(number value) ⇒ ?goog.debug.Logger.Level Gets the highest predefined level <= #value. |
Function Summary | |
monitorAll(!goog.debug.EntryPointMonitor monitor) Configures a monitor to wrap all entry points. + +Entry points that have already been registered are immediately wrapped by +the monitor. When an entry point is registered in the future, it will also +be wrapped by the monitor when it is registered. | |
register(function (Function): ? callback) Register an entry point with this module. + +The entry point will be instrumented when a monitor is passed to +goog.debug.entryPointRegistry.monitorAll. If this has already occurred, the +entry point is instrumented immediately. | |
unmonitorAllIfPossible(!goog.debug.EntryPointMonitor monitor) Try to unmonitor all the entry points that have already been registered. If +an entry point is registered in the future, it will not be wrapped by the +monitor when it is registered. Note that this may fail if the entry points +have additional wrapping. |
Function Summary | |
append(!Node parent, (goog.dom.Appendable|null|undefined) var_args) Appends a node with text or other nodes. | |
appendChild(?Node parent, ?Node child) Appends a child to a node. | |
append_(!Document doc, !Node parent, !Arguments args, number startIndex) Appends a node with text or other nodes. | |
canHaveChildren(?Node node) ⇒ boolean Determines if the given node can contain children, intended to be used for +HTML generation. + +IE natively supports node.canHaveChildren but has inconsistent behavior. +Prior to IE8 the base tag allows children and in IE9 all nodes return true +for canHaveChildren. + +In practice all non-IE browsers allow you to add children to any node, but +the behavior is inconsistent: + + +var a = document.createElement('br'); +a.appendChild(document.createTextNode('foo')); +a.appendChild(document.createTextNode('bar')); +console.log(a.childNodes.length); // 2 +console.log(a.innerHTML); // Chrome: "", IE9: "foobar", FF3.5: "foobar" ++ +TODO(user): Rename shouldAllowChildren() ? | |
canUseQuerySelector_((Document|Element|null) parent) ⇒ boolean Prefer the standardized (http://www.w3.org/TR/selectors-api/), native and +fast W3C Selectors API. However, the version of WebKit that shipped with +Safari 3.1 and Chrome has a bug where it will not correctly match mixed- +case class name selectors in quirks mode. | |
compareNodeOrder(?Node node1, ?Node node2) ⇒ number Compares the document order of two nodes, returning 0 if they are the same +node, a negative number if node1 is before node2, and a positive number if +node2 is before node1. Note that we compare the order the tags appear in the +document so in the tree text the B node is considered to be +before the I node. | |
compareParentsDescendantNodeIe_(?Node textNode, ?Node node) ⇒ number Utility function to compare the position of two nodes, when +{@code textNode}'s parent is an ancestor of {@code node}. If this entry +condition is not met, this function will attempt to reference a null object. | |
compareSiblingOrder_(?Node node1, ?Node node2) ⇒ number Utility function to compare the position of two nodes known to be non-equal +siblings. | |
contains(?Node parent, ?Node descendant) ⇒ boolean Whether a node contains another node. | |
createDom(string tagName, (Object|null|string=) opt_attributes, (NodeList|Object|null|string|undefined) var_args) ⇒ !Element Returns a dom node with a set of attributes. This function accepts varargs
+for subsequent nodes to be added. Subsequent nodes will be added to the
+first node as childNodes.
+
+So:
+ | |
createDom_(!Document doc, !Arguments args) ⇒ !Element Helper for {@code createDom}. | |
createElement(string name) ⇒ !Element Creates a new element. | |
createTable(number rows, number columns, boolean= opt_fillWithNbsp) ⇒ !Element Create a table. | |
createTable_(!Document doc, number rows, number columns, boolean fillWithNbsp) ⇒ !Element Create a table. | |
createTextNode(string content) ⇒ !Text Creates a new text node. | |
findCommonAncestor((Node|null|undefined) var_args) ⇒ ?Node Find the deepest common ancestor of the given nodes. | |
findNode(?Node root, function ((Node|null)): boolean p) ⇒ (Node|null|undefined) Finds the first descendant node that matches the filter function, using +a depth first search. This function offers the most general purpose way +of finding a matching element. You may also wish to consider +{@code goog.dom.query} which can express many matching criteria using +CSS selector expressions. These expressions often result in a more +compact representation of the desired result. | |
findNodes(?Node root, function ((Node|null)): boolean p) ⇒ ?Array Finds all the descendant nodes that match the filter function, using a +a depth first search. This function offers the most general-purpose way +of finding a set of matching elements. You may also wish to consider +{@code goog.dom.query} which can express many matching criteria using +CSS selector expressions. These expressions often result in a more +compact representation of the desired result. | |
findNodes_(?Node root, function ((Node|null)): boolean p, ?Array rv, boolean findOne) ⇒ boolean Finds the first or all the descendant nodes that match the filter function, +using a depth first search. | |
flattenElement(?Element element) ⇒ (Element|null|undefined) Flattens an element. That is, removes it and replace it with its children. +Does nothing if the element is not in the document. | |
getActiveElement(?Document doc) ⇒ ?Element Determines the active element in the given document. | |
getAncestor(?Node element, function ((Node|null)): boolean matcher, boolean= opt_includeNode, number= opt_maxSearchSteps) ⇒ ?Node Walks up the DOM hierarchy returning the first ancestor that passes the +matcher function. | |
getAncestorByClass(?Node element, ?string= opt_class) ⇒ ?Node Walks up the DOM hierarchy returning the first ancestor that has the passed +class name. If the passed element matches the specified criteria, the +element itself is returned. | |
getAncestorByTagNameAndClass(?Node element, ?string= opt_tag, ?string= opt_class) ⇒ ?Node Walks up the DOM hierarchy returning the first ancestor that has the passed +tag name and/or class name. If the passed element matches the specified +criteria, the element itself is returned. | |
getChildren(?Element element) ⇒ (Array|NodeList|null) Returns an array containing just the element children of the given element. | |
getCompatMode() ⇒ string Returns the compatMode of the document. | |
getDocument() ⇒ !Document Gets the document object being used by the dom library. | |
getDocumentHeight() ⇒ number Calculates the height of the document. | |
getDocumentHeight_(?Window win) ⇒ number Calculates the height of the document of the given window. + +Function code copied from the opensocial gadget api: +gadgets.window.adjustHeight(opt_height) | |
getDocumentScroll() ⇒ !goog.math.Coordinate Gets the document scroll distance as a coordinate object. | |
getDocumentScrollElement() ⇒ ?Element Gets the document scroll element. | |
getDocumentScrollElement_(!Document doc) ⇒ ?Element Helper for {@code getDocumentScrollElement}. | |
getDocumentScroll_(!Document doc) ⇒ !goog.math.Coordinate Helper for {@code getDocumentScroll}. | |
getDomHelper((Node|Window|null=) opt_element) ⇒ !goog.dom.DomHelper Gets the DomHelper object for the document where the element resides. | |
getElement((Element|null|string) element) ⇒ ?Element Alias for getElementById. If a DOM node is passed in then we just return +that. | |
getElementByClass(string className, (Document|Element|null=) opt_el) ⇒ ?Element Returns the first element with the provided className. | |
getElementsByClass(string className, (Document|Element|null=) opt_el) ⇒ {length: number} Returns an array of all the elements with the provided className. | |
getElementsByTagNameAndClass(?string= opt_tag, ?string= opt_class, (Document|Element|null=) opt_el) ⇒ {length: number} Looks up elements by both tag and class name, using browser native functions +({@code querySelectorAll}, {@code getElementsByTagName} or +{@code getElementsByClassName}) where possible. This function +is a useful, if limited, way of collecting a list of DOM elements +with certain characteristics. {@code goog.dom.query} offers a +more powerful and general solution which allows matching on CSS3 +selector expressions, but at increased cost in code size. If all you +need is particular tags belonging to a single class, this function +is fast and sleek. | |
getElementsByTagNameAndClass_(!Document doc, ?string= opt_tag, ?string= opt_class, (Document|Element|null=) opt_el) ⇒ {length: number} Helper for {@code getElementsByTagNameAndClass}. | |
getFirstElementChild(?Node node) ⇒ ?Element Returns the first child node that is an element. | |
getFrameContentDocument(?Element frame) ⇒ !Document Cross-browser function for getting the document element of a frame or iframe. | |
getFrameContentWindow((HTMLFrameElement|HTMLIFrameElement|null) frame) ⇒ ?Window Cross-browser function for getting the window of a frame or iframe. | |
getLastElementChild(?Node node) ⇒ ?Element Returns the last child node that is an element. | |
getNextElementNode_(?Node node, boolean forward) ⇒ ?Element Returns the first node that is an element in the specified direction, +starting with {@code node}. | |
getNextElementSibling(?Node node) ⇒ ?Element Returns the first next sibling that is an element. | |
getNextNode(?Node node) ⇒ ?Node Returns the next node in source order from the given node. | |
getNodeAtOffset(?Node parent, number offset, ?Object= opt_result) ⇒ ?Node Returns the node at a given offset in a parent node. If an object is +provided for the optional third parameter, the node and the remainder of the +offset will stored as properties of this object. | |
getNodeTextLength(?Node node) ⇒ number Returns the text length of the text contained in a node, without markup. This +is equivalent to the selection length if the node was selected, or the number +of cursor movements to traverse the node. Images & BRs take one space. New +lines are ignored. | |
getNodeTextOffset(?Node node, ?Node= opt_offsetParent) ⇒ number Returns the text offset of a node relative to one of its ancestors. The text +length is the same as the length calculated by goog.dom.getNodeTextLength. | |
getOuterHtml(?Element element) ⇒ string Gets the outerHTML of a node, which islike innerHTML, except that it +actually contains the HTML of the node itself. | |
getOwnerDocument((Node|Window|null) node) ⇒ !Document Returns the owner document for a node. | |
getPageScroll(?Window= opt_window) ⇒ !goog.math.Coordinate Gets the page scroll distance as a coordinate object. | |
getParentElement(?Element element) ⇒ ?Element Returns an element's parent, if it's an Element. | |
getPreviousElementSibling(?Node node) ⇒ ?Element Returns the first previous sibling that is an element. | |
getPreviousNode(?Node node) ⇒ ?Node Returns the previous node in source order from the given node. | |
getRawTextContent(?Node node) ⇒ string Returns the text content of the current node, without markup. + +Unlike {@code getTextContent} this method does not collapse whitespaces +or normalize lines breaks. | |
getTextContent(?Node node) ⇒ string Returns the text content of the current node, without markup and invisible +symbols. New lines are stripped and whitespace is collapsed, +such that each character would be visible. + +In browsers that support it, innerText is used. Other browsers attempt to +simulate it via node traversal. Line breaks are canonicalized in IE. | |
getTextContent_(?Node node, ?Array buf, boolean normalizeWhitespace) Recursive support function for text content retrieval. | |
getViewportSize(?Window= opt_window) ⇒ !goog.math.Size Gets the dimensions of the viewport. + +Gecko Standards mode: +docEl.clientWidth Width of viewport excluding scrollbar. +win.innerWidth Width of viewport including scrollbar. +body.clientWidth Width of body element. + +docEl.clientHeight Height of viewport excluding scrollbar. +win.innerHeight Height of viewport including scrollbar. +body.clientHeight Height of document. + +Gecko Backwards compatible mode: +docEl.clientWidth Width of viewport excluding scrollbar. +win.innerWidth Width of viewport including scrollbar. +body.clientWidth Width of viewport excluding scrollbar. + +docEl.clientHeight Height of document. +win.innerHeight Height of viewport including scrollbar. +body.clientHeight Height of viewport excluding scrollbar. + +IE6/7 Standards mode: +docEl.clientWidth Width of viewport excluding scrollbar. +win.innerWidth Undefined. +body.clientWidth Width of body element. + +docEl.clientHeight Height of viewport excluding scrollbar. +win.innerHeight Undefined. +body.clientHeight Height of document element. + +IE5 + IE6/7 Backwards compatible mode: +docEl.clientWidth 0. +win.innerWidth Undefined. +body.clientWidth Width of viewport excluding scrollbar. + +docEl.clientHeight 0. +win.innerHeight Undefined. +body.clientHeight Height of viewport excluding scrollbar. + +Opera 9 Standards and backwards compatible mode: +docEl.clientWidth Width of viewport excluding scrollbar. +win.innerWidth Width of viewport including scrollbar. +body.clientWidth Width of viewport excluding scrollbar. + +docEl.clientHeight Height of document. +win.innerHeight Height of viewport including scrollbar. +body.clientHeight Height of viewport excluding scrollbar. + +WebKit: +Safari 2 +docEl.clientHeight Same as scrollHeight. +docEl.clientWidth Same as innerWidth. +win.innerWidth Width of viewport excluding scrollbar. +win.innerHeight Height of the viewport including scrollbar. +frame.innerHeight Height of the viewport exluding scrollbar. + +Safari 3 (tested in 522) + +docEl.clientWidth Width of viewport excluding scrollbar. +docEl.clientHeight Height of viewport excluding scrollbar in strict mode. +body.clientHeight Height of viewport excluding scrollbar in quirks mode. | |
getViewportSize_(?Window win) ⇒ !goog.math.Size Helper for {@code getViewportSize}. | |
getWindow(?Document= opt_doc) ⇒ !Window Gets the window object associated with the given document. | |
getWindow_(!Document doc) ⇒ !Window Helper for {@code getWindow}. | |
htmlToDocumentFragment(string htmlString) ⇒ !Node Converts an HTML string into a document fragment. | |
htmlToDocumentFragment_(!Document doc, string htmlString) ⇒ !Node Helper for {@code htmlToDocumentFragment}. | |
insertChildAt(?Element parent, ?Node child, number index) Insert a child at a given index. If index is larger than the number of child +nodes that the parent currently has, the node is inserted as the last child +node. | |
insertSiblingAfter(?Node newNode, ?Node refNode) Inserts a new node after an existing reference node (i.e. as the next +sibling). If the reference node has no parent, then does nothing. | |
insertSiblingBefore(?Node newNode, ?Node refNode) Inserts a new node before an existing reference node (i.e. as the previous +sibling). If the reference node has no parent, then does nothing. | |
isCss1CompatMode() ⇒ boolean Returns true if the browser is in "CSS1-compatible" (standards-compliant) +mode, false otherwise. | |
isCss1CompatMode_(?Document doc) ⇒ boolean Returns true if the browser is in "CSS1-compatible" (standards-compliant) +mode, false otherwise. | |
isElement(<Any Type> obj) ⇒ boolean Whether the object looks like an Element. | |
isFocusableTabIndex(?Element element) ⇒ boolean Returns true if the element has a tab index that allows it to receive +keyboard focus (tabIndex >= 0), false otherwise. Note that form elements +natively support keyboard focus, even if they have no tab index. | |
isNodeLike(<Any Type> obj) ⇒ boolean Whether the object looks like a DOM node. | |
isNodeList(?Object val) ⇒ boolean Returns true if the object is a {@code NodeList}. To qualify as a NodeList, +the object must have a numeric length property and an item function (which +has type 'string' on IE for some reason). | |
isWindow(<Any Type> obj) ⇒ boolean Returns true if the specified value is a Window object. This includes the +global window for HTML pages, and iframe windows. | |
removeChildren(?Node node) Removes all the child nodes on a DOM node. | |
removeNode(?Node node) ⇒ ?Node Removes a node from its parent. | |
replaceNode(?Node newNode, ?Node oldNode) Replaces a node in the DOM tree. Will do nothing if {@code oldNode} has no +parent. | |
setFocusableTabIndex(?Element element, boolean enable) Enables or disables keyboard focus support on the element via its tab index. +Only elements for which {@link goog.dom.isFocusableTabIndex} returns true +(or elements that natively support keyboard focus, like form elements) can +receive keyboard focus. See http://go/tabindex for more info. | |
setProperties(?Element element, ?Object properties) Sets multiple properties on a node. | |
setTextContent(?Element element, string text) Cross-browser function for setting the text content of an element. |
Create an instance of a DOM helper with a new document object.
Instance Method Summary | |
createDom(string tagName, (Object|null|string=) opt_attributes, (goog.dom.Appendable|null|undefined) var_args) ⇒ !Element Returns a dom node with a set of attributes. This function accepts varargs
+for subsequent nodes to be added. Subsequent nodes will be added to the
+first node as childNodes.
+
+So:
+ | |
createElement(string name) ⇒ !Element Creates a new element. | |
createTable(number rows, number columns, boolean= opt_fillWithNbsp) ⇒ !Element Create a table. | |
createTextNode(string content) ⇒ !Text Creates a new text node. | |
getCompatMode() ⇒ string Returns the compatMode of the document. | |
getDocument() ⇒ !Document Gets the document object being used by the dom library. | |
getDocumentHeight() ⇒ number Calculates the height of the document. | |
getDocumentScroll() ⇒ !goog.math.Coordinate Gets the document scroll distance as a coordinate object. | |
getDocumentScrollElement() ⇒ ?Element Gets the document scroll element. | |
getElement((Element|null|string) element) ⇒ ?Element Alias for {@code getElementById}. If a DOM node is passed in then we just +return that. | |
getElementByClass(string className, (Document|Element|null=) opt_el) ⇒ ?Element Returns the first element we find matching the provided class name. | |
getElementsByClass(string className, (Document|Element|null=) opt_el) ⇒ {length: number} Returns an array of all the elements with the provided className. | |
getElementsByTagNameAndClass(?string= opt_tag, ?string= opt_class, (Document|Element|null=) opt_el) ⇒ {length: number} Looks up elements by both tag and class name, using browser native functions +({@code querySelectorAll}, {@code getElementsByTagName} or +{@code getElementsByClassName}) where possible. The returned array is a live +NodeList or a static list depending on the code path taken. | |
getViewportSize(?Window= opt_window) ⇒ !goog.math.Size Gets the dimensions of the viewport. | |
getWindow() ⇒ !Window Gets the window object associated with the document. | |
htmlToDocumentFragment(string htmlString) ⇒ !Node Converts an HTML string into a node or a document fragment. A single Node +is used if the {@code htmlString} only generates a single node. If the +{@code htmlString} generates multiple nodes then these are put inside a +{@code DocumentFragment}. | |
isCss1CompatMode() ⇒ boolean Returns true if the browser is in "CSS1-compatible" (standards-compliant) +mode, false otherwise. | |
setDocument(!Document document) Sets the document object. |
Function Summary | |
add(?Node element, (string|undefined) var_args) ⇒ boolean Adds a class or classes to an element. Does not add multiples of class names. | |
addRemove(?Node element, (Array.<string>|null|string) classesToRemove, (Array.<string>|null|string) classesToAdd) Adds zero or more classes to an element and removes zero or more as a single +operation. Unlike calling {@link goog.dom.classes.add} and +{@link goog.dom.classes.remove} separately, this is more efficient as it only +parses the class property once. + +If a class is in both the remove and add lists, it will be added. Thus, +you can use this instead of {@link goog.dom.classes.swap} when you have +more than two class names that you want to swap. | |
add_(?Array.<string> classes, ?Array.<string> args) ⇒ boolean Helper method for {@link goog.dom.classes.add} and +{@link goog.dom.classes.addRemove}. Adds one or more classes to the supplied +classes array. | |
enable(?Node element, string className, boolean enabled) Adds or removes a class depending on the enabled argument. | |
get(?Node element) ⇒ ?Array Gets an array of class names on an element | |
has(?Node element, string className) ⇒ boolean Returns true if an element has a class. | |
remove(?Node element, (string|undefined) var_args) ⇒ boolean Removes a class or classes from an element. | |
remove_(?Array.<string> classes, ?Array.<string> args) ⇒ boolean Helper method for {@link goog.dom.classes.remove} and +{@link goog.dom.classes.addRemove}. Removes one or more classes from the +supplied classes array. | |
set(?Node element, string className) Sets the entire class name of an element. | |
swap(?Node element, string fromClass, string toClass) ⇒ boolean Switches a class on an element from one to another without disturbing other +classes. If the fromClass isn't removed, the toClass won't be added. | |
toggle(?Node element, string className) ⇒ boolean Removes a class if an element has it, and adds it the element doesn't have +it. Won't affect other classes on the node. |
Function Summary | |
cleanUp_(string type, boolean capture, number srcUid, ?Array listenerArray) Cleans up the listener array as well as the listener tree | |
dispatchEvent(?goog.events.EventTarget src, (Object|goog.events.Event|null|string) e) ⇒ boolean Dispatches an event (or event like object) and calls all listeners +listening for events of this type. The type of the event is decided by the +type property on the event object. + +If any of the listeners returns false OR calls preventDefault then this +function will return false. If one of the capture listeners calls +stopPropagation, then the bubble listeners won't fire. | |
expose(?Object e) ⇒ string Provides a nice string showing the normalized event objects public members | |
fireListener(?goog.events.Listener listener, ?Object eventObject) ⇒ boolean Fires a listener with a set of arguments | |
fireListeners(?Object obj, string type, boolean capture, ?Object eventObject) ⇒ boolean Fires an object's listeners of a particular type and phase | |
fireListeners_(?Object map, ?Object obj, string type, boolean capture, ?Object eventObject) ⇒ boolean Fires an object's listeners of a particular type and phase. | |
getListener((EventTarget|goog.events.EventTarget|null) src, ?string type, ?Object listener, boolean= opt_capt, ?Object= opt_handler) ⇒ ?goog.events.Listener Gets the goog.events.Listener for the event or null if no such listener is +in use. | |
getListeners(?Object obj, string type, boolean capture) ⇒ ?Array Gets the listeners for a given object, type and capture phase. | |
getListeners_(?Object obj, ?string type, boolean capture) ⇒ ?Array Gets the listeners for a given object, type and capture phase. | |
getOnString_(string type) ⇒ string Returns a string wth on prepended to the specified type. This is used for IE +which expects "on" to be prepended. This function caches the string in order +to avoid extra allocations in steady state. | |
getProxy() ⇒ ?Function Helper function for returning a proxy function. | |
getTotalListenerCount() ⇒ number Gets the total number of listeners currently in the system. | |
getUniqueId(string identifier) ⇒ string Creates a unique event id. | |
handleBrowserEvent_(string key, ?Event= opt_evt) ⇒ boolean Handles an event and dispatches it to the correct listeners. This +function is a proxy for the real listener the user specified. | |
hasListener((EventTarget|goog.events.EventTarget|null) obj, string= opt_type, boolean= opt_capture) ⇒ boolean Returns whether an event target has any active listeners matching the +specified signature. If either the type or capture parameters are +unspecified, the function will match on the remaining criteria. | |
isMarkedIeEvent_(?Event e) ⇒ boolean This is used to check if an IE event has already been handled by the Closure +system so we do not do the Closure pass twice for a bubbling event. | |
listen((EventTarget|goog.events.EventTarget|null) src, (Array.<string>|null|string) type, ?Object listener, boolean= opt_capt, ?Object= opt_handler) ⇒ ?number Adds an event listener for a specific event on a DOM Node or an object that +has implemented {@link goog.events.EventTarget}. A listener can only be +added once to an object and if it is added again the key for the listener +is returned. | |
listenOnce((EventTarget|goog.events.EventTarget|null) src, (Array.<string>|null|string) type, ?Object listener, boolean= opt_capt, ?Object= opt_handler) ⇒ ?number Adds an event listener for a specific event on a DomNode or an object that +has implemented {@link goog.events.EventTarget}. After the event has fired +the event listener is removed from the target. | |
listenWithWrapper((EventTarget|goog.events.EventTarget|null) src, ?goog.events.EventWrapper wrapper, ?Object listener, boolean= opt_capt, ?Object= opt_handler) Adds an event listener with a specific event wrapper on a DOM Node or an +object that has implemented {@link goog.events.EventTarget}. A listener can +only be added once to an object. | |
markIeEvent_(?Event e) This is used to mark the IE event object so we do not do the Closure pass +twice for a bubbling event. | |
protectBrowserEventEntryPoint(?goog.debug.ErrorHandler errorHandler) Installs exception protection for the browser event entry point using the +given error handler. | |
removeAll(?Object= opt_obj, string= opt_type, boolean= opt_capt) ⇒ number Removes all listeners from an object, if no object is specified it will +remove all listeners that have been registered. You can also optionally +remove listeners of a particular type or capture phase. | |
unlisten((EventTarget|goog.events.EventTarget|null) src, (Array.<string>|null|string) type, ?Object listener, boolean= opt_capt, ?Object= opt_handler) ⇒ ?boolean Removes an event listener which was added with listen(). | |
unlistenByKey(?number key) ⇒ boolean Removes an event listener which was added with listen() by the key +returned by listen(). | |
unlistenWithWrapper((EventTarget|goog.events.EventTarget|null) src, ?goog.events.EventWrapper wrapper, ?Object listener, boolean= opt_capt, ?Object= opt_handler) Removes an event listener which was added with listenWithWrapper(). |
Accepts a browser event object and creates a patched, cross browser event +object. +The content of this object will not be initialized if no event object is +provided. If this is the case, init() needs to be invoked separately.
extends goog.events.EventInstance Method Summary | |
disposeInternal() Deletes or nulls out any references to COM objects, DOM nodes, or other +disposable objects. Classes that extend {@code goog.Disposable} should +override this method. +Not reentrant. To avoid calling it twice, it must only be called from the +subclass' {@code disposeInternal} method. Everywhere else the public +{@code dispose} method must be used. +For example: + +mypackage.MyClass = function() { +goog.base(this); +// Constructor logic specific to MyClass. +... +}; +goog.inherits(mypackage.MyClass, goog.Disposable); + +mypackage.MyClass.prototype.disposeInternal = function() { +goog.base(this, 'disposeInternal'); +// Dispose logic specific to MyClass. +... +}; + | |
getBrowserEvent() ⇒ ?Event | |
init(?Event e, ?Node= opt_currentTarget) Accepts a browser event object and creates a patched, cross browser event +object. | |
isButton(?goog.events.BrowserEvent.MouseButton button) ⇒ boolean Tests to see which button was pressed during the event. This is really only +useful in IE and Gecko browsers. And in IE, it's only useful for +mousedown/mouseup events, because click only fires for the left mouse button. + +Safari 2 only reports the left button being clicked, and uses the value '1' +instead of 0. Opera only reports a mousedown event for the middle button, and +no mouse events for the right button. Opera has default behavior for left and +middle click that can only be overridden via a configuration setting. + +There's a nice table of this mess at http://www.unixpapa.com/js/mouse.html. | |
isMouseActionButton() ⇒ boolean Whether this has an "action"-producing mouse button. + +By definition, this includes left-click on windows/linux, and left-click +without the ctrl key on Macs. | |
preventDefault() Prevents the default action, for example a link redirecting to a url. | |
stopPropagation() Stops event propagation. |
A base class for event objects, so that they can support preventDefault and +stopPropagation.
extends goog.DisposableInstance Method Summary | |
disposeInternal() Deletes or nulls out any references to COM objects, DOM nodes, or other +disposable objects. Classes that extend {@code goog.Disposable} should +override this method. +Not reentrant. To avoid calling it twice, it must only be called from the +subclass' {@code disposeInternal} method. Everywhere else the public +{@code dispose} method must be used. +For example: + +mypackage.MyClass = function() { +goog.base(this); +// Constructor logic specific to MyClass. +... +}; +goog.inherits(mypackage.MyClass, goog.Disposable); + +mypackage.MyClass.prototype.disposeInternal = function() { +goog.base(this, 'disposeInternal'); +// Dispose logic specific to MyClass. +... +}; + | |
preventDefault() Prevents the default action, for example a link redirecting to a url. | |
stopPropagation() Stops event propagation. |
Static Method Summary | |
preventDefault(!goog.events.Event e) Prevents the default action. It is equivalent to +{@code e.preventDefault()}, but can be used as the callback argument of +{@link goog.events.listen} without declaring another function. | |
stopPropagation(!goog.events.Event e) Stops the propagation of the event. It is equivalent to +{@code e.stopPropagation()}, but can be used as the callback argument of +{@link goog.events.listen} without declaring another function. |
Super class for objects that want to easily manage a number of event +listeners. It allows a short cut to listen and also provides a quick way +to remove all events listeners belonging to this object.
extends goog.DisposableInstance Method Summary | |
disposeInternal() Disposes of this EventHandler and removes all listeners that it registered. | |
getListenerCount() ⇒ number | |
handleEvent(?goog.events.Event e) Default event handler | |
listen((EventTarget|goog.events.EventTarget|null) src, (Array.<string>|null|string) type, ?Object= opt_fn, boolean= opt_capture, ?Object= opt_handler) ⇒ ?goog.events.EventHandler Listen to an event on a DOM node or EventTarget. If the function is omitted +then the EventHandler's handleEvent method will be used. | |
listenOnce((EventTarget|goog.events.EventTarget|null) src, (Array.<string>|null|string) type, ?Object= opt_fn, boolean= opt_capture, ?Object= opt_handler) ⇒ ?goog.events.EventHandler Listen to an event on a DOM node or EventTarget. If the function is omitted +then the EventHandler's handleEvent method will be used. After the event has +fired the event listener is removed from the target. If an array of event +types is provided, each event type will be listened to once. | |
listenWithWrapper((EventTarget|goog.events.EventTarget|null) src, ?goog.events.EventWrapper wrapper, ?Object listener, boolean= opt_capt, ?Object= opt_handler) ⇒ ?goog.events.EventHandler Adds an event listener with a specific event wrapper on a DOM Node or an +object that has implemented {@link goog.events.EventTarget}. A listener can +only be added once to an object. | |
removeAll() Unlistens to all events. | |
unlisten((EventTarget|goog.events.EventTarget|null) src, (Array.<string>|null|string) type, ?Object= opt_fn, boolean= opt_capture, ?Object= opt_handler) ⇒ ?goog.events.EventHandler Unlistens on an event. | |
unlistenWithWrapper((EventTarget|goog.events.EventTarget|null) src, ?goog.events.EventWrapper wrapper, ?Object listener, boolean= opt_capt, ?Object= opt_handler) ⇒ ?goog.events.EventHandler Removes an event listener which was added with listenWithWrapper(). |
Inherit from this class to give your object the ability to dispatch events. +Note that this class provides event sending behaviour, not event +receiving behaviour: your object will be able to broadcast events, and other +objects will be able to listen for those events using goog.events.listen(). + +
The name "EventTarget" reflects the fact that this class implements the + +EventTarget interface as defined by W3C DOM 2/3, with a few differences: +
Unless propagation is stopped, an event dispatched by an EventTarget
+will bubble to the parent returned by getParentEventTarget
.
+To set the parent, call setParentEventTarget
or override
+getParentEventTarget
in a subclass. Subclasses that don't
+support changing the parent should override the setter to throw an error.
+
+
Example usage: +
+var source = new goog.events.EventTarget(); +function handleEvent(event) { +alert('Type: ' + e.type + '\nTarget: ' + e.target); +} +goog.events.listen(source, 'foo', handleEvent); +... +source.dispatchEvent({type: 'foo'}); // will call handleEvent +// or source.dispatchEvent('foo'); +... +goog.events.unlisten(source, 'foo', handleEvent); + +// You can also use the Listener interface: +var listener = { +handleEvent: function(event) { +... +} +}; +goog.events.listen(source, 'bar', listener); +extends goog.Disposable
Instance Method Summary | |
addEventListener(string type, ?Object handler, boolean= opt_capture, ?Object= opt_handlerScope) Adds an event listener to the event target. The same handler can only be +added once per the type. Even if you add the same handler multiple times +using the same type then it will only be called once when the event is +dispatched. + +Supported for legacy but use goog.events.listen(src, type, handler) instead. | |
dispatchEvent((Object|goog.events.Event|null|string) e) ⇒ boolean Dispatches an event (or event like object) and calls all listeners +listening for events of this type. The type of the event is decided by the +type property on the event object. + +If any of the listeners returns false OR calls preventDefault then this +function will return false. If one of the capture listeners calls +stopPropagation, then the bubble listeners won't fire. | |
disposeInternal() Unattach listeners from this object. Classes that extend EventTarget may +need to override this method in order to remove references to DOM Elements +and additional listeners, it should be something like this: + +MyClass.prototype.disposeInternal = function() { +MyClass.superClass_.disposeInternal.call(this); +// Dispose logic for MyClass +}; + | |
getParentEventTarget() ⇒ ?goog.events.EventTarget Returns the parent of this event target to use for bubbling. | |
removeEventListener(string type, ?Object handler, boolean= opt_capture, ?Object= opt_handlerScope) Removes an event listener from the event target. The handler must be the +same object as the one added. If the handler has not been added then +nothing is done. | |
setParentEventTarget(?goog.events.EventTarget parent) Sets the parent of this event target to use for bubbling. |
Simple class that stores information about a listener
Instance Method Summary | |
handleEvent(?Object eventObject) ⇒ boolean Calls the internal listener | |
init(?Object listener, ?Function proxy, ?Object src, string type, boolean capture, ?Object= opt_handler) Initializes the listener. |
Event object dispatched after the history state has changed.
extends goog.events.Event \ No newline at end of file diff --git a/docs/goog/history/Html5History.html b/docs/goog/history/Html5History.html new file mode 100644 index 0000000..7d2c6e1 --- /dev/null +++ b/docs/goog/history/Html5History.html @@ -0,0 +1,15 @@ +An implementation compatible with goog.History that uses the HTML5 +history APIs.
extends goog.events.EventTargetInstance Method Summary | |
disposeInternal() Unattach listeners from this object. Classes that extend EventTarget may +need to override this method in order to remove references to DOM Elements +and additional listeners, it should be something like this: + +MyClass.prototype.disposeInternal = function() { +MyClass.superClass_.disposeInternal.call(this); +// Dispose logic for MyClass +}; + | |
getPathPrefix() ⇒ string Gets the path prefix. | |
getToken() ⇒ string Returns the current token. | |
getUrl_(string token) ⇒ string Gets the URL to set when calling history.pushState | |
onHistoryEvent_(?goog.events.BrowserEvent e) Handles history events dispatched by the browser. | |
replaceToken(string token, string= opt_title) Replaces the current history state without affecting the rest of the history +stack. | |
setEnabled(boolean enable) Starts or stops the History. When enabled, the History object +will immediately fire an event for the current location. The caller can set +up event listeners between the call to the constructor and the call to +setEnabled. | |
setPathPrefix(string pathPrefix) Sets the path prefix to use if storing tokens in the path. The path +prefix should start and end with slash. | |
setToken(string token, string= opt_title) Sets the history state. | |
setUseFragment(boolean useFragment) Sets whether to use the fragment to store tokens. |
Static Method Summary | |
isSupported(?Window= opt_win) ⇒ boolean Returns whether Html5History is supported. |
Function Summary | |
chain((goog.iter.Iterator|null|undefined) var_args) ⇒ !goog.iter.Iterator Takes zero or more iterators and returns one iterator that will iterate over +them in the order chained. | |
cycle(!goog.iter.Iterable iterable) ⇒ !goog.iter.Iterator Create an iterator to cycle over the iterable's elements indefinitely. +For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ... | |
dropWhile(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) ⇒ !goog.iter.Iterator Builds a new iterator that iterates over the original, but skips elements as +long as a supplied function returns true. | |
equals(?goog.iter.Iterable iterable1, ?goog.iter.Iterable iterable2) ⇒ boolean Iterates over 2 iterators and returns true if they contain the same sequence +of elements and have the same length. | |
every(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) ⇒ boolean Goes through the values in the iterator. Calls f for each these and if any of +them returns false this returns false (without checking the rest). If all +return true this will return true. | |
filter(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) ⇒ !goog.iter.Iterator Calls a function for every element in the iterator, and if the function +returns true adds the element to a new iterator. | |
forEach(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) Calls a function for each element in the iterator with the element of the +iterator passed as argument. | |
join(?goog.iter.Iterable iterable, string deliminator) ⇒ string Joins the values in a iterator with a delimiter. | |
map(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) ⇒ !goog.iter.Iterator For every element in the iterator call a function and return a new iterator +with that value. | |
nextOrValue(?goog.iter.Iterable iterable, <Any Type> defaultValue) ⇒ <Any Type> Advances the iterator to the next position, returning the given default value +instead of throwing an exception if the iterator has no more entries. | |
product((goog.array.ArrayLike|undefined) var_args) ⇒ !goog.iter.Iterator Cartesian product of zero or more sets. Gives an iterator that gives every +combination of one element chosen from each set. For example, +([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]). | |
range(number startOrStop, number= opt_stop, number= opt_step) ⇒ !goog.iter.Iterator Creates a new iterator that returns the values in a range. This function +can take 1, 2 or 3 arguments: + +range(5) same as range(0, 5, 1) +range(2, 5) same as range(2, 5, 1) + | |
reduce(?goog.iter.Iterable iterable, ?Function f, <Any Type> val, ?Object= opt_obj) ⇒ <Any Type> Passes every element of an iterator into a function and accumulates the +result. | |
some(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) ⇒ boolean Goes through the values in the iterator. Calls f for each these and if any of +them returns true, this returns true (without checking the rest). If all +return false this will return false. | |
takeWhile(?goog.iter.Iterable iterable, ?Function f, ?Object= opt_obj) ⇒ !goog.iter.Iterator Builds a new iterator that iterates over the original, but only as long as a +supplied function returns true. | |
toArray(?goog.iter.Iterable iterable) ⇒ !Array Converts the iterator to an array | |
toIterator(?goog.iter.Iterable iterable) ⇒ !goog.iter.Iterator Returns an iterator that knows how to iterate over the values in the object. |
Class/interface for iterators. An iterator needs to implement a {@code next} +method and it needs to throw a {@code goog.iter.StopIteration} when the +iteration passes beyond the end. Iterators have no {@code hasNext} method. +It is recommended to always use the helper functions to iterate over the +iterator or in case you are only targeting JavaScript 1.7 for in loops.
Instance Method Summary | |
__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator Returns the {@code Iterator} object itself. This is used to implement +the iterator protocol in JavaScript 1.7 | |
next() ⇒ <Any Type> Returns the next value of the iteration. This will throw the object +{@see goog.iter#StopIteration} when the iteration passes the end. |
Function Summary | |
isValid_(string s) ⇒ boolean Tests if a string is an invalid JSON string. This only ensures that we are +not using any invalid characters | |
parse(<Any Type> s) ⇒ ?Object Parses a JSON string and returns the result. This throws an exception if +the string is an invalid JSON string. + +Note that this is very slow on large strings. If you trust the source of +the string then you should use unsafeParse instead. | |
serialize(<Any Type> object, ?goog.json.Replacer= opt_replacer) ⇒ string Serializes an object or a value to a JSON string. | |
unsafeParse(string s) ⇒ ?Object Parses a JSON string and returns the result. This uses eval so it is open +to security issues and it should only be used if you trust the source. |
Class that is used to serialize JSON objects to a string.
Instance Method Summary | |
serialize(<Any Type> object) ⇒ string Serializes an object or a value to a JSON string. | |
serializeArray_(?Array arr, ?Array sb) Serializes an array to a JSON string | |
serializeNumber_(number n, ?Array sb) Serializes a number to a JSON string | |
serializeObject_(?Object obj, ?Array sb) Serializes an object to a JSON string | |
serializeString_(string s, ?Array sb) Serializes a string to a JSON string | |
serialize_(<Any Type> object, ?Array sb) Serializes a generic value to a JSON string |
Class for representing a box. A box is specified as a top, right, bottom, +and left. A box is useful for representing margins and padding.
Instance Method Summary | |
clone() ⇒ !goog.math.Box Creates a copy of the box with the same dimensions. | |
contains((goog.math.Box|goog.math.Coordinate|null) other) ⇒ boolean Returns whether the box contains a coordinate or another box. | |
expand((goog.math.Box|null|number) top, number= opt_right, number= opt_bottom, number= opt_left) ⇒ !goog.math.Box Expands box with the given margins. | |
expandToInclude(?goog.math.Box box) Expand this box to include another box. +NOTE(user): This is used in code that needs to be very fast, please don't +add functionality to this function at the expense of speed (variable +arguments, accepting multiple argument types, etc). | |
toString() ⇒ string Returns a nice string representing the box. |
Static Method Summary | |
boundingBox((goog.math.Coordinate|null|undefined) var_args) ⇒ !goog.math.Box Creates a Box by bounding a collection of goog.math.Coordinate objects | |
contains(?goog.math.Box box, (goog.math.Box|goog.math.Coordinate|null) other) ⇒ boolean Returns whether a box contains a coordinate or another box. | |
distance(?goog.math.Box box, ?goog.math.Coordinate coord) ⇒ number Returns the distance between a coordinate and the nearest corner/side of a +box. Returns zero if the coordinate is inside the box. | |
equals(?goog.math.Box a, ?goog.math.Box b) ⇒ boolean Compares boxes for equality. | |
intersects(?goog.math.Box a, ?goog.math.Box b) ⇒ boolean Returns whether two boxes intersect. | |
intersectsWithPadding(?goog.math.Box a, ?goog.math.Box b, number padding) ⇒ boolean Returns whether two boxes would intersect with additional padding. |
Class for representing coordinates and positions.
Instance Method Summary | |
clone() ⇒ !goog.math.Coordinate Returns a new copy of the coordinate. | |
toString() ⇒ string Returns a nice string representing the coordinate. |
Static Method Summary | |
difference(!goog.math.Coordinate a, !goog.math.Coordinate b) ⇒ !goog.math.Coordinate Returns the difference between two coordinates as a new +goog.math.Coordinate. | |
distance(!goog.math.Coordinate a, !goog.math.Coordinate b) ⇒ number Returns the distance between two coordinates. | |
equals(?goog.math.Coordinate a, ?goog.math.Coordinate b) ⇒ boolean Compares coordinates for equality. | |
squaredDistance(!goog.math.Coordinate a, !goog.math.Coordinate b) ⇒ number Returns the squared distance between two coordinates. Squared distances can +be used for comparisons when the actual value is not required. + +Performance note: eliminating the square root is an optimization often used +in lower-level languages, but the speed difference is not nearly as +pronounced in JavaScript (only a few percent.) | |
sum(!goog.math.Coordinate a, !goog.math.Coordinate b) ⇒ !goog.math.Coordinate Returns the sum of two coordinates as a new goog.math.Coordinate. |
Class for representing rectangular regions.
Instance Method Summary | |
boundingRect(?goog.math.Rect rect) Expand this rectangle to also include the area of the given rectangle. | |
clone() ⇒ !goog.math.Rect Returns a new copy of the rectangle. | |
contains((goog.math.Coordinate|goog.math.Rect|null) another) ⇒ boolean Tests whether this rectangle entirely contains another rectangle or +coordinate. | |
difference(?goog.math.Rect rect) ⇒ !Array Computes the difference regions between this rectangle and {@code rect}. The +return value is an array of 0 to 4 rectangles defining the remaining regions +of this rectangle after the other has been subtracted. | |
getSize() ⇒ !goog.math.Size Returns the size of this rectangle. | |
intersection(?goog.math.Rect rect) ⇒ boolean Computes the intersection of this rectangle and the rectangle parameter. If +there is no intersection, returns false and leaves this rectangle as is. | |
intersects(?goog.math.Rect rect) ⇒ boolean Returns whether a rectangle intersects this rectangle. | |
toBox() ⇒ !goog.math.Box Returns a new Box object with the same position and dimensions as this +rectangle. | |
toString() ⇒ string Returns a nice string representing size and dimensions of rectangle. |
Static Method Summary | |
boundingRect(?goog.math.Rect a, ?goog.math.Rect b) ⇒ ?goog.math.Rect Returns a new rectangle which completely contains both input rectangles. | |
createFromBox(?goog.math.Box box) ⇒ !goog.math.Rect Creates a new Rect object with the same position and dimensions as a given +Box. Note that this is only the inverse of toBox if left/top are defined. | |
difference(?goog.math.Rect a, ?goog.math.Rect b) ⇒ !Array Computes the difference regions between two rectangles. The return value is +an array of 0 to 4 rectangles defining the remaining regions of the first +rectangle after the second has been subtracted. | |
equals(?goog.math.Rect a, ?goog.math.Rect b) ⇒ boolean Compares rectangles for equality. | |
intersection(?goog.math.Rect a, ?goog.math.Rect b) ⇒ ?goog.math.Rect Returns the intersection of two rectangles. Two rectangles intersect if they +touch at all, for example, two zero width and height rectangles would +intersect if they had the same top and left. | |
intersects(?goog.math.Rect a, ?goog.math.Rect b) ⇒ boolean Returns whether two rectangles intersect. Two rectangles intersect if they +touch at all, for example, two zero width and height rectangles would +intersect if they had the same top and left. |
Class for representing sizes consisting of a width and height. Undefined +width and height support is deprecated and results in compiler warning.
Instance Method Summary | |
area() ⇒ number | |
aspectRatio() ⇒ number | |
ceil() ⇒ !goog.math.Size Clamps the width and height parameters upward to integer values. | |
clone() ⇒ !goog.math.Size | |
fitsInside(!goog.math.Size target) ⇒ boolean | |
floor() ⇒ !goog.math.Size Clamps the width and height parameters downward to integer values. | |
getLongest() ⇒ number | |
getShortest() ⇒ number | |
isEmpty() ⇒ boolean | |
perimeter() ⇒ number | |
round() ⇒ !goog.math.Size Rounds the width and height parameters to integer values. | |
scale(number s) ⇒ !goog.math.Size Scales the size uniformly by a factor. | |
scaleToFit(!goog.math.Size target) ⇒ !goog.math.Size Uniformly scales the size to fit inside the dimensions of a given size. The +original aspect ratio will be preserved. + +This function assumes that both Sizes contain strictly positive dimensions. | |
toString() ⇒ string Returns a nice string representing size. |
Static Method Summary | |
equals(?goog.math.Size a, ?goog.math.Size b) ⇒ boolean Compares sizes for equality. |
Default factory to use when creating xhr objects. You probably shouldn't be +instantiating this directly, but rather using it via goog.net.XmlHttp.
extends goog.net.XmlHttpFactoryInstance Method Summary | |
createInstance() ⇒ (GearsHttpRequest|XMLHttpRequest) | |
getProgId_() ⇒ string Initialize the private state used by other functions. | |
internalGetOptions() ⇒ ?Object Override this method in subclasses to preserve the caching offered by +getOptions(). |
An xhr factory subclass which can be constructed using two factory methods. +This exists partly to allow the preservation of goog.net.XmlHttp.setFactory() +with an unchanged signature.
extends goog.net.XmlHttpFactoryInstance Method Summary | |
createInstance() ⇒ (GearsHttpRequest|XMLHttpRequest) | |
getOptions() ⇒ ?Object |
Basic class for handling XMLHttpRequests.
extends goog.events.EventTargetInstance Method Summary | |
abort(?goog.net.ErrorCode= opt_failureCode) Abort the current XMLHttpRequest | |
cleanUpXhr_(boolean= opt_fromDispose) Remove the listener to protect against leaks, and nullify the XMLHttpRequest +object. | |
createXhr() ⇒ (GearsHttpRequest|XMLHttpRequest|null) Creates a new XHR object. | |
dispatchErrors_() Dispatches COMPLETE and ERROR in case of an error. This ensures that we do +not dispatch multiple error events. | |
disposeInternal() Nullifies all callbacks to reduce risks of leaks. | |
error_(?goog.net.ErrorCode errorCode, ?Error err) Something errorred, so inactivate, fire error callback and clean up | |
formatMsg_(string msg) ⇒ string Adds the last method, status and URI to the message. This is used to add +this information to the logging calls. | |
getAllResponseHeaders() ⇒ string Gets the text of all the headers in the response. +Will only return correct result when called from the context of a callback +and the request has completed. | |
getLastError() ⇒ string Get the last error message | |
getLastErrorCode() ⇒ ?goog.net.ErrorCode Get the last error message | |
getLastUri() ⇒ string Get the last Uri that was requested | |
getReadyState() ⇒ ?goog.net.XmlHttp.ReadyState Get the readystate from the Xhr object +Will only return correct result when called from the context of a callback | |
getResponse() ⇒ <Any Type> Get the response as the type specificed by {@link #setResponseType}. At time +of writing, this is only directly supported in very recent versions of WebKit +(10.0.612.1 dev and later). If the field is not supported directly, we will +try to emulate it. + +Emulating the response means following the rules laid out at +http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-response-attribute. + +On browsers with no support for this (Chrome < 10, Firefox < 4, etc), only +response types of DEFAULT or TEXT may be used, and the response returned will +be the text response. + +On browsers with Mozilla's draft support for array buffers (Firefox 4, 5), +only response types of DEFAULT, TEXT, and ARRAY_BUFFER may be used, and the +response returned will be either the text response or the Mozilla +implementation of the array buffer response. + +On browsers will full support, any valid response type supported by the +browser may be used, and the response provided by the browser will be +returned. | |
getResponseHeader(string key) ⇒ (string|undefined) Get the value of the response-header with the given name from the Xhr object +Will only return correct result when called from the context of a callback +and the request has completed | |
getResponseJson(string= opt_xssiPrefix) ⇒ (Object|null|undefined) Get the response and evaluates it as JSON from the Xhr object +Will only return correct result when called from the context of a callback | |
getResponseText() ⇒ string Get the response text from the Xhr object +Will only return correct result when called from the context of a callback. | |
getResponseType() ⇒ ?goog.net.XhrIo.ResponseType Gets the desired type for the response. | |
getResponseXml() ⇒ ?Document Get the response XML from the Xhr object +Will only return correct result when called from the context of a callback. | |
getStatus() ⇒ number Get the status from the Xhr object +Will only return correct result when called from the context of a callback | |
getStatusText() ⇒ string Get the status text from the Xhr object +Will only return correct result when called from the context of a callback | |
getTimeoutInterval() ⇒ number Returns the number of milliseconds after which an incomplete request will be +aborted, or 0 if no timeout is set. | |
getWithCredentials() ⇒ boolean Gets whether a "credentialed" request is to be sent. | |
isActive() ⇒ boolean | |
isComplete() ⇒ boolean | |
isLastUriEffectiveSchemeHttp_() ⇒ boolean | |
isSuccess() ⇒ boolean | |
onReadyStateChangeEntryPoint_() Used to protect the onreadystatechange handler entry point. Necessary +as {#onReadyStateChange_} maybe called from within send or abort, this +method is only called when {#onReadyStateChange_} is called as an +entry point. +{@see #protectEntryPoints} | |
onReadyStateChangeHelper_() Helper for {@link #onReadyStateChange_}. This is used so that +entry point calls to {@link #onReadyStateChange_} can be routed through +{@link #onReadyStateChangeEntryPoint_}. | |
onReadyStateChange_() Internal handler for the XHR object's readystatechange event. This method +checks the status and the readystate and fires the correct callbacks. +If the request has ended, the handlers are cleaned up and the XHR object is +nullified. | |
send((goog.Uri|null|string) url, string= opt_method, (GearsBlob|null|string=) opt_content, (Object|goog.structs.Map|null=) opt_headers) Instance send that actually uses XMLHttpRequest to make a server call. | |
setResponseType(?goog.net.XhrIo.ResponseType type) Sets the desired type for the response. At time of writing, this is only +supported in very recent versions of WebKit (10.0.612.1 dev and later). + +If this is used, the response may only be accessed via {@link #getResponse}. | |
setTimeoutInterval(number ms) Sets the number of milliseconds after which an incomplete request will be +aborted and a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no +timeout is set. | |
setWithCredentials(boolean withCredentials) Sets whether a "credentialed" request that is aware of cookie and +authentication information should be made. This option is only supported by +browsers that support HTTP Access Control. As of this writing, this option +is not supported in IE. | |
timeout_() The request didn't complete after {@link goog.net.XhrIo#timeoutInterval_} +milliseconds; raises a {@link goog.net.EventType.TIMEOUT} event and aborts +the request. |
Static Method Summary | |
cleanup() Disposes all non-disposed instances of goog.net.XhrIo created by +{@link goog.net.XhrIo.send}. +{@link goog.net.XhrIo.send} cleans up the goog.net.XhrIo instance +it creates when the request completes or fails. However, if +the request never completes, then the goog.net.XhrIo is not disposed. +This can occur if the window is unloaded before the request completes. +We could have {@link goog.net.XhrIo.send} return the goog.net.XhrIo +it creates and make the client of {@link goog.net.XhrIo.send} be +responsible for disposing it in this case. However, this makes things +significantly more complicated for the client, and the whole point +of {@link goog.net.XhrIo.send} is that it's simple and easy to use. +Clients of {@link goog.net.XhrIo.send} should call +{@link goog.net.XhrIo.cleanup} when doing final +cleanup on window unload. | |
cleanupSend_(?goog.net.XhrIo XhrIo) Disposes of the specified goog.net.XhrIo created by +{@link goog.net.XhrIo.send} and removes it from +{@link goog.net.XhrIo.pendingStaticSendInstances_}. | |
protectEntryPoints(?goog.debug.ErrorHandler errorHandler) Installs exception protection for all entry point introduced by +goog.net.XhrIo instances which are not protected by +{@link goog.debug.ErrorHandler#protectWindowSetTimeout}, +{@link goog.debug.ErrorHandler#protectWindowSetInterval}, or +{@link goog.events.protectBrowserEventEntryPoint}. | |
send((goog.Uri|null|string) url, ?Function= opt_callback, string= opt_method, (GearsBlob|null|string=) opt_content, (Object|goog.structs.Map|null=) opt_headers, number= opt_timeoutInterval) Static send that creates a short lived instance of XhrIo to send the +request. |
A pool of XhrIo objects.
extends goog.structs.PriorityPoolInstance Method Summary | |
createObject() ⇒ ?goog.net.XhrIo Creates an instance of an XhrIo object to use in the pool. | |
disposeObject(?goog.net.XhrIo obj) Should be overridden to dispose of an object, default implementation is to +remove all its members which should render it useless. | |
objectCanBeReused(?goog.net.XhrIo obj) ⇒ boolean Determine if an object has become unusable and should not be used. |
A manager of an XhrIoPool.
extends goog.events.EventTargetInstance Method Summary | |
abort(string id, boolean= opt_force) Aborts the request associated with id. | |
addXhrListener_(?goog.net.XhrIo xhrIo, ?Function func, (Array.<string>|null|string=) opt_types) Adds a listener for XHR events on an XhrIo object. | |
disposeInternal() Unattach listeners from this object. Classes that extend EventTarget may +need to override this method in order to remove references to DOM Elements +and additional listeners, it should be something like this: + +MyClass.prototype.disposeInternal = function() { +MyClass.superClass_.disposeInternal.call(this); +// Dispose logic for MyClass +}; + | |
getOutstandingCount() ⇒ number Returns the number of reuqests either in flight, or waiting to be sent. | |
handleAbort_(string id, ?goog.net.XhrIo xhrIo) Handles the abort of an underlying XhrIo object. | |
handleAvailableXhr_(string id, ?goog.net.XhrIo xhrIo) Handles when an XhrIo object becomes available. Sets up the events, fires +the READY event, and starts the process to send the request. | |
handleComplete_(string id, ?goog.net.XhrIo xhrIo, ?goog.events.Event e) ⇒ ?Object Handles the complete of a request. Dispatches the COMPLETE event and sets the +the request as completed if the request has succeeded, or is done retrying. | |
handleError_(string id, ?goog.net.XhrIo xhrIo) Handles the error of a request. If the request has not reach its maximum +number of retries, then it lets the request retry naturally (will let the +request hit the READY state). Else, it dispatches the ERROR event. | |
handleEvent_(string id, ?goog.events.Event e) ⇒ ?Object Handles all events fired by the XhrIo object for a given request. | |
handleSuccess_(string id, ?goog.net.XhrIo xhrIo) Handles the success of a request. Dispatches the SUCCESS event and sets the +the request as completed. | |
removeXhrListener_(?goog.net.XhrIo xhrIo, ?Function func, (Array.<string>|null|string=) opt_types) Remove listeners for XHR events on an XhrIo object. | |
retry_(string id, ?goog.net.XhrIo xhrIo) Attempts to retry the given request. If the request has already attempted +the maximum number of retries, then it removes the request and releases +the XhrIo object back into the pool. | |
send(string id, string url, string= opt_method, string= opt_content, (Object|goog.structs.Map|null=) opt_headers, <Any Type> opt_priority, ?Function= opt_callback, number= opt_maxRetries) ⇒ ?goog.net.XhrManager.Request Registers the given request to be sent. Throws an error if a request +already exists with the given ID. +NOTE: It is not sent immediately. It is queued and will be sent when an +XhrIo object becomes available, taking into account the request's +priority. | |
setTimeoutInterval(number ms) Sets the number of milliseconds after which an incomplete request will be +aborted. Zero means no timeout is set. |
An event dispatched by XhrManager.
extends goog.events.EventInstance Method Summary | |
disposeInternal() Deletes or nulls out any references to COM objects, DOM nodes, or other +disposable objects. Classes that extend {@code goog.Disposable} should +override this method. +Not reentrant. To avoid calling it twice, it must only be called from the +subclass' {@code disposeInternal} method. Everywhere else the public +{@code dispose} method must be used. +For example: + +mypackage.MyClass = function() { +goog.base(this); +// Constructor logic specific to MyClass. +... +}; +goog.inherits(mypackage.MyClass, goog.Disposable); + +mypackage.MyClass.prototype.disposeInternal = function() { +goog.base(this, 'disposeInternal'); +// Dispose logic specific to MyClass. +... +}; + |
An encapsulation of everything needed to make a Xhr request. +NOTE: This is used internal to the XhrManager.
extends goog.DisposableInstance Method Summary | |
disposeInternal() Deletes or nulls out any references to COM objects, DOM nodes, or other +disposable objects. Classes that extend {@code goog.Disposable} should +override this method. +Not reentrant. To avoid calling it twice, it must only be called from the +subclass' {@code disposeInternal} method. Everywhere else the public +{@code dispose} method must be used. +For example: + +mypackage.MyClass = function() { +goog.base(this); +// Constructor logic specific to MyClass. +... +}; +goog.inherits(mypackage.MyClass, goog.Disposable); + +mypackage.MyClass.prototype.disposeInternal = function() { +goog.base(this, 'disposeInternal'); +// Dispose logic specific to MyClass. +... +}; + | |
getAborted() ⇒ boolean Gets the aborted status. | |
getAttemptCount() ⇒ number Gets the number of attempts so far. | |
getCompleteCallback() ⇒ (Function|null|undefined) Gets the callback for when the request is complete. | |
getCompleted() ⇒ boolean Gets the completed status. | |
getContent() ⇒ (string|undefined) Gets the post data. | |
getHeaders() ⇒ (Object|goog.structs.Map|null) Gets the map of headers. | |
getMaxRetries() ⇒ number Gets the maximum number of times the request should be retried. | |
getMethod() ⇒ string Gets the send method. | |
getUrl() ⇒ string Gets the uri. | |
getXhrEventCallback() ⇒ (Function|null|undefined) Gets the callback attached to the events of the XhrIo object. | |
hasReachedMaxRetries() ⇒ boolean Returns whether the request has reached the maximum number of retries. | |
increaseAttemptCount() Increases the number of attempts so far. | |
setAborted(boolean aborted) Sets the aborted status. | |
setCompleted(boolean complete) Sets the completed status. |
Abstract base class for an XmlHttpRequest factory.
Instance Method Summary | |
createInstance() ⇒ (GearsHttpRequest|XMLHttpRequest) | |
getOptions() ⇒ ?Object | |
internalGetOptions() ⇒ ?Object Override this method in subclasses to preserve the caching offered by +getOptions(). |
Function Summary | |
add(?Object obj, string key, <Any Type> val) Adds a key-value pair to the object. Throws an exception if the key is +already in use. Use set if you want to change an existing pair. | |
clear(?Object obj) Removes all key value pairs from the object/map/hash. | |
clone(?Object obj) ⇒ !Object Does a flat clone of the object. | |
contains(?Object obj, <Any Type> val) ⇒ boolean Whether the object/hash/map contains the given object as a value. +An alias for goog.object.containsValue(obj, val). | |
containsKey(?Object obj, <Any Type> key) ⇒ boolean Whether the object/map/hash contains the given key. | |
containsValue(?Object obj, <Any Type> val) ⇒ boolean Whether the object/map/hash contains the given value. This is O(n). | |
create(<Any Type> var_args) ⇒ !Object Creates a new object built from the key-value pairs provided as arguments. | |
createSet(<Any Type> var_args) ⇒ !Object Creates a new object where the property names come from the arguments but +the value is always set to true | |
every(?Object obj, ?Function f, ?Object= opt_obj) ⇒ boolean Calls a function for each element in an object/map/hash. If +all calls return true, returns true. If any call returns false, returns +false at this point and does not continue to check the remaining elements. | |
extend(?Object target, (Object|null|undefined) var_args) Extends an object with another object. +This operates 'in-place'; it does not create a new Object. + +Example: +var o = {}; +goog.object.extend(o, {a: 0, b: 1}); +o; // {a: 0, b: 1} +goog.object.extend(o, {c: 2}); +o; // {a: 0, b: 1, c: 2} | |
filter(?Object obj, ?Function f, ?Object= opt_obj) ⇒ !Object Calls a function for each element in an object/map/hash. If that call returns +true, adds the element to a new object. | |
findKey(?Object obj, function (*, string, (Object|null)): boolean f, ?Object= opt_this) ⇒ (string|undefined) Searches an object for an element that satisfies the given condition and +returns its key. | |
findValue(?Object obj, function (*, string, (Object|null)): boolean f, ?Object= opt_this) ⇒ <Any Type> Searches an object for an element that satisfies the given condition and +returns its value. | |
forEach(?Object obj, ?Function f, ?Object= opt_obj) Calls a function for each element in an object/map/hash. | |
get(?Object obj, string key, <Any Type> opt_val) ⇒ <Any Type> Returns the value for the given key. | |
getAnyKey(?Object obj) ⇒ (string|undefined) Returns one key from the object map, if any exists. +For map literals the returned key will be the first one in most of the +browsers (a know exception is Konqueror). | |
getAnyValue(?Object obj) ⇒ <Any Type> Returns one value from the object map, if any exists. +For map literals the returned value will be the first one in most of the +browsers (a know exception is Konqueror). | |
getCount(?Object obj) ⇒ number Returns the number of key-value pairs in the object map. | |
getKeys(?Object obj) ⇒ !Array Returns the keys of the object/map/hash. | |
getValueByKeys(!Object obj, (Array.<(number|string)>|number|string|undefined) var_args) ⇒ <Any Type> Get a value from an object multiple levels deep. This is useful for +pulling values from deeply nested objects, such as JSON responses. +Example usage: getValueByKeys(jsonObj, 'foo', 'entries', 3) | |
getValues(?Object obj) ⇒ !Array Returns the values of the object/map/hash. | |
isEmpty(?Object obj) ⇒ boolean Whether the object/map/hash is empty. | |
map(?Object obj, ?Function f, ?Object= opt_obj) ⇒ !Object For every element in an object/map/hash calls a function and inserts the +result into a new object. | |
remove(?Object obj, <Any Type> key) ⇒ boolean Removes a key-value pair based on the key. | |
set(?Object obj, string key, <Any Type> value) Adds a key-value pair to the object/map/hash. | |
setIfUndefined(?Object obj, string key, <Any Type> value) ⇒ <Any Type> Adds a key-value pair to the object/map/hash if it doesn't exist yet. | |
some(?Object obj, ?Function f, ?Object= opt_obj) ⇒ boolean Calls a function for each element in an object/map/hash. If any +call returns true, returns true (without checking the rest). If +all calls return false, returns false. | |
transpose(?Object obj) ⇒ !Object Returns a new object in which all the keys and values are interchanged +(keys become values and values become keys). If multiple keys map to the +same value, the chosen transposed value is implementation-dependent. | |
unsafeClone(<Any Type> obj) ⇒ <Any Type> Clones a value. The input may be an Object, Array, or basic type. Objects and
+arrays will be cloned recursively.
+
+WARNINGS:
+ |
Function Summary | |
canAccessProperty(?Object obj, string prop) ⇒ boolean Check if a property can be accessed without throwing an exception. | |
object(!Function type, ?Object object) ⇒ ?Object Syntax for object literal casts. | |
sinkValue() To assert to the compiler that an operation is needed when it would
+otherwise be stripped. For example:
+ |
The base implementation for all storage APIs.
Instance Method Summary | |
get(string key) ⇒ <Any Type> Get an item from the data storage. | |
remove(string key) Remove an item from the data storage. | |
set(string key, <Any Type> value) Set an item in the data storage. |
Provides a storage mechanism that uses HTML5 local storage.
extends goog.storage.mechanism.HTML5WebStorage \ No newline at end of file diff --git a/docs/goog/storage/mechanism/HTML5WebStorage.html b/docs/goog/storage/mechanism/HTML5WebStorage.html new file mode 100644 index 0000000..a7bfccc --- /dev/null +++ b/docs/goog/storage/mechanism/HTML5WebStorage.html @@ -0,0 +1,9 @@ +Provides a storage mechanism that uses HTML5 Web storage.
extends goog.storage.mechanism.IterableMechanismInstance Method Summary | |
__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator Returns an iterator that iterates over the elements in the storage. Will +throw goog.iter.StopIteration after the last element. | |
clear() Remove all key-value pairs. + +Could be overridden in a subclass, as the default implementation is not very +efficient - it iterates over all keys. | |
get(string key) ⇒ ?string Get the value stored under a key. | |
getCount() ⇒ number Get the number of stored key-value pairs. + +Could be overridden in a subclass, as the default implementation is not very +efficient - it iterates over all keys. | |
isAvailable() ⇒ boolean Determines whether or not the mechanism is available. +It works only if the provided web storage object exists and is enabled. | |
remove(string key) Remove a key and its value. | |
set(string key, string value) Set a value for a key. |
Interface for all iterable storage mechanisms.
extends goog.storage.mechanism.MechanismInstance Method Summary | |
__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator Returns an iterator that iterates over the elements in the storage. Will +throw goog.iter.StopIteration after the last element. | |
clear() Remove all key-value pairs. + +Could be overridden in a subclass, as the default implementation is not very +efficient - it iterates over all keys. | |
getCount() ⇒ number Get the number of stored key-value pairs. + +Could be overridden in a subclass, as the default implementation is not very +efficient - it iterates over all keys. |
Basic interface for all storage mechanisms.
Instance Method Summary | |
get(string key) ⇒ ?string Get the value stored under a key. | |
remove(string key) Remove a key and its value. | |
set(string key, string value) Set a value for a key. |
Function Summary | |
buildString(<Any Type> var_args) ⇒ string Concatenates string expressions. This is useful +since some browsers are very inefficient when it comes to using plus to +concat strings. Be careful when using null and undefined here since +these will not be included in the result. If you need to represent these +be sure to cast the argument to a String first. +For example: + buildString('a', 'b', 'c', 'd') -> 'abcd' +buildString(null, undefined) -> '' + | |
canonicalizeNewlines(string str) ⇒ string Replaces Windows and Mac new lines with unix style: \r or \r\n with \n. | |
caseInsensitiveCompare(string str1, string str2) ⇒ number A string comparator that ignores case. +-1 = str1 less than str2 +0 = str1 equals str2 +1 = str1 greater than str2 | |
caseInsensitiveEndsWith(string str, string suffix) ⇒ boolean Case-insensitive suffix-checker. | |
caseInsensitiveStartsWith(string str, string prefix) ⇒ boolean Case-insensitive prefix-checker. | |
collapseBreakingSpaces(string str) ⇒ string Removes the breaking spaces from the left and right of the string and +collapses the sequences of breaking spaces in the middle into single spaces. +The original and the result strings render the same way in HTML. | |
collapseWhitespace(string str) ⇒ string Converts multiple whitespace chars (spaces, non-breaking-spaces, new lines +and tabs) to a single space, and strips leading and trailing whitespace. | |
compareElements_((boolean|number|string) left, (boolean|number|string) right) ⇒ number Compares elements of a version number. | |
compareVersions((number|string) version1, (number|string) version2) ⇒ number Compares two version numbers. | |
contains(string s, string ss) ⇒ boolean Checks whether a string contains a given character. | |
countOf(string s, string ss) ⇒ number Returns the non-overlapping occurrences of ss in s. +If either s or ss evalutes to false, then returns zero. | |
createUniqueString() ⇒ string Generates and returns a string which is unique in the current document. +This is useful, for example, to create unique IDs for DOM elements. | |
endsWith(string str, string suffix) ⇒ boolean Fast suffix-checker. | |
escapeChar(string c) ⇒ string Takes a character and returns the escaped string for that character. For +example escapeChar(String.fromCharCode(15)) -> "\\x0E". | |
escapeString(string str) ⇒ string Takes a string and returns the escaped string for that character. | |
getRandomString() ⇒ string Returns a string with at least 64-bits of randomness. + +Doesn't trust Javascript's random function entirely. Uses a combination of +random and current timestamp, and then encodes the string in base-36 to +make it shorter. | |
hashCode(string str) ⇒ number String hash function similar to java.lang.String.hashCode(). +The hash code for a string is computed as +s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], +where s[i] is the ith character of the string and n is the length of +the string. We mod the result to make it between 0 (inclusive) and 2^32 +(exclusive). | |
htmlEscape(string str, boolean= opt_isLikelyToContainHtmlChars) ⇒ string Escape double quote '"' characters in addition to '&', '<', and '>' so that a +string can be included in an HTML tag attribute value within double quotes. + +It should be noted that > doesn't need to be escaped for the HTML or XML to +be valid, but it has been decided to escape it for consistency with other +implementations. + +NOTE(user): +HtmlEscape is often called during the generation of large blocks of HTML. +Using statics for the regular expressions and strings is an optimization +that can more than half the amount of time IE spends in this function for +large apps, since strings and regexes both contribute to GC allocations. + +Testing for the presence of a character before escaping increases the number +of function calls, but actually provides a speed increase for the average +case -- since the average case often doesn't require the escaping of all 4 +characters and indexOf() is much cheaper than replace(). +The worst case does suffer slightly from the additional calls, therefore the +opt_isLikelyToContainHtmlChars option has been included for situations +where all 4 HTML entities are very likely to be present and need escaping. + +Some benchmarks (times tended to fluctuate +-0.05ms): +FireFox IE6 +(no chars / average (mix of cases) / all 4 chars) +no checks 0.13 / 0.22 / 0.22 0.23 / 0.53 / 0.80 +indexOf 0.08 / 0.17 / 0.26 0.22 / 0.54 / 0.84 +indexOf + re test 0.07 / 0.17 / 0.28 0.19 / 0.50 / 0.85 + +An additional advantage of checking if replace actually needs to be called +is a reduction in the number of object allocations, so as the size of the +application grows the difference between the various methods would increase. | |
isAlpha(string str) ⇒ boolean Checks if a string contains all letters. | |
isAlphaNumeric(string str) ⇒ boolean Checks if a string contains only numbers or letters. | |
isBreakingWhitespace(string str) ⇒ boolean Checks if a string is all breaking whitespace. | |
isEmpty(string str) ⇒ boolean Checks if a string is empty or contains only whitespaces. | |
isEmptySafe(<Any Type> str) ⇒ boolean Checks if a string is null, empty or contains only whitespaces. | |
isNumeric(<Any Type> str) ⇒ boolean Checks if a string contains only numbers. | |
isSpace(string ch) ⇒ boolean Checks if a character is a space character. | |
isUnicodeChar(string ch) ⇒ boolean Checks if a character is a valid unicode character. | |
makeSafe(<Any Type> obj) ⇒ string Returns a string representation of the given object, with +null and undefined being returned as the empty string. | |
newLineToBr(string str, boolean= opt_xml) ⇒ string Converts \n to | |
normalizeSpaces(string str) ⇒ string Normalizes spaces in a string, replacing all consecutive spaces and tabs +with a single space. Replaces non-breaking space with a space. | |
normalizeWhitespace(string str) ⇒ string Normalizes whitespace in a string, replacing all whitespace chars with +a space. | |
numerateCompare(string str1, string str2) ⇒ number String comparison function that handles numbers in a way humans might expect. +Using this function, the string "File 2.jpg" sorts before "File 10.jpg". The +comparison is mostly case-insensitive, though strings that are identical +except for case are sorted with the upper-case strings before lower-case. + +This comparison function is significantly slower (about 500x) than either +the default or the case-insensitive compare. It should not be used in +time-critical code, but should be fast enough to sort several hundred short +strings (like filenames) with a reasonable delay. | |
padNumber(number num, number length, number= opt_precision) ⇒ string Pads number to given length and optionally rounds it to a given precision. +For example: + padNumber(1.25, 2, 3) -> '01.250' +padNumber(1.25, 2) -> '01.25' +padNumber(1.25, 2, 1) -> '01.3' +padNumber(1.25, 0) -> '1.25' | |
quote(string s) ⇒ string Encloses a string in double quotes and escapes characters so that the +string is a valid JS string. | |
regExpEscape(<Any Type> s) ⇒ string Escapes characters in the string that are not safe to use in a RegExp. | |
remove(string s, string ss) ⇒ string Removes the first occurrence of a substring from a string. | |
removeAll(string s, string ss) ⇒ string Removes all occurrences of a substring from a string. | |
removeAt(string s, number index, number stringLength) ⇒ string Removes a substring of a specified length at a specific +index in a string. | |
repeat(string string, number length) ⇒ string Repeats a string n times. | |
startsWith(string str, string prefix) ⇒ boolean Fast prefix-checker. | |
stripNewlines(string str) ⇒ string Takes a string and replaces newlines with a space. Multiple lines are +replaced with a single space. | |
stripQuotes(string str, string quoteChars) ⇒ string Strip quote characters around a string. The second argument is a string of +characters to treat as quotes. This can be a single character or a string of +multiple character and in that case each of those are treated as possible +quote characters. For example: + + +goog.string.stripQuotes('"abc"', '"`') --> 'abc' +goog.string.stripQuotes('`abc`', '"`') --> 'abc' + | |
subs(string str, <Any Type> var_args) ⇒ string Does simple python-style string substitution. +subs("foo%s hot%s", "bar", "dog") becomes "foobar hotdog". | |
toCamelCase(string str) ⇒ string Converts a string from selector-case to camelCase (e.g. from +"multi-part-string" to "multiPartString"), useful for converting +CSS selectors and HTML dataset keys to their equivalent JS properties. | |
toMap(string s) ⇒ ?Object Takes a string and creates a map (Object) in which the keys are the +characters in the string. The value for the key is set to true. You can +then use goog.object.map or goog.array.map to change the values. | |
toNumber(string str) ⇒ number Converts the supplied string to a number, which may be Ininity or NaN. +This function strips whitespace: (toNumber(' 123') === 123) +This function accepts scientific notation: (toNumber('1e1') === 10) + +This is better than Javascript's built-in conversions because, sadly: +(Number(' ') === 0) and (parseFloat('123a') === 123) | |
toSelectorCase(string str) ⇒ string Converts a string from camelCase to selector-case (e.g. from +"multiPartString" to "multi-part-string"), useful for converting JS +style and dataset properties to equivalent CSS selectors and HTML keys. | |
trim(string str) ⇒ string Trims white spaces to the left and right of a string. | |
trimLeft(string str) ⇒ string Trims whitespaces at the left end of a string. | |
trimRight(string str) ⇒ string Trims whitespaces at the right end of a string. | |
truncate(string str, number chars, boolean= opt_protectEscapedCharacters) ⇒ string Truncates a string to a certain length and adds '...' if necessary. The +length also accounts for the ellipsis, so a maximum length of 10 and a string +'Hello World!' produces 'Hello W...'. | |
truncateMiddle(string str, number chars, boolean= opt_protectEscapedCharacters, number= opt_trailingChars) ⇒ string Truncate a string in the middle, adding "..." if necessary, +and favoring the beginning of the string. | |
unescapeEntities(string str) ⇒ string Unescapes an HTML string. | |
unescapeEntitiesUsingDom_(string str) ⇒ string Unescapes an HTML string using a DOM to resolve non-XML, non-numeric +entities. This function is XSS-safe and whitespace-preserving. | |
unescapePureXmlEntities_(string str) ⇒ string Unescapes XML entities. | |
urlDecode(string str) ⇒ string URL-decodes the string. We need to specially handle '+'s because +the javascript library doesn't convert them to spaces. | |
urlEncode(<Any Type> str) ⇒ string URL-encodes a string | |
whitespaceEscape(string str, boolean= opt_xml) ⇒ string Do escaping of whitespace to preserve spatial formatting. We use character +entity #160 to make it safer for xml. |
Function Summary | |
clear(?Object col) Removes all the elements from the collection. | |
contains(?Object col, <Any Type> val) ⇒ boolean Whether the collection contains the given value. This is O(n) and uses +equals (==) to test the existence. | |
every(?Object col, ?Function f, ?Object= opt_obj) ⇒ boolean Calls f for each value in a collection. If all calls return true this return +true this returns true. If any returns false this returns false at this point +and does not continue to check the remaining values. | |
filter(?Object col, ?Function f, ?Object= opt_obj) ⇒ !Object Calls a function for every value in the collection. When a call returns true, +adds the value to a new collection (Array is returned by default). | |
forEach(?Object col, ?Function f, ?Object= opt_obj) Calls a function for each value in a collection. The function takes +three arguments; the value, the key and the collection. | |
getCount(?Object col) ⇒ number Returns the number of values in the collection-like object. | |
getKeys(?Object col) ⇒ (Array|undefined) Returns the keys of the collection. Some collections have no notion of +keys/indexes and this function will return undefined in those cases. | |
getValues(?Object col) ⇒ !Array Returns the values of the collection-like object. | |
isEmpty(?Object col) ⇒ boolean Whether the collection is empty. | |
map(?Object col, ?Function f, ?Object= opt_obj) ⇒ !Object Calls a function for every value in the collection and adds the result into a +new collection (defaults to creating a new Array). | |
some((Object|null|string) col, ?Function f, ?Object= opt_obj) ⇒ boolean Calls f for each value in a collection. If any call returns true this returns +true (without checking the rest). If all returns false this returns false. |
Class for a Heap datastructure.
Instance Method Summary | |
clear() Removes all elements from the heap. | |
clone() ⇒ ?goog.structs.Heap Clones a heap and returns a new heap | |
containsKey(?Object key) ⇒ boolean Whether the heap contains the given key. | |
containsValue(?Object val) ⇒ boolean Whether the heap contains the given value. | |
getCount() ⇒ number The number of key-value pairs in the map | |
getKeys() ⇒ ?Array Gets the keys of the heap. | |
getLeftChildIndex_(number index) ⇒ number Gets the index of the left child of the node at the given index. | |
getParentIndex_(number index) ⇒ number Gets the index of the parent of the node at the given index. | |
getRightChildIndex_(number index) ⇒ number Gets the index of the right child of the node at the given index. | |
getValues() ⇒ ?Array Gets the values of the heap. | |
insert(<Any Type> key, <Any Type> value) Insert the given value into the heap with the given key. | |
insertAll((Object|goog.structs.Heap|null) heap) Adds multiple key-value pairs from another goog.structs.Heap or Object | |
isEmpty() ⇒ boolean Returns true if this heap contains no elements. | |
moveDown_(number index) Moves the node at the given index down to its proper place in the heap. | |
moveUp_(number index) Moves the node at the given index up to its proper place in the heap. | |
peek() ⇒ <Any Type> Retrieves but does not remove the root value of this heap. | |
peekKey() ⇒ <Any Type> Retrieves but does not remove the key of the root node of this heap. | |
remove() ⇒ <Any Type> Retrieves and removes the root value of this heap. |
Class for Hash Map datastructure.
Instance Method Summary | |
__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator Returns an iterator that iterates over the values or the keys in the map. +This throws an exception if the map was mutated since the iterator was +created. | |
addAll(?Object map) Adds multiple key-value pairs from another goog.structs.Map or Object. | |
cleanupKeysArray_() Cleans up the temp keys array by removing entries that are no longer in the +map. | |
clear() Removes all key-value pairs from the map. | |
clone() ⇒ !goog.structs.Map Clones a map and returns a new map. | |
containsKey(<Any Type> key) ⇒ boolean Whether the map contains the given key. | |
containsValue(<Any Type> val) ⇒ boolean Whether the map contains the given value. This is O(n). | |
equals(?goog.structs.Map otherMap, function (*, *): boolean= opt_equalityFn) ⇒ boolean Whether this map is equal to the argument map. | |
get(<Any Type> key, <Any Type> opt_val) ⇒ <Any Type> Returns the value for the given key. If the key is not found and the default +value is not given this will return {@code undefined}. | |
getCount() ⇒ number | |
getKeyIterator() ⇒ !goog.iter.Iterator Returns an iterator that iterates over the keys in the map. Removal of keys +while iterating might have undesired side effects. | |
getKeys() ⇒ !Array Returns the keys of the map. | |
getValueIterator() ⇒ !goog.iter.Iterator Returns an iterator that iterates over the values in the map. Removal of +keys while iterating might have undesired side effects. | |
getValues() ⇒ !Array Returns the values of the map. | |
isEmpty() ⇒ boolean | |
remove(<Any Type> key) ⇒ boolean Removes a key-value pair based on the key. This is O(logN) amortized due to +updating the keys array whenever the count becomes half the size of the keys +in the keys array. | |
set(<Any Type> key, <Any Type> value) Adds a key-value pair to the map. | |
toObject() ⇒ !Object | |
transpose() ⇒ !goog.structs.Map Returns a new map in which all the keys and values are interchanged +(keys become values and values become keys). If multiple keys map to the +same value, the chosen transposed value is implementation-dependent. + +It acts very similarly to {goog.object.transpose(Object)}. |
Static Method Summary | |
defaultEquals(<Any Type> a, <Any Type> b) ⇒ boolean Default equality test for values. | |
hasKey_(?Object obj, <Any Type> key) ⇒ boolean Safe way to test for hasOwnProperty. It even allows testing for +'hasOwnProperty'. |
A generic immutable node. This can be used in various collections that +require a node object for its item (such as a heap).
Instance Method Summary | |
clone() ⇒ ?goog.structs.Node Clones a node and returns a new node. | |
getKey() ⇒ <Any Type> Gets the key. | |
getValue() ⇒ <Any Type> Gets the value. |
A generic pool class. If min is greater than max, an error is thrown.
extends goog.DisposableInstance Method Summary | |
addFreeObject(?Object obj) Adds an object to the collection of objects that are free. If the object can +not be added, then it is disposed. | |
adjustForMinMax() Adjusts the objects held in the pool to be within the min/max constraints. + +NOTE: It is possible that the number of objects in the pool will still be +greater than the maximum count of objects allowed. This will be the case +if no more free objects can be disposed of to get below the minimum count +(i.e., all objects are in use). | |
contains(?Object obj) ⇒ boolean Returns true if the given object is in the pool. | |
createObject() ⇒ ?Object Should be overriden by sub-classes to return an instance of the object type +that is expected in the pool. | |
disposeInternal() Disposes of the pool and all objects currently held in the pool. | |
disposeObject(?Object obj) Should be overriden to dispose of an object. Default implementation is to +remove all its members, which should render it useless. Calls the object's +{@code dispose()} method, if available. | |
getCount() ⇒ number Returns the number of objects currently in the pool. | |
getFreeCount() ⇒ number Returns the number of objects currently free in the pool. | |
getInUseCount() ⇒ number Returns the number of objects currently in use in the pool. | |
getObject() ⇒ (Object|null|undefined) | |
isEmpty() ⇒ boolean Determines if the pool contains no objects. | |
objectCanBeReused(?Object obj) ⇒ boolean Should be overriden to determine whether an object has become unusable and +should not be returned by getObject(). Calls the object's +{@code canBeReused()} method, if available. | |
releaseObject(?Object obj) ⇒ boolean Returns an object to the pool of available objects so that it can be reused. | |
removeFreeObject_() ⇒ (Object|null|undefined) Removes a free object from the collection of objects that are free so that it +can be used. + +NOTE: This method does not mark the returned object as in use. | |
setDelay(number delay) Sets the minimum delay between objects being returned by getObject, in +milliseconds. This defaults to zero, meaning that no minimum delay is +enforced and objects may be used as soon as they're available. | |
setMaximumCount(number max) Sets the maximum count of the pool. +If max is less than the max count of the pool, an error is thrown. | |
setMinimumCount(number min) Sets the minimum count of the pool. +If min is greater than the max count of the pool, an error is thrown. |
A generic pool class. If max is greater than min, an error is thrown.
extends goog.structs.PoolInstance Method Summary | |
addFreeObject(?Object obj) Adds an object to the collection of objects that are free. If the object can +not be added, then it is disposed. + +NOTE: This method does not remove the object from the in use collection. | |
adjustForMinMax() Adjusts the objects held in the pool to be within the min/max constraints. + +NOTE: It is possible that the number of objects in the pool will still be +greater than the maximum count of objects allowed. This will be the case +if no more free objects can be disposed of to get below the minimum count +(i.e., all objects are in use). | |
disposeInternal() Disposes of the pool and all objects currently held in the pool. | |
getObject(?Function= opt_callback, <Any Type> opt_priority) ⇒ (Object|null|undefined) Get a new object from the the pool, if there is one available, otherwise +return undefined. | |
handleQueueRequests_() Handles the request queue. Tries to fires off as many queued requests as +possible. | |
setDelay(number delay) Sets the minimum delay between objects being returned by getObject, in +milliseconds. This defaults to zero, meaning that no minimum delay is +enforced and objects may be used as soon as they're available. |
Class for Priority Queue datastructure.
extends goog.structs.HeapInstance Method Summary | |
dequeue() ⇒ <Any Type> Retrieves and removes the head of this queue. | |
enqueue(<Any Type> priority, <Any Type> value) Puts the specified value in the queue. |
Class for FIFO Queue data structure.
Instance Method Summary | |
clear() Removes all elements from the queue. | |
contains(<Any Type> obj) ⇒ boolean Returns true if the given value is in the queue. | |
dequeue() ⇒ <Any Type> Retrieves and removes the head of this queue. | |
enqueue(<Any Type> element) Puts the specified element on this queue. | |
getCount() ⇒ number Returns the number of elements in this queue. | |
getValues() ⇒ ?Array Returns all the values in the queue. | |
isEmpty() ⇒ boolean Returns true if this queue contains no elements. | |
peek() ⇒ <Any Type> Retrieves but does not remove the head of this queue. | |
remove(<Any Type> obj) ⇒ boolean Removes the first occurrence of a particular value from the queue. |
A set that can contain both primitives and objects. Adding and removing +elements is O(1). Primitives are treated as identical if they have the same +type and convert to the same string. Objects are treated as identical only +if they are references to the same object. WARNING: A goog.structs.Set can +contain both 1 and (new Number(1)), because they are not the same. WARNING: +Adding (new Number(1)) twice will yield two distinct elements, because they +are two different objects. WARNING: Any object that is added to a +goog.structs.Set will be modified! Because goog.getUid() is used to +identify objects, every object in the set will be mutated.
Instance Method Summary | |
__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator Returns an iterator that iterates over the elements in this set. | |
add(<Any Type> element) Add a primitive or an object to the set. | |
addAll(?Object col) Adds all the values in the given collection to this set. | |
clear() Removes all elements from this set. | |
clone() ⇒ !goog.structs.Set Creates a shallow clone of this set. | |
contains(<Any Type> element) ⇒ boolean Tests whether this set contains the given element. | |
containsAll(?Object col) ⇒ boolean Tests whether this set contains all the values in a given collection. +Repeated elements in the collection are ignored, e.g. (new +goog.structs.Set([1, 2])).containsAll([1, 1]) is True. | |
difference(?Object col) ⇒ !goog.structs.Set Finds all values that are present in this set and not in the given +collection. | |
equals(?Object col) ⇒ boolean Tests whether the given collection consists of the same elements as this set, +regardless of order, without repetition. Primitives are treated as equal if +they have the same type and convert to the same string; objects are treated +as equal if they are references to the same object. This operation is O(n). | |
getCount() ⇒ number | |
getValues() ⇒ !Array Returns an array containing all the elements in this set. | |
intersection(?Object col) ⇒ !goog.structs.Set Finds all values that are present in both this set and the given collection. | |
isEmpty() ⇒ boolean Tests whether this set is empty. | |
isSubsetOf(?Object col) ⇒ boolean Tests whether the given collection contains all the elements in this set. +Primitives are treated as equal if they have the same type and convert to the +same string; objects are treated as equal if they are references to the same +object. This operation is O(n). | |
remove(<Any Type> element) ⇒ boolean Removes the given element from this set. | |
removeAll(?Object col) Removes all values in the given collection from this set. |
Static Method Summary | |
getKey_(<Any Type> val) ⇒ string Obtains a unique key for an element of the set. Primitives will yield the +same key if they have the same type and convert to the same string. Object +references will yield the same key only if they refer to the same object. |
Function Summary | |
clearTransparentBackgroundImage(?Element el) Clears the background image of an element in a browser independent manner. | |
getBackgroundColor(?Element element) ⇒ string Retrieves the computed background color string for a given element. The +string returned is suitable for assigning to another element's +background-color, but is not guaranteed to be in any particular string +format. Accessing the color in a numeric form may not be possible in all +browsers or with all input. + +If the background color for the element is defined as a hexadecimal value, +the resulting string can be parsed by goog.color.parse in all supported +browsers. + +Whether named colors like "red" or "lightblue" get translated into a +format which can be parsed is browser dependent. Calling this function on +transparent elements will return "transparent" in most browsers or +"rgba(0, 0, 0, 0)" in WebKit. | |
getBorderBox(?Element element) ⇒ !goog.math.Box Gets the computed border widths (on all sides) in pixels | |
getBorderBoxSize(?Element element) ⇒ !goog.math.Size Gets the border box size for an element. | |
getBoundingClientRect_(?Element el) ⇒ ?Object Gets the client rectangle of the DOM element. + +getBoundingClientRect is part of a new CSS object model draft (with a +long-time presence in IE), replacing the error-prone parent offset +computation and the now-deprecated Gecko getBoxObjectFor. + +This utility patches common browser bugs in getClientBoundingRect. It +will fail if getClientBoundingRect is unsupported. + +If the element is not in the DOM, the result is undefined, and an error may +be thrown depending on user agent. | |
getBounds(?Element element) ⇒ !goog.math.Rect Returns a bounding rectangle for a given element in page space. | |
getBox_(?Element element, string stylePrefix) ⇒ !goog.math.Box Gets the computed paddings or margins (on all sides) in pixels. | |
getCascadedStyle(?Element element, string style) ⇒ string Gets the cascaded style value of a node, or null if the value cannot be +computed (only Internet Explorer can do this). | |
getClientLeftTop(?Element el) ⇒ !goog.math.Coordinate Returns clientLeft (width of the left border and, if the directionality is +right to left, the vertical scrollbar) and clientTop as a coordinate object. | |
getClientPosition((Element|Event|goog.events.Event|null) el) ⇒ !goog.math.Coordinate Returns the position of the event or the element's border box relative to +the client viewport. | |
getClientViewportElement(?Node= opt_node) ⇒ ?Element Returns the viewport element for a particular document | |
getComputedCursor(?Element element) ⇒ string Retrieves the computed value of the cursor CSS attribute. | |
getComputedOverflowX(?Element element) ⇒ string Retrieves the computed value of the overflow-x CSS attribute. | |
getComputedOverflowY(?Element element) ⇒ string Retrieves the computed value of the overflow-y CSS attribute. | |
getComputedPosition(?Element element) ⇒ string Retrieves the computed value of the position CSS attribute. | |
getComputedStyle(?Element element, string property) ⇒ string Retrieves a computed style value of a node. It returns empty string if the +value cannot be computed (which will be the case in Internet Explorer) or +"none" if the property requested is an SVG one and it has not been +explicitly set (firefox and webkit). | |
getComputedTextAlign(?Element element) ⇒ string Retrieves the computed value of the text-align CSS attribute. | |
getComputedZIndex(?Element element) ⇒ (number|string) Retrieves the computed value of the z-index CSS attribute. | |
getContentBoxSize(?Element element) ⇒ !goog.math.Size Gets the content box size for an element. This is potentially expensive in +all browsers. | |
getFloat(?Element el) ⇒ string Gets value of explicitly-set float CSS property on an element. | |
getFontFamily(?Element el) ⇒ string Returns the font face applied to a given node. Opera and IE should return +the font actually displayed. Firefox returns the author's most-preferred +font (whether the browser is capable of displaying it or not.) | |
getFontSize(?Element el) ⇒ number Returns the font size, in pixels, of text in an element. | |
getFramedPageOffset(?Element el, ?Window relativeWin) ⇒ !goog.math.Coordinate Returns a Coordinate object relative to the top-left of an HTML document +in an ancestor frame of this element. Used for measuring the position of +an element inside a frame relative to a containing frame. | |
getIePixelBorder_(?Element element, string prop) ⇒ number Helper function for IE to get the pixel border. | |
getIePixelDistance_(?Element element, string propName) ⇒ number Helper function for getting the pixel padding or margin for IE. | |
getIePixelValue_(?Element element, string value, string name, string pixelName) ⇒ number IE specific function that converts a non pixel unit to pixels. | |
getLengthUnits(string value) ⇒ ?string Returns the units used for a CSS length measurement. | |
getMarginBox(?Element element) ⇒ !goog.math.Box Gets the computed margins (on all sides) in pixels. | |
getOffsetParent(?Element element) ⇒ ?Element Returns the first parent that could affect the position of a given element. | |
getOpacity(?Element el) ⇒ (number|string) Gets the opacity of a node (x-browser). This gets the inline style opacity +of the node, and does not take into account the cascaded or the computed +style for this node. | |
getPaddingBox(?Element element) ⇒ !goog.math.Box Gets the computed paddings (on all sides) in pixels. | |
getPageOffset(?Element el) ⇒ !goog.math.Coordinate Returns a Coordinate object relative to the top-left of the HTML document. +Implemented as a single function to save having to do two recursive loops in +opera and safari just to get both coordinates. If you just want one value do +use goog.style.getPageOffsetLeft() and goog.style.getPageOffsetTop(), but +note if you call both those methods the tree will be analysed twice. | |
getPageOffsetLeft(?Element el) ⇒ number Returns the left coordinate of an element relative to the HTML document | |
getPageOffsetTop(?Element el) ⇒ number Returns the top coordinate of an element relative to the HTML document | |
getPixelStyleValue_((number|string) value, boolean round) ⇒ string Helper function to create a string to be set into a pixel-value style +property of an element. Can round to the nearest integer value. | |
getPosition(?Element element) ⇒ !goog.math.Coordinate Gets the offsetLeft and offsetTop properties of an element and returns them +in a Coordinate object | |
getRelativePosition((Element|Event|goog.events.Event|null) a, (Element|Event|goog.events.Event|null) b) ⇒ !goog.math.Coordinate Returns the position of an element relative to another element in the +document. A relative to B | |
getScrollbarWidth(string= opt_className) ⇒ number Returns the scroll bar width (represents the width of both horizontal +and vertical scroll). | |
getSize(?Element element) ⇒ !goog.math.Size Gets the height and width of an element, even if its display is none. +Specifically, this returns the height and width of the border box, +irrespective of the box model in effect. | |
getSizeWithDisplay_(?Element element) ⇒ !goog.math.Size Gets the height and with of an element when the display is not none. | |
getStyle(?Element element, string property) ⇒ string Retrieves an explicitly-set style value of a node. This returns '' if there +isn't a style attribute on the element or if this style property has not been +explicitly set in script. | |
getStyle_(?Element element, string style) ⇒ string Cross-browser pseudo get computed style. It returns the computed style where +available. If not available it tries the cascaded style value (IE +currentStyle) and in worst case the inline style value. It shouldn't be +called directly, see http://wiki/Main/ComputedStyleVsCascadedStyle for +discussion. | |
getVisibleRectForElement(?Element element) ⇒ ?goog.math.Box Calculates and returns the visible rectangle for a given element. Returns a +box describing the visible portion of the nearest scrollable offset ancestor. +Coordinates are given relative to the document. | |
installStyles(string stylesString, ?Node= opt_node) ⇒ (Element|StyleSheet|null) Installs the styles string into the window that contains opt_element. If +opt_element is null, the main window is used. | |
isElementShown(?Element el) ⇒ boolean Test whether the given element has been shown or hidden via a call to +{@link #showElement}. + +Note this is strictly a companion method for a call +to {@link #showElement} and the same caveats apply; in particular, this +method does not guarantee that the return value will be consistent with +whether or not the element is actually visible. | |
isRightToLeft(?Element el) ⇒ boolean Returns true if the element is using right to left (rtl) direction. | |
isUnselectable(?Element el) ⇒ boolean Returns true if the element is set to be unselectable, false otherwise. +Note that on some platforms (e.g. Mozilla), even if an element isn't set +to be unselectable, it will behave as such if any of its ancestors is +unselectable. | |
parseStyleAttribute(string value) ⇒ !Object Parses a style attribute value. Converts CSS property names to camel case. | |
scrollIntoContainerView(?Element element, ?Element container, boolean= opt_center) Changes the scroll position of {@code container} with the minimum amount so +that the content and the borders of the given {@code element} become visible. +If the element is bigger than the container, its top left corner will be +aligned as close to the container's top left corner as possible. | |
setBorderBoxSize(?Element element, ?goog.math.Size size) Sets the border box size of an element. This is potentially expensive in IE +if the document is CSS1Compat mode | |
setBoxSizingSize_(?Element element, ?goog.math.Size size, string boxSizing) Helper function that sets the box sizing as well as the width and height | |
setContentBoxSize(?Element element, ?goog.math.Size size) Sets the content box size of an element. This is potentially expensive in IE +if the document is BackCompat mode. | |
setFloat(?Element el, string value) Sets CSS float property on an element. | |
setHeight(?Element element, (number|string) height) Set the height of an element. Sets the element's style property. | |
setInlineBlock(?Element el) Sets 'display: inline-block' for an element (cross-browser). | |
setOpacity(?Element el, (number|string) alpha) Sets the opacity of a node (x-browser). | |
setPageOffset(?Element el, (goog.math.Coordinate|null|number) x, number= opt_y) Moves an element to the given coordinates relative to the client viewport. | |
setPosition(?Element el, (goog.math.Coordinate|null|number|string) arg1, (number|string=) opt_arg2) Sets the top/left values of an element. If no unit is specified in the +argument then it will add px. | |
setPreWrap(?Element el) Sets 'white-space: pre-wrap' for a node (x-browser). + +There are as many ways of specifying pre-wrap as there are browsers. + +CSS3/IE8: white-space: pre-wrap; +Mozilla: white-space: -moz-pre-wrap; +Opera: white-space: -o-pre-wrap; +IE6/7: white-space: pre; word-wrap: break-word; | |
setSize(?Element element, (goog.math.Size|null|number|string) w, (number|string=) opt_h) Sets the width/height values of an element. If an argument is numeric, +or a goog.math.Size is passed, it is assumed to be pixels and will add +'px' after converting it to an integer in string form. (This just sets the +CSS width and height properties so it might set content-box or border-box +size depending on the box model the browser is using.) | |
setStyle(?Element element, (Object|null|string) style, (boolean|number|string=) opt_value) Sets a style value on an element. + +This function is not indended to patch issues in the browser's style +handling, but to allow easy programmatic access to setting dash-separated +style properties. An example is setting a batch of properties from a data +object without overwriting old styles. When possible, use native APIs: +elem.style.propertyKey = 'value' or (if obliterating old styles is fine) +elem.style.cssText = 'property1: value1; property2: value2'. | |
setStyle_(?Element element, (boolean|number|string|undefined) value, string style) Sets a style value on an element, with parameters swapped to work with +{@code goog.object.forEach()}. | |
setStyles((Element|StyleSheet|null) element, string stylesString) Sets the content of a style element. The style element can be any valid +style element. This element will have its content completely replaced by +the new stylesString. | |
setTransparentBackgroundImage(?Element el, string src) Sets the background of an element to a transparent image in a browser- +independent manner. + +This function does not support repeating backgrounds or alternate background +positions to match the behavior of Internet Explorer. It also does not +support sizingMethods other than crop since they cannot be replicated in +browsers other than Internet Explorer. | |
setUnselectable(?Element el, boolean unselectable, boolean= opt_noRecurse) Makes the element and its descendants selectable or unselectable. Note +that on some platforms (e.g. Mozilla), even if an element isn't set to +be unselectable, it will behave as such if any of its ancestors is +unselectable. | |
setWidth(?Element element, (number|string) width) Set the width of an element. Sets the element's style property. | |
showElement(?Element el, <Any Type> display) Shows or hides an element from the page. Hiding the element is done by +setting the display property to "none", removing the element from the +rendering hierarchy so it takes up no space. To show the element, the default +inherited display property is restored (defined either in stylesheets or by +the browser's default style rules.) + +Caveat 1: if the inherited display property for the element is set to "none" +by the stylesheets, that is the property that will be restored by a call to +showElement(), effectively toggling the display between "none" and "none". + +Caveat 2: if the element display style is set inline (by setting either +element.style.display or a style attribute in the HTML), a call to +showElement will clear that setting and defer to the inherited style in the +stylesheet. | |
toCamelCase(<Any Type> selector) ⇒ string Converts a CSS selector in the form style-property to styleProperty. | |
toSelectorCase(string selector) ⇒ string Converts a CSS selector in the form styleProperty to style-property. | |
toStyleAttribute(?Object obj) ⇒ string Reverse of parseStyleAttribute; that is, takes a style object and returns the +corresponding attribute value. Converts camel case property names to proper +CSS selector names. | |
translateRectForAnotherFrame(?goog.math.Rect rect, ?goog.dom.DomHelper origBase, ?goog.dom.DomHelper newBase) Translates the specified rect relative to origBase page, for newBase page. +If origBase and newBase are the same, this function does nothing. | |
uninstallStyles((Element|StyleSheet|null) styleSheet) Removes the styles added by {@link #installStyles}. |
Default implementation of UI component.
extends goog.events.EventTargetInstance Method Summary | |
addChild(?goog.ui.Component child, boolean= opt_render) Adds the specified component as the last child of this component. See +{@link goog.ui.Component#addChildAt} for detailed semantics. | |
addChildAt(?goog.ui.Component child, number index, boolean= opt_render) Adds the specified component as a child of this component at the given +0-based index. + +Both {@code addChild} and {@code addChildAt} assume the following contract +between parent and child components: +
| |
canDecorate(?Element element) ⇒ boolean Determines if a given element can be decorated by this type of component. +This method should be overridden by inheriting objects. | |
createDom() Creates the initial DOM representation for the component. The default +implementation is to set this.element_ = div. | |
decorate(?Element element) Decorates the element for the UI component. | |
decorateInternal(?Element element) Actually decorates the element. Should be overridden by inheriting objects. +This method can assume there are checks to ensure the component has not +already been rendered have occurred and that enter document will be called +afterwards. This method is considered protected. | |
disposeInternal() Disposes of the component. Calls {@code exitDocument}, which is expected to +remove event handlers and clean up the component. Propagates the call to +the component's children, if any. Removes the component's DOM from the +document unless it was decorated. | |
enterDocument() Called when the component's element is known to be in the document. Anything +using document.getElementById etc. should be done at this stage. + +If the component contains child components, this call is propagated to its +children. | |
exitDocument() Called by dispose to clean up the elements and listeners created by a +component, or by a parent component/application who has removed the +component from the document but wants to reuse it later. + +If the component contains child components, this call is propagated to its +children. + +It should be possible for the component to be rendered again once this method +has been called. | |
forEachChild(?Function f, ?Object= opt_obj) Calls the given function on each of this component's children in order. If +{@code opt_obj} is provided, it will be used as the 'this' object in the +function when called. The function should take two arguments: the child +component and its 0-based index. The return value is ignored. | |
getChild(string id) ⇒ ?goog.ui.Component Returns the child with the given ID, or null if no such child exists. | |
getChildAt(number index) ⇒ ?goog.ui.Component Returns the child at the given index, or null if the index is out of bounds. | |
getChildCount() ⇒ number Returns the number of children of this component. | |
getChildIds() ⇒ ?Array.<string> Returns an array containing the IDs of the children of this component, or an +empty array if the component has no children. | |
getContentElement() ⇒ ?Element Returns the DOM element into which child components are to be rendered, +or null if the component itself hasn't been rendered yet. This default +implementation returns the component's root element. Subclasses with +complex DOM structures must override this method. | |
getDomHelper() ⇒ !goog.dom.DomHelper Returns the dom helper that is being used on this component. | |
getElement() ⇒ ?Element Gets the component's element. | |
getElementByClass(string className) ⇒ ?Element Returns the first element in this component's DOM with the provided +className. | |
getElementByFragment(string idFragment) ⇒ ?Element Helper function for returning an element in the document with a unique id +generated using makeId(). | |
getElementsByClass(string className) ⇒ !goog.array.ArrayLike Returns an array of all the elements in this component's DOM with the +provided className. | |
getFragmentFromId(string id) ⇒ string Helper function for returning the fragment portion of an id generated using +makeId(). | |
getHandler() ⇒ !goog.events.EventHandler Returns the event handler for this component, lazily created the first time +this method is called. | |
getId() ⇒ string Gets the unique ID for the instance of this component. If the instance +doesn't already have an ID, generates one on the fly. | |
getModel() ⇒ <Any Type> Returns the model associated with the UI component. | |
getParent() ⇒ ?goog.ui.Component Returns the component's parent, if any. | |
hasChildren() ⇒ boolean Returns true if the component has children. | |
indexOfChild(?goog.ui.Component child) ⇒ number Returns the 0-based index of the given child component, or -1 if no such +child is found. | |
isInDocument() ⇒ boolean Determines whether the component has been added to the document. | |
isRightToLeft() ⇒ boolean Returns true if the component is rendered right-to-left, false otherwise. +The first time this function is invoked, the right-to-left rendering property +is set if it has not been already. | |
makeId(string idFragment) ⇒ string Helper function for subclasses that gets a unique id for a given fragment, +this can be used by components to generate unique string ids for DOM +elements. | |
makeIds(?Object object) ⇒ ?Object Makes a collection of ids. This is a convenience method for makeId. The +object's values are the id fragments and the new values are the generated +ids. The key will remain the same. | |
removeChild((goog.ui.Component|null|string) child, boolean= opt_unrender) ⇒ ?goog.ui.Component Removes the given child from this component, and returns it. Throws an error +if the argument is invalid or if the specified child isn't found in the +parent component. The argument can either be a string (interpreted as the +ID of the child component to remove) or the child component itself. + +If {@code opt_unrender} is true, calls {@link goog.ui.component#exitDocument} +on the removed child, and subsequently detaches the child's DOM from the +document. Otherwise it is the caller's responsibility to clean up the child +component's DOM. | |
removeChildAt(number index, boolean= opt_unrender) ⇒ ?goog.ui.Component Removes the child at the given index from this component, and returns it. +Throws an error if the argument is out of bounds, or if the specified child +isn't found in the parent. See {@link goog.ui.Component#removeChild} for +detailed semantics. | |
removeChildren(boolean= opt_unrender) Removes every child component attached to this one. | |
render(?Element= opt_parentElement) Renders the component. If a parent element is supplied, the component's +element will be appended to it. If there is no optional parent element and +the element doesn't have a parentNode then it will be appended to the +document body. + +If this component has a parent component, and the parent component is +not in the document already, then this will not call {@code enterDocument} +on this component. + +Throws an Error if the component is already rendered. | |
renderBefore(?Node sibling) Renders the component before another element. The other element should be in +the document already. + +Throws an Error if the component is already rendered. | |
render_(?Element= opt_parentElement, ?Node= opt_beforeNode) Renders the component. If a parent element is supplied, the component's +element will be appended to it. If there is no optional parent element and +the element doesn't have a parentNode then it will be appended to the +document body. + +If this component has a parent component, and the parent component is +not in the document already, then this will not call {@code enterDocument} +on this component. + +Throws an Error if the component is already rendered. | |
setElementInternal(?Element element) Sets the component's root element to the given element. Considered +protected and final. + +This should generally only be called during createDom. Setting the element +does not actually change which element is rendered, only the element that is +associated with this UI component. | |
setId(string id) Assigns an ID to this component instance. It is the caller's responsibility +to guarantee that the ID is unique. If the component is a child of a parent +component, then the parent component's child index is updated to reflect the +new ID; this may throw an error if the parent already has a child with an ID +that conflicts with the new ID. | |
setModel(<Any Type> obj) Sets the model associated with the UI component. | |
setParent(?goog.ui.Component parent) Sets the parent of this component to use for event bubbling. Throws an error +if the component already has a parent or if an attempt is made to add a +component to itself as a child. Callers must use {@code removeChild} +or {@code removeChildAt} to remove components from their containers before +calling this method. | |
setParentEventTarget(?goog.events.EventTarget parent) Overrides {@link goog.events.EventTarget#setParentEventTarget} to throw an +error if the parent component is set, and the argument is not the parent. | |
setRightToLeft(boolean rightToLeft) Set is right-to-left. This function should be used if the component needs +to know the rendering direction during dom creation (i.e. before +{@link #enterDocument} is called and is right-to-left is set). | |
wasDecorated() ⇒ boolean |
Static Method Summary | |
getStateTransitionEvent(?goog.ui.Component.State state, boolean isEntering) ⇒ ?goog.ui.Component.EventType Static helper method; returns the type of event components are expected to +dispatch when transitioning to or from the given state. | |
setDefaultRightToLeft(?boolean rightToLeft) Set the default right-to-left value. This causes all component's created from +this point foward to have the given value. This is useful for cases where +a given page is always in one directionality, avoiding unnecessary +right to left determinations. |
Creates a new id generator.
Instance Method Summary | |
getNextUniqueId() ⇒ string Gets the next unique ID. |
Function Summary | |
compare(string v1, string v2) ⇒ number Compares two version numbers. | |
determinePlatform_() ⇒ string | |
determineVersion_() ⇒ string | |
getDocumentMode_() ⇒ (number|undefined) | |
getNavigator() ⇒ ?Object | |
getUserAgentString() ⇒ ?string Returns the userAgent string for the current browser. +Some user agents (I'm thinking of you, Gears WorkerPool) do not expose a +navigator object off the global scope. In that case we return null. | |
initPlatform_() Initialize the goog.userAgent constants that define which platform the user +agent is running on. | |
init_() Initializer for goog.userAgent. + +This is a named function so that it can be stripped via the jscompiler +option for stripping types. | |
isDocumentMode(number documentMode) ⇒ boolean Whether the IE effective document mode is higher or the same as the given +document mode version. +NOTE: Only for IE, return false for another browser. | |
isVersion((number|string) version) ⇒ boolean Whether the user agent version is higher or the same as the given version.
+NOTE: When checking the version numbers for Firefox and Safari, be sure to
+use the engine's version, not the browser's version number. For example,
+Firefox 3.0 corresponds to Gecko 1.9 and Safari 3.0 to Webkit 522.11.
+Opera and Internet Explorer versions match the product release number. |
Instance Method Summary | |
create() | |
del() | |
onCreateComplete_(?mvc.Model model, ?Function callback, ?goog.events.Event e) override this to do processing on returned data | |
onDelComplete_(?mvc.Model model, ?Function callback, ?Event e) override this to do processing on returned data | |
onReadComplete_(?mvc.Model model, ?Function callback, ?goog.events.Event e) override this to do processing on returned data | |
onUpdateComplete_(?mvc.Model model, ?Function callback, ?Event e) override this to do processing on returned data | |
read() | |
update() | |
urlifyString(string val) ⇒ function ((mvc.Model|null)): string takes a string defining a url where :attribute will return that models +attribute. e.g. + +var obj = new mvc.Model({attrs:{'id': 'fred'}}); +var urlGen = urlifyString("/object=:id/blah"); +urlGen(obj); // returns "/object=fred/blah" |
A collection of models. Extends model so it has it's own values
extends mvc.ModelInstance Method Summary | |
add((Array|mvc.Model|null) model, number= opt_ind, boolean= opt_silent) ⇒ boolean accepts a model or array of models and adds them at the end unless an index +to insert is given. | |
at(number index) ⇒ ?mvc.Model get a model by it's index in the collection | |
change_() | |
clear(boolean= opt_silent) remove all models from the collection | |
getById(string id) ⇒ ?mvc.Model get a model by it's ID | |
getLength() ⇒ number returns the number of models in the collection | |
getModels((function ((mvc.Model|null)): (Boolean|null)=) opt_filter) ⇒ ?Array get all the models, optionally filter by function | |
modelChange(?Function fn, ?Object= opt_handler) ⇒ number use this to bind functions to a change in any of the collections models | |
newModel(?Object= opt_options, boolean= opt_silent) ⇒ ?mvc.Model add a new model with the given options. The type of model is given by the +modelType of the collection | |
pluck((Array|null|string) key) ⇒ ?Array.<(Object.<*>|null)> plucks an attribute from each model and returns as an array. If you pass +an array of keys then the array will contain a map of each key and it's +value | |
remove((Array|mvc.Model|null) model, boolean= opt_silent) remove the given model from the collection | |
setComparator(function ((mvc.Model|null), (mvc.Model|null)): number fn, boolean= opt_silent) function to sort models by. Function should take two models and +return -1, 0 or 1. Also takes whether to fire a change event after sorting | |
sort(boolean= opt_silent) tells the collection to sort it's models. This is used internally | |
unbind(number id) ⇒ boolean unbind a listener by id |
instantiate with a mvc.Model
extends goog.ui.ComponentInstance Method Summary | |
click(?Function fn, (Array.<string>|null|string=) opt_className, <Any Type> opt_handler, number= opt_priority) ⇒ number same as on but assumes the event type is a click | |
getEls(string selector) ⇒ ?goog.array.ArrayLike pass in a string like "#elementId", ".className" or "tagName[ .className]" +to get array of elements with the id, class or tag and class name | |
handleEvents_(string type, ?Event e) Internal use. Handles and delegates events | |
off(string uid) take off a lister by it's id' | |
on(string eventName, ?Function fn, (Array.<string>|null|string=) opt_className, <Any Type> opt_handler, number= opt_priority) ⇒ number delegating events. An event type is needed as well as a handling function. +if a third parameter is passed then elements with that class will be +listened to, otherwise the whole component. Returns a uid that can be used +to end the listener with the off method | |
once(string eventName, ?Function fn, (Array.<string>|null|string=) opt_className, <Any Type> opt_handler, number= opt_priority) ⇒ number same as on, but will only fire once | |
remove() remove the element and dispose |
Instance Method Summary | |
create() | |
del() | |
getUID() ⇒ string | |
read() | |
update() |
Instance Method Summary | |
broadcast(string message, <Any Type> opt_args) broadcast the message to the listeners | |
isListened(string message) ⇒ boolean check to see if anyone is listening for a message | |
off(number uid) remove the listener by it's id | |
on((Array.<string>|null|string) message, ?Object fn, ?Object= opt_handler) ⇒ ?number the message to listen for and the handler. Can either be a function to run +or an object of the type: {init:Function, fn:Function, dispose:Function} +which will run init when the message becomes available and dispose when +a message is no longer supported. Returns a uid that can be used with +off to remove the listener | |
once(string message, ?Function handler) ⇒ number this will only run the function the first time the message is given | |
register(?Object obj, ?Array.<string> messages) lets components know that a message can be fired by an object. | |
reset() reset the mediator to it's original state | |
unregister(?Object obj, ?Array.<string>= opt_messages) removes the object from the register for that message |
Pass an object with key value pairs for the attributes of the model
extends goog.events.EventTargetInstance Method Summary | |
addSchemaRules(?Object schema) adds more rules to the schema | |
alias(string newName, string oldName) Can be used to create an alias, e.g: +model.alias('surname', 'lastName'); | |
bind((Array|null|string) name, ?Function fn, <Any Type> opt_handler) ⇒ number Allows easy binding of a model's attribute to an element or a function. +bind('name', function(value), handler) allows you to run a function and +optionally bind it to the handler. You can also pass in an array of names +to listen for a change on any of the attributes. | |
bindAll(?Function fn, ?Object= opt_handler) ⇒ number bind to any change event | |
bindUnload(?Function fn, ?Object= opt_handler) ⇒ number | |
change() fires the change event for the model | |
change_() function called when a change is detected on the object. Call the model's +.change() function to fire manually | |
dispose(boolean= opt_sync) | |
fetch((function ((Object|null), number, (mvc.Model|null)): ?=) opt_callback) reads an object fomr an external source using sync | |
format(string attr, ?Function fn) Can be used to change format returned when using get, e.g: +model.format('date', function(date) {return date.toDateString();}); | |
get(string key, <Any Type> opt_default) ⇒ <Any Type> gets the value for an attribute | |
getBinder(string key) ⇒ ?Function can use this to construct setters. For instance if you would set a value +like: +model.set('location:latitude', number); +you can make a convenience method like this: +model.lat = model.getBinder('location:latitude'); +and then you only need to use: +model.lat(number); // to set +var lat = model.lat(); // to get | |
getChanges() ⇒ ?Array.<string> returns object of changed attributes and their values | |
getCid() ⇒ string return local id | |
has(string key) ⇒ boolean | |
isNew() ⇒ boolean returns whether an ID has been set by the server | |
meta(string attr, ?Array.<string> require, ?Function fn) Can be used to make an attribute out of other attributes. This can be bound +and will fire whenever a change is made to the required attributes e.g. +model.meta('fullName', ['firstName', 'lastName'], +function(firstName, lastName){ +return firstName + " " + lastName; +}); | |
parseSchemaFn_(<Any Type> fn) ⇒ ?Function used internally to parse strings and regexes in to functions | |
prev(string key) ⇒ <Any Type> returns the previous value of the attribute | |
reset(boolean= opt_silent) removes all attributes | |
revert(boolean= opt_silent) ⇒ ?mvc.Model reverts an object's values to it's last fetch | |
save() pushes the object to the sync | |
set((Object|null|string) key, <Any Type> opt_val, boolean= opt_silent) ⇒ boolean set either a map of key values or a key value | |
setSchema(?Object schema) sets the schema | |
setSync(?mvc.Sync sync) sets the sync for the model | |
setter(string attr, ?Function fn) | |
toJson() ⇒ !Object returns full copy of the attributes | |
unbind(number id) ⇒ boolean unbind a listener by id | |
unset(string key, boolean= opt_silent) ⇒ boolean |
Static Method Summary | |
create(?Object= opt_options) ⇒ ?mvc.Model instead of doing: model = new mvc.Model(options); +you can do: mvc.Model.create(options); |
Instance Method Summary | |
navigate(string fragment) pass through the fragment for the URL | |
onChange_() | |
route((RegExp|null|string) route, ?Function fn) define route as string or regex. /:abc/ will pass "abc" through as an +argument. *abc/def will pass through all after the * as an argument |
Instance Method Summary | |
get(string= opt_input, function (): ?= opt_model) ⇒ ?mvc.Model takes two arguments. The model's id (or leave out to create a new model) +and the type of model to create if none found in cache | |
set((Array|mvc.Model|null) models) this is used to setup the store from cache |