Add TypeScript definition file for JointJS Graphic Library (http://www.jointjs.com)

This commit is contained in:
areel
2013-08-27 19:20:26 +01:00
parent 3449ebae02
commit 54ab49c723
3 changed files with 125 additions and 0 deletions
+1
View File
@@ -92,6 +92,7 @@ List of Definitions
* [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/))
* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov))
* [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac))
* [JointJS](http://www.jointjs.com/) (by [Aidan Reel](http://github.com/areel))
* [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) (by [Dániel Tar](https://github.com/qcz))
* [jQuery](http://jquery.com/) (from TypeScript samples)
* [jQuery Mobile](http://jquerymobile.com) (by [Boris Yankov](https://github.com/borisyankov))
+9
View File
@@ -0,0 +1,9 @@
# JointJS Definitions Usage Notes
TypeScript definitions for the JointJS framework available at http://www.jointjs.com
Current version 0.6
## Referencing JointJS definition files in your code
Add `/// <reference path="jointjs.d.ts" />` at the top of your code.
+115
View File
@@ -0,0 +1,115 @@
// Type definitions for Joint JS 0.6
// Project: http://www.jointjs.com/
// Definitions by: Aidan Reel <http://github.com/areel> with help from David Durman <http://github.com/DavidDurman>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
declare module joint {
module dia {
interface IElementSize {
width: number;
height: number;
}
class Graph extends Backbone.Model {
initialize();
fromJSON(json: any);
clear();
addCell(cell: Cell);
addCells(cells: Cell[]);
getConnectedLinks(cell: Cell, opt?: any): Link[];
disconnectLinks(cell: Cell);
removeLinks(cell: Cell);
}
class Cell extends Backbone.Model {
toJSON();
remove(options?: any);
toFront();
toBack();
embed(cell: Cell);
unembed(cell: Cell);
getEmbeddedCells(): Cell[];
clone<T>(opt?: any): T; // @todo: return can either be Cell or Cell[].
attr(attrs: any): Cell;
}
class Element extends Cell {
position(x: number, y: number): Element;
translate(tx: number, ty?: number): Element;
resize(width: number, height: number): Element;
rotate(angle: number, absolute): Element;
}
interface IDefaults {
type: string;
}
class Link extends Cell {
defaults: IDefaults;
disconnect(): Link;
label(idx?: number, value?: any): any; // @todo: returns either a label under idx or Link if both idx and value were passed
}
interface IOptions {
width: number;
height: number;
gridSize: number;
perpendicularLinks: boolean;
elementView: ElementView;
linkView: LinkView;
}
class Paper extends Backbone.View {
options: IOptions;
setDimensions(width: number, height: number);
scale(sx: number, sy?: number, ox?: number, oy?: number): Paper;
rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already
findView(el: any): CellView;
findViewByModel(modelOrId: any): CellView;
findViewsFromPoint(p: { x: number; y: number; }): CellView[];
findViewsInArea(r: { x: number; y: number; width: number; height: number; }): CellView[];
snapToGrid(p): { x: number; y: number; };
}
class ElementView {
scale(sx: number, sy: number);
}
class CellView extends Backbone.View {
getBBox(): { x: number; y: number; width: number; height: number; };
highlight(el?: any);
unhighlight(el?: any);
findMagnet(el: any);
getSelector(el: any);
}
class LinkView extends CellView {
getConnectionLength(): number;
getPointAtLength(length: number): { x: number; y: number; };
}
}
module ui { }
module shapes {
module basic {
class Generic extends joint.dia.Element { }
class Rect extends Generic { }
class Text extends Generic { }
class Circle extends Generic { }
class Image extends Generic { }
}
}
module util {
function uuid(): string;
function guid(obj: any): string;
function mixin(objects: any[]): any;
function supplement(objects: any[]): any;
function deepMixin(objects: any[]): any;
function deepSupplement(objects: any[]): any;
}
}