Namespace i$
The global namespace of the IBM Client API
Defined in: core_ext_layer.js.uncompressed.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
The global namespace of the IBM Client API
|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
i$.global
Refers to the global namespace, by default the window object.
|
| <static> |
i$.isChrome
Value indicating the version of Chrome being used; undefined
otherwise.
|
| <static> |
i$.isFF
Value indicating the version of Firefox being used; undefined
otherwise.
|
| <static> |
i$.isIE
Value indicating the version of Internet Explorer being used; undefined
otherwise.
|
| <static> |
i$.isOpera
Value indicating the version of Opera being used; undefined
otherwise.
|
| <static> |
i$.isSafari
Value indicating the version of Safari being used; undefined
otherwise.
|
| <static> |
i$.isWebKit
Value indicating the version of WebKit being used; undefined
otherwise.
|
| <static> |
Defines a promise which is resolved when the page has finished loading,
more specifically when the browser issues the onload event.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
i$.addClass(node, className)
Adds the specified class to the given DOM node.
|
| <static> |
i$.addListener(name, func)
Registers a callback function for a given event name.
|
| <static> |
i$.addOnLoad(func, scope)
Adds a function to call on page load
|
| <static> |
i$.addOnUnload(func, scope)
Adds a function to call on page unload.
|
| <static> |
i$.addQueryString(an, obj)
Adds a query string to a given URI.
|
| <static> |
i$.augment(func, props)
Like i$.mash but mashes properties into the function's prototype.
|
| <static> |
i$.bindDomEvt(node, name, func)
Binds a function to a DOM event such as 'onmouseleave'.
|
| <static> |
i$.byId(id)
This is a simple alias to document.getElementById, which is shorter to write.
|
| <static> |
i$.cachedFn(func, scope)
Wraps a function into a singleton-factory builder such that on the first function call,
it calls the wrapped function and stores its return value then returns it.
|
| <static> |
i$.createDom(name, attrs, parent)
This method create a new DOM node with given attributes and adds it
into the DOM at the same time if required
|
| <static> |
i$.deleteCookie(name, path, domain)
Deletes a cookie.
|
| <static> |
i$.each(obj, func, scope)
Enumerates over all properties of obj if obj is an object, or all items in obj if it is an array or is
like an array (see i$.isLikeArray), calling function func in optional scope (defaulting to the global scope)
for each enumerated value.
|
| <static> |
i$.every(arr, func, scope)
Tests whether all elements in the array pass the test implemented by the provided function.
|
| <static> |
i$.fireEvent(name, payload)
Fires an event with a payload and sends it to all registered listeners of the given event name
|
| <static> |
i$.fromJson(str)
Parses a JSON string to return a JavaScript object.
|
| <static> |
i$.fromPath(namepath, create, scope)
Gets whatever value is resolved by the dot-delimited namepath in the property chain of the scope object,
which defaults to the global scope if none is provided.
|
| <static> |
i$.fromQuery(query)
Returns an associative map of type object with the parsed values of the given string.
|
| <static> |
i$.getCookie(name)
Gets a cookie.
|
| <static> |
i$.hasClass(node, className)
Determine whether the given DOM node is assigned the given class.
|
| <static> |
i$.isArray(obj)
Determines if an object is an array or not.
|
| <static> |
i$.isBoolean(obj)
Determines if an object is a boolean or not.
|
| <static> |
i$.isDescendant(node, ancestor)
Determines whether the specified node is a descendant of the ancestor.
|
| <static> |
i$.isFunction(obj)
Determines if an object is a function or not.
|
| <static> |
i$.isLikeArray(obj)
Determines if an object is array like or not.
|
| <static> |
i$.isNode(obj)
Determines if an object is a DOM node or not.
|
| <static> |
i$.isNumber(obj)
Determines if an object is a number or not.
|
| <static> |
i$.isObject(obj)
Determines if an object is an object or not.
|
| <static> |
i$.isRTL(locale)
Determines whether a certain locale is a right to left language.
|
| <static> |
i$.isString(obj)
Determines if an object is a string or not.
|
| <static> |
i$.loadScript(args)
Loads JavaScript at some URL via a script tag in the head of the page
allowing asynchronous handling of scripts that may be in the same domain
as the current one or across domains.
|
| <static> |
i$.make(proto, props)
Creates and returns a new object whose prototype is the proto argument.
|
| <static> |
i$.mash(obj, props)
Enumerates over arguments, mashing all the native properties of each argument
object into the first argument object, returning the first.
|
| <static> |
i$.mashSpec(names, obj, props)
Like i$.mash but only mashes properties whose names are in the names array first
argument.
|
| <static> |
i$.merge(obj, target, path)
Merges a value object's properties into the target object.
|
| <static> |
i$.partial(func, args)
Generates a partial function based on an existing function.
|
| <static> |
i$.removeClass(node, className)
Remove a single class from the given DOM node.
|
| <static> |
i$.removeListener(handle)
Removes a listener from the given event name, based on previously received connection data.
|
| <static> |
i$.scope(obj, func, args)
Generates a partial function based on an existing function but fixes the scope in which the
partial function is called regardless of the eventual calling scope.
|
| <static> |
i$.setCookie(name, value, expiry, path, domain, secure)
Sets a cookie.
|
| <static> |
i$.shadow(source, target, names, overwrite)
Creates shadowing functions on target that call the underlying functions on the shadowed source referred
to by source.
|
| <static> |
i$.some(arr, func, scope)
Tests whether some element in the array passes the test implemented by the provided function.
|
| <static> |
i$.toArray(obj)
Returns a true array from obj, creating a copy if obj is already an array.
|
| <static> |
i$.toggleClass(node, className)
Add or remove one class from the given DOM node.
|
| <static> |
i$.toJson(obj, pretty)
Returns a JSON serialization of an object.
|
| <static> |
i$.toPath(namepath, value, scope)
Sets a value to the dot-delimited path namepath in the property chain of the scope object,
which defaults to the global scope if none is provided.
|
| <static> |
i$.toQuery(obj)
Returns a query string serialization of an object, more specifically an associative map
where names must be of type string.
|
| <static> |
i$.trim(str)
The trim function removes all newlines, spaces (including non-breaking spaces), and tabs
from the beginning and end of the supplied string.
|
| <static> |
i$.unbindDomEvt(binding)
Unbinds a previously bound event.
|
| <static> |
i$.unwrap(obj, name)
Unwraps a previously wrapped function at obj[name] from i$.wrap to its original form and
resets it back.
|
| <static> |
i$.wrap(obj, name, func)
Provides light-weight AOP-style programming with around advice semantics.
|
| <static> |
i$.xhr(method, args)
Sends an AJAX request.
|
| <static> |
i$.xhrDelete(args)
Executes an XmlHttpRequest using the HTTP DELETE method using the same arguments
as i$.xhr except with the first argument pre-filled.
|
| <static> |
i$.xhrGet(args)
Executes an XmlHttpRequest using the HTTP GET method using the same arguments
as i$.xhr except with the first argument pre-filled.
|
| <static> |
i$.xhrPost(args)
Executes an XmlHttpRequest using the HTTP POST method using the same arguments
as i$.xhr except with the first argument pre-filled.
|
| <static> |
i$.xhrPut(args)
Executes an XmlHttpRequest using the HTTP PUT method using the same arguments
as i$.xhr except with the first argument pre-filled.
|
Field Detail
<static>
{Window}
i$.global
Refers to the global namespace, by default the window object.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
{Number}
i$.isChrome
Value indicating the version of Chrome being used; undefined
otherwise.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
{Number}
i$.isFF
Value indicating the version of Firefox being used; undefined
otherwise.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
{Number}
i$.isIE
Value indicating the version of Internet Explorer being used; undefined
otherwise.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
{Number}
i$.isOpera
Value indicating the version of Opera being used; undefined
otherwise.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
{Number}
i$.isSafari
Value indicating the version of Safari being used; undefined
otherwise.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
{Number}
i$.isWebKit
Value indicating the version of WebKit being used; undefined
otherwise.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
<static>
i$.onLoadPromise
Defines a promise which is resolved when the page has finished loading,
more specifically when the browser issues the onload event.
i$.onLoadPromise.then(function() {
// this is called on load
});
Method Detail
<static>
{void}
i$.addClass(node, className)
Adds the specified class to the given DOM node.
- Parameters:
- {DOMNode} node
- the DOM node to add the class on. Must not be null.
- {String} className
- One class name to be added to the class attribute. Must not be null.
<static>
{Object}
i$.addListener(name, func)
Registers a callback function for a given event name.
The event name does not compare to a topic as known from pub/sub mechanisms.
Therefore if an event to 'public/theme/message/error' is registered and somebody is sending something to
'public/theme/message' it will not received by the mapped function.
To register more than one event listener for the event name, call addListener() for the same even name multiple times.
Example 1:
i$.addListener("sport/baseball/catcher",
function(pitch1, pitch2, pitch3) {
alert(pitch1+"/"+pitch2+"/"+pitch3);
});
//pitching
i$.fireEvent("sport/baseball/catcher",
["fastball", "curveball", "homerun"]); // alerts "fastball/curveball/homerun"
Example 2:
i$.addListener("sport/baseball/fielder",
function(hit1, hit2) {
alert(hit1+"/"+hit2);
});
i$.addListener("sport/baseball/fielder",
function(hit1, hit2) {
alert(hit1+"/"+hit2);
});
i$.fireEvent("sport/baseball/fielder",
["slap", "homerun"]); // alerts "slap/homerun" twice
- Parameters:
- {String} name
- name of the event. Must not be null.
- {Function} func
- Callback function to be called when the event is issued. Must not be null.
- Returns:
- {Object} Returns a connection object which must be used again to remove the listener i$.removeListener.
<static>
{void}
i$.addOnLoad(func, scope)
Adds a function to call on page load
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Function|String} func
- The function to call, either a function or name of a function on scope object. Must not be null
- {Object} scope Optional, Default: i$.global
- The scope in which to call the function, i.e. the 'this' keyword within the function represents the scope object
<static>
{void}
i$.addOnUnload(func, scope)
Adds a function to call on page unload. Not supported on Opera.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Function|String} func
- The function to call, either a function or name of a function on scope object. Must not be null.
- {Object} scope Optional, Default: i$.global
- The scope in which to call the function
<static>
{String}
i$.addQueryString(an, obj)
Adds a query string to a given URI. If the URI has already query parameters
additional query parameters will be concatenated to the existing URI.
Example 1:
var str = i$.addQueryString("http://foo.bar", {
"cat" : "chases",
"mouse" : ["runs", "hides"]
});
alert(str); // alerts "http://foo.bar?cat=chases&mouse=runs&mouse=hides"
Example 2:
var str = i$.addQueryString("http://foo.bar?foo=baz", {
"cat" : "chases",
"mouse" : ["runs", "hides"]
});
alert(str); // alerts "http://foo.bar?foo=baz&cat=chases&mouse=runs&mouse=hides"
- Parameters:
- {String} an
- URI with or without query string params. Must not be null
- {Object} obj
- The JavaScript object to serialize. Must not be null
- Returns:
- {String} an URI where the input URI and input query string has been appended
<static>
{Function}
i$.augment(func, props)
Like i$.mash but mashes properties into the function's prototype.
Properties with the same name are resolved by using the last
argument that contains that property.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
var visuals = {
color: "white"
};
var structural = {
make: "sedan"
};
i$.augment(Car, visuals, structural);
is functionally equivalent to:
Car.prototype.color = "white";
Car.prototype.make = "sedan";
- Parameters:
- {Function} func
- Function whose prototype should be augmented. Must not be null.
- {Object} props
- Objects to mash properties into the prototype. Must not be null.
- Returns:
- {Function} Returns func again which has been passed into the augment function
<static>
{Object}
i$.bindDomEvt(node, name, func)
Binds a function to a DOM event such as 'onmouseleave'.
- Parameters:
- {DOMNode} node
- node to bind the event on. Must not be null.
- {String} name
- name of the event to bind. Must not be null.
- {Function} func
- Callback function to be called when the event is issued. Must not be null.
- Returns:
- {Object} Returns a connection object which must be used again to unbind the event i$.unbindDomEvt.
<static>
{void}
i$.byId(id)
This is a simple alias to document.getElementById, which is shorter to write.
- Parameters:
- {String} id
- The id of the DOM node to be returned. Must not be null.
<static>
{Function}
i$.cachedFn(func, scope)
Wraps a function into a singleton-factory builder such that on the first function call,
it calls the wrapped function and stores its return value then returns it. On subsequent
calls, it just returns the original value.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
var singleton = i$.cachedFn(function() {
alert("hello");
return true;
});
singleton(); // alerts "hello"
singleton(); // does not alert anything, just returns true
- Parameters:
- {Function} func
- the function to be called the first time. Must not be null.
- {Object} scope Optional
- Object optional scope to call func in
- Returns:
- {Function} Returns the singleton factory function. Never null.
<static>
{DOMNode}
i$.createDom(name, attrs, parent)
This method create a new DOM node with given attributes and adds it
into the DOM at the same time if required
Example 1: Creates a new div element which is not part of any DOM (yet).
var divElement = i$.createDom("div");
Example 2: Inserts a new input element into a 'form' with the attributes, type, name, value
i$.createDom("input", {
"type": "hidden",
"name": "x-method-override",
"value": method.toUpperCase()
}, form);
- Parameters:
- {String} name
- DOM node name, examples are "div", "a" and "span". Must not be null.
- {Object} attrs Optional
- associative map defining name and value to be set on the new DOM node.
- {DOMNode} parent Optional
- The parent DOM node under which the newly created node should be inserted. If this is not defined the DOM node will not be inserted into the DOM and must be added manually afterwards.
- Returns:
- {DOMNode} Returns the newly created DOM node. Never null.
<static>
{void}
i$.deleteCookie(name, path, domain)
Deletes a cookie.
- Parameters:
- {String} name
- The name of the cookie to delete. Must not be null.
- {String} path Optional
- The path for the cookie (must be the same as the path used to create the cookie). Defaults to / (the entire site) if not specified.
- {String} domain Optional
- The domain of the cookie (must be the same as the domain used to create the cookie). Defaults to the domain of the calling document if not specified.
<static>
{void}
i$.each(obj, func, scope)
Enumerates over all properties of obj if obj is an object, or all items in obj if it is an array or is
like an array (see i$.isLikeArray), calling function func in optional scope (defaulting to the global scope)
for each enumerated value.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object|Array} obj
- Object or Array to enumerate. Must not be null
- {Function} func
- Function with signature function(value, index|propName, originalObject) to call for each property or index. Must not be null
- {Object} scope Optional, Default: i$.global
- Object optional scope to call func in
<static>
{Boolean}
i$.every(arr, func, scope)
Tests whether all elements in the array pass the test implemented by the provided function.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Array|ArrayLike} arr
- Array to search; may simply be like an array. Must not be null.
- {Function} func
- Function with signature function(value) to call for each property or index. Must not be null.
- {Object} scope Optional, Default: i$.global
- Object optional scope to call func in
- Returns:
- {Boolean} Returns true if calling function func on each of the items in arr never returns false; false otherwise.
<static>
{i$.promise.Promise}
i$.fireEvent(name, payload)
Fires an event with a payload and sends it to all registered listeners of the given event name
i$.addListener("sport/baseball/batter",
function(pitch) {
alert("hitting "+pitch);
});
//pitching
i$.fireEvent("sport/baseball/batter", ["fastball"]) // alerts "hitting fastball"
.then(function() {
alert("event received");
});
- Parameters:
- {String} name
- name of the event. Must not be null.
- {Array} payload
- The payload as array to be sent to all registered listeners.
- Returns:
- {i$.promise.Promise} TBD
<static>
{Object}
i$.fromJson(str)
Parses a JSON string to return a JavaScript object.
- Parameters:
- {String} str
- the JSON string. Must not be null
- Returns:
- {Object} An object with all values of the JSON string. Never null.
<static>
{Object}
i$.fromPath(namepath, create, scope)
Gets whatever value is resolved by the dot-delimited namepath in the property chain of the scope object,
which defaults to the global scope if none is provided. Conditionally creates the path if any
part of it does not exist, setting empty objects at each null or undefined segment in the path.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
Example 1:
var obj = i$.fromPath("com.ibm.theme.feature");
alert(obj); // alerts "null"
Example 2:
var obj = i$.fromPath("com.ibm.theme.feature", true);
alert(obj===com.ibm.theme.feature); // alerts "true"
Example 3:
var obj1 = i$.fromPath("com.ibm.theme", true);
var obj2 = i$.fromPath("feature", true, obj1);
alert(obj2===com.ibm.theme.feature); // alerts "true"
- Parameters:
- {String} namepath
- String with dot-delimited segments that refer to a name path to an object. Must not be null.
- {Boolean} create Optional, Default: false
- Boolean value that instructs the function to create the name path if it does not exist completely.
- {Object} scope Optional, Default: i$.global
- Object to begin the lookup for the name path resolution.
- Returns:
- {Object} the path object or null.
<static>
{Object}
i$.fromQuery(query)
Returns an associative map of type object with the parsed values of the given string.
Multi-values are represented as arrays.
i$.fromQuery("cat=chases&mouse=runs&mouse=hides");
// returns an object with the following format:
// {
// "cat" : "chases",
// "mouse" : ["runs", "hides"]
// }
- Parameters:
- {String} query
- The query string to parse. Must not be null
- Returns:
- {Object} The object representing the query string.
<static>
{String}
i$.getCookie(name)
Gets a cookie.
- Parameters:
- {String} name
- The name of the cookie to get. Must not be null
- Returns:
- {String} A string that is the value of the cookie, or null if the cookie does not exist.
<static>
{Boolean}
i$.hasClass(node, className)
Determine whether the given DOM node is assigned the given class.
- Parameters:
- {DOMNode} node
- the DOM node to test. Must not be null.
- {String} className
- the class name to test against. Must not be null.
- Returns:
- {Boolean} true if the DOM node has the given class name assigned, false otherwise
<static>
{Boolean}
i$.isArray(obj)
Determines if an object is an array or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is an array, false otherwise.
<static>
{Boolean}
i$.isBoolean(obj)
Determines if an object is a boolean or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is a boolean, false otherwise.
<static>
{Boolean}
i$.isDescendant(node, ancestor)
Determines whether the specified node is a descendant of the ancestor.
- Parameters:
- {DOMNode} node
- node to test. Must not be null.
- {DOMNode} ancestor
- node of potential parent to test against. Must not be null.
- Returns:
- {Boolean} Returns true if the specified node is a descendant of the ancestor, false otherwise
<static>
{Boolean}
i$.isFunction(obj)
Determines if an object is a function or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is a function, false otherwise.
<static>
{Boolean}
i$.isLikeArray(obj)
Determines if an object is array like or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is like an array, namely that it at least has a length property of type number; false otherwise.
<static>
{Boolean}
i$.isNode(obj)
Determines if an object is a DOM node or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is a DOM node, false otherwise.
<static>
{Boolean}
i$.isNumber(obj)
Determines if an object is a number or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is a number, false otherwise.
<static>
{Boolean}
i$.isObject(obj)
Determines if an object is an object or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is an object, false otherwise.
<static>
{Boolean}
i$.isRTL(locale)
Determines whether a certain locale is a right to left language.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {String} locale
- The locale to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if locale is right to left, false otherwise.
<static>
{Boolean}
i$.isString(obj)
Determines if an object is a string or not.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- Object to be tested. Must not be null.
- Returns:
- {Boolean} Returns true if obj is a string, false otherwise.
<static>
{i$.promise.Promise}
i$.loadScript(args)
Loads JavaScript at some URL via a script tag in the head of the page
allowing asynchronous handling of scripts that may be in the same domain
as the current one or across domains.
- Parameters:
- {Object} args
- A config object used to refine how the request is processed.
- {String} args.url
- url to which the request should be sent, required
- {Function} args.callback Optional
- Function to call when the request completes, with the following signature: function(success, data){}
- {Number} args.timeout Optional
- A timeout, if exceeded cancels the XHR and rejects the returned promise.
- {Object} args.scriptAttrs Optional
- map of attributes to add to the script
- Returns:
- {i$.promise.Promise} A promise that resolves to a simple string 'responseData' on success or 'error' on failure. Chaining promises to this one should not change the structure of the resolved value in delegated promises unless their consumers aren't expecting the resolved value to be in the JSON structure produced by this i$.xhr API call. Modifying the value to implement filtering promise chains is properly done by modifying the resolved value's data property and returning either the resolved value again or an undefined value to ensure the consumers can safely assume the same JSON structure in their callbacks.
<static>
{Object}
i$.make(proto, props)
Creates and returns a new object whose prototype is the proto argument. This provides
a light-weight API for building prototypal inheritance structures without
constructing instances of the o argument. All arguments after the proto argument
are used to mash properties into the new object just like i$.mash.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} proto
- Object to use as the prototype of the returned object. Must not be null.
- {Object} props
- Objects to mash properties into the prototype. Must not be null.
- Returns:
- {Object} A new object. Never null.
<static>
{Function}
i$.mash(obj, props)
Enumerates over arguments, mashing all the native properties of each argument
object into the first argument object, returning the first. Properties with the
same name are resolved by using the last argument that contains that property.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
var bag1 = {
prop1: "value",
prop2: "Pass"
};
var bag2 = {
prop2: 15
};
i$.mash(stash, bag1, bag2);
is functionally equivalent to:
stash.prop1 = "value";
stash.prop2 = "Pass";
stash.prop2 = 15;
- Parameters:
- {Object} obj
- Target object to get new property values from subsequent arguments. Must not be null.
- {Object} props
- Objects to mash properties into the prototype. Must not be null.
- Returns:
- {Function} Returns obj again which has been passed into the mash function
<static>
{Function}
i$.mashSpec(names, obj, props)
Like i$.mash but only mashes properties whose names are in the names array first
argument. The same semantics as i$.mash are applied except that the arguments
are shifted by one to accommodate the names argument. This is useful for only mashing
certain known properties from various objects into a target.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {String[]} names
- An array of property names to mash. Must not be null.
- {Object} obj
- Target object to get new property values from subsequent arguments. Must not be null.
- {Object} props
- Objects to mash properties from. Must not be null.
- Returns:
- {Function} Returns obj again which has been passed into the mashSpec function
<static>
{Object|Array}
i$.merge(obj, target, path)
Merges a value object's properties into the target object. If value and target are both
arrays then a resulting merged array is created, otherwise all object properties are
merged from value into target.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
Example 1:
var visuals = {
color: "white"
};
var structural = {
make: "sedan"
};
var car = {};
i$.merge(visuals, car);
i$.merge(structural, car);
Result:
car = {
color: "white",
make: "sedan"
};
Example 2: var car = ["4 doors"]; i$.merge(["white","sedan"], car); Result: car = ["4 doors", "white", "sedan"]
- Parameters:
- {Object|Array} obj
- Either object or array/array-like object to merge into the target object. Must not be null.
- {Object|Array} target Optional, Default: i$.global
- The target object or array
- path
- Returns:
- {Object|Array} Returns the merged object target. Same type as the target object that was passed in.
<static>
{Function}
i$.partial(func, args)
Generates a partial function based on an existing function. The first argument denotes the
function to create a new partial for. All subsequent arguments after that are used to
prefill the original function's parameters with fixed values whenever the partial is
called. Any undefined values in the arguments list will be used as a placeholder to
shift in the actual calling arguments. Any calling arguments that are left over after
shifting into placeholder locations will be concatenated to the end of the resulting
arguments that are passed to the original function as if they were default placeholders.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
Example 1
var f = i$.partial(function(a, b, c){
alert(a + " - " + b + " - " + c);
}, 1, 5); // fixes the first 2 parameters a and b
f(10); // alerts "1 - 5 - 10"
Example 2
var f = i$.partial(function(a, b, c){
alert(a + " - " + b + " - " + c);
}, 1, undefined, 5); // fixes parameter a and c, and marks b as a placeholder
f(3); // alerts "1 - 3 - 5"
Example 3
var f = i$.partial(function(a, b, c){
alert(a + " - " + b + " - " + c);
}, undefined, 10); // fixes parameter b
f(1, 100); // alerts "1 - 10 - 100"
- Parameters:
- {Function} func
- Function to create a partial from. Must not be null.
- {Mixed} args Optional
- Values to set at fixed positions in the calling context's actual arguments.
- Returns:
- {Function} A new partial function based on f. Never null.
<static>
{void}
i$.removeClass(node, className)
Remove a single class from the given DOM node.
- Parameters:
- {DOMNode} node
- the DOM node to remove the class from. Must not be null.
- {String} className
- One class name to be removed from the class attribute. Must not be null.
<static>
{void}
i$.removeListener(handle)
Removes a listener from the given event name, based on previously received connection data.
var handle = i$.addListener("sport/baseball/catcher",
function(pitch1, pitch2, pitch3) {
alert(pitch1+"/"+pitch2+"/"+pitch3);
});
//pitching
i$.fireEvent("sport/baseball/catcher",
["fastball", "curveball", "homerun"]); // alerts "fastball/curveball/homerun"
i$.removeListener(handle);
i$.fireEvent("sport/baseball/catcher",
["fastball", "curveball", "homerun"]); // no alert
- Parameters:
- {Object} handle
- The connection handle returned from i$.addListener. Must not be null.
<static>
{Function}
i$.scope(obj, func, args)
Generates a partial function based on an existing function but fixes the scope in which the
partial function is called regardless of the eventual calling scope.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
Example 1:
var obj = {a: 1};
var f = i$.scope(obj, function(b, c){
alert(this.a + " - " + b + " - " + c);
});
f(3, 5); // alerts "1 - 3 - 5"
Example 2:
var obj = {a: 1};
var f = i$.scope(obj, function(b, c){
alert(this.a + " - " + b + " - " + c);
}, undefined, 5);
f(3); // alerts "1 - 3 - 5"
- Parameters:
- {Object} obj
- Object to scope the function to so that the returned function always calls func in context of this scope object. Must not be null.
- {Function} func
- Function to scope. Must not be null.
- {Mixed} args Optional
- Arguments with same semantics as i$.partial
- Returns:
- {Function} A new function like i$.partial but fixes the function's scope permanently. Calling this without additional arguments besides obj and func simply creates a new function of the same arity whose scope is fixed to obj.
- See:
- i$.partial
<static>
{void}
i$.setCookie(name, value, expiry, path, domain, secure)
Sets a cookie.
- Parameters:
- {String} name
- The name of the cookie to set. Must not be null.
- {String} value
- The value to set into the cookie. Must not be null.
- {Date} expiry Optional
- The date that the cookie expires. Defaults to 100 years from now if not specified.
- {String} path Optional
- The path for which the cookie is valid. Defaults to / (the entire site) if not specified.
- {String} domain Optional
- The domain of the cookie. Defaults to the domain of the calling document if not specified.
- {boolean} secure Optional
- Whether to secure transmission of the cookie or not. Defaults to unsecure if not specified.
<static>
{void}
i$.shadow(source, target, names, overwrite)
Creates shadowing functions on target that call the underlying functions on the shadowed source referred
to by source. Those functions are called in the source's scope instead of the target's. This allows
building up functions with less code that provide passthroughs to other objects as well as hiding
APIs (Example: read-only).
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
Example 1:
var source = {
say: function(){
alert("I am " + this.name);
},
name: "Sam"
};
var target = {
name: "Mouse"
};
i$.shadow(source, target, ["say"]); // creates a "say" function on target
target.say(); // alerts "I am Mouse"
source.say = function(){ alert(this.name + " I am"); };
target.say(); // alerts "Mouse I am"
Example 2:
var target = {
name: "Mouse",
sourceProp: {
say: function(){
alert("I am " + this.name);
},
name: "Sam"
}
};
i$.shadow("sourceProp", target, ["say"]); // creates a "say" function on target
target.say(); // alerts "I am Mouse"
target.sourceProp.say = function(){ alert(this.name + " I am"); };
target.say(); // alerts "Mouse I am"
- Parameters:
- {String|Object} source
- String|Object refers to the source to delegate functions to. If it is a string, it refers to the name of the property on the scope of the function's execution context. If it is an object, it is accessed directly as a property on that object.
- {Object} target
- Object the target to create new functions on which shadow functions on the source.
- {Array} names
- Array of string names to create function properties for.
- {Boolean} overwrite Optional, Default: false
- Boolean property to specify whether or not the shadowing process should overwrite existing functions on the target with the same name.
<static>
{Boolean}
i$.some(arr, func, scope)
Tests whether some element in the array passes the test implemented by the provided function.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Array|ArrayLike} arr
- Array to search; may simply be like an array. Must not be null.
- {Function} func
- Function with signature function(value) to call for each property or index. Must not be null.
- {Object} scope Optional, Default: i$.global
- Object optional scope to call func in
- Returns:
- {Boolean} Returns true if calling function func on each of the items in arr ever returns true; false otherwise.
<static>
{Array}
i$.toArray(obj)
Returns a true array from obj, creating a copy if obj is already an array. Useful for
coercing array-like structures into true arrays safely.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object|Array} obj
- Array or array-like object to convert into a new array. Must not be null.
- Returns:
- {Array} A new array. Never null.
<static>
{void}
i$.toggleClass(node, className)
Add or remove one class from the given DOM node.
- Parameters:
- {DOMNode} node
- the DOM node. Must not be null.
- {String} className
- One class name to be added or removed from the class attribute. Must not be null.
<static>
{String}
i$.toJson(obj, pretty)
Returns a JSON serialization of an object.
- Parameters:
- {Object} obj
- The JavaScript object to serialize. Must not be null
- {String} pretty Optional, Default: false
- if true the string representation is pretty printed.
- Returns:
- {String} A JSON string representing the JavaScipt object.
<static>
{Mixed}
i$.toPath(namepath, value, scope)
Sets a value to the dot-delimited path namepath in the property chain of the scope object,
which defaults to the global scope if none is provided.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
Example 1:
i$.toPath("com.ibm.theme.feature", {
say: function() {
alert("hello");
}
});
com.ibm.theme.feature.say(); // alerts "hello"
Example 2:
var ibm = i$.fromPath("com.ibm", true);
i$.toPath("theme.feature", {
say: function() {
alert("hello");
}
}, ibm);
com.ibm.theme.feature.say(); // alerts "hello"
- Parameters:
- {String} namepath
- String with dot-delimited parts that refer to a name path to an object. Must not be null. Any null or undefined segments in the path will be initialized to empty objects.
- {Mixed} value
- Any value to set at the last part of the objects resolved by the name path. Must not be null.
- {Object} scope Optional, Default: i$.global
- Object to begin the lookup for the name path resolution.
- Returns:
- {Mixed} the passed in value.
<static>
{String}
i$.toQuery(obj)
Returns a query string serialization of an object, more specifically an associative map
where names must be of type string. Values can either be of type string or array.
Example 1:
var query = i$.toQuery({
"cat" : "chases",
"mouse" : "hides"
});
alert(query); // alerts "cat=chases&mouse=hides"
Example 2:
var query = i$.toQuery({
"cat" : "chases",
"mouse" : ["runs", "hides"]
});
alert(query); // alerts "cat=chases&mouse=runs&mouse=hides"
- Parameters:
- {Object} obj
- The JavaScript object to serialize. Must not be null
- Returns:
- {String} A query string representing the object.
<static>
{String}
i$.trim(str)
The trim function removes all newlines, spaces (including non-breaking spaces), and tabs
from the beginning and end of the supplied string. If these whitespace characters occur
in the middle of the string, they are preserved.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {String} str
- String to be trimmed. Must not be null.
- Returns:
- {String} The trimmed string
<static>
{void}
i$.unbindDomEvt(binding)
Unbinds a previously bound event.
- Parameters:
- {Object} binding
- the connection object which was returned from the i$.bindDomEvt. Must not be null.
<static>
{Function}
i$.unwrap(obj, name)
Unwraps a previously wrapped function at obj[name] from i$.wrap to its original form and
resets it back.
Defined in: main_layer.js.uncompressed.js.
Defined in: main_layer.js.uncompressed.js.
- Parameters:
- {Object} obj
- object to unwrap a function property on. Must not be null.
- {String} name
- name of the object property that references a function to unwrap. Must not be null.
- Returns:
- {Function} the unwrapped function or if no unwrapping possible, the original function again. Never null.
<static>
{Function}
i$.wrap(obj, name, func)
Provides light-weight AOP-style programming with around advice semantics.
Overrides the function at obj[name] with a new function that effectively wraps the previous
one and that has this signature: function(originalFn, arguments)
Normal processing can be continued by returning the return value from calling
originalFn.apply(this, arguments).
The modified object property is tagged such that it can be unwrapped to restore its
original form using i$.unwrap.
Defined in: main_layer.js.uncompressed.js.
Note: A function property may be wrapped multiple times, but is modeled as a stack such that i$.unwrap will only unwrap the top wrapping layer at that point in time.
Defined in: main_layer.js.uncompressed.js.
Example:
var car = {
drive: function(){
console.log("Driving");
}
};
i$.wrap(car, "drive", function(originalFn, args) {
if(!isIcy) {
return originalFn.apply(this, args);
}
else {
console.warn("It is too icy!");
}
});
- Parameters:
- {Object} obj
- object to wrap a function property on. Must not be null.
- {String} name
- name of the object property that references a function to wrap. Must not be null.
- {Function} func
- function to replace the original with that has the signature function(originalFn, args). Must not be null.
- Returns:
- {Function} the wrapped function. Never null.
<static>
{i$.promise.Promise}
i$.xhr(method, args)
Sends an AJAX request.
- Parameters:
- {String} method Optional, Default: "get"
- HTTP method such as "get or "post", default = "get"
- {Object} args
- A config object used to refine how the request is processed.
- {String} args.url
- url to which the request should be sent, required
- {String} args.sync Optional, Default: false
- HTTP method such as "get or "post", default = "get"
- {Function} args.callback Optional
- Function to call when the request completes, with the following signature: function(responseBody, httpStatus, statusText){}
- {Object} args.headers Optional
- an associative map of strings defining the headers of this xhr.
- {String} args.postData Optional
- a string of data you wish to send as the post body.
- {String} args.responseType Optional, Default: "text"
- Response type choices are "xml" or "json", default is "text".
- {Integer} args.timeout Optional
- The timeout in milliseconds before rejecting the promise and calling the error function. The data parameter is set to "timeout" in this case.
- Returns:
- {i$.promise.Promise} A promise that resolves to {data: responseData, xhr: xhr} on success or {data: error, xhr: xhr} on failure. Chaining promises to this one should not change the structure of the resolved value in delegated promises unless their consumers aren't expecting the resolved value to be in the JSON structure produced by this i$.xhr API call. Modifying the value to implement filtering promise chains is properly done by modifying the resolved value's data property and returning either the resolved value again or an undefined value to ensure the consumers can safely assume the same JSON structure in their callbacks.
<static>
{i$.promise.Promise}
i$.xhrDelete(args)
Executes an XmlHttpRequest using the HTTP DELETE method using the same arguments
as i$.xhr except with the first argument pre-filled.
- Parameters:
- {Object} args
- For description see i$.xhr
- Returns:
- {i$.promise.Promise} For description see i$.xhr
- See:
- i$.xhr
<static>
{i$.promise.Promise}
i$.xhrGet(args)
Executes an XmlHttpRequest using the HTTP GET method using the same arguments
as i$.xhr except with the first argument pre-filled.
- Parameters:
- {Object} args
- For description see i$.xhr
- Returns:
- {i$.promise.Promise} For description see i$.xhr
- See:
- i$.xhr
<static>
{i$.promise.Promise}
i$.xhrPost(args)
Executes an XmlHttpRequest using the HTTP POST method using the same arguments
as i$.xhr except with the first argument pre-filled.
- Parameters:
- {Object} args
- For description see i$.xhr
- Returns:
- {i$.promise.Promise} For description see i$.xhr
- See:
- i$.xhr
<static>
{i$.promise.Promise}
i$.xhrPut(args)
Executes an XmlHttpRequest using the HTTP PUT method using the same arguments
as i$.xhr except with the first argument pre-filled.
- Parameters:
- {Object} args
- For description see i$.xhr
- Returns:
- {i$.promise.Promise} For description see i$.xhr
- See:
- i$.xhr