Gets or sets an object that contains all localizable strings in the Wijmo library.
The culture selector is a two-letter string that represents an ISO 639 culture.
addClass(e: HTMLElement, className: string): void
Adds a class to an element.
Element that will have the class added.
Class to add to the element.
animate(apply: Function, duration?: number, step?: number): number
Calls a function on a timer with a parameter varying between zero and one.
Use this function to create animations by modifying document properties or styles on a timer.
For example, the code below changes the opacity of an element from zero to one in one second:
var element = document.getElementById('someElement'); animate(function(pct) { element.style.opacity = pct; }, 1000);
The function returns an interval ID that you can use to stop the animation. This is typically done when you are starting a new animation and wish to suspend other on-going animations on the same element. For example, the code below keeps track of the interval ID and clears if before starting a new animation:
var element = document.getElementById('someElement'); if (this._animInterval) { clearInterval(this._animInterval); } var self = this; self._animInterval = animate(function(pct) { element.style.opacity = pct; if (pct == 1) { self._animInterval = null; } }, 1000);
Callback function that modifies the document. The function takes a single parameter that represents a percentage.
The duration of the animation, in milliseconds.
The interval between animation frames, in milliseconds.
asArray(value: any, nullOK?: boolean): any[]
Asserts that a value is an array.
Value supposed to be an array.
Whether null values are acceptable.
asBoolean(value: boolean, nullOK?: boolean): boolean
Asserts that a value is a Boolean.
Value supposed to be Boolean.
Whether null values are acceptable.
asCollectionView(value: any, nullOK?: boolean): ICollectionView
Asserts that a value is an ICollectionView or an Array.
Array or ICollectionView.
Whether null values are acceptable.
asDate(value: Date, nullOK?: boolean): Date
Asserts that a value is a Date.
Value supposed to be a Date.
Whether null values are acceptable.
asEnum(value: number, enumType: any, nullOK?: boolean): number
Asserts that a value is a valid setting for an enumeration.
Value supposed to be a member of the enumeration.
Enumeration to test for.
Whether null values are acceptable.
asFunction(value: any, nullOK?: boolean): Function
Asserts that a value is a function.
Value supposed to be a function.
Whether null values are acceptable.
asInt(value: number, nullOK?: boolean, positive?: boolean): number
Asserts that a value is an integer.
Value supposed to be an integer.
Whether null values are acceptable.
Whether to accept only positive integers.
asNumber(value: number, nullOK?: boolean, positive?: boolean): number
Asserts that a value is a number.
Value supposed to be numeric.
Whether null values are acceptable.
Whether to accept only positive numeric values.
assert(condition: boolean, msg: string): void
Throws an exception if a condition is false.
Condition expected to be true.
Message of the exception if the condition is not true.
asString(value: string, nullOK?: boolean): string
Asserts that a value is a string.
Value supposed to be a string.
Whether null values are acceptable.
asType(value: any, type: any, nullOK?: boolean): any
Asserts that a value is an instance of a given type.
Value to be checked.
Type of value expected.
Whether null values are acceptable.
changeType(value: any, type: DataType, format: string): any
Changes the type of a value.
If the conversion fails, the original value is returned. To check if a conversion succeeded, you should check the type of the returned value.
Value to convert.
DataType to convert the value to.
Format to use when converting to or from strings.
clamp(value: number, min: number, max: number): number
Clamps a value between a minimum and a maximum.
closest(e: any, selector: string): Node
Finds the closest ancestor that satisfies a selector.
Element where the search should start.
A string containing a selector expression to match elements against.
contains(parent: any, child: any): boolean
Checks whether an HTML element contains another.
Parent element.
Child element.
copy(dst: any, src: any): void
Copies properties from an object to another.
This method is typically used to initialize controls and other Wijmo objects by setting their properties and assigning event handlers.
The destination object must define all the properties defined in the source, or an error will be thrown.
The destination object.
The source object.
createElement(html: string, appendTo?: HTMLElement): HTMLElement
Creates an element from an HTML string.
HTML fragment to convert into an HTMLElement.
Optional HTMLElement to append the new element to.
enable(e: HTMLElement, value: boolean): void
Enables or disables an element.
Element to enable or disable.
Whether to enable or disable the element.
escapeHtml(text: string): void
Escapes a string by replacing HTML characters as text entities.
Strings entered by uses should always be escaped before they are displayed in HTML pages. This ensures page integrity and prevents HTML/javascript injection attacks.
Text to escape.
format(format: string, data: any, formatFunction?: Function): string
Replaces each format item in a specified string with the text equivalent of an object's value.
The function works by replacing parts of the formatString with the pattern '{name:format}' with properties of the data parameter. For example:
var data = { name: 'Joe', amount: 123456 }; var msg = wijmo.format('Hello {name}, you won {amount:n2}!', data);
The optional formatFunction allows you to customize the content by providing context-sensitive formatting. If provided, the format function gets called for each format element and gets passed the data object, the parameter name, the format, and the value; it should return an output string. For example:
var data = { name: 'Joe', amount: 123456 }; var msg = wijmo.format('Hello {name}, you won {amount:n2}!', data, function (data, name, fmt, val) { if (wijmo.isString(data[name])) { val = wijmo.escapeHtml(data[name]); } return val; });
A composite format string.
The data object used to build the string.
An optional function used to format items in context.
getActiveElement(): void
Gets a reference to the element that contains the focus, accounting for shadow document fragments.
getAggregate(aggType: Aggregate, items: any[], binding?: string): void
Calculates an aggregate value from the values in an array.
Type of aggregate to calculate.
Array with the items to aggregate.
Name of the property to aggregate on (in case the items are not simple values).
getElement(selector: any): HTMLElement
Gets an element from a jQuery-style selector.
An element, a query selector string, or a jQuery object.
getElementRect(e: Element): Rect
Gets the bounding rectangle of an element in page coordinates.
This is similar to the getBoundingClientRect function, except that uses window coordinates, which change when the document scrolls.
getType(value: any): DataType
Gets the type of a value.
Value to test.
getUniqueId(baseId: string): string
Creates a new unique id for an element by adding sequential numbers to a given base id.
String to use as a basis for generating the unique id.
getVersion(): string
Gets the version of the Wijmo library that is currently loaded.
hasClass(e: HTMLElement, className: string): boolean
Checks whether an element has a class.
Element to check.
Class to check for.
hasItems(value: ICollectionView): void
Checks whether an ICollectionView is defined and not empty.
ICollectionView to check.
hidePopup(popup: HTMLElement, remove?: boolean, fadeOut?: boolean): void
Hides a popup element previously displayed with the showPopup method.
Popup element to hide.
Whether to remove the popup from the DOM or just to hide it.
Whether to use a fade-out animation to make the popup disappear gradually.
httpRequest(url: string, settings?: any): XMLHttpRequest
Performs HTTP requests.
String containing the URL to which the request is sent.
An optional object used to configure the request.
The settings object may contain the following:
method | The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). The default is "GET". |
data | Data to be sent to the server. It is appended to the url for GET requests, and converted to a string for other requests. |
async | By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. |
success | A function to be called if the request succeeds. The function gets passed a single parameter of type XMLHttpRequest. |
error | A function to be called if the request fails. The function gets passed a single parameter of type XMLHttpRequest. |
complete | A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed a single parameter of type XMLHttpRequest. |
beforeSend | A function to be called immediately before the request us sent. The function gets passed a single parameter of type XMLHttpRequest. |
requestHeaders | A JavaScript object containing key/value pairs to be added to the request headers. |
user | A username to be used with XMLHttpRequest in response to an HTTP access authentication request. |
password | A password to be used with XMLHttpRequest in response to an HTTP access authentication request. |
Use the success to obtain the result of the request which is provided in the callback's XMLHttpRequest parameter. For example, the code below uses the httpRequest method to retrieve a list of customers from an OData service:
wijmo.httpRequest('http://services.odata.org/Northwind/Northwind.svc/Customers?$format=json', {
success: function (xhr) {
var response = JSON.parse(xhr.response),
customers = response.value;
// do something with the customers...
}
});
isArray(value: any): boolean
Determines whether an object is an Array.
Value to test.
isBoolean(value: any): boolean
Determines whether an object is a Boolean.
Value to test.
isDate(value: any): boolean
Determines whether an object is a Date.
Value to test.
isFunction(value: any): boolean
Determines whether an object is a function.
Value to test.
isInt(value: any): boolean
Determines whether an object is an integer.
Value to test.
isNullOrWhiteSpace(value: string): boolean
Determines whether a string is null, empty, or whitespace only.
Value to test.
isNumber(value: any): boolean
Determines whether an object is a number.
Value to test.
isObject(value: any): boolean
Determines whether a value is an object (as opposed to a value type, an array, or a Date).
Value to test.
isPrimitive(value: any): boolean
Determines whether an object is a primitive type (string, number, boolean, or date).
Value to test.
isString(value: any): boolean
Determines whether an object is a string.
Value to test.
isUndefined(value: any): boolean
Determines whether an object is undefined.
Value to test.
mouseToPage(e: any): Point
Converts mouse or touch event arguments into a Point in page coordinates.
moveFocus(parent: HTMLElement, offset: number): void
Moves the focus to the next/previous/first focusable child within a given parent element.
Parent element.
Offset to use when moving the focus (use zero to focus on the first focusable child).
removeClass(e: HTMLElement, className: string): void
Removes a class from an element.
Element that will have the class removed.
Class to remove form the element.
setAttribute(e: Element, name: string, value?: any): void
Sets or clears an attribute on an element.
Element that will be updated.
Name of the attribute to add or remove.
Value of the attribute, or null to remove the attribute from the element.
setCss(e: any, css: any): void
Modifies the style of an element by applying the properties specified in an object.
Element or array of elements whose style will be modified.
Object containing the style properties to apply to the element.
setSelectionRange(e: HTMLInputElement, start: number, end?: number): void
Sets the start and end positions of a selection in a text field.
This method is similar to the native setSelectionRange method in HTMLInputElement objects, except it checks for conditions that may cause exceptions (element not in the DOM, disabled, or hidden).
Offset into the text field for the start of the selection.
Offset into the text field for the end of the selection.
setText(e: HTMLElement, text: string): void
Sets the text content of an element.
Element that will have its content updated.
Plain text to be assigned to the element.
showPopup(popup: HTMLElement, ref?: any, above?: boolean, fadeIn?: boolean, copyStyles?: boolean): void
Shows an element as a popup.
The popup element becomes a child of the body element, and is positioned above or below a reference rectangle, depending on how much room is available.
The reference rectangle may be specified as one of the following:
Call the hidePopup method to hide the popup.
Element to show as a popup.
Reference element or rectangle used to position the popup.
Position popup above the reference rectangle if possible.
Use a fade-in animation to make the popup appear gradually.
Copy font and color styles from reference element.
toFixed(value: number, prec: number, truncate: boolean): number
Rounds or truncates a number to a specified precision.
Value to round or truncate.
Number of decimal digits for the result.
Whether to truncate or round the original value.
toggleClass(e: HTMLElement, className: string, addOrRemove?: boolean): void
Adds or removes a class to or from an element.
Element that will have the class added.
Class to add or remove.
Whether to add or remove the class. If not provided, the class is toggled. Use true to add class to element and false to remove class from element.
toHeaderCase(text: string): string
Converts a camel-cased string into a header-type string by capitalizing the first letter and adding spaces before uppercase characters preceded by lower-case characters.
For example, 'somePropertyName' becomes 'Some Property Name'.
String to convert to header case.
tryCast(value: any, type: any): any
Casts a value to a type if possible.
Value to cast.
Type or interface name to cast to.
Contains utilities used by all controls and modules, as well as the Control and Event classes.