Merge pull request #3610 from DenEwout/master

Separated JointJS from Rappid
This commit is contained in:
Masahiro Wakame
2015-03-05 23:17:23 +09:00
3 changed files with 110 additions and 84 deletions
+71 -84
View File
@@ -1,6 +1,6 @@
// Type definitions for Joint JS 0.6
// Type definitions for Joint JS 0.9.3
// Project: http://www.jointjs.com/
// Definitions by: Aidan Reel <http://github.com/areel>, David Durman <http://github.com/DavidDurman>
// Definitions by: Aidan Reel <http://github.com/areel>, David Durman <http://github.com/DavidDurman>, Ewout Van Gossum <https://github.com/DenEwout>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
@@ -16,34 +16,36 @@ declare module joint {
}
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);
addCell(cell:Cell) : void;
addCells(cells:Cell[]) : void;
initialize() : void;
fromJSON(json:any) : void;
toJSON() : Object;
clear() : void;
getConnectedLinks(cell:Cell, opt?:any):Link[];
disconnectLinks(cell:Cell) : void;
removeLinks(cell:Cell) : void;
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;
toJSON() : Object;
remove(options?:any) : void;
toFront() : void;
toBack() : void;
embed(cell:Cell) : void;
unembed(cell:Cell) : void;
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;
position(x:number, y:number):Element;
translate(tx:number, ty?:number):Element;
resize(width:number, height:number):Element;
rotate(angle:number, options : {absolute : boolean; origin: {x:number;y:number}}):Element;
remove(): void;
}
interface IDefaults {
@@ -51,9 +53,10 @@ declare module joint {
}
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
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
remove(): void;
}
interface IOptions {
@@ -66,82 +69,66 @@ declare module joint {
}
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; };
options:IOptions;
setDimensions(width:number, height:number) : void;
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[];
}
class ElementView extends CellView {
scale(sx: number, sy: number);
class ElementView extends CellView {
scale(sx:number, sy:number) : void;
}
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);
getBBox():{ x: number; y: number; width: number; height: number; };
highlight(el?:any): void;
unhighlight(el?:any): void;
findMagnet(el:any): void;
getSelector(el:any): void;
pointerdblclick(evt:any, x:number, y:number):void;
pointerclick(evt:any, x:number, y:number):void;
pointerdown(evt:any, x:number, y:number):void;
pointermove(evt:any, x:number, y:number):void;
pointerup(evt:any, x:number, y:number):void;
}
class LinkView extends CellView {
getConnectionLength(): number;
getPointAtLength(length: number): { x: number; y: number; };
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 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 { }
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;
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;
}
}
+1
View File
@@ -0,0 +1 @@
These definitions are far from complete.
+38
View File
@@ -0,0 +1,38 @@
// Type definitions for Rappid 1.5
// Project: http://jointjs.com/about-rappid
// Definitions by: Ewout Van Gossum <https://github.com/DenEwout>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jointjs/jointjs.d.ts" />
/// <reference path="../backbone/backbone.d.ts" />
declare module joint{
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) : void;
destroySelectionBox(cellView:joint.dia.CellView) : void;
startSelecting(evt:any) : void;
cancelSelection() : void;
addHandle(handle:Handle) : void;
removeHandle(name:string) : void;
changeHandle(name:string, handle:Handle) : void;
}
}
}