Merge pull request #1 from borisyankov/master

Merge into nikeee/master
This commit is contained in:
Niklas Mollenhauer
2013-09-06 01:06:36 -07:00
45 changed files with 13896 additions and 6345 deletions
+2
View File
@@ -166,6 +166,7 @@ List of Definitions
* [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/))
* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
* [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo))
* [Restify](https://github.com/mcavage/node-restify) (by [Bret Little](https://github.com/blittle))
* [Royalslider](http://dimsemenov.com/plugins/royal-slider/) (by [Christiaan Rakowski](https://github.com/csrakowski))
* [Rx.js](http://rx.codeplex.com/) (by [gsino](http://www.codeplex.com/site/users/view/gsino))
@@ -199,6 +200,7 @@ List of Definitions
* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
* [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/))
* [Underscore-ko.js](https://github.com/kamranayub/UnderscoreKO) (by [Maurits Elbers](https://github.com/MagicMau))
* [UUID.js](https://github.com/LiosK/UUID.js) (by [Jason Jarrett](https://github.com/staxmanade))
* [Viewporter](https://github.com/zynga/viewporter) (by [Boris Yankov](https://github.com/borisyankov))
* [Vimeo](http://developer.vimeo.com/player/js-api) (by [Daz Wilkin](https://github.com/DazWilkin/))
* [WebRTC](http://dev.w3.org/2011/webrtc/editor/webrtc.html) (by [Ken Smith](https://github.com/smithkl42))
+46
View File
@@ -0,0 +1,46 @@
/// <reference path="UUID.d.ts" />
// Copied below from readme at https://github.com/LiosK/UUID.js
// the simplest way to get an UUID (as a hexadecimal string)
console.log(UUID.generate()); // "0db9a5fa-f532-4736-89d6-8819c7f3ac7b"
// create a version 4 (random-numbers-based) UUID object
var objV4 = UUID.genV4();
// create a version 1 (time-based) UUID object
var objV1 = UUID.genV1();
// create an UUID object from a hexadecimal string
var uuid = UUID.parse("a0e0f130-8c21-11df-92d9-95795a3bcd40");
// UUID object as a string
console.log(uuid.toString()); // "a0e0f130-8c21-11df-92d9-95795a3bcd40"
console.log(uuid.hexString); // "a0e0f130-8c21-11df-92d9-95795a3bcd40"
console.log(uuid.bitString); // "101000001110000 ... 1100110101000000"
console.log(uuid.urn); // "urn:uuid:a0e0f130-8c21-11df-92d9-95795a3bcd40"
// compare UUID objects
console.log(objV4.equals(objV1)); // false
// show version numbers
console.log(objV4.version); // 4
console.log(objV1.version); // 1
// get UUID field values in 3 different formats by 2 different accessors
console.log(uuid.intFields.timeLow); // 2699096368
console.log(uuid.bitFields.timeMid); // "1000110000100001"
console.log(uuid.hexFields.timeHiAndVersion); // "11df"
console.log(uuid.intFields.clockSeqHiAndReserved); // 146
console.log(uuid.bitFields.clockSeqLow); // "11011001"
console.log(uuid.hexFields.node); // "95795a3bcd40"
console.log(uuid.intFields[0]); // 2699096368
console.log(uuid.bitFields[1]); // "1000110000100001"
console.log(uuid.hexFields[2]); // "11df"
console.log(uuid.intFields[3]); // 146
console.log(uuid.bitFields[4]); // "11011001"
console.log(uuid.hexFields[5]); // "95795a3bcd40"
+88
View File
@@ -0,0 +1,88 @@
// Type definitions for UUID.js core-1.0
// Project: https://github.com/LiosK/UUID.js
// Definitions by: Jason Jarrett <https://github.com/staxmanade/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module UUID {
interface UUIDStatic {
/**
* The simplest function to get an UUID string.
* @returns {string} A version 4 UUID string.
*/
generate(): string;
/**
* Generates a version 4 {@link UUID}.
* @returns {UUID} A version 4 {@link UUID} object.
* @since 3.0
*/
genV4(): UUID;
/**
* Generates a version 1 {@link UUID}.
* @returns {UUID} A version 1 {@link UUID} object.
* @since 3.0
*/
genV1(): UUID;
/**
* Converts hexadecimal UUID string to an {@link UUID} object.
* @param {string} strId UUID hexadecimal string representation ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
* @returns {UUID} {@link UUID} object or null.
* @since 3.0
*/
parse(uuid: string): UUID;
/**
* Re-initializes version 1 UUID state.
* @since 3.0
*/
resetState(): void;
/**
* Reinstalls {@link UUID.generate} method to emulate the interface of UUID.js version 2.x.
* @since 3.1
* @deprecated Version 2.x. compatible interface is not recommended.
*/
makeBackwardCompatible(): void;
}
interface UUIDArray<T> extends Array<T> {
timeLow: string;
timeMid: string;
timeHiAndVersion: string;
clockSeqHiAndReserved: string;
clockSeqLow: string;
node: string;
}
interface UUID {
intFields: UUIDArray<number>;
bitFields: UUIDArray<string>;
hexFields: UUIDArray<string>;
version: number;
bitString: string;
hexString: string;
urn: string;
/**
* Tests if two {@link UUID} objects are equal.
* @param {UUID} uuid
* @returns {bool} True if two {@link UUID} objects are equal.
*/
equals(uuid: UUID): boolean;
/**
* Returns UUID string representation.
* @returns {string} {@link UUID#hexString}.
*/
toString(): string;
}
}
declare var UUID: UUID.UUIDStatic;
+2 -2
View File
@@ -96,7 +96,7 @@ Since you are augmenting the $scope object, you should let the compiler know wha
$scope.title = 'Yabadabadu';
}
## Exemples
## Examples
### Working with $resource
@@ -151,4 +151,4 @@ Since you are augmenting the $scope object, you should let the compiler know wha
article.$save();
article.$publish();
}
}
+8 -1
View File
@@ -149,7 +149,7 @@ module HttpAndRegularPromiseTests {
}
}
// Test for AngularJS Syntac
// Test for AngularJS Syntax
module My.Namespace {
export var x; // need to export something for module to kick in
@@ -210,3 +210,10 @@ foo.then((x) => {
// x is infered to be a number, which is the resolved value of a promise
x.toFixed();
});
// angular.element() tests
var element = angular.element("div.myApp");
var scope: ng.IScope = element.scope();
Vendored Regular → Executable
+38 -4
View File
@@ -33,7 +33,7 @@ declare module ng {
bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService;
bootstrap(element: Element, modules?: any[]): auto.IInjectorService;
copy(source: any, destination?: any): any;
element: JQueryStatic;
element: IAugmentedJQueryStatic;
equals(value1: any, value2: any): boolean;
extend(destination: any, ...sources: any[]): any;
forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
@@ -138,6 +138,7 @@ declare module ng {
$valid: boolean;
$invalid: boolean;
$error: any;
$setDirty(dirty: boolean): void;
}
///////////////////////////////////////////////////////////////////////////
@@ -518,8 +519,8 @@ declare module ng {
pendingRequests: any[];
}
// This is just for hinting.
// Some opetions might not be available depending on the request.
// This is just for hinting.
// Some opetions might not be available depending on the request.
// see http://docs.angularjs.org/api/ng.$http#Usage for options explanations
interface IRequestConfig {
method: string;
@@ -550,10 +551,11 @@ declare module ng {
config?: IRequestConfig;
}
interface IHttpPromise<T> extends IPromise<T> {
interface IHttpPromise<T> extends IPromise<T> {
success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
error(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
}
interface IHttpProvider extends IServiceProvider {
@@ -669,6 +671,38 @@ declare module ng {
compile?: Function;
}
///////////////////////////////////////////////////////////////////////////
// angular.element
// when calling angular.element, angular returns a jQuery object,
// augmented with additional methods like e.g. scope.
// see: http://docs.angularjs.org/api/angular.element
///////////////////////////////////////////////////////////////////////////
interface IAugmentedJQueryStatic extends JQueryStatic {
(selector: string, context?: any): IAugmentedJQuery;
(element: Element): IAugmentedJQuery;
(object: {}): IAugmentedJQuery;
(elementArray: Element[]): IAugmentedJQuery;
(object: JQuery): IAugmentedJQuery;
(func: Function): IAugmentedJQuery;
(array: any[]): IAugmentedJQuery;
(): IAugmentedJQuery;
}
interface IAugmentedJQuery extends JQuery {
// TODO: events, how to define?
//$destroy
controller(name: string): any;
injector(): any;
scope(): IScope;
inheritedData(key: string, value: any): JQuery;
inheritedData(obj: { [key: string]: any; }): JQuery;
inheritedData(key?: string): any;
}
///////////////////////////////////////////////////////////////////////////
// AUTO module (angular.js)
+1 -1
View File
@@ -67,7 +67,7 @@ declare module Backbone {
}
class Events {
on(eventName: string, callback: (...args: any[]) => void , context?: any): any;
on(eventName: any, callback?: (...args: any[]) => void , context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void , context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void , context?: any): any;
+3 -1
View File
@@ -829,4 +829,6 @@ $(document).ready(function () {
}
});
});
});
$('#calendar').fullCalendar('refetchEvents')
+100 -1
View File
@@ -7,10 +7,25 @@
declare module FullCalendar {
export interface Calendar {
/**
* Formats a Date object into a string.
*/
formatDate(date: Date, format: string, options?: Options): string;
/**
* Formats a date range (two Date objects) into a string.
*/
formatDates(date1: Date, date2: Date, format: string, options?: Options): string;
/**
* Parses a string into a Date object.
*/
parseDate(dateString: string, ignoreTimezone?: boolean): Date;
/**
* Parses an ISO8601 string into a Date object.
*/
parseISO8601(dateString: string, ignoreTimezone?: boolean): Date;
/**
* Gets the version of Fullcalendar
*/
version: string;
}
@@ -179,33 +194,117 @@ declare module FullCalendar {
}
interface JQuery {
/**
* Create calendar object
*/
fullCalendar(options: FullCalendar.Options): JQuery;
/**
* Generic method function
*/
fullCalendar(method: string, arg1: any, arg2: any, arg3: any): void;
/**
* Get/Set option value
*/
fullCalendar(method: 'option', option: string, value?: any): void;
/**
* Immediately forces the calendar to render and/or readjusts its size.
*/
fullCalendar(method: 'render'): void;
/**
* Restores the element to the state before FullCalendar was initialized.
*/
fullCalendar(method: 'destroy'): void;
/**
* Moves the calendar one step back (either by a month, week, or day).
*/
fullCalendar(method: 'prev'): void;
/**
* Moves the calendar one step forward (either by a month, week, or day).
*/
fullCalendar(method: 'next'): void;
/**
* Moves the calendar back one year.
*/
fullCalendar(method: 'prevYear'): void;
/**
* Moves the calendar forward one year.
*/
fullCalendar(method: 'nextYear'): void;
/**
* Moves the calendar to the current date.
*/
fullCalendar(method: 'today'): void;
/**
* Returns the View Object for the current view.
*/
fullCalendar(method: 'getView'): FullCalendar.View;
/**
* Immediately switches to a different view.
*/
fullCalendar(method: 'changeView', viewName: string): void;
/**
* Moves the calendar to an arbitrary year/month/date.
*/
fullCalendar(method: 'gotoDate', year: number, month?: number, date?: number): void;
/**
* Moves the calendar to an arbitrary date.
*/
fullCalendar(method: 'gotoDate', date: Date): void;
/**
* Moves the calendar forward/backward an arbitrary amount of time.
*/
fullCalendar(method: 'incrementDate', year: number, month?: number, date?: number): void;
/**
* Returns a Date object for the current date of the calendar.
*/
fullCalendar(method: 'getDate'): Date;
/**
* A method for programmatically selecting a period of time.
*/
fullCalendar(method: 'select', startDate: Date, endDate: Date, allDay: boolean): void;
/**
* A method for programmatically clearing the current selection.
*/
fullCalendar(method: 'unselect'): void;
/**
* Reports changes to an event and renders them on the calendar.
*/
fullCalendar(method: 'updateEvent', event: FullCalendar.EventObject): void;
/**
* Retrieves events that FullCalendar has in memory.
*/
fullCalendar(method: 'clientEvents', idOrfilter?: any): Array<FullCalendar.EventObject>;
/**
* Retrieves events that FullCalendar has in memory.
*/
fullCalendar(method: 'clientEvents', idOrfilter?: (e: FullCalendar.EventObject) => boolean): Array<FullCalendar.EventObject>;
/**
* Removes events from the calendar.
*/
fullCalendar(method: 'removeEvents', idOrfilter?: any): void;
/**
* Removes events from the calendar.
*/
fullCalendar(method: 'removeEvents', idOrfilter?: (e: FullCalendar.EventObject) => boolean): void;
fullCalendar(method: 'refreshEvents'): void;
/**
* Refetches events from all sources and rerenders them on the screen.
*/
fullCalendar(method: 'refetchEvents'): void;
/**
* Dynamically adds an event source.
*/
fullCalendar(method: 'addEventSource', source: any): void;
/**
* Dynamically removes an event source.
*/
fullCalendar(method: 'removeEventSource', source: any): void;
/**
* Renders a new event on the calendar.
*/
fullCalendar(method: 'renderEvent', event: FullCalendar.EventObject, stick?: boolean): void;
/**
* Rerenders all events on the calendar.
*/
fullCalendar(method: 'rerenderEvents'): void;
}
+385 -385
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -104,10 +104,10 @@ declare module gapi.client {
* If supplied, the request is executed immediately and no gapi.client.HttpRequest object is returned
*/
callback?: () => any;
}): HttpRequest;
}): HttpRequest<any>;
/**
* Creates an RPC Request directly. The method name and version identify the method to be executed and the RPC params are provided upon RPC creation.
* @param method The method to be executed.
* @param method The method to be executed.
* @param version The version of the API which defines the method to be executed. Defaults to v1
* @param rpcParams A key-value pair of the params to supply to this RPC
*/
@@ -187,7 +187,7 @@ declare module gapi.client {
* Similar to gapi.client.HttpRequest except this object encapsulates requests generated by registered methods.
*/
export class RpcRequest {
/**
* Executes the request and runs the supplied callback with the response.
* @param callback The callback function which executes when the request succeeds or fails.
+1 -1
View File
@@ -110,7 +110,7 @@ var highChartSettings: HighchartsOptions = {
}]
};
var chart = $("#container").highcharts(highChartSettings);
var container = $("#container").highcharts(highChartSettings);
var options = Highcharts.getOptions();
+7 -1
View File
@@ -1111,5 +1111,11 @@ interface HighchartsSeriesObject {
}
interface JQuery {
highcharts(options: HighchartsOptions): HighchartsChart;
/**
* Creates a new Highcharts.Chart for the current JQuery selector; usually
* a div selected by $('#container')
* @param {HighchartsOptions} options Options for this chart
* @return current {JQuery} selector the current JQuery selector
**/
highcharts(options: HighchartsOptions): JQuery;
}
+26 -26
View File
@@ -6,25 +6,25 @@
/// <reference path="../node/node.d.ts" />
/**
* Complets an asynchronous task, allowing Jake's execution to proceed to the next task
* Complets an asynchronous task, allowing Jake's execution to proceed to the next task
*/
declare function complete(): void;
/**
* Creates a description for a Jake Task (or FileTask, DirectoryTask). When invoked, the description that iscreated will be associated with whatever Task is created next.
* Creates a description for a Jake Task (or FileTask, DirectoryTask). When invoked, the description that iscreated will be associated with whatever Task is created next.
* @param description The description for the Task
*/
declare function desc(description:string): void;
/**
* Creates a Jake DirectoryTask. Can be used as a prerequisite for FileTasks, or for simply ensuring a directory exists for use with a Task's action.
* Creates a Jake DirectoryTask. Can be used as a prerequisite for FileTasks, or for simply ensuring a directory exists for use with a Task's action.
* @param name The name of the DiretoryTask
*/
declare function directory(name:string): jake.DirectoryTask;
/**
* Causes Jake execution to abort with an error. Allows passing an optional error code, which will be used to set the exit-code of exiting process.
* Causes Jake execution to abort with an error. Allows passing an optional error code, which will be used to set the exit-code of exiting process.
* @param err The error to thow when aborting execution. If this argument is an Error object, it will simply be thrown. If a String, it will be used as the error-message. (If it is a multi-line String, the first line will be used as the Error message, and the remaining lines will be used as the error-stack.)
*/
declare function fail(...err:string[]): void;
@@ -32,7 +32,7 @@ declare function fail(...err:Error[]): void;
declare function fail(...err:any[]): void;
/**
* Creates a Jake FileTask.
* Creates a Jake FileTask.
* @name name The name of the Task
* @param prereqs Prerequisites to be run before this task
* @param action The action to perform for this task
@@ -41,7 +41,7 @@ declare function fail(...err:any[]): void;
declare function file(name:string, prereqs?:string[], action?:()=>void, opts?:jake.FileTaskOptions): jake.FileTask;
/**
* Creates a namespace which allows logical grouping of tasks, and prevents name-collisions with task-names. Namespaces can be nested inside of other namespaces.
* Creates a namespace which allows logical grouping of tasks, and prevents name-collisions with task-names. Namespaces can be nested inside of other namespaces.
* @param name The name of the namespace
* @param scope The enclosing scope for the namespaced tasks
*/
@@ -51,7 +51,7 @@ declare function namespace(name:string, scope:()=>void): void;
* @param name The name of the Task
* @param prereqs Prerequisites to be run before this task
* @param action The action to perform for this task
* @param opts
* @param opts
*/
declare function task(name:string, prereqs?:string[], action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task;
declare function task(name:string, action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task;
@@ -71,15 +71,15 @@ declare module jake{
* The jake.mkdirP utility recursively creates a set of nested directories. It will not throw an error if any of the directories already exists.
* https://github.com/substack/node-mkdirp
*/
export function mkdirP(name:string, mode?:string, f?:(er:Error, made:any)=>void): void;
export function mkdirP(name:string, mode?:string, f?:(er:Error, made:any)=>void): void;
export function mkdirP(name:string, f?:(er:Error, made:any)=>void): void;
/**
* The jake.cpR utility does a recursive copy of a file or directory.
* Note that this command can only copy files and directories; it does not perform globbing (so arguments like '*.txt' are not possible).
* Note that this command can only copy files and directories; it does not perform globbing (so arguments like '*.txt' are not possible).
* @param path the file/directory to copy,
* @param destination the destination.
*/
* @param destination the destination.
*/
export function cpR(path:string, destination:string, opts?:UtilOptions, callback?:()=>void): void;
export function cpR(path:string, destination:string, callback?:(err:Error)=>void): void;
@@ -108,7 +108,7 @@ declare module jake{
* print to stderr, default false
*/
printStderr?:boolean;
/**
* stop execution on error, default true
*/
@@ -154,8 +154,8 @@ declare module jake{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export var program: {
opts: {
[name:string]: any;
opts: {
[name:string]: any;
quiet: boolean;
};
taskNames: string[];
@@ -179,7 +179,7 @@ declare module jake{
/**
* A Jake Task
*
*
* @event complete
*/
export class Task implements EventEmitter {
@@ -195,7 +195,7 @@ declare module jake{
* Runs prerequisites, then this task. If the task has already been run, will not run the task again.
*/
invoke(): void;
/**
* Runs this task, without running any prerequisites. If the task has already been run, it will still run it again.
*/
@@ -207,7 +207,7 @@ declare module jake{
removeListener(event: string, listener: Function): void;
removeAllListeners(event?: string): void;
setMaxListeners(n: number): void;
listeners(event: string): { Function; }[];
listeners(event: string): Function[];
emit(event: string, arg1?: any, arg2?: any): void;
}
@@ -222,7 +222,7 @@ declare module jake{
export interface FileTaskOptions{
/**
* Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task.
* Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task.
* @default false
*/
asyc?: boolean;
@@ -274,7 +274,7 @@ declare module jake{
exclude(...file:RegExp[]): void;
exclude(file:FileFilter[]): void;
exclude(...file:FileFilter[]): void;
/**
* Populates the FileList from the include/exclude rules with a list of
@@ -306,8 +306,8 @@ declare module jake{
* Equivalent to the '-C' command for the `tar` and `jar` commands. ("Change to this directory before adding files.")
*/
archiveChangeDir: string;
/**
/**
* Specifies the files and directories to include in the package-archive. If unset, this will default to the main package directory -- i.e., name + version.
*/
archiveContentDir: string;
@@ -319,7 +319,7 @@ declare module jake{
/**
* Can be set to point the `jar` utility at a manifest file to use in a .jar archive. If unset, one will be automatically created by the `jar` utility. This path should be relative to the root of the package directory (this.packageDir above, likely 'pkg')
*/
*/
manifestFile: string;
/**
@@ -327,7 +327,7 @@ declare module jake{
*/
name: string;
/**
/**
* If set to true, uses the `jar` utility to create a .jar archive of the pagckage
*/
needJar: boolean;
@@ -348,8 +348,8 @@ declare module jake{
needZip: boolean;
/**
* The list of files and directories to include in the package-archive
*/
* The list of files and directories to include in the package-archive
*/
packageFiles: FileList;
/**
@@ -385,4 +385,4 @@ declare module jake{
export function setMaxListeners(n: number): void;
export function listeners(event: string): { Function; }[];
export function emit(event: string, arg1?: any, arg2?: any): void;
}
}
+2 -2
View File
@@ -77,7 +77,7 @@ declare module joint {
snapToGrid(p): { x: number; y: number; };
}
class ElementView {
class ElementView extends CellView {
scale(sx: number, sy: number);
}
class CellView extends Backbone.View {
@@ -110,6 +110,6 @@ declare module joint {
function mixin(objects: any[]): any;
function supplement(objects: any[]): any;
function deepMixin(objects: any[]): any;
function deepSupplement(objects: any[]): any;
function deepSupplement(objects: any[], defaultIndicator?: any): any;
}
}
+3 -3
View File
@@ -32,8 +32,8 @@ interface GridsterDraggable {
limit: boolean;
offset_left: number;
drag: (event: Event, ui: GridsterUi) => void;
start: (event: Event, ui: { helper: JQuery }) => void;
stop: (event: Event, ui: { helper: JQuery }) => void;
start: (event: Event, ui: { helper: JQuery; }) => void;
stop: (event: Event, ui: { helper: JQuery; }) => void;
}
interface GridsterUi {
@@ -228,4 +228,4 @@ interface Gridster {
* @return Returns the instance of the Gridster class.
**/
disable(): Gridster;
}
}
@@ -11,6 +11,20 @@ $(function () {
});
});
$(function () {
$(selector).pagination({
onPageClick: (page) => {
}
});
});
$(function () {
$(selector).pagination({
onPageClick: (page, event) => {
}
});
});
$(function () {
$(selector).pagination('selectPage', 1);
});
+1 -1
View File
@@ -18,7 +18,7 @@ interface SimplePaginationOptions {
nextText?: string;
cssStyle?: string;
selectOnClick?: boolean;
onPageClick?: (page?: number, event?: any) => void;
onPageClick?: (page: number, event: any) => void;
onInit?: () => void;
}
+3 -1
View File
@@ -807,6 +807,8 @@ interface JQuery {
queue(queueName: string, newQueueOrCallback: any): JQuery;
queue(newQueueOrCallback: any): JQuery;
}
declare module "jquery" {
export = $;
}
declare var jQuery: JQueryStatic;
declare var $: JQueryStatic;
+21 -2
View File
@@ -186,6 +186,10 @@ interface ListViewEvents {
create?: JQueryMobileEvent;
}
interface NavbarOptions {
iconpos: string;
}
interface JQueryMobileOptions {
activeBtnClass?: string;
activePageClass?: string;
@@ -274,12 +278,22 @@ interface LoadPageOptions {
type?: string;
}
interface LoaderOptions {
theme?: string;
textVisible?: boolean;
html?: string;
text?: string;
textonly?: boolean;
}
interface JQueryMobile extends JQueryMobileOptions {
version: string;
changePage(to: any, options?: ChangePageOptions): void;
initializePage(): void;
loadPage(url: any, options?: LoadPageOptions): void;
loading(command: string, options? ): void;
loading(command: string, options?: LoaderOptions): void;
base;
silentScroll(yPos: number): void;
@@ -373,9 +387,14 @@ interface JQuery {
listview(command: string): JQuery;
listview(options: ListViewOptions): JQuery;
listview(events: ListViewEvents): JQuery;
navbar(options?: NavbarOptions): JQuery;
table(): JQuery;
table(command: string): JQuery;
}
interface JQueryStatic {
mobile: JQueryMobile;
}
}
+2 -1
View File
@@ -955,6 +955,7 @@ interface JQuery {
slider(methodName: 'values', index: number): number;
slider(methodName: string, index: number, value: number): void;
slider(methodName: 'values', index: number, value: number): void;
slider(methodName: string, values: Array<number>): void;
slider(methodName: 'values', values: Array<number>): void;
slider(methodName: 'widget'): JQuery;
slider(options: JQueryUI.SliderOptions): JQuery;
@@ -1072,4 +1073,4 @@ interface JQueryStatic {
datepicker: JQueryUI.Datepicker;
widget: JQueryUI.Widget;
Widget: JQueryUI.Widget;
}
}
+1399
View File
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
///<reference path="./jsfl.d.ts" />
interface _xjsfl {
init(_this: any): void;
uri: string;
}
declare class _File {
constructor(path: string);
copy(path: string): _File;
write(data: string): _File;
contents: string;
}
declare class _Folder {
constructor(path: string);
contents: _File[];
}
declare class _Context {
static create(): _Context;
static from(frame: FlashFrame): _Context;
layer: FlashLayer;
frame: FlashFrame;
keyframes: FlashFrame[];
elements: FlashElement[];
setLayer(index: number);
update();
goto();
}
interface GenericCollection<T> {
elements: T[];
rename(pattern: string): GenericCollection<T>;
update(): GenericCollection<T>;
select(): GenericCollection<T>;
toGrid(x: number, y: number): GenericCollection<T>;
randomize(info: any): GenericCollection<T>;
each(callback: (element: T, index?: number, elements?: T[]) => void );
}
interface ElementCollection extends GenericCollection<FlashElement> {
}
interface ItemCollection extends GenericCollection<FlashItem> {
}
declare class _URI {
constructor(path: string);
uri: string;
folder: string;
name: string;
extension: string;
path: string;
type: string;
toURI(string: string): string;
}
declare var xjsfl: _xjsfl;
// Global variables
declare var $dom: FlashDocument;
declare var $timeline: FlashTimeline;
declare var $library: FlashLibrary;
declare var $selection: FlashElement[];
// Global functions
// Output
declare function trace(...args: any[]): void;
declare function clear(): void;
declare function format(format: string, ...params: any[]): void;
// Inspection and debugging
declare function inspect(item: any): void;
declare function list(item: any): void;
declare function debug(item: any): void;
// Library / class loading
declare function include(className: string): void;
declare function require(className: string): void;
// File
declare function load(filePath: string): string;
declare function save(filePath: string, data: string): void;
// http://www.xjsfl.com/support/guides/working-with-flash/introduction-to-selectors
// http://www.xjsfl.com/support/api/elements/ElementSelector
declare function $(selector: string): ElementCollection; // ElementSelector
// http://www.xjsfl.com/support/api/elements/ItemSelector
declare function $$(selector: string): ItemCollection; // ItemSelector
+1 -1
View File
@@ -260,7 +260,7 @@ interface KnockoutExtenders {
}
interface KnockoutObservableArrayFunctions {
filterByProperty(propName, matchValue): KnockoutComputed;
filterByProperty(propName, matchValue): KnockoutComputed<any>;
}
declare var validate;
+25 -1
View File
@@ -1,5 +1,29 @@
/// <reference path="ladda.d.ts" />
// Automatically trigger the loading animation on click
Ladda.bind('input[type=submit]');
// Same as the above but automatically stops after two seconds
Ladda.bind('input[type=submit]', { timeout: 2000 });
// Create a new instance of ladda for the specified button
var l = Ladda.create(document.querySelector('.my-button'));
// Start loading
l.start();
// Will display a progress bar for 50% of the button width
l.setProgress(0.5);
// Stop loading
l.stop();
// Toggle between loading/not loading states
l.toggle();
// Check the current state
l.isLoading();
// Test bind
Ladda.bind('button.ladda-button', { timeout: 42, callback: btn => alert('Clicked!!!') });
Ladda.bind('button.ladda-button');
@@ -17,4 +41,4 @@ var laddaBtn = Ladda.create(btnElement);
laddaBtn.start().stop().toggle().setProgress(42).enable().disable().start();
// Test isLoading
console.assert(laddaBtn.isLoading() === true);
console.assert(laddaBtn.isLoading() === true);
+3 -3
View File
@@ -1,4 +1,4 @@
// Type definitions for jStorage 0.4.0
// Type definitions for Ladda 0.7.0
// Project: https://github.com/hakimel/Ladda
// Definitions by: Danil Flores <https://github.com/dflor003/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -29,7 +29,7 @@ declare module Ladda {
function bind(target: HTMLElement, options?: ILaddaOptions): void;
function bind(cssSelector: string, options?: ILaddaOptions): void;
function create(button: HTMLElement): ILaddaButton;
function create(button: Element): ILaddaButton;
function stopAll(): void;
}
}
+19 -9
View File
@@ -1,6 +1,11 @@
#Meteor Type Definitions Usage Notes
In order to effectively write your Meteor app with TypeScript, there are a few extra things you will need to do in addition to simply referencing the Meteor type definition file and renaming all of your *.js files to *.ts (which alone will not work).
In order to effectively write a Meteor app with TypeScript, you will probably need to do these things:
- Reference the Meteor type definitions file (meteor.d.ts)
- Create a Template definition file
- Create Collections within a module or modules
##Referencing Meteor type definitions in your app
- Place the meteor.d.ts file in a directory (maybe `<app root dir>/lib/typescript`)
@@ -23,6 +28,7 @@ This will make these typed Meteor variables/objects available across your applic
*Please note that the Template variable is not automatically available. You need to follow the instructions below to use the Template variable.*
##Defining Templates
In order to call `Template.yourTemplateName.method`, you will need to create a simple TypeScript definition file that declares a Template variable containing a list of template view-models/managers of type IMeteorViewModel (or IMeteorManager, which is the same as IMeteorViewModel). A good place for this definition could be `<app root dir>/client/views/view-model-types.d.ts`. Here is an example of that file:
@@ -42,25 +48,29 @@ In order to call `Template.yourTemplateName.method`, you will need to create a s
header: IMeteorViewModel;
}
After you create this file, you may access the Template variable by declaring something like `/// <reference path='../view-model-types.d.ts'/>` at the top of any TypeScript file containing references to Template. Something like `Template.postsList.helpers()` would then transpile successfully (and have the benefits of typing).
After you create this file, you may access the Template variable by declaring something similar to `/// <reference path='../view-model-types.d.ts'/>` at the top of any TypeScript file containing references to Template. Something like `Template.postsList.helpers()` would then transpile successfully (and also have the benefits of typing).
##Defining Collections
In TypeScript, global variables are not allowed, and in a Meteor app, creating a local variable (using `var <varName>`) limits a variable's scope to the file. However, you will probably want to define variables, such as collections, that can be used across files. In the case of collections, one way to work around these limitations is to wrap each collection within a module, and then make the module globally accessible. Here is an example using posts.ts:
In TypeScript, global variables are not allowed, and in a Meteor app, creating a local variable (using `var <varName>`) limits a variable's scope to the file. However, you will probably want to define variables, such as collections, that can be used across multiple files. In the case of collections, one way to work around these limitations is to wrap the definitions of all collections within a module, and then make the module globally accessible. Here is an example (collections/models.ts):
module PostsModel {
module Models {
export var Posts = new Meteor.Collection('posts');
};
export var Comments = new Meteor.Collection('comments');
export var Notifications = new Meteor.Collection('notifications');
}
this.PostsModel = PostsModel;
this.Models = Models;
You can then access the Posts collection by placing `/// <reference path='../../../collections/posts.ts'/>` at the top of a TypeScript file. The code would look like this:
You can then access the Posts collection by placing something similar to `/// <reference path='../../../collections/models.ts'/>` at the top of a TypeScript file. The code within the file would look something like this:
PostsModel.Posts.findOne(Session.get('currentPostId'));
Models.Posts.findOne(Session.get('currentPostId'));
For organizational purposes, any additional code related to each Collection can be placed in a separate file per each collection. Alternatively, you could wrap each collection in its own module (e.g. PostsModel for posts, CommentsModel for comments).
##Reference app
A simple Meteor reference application created with TypeScript is listed below. It is based on the Microscope reference app in [Discover Meteor](http://www.discovermeteor.com/ "http://www.discovermeteor.com/").
Listed below is a simple Meteor reference application created with TypeScript is listed below. It is based on the Microscope reference app in [Discover Meteor](http://www.discovermeteor.com/ "http://www.discovermeteor.com/").
- Sample Site: <http://microscopic-typescript.meteor.com/>
- Code (TypeScript and transpiled JS): <https://github.com/fullflavedave/MicroscopicTypeScript>
+24 -4
View File
@@ -184,7 +184,16 @@ declare module "azure" {
}
export class TableQuery {
static select(...fields: string[]): TableQuery;
from(table: string): TableQuery;
whereKeys(partitionKey: string, rowKey: string): TableQuery;
whereNextKeys(partitionKey: string, rowKey: string): TableQuery;
where(condition: string, ...values: string[]): TableQuery;
and(condition: string, ...arguments: string[]): TableQuery;
or(condition: string, ...arguments: string[]): TableQuery;
top(integer): TableQuery;
toQueryObject(): any;
toPath(): string;
}
export class BatchServiceClient extends StorageServiceClient {
@@ -207,11 +216,17 @@ declare module "azure" {
}
export class LinearRetryPolicyFilter {
constructor(retryCount?: number, retryInterval?: number);
retryCount: number;
retryInterval: number;
}
export class ExponentialRetryPolicyFilter {
constructor(retryCount?: number, retryInterval?: number, minRetryInterval?: number, maxRetryInterval?: number);
retryCount: number;
retryInterval: number;
minRetryInterval: number;
maxRetryInterval: number;
}
export class SharedAccessSignature {
@@ -323,6 +338,10 @@ declare module "azure" {
export interface QueryEntitiesResultContinuation extends QueryResultContinuation {
tableQuery: TableQuery;
nextPartitionKey: string;
nextRowKey: string;
getNextPage(callback?: QueryEntitiesCallback): void;
hasNextPage(): boolean;
}
export interface ModifyEntityCallback {
@@ -361,4 +380,5 @@ declare module "azure" {
//#endregion
export function isEmulated(): boolean;
}
}
+50 -32
View File
@@ -16,11 +16,11 @@ declare var __filename: string;
declare var __dirname: string;
declare function setTimeout(callback: () => void , ms: number): any;
declare function clearTimeout(timeoutId: any);
declare function clearTimeout(timeoutId: any): void;
declare function setInterval(callback: () => void , ms: number): any;
declare function clearInterval(intervalId: any);
declare function clearInterval(intervalId: any): void;
declare function setImmediate(callback: () => void ): any;
declare function clearImmediate(immediateId: any);
declare function clearImmediate(immediateId: any): void;
declare var require: {
(id: string): any;
@@ -68,13 +68,13 @@ declare var Buffer: {
************************************************/
interface EventEmitter {
addListener(event: string, listener: Function);
on(event: string, listener: Function);
addListener(event: string, listener: Function): void;
on(event: string, listener: Function): void;
once(event: string, listener: Function): void;
removeListener(event: string, listener: Function): void;
removeAllListeners(event?: string): void;
setMaxListeners(n: number): void;
listeners(event: string): { Function; }[];
listeners(event: string): Function[];
emit(event: string, arg1?: any, arg2?: any): void;
}
@@ -209,24 +209,24 @@ declare module "querystring" {
declare module "events" {
export interface NodeEventEmitter {
addListener(event: string, listener: Function);
addListener(event: string, listener: Function): void;
on(event: string, listener: Function): any;
once(event: string, listener: Function): void;
removeListener(event: string, listener: Function): void;
removeAllListeners(event?: string): void;
setMaxListeners(n: number): void;
listeners(event: string): { Function; }[];
listeners(event: string): Function[];
emit(event: string, arg1?: any, arg2?: any): void;
}
export class EventEmitter implements NodeEventEmitter {
addListener(event: string, listener: Function);
addListener(event: string, listener: Function): void;
on(event: string, listener: Function): any;
once(event: string, listener: Function): void;
removeListener(event: string, listener: Function): void;
removeAllListeners(event?: string): void;
setMaxListeners(n: number): void;
listeners(event: string): { Function; }[];
listeners(event: string): Function[];
emit(event: string, arg1?: any, arg2?: any): void;
}
}
@@ -294,7 +294,7 @@ declare module "http" {
}
export interface Agent { maxSockets: number; sockets: any; requests: any; }
export var STATUS_CODES;
export var STATUS_CODES: any;
export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) =>void ): Server;
export function createClient(port?: number, host?: string): any;
export function request(options: any, callback?: Function): ClientRequest;
@@ -335,7 +335,7 @@ declare module "cluster" {
export function removeListener(event: string, listener: Function): void;
export function removeAllListeners(event?: string): void;
export function setMaxListeners(n: number): void;
export function listeners(event: string): { Function; }[];
export function listeners(event: string): Function[];
export function emit(event: string, arg1?: any, arg2?: any): void;
}
@@ -359,13 +359,13 @@ declare module "zlib" {
export function createInflateRaw(options: ZlibOptions): InflateRaw;
export function createUnzip(options: ZlibOptions): Unzip;
export function deflate(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function gzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function gunzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function inflate(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function unzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void;
export function deflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
export function gzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
export function gunzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
export function inflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
export function unzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void;
// Constants
export var Z_NO_FLUSH: number;
@@ -480,7 +480,7 @@ declare module "punycode" {
decode(string: string): string;
encode(codePoints: number[]): string;
}
export var version;
export var version: any;
}
declare module "repl" {
@@ -599,7 +599,7 @@ declare module "url" {
slashes: boolean;
}
export function parse(urlStr: string, parseQueryString? , slashesDenoteHost? ): Url;
export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
export function format(url: Url): string;
export function resolve(from: string, to: string): string;
}
@@ -771,19 +771,19 @@ declare module "fs" {
export function futimesSync(fd: string, atime: number, mtime: number): void;
export function fsync(fd: string, callback?: Function): void;
export function fsyncSync(fd: string): void;
export function write(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err, written: number, buffer: NodeBuffer) =>any): void;
export function write(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) =>any): void;
export function writeSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): void;
export function read(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err, bytesRead: number, buffer: NodeBuffer) => void): void;
export function read(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void;
export function readSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): any[];
export function readFile(filename: string, options: { encoding?: string; flag?: string; }, callback: (err, data: any) => void ): void;
export function readFile(filename: string, callback: (err, data: NodeBuffer) => void ): void;
export function readFile(filename: string, options: { encoding?: string; flag?: string; }, callback: (err: Error, data: any) => void ): void;
export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void;
export function readFileSync(filename: string): NodeBuffer;
export function readFileSync(filename: string, options: { encoding?: string; flag?: string; }): any;
export function writeFile(filename: string, data: any, callback?: (err) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err) => void): void;
export function writeFile(filename: string, data: any, callback?: (err: Error) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: Error) => void): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err) => void): void;
export function appendFile(filename: string, data: any, callback?: (err) => void): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: Error) => void): void;
export function appendFile(filename: string, data: any, callback?: (err: Error) => void): void;
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void;
export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void;
@@ -808,7 +808,7 @@ declare module "fs" {
declare module "path" {
export function normalize(p: string): string;
export function join(...paths: any[]): string;
export function resolve(to: string);
export function resolve(to: string): string;
export function resolve(from: string, to: string): string;
export function resolve(from: string, from2: string, to: string): string;
export function resolve(from: string, from2: string, from3: string, to: string): string;
@@ -975,7 +975,7 @@ declare module "crypto" {
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void;
export function randomBytes(size: number, callback?: (err: Error, buf: NodeBuffer) =>void );
export function randomBytes(size: number, callback?: (err: Error, buf: NodeBuffer) =>void ): void;
}
declare module "stream" {
@@ -1001,6 +1001,24 @@ declare module "stream" {
pipe(destination: WritableStream, options?: { end?: boolean; }): void;
}
export interface ReadableOptions {
highWaterMark?: number;
encoding?: string;
objectMode?: boolean;
}
export class Readable extends events.EventEmitter implements ReadableStream {
readable: boolean;
constructor(opts?: ReadableOptions);
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
destroy(): void;
pipe(destination: WritableStream, options?: { end?: boolean; }): void;
_read(): void;
push(chunk: any, encoding?: string): boolean;
}
export interface ReadWriteStream extends ReadableStream, WritableStream { }
}
@@ -1065,4 +1083,4 @@ declare module "domain" {
export function bind(cb: (er: Error, data: any) =>any): any;
export function intercept(cb: (data: any) => any): any;
export function dispose(): void;
}
}
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="ravenjs.d.ts" />
var options: RavenOptions = {
logger: 'my-logger',
ignoreUrls: [
/graph\.facebook\.com/i
],
ignoreErrors: [
'fb_xd_fragment'
],
includePaths: [
/https?:\/\/(www\.)?getsentry\.com/,
/https?:\/\/d3nslu0hdya83q\.cloudfront\.net/
]
};
Raven.config('https://public@getsentry.com/1', options).install();
var throwsError = () => {
throw new Error('broken');
};
try {
throwsError();
} catch(e) {
Raven.captureException(e);
Raven.captureException(e, {tags: { key: "value" }});
}
Raven.context(throwsError);
Raven.context({tags: { key: "value" }}, throwsError);
setTimeout(Raven.wrap(throwsError), 1000);
Raven.wrap({logger: "my.module"}, throwsError)();
Raven.setUser({
email: 'matt@example.com',
id: '123'
});
Raven.captureMessage('Broken!');
Raven.captureMessage('Broken!', {tags: { key: "value" }});
+124
View File
@@ -0,0 +1,124 @@
// Type definitions for Raven.js
// Project: https://github.com/getsentry/raven-js
// Definitions by: Santi Albo <https://github.com/santialbo/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var Raven: RavenStatic;
interface RavenOptions {
/** The name of the logger used by Sentry. Default: javascript */
logger?: string;
/** List of messages to be fitlered out before being sent to Sentry. */
ignoreErrors?: string[];
/** Similar to ignoreErrors, but will ignore errors from whole urls patching a regex pattern. */
ignoreUrls?: RegExp[];
/** The inverse of ignoreUrls. Only report errors from whole urls matching a regex pattern. */
whitelistUrls?: RegExp[];
/** An array of regex patterns to indicate which urls are a part of your app. */
includePaths?: RegExp[];
/** Additional data to be tagged onto the error. */
tags?: any;
extra?: any;
}
interface RavenStatic {
/** Raven.js version. */
VERSION: string;
/*
* Allow Raven to be configured as soon as it is loaded
* It uses a global RavenConfig = {dsn: '...', config: {}}
*
* @return undefined
*/
afterLoad(): void;
/*
* Allow multiple versions of Raven to be installed.
* Strip Raven from the global context and returns the instance.
*
* @return {Raven}
*/
noConflict(): RavenStatic;
/*
* Configure Raven with a DSN and extra options
*
* @param {string} dsn The public Sentry DSN
* @param {object} options Optional set of of global options [optional]
* @return {Raven}
*/
config(dsn: string, options?: RavenOptions): RavenStatic;
/*
* Installs a global window.onerror error handler
* to capture and report uncaught exceptions.
* At this point, install() is required to be called due
* to the way TraceKit is set up.
*
* @return {Raven}
*/
install(): RavenStatic;
/*
* Wrap code within a context so Raven can capture errors
* reliably across domains that is executed immediately.
*
* @param {object} options A specific set of options for this context [optional]
* @param {function} func The callback to be immediately executed within the context
* @param {array} args An array of arguments to be called with the callback [optional]
*/
context(func: Function, ...args: any[]): void;
context(options: RavenOptions, func: Function, ...args: any[]): void;
/*
* Wrap code within a context and returns back a new function to be executed
*
* @param {object} options A specific set of options for this context [optional]
* @param {function} func The function to be wrapped in a new context
* @return {function} The newly wrapped functions with a context
*/
wrap(func: Function): Function;
wrap(options: RavenOptions, func: Function): Function;
/*
* Uninstalls the global error handler.
*
* @return {Raven}
*/
uninstall(): RavenStatic;
/*
* Manually capture an exception and send it over to Sentry
*
* @param {error} ex An exception to be logged
* @param {object} options A specific set of options for this error [optional]
* @return {Raven}
*/
captureException(ex: Error, options?: RavenOptions): RavenStatic;
/*
* Manually send a message to Sentry
*
* @param {string} msg A plain message to be captured in Sentry
* @param {object} options A specific set of options for this message [optional]
* @return {Raven}
*/
captureMessage(msg: string, options?: RavenOptions): RavenStatic;
/*
* Set/clear a user to be sent along with the payload.
*
* @param {object} user An object representing user data [optional]
* @return {Raven}
*/
setUser(user?: any): RavenStatic;
}
+32 -1
View File
@@ -88,7 +88,9 @@ function test_config() {
RestangularProvider.setDefaultHttpFields({ cache: true });
RestangularProvider.setMethodOverriders(["put", "patch"]);
RestangularProvider.setListTypeIsArray(true);
RestangularProvider.setErrorInterceptor(function (response) {
console.error('' + response.status + ' ' + response.data);
});
RestangularProvider.setRestangularFields({
id: "_id",
@@ -104,4 +106,33 @@ function test_config() {
elem.accountName = 'Changed';
return elem;
});
var myRestangular = Restangular.withConfig((configurer: RestangularProvider) => {
configurer.setBaseUrl('/api/v1');
configurer.setExtraFields(['name']);
configurer.setErrorInterceptor(function (response) {
console.error('' + response.status + ' ' + response.data);
});
configurer.setResponseExtractor(function (response, operation) {
return response.data;
});
configurer.setDefaultHttpFields({ cache: true });
configurer.setMethodOverriders(["put", "patch"]);
configurer.setRestangularFields({
id: "_id",
route: "restangularRoute"
});
configurer.setRequestSuffix('.json');
configurer.setRequestInterceptor(function (element, operation, route, url) {
});
configurer.addElementTransformer('accounts', false, function (elem) {
elem.accountName = 'Changed';
return elem;
});
});
}
+31 -11
View File
@@ -11,7 +11,7 @@ interface Restangular extends RestangularCustom {
one(route: string, id?: string): RestangularElement;
all(route: string): RestangularCollection;
copy(fromElement: any): RestangularElement;
withConfig(configurer: any): Restangular;
withConfig(configurer: (RestangularProvider) => any): Restangular;
}
interface RestangularElement extends Restangular {
@@ -49,16 +49,36 @@ interface RestangularCustom {
}
interface RestangularProvider {
setBaseUrl(newValue: string): void;
setExtraFields(newValues: string[]): void;
setDefaultHttpFields(newValue: any): void;
setMethodOverriders(newValue: any): void;
setResponseExtractor(newValue: any): void;
setRequestInterceptor(newValue: any): void;
setListTypeIsArray(newValue: boolean): void;
setRestangularFields(newValue: any): void;
setRequestSuffix(newValue: any): void;
addElementTransformer(type, secondArg, thirdArg): void;
setBaseUrl(baseUrl: string): void;
setExtraFields(fields: string[]): void;
setParentless(parentless: boolean, routes: string[]): void;
setDefaultHttpFields(httpFields: any): void;
addElementTransformer(route: string, transformer: Function): void;
addElementTransformer(route: string, isCollection: boolean, transformer: Function): void;
setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: Restangular) => any): void;
setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred<any>) => any): void;
setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred<any>) => any): void;
setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any);
setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any});
setErrorInterceptor(errorInterceptor: (response: RestangularResponse) => any): void;
setRestangularFields(fields: {[fieldName: string]: string}): void;
setMethodOverriders(overriders: string[]): void;
setDefaultRequestParams(params: any): void;
setDefaultRequestParams(methods: any, params: any): void;
setFullResponse(fullResponse: boolean): void;
setDefaultHeaders(headers: any): void;
setRequestSuffix(suffix: string): void;
setUseCannonicalId(useCannonicalId: boolean): void;
}
interface RestangularResponse {
status: number;
data: any;
config: {
method: string;
url: string;
params: any;
}
}
declare var Restangular: Restangular;
+177 -163
View File
@@ -1,8 +1,9 @@
/// <reference path="sammyjs.d.ts" />
function test_general() {
// Example from homepage
var app = Sammy('#main', function () {
var _this: Sammy.Application;
var _this: Sammy.Application = this;
_this.use('Mustache');
_this.get('#/', function () {
var _this: Sammy.RenderContext;
@@ -64,7 +65,7 @@ function test_app() {
});
var app = $.sammy(),
context = { verb: 'get', path: '#/mypath' };
context = { verb: 'get', path: '#/mypath' };
app.contextMatchesOptions(context, '#/mypath');
app.contextMatchesOptions(context, '#/otherpath');
@@ -98,15 +99,13 @@ function test_app() {
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.helpers({
var better = _this.helpers({
upcase: function (text) {
return text.toString().toUpperCase();
}
});
_this.get('#/', function () {
with (_this) {
$('#main').html(upcase($('#main').text()));
}
better.get('#/', function () {
$('#main').html(better.upcase($('#main').text()));
});
});
@@ -137,7 +136,7 @@ function test_app() {
context.$element().html(content);
context.$element().fadeIn('slow', function () {
if (callback) {
callback.apply();
callback.apply(this);
}
});
});
@@ -179,146 +178,156 @@ function test_misc() {
$.sammy(function () {
var _this: Sammy.Application;
_this.get('#/:name', function () {
if (_this.params['name'] == 'sammy') {
_this.partial('name.html.erb', { name: 'Sammy' });
var _evt: Sammy.EventContext = this;
if (_evt.params['name'] == 'sammy') {
_evt.partial('name.html.erb', { name: 'Sammy' });
} else {
_this.redirect('#/somewhere-else')
_evt.redirect('#/somewhere-else')
}
});
});
var _this: Sammy.Application;
_this.redirect('#/other/route');
_this.redirect('#', 'other', 'route');
_this.render('mytemplate.mustache', { name: 'quirkey' })
.appendTo('ul');
_this.renderEach('mytemplate.mustache', [{ name: 'quirkey' }, { name: 'endor' }]);
function evtContextTests() {
var _this: Sammy.EventContext;
_this.redirect('#/other/route');
_this.redirect('#', 'other', 'route');
_this.render('mytemplate.mustache', { name: 'quirkey' })
.appendTo('ul');
_this.renderEach('mytemplate.mustache', [{ name: 'quirkey' }, { name: 'endor' }]);
var item = {
name: 'My Item',
price: '$25.50',
meta: {
id: '123'
}
};
var form = new Sammy.FormBuilder('item', item);
form.text('name');
var item = {
name: 'My Item',
price: '$25.50',
meta: {
id: '123'
}
};
var form = new Sammy.FormBuilder('item', item);
form.text('name');
var options = [
['Small', 's'],
['Medium', 'm'],
['Large', 'l']
];
form.select('size', options);
var options = [
['Small', 's'],
['Medium', 'm'],
['Large', 'l']
];
form.select('size', options);
$.sammy(function () {
var _this: Sammy.Application;
_this.use('GoogleAnalytics')
$.sammy(function () {
var _this: Sammy.Application;
_this.use('GoogleAnalytics')
_this.get('#/dont/track/me', function () {
_this.noTrack();
var evt: Sammy.GoogleAnalytics = this;
evt.noTrack();
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use(Sammy.Haml);
_this.get('#/hello/:name', function () {
var evt: Sammy.Haml = this;
evt.title = 'Hello!';
evt.name = evt.params.name;
evt.partial('mytemplate.haml');
});
});
app.run()
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use(Sammy.Haml);
_this.get('#/hello/:name', function () {
_this.title = 'Hello!'
_this.name = _this.params.name;
_this.partial('mytemplate.haml');
var _this: Sammy.Application;
_this.use('Handlebars', 'hb');
_this.get('#/hello/:name', function () {
var evt: Sammy.Handlebars = this;
evt.title = 'Hello!'
evt.name = evt.params.name;
evt.partial('mytemplate.hb');
});
});
});
app.run()
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Handlebars', 'hb');
_this.get('#/hello/:name/to/:friend', function (context: Sammy.Handlebars) {
context.load('mypartial.hb')
.then(function (partial) {
context.partials = { hello_friend: partial };
context.name = context.params.name;
// dynamically add a property to the context
(<any>context).friend = context.params.friend;
context.partial('mytemplate.hb');
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Hogan', 'hg');
_this.get('#/hello/:name', function () {
var evt: Sammy.Hogan = this;
evt.title = 'Hello!'
evt.name = evt.params.name;
evt.partial('mytemplate.hg');
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Hogan', 'hg');
_this.get('#/hello/:name/to/:friend', function (context) {
context.load('mypartial.hg')
.then(function (partial) {
context.partials = { hello_friend: partial };
context.name = context.params.name;
context.friend = context.params.friend;
context.partial('mytemplate.hg');
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use(Sammy.JSON);
_this.get('#/', function () {
var evt: Sammy.JSON = this;
evt.json({ user_id: 123 });
evt.json("{\"user_id\":\"123\"}");
evt.json("{\"user_id\":\"123\"}").user_id;
});
})
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Handlebars', 'hb');
_this.get('#/hello/:name', function () {
_this.title = 'Hello!'
_this.name = _this.params.name;
_this.partial('mytemplate.hb');
var _this: Sammy.Application;
_this.use('Mustache', 'ms');
_this.get('#/hello/:name', function () {
var evt: Sammy.Mustache = this;
evt.title = 'Hello!'
evt.name = evt.params.name;
evt.partial('mytemplate.ms');
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Handlebars', 'hb');
_this.get('#/hello/:name/to/:friend', function (context) {
_this.load('mypartial.hb')
.then(function (partial) {
context.partials = { hello_friend: partial };
context.name = context.params.name;
context.friend = context.params.friend;
context.partial('mytemplate.hb');
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Mustache', 'ms');
_this.get('#/hello/:name/to/:friend', function (context: Sammy.Mustache) {
context.load('mypartial.ms')
.then(function (partial) {
context.partials = { hello_friend: partial };
context.name = context.params.name;
(<any>context).friend = context.params.friend;
context.partial('mytemplate.ms');
});
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Hogan', 'hg');
_this.get('#/hello/:name', function () {
_this.title = 'Hello!'
_this.name = _this.params.name;
_this.partial('mytemplate.hg');
var app = $.sammy(function (app) {
var _this: Sammy.Application;
_this.use(Sammy.NestedParams);
_this.post('#/parse_me', function (context) {
$.log(context.params);
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Hogan', 'hg');
_this.get('#/hello/:name/to/:friend', function (context) {
_this.load('mypartial.hg')
.then(function (partial) {
context.partials = { hello_friend: partial };
context.name = context.params.name;
context.friend = context.params.friend;
context.partial('mytemplate.hg');
});
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use(Sammy.JSON);
_this.get('#/', function () {
_this.json({ user_id: 123 });
_this.json("{\"user_id\":\"123\"}");
_this.json("{\"user_id\":\"123\"}").user_id;
});
})
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Mustache', 'ms');
_this.get('#/hello/:name', function () {
_this.title = 'Hello!'
_this.name = _this.params.name;
_this.partial('mytemplate.ms');
});
});
var app = $.sammy(function () {
var _this: Sammy.Application;
_this.use('Mustache', 'ms');
_this.get('#/hello/:name/to/:friend', function (context) {
_this.load('mypartial.ms')
.then(function (partial) {
context.partials = { hello_friend: partial };
context.name = context.params.name;
context.friend = context.params.friend;
context.partial('mytemplate.ms');
});
});
});
var app = $.sammy(function (app) {
var _this: Sammy.Application;
_this.use(Sammy.NestedParams);
_this.post('#/parse_me', function (context) {
$.log(_this.params);
});
});
};
var _this: Sammy.Application;
_this.use('Storage');
@@ -333,7 +342,7 @@ function test_misc() {
_this.bind("oauth.connected", function () { $("#signin").hide() });
_this.bind("oauth.disconnected", function () { $("#signin").show() });
_this.bind("oauth.denied", function (evt, error) {
_this.partial("admin/views/no_access.tmpl", { error: error.message });
evt.partial("admin/views/no_access.tmpl", { error: error.message });
});
_this.get("#/signout", function (context) {
context.loseAccessToken();
@@ -341,27 +350,29 @@ function test_misc() {
});
_this.get('#/', function () {
_this.render('mytemplate.template', { name: 'test' });
this.render('mytemplate.template', { name: 'test' });
});
_this.send($.getJSON, '/app.json')
.then(function (json) {
$('#message').text(json['message']);
}
);
);
_this.get('#/', function () {
_this.load('myfile.txt')
var evt: Sammy.EventContext = this;
evt.load('myfile.txt')
.then(function (content) {
$('#main').html(content);
});
});
_this.get('#/', function () {
_this.load('mytext.json')
var evt: Sammy.EventContext = this;
evt.load('mytext.json')
.then(function (content) {
var context = _this,
data = JSON.parse(content);
var context = this,
data = JSON.parse(content);
context.wait();
$.post(data.url, {}, function (response) {
context.next(JSON.parse(response));
@@ -386,7 +397,8 @@ function test_misc() {
store.each(function (key, value) {
Sammy.log('key', key, 'value', value);
});
var store = new Sammy.Store;
store = new Sammy.Store();
store.exists('foo');
store.fetch('foo', function () {
return 'bar!';
@@ -396,7 +408,7 @@ function test_misc() {
return 'baz!';
});
var store = new Sammy.Store;
store = new Sammy.Store();
store.set('one', 'two');
store.set('two', 'three');
store.set('1', 'two');
@@ -404,12 +416,12 @@ function test_misc() {
return value === 'two';
});
var store = new Sammy.Store;
var store = new Sammy.Store();
store.load('mytemplate', '/mytemplate.tpl', function () {
s.get('mytemplate')
store.get('mytemplate')
});
var store = new Sammy.Store({ name: 'kvo' });
store = new Sammy.Store({ name: 'kvo' });
$('body').bind('set-kvo-foo', function (e, data) {
Sammy.log(data.key + ' changed to ' + data.value);
});
@@ -418,17 +430,19 @@ function test_misc() {
$.sammy(function () {
_this.use('Template');
_this.get('#/', function () {
_this.user = { name: 'Aaron Quint' };
_this.partial('user.template');
var evt: Sammy.EventContext = this;
// Adding a dynamic property
(<any>evt).user = { name: 'Aaron Quint' };
evt.partial('user.template');
})
});
_this.use(Sammy.Template, 'tpl');
_this.get('#/', function () {
_this.partial('myfile.tpl');
this.partial('myfile.tpl');
});
_this.get('#/', function () {
_this.template('myform.tpl', { form: "<form></form>" }, { escape_html: false });
this.template('myform.tpl', { form: "<form></form>" }, { escape_html: false });
});
}
@@ -440,21 +454,21 @@ function test_routes() {
_this.put('#/post/form', function () {
return false;
});
_thisget('/test/123', function () {
_this.get('/test/123', function () {
});
_thisget('#/by_name/:name', function () {
alert(_this.params['name']);
_this.get('#/by_name/:name', function () {
alert(this.params['name']);
});
_thisget(/\#\/by_name\/(.*)/, function () {
alert(_this.params['splat']);
_this.get(/\#\/by_name\/(.*)/, function () {
alert(this.params['splat']);
});
_thisget('#/by_name/:name', function () {
_this.redirect('#', _this.params['name']);
_this.get('#/by_name/:name', function () {
this.redirect('#', this.params['name']);
});
_thisget('#/by_name/:name', function (context) {
context.redirect('#', _this.params['name']);
_this.get('#/by_name/:name', function (context) {
context.redirect('#', this.params['name']);
});
}
@@ -466,16 +480,16 @@ function test_events() {
_this.redirect('#/');
});
var app = $.sammy(function () {
var app1 = $.sammy(function () {
var _this: Sammy.Application;
_this.bind('test', function () {
var _this: Sammy.EventContext;
_this.trigger('other-event');
});
});
app.trigger('other-event');
app1.trigger('other-event');
var app = $.sammy(function () {
var app2 = $.sammy(function () {
var _this: Sammy.Application;
_this.bind('test', function (e, data) {
alert(data['my_data']);
@@ -495,12 +509,12 @@ function test_plugins() {
}
});
};
var app = $.sammy(function () {
var app1 = $.sammy(function () {
var _this: Sammy.Application;
_this.use(MyPlugin);
_this.get('#/', function () {
var _this: Sammy.EventContext;
_this.alert("I'm home");
alert("I'm home");
});
});
var MyAdvancedPlugin = function (app, prefix, suffix) {
@@ -516,25 +530,25 @@ function test_plugins() {
var _this: Sammy.Application;
_this.use(MyAdvancedPlugin, 'BEFORE!', 'AFTER!');
_this.get('#/', function () {
_this.alert("I'm home");
alert("I'm home");
});
});
var dbLoadAndDisplay = function (app) {
var _this: Sammy.Application;
_this.get('#/', function () {
_this.record = _this.app.db[_this.app.element_selector];
_this.app.swap(_this.record.toHTML());
this.record = this.app.db[this.app.element_selector];
this.app.swap(this.record.toHTML());
});
_this.bind('run', function () {
});
};
var app1 = Sammy('#div_1', function () {
_this.use(dbLoadAndDisplay);
this.use(dbLoadAndDisplay);
});
var app2 = Sammy('#div_2', function () {
_this.use(dbLoadAndDisplay);
this.use(dbLoadAndDisplay);
});
}
+44 -15
View File
@@ -20,18 +20,20 @@ declare function Sammy(selector: string, handler: Function): Sammy.Application;
interface JQueryStatic {
sammy: SammyFunc;
log: Function;
}
declare module Sammy {
export function Cache(app, options);
export function DataCacheProxy(initial, $element);
export function DataLocationProxy(app, data_name, href_attribute);
export var DataLocationProxy:DataLocationProxy;
export function DefaultLocationProxy(app, run_interval_every);
export function EJS(app, method_alias);
export function Exceptional(app, errorReporter);
export function Flash(app);
export var FormBuilder: FormBuilder;
export function Form(app); // formFor ( name, object, content_callback )
export function Haml(app, method_alias);
@@ -49,15 +51,17 @@ declare module Sammy {
export function PushLocationProxy(app);
export function Session(app, options);
export function Storage(app);
export var Store: Store;
export function Title();
export function Template(app, method_alias);
export function Tmpl(app, method_alias);
export function addLogger(logger);
export function log();
export function log(...args:any[]);
export interface Object {
export class Object {
new (obj: any);
constructor(obj: any);
escapeHTML(s: string): string;
h(s: string): string;
@@ -82,6 +86,7 @@ declare module Sammy {
after(callback: Function): Application;
any(verb: string, path: string, callback: Function): void;
around(callback: Function): Application;
before(callback: Function): Application;
before(options: any, callback: Function): Application;
bind(name: string, callback: Function): Application;
bind(name: string, data: any, callback: Function): Application;
@@ -96,8 +101,8 @@ declare module Sammy {
get(path: string, callback: Function): Application;
get(path: RegExp, callback: Function): Application;
getLocation(): string;
helper(name: string, method: Function): Application;
helpers(extensions: any): Application;
helper(name: string, method: Function): any; // Behaviour similar to _.extend
helpers(extensions: any): any; // Behaviour similar to _.extend
isRunning(): boolean;
log(...params: any[]): void;
lookupRoute(verb: string, path: string): any;
@@ -113,19 +118,27 @@ declare module Sammy {
route(verb: string, path: RegExp, callback: Function): Application;
run(start_url?: string): Application;
runRoute(verb: string, path?: string, params?: any, target?: any): any;
send(...params: any[]);
setLocation(new_location: string): string;
setLocationProxy(new_proxy: DataLocationProxy): void;
swap(content: any, callback: Function): string;
swap(content: any, callback: Function): any;
templateCache(key: string, value: any): any;
toString(): string;
trigger(name: string, data?: any): Application;
unload(): Application;
use(...params: any[]): void;
// Features provided by oauth2 plugin
oauthorize: string;
requireOAuth();
requireOAuth(path?:string);
requireOAuth(callback?: Function);
}
export interface DataLocationProxy {
new (app, run_interval_every): DataLocationProxy;
new (app, run_interval_every?): DataLocationProxy;
new (app, data_name, href_attribute): DataLocationProxy;
fullPath(location_obj): string;
bind(): void;
@@ -142,19 +155,25 @@ declare module Sammy {
engineFor(engine: any): any;
eventNamespace(): string;
interpolate(content: any, data: any, engine: any, partials): EventContext;
json(str: any): any;
json(str: string): any;
load(location: any, options?: any, callback?: Function): any;
loadPartials(partials);
notFound(): any;
partial(location: string, data: any, callback: Function, partials): RenderContext;
params: Object;
partial(location: string, data?: any, callback?: Function, partials?): RenderContext;
partials: any;
params: any;
redirect(...params: any[]): void;
render(location: string, data: any, callback: Function, partials): RenderContext;
renderEach(location: any, name?: string, data?: any, callback?: Function): RenderContext;
render(location: string, data?: any, callback?: Function, partials?): RenderContext;
renderEach(location: any, data?: { name: string;data?:any}[],callback?: Function): RenderContext;
send(...params: any[]): RenderContext;
swap(contents: any, callback: Function): string;
toString(): string;
trigger(name: string, data?: any): EventContext;
// Provided by common sammy modules:
name: any;
title: any;
}
export interface FormBuilder {
@@ -186,6 +205,16 @@ declare module Sammy {
track(path);
}
export interface Haml extends EventContext { }
export interface Handlebars extends EventContext { }
export interface Hogan extends EventContext { }
export interface JSON extends EventContext { }
export interface Mustache extends EventContext { }
export interface RenderContext extends Object {
new (event_context);
@@ -204,10 +233,10 @@ declare module Sammy {
render(location: string, callback: Function, partials?: any): RenderContext;
render(location: string, data: any, callback: Function): RenderContext;
render(location: string, data: any, callback: Function, partials: any): RenderContext;
renderEach(location: string, name: string, data: any, callback: Function): RenderContext;
renderEach(location: string, name?: string, data?: any, callback?: Function): RenderContext;
replace(selector: string): RenderContext;
send(...params: any[]): RenderContext;
swap(callback: Function): RenderContext;
swap(callback?: Function): RenderContext;
then(callback: Function): RenderContext;
trigger(name, data);
wait(): void;
@@ -228,7 +257,7 @@ declare module Sammy {
stores: any;
new (options);
new (options?:any);
clear(key: string): any;
clearAll(): void;
+9737 -5611
View File
File diff suppressed because it is too large Load Diff
+41
View File
@@ -0,0 +1,41 @@
/// <reference path="siesta.d.ts" />
StartTest(function (t: Siesta.Test.ExtJS) {
t.waitForComponentQuery('#myItemId', () => {
t.ajaxRequestAndThen('http://some/url', () => {
t.isBoolean(123, 'not a boolean');
}, null);
}, null, 2000);
});
startTest(function (t: Siesta.Test.Browser) {
t.waitForSelectors(['.class', '#id'], () => { });
});
describe(function (t: Siesta.Test.jQuery) {
var library = t.get$();
t.describe('My Module', () => {
t.it('should do something', () => {
t.expect('some string').not.toBe('some other string');
});
});
});
var Harness = Siesta.Harness.Browser;
Harness.start({
group: 'MyGroup',
items: [
'test-script01.js',
'test-script02.js',
{
url: 'http://somesite.com/test-script03.js',
preload: [{
type: 'css',
url: 'http://somesite.com/test-script03.ashx'
}]
}
],
option1: true
});
+1071
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -59,7 +59,7 @@ interface SinonSpy extends SinonSpyCallApi {
calledBefore(anotherSpy: SinonSpy): boolean;
calledAfter(anotherSpy: SinonSpy): boolean;
calledWithNew(spy: SinonSpy): boolean;
withArgs(...args: any[]): void;
withArgs(...args: any[]): SinonSpy;
alwaysCalledOn(obj: any);
alwaysCalledWith(...args: any[]);
alwaysCalledWithExactly(...args: any[]);
@@ -109,6 +109,7 @@ interface SinonStub extends SinonSpy {
yieldsOnAsync(context: any, ...args: any[]): SinonStub;
yieldsToAsync(property: string, ...args: any[]): SinonStub;
yieldsToOnAsync(property: string, context: any, ...args: any[]): SinonStub;
withArgs(...args: any[]): SinonStub;
}
interface SinonStubStatic {
+57 -57
View File
@@ -496,15 +496,15 @@ declare module Slick {
**/
width?: number;
}
export interface EditorFactory {
getEditor(column): Editors.Editor;
}
export interface FormatterFactory<T extends Slick.SlickData> {
getFormatter(column: Column<T>): Formatter;
getFormatter(column: Column<T>): Formatter<any>;
}
export interface GridOptions<T extends Slick.SlickData> {
/**
@@ -518,7 +518,7 @@ declare module Slick {
asyncEditorLoadDelay?: number;
/**
*
*
**/
asyncPostRenderDelay?: number;
@@ -528,7 +528,7 @@ declare module Slick {
autoEdit?: boolean;
/**
*
*
**/
autoHeight?: boolean;
@@ -543,22 +543,22 @@ declare module Slick {
cellHighlightCssClass?: string;
/**
*
*
**/
dataItemColumnValueExtractor?: any;
/**
*
*
**/
defaultColumnWidth?: number;
/**
*
*
**/
defaultFormatter?: Formatter<T>;
/**
*
*
**/
editable?: boolean;
@@ -598,7 +598,7 @@ declare module Slick {
enableCellNavigation?: boolean;
/**
*
*
**/
enableColumnReorder?: boolean;
@@ -608,7 +608,7 @@ declare module Slick {
enableRowReordering?: any;
/**
*
*
**/
enableTextSelectionOnCells?: boolean;
@@ -623,7 +623,7 @@ declare module Slick {
forceFitColumns?: boolean;
/**
*
*
**/
forceSyncScrolling?: boolean;
@@ -638,12 +638,12 @@ declare module Slick {
fullWidthRows?: boolean;
/**
*
*
**/
headerRowHeight?: number;
/**
*
*
**/
leaveSpaceForNewRows?: boolean;
@@ -653,22 +653,22 @@ declare module Slick {
multiColumnSort?: boolean;
/**
*
*
**/
multiSelect?: boolean;
/**
*
*
**/
rowHeight?: number;
/**
*
*
**/
selectedCellCssClass?: string;
/**
*
*
**/
showHeaderRow?: boolean;
@@ -678,11 +678,11 @@ declare module Slick {
syncColumnCellResize?: boolean;
/**
*
*
**/
topPanelHeight?: number;
}
export interface DataProvider {
getItem(index: number): SlickData;
getLength(): number;
@@ -697,7 +697,7 @@ declare module Slick {
* Selection models are controllers responsible for handling user interactions and notifying subscribers of the changes in the selection. Selection is represented as an array of Slick.Range objects.
* You can get the current selection model from the grid by calling getSelectionModel() and set a different one using setSelectionModel(selectionModel). By default, no selection model is set.
* The grid also provides two helper methods to simplify development - getSelectedRows() and setSelectedRows(rowsArray), as well as an onSelectedRowsChanged event.
* SlickGrid includes two pre-made selection models - Slick.CellSelectionModel and Slick.RowSelectionModel, but you can easily write a custom one.
* SlickGrid includes two pre-made selection models - Slick.CellSelectionModel and Slick.RowSelectionModel, but you can easily write a custom one.
**/
export class SelectionModel<T extends Slick.SlickData, E> {
/**
@@ -712,7 +712,7 @@ declare module Slick {
onSelectedRangesChanged: Slick.SlickEvent<E>;
}
export class Grid<T extends SlickData> {
/**
@@ -765,7 +765,7 @@ declare module Slick {
//public getData(): DataView;
/**
* Returns the databinding item at a given position.
* Returns the databinding item at a given position.
* @param index Item index.
* @return
**/
@@ -774,12 +774,12 @@ declare module Slick {
/**
* Sets a new source for databinding and removes all rendered rows. Note that this doesn't render the new rows - you can follow it with a call to render() to do that.
* @param newData New databinding source. This can either be a regular JavaScript array or a custom object exposing getItem(index) and getLength() functions.
* @param scrollToTop If true, the grid will reset the vertical scroll position to the top of the grid.
* @param scrollToTop If true, the grid will reset the vertical scroll position to the top of the grid.
**/
public setData(newData: T[], scrollToTop: boolean): void;
/**
* Returns the size of the databinding source.
* Returns the size of the databinding source.
* @return
**/
public getDataLength(): number;
@@ -788,7 +788,7 @@ declare module Slick {
* Returns an object containing all of the Grid options set on the grid. See a list of Grid Options here.
* @return
**/
public getOptions(): GridOptions;
public getOptions(): GridOptions<any>;
/**
* Returns an array of row indices corresponding to the currently selected rows.
@@ -800,16 +800,16 @@ declare module Slick {
* Returns the current SelectionModel. See here for more information about SelectionModels.
* @return
**/
public getSelectionModel(): SelectionModel;
public getSelectionModel(): SelectionModel<any, any>;
/**
* Extends grid options with a given hash. If an there is an active edit, the grid will attempt to commit the changes and only continue if the attempt succeeds.
* Extends grid options with a given hash. If an there is an active edit, the grid will attempt to commit the changes and only continue if the attempt succeeds.
* @options An object with configuration options.
**/
public setOptions(options: GridOptions<T>): void;
/**
* Accepts an array of row indices and applies the current selectedCellCssClass to the cells in the row, respecting whether cells have been flagged as selectable.
* Accepts an array of row indices and applies the current selectedCellCssClass to the cells in the row, respecting whether cells have been flagged as selectable.
* @param rowsArray An array of row numbers.
**/
public setSelectedRows(rowsArray: number[]): void;
@@ -843,7 +843,7 @@ declare module Slick {
public getColumns(): Column[];
/**
* Sets grid columns. Column headers will be recreated and all rendered rows will be removed. To rerender the grid (if necessary), call render().
* Sets grid columns. Column headers will be recreated and all rendered rows will be removed. To rerender the grid (if necessary), call render().
* @param columnDefinitions An array of column definitions.
**/
public setColumns(columnDefinitions: Column[]): void;
@@ -868,7 +868,7 @@ declare module Slick {
public getSortColumns(): Column[];
/**
* Updates an existing column definition and a corresponding header DOM element with the new title and tooltip.
* Updates an existing column definition and a corresponding header DOM element with the new title and tooltip.
* @param columnId Column id.
* @param title New column name.
* @param toolTip New column tooltip.
@@ -913,7 +913,7 @@ declare module Slick {
public canCellBeSelected(row: number, col: number): boolean;
/**
* Attempts to switch the active cell into edit mode. Will throw an error if the cell is set to be not editable. Uses the specified editor, otherwise defaults to any default editor for that given cell.
* Attempts to switch the active cell into edit mode. Will throw an error if the cell is set to be not editable. Uses the specified editor, otherwise defaults to any default editor for that given cell.
* @param editor A SlickGrid editor (see examples in slick.editors.js).
**/
public editActiveCell(editor: Editors.Editor<T>): void;
@@ -927,10 +927,10 @@ declare module Slick {
public flashCell(row: number, cell: number, speed?: number): void;
/**
* Returns an object representing the coordinates of the currently active cell:
* Returns an object representing the coordinates of the currently active cell:
* @example
* {
* row: activeRow,
* row: activeRow,
* cell: activeCell
* }
* @return
@@ -938,7 +938,7 @@ declare module Slick {
public getActiveCell(): Cell;
/**
* Returns the DOM element containing the currently active cell. If no cell is active, null is returned.
* Returns the DOM element containing the currently active cell. If no cell is active, null is returned.
* @return
**/
public getActiveCellNode(): HTMLElement;
@@ -960,7 +960,7 @@ declare module Slick {
* Returns the active cell editor. If there is no actively edited cell, null is returned.
* @return
**/
public getCellEditor(): Editors.Editor;
public getCellEditor(): Editors.Editor<any>;
/**
* Returns a hash containing row and cell indexes from a standard W3C/jQuery event.
@@ -1002,7 +1002,7 @@ declare module Slick {
* @return
**/
public gotoCell(row: number, cell: number, forceEdit?: boolean): void;
/**
* todo: no docs
* @return
@@ -1032,7 +1032,7 @@ declare module Slick {
* @param columnId
* @return
**/
public getHeaderRowColumn(columnId: string): Column;
public getHeaderRowColumn(columnId: string): Column<any>;
/**
* todo: no docs
@@ -1045,7 +1045,7 @@ declare module Slick {
* @return
**/
public navigateDown(): boolean;
/**
* Switches the active cell one cell left skipping unselectable cells. Unline navigatePrev, navigateLeft stops at the first cell of the row. Returns a boolean saying whether it was able to complete or not.
* @return
@@ -1103,7 +1103,7 @@ declare module Slick {
* @param hash A hash of additional cell CSS classes keyed by row number and then by column id. Multiple CSS classes can be specified and separated by space.
**/
public setCellCssStyles(key: string, hash: CellCssStylesHash): void;
// #endregion Cells
// #region Events
@@ -1171,8 +1171,8 @@ declare module Slick {
// #region Editors
public getEditorLock(): EditorLock;
public getEditController(): Editors.Editor;
public getEditorLock(): EditorLock<any>;
public getEditController(): Editors.Editor<any>;
// #endregion Editors
}
@@ -1241,7 +1241,7 @@ declare module Slick {
}
export interface OnColumnsReorderedEventData {
}
export interface OnValidationErrorEventData<T extends SlickData> {
@@ -1316,13 +1316,13 @@ declare module Slick {
export interface OnHeaderMouseEventData<T extends SlickData> {
column: Column<T>;
}
// todo: merge with existing column definition
export interface Column {
sortCol?: string;
sortAsc?: boolean;
}
export interface OnSortEventData<T extends SlickData> {
multiColumnSort: boolean;
sortCol?: Column<T>;
@@ -1378,7 +1378,7 @@ declare module Slick {
container: HTMLElement;
grid: Grid<T>;
}
export class Editor<T extends Slick.SlickData> {
constructor(args: EditorOptions<T>);
public init(): void;
@@ -1393,7 +1393,7 @@ declare module Slick {
export class Text<T extends Slick.SlickData> extends Editor<T> {
constructor(args: EditorOptions<T>);
public getValue(): string;
public setValue(val: string): void;
public serializeValue(): string;
@@ -1434,7 +1434,7 @@ declare module Slick {
export class LongText<T extends Slick.SlickData> extends Editor<T> {
constructor(args: EditorOptions<T>);
public handleKeyDown(e: Event): void;
public save(): void;
public cancel(): void;
@@ -1446,7 +1446,7 @@ declare module Slick {
}
export interface Formatter<T extends Slick.SlickData> {
(row: number, cell: number, columnDef: Column<T>, dataContext: SlickData): string;
(row: number, cell: number, value: any, columnDef: Column<T>, dataContext: SlickData): string;
}
export module Formatters {
@@ -1459,15 +1459,15 @@ declare module Slick {
export module Data {
export interface DataViewOptions<T extends Slick.SlickData> {
groupItemMetadataProvider: GroupItemMetadataProvider<T>;
inlineFilters: boolean;
groupItemMetadataProvider?: GroupItemMetadataProvider<T>;
inlineFilters?: boolean;
}
/**
* Item -> Data by index
* Row -> Data by row
**/
export class DataView<T extends Slick.SlickData> {
export class DataView<T extends Slick.SlickData> implements DataProvider {
constructor(options: DataViewOptions<T>);
@@ -1489,12 +1489,12 @@ declare module Slick {
* @deprecated
**/
public groupBy(valueGetter, valueFormatter, sortComparer): void;
/**
* @deprecated
**/
public setAggregators(groupAggregators, includeCollapsed): void;
/**
* @param level Optional level to collapse. If not specified, applies to all levels.
**/
@@ -1537,7 +1537,7 @@ declare module Slick {
public syncGridCellCssStyles(grid: Grid<T>, key: string): void;
public getLength(): number;
public getItem(): void;
public getItem(index: number): SlickData;
public getItemMetadata(): void;
public onRowCountChanged: Slick.SlickEvent<OnRowCountChangedEventData>;
@@ -1596,11 +1596,11 @@ declare module Slick {
}
export class Min<T> extends Aggregator<T> {
}
export class Max<T> extends Aggregator<T> {
}
export class Sum<T> extends Aggregator<T> {
+12
View File
@@ -0,0 +1,12 @@
/// <reference path="superagent.d.ts" />
import superagent = require('superagent')
var agent = superagent.agent();
agent
.post('http://localhost:3000/signin')
.send({ email: 'test@dummy.com', password: 'bacon' })
.end((err, res) => {
if (err) throw err;
if (res.status !== 200) throw new Error('bad status ' + res.status);
});
+84
View File
@@ -0,0 +1,84 @@
// Type definitions for SuperAgent 0.15.4
// Project: https://github.com/visionmedia/superagent
// Definitions by: Alex Varju <https://github.com/varju/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../node/node.d.ts' />
declare module "superagent" {
export interface Response {
text: string;
body: Object;
header: Object;
type: string;
charset: string;
status: number;
statusType: number;
info: boolean;
ok: boolean;
redirect: boolean;
clientError: boolean;
serverError: boolean;
error: any;
accepted: boolean;
noContent: boolean;
badRequest: boolean;
unauthorized: boolean;
notAcceptable: boolean;
notFound: boolean;
forbidden: boolean;
get(header: string): string;
}
export interface Request {
attach(field: string, file: string, filename: string): Request;
redirects(n: number): Request;
part(): Request;
set(field: string, val: string): Request;
set(field: Object): Request;
get(field: string): string;
type(val: string): Request;
query(val: Object): Request;
send(data: string): Request;
send(data: Object): Request;
write(data: string, encoding: string): boolean;
write(data: NodeBuffer, encoding: string): boolean;
pipe(stream: WritableStream, options?: Object): WritableStream;
buffer(val: boolean): Request;
timeout(ms: number): Request;
clearTimeout(): Request;
abort(): void;
auth(user: string, name: string): Request;
field(name: string, val: string): Request;
end(callback?: (err: Error, res: Response) => void): Request;
}
export interface Agent {
get(url: string, callback?: (err: Error, res: Response) => void): Request;
post(url: string, callback?: (err: Error, res: Response) => void): Request;
put(url: string, callback?: (err: Error, res: Response) => void): Request;
head(url: string, callback?: (err: Error, res: Response) => void): Request;
del(url: string, callback?: (err: Error, res: Response) => void): Request;
options(url: string, callback?: (err: Error, res: Response) => void): Request;
trace(url: string, callback?: (err: Error, res: Response) => void): Request;
copy(url: string, callback?: (err: Error, res: Response) => void): Request;
lock(url: string, callback?: (err: Error, res: Response) => void): Request;
mkcol(url: string, callback?: (err: Error, res: Response) => void): Request;
move(url: string, callback?: (err: Error, res: Response) => void): Request;
propfind(url: string, callback?: (err: Error, res: Response) => void): Request;
proppatch(url: string, callback?: (err: Error, res: Response) => void): Request;
unlock(url: string, callback?: (err: Error, res: Response) => void): Request;
report(url: string, callback?: (err: Error, res: Response) => void): Request;
mkactivity(url: string, callback?: (err: Error, res: Response) => void): Request;
checkout(url: string, callback?: (err: Error, res: Response) => void): Request;
merge(url: string, callback?: (err: Error, res: Response) => void): Request;
//m-search(url: string, callback?: (err: Error, res: Response) => void): Request;
notify(url: string, callback?: (err: Error, res: Response) => void): Request;
subscribe(url: string, callback?: (err: Error, res: Response) => void): Request;
unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Request;
patch(url: string, callback?: (err: Error, res: Response) => void): Request;
parse(fn: Function): Request;
}
export function agent(): Agent;
}
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="supertest.d.ts" />
/// <reference path="../express/express.d.ts" />
import supertest = require('supertest')
import express = require('express');
var app = express();
supertest(app)
.get('/user')
.expect('Content-Type', /json/)
.expect('Content-Length', '20')
.expect(201)
.end((err, res) => {
if (err) throw err;
});
+53
View File
@@ -0,0 +1,53 @@
// Type definitions for SuperTest 0.8.0
// Project: https://github.com/visionmedia/supertest
// Definitions by: Alex Varju <https://github.com/varju/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../superagent/superagent.d.ts' />
declare module "supertest" {
import superagent = require('superagent');
module supertest {
interface Test extends superagent.Request {
url: string;
serverAddress(app: any, path: string): string;
expect(status: number, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(status: number, body: string, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(body: string, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(body: RegExp, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(body: Object, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(field: string, val: string, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(field: string, val: RegExp, callback?: (err: Error, res: superagent.Response) => void): Test;
}
interface SuperTest {
get(url: string): Test;
post(url: string): Test;
put(url: string): Test;
head(url: string): Test;
del(url: string): Test;
options(url: string): Test;
trace(url: string): Test;
copy(url: string): Test;
lock(url: string): Test;
mkcol(url: string): Test;
move(url: string): Test;
propfind(url: string): Test;
proppatch(url: string): Test;
unlock(url: string): Test;
report(url: string): Test;
mkactivity(url: string): Test;
checkout(url: string): Test;
merge(url: string): Test;
//m-search(url: string): Test;
notify(url: string): Test;
subscribe(url: string): Test;
unsubscribe(url: string): Test;
patch(url: string): Test;
}
}
function supertest(app: any): supertest.SuperTest;
export = supertest;
}
+3
View File
@@ -62,6 +62,9 @@ declare module WinJS {
function start(): void;
function stop(): void;
}
class ErrorFromName {
constructor(name: string, message?: string);
}
class Promise<T> {
constructor(init: (c: any, e: any, p: any) => void);
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void ): Promise<U>;