This commit is contained in:
Christiaan Rakowski
2013-07-01 22:15:35 +02:00
18 changed files with 522 additions and 639 deletions
+95
View File
@@ -0,0 +1,95 @@
box2dweb.d.ts
===========
This is a derived work of the original Box2D C++ located here: http://box2d.org/
This is a typescript definitions file for box2dweb.js located here: http://code.google.com/p/box2dweb/
There are a few ports of Box2D to javascript, I have specifically picked box2dweb.js since it has zero dependencies and can be linked to your project via a single file. It also appears to be the most up to date with box2d and is a direct automated port from Box2DFlash (http://www.box2dflash.org/)
Basic Usage
==========
Import Statements
-----------------
Reference the box2dweb.d.ts file in your project and in an appropriate location include the following import statements to reduce the amount of typing you will need to do to acccess deeply nested modules.
```typescript
/// <reference path="box2dweb.d.ts" />
// Include the following imports, or add more/less, to reduce the module nesting.
import b2Common = Box2D.Common;
import b2Math = Box2D.Common.Math;
import b2Collision = Box2D.Collision;
import b2Shapes = Box2D.Collision.Shapes;
import b2Dynamics = Box2D.Dynamics;
import b2Contacts = Box2D.Dynamics.Contacts;
import b2Controllers = Box2D.Dynamics.Controllers;
import b2Joints = Box2D.Dynamics.Joints;
```
Debug Drawing
-------------
Notes from Box2DWeb
Although Box2D is a physics engine and therefore has nothing to do with drawing, Box2dFlash provides such methods for debugging which are defined in the b2DebugDraw class. In Box2dWeb, a b2DebugDraw takes a canvas-context instead of a Sprite:
```typescript
var debugDraw = new Box2D.Dynamics.b2DebugDraw();
debugDraw.SetSprite(document.getElementsByTagName("canvas")[0].getContext("2d"));
```
Events
------
Notes from Box2DWeb
You have to implement event-interfaces in Box2dFlash. Since Javascript doesn't support classical inheritance natively, I show you how to deal with events in Box2dWeb:
```typescript
var world = new Box2D.Dynamics.b2World(new Box2D.Common.Math.b2Vec2(0, 10), true);
/* ... add bodies, etc. ... */
var myListener = new Box2D.Dynamics.b2DestructionListener;
myListener.SayGoodbyeFixture = function(fixture) {
alert("goodbye fixture ...");
}
world.SetDestructionListener(myListener);
```
Change Log
==========
2.1a 2013/06/28
---------------
* Upgraded to TypeScript v0.9
* Removed import statements so the user can now declare the smaller namespaces in their code. Before the import statements were not 'exported', so they appeared as 'any' objects.
License
=======
Box2DWeb-2.1.d.ts Copyright (c) 2012 Josh Baldwin http://github.com/jbaldwin/box2dweb.d.ts
There are a few competing javascript Box2D ports.
This definitions file is for Box2dWeb.js ->
http://code.google.com/p/box2dweb/
Box2D C++ Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="box2dweb.d.ts" />
import b2Common = Box2D.Common;
import b2Math = Box2D.Common.Math;
import b2Collision = Box2D.Collision;
import b2Shapes = Box2D.Collision.Shapes;
import b2Dynamics = Box2D.Dynamics;
import b2Contacts = Box2D.Dynamics.Contacts;
import b2Controllers = Box2D.Dynamics.Controllers;
import b2Joints = Box2D.Dynamics.Joints;
var w1 = new Box2D.Dynamics.b2World(new Box2D.Common.Math.b2Vec2(0, 10), true);
var w2 = new b2Dynamics.b2World(new b2Math.b2Vec2(0, 10), true);
var debugDraw = new Box2D.Dynamics.b2DebugDraw();
debugDraw.SetSprite(document.getElementsByTagName("canvas")[0].getContext("2d"));
+209 -220
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,7 +1,7 @@
/// <reference path="breeze-1.0.d.ts" />
import breeze = module(Breeze);
import core = module(BreezeCore);
import breeze = Breeze;
import core = BreezeCore;
function test_dataType() {
var typ = breeze.DataType.DateTime;
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference path="breeze.d.ts" />
import core = module(breezeCore);
import core = breezeCore;
function test_dataType() {
var typ = breeze.DataType.DateTime;
+1 -1
View File
@@ -748,7 +748,7 @@ declare module breeze {
constructor (name: string, validatorFn: ValidatorFunction, context?: any);
static boolean(): Validator;
static bool(): Validator;
static byte(): Validator;
static date(): Validator;
static duration(): Validator;
+12 -219
View File
@@ -780,6 +780,10 @@ interface ExpressServerResponse {
charset: string;
}
interface ExpressRequestFunction {
(req: ExpressServerRequest, res: ExpressServerResponse, next: Function): any;
}
interface ExpressApplication {
/**
* Initialize the server.
@@ -1020,228 +1024,17 @@ interface ExpressApplication {
render(name: string, fn: Function);
get (name: string): any;
get(name: string, ...handlers: ExpressRequestFunction[]): any;
get(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
get (name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: string, ...handlers: ExpressRequestFunction[]): any;
post(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
get (name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: string, ...handlers: ExpressRequestFunction[]): any;
put(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
get (name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
get (name: RegExp): any;
get (name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
get (name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
post(name: string): any;
post(name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
post(name: RegExp): any;
post(name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
post(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
put(name: string): any;
put(name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
put(name: RegExp): any;
put(name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
put(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
del(name: string): any;
del(name: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: string,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
del(name: RegExp): any;
del(name: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any): any;
del(name: RegExp,
handler: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler2: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler3: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler4: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
handler5: (req: ExpressServerRequest, res: ExpressServerResponse, next: Function) => any,
...handlers: any[]): any;
del(name: string, ...handlers: ExpressRequestFunction[]): any;
del(name: RegExp, ...handlers: ExpressRequestFunction[]): any;
/**
* Listen for connections.
+1
View File
@@ -40,6 +40,7 @@ $('#example3').glDatePicker(
{
date: new Date(0, 0, 1),
data: { message: 'Happy New Year!' },
repeatMonth: false,
repeatYear: true
},
],
+7 -7
View File
@@ -24,7 +24,7 @@ class Assert {
static passedTests: number = 0;
static Results() {
console.log('Tests succeeded - ' + passedTests + '/' + totalTests + '; Tests failed - ' + (totalTests - passedTests) + '/' + totalTests);
console.log('Tests succeeded - ' + this.passedTests + '/' + this.totalTests + '; Tests failed - ' + (this.totalTests - this.passedTests) + '/' + this.totalTests);
}
static AssertionFailed(actual: any, expected: any, test: string) {
@@ -32,21 +32,21 @@ class Assert {
}
static Equal(actual: any, expected: any, test?: string) {
totalTests++;
this.totalTests++;
if (actual === expected) {
passedTests++;
this.passedTests++;
return;
}
AssertionFailed(actual, expected, test);
this.AssertionFailed(actual, expected, test);
}
static NotEqual(actual: any, expected: any, test?: string) {
totalTests++;
this.totalTests++;
if (actual !== expected) {
passedTests++;
this.passedTests++;
return;
}
AssertionFailed(actual, expected, test);
this.AssertionFailed(actual, expected, test);
}
}
+20 -20
View File
@@ -190,7 +190,7 @@ interface JQuerySupport {
interface JQueryParam {
(obj: any): string;
(obj: any, traditional: bool): string;
(obj: any, traditional: boolean): string;
}
/*
@@ -224,7 +224,7 @@ interface JQueryStatic {
Callbacks(flags?: string): JQueryCallback;
// Core
holdReady(hold: bool): any;
holdReady(hold: boolean): any;
(selector: string, context?: any): JQuery;
(element: Element): JQuery;
@@ -235,7 +235,7 @@ interface JQueryStatic {
(array: any[]): JQuery;
(): JQuery;
noConflict(removeAll?: bool): Object;
noConflict(removeAll?: boolean): Object;
when(...deferreds: any[]): JQueryPromise;
@@ -296,11 +296,11 @@ interface JQueryStatic {
each<T>(collection: T[], callback: (indexInArray: number, valueOfElement: T) => any): any;
extend(target: any, ...objs: any[]): Object;
extend(deep: bool, target: any, ...objs: any[]): Object;
extend(deep: boolean, target: any, ...objs: any[]): Object;
globalEval(code: string): any;
grep<T>(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: bool): T[];
grep<T>(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[];
inArray<T>(value: T, array: T[], fromIndex?: number): number;
@@ -336,15 +336,15 @@ interface JQueryStatic {
type(obj: any): string;
unique(arr: any[]): any[];
/**
/**
* Parses a string into an array of DOM nodes.
*
* @param data HTML string to be parsed
* @param context DOM element to serve as the context in which the HTML fragment will be created
* @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
*/
parseHTML(data: string, context?: HTMLElement, keepScripts?: bool): any[];
parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[];
}
/*
@@ -396,8 +396,8 @@ interface JQuery {
removeProp(propertyName: any): JQuery;
toggleClass(className: any, swtch?: bool): JQuery;
toggleClass(swtch?: bool): JQuery;
toggleClass(className: any, swtch?: boolean): JQuery;
toggleClass(swtch?: boolean): JQuery;
toggleClass(func: (index: any, cls: any, swtch: any) => any): JQuery;
val(): any;
@@ -425,8 +425,8 @@ interface JQuery {
offset(coordinates: any): JQuery;
offset(func: (index: any, coords: any) => any): JQuery;
outerHeight(includeMargin?: bool): number;
outerWidth(includeMargin?: bool): number;
outerHeight(includeMargin?: boolean): number;
outerWidth(includeMargin?: boolean): number;
position(): { top: number; left: number; };
@@ -491,17 +491,17 @@ interface JQuery {
slideUp(duration?: any, callback?: any): JQuery;
slideUp(duration?: any, easing?: string, callback?: any): JQuery;
stop(clearQueue?: bool, jumpToEnd?: bool): JQuery;
stop(queue?: any, clearQueue?: bool, jumpToEnd?: bool): JQuery;
stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery;
stop(queue?: any, clearQueue?: boolean, jumpToEnd?: boolean): JQuery;
toggle(duration?: any, callback?: any): JQuery;
toggle(duration?: any, easing?: string, callback?: any): JQuery;
toggle(showOrHide: bool): JQuery;
toggle(showOrHide: boolean): JQuery;
// Events
bind(eventType: string, eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
bind(eventType: string, eventData: any, preventBubble: bool): JQuery;
bind(eventType: string, preventBubble: bool): JQuery;
bind(eventType: string, eventData: any, preventBubble: boolean): JQuery;
bind(eventType: string, preventBubble: boolean): JQuery;
bind(...events: any[]);
blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
@@ -603,7 +603,7 @@ interface JQuery {
triggerHandler(eventType: string, ...extraParameters: any[]): Object;
unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
unbind(eventType: string, fls: bool): JQuery;
unbind(eventType: string, fls: boolean): JQuery;
unbind(evt: any): JQuery;
undelegate(): JQuery;
@@ -636,7 +636,7 @@ interface JQuery {
before(...content: any[]): JQuery;
before(func: (index: any) => any);
clone(withDataAndEvents?: bool, deepWithDataAndEvents?: bool): JQuery;
clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery;
detach(selector?: any): JQuery;
@@ -770,4 +770,4 @@ interface JQuery {
}
declare var jQuery: JQueryStatic;
declare var $: JQueryStatic;
declare var $: JQueryStatic;
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference path="LeapMotionTS.d.ts" />
import Leap = module('../LeapMotionTS');
import Leap = module('LeapMotionTS');
var controller: Leap.Controller = new Leap.Controller();
controller.addEventListener(Leap.LeapEvent.LEAPMOTION_FRAME, (event: Leap.LeapEvent) => {
+73 -73
View File
@@ -1,4 +1,4 @@
// Type definitions for Moment.js 1.7
// Type definitions for Moment.js 2.0.0
// Project: https://github.com/timrwood/moment
// Definitions by: Michael Lakerveld <https://github.com/Lakerfield>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
@@ -56,7 +56,7 @@ interface Moment {
format(format: string): string;
format(): string;
fromNow(withoutSuffix?: bool): string;
fromNow(withoutSuffix?: boolean): string;
startOf(soort: string): Moment;
endOf(soort: string): Moment;
@@ -75,7 +75,7 @@ interface Moment {
utc(): Moment; // current date/time in UTC mode
isValid(): bool;
isValid(): boolean;
year(y: number): Moment;
year(): number;
@@ -98,58 +98,58 @@ interface Moment {
eod(): Moment; // End of Day
from(f: Moment): string;
from(f: Moment, suffix: bool): string;
from(f: Moment, suffix: boolean): string;
from(d: Date): string;
from(s: string): string;
from(date: number[]): string;
diff(b: Moment): number;
diff(b: Moment, soort: string): number;
diff(b: Moment, soort: string, round: bool): number;
diff(b: Moment, soort: string, round: boolean): number;
toDate(): Date;
unix(): number;
isLeapYear(): bool;
isLeapYear(): boolean;
zone(): number;
daysInMonth(): number;
isDST(): bool;
isDST(): boolean;
isBefore(b: Moment): bool;
isBefore(b: string): bool;
isBefore(b: Number): bool;
isBefore(b: Date): bool;
isBefore(b: Array): bool;
isBefore(b: Moment, granularity: string): bool;
isBefore(b: String, granularity: string): bool;
isBefore(b: Number, granularity: string): bool;
isBefore(b: Date, granularity: string): bool;
isBefore(b: Array, granularity: string): bool;
isBefore(b: Moment): boolean;
isBefore(b: string): boolean;
isBefore(b: Number): boolean;
isBefore(b: Date): boolean;
isBefore(b: Array): boolean;
isBefore(b: Moment, granularity: string): boolean;
isBefore(b: String, granularity: string): boolean;
isBefore(b: Number, granularity: string): boolean;
isBefore(b: Date, granularity: string): boolean;
isBefore(b: Array, granularity: string): boolean;
isAfter(b: Moment): bool;
isAfter(b: string): bool;
isAfter(b: Number): bool;
isAfter(b: Date): bool;
isAfter(b: Array): bool;
isAfter(b: Moment, granularity: string): bool;
isAfter(b: String, granularity: string): bool;
isAfter(b: Number, granularity: string): bool;
isAfter(b: Date, granularity: string): bool;
isAfter(b: Array, granularity: string): bool;
isAfter(b: Moment): boolean;
isAfter(b: string): boolean;
isAfter(b: Number): boolean;
isAfter(b: Date): boolean;
isAfter(b: Array): boolean;
isAfter(b: Moment, granularity: string): boolean;
isAfter(b: String, granularity: string): boolean;
isAfter(b: Number, granularity: string): boolean;
isAfter(b: Date, granularity: string): boolean;
isAfter(b: Array, granularity: string): boolean;
isSame(b: Moment): bool;
isSame(b: string): bool;
isSame(b: Number): bool;
isSame(b: Date): bool;
isSame(b: Array): bool;
isSame(b: Moment, granularity: string): bool;
isSame(b: String, granularity: string): bool;
isSame(b: Number, granularity: string): bool;
isSame(b: Date, granularity: string): bool;
isSame(b: Array, granularity: string): bool;
isSame(b: Moment): boolean;
isSame(b: string): boolean;
isSame(b: Number): boolean;
isSame(b: Date): boolean;
isSame(b: Array): boolean;
isSame(b: Moment, granularity: string): boolean;
isSame(b: String, granularity: string): boolean;
isSame(b: Number, granularity: string): boolean;
isSame(b: Date, granularity: string): boolean;
isSame(b: Array, granularity: string): boolean;
lang(language: string);
lang(reset: bool);
lang(reset: boolean);
lang(): string;
}
@@ -174,7 +174,7 @@ interface MomentLanguage {
weekdaysMin?: any;
longDateFormat?: MomentLongDateFormat;
relativeTime?: MomentRelativeTime;
meridiem?: (hour: number, minute: number, isLowercase: bool) => string;
meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
calendar?: MomentCalendar;
ordinal?: (num: number) => string;
@@ -196,7 +196,7 @@ interface MomentLongDateFormat {
}
interface MomentRelativeTime {
future: any;
past: any;
s: any;
@@ -233,8 +233,8 @@ interface MomentStatic {
utc(String: string): Moment; // parse string into UTC mode
utc(String1: string, String2: string): Moment; // parse a string and format into UTC mode
isMoment(): bool;
isMoment(m: any): bool;
isMoment(): boolean;
isMoment(m: any): boolean;
lang(language: string);
lang(language: string, definition: MomentLanguage);
months: string[];
@@ -244,7 +244,7 @@ interface MomentStatic {
weekdaysMin: string[];
longDateFormat: any;
relativeTime: any;
meridiem: (hour: number, minute: number, isLowercase: bool) => string;
meridiem: (hour: number, minute: number, isLowercase: boolean) => string;
calendar: any;
ordinal: (num: number) => string;
@@ -254,38 +254,38 @@ interface MomentStatic {
duration(object: any): Duration;
duration(): Duration;
isBefore(b: Moment): bool;
isBefore(b: string): bool;
isBefore(b: Number): bool;
isBefore(b: Date): bool;
isBefore(b: Array): bool;
isBefore(b: Moment, granularity: string): bool;
isBefore(b: String, granularity: string): bool;
isBefore(b: Number, granularity: string): bool;
isBefore(b: Date, granularity: string): bool;
isBefore(b: Array, granularity: string): bool;
isBefore(b: Moment): boolean;
isBefore(b: string): boolean;
isBefore(b: Number): boolean;
isBefore(b: Date): boolean;
isBefore(b: Array): boolean;
isBefore(b: Moment, granularity: string): boolean;
isBefore(b: String, granularity: string): boolean;
isBefore(b: Number, granularity: string): boolean;
isBefore(b: Date, granularity: string): boolean;
isBefore(b: Array, granularity: string): boolean;
isAfter(b: Moment): bool;
isAfter(b: string): bool;
isAfter(b: Number): bool;
isAfter(b: Date): bool;
isAfter(b: Array): bool;
isAfter(b: Moment, granularity: string): bool;
isAfter(b: String, granularity: string): bool;
isAfter(b: Number, granularity: string): bool;
isAfter(b: Date, granularity: string): bool;
isAfter(b: Array, granularity: string): bool;
isAfter(b: Moment): boolean;
isAfter(b: string): boolean;
isAfter(b: Number): boolean;
isAfter(b: Date): boolean;
isAfter(b: Array): boolean;
isAfter(b: Moment, granularity: string): boolean;
isAfter(b: String, granularity: string): boolean;
isAfter(b: Number, granularity: string): boolean;
isAfter(b: Date, granularity: string): boolean;
isAfter(b: Array, granularity: string): boolean;
isSame(b: Moment): bool;
isSame(b: string): bool;
isSame(b: Number): bool;
isSame(b: Date): bool;
isSame(b: Array): bool;
isSame(b: Moment, granularity: string): bool;
isSame(b: String, granularity: string): bool;
isSame(b: Number, granularity: string): bool;
isSame(b: Date, granularity: string): bool;
isSame(b: Array, granularity: string): bool;
isSame(b: Moment): boolean;
isSame(b: string): boolean;
isSame(b: Number): boolean;
isSame(b: Date): boolean;
isSame(b: Array): boolean;
isSame(b: Moment, granularity: string): boolean;
isSame(b: String, granularity: string): boolean;
isSame(b: Number, granularity: string): boolean;
isSame(b: Date, granularity: string): boolean;
isSame(b: Array, granularity: string): boolean;
}
declare var moment: MomentStatic;
+36 -78
View File
@@ -73,9 +73,6 @@ function test_camera() {
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
}
function test_capture() {
@@ -120,64 +117,12 @@ function test_capture() {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles[i]);
}
}
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
function captureImage() {
navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });
}
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
ft.upload(path,
"http://my.domain.com/upload.php",
function (result) {
console.log('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function (error) {
console.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles[i]);
}
}
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
function captureVideo() {
navigator.device.capture.captureVideo(captureSuccess, captureError, { limit: 2 });
}
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
ft.upload(path,
"http://my.domain.com/upload.php",
function (result) {
console.log('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function (error) {
console.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
}
function test_compass() {
@@ -191,9 +136,10 @@ function test_compass() {
function onError(compassError) {
alert('Compass Error: ' + compassError.code);
}
}
function test_compass2() {
var watchID = null;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
startWatch();
@@ -215,7 +161,9 @@ function test_compass() {
function onError(compassError) {
alert('Compass error: ' + compassError.code);
}
}
function test_compass3() {
var watchID = null;
function startWatch() {
var options = { frequency: 3000 };
watchID = navigator.compass.watchHeading(onSuccess, onError, options);
@@ -281,7 +229,17 @@ function test_contacts() {
console.log("Original contact name = " + contact.name.givenName);
console.log("Cloned contact name = " + clone.name.givenName);
contact.remove(onSuccess, onError);
}
function test_contacts2() {
function onSuccess(contacts) {
for (var i = 0; i < contacts.length; i++) {
console.log("Display Name = " + contacts[i].displayName);
}
}
function onError(contactError) {
alert('onError!');
}
function onDeviceReady() {
var contact = navigator.contacts.create();
contact.displayName = "Plumber";
@@ -375,7 +333,8 @@ function test_file() {
function fail(evt) {
console.log(evt.target.error.code);
}
}
function test_file2() {
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
@@ -403,7 +362,8 @@ function test_file() {
function fail(error) {
console.log(error.code);
}
}
function test_file3() {
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
}
@@ -459,11 +419,6 @@ function test_file() {
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
var uri = encodeURI("http://some.server.com/upload.php");
var fileURI = "";
var options = new FileUploadOptions();
@@ -480,20 +435,21 @@ function test_file() {
function test_geolocation() {
var onSuccess = function (position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
function onError(error: GeolocationError) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function test_geolocation2() {
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
@@ -606,7 +562,8 @@ function test_inAppBrowser() {
}
function test_media() {
var my_media = new Media(src, ()=>{}, ()=>{});
var src = '';
var my_media = new Media(src, () => { }, () => { });
var mediaTimer = setInterval(function () {
my_media.getCurrentPosition(
function (position) {
@@ -617,7 +574,7 @@ function test_media() {
function (e) {
console.log("Error getting pos=" + e);
}
);
);
}, 1000);
var counter = 0;
@@ -646,7 +603,8 @@ function test_media() {
my_media.pause();
}, 10000);
}
}
function test_media2() {
function playAudio(url) {
var my_media = new Media(url,
function () {
+2 -2
View File
@@ -1,6 +1,6 @@
/// <reference path="platform.d.ts" />
declare interface ITestContainer {
interface ITestContainer {
[name: string]: PlatformStatic;
}
@@ -54,7 +54,7 @@ function runTests() {
onFalse = (name: string) => {
return function () => {
return () => {
console.log('\tfailed on prop "' + name + '" for "' + n + '"');
}
}
+2 -2
View File
@@ -14,8 +14,8 @@ interface PlatformStatic {
ua?: string;
version?: string;
os?: PlatformOS;
parse(ua: string): PlatformStatic;
toString(): string;
parse?(ua: string): PlatformStatic;
toString?(): string;
}
interface PlatformOS {
+24 -9
View File
@@ -1,3 +1,4 @@
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="Q.d.ts" />
import q = module('q');
@@ -40,14 +41,14 @@ Q.all([
Q.fcall(function () { })
.then(function () { })
.then(function () { })
.then(function () { })
.then(function (value4) {
// Do something with value4
}, function (error) {
// Handle any error from step1 through step4
}).done();
.then(function () { })
.then(function () { })
.then(function () { })
.then(function (value4) {
// Do something with value4
}, function (error) {
// Handle any error from step1 through step4
}).done();
Q.allResolved([])
.then(function (promises: Q.Promise<any>[]) {
@@ -58,4 +59,18 @@ Q.allResolved([])
var exception = promise.valueOf().exception;
}
})
});
});
declare var arrayPromise: Q.IPromise<number[]>;
declare var stringPromise: Q.IPromise<string>;
declare function returnsNumPromise(text: string): Q.Promise<number>;
Q<number[]>(arrayPromise) // type specification required
.then(arr => arr.join(','))
.then<number>(returnsNumPromise) // requires specification
.then(num => num.toFixed());
declare var jPromise: JQueryPromise;
// if jQuery promises definition supported generics, this could be more interesting example
Q<any>(jPromise).then((val) => val.toExponential());
Vendored
+15 -2
View File
@@ -3,9 +3,17 @@
// Definitions by: Barrie Nemetchek, Andrew Gaspar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare function Q<T>(value): Q.Promise<T>;
declare function Q<T>(value: T): Q.Promise<T>;
declare function Q<T>(promise: Q.IPromise<T>): Q.Promise<T>;
declare module Q {
interface IPromise<T> {
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => U): IPromise<U>;
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => U): IPromise<U>;
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => IPromise<U>): IPromise<U>;
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => IPromise<U>): IPromise<U>;
}
interface Deferred<T> {
promise: Promise<T>;
resolve(value: T): any;
@@ -18,7 +26,12 @@ declare module Q {
fail(errorCallback: Function): Promise<any>;
fin(finallyCallback: Function): Promise<T>;
finally(finallyCallback: Function): Promise<T>;
then(onFulfilled?: (value: T) => any, onRejected?: (reason) => any, onProgress?: Function): Promise<any>;
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => U, onProgress?: Function): Promise<U>;
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => U, onProgress?: Function): Promise<U>;
then<U>(onFulfill: (value: T) => U, onReject?: (reason) => IPromise<U>, onProgress?: Function): Promise<U>;
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason) => IPromise<U>, onProgress?: Function): Promise<U>;
spread(onFulfilled: Function, onRejected?: Function): Promise<any>;
catch(onRejected: Function): Promise<any>;
progress(onProgress: Function): Promise<any>;
+5 -2
View File
@@ -244,7 +244,10 @@ interface RaphaelStatic {
fn: any;
format(token: string, ...parameters: any[]): string;
fullfill(token: string, json: JSON): string;
getColor(value?: number): string;
getColor {
(value?: number): string;
reset();
};
getPointAtLength(path: string, length: number): { x: number; y: number; alpha: number; };
getRGB(colour: string): { r: number; g: number; b: number; hex: string; error: bool; };
getSubpath(path: string, from: number, to: number): string;
@@ -287,4 +290,4 @@ interface RaphaelStatic {
vml: bool;
}
declare var Raphael: RaphaelStatic;
declare var Raphael: RaphaelStatic;