forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery-cropbox.d.ts
122 lines (110 loc) · 3.89 KB
/
jquery-cropbox.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
// Type definitions for jQuery cropbox
// Project: https://github.com/acornejo/jquery-cropbox
// Definitions by: Per Kastman <https://github.com/PerKastman/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
declare module jQueryCropBox {
enum ShowControls {
never,
always,
hover,
auto
}
interface CropboxArea {
cropX: number;
cropY: number;
cropW: number;
cropH: number;
}
interface CropboxOptions {
/**
* Width in pixels of the cropping window
*/
width?: number;
/**
* Height in pixels of the cropping window
*/
height?: number;
/**
* Number of incremental zoom steps. With the default of 10, you have to click the zoom-in button 9 times to reach 100%.
*/
zoom?: number;
/**
* Maximum zoom value. With the default of 1.0 users can't zoom beyond the maximum image resolution.
*/
maxZoom?: number;
/**
* If not null, this is the entire html block that should appear on hover over the image for instructions and/or buttons (could include the zoom in/out buttons for example). If null, the default html block is used which has the text "Click to drag" and the zoom in/out buttons. Use false to disable controls.
*/
controls?: any;
/**
* Set the initial cropping area
*/
result?: CropboxArea;
/**
* This flag is used to determine when to display the controls. Never, always and hover do exactly what you would expect (never show them, always show them, show them on hover). The auto flag is the same as the hover flag, except that on mobile devices it always shows the controls (since there is no hover event).
*/
showControls?: ShowControls
}
interface CropboxDragOptions {
startX: number,
startY: number,
dx: number,
dy: number
}
interface CropboxSetCropOptions {
cropX: number,
cropY: number,
cropW: number,
cropH: number
}
interface Cropbox {
/**
* Increase image zoom level by one step
*/
zoomIn(): void;
/**
* Decrease image zoom level by one step
*/
zoomOut(): void;
/**
* Set zoom leevl to a value between 0 and 1. Need to call update to reflect the changes.
*/
zoom(percent: number): void;
/**
* Simulate image dragging, starting from (startX,startY) and moving a delta of (dx,dy). Need to call update to reflect the changes.
*/
drag(options: CropboxDragOptions): void;
/**
* Set crop window.
*/
setCrop(options: CropboxSetCropOptions): void;
/**
* Update the cropped result (must call after zoom and drag).
*/
update(): void;
/**
* Generate a URL for the cropped image on the client (requires HTML5 compliant browser).
*/
getDataURL(): string;
/**
* Generate a Blob with the cropped image (requires HTML5 compliant browser).
*/
getBlob(): any;
/**
* Remove the cropbox functionality from the image.
*/
remove(): void;
/**
* Attach an event handler function for one event on the Crop Box
*/
on(event: string, callback: jQueryCropBox.EventCallback): void;
}
type EventCallback = (e: Event, data: any, img: jQueryCropBox.Cropbox) => void;
}
interface JQuery {
cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox
}
interface JQueryStatic {
cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox
}