, Armin Sander
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+// missing:
+// - Static methods that are defined in JQueryStatic.fn are not typed.
+// - Plugin and extension definitions are not typed.
+// - Some return types are not fully wokring
+
+///
+
+interface JQuery {
+ DataTable(param?: DataTables.Settings): DataTables.DataTable;
+}
+
+//TODO: Wrong, as jquery.d.ts has no interface for fn
+//interface JQueryStatic {
+// dataTable: DataTables.StaticFunctions;
+//}
+
+declare module DataTables {
+ export interface DataTable extends DataTableCore {
+ /**
+ * Get the data for the whole table.
+ */
+ data(): DataTable;
+
+ /**
+ * Order Methods / Object
+ */
+ order: OrderMethods;
+
+ //#region "Cell/Cells"
+
+ /**
+ * Select the cell found by a cell selector
+ *
+ * @param cellSelector Cell selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ cell(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods;
+
+ /**
+ * Select the cell found by a cell selector
+ *
+ * @param rowSelector Row selector.
+ * @param cellSelector Cell selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ cell(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods;
+
+ /**
+ * Select all cells
+ *
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ cells(modifier?: ObjectSelectorModifier): CellsMethods;
+
+ /**
+ * Select cells found by a cell selector
+ *
+ * @param cellSelector Cell selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ cells(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods;
+
+ /**
+ * Select cells found by both row and column selectors
+ *
+ * @param rowSelector Row selector.
+ * @param cellSelector Cell selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ cells(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods;
+ //#endregion "Cell/Cells"
+
+ //#region "Column/Columns"
+
+ /**
+ * Column Methods / Object
+ */
+ column: ColumnMethodsModel;
+
+ /**
+ * Columns Methods / Object
+ */
+ columns: ColumnsMethodsModel;
+
+ //#endregion "Column/Columns"
+
+ //#region "Row/Rows"
+
+ /**
+ * Row Methode / Object
+ */
+ row: RowMethodsModel
+
+ /**
+ * Rows Methods / Object
+ */
+ rows: RowsMethodsModel
+
+ //#endregion "Row/Rows"
+
+ //#region "Table/Tables"
+
+ /**
+ * Select a table based on a selector from the API's context
+ *
+ * @param tableSelector Table selector.
+ */
+ table(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TableMethods;
+
+ /**
+ * Select all tables
+ */
+ tables(): TablesMethods;
+
+ /**
+ * Select tables based on the given selector
+ *
+ * @param tableSelector Table selector.
+ */
+ tables(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TablesMethods;
+
+ //#endregion "Table/Tables"
+ }
+
+ export interface DataTables extends DataTableCore {
+ [index: number]: DataTable;
+ }
+
+ interface ObjectSelectorModifier {
+ /**
+ * The order modifier provides the ability to control which order the rows are processed in.
+ * Values: 'current', 'applied', 'index', 'original'
+ */
+ order?: string;
+
+ /**
+ * The search modifier provides the ability to govern which rows are used by the selector using the search options that are applied to the table.
+ * Values: 'none', 'applied', 'removed'
+ */
+ search?: string;
+
+ /**
+ * The page modifier allows you to control if the selector should consider all data in the table, regardless of paging, or if only the rows in the currently disabled page should be used.
+ * Values: 'all', 'current'
+ */
+ page?: string;
+ }
+
+ //#region "Namespaces"
+
+ //#region "core-methods"
+
+ interface DataTableCore extends UtilityMethods {
+ /**
+ * Get jquery object
+ */
+ $(selector: string | Node | Node[]| JQuery, modifier?: ObjectSelectorModifier): JQuery;
+
+ ///// Almost identical to $ in operation, but in this case returns the data for the matched rows.
+ //_(selector: string | Node | Node[] | JQuery, modifier?: ObjectSelectorModifier): JQuery;
+
+ /**
+ * Ajax Methods
+ */
+ ajax: AjaxMethodModel;
+
+ /**
+ * Clear the table of all data.
+ */
+ clear(): DataTable;
+
+ /**
+ * Destroy the DataTables in the current context.
+ *
+ * @param remove Completely remove the table from the DOM (true) or leave it in the DOM in its original plain un-enhanced HTML state (default, false).
+ */
+ destroy(remove?: boolean): DataTable;
+
+ /**
+ * Destroy the DataTables in the current context.
+ *
+ * @param reset Reset (default) or hold the current paging position. A full re-sort and re-filter is performed when this method is called, which is why the pagination reset is the default action.
+ */
+ draw(reset?: boolean): DataTable;
+
+ /**
+ * Table events removal.
+ *
+ * @param event Event name to remove.
+ * @param callback Specific callback function to remove if you want to unbind a single event listener.
+ */
+ off(event: string, callback?: Function): DataTable;
+
+ /**
+ * Table events listener.
+ *
+ * @param event Event to listen for.
+ * @param callback Specific callback function to remove if you want to unbind a single event listener.
+ */
+ on(event: string, callback: Function): DataTable;
+
+ /**
+ * Listen for a table event once and then remove the listener.
+ *
+ * @param event Event to listen for.
+ * @param callback Specific callback function to remove if you want to unbind a single event listener.
+ */
+ one(event: string, callback: Function): DataTable;
+
+ /**
+ * Page Methods / Object
+ */
+ page: PageMethods;
+
+ /**
+ * Get current search
+ */
+ search(): string;
+
+ /**
+ * Search for data in the table.
+ *
+ * @param input Search string to apply to the table.
+ * @param regex Treat as a regular expression (true) or not (default, false).
+ * @param smart Perform smart search.
+ * @param caseInsen Do case-insensitive matching (default, true) or not (false).
+ */
+ search(input: string, regex?: boolean, smart?: boolean, caseInsen?: boolean): DataTable;
+
+ /**
+ * Obtain the table's settings object
+ */
+ settings(): DataTable;
+
+ /**
+ * Page Methods / Object
+ */
+ state: StateMethods;
+ }
+
+ //#region "ajax-methods"
+
+ interface AjaxMethods extends DataTable {
+ /**
+ * Reload the table data from the Ajax data source.
+ *
+ * @param callback Function which is executed when the data as been reloaded and the table fully redrawn.
+ * @param resetPaging Reset (default action or true) or hold the current paging position (false).
+ */
+ load(callback?: Function, resetPaging?: boolean): DataTable;
+ }
+
+ interface AjaxMethodModel {
+ /**
+ * Get the latest JSON data obtained from the last Ajax request DataTables made
+ */
+ json(): Object;
+
+ /**
+ * Get the data submitted by DataTables to the server in the last Ajax request
+ */
+ params(): Object;
+
+ /**
+ * Reload the table data from the Ajax data source.
+ *
+ * @param callback Function which is executed when the data as been reloaded and the table fully redrawn.
+ * @param resetPaging Reset (default action or true) or hold the current paging position (false).
+ */
+ reload(callback?: Function, resetPaging?: boolean): DataTable;
+
+ /**
+ * Reload the table data from the Ajax data source
+ */
+ url(): string;
+
+ /**
+ * Reload the table data from the Ajax data source
+ *
+ * @param url URL to set to be the Ajax data source for the table.
+ */
+ url(url: string): AjaxMethods;
+ }
+
+ //#endregion "ajax-methods"
+
+ //#region "order-methods"
+
+ interface OrderMethods {
+ /**
+ * Get the ordering applied to the table.
+ */
+ (): (string | number)[][];
+
+ /**
+ * Set the ordering applied to the table.
+ *
+ * @param order Order Model
+ */
+ (order?: (string | number)[]): DataTable;
+ (order?: (string | number)[][]): DataTable;
+ (order: (string | number)[], ...args: any[]): DataTable;
+
+ /**
+ * Add an ordering listener to an element, for a given column.
+ *
+ * @param node Selector
+ * @param column Column index
+ * @param callback Callback function
+ */
+ listener(node: string | Node | JQuery, column: number, callback: Function): DataTable;
+ }
+ //#endregion "order-methods"
+
+ //#region "page-methods"
+
+ interface PageMethods {
+ /**
+ * Get the current page of the table.
+ */
+ (): number;
+
+ /**
+ * Set the current page of the table.
+ *
+ * @param page Index or 'first', 'next', 'previous', 'last'
+ */
+ (page: number | string): DataTable;
+
+ /**
+ * Get paging information about the table
+ */
+ info(): PageMethodeModelInfoReturn;
+
+ /**
+ * Get the table's page length.
+ */
+ len(): number;
+
+ /**
+ * Set the table's page length.
+ *
+ * @param length Page length to set. use -1 to show all records.
+ */
+ len(length: number): DataTable;
+ }
+
+ interface PageMethodeModelInfoReturn {
+ page: number;
+ pages: number;
+ start: number;
+ end: number;
+ length: number;
+ recordsTotal: number;
+ recordsDisplay: number;
+ }
+
+ //#endregion "page-methods"
+
+ //#region "state-methods"
+
+ interface StateMethods {
+ /**
+ * Get the last saved state of the table
+ */
+ (): StateReturnModel;
+
+ /**
+ * Clear the saved state of the table.
+ */
+ clear(): DataTable;
+
+ /**
+ * Get the table state that was loaded during initialisation.
+ */
+ loaded(): StateReturnModel;
+
+ /**
+ * Trigger a state save.
+ */
+ save(): DataTable;
+ }
+
+ interface StateReturnModel {
+ time: number;
+ start: number;
+ length: number;
+ order: (string | number)[][];
+ search: SearchSettings;
+ columns: StateReturnModelColumns[];
+ }
+
+ interface StateReturnModelColumns {
+ search: SearchSettings;
+ visible: boolean;
+ }
+
+ //#endregion "state-methods"
+
+ //#endregion "core-methods"
+
+ //#region "util-methods"
+
+ interface UtilityMethods {
+ /**
+ * Concatenate two or more API instances together
+ *
+ * @param a API instance to concatenate to the initial instance.
+ * @param b Additional API instance(s) to concatenate to the initial instance.
+ */
+ concat(a: Object, ...b: Object[]): DataTable;
+
+ /**
+ * Iterate over the contents of the API result set.
+ *
+ * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters
+ */
+ each(fn: Function): DataTable;
+
+ /**
+ * Reduce an Api instance to a single context and result set.
+ *
+ * @param idx Index to select
+ */
+ eq(idx: number): DataTable;
+
+ /**
+ * Iterate over the result set of an API instance and test each item, creating a new instance from those items which pass.
+ *
+ * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters.
+ */
+ filter(fn: Function): DataTable;
+
+ /**
+ * Flatten a 2D array structured API instance to a 1D array structure.
+ */
+ flatten(): DataTable;
+
+ /**
+ * Find the first instance of a value in the API instance's result set.
+ *
+ * @param value Value to find in the instance's result set.
+ */
+ indexOf(value: any): number;
+
+ /**
+ * Join the elements in the result set into a string.
+ *
+ * @param separator The string that will be used to separate each element of the result set.
+ */
+ join(separator: string): string;
+
+ /**
+ * Find the last instance of a value in the API instance's result set.
+ *
+ * @param value Value to find in the instance's result set.
+ */
+ lastIndexOf(value: any): number;
+
+ /**
+ * Number of elements in an API instance's result set.
+ */
+ length: number;
+
+ /**
+ * Iterate over the result set of an API instance, creating a new API instance from the values returned by the callback.
+ *
+ * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters.
+ */
+ map(fn: Function): DataTable;
+
+ /**
+ * Iterate over the result set of an API instance, creating a new API instance from the values retrieved from the original elements.
+ *
+ * @param property Object property name to use from the element in the original result set for the new result set.
+ */
+ pluck(property: number | string): DataTable;
+
+ /**
+ * Remove the last item from an API instance's result set.
+ */
+ pop(): any;
+
+ /**
+ * Add one or more items to the end of an API instance's result set.
+ *
+ * @param value_1 Item to add to the API instance's result set.
+ */
+ push(value_1: any | any[], ...value_2: any[]): number;
+
+ /**
+ * Apply a callback function against and accumulator and each element in the Api's result set (left-to-right).
+ *
+ * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters.
+ * @param initialValue Value to use as the first argument of the first call to the fn callback.
+ */
+ reduce(fn: Function, initialValue?: any): any;
+
+ /**
+ * Apply a callback function against and accumulator and each element in the Api's result set (right-to-left).
+ *
+ * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters.
+ * @param initialValue Value to use as the first argument of the first call to the fn callback.
+ */
+ reduceRight(fn: Function, initialValue?: any): any;
+
+ /**
+ * Reverse the result set of the API instance and return the original array.
+ */
+ reverse(): DataTable;
+
+ /**
+ * Remove the first item from an API instance's result set.
+ */
+ shift(): any;
+
+ /**
+ * Sort the elements of the API instance's result set.
+ *
+ * @param fn This is a standard Javascript sort comparison function. It accepts two parameters.
+ */
+ sort(fn?: Function): DataTable;
+
+ /**
+ * Modify the contents of an Api instance's result set, adding or removing items from it as required.
+ *
+ * @param index Index at which to start modifying the Api instance's result set.
+ * @param howMany Number of elements to remove from the result set.
+ * @param value_1 Item to add to the result set at the index specified by the first parameter.
+ */
+ splice(index: number, howMany: number, value_1?: any | any[], ...value_2: any[]): any[];
+
+ /**
+ * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set.
+ */
+ to$(): JQuery;
+
+ /**
+ * Create a native Javascript array object from an API instance.
+ */
+ toArray(): any[];
+
+ /**
+ * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set.
+ */
+ toJQuery(): JQuery;
+
+ /**
+ * Create a new API instance containing only the unique items from a the elements in an instance's result set.
+ */
+ unique(): DataTable;
+
+ /**
+ * Add one or more items to the start of an API instance's result set.
+ *
+ * @param value_1 Item to add to the API instance's result set.
+ */
+ unshift(value_1: any | any[], ...value_2: any[]): number;
+ }
+
+ //#endregion "util-methods"
+
+ interface CommonSubMethods {
+ /**
+ * Get the DataTables cached data for the selected cell
+ *
+ * @param t Specify which cache the data should be read from. Can take one of two values: search or order
+ */
+ cache(t: string): DataTable;
+ }
+
+ //#region "cell-methods"
+
+ interface CommonCellMethods extends CommonSubMethods {
+ /**
+ * Invalidate the data held in DataTables for the selected cells
+ *
+ * @param source Data source to read the new data from.
+ */
+ invalidate(source?: string): DataTable;
+
+ /**
+ * Get data for the selected cell
+ *
+ * @param f Data type to get. This can be one of: 'display', 'filter', 'sort', 'type'
+ */
+ render(t: string): any;
+ }
+
+ interface CellMethods extends DataTableCore, CommonCellMethods {
+ /**
+ * Get data for the selected cell
+ */
+ data(): any;
+
+ /**
+ * Get data for the selected cell
+ *
+ * @param data Value to assign to the data for the cell
+ */
+ data(data: any): DataTable;
+
+ /**
+ * Get index information about the selected cell
+ */
+ index(): CellIndexReturn;
+
+ /**
+ * Get the DOM element for the selected cell
+ */
+ node(): Node;
+ }
+
+ interface CellIndexReturn {
+ row: number;
+ column: number;
+ columnVisible: number;
+ }
+
+ interface CellsMethods extends DataTableCore, CommonCellMethods {
+ /**
+ * Get data for the selected cells
+ */
+ data(): DataTable;
+
+ /**
+ * Get index information about the selected cells
+ */
+ indexes(): DataTable;
+
+ /**
+ * Get the DOM elements for the selected cells
+ */
+ nodes(): DataTable;
+ }
+ //#endregion "cell-methods"
+
+ //#region "column-methods"
+
+ interface CommonColumnMethod extends CommonSubMethods {
+ /**
+ * Get the footer th / td cell for the selected column.
+ */
+ footer(): any;
+
+ /**
+ * Get the header th / td cell for a column.
+ */
+ header(): Node;
+
+ /**
+ * Order the table, in the direction specified, by the column selected by the column()DT selector.
+ *
+ * @param direction Direction of sort to apply to the selected column - desc (descending) or asc (ascending).
+ */
+ order(direction: string): DataTable;
+
+ /**
+ * Get the visibility of the selected column.
+ */
+ visible(): boolean;
+
+ /**
+ * Set the visibility of the selected column.
+ *
+ * @param show Specify if the column should be visible (true) or not (false).
+ * @param redrawCalculations Indicate if DataTables should recalculate the column layout (true - default) or not (false). Typically this would be left as the default value, but it can be useful to disable when using the method in a loop - so the calculations are performed on every call as they can hamper performance.
+ */
+ visible(show: boolean, redrawCalculations?: boolean): DataTable;
+ }
+
+ interface ColumnMethodsModel {
+ /**
+ * Select the column found by a column selector
+ *
+ * @param cellSelector Cell selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnMethods;
+
+ /**
+ * Convert from the input column index type to that required.
+ *
+ * @param t The type on conversion that should take place: 'fromVisible', 'toData', 'fromData', 'toVisible'
+ * @param index The index to be converted
+ */
+ index(t: string, index: number): number;
+ }
+
+ interface ColumnMethods extends DataTableCore, CommonColumnMethod {
+ /**
+ * Get the data for the cells in the selected column.
+ */
+ data(): DataTable;
+
+ /**
+ * Get the data source property for the selected column
+ */
+ dataSrc(): number | string | Function;
+
+ /**
+ * Get index information about the selected cell
+ *
+ * @param t Specify if you want to get the column data index (default) or the visible index (visible).
+ */
+ index(t?: string): DataTable;
+
+ /**
+ * Obtain the th / td nodes for the selected column
+ */
+ nodes(): DataTable[];
+ }
+
+ interface ColumnsMethodsModel {
+ /**
+ * Select all columns
+ *
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ (modifier?: ObjectSelectorModifier): ColumnsMethods;
+
+ /**
+ * Select columns found by a cell selector
+ *
+ * @param cellSelector Cell selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnsMethods;
+
+ /**
+ * Recalculate the column widths for layout.
+ */
+ adjust(): DataTable;
+ }
+
+ interface ColumnsMethods extends DataTableCore, CommonColumnMethod {
+ /**
+ * Obtain the data for the columns from the selector
+ */
+ data(): DataTable;
+
+ /**
+ * Get the data source property for the selected columns.
+ */
+ dataSrc(): DataTable;
+
+ /**
+ * Get the column indexes of the selected columns.
+ *
+ * @param t Specify if you want to get the column data index (default) or the visible index (visible).
+ */
+ indexes(t?: string): DataTable;
+
+ /**
+ * Obtain the th / td nodes for the selected columns
+ */
+ nodes(): DataTable[][];
+ }
+ //#endregion "column-methods"
+
+ //#region "row-methods"
+
+ interface CommonRowMethod extends CommonSubMethods {
+ /**
+ * Obtain the th / td nodes for the selected column
+ *
+ * @param source Data source to read the new data from. Values: 'auto', 'data', 'dom'
+ */
+ invalidate(source?: string): DataTable;
+ }
+
+ interface RowChildMethodModel {
+ /**
+ * Get the child row(s) that have been set for a parent row
+ */
+ (): JQuery;
+
+ /**
+ * Get the child row(s) that have been set for a parent row
+ *
+ * @param showRemove This parameter can be given as true or false
+ */
+ (showRemove: boolean): RowChildMethods;
+
+ /**
+ * Set the data to show in the child row(s). Note that calling this method will replace any child rows which are already attached to the parent row.
+ *
+ * @param data The data to be shown in the child row can be given in multiple different ways.
+ * @param className Class name that is added to the td cell node(s) of the child row(s). As of 1.10.1 it is also added to the tr row node of the child row(s).
+ */
+ (data: (string | Node | JQuery) | (string | Node | JQuery)[], className?: string): RowChildMethods;
+
+ /**
+ * Hide the child row(s) of a parent row
+ */
+ hide(): DataTable;
+
+ /**
+ * Check if the child rows of a parent row are visible
+ */
+ isShown(): DataTable;
+
+ /**
+ * Remove child row(s) from display and release any allocated memory
+ */
+ remove(): DataTable;
+
+ /**
+ * Show the child row(s) of a parent row
+ */
+ show(): DataTable;
+ }
+
+ interface RowChildMethods extends DataTableCore {
+ /**
+ * Hide the child row(s) of a parent row
+ */
+ hide(): DataTable;
+
+ /**
+ * Remove child row(s) from display and release any allocated memory
+ */
+ remove(): DataTable;
+
+ /**
+ * Make newly defined child rows visible
+ */
+ show(): DataTable;
+ }
+
+ interface RowMethodsModel {
+ /**
+ * Select a row found by a row selector
+ *
+ * @param rowSelector Row selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ (rowSelector: any, modifier?: ObjectSelectorModifier): RowMethods;
+
+ /**
+ * Add a new row to the table using the given data
+ *
+ * @param data Data to use for the new row. This may be an array, object or Javascript object instance, but must be in the same format as the other data in the table
+ */
+ add(data: any[]| Object): DataTable;
+ }
+
+ interface RowMethods extends DataTableCore, CommonRowMethod {
+ /**
+ * Order Methods / Object
+ */
+ child: RowChildMethodModel;
+
+ /**
+ * Get the data for the selected row
+ */
+ data(): any[]| Object;
+
+ /**
+ * Set the data for the selected row
+ *
+ * @param d Data to use for the row.
+ */
+ data(d: any[]| Object): DataTable;
+
+ /**
+ * Get the row index of the row column.
+ */
+ index(): number;
+
+ /**
+ * Obtain the tr node for the selected row
+ */
+ node(): Node;
+
+ /**
+ * Delete the selected row from the DataTable.
+ */
+ remove(): Node;
+ }
+
+ interface RowsMethodsModel {
+ /**
+ * Select all rows
+ *
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ (modifier?: ObjectSelectorModifier): RowsMethods;
+
+ /**
+ * Select rows found by a row selector
+ *
+ * @param cellSelector Row selector.
+ * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account.
+ */
+ (rowSelector: any, modifier?: ObjectSelectorModifier): RowsMethods;
+
+ /**
+ * Add new rows to the table using the data given
+ *
+ * @param data Array of data elements, with each one describing a new row to be added to the table
+ */
+ add(data: any[]): DataTable;
+ }
+
+ interface RowsMethods extends DataTableCore, CommonRowMethod {
+ /**
+ * Get the data for the rows from the selector
+ */
+ data(): DataTable;
+
+ /**
+ * Set the data for the selected row
+ *
+ * @param d Data to use for the row.
+ */
+ data(d: any[]| Object): DataTable;
+
+ /**
+ * Get the row indexes of the selected rows.
+ */
+ indexes(): DataTable;
+
+ /**
+ * Obtain the tr nodes for the selected rows
+ */
+ nodes(): DataTable;
+
+ /**
+ * Delete the selected rows from the DataTable.
+ */
+ remove(): DataTable;
+ }
+ //#endregion "row-methods"
+
+ //#region "table-methods"
+
+ interface TableMethods extends DataTableCore {
+ /**
+ * Get the tfoot node for the table in the API's context
+ */
+ footer(): Node;
+
+ /**
+ * Get the thead node for the table in the API's context
+ */
+ header(): Node;
+
+ /**
+ * Get the tbody node for the table in the API's context
+ */
+ body(): Node;
+
+ /**
+ * Get the div container node for the table in the API's context
+ */
+ container(): Node;
+
+ /**
+ * Get the table node for the table in the API's context
+ */
+ node(): Node;
+ }
+
+ interface TablesMethods extends DataTableCore {
+ /**
+ * Get the tfoot nodes for the tables in the API's context
+ */
+ footer(): DataTable;
+
+ /**
+ * Get the thead nodes for the tables in the API's context
+ */
+ header(): DataTable;
+
+ /**
+ * Get the tbody nodes for the tables in the API's context
+ */
+ body(): DataTable;
+
+ /**
+ * Get the div container nodes for the tables in the API's context
+ */
+ containers(): DataTable;
+
+ /**
+ * Get the table nodes for the tables in the API's context
+ */
+ nodes(): DataTable;
+ }
+ //#endregion "table-methods"
+
+ //#endregion "Namespaces"
+
+ //#region "Static-Methods"
+
+ export interface StaticFunctions {
+ /**
+ * Check is a table node is a DataTable or not
+ *
+ * @param table Selector string for table
+ */
+ isDataTable(table: string): boolean;
+
+ /**
+ * Get all DataTables on the page
+ *
+ * @param visible Get only visible tables
+ */
+ tables(visible?: boolean): DataTables.DataTable[];
+
+ /**
+ * Version number compatibility check function
+ *
+ * @param version Version string
+ */
+ versionCheck(version: string): boolean;
+
+ /**
+ * Utils
+ */
+ util: StaticUtilFunctions;
+
+ /**
+ * Check is a table node is a DataTable or not
+ *
+ * @param table Selector string for table
+ */
+ Api(selector: string | Node | Node[]| JQuery): DataTables.DataTable;
+ }
+
+ export interface StaticUtilFunctions {
+ /**
+ * Escape special characters in a regular expression string. Since: 1.10.4
+ *
+ * @param str String to escape
+ */
+ escapeRegex(str: string): string;
+
+ /**
+ * Throttle the calls to a method to reduce call frequency. Since: 1.10.3
+ *
+ * @param fn Function
+ * @param period ms
+ */
+ throttle(fn: Function, period?: number): Function;
+ }
+
+ //#endregion "Static-Methods"
+
+ //#region "Settings"
+
+ export interface Settings {
+
+ //#region "Features"
+
+ /**
+ * Feature control DataTables' smart column width handling. Since: 1.10
+ */
+ autoWidth?: boolean;
+
+ /**
+ * Feature control deferred rendering for additional speed of initialisation. Since: 1.10
+ */
+ deferRender?: boolean;
+
+ /**
+ * Feature control table information display field. Since: 1.10
+ */
+ info?: boolean;
+
+ /**
+ * Use markup and classes for the table to be themed by jQuery UI ThemeRoller. Since: 1.10
+ */
+ jQueryUI?: boolean;
+
+ /**
+ * Feature control the end user's ability to change the paging display length of the table. Since: 1.10
+ */
+ lengthChange?: boolean;
+
+ /**
+ * Feature control ordering (sorting) abilities in DataTables. Since: 1.10
+ */
+ ordering?: boolean;
+
+ /**
+ * Enable or disable table pagination. Since: 1.10
+ */
+ paging?: boolean;
+
+ /**
+ * Feature control the processing indicator. Since: 1.10
+ */
+ processing?: boolean;
+
+ /**
+ * Horizontal scrolling. Since: 1.10
+ */
+ scrollX?: boolean;
+
+ /**
+ * Vertical scrolling. Since: 1.10 Exp: "200px"
+ */
+ scrollY?: string;
+
+ /**
+ * Feature control search (filtering) abilities Since: 1.10
+ */
+ searching?: boolean;
+
+ /**
+ * Feature control DataTables' server-side processing mode. Since: 1.10
+ */
+ serverSide?: boolean;
+
+ /**
+ * State saving - restore table state on page reload. Since: 1.10
+ */
+ stateSave?: boolean;
+
+ //#endregion "Features"
+
+ //#region "Data"
+
+ /**
+ * Load data for the table's content from an Ajax source. Since: 1.10
+ */
+ ajax?: string | AjaxSettings | FunctionAjax;
+
+ /**
+ * Data to use as the display data for the table. Since: 1.10
+ */
+ data?: Object;
+
+ //#endregion "Data"
+
+ //#region "Options"
+
+ /**
+ * Data to use as the display data for the table. Since: 1.10
+ */
+ columns?: ColumnSettings[];
+
+ /**
+ * Assign a column definition to one or more columns.. Since: 1.10
+ */
+ columnDefs?: ColumnDefsSettings[];
+
+ /**
+ * Delay the loading of server-side data until second draw
+ */
+ deferLoading?: number | number[];
+
+ /**
+ * Destroy any existing table matching the selector and replace with the new options. Since: 1.10
+ */
+ destroy?: boolean;
+
+ /**
+ * Initial paging start point. Since: 1.10
+ */
+ displayStart?: number;
+
+ /**
+ * Define the table control elements to appear on the page and in what order. Since: 1.10
+ */
+ dom?: string;
+
+ /**
+ * Change the options in the page length select list. Since: 1.10
+ */
+ lengthMenu?: (number | string)[]| (number | string)[][];
+
+ /**
+ * Control which cell the order event handler will be applied to in a column. Since: 1.10
+ */
+ orderCellsTop?: boolean;
+
+ /**
+ * Highlight the columns being ordered in the table's body. Since: 1.10
+ */
+ orderClasses?: boolean;
+
+ /**
+ * Initial order (sort) to apply to the table. Since: 1.10
+ */
+ order?: (string | number)[]| (string | number)[][];
+
+ /**
+ * Ordering to always be applied to the table. Since: 1.10
+ */
+ orderFixed?: (string | number)[]| (string | number)[][]| Object;
+
+ /**
+ * Multiple column ordering ability control. Since: 1.10
+ */
+ orderMulti?: boolean;
+
+ /**
+ * Change the initial page length (number of rows per page). Since: 1.10
+ */
+ pageLength?: number;
+
+ /**
+ * Pagination button display options. Basic Types: simple, simple_numbers, full, full_numbers
+ */
+ pagingType?: string;
+
+ /**
+ * Retrieve an existing DataTables instance. Since: 1.10
+ */
+ retrieve?: boolean
+
+ /**
+ * Display component renderer types. Since: 1.10
+ */
+ renderer?: string | RendererSettings;
+
+ /**
+ * Allow the table to reduce in height when a limited number of rows are shown. Since: 1.10
+ */
+ scrollCollapse?: boolean;
+
+ /**
+ * Set an initial filter in DataTables and / or filtering options. Since: 1.10
+ */
+ search?: SearchSettings;
+
+ /**
+ * Define an initial search for individual columns. Since: 1.10
+ */
+ searchCols?: SearchSettings[];
+
+ /**
+ * Set a throttle frequency for searching. Since: 1.10
+ */
+ searchDelay?: number;
+
+ /**
+ * Saved state validity duration. Since: 1.10
+ */
+ stateDuration?: number;
+
+ /**
+ * Set the zebra stripe class names for the rows in the table. Since: 1.10
+ */
+ stripeClasses?: string[];
+
+ /**
+ * Tab index control for keyboard navigation. Since: 1.10
+ */
+ tabIndex?: number;
+
+ //#endregion "Options"
+
+ //#region "Callbacks"
+
+ /**
+ * Callback for whenever a TR element is created for the table's body. Since: 1.10
+ */
+ createdRow?: FunctionCreateRow;
+
+ /**
+ * Function that is called every time DataTables performs a draw. Since: 1.10
+ */
+ drawCallback?: FunctionDrawCallback;
+
+ /**
+ * Footer display callback function. Since: 1.10
+ */
+ footerCallback?: FunctionFooterCallback;
+
+ /**
+ * Number formatting callback function. Since: 1.10
+ */
+ formatNumber?: FunctionFormatNumber;
+
+ /**
+ * Header display callback function. Since: 1.10
+ */
+ headerCallback?: FunctionHeaderCallback;
+
+ /**
+ * Table summary information display callback. Since: 1.10
+ */
+ infoCallback?: FunctionInfoCallback;
+
+ /**
+ * Initialisation complete callback. Since: 1.10
+ */
+ initComplete?: FunctionInitComplete;
+
+ /**
+ * Pre-draw callback. Since: 1.10
+ */
+ preDrawCallback?: FunctionPreDrawCallback;
+
+ /**
+ * Row draw callback.. Since: 1.10
+ */
+ rowCallback?: FunctionRowCallback;
+
+ /**
+ * Callback that defines where and how a saved state should be loaded. Since: 1.10
+ */
+ stateLoadCallback?: FunctionStateLoadCallback;
+
+ /**
+ * State loaded callback. Since: 1.10
+ */
+ stateLoaded?: FunctionStateLoaded;
+
+ /**
+ * State loaded - data manipulation callback. Since: 1.10
+ */
+ stateLoadParams?: FunctionStateLoadParams;
+
+ /**
+ * Callback that defines how the table state is stored and where. Since: 1.10
+ */
+ stateSaveCallback?: FunctionStateSaveCallback;
+
+ /**
+ * State save - data manipulation callback. Since: 1.10
+ */
+ stateSaveParams?: FunctionStateSaveParams;
+
+ //#endregion "Callbacks"
+
+ //#region "Language"
+
+ language?: LanguageSettings;
+
+ //#endregion "Language"
+ }
+
+ //#region "ajax-settings"
+
+ export interface AjaxDataRequest {
+ draw: number;
+ start: number;
+ length: number;
+ data: any;
+ order: AjaxDataRequestOrder[];
+ columns: AjaxDataRequestColumn[];
+ search: AjaxDataRequestSearch;
+ }
+
+ export interface AjaxDataRequestSearch {
+ value: string;
+ regex: boolean;
+ }
+
+ export interface AjaxDataRequestOrder {
+ column: number;
+ dir: string;
+ }
+
+ export interface AjaxDataRequestColumn {
+ data: string | number;
+ name: string;
+ searchable: boolean;
+ orderable: boolean;
+ search: AjaxDataRequestSearch;
+ }
+
+ export interface AjaxData {
+ draw: number;
+ recordsTotal: number;
+ recordsFiltered: number;
+ data: any;
+ error?: string;
+ }
+
+ interface AjaxSettings extends JQueryAjaxSettings {
+ /**
+ * Add or modify data submitted to the server upon an Ajax request. Since: 1.10
+ */
+ data?: Object | FunctionAjaxData;
+
+ /**
+ * Data property or manipulation method for table data. Since: 1.10
+ */
+ dataSrc?: string | Function;
+ }
+
+ interface FunctionAjax {
+ (data: Object, callback: Function, settings: SettingsLegacy): void;
+ }
+
+ interface FunctionAjaxData {
+ (data: Object): string | Object;
+ }
+
+ //#endregion "ajax-settings"
+
+ //#region "colunm-settings"
+
+ export interface ColumnSettings {
+ /**
+ * Cell type to be created for a column. th/td Since: 1.10
+ */
+ cellType?: string;
+
+ /**
+ * Class to assign to each cell in the column. Since: 1.10
+ */
+ className?: string;
+
+ /**
+ * Add padding to the text content used when calculating the optimal with for a table. Since: 1.10
+ */
+ contentPadding?: string;
+
+ /**
+ * Cell created callback to allow DOM manipulation. Since: 1.10
+ */
+ createdCell?: FunctionColumnCreatedCell;
+
+ /**
+ * Class to assign to each cell in the column. Since: 1.10
+ */
+ data?: number | string | ObjectColumnData | FunctionColumnData;
+
+ /**
+ * Set default, static, content for a column. Since: 1.10
+ */
+ defaultContent?: string;
+
+ /**
+ * Set a descriptive name for a column. Since: 1.10
+ */
+ name?: string;
+
+ /**
+ * Enable or disable ordering on this column. Since: 1.10
+ */
+ orderable?: boolean;
+
+ /**
+ * Define multiple column ordering as the default order for a column. Since: 1.10
+ */
+ orderData?: number | number[];
+
+ /**
+ * Live DOM sorting type assignment. Since: 1.10
+ */
+ orderDataType?: string;
+
+ /**
+ * Order direction application sequence. Since: 1.10
+ */
+ orderSequence?: string[];
+
+ /**
+ * Render (process) the data for use in the table. Since: 1.10
+ */
+ render?: number | string | ObjectColumnRender | FunctionColumnRender;
+
+ /**
+ * Enable or disable filtering on the data in this column. Since: 1.10
+ */
+ searchable?: boolean;
+
+ /**
+ * Set the column title. Since: 1.10
+ */
+ title?: string;
+
+ /**
+ * Set the column type - used for filtering and sorting string processing. Since: 1.10
+ */
+ type?: string;
+
+ /**
+ * Enable or disable the display of this column. Since: 1.10
+ */
+ visible?: boolean;
+
+ /**
+ * Column width assignment. Since: 1.10
+ */
+ width?: string;
+ }
+
+ interface ColumnDefsSettings extends ColumnSettings {
+ targets: string | number | (number | string)[]
+ }
+
+ interface FunctionColumnCreatedCell {
+ (cell: Node, cellData: any, rowData: any, row: number, col: number): void;
+ }
+
+ interface FunctionColumnData {
+ (row: any, t: string, s: any, meta: Object): void;
+ }
+
+ interface ObjectColumnData {
+ _: string;
+ filter?: string;
+ display?: string;
+ type?: string;
+ sort?: string;
+ }
+
+ interface ObjectColumnRender extends ObjectColumnData {
+ }
+
+ interface FunctionColumnRender {
+ (data: Node, t: Node, row: Node, meta: Object): void;
+ }
+
+ //#endregion "colunm-settings"
+
+ //#region "other-settings"
+
+ export interface RendererSettings {
+ header?: string;
+ pageButton?: string;
+ }
+
+ export interface SearchSettings {
+ /**
+ * Control case-sensitive filtering option. Since: 1.10
+ */
+ caseInsensitive?: boolean;
+
+ /**
+ * Enable / disable escaping of regular expression characters in the search term. Since: 1.10
+ */
+ regex?: boolean;
+
+ /**
+ * Enable / disable DataTables' smart filtering. Since: 1.10
+ */
+ smart?: boolean;
+
+ /**
+ * Set an initial filtering condition on the table. Since: 1.10
+ */
+ search?: string;
+ }
+
+ //#endregion "other-settings"
+
+ //#region "callback-functions"
+
+ interface FunctionCreateRow {
+ (row: Node, data: any[]| Object, dataIndex: number): void;
+ }
+
+ interface FunctionDrawCallback {
+ (settings: SettingsLegacy): void;
+ }
+
+ interface FunctionFooterCallback {
+ (tfoot: Node, data: any[], start: number, end: number, display: any[]): void;
+ }
+
+ interface FunctionFormatNumber {
+ (formatNumber: number): void;
+ }
+
+ interface FunctionHeaderCallback {
+ (thead: Node, data: any[], start: number, end: number, display: any[]): void;
+ }
+
+ interface FunctionInfoCallback {
+ (settings: SettingsLegacy, start: number, end: number, mnax: number, total: number, pre: string): void;
+ }
+
+ interface FunctionInitComplete {
+ (settings: SettingsLegacy, json: Object): void;
+ }
+
+ interface FunctionPreDrawCallback {
+ (settings: SettingsLegacy): void;
+ }
+
+ interface FunctionRowCallback {
+ (row: Node, data: any[]| Object): void;
+ }
+
+ interface FunctionStateLoadCallback {
+ (settings: SettingsLegacy): void;
+ }
+
+ interface FunctionStateLoaded {
+ (settings: SettingsLegacy, data: Object): void;
+ }
+
+ interface FunctionStateLoadParams {
+ (settings: SettingsLegacy, data: Object): void;
+ }
+
+ interface FunctionStateSaveCallback {
+ (settings: SettingsLegacy, data: Object): void;
+ }
+
+ interface FunctionStateSaveParams {
+ (settings: SettingsLegacy, data: Object): void;
+ }
+
+ //#endregion "callback-functions"
+
+ //#region "language-settings"
+
+ interface LanguageSettings {
+ emptyTable: string;
+ info: string;
+ infoEmpty: string;
+ infoFiltered: string;
+ infoPostFix: string;
+ thousands: string;
+ lengthMenu: string;
+ loadingRecords: string;
+ processing: string;
+ search: string;
+ zeroRecords: string;
+ paginate: LanguagePaginateSettings;
+ aria: LanguageAriaSettings;
+ }
+
+ interface LanguagePaginateSettings {
+ first: string;
+ last: string;
+ next: string;
+ previous: string;
+ }
+
+ interface LanguageAriaSettings {
+ sortAscending: string;
+ sortDescending: string;
+ }
+
+ //#endregion "language-settings"
+
+ //#endregion "Settings"
+
+ //#region "SettingsLegacy"
+
+ interface ArrayStringNode {
+ [index: string]: Node;
+ }
+
+ export interface SettingsLegacy {
+ ajax: any;
+ oApi: any;
+ oFeatures: FeaturesLegacy;
+ oScroll: ScrollingLegacy;
+ oLanguage: LanguageLegacy; // | { fnInfoCallback: FunctionInfoCallback; };
+ oBrowser: { bScrollOversize: boolean; };
+ aanFeatures: ArrayStringNode[][];
+ aoData: RowLegacy[];
+ aiDisplay: number[];
+ aiDisplayMaster: number[];
+ aoColumns: ColumnLegacy[];
+ aoHeader: any[];
+ aoFooter: any[];
+ asDataSearch: string[];
+ oPreviousSearch: any;
+ aoPreSearchCols: any[];
+ aaSorting: any[][];
+ aaSortingFixed: any[][];
+ asStripeClasses: string[];
+ asDestroyStripes: string[];
+ sDestroyWidth: number;
+ aoRowCallback: FunctionRowCallback[];
+ aoHeaderCallback: FunctionHeaderCallback[];
+ aoFooterCallback: FunctionFooterCallback[];
+ aoDrawCallback: FunctionDrawCallback[];
+ aoRowCreatedCallback: FunctionCreateRow[];
+ aoPreDrawCallback: FunctionPreDrawCallback[];
+ aoInitComplete: FunctionInitComplete[];
+ aoStateSaveParams: FunctionStateSaveParams[];
+ aoStateLoadParams: FunctionStateLoadParams[];
+ aoStateLoaded: FunctionStateLoaded[];
+ sTableId: string;
+ nTable: Node;
+ nTHead: Node;
+ nTFoot: Node;
+ nTBody: Node;
+ nTableWrapper: Node;
+ bDeferLoading: boolean;
+ bInitialized: boolean;
+ aoOpenRows: any[];
+ sDom: string;
+ sPaginationType: string;
+ iCookieDuration: number;
+ sCookiePrefix: string;
+ fnCookieCallback: CookieCallbackLegacy;
+ aoStateSave: FunctionStateSaveCallback[];
+ aoStateLoad: FunctionStateLoadCallback[];
+ oLoadedState: any;
+ sAjaxSource: string;
+ sAjaxDataProp: string;
+ bAjaxDataGet: boolean;
+ jqXHR: any;
+ fnServerData: any;
+ aoServerParams: any[];
+ sServerMethod: string;
+ fnFormatNumber: FunctionFormatNumber;
+ aLengthMenu: any[];
+ iDraw: number;
+ bDrawing: boolean;
+ iDrawError: number;
+ _iDisplayLength: number;
+ _iDisplayStart: number;
+ _iDisplayEnd: number;
+ _iRecordsTotal: number;
+ _iRecordsDisplay: number;
+ bJUI: boolean;
+ oClasses: any;
+ bFiltered: boolean;
+ bSorted: boolean;
+ bSortCellsTop: boolean;
+ oInit: any;
+ aoDestroyCallback: any[];
+ fnRecordsTotal: () => number;
+ fnRecordsDisplay: () => number;
+ fnDisplayEnd: () => number;
+ oInstance: any;
+ sInstance: string;
+ iTabIndex: number;
+ nScrollHead: Node;
+ nScrollFoot: Node;
+ }
+
+ export interface FeaturesLegacy {
+ bAutoWidth: boolean;
+ bDeferRender: boolean;
+ bFilter: boolean;
+ bInfo: boolean;
+ bLengthChange: boolean;
+ bPaginate: boolean;
+ bProcessing: boolean;
+ bServerSide: boolean;
+ bSort: boolean;
+ bSortClasses: boolean;
+ bStateSave: boolean;
+ }
+
+ export interface ScrollingLegacy {
+ bAutoCss: boolean;
+ bCollapse: boolean;
+ bInfinite: boolean;
+ iBarWidth: number;
+ iLoadGap: number;
+ sX: string;
+ sY: string;
+ }
+
+ export interface RowLegacy {
+ nTr: Node;
+ _aData: any;
+ _aSortData: any[];
+ _anHidden: Node[];
+ _sRowStripe: string;
+ }
+
+ export interface ColumnLegacy {
+ aDataSort: any;
+ asSorting: string[];
+ bSearchable: boolean;
+ bSortable: boolean;
+ bVisible: boolean;
+ _bAutoType: boolean;
+ fnCreatedCell: FunctionColumnCreatedCell;
+ fnGetData: (data: any, specific: string) => any;
+ fnSetData: (data: any, value: any) => void;
+ mData: any;
+ mRender: any;
+ nTh: Node;
+ nIf: Node;
+ sClass: string;
+ sContentPadding: string;
+ sDefaultContent: string;
+ sName: string;
+ sSortDataType: string;
+ sSortingClass: string;
+ sSortingClassJUI: string;
+ sTitle: string;
+ sType: string;
+ sWidth: string;
+ sWidthOrig: string;
+ }
+
+ export interface CookieCallbackLegacy {
+ (name: string, data: any, expires: string, path: string, cookie: string): void;
+ }
+
+ export interface LanguageLegacy {
+ oAria?: LanguageAriaLegacy;
+ oPaginate?: LanguagePaginateLegacy;
+ sEmptyTable?: string;
+ sInfo?: string;
+ sInfoEmpty?: string;
+ sInfoFiltered?: string;
+ sInfoPostFix?: string;
+ sInfoThousands?: string;
+ sLengthMenu?: string;
+ sLoadingRecords?: string;
+ sProcessing?: string;
+ sSearch?: string;
+ sUrl?: string;
+ sZeroRecords?: string;
+ }
+
+ export interface LanguageAriaLegacy {
+ sSortAscending?: string;
+ sSortDescending?: string;
+ }
+
+ export interface LanguagePaginateLegacy {
+ sFirst?: string;
+ sLast?: string;
+ sNext?: string;
+ sPrevious?: string;
+ }
+ //#endregion "SettingsLegacy"
+
+}
\ No newline at end of file
diff --git a/jquery.window/jquery.window-tests.ts b/jquery.window/jquery.window-tests.ts
new file mode 100644
index 000000000..0b5fa7e83
--- /dev/null
+++ b/jquery.window/jquery.window-tests.ts
@@ -0,0 +1,139 @@
+///
+///
+
+function example_1() {
+ $.window({
+ title: "Cyclops Studio",
+ url: "http://apps.fstoke.me/"
+ });
+}
+
+function example_2() {
+ $.window({
+ showModal: true,
+ modalOpacity: 0.5,
+ icon: "http://www.fstoke.me/favicon.ico",
+ title: "Professional JavaScript for Web Developers",
+ content: $("#window_block2").html(), // load window_block2 html content
+ footerContent: "
This is a nice plugin :^)"
+ });
+};
+
+function example_3() {
+ // prepare customerized static attributes, see static attributes
+ // Note: you should call this method before starting to create window instances, or windows might display wrong.
+ $.window.prepare({
+ dock: 'bottom', // change the dock direction: 'left', 'right', 'top', 'bottom'
+ animationSpeed: 200, // set animation speed
+ minWinLong: 180 // set minimized window long dimension width in pixel
+ });
+
+ // limit window within body
+ $.window({
+ icon: 'http://www.fstoke.me/favicon.ico',
+ title: "This window only can be dragged within body boundary",
+ content: "I only can be dragged within body element." +
+ "
Really? Really? You can try it... :)
",
+ checkBoundary: true,
+ x: 80,
+ y: 80
+ });
+
+ // limit window within a element
+ $("#my_boundary_panel").window({
+ icon: 'http://mail.google.com/favicon.ico',
+ title: "This window only can be dragged within its parent element",
+ content: "I only can be dragged within my boss...@@
",
+ checkBoundary: true,
+ width: 200,
+ height: 160,
+ maxWidth: 400,
+ maxHeight: 300,
+ x: 80,
+ y: 80
+ });
+
+ // assign the dock area
+ $.window.prepare({
+ dock: 'bottom', // change the dock direction: 'left', 'right', 'top', 'bottom'
+ dockArea: $('#myDockArea'), // set the dock area
+ animationSpeed: 200, // set animation speed
+ minWinLong: 180 // set minimized window long dimension width in pixel
+ });
+}
+
+function example_4() {
+ $.window({
+ title: "Un-draggable & Un-resizable Window",
+ content: "I can't be dragged...
" +
+ "I can't be resized too...
Of course, maximize and minimize are also disabled...
" +
+ "So... What can I do? I only can be closed. @_@
",
+ draggable: false,
+ resizable: false,
+ maximizable: false,
+ minimizable: false,
+ showModal: true
+ });
+}
+
+function example_5() {
+ var log = console.log;
+ $.window({
+ title: "complext window",
+ content: $("#window_block5").html(), // load window_block5 html content
+ x: 150, // the x-axis value on screen, if -1 means put on screen center
+ y: 100, // the y-axis value on screen, if -1 means put on screen center
+ width: 600, // window width
+ height: 300, // window height
+ minWidth: 200, // the minimum width, if -1 means no checking
+ minHeight: 100, // the minimum height, if -1 means no checking
+ maxWidth: 700, // the minimum width, if -1 means no checking
+ maxHeight: 400, // the minimum height, if -1 means no checking
+ scrollable: false, // a boolean flag to show scroll bar or not
+ onOpen: (wnd: JQueryWindow.Window) => { // a callback function while container is added into body
+ alert('open');
+ },
+ onShow: (wnd: JQueryWindow.Window) => { // a callback function while whole window display routine is finished
+ alert('show');
+ },
+ onClose: (wnd: JQueryWindow.Window) => { // a callback function while user click close button
+ alert('close');
+ },
+ onSelect: (wnd: JQueryWindow.Window) => { // a callback function while user select the window
+ log('select');
+ },
+ onUnselect: (wnd: JQueryWindow.Window) => { // a callback function while window unselected
+ log('unelect');
+ },
+ onDrag: (wnd: JQueryWindow.Window) => { // a callback function while window is going to drag
+ log('drag');
+ },
+ afterDrag: (wnd: JQueryWindow.Window) => { // a callback function after window dragged
+ log('after dragged');
+ },
+ onResize: (wnd: JQueryWindow.Window) => { // a callback function while window is going to resize
+ log('resize');
+ },
+ afterResize: (wnd: JQueryWindow.Window) => { // a callback function after window resized
+ log('after resized');
+ },
+ onMinimize: (wnd: JQueryWindow.Window) => { // a callback function while window is going to minimize
+ log('minimize');
+ },
+ afterMinimize: (wnd: JQueryWindow.Window) => { // a callback function after window minimized
+ log('after minimized');
+ },
+ onMaximize: (wnd: JQueryWindow.Window) => { // a callback function while window is going to maximize
+ log('maximize');
+ },
+ afterMaximize: (wnd: JQueryWindow.Window) => { // a callback function after window maximized
+ log('after maximized');
+ },
+ onCascade: (wnd: JQueryWindow.Window) => { // a callback function while window is going to cascade
+ log('cascade');
+ },
+ afterCascade: (wnd: JQueryWindow.Window) => { // a callback function after window cascaded
+ log('after cascaded');
+ }
+ });
+}
\ No newline at end of file
diff --git a/jquery.window/jquery.window.d.ts b/jquery.window/jquery.window.d.ts
new file mode 100644
index 000000000..8fb4bbc81
--- /dev/null
+++ b/jquery.window/jquery.window.d.ts
@@ -0,0 +1,460 @@
+// Type definitions for Window plugin for jQuery 5.0.4
+// Project: http://fstoke.me/jquery/window/
+// Definitions by: Ryan Graham
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module JQueryWindow {
+ // Instance methods
+ interface Window {
+ /**
+ get window id
+ **/
+ getWindowId(): string;
+ /**
+ get window container's parent panel, it's a jQuery object
+ **/
+ getCaller(): JQuery;
+ /**
+ get window container panel, it's a jQuery object
+ **/
+ getContainer(): JQuery;
+ /**
+ get window header panel, it's a jQuery object
+ **/
+ getHeader(): JQuery;
+ /**
+ get window frame panel, it's a jQuery object
+ **/
+ getFrame(): JQuery;
+ /**
+ get window footer panel, it's a jQuery object
+ **/
+ getFooter(): JQuery;
+ /**
+ set current window as screen center
+ **/
+ alignCenter(): void;
+ /**
+ set current window as horizontal center
+ **/
+ alignHorizontalCenter(): void;
+ /**
+ set current window as vertical center
+ **/
+ alignVerticalCenter(): void;
+ /**
+ select current window, it will increase the original z-index value with 2
+ **/
+ select(): void;
+ /**
+ unselect current window, it will set the z-index as original options.z
+ **/
+ unselect(): void;
+ /**
+ move current window to target position or shift it by passed distance
+ **/
+ move(x: number, y: number, bShift: boolean): void;
+ /**
+ resize current window to target width/height
+ **/
+ resize(width: number, height: number): void;
+ /**
+ maximize current window
+ **/
+ maximize(): void;
+ /**
+ minimize current window
+ **/
+ minimize(): void;
+ /**
+ restore current window, it could be maximized or cascade status
+ **/
+ restore(): void;
+ /**
+ close current window
+ **/
+ close(quiet: boolean): void;
+ /**
+ hide current window
+ **/
+ hide(): void;
+ /**
+ show current window
+ **/
+ show(): void;
+ /**
+ change window title
+ **/
+ setTitle(title: string): void;
+ /**
+ change iframe url
+ **/
+ setUrl(url: string): void;
+ /**
+ change frame content
+ **/
+ setContent(content: string|JQuery|HTMLElement): void;
+ /**
+ change footer content
+ **/
+ setFooterContent(content: string|JQuery|HTMLElement): void;
+ /**
+ get window title text
+ **/
+ getTitle(): string;
+ /**
+ get url string
+ **/
+ getUrl(): string;
+ /**
+ get frame html content
+ **/
+ getContent(): string;
+ /**
+ get footer html content
+ **/
+ getFooterContent(): string;
+ /**
+ get window maximized status
+ **/
+ isMaximized(): boolean;
+ /**
+ get window minmized status
+ **/
+ isMinimized(): boolean;
+ /**
+ get window selected status
+ **/
+ isSelected(): boolean;
+ /**
+ set window icon
+ **/
+ setIcon(iconUrl: string): void;
+ /**
+ show window icon
+ **/
+ showIcon(): void;
+ /**
+ hide window icon
+ **/
+ hideIcon(): void;
+ }
+
+ // Static methods
+ interface Static {
+ (options: WindowOptions): JQueryWindow.Window;
+ /**
+ initialize with customerized static setting attributes
+ **/
+ prepare(options?: StaticOptions): void;
+ /**
+ close all created windows
+ **/
+ closeAll(quiet?: boolean): void;
+ /**
+ hide all created windows
+ **/
+ hideAll(): void;
+ /**
+ show all created windows
+ **/
+ showAll(): void;
+ /**
+ return all created windows instance
+ **/
+ getAll(): Array;
+ /**
+ get the window instance by passed window id
+ **/
+ getWindow(windowId: string): JQueryWindow.Window;
+ /**
+ get the selected window instance
+ **/
+ getSelectedWindow(): JQueryWindow.Window;
+ }
+
+ // Static options
+ interface StaticOptions {
+ /**
+ the direction of minimized window dock at. the available values are [left, right, top, bottom]
+ **/
+ dock?: string;
+ /**
+ the area which the windows will dock at
+ **/
+ dockArea?: JQuery|HTMLElement;
+ /**
+ the speed of animations: maximize, minimize, restore, shift, in milliseconds
+ **/
+ animationSpeed?: number;
+ /**
+ the narrow dimension of minimized window
+ **/
+ minWinNarrow?: number;
+ /**
+ the long dimension of minimized window
+ **/
+ minWinLong?: number;
+ /**
+ to handle browser scrollbar when window status changed(maximize, minimize, cascade)
+ **/
+ handleScrollbar?: boolean;
+ /**
+ to decide show log in firebug, IE8, chrome console
+ **/
+ showLog?: boolean;
+ }
+
+ // Instance options
+ interface WindowOptions {
+ /**
+ an icon image url string. if this attribute is given, it will force to replace the original favicon of remote page on window. or you can set it as null to hide icon.
+ **/
+ icon?: string;
+ /**
+ the title text of window
+ **/
+ title: string;
+ /**
+ the target url of iframe ready to load.
+ **/
+ url?: string;
+ /**
+ this attribute only works when url is null. when passing a jquery object or a element, it will clone the original one to append.
+ **/
+ content?: string|JQuery|HTMLElement;
+ /**
+ same as content attribute, but it's put on footer panel.
+ **/
+ footerContent?: string|JQuery|HTMLElement;
+ /**
+ container extra class
+ **/
+ containerClass?: string;
+ /**
+ header extra class
+ **/
+ headerClass?: string;
+ /**
+ frame extra class
+ **/
+ frameClass?: string;
+ /**
+ footer extra class
+ **/
+ footerClass?: string;
+ /**
+ selected header extra class
+ **/
+ selectedHeaderClass?: string;
+ /**
+ the x-axis value on screen(or caller element), if -1 means put on screen(or caller element) center
+ **/
+ x?: number;
+ /**
+ the y-axis value on screen(or caller element), if -1 means put on screen(or caller element) center
+ **/
+ y?: number;
+ /**
+ the css z-index value
+ **/
+ z?: number;
+ /**
+ window width
+ **/
+ width?: number;
+ /**
+ window height
+ **/
+ height?: number;
+ /**
+ the minimum width, if -1 means no checking
+ **/
+ minWidth?: number;
+ /**
+ the minimum height, if -1 means no checking
+ **/
+ minHeight?: number;
+ /**
+ the maximum width, if -1 means no checking
+ **/
+ maxWidth?: number;
+ /**
+ the maximum height, if -1 means no checking
+ **/
+ maxHeight?: number;
+ /**
+ to control show modal on background
+ **/
+ showModal?: boolean;
+ /**
+ the opacity of modal dialog
+ **/
+ modalOpacity?: number;
+ /**
+ to control show footer panel
+ **/
+ showFooter?: boolean;
+ /**
+ to control display window as round corner
+ **/
+ showRoundCorner?: boolean;
+ /**
+ to control window closable
+ **/
+ closable?: boolean;
+ /**
+ to control window minimizable
+ **/
+ minimizable?: boolean;
+ /**
+ to control window maximizable
+ **/
+ maximizable?: boolean;
+ /**
+ to control window with remote url could be bookmarked
+ **/
+ bookmarkable?: boolean;
+ /**
+ to control window draggable
+ **/
+ draggable?: boolean;
+ /**
+ to control window resizable
+ **/
+ resizable?: boolean;
+ /**
+ to show scroll bar or not
+ **/
+ scrollable?: boolean;
+ /**
+ to check window dialog overflow html body or caller element
+ **/
+ checkBoundary?: boolean;
+ /**
+ to limit window only can be dragged within browser window. this attribute only works when checkBoundary is true and caller is null.
+ **/
+ withinBrowserWindow?: boolean;
+ /**
+ to describe the customized button display and callback function
+ **/
+ custBtns?: Array;
+ /**
+ a callback function while container is added into body
+ **/
+ onOpen?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while whole window display routine is finished
+ **/
+ onShow?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while user click close button
+ **/
+ onClose?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while user select the window
+ **/
+ onSelect?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while window unselected
+ **/
+ onUnselect?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while window is going to drag
+ **/
+ onDrag?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function after window dragged
+ **/
+ afterDrag?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while window is going to resize
+ **/
+ onResize?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function after window resized
+ **/
+ afterResize?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while window is going to minimize
+ **/
+ onMinimize?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function after window minimized
+ **/
+ afterMinimize?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while window is going to maximize
+ **/
+ onMaximize?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function after window maximized
+ **/
+ afterMaximize?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while window is going to cascade
+ **/
+ onCascade?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function after window cascaded
+ **/
+ afterCascade?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while iframe ready to connect remoting url. this attribute only works while url attribute is given
+ **/
+ onIframeStart?: (wnd: JQueryWindow.Window) => void;
+ /**
+ a callback function while iframe load finished. this attribute only works while url attribute is given
+ **/
+ onIframeEnd?: (wnd: JQueryWindow.Window) => void;
+ /**
+ if null means no check, or pass a string to show warning message while iframe is going to redirect current top page
+ **/
+ iframeRedirectCheckMsg?: string;
+ /**
+ random the new created window position, it only works when options x,y value both are -1
+ **/
+ createRandomOffset?: { x: number; y: number };
+ }
+
+ // Button definition
+ interface Button {
+ /**
+
+ **/
+ id: string;
+ /**
+
+ **/
+ title?: string;
+ /**
+
+ **/
+ clazz?: string;
+ /**
+
+ **/
+ style?: string;
+ /**
+
+ **/
+ image: string;
+ /**
+
+ **/
+ callback: (btn: JQueryWindow.Button, wnd: JQueryWindow.Window) => void;
+ }
+
+}
+
+// Register with JQuery instance
+interface JQuery {
+ window(options: JQueryWindow.WindowOptions): JQueryWindow.Window;
+}
+
+// Register with JQuery static
+interface JQueryStatic {
+ window: JQueryWindow.Static;
+}
\ No newline at end of file
diff --git a/meteor/README.md b/meteor/README.md
index ae8178f2c..8f93e1816 100644
--- a/meteor/README.md
+++ b/meteor/README.md
@@ -1,6 +1,6 @@
# Meteor Type Definitions
-These are the definitions for version 1.0.3.1 of Meteor.
+These are the definitions for version 1.1.0.1 of Meteor.
Although these definitions can be downloaded separately for use, the recommended way to use these definitions in a Meteor application is by installing the
[typescript-libs](https://atmospherejs.com/meteortypescript/typescript-libs) Meteor smart package from atmosphere. The smart package contains TypeScript
@@ -16,25 +16,21 @@ to generate the official [Meteor docs] (http://docs.meteor.com/).
## Usage
-1. If you are using the smart package, add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The
-definitions can be found somewhere deep within `/.meteor/...`. The following will probably work:
+1. Add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The definitions can be found somewhere
+deep within `/.meteor/...`. The following will probably work:
$ ln -s ../.meteor/local/build/programs/server/assets/packages/meteortypescript_typescript-libs/definitions package_defs
-
If the definitions can't be found within the .meteor directory, you will have to manually pull down the definitions from github and add them to your project:
- If you are just using the *meteor.d.ts* file from this source, you can just add the file to any directory in your project (e.g. ".typescript" or "lib").
-
2. Install the [Typescript compiler for Meteor](https://github.com/meteor-typescript/meteor-typescript-compiler) or an [IDE which can transpile TypeScript to JavaScript](#transpiling-typescript).
3. From the typescript files, add references. Reference the definition files with a single line:
/// (substitute path in your project)
-
Or you can reference definition files individually:
-
+
/// (substitue path in your project)
///
///
@@ -46,26 +42,28 @@ definitions can be found somewhere deep within `/.meteor/...`.
### References
-Try to stay away from referencing *file.ts*, rather generate a *file.d.ts* using `tsc --reference file.ts`, and reference it in your file. Compilation will
-be much faster and code cleaner - it's always better to split definition from implemention.
+Meteor code can run on the client and the server, for this reason you should try to stay away from referencing *file.ts* directly: you may get unexpected results.
+Rather generate a *file.d.ts* using `tsc --reference file.ts`, and reference it in your file.
+
+Compilation will be much faster and code cleaner - it's always better to split definition from implementation anyways.
### Templates
-When specifying template *helpers*, *events*, and functions for *created*, *rendered*, and *destroyed*, you will need to use a "bracket notation" instead of the "dot notation":
+With the exception of the **body** and **head** templates, Meteor's Template dot notation cannot be used (ie. *Template.mytemplate*). Thanks to Typescript static typing checks, you will need to used the *bracket notation* to access the Template.
- Template['myTemplateName']['helpers']({
+
+ Template['myTemplateName'].helpers({
foo: function () {
return Session.get("foo");
}
});
- Template['myTemplateName']['rendered'] = function ( ) { ... }
+ Template['myTemplateName'].rendered = function ( ) { ... }
+
-This is because TypeScript enforces typing and it will throw an error saying "myTemplateName" does not exist when using the dot notation.
+### Form fields
-### Accessing a Form field
-
-Trying to read a form field value? use `(evt.target).value`.
+Form fields typically need to be casted to . For instance to read a form field value, use `(evt.target).value`.
### Global variables
@@ -77,7 +75,7 @@ Preface any global variable declarations with a TypeScript "declare var" stateme
### Collections
-The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the
+The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the
additional benefit of succinctly documenting collection schema definitions (that are actually enforced).
To define collections, you will need to create an interface representing the collection and then declare a Collection type variable with that interface type (as a generic):
@@ -113,7 +111,7 @@ for all of you custom definitions. e.g. contents of ".typescript/custom_defs/cu
///
///
///
-
+
## Transpiling TypeScript
@@ -132,4 +130,4 @@ Then, within WebStorm, go to Preferences -> File Watchers -> "+" symbol and add
Last option, is to compile code from the command line. With node and the typescript compiler installed:
- $ tsc *.ts
\ No newline at end of file
+ $ tsc *.ts
diff --git a/meteor/meteor-tests.ts b/meteor/meteor-tests.ts
index e4c5b9066..ec2ad3b81 100644
--- a/meteor/meteor-tests.ts
+++ b/meteor/meteor-tests.ts
@@ -8,21 +8,15 @@
/*********************************** Begin setup for tests ******************************/
-
-// A developer must declare a var Template like this in a separate file to use this TypeScript type definition file
-//interface ITemplate {
-// adminDashboard: Meteor.Template;
-// chat: Meteor.Template;
-//}
-//declare var Template: ITemplate;
-
var Rooms = new Mongo.Collection('rooms');
var Messages = new Mongo.Collection('messages');
-var Monkeys = new Mongo.Collection('monkeys');
-var x = new Mongo.Collection('x');
-var y = new Mongo.Collection('y');
-
-var check = function(str1, str2) {};
+interface MonkeyDAO {
+ _id: string;
+ name: string;
+}
+var Monkeys = new Mongo.Collection('monkeys');
+//var x = new Mongo.Collection('x');
+//var y = new Mongo.Collection('y');
/********************************** End setup for tests *********************************/
@@ -98,8 +92,8 @@ Tracker.autorun(function () {
});
console.log("Current room has " +
- Counts.find(Session.get("roomId")).count +
- " messages.");
+Counts.find(Session.get("roomId")).count +
+" messages.");
/**
* From Publish and Subscribe, Meteor.subscribe section
@@ -124,7 +118,7 @@ Meteor.methods({
var you_want_to_throw_an_error = true;
if (you_want_to_throw_an_error)
- throw new Meteor.Error("404", "Can't find my pants");
+ throw new Meteor.Error("404", "Can't find my pants");
return "some return value";
},
@@ -146,15 +140,15 @@ var result = Meteor.call('foo', 1, 2);
// DA: I added the "var" keyword in there
interface ChatroomsDAO {
- _id?: string;
+ _id?: string;
}
interface MessagesDAO {
- _id?: string;
+ _id?: string;
}
var Chatrooms = new Mongo.Collection("chatrooms");
Messages = new Mongo.Collection("messages");
-var myMessages = Messages.find({userId: Session.get('myUserId')}).fetch();
+var myMessages = Messages.find({userId: Session.get('myUserId')}).fetch();
Messages.insert({text: "Hello, world!"});
@@ -171,10 +165,10 @@ Posts.insert({title: "Hello world", body: "First post"});
* since there is already a Collection constructor with a different signature
*
var Scratchpad = new Mongo.Collection;
-for (var i = 0; i < 10; i++)
- Scratchpad.insert({number: i * 2});
-assert(Scratchpad.find({number: {$lt: 9}}).count() === 5);
-**/
+ for (var i = 0; i < 10; i++)
+ Scratchpad.insert({number: i * 2});
+ assert(Scratchpad.find({number: {$lt: 9}}).count() === 5);
+ **/
var Animal = function (doc) {
// _.extend(this, doc);
@@ -185,11 +179,16 @@ Animal.prototype = {
makeNoise: function () {
console.log(this.sound);
}
+};
+
+
+interface AnimalDAO {
+ _id: string;
+ makeNoise: () => void;
}
-
// Define a Collection that uses Animal as its document
-var Animals = new Mongo.Collection("Animals", {
+var Animals = new Mongo.Collection("Animals", {
transform: function (doc) { return new Animal(doc); }
});
@@ -225,8 +224,8 @@ Template['adminDashboard'].events({
Meteor.methods({
declareWinners: function () {
Players.update({score: {$gt: 10}},
- {$addToSet: {badges: "Winner"}},
- {multi: true});
+ {$addToSet: {badges: "Winner"}},
+ {multi: true});
}
});
@@ -348,7 +347,7 @@ Session.equals("key", value);
*/
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
- {fields: {'other': 1, 'things': 1}});
+ {fields: {'other': 1, 'things': 1}});
});
Meteor.users.deny({update: function () { return true; }});
@@ -412,8 +411,8 @@ Accounts.emailTemplates.enrollAccount.subject = function (user) {
};
Accounts.emailTemplates.enrollAccount.text = function (user, url) {
return "You have been selected to participate in building a better future!"
- + " To activate your account, simply click the link below:\n\n"
- + url;
+ + " To activate your account, simply click the link below:\n\n"
+ + url;
};
/**
@@ -424,6 +423,36 @@ Template['adminDashboard'].helpers({
return Session.get("foo");
}
});
+Template['newTemplate'].helpers({
+ helperName: function () {
+ }
+});
+
+Template['newTemplate'].created = function () {
+
+};
+
+Template['newTemplate'].rendered = function () {
+
+};
+
+Template['newTemplate'].destroyed = function () {
+
+};
+
+Template['newTemplate'].events({
+ 'click .something': function (event) {
+ }
+});
+
+Template.registerHelper('testHelper', function() {
+ return 'tester';
+});
+
+var instance = Template.instance();
+var data = Template.currentData();
+var data = Template.parentData(1);
+var body = Template.body;
/**
* From Match section
@@ -481,10 +510,9 @@ Tracker.autorun(function (c) {
* From Deps, Deps.Computation
*/
if (Tracker.active) {
- Tracker.onInvalidate(function () {
- x.destroy();
- y.finalize();
- });
+ Tracker.onInvalidate(function () {
+ console.log('invalidated');
+ });
}
/**
@@ -494,15 +522,15 @@ var weather = "sunny";
var weatherDep = new Tracker.Dependency;
var getWeather = function () {
- weatherDep.depend();
- return weather;
+ weatherDep.depend();
+ return weather;
};
var setWeather = function (w) {
- weather = w;
- // (could add logic here to only call changed()
- // if the new value is different from the old)
- weatherDep.changed();
+ weather = w;
+ // (could add logic here to only call changed()
+ // if the new value is different from the old)
+ weatherDep.changed();
};
/**
@@ -512,7 +540,7 @@ Meteor.methods({checkTwitter: function (userId) {
check(userId, String);
this.unblock();
var result = HTTP.call("GET", "http://api.twitter.com/xyz",
- {params: {user: userId}});
+ {params: {user: userId}});
if (result.statusCode === 200)
return true
return false;
@@ -520,12 +548,12 @@ Meteor.methods({checkTwitter: function (userId) {
HTTP.call("POST", "http://api.twitter.com/xyz",
- {data: {some: "json", stuff: 1}},
- function (error, result) {
- if (result.statusCode === 200) {
- Session.set("twizzled", true);
- }
- });
+ {data: {some: "json", stuff: 1}},
+ function (error, result) {
+ if (result.statusCode === 200) {
+ Session.set("twizzled", true);
+ }
+ });
/**
* From Email, Email.send section
@@ -542,9 +570,9 @@ Meteor.methods({
// In your client code: asynchronously send an email
Meteor.call('sendEmail',
- 'alice@example.com',
- 'Hello from Meteor!',
- 'This is a test of Email.send.');
+ 'alice@example.com',
+ 'Hello from Meteor!',
+ 'This is a test of Email.send.');
var testTemplate = new Blaze.Template();
var testView = new Blaze.View();
@@ -562,8 +590,8 @@ Blaze.toHTMLWithData(testTemplate, function() {});
Blaze.toHTMLWithData(testView, {test: 1});
Blaze.toHTMLWithData(testView, function() {});
-var reactiveVar1 = new ReactiveVar('test value');
-var reactiveVar2 = new ReactiveVar('test value', function(oldVal) { return true; });
+var reactiveVar1 = new ReactiveVar('test value');
+var reactiveVar2 = new ReactiveVar('test value', function(oldVal) { return true; });
var varValue: string = reactiveVar1.get();
reactiveVar1.set('new value');
\ No newline at end of file
diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts
index e64547096..4118fbe06 100644
--- a/meteor/meteor.d.ts
+++ b/meteor/meteor.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Meteor 1.0.3.1
+// Type definitions for Meteor 1.1.0.1
// Project: http://www.meteor.com/
// Definitions by: Dave Allen
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -7,344 +7,419 @@
* These are the modules and interfaces that can't be automatically generated from the Meteor data.js file
*/
-interface EJSON extends JSON {}
-interface TemplateStatic {
- new(): Template;
- [templateName: string]: Meteor.TemplatePage;
+interface EJSONable {
+ [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSON.CustomType;
}
+interface JSONable {
+ [key: string]: number | string | boolean | Object | number[] | string[] | Object[];
+}
+interface EJSON extends EJSONable {}
declare module Match {
- var Any;
- var String;
- var Integer;
- var Boolean;
- var undefined;
- //function null(); // not allowed in TypeScript
- var Object;
- function Optional(pattern):boolean;
- function ObjectIncluding(dico):boolean;
- function OneOf(...patterns);
- function Where(condition);
+ var Any;
+ var String;
+ var Integer;
+ var Boolean;
+ var undefined;
+ //function null(); // not allowed in TypeScript
+ var Object;
+ function Optional(pattern):boolean;
+ function ObjectIncluding(dico):boolean;
+ function OneOf(...patterns);
+ function Where(condition);
}
declare module Meteor {
- //interface EJSONObject extends Object {}
+ /** Start definitions for Template **/
+ interface Event {
+ type:string;
+ target:HTMLElement;
+ currentTarget:HTMLElement;
+ which: number;
+ stopPropagation():void;
+ stopImmediatePropagation():void;
+ preventDefault():void;
+ isPropagationStopped():boolean;
+ isImmediatePropagationStopped():boolean;
+ isDefaultPrevented():boolean;
+ }
- /** Start definitions for Template **/
- // DA: "Template" needs to support these functions:
- // Template..rendered
- // Template..created
- // Template..destroyed
- // Template..helpers
- // Template..events
- // and
- // Template.currentData
- // Template.parentData, etc.
+ interface EventHandlerFunction extends Function {
+ (event?:Meteor.Event):void;
+ }
- interface Event {
- type:string;
- target:HTMLElement;
- currentTarget:HTMLElement;
- which: number;
- stopPropagation():void;
- stopImmediatePropagation():void;
- preventDefault():void;
- isPropagationStopped():boolean;
- isImmediatePropagationStopped():boolean;
- isDefaultPrevented():boolean;
- }
+ interface EventMap {
+ [id:string]:Meteor.EventHandlerFunction;
+ }
+ /** End definitions for Template **/
- interface EventHandlerFunction extends Function {
- (event?:Meteor.Event):any;
- }
+ interface LoginWithExternalServiceOptions {
+ requestPermissions?: string[];
+ requestOfflineToken?: Boolean;
+ forceApprovalPrompt?: Boolean;
+ userEmail?: string;
+ loginStyle?: string;
+ }
- interface EventMap {
- [id:string]:Meteor.EventHandlerFunction;
- }
+ function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- interface TemplatePage {
- rendered: Function;
- created: Function;
- destroyed: Function;
- events(eventMap:Meteor.EventMap): void;
- helpers(helpers:{[id:string]: any}): void;
- }
- /** End definitions for Template **/
+ interface UserEmail {
+ address:string;
+ verified:boolean;
+ }
- interface LoginWithExternalServiceOptions {
- requestPermissions?: string[];
- requestOfflineToken?: Boolean;
- forceApprovalPrompt?: Boolean;
- userEmail?: string;
- loginStyle?: string;
- }
+ interface User {
+ _id?:string;
+ username?:string;
+ emails?:Meteor.UserEmail[];
+ createdAt?: number;
+ profile?: any;
+ services?: any;
+ }
- function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
- function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
+ interface SubscriptionHandle {
+ stop(): void;
+ ready(): boolean;
+ }
- interface UserEmail {
- address:string;
- verified:boolean;
- }
+ interface Tinytest {
+ add(name:string, func:Function);
+ addAsync(name:string, func:Function);
+ }
- interface User {
- _id?:string;
- username?:string;
- emails?:Meteor.UserEmail[];
- createdAt?: number;
- profile?: any;
- services?: any;
- }
+ enum StatusEnum {
+ connected,
+ connecting,
+ failed,
+ waiting,
+ offline
+ }
- interface SubscriptionHandle {
- stop(): void;
- ready(): boolean;
- }
+ interface LiveQueryHandle {
+ stop(): void;
+ }
- interface Tinytest {
- add(name:string, func:Function);
- addAsync(name:string, func:Function);
- }
+ interface EmailFields {
+ subject?: Function;
+ text?: Function;
+ }
- enum StatusEnum {
- connected,
- connecting,
- failed,
- waiting,
- offline
- }
+ interface EmailTemplates {
+ from: string;
+ siteName: string;
+ resetPassword: Meteor.EmailFields;
+ enrollAccount: Meteor.EmailFields;
+ verifyEmail: Meteor.EmailFields;
+ }
- interface LiveQueryHandle {
- stop(): void;
- }
+ interface Error {
+ error: number;
+ reason?: string;
+ details?: string;
+ }
- interface EmailFields {
- subject?: Function;
- text?: Function;
- }
-
- interface EmailTemplates {
- from: string;
- siteName: string;
- resetPassword: Meteor.EmailFields;
- enrollAccount: Meteor.EmailFields;
- verifyEmail: Meteor.EmailFields;
- }
-
- interface Error {
- error: number;
- reason?: string;
- details?: string;
- }
-
- interface Connection {
- id: string;
- close: Function;
- onClose: Function;
- clientAddress: string;
- httpHeaders: Object;
- }
+ interface Connection {
+ id: string;
+ close: Function;
+ onClose: Function;
+ clientAddress: string;
+ httpHeaders: Object;
+ }
}
declare module Mongo {
- interface Selector extends Object {}
- interface Modifier {}
- interface SortSpecifier {}
- interface FieldSpecifier {
- [id: string]: Number;
- }
- enum IdGenerationEnum {
- STRING,
- MONGO
- }
- interface AllowDenyOptions {
- insert?: (userId:string, doc) => boolean;
- update?: (userId, doc, fieldNames, modifier) => boolean;
- remove?: (userId, doc) => boolean;
- fetch?: string[];
- transform?: Function;
- }
+ interface Selector extends Object {}
+ interface Modifier {}
+ interface SortSpecifier {}
+ interface FieldSpecifier {
+ [id: string]: Number;
+ }
+ enum IdGenerationEnum {
+ STRING,
+ MONGO
+ }
+ interface AllowDenyOptions {
+ insert?: (userId:string, doc) => boolean;
+ update?: (userId, doc, fieldNames, modifier) => boolean;
+ remove?: (userId, doc) => boolean;
+ fetch?: string[];
+ transform?: Function;
+ }
}
declare module HTTP {
- interface HTTPRequest {
- content?:string;
- data?:any;
- query?:string;
- params?:{[id:string]:string};
- auth?:string;
- headers?:{[id:string]:string};
- timeout?:number;
- followRedirects?:boolean;
- }
- interface HTTPResponse {
- statusCode:number;
- content:string;
- // response is not always json
- data:any;
- headers:{[id:string]:string};
- }
+ interface HTTPRequest {
+ content?:string;
+ data?:any;
+ query?:string;
+ params?:{[id:string]:string};
+ auth?:string;
+ headers?:{[id:string]:string};
+ timeout?:number;
+ followRedirects?:boolean;
+ }
+
+ interface HTTPResponse {
+ statusCode?:number;
+ headers?:{[id:string]: string};
+ content?:string;
+ data?:any;
+ }
+
+ function call(method: string, url: string, options?: HTTP.HTTPRequest, asyncCallback?:Function):HTTP.HTTPResponse;
+ function del(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
+ function get(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
+ function post(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
+ function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
+
}
declare module Email {
- interface EmailMessage {
- from: string;
- to: any; // string or string[]
- cc?: any; // string or string[]
- bcc?: any; // string or string[]
- replyTo?: any; // string or string[]
- subject: string;
- text?: string;
- html?: string;
- headers?: {[id: string]: string};
- }
+ interface EmailMessage {
+ from: string;
+ to: any; // string or string[]
+ cc?: any; // string or string[]
+ bcc?: any; // string or string[]
+ replyTo?: any; // string or string[]
+ subject: string;
+ text?: string;
+ html?: string;
+ headers?: {[id: string]: string};
+ }
}
declare module DDP {
- interface DDPStatic {
- subscribe(name, ...rest);
- call(method:string, ...parameters):void;
- apply(method:string, ...parameters):void;
- methods(IMeteorMethodsDictionary);
- status():DDPStatus;
- reconnect();
- disconnect();
- onReconnect();
- }
+ interface DDPStatic {
+ subscribe(name, ...rest);
+ call(method:string, ...parameters):void;
+ apply(method:string, ...parameters):void;
+ methods(IMeteorMethodsDictionary);
+ status():DDPStatus;
+ reconnect();
+ disconnect();
+ onReconnect();
+ }
- interface DDPStatus {
- connected: boolean;
- status: Meteor.StatusEnum;
- retryCount: number;
- //To turn this into an interval until the next reconnection, use retryTime - (new Date()).getTime()
- retryTime?: number;
- reason?: string;
- }
+ interface DDPStatus {
+ connected: boolean;
+ status: Meteor.StatusEnum;
+ retryCount: number;
+ //To turn this into an interval until the next reconnection, use retryTime - (new Date()).getTime()
+ retryTime?: number;
+ reason?: string;
+ }
}
declare module Random {
- function id(numberOfChars?: number): string;
- function secret(numberOfChars?: number): string;
- function fraction():number;
- function hexString(numberOfDigits:number):string; // @param numberOfDigits, @returns a random hex string of the given length
- function choice(array:any[]):string; // @param array, @return a random element in array
- function choice(str:string):string; // @param str, @return a random char in str
+ function id(numberOfChars?: number): string;
+ function secret(numberOfChars?: number): string;
+ function fraction():number;
+ function hexString(numberOfDigits:number):string; // @param numberOfDigits, @returns a random hex string of the given length
+ function choice(array:any[]):string; // @param array, @return a random element in array
+ function choice(str:string):string; // @param str, @return a random char in str
}
declare module Blaze {
- interface View {
- name: string;
- parentView: Blaze.View;
- isCreated: boolean;
- isRendered: boolean;
- isDestroyed: boolean;
- renderCount: number;
- autorun(runFunc: Function): void;
- onViewCreated(func: Function): void;
- onViewReady(func: Function): void;
- onViewDestroyed(func: Function): void;
- firstNode(): Node;
- lastNode(): Node;
- template: Blaze.Template;
- templateInstance(): any;
- }
- interface Template {
- viewName: string;
- renderFunction: Function;
- constructView(): Blaze.View;
- }
+ interface View {
+ name: string;
+ parentView: Blaze.View;
+ isCreated: boolean;
+ isRendered: boolean;
+ isDestroyed: boolean;
+ renderCount: number;
+ autorun(runFunc: Function): void;
+ onViewCreated(func: Function): void;
+ onViewReady(func: Function): void;
+ onViewDestroyed(func: Function): void;
+ firstNode(): Node;
+ lastNode(): Node;
+ template: Blaze.Template;
+ templateInstance(): any;
+ }
+ interface Template {
+ viewName: string;
+ renderFunction: Function;
+ constructView(): Blaze.View;
+ }
}
+declare module BrowserPolicy {
+
+ interface framing {
+ disallow():void;
+ restrictToOrigin(origin:string):void;
+ allowAll():void;
+ }
+ interface content {
+ allowEval():void;
+ allowInlineStyles():void;
+ allowInlineScripts():void;
+ allowSameOriginForAll():void;
+ allowDataUrlForAll():void;
+ allowOriginForAll(origin:string):void;
+ allowImageOrigin(origin:string):void;
+ allowFrameOrigin(origin:string):void;
+ allowContentTypeSniffing():void;
+ allowAllContentOrigin():void;
+ allowAllContentDataUrl():void;
+ allowAllContentSameOrigin():void;
+
+ disallowAll():void;
+ disallowInlineStyles():void;
+ disallowEval():void;
+ disallowInlineScripts():void;
+ disallowFont():void;
+ disallowObject():void;
+ disallowAllContent():void;
+ //TODO: add the basic content types
+ // allowOrigin(origin)
+ // allowDataUrl()
+ // allowSameOrigin()
+ // disallow()
+ }
+}
+
+declare module Tracker {
+ export var ComputationFunction: (computation: Tracker.Computation) => void;
+
+}
+
+declare var IterationCallback: (doc: T, index: number, cursor: Mongo.Cursor) => void;
+
/**
* These modules and interfaces are automatically generated from the Meteor api.js file
*/
declare module Accounts {
- var ui: {
- config(options: {
- requestPermissions?: Object;
- requestOfflineToken?: Object;
- forceApprovalPrompt?: Object;
- passwordSignupFields?: string;
- }): void;
- };
- var emailTemplates: Meteor.EmailTemplates;
+ function changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
function config(options: {
- sendVerificationEmail?: boolean;
- forbidClientAccountCreation?: Boolean;
- restrictCreationByEmailDomain?: string | Function;
- loginExpirationInDays?: number;
- oauthSecretKey?: string;
- }): void;
- function validateLoginAttempt(func: Function): {stop: Function};
- function onLogin(func: Function): {stop: Function};
- function onLoginFailure(func: Function): {stop: Function};
+ sendVerificationEmail?: boolean;
+ forbidClientAccountCreation?: boolean;
+ restrictCreationByEmailDomain?: string | Function;
+ loginExpirationInDays?: number;
+ oauthSecretKey?: string;
+ }): void;
+ function createUser(options: {
+ username?: string;
+ email?: string;
+ password?: string;
+ profile?: Object;
+ }, callback?: Function): string;
+ var emailTemplates: Meteor.EmailTemplates;
+ function forgotPassword(options: {
+ email?: string;
+ }, callback?: Function): void;
function onCreateUser(func: Function): void;
- function validateNewUser(func: Function): void;
- function onResetPasswordLink(callback: Function): void;
function onEmailVerificationLink(callback: Function): void;
function onEnrollmentLink(callback: Function): void;
- function createUser(options: {
- username?: string;
- email?: string;
- password?: string;
- profile?: Object;
- }, callback?: Function): string;
- function changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
- function forgotPassword(options: {
- email?: string;
- }, callback?: Function): void;
+ function onLogin(func: Function): {stop: Function};
+ function onLoginFailure(func: Function): {stop: Function};
+ function onResetPasswordLink(callback: Function): void;
function resetPassword(token: string, newPassword: string, callback?: Function): void;
- function verifyEmail(token: string, callback?: Function): void;
- function setPassword(userId: string, newPassword: string): void;
- function sendResetPasswordEmail(userId: string, email?: string): void;
function sendEnrollmentEmail(userId: string, email?: string): void;
+ function sendResetPasswordEmail(userId: string, email?: string): void;
function sendVerificationEmail(userId: string, email?: string): void;
+ function setPassword(userId: string, newPassword: string, options?: {
+ logout?: Object;
+ }): void;
+ var ui: {
+ config(options: {
+ requestPermissions?: Object;
+ requestOfflineToken?: Object;
+ forceApprovalPrompt?: Object;
+ passwordSignupFields?: string;
+ }): void;
+ };
+ function validateLoginAttempt(func: Function): {stop: Function};
+ function validateNewUser(func: Function): void;
+ function verifyEmail(token: string, callback?: Function): void;
+}
+
+declare module App {
+ function accessRule(domainRule: string, options?: {
+ launchExternal?: boolean;
+ }); /** TODO: add return value **/
+function configurePlugin(pluginName: string, config: Object): void;
+ function icons(icons: Object): void;
+ function info(options: {
+ id?: string;
+ version?: string;
+ name?: string;
+ description?: string;
+ author?: string;
+ email?: string;
+ website?: string;
+ }): void;
+ function launchScreens(launchScreens: Object): void;
+ function setPreference(name: string, value: string): void;
+}
+
+declare module Assets {
+ function getBinary(assetPath: string, asyncCallback?: Function): EJSON;
+ function getText(assetPath: string, asyncCallback?: Function): string;
}
declare module Blaze {
- var currentView: Blaze.View;
- function With(data: Object | Function, contentFunc: Function): Blaze.View;
- function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
- function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
- function isTemplate(value: any): boolean;
- function render(templateOrView: Template | Blaze.View, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View;
- function renderWithData(templateOrView: Template | Blaze.View, data: Object | Function, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View;
- function remove(renderedView: Blaze.View): void;
- function toHTML(templateOrView: Template | Blaze.View): string;
- function toHTMLWithData(templateOrView: Template | Blaze.View, data: Object | Function): string;
- function getData(elementOrView?: HTMLElement | Blaze.View): Object;
- function getView(element?: HTMLElement): Blaze.View;
- function Template(viewName?: string, renderFunction?: Function): void;
- interface Template{
+ function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
+ var Template: TemplateStatic;
+ interface TemplateStatic {
+ new(viewName?: string, renderFunction?: Function): Template;
+ // It should be [templateName: string]: TemplateInstance but this is not possible -- user will need to cast to TemplateInstance
+ [templateName: string]: any | Template; // added "any" to make it work
+ head: Template;
+ find(selector:string):Blaze.Template;
+ findAll(selector:string):Blaze.Template[];
+ $:any;
+ }
+ interface Template {
}
- function TemplateInstance(view: Blaze.View): void;
- interface TemplateInstance{
+ var TemplateInstance: TemplateInstanceStatic;
+ interface TemplateInstanceStatic {
+ new(view: Blaze.View): TemplateInstance;
+ }
+ interface TemplateInstance {
+ $(selector: string): any;
+ autorun(runFunc: Function): Object;
data: Object;
- view: Object;
+ find(selector?: string): Blaze.TemplateInstance;
+ findAll(selector: string): Blaze.TemplateInstance[];
firstNode: Object;
lastNode: Object;
- $(selector: string): Node[];
- findAll(selector: string): HTMLElement[];
- find(selector?: string): HTMLElement;
- autorun(runFunc: Function): Object;
+ subscribe(name: string, ...args): Meteor.SubscriptionHandle;
+ subscriptionsReady(): boolean;
+ view: Object;
}
- function View(name?: string, renderFunction?: Function): void;
- interface View{
+ function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
+ var View: ViewStatic;
+ interface ViewStatic {
+ new(name?: string, renderFunction?: Function): View;
+ }
+ interface View {
}
+ function With(data: Object | Function, contentFunc: Function): Blaze.View;
+ var currentView: Blaze.View;
+ function getData(elementOrView?: HTMLElement | Blaze.View): Object;
+ function getView(element?: HTMLElement): Blaze.View;
+ function isTemplate(value: any): boolean;
+ function remove(renderedView: Blaze.View): void;
+ function render(templateOrView: Template | Blaze.View, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View;
+ function renderWithData(templateOrView: Template | Blaze.View, data: Object | Function, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View;
+ function toHTML(templateOrView: Template | Blaze.View): string;
+ function toHTMLWithData(templateOrView: Template | Blaze.View, data: Object | Function): string;
}
-declare module Match {
- function test(value: any, pattern: any): boolean;
+declare module Cordova {
+ function depends(dependencies:{[id:string]:string}): void;
}
declare module DDP {
@@ -352,330 +427,355 @@ declare module DDP {
}
declare module EJSON {
- var newBinary: any;
- function addType(name: string, factory: Function): void;
- function toJSONValue(val: EJSON): JSON;
- function fromJSONValue(val: JSON): any;
- function stringify(val: EJSON, options?: {
- indent?: boolean | number | string;
- canonical?: Boolean;
- }): string;
- function parse(str: string): EJSON;
- function isBinary(x: Object): boolean;
- function equals(a: EJSON, b: EJSON, options?: {
- keyOrderSensitive?: boolean;
- }): boolean;
- function clone(val:T): T;
- function CustomType(): void;
- interface CustomType{
- typeName(): string;
- toJSONValue(): JSON;
+ var CustomType: CustomTypeStatic;
+ interface CustomTypeStatic {
+ new(): CustomType;
+ }
+ interface CustomType {
clone(): EJSON.CustomType;
equals(other: Object): boolean;
+ toJSONValue(): JSON;
+ typeName(): string;
}
+ function addType(name: string, factory: (val: EJSONable) => JSONable): void;
+ function clone(val:T): T;
+ function equals(a: EJSON, b: EJSON, options?: {
+ keyOrderSensitive?: boolean;
+ }): boolean;
+ function fromJSONValue(val: JSON): any;
+ function isBinary(x: Object): boolean;
+ var newBinary: any;
+ function parse(str: string): EJSON;
+ function stringify(val: EJSON, options?: {
+ indent?: boolean | number | string;
+ canonical?: boolean;
+ }): string;
+ function toJSONValue(val: EJSON): JSON;
+}
+
+declare module Match {
+ function test(value: any, pattern: any): boolean;
}
declare module Meteor {
- var users: Mongo.Collection;
- var isClient: boolean;
- var isServer: boolean;
- var settings: {[id:string]: any};
- var isCordova: boolean;
- var release: string;
- function userId(): string;
- function loggingIn(): boolean;
- function user(): Meteor.User;
- function logout(callback?: Function): void;
- function logoutOtherClients(callback?: Function): void;
- function loginWith(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: Boolean;
- userEmail?: string;
- loginStyle?: string;
- }, callback?: Function): void;
- function loginWithPassword(user: Object | string, password: string, callback?: Function): void;
- function subscribe(name: string, ...args): SubscriptionHandle;
- function call(name: string, ...args): void;
- function apply(name: string, args: EJSON[], options?: {
- wait?: boolean;
- onResultReceived?: Function;
- }, asyncCallback?: Function): void;
- function status(): Meteor.StatusEnum;
- function reconnect(): void;
- function disconnect(): void;
- function onConnection(callback: Function): void;
- function publish(name: string, func: Function): void;
- function methods(methods: Object): void;
- function wrapAsync(func: Function, context?: Object): any;
- function startup(func: Function): void;
- function setTimeout(func: Function, delay: number): number;
- function setInterval(func: Function, delay: number): number;
- function clearInterval(id: number): void;
- function clearTimeout(id: number): void;
- function absoluteUrl(path?: string, options?: {
- secure?: boolean;
- replaceLocalhost?: Boolean;
- rootUrl?: string;
- }): string;
- function Error(error: string, reason?: string, details?: string): void;
- interface Error{
+ var Error: ErrorStatic;
+ interface ErrorStatic {
+ new(error: string, reason?: string, details?: string): Error;
+ }
+ interface Error {
}
+ function absoluteUrl(path?: string, options?: {
+ secure?: boolean;
+ replaceLocalhost?: boolean;
+ rootUrl?: string;
+ }): string;
+ function apply(name: string, args: EJSONable[], options?: {
+ wait?: boolean;
+ onResultReceived?: Function;
+ }, asyncCallback?: Function): any;
+ function call(name: string, ...args): any;
+ function clearInterval(id: number): void;
+ function clearTimeout(id: number): void;
+ function disconnect(): void;
+ var isClient: boolean;
+ var isCordova: boolean;
+ var isServer: boolean;
+ function loggingIn(): boolean;
+ function loginWith(options?: {
+ requestPermissions?: string[];
+ requestOfflineToken?: boolean;
+ forceApprovalPrompt?: boolean;
+ userEmail?: string;
+ loginStyle?: string;
+ }, callback?: Function): void;
+ function loginWithPassword(user: Object | string, password: string, callback?: Function): void;
+ function logout(callback?: Function): void;
+ function logoutOtherClients(callback?: Function): void;
+ function methods(methods: Object): void;
+ function onConnection(callback: Function): void;
+ function publish(name: string, func: Function): void;
+ function reconnect(): void;
+ var release: string;
+ function setInterval(func: Function, delay: number): number;
+ function setTimeout(func: Function, delay: number): number;
+ var settings: {[id:string]: any};
+ function startup(func: Function): void;
+ function status(): Meteor.StatusEnum;
+ function subscribe(name: string, ...args): Meteor.SubscriptionHandle;
+ function user(): Meteor.User;
+ function userId(): string;
+ var users: Mongo.Collection;
+ function wrapAsync(func: Function, context?: Object): any;
}
declare module Mongo {
- function Collection(name: string, options?: {
- connection?: Object;
- idGeneration?: string;
- transform?: Function;
- }): void;
- interface Collection{
- insert(doc: Object, callback?: Function): string;
- update(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
- multi?: boolean;
- upsert?: Boolean;
- }, callback?: Function): number;
- find(selector?: Mongo.Selector, options?: {
- sort?: Mongo.SortSpecifier;
- skip?: number;
- limit?: number;
- fields?: Mongo.FieldSpecifier;
- reactive?: boolean;
- transform?: Function;
- }): Mongo.Cursor;
- findOne(selector?: Mongo.Selector, options?: {
- sort?: Mongo.SortSpecifier;
- skip?: number;
- fields?: Mongo.FieldSpecifier;
- reactive?: boolean;
- transform?: Function;
- }): T;
- remove(selector: Mongo.Selector, callback?: Function): void;
- upsert(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
- multi?: boolean;
- }, callback?: Function): {numberAffected?: number; insertedId?: string;};
+ var Collection: CollectionStatic;
+ interface CollectionStatic {
+ new(name: string, options?: {
+ connection?: Object;
+ idGeneration?: string;
+ transform?: Function;
+ }): Collection;
+ }
+ interface Collection {
allow(options: {
- insert?: (userId:string, doc) => boolean;
- update?: (userId, doc, fieldNames, modifier) => boolean;
- remove?: (userId, doc) => boolean;
- fetch?: string[];
- transform?: Function;
- }): boolean;
+ insert?: (userId:string, doc) => boolean;
+ update?: (userId, doc, fieldNames, modifier) => boolean;
+ remove?: (userId, doc) => boolean;
+ fetch?: string[];
+ transform?: Function;
+ }): boolean;
deny(options: {
- insert?: (userId:string, doc) => boolean;
- update?: (userId, doc, fieldNames, modifier) => boolean;
- remove?: (userId, doc) => boolean;
- fetch?: string[];
- transform?: Function;
- }): boolean;
+ insert?: (userId:string, doc) => boolean;
+ update?: (userId, doc, fieldNames, modifier) => boolean;
+ remove?: (userId, doc) => boolean;
+ fetch?: string[];
+ transform?: Function;
+ }): boolean;
+ find(selector?: Mongo.Selector, options?: {
+ sort?: Mongo.SortSpecifier;
+ skip?: number;
+ limit?: number;
+ fields?: Mongo.FieldSpecifier;
+ reactive?: boolean;
+ transform?: Function;
+ }): Mongo.Cursor;
+ findOne(selector?: Mongo.Selector, options?: {
+ sort?: Mongo.SortSpecifier;
+ skip?: number;
+ fields?: Mongo.FieldSpecifier;
+ reactive?: boolean;
+ transform?: Function;
+ }): T;
+ insert(doc: Object, callback?: Function): string;
+ remove(selector: Mongo.Selector, callback?: Function): void;
+ update(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
+ multi?: boolean;
+ upsert?: boolean;
+ }, callback?: Function): number;
+ upsert(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
+ multi?: boolean;
+ }, callback?: Function): {numberAffected?: number; insertedId?: string;};
+ _ensureIndex(indexName: string, options?: {[key: string]: any}): void;
}
- function ObjectID(hexString: string): void;
- interface ObjectID{
+ var Cursor: CursorStatic;
+ interface CursorStatic {
+ new(): Cursor;
}
-
- function Cursor(): void;
- interface Cursor{
- forEach(callback: Function, thisArg?: any): void;
- map(callback: Function, thisArg?: any): void;
- fetch(): Array;
+ interface Cursor {
count(): number;
+ fetch(): Array;
+ forEach(callback: (doc: T, index: number, cursor: Mongo.Cursor) => void, thisArg?: any): void;
+ map(callback: (doc: T, index: number, cursor: Mongo.Cursor) => void, thisArg?: any): Array;
observe(callbacks: Object): Meteor.LiveQueryHandle;
observeChanges(callbacks: Object): Meteor.LiveQueryHandle;
}
-}
-
-declare module Tracker {
- var active: boolean;
- var currentComputation: Tracker.Computation;
- function Computation(): void;
- interface Computation{
- stopped: boolean;
- invalidated: boolean;
- firstRun: boolean;
- onInvalidate(callback: Function): void;
- invalidate(): void;
- stop(): void;
+ var ObjectID: ObjectIDStatic;
+ interface ObjectIDStatic {
+ new(hexString: string): ObjectID;
+ }
+ interface ObjectID {
}
- function flush(): void;
- function autorun(runFunc: Function): Tracker.Computation;
- function nonreactive(func: Function): void;
- function onInvalidate(callback: Function): void;
- function afterFlush(callback: Function): void;
- function Dependency(): void;
- interface Dependency{
- depend(fromComputation?: Tracker.Computation): boolean
- changed(): void;
- hasDependents(): boolean
- }
-
-}
-
-declare module Assets {
- function getText(assetPath: string, asyncCallback?: Function): string;
- function getBinary(assetPath: string, asyncCallback?: Function): EJSON;
-}
-
-declare module App {
- function info(options: {
- id?: string;
- version?: string;
- name?: string;
- description?: string;
- author?: string;
- email?: string;
- website?: string;
- }): void;
- function setPreference(name: string, value: string): void;
- function configurePlugin(pluginName: string, config: Object): void;
- function icons(icons: Object): void;
- function launchScreens(launchScreens: Object): void;
-}
-
-declare module Package {
- function describe(options: {
- summary?: string;
- version?: string;
- name?: string;
- git?: string;
- documentation?: string;
- }): void;
- function onUse(func: Function): void;
- function onTest(func: Function): void;
- function registerBuildPlugin(options?: {
- name?: string;
- use?: string | string[];
- sources?: string[];
- npmDependencies?: Object;
- }): void;
}
declare module Npm {
function depends(dependencies:{[id:string]:string}): void;
- function require(name: string): void;
+ function require(name: string): any;
}
-declare module Cordova {
- function depends(dependencies:{[id:string]:string}): void;
+declare module Package {
+ function describe(options: {
+ summary?: string;
+ version?: string;
+ name?: string;
+ git?: string;
+ documentation?: string;
+ }): void;
+ function onTest(func: Function): void;
+ function onUse(func: Function): void;
+ function registerBuildPlugin(options?: {
+ name?: string;
+ use?: string | string[];
+ sources?: string[];
+ npmDependencies?: Object;
+ }): void;
+}
+
+declare module Tracker {
+ function Computation(): void;
+ interface Computation {
+ firstRun: boolean;
+ invalidate(): void;
+ invalidated: boolean;
+ onInvalidate(callback: Function): void;
+ stop(): void;
+ stopped: boolean;
+ }
+
+ var Dependency: DependencyStatic;
+ interface DependencyStatic {
+ new(): Dependency;
+ }
+ interface Dependency {
+ changed(): void;
+ depend(fromComputation?: Tracker.Computation): boolean;
+ hasDependents(): boolean;
+ }
+
+ var active: boolean;
+ function afterFlush(callback: Function): void;
+ function autorun(runFunc: (computation: Tracker.Computation) => void, options?: {
+ onError?: Function;
+ }): Tracker.Computation;
+ var currentComputation: Tracker.Computation;
+ function flush(): void;
+ function nonreactive(func: Function): void;
+ function onInvalidate(callback: Function): void;
}
declare module Session {
- function set(key: string, value: EJSON | any /** Undefined **/): void;
- function setDefault(key: string, value: EJSON | any /** Undefined **/): void;
- function get(key: string): any;
function equals(key: string, value: string | number | boolean | any /** Null **/ | any /** Undefined **/): boolean;
+ function get(key: string): any;
+ function set(key: string, value: EJSONable | any /** Undefined **/): void;
+ function setDefault(key: string, value: EJSONable | any /** Undefined **/): void;
}
declare module HTTP {
function call(method: string, url: string, options?: {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
- }, asyncCallback?: Function): HTTP.HTTPResponse;
+ content?: string;
+ data?: Object;
+ query?: string;
+ params?: Object;
+ auth?: string;
+ headers?: Object;
+ timeout?: number;
+ followRedirects?: boolean;
+ npmRequestOptions?: Object;
+ }, asyncCallback?: Function): HTTP.HTTPResponse;
+ function del(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
function get(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
function post(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
function put(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
- function del(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
}
declare module Email {
function send(options: {
- from?: string;
- to?: string | string[];
- cc?: string | string[];
- bcc?: string | string[];
- replyTo?: string | string[];
- subject?: string;
- text?: string;
- html?: string;
- headers?: Object;
- }): void;
+ from?: string;
+ to?: string | string[];
+ cc?: string | string[];
+ bcc?: string | string[];
+ replyTo?: string | string[];
+ subject?: string;
+ text?: string;
+ html?: string;
+ headers?: Object;
+ attachments?: Object[];
+ }): void;
}
-declare function Subscription(): void;
-interface Subscription{
- connection: Meteor.Connection;
- userId: string;
- error(error: Error): void;
- stop(): void;
- onStop(func: Function): void;
- added(collection: string, id: string, fields: Object): void;
- changed(collection: string, id: string, fields: Object): void;
- removed(collection: string, id: string): void;
- ready(): void;
+declare var CompileStep: CompileStepStatic;
+interface CompileStepStatic {
+ new(): CompileStep;
+}
+interface CompileStep {
+ addAsset(options: {
+ }, path: string, data: any /** Buffer **/ | string); /** TODO: add return value **/
+ addHtml(options: {
+ section?: string;
+ data?: string;
+ }); /** TODO: add return value **/
+ addJavaScript(options: {
+ path?: string;
+ data?: string;
+ sourcePath?: string;
+ }); /** TODO: add return value **/
+ addStylesheet(options: {
+ }, path: string, data: string, sourceMap: string); /** TODO: add return value **/
+ arch; /** TODO: add return value **/
+ declaredExports; /** TODO: add return value **/
+ error(options: {
+ }, message: string, sourcePath?: string, line?: number, func?: string); /** TODO: add return value **/
+ fileOptions; /** TODO: add return value **/
+ fullInputPath; /** TODO: add return value **/
+ inputPath; /** TODO: add return value **/
+ inputSize; /** TODO: add return value **/
+ packageName; /** TODO: add return value **/
+ pathForSourceMap; /** TODO: add return value **/
+ read(n?: number): any;
+ rootOutputPath; /** TODO: add return value **/
}
-declare function ReactiveVar(initialValue: T, equalsFunc?: Function): void;
-interface ReactiveVar{
+declare var PackageAPI: PackageAPIStatic;
+interface PackageAPIStatic {
+ new(): PackageAPI;
+}
+interface PackageAPI {
+ addFiles(filename: string | string[], architecture?: string): void;
+ export(exportedObject: string, architecture?: string): void;
+ imply(packageSpecs: string | string[]): void;
+ use(packageNames: string | string[], architecture?: string, options?: {
+ weak?: boolean;
+ unordered?: boolean;
+ }): void;
+ versionsFrom(meteorRelease: string | string[]): void;
+}
+
+declare var ReactiveVar: ReactiveVarStatic;
+interface ReactiveVarStatic {
+ new(initialValue: T, equalsFunc?: Function): ReactiveVar;
+}
+interface ReactiveVar {
get(): T;
set(newValue: T): void;
}
+declare var Subscription: SubscriptionStatic;
+interface SubscriptionStatic {
+ new(): Subscription;
+}
+interface Subscription {
+ added(collection: string, id: string, fields: Object): void;
+ changed(collection: string, id: string, fields: Object): void;
+ connection: Meteor.Connection;
+ error(error: Error): void;
+ onStop(func: Function): void;
+ ready(): void;
+ removed(collection: string, id: string): void;
+ stop(): void;
+ userId: string;
+}
+
declare var Template: TemplateStatic;
-// TemplateStatic interface should be defined separately at top with static methods
-interface Template{
- onCreated: Function;
- onRendered: Function;
- onDestroyed: Function;
- created: Function;
- rendered: Function;
- destroyed: Function;
- body: TemplateStatic;
- helpers(helpers:{[id:string]: any}): void;
- events(eventMap: {[actions: string]: Function}): void;
- instance(): Blaze.TemplateInstance;
+interface TemplateStatic {
+ new(): Template;
+ // It should be [templateName: string]: TemplateInstance but this is not possible -- user will need to cast to TemplateInstance
+ [templateName: string]: any | Template; // added "any" to make it work
+ head: Template;
+ find(selector:string):Blaze.Template;
+ findAll(selector:string):Blaze.Template[];
+ $:any;
+ body: Template;
currentData(): {};
+ instance(): Blaze.TemplateInstance;
parentData(numLevels?: number): {};
registerHelper(name: string, helperFunction: Function): void;
}
-
-declare function CompileStep(): void;
-interface CompileStep{
- inputSize; /** TODO: add return value **/
- inputPath; /** TODO: add return value **/
- fullInputPath; /** TODO: add return value **/
- pathForSourceMap; /** TODO: add return value **/
- packageName; /** TODO: add return value **/
- rootOutputPath; /** TODO: add return value **/
- arch; /** TODO: add return value **/
- fileOptions; /** TODO: add return value **/
- declaredExports; /** TODO: add return value **/
- read(n?: number); /** TODO: add return value **/
- addHtml(options: {
- section?: string;
- data?: string;
- }); /** TODO: add return value **/
- addStylesheet(options: {
- }, path: string, data: string, sourceMap: string); /** TODO: add return value **/
- addJavaScript(options: {
- path?: string;
- data?: string;
- sourcePath?: string;
- }); /** TODO: add return value **/
- addAsset(options: {
- }, path: string, data: any /** Buffer **/ | string); /** TODO: add return value **/
- error(options: {
- }, message: string, sourcePath?: string, line?: number, func?: string); /** TODO: add return value **/
-}
-
-declare function PackageAPI(): void;
-interface PackageAPI{
- use(packageNames: string | string[], architecture?: string, options?: {
- weak?: boolean;
- unordered?: Boolean;
- }): void;
- imply(packageSpecs: string | string[]): void;
- addFiles(filename: string | string[], architecture?: string): void;
- versionsFrom(meteorRelease: string | string[]): void;
- export(exportedObject: string, architecture?: string): void;
+interface Template {
+ created: Function;
+ destroyed: Function;
+ events(eventMap: {[actions: string]: Function}): void;
+ helpers(helpers:{[id:string]: any}): void;
+ onCreated: Function;
+ onDestroyed: Function;
+ onRendered: Function;
+ rendered: Function;
}
+declare function MethodInvocation(options: {
+}); /** TODO: add return value **/
+declare function check(value: any, pattern: any): void;
diff --git a/notifyjs/notifyjs-tests.ts b/notifyjs/notifyjs-tests.ts
index 8771224c8..1b1d7f906 100644
--- a/notifyjs/notifyjs-tests.ts
+++ b/notifyjs/notifyjs-tests.ts
@@ -14,6 +14,7 @@ function test_Notify_constructor() {
body : "fuga",
icon : "./logo.png",
tag : "user",
+ timeout : 1000,
notifyShow : (e:Event)=> console.log("notifyShow", e),
notifyClose : ()=> console.log("notifyClose"),
notifyClick : ()=> console.log("notifyClick"),
diff --git a/notifyjs/notifyjs.d.ts b/notifyjs/notifyjs.d.ts
index f36b8fbcd..0cff4e0c5 100644
--- a/notifyjs/notifyjs.d.ts
+++ b/notifyjs/notifyjs.d.ts
@@ -72,6 +72,11 @@ declare module notifyjs {
* unique identifier to stop duplicate notifications
*/
tag? : string;
+
+ /**
+ * number of seconds to close the notification automatically
+ */
+ timeout? : number;
/**
* callback when notification is shown
diff --git a/object-path/object-path-tests.ts b/object-path/object-path-tests.ts
index 5984c78a8..d29cec141 100644
--- a/object-path/object-path-tests.ts
+++ b/object-path/object-path-tests.ts
@@ -1,68 +1,94 @@
-///
-
-var
- object = {
- one: 1,
- two: {
- three: 3,
- four: ['4']
- }
- },
- array: any[] = [],
- Null:any = null;
-
-objectPath.del(array) === ['12'];
-objectPath.del(object) === object;
-objectPath.del(object) === object;
-
-objectPath.del() === void 0;
-objectPath.del(object, ['1','2','3']);
-objectPath.del(object, [1,2,3]);
-objectPath.del(object, 1);
-objectPath.del(object, 'one').one === 1;
-
-objectPath.coalesce(object, ['1','2']) === void 0;
-objectPath.coalesce(object, ['1',['2','1']]) === void 0;
-objectPath.coalesce(object, ['1',['2','1']], 1) === 1;
-objectPath.coalesce(object, [1,1], 1) === 1;
-objectPath.coalesce(object, >[1,[1,1]], 1) === 1;
-
-objectPath.ensureExists(object, '1.2', 2);
-objectPath.ensureExists(object, 1, 2);
-objectPath.ensureExists(object, [1,2], 2);
-objectPath.ensureExists(object, ['1','2'], 2);
-objectPath.ensureExists(object, ['1','2'], 2) === 3;
-objectPath.ensureExists(object, ['1','2'], 2) === [[]];
-
-objectPath.push(object, 1, 1,2,3,4);
-objectPath.push(object, 1, 1,'2', 3, false);
-objectPath.push(object, 'one.four', 1,'2', 3, false);
-objectPath.push(object, ['one','two'], [1,'2', 3, false]);
-
-objectPath.get(array) === array;
-objectPath.get(Null) === Null;
-objectPath.get() === void 0;
-objectPath.get(object, 'one') === 1;
-objectPath.get(object, ['two','three']) === 3;
-objectPath.get(object, ['three'], 3) === 3;
-objectPath.get(object, 'three', 3) === 3;
-objectPath.get(object, 0, 3) === 3;
-objectPath.get(object, 0, '3') === '3';
-objectPath.get(object, 0, ['1','2']) === ['1','2'];
-objectPath.get(object, 0) === 10;
-
-objectPath.set(object, '1.2', true);
-objectPath.set(object, ['1','2'], true);
-objectPath.set(object, [1, 2], true);
-objectPath.set(object, '1.2', true, true);
-objectPath.set(object, '1.2', true, false);
-objectPath.set(object, '1.2', true, false) === ['string'];
-objectPath.set(object, '1.2', true, false) === object;
-
-objectPath.insert(object, '1.2', 1);
-objectPath.insert(object, ['1','2'], 1);
-objectPath.insert(object, 1, 1);
-objectPath.insert(object, [1,2], 1);
-objectPath.insert(object, '1.2', 1, 2);
-objectPath.insert(object, ['1.2'], 1, 6);
-
+///
+
+import ObjectPath = require('object-path');
+
+var
+ object = {
+ one: 1,
+ two: {
+ three: 3,
+ four: ['4']
+ }
+ },
+ array: any[] = [],
+ Null:any = null;
+
+var obj = ObjectPath(object);
+
+obj.del(array);
+obj.coalesce([1,2]);
+obj.ensureExists('1.2', 1);
+obj.push(1, 'value');
+obj.get(array);
+obj.set(array, 'value');
+obj.insert(1, 10);
+
+objectPath.del(array) === ['12'];
+objectPath.del(object) === object;
+objectPath.del(object) === object;
+obj.del() === object;
+
+objectPath.has(object, ['1','2','3']) === true;
+objectPath.has(object, ['1.2.3']) === false;
+objectPath.has(object, [1,2,3]) === true;
+objectPath.has(object, 1) === false;
+objectPath.has() === false;
+
+objectPath.del() === void 0;
+objectPath.del(object, ['1','2','3']);
+objectPath.del(object, [1,2,3]);
+objectPath.del(object, 1);
+objectPath.del(object, 'one').one === 1;
+obj.del('one').one === 1;
+
+objectPath.coalesce(object, ['1','2']) === void 0;
+objectPath.coalesce(object, ['1',['2','1']]) === void 0;
+objectPath.coalesce(object, ['1',['2','1']], 1) === 1;
+objectPath.coalesce(object, [1,1], 1) === 1;
+objectPath.coalesce(object, >[1,[1,1]], 1) === 1;
+obj.coalesce(>[1,[1,1]], 1) === 1;
+
+objectPath.ensureExists(object, '1.2', 2);
+objectPath.ensureExists(object, 1, 2);
+objectPath.ensureExists(object, [1,2], 2);
+objectPath.ensureExists(object, ['1','2'], 2);
+objectPath.ensureExists(object, ['1','2'], 2) === 3;
+objectPath.ensureExists(object, ['1','2'], 2) === [[]];
+obj.ensureExists(['1','2'], 2) === [[]];
+
+objectPath.push(object, 1, 1,2,3,4);
+objectPath.push(object, 1, 1,'2', 3, false);
+objectPath.push(object, 'one.four', 1,'2', 3, false);
+objectPath.push(object, ['one','two'], [1,'2', 3, false]);
+obj.push(['one','two'], [1,'2', 3, false]);
+
+objectPath.get(array) === array;
+objectPath.get(Null) === Null;
+objectPath.get() === void 0;
+objectPath.get(object, 'one') === 1;
+objectPath.get(object, ['two','three']) === 3;
+objectPath.get(object, ['three'], 3) === 3;
+objectPath.get(object, 'three', 3) === 3;
+objectPath.get(object, 0, 3) === 3;
+objectPath.get(object, 0, '3') === '3';
+objectPath.get(object, 0, ['1','2']) === ['1','2'];
+objectPath.get(object, 0) === 10;
+obj.get(0) === 10;
+
+objectPath.set(object, '1.2', true);
+objectPath.set(object, ['1','2'], true);
+objectPath.set(object, [1, 2], true);
+objectPath.set(object, '1.2', true, true);
+objectPath.set(object, '1.2', true, false);
+objectPath.set(object, '1.2', true, false) === ['string'];
+objectPath.set(object, '1.2', true, false) === object;
+obj.set('1.2', true, false) === object;
+
+objectPath.insert(object, '1.2', 1);
+objectPath.insert(object, ['1','2'], 1);
+objectPath.insert(object, 1, 1);
+objectPath.insert(object, [1,2], 1);
+objectPath.insert(object, '1.2', 1, 2);
+objectPath.insert(object, ['1.2'], 1, 6);
+obj.insert(['1.2'], 1, 6);
+
diff --git a/object-path/object-path.d.ts b/object-path/object-path.d.ts
index fe38f8702..711a305dc 100644
--- a/object-path/object-path.d.ts
+++ b/object-path/object-path.d.ts
@@ -1,238 +1,470 @@
-// Type definitions for objectPath v0.6.0
-// Project: https://github.com/mariocasciaro/object-path
-// Definitions by: Paulo Cesar
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-declare var objectPath: objectPath.IObjectPathStatic;
-
-declare module objectPath {
-
- interface IStringArray {
- [index: number]: string;
- }
-
- interface INumberArray {
- [index: number]: number;
- }
-
- interface IObjectPathStatic {
- /*======== Del =========*/
-
- /**
- * Deletes a member from object or array
- * @param {object} object
- * @param {string[]|string} path
- * @return object
- */
- del(object: T, path: IStringArray): T;
- /**
- * @see objectPath.del
- */
- del(object: T, path: INumberArray): T;
- /**
- * @see objectPath.del
- */
- del(object: T, path: number): T;
- /**
- * @see objectPath.del
- */
- del(object: T, path: string): T;
- /**
- * @see objectPath.del
- */
- del(object: T): T;
- /**
- * @see objectPath.del
- */
- del():void;
-
- /*======== Get =========*/
- /**
- * Get a path from an object
- * @param {object} object
- * @param {string|string[]|number|number[]} path
- * @param {*} [defaultValue=undefined]
- */
- get(object: T, path: string, defaultValue?: TResult): TResult;
- /**
- * @see objectPath.get
- */
- get(object: T, path: IStringArray, defaultValue?: TResult): TResult;
- /**
- * @see objectPath.get
- */
- get(object: T, path: number, defaultValue?: TResult): TResult;
- /**
- * @see objectPath.get
- */
- get(object: T, path: INumberArray, defaultValue?: TResult): TResult;
- /**
- * @see objectPath.get
- */
- get(object: T): T;
- /**
- * @see objectPath.get
- */
- get():void;
-
- /*======== Set =========*/
- /**
- * Set a path to a value
- * @param {object} object
- * @param {string|string[]|number|number[]} path
- * @param {*} value
- * @param {boolean} [doNotReplace=false]
- * @return Any existing value on the path if any
- */
- set(object: T, path: string, value: any, doNotReplace?:boolean): TExisting;
- /**
- * @see objectPath.set
- */
- set(object: T, path: number, value: any, doNotReplace?:boolean): TExisting;
- /**
- * @see objectPath.set
- */
- set(object: T, path: IStringArray, value: any, doNotReplace?:boolean): TExisting;
- /**
- * @see objectPath.set
- */
- set(object: T, path: INumberArray, value: any, doNotReplace?:boolean): TExisting;
- /**
- * @see objectPath.set
- */
- set(object: T): T;
- /**
- * @see objectPath.set
- */
- set():void;
-
- /*======== Push =========*/
- /**
- * Create (if path isn't an array) and push the value to it. Can push unlimited number of values
- * @param {object} object
- */
- push(object: T, path: INumberArray, ...args:any[]):void;
- /**
- * @see objectPath.push
- */
- push(object: T, path: IStringArray, ...args:any[]):void;
- /**
- * @see objectPath.push
- */
- push(object: T, path: number, ...args:any[]):void;
- /**
- * @see objectPath.push
- */
- push(object: T, path: string, ...args:any[]):void;
- /**
- * @see objectPath.push
- */
- push():void;
-
- /*======== Coalesce =========*/
- /**
- * Get the first non undefined property
- * @param {object} object
- * @param {string[]|string[][]|number[]|number[][]} paths
- * @param {*} defaultValue
- * @return {*}
- */
- coalesce(object: T, paths: IStringArray, defaultValue?: any):TResult;
- /**
- * @see objectPath.coalesce
- */
- coalesce(object: T, paths: INumberArray, defaultValue?: any):TResult;
- /**
- * @see objectPath.coalesce
- */
- coalesce(object: T, paths: IStringArray[], defaultValue?: any):TResult;
- /**
- * @see objectPath.coalesce
- */
- coalesce(object: T, paths: INumberArray[], defaultValue?: any):TResult;
-
- /*======== Empty =========*/
- /**
- * Empty a path. Arrays are set to length 0, objects have all elements deleted, strings
- * are set to empty, numbers to 0, everything else is set to null
- * @param {object} object
- * @param {string|string[]|number[]} path
- */
- empty(object: T, path: string):TResult;
- /**
- * @see objectPath.empty
- */
- empty(object: T, path: INumberArray):TResult;
- /**
- * @see objectPath.empty
- */
- empty(object: T, path: IStringArray):TResult;
- /**
- * @see objectPath.empty
- */
- empty(object: T, path: number):TResult;
- /**
- * @see objectPath.empty
- */
- empty(object: T):T;
- /**
- * @see objectPath.empty
- */
- empty():void;
-
- /*======== EnsureExists =========*/
- /**
- * Set a value if it doesn't exist, do nothing if it does
- * @param {object} object
- * @param {string|string[]|number|number[]} path
- */
- ensureExists(object: T, path: string, value: any):TResult;
- /**
- * @see objectPath.ensureExists
- */
- ensureExists(object: T, path: number, value: any):TResult;
- /**
- * @see objectPath.ensureExists
- */
- ensureExists(object: T, path: INumberArray, value: any):TResult;
- /**
- * @see objectPath.ensureExists
- */
- ensureExists(object: T, path: IStringArray, value: any):TResult;
- /**
- * @see objectPath.ensureExists
- */
- ensureExists(object: T): T;
- /**
- * @see objectPath.ensureExists
- */
- ensureExists():void;
-
- /*======== Insert =========*/
- /**
- * Insert an item in an array path
- * @param {object} object
- * @param {string|string[]|number|number[]} path
- * @param {*} value
- * @param {number} [at=0]
- */
- insert(object: T, path: string, value: any, at?: number):void;
- /**
- * @see objectPath.insert
- */
- insert(object: T, path: INumberArray, value: any, at?: number):void;
- /**
- * @see objectPath.insert
- */
- insert(object: T, path: IStringArray, value: any, at?: number):void;
- /**
- * @see objectPath.insert
- */
- insert(object: T, path: number, value: any, at?: number):void;
- }
-
-}
-
-declare module 'objectPath' {
- export = objectPath;
+// Type definitions for objectPath v0.9.x
+// Project: https://github.com/mariocasciaro/object-path
+// Definitions by: Paulo Cesar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare var objectPath: objectPath.IObjectPathStatic;
+
+declare module objectPath {
+
+ interface IStringArray {
+ [index: number]: string;
+ }
+
+ interface INumberArray {
+ [index: number]: number;
+ }
+
+ interface IObjectPathStatic {
+ /**
+ * Binds an object
+ */
+ (object: T): IObjectPathBound;
+
+ /*======== Del =========*/
+
+ /**
+ * Deletes a member from object or array
+ * @param {object} object
+ * @param {string[]|string} path
+ * @return object
+ */
+ del(object: T, path: IStringArray): T;
+ /**
+ * @see objectPath.del
+ */
+ del(object: T, path: INumberArray): T;
+ /**
+ * @see objectPath.del
+ */
+ del(object: T, path: number): T;
+ /**
+ * @see objectPath.del
+ */
+ del(object: T, path: string): T;
+ /**
+ * @see objectPath.del
+ */
+ del(object: T): T;
+ /**
+ * @see objectPath.del
+ */
+ del():void;
+
+ /*======== Has =========*/
+ /**
+ * Tests path existence
+ * @param {object} object
+ * @param {string[]|string} path
+ * @return object
+ */
+ has(object: T, path: IStringArray): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(object: T, path: INumberArray): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(object: T, path: string): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(object: T, path: number): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(object: T): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(): boolean;
+
+ /*======== Get =========*/
+ /**
+ * Get a path from an object
+ * @param {object} object
+ * @param {string|string[]|number|number[]} path
+ * @param {*} [defaultValue=undefined]
+ */
+ get(object: T, path: string, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(object: T, path: IStringArray, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(object: T, path: number, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(object: T, path: INumberArray, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(object: T): T;
+ /**
+ * @see objectPath.get
+ */
+ get():void;
+
+ /*======== Set =========*/
+ /**
+ * Set a path to a value
+ * @param {object} object
+ * @param {string|string[]|number|number[]} path
+ * @param {*} value
+ * @param {boolean} [doNotReplace=false]
+ * @return Any existing value on the path if any
+ */
+ set(object: T, path: string, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(object: T, path: number, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(object: T, path: IStringArray, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(object: T, path: INumberArray, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(object: T): T;
+ /**
+ * @see objectPath.set
+ */
+ set():void;
+
+ /*======== Push =========*/
+ /**
+ * Create (if path isn't an array) and push the value to it. Can push unlimited number of values
+ * @param {object} object
+ */
+ push(object: T, path: INumberArray, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push(object: T, path: IStringArray, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push(object: T, path: number, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push(object: T, path: string, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push():void;
+
+ /*======== Coalesce =========*/
+ /**
+ * Get the first non undefined property
+ * @param {object} object
+ * @param {string[]|string[][]|number[]|number[][]} paths
+ * @param {*} defaultValue
+ * @return {*}
+ */
+ coalesce(object: T, paths: IStringArray, defaultValue?: any):TResult;
+ /**
+ * @see objectPath.coalesce
+ */
+ coalesce(object: T, paths: INumberArray, defaultValue?: any):TResult;
+ /**
+ * @see objectPath.coalesce
+ */
+ coalesce(object: T, paths: IStringArray[], defaultValue?: any):TResult;
+ /**
+ * @see objectPath.coalesce
+ */
+ coalesce(object: T, paths: INumberArray[], defaultValue?: any):TResult;
+
+ /*======== Empty =========*/
+ /**
+ * Empty a path. Arrays are set to length 0, objects have all elements deleted, strings
+ * are set to empty, numbers to 0, everything else is set to null
+ * @param {object} object
+ * @param {string|string[]|number[]} path
+ */
+ empty(object: T, path: string):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(object: T, path: INumberArray):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(object: T, path: IStringArray):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(object: T, path: number):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(object: T):T;
+ /**
+ * @see objectPath.empty
+ */
+ empty():void;
+
+ /*======== EnsureExists =========*/
+ /**
+ * Set a value if it doesn't exist, do nothing if it does
+ * @param {object} object
+ * @param {string|string[]|number|number[]} path
+ */
+ ensureExists(object: T, path: string, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(object: T, path: number, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(object: T, path: INumberArray, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(object: T, path: IStringArray, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(object: T): T;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists():void;
+
+ /*======== Insert =========*/
+ /**
+ * Insert an item in an array path
+ * @param {object} object
+ * @param {string|string[]|number|number[]} path
+ * @param {*} value
+ * @param {number} [at=0]
+ */
+ insert(object: T, path: string, value: any, at?: number):void;
+ /**
+ * @see objectPath.insert
+ */
+ insert(object: T, path: INumberArray, value: any, at?: number):void;
+ /**
+ * @see objectPath.insert
+ */
+ insert(object: T, path: IStringArray, value: any, at?: number):void;
+ /**
+ * @see objectPath.insert
+ */
+ insert(object: T, path: number, value: any, at?: number):void;
+ }
+
+ interface IObjectPathBound {
+ /*======== Del =========*/
+
+ /**
+ * @see objectPath.ensureExists
+ */
+ del(path: IStringArray): T;
+ /**
+ * @see objectPath.del
+ */
+ del(path: INumberArray): T;
+ /**
+ * @see objectPath.del
+ */
+ del(path: number): T;
+ /**
+ * @see objectPath.del
+ */
+ del(path: string): T;
+ /**
+ * @see objectPath.del
+ */
+ del(): T;
+
+ /*======== Has =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ has(path: IStringArray): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(path: INumberArray): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(path: string): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(path: number): boolean;
+ /**
+ * @see objectPath.has
+ */
+ has(): boolean;
+
+ /*======== Get =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ get(path: string, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(path: IStringArray, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(path: number, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(path: INumberArray, defaultValue?: TResult): TResult;
+ /**
+ * @see objectPath.get
+ */
+ get(): T;
+
+ /*======== Set =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ set(path: string, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(path: number, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(path: IStringArray, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(path: INumberArray, value: any, doNotReplace?:boolean): TExisting;
+ /**
+ * @see objectPath.set
+ */
+ set(): T;
+
+ /*======== Push =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ push(path: INumberArray, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push(path: IStringArray, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push(path: number, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push(path: string, ...args:any[]):void;
+ /**
+ * @see objectPath.push
+ */
+ push():void;
+
+ /*======== Coalesce =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ coalesce(paths: IStringArray, defaultValue?: any):TResult;
+ /**
+ * @see objectPath.coalesce
+ */
+ coalesce(paths: INumberArray, defaultValue?: any):TResult;
+ /**
+ * @see objectPath.coalesce
+ */
+ coalesce(paths: IStringArray[], defaultValue?: any):TResult;
+ /**
+ * @see objectPath.coalesce
+ */
+ coalesce(paths: INumberArray[], defaultValue?: any):TResult;
+
+ /*======== Empty =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ empty(path: string):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(path: INumberArray):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(path: IStringArray):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty(path: number):TResult;
+ /**
+ * @see objectPath.empty
+ */
+ empty():T;
+
+ /*======== EnsureExists =========*/
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(path: string, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(path: number, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(path: INumberArray, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(path: IStringArray, value: any):TResult;
+ /**
+ * @see objectPath.ensureExists
+ */
+ ensureExists(): T;
+
+ /*======== Insert =========*/
+ /**
+ * @see objectPath.insert
+ */
+ insert(path: string, value: any, at?: number):void;
+ /**
+ * @see objectPath.insert
+ */
+ insert(path: INumberArray, value: any, at?: number):void;
+ /**
+ * @see objectPath.insert
+ */
+ insert(path: IStringArray, value: any, at?: number):void;
+ /**
+ * @see objectPath.insert
+ */
+ insert(path: number, value: any, at?: number):void;
+ }
+}
+
+// browser version
+declare module 'objectPath' {
+ export = objectPath;
+}
+
+// node version
+declare module 'object-path' {
+ export = objectPath;
}
\ No newline at end of file
diff --git a/on-finished/on-finished-tests.ts b/on-finished/on-finished-tests.ts
new file mode 100644
index 000000000..c3956ac6b
--- /dev/null
+++ b/on-finished/on-finished-tests.ts
@@ -0,0 +1,16 @@
+///
+///
+
+import events = require('events');
+import onFinished = require('on-finished');
+
+function test_finished() {
+
+ var e = new events.EventEmitter();
+
+ var ret: NodeJS.EventEmitter = onFinished(e, () => {
+ //callback
+ });
+
+ var finished: boolean = onFinished.isFinished(e);
+}
diff --git a/on-finished/on-finished.d.ts b/on-finished/on-finished.d.ts
new file mode 100644
index 000000000..0ca4f2286
--- /dev/null
+++ b/on-finished/on-finished.d.ts
@@ -0,0 +1,18 @@
+// Type definitions for on-finished v2.2.0
+// Project: https://github.com/jshttp/on-finished
+// Definitions by: Honza Dvorsky
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+
+declare module 'on-finished' {
+
+ function onFinished(msg:NodeJS.EventEmitter, listener:Function): NodeJS.EventEmitter;
+
+ module onFinished {
+ export function isFinished(msg:NodeJS.EventEmitter):boolean;
+ }
+
+ export = onFinished;
+}
diff --git a/on-headers/on-headers-tests.ts b/on-headers/on-headers-tests.ts
new file mode 100644
index 000000000..11f33c4ef
--- /dev/null
+++ b/on-headers/on-headers-tests.ts
@@ -0,0 +1,20 @@
+///
+
+import http = require('http')
+import onHeaders = require('on-headers')
+
+http.createServer(onRequest)
+ .listen(3000);
+
+function onRequest(req: http.ServerRequest, res: http.ServerResponse) {
+ onHeaders(res, addPoweredBy);
+ res.setHeader('Content-Type', 'text/plain')
+ res.end('hello!');
+}
+
+function addPoweredBy(): void {
+ // set if not set by end of request
+ if (!this.getHeader('X-Powered-By')) {
+ this.setHeader('X-Powered-By', 'Node.js');
+ }
+}
diff --git a/on-headers/on-headers.d.ts b/on-headers/on-headers.d.ts
new file mode 100644
index 000000000..bf873fd82
--- /dev/null
+++ b/on-headers/on-headers.d.ts
@@ -0,0 +1,33 @@
+// Type definitions for serve-favicon 2.1.6
+// Project: https://github.com/jshttp/on-headers
+// Definitions by: John Jeffery
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "on-headers" {
+ import http = require("http");
+
+ /**
+ * This will add the listener to fire when headers are emitted for res.
+ * The listener is passed the response object as its context (this).
+ * Headers are considered emitted only once, right before they
+ * are sent to the client.
+ *
+ * When this is called multiple times on the same res, the listeners
+ * are fired in the reverse order they were added.
+ *
+ * @param res HTTP server response object
+ * @param listener Function to call prior to headers being emitted,
+ * the response object is passed as this context.
+ */
+ function onHeaders(res: http.ServerResponse, listener: Function):void;
+
+ // Note that this definition might be able to be improved in a future
+ // version of typescript. At the moment it is not possible to declare
+ // the type of the 'this' context for a function, but it might be included
+ // in a future typescript version.
+ // https://github.com/Microsoft/TypeScript/issues/229
+
+ export = onHeaders;
+}
\ No newline at end of file
diff --git a/onsenui/onsenui-tests.ts b/onsenui/onsenui-tests.ts
new file mode 100644
index 000000000..58b72da6e
--- /dev/null
+++ b/onsenui/onsenui-tests.ts
@@ -0,0 +1,216 @@
+///
+
+function onsStatic(): void {
+ ons.ready(function(): void {
+ alert('Ready!');
+ });
+ ons.bootstrap();
+ ons.enableAutoStatusBarFill();
+ ons.disableAutoStatusBarFill();
+ ons.findParentComponentUntil('ons-page');
+ ons.findComponent('.class1');
+ ons.setDefaultDeviceBackButtonListener(null);
+ ons.disableDeviceBackButtonHandler();
+ ons.enableDeviceBackButtonHandler();
+ ons.isReady();
+ var content: HTMLElement = document.getElementById('#my-content');
+ content.innerHTML = 'Test Button';
+ ons.compile(content);
+ ons.isWebView();
+ ons.createAlertDialog('myPage.html');
+ ons.createDialog('myPage.html');
+ ons.createPopover('myPage.html');
+
+ var options: alertOptions = {
+ message: 'text message'
+ };
+ ons.notification.alert(options);
+ ons.notification.confirm(options);
+ ons.notification.prompt(options);
+
+ var potrait: boolean = ons.orientation.isPortrait();
+ var isLandscape: boolean = ons.orientation.isLandscape();
+ ons.orientation.on('eventName', null);
+ ons.orientation.once('eventName', null);
+ ons.orientation.off('eventName', null);
+
+ var web: boolean = ons.platform.isWebView();
+ var ios: boolean = ons.platform.isIOS();
+ var iPhone: boolean = ons.platform.isIPhone();
+ var iPad: boolean = ons.platform.isIPad();
+ var blackBerry: boolean = ons.platform.isBlackBerry();
+ var opera: boolean = ons.platform.isOpera();
+ var firefox: boolean = ons.platform.isFirefox();
+ var safari: boolean = ons.platform.isSafari();
+ var chrome: boolean = ons.platform.isChrome();
+ var ie: boolean = ons.platform.isIE();
+ var ios7above: boolean = ons.platform.isIOS7above();
+
+}
+
+function onsPage(page: PageView): void {
+ var DBBHandler: any = page.getDeviceBackButtonHandler();
+}
+
+function onsCarousel(carousel: CarouselView): void {
+ carousel.next();
+ carousel.prev();
+ carousel.first();
+ carousel.last();
+ carousel.setSwipeable(true);
+ var swipeable: boolean = carousel.isSwipeable();
+ carousel.setActiveCarouselItemIndex(0);
+ carousel.getActiveCarouselItemIndex();
+ var autoScrollEnabled: boolean = carousel.isAutoScrollEnabled();
+ carousel.setAutoScrollEnabled(true);
+ carousel.getAutoScrollRatio();
+ carousel.setOverscrollable(true);
+ var overscrollable: boolean = carousel.isOverscrollable();
+ carousel.refresh();
+ var disabled: boolean = carousel.isDisabled();
+ carousel.setDisabled(false);
+ carousel.on('eventName', null);
+ carousel.once('eventName', null);
+ carousel.off('eventName', null);
+}
+
+function onsPullHook(pullHook: PullHookView): void {
+ pullHook.setDisabled(false);
+ var disabled: boolean = pullHook.isDisabled();
+ pullHook.setHeight(15);
+ pullHook.setThresholdHeight(4);
+ pullHook.on('eventName', null);
+ pullHook.once('eventName', null);
+ pullHook.off('eventName', null);
+}
+
+function onsSplitView(splitViewVar: SplitView): void {
+ splitViewVar.setMainPage('myPage.html');
+ splitViewVar.setSecondaryPage('myPage2.html');
+ splitViewVar.update();
+ splitViewVar.on('eventName', null);
+ splitViewVar.once('eventName', null);
+ splitViewVar.off('eventName', null);
+}
+
+function onsAlertDialog(alertDialog: AlertDialogView): void {
+ var options: dialogOptions = {
+ animation: 'default'
+ };
+ alertDialog.show(options);
+ alertDialog.hide(options);
+ var shown: boolean = alertDialog.isShown();
+ alertDialog.destroy();
+ alertDialog.setCancelable(true);
+ var cancelable: boolean = alertDialog.isCancelable();
+ alertDialog.setDisabled(false);
+ var disabled: boolean = alertDialog.isDisabled();
+ alertDialog.on('eventName', null);
+ alertDialog.once('eventName', null);
+ alertDialog.off('eventName', null);
+}
+
+function onsDialog(dialog: DialogView): void {
+ var options: dialogOptions = {
+ animation: 'default'
+ };
+ dialog.show(options);
+ dialog.hide(options);
+ var shown: boolean = dialog.isShown();
+ dialog.destroy();
+ var DBBHandler: any = dialog.getDeviceBackButtonHandler();
+ dialog.setCancelable(true);
+ var cancelable: boolean = dialog.isCancelable();
+ dialog.setDisabled(false);
+ var disabled: boolean = dialog.isDisabled();
+ dialog.on('eventName', null);
+ dialog.once('eventName', null);
+ dialog.off('eventName', null);
+}
+
+function onsButton(button: ButtonView): void {
+ button.startSpin();
+ button.stopSpin();
+ var spinning: boolean = button.isSpinning();
+ button.setSpinAnimation('slide-left');
+ button.setDisabled(false);
+ var disabled: boolean = button.isDisabled();
+}
+
+function onsSwitch(switchVar: SwitchView): void {
+ var checked: boolean = switchVar.isChecked();
+ switchVar.setChecked(true);
+ var checkbox: HTMLElement = switchVar.getCheckboxElement();
+ switchVar.on('eventName', null);
+ switchVar.once('eventName', null);
+ switchVar.off('eventName', null);
+}
+
+function onsModal(modal: ModalView): void {
+ modal.toggle();
+ modal.show();
+ modal.hide();
+ var DBBHandler: boolean = modal.getDeviceBackButtonHandler();
+}
+
+function onsNavigator(navigator: NavigatorView): void {
+ var options: navigatorOptions = {
+ animation: 'slide'
+ };
+ navigator.pushPage('myPage.html');
+ navigator.insertPage(2, 'myPage2.html');
+ navigator.popPage();
+ navigator.resetToPage('myPage.html');
+ var currentPage: any = navigator.getCurrentPage();
+ var pages: objectArray = navigator.getPages();
+ var DBBHandler: any = navigator.getDeviceBackButtonHandler();
+ navigator.on('eventName', null);
+ navigator.once('eventName', null);
+ navigator.off('eventName', null);
+}
+
+function onsSlidingMenu(slidingMenu: SlidingMenuView): void {
+ var options: slidingMenuOptions = {
+ closeMenu: true
+ };
+ slidingMenu.setMainPage('myPage.html', options);
+ slidingMenu.setMenuPage('myMenu.html', options);
+ slidingMenu.openMenu(options);
+ slidingMenu.closeMenu(options);
+ slidingMenu.toggleMenu(options);
+ var opened: boolean = slidingMenu.isMenuOpened();
+ var DBBHandler: any = slidingMenu.getDeviceBackButtonHandler();
+ slidingMenu.setSwipeable(true);
+ slidingMenu.on('eventName', null);
+ slidingMenu.once('eventName', null);
+ slidingMenu.off('eventName', null);
+}
+
+function onsTabbar(tabBar: TabbarView): void {
+ var options: tabbarOptions = {
+ keepPage: true
+ };
+ tabBar.setActiveTab(2, options);
+ var activeTab: number = tabBar.getActiveTab();
+ tabBar.loadPage('myPage.html');
+ tabBar.on('eventName', null);
+ tabBar.once('eventName', null);
+ tabBar.off('eventName', null);
+}
+
+function onsPopover(popover: PopoverView): void {
+ var options: popoverOptions = {
+ animation: 'fade'
+ }
+ popover.show('#element5', options);
+ popover.hide(options);
+ var shown: boolean = popover.isShown();
+ popover.destroy();
+ popover.setCancelable(true);
+ var cancelable: boolean = popover.isCancelable();
+ popover.setDisabled(true);
+ var disabled: boolean = popover.isDisabled();
+ popover.on('eventName', null);
+ popover.once('eventName', null);
+ popover.off('eventName', null);
+}
diff --git a/onsenui/onsenui.d.ts b/onsenui/onsenui.d.ts
new file mode 100644
index 000000000..287c8e2f5
--- /dev/null
+++ b/onsenui/onsenui.d.ts
@@ -0,0 +1,1017 @@
+// Type definitions for Onsen UI
+// Project: http://onsen.io
+// Definitions by: Fran Dios
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+// Some useful types
+interface stringArray {
+ [index: number]: string;
+}
+
+interface objectArray {
+ [index: number]: any;
+}
+
+
+/**
+ * @description Should be used as root component of each page. The content inside page component is scrollable
+ */
+interface PageView {
+ /**
+ * @return {Object} Device back button handler
+ * @description Get the associated back button handler. This method may return null if no handler is assigned
+ */
+ getDeviceBackButtonHandler(): any;
+}
+
+/**
+ * @description Carousel component
+ */
+interface CarouselView {
+ /**
+ * @description Show next ons-carousel item
+ */
+ next(): void;
+ /**
+ * @description Show previous ons-carousel item
+ */
+ prev(): void;
+ /**
+ * @description Show first ons-carousel item
+ */
+ first(): void;
+ /**
+ * @description Show last ons-carousel item
+ */
+ last(): void;
+ /**
+ * @param {Booelan} swipeable If value is true the carousel will be swipeable
+ * @description Set whether the carousel is swipeable or not
+ */
+ setSwipeable(swipeable: boolean): void;
+ /**
+ * @return {Boolean} true if the carousel is swipeable
+ * @description Returns whether the carousel is swipeable or not
+ */
+ isSwipeable(): boolean;
+ /**
+ * @param {Number} index The index that the carousel should be set to
+ * @description Specify the index of the ons-carousel-item to show
+ */
+ setActiveCarouselItemIndex(index: number): void;
+ /**
+ * @return {Number} The current carousel item index
+ * @description Returns the index of the currently visible ons-carousel-item
+ */
+ getActiveCarouselItemIndex(): number;
+ /**
+ * @param {Boolean} enabled If true auto scroll will be enabled
+ * @description Enable or disable "auto-scroll" attribute
+ */
+ setAutoScrollEnabled(enabled: boolean): void;
+ /**
+ * @return {Boolean} true if auto scroll is enabled
+ * @description Returns whether the "auto-scroll" attribute is set or not
+ */
+ isAutoScrollEnabled(): boolean;
+ /**
+ * @param {Number} ratio The desired ratio
+ * @description Set the auto scroll ratio. Must be a value between 0.0 and 1.0
+ */
+ setAutoScrollRatio(ratio: number): void;
+ /**
+ * @return {Number} The current auto scroll ratio
+ * @description Returns the current auto scroll ratio
+ */
+ getAutoScrollRatio(): number;
+ /**
+ * @param {Boolean} overscrollable If true the carousel will be overscrollable
+ * @description Set whether the carousel is overscrollable or not
+ */
+ setOverscrollable(overscrollable: boolean): void;
+ /**
+ * @return {Boolean} Whether the carousel is overscrollable or not
+ * @description Returns whether the carousel is overscrollable or not
+ */
+ isOverscrollable(): boolean;
+ /**
+ * @description Update the layout of the carousel. Used when adding ons-carousel-items dynamically or to automatically adjust the size
+ */
+ refresh(): void;
+ /**
+ * @return {Boolean} Whether the carousel is disabled or not
+ * @description Returns whether the dialog is disabled or enabled
+ */
+ isDisabled(): boolean;
+ /**
+ * @param {Boolean} disabled If true the carousel will be disabled
+ * @description Disable or enable the dialog
+ */
+ setDisabled(disabled: boolean): void;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+/**
+ * @description Component that adds "pull-to-refresh" to an element
+ */
+interface PullHookView {
+ /**
+ * @param {Boolean} disabled If true the pull hook will be disabled
+ * @description Disable or enable the component
+ */
+ setDisabled(disabled: boolean): void;
+ /**
+ * @return {Boolean} true if the pull hook is disabled
+ * @description Returns whether the component is disabled or enabled
+ */
+ isDisabled(): boolean;
+ /**
+ * @param {Number} height Desired height
+ * @description Specify the height
+ */
+ setHeight(height: number): void;
+ /**
+ * @param {Number} thresholdHeight Desired threshold height
+ * @description Specify the threshold height
+ */
+ setThresholdHeight(thresholdHeight: number): void;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+/**
+ * @description Divides the screen into a left and right section
+ */
+interface SplitView {
+ /**
+ * @param {String} pageUrl Page URL. Can be either an HTML document or an
+ * @description Show the page specified in pageUrl in the right section
+ */
+ setMainPage(pageUrl: string): void;
+ /**
+ * @param {String} pageUrl Page URL. Can be either an HTML document or an
+ * @description Show the page specified in pageUrl in the left section
+ */
+ setSecondaryPage(pageUrl: string): void;
+ /**
+ * @description Trigger an 'update' event and try to determine if the split behaviour should be changed
+ */
+ update(): void;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+interface dialogOptions {
+ animation?: string;
+ callback?: any;
+}
+
+
+/**
+ * @modifier android Display an Android style alert dialog
+ * @description Alert dialog that is displayed on top of the current screen
+ */
+interface AlertDialogView {
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "fade", "slide" and "none"
+ * @param {Function} [options.callback] Function to execute after the dialog has been revealed
+ * @description Show the alert dialog
+ */
+ show(options?: dialogOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "fade", "slide" and "none"
+ * @param {Function} [options.callback] Function to execute after the dialog has been hidden
+ * @description Hide the alert dialog
+ */
+ hide(options?: dialogOptions): void;
+ /**
+ * @description Returns whether the dialog is visible or not
+ * @return {Boolean} true if the dialog is currently visible
+ */
+ isShown(): boolean;
+ /**
+ * @description Destroy the alert dialog and remove it from the DOM tree
+ */
+ destroy(): void;
+ /**
+ * @description Define whether the dialog can be canceled by the user or not
+ * @param {Boolean} cancelable If true the dialog will be cancelable
+ */
+ setCancelable(cancelable: boolean): void;
+ /**
+ * @description Returns whether the dialog is cancelable or not
+ * @return {Boolean} true if the dialog is cancelable
+ */
+ isCancelable(): boolean;
+ /**
+ * @description Disable or enable the alert dialog
+ * @param {Boolean} disabled If true the dialog will be disabled
+ */
+ setDisabled(disabled: boolean): void;
+ /**
+ * @description Returns whether the dialog is disabled or enabled
+ * @return {Boolean} true if the dialog is disabled
+ */
+ isDisabled(): boolean;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+/**
+ * @description Dialog that is displayed on top of current screen
+ */
+interface DialogView {
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
+ * @param {Function} [options.callback] This function is called after the dialog has been revealed
+ * @description Show the dialog
+ */
+ show(options?: dialogOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
+ * @param {Function} [options.callback] This functions is called after the dialog has been hidden
+ * @description Hide the dialog
+ */
+ hide(options?: dialogOptions): void;
+ /**
+ * @description Returns whether the dialog is visible or not
+ * @return {Boolean} true if the dialog is visible
+ */
+ isShown(): boolean;
+ /**
+ * @description Destroy the dialog and remove it from the DOM tree
+ */
+ destroy(): void;
+ /**
+ * @return {Object} Device back button handler
+ * @description Retrieve the back button handler for overriding the default behavior
+ */
+ getDeviceBackButtonHandler(): any;
+ /**
+ * @param {Boolean} cancelable If true the dialog will be cancelable
+ * @description Define whether the dialog can be canceled by the user or not
+ */
+ setCancelable(cancelable: boolean): void;
+ /**
+ * @description Returns whether the dialog is cancelable or not
+ * @return {Boolean} true if the dialog is cancelable
+ */
+ isCancelable(): boolean;
+ /**
+ * @description Disable or enable the dialog
+ * @param {Boolean} disabled If true the dialog will be disabled
+ */
+ setDisabled(disabled: boolean): void;
+ /**
+ * @description Returns whether the dialog is disabled or enabled
+ * @return {Boolean} true if the dialog is disabled
+ */
+ isDisabled(): boolean;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+/**
+ * @modifier outline Button with outline and transparent background
+ * @modifier light Button that doesn't stand out
+ * @modifier quiet Button with no outline and or background
+ * @modifier cta Button that really stands out
+ * @modifier large Large button that covers the width of the screen
+ * @modifier large--quiet Large quiet button
+ * @modifier large--cta Large call to action button
+ * @description Button component. If you want to place a button in a toolbar, use ons-toolbar-button or ons-back-button instead
+ */
+interface ButtonView {
+ /**
+ * @description Show spinner on the button
+ */
+ startSpin(): void;
+ /**
+ * @description Remove spinner from button
+ */
+ stopSpin(): void;
+ /**
+ * @return {Boolean} true if the button is spinning
+ * @description Return whether the spinner is visible or not
+ */
+ isSpinning(): boolean;
+ /**
+ * @description Set spin animation. Possible values are "slide-left" (default), "slide-right", "slide-up", "slide-down", "expand-left", "expand-right", "expand-up", "expand-down", "zoom-out", "zoom-in"
+ * @param {String} animation Animation name
+ */
+ setSpinAnimation(animation: string): void;
+ /**
+ * @description Disable or enable the button
+ */
+ setDisabled(disabled: boolean): void;
+ /**
+ * @return {Boolean} true if the button is disabled
+ * @description Returns whether the button is disabled or enabled
+ */
+ isDisabled(): boolean;
+}
+
+/**
+ * @description Switch component
+ */
+interface SwitchView {
+ /**
+ * @return {Boolean} true if the switch is on
+ * @description Returns true if the switch is ON
+ */
+ isChecked(): boolean;
+ /**
+ * @param {Boolean} checked If true the switch will be set to on
+ * @description Set the value of the switch. isChecked can be either true or false
+ */
+ setChecked(checked: boolean): void;
+ /**
+ * @return {HTMLElement} The underlying checkbox element
+ * @description Get inner input[type=checkbox] element
+ */
+ getCheckboxElement(): HTMLElement;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+/**
+ * @description
+ * Modal component that masks current screen
+ * Underlying components are not subject to any events while the modal component is shown
+ */
+interface ModalView {
+ /**
+ * @description Toggle modal visibility
+ */
+ toggle(): void;
+ /**
+ * @description Show modal
+ */
+ show(): void;
+ /**
+ * @description Hide modal
+ */
+ hide(): void;
+ /**
+ * @return {Object} Device back button handler
+ * @description Retrieve the back button handler
+ */
+ getDeviceBackButtonHandler(): any;
+}
+
+interface navigatorOptions {
+ animation?: string;
+ onTransitionEnd?: any;
+}
+
+/**
+ * @description A component that provides page stack management and navigation. This component does not have a visible content
+ */
+interface NavigatorView {
+ /**
+ * @param {String} pageUrl Page URL. Can be either a HTML document or a <ons-template>
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "slide", "simpleslide", "lift", "fade" and "none"
+ * @param {Function} [options.onTransitionEnd] Function that is called when the transition has ended
+ * @description Pushes the specified pageUrl into the page stack
+ */
+ pushPage(pageUrl: string, options?: navigatorOptions): void;
+ /**
+ * @param {Number} index The index where it should be inserted
+ * @param {String} pageUrl Page URL. Can be either a HTML document or a <ons-template>
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "slide", "simpleslide", "lift", "fade" and "none"
+ * @description Insert the specified pageUrl into the page stack with specified index
+ */
+ insertPage(index: number, pageUrl: string, options?: navigatorOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {Function} [options.onTransitionEnd] Function that is called when the transition has ended
+ * @description Pops the current page from the page stack. The previous page will be displayed
+ */
+ popPage(options?: navigatorOptions): void;
+ /**
+ * @param {String} pageUrl Page URL. Can be either a HTML document or an <ons-template>
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "slide", "simpleslide", "lift", "fade" and "none"
+ * @param {Function} [options.onTransitionEnd] Function that is called when the transition has ended
+ * @description Clears page stack and adds the specified pageUrl to the page stack
+ */
+ resetToPage(pageUrl: string, options?: navigatorOptions): void;
+ /**
+ * @return {Object} Current page object
+ * @description Get current page's navigator item. Use this method to access options passed by pushPage() or resetToPage() method
+ */
+ getCurrentPage(): any;
+ /**
+ * @return {List} List of page objects
+ * @description Retrieve the entire page stack of the navigator
+ */
+ getPages(): objectArray;
+ /**
+ * @return {Object} Device back button handler
+ * @description Retrieve the back button handler for overriding the default behavior
+ */
+ getDeviceBackButtonHandler(): any;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+interface slidingMenuOptions {
+ closeMenu?: boolean;
+ callback?: any;
+}
+
+/**
+ * @description Component for sliding UI where one page is overlayed over another page. The above page can be slided aside to reveal the page behind
+ */
+interface SlidingMenuView {
+ /**
+ * @param {String} pageUrl Page URL. Can be either an HTML document or an <ons-template>
+ * @param {Object} [options] Parameter object
+ * @param {Boolean} [options.closeMenu] If true the menu will be closed
+ * @param {Function} [options.callback] Function that is executed after the page has been set
+ * @description Show the page specified in pageUrl in the main contents pane
+ */
+ setMainPage(pageUrl: string, options?: slidingMenuOptions): void;
+ /**
+ * @param {String} pageUrl Page URL. Can be either an HTML document or an <ons-template>
+ * @param {Object} [options] Parameter object
+ * @param {Boolean} [options.closeMenu] If true the menu will be closed after the menu page has been set
+ * @param {Function} [options.callback] This function will be executed after the menu page has been set
+ * @description Show the page specified in pageUrl in the side menu pane
+ */
+ setMenuPage(pageUrl: string, options?: slidingMenuOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {Function} [options.callback] This function will be called after the menu has been opened
+ * @description Slide the above layer to reveal the layer behind
+ */
+ openMenu(options?: slidingMenuOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {Function} [options.callback] This function will be called after the menu has been closed
+ * @description Slide the above layer to hide the layer behind
+ */
+ closeMenu(options?: slidingMenuOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {Function} [options.callback] This function will be called after the menu has been opened or closed
+ * @description Slide the above layer to reveal the layer behind if it is currently hidden, otherwise, hide the layer behind
+ */
+ toggleMenu(options?: slidingMenuOptions): void;
+ /**
+ * @return {Boolean} true if the menu is currently open
+ * @description Returns true if the menu page is open, otherwise false
+ */
+ isMenuOpened(): boolean;
+ /**
+ * @return {Object} Device back button handler
+ * @description Retrieve the back-button handler
+ */
+ getDeviceBackButtonHandler(): any;
+ /**
+ * @param {Boolean} swipeable If true the menu will be swipeable
+ * @description Specify if the menu should be swipeable or not
+ */
+ setSwipeable(swipeable: boolean): void;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+interface tabbarOptions {
+ keepPage?: boolean;
+}
+
+/**
+ * @description A component to display a tab bar on the bottom of a page. Used with ons-tab to manage pages using tabs
+ */
+interface TabbarView {
+ /**
+ * @param {Number} index Tab index
+ * @param {Object} [options] Parameter object
+ * @param {Boolean} [options.keepPage] If true the page will not be changed
+ * @param {String} [options.animation] Animation name. Available animations are "fade" and "none"
+ * @return {Boolean} true if the change was successful
+ * @description Show specified tab page. Animations and other options can be specified by the second parameter
+ */
+ setActiveTab(index: number, options?: tabbarOptions): boolean;
+ /**
+ * @return {Number} The index of the currently active tab
+ * @description Returns tab index on current active tab. If active tab is not found, returns -1
+ */
+ getActiveTab(): number;
+ /**
+ * @param {String} url Page URL. Can be either an HTML document or an <ons-template>
+ * @description Displays a new page without changing the active index
+ */
+ loadPage(url: string): void;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+interface popoverOptions {
+ animation?: string;
+}
+
+/**
+ * @modifier android Display an Android style popover
+ * @description A component that displays a popover next to an element
+ */
+interface PopoverView {
+ /**
+ * @param {String|Event|HTMLElement} target Target element. Can be either a CSS selector, an event object or a DOM element
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "fade" and "none"
+ * @description Open the popover and point it at a target. The target can be either an event, a css selector or a DOM element
+ */
+ show(target: any, options?: popoverOptions): void;
+ /**
+ * @param {Object} [options] Parameter object
+ * @param {String} [options.animation] Animation name. Available animations are "fade" and "none"
+ * @description Close the popover
+ */
+ hide(options?: popoverOptions): void;
+ /**
+ * @return {Boolean} true if the popover is visible
+ * @description Returns whether the popover is visible or not
+ */
+ isShown(): boolean;
+ /**
+ * @description Destroy the popover and remove it from the DOM tree
+ */
+ destroy(): void;
+ /**
+ * @param {Boolean} cancelable If true the popover will be cancelable
+ * @description Set whether the popover can be canceled by the user when it is shown
+ */
+ setCancelable(cancelable: boolean): void;
+ /**
+ * @return {Boolean} true if the popover is cancelable
+ * @description Returns whether the popover is cancelable or not
+ */
+ isCancelable(): boolean;
+ /**
+ * @param {Boolean} disabled If true the popover will be disabled
+ * @description Disable or enable the popover
+ */
+ setDisabled(disabled: boolean): void;
+ /**
+ * @return {Boolean} true if the popover is disabled
+ * @description Returns whether the popover is disabled or enabled
+ */
+ isDisabled(): boolean;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+//# Onsen Objects
+
+/**
+ * @description A global object that's used in Onsen UI. This object can be reached from the AngularJS scope
+ */
+interface onsStatic {
+ /**
+ * @description Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized
+ * @param {Function} callback Function that executes after Onsen UI has been initialized
+ */
+ ready(callback: any): void;
+ /**
+ * @description Initialize Onsen UI. Can be used to load Onsen UI without using the ng-app attribute from AngularJS
+ * @param {String} [moduleName] AngularJS module name
+ * @param {Array} [dependencies] List of AngularJS module dependencies
+ * @return {Object} An AngularJS module object
+ */
+ bootstrap(moduleName?: string, dependencies?: objectArray): any;
+ /**
+ * @description Enable status bar fill feature on iOS7 and above
+ */
+ enableAutoStatusBarFill(): void;
+ /**
+ * @description Disable status bar fill feature on iOS7 and above
+ */
+ disableAutoStatusBarFill(): void;
+ /**
+ * @param {String} name Name of component, i.e. 'ons-page'
+ * @param {Object|jqLite|HTMLElement} [dom] $event, jqLite or HTMLElement object
+ * @return {Object} Component object. Will return null if no component was found
+ * @description Find parent component object of dom element
+ */
+ findParentComponentUntil(name: string, dom?: any): any;
+ /**
+ * @param {String} selector CSS selector
+ * @param {HTMLElement} [dom] DOM element to search from
+ * @return {Object} Component object. Will return null if no component was found
+ * @description Find component object using CSS selector
+ */
+ findComponent(selector: string, dom?: HTMLElement): any;
+ /**
+ * @param {Function} listener Function that executes when device back button is pressed
+ * @description Set default handler for device back button
+ */
+ setDefaultDeviceBackButtonListener(listener: (eventObject: any) => any): void;
+ /**
+ * @description Disable device back button event handler
+ */
+ disableDeviceBackButtonHandler(): void;
+ /**
+ * @description Enable device back button event handler
+ */
+ enableDeviceBackButtonHandler(): void;
+ /**
+ * @return {Boolean} Will be true if Onsen UI is initialized
+ * @description Returns true if Onsen UI is initialized
+ */
+ isReady(): boolean;
+ /**
+ * @param {HTMLElement} dom Element to compile
+ * @description Compile Onsen UI components
+ */
+ compile(dom: HTMLElement): void;
+ /**
+ * @return {Boolean} Will be true if the app is running in Cordova
+ * @description Returns true if running inside Cordova
+ */
+ isWebView(): boolean;
+ /**
+ * @param {String} page Page name. Can be either an HTML file or an containing a component
+ * @param {Object} [options] Parameter object
+ * @param {Object} [options.parentScope] Parent scope of the dialog. Used to bind models and access scope methods from the dialog
+ * @return {Promise} Promise object that resolves to the alert dialog component object
+ * @description Create a alert dialog instance from a template
+ */
+ createAlertDialog(page: string): any;
+ /**
+ * @param {String} page Page name. Can be either an HTML file or an containing a component
+ * @param {Object} [options] Parameter object
+ * @param {Object} [options.parentScope] Parent scope of the dialog. Used to bind models and access scope methods from the dialog
+ * @return {Promise} Promise object that resolves to the dialog component object
+ * @description Create a dialog instance from a template
+ */
+ createDialog(page: string): any;
+ /**
+ * @param {String} page Page name. Can be either an HTML file or an containing a component
+ * @param {Object} [options] Parameter object
+ * @param {Object} [options.parentScope] Parent scope of the dialog. Used to bind models and access scope methods from the dialog
+ * @return {Promise} Promise object that resolves to the popover component object
+ * @description Create a popover instance from a template
+ */
+ createPopover(page: string): any;
+
+ /**
+ * @description Utility methods to create different kinds of alert dialogs. There are three methods available: alert, confirm and prompt
+ */
+ notification: onsNotification;
+
+ /**
+ * @description Utility methods for orientation detection
+ */
+ orientation: onsOrientation;
+
+ /**
+ * @description Utility methods to detect current platform
+ */
+ platform: onsPlatform;
+}
+
+
+interface alertOptions {
+ message?: string;
+ messageHTML?: string;
+ buttonLabel?: string;
+ buttonLabels?: stringArray;
+ primaryButtonIndex?: number;
+ cancelable?: boolean;
+ animation?: string;
+ title?: string;
+ modifier?: string;
+ callback?: any;
+}
+
+interface onsNotification {
+ /**
+ * @param {Object} options Parameter object
+ * @param {String} [options.message] Alert message
+ * @param {String} [options.messageHTML] Alert message in HTML
+ * @param {String} [options.buttonLabel] Label for confirmation button. Default is "OK"
+ * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
+ * @param {String} [options.title] Dialog title. Default is "Alert"
+ * @param {String} [options.modifier] Modifier for the dialog
+ * @param {Function} [options.callback] Function that executes after dialog has been closed
+ * @description
+ * Display an alert dialog to show the user a message
+ * The content of the message can be either simple text or HTML
+ * Must specify either message or messageHTML
+ */
+ alert(options: alertOptions): void;
+ /**
+ * @param {Object} options Parameter object
+ * @param {String} [options.message] Confirmation question
+ * @param {String} [options.messageHTML] Dialog content in HTML
+ * @param {Array} [options.buttonLabels] Labels for the buttons. Default is ["Cancel", "OK"]
+ * @param {Number} [options.primaryButtonIndex] Index of primary button. Default is 1
+ * @param {Boolean} [options.cancelable] Whether the dialog is cancelable or not. Default is false
+ * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
+ * @param {String} [options.title] Dialog title. Default is "Confirm"
+ * @param {String} [options.modifier] Modifier for the dialog
+ * @param {Function} [options.callback]
+ * Function that executes after the dialog has been closed
+ * Argument for the function is the index of the button that was pressed or -1 if the dialog was canceled
+ * @description
+ * Display a dialog to ask the user for confirmation
+ * The default button labels are "Cancel" and "OK" but they can be customized
+ * Must specify either message or messageHTML
+ */
+ confirm(options: alertOptions): void;
+ /**
+ * @param {Object} options Parameter object
+ * @param {String} [options.message] Prompt question
+ * @param {String} [options.messageHTML] Dialog content in HTML
+ * @param {String} [options.buttonLabel] Label for confirmation button. Default is "OK"
+ * @param {Number} [options.primaryButtonIndex] Index of primary button. Default is 1
+ * @param {Boolean} [options.cancelable] Whether the dialog is cancelable or not. Default is false
+ * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
+ * @param {String} [options.title] Dialog title. Default is "Alert"
+ * @param {String} [options.modifier] Modifier for the dialog
+ * @param {Function} [options.callback]
+ * Function that executes after the dialog has been closed
+ * Argument for the function is the value of the input field or null if the dialog was canceled
+ * @description
+ * Display a dialog with a prompt to ask the user a question
+ * Must specify either message or messageHTML
+ */
+ prompt(options: alertOptions): void;
+}
+
+interface onsOrientation {
+ /**
+ * @return {Boolean} Will be true if the current orientation is portrait mode
+ * @description Returns whether the current screen orientation is portrait or not
+ */
+ isPortrait(): boolean;
+ /**
+ * @return {Boolean} Will be true if the current orientation is landscape mode
+ * @description Returns whether the current screen orientation is landscape or not
+ */
+ isLandscape(): boolean;
+ /**
+ * @description Add an event listener
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ on(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Add an event listener that's only triggered once
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ once(eventName: string, listener: (eventObject: any) => any): void;
+ /**
+ * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed
+ * @param {String} eventName Name of the event
+ * @param {Function} listener Function to execute when the event is triggered
+ */
+ off(eventName: string, listener?: (eventObject: any) => any): void;
+}
+
+interface onsPlatform {
+ /**
+ * @description Returns whether app is running in Cordova
+ * @return {Boolean}
+ */
+ isWebView(): boolean;
+
+ /**
+ * @description Returns whether the OS is iOS
+ * @return {Boolean}
+ */
+ isIOS(): boolean;
+
+ /**
+ * @description Returns whether the OS is Android
+ * @return {Boolean}
+ */
+ isAndroid(): boolean;
+
+ /**
+ * @description Returns whether the device is iPhone
+ * @return {Boolean}
+ */
+ isIPhone(): boolean;
+
+ /**
+ * @description Returns whether the device is iPad
+ * @return {Boolean}
+ */
+ isIPad(): boolean;
+
+ /**
+ * @description Returns whether the device is BlackBerry
+ * @return {Boolean}
+ */
+ isBlackBerry(): boolean;
+
+ /**
+ * @description Returns whether the browser is Opera
+ * @return {Boolean}
+ */
+ isOpera(): boolean;
+
+ /**
+ * @description Returns whether the browser is Firefox
+ * @return {Boolean}
+ */
+ isFirefox(): boolean;
+
+ /**
+ * @description Returns whether the browser is Safari
+ * @return {Boolean}
+ */
+ isSafari(): boolean;
+
+ /**
+ * @description Returns whether the browser is Chrome
+ * @return {Boolean}
+ */
+ isChrome(): boolean;
+
+ /**
+ * @description Returns whether the browser is Internet Explorer
+ * @return {Boolean}
+ */
+ isIE(): boolean;
+
+ /**
+ * @description Returns whether the iOS version is 7 or above
+ * @return {Boolean}
+ */
+ isIOS7above(): boolean;
+}
+
+declare var ons: onsStatic;
diff --git a/passport-local/passport-local.d.ts b/passport-local/passport-local.d.ts
index 6b3cbef38..d61e51b15 100644
--- a/passport-local/passport-local.d.ts
+++ b/passport-local/passport-local.d.ts
@@ -13,6 +13,7 @@ declare module 'passport-local' {
interface IStrategyOptions {
usernameField?: string;
passwordField?: string;
+ passReqToCallback?: boolean;
}
interface IVerifyOptions {
@@ -20,6 +21,7 @@ declare module 'passport-local' {
}
interface VerifyFunction {
+ (req: express.Request, username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void;
(username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void;
}
diff --git a/threejs/three.d.ts b/threejs/three.d.ts
index b74844407..a9255f3b5 100644
--- a/threejs/three.d.ts
+++ b/threejs/three.d.ts
@@ -1211,11 +1211,11 @@ declare module THREE {
getObjectByProperty( name: string, value: string, recursive?: boolean ): Object3D;
- getWorldPosition(optionalTarget: Vector3): Vector3;
- getWorldQuaternion(optionalTarget: Quaternion): Quaternion;
- getWorldRotation(optionalTarget: Euler): Euler;
- getWorldScale(optionalTarget: Vector3): Vector3;
- getWorldDirection(optionalTarget: Vector3): Vector3;
+ getWorldPosition(optionalTarget?: Vector3): Vector3;
+ getWorldQuaternion(optionalTarget?: Quaternion): Quaternion;
+ getWorldRotation(optionalTarget?: Euler): Euler;
+ getWorldScale(optionalTarget?: Vector3): Vector3;
+ getWorldDirection(optionalTarget?: Vector3): Vector3;
/**
* Translates object along arbitrary axis by distance.
diff --git a/webcomponents.js/webcomponents.js-tests.ts b/webcomponents.js/webcomponents.js-tests.ts
new file mode 100644
index 000000000..316f9dd8e
--- /dev/null
+++ b/webcomponents.js/webcomponents.js-tests.ts
@@ -0,0 +1,39 @@
+///
+
+/*
+ * Custom Elements
+ */
+var fooProto = Object.create(HTMLElement.prototype, {
+ createdCallback() {
+ // `this` should be the created element
+ this.getElementsByTagName("a");
+ }
+});
+
+document.registerElement("x-foo", {
+ prototype: fooProto
+});
+
+window.CustomElements.hasNative;
+window.CustomElements.flags;
+window.CustomElements.ready;
+window.CustomElements.useNative;
+
+/*
+ * HTMLImports
+ */
+
+window.HTMLImports.isIE;
+window.HTMLImports.rootDocument.querySelectorAll("div");
+window.HTMLImports.useNative;
+window.HTMLImports.whenReady(() => {
+ return window.HTMLImports.ready === true;
+});
+
+document.querySelectorAll(`link[type=${window.HTMLImports.IMPORT_LINK_TYPE}`);
+
+/*
+ * Web Components
+ */
+window.WebComponents.flags;
+
diff --git a/webcomponents.js/webcomponents.js.d.ts b/webcomponents.js/webcomponents.js.d.ts
new file mode 100644
index 000000000..43e85373f
--- /dev/null
+++ b/webcomponents.js/webcomponents.js.d.ts
@@ -0,0 +1,48 @@
+// Type definitions for webcomponents.js 0.6.0
+// Project: https://github.com/webcomponents/webcomponentsjs
+// Definitions by: Adi Dahiya
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module webcomponents {
+
+ export interface CustomElementInit {
+ prototype: HTMLElement;
+ extends?: string;
+ }
+
+ export interface CustomElementsPolyfill {
+ hasNative: boolean;
+ flags: any;
+ ready: boolean;
+ useNative: boolean;
+ }
+
+ export interface HTMLImportsPolyfill {
+ IMPORT_LINK_TYPE: string;
+ isIE: boolean;
+ flags: any;
+ ready: boolean;
+ rootDocument: Document;
+ useNative: boolean;
+ whenReady(callback: () => void): void;
+ }
+
+ export interface Polyfill {
+ flags: any;
+ }
+
+}
+
+declare module "webcomponents.js" {
+ export = webcomponents;
+}
+
+interface Document {
+ registerElement(name: string, prototype: webcomponents.CustomElementInit): void;
+}
+
+interface Window {
+ CustomElements: webcomponents.CustomElementsPolyfill;
+ HTMLImports: webcomponents.HTMLImportsPolyfill;
+ WebComponents: webcomponents.Polyfill;
+}
diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts
index cc3e6320a..5248f5d1d 100644
--- a/whatwg-fetch/whatwg-fetch-tests.ts
+++ b/whatwg-fetch/whatwg-fetch-tests.ts
@@ -11,6 +11,16 @@ function test_fetchUrlWithOptions() {
handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
}
+function test_fetchUrlWithHeadersObject() {
+ var requestOptions: RequestInit = {
+ method: "POST",
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ };
+ handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
+}
+
function test_fetchUrl() {
handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php"));
}
@@ -21,4 +31,4 @@ function handlePromise(promise: Promise) {
}).then((text) => {
console.log(text);
});
-}
\ No newline at end of file
+}
diff --git a/whatwg-fetch/whatwg-fetch.d.ts b/whatwg-fetch/whatwg-fetch.d.ts
index d847463bd..4a4a9612c 100644
--- a/whatwg-fetch/whatwg-fetch.d.ts
+++ b/whatwg-fetch/whatwg-fetch.d.ts
@@ -19,7 +19,7 @@ declare class Request {
interface RequestInit {
method?: string;
- headers?: HeaderInit;
+ headers?: HeaderInit|{ [index: string]: string };
body?: BodyInit;
mode?: RequestMode;
credentials?: RequestCredentials;
@@ -81,4 +81,4 @@ declare type RequestInfo = Request|string;
interface Window {
fetch(url: string, init?: RequestInit): Promise;
-}
\ No newline at end of file
+}