Class Sfdc.canvas
Canvas
Defined in: canvas.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
Sfdc.canvas.appearsJson(value)
Checks whether the value appears to be JSON.
|
<static> |
Sfdc.canvas.attr(el, name)
Returns the value for the given attribute name on the given DOM element.
|
<static> |
Sfdc.canvas.byClass(class)
Returns a set of DOM elements with the given class names in the current document.
|
<static> |
Sfdc.canvas.byId(id)
Returns the DOM element with the given ID in the current document.
|
<static> |
Sfdc.canvas.decode(str)
decode a base 64 string.
|
<static> |
Sfdc.canvas.each(obj, it, ctx)
Calls a defined function for each element in an object.
|
<static> |
Sfdc.canvas.endsWith(str, suffix)
Determines if a string ends with a particular suffix.
|
<static> |
Sfdc.canvas.extend(dest, mixin1-n)
Adds the contents of two or more objects to
a destination object.
|
<static> |
Sfdc.canvas.hasOwn(obj, prop)
Checks whether an object contains an uninherited property.
|
<static> |
Sfdc.canvas.identity(obj)
Returns the argument.
|
<static> |
Sfdc.canvas.indexOf(array, item)
Returns the location of an element in an array.
|
<static> |
Sfdc.canvas.invoker(fn)
Runs the specified function.
|
<static> |
Sfdc.canvas.isArguments(value)
Checks whether an object is the argument set for a function.
|
<static> |
Sfdc.canvas.isArray(value)
Checks whether an object is an array.
|
<static> |
Sfdc.canvas.isEmpty(obj)
Returns true if the object is null, or the object has no
enumerable properties/attributes.
|
<static> |
Sfdc.canvas.isFunction(value)
Checks whether an object is a function.
|
<static> |
Sfdc.canvas.isNil(value)
Checks whether an object is undefined, null, or an empty string.
|
<static> |
Sfdc.canvas.isNumber(value)
Checks whether a value is a number.
|
<static> |
Sfdc.canvas.isObject(value)
Checks whether a value is of type object and isn't null.
|
<static> |
Sfdc.canvas.isString(value)
Checks whether a value is of type string and isn't null.
|
<static> |
Sfdc.canvas.isUndefined(value)
Checks whether an object is currently undefined.
|
<static> |
Sfdc.canvas.map(obj, it, ctx)
Creates a new array with the results of calling the
function on each element in the object.
|
<static> |
Sfdc.canvas.module(ns, decl)
Adds a module to the global.Sfdc.canvas object.
|
<static> |
Sfdc.canvas.nop()
An empty or blank function.
|
<static> |
Sfdc.canvas.objectify(q)
Converts a query string into an object.
|
Of(obj)
Returns the prototype of the specified object.
|
|
<static> |
Sfdc.canvas.onReady(cb)
Registers a callback to be called after the DOM is ready.
|
<static> |
Sfdc.canvas.param(a, encode)
Serializes an object into a string that can be used as a URL query string.
|
<static> |
Sfdc.canvas.query(url, q)
Appends the query string to the end of the URL and removes any hash tag.
|
<static> |
Sfdc.canvas.remove(array, item)
Removes an element from an array.
|
<static> |
Sfdc.canvas.size(obj)
Calculates the number of elements in an object.
|
<static> |
Sfdc.canvas.slice(array, begin, end)
Creates a new array containing the selected elements of the given array.
|
<static> |
Sfdc.canvas.startsWithHttp(orig, newUrl)
Convenience method to prepend a method with a fully qualified url, if the
method does not begin with http protocol.
|
<static> |
Sfdc.canvas.stripUrl(url)
Strips out the URL to {scheme}://{host}:{port}.
|
<static> |
Sfdc.canvas.toArray(iterable)
Creates an array from an object.
|
<static> |
Sfdc.canvas.validEventName(name, res)
Validates the event name.
|
<static> |
Sfdc.canvas.values(obj)
Creates an array containing all the elements of the given object.
|
Method Detail
<static>
{Boolean}
Sfdc.canvas.appearsJson(value)
Checks whether the value appears to be JSON.
- Parameters:
- {String} value
- The JSON string to check
- Returns:
- {Boolean}
true
if the string starts and stops with {} , otherwisefalse
<static>
{String}
Sfdc.canvas.attr(el, name)
Returns the value for the given attribute name on the given DOM element.
- Parameters:
- {DOMElement} el
- The element on which to check the attribute.
- {String} name
- The name of the attribute for which to find a value.
- Returns:
- {String} The given attribute's value.
<static>
{Array}
Sfdc.canvas.byClass(class)
Returns a set of DOM elements with the given class names in the current document.
- Parameters:
- {String} class
- The class names to find in the DOM; multiple classnames can be passed, separated by whitespace
- Returns:
- {Array} Set of DOM elements that all have the given class name
<static>
{DOMElement}
Sfdc.canvas.byId(id)
Returns the DOM element with the given ID in the current document.
- Parameters:
- {String} id
- The ID of the DOM element
- Returns:
- {DOMElement} The DOM element with the given ID. Returns null if the element doesn't exist.
<static>
Sfdc.canvas.decode(str)
decode a base 64 string.
- Parameters:
- {String} str
- - base64 encoded string
- Returns:
- decoded string
<static>
Sfdc.canvas.each(obj, it, ctx)
Calls a defined function for each element in an object.
- Parameters:
- {Object} obj
- The object to loop through. The object can be an array, an array like object, or a map of properties.
- {Function} it
- The callback function to run for each element
- {Object} ctx Optional
- The context object to be used for the callback function. Defaults to the original object if not provided.
<static>
{boolean}
Sfdc.canvas.endsWith(str, suffix)
Determines if a string ends with a particular suffix.
- Parameters:
- {String} str
- The string to check
- {String} suffix
- The suffix to check for
- Returns:
- {boolean}
true
, if the string ends with suffix; otherwise,false
.
<static>
{Object}
Sfdc.canvas.extend(dest, mixin1-n)
Adds the contents of two or more objects to
a destination object.
- Parameters:
- {Object} dest
- The destination object to modify
- {Object} mixin1-n
- An unlimited number of objects to add to the destination object
- Returns:
- {Object} The modified destination object
<static>
{Boolean}
Sfdc.canvas.hasOwn(obj, prop)
Checks whether an object contains an uninherited property.
- Parameters:
- {Object} obj
- The object to check
- {String} prop
- The property name to check for
- Returns:
- {Boolean}
true
if the property exists for the object and isn't inherited; otherwisefalse
<static>
{Object}
Sfdc.canvas.identity(obj)
Returns the argument.
- Parameters:
- {Object} obj
- The object to return, untouched.
- Returns:
- {Object} The argument used for this function call
<static>
{Integer}
Sfdc.canvas.indexOf(array, item)
Returns the location of an element in an array.
- Parameters:
- {Array} array
- The array to check
- {Object} item
- The item to search for within the array
- Returns:
- {Integer} The index of the element within the array. Returns -1 if the element isn't found.
<static>
Sfdc.canvas.invoker(fn)
Runs the specified function.
- Parameters:
- {Function} fn
- The function to run
<static>
{Boolean}
Sfdc.canvas.isArguments(value)
Checks whether an object is the argument set for a function.
- Parameters:
- {Object} value
- The object to check
- Returns:
- {Boolean}
true
if the object or value is the argument set for a function; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isArray(value)
Checks whether an object is an array.
- Parameters:
- {Object} value
- The object to check
- Returns:
- {Boolean}
true
if the object or value is of type array; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isEmpty(obj)
Returns true if the object is null, or the object has no
enumerable properties/attributes.
- Parameters:
- {Object} obj
- The object to check
- Returns:
- {Boolean}
true
if the object or value is null, or is an object with no enumerable properties/attributes.
<static>
{Boolean}
Sfdc.canvas.isFunction(value)
Checks whether an object is a function.
- Parameters:
- {Object} value
- The object to check
- Returns:
- {Boolean}
true
if the object or value is a function; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isNil(value)
Checks whether an object is undefined, null, or an empty string.
- Parameters:
- {Object} value
- The object to check
- Returns:
- {Boolean}
true
if the object or value is of type undefined; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isNumber(value)
Checks whether a value is a number. This function doesn't resolve strings to numbers.
- Parameters:
- {Object} value
- Object to check
- Returns:
- {Boolean}
true
if the object or value is a number; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isObject(value)
Checks whether a value is of type object and isn't null.
- Parameters:
- {Object} value
- The object to check
- Returns:
- {Boolean}
true
if the object or value is of type object; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isString(value)
Checks whether a value is of type string and isn't null.
- Parameters:
- {Object} value
- The string to check
- Returns:
- {Boolean}
true
if the string or value is of type string; otherwisefalse
<static>
{Boolean}
Sfdc.canvas.isUndefined(value)
Checks whether an object is currently undefined.
- Parameters:
- {Object} value
- The object to check
- Returns:
- {Boolean}
true
if the object or value is of type undefined; otherwisefalse
<static>
{Array}
Sfdc.canvas.map(obj, it, ctx)
Creates a new array with the results of calling the
function on each element in the object.
- Parameters:
- {Object} obj
- The object to use
- {Function} it
- The callback function to run for each element
- {Object} ctx Optional
- The context object to be used for the callback function. Defaults to the original object if not provided.
- Returns:
- {Array} The array that is created by calling the function on each element in the object.
<static>
{Object}
Sfdc.canvas.module(ns, decl)
Adds a module to the global.Sfdc.canvas object.
- Parameters:
- {String} ns
- The namespace for the new module
- decl
- Returns:
- {Object} The global.Sfdc.canvas object with a new module added.
<static>
Sfdc.canvas.nop()
An empty or blank function.
<static>
{Object}
Sfdc.canvas.objectify(q)
Converts a query string into an object.
- Parameters:
- {String} q
- param1=value1¶m1=value2¶m2=value2
- Returns:
- {Object} {param1 : ['value1', 'value2'], param2 : 'value2'}
{Object}
Of(obj)
Returns the prototype of the specified object.
- Parameters:
- {Object} obj
- The object for which to find the prototype
- Returns:
- {Object} The object that is the prototype of the given object.
<static>
Sfdc.canvas.onReady(cb)
Registers a callback to be called after the DOM is ready.
- Parameters:
- {Function} cb
- The callback function to be called
<static>
{String}
Sfdc.canvas.param(a, encode)
Serializes an object into a string that can be used as a URL query string.
- Parameters:
- {Object|Array} a
- The array or object to serialize
- {Boolean} encode Optional, Default: false
- Indicates that the string should be encoded
- Returns:
- {String} A string representing the object as a URL query string.
<static>
Sfdc.canvas.query(url, q)
Appends the query string to the end of the URL and removes any hash tag.
- Parameters:
- {String} url
- The URL to be appended to
- q
- Returns:
- The URL with the query string appended.
<static>
Sfdc.canvas.remove(array, item)
Removes an element from an array.
- Parameters:
- {Array} array
- The array to modify
- {Object} item
- The element to remove from the array
<static>
{Integer}
Sfdc.canvas.size(obj)
Calculates the number of elements in an object.
- Parameters:
- {Object} obj
- The object to size
- Returns:
- {Integer} The number of elements in the object.
<static>
{Array}
Sfdc.canvas.slice(array, begin, end)
Creates a new array containing the selected elements of the given array.
- Parameters:
- {Array} array
- The array to subset
- {Integer} begin Optional, Default: 0
- The index that specifies where to start the selection
- {Integer} end Optional, Default: array.length
- The index that specifies where to end the selection
- Returns:
- {Array} A new array that contains the selected elements.
<static>
{String}
Sfdc.canvas.startsWithHttp(orig, newUrl)
Convenience method to prepend a method with a fully qualified url, if the
method does not begin with http protocol.
- Parameters:
- {String} orig
- The original url to check
- {String} newUrl
- The new url to use if it does not begin with http(s) protocol.
- Returns:
- {String} orig if the url begins with http, or newUrl if it does not.
<static>
{String}
Sfdc.canvas.stripUrl(url)
Strips out the URL to {scheme}://{host}:{port}. Removes any path and query string information.
- Parameters:
- {String} url
- The URL to be modified
- Returns:
- {String} The {scheme}://{host}:{port} portion of the URL.
<static>
{Array}
Sfdc.canvas.toArray(iterable)
Creates an array from an object.
- Parameters:
- {Object} iterable
- The source object used to create the array.
- Returns:
- {Array} The new array created from the object.
<static>
{int}
Sfdc.canvas.validEventName(name, res)
Validates the event name.
- Parameters:
- {String} name
- Name of the event; can include the namespace (namespace.name).
- {String} res
- Reserved namespace name to allow against default
- Returns:
- {int} error code, 0 if valid
<static>
{Array}
Sfdc.canvas.values(obj)
Creates an array containing all the elements of the given object.
- Parameters:
- {Object} obj
- The source object used to create the array
- Returns:
- {Array} An array containing all the elements in the object.