diff --git a/README.md b/README.md index 0c0a629192..98f6ccdc44 100755 --- a/README.md +++ b/README.md @@ -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)) diff --git a/jointjs/README.md b/jointjs/README.md new file mode 100644 index 0000000000..5ea728842f --- /dev/null +++ b/jointjs/README.md @@ -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 `/// ` at the top of your code. \ No newline at end of file diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts new file mode 100644 index 0000000000..d3e6a204ea --- /dev/null +++ b/jointjs/jointjs.d.ts @@ -0,0 +1,115 @@ +// Type definitions for Joint JS 0.6 +// Project: http://www.jointjs.com/ +// Definitions by: Aidan Reel with help from David Durman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +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(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; + } +} \ No newline at end of file