forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjointjs.d.ts
147 lines (123 loc) · 4.68 KB
/
jointjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Type definitions for Joint JS 0.6
// Project: http://www.jointjs.com/
// Definitions by: Aidan Reel <http://github.com/areel>, 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);
findModelsFromPoint(point:{x : number; y: number}):Element[];
}
class Cell extends Backbone.Model {
toJSON();
remove(options?: any);
toFront();
toBack();
embed(cell: Cell);
unembed(cell: Cell);
getEmbeddedCells(): Cell[];
clone(opt?: any): Backbone.Model; // @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<Backbone.Model> {
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 extends CellView {
scale(sx: number, sy: number);
}
class CellView extends Backbone.View<Cell> {
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 {
interface Handle {
name : string;
position : string;
icon: string;
}
class SelectionView extends Backbone.Model {
paper:joint.dia.Paper;
graph:joint.dia.Graph;
model:Backbone.Collection<joint.dia.Cell>;
constructor(opt:{
paper : joint.dia.Paper;
graph : joint.dia.Graph;
model : Backbone.Collection<joint.dia.Cell>
});
createSelectionBox(cellView:joint.dia.CellView);
destroySelectionBox(cellView:joint.dia.CellView);
startSelecting(evt:any);
cancelSelection();
addHandle(handle:Handle);
removeHandle(name:string);
changeHandle(name:string, handle:Handle);
}
}
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[], defaultIndicator?: any): any;
}
}