-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.d.ts
227 lines (192 loc) · 5.65 KB
/
index.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// Type definitions for OdoDialog
// Project: odopod-code-library
// Definitions by: Glen Cheney <https://github.com/Vestride>
export as namespace OdoDialog;
export = OdoDialog;
declare class OdoDialog {
/**
* Create a new dialog.
* @param {HTMLElement} element Main element which represents this class.
* @param {OdoDialog.Options} [opts] Instance options.
* @throws {TypeError} Throws when the element is not of type HTMLElement.
*/
constructor(element: HTMLElement, opts?: OdoDialog.Options);
/** Main element for this class */
element: HTMLElement;
options: OdoDialog.Options;
/**
* Id attribute from the main element.
* @type {string}
*/
id: string;
/**
* Dialog backdrop element.
* @protected
* @type {HTMLElement}
*/
protected backdrop: HTMLElement;
/**
* Dialog content (role=document)
* @protected
* @type {HTMLElement}
*/
protected content: HTMLElement;
/**
* Whether the dialog is open.
* @type {boolean}
*/
isOpen: boolean;
/**
* z-index of the main dialog element. This only changes when multiple dialogs
* are open at the same time.
*/
z: number;
/**
* Whether the dialog is currently animating.
* @protected
* @type {boolean}
*/
protected isAnimating: boolean;
/*~
*~ From tiny emitter
*~ https://github.com/scottcorgan/tiny-emitter/blob/master/index.d.ts
*/
on(event: string, callback: Function, ctx?: any): OdoDialog;
once(event: string, callback: Function, ctx?: any): OdoDialog;
emit(event: string, ...args: any[]): OdoDialog;
off(event: string, callback?: Function): OdoDialog;
/**
* Find descendent element by class.
* @param {string} name Name of the class to find.
* @return {Element} The element or undefined.
*/
getByClass(name: string): Element | undefined;
/**
* Click handler on the main element. When the dialog is dismissable and the
* user clicked outside the content (i.e. the backdrop), close it.
* @param {Event} evt Event object.
* @protected
*/
protected onClick(evt: MouseEvent): void;
/**
* Keypress event handler
* @param {Event} evt Event object
* @protected
*/
protected onKeyPress(evt: KeyboardEvent): void;
/**
* The dialog has a height of 100vh, which, in mobile safari, is incorrect
* when the toolbars are visible, not allowing the user to scroll the full
* height of the content within it.
* The viewportHeight parameter is optional so that it can be read in the open()
* method with all the other DOM reads. This avoids read->write->read #perfmatters.
* @param {number} [viewportHeight=window.innerHeight] Height of the viewport.
* @protected
*/
protected onResize(viewportHeight?: number): void;
/**
* Checks to see if a dialog is already open or animating If not, opens dialog.
* @param {boolean} [sync=false] Whether to open with transitions or not.
*/
open(sync?: false): void;
/**
* Hides dialog
* @param {boolean} [sync=false] Whether to close with transitions or not.
*/
close(sync?: false): void;
/**
* Modify dialog z-indices and more because there are about to be multiple
* dialogs open at the same time.
*/
protected handleOtherOpenDialogs(): void;
/**
* Dialog went into the background and has another dialog open above it.
*/
protected didEnterBackground(): void;
/**
* Dialog came back into the foreground after being in the background.
*/
protected didEnterForeground(): void;
/**
* Close the dialog, remove event listeners and element references.
*/
dispose(): void;
}
declare namespace OdoDialog {
export interface Options {
dismissable?: boolean;
scrollableElement?: string;
}
/**
* Instantiates all instances of dialogs with the same settings
* @param {OdoDialog.Options} [options] Object of all dialog options. Is optional.
* @return {OdoDialog[]}
*/
function initializeAll(options?: OdoDialog.Options): OdoDialog[];
/**
* Clear all references to dialogs so there are no duplicates.
*/
function disposeAll(): void;
/**
* Retrieve a dialog instance by its id.
* @param {string} id Id of the dialog.
* @return {OdoDialog} The dialog or undefined if there is no dialog with the given id.
*/
function getDialogById(id: string): OdoDialog | undefined;
/**
* Count how many dialogs are currently open.
* @return {number}
*/
function getOpenDialogCount(): number;
/**
* Find the z index of the top-most dialog instance.
* @return {number}
*/
function getTopLayer(): number;
/**
* Array of dialog instances.
* @type {OdoDialog[]}
*/
const Instances: OdoDialog[];
/**
* HTML class names for elements of the dialog.
*/
enum Classes {
BODY_OPEN = 'odo-dialog-open',
BASE = 'odo-dialog',
OPEN = 'odo-dialog--open',
ENTER = 'odo-dialog--enter',
ENTERING = 'odo-dialog--enter-active',
LEAVE = 'odo-dialog--leave',
LEAVING = 'odo-dialog--leave-active',
VISIBLE = 'odo-dialog--visible',
FULLSCREEN = 'odo-dialog--full',
NO_AUTO_MARGIN = 'odo-dialog--no-auto-margin',
BACKDROP = 'odo-dialog-backdrop',
CONTENT = 'odo-dialog__content',
}
/**
* Events emitted by dialog instances.
*/
enum EventType {
OPENED = 'ododialog:open',
CLOSED = 'ododialog:closed',
TRIGGER_CLICKED = 'ododialog:triggerclicked',
}
enum Keys {
ESC = 27,
TAB = 9,
}
/**
* Default options for each instance.
*/
const Defaults: OdoDialog.Options;
/**
* Whether auto margins work for flex children in the current browser.
*/
const SUPPORTS_AUTO_MARGINS: boolean;
/**
* Width of the scrollbar.
*/
const SCROLLBAR_WIDTH: number;
}