From f2466a2fe6c4859e3aa613b542ec12fe033bbdd0 Mon Sep 17 00:00:00 2001 From: Kurt Berglund Date: Mon, 30 Jun 2014 19:36:16 -0700 Subject: [PATCH] Slimmed down version of our Khan/PhET store page to serve as a basic template for future pages of this type. Removes use of a backend service for search and instead stubs out some JSON parts for it. --- jquery.d.ts | 3854 +++++++++++++++++++++++++++++++++++++++++++++++ knockout.d.ts | 515 +++++++ labs-1.0.4.d.ts | 2165 ++++++++++++++++++++++++++ site.css | 252 ++++ store.html | 192 +++ store.js | 251 +++ store.ts | 283 ++++ 7 files changed, 7512 insertions(+) create mode 100644 jquery.d.ts create mode 100644 knockout.d.ts create mode 100644 labs-1.0.4.d.ts create mode 100644 site.css create mode 100644 store.html create mode 100644 store.js create mode 100644 store.ts diff --git a/jquery.d.ts b/jquery.d.ts new file mode 100644 index 0000000..b42f77a --- /dev/null +++ b/jquery.d.ts @@ -0,0 +1,3854 @@ +// Type definitions for jQuery 1.10.x / 2.0.x +// Project: http://jquery.com/ +// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton, Diullei Gomes , Tass Iliopoulos , Jason Swearingen, Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + +/** + * Interface for the AJAX setting that will configure the AJAX request + */ +interface JQueryAjaxSettings { + /** + * The content type sent in the request header that tells the server what kind of response it will accept in return. If the accepts setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. + */ + accepts?: any; + /** + * 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. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success(). + */ + async?: boolean; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request. + */ + beforeSend? (jqXHR: JQueryXHR, settings: JQueryAjaxSettings): any; + /** + * If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET. + */ + cache?: boolean; + /** + * A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. + */ + complete? (jqXHR: JQueryXHR, textStatus: string): any; + /** + * An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. (version added: 1.5) + */ + contents?: { [key: string]: any; }; + //According to jQuery.ajax source code, ajax's option actually allows contentType to set to "false" + // https://github.com/borisyankov/DefinitelyTyped/issues/742 + /** + * When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. + */ + contentType?: any; + /** + * This object will be made the context of all Ajax-related callbacks. By default, the context is an object that represents the ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). + */ + context?: any; + /** + * An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. (version added: 1.5) + */ + converters?: { [key: string]: any; }; + /** + * If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. (version added: 1.5) + */ + crossDomain?: boolean; + /** + * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). + */ + data?: any; + /** + * A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter. + */ + dataFilter? (data: any, ty: any): any; + /** + * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). + */ + dataType?: string; + /** + * A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. + */ + error? (jqXHR: JQueryXHR, textStatus: string, errorThrow: string): any; + /** + * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. + */ + global?: boolean; + /** + * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. (version added: 1.5) + */ + headers?: { [key: string]: any; }; + /** + * Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data. + */ + ifModified?: boolean; + /** + * Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. (version added: 1.5.1) + */ + isLocal?: boolean; + /** + * Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" } + */ + jsonp?: any; + /** + * Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. + */ + jsonpCallback?: any; + /** + * A mime type to override the XHR mime type. (version added: 1.5.1) + */ + mimeType?: string; + /** + * A password to be used with XMLHttpRequest in response to an HTTP access authentication request. + */ + password?: string; + /** + * By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. + */ + processData?: boolean; + /** + * Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. + */ + scriptCharset?: string; + /** + * An object of numeric HTTP codes and functions to be called when the response has the corresponding code. f the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. (version added: 1.5) + */ + statusCode?: { [key: string]: any; }; + /** + * A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. + */ + success? (data: any, textStatus: string, jqXHR: JQueryXHR): any; + /** + * Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. + */ + timeout?: number; + /** + * Set this to true if you wish to use the traditional style of param serialization. + */ + traditional?: boolean; + /** + * The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers. + */ + type?: string; + /** + * A string containing the URL to which the request is sent. + */ + url?: string; + /** + * A username to be used with XMLHttpRequest in response to an HTTP access authentication request. + */ + username?: string; + /** + * Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory. + */ + xhr?: any; + /** + * An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed. In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. (version added: 1.5.1) + */ + xhrFields?: { [key: string]: any; }; +} + +/** + * Interface for the jqXHR object + */ +interface JQueryXHR extends XMLHttpRequest, JQueryPromise { + /** + * The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header. As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). + */ + overrideMimeType(mimeType: string): any; + abort(statusText?: string): void; +} + +/** + * Interface for the JQuery callback + */ +interface JQueryCallback { + /** + * Add a callback or a collection of callbacks to a callback list. + * + * @param callbacks A function, or array of functions, that are to be added to the callback list. + */ + add(callbacks: Function): JQueryCallback; + /** + * Add a callback or a collection of callbacks to a callback list. + * + * @param callbacks A function, or array of functions, that are to be added to the callback list. + */ + add(callbacks: Function[]): JQueryCallback; + + /** + * Disable a callback list from doing anything more. + */ + disable(): JQueryCallback; + + /** + * Determine if the callbacks list has been disabled. + */ + disabled(): boolean; + + /** + * Remove all of the callbacks from a list. + */ + empty(): JQueryCallback; + + /** + * Call all of the callbacks with the given arguments + * + * @param arguments The argument or list of arguments to pass back to the callback list. + */ + fire(...arguments: any[]): JQueryCallback; + + /** + * Determine if the callbacks have already been called at least once. + */ + fired(): boolean; + + /** + * Call all callbacks in a list with the given context and arguments. + * + * @param context A reference to the context in which the callbacks in the list should be fired. + * @param arguments An argument, or array of arguments, to pass to the callbacks in the list. + */ + fireWith(context?: any, ...args: any[]): JQueryCallback; + + /** + * Determine whether a supplied callback is in a list + * + * @param callback The callback to search for. + */ + has(callback: Function): boolean; + + /** + * Lock a callback list in its current state. + */ + lock(): JQueryCallback; + + /** + * Determine if the callbacks list has been locked. + */ + locked(): boolean; + + /** + * Remove a callback or a collection of callbacks from a callback list. + * + * @param callbacks A function, or array of functions, that are to be removed from the callback list. + */ + remove(callbacks: Function): JQueryCallback; + /** + * Remove a callback or a collection of callbacks from a callback list. + * + * @param callbacks A function, or array of functions, that are to be removed from the callback list. + */ + remove(callbacks: Function[]): JQueryCallback; +} + +/** + * Allows jQuery Promises to interop with non-jQuery promises + */ +interface JQueryGenericPromise { + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + */ + then(doneFilter: (value: T) => U, failFilter?: (reason: any) => U): JQueryGenericPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + */ + then(doneFilter: (value: T) => JQueryGenericPromise, failFilter?: (reason: any) => U): JQueryGenericPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + */ + then(doneFilter: (value: T) => U, failFilter?: (reason: any) => JQueryGenericPromise): JQueryGenericPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + */ + then(doneFilter: (value: T) => JQueryGenericPromise, failFilter?: (reason: any) => JQueryGenericPromise): JQueryGenericPromise; +} + +/** + * Interface for the JQuery promise, part of callbacks + */ +interface JQueryPromise { + /** + * Add handlers to be called when the Deferred object is either resolved or rejected. + * + * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. + * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + */ + always(alwaysCallbacks1?: T, ...alwaysCallbacks2: T[]): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object is resolved. + * + * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. + * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + */ + done(doneCallbacks1?: T, ...doneCallbacks2: T[]): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object is rejected. + * + * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. + * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + */ + fail(failCallbacks1?: T, ...failCallbacks2: T[]): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object generates progress notifications. + * + * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + */ + progress(...progressCallbacks: T[]): JQueryDeferred; + + /** + * Add handlers to be called when the Deferred object is either resolved or rejected. + * + * @param alwaysCallbacks A function, or array of functions, that is called when the Deferred is resolved or rejected. + */ + always(...alwaysCallbacks: any[]): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved. + * + * @param doneCallbacks A function, or array of functions, that are called when the Deferred is resolved. + */ + done(...doneCallbacks: any[]): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is rejected. + * + * @param failCallbacks A function, or array of functions, that are called when the Deferred is rejected. + */ + fail(...failCallbacks: any[]): JQueryPromise; + /** + * Add handlers to be called when the Deferred object generates progress notifications. + * + * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + */ + progress(...progressCallbacks: any[]): JQueryPromise; + + // Deprecated - given no typings + pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; + + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (value: T) => U, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (value: T) => JQueryGenericPromise, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (value: T) => U, failFilter?: (...reasons: any[]) => JQueryGenericPromise, progressFilter?: (...progression: any[]) => any): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (value: T) => JQueryGenericPromise, failFilter?: (...reasons: any[]) => JQueryGenericPromise, progressFilter?: (...progression: any[]) => any): JQueryPromise; + + // Because JQuery Promises Suck + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (...values: any[]) => U, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (...values: any[]) => JQueryGenericPromise, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (...values: any[]) => U, failFilter?: (...reasons: any[]) => JQueryGenericPromise, progressFilter?: (...progression: any[]) => any): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + * @param progressFilter An optional function that is called when progress notifications are sent to the Deferred. + */ + then(doneFilter: (...values: any[]) => JQueryGenericPromise, failFilter?: (...reasons: any[]) => JQueryGenericPromise, progressFilter?: (...progression: any[]) => any): JQueryPromise; +} + +/** + * Interface for the JQuery deferred, part of callbacks + */ +interface JQueryDeferred extends JQueryPromise { + /** + * Add handlers to be called when the Deferred object is either resolved or rejected. + * + * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. + * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + */ + always(alwaysCallbacks1?: T, ...alwaysCallbacks2: T[]): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object is resolved. + * + * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. + * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + */ + done(doneCallbacks1?: T, ...doneCallbacks2: T[]): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object is rejected. + * + * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. + * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + */ + fail(failCallbacks1?: T, ...failCallbacks2: T[]): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object generates progress notifications. + * + * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + */ + progress(...progressCallbacks: T[]): JQueryDeferred; + + /** + * Call the progressCallbacks on a Deferred object with the given args. + * + * @param args Optional arguments that are passed to the progressCallbacks. + */ + notify(...args: any[]): JQueryDeferred; + + /** + * Call the progressCallbacks on a Deferred object with the given context and args. + * + * @param context Context passed to the progressCallbacks as the this object. + * @param args Optional arguments that are passed to the progressCallbacks. + */ + notifyWith(context: any, ...args: any[]): JQueryDeferred; + + /** + * Reject a Deferred object and call any failCallbacks with the given args. + * + * @param args Optional arguments that are passed to the failCallbacks. + */ + reject(...args: any[]): JQueryDeferred; + /** + * Reject a Deferred object and call any failCallbacks with the given context and args. + * + * @param context Context passed to the failCallbacks as the this object. + * @param args An optional array of arguments that are passed to the failCallbacks. + */ + rejectWith(context: any, ...args: any[]): JQueryDeferred; + + /** + * Resolve a Deferred object and call any doneCallbacks with the given args. + * + * @param value First argument passed to doneCallbacks. + * @param args Optional subsequent arguments that are passed to the doneCallbacks. + */ + resolve(value?: T, ...args: any[]): JQueryDeferred; + + /** + * Resolve a Deferred object and call any doneCallbacks with the given context and args. + * + * @param context Context passed to the doneCallbacks as the this object. + * @param args An optional array of arguments that are passed to the doneCallbacks. + */ + resolveWith(context: any, ...args: any[]): JQueryDeferred; + /** + * Determine the current state of a Deferred object. + */ + state(): string; + + /** + * Return a Deferred's Promise object. + * + * @param target Object onto which the promise methods have to be attached + */ + promise(target?: any): JQueryPromise; +} + +/** + * Interface of the JQuery extension of the W3C event object + */ +interface BaseJQueryEventObject extends Event { + data: any; + delegateTarget: Element; + isDefaultPrevented(): boolean; + isImmediatePropogationStopped(): boolean; + isPropagationStopped(): boolean; + namespace: string; + preventDefault(): any; + relatedTarget: Element; + result: any; + stopImmediatePropagation(): void; + stopPropagation(): void; + pageX: number; + pageY: number; + which: number; + metaKey: boolean; +} + +interface JQueryInputEventObject extends BaseJQueryEventObject { + altKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; +} + +interface JQueryMouseEventObject extends JQueryInputEventObject { + button: number; + clientX: number; + clientY: number; + offsetX: number; + offsetY: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; +} + +interface JQueryKeyEventObject extends JQueryInputEventObject { + char: any; + charCode: number; + key: any; + keyCode: number; +} + +interface JQueryPopStateEventObject extends BaseJQueryEventObject { + originalEvent: PopStateEvent; +} + +interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject, JQueryPopStateEventObject { +} + +/* + Collection of properties of the current browser +*/ + +interface JQuerySupport { + ajax?: boolean; + boxModel?: boolean; + changeBubbles?: boolean; + checkClone?: boolean; + checkOn?: boolean; + cors?: boolean; + cssFloat?: boolean; + hrefNormalized?: boolean; + htmlSerialize?: boolean; + leadingWhitespace?: boolean; + noCloneChecked?: boolean; + noCloneEvent?: boolean; + opacity?: boolean; + optDisabled?: boolean; + optSelected?: boolean; + scriptEval? (): boolean; + style?: boolean; + submitBubbles?: boolean; + tbody?: boolean; +} + +interface JQueryParam { + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @param obj An array or object to serialize. + */ + (obj: any): string; + + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @param obj An array or object to serialize. + * @param traditional A Boolean indicating whether to perform a traditional "shallow" serialization. + */ + (obj: any, traditional: boolean): string; +} + +/** + * The interface used to construct jQuery events (with $.Event). It is + * defined separately instead of inline in JQueryStatic to allow + * overriding the construction function with specific strings + * returning specific event objects. + */ +interface JQueryEventConstructor { + (name: string, eventProperties?: any): JQueryEventObject; + new (name: string, eventProperties?: any): JQueryEventObject; +} + +/** + * The interface used to specify coordinates. + */ +interface JQueryCoordinates { + left: number; + top: number; +} + +interface JQueryAnimationOptions { + /** + * A string or number determining how long the animation will run. + */ + duration?: any; + /** + * A string indicating which easing function to use for the transition. + */ + easing?: string; + /** + * A function to call once the animation is complete. + */ + complete?: Function; + /** + * A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set. + */ + step?: (now: number, tween: any) => any; + /** + * A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties. (version added: 1.8) + */ + progress?: (animation: JQueryPromise, progress: number, remainingMs: number) => any; + /** + * A function to call when the animation begins. (version added: 1.8) + */ + start?: (animation: JQueryPromise) => any; + /** + * A function to be called when the animation completes (its Promise object is resolved). (version added: 1.8) + */ + done?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + /** + * A function to be called when the animation fails to complete (its Promise object is rejected). (version added: 1.8) + */ + fail?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + /** + * A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected). (version added: 1.8) + */ + always?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + /** + * A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call .dequeue("queuename") to start it. + */ + queue?: any; + /** + * A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions. (version added: 1.4) + */ + specialEasing?: Object; +} + +/** + * Static members of jQuery (those on $ and jQuery themselves) + */ +interface JQueryStatic { + + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ + ajax(settings: JQueryAjaxSettings): JQueryXHR; + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param url A string containing the URL to which the request is sent. + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ + ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR; + + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param dataTypes An optional string containing one or more space-separated dataTypes + * @param handler A handler to set default values for future Ajax requests. + */ + ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param handler A handler to set default values for future Ajax requests. + */ + ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + + ajaxSettings: JQueryAjaxSettings; + + /** + * Set default values for future Ajax requests. Its use is not recommended. + * + * @param options A set of key/value pairs that configure the default Ajax request. All options are optional. + */ + ajaxSetup(options: JQueryAjaxSettings): void; + + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load a JavaScript file from the server using a GET HTTP request, then execute it. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + */ + param: JQueryParam; + + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + + /** + * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. + * + * @param flags An optional list of space-separated flags that change how the callback list behaves. + */ + Callbacks(flags?: string): JQueryCallback; + + /** + * Holds or releases the execution of jQuery's ready event. + * + * @param hold Indicates whether the ready hold is being requested or released + */ + holdReady(hold: boolean): void; + + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param selector A string containing a selector expression + * @param context A DOM Element, Document, or jQuery to use as context + */ + (selector: string, context?: Element): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param selector A string containing a selector expression + * @param context A DOM Element, Document, or jQuery to use as context + */ + (selector: string, context?: JQuery): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param element A DOM element to wrap in a jQuery object. + */ + (element: Element): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + */ + (elementArray: Element[]): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param object A plain object to wrap in a jQuery object. + */ + (object: {}): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param object An existing jQuery object to clone. + */ + (object: JQuery): JQuery; + /** + * Specify a function to execute when the DOM is fully loaded. + */ + (): JQuery; + + /** + * Creates DOM elements on the fly from the provided string of raw HTML. + * + * @param html A string of HTML to create on the fly. Note that this parses HTML, not XML. + * @param ownerDocument A document in which the new elements will be created. + */ + (html: string, ownerDocument?: Document): JQuery; + /** + * Creates DOM elements on the fly from the provided string of raw HTML. + * + * @param html A string defining a single, standalone, HTML element (e.g.
or
). + * @param attributes An object of attributes, events, and methods to call on the newly-created element. + */ + (html: string, attributes: Object): JQuery; + + /** + * Binds a function to be executed when the DOM has finished loading. + * + * @param callback A function to execute after the DOM is ready. + */ + (callback: Function): JQuery; + + /** + * Relinquish jQuery's control of the $ variable. + * + * @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). + */ + noConflict(removeAll?: boolean): Object; + + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: JQueryGenericPromise[]): JQueryPromise; + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: T[]): JQueryPromise; + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: any[]): JQueryPromise; + + /** + * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties. + */ + cssHooks: { [key: string]: any; }; + cssNumber: any; + + /** + * Store arbitrary data associated with the specified element. Returns the value that was set. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + * @param value The new data value. + */ + data(element: Element, key: string, value: T): T; + /** + * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + */ + data(element: Element, key: string): any; + /** + * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + * + * @param element The DOM element to associate with the data. + */ + data(element: Element): any; + + /** + * Execute the next function on the queue for the matched element. + * + * @param element A DOM element from which to remove and execute a queued function. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + dequeue(element: Element, queueName?: string): void; + + /** + * Determine whether an element has any jQuery data associated with it. + * + * @param element A DOM element to be checked for data. + */ + hasData(element: Element): boolean; + + /** + * Show the queue of functions to be executed on the matched element. + * + * @param element A DOM element to inspect for an attached queue. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + queue(element: Element, queueName?: string): any[]; + /** + * Manipulate the queue of functions to be executed on the matched element. + * + * @param element A DOM element where the array of queued functions is attached. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(element: Element, queueName: string, newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed on the matched element. + * + * @param element A DOM element on which to add a queued function. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param callback The new function to add to the queue. + */ + queue(element: Element, queueName: string, callback: Function): JQuery; + + /** + * Remove a previously-stored piece of data. + * + * @param element A DOM element from which to remove data. + * @param name A string naming the piece of data to remove. + */ + removeData(element: Element, name?: string): JQuery; + + /** + * A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function. + * + * @param beforeStart A function that is called just before the constructor returns. + */ + Deferred(beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; + + /** + * Effects + */ + fx: { + tick: () => void; + /** + * The rate (in milliseconds) at which animations fire. + */ + interval: number; + stop: () => void; + speeds: { slow: number; fast: number; }; + /** + * Globally disable all animations. + */ + off: boolean; + step: any; + }; + + /** + * Takes a function and returns a new one that will always have a particular context. + * + * @param fnction The function whose context will be changed. + * @param context The object to which the context (this) of the function should be set. + * @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument. + */ + proxy(fnction: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any; + /** + * Takes a function and returns a new one that will always have a particular context. + * + * @param context The object to which the context (this) of the function should be set. + * @param name The name of the function whose context will be changed (should be a property of the context object). + * @param additionalArguments Any number of arguments to be passed to the function named in the name argument. + */ + proxy(context: Object, name: string, ...additionalArguments: any[]): any; + + Event: JQueryEventConstructor; + + /** + * Takes a string and throws an exception containing it. + * + * @param message The message to send out. + */ + error(message: any): JQuery; + + expr: any; + fn: any; //TODO: Decide how we want to type this + + isReady: boolean; + + // Properties + support: JQuerySupport; + + /** + * Check to see if a DOM element is a descendant of another DOM element. + * + * @param container The DOM element that may contain the other element. + * @param contained The DOM element that may be contained by (a descendant of) the other element. + */ + contains(container: Element, contained: Element): boolean; + + /** + * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + * + * @param collection The object or array to iterate over. + * @param callback The function that will be executed on every object. + */ + each( + collection: T[], + callback: (indexInArray: number, valueOfElement: T) => any + ): any; + + /** + * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + * + * @param collection The object or array to iterate over. + * @param callback The function that will be executed on every object. + */ + each( + collection: any, + callback: (indexInArray: any, valueOfElement: any) => any + ): any; + + /** + * Merge the contents of two or more objects together into the first object. + * + * @param target An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument. + * @param object1 An object containing additional properties to merge in. + * @param objectN Additional objects containing properties to merge in. + */ + extend(target: any, object1?: any, ...objectN: any[]): any; + /** + * Merge the contents of two or more objects together into the first object. + * + * @param deep If true, the merge becomes recursive (aka. deep copy). + * @param target The object to extend. It will receive the new properties. + * @param object1 An object containing additional properties to merge in. + * @param objectN Additional objects containing properties to merge in. + */ + extend(deep: boolean, target: any, object1?: any, ...objectN: any[]): any; + + /** + * Execute some JavaScript code globally. + * + * @param code The JavaScript code to execute. + */ + globalEval(code: string): any; + + /** + * Finds the elements of an array which satisfy a filter function. The original array is not affected. + * + * @param array The array to search through. + * @param func The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. this will be the global window object. + * @param invert If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false. + */ + grep(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[]; + + /** + * Search for a specified value within an array and return its index (or -1 if not found). + * + * @param value The value to search for. + * @param array An array through which to search. + * @param fromIndex he index of the array at which to begin the search. The default is 0, which will search the whole array. + */ + inArray(value: T, array: T[], fromIndex?: number): number; + + /** + * Determine whether the argument is an array. + * + * @param obj Object to test whether or not it is an array. + */ + isArray(obj: any): boolean; + /** + * Check to see if an object is empty (contains no enumerable properties). + * + * @param obj The object that will be checked to see if it's empty. + */ + isEmptyObject(obj: any): boolean; + /** + * Determine if the argument passed is a Javascript function object. + * + * @param obj Object to test whether or not it is a function. + */ + isFunction(obj: any): boolean; + /** + * Determines whether its argument is a number. + * + * @param obj The value to be tested. + */ + isNumeric(value: any): boolean; + /** + * Check to see if an object is a plain object (created using "{}" or "new Object"). + * + * @param obj The object that will be checked to see if it's a plain object. + */ + isPlainObject(obj: any): boolean; + /** + * Determine whether the argument is a window. + * + * @param obj Object to test whether or not it is a window. + */ + isWindow(obj: any): boolean; + /** + * Check to see if a DOM node is within an XML document (or is an XML document). + * + * @param node he DOM node that will be checked to see if it's in an XML document. + */ + isXMLDoc(node: Node): boolean; + + /** + * Convert an array-like object into a true JavaScript array. + * + * @param obj Any object to turn into a native Array. + */ + makeArray(obj: any): any[]; + + /** + * Translate all items in an array or object to new array of items. + * + * @param array The Array to translate. + * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object. + */ + map(array: T[], callback: (elementOfArray: T, indexInArray: number) => U): U[]; + /** + * Translate all items in an array or object to new array of items. + * + * @param arrayOrObject The Array or Object to translate. + * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object. + */ + map(arrayOrObject: any, callback: (value: any, indexOrKey: any) => any): any; + + /** + * Merge the contents of two arrays together into the first array. + * + * @param first The first array to merge, the elements of second added. + * @param second The second array to merge into the first, unaltered. + */ + merge(first: T[], second: T[]): T[]; + + /** + * An empty function. + */ + noop(): any; + + /** + * Return a number representing the current time. + */ + now(): number; + + /** + * Takes a well-formed JSON string and returns the resulting JavaScript object. + * + * @param json The JSON string to parse. + */ + parseJSON(json: string): Object; + + /** + * Parses a string into an XML document. + * + * @param data a well-formed XML string to be parsed + */ + parseXML(data: string): XMLDocument; + + /** + * Remove the whitespace from the beginning and end of a string. + * + * @param str Remove the whitespace from the beginning and end of a string. + */ + trim(str: string): string; + + /** + * Determine the internal JavaScript [[Class]] of an object. + * + * @param obj Object to get the internal JavaScript [[Class]] of. + */ + type(obj: any): string; + + /** + * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. + * + * @param array The Array of DOM elements. + */ + unique(array: Element[]): Element[]; + + /** + * Parses a string into an array of DOM nodes. + * + * @param data HTML string to be parsed + * @param context DOM element to serve as the context in which the HTML fragment will be created + * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + */ + parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[]; +} + +/** + * The jQuery instance members + */ +interface JQuery { + /** + * Register a handler to be called when Ajax requests complete. This is an AjaxEvent. + * + * @param handler The function to be invoked. + */ + ajaxComplete(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery; + /** + * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxError(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxSettings: JQueryAjaxSettings, thrownError: any) => any): JQuery; + /** + * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxSend(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxOptions: JQueryAjaxSettings) => any): JQuery; + /** + * Register a handler to be called when the first Ajax request begins. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxStart(handler: () => any): JQuery; + /** + * Register a handler to be called when all Ajax requests have completed. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxStop(handler: () => any): JQuery; + /** + * Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxSuccess(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: JQueryAjaxSettings) => any): JQuery; + + /** + * Load data from the server and place the returned HTML into the matched element. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param complete A callback function that is executed when the request completes. + */ + load(url: string, data?: string, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery; + /** + * Load data from the server and place the returned HTML into the matched element. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param complete A callback function that is executed when the request completes. + */ + load(url: string, data?: Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery; + + /** + * Encode a set of form elements as a string for submission. + */ + serialize(): string; + /** + * Encode a set of form elements as an array of names and values. + */ + serializeArray(): Object[]; + + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param className One or more space-separated classes to be added to the class attribute of each matched element. + */ + addClass(className: string): JQuery; + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + */ + addClass(func: (index: number, className: string) => string): JQuery; + + /** + * Add the previous set of elements on the stack to the current set, optionally filtered by a selector. + */ + addBack(selector?: string): JQuery; + + /** + * Get the value of an attribute for the first element in the set of matched elements. + * + * @param attributeName The name of the attribute to get. + */ + attr(attributeName: string): string; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param value A value to set for the attribute. + */ + attr(attributeName: string, value: string): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param value A value to set for the attribute. + */ + attr(attributeName: string, value: number): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments. + */ + attr(attributeName: string, func: (index: number, attr: any) => any): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributes An object of attribute-value pairs to set. + */ + attr(attributes: Object): JQuery; + + /** + * Determine whether any of the matched elements are assigned the given class. + * + * @param className The class name to search for. + */ + hasClass(className: string): boolean; + + /** + * Get the HTML contents of the first element in the set of matched elements. + */ + html(): string; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param htmlString A string of HTML to set as the content of each matched element. + */ + html(htmlString: string): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + */ + html(func: (index: number, oldhtml: string) => string): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + */ + + /** + * Get the value of a property for the first element in the set of matched elements. + * + * @param propertyName The name of the property to get. + */ + prop(propertyName: string): any; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param value A value to set for the property. + */ + prop(propertyName: string, value: string): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param value A value to set for the property. + */ + prop(propertyName: string, value: number): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param value A value to set for the property. + */ + prop(propertyName: string, value: boolean): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + */ + prop(properties: Object): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element. + */ + prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): JQuery; + + /** + * Remove an attribute from each element in the set of matched elements. + * + * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. + */ + removeAttr(attributeName: string): JQuery; + + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param className One or more space-separated classes to be removed from the class attribute of each matched element. + */ + removeClass(className?: string): JQuery; + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param function A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + */ + removeClass(func: (index: number, className: string) => string): JQuery; + + /** + * Remove a property for the set of matched elements. + * + * @param propertyName The name of the property to remove. + */ + removeProp(propertyName: string): JQuery; + + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set. + * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. + */ + toggleClass(className: string, swtch?: boolean): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param swtch A boolean value to determine whether the class should be added or removed. + */ + toggleClass(swtch?: boolean): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments. + * @param swtch A boolean value to determine whether the class should be added or removed. + */ + toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): JQuery; + + /** + * Get the current value of the first element in the set of matched elements. + */ + val(): any; + /** + * Set the value of each element in the set of matched elements. + * + * @param value A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked. + */ + val(value: string): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param value A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked. + */ + val(value: string[]): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: any) => any): JQuery; + + /** + * Get the value of style properties for the first element in the set of matched elements. + * + * @param propertyName A CSS property. + */ + css(propertyName: string): string; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: string): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: string[]): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: number[]): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + css(propertyName: string, value: (index: number, value: string) => string): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + css(propertyName: string, value: (index: number, value: number) => number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + */ + css(properties: Object): JQuery; + + /** + * Get the current computed height for the first element in the set of matched elements. + */ + height(): number; + /** + * Set the CSS height of every matched element. + * + * @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string). + */ + height(value: number): JQuery; + /** + * Set the CSS height of every matched element. + * + * @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string). + */ + height(value: string): JQuery; + /** + * Set the CSS height of every matched element. + * + * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + */ + height(func: (index: number, height: number) => number): JQuery; + /** + * Set the CSS height of every matched element. + * + * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + */ + height(func: (index: number, height: string) => string): JQuery; + /** + * Set the CSS height of every matched element. + * + * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + */ + height(func: (index: number, height: string) => number): JQuery; + /** + * Set the CSS height of every matched element. + * + * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + */ + height(func: (index: number, height: number) => string): JQuery; + + /** + * Get the current computed height for the first element in the set of matched elements, including padding but not border. + */ + innerHeight(): number; + + /** + * Sets the inner height on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerHeight(height: number): JQuery; + + /** + * Sets the inner height on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerHeight(height: string): JQuery; + + /** + * Get the current computed width for the first element in the set of matched elements, including padding but not border. + */ + innerWidth(): number; + + /** + * Sets the inner width on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerWidth(width: number): JQuery; + + /** + * Sets the inner width on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerWidth(width: string): JQuery; + + /** + * Get the current coordinates of the first element in the set of matched elements, relative to the document. + */ + offset(): JQueryCoordinates; + /** + * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + * + * @param coordinates An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + */ + offset(coordinates: JQueryCoordinates): JQuery; + /** + * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + * + * @param func A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties. + */ + offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): JQuery; + + /** + * Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. + * + * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + */ + outerHeight(includeMargin?: boolean): number; + + /** + * Sets the outer height on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerHeight(height: number): JQuery; + + /** + * Sets the outer height on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerHeight(height: string): JQuery; + + /** + * Get the current computed width for the first element in the set of matched elements, including padding and border. + * + * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + */ + outerWidth(includeMargin?: boolean): number; + + /** + * Sets the outer width on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerWidth(width: number): JQuery; + + /** + * Sets the outer width on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerWidth(width: string): JQuery; + + /** + * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. + */ + position(): JQueryCoordinates; + + /** + * Get the current horizontal position of the scroll bar for the first element in the set of matched elements or set the horizontal position of the scroll bar for every matched element. + */ + scrollLeft(): number; + /** + * Set the current horizontal position of the scroll bar for each of the set of matched elements. + * + * @param value An integer indicating the new position to set the scroll bar to. + */ + scrollLeft(value: number): JQuery; + + /** + * Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element. + */ + scrollTop(): number; + /** + * Set the current vertical position of the scroll bar for each of the set of matched elements. + * + * @param value An integer indicating the new position to set the scroll bar to. + */ + scrollTop(value: number): JQuery; + + /** + * Get the current computed width for the first element in the set of matched elements. + */ + width(): number; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + width(value: number): JQuery; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + width(value: string): JQuery; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + */ + width(func: (index: number, width: number) => number): JQuery; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + */ + width(func: (index: number, width: string) => string): JQuery; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + */ + width(func: (index: number, width: string) => number): JQuery; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + */ + width(func: (index: number, width: number) => string): JQuery; + + /** + * Remove from the queue all items that have not yet been run. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + clearQueue(queueName?: string): JQuery; + + /** + * Store arbitrary data associated with the matched elements. + * + * @param key A string naming the piece of data to set. + * @param value The new data value; it can be any Javascript type including Array or Object. + */ + data(key: string, value: any): JQuery; + /** + * Store arbitrary data associated with the matched elements. + * + * @param obj An object of key-value pairs of data to update. + */ + data(obj: { [key: string]: any; }): JQuery; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + * + * @param key Name of the data stored. + */ + data(key: string): any; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + */ + data(): any; + + /** + * Execute the next function on the queue for the matched elements. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + dequeue(queueName?: string): JQuery; + + /** + * Remove a previously-stored piece of data. + * + * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete. + */ + removeData(name: string): JQuery; + /** + * Remove a previously-stored piece of data. + * + * @param list An array of strings naming the pieces of data to delete. + */ + removeData(list: string[]): JQuery; + + /** + * Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished. + * + * @param type The type of queue that needs to be observed. (default: fx) + * @param target Object onto which the promise methods have to be attached + */ + promise(type?: string, target?: Object): JQueryPromise; + + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + animate(properties: Object, duration?: string, complete?: Function): JQuery; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + animate(properties: Object, duration?: number, complete?: Function): JQuery; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. (default: swing) + * @param complete A function to call once the animation is complete. + */ + animate(properties: Object, duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. (default: swing) + * @param complete A function to call once the animation is complete. + */ + animate(properties: Object, duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param options A map of additional options to pass to the method. + */ + animate(properties: Object, options: JQueryAnimationOptions): JQuery; + + /** + * Set a timer to delay execution of subsequent items in the queue. + * + * @param duration An integer indicating the number of milliseconds to delay execution of the next item in the queue. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + delay(duration: number, queueName?: string): JQuery; + + /** + * Display the matched elements by fading them to opaque. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeIn(duration?: number, complete?: Function): JQuery; + /** + * Display the matched elements by fading them to opaque. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeIn(duration?: string, complete?: Function): JQuery; + /** + * Display the matched elements by fading them to opaque. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeIn(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements by fading them to opaque. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeIn(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements by fading them to opaque. + * + * @param options A map of additional options to pass to the method. + */ + fadeIn(options: JQueryAnimationOptions): JQuery; + + /** + * Hide the matched elements by fading them to transparent. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeOut(duration?: number, complete?: Function): JQuery; + /** + * Hide the matched elements by fading them to transparent. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeOut(duration?: string, complete?: Function): JQuery; + /** + * Hide the matched elements by fading them to transparent. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeOut(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements by fading them to transparent. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeOut(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements by fading them to transparent. + * + * @param options A map of additional options to pass to the method. + */ + fadeOut(options: JQueryAnimationOptions): JQuery; + + /** + * Adjust the opacity of the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param opacity A number between 0 and 1 denoting the target opacity. + * @param complete A function to call once the animation is complete. + */ + fadeTo(duration: string, opacity: number, complete?: Function): JQuery; + /** + * Adjust the opacity of the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param opacity A number between 0 and 1 denoting the target opacity. + * @param complete A function to call once the animation is complete. + */ + fadeTo(duration: number, opacity: number, complete?: Function): JQuery; + /** + * Adjust the opacity of the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param opacity A number between 0 and 1 denoting the target opacity. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeTo(duration: string, opacity: number, easing?: string, complete?: Function): JQuery; + /** + * Adjust the opacity of the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param opacity A number between 0 and 1 denoting the target opacity. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeTo(duration: number, opacity: number, easing?: string, complete?: Function): JQuery; + + /** + * Display or hide the matched elements by animating their opacity. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeToggle(duration?: number, complete?: Function): JQuery; + /** + * Display or hide the matched elements by animating their opacity. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeToggle(duration?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements by animating their opacity. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeToggle(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements by animating their opacity. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeToggle(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements by animating their opacity. + * + * @param options A map of additional options to pass to the method. + */ + fadeToggle(options: JQueryAnimationOptions): JQuery; + + /** + * Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements. + * + * @param queue The name of the queue in which to stop animations. + */ + finish(queue?: string): JQuery; + + /** + * Hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + hide(duration?: number, complete?: Function): JQuery; + /** + * Hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + hide(duration?: string, complete?: Function): JQuery; + /** + * Hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + hide(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + hide(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements. + * + * @param options A map of additional options to pass to the method. + */ + hide(options: JQueryAnimationOptions): JQuery; + + /** + * Display the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + show(duration?: number, complete?: Function): JQuery; + /** + * Display the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + show(duration?: string, complete?: Function): JQuery; + /** + * Display the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + show(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + show(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements. + * + * @param options A map of additional options to pass to the method. + */ + show(options: JQueryAnimationOptions): JQuery; + + /** + * Display the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideDown(duration?: number, complete?: Function): JQuery; + /** + * Display the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideDown(duration?: string, complete?: Function): JQuery; + /** + * Display the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideDown(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideDown(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements with a sliding motion. + * + * @param options A map of additional options to pass to the method. + */ + slideDown(options: JQueryAnimationOptions): JQuery; + + /** + * Display or hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideToggle(duration?: number, complete?: Function): JQuery; + /** + * Display or hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideToggle(duration?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideToggle(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideToggle(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements with a sliding motion. + * + * @param options A map of additional options to pass to the method. + */ + slideToggle(options: JQueryAnimationOptions): JQuery; + + /** + * Hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideUp(duration?: number, complete?: Function): JQuery; + /** + * Hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideUp(duration?: string, complete?: Function): JQuery; + /** + * Hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideUp(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideUp(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements with a sliding motion. + * + * @param options A map of additional options to pass to the method. + */ + slideUp(options: JQueryAnimationOptions): JQuery; + + /** + * Stop the currently-running animation on the matched elements. + * + * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false. + * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false. + */ + stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery; + /** + * Stop the currently-running animation on the matched elements. + * + * @param queue The name of the queue in which to stop animations. + * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false. + * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false. + */ + stop(queue?: string, clearQueue?: boolean, jumpToEnd?: boolean): JQuery; + + /** + * Display or hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + toggle(duration?: number, complete?: Function): JQuery; + /** + * Display or hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + toggle(duration?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + toggle(duration?: number, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + toggle(duration?: string, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements. + * + * @param options A map of additional options to pass to the method. + */ + toggle(options: JQueryAnimationOptions): JQuery; + /** + * Display or hide the matched elements. + * + * @param showOrHide A Boolean indicating whether to show or hide the elements. + */ + toggle(showOrHide: boolean): JQuery; + + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute each time the event is triggered. + */ + bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ + bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ + bind(eventType: string, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param events An object containing one or more DOM event types and functions to execute for them. + */ + bind(events: any): JQuery; + + /** + * Trigger the "blur" event on an element + */ + blur(): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + blur(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "change" event on an element. + */ + change(): JQuery; + /** + * Bind an event handler to the "change" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + change(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "change" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "click" event on an element. + */ + click(): JQuery; + /** + * Bind an event handler to the "click" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + */ + click(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "click" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + click(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "dblclick" event on an element. + */ + dblclick(): JQuery; + /** + * Bind an event handler to the "dblclick" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + dblclick(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "dblclick" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + dblclick(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + delegate(selector: any, eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "focus" event on an element. + */ + focus(): JQuery; + /** + * Bind an event handler to the "focus" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focus(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focus" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind an event handler to the "focusin" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focusin(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focusin" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focusin(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind an event handler to the "focusout" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focusout(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focusout" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focusout(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. + * + * @param handlerIn A function to execute when the mouse pointer enters the element. + * @param handlerOut A function to execute when the mouse pointer leaves the element. + */ + hover(handlerIn: (eventObject: JQueryEventObject) => any, handlerOut: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements. + * + * @param handlerInOut A function to execute when the mouse pointer enters or leaves the element. + */ + hover(handlerInOut: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "keydown" event on an element. + */ + keydown(): JQuery; + /** + * Bind an event handler to the "keydown" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keydown(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the keydown"" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keydown(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Trigger the "keypress" event on an element. + */ + keypress(): JQuery; + /** + * Bind an event handler to the "keypress" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keypress(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keypress" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keypress(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Trigger the "keyup" event on an element. + */ + keyup(): JQuery; + /** + * Bind an event handler to the "keyup" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keyup(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keyup" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keyup(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Bind an event handler to the "load" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + load(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "load" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + load(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "mousedown" event on an element. + */ + mousedown(): JQuery; + /** + * Bind an event handler to the "mousedown" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mousedown(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mousedown" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mousedown(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseenter" event on an element. + */ + mouseenter(): JQuery; + /** + * Bind an event handler to be fired when the mouse enters an element. + * + * @param handler A function to execute when the event is triggered. + */ + mouseenter(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to be fired when the mouse enters an element. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseenter(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseleave" event on an element. + */ + mouseleave(): JQuery; + /** + * Bind an event handler to be fired when the mouse leaves an element. + * + * @param handler A function to execute when the event is triggered. + */ + mouseleave(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to be fired when the mouse leaves an element. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseleave(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mousemove" event on an element. + */ + mousemove(): JQuery; + /** + * Bind an event handler to the "mousemove" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mousemove(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mousemove" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mousemove(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseout" event on an element. + */ + mouseout(): JQuery; + /** + * Bind an event handler to the "mouseout" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseout(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseout" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseout(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseover" event on an element. + */ + mouseover(): JQuery; + /** + * Bind an event handler to the "mouseover" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseover(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseover" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseover(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseup" event on an element. + */ + mouseup(): JQuery; + /** + * Bind an event handler to the "mouseup" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseup(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseup" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseup(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Remove an event handler. + */ + off(): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + * @param handler A handler function previously attached for the event(s), or the special value false. + */ + off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param handler A handler function previously attached for the event(s), or the special value false. + */ + off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s). + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + */ + off(events: { [key: string]: any; }, selector?: string): JQuery; + + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). + */ + on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + on(events: { [key: string]: any; }, selector?: any, data?: any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute at the time the event is triggered. + */ + one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param data An object containing data that will be passed to the event handler. + * @param handler A function to execute at the time the event is triggered. + */ + one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; + + + /** + * Specify a function to execute when the DOM is fully loaded. + * + * @param handler A function to execute after the DOM is ready. + */ + ready(handler: Function): JQuery; + + /** + * Trigger the "resize" event on an element. + */ + resize(): JQuery; + /** + * Bind an event handler to the "resize" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + resize(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "resize" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + resize(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "scroll" event on an element. + */ + scroll(): JQuery; + /** + * Bind an event handler to the "scroll" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + scroll(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "scroll" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + scroll(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "select" event on an element. + */ + select(): JQuery; + /** + * Bind an event handler to the "select" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + select(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "select" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + select(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "submit" event on an element. + */ + submit(): JQuery; + /** + * Bind an event handler to the "submit" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + submit(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "submit" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(eventType: string, extraParameters?: any[]): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(eventType: string, extraParameters?: Object): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param event A jQuery.Event object. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(event: JQueryEventObject, extraParameters?: any[]): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param event A jQuery.Event object. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(event: JQueryEventObject, extraParameters?: Object): JQuery; + + /** + * Execute all handlers attached to an element for an event. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters An array of additional parameters to pass along to the event handler. + */ + triggerHandler(eventType: string, ...extraParameters: any[]): Object; + + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param handler The function that is to be no longer executed. + */ + unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + */ + unbind(eventType: string, fls: boolean): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param evt A JavaScript event object as passed to an event handler. + */ + unbind(evt: any): JQuery; + + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + */ + undelegate(): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param eventType A string containing a JavaScript event type, such as "click" or "keydown" + * @param handler A function to execute at the time the event is triggered. + */ + undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param events An object of one or more event types and previously bound functions to unbind from them. + */ + undelegate(selector: string, events: Object): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param namespace A string containing a namespace to unbind all events from. + */ + undelegate(namespace: string): JQuery; + + /** + * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) + * + * @param handler A function to execute when the event is triggered. + */ + unload(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) + * + * @param eventData A plain object of data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. (DEPRECATED from v1.10) + */ + context: Element; + + jquery: string; + + /** + * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) + * + * @param handler A function to execute when the event is triggered. + */ + error(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) + * + * @param eventData A plain object of data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Add a collection of DOM elements onto the jQuery stack. + * + * @param elements An array of elements to push onto the stack and make into a new jQuery object. + */ + pushStack(elements: any[]): JQuery; + /** + * Add a collection of DOM elements onto the jQuery stack. + * + * @param elements An array of elements to push onto the stack and make into a new jQuery object. + * @param name The name of a jQuery method that generated the array of elements. + * @param arguments The arguments that were passed in to the jQuery method (for serialization). + */ + pushStack(elements: any[], name: string, arguments: any[]): JQuery; + + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: JQuery, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: any[], ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: Element, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: Text, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + after(func: (index: number) => any): JQuery; + + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: JQuery, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: any[], ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: Element, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: Text, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + */ + append(func: (index: number, html: string) => any): JQuery; + + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: JQuery): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: any[]): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: Element): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: string): JQuery; + + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + */ + before(content1: JQuery, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + */ + before(content1: any[], ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + */ + before(content1: Element, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + */ + before(content1: Text, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + */ + before(content1: string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + before(func: (index: number) => any): JQuery; + + /** + * Create a deep copy of the set of matched elements. + * + * param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. + * param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). + */ + clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery; + + /** + * Remove the set of matched elements from the DOM. + * + * param selector A selector expression that filters the set of matched elements to be removed. + */ + detach(selector?: string): JQuery; + + /** + * Remove all child nodes of the set of matched elements from the DOM. + */ + empty(): JQuery; + + /** + * Insert every element in the set of matched elements after the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + */ + insertAfter(target: JQuery): JQuery; + /** + * Insert every element in the set of matched elements after the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + */ + insertAfter(target: any[]): JQuery; + /** + * Insert every element in the set of matched elements after the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + */ + insertAfter(target: Element): JQuery; + /** + * Insert every element in the set of matched elements after the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + */ + insertAfter(target: Text): JQuery; + /** + * Insert every element in the set of matched elements after the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + */ + insertAfter(target: string): JQuery; + + /** + * Insert every element in the set of matched elements before the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + */ + insertBefore(target: JQuery): JQuery; + /** + * Insert every element in the set of matched elements before the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + */ + insertBefore(target: any[]): JQuery; + /** + * Insert every element in the set of matched elements before the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + */ + insertBefore(target: Element): JQuery; + /** + * Insert every element in the set of matched elements before the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + */ + insertBefore(target: Text): JQuery; + /** + * Insert every element in the set of matched elements before the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + */ + insertBefore(target: string): JQuery; + + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + */ + prepend(content1: JQuery, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + */ + prepend(content1: any[], ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + */ + prepend(content1: Element, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + */ + prepend(content1: Text, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + */ + prepend(content1: string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + */ + prepend(func: (index: number, html: string) => any): JQuery; + + /** + * Insert every element in the set of matched elements to the beginning of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + */ + prependTo(target: JQuery): JQuery; + /** + * Insert every element in the set of matched elements to the beginning of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + */ + prependTo(target: any[]): JQuery; + /** + * Insert every element in the set of matched elements to the beginning of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + */ + prependTo(target: Element): JQuery; + /** + * Insert every element in the set of matched elements to the beginning of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + */ + prependTo(target: string): JQuery; + + /** + * Remove the set of matched elements from the DOM. + * + * @param selector A selector expression that filters the set of matched elements to be removed. + */ + remove(selector?: string): JQuery; + + /** + * Replace each target element with the set of matched elements. + * + * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. + */ + replaceAll(target: JQuery): JQuery; + /** + * Replace each target element with the set of matched elements. + * + * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. + */ + replaceAll(target: any[]): JQuery; + /** + * Replace each target element with the set of matched elements. + * + * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. + */ + replaceAll(target: Element): JQuery; + /** + * Replace each target element with the set of matched elements. + * + * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. + */ + replaceAll(target: string): JQuery; + + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + */ + replaceWith(newContent: JQuery): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + */ + replaceWith(newContent: any[]): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + */ + replaceWith(newContent: Element): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + */ + replaceWith(newContent: Text): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + */ + replaceWith(newContent: string): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param func A function that returns content with which to replace the set of matched elements. + */ + replaceWith(func: () => any): JQuery; + + /** + * Get the combined text contents of each element in the set of matched elements, including their descendants. + */ + text(): string; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param text The text to set as the content of each matched element. + */ + text(text: string): JQuery; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param text The text to set as the content of each matched element. + */ + text(text: number): JQuery; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param text The text to set as the content of each matched element. + */ + text(text: boolean): JQuery; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. + */ + text(func: (index: number, text: string) => string): JQuery; + + /** + * Retrieve all the elements contained in the jQuery set, as an array. + */ + toArray(): any[]; + + /** + * Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place. + */ + unwrap(): JQuery; + + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrap(wrappingElement: JQuery): JQuery; + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrap(wrappingElement: Element): JQuery; + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrap(wrappingElement: string): JQuery; + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + wrap(func: (index: number) => any): JQuery; + + /** + * Wrap an HTML structure around all elements in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrapAll(wrappingElement: JQuery): JQuery; + /** + * Wrap an HTML structure around all elements in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrapAll(wrappingElement: Element): JQuery; + /** + * Wrap an HTML structure around all elements in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrapAll(wrappingElement: string): JQuery; + + /** + * Wrap an HTML structure around the content of each element in the set of matched elements. + * + * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. + */ + wrapInner(wrappingElement: JQuery): JQuery; + /** + * Wrap an HTML structure around the content of each element in the set of matched elements. + * + * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. + */ + wrapInner(wrappingElement: Element): JQuery; + /** + * Wrap an HTML structure around the content of each element in the set of matched elements. + * + * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. + */ + wrapInner(wrappingElement: string): JQuery; + /** + * Wrap an HTML structure around the content of each element in the set of matched elements. + * + * @param func A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + wrapInner(func: (index: number) => any): JQuery; + + /** + * Iterate over a jQuery object, executing a function for each matched element. + * + * @param func A function to execute for each matched element. + */ + each(func: (index: number, elem: Element) => any): JQuery; + + /** + * Retrieve one of the elements matched by the jQuery object. + * + * @param index A zero-based integer indicating which element to retrieve. + */ + get(index: number): HTMLElement; + /** + * Retrieve the elements matched by the jQuery object. + */ + get(): any[]; + + /** + * Search for a given element from among the matched elements. + */ + index(): number; + /** + * Search for a given element from among the matched elements. + * + * @param selector A selector representing a jQuery collection in which to look for an element. + */ + index(selector: string): number; + /** + * Search for a given element from among the matched elements. + * + * @param element The DOM element or first element within the jQuery object to look for. + */ + index(element: JQuery): number; + /** + * Search for a given element from among the matched elements. + * + * @param element The DOM element or first element within the jQuery object to look for. + */ + index(element: Element): number; + + /** + * The number of elements in the jQuery object. + */ + length: number; + /** + * A selector representing selector passed to jQuery(), if any, when creating the original set. + * version deprecated: 1.7, removed: 1.9 + */ + selector: string; + [index: string]: any; + [index: number]: HTMLElement; + + /** + * Add elements to the set of matched elements. + * + * @param selector A string representing a selector expression to find additional elements to add to the set of matched elements. + * @param context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. + */ + add(selector: string, context?: Element): JQuery; + /** + * Add elements to the set of matched elements. + * + * @param elements One or more elements to add to the set of matched elements. + */ + add(...elements: Element[]): JQuery; + /** + * Add elements to the set of matched elements. + * + * @param html An HTML fragment to add to the set of matched elements. + */ + add(html: string): JQuery; + /** + * Add elements to the set of matched elements. + * + * @param obj An existing jQuery object to add to the set of matched elements. + */ + add(obj: JQuery): JQuery; + + /** + * Get the children of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + children(selector?: string): JQuery; + + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param selector A string containing a selector expression to match elements against. + */ + closest(selector: string): JQuery; + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param selector A string containing a selector expression to match elements against. + * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + */ + closest(selector: string, context?: Element): JQuery; + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param obj A jQuery object to match elements against. + */ + closest(obj: JQuery): JQuery; + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param element An element to match elements against. + */ + closest(element: Element): JQuery; + + /** + * Get an array of all the elements and selectors matched against the current element up through the DOM tree. + * + * @param selectors An array or string containing a selector expression to match elements against (can also be a jQuery object). + * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + */ + closest(selectors: any, context?: Element): any[]; + + /** + * Get the children of each element in the set of matched elements, including text and comment nodes. + */ + contents(): JQuery; + + /** + * End the most recent filtering operation in the current chain and return the set of matched elements to its previous state. + */ + end(): JQuery; + + /** + * Reduce the set of matched elements to the one at the specified index. + * + * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set. + * + */ + eq(index: number): JQuery; + + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param selector A string containing a selector expression to match the current set of elements against. + */ + filter(selector: string): JQuery; + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param func A function used as a test for each element in the set. this is the current DOM element. + */ + filter(func: (index: number) => any): JQuery; + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param element An element to match the current set of elements against. + */ + filter(element: Element): JQuery; + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param obj An existing jQuery object to match the current set of elements against. + */ + filter(obj: JQuery): JQuery; + + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param selector A string containing a selector expression to match elements against. + */ + find(selector: string): JQuery; + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param element An element to match elements against. + */ + find(element: Element): JQuery; + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param obj A jQuery object to match elements against. + */ + find(obj: JQuery): JQuery; + + /** + * Reduce the set of matched elements to the first in the set. + */ + first(): JQuery; + + /** + * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. + * + * @param selector A string containing a selector expression to match elements against. + */ + has(selector: string): JQuery; + /** + * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. + * + * @param contained A DOM element to match elements against. + */ + has(contained: Element): JQuery; + + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param selector A string containing a selector expression to match elements against. + */ + is(selector: string): boolean; + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param func A function used as a test for the set of elements. It accepts one argument, index, which is the element's index in the jQuery collection.Within the function, this refers to the current DOM element. + */ + is(func: (index: number) => any): boolean; + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param obj An existing jQuery object to match the current set of elements against. + */ + is(obj: JQuery): boolean; + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param elements One or more elements to match the current set of elements against. + */ + is(elements: any): boolean; + + /** + * Reduce the set of matched elements to the final one in the set. + */ + last(): JQuery; + + /** + * Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. + * + * @param callback A function object that will be invoked for each element in the current set. + */ + map(callback: (index: number, domElement: Element) => any): JQuery; + + /** + * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + next(selector?: string): JQuery; + + /** + * Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + nextAll(selector?: string): JQuery; + + /** + * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + * + * @param selector A string containing a selector expression to indicate where to stop matching following sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + nextUntil(selector?: string, filter?: string): JQuery; + /** + * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + * + * @param element A DOM node or jQuery object indicating where to stop matching following sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + nextUntil(element?: Element, filter?: string): JQuery; + /** + * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + * + * @param obj A DOM node or jQuery object indicating where to stop matching following sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + nextUntil(obj?: JQuery, filter?: string): JQuery; + + /** + * Remove elements from the set of matched elements. + * + * @param selector A string containing a selector expression to match elements against. + */ + not(selector: string): JQuery; + /** + * Remove elements from the set of matched elements. + * + * @param func A function used as a test for each element in the set. this is the current DOM element. + */ + not(func: (index: number) => any): JQuery; + /** + * Remove elements from the set of matched elements. + * + * @param elements One or more DOM elements to remove from the matched set. + */ + not(...elements: Element[]): JQuery; + /** + * Remove elements from the set of matched elements. + * + * @param obj An existing jQuery object to match the current set of elements against. + */ + not(obj: JQuery): JQuery; + + /** + * Get the closest ancestor element that is positioned. + */ + offsetParent(): JQuery; + + /** + * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + parent(selector?: string): JQuery; + + /** + * Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + parents(selector?: string): JQuery; + + /** + * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param selector A string containing a selector expression to indicate where to stop matching ancestor elements. + * @param filter A string containing a selector expression to match elements against. + */ + parentsUntil(selector?: string, filter?: string): JQuery; + /** + * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param element A DOM node or jQuery object indicating where to stop matching ancestor elements. + * @param filter A string containing a selector expression to match elements against. + */ + parentsUntil(element?: Element, filter?: string): JQuery; + /** + * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param obj A DOM node or jQuery object indicating where to stop matching ancestor elements. + * @param filter A string containing a selector expression to match elements against. + */ + parentsUntil(obj?: JQuery, filter?: string): JQuery; + + /** + * Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + prev(selector?: string): JQuery; + + /** + * Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + prevAll(selector?: string): JQuery; + + /** + * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param selector A string containing a selector expression to indicate where to stop matching preceding sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + prevUntil(selector?: string, filter?: string): JQuery; + /** + * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param element A DOM node or jQuery object indicating where to stop matching preceding sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + prevUntil(element?: Element, filter?: string): JQuery; + /** + * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param obj A DOM node or jQuery object indicating where to stop matching preceding sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + prevUntil(obj?: JQuery, filter?: string): JQuery; + + /** + * Get the siblings of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + siblings(selector?: string): JQuery; + + /** + * Reduce the set of matched elements to a subset specified by a range of indices. + * + * @param start An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set. + * @param end An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set. + */ + slice(start: number, end?: number): JQuery; + + /** + * Show the queue of functions to be executed on the matched elements. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + queue(queueName?: string): any[]; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. + */ + queue(callback: Function): JQuery; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(queueName: string, newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. + */ + queue(queueName: string, callback: Function): JQuery; +} +declare module "jquery" { + export = $; +} +declare var jQuery: JQueryStatic; +declare var $: JQueryStatic; diff --git a/knockout.d.ts b/knockout.d.ts new file mode 100644 index 0000000..66ebe27 --- /dev/null +++ b/knockout.d.ts @@ -0,0 +1,515 @@ +// Type definitions for Knockout 2.3 +// Project: http://knockoutjs.com +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface KnockoutSubscribableFunctions { + notifySubscribers(valueToWrite?: T, event?: string): void; +} + +interface KnockoutComputedFunctions { +} + +interface KnockoutObservableFunctions { + equalityComparer(a: any, b: any): boolean; +} + +interface KnockoutObservableArrayFunctions { + // General Array functions + indexOf(searchElement: T, fromIndex?: number): number; + slice(start: number, end?: number): T[]; + splice(start: number): T[]; + splice(start: number, deleteCount: number, ...items: T[]): T[]; + pop(): T; + push(...items: T[]): void; + shift(): T; + unshift(...items: T[]): number; + reverse(): T[]; + sort(): void; + sort(compareFunction: (left: T, right: T) => number): void; + + // Ko specific + replace(oldItem: T, newItem: T): void; + + remove(item: T): T[]; + remove(removeFunction: (item: T) => boolean): T[]; + removeAll(items: T[]): T[]; + removeAll(): T[]; + + destroy(item: T): void; + destroyAll(items: T[]): void; + destroyAll(): void; +} + +interface KnockoutSubscribableStatic { + fn: KnockoutSubscribableFunctions; + + new (): KnockoutSubscribable; +} + +interface KnockoutSubscription { + dispose(): void; +} + +interface KnockoutSubscribable extends KnockoutSubscribableFunctions { + subscribe(callback: (newValue: T) => void, target?: any, event?: string): KnockoutSubscription; + subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable; + getSubscriptionsCount(): number; +} + +interface KnockoutComputedStatic { + fn: KnockoutComputedFunctions; + + (): KnockoutComputed; + (func: () => T, context?: any, options?: any): KnockoutComputed; + (def: KnockoutComputedDefine): KnockoutComputed; + (options?: any): KnockoutComputed; +} + +interface KnockoutComputed extends KnockoutObservable, KnockoutComputedFunctions { + + dispose(): void; + isActive(): boolean; + getDependenciesCount(): number; + extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed; +} + +interface KnockoutObservableArrayStatic { + fn: KnockoutObservableArrayFunctions; + + (value?: T[]): KnockoutObservableArray; +} + +interface KnockoutObservableArray extends KnockoutObservable, KnockoutObservableArrayFunctions { + extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray; +} + +interface KnockoutObservableStatic { + fn: KnockoutObservableFunctions; + + (value?: T): KnockoutObservable; +} + +interface KnockoutObservable extends KnockoutSubscribable, KnockoutObservableFunctions { + (): T; + (value: T): void; + + peek(): T; + valueHasMutated?:{(): void;}; + valueWillMutate?:{(): void;}; + extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable; +} + +interface KnockoutComputedDefine { + read(): T; + write? (value: T): void; + disposeWhenNodeIsRemoved?: Node; + disposeWhen? (): boolean; + owner?: any; + deferEvaluation?: boolean; +} + +interface KnockoutBindingContext { + $parent: any; + $parents: any[]; + $root: any; + $data: any; + $index?: number; + $parentContext?: KnockoutBindingContext; + + extend(properties: any): any; + createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; +} + +interface KnockoutBindingHandler { + init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void; + update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void; + options?: any; +} + +interface KnockoutBindingHandlers { + [bindingHandler: string]: KnockoutBindingHandler; + + // Controlling text and appearance + visible: KnockoutBindingHandler; + text: KnockoutBindingHandler; + html: KnockoutBindingHandler; + css: KnockoutBindingHandler; + style: KnockoutBindingHandler; + attr: KnockoutBindingHandler; + + // Control Flow + foreach: KnockoutBindingHandler; + if: KnockoutBindingHandler; + ifnot: KnockoutBindingHandler; + with: KnockoutBindingHandler; + + // Working with form fields + click: KnockoutBindingHandler; + event: KnockoutBindingHandler; + submit: KnockoutBindingHandler; + enable: KnockoutBindingHandler; + disable: KnockoutBindingHandler; + value: KnockoutBindingHandler; + hasfocus: KnockoutBindingHandler; + checked: KnockoutBindingHandler; + options: KnockoutBindingHandler; + selectedOptions: KnockoutBindingHandler; + uniqueName: KnockoutBindingHandler; + + // Rendering templates + template: KnockoutBindingHandler; +} + +interface KnockoutMemoization { + memoize(callback: () => string): string; + unmemoize(memoId: string, callbackParams: any[]): boolean; + unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: any[]): boolean; + parseMemoText(memoText: string): string; +} + +interface KnockoutVirtualElement {} + +interface KnockoutVirtualElements { + allowedBindings: { [bindingName: string]: boolean; }; + emptyNode(node: KnockoutVirtualElement ): void; + firstChild(node: KnockoutVirtualElement ): KnockoutVirtualElement; + insertAfter( container: KnockoutVirtualElement, nodeToInsert: HTMLElement, insertAfter: HTMLElement ): void; + nextSibling(node: KnockoutVirtualElement): HTMLElement; + prepend(node: KnockoutVirtualElement, toInsert: HTMLElement ): void; + setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: HTMLElement; } ): void; + childNodes(node: KnockoutVirtualElement ): HTMLElement[]; +} + +interface KnockoutExtenders { + throttle(target: any, timeout: number): KnockoutComputed; + notify(target: any, notifyWhen: string): any; +} + +interface KnockoutUtils { + + ////////////////////////////////// + // utils.domManipulation.js + ////////////////////////////////// + + simpleHtmlParse(html: string): any[]; + + jQueryHtmlParse(html: string): any[]; + + parseHtmlFragment(html: string): any[]; + + setHtml(node: Element, html: string): void; + + setHtml(node: Element, html: () => string): void; + + ////////////////////////////////// + // utils.domData.js + ////////////////////////////////// + + domData: { + get (node: Element, key: string): any; + + set (node: Element, key: string, value: any): void; + + getAll(node: Element, createIfNotFound: boolean): any; + + clear(node: Element): boolean; + }; + + ////////////////////////////////// + // utils.domNodeDisposal.js + ////////////////////////////////// + + domNodeDisposal: { + addDisposeCallback(node: Element, callback: Function): void; + + removeDisposeCallback(node: Element, callback: Function): void; + + cleanNode(node: Element): Element; + + removeNode(node: Element): void; + }; + + ////////////////////////////////// + // utils.js + ////////////////////////////////// + + fieldsIncludedWithJsonPost: any[]; + + compareArrays(a: T[], b: T[]): Array>; + + arrayForEach(array: T[], action: (item: T) => void): void; + + arrayIndexOf(array: T[], item: T): number; + + arrayFirst(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T; + + arrayRemoveItem(array: any[], itemToRemove: any): void; + + arrayGetDistinctValues(array: T[]): T[]; + + arrayMap(array: T[], mapping: (item: T) => U): U[]; + + arrayFilter(array: T[], predicate: (item: T) => boolean): T[]; + + arrayPushAll(array: T[], valuesToPush: T[]): T[]; + + arrayPushAll(array: KnockoutObservableArray, valuesToPush: T[]): T[]; + + extend(target: Object, source: Object): Object; + + emptyDomNode(domNode: HTMLElement): void; + + moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement; + + cloneNodes(nodesArray: any[], shouldCleanNodes: boolean): any[]; + + setDomNodeChildren(domNode: any, childNodes: any[]): void; + + replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void; + + setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void; + + stringTrim(str: string): string; + + stringTokenize(str: string, delimiter: string): string; + + stringStartsWith(str: string, startsWith: string): string; + + domNodeIsContainedBy(node: any, containedByNode: any): boolean; + + domNodeIsAttachedToDocument(node: any): boolean; + + tagNameLower(element: any): string; + + registerEventHandler(element: any, eventType: any, handler: Function): void; + + triggerEvent(element: any, eventType: any): void; + + unwrapObservable(value: KnockoutObservable): T; + + peekObservable(value: KnockoutObservable): T; + + toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void; + + //setTextContent(element: any, textContent: string): void; // NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670 + + setElementName(element: any, name: string): void; + + forceRefresh(node: any): void; + + ensureSelectElementIsRenderedCorrectly(selectElement: any): void; + + range(min: any, max: any): any; + + makeArray(arrayLikeObject: any): any[]; + + getFormFields(form: any, fieldName: string): any[]; + + parseJson(jsonString: string): any; + + stringifyJson(data: any, replacer?: Function, space?: string): string; + + postJson(urlOrForm: any, data: any, options: any): void; + + ieVersion: number; + + isIe6: boolean; + + isIe7: boolean; +} + +interface KnockoutArrayChange { + status: string; + value: T; + index: number; +} + +////////////////////////////////// +// templateSources.js +////////////////////////////////// + +interface KnockoutTemplateSourcesDomElement { + + text(valueToWrite?: any): any; + + data(key: string, valueToWrite?: any): any; +} + + +interface KnockoutTemplateSources { + + domElement: KnockoutTemplateSourcesDomElement; + + anonymousTemplate: { + + prototype: KnockoutTemplateSourcesDomElement; + + new (element: Element): KnockoutTemplateSourcesDomElement; + }; +} + +////////////////////////////////// +// nativeTemplateEngine.js +////////////////////////////////// + +interface KnockoutNativeTemplateEngine { + + renderTemplateSource(templateSource: Object, bindingContext?: KnockoutBindingContext, options?: Object): any[]; +} + +////////////////////////////////// +// templateEngine.js +////////////////////////////////// + +interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine { + + createJavaScriptEvaluatorBlock(script: string): string; + + makeTemplateSource(template: any, templateDocument?: Document): any; + + renderTemplate(template: any, bindingContext: KnockoutBindingContext, options: Object, templateDocument: Document): any; + + isTemplateRewritten(template: any, templateDocument: Document): boolean; + + rewriteTemplate(template: any, rewriterCallback: Function, templateDocument: Document): void; +} + +///////////////////////////////// + +interface KnockoutStatic { + utils: KnockoutUtils; + memoization: KnockoutMemoization; + bindingHandlers: KnockoutBindingHandlers; + virtualElements: KnockoutVirtualElements; + extenders: KnockoutExtenders; + + applyBindings(viewModel: any, rootNode?: any): void; + applyBindingsToDescendants(viewModel: any, rootNode: any): void; + applyBindingsToNode(node: Element, options: any, viewModel: any): void; + + subscribable: KnockoutSubscribableStatic; + observable: KnockoutObservableStatic; + computed: KnockoutComputedStatic; + observableArray: KnockoutObservableArrayStatic; + + contextFor(node: any): any; + isSubscribable(instance: any): boolean; + toJSON(viewModel: any, replacer?: Function, space?: any): string; + toJS(viewModel: any): any; + isObservable(instance: any): boolean; + isWriteableObservable(instance: any): boolean; + isComputed(instance: any): boolean; + dataFor(node: any): any; + removeNode(node: Element): void; + cleanNode(node: Element): Element; + renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; + renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; + unwrap(value: any): any; + + ////////////////////////////////// + // templateSources.js + ////////////////////////////////// + + templateSources: KnockoutTemplateSources; + + ////////////////////////////////// + // templateEngine.js + ////////////////////////////////// + + templateEngine: { + + prototype: KnockoutTemplateEngine; + + new (): KnockoutTemplateEngine; + }; + + ////////////////////////////////// + // templateRewriting.js + ////////////////////////////////// + + templateRewriting: { + + ensureTemplateIsRewritten(template: Node, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any; + ensureTemplateIsRewritten(template: string, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any; + + memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine): any; + + applyMemoizedBindingsToNextSibling(bindings: any, nodeName: string): string; + }; + + ////////////////////////////////// + // nativeTemplateEngine.js + ////////////////////////////////// + + nativeTemplateEngine: { + + prototype: KnockoutNativeTemplateEngine; + + new (): KnockoutNativeTemplateEngine; + + instance: KnockoutNativeTemplateEngine; + }; + + ////////////////////////////////// + // jqueryTmplTemplateEngine.js + ////////////////////////////////// + + jqueryTmplTemplateEngine: { + + prototype: KnockoutTemplateEngine; + + renderTemplateSource(templateSource: Object, bindingContext: KnockoutBindingContext, options: Object): Node[]; + + createJavaScriptEvaluatorBlock(script: string): string; + + addTemplate(templateName: string, templateMarkup: string): void; + }; + + ////////////////////////////////// + // templating.js + ////////////////////////////////// + + setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine): void; + + renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + + renderTemplateForEach(template: Function, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + renderTemplateForEach(template: any, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + + expressionRewriting: { + bindingRewriteValidators: any; + }; + + ///////////////////////////////// + + bindingProvider: any; + + ///////////////////////////////// + // selectExtensions.js + ///////////////////////////////// + + selectExtensions: { + + readValue(element: HTMLElement): any; + + writeValue(element: HTMLElement, value: any): void; + }; +} + +declare module "knockout" { + export = ko; +} + +declare var ko: KnockoutStatic; diff --git a/labs-1.0.4.d.ts b/labs-1.0.4.d.ts new file mode 100644 index 0000000..2b43642 --- /dev/null +++ b/labs-1.0.4.d.ts @@ -0,0 +1,2165 @@ +/*! + * Labs.js JavaScript API for Office Mix + * Version: 1.0.4 * Copyright (c) Microsoft Corporation. All rights reserved. + * Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419. + */ +declare module Labs.Core { + /** + * Definition of a lab action. An action represents an interaction a user has taken with the lab. + */ + interface IAction { + /** + * The type of action taken. + */ + type: string; + /** + * The options sent with the action + */ + options: Core.IActionOptions; + /** + * The result of the action + */ + result: Core.IActionResult; + /** + * The time at which the action was completed. In milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + time: number; + } +} +declare module Labs.Core { + /** + * The results of taking an action. Depending on the type of action these will either be set by the server side + * or provided by the client when taking the action. + */ + interface IActionResult { + } +} +declare module Labs.Core { + /** + * Base class for instances of a lab component. An instance is an instantiation of a component for a user. It contains + * a translated view of the component for a particular run of the lab. This view may exclude hidden information (answers, hints, etc...) + * and also contains IDs to identify the various instances. + */ + interface IComponentInstance extends Core.ILabObject, Core.IUserData { + /** + * The ID of the component this instance is associated with + */ + componentId: string; + /** + * The name of the component + */ + name: string; + /** + * value property map associated with the component + */ + values: { + [type: string]: Core.IValueInstance[]; + }; + } +} +declare module Labs.Core { + /** + * Information about the lab configuration. + */ + interface IConfigurationInfo { + /** + * The version of the host the lab configuration was created with. + */ + hostVersion: Core.IVersion; + } +} +declare module Labs.Core { + /** + * Response information coming from a connection call + */ + interface IConnectionResponse { + /** + * Initialization information or null if the app has not yet been initialized + */ + initializationInfo: Core.IConfigurationInfo; + /** + * The current mode the lab is running in + */ + mode: Core.LabMode; + /** + * Version information for server side + */ + hostVersion: Core.IVersion; + /** + * Information about the user + */ + userInfo: Core.IUserInfo; + } +} +declare module Labs.Core { + /** + * Options passed as part of a get action + */ + interface IGetActionOptions { + } +} +declare module Labs.Core { + /** + * Options passed as part of a lab create. + */ + interface ILabCreationOptions { + } +} +declare module Labs.Core { + /** + * Version information about the lab host + */ + interface ILabHostVersionInfo { + /** + * The API version of the host + */ + version: Core.IVersion; + } +} +declare module Labs.Core { + /** + * Definition of lab action options. These are the options passed when performing a given action. + */ + interface IActionOptions { + } +} +declare module Labs.Core { + /** + * Base interface for messages sent between the client and the host. + */ + interface IMessage { + } +} +declare module Labs.Core { + /** + * Base interface for responses to messages sent to the host. + */ + interface IMessageResponse { + } +} +declare module Labs.Core { + /** + * User information + */ + interface IUserInfo { + /** + * Unique identifier for the given lab user + */ + id: string; + /** + * Permissions the user has access to + */ + permissions: string[]; + } +} +declare module Labs.Core { + /** + * An intance of an IValue + */ + interface IValueInstance { + /** + * ID for the value this instance represents + */ + valueId: string; + /** + * Flag indicating whether or not this value is considered a hint + */ + isHint: boolean; + /** + * Flag indicating whether or not the instance information contains the value. + */ + hasValue: boolean; + /** + * The value. May or may not be set depending on if it has been hidden. + */ + value?: any; + } +} +declare module Labs.Core { + /** + * Version information + */ + interface IVersion { + /** + * Major version + */ + major: number; + /** + * Minor version + */ + minor: number; + } +} +declare module Labs.Core { + /** + * Custom analytics configuration information. Allows the develper to specify which iframe to load + * in order to display custom analytics for a user's run of a lab. + */ + interface IAnalyticsConfiguration { + } +} +declare module Labs.Core { + /** + * Completion status for the lab. Passed when completing the lab to indicate the result of the interaction. + */ + interface ICompletionStatus { + } +} +declare module Labs.Core { + /** + * Interface for Labs.js callback methods + */ + interface ILabCallback { + /** + * Callback signature + * + * @param { err } If an error has occurred this will be non-null + * @param { data } The data returned with the callback + */ + (err: any, data: T): void; + } +} +declare module Labs.Core { + /** + * A lab object contains a type field which indicates what type of object it is + */ + interface ILabObject { + /** + * The type name for the object + */ + type: string; + } +} +declare module Labs.Core { + /** + * Timeline configuration options. Allows the lab developer to specify a set of timeline configuration options. + */ + interface ITimelineConfiguration { + /** + * The duration of the lab in seconds + */ + duration: number; + /** + * A list of timeline capabilities the lab supports. i.e. play, pause, seek, fast forward... + */ + capabilities: string[]; + } +} +declare module Labs.Core { + /** + * Base interface to represent custom user data stored on an object + */ + interface IUserData { + /** + * An optional data field stored on the object for custom fields. + */ + data?: any; + } +} +declare module Labs.Core { + /** + * Base class for values stored with a lab + */ + interface IValue { + /** + * Flag indicating whether or not this value is considered a hint + */ + isHint: boolean; + /** + * The value + */ + value: any; + } +} +declare module Labs.Core { + /** + * Lab configuration data structure + */ + interface IConfiguration extends Core.IUserData { + /** + * The version of the application associated with this configuration + */ + appVersion: Core.IVersion; + /** + * The components of the lab + */ + components: Core.IComponent[]; + /** + * The name of the lab + */ + name: string; + /** + * Lab timeline configuration + */ + timeline: Core.ITimelineConfiguration; + /** + * Lab analytics configuration + */ + analytics: Core.IAnalyticsConfiguration; + } +} +declare module Labs.Core { + /** + * Base class for instances of a lab configuration. An instance is an instantiation of a configuration for a user. It contains + * a translated view of the configuration for a particular run of the lab. This view may exclude hidden information (answers, hints, etc...) + * and also contains IDs to identify the various instances. + */ + interface IConfigurationInstance extends Core.IUserData { + /** + * The version of the application associated with this configuration + */ + appVersion: Core.IVersion; + /** + * The components of the lab + */ + components: Core.IComponentInstance[]; + /** + * The name of the lab + */ + name: string; + /** + * Lab timeline configuration + */ + timeline: Core.ITimelineConfiguration; + } +} +declare module Labs.Core { + /** + * Base class for components of a lab. + */ + interface IComponent extends Core.ILabObject, Core.IUserData { + /** + * The name of the component + */ + name: string; + /** + * value property map associated with the component + */ + values: { + [type: string]: Core.IValue[]; + }; + } +} +declare module Labs.Core { + /** + * The current mode of the lab. Whether in edit mode or view mode. Edit is when configuring the lab and view + * is when taking the lab. + */ + enum LabMode { + /** + * The lab is in edit mode. Meaning the user is configuring it + */ + Edit, + /** + * The lab is in view mode. Meaning the user is taking it + */ + View, + } +} +declare module Labs.Core { + /** + * The ILabHost interfaces provides an abstraction for connecting Labs.js to the host + */ + interface ILabHost { + /** + * Retrieves the versions supported by this lab host. + */ + getSupportedVersions(): Core.ILabHostVersionInfo[]; + /** + * Initializes communication with the host + * + * @param { versions } The list of versions that the client of the host can make use of + * @param { callback } Callback for when the connection is complete + */ + connect(versions: Core.ILabHostVersionInfo[], callback: Core.ILabCallback); + /** + * Stops communication with the host + * + * @param { completionStatus } The final status of the lab at the time of the disconnect + * @param { callback } Callback fired when the disconnect completes + */ + disconnect(callback: Core.ILabCallback); + /** + * Adds an event handler for dealing with messages coming from the host. The resolved promsie + * will be returned back to the host + * + * @param { handler } The event handler + */ + on(handler: (string: any, any: any) => void); + /** + * Sends a message to the host + * + * @param { type } The type of message being sent + * @param { options } The options for that message + * @param { callback } Callback invoked once the message has been received + */ + sendMessage(type: string, options: Core.IMessage, callback: Core.ILabCallback); + /** + * Creates the lab. Stores the host information and sets aside space for storing the configuration and other elements. + * + * @param { options } Options passed as part of creation + */ + create(options: Core.ILabCreationOptions, callback: Core.ILabCallback); + /** + * Gets the current lab configuration from the host + * + * @param { callback } Callback method for retrieving configuration information + */ + getConfiguration(callback: Core.ILabCallback); + /** + * Sets a new lab configuration on the host + * + * @param { configuration } The lab configuration to set + * @param { callback } Callback fired when the configuration is set + */ + setConfiguration(configuration: Core.IConfiguration, callback: Core.ILabCallback); + /** + * Retrieves the instance configuration for the lab + * + * @param { callback } Callback that will be called when the configuration instance is retrieved + */ + getConfigurationInstance(callback: Core.ILabCallback); + /** + * Gets the current state of the lab for the user + * + * @param { completionStatus } Callback that will return the current lab state + */ + getState(callback: Core.ILabCallback); + /** + * Sets the state of the lab for the user + * + * @param { state } The lab state + * @param { callback } Callback that will be invoked when the state has been set + */ + setState(state: any, callback: Core.ILabCallback); + /** + * Takes an attempt action + * + * @param { type } The type of action + * @param { options } The options provided with the action + * @param { callback } Callback which returns the final executed action + */ + takeAction(type: string, options: Core.IActionOptions, callback: Core.ILabCallback); + /** + * Takes an action that has already been completed + * + * @param { type } The type of action + * @param { options } The options provided with the action + * @param { result } The result of the action + * @param { callback } Callback which returns the final executed action + */ + takeAction(type: string, options: Core.IActionOptions, result: Core.IActionResult, callback: Core.ILabCallback); + /** + * Retrieves the actions for a given attempt + * + * @param { type } The type of get action + * @param { options } The options provided with the get action + * @param { callback } Callback which returns the list of completed actions + */ + getActions(type: string, options: Core.IGetActionOptions, callback: Core.ILabCallback); + } +} +declare module Labs.Core { + /** + * Static class representing the permissions allowed for the given user of the lab + */ + class Permissions { + /** + * Ability to edit the lab + */ + static Edit: string; + /** + * Ability to take the lab + */ + static Take: string; + } +} + + +declare module Labs.Core.Actions { + /** + * Closes the component and indicates there will be no future actions against it. + */ + var CloseComponentAction: string; + /** + * Closes a component and indicates there will be no more actions against it. + */ + interface ICloseComponentOptions extends Core.IActionOptions { + /** + * The component to close. + */ + componentId: string; + } +} +declare module Labs.Core.Actions { + /** + * Action to create a new attempt + */ + var CreateAttemptAction: string; + /** + * Creates a new attempt for the given component. + */ + interface ICreateAttemptOptions extends Core.IActionOptions { + /** + * The component the attempt is associated with + */ + componentId: string; + } +} +declare module Labs.Core.Actions { + /** + * The result of creating an attempt for the given component. + */ + interface ICreateAttemptResult extends Core.IActionResult { + /** + * The ID of the created attempt + */ + attemptId: string; + } +} +declare module Labs.Core.Actions { + /** + * Action to create a new component + */ + var CreateComponentAction: string; + /** + * Creates a new component + */ + interface ICreateComponentOptions extends Core.IActionOptions { + /** + * The component invoking the create component action. + */ + componentId: string; + /** + * The component to create + */ + component: Core.IComponent; + /** + * An (optional) field used to correlate this component across all instances of a lab. + * Allows the hosting system to identify different attempts at the same component. + */ + correlationId?: string; + } +} +declare module Labs.Core.Actions { + /** + * The result of creating a new component. + */ + interface ICreateComponentResult extends Core.IActionResult { + /** + * The created component instance + */ + componentInstance: Core.IComponentInstance; + } +} +declare module Labs.Core.Actions { + /** + * The result of a get value action + */ + interface IGetValueResult extends Core.IActionResult { + /** + * The retrieved value + */ + value: any; + } +} +declare module Labs.Core.Actions { + /** + * The result of submitting an answer for an attempt + */ + interface ISubmitAnswerResult extends Core.IActionResult { + /** + * An ID associated with the submission. Will be filled in by the server. + */ + submissionId: string; + /** + * Whether the attempt is complete due to this submission + */ + complete: boolean; + /** + * Scoring information associated with the submission + */ + score: any; + } +} +declare module Labs.Core.Actions { + /** + * Attempt timeout action + */ + var AttemptTimeoutAction: string; + /** + * Options for the attempt timeout action + */ + interface IAttemptTimeoutOptions extends Core.IActionOptions { + /** + * The ID of the attempt that timed out + */ + attemptId: string; + } +} +declare module Labs.Core.Actions { + /** + * Action to retrieve a value associated with an attempt. + */ + var GetValueAction: string; + interface IGetValueOptions extends Core.IActionOptions { + /** + * The component the get value is associated with + */ + componentId: string; + /** + * The attempt to get the value for + */ + attemptId: string; + /** + * The ID of the value to receive + */ + valueId: string; + } +} +declare module Labs.Core.Actions { + /** + * Resume attempt action. Used to indicate the user is resuming work on a given attempt. + */ + var ResumeAttemptAction: string; + /** + * Options associated with a resume attempt + */ + interface IResumeAttemptOptions extends Core.IActionOptions { + /** + * The component the attempt is associated with + */ + componentId: string; + /** + * The attempt that is being resumed + */ + attemptId: string; + } +} +declare module Labs.Core.Actions { + /** + * Action to submit an answer for a given attempt + */ + var SubmitAnswerAction: string; + /** + * Options for the submit answer action + */ + interface ISubmitAnswerOptions extends Core.IActionOptions { + /** + * The component the submission is associated with + */ + componentId: string; + /** + * The attempt the submission is associated with + */ + attemptId: string; + /** + * The answer being submitted + */ + answer: any; + } +} + + +declare module Labs.Core.GetActions { + /** + * Gets actions associated with a given component. + */ + var GetComponentActions: string; + /** + * Options associated with a get component actions + */ + interface IGetComponentActionsOptions extends Core.IGetActionOptions { + /** + * The component being searched for + */ + componentId: string; + /** + * The type of action being searched for + */ + action: string; + } +} +declare module Labs.Core.GetActions { + /** + * Get attempt get action. Retrieves all actions associated with a given attempt. + */ + var GetAttempt: string; + /** + * Options associated with a get attempt get action. + */ + interface IGetAttemptOptions extends Core.IGetActionOptions { + /** + * The attempt ID to retrieve all the actions for + */ + attemptId: string; + } +} + + + + +declare module Labs.Core { + /** + * Interface for EventManager callbacks + */ + interface IEventCallback { + (data: any): void; + } +} +declare module Labs { + var TimelineNextMessageType: string; + interface ITimelineNextMessage extends Labs.Core.IMessage { + status: Labs.Core.ICompletionStatus; + } +} +declare module Labs { + /** + * Base class for components instances + */ + class ComponentInstanceBase { + /** + * The ID of the component + */ + public _id: string; + /** + * The LabsInternal object for use by the component instance + */ + public _labs: Labs.LabsInternal; + constructor(); + /** + * Attaches a LabsInternal to this component instance + * + * @param { id } The ID of the component + * @param { labs } The LabsInternal object for use by the instance + */ + public attach(id: string, labs: Labs.LabsInternal): void; + } +} +declare module Labs { + /** + * Class representing a component instance. An instance is an instantiation of a component for a user. It contains + * a translated view of the component for a particular run of the lab. + */ + class ComponentInstance extends Labs.ComponentInstanceBase { + /** + * Constructs a new ComponentInstance. + */ + constructor(); + /** + * Begins a new attempt at the component + * + * @param { callback } Callback fired when the attempt has been created + */ + public createAttempt(callback: Labs.Core.ILabCallback): void; + /** + * Retrieves all attempts associated with the given component + * + * @param { callback } Callback fired once the attempts have been retrieved + */ + public getAttempts(callback: Labs.Core.ILabCallback): void; + /** + * Retrieves the default create attempt options. Can be overriden by derived classes. + */ + public getCreateAttemptOptions(): Labs.Core.Actions.ICreateAttemptOptions; + /** + * method to built an attempt from the given action. Should be implemented by derived classes. + * + * @param { createAttemptResult } The create attempt action for the attempt + */ + public buildAttempt(createAttemptResult: Labs.Core.IAction): T; + } +} +declare module Labs { + /** + * Enumeration of the connection states + */ + enum ConnectionState { + /** + * Disconnected + */ + Disconnected, + /** + * In the process of connecting + */ + Connecting, + /** + * Connected + */ + Connected, + } +} +declare module Labs { + /** + * Helper class to manage a set of event handlers + */ + class EventManager { + private _handlers; + private getHandler(event); + /** + * Adds a new event handler for the given event + * + * @param { event } The event to add a handler for + * @param { handler } The event handler to add + */ + public add(event: string, handler: Labs.Core.IEventCallback): void; + /** + * Removes an event handler for the given event + * + * @param { event } The event to remove a handler for + * @param { handler } The event handler to remove + */ + public remove(event: string, handler: Labs.Core.IEventCallback): void; + /** + * Fires the given event + * + * @param { event } The event to fire + * @param { data } Data associated with the event + */ + public fire(event: string, data: any): void; + } +} +declare module Labs { + /** + * The LabEditor allows for the editing of the given lab. This includes getting and setting + * the entire configuration associated with the lab. + */ + class LabEditor { + private _labsInternal; + private _doneCallback; + /** + * Constructs a new LabEditor + * + * @param { labsInternal } LabsInternal to use with the editor + * @param { doneCallback } Callback to invoke when the editor is finished + */ + constructor(labsInternal: Labs.LabsInternal, doneCallback: Function); + /** + * Creates a new lab. This prepares the lab storage and saves the host version + * + * @param { labsInternal } LabsInternal to use with the editor + * @param { doneCallback } Callback to invoke when the editor is finished + * @param { callback } Callback fired once the LabEditor has been created + */ + static Create(labsInternal: Labs.LabsInternal, doneCallback: Function, callback: Labs.Core.ILabCallback): void; + /** + * Gets the current lab configuration + * + * @param { callback } Callback fired once the configuration has been retrieved + */ + public getConfiguration(callback: Labs.Core.ILabCallback): void; + /** + * Sets a new lab configuration + * + * @param { configuration } The configuration to set + * @param { callback } Callback fired once the configuration has been set + */ + public setConfiguration(configuration: Labs.Core.IConfiguration, callback: Labs.Core.ILabCallback): void; + /** + * Indicates that the user is done editing the lab. + * + * @param { callback } Callback fired once the lab editor has finished + */ + public done(callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs { + /** + * A LabInstance is an instance of the configured lab for the current user. It is used to + * record and retrieve per user lab data. + */ + class LabInstance { + private _labsInternal; + private _doneCallback; + public data: any; + /** + * The components that make up the lab instance + */ + public components: Labs.ComponentInstanceBase[]; + /** + * Constructs a new LabInstance + * + * @param { labsInternal } The LabsInternal to use with the instance + * @param { components } The components of the lab instance + * @param { doneCallback } Callback to invoke once the user is done taking the instance + * @param { data } Custom data attached to the lab + */ + constructor(labsInternal: Labs.LabsInternal, components: Labs.ComponentInstanceBase[], doneCallback: Function, data: any); + /** + * Creates a new LabInstance + * + * @param { labsInternal } The LabsInternal to use with the instance + * @param { doneCallback } Callback to invoke once the user is done taking the instance + * @param { callback } Callback that fires once the LabInstance has been created + */ + static Create(labsInternal: Labs.LabsInternal, doneCallback: Function, callback: Labs.Core.ILabCallback): void; + /** + * Gets the current state of the lab for the user + * + * @param { callback } Callback that fires with the lab state + */ + public getState(callback: Labs.Core.ILabCallback): void; + /** + * Sets the state of the lab for the user + * + * @param { state } The state to set + * @param { callback } Callback that fires once the state is set + */ + public setState(state: any, callback: Labs.Core.ILabCallback): void; + /** + * Indicates that the user is done taking the lab. + * + * @param { callback } Callback fired once the lab instance has finished + */ + public done(callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs { + /** + * Method to use to construct a default ILabHost + */ + var DefaultHostBuilder: () => Core.ILabHost; + /** + * Initializes a connection with the host. + * + * @param { labHost } The (optional) ILabHost to use. If not specified will be constructed with the DefaultHostBuilder + * @param { callback } Callback to fire once the connection has been established + */ + function connect(callback: Core.ILabCallback); + function connect(labHost: Core.ILabHost, callback: Core.ILabCallback); + /** + * Returns whether or not the labs are connected to the host. + */ + function isConnected(): boolean; + /** + * Retrieves the information associated with a connection + */ + function getConnectionInfo(): Core.IConnectionResponse; + /** + * Disconnects from the host. + * + * @param { completionStatus } The final result of the lab interaction + */ + function disconnect(): void; + /** + * Opens the lab for editing. When in edit mode the configuration can be specified. A lab cannot be edited while it + * is being taken. + * + * @param { callback } Callback fired once the LabEditor is created + */ + function editLab(callback: Core.ILabCallback): void; + /** + * Takes the given lab. This allows results to be sent for the lab. A lab cannot be taken while it is being edited. + * + * @param { callback } Callback fired once the LabInstance is created + */ + function takeLab(callback: Core.ILabCallback): void; + /** + * Adds a new event handler for the given event + * + * @param { event } The event to add a handler for + * @param { handler } The event handler to add + */ + function on(event: string, handler: Core.IEventCallback): void; + /** + * Removes an event handler for the given event + * + * @param { event } The event to remove a handler for + * @param { handler } The event handler to remove + */ + function off(event: string, handler: Core.IEventCallback): void; + /** + * Retrieves the Timeline object that can be used to control the host's player control. + */ + function getTimeline(): Timeline; + /** + * Registers a function to deserialize the given type. Should be used by component authors only. + * + * @param { type } The type to deserialize + * @param { deserialize } The deserialization function + */ + function registerDeserializer(type: string, deserialize: (json: Core.ILabObject) => any): void; + /** + * Deserializes the given json object into an object. Should be used by component authors only. + * + * @param { json } The ILabObject to deserialize + */ + function deserialize(json: Core.ILabObject): any; +} +declare module Labs { + /** + * Class used to interface with the underlying ILabsHost interface. + */ + class LabsInternal { + /** + * Current state of the LabsInternal + */ + private _state; + /** + * The driver to send our commands to + */ + private _labHost; + /** + * Helper class to manage events in the system + */ + private _eventManager; + /** + * The cached configuration and state for the lab + */ + private _configuration; + /** + * The version of the host this LabsInternal is making use of + */ + private _hostVersion; + /** + * Start out queueing pending messages until we are notified to invoke them + */ + private _queuePendingMessages; + /** + * Pending messages to invoke from the EventManager + */ + private _pendingMessages; + /** + * Constructs a new LabsInternal + * + * @param { labHost } The ILabHost to make use of + */ + constructor(labHost: Labs.Core.ILabHost); + /** + * Connect to the host + * + * @param { callback } Callback that will return the IConnectionResponse when connected + */ + public connect(callback: Labs.Core.ILabCallback): void; + /** + * Fires all pending messages + */ + public firePendingMessages(): void; + /** + * Creates a new lab + * + * @param { callback } Callback fired once the create operation completes + */ + public create(callback: Labs.Core.ILabCallback): void; + /** + * Terminates the LabsInternal class and halts the connection. + */ + public dispose(): void; + /** + * Adds an event handler for the given event + * + * @param { event } The event to listen for + * @param { handler } Handler fired for the given event + */ + public on(event: string, handler: Labs.Core.IEventCallback): void; + /** + * Sends a message to the host + * + * @param { type } The type of message being sent + * @param { options } The options for that message + * @param { callback } Callback invoked once the message has been received + */ + public sendMessage(type: string, options: Labs.Core.IMessage, callback: Labs.Core.ILabCallback): void; + /** + * Removes an event handler for the given event + * + * @param { event } The event whose handler should be removed + * @param { handler } Handler to remove + */ + public off(event: string, handler: Labs.Core.IEventCallback): void; + /** + * Gets the current state of the lab for the user + * + * @param { callback } Callback that fires when the state is retrieved + */ + public getState(callback: Labs.Core.ILabCallback): void; + /** + * Sets the state of the lab for the user + * + * @param { state } The state to set + * @param { callback } Callback fired once the state has been set + */ + public setState(state: any, callback: Labs.Core.ILabCallback): void; + /** + * Gets the current lab configuration + * + * @param { callback } Callback that fires when the configuration is retrieved + */ + public getConfiguration(callback: Labs.Core.ILabCallback): void; + /** + * Sets a new lab configuration + * + * @param { configuration } The lab configuration to set + * @param { callback } Callback that fires once the configuration has been set + */ + public setConfiguration(configuration: Labs.Core.IConfiguration, callback: Labs.Core.ILabCallback): void; + /** + * Retrieves the configuration instance for the lab. + * + * @param { callback } Callback that fires when the configuration instance has been retrieved + */ + public getConfigurationInstance(callback: Labs.Core.ILabCallback): void; + /** + * Takes an action + * + * @param { type } The type of action to take + * @param { options } The options associated with the action + * @param { result } The result of the action + * @param { callback } Callback that fires once the action has completed + */ + public takeAction(type: string, options: Labs.Core.IActionOptions, callback: Labs.Core.ILabCallback); + public takeAction(type: string, options: Labs.Core.IActionOptions, result: Labs.Core.IActionResult, callback: Labs.Core.ILabCallback); + /** + * Retrieves actions + * + * @param { type } The type of get to perform + * @param { options } The options associated with the get + * @param { callback } Callback that fires with the completed actions + */ + public getActions(type: string, options: Labs.Core.IGetActionOptions, callback: Labs.Core.ILabCallback): void; + /** + * Checks whether or not the LabsInternal is initialized + */ + private checkIsInitialized(); + } +} +declare module Labs { + /** + * Provides access to the labs.js timeline + */ + class Timeline { + private _labsInternal; + constructor(labsInternal: Labs.LabsInternal); + /** + * Used to indicate that the timeline should advance to the next slide. + */ + public next(completionStatus: Labs.Core.ICompletionStatus, callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs { + /** + * A ValueHolder is responsible for holding a value that when requested is tracked by labs.js. + * This value may be stored locally or stored on the server. + */ + class ValueHolder { + /** + * The component the value is associated with + */ + private _componentId; + /** + * Attempt the value is associated with + */ + private _attemptId; + /** + * Underlying labs device + */ + private _labs; + /** + * Whether or not the value is a hint + */ + public isHint: boolean; + /** + * Whether or not the value has been requested. + */ + public hasBeenRequested: boolean; + /** + * Whether or not the value holder currently has the value. + */ + public hasValue: boolean; + /** + * The value held by the holder. + */ + public value: T; + /** + * The ID for the value + */ + public id: string; + /** + * Constructs a new ValueHolder + * + * @param { componentId } The component the value is associated with + * @param { attemptId } The attempt the value is associated with + * @param { id } The id of the value + * @param { labs } The labs device that can be used to request the value + * @param { isHint } Whether or not the value is a hint + * @param { hasBeenRequested } Whether or not the value has already been requested + * @param { hasValue } Whether or not the value is available + * @param { value } If hasValue is true this is the value, otherwise is optional + */ + constructor(componentId: string, attemptId: string, id: string, labs: Labs.LabsInternal, isHint: boolean, hasBeenRequested: boolean, hasValue: boolean, value?: T); + /** + * Retrieves the given value + * + * @param { callback } Callback that returns the given value + */ + public getValue(callback: Labs.Core.ILabCallback): void; + /** + * Internal method used to actually provide a value to the value holder + * + * @param { value } The value to set for the holder + */ + public provideValue(value: T): void; + } +} + + +declare module Labs.Components { + /** + * Base class for attempts + */ + class ComponentAttempt { + public _componentId: string; + public _id: string; + public _labs: Labs.LabsInternal; + public _resumed: boolean; + public _state: Labs.ProblemState; + public _values: { + [type: string]: Labs.ValueHolder[]; + }; + /** + * Constructs a new ComponentAttempt. + * + * @param { labs } The LabsInternal to use with the attempt + * @param { attemptId } The ID associated with the attempt + * @param { values } The values associated with the attempt + */ + constructor(labs: Labs.LabsInternal, componentId: string, attemptId: string, values: { + [type: string]: Labs.Core.IValueInstance[]; + }); + /** + * Verifies that the attempt has been resumed + */ + public verifyResumed(): void; + /** + * Returns whether or not the app has been resumed + */ + public isResumed(): boolean; + /** + * Used to indicate that the lab has resumed progress on the given attempt. Loads in existing data as part of this process. An attempt + * must be resumed before it can be used. + * + * @param { callback } Callback fired once the attempt is resumed + */ + public resume(callback: Labs.Core.ILabCallback): void; + /** + * Helper method to send the resume action to the host + */ + private sendResumeAction(callback); + /** + * Runs over the retrieved actions for the attempt and populates the state of the lab + */ + private resumeCore(actions); + /** + * Retrieves the state of the lab + */ + public getState(): Labs.ProblemState; + public processAction(action: Labs.Core.IAction): void; + /** + * Retrieves the cached values associated with the attempt + * + * @param { key } The key to lookup in the value map + */ + public getValues(key: string): Labs.ValueHolder[]; + /** + * Makes use of a value in the value array + */ + private useValue(completedSubmission); + } +} +declare module Labs.Components { + /** + * A class representing an attempt at an activity component + */ + class ActivityComponentAttempt extends Components.ComponentAttempt { + constructor(labs: Labs.LabsInternal, componentId: string, attemptId: string, values: { + [type: string]: Labs.Core.IValueInstance[]; + }); + /** + * Called to indicate that the activity has completed + * + * @param { callback } Callback invoked once the activity has completed + */ + public complete(callback: Labs.Core.ILabCallback): void; + /** + * Runs over the retrieved actions for the attempt and populates the state of the lab + */ + public processAction(action: Labs.Core.IAction): void; + } +} +declare module Labs.Components { + var ActivityComponentInstanceType: string; + class ActivityComponentInstance extends Labs.ComponentInstance { + /** + * The underlying IActivityComponentInstance this class represents + */ + public component: Components.IActivityComponentInstance; + /** + * Constructs a new ActivityComponentInstnace + * + * @param { component } The IActivityComponentInstance to create this class from + */ + constructor(component: Components.IActivityComponentInstance); + /** + * Builds a new ActivityComponentAttempt. Implements abstract method defined on the base class. + * + * @param { createAttemptResult } The result from a create attempt action + */ + public buildAttempt(createAttemptAction: Labs.Core.IAction): Components.ActivityComponentAttempt; + } +} +declare module Labs.Components { + /** + * Answer to a choice component problem + */ + class ChoiceComponentAnswer { + /** + * The answer value + */ + public answer: any; + /** + * Constructs a new ChoiceComponentAnswer + */ + constructor(answer: any); + } +} +declare module Labs.Components { + /** + * A class representing an attempt at a choice component + */ + class ChoiceComponentAttempt extends Components.ComponentAttempt { + private _submissions; + /** + * Constructs a new ChoiceComponentAttempt. + * + * @param { labs } The LabsInternal to use with the attempt + * @param { attemptId } The ID associated with the attempt + * @param { values } The values associated with the attempt + */ + constructor(labs: Labs.LabsInternal, componentId: string, attemptId: string, values: { + [type: string]: Labs.Core.IValueInstance[]; + }); + /** + * Used to mark that the lab has timed out + * + * @param { callback } Callback fired once the server has received the timeout message + */ + public timeout(callback: Labs.Core.ILabCallback): void; + /** + * Retrieves all of the submissions that have previously been submitted for the given attempt + */ + public getSubmissions(): Components.ChoiceComponentSubmission[]; + /** + * Submits a new answer that was graded by the lab and will not use the host to compute a grade. + * + * @param { answer } The answer for the attempt + * @param { result } The result of the submission + * @param { callback } Callback fired once the submission has been received + */ + public submit(answer: Components.ChoiceComponentAnswer, result: Components.ChoiceComponentResult, callback: Labs.Core.ILabCallback): void; + public processAction(action: Labs.Core.IAction): void; + /** + * Helper method used to handle a returned submission from labs core + */ + private storeSubmission(completedSubmission); + } +} +declare module Labs.Components { + /** + * The name of the component instance. A choice component is a component that has multiple choice options and supports zero + * or more responses. Optionally there is a correct list of choices. + */ + var ChoiceComponentInstanceType: string; + /** + * Class representing a choice component instance + */ + class ChoiceComponentInstance extends Labs.ComponentInstance { + /** + * The underlying IChoiceComponentInstance this class represents + */ + public component: Components.IChoiceComponentInstance; + /** + * Constructs a new ChoiceComponentInstance + * + * @param { component } The IChoiceComponentInstance to create this class from + */ + constructor(component: Components.IChoiceComponentInstance); + /** + * Builds a new ChoiceComponentAttempt. Implements abstract method defined on the base class. + * + * @param { createAttemptResult } The result from a create attempt action + */ + public buildAttempt(createAttemptAction: Labs.Core.IAction): Components.ChoiceComponentAttempt; + } +} +declare module Labs.Components { + /** + * The name of the component instance. A dynamic component is a component that allows for new components to be inserted within it. + */ + var DynamicComponentInstanceType: string; + /** + * Class representing a dynamic component. A dynamic component is used to create, at runtime, new components. + */ + class DynamicComponentInstance extends Labs.ComponentInstanceBase { + public component: Components.IDynamicComponentInstance; + /** + * Constructs a new dynamic component instance from the provided definition + */ + constructor(component: Components.IDynamicComponentInstance); + /** + * Retrieves all the components created by this dynamic component. + */ + public getComponents(callback: Labs.Core.ILabCallback): void; + /** + * Creates a new component. + */ + public createComponent(component: Labs.Core.IComponent, callback: Labs.Core.ILabCallback): void; + private createComponentInstance(action); + /** + * Used to indicate that there will be no more submissions associated with this component + */ + public close(callback: Labs.Core.ILabCallback): void; + /** + * Returns whether or not the dynamic component is closed + */ + public isClosed(callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs.Components { + /** + * Type string for an ActivityComponent + */ + var ActivityComponentType: string; + /** + * An activity component is simply an activity for the taker to experience. Examples are viewing a web page + * or watching a video. + */ + interface IActivityComponent extends Labs.Core.IComponent { + /** + * Whether or not the input component is secure. This is not yet implemented. + */ + secure: boolean; + } +} +declare module Labs.Components { + interface IActivityComponentInstance extends Labs.Core.IComponentInstance { + } +} +declare module Labs.Components { + /** + * A choice for a problem + */ + interface IChoice { + /** + * Unique id to represent the choice + */ + id: string; + /** + * Display string to use to represent the value + * I think I should put this into the value type - have default ones show up - and then have custom values within + */ + name: string; + /** + * The value of the choice + */ + value: any; + } +} +declare module Labs.Components { + /** + * Type string to use with this type of component + */ + var ChoiceComponentType: string; + /** + * A choice problem is a problem type where the user is presented with a list of choices and then needs to select + * an answer from them. + */ + interface IChoiceComponent extends Labs.Core.IComponent { + /** + * The list of choices associated with the problem + */ + choices: Components.IChoice[]; + /** + * A time limit for the problem + */ + timeLimit: number; + /** + * The maximum number of attempts allowed for the problem + */ + maxAttempts: number; + /** + * The max score for the problem + */ + maxScore: number; + /** + * Whether or not this problem has an answer + */ + hasAnswer: boolean; + /** + * The answer. Either an array if multiple answers are supported or a single ID if only one answer is supported. + */ + answer: any; + /** + * Whether or not the quiz is secure - meaning that secure fields are held from the user. + * This is not yet implemented. + */ + secure: boolean; + } +} +declare module Labs.Components { + /** + * An instance of a choice component + */ + interface IChoiceComponentInstance extends Labs.Core.IComponentInstance { + /** + * The list of choices associated with the problem + */ + choices: Components.IChoice[]; + /** + * A time limit for the problem + */ + timeLimit: number; + /** + * The maximum number of attempts allowed for the problem + */ + maxAttempts: number; + /** + * The max score for the problem + */ + maxScore: number; + /** + * Whether or not this problem has an answer + */ + hasAnswer: boolean; + /** + * The answer. Either an array if multiple answers are supported or a single ID if only one answe is supported. + */ + answer: any; + /** + * Whether or not the quiz is secure - meaning that secure fields are held from the user + */ + secure: boolean; + } +} +declare module Labs.Components { + var Infinite: number; + /** + * Type string for a dynamic component + */ + var DynamicComponentType: string; + /** + * A dynamic component represents one that can generate other components at runtime. + * This can be used for branching questions, dynamically generated ones, etc... + */ + interface IDynamicComponent extends Labs.Core.IComponent { + /** + * An array containing the types of components this dynamic component may generate + */ + generatedComponentTypes: string[]; + /** + * The maximum number of components that will be generated by this DynamicComponent. Or Labs.Components.Infinite if + * there is no cap. + */ + maxComponents: number; + } +} +declare module Labs.Components { + /** + * An instance of a dynamic component. + */ + interface IDynamicComponentInstance extends Labs.Core.IComponentInstance { + /** + * An array containing the types of components this dynamic component may generate + */ + generatedComponentTypes: string[]; + /** + * The maximum number of components that will be generated by this DynamicComponent. Or Labs.Components.Infinite if + * there is no cap. + */ + maxComponents: number; + } +} +declare module Labs.Components { + /** + * A hint in a lab + */ + interface IHint extends Labs.Core.IValue { + /** + * Display value to use for the hint + */ + name: string; + } +} +declare module Labs.Components { + /** + * Type string to use with this type of component + */ + var InputComponentType: string; + /** + * An input problem is one in which the user enters an input which is checked against a correct value. + */ + interface IInputComponent extends Labs.Core.IComponent { + /** + * The max score for the input component + */ + maxScore: number; + /** + * Time limit associated with the input problem + */ + timeLimit: number; + /** + * Whether or not the component has an answer + */ + hasAnswer: boolean; + /** + * The answer to the component (if it exists) + */ + answer: any; + /** + * Whether or not the input component is secure. This is not yet implemented. + */ + secure: boolean; + } +} +declare module Labs.Components { + /** + * An input problem is one in which the user enters an input which is checked against a correct value. + */ + interface IInputComponentInstance extends Labs.Core.IComponentInstance { + /** + * The max score for the input component + */ + maxScore: number; + /** + * Time limit associated with the input problem + */ + timeLimit: number; + /** + * The answer to the component + */ + answer: any; + } +} +declare module Labs.Components { + /** + * Answer to an input component problem + */ + class InputComponentAnswer { + /** + * The answer value + */ + public answer: any; + /** + * Constructs a new InputComponentAnswer + */ + constructor(answer: any); + } +} +declare module Labs.Components { + /** + * A class representing an attempt at an input component + */ + class InputComponentAttempt extends Components.ComponentAttempt { + private _submissions; + constructor(labs: Labs.LabsInternal, componentId: string, attemptId: string, values: { + [type: string]: Labs.Core.IValueInstance[]; + }); + /** + * Runs over the retrieved actions for the attempt and populates the state of the lab + */ + public processAction(action: Labs.Core.IAction): void; + /** + * Retrieves all of the submissions that have previously been submitted for the given attempt + */ + public getSubmissions(): Components.InputComponentSubmission[]; + /** + * Submits a new answer that was graded by the lab and will not use the host to compute a grade. + * + * @param { answer } The answer for the attempt + * @param { result } The result of the submission + * @param { callback } Callback fired once the submission has been received + */ + public submit(answer: Components.InputComponentAnswer, result: Components.InputComponentResult, callback: Labs.Core.ILabCallback): void; + /** + * Helper method used to handle a returned submission from labs core + */ + private storeSubmission(completedSubmission); + } +} +declare module Labs.Components { + /** + * The name of the component instance. An input component is a component that allows free form + * input from a user. + */ + var InputComponentInstanceType: string; + /** + * Class representing an input component instance + */ + class InputComponentInstance extends Labs.ComponentInstance { + /** + * The underlying IInputComponentInstance this class represents + */ + public component: Components.IInputComponentInstance; + /** + * Constructs a new InputComponentInstance + * + * @param { component } The IInputComponentInstance to create this class from + */ + constructor(component: Components.IInputComponentInstance); + /** + * Builds a new InputComponentAttempt. Implements abstract method defined on the base class. + * + * @param { createAttemptResult } The result from a create attempt action + */ + public buildAttempt(createAttemptAction: Labs.Core.IAction): Components.InputComponentAttempt; + } +} +declare module Labs.Components { + /** + * The result of an input component submission + */ + class InputComponentResult { + /** + * The score associated with the submission + */ + public score: any; + /** + * Whether or not the result resulted in the completion of the attempt + */ + public complete: boolean; + /** + * Constructs a new InputComponentResult + * + * @param { score } The score of the result + * @param { complete } Whether or not the result completed the attempt + */ + constructor(score: any, complete: boolean); + } +} +declare module Labs.Components { + /** + * Class that represents an input component submission + */ + class InputComponentSubmission { + /** + * The answer associated with the submission + */ + public answer: Components.InputComponentAnswer; + /** + * The result of the submission + */ + public result: Components.InputComponentResult; + /** + * The time at which the submission was received + */ + public time: number; + /** + * Constructs a new InputComponentSubmission + * + * @param { answer } The answer associated with the submission + * @param { result } The result of the submission + * @param { time } The time at which the submission was received + */ + constructor(answer: Components.InputComponentAnswer, result: Components.InputComponentResult, time: number); + } +} +declare module Labs { + /** + * State values for a lab + */ + enum ProblemState { + /** + * The problem is in progress + */ + InProgress, + /** + * The problem has timed out + */ + Timeout, + /** + * The problem has completed + */ + Completed, + } +} +declare module Labs.Components { + /** + * The result of a choice component submission + */ + class ChoiceComponentResult { + /** + * The score associated with the submission + */ + public score: any; + /** + * Whether or not the result resulted in the completion of the attempt + */ + public complete: boolean; + /** + * Constructs a new ChoiceComponentResult + * + * @param { score } The score of the result + * @param { complete } Whether or not the result completed the attempt + */ + constructor(score: any, complete: boolean); + } +} +declare module Labs.Components { + /** + * Class that represents a choice component submission + */ + class ChoiceComponentSubmission { + /** + * The answer associated with the submission + */ + public answer: Components.ChoiceComponentAnswer; + /** + * The result of the submission + */ + public result: Components.ChoiceComponentResult; + /** + * The time at which the submission was received + */ + public time: number; + /** + * Constructs a new ChoiceComponentSubmission + * + * @param { answer } The answer associated with the submission + * @param { result } The result of the submission + * @param { time } The time at which the submission was received + */ + constructor(answer: Components.ChoiceComponentAnswer, result: Components.ChoiceComponentResult, time: number); + } +} + + +declare module Labs { + /** + * General command used to pass messages between the client and host + */ + class Command { + public type: string; + public commandData: any; + /** + * Constructs a new command + * + * @param { type } The type of command + * @param { commandData } Optional data associated with the command + */ + constructor(type: string, commandData?: any); + } +} +/** +* Strings representing supported command types +*/ +declare module Labs.CommandType { + var Connect: string; + var Disconnect: string; + var Create: string; + var GetConfigurationInstance: string; + var TakeAction: string; + var GetCompletedActions: string; + var ModeChanged: string; + var GetConfiguration: string; + var SetConfiguration: string; + var GetState: string; + var SetState: string; + var SendMessage: string; +} +declare module Labs.Core { + /** + * Static class containing the different event types. + */ + class EventTypes { + /** + * Mode changed event type. Fired whenever the lab mode is changed. + */ + static ModeChanged: string; + /** + * Event invoked when the app becomes active. + */ + static Activate: string; + /** + * Event invoked when the app is deactivated + */ + static Deactivate: string; + } +} +declare module Labs { + /** + * Command data associated with a GetActions command + */ + interface GetActionsCommandData { + /** + * The type of get + */ + type: string; + /** + * Options for the get command + */ + options: Labs.Core.IGetActionOptions; + } +} +declare module Labs { + /** + * Type of message being sent over the wire + */ + enum MessageType { + Message, + Completion, + Failure, + } + /** + * The message being sent + */ + class Message { + public id: number; + public labId: string; + public type: MessageType; + public payload: any; + constructor(id: number, labId: string, type: MessageType, payload: any); + } + /** + * Interface for defining event handlers + */ + interface IMessageHandler { + (origin: Window, data: any, callback: Labs.Core.ILabCallback): void; + } + class MessageProcessor { + public isStarted: boolean; + public eventListener: EventListener; + public nextMessageId: number; + private messageMap; + public targetOrigin: string; + public messageHandler: IMessageHandler; + private _labId; + constructor(labId: string, targetOrigin: string, messageHandler: IMessageHandler); + private throwIfNotStarted(); + private getNextMessageId(); + private parseOrigin(href); + private listener(event); + private postMessage(targetWindow, message); + public start(): void; + public stop(): void; + public sendMessage(targetWindow: Window, data: any, callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs.Core { + /** + * Data associated with a mode changed event + */ + interface ModeChangedEventData { + /** + * The mode being set + */ + mode: string; + } +} +declare module Labs { + /** + * Data associated with a take action command + */ + interface SendMessageCommandData { + /** + * The type of message + */ + type: string; + /** + * Options associated with the message + */ + options: Labs.Core.IMessage; + } +} +declare module Labs { + /** + * Data associated with a take action command + */ + interface TakeActionCommandData { + /** + * The type of action + */ + type: string; + /** + * Options associated with the action + */ + options: Labs.Core.IActionOptions; + /** + * The result of the action + */ + result: Labs.Core.IActionResult; + } +} + + + +declare module Labs { + interface IHostMessage { + type: string; + options: Labs.Core.IMessage; + response: Labs.Core.IMessageResponse; + } + class InMemoryLabHost implements Labs.Core.ILabHost { + private _version; + private _labState; + private _messages; + constructor(version: Labs.Core.IVersion); + public getSupportedVersions(): Labs.Core.ILabHostVersionInfo[]; + public connect(versions: Labs.Core.ILabHostVersionInfo[], callback: Labs.Core.ILabCallback): void; + public disconnect(callback: Labs.Core.ILabCallback): void; + public on(handler: (string: any, any: any) => void): void; + public sendMessage(type: string, options: Labs.Core.IMessage, callback: Labs.Core.ILabCallback): void; + public getMessages(): IHostMessage[]; + public create(options: Labs.Core.ILabCreationOptions, callback: Labs.Core.ILabCallback): void; + public getConfiguration(callback: Labs.Core.ILabCallback): void; + public setConfiguration(configuration: Labs.Core.IConfiguration, callback: Labs.Core.ILabCallback): void; + public getState(callback: Labs.Core.ILabCallback): void; + public setState(state: any, callback: Labs.Core.ILabCallback): void; + public getConfigurationInstance(callback: Labs.Core.ILabCallback): void; + public takeAction(type: string, options: Labs.Core.IActionOptions, callback: Labs.Core.ILabCallback); + public takeAction(type: string, options: Labs.Core.IActionOptions, result: Labs.Core.IActionResult, callback: Labs.Core.ILabCallback); + public getActions(type: string, options: Labs.Core.IGetActionOptions, callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs { + class InMemoryLabState { + private _configuration; + private _configurationInstance; + private _state; + private _actions; + private _nextId; + private _componentInstances; + constructor(); + public getConfiguration(): Labs.Core.IConfiguration; + public setConfiguration(configuration: Labs.Core.IConfiguration): void; + public getState(): any; + public setState(state: any): void; + public getConfigurationInstance(): Labs.Core.IConfigurationInstance; + private getConfigurationInstanceFromConfiguration(configuration); + private getAndStoreComponentInstanceFromComponent(component); + public takeAction(type: string, options: Labs.Core.IActionOptions, result: any): Labs.Core.IAction; + private takeActionCore(type, options, result); + private findConfigurationValue(componentId, attemptId, valueId); + public getAllActions(): Labs.Core.IAction[]; + public setActions(actions: Labs.Core.IAction[]): void; + public getActions(type: string, options: Labs.Core.IGetActionOptions): Labs.Core.IAction[]; + } +} +interface OfficeInterface { + initialize: any; + context: any; + AsyncResultStatus: any; + Index: any; + GoToType: any; +} +declare var Office: OfficeInterface; +declare module Labs { + interface IPromise { + then(callback: Function); + } + class Resolver { + private _callbacks; + private _isResolved; + private _resolvedValue; + public promise: IPromise; + constructor(); + public resolve(value?: any): void; + private fireCallbacks(); + } + interface ILabsSettings { + /** + * The lab configuration + */ + configuration?: Labs.Core.IConfiguration; + /** + * The version of the host used to create the lab + */ + hostVersion?: Labs.Core.IVersion; + /** + * Boolean that is set to true when the lab is published + */ + published?: boolean; + /** + * The published ID of the lab + */ + publishedAppId?: string; + } + class OfficeJSLabHost implements Labs.Core.ILabHost { + private _officeInitialized; + private _labHost; + private _version; + static SettingsKeyName: string; + constructor(); + public getSupportedVersions(): Labs.Core.ILabHostVersionInfo[]; + public connect(versions: Labs.Core.ILabHostVersionInfo[], callback: Labs.Core.ILabCallback): void; + public disconnect(callback: Labs.Core.ILabCallback): void; + public on(handler: (string: any, any: any) => void): void; + public sendMessage(type: string, options: Labs.Core.IMessage, callback: Labs.Core.ILabCallback): void; + public create(options: Labs.Core.ILabCreationOptions, callback: Labs.Core.ILabCallback): void; + public getConfiguration(callback: Labs.Core.ILabCallback): void; + public setConfiguration(configuration: Labs.Core.IConfiguration, callback: Labs.Core.ILabCallback): void; + public getConfigurationInstance(callback: Labs.Core.ILabCallback): void; + public getState(callback: Labs.Core.ILabCallback): void; + public setState(state: any, callback: Labs.Core.ILabCallback): void; + public takeAction(type: string, options: Labs.Core.IActionOptions, callback: Labs.Core.ILabCallback); + public takeAction(type: string, options: Labs.Core.IActionOptions, result: Labs.Core.IActionResult, callback: Labs.Core.ILabCallback); + public getActions(type: string, options: Labs.Core.IGetActionOptions, callback: Labs.Core.ILabCallback): void; + } +} +declare module Labs { + /** + * PostMessageLabHost - ILabHost that uses PostMessage for its communication mechanism + */ + class PostMessageLabHost implements Labs.Core.ILabHost { + private _handlers; + private _messageProcessor; + private _version; + private _targetWindow; + private _state; + private _deferredEvents; + constructor(labId: string, targetWindow: Window, targetOrigin: string); + private handleEvent(command, callback); + private invokeDeferredEvents(err); + private invokeEvent(err, command, callback); + public getSupportedVersions(): Labs.Core.ILabHostVersionInfo[]; + public connect(versions: Labs.Core.ILabHostVersionInfo[], callback: Labs.Core.ILabCallback): void; + public disconnect(callback: Labs.Core.ILabCallback): void; + public on(handler: (string: any, any: any) => void): void; + public sendMessage(type: string, options: Labs.Core.IMessage, callback: Labs.Core.ILabCallback): void; + public create(options: Labs.Core.ILabCreationOptions, callback: Labs.Core.ILabCallback): void; + public getConfiguration(callback: Labs.Core.ILabCallback): void; + public setConfiguration(configuration: Labs.Core.IConfiguration, callback: Labs.Core.ILabCallback): void; + public getConfigurationInstance(callback: Labs.Core.ILabCallback): void; + public getState(callback: Labs.Core.ILabCallback): void; + public setState(state: any, callback: Labs.Core.ILabCallback): void; + public takeAction(type: string, options: Labs.Core.IActionOptions, callback: Labs.Core.ILabCallback); + public takeAction(type: string, options: Labs.Core.IActionOptions, result: Labs.Core.IActionResult, callback: Labs.Core.ILabCallback); + public getActions(type: string, options: Labs.Core.IGetActionOptions, callback: Labs.Core.ILabCallback): void; + private sendCommand(command, callback); + } +} +declare module Labs { + class RichClientOfficeJSLabsHost implements Labs.Core.ILabHost { + private _handlers; + private _activeMode; + private _version; + private _labState; + private _createdHostVersion; + private _activeViewP; + constructor(configuration: Labs.Core.IConfiguration, createdHostVersion: Labs.Core.IVersion); + private getLabModeFromActiveView(view); + public getSupportedVersions(): Labs.Core.ILabHostVersionInfo[]; + public connect(versions: Labs.Core.ILabHostVersionInfo[], callback: Labs.Core.ILabCallback): void; + public disconnect(callback: Labs.Core.ILabCallback): void; + public on(handler: (string: any, any: any) => void): void; + public sendMessage(type: string, options: Labs.Core.IMessage, callback: Labs.Core.ILabCallback): void; + public create(options: Labs.Core.ILabCreationOptions, callback: Labs.Core.ILabCallback): void; + public getConfiguration(callback: Labs.Core.ILabCallback): void; + public setConfiguration(configuration: Labs.Core.IConfiguration, callback: Labs.Core.ILabCallback): void; + private updateStoredLabsState(callback); + public getConfigurationInstance(callback: Labs.Core.ILabCallback): void; + public getState(callback: Labs.Core.ILabCallback): void; + public setState(state: any, callback: Labs.Core.ILabCallback): void; + public takeAction(type: string, options: Labs.Core.IActionOptions, callback: Labs.Core.ILabCallback); + public takeAction(type: string, options: Labs.Core.IActionOptions, result: Labs.Core.IActionResult, callback: Labs.Core.ILabCallback); + public getActions(type: string, options: Labs.Core.IGetActionOptions, callback: Labs.Core.ILabCallback): void; + } +} diff --git a/site.css b/site.css new file mode 100644 index 0000000..46b0aa0 --- /dev/null +++ b/site.css @@ -0,0 +1,252 @@ +/* overload office */ +body { + font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif; + /* font-size: 14px; */ + /* line-height: 1.428571429;*/ + color: #333333; + background-color: #ffffff; +} + +html, body { + width: 100%; + height: 100%; + margin: 0px; + overflow: hidden; +} + +.office-app-icon { + width: 98px; + height: 98px; + border: 1px solid black; +} + +.office-app > .office-app-icon { + float: left !important; + margin-right: 25px; + vertical-align: top; +} + +.office-app > .app-details { + overflow: hidden; +} + +.office-app > .app-actions { + float: right !important; +} + +.row { + margin: 0px; +} + +/* Layout */ +div.active-template { + height: 100%; + width: 100%; +} + +#top { + background-color: rgb(42, 50, 106); + color: #FFFFFF; + margin-bottom: 0; + padding: 0 20px; + height: 147px; + position: absolute; + top: 0px; + left: 0px; + z-index: 1000; + width: 100%; +} + +#searchInputBox { + margin-top: 25px; +} + +#main-container { + margin: 0px; + font-size: 14px; + position: absolute; + top: 147px; + left: 200px; + right: 0px; + bottom: 0px; +} + +#domain-list-container { + position: absolute; + color: #FFFFFF; + background-color: #FF9933; + height: 100%; + z-index: 500; + width: 200px; + padding: 20px 15px; +} + +#categories-container { + padding: 20px 15px; + background-color: #FFFFFF; + height: 100%; + overflow: auto; +} + +.domain { + padding: 147px 0px; + margin-bottom: 10px; +} + +a.app-btn { + text-decoration: none; + outline: 0; + color: #FFFFFF; +} + +.domain.selected { + background-color: #793541; +} + +.categories { + color: #935D67; +} + +.category { + color: #99656E; + margin-bottom: 30px; +} + +.category-title { + margin-bottom: 8px; +} + +.content { + display: inline-block; + margin: 0px 5px 5px 0px; + max-width: 124px; + min-height: 84px; + max-height: 84px; +} + +.content-image { + width: 124px; + height: 88px; +} + +.content-title { + position: relative; + margin-top: -28px; + width: 124px; + height: 28px; + padding: 3px; + color: #FFFFFF; + white-space: nowrap; + overflow: hidden; + background-color: #9B9188; +} + +/** detail page */ +#content-detail { + height: 100%; +} + +#content-detail-wrapper { + height: 100%; + background-color: #17234E; + padding: 20px; + color: #FFFFFF; +} + +#detail-left { + height: 100%; +} + +#detail-right { + height: 100%; +} + +#detail-buttons { + position: absolute; + bottom: 5px; + left: 5px; +} + +/** preview page */ +.preview-frame { + width: 100%; + height: 100%; +} + +#detail-title { + font-size: 16px; + font-weight: bold; + margin-bottom: 20px; +} + +.btn-detail { + padding: 2px 12px 3px 12px; + border-width: 1px; + border-color: #FFFFFF; + border-style: solid; + border-radius: 0; +} + +.btn-detail a { + color: #FFFFFF; + text-decoration: none; +} + +/** view page */ +#view-frame { + width: 100%; + height: 100%; +} +#edit-pages { + height: 100%; +} + +#select-contents { + height: 100%; +} + +.window-size { + width: 100%; + height: 100%; + padding-top: 25px; + background: black; +} + +/* Banner images */ +#banner-title { + margin-top: 8px; +} + +#banner-title-logo { + width: 223px; + height: 106px; + display: block; +} + +#banner-title-terms { +} + +#banner-title-terms a { + margin-left: -1px; + color: gray; +} + +#banner-title-terms a:active{ + background-color: transparent; +} + +#banner-logo { + margin-top: 35px; + width: 150px; + height: 77px; + float: right; +} + +.terms-header { + position: absolute; + top: 0px; + height: 25px; + text-align: right; + padding-left: 10px; + color: white; +} \ No newline at end of file diff --git a/store.html b/store.html new file mode 100644 index 0000000..e7ebdff --- /dev/null +++ b/store.html @@ -0,0 +1,192 @@ + + + + + + + PhET Simulations + + + + + + + + + + +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/store.js b/store.js new file mode 100644 index 0000000..642d402 --- /dev/null +++ b/store.js @@ -0,0 +1,251 @@ +var MixAppBrowser; +(function (MixAppBrowser) { + /** + * Helper method to create a ILabCallback for the given jQuery deferred object + */ + function createCallback(deferred) { + return function (err, data) { + if (err) { + deferred.reject(err); + } else { + deferred.resolve(data); + } + }; + } + + var MixAppBrowserViewModel = (function () { + function MixAppBrowserViewModel(links, initialMode) { + var _this = this; + // The view the app is currently within + this._appView = ko.observable(); + // The view selected by the user + this._userView = ko.observable("edit"); + this._modeSwitchP = $.when(); + this._links = links; + + // Setup knockout observables + this.domains = ko.observableArray([]); + this.activeDomain = ko.observable(); + this.item = ko.observable(); + this.searchText = ko.observable(""); + + this.activeItemUrl = ko.computed(function () { + var item = _this.item(); + return item ? item.providerId : null; + }); + + this.view = ko.computed(function () { + var appView = _this._appView(); + var userView = _this._userView(); + + if (appView === "view" || (appView === "edit" && userView === "view")) { + return "viewTemplate"; + } else if (appView === "edit") { + return "editTemplate"; + } else { + return "loadingTemplate"; + } + }); + + // Events coming from the lab host + Labs.on(Labs.Core.EventTypes.ModeChanged, function (data) { + var modeChangedEventData = data; + _this.switchToMode(Labs.Core.LabMode[modeChangedEventData.mode]); + return $.when(); + }); + + Labs.on(Labs.Core.EventTypes.Activate, function (data) { + }); + + Labs.on(Labs.Core.EventTypes.Deactivate, function (data) { + }); + + // Set the initial mode + this.switchToMode(initialMode); + } + MixAppBrowserViewModel.prototype.switchToMode = function (mode) { + var _this = this; + // wait for any previous mode switch to complete before performing the new one + this._modeSwitchP = this._modeSwitchP.then(function () { + var switchedStateDeferred = $.Deferred(); + + if (_this._labInstance) { + _this._labInstance.done(createCallback(switchedStateDeferred)); + } else if (_this._labEditor) { + _this._labEditor.done(createCallback(switchedStateDeferred)); + } else { + switchedStateDeferred.resolve(); + } + + // and now switch the state + return switchedStateDeferred.promise().then(function () { + _this._labEditor = null; + _this._labInstance = null; + + if (mode === Labs.Core.LabMode.Edit) { + return _this.switchToEditMode(); + } else { + return _this.switchToViewMode(); + } + }); + }); + }; + + MixAppBrowserViewModel.prototype.switchToEditMode = function () { + var _this = this; + var editLabDeferred = $.Deferred(); + Labs.editLab(createCallback(editLabDeferred)); + + return editLabDeferred.promise().then(function (labEditor) { + _this._labEditor = labEditor; + _this._appView("edit"); + + var configurationDeferred = $.Deferred(); + _this._labEditor.getConfiguration(createCallback(configurationDeferred)); + return configurationDeferred.promise().then(function (configuration) { + if (configuration) { + var id = _this._links.getIdFromConfiguration(configuration); + + // This should just be a method to show + _this._links.get(id).done(function (item) { + _this._userView("view"); + _this.item(item); + }); + } else { + _this.loadDomain(); + } + }); + }); + }; + + MixAppBrowserViewModel.prototype.loadDomain = function () { + var _this = this; + if (this.domains().length > 0) { + return $.when(); + } + + return this._links.loadCategories(2).then(function (domains) { + _this.domains(domains); + _this.setActiveDomain(domains[0]); + }); + }; + + MixAppBrowserViewModel.prototype.setActiveDomain = function (domain) { + var _this = this; + var clonedDomain = $.extend(true, {}, domain); + clonedDomain.children.forEach(function (category) { + category.children = []; + }); + this.activeDomain(clonedDomain); + + $.each(clonedDomain.children, function (index, category) { + _this._links.loadCategory(category.providerId, _this.searchText()).then(function (list) { + category.children = list; + + // force a re-render of the page by updating the root binding + // TODO replace this with view models for sub items + _this.activeDomain(_this.activeDomain()); + }); + }); + }; + + MixAppBrowserViewModel.prototype.switchToViewMode = function () { + var _this = this; + var takeLabDeferred = $.Deferred(); + Labs.takeLab(createCallback(takeLabDeferred)); + return takeLabDeferred.promise().then(function (labInstance) { + _this._labInstance = labInstance; + _this.loadItem(labInstance); + }); + }; + + MixAppBrowserViewModel.prototype.loadItem = function (labInstance) { + var _this = this; + var activityComponent = this._labInstance.components[0]; + + this._links.get(activityComponent.component.data.id).done(function (item) { + var attemptsDeferred = $.Deferred(); + activityComponent.getAttempts(createCallback(attemptsDeferred)); + var attemptP = attemptsDeferred.promise().then(function (attempts) { + var currentAttemptDeferred = $.Deferred(); + if (attempts.length > 0) { + currentAttemptDeferred.resolve(attempts[attempts.length - 1]); + } else { + activityComponent.createAttempt(createCallback(currentAttemptDeferred)); + } + + return currentAttemptDeferred.then(function (currentAttempt) { + var resumeDeferred = $.Deferred(); + currentAttempt.resume(createCallback(resumeDeferred)); + return resumeDeferred.promise().then(function () { + return currentAttempt; + }); + }); + }); + + return attemptP.then(function (attempt) { + var completeDeferred = $.Deferred(); + if (attempt.getState() !== Labs.ProblemState.Completed) { + attempt.complete(createCallback(completeDeferred)); + } else { + completeDeferred.resolve(); + } + + _this._appView("view"); + _this.item(item); + + return completeDeferred.promise(); + }); + }); + }; + + // + // Action invoked when the user clicks on the insert button on the details page + // + MixAppBrowserViewModel.prototype.onInsertClick = function () { + var _this = this; + var configuration = this._links.buildConfiguration(this.item()); + if (this._labEditor) { + this._labEditor.setConfiguration(configuration, function (err, unused) { + _this._userView("view"); + }); + } + }; + + // + // Method invoked when the user clicks on a selection and wants to move to the details page + // + MixAppBrowserViewModel.prototype.moveToDetailPage = function (content) { + var _this = this; + this._links.get(content.id).then(function (item) { + _this.item(item); + }); + }; + + // + // Moves back to the select page + // + MixAppBrowserViewModel.prototype.moveToSelectPage = function () { + this.item(null); + }; + + // + // Callback inoked when a search occurs + // + MixAppBrowserViewModel.prototype.search = function () { + this.setActiveDomain(this.activeDomain()); + }; + return MixAppBrowserViewModel; + })(); + + function initialize(driver) { + $(document).ready(function () { + // Initialize Labs.JS + Labs.connect(function (err, connectionResponse) { + var viewModel = new MixAppBrowserViewModel(driver, connectionResponse.mode); + ko.applyBindings(viewModel); + }); + }); + } + MixAppBrowser.initialize = initialize; +})(MixAppBrowser || (MixAppBrowser = {})); diff --git a/store.ts b/store.ts new file mode 100644 index 0000000..2bc541f --- /dev/null +++ b/store.ts @@ -0,0 +1,283 @@ +module MixAppBrowser { + export interface AppDataDriver { + loadCategories(maxDepth: number): JQueryPromise; + + loadCategory(parentId: string, searchText: string): JQueryPromise; + + get(id: string): JQueryPromise; + + buildConfiguration(content: AppContent): Labs.Core.IConfiguration; + + getIdFromConfiguration(configuration: Labs.Core.IConfiguration) : string; + } + + // Top-level ndoes in a topic tree + export interface AppContent { + id: string; + type: string; + title: string; + providerId: string; + readableId: string; + youtubeId: string; + durationInSec: number; + thumbnailUrl: string; + contentUrl: string; + children: AppContent[]; + } + + /** + * Helper method to create a ILabCallback for the given jQuery deferred object + */ + function createCallback(deferred: JQueryDeferred): Labs.Core.ILabCallback { + return (err, data) => { + if (err) { + deferred.reject(err); + } + else { + deferred.resolve(data); + } + }; + } + + class MixAppBrowserViewModel { + view: KnockoutComputed; + + contentType: KnockoutObservable; + domains: KnockoutObservableArray; + activeDomain: KnockoutObservable; + item: KnockoutObservable; + searchText: KnockoutObservable; + activeItemUrl: KnockoutComputed; + + // The view the app is currently within + private _appView: KnockoutObservable = ko.observable(); + // The view selected by the user + private _userView: KnockoutObservable = ko.observable("edit"); + + private _labEditor: Labs.LabEditor; + private _labInstance: Labs.LabInstance; + private _links: AppDataDriver; + private _modeSwitchP: JQueryPromise = $.when(); + + constructor(links: AppDataDriver, initialMode: Labs.Core.LabMode) { + this._links = links; + + // Setup knockout observables + this.domains = ko.observableArray([]); + this.activeDomain = ko.observable(); + this.item = ko.observable(); + this.searchText = ko.observable(""); + + this.activeItemUrl = ko.computed(()=> { + var item = this.item(); + return item ? item.providerId : null; + }); + + this.view = ko.computed(()=> { + var appView = this._appView(); + var userView = this._userView(); + + if (appView === "view" || (appView === "edit" && userView === "view")) { + return "viewTemplate"; + } + else if (appView === "edit") { + return "editTemplate"; + } else { + return "loadingTemplate"; + } + }); + + // Events coming from the lab host + Labs.on(Labs.Core.EventTypes.ModeChanged, (data) => { + var modeChangedEventData = data; + this.switchToMode(Labs.Core.LabMode[modeChangedEventData.mode]); + return $.when(); + }); + + Labs.on(Labs.Core.EventTypes.Activate, (data) => { + }); + + Labs.on(Labs.Core.EventTypes.Deactivate, (data) => { + }); + + // Set the initial mode + this.switchToMode(initialMode); + } + + switchToMode(mode: Labs.Core.LabMode) { + // wait for any previous mode switch to complete before performing the new one + this._modeSwitchP = this._modeSwitchP.then(() => { + var switchedStateDeferred = $.Deferred(); + + // End any existing operations + if (this._labInstance) { + this._labInstance.done(createCallback(switchedStateDeferred)); + } + else if (this._labEditor) { + this._labEditor.done(createCallback(switchedStateDeferred)); + } else { + switchedStateDeferred.resolve(); + } + + // and now switch the state + return switchedStateDeferred.promise().then(() => { + this._labEditor = null; + this._labInstance = null; + + if (mode === Labs.Core.LabMode.Edit) { + return this.switchToEditMode(); + } else { + return this.switchToViewMode(); + } + }); + }); + } + + private switchToEditMode(): JQueryPromise { + var editLabDeferred = $.Deferred(); + Labs.editLab(createCallback(editLabDeferred)); + + return editLabDeferred.promise().then((labEditor) => { + this._labEditor = labEditor; + this._appView("edit"); + + var configurationDeferred = $.Deferred(); + this._labEditor.getConfiguration(createCallback(configurationDeferred)); + return configurationDeferred.promise().then((configuration) => { + if (configuration) { + var id = this._links.getIdFromConfiguration(configuration); + + // This should just be a method to show + this._links.get(id).done((item: AppContent) => { + this._userView("view"); + this.item(item); + }); + } else { + this.loadDomain(); + } + }); + }); + } + + private loadDomain(): JQueryPromise { + if (this.domains().length > 0) { + return $.when(); + } + + return this._links.loadCategories(2).then((domains) => { + this.domains(domains); + this.setActiveDomain(domains[0]); + }); + } + + private setActiveDomain(domain: AppContent) { + var clonedDomain = $.extend(true, {}, domain); + clonedDomain.children.forEach((category) => { category.children = [] }); + this.activeDomain(clonedDomain); + + $.each(clonedDomain.children, (index, category) => { + this._links.loadCategory( + category.providerId, + this.searchText()).then((list) => { + category.children = list; + // force a re-render of the page by updating the root binding + // TODO replace this with view models for sub items + this.activeDomain(this.activeDomain()); + }); + }); + } + + private switchToViewMode(): JQueryPromise { + var takeLabDeferred = $.Deferred(); + Labs.takeLab(createCallback(takeLabDeferred)); + return takeLabDeferred.promise().then((labInstance) => { + this._labInstance = labInstance; + this.loadItem(labInstance); + }); + } + + private loadItem(labInstance: Labs.LabInstance) { + var activityComponent = this._labInstance.components[0]; + + this._links.get(activityComponent.component.data.id).done((item) => { + var attemptsDeferred = $.Deferred(); + activityComponent.getAttempts(createCallback(attemptsDeferred)); + var attemptP = attemptsDeferred.promise().then((attempts) => { + var currentAttemptDeferred = $.Deferred(); + if (attempts.length > 0) { + currentAttemptDeferred.resolve(attempts[attempts.length - 1]); + } else { + activityComponent.createAttempt(createCallback(currentAttemptDeferred)); + } + + return currentAttemptDeferred.then((currentAttempt: Labs.Components.ActivityComponentAttempt) => { + var resumeDeferred = $.Deferred(); + currentAttempt.resume(createCallback(resumeDeferred)); + return resumeDeferred.promise().then(() => { + return currentAttempt; + }); + }); + }); + + return attemptP.then((attempt: Labs.Components.ActivityComponentAttempt) => { + var completeDeferred = $.Deferred(); + if (attempt.getState() !== Labs.ProblemState.Completed) { + attempt.complete(createCallback(completeDeferred)); + } else { + completeDeferred.resolve(); + } + + this._appView("view"); + this.item(item); + + return completeDeferred.promise(); + }); + }); + } + + // + // Action invoked when the user clicks on the insert button on the details page + // + onInsertClick() { + var configuration = this._links.buildConfiguration(this.item()); + if (this._labEditor) { + this._labEditor.setConfiguration(configuration, (err, unused) => { + this._userView("view"); + }); + } + } + + // + // Method invoked when the user clicks on a selection and wants to move to the details page + // + moveToDetailPage(content: AppContent) { + this._links.get(content.id).then((item: AppContent) => { + this.item(item); + }); + } + + // + // Moves back to the select page + // + moveToSelectPage() { + this.item(null); + } + + // + // Callback inoked when a search occurs + // + search() { + this.setActiveDomain(this.activeDomain()); + } + } + + export function initialize(driver: AppDataDriver) { + $(document).ready(() => { + // Initialize Labs.JS + Labs.connect((err, connectionResponse) => { + var viewModel = new MixAppBrowserViewModel(driver, connectionResponse.mode); + ko.applyBindings(viewModel); + }); + }); + } +}