forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ionic.d.ts
391 lines (375 loc) · 13.4 KB
/
ionic.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
// Type definitions for Ionic
// Project: http://ionicframework.com
// Definitions by: Spencer Williams <https://github.com/spencerwi/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
interface IonicStatic {
/**
* What Ionic package version is.
*/
version: string;
Platform: {
/**
* Trigger a callback once the device is ready, or immediately
* if the device is already ready. This method can be run from
* anywhere and does not need to be wrapped by any additonal methods.
* When the app is within a WebView (Cordova), it’ll fire
* the callback once the device is ready. If the app is within
* a web browser, it’ll fire the callback after window.load.
* Please remember that Cordova features (Camera, FileSystem, etc) still
* will not work in a web browser.
*/
ready(callback: ()=>any): void;
/**
* Set the grade of the device: ‘a’, ‘b’, or ‘c’. ‘a’ is the best
* (most css features enabled), ‘c’ is the worst. By default, sets the grade
* depending on the current device.
*/
setGrade(grade: string): void;
/**
* Return the current device (given by cordova).
*/
device(): any;
/**
* Check if we are running within a WebView (such as Cordova).
*/
isWebView(): boolean;
/**
* Whether we are running on iPad.
*/
isIPad(): boolean;
/**
* Whether we are running on iOS.
*/
isIOS(): boolean;
/**
* Whether we are running on Android.
*/
isAndroid(): boolean;
/**
* Whether we are running on Windows Phone.
*/
isWindowsPhone(): boolean;
/**
* The name of the current platform.
*/
platform(): string;
/**
* The version of the current device platform.
*/
version(): number;
/**
* Exit the app.
*/
exitApp(): void;
/**
* Shows or hides the device status bar (in Cordova). Requires cordova plugin add org.apache.cordova.statusbar
*/
showStatusBar(shouldShow: boolean): void;
/**
* Sets whether the app is fullscreen or not (in Cordova).
*/
fullScreen(showFullScreen?: boolean, showStatusBar?: boolean): void;
/**
* Whether the device is ready.
*/
isReady: boolean;
/**
* Whether the device is fullscreen.
*/
isFullScreen: boolean;
/**
* An array of all platforms found.
*/
platforms: Array<string>;
/**
* What grade the current platform is.
*/
grade: string;
};
}
declare var ionic: IonicStatic;
declare module 'ionic' {
export = ionic;
}
declare module ionic {
module actionSheet {
interface IonicActionSheetService {
show(options: IonicActionSheetOptions): ()=>void;
}
interface IonicActionSheetButton {
text: string;
}
interface IonicActionSheetOptions {
buttons?: Array<IonicActionSheetButton>;
titleText?: string;
cancelText?: string;
destructiveText?: string;
cancel?: ()=>any;
buttonClicked?: (index: number)=>boolean;
destructiveButtonClicked?: ()=>boolean;
cancelOnStateChange?: boolean;
cssClass?: string;
}
}
module backdrop {
interface IonicBackdropService {
retain(): void;
release(): void;
}
}
module gestures {
interface IonicGestureService {
on(eventType: string, callback: (e: any)=>any, $element: angular.IAugmentedJQuery, options: any): IonicGesture;
off(gesture: IonicGesture, eventType: string, callback: (e: any)=>any): void;
}
interface IonicGesture {
element: Element;
enabled: boolean;
options: {stop_browser_behavior: string };
on(gesture: string, handler: Function): IonicGesture;
off(gesture: string, handler: Function): IonicGesture;
trigger(gesture: string, eventData: any): IonicGesture;
enable(state: boolean): IonicGesture;
}
}
module list {
interface IonicListDelegate {
showReorder(showReorder?: boolean): boolean;
showDelete(showDelete?: boolean): boolean;
canSwipeItems(canSwipeItems?: boolean): boolean;
closeOptionButtons(): void;
$getByHandle(handle: string): IonicListDelegate;
}
}
module loading {
interface IonicLoadingService {
show(opts?: IonicLoadingOptions): void;
hide(): void;
}
interface IonicLoadingOptions {
template?: string;
templateUrl?: string;
scope?: any;
noBackdrop?: boolean;
hideOnStateChange?: boolean;
delay?: number;
duration?: number;
}
}
module modal {
interface IonicModalService {
fromTemplate(templateString: string, options?: IonicModalOptions): IonicModalController;
fromTemplateUrl(templateUrl: string, options?: IonicModalOptions): angular.IPromise<IonicModalController>;
}
interface IonicModalController {
initialize(options: IonicModalOptions): void;
show(): angular.IPromise<void>;
hide(): angular.IPromise<void>;
remove(): angular.IPromise<void>;
isShown(): boolean;
}
interface IonicModalOptions {
scope?: any;
animation?: string;
focusFirstInput?: boolean;
backdropClickToClose?: boolean;
hardwareBackButtonClose?: boolean;
}
}
module navigation {
interface IonicNavBarDelegate {
align(direction?: string): void;
showBackButton(show?: boolean): boolean;
showBar(show?: boolean): boolean;
title(title: string): void;
}
interface IonicHistoryService {
viewHistory(): any;
currentView(): any;
currentHistoryId(): string;
currentTitle(val?: string): string;
backView(): any;
backTitle(): string;
forwardView(): any;
currentStateName(): string;
goBack(backCount?: number): void;
clearHistory(): void;
clearCache(): angular.IPromise<any>;
nextViewOptions(options: IonicHistoryNextViewOptions): void;
}
interface IonicHistoryNextViewOptions {
disableAnimate?: boolean;
disableBack?: boolean;
historyRoot?: boolean;
}
}
module platform {
interface IonicPlatformService {
onHardwareBackButton(callback: Function): void;
offHardwareBackButton(callback: Function): void;
registerBackButtonAction(callback: Function, priority: number, actionId?: any): Function;
on(type: string, callback: Function): Function;
ready(callback?: Function): angular.IPromise<any>;
}
}
module popover {
interface IonicPopoverService {
fromTemplate(templateString: string, options: IonicPopoverOptions): IonicPopoverController;
fromTemplateUrl(templateUrl: string, options: IonicPopoverOptions): angular.IPromise<IonicPopoverController>;
}
interface IonicPopoverController {
initialize(options: IonicPopoverOptions): void;
show($event?: any): angular.IPromise<any>;
hide(): angular.IPromise<any>;
isShown(): boolean;
remove(): angular.IPromise<any>;
}
interface IonicPopoverOptions {
scope?: any;
focusFirstInput?: boolean;
backdropClickToClose?: boolean;
hardwareBackButtonClose?: boolean;
}
}
module popup {
interface IonicPopupService {
show(options: IonicPopupFullOptions): IonicPopupPromise;
alert(options: IonicPopupAlertOptions): IonicPopupPromise;
confirm(options: IonicPopupConfirmOptions): IonicPopupConfirmPromise;
prompt(options: IonicPopupPromptOptions): IonicPopupPromise;
}
interface IonicPopupConfirmPromise extends angular.IPromise<boolean> {
close(value?: boolean): void;
}
interface IonicPopupPromise extends angular.IPromise<any> {
close(value?: any): any;
}
interface IonicPopupBaseOptions {
title?: string;
cssClass?: string;
subTitle?: string;
template?: string;
templateUrl?: string;
}
interface IonicPopupFullOptions extends IonicPopupBaseOptions {
scope?: any;
buttons?: Array<IonicPopupButton>;
}
interface IonicPopupButton {
text: string;
type?: string;
onTap?(event?: any): void;
}
interface IonicPopupAlertOptions extends IonicPopupBaseOptions {
okText?: string;
okType?: string;
}
interface IonicPopupConfirmOptions extends IonicPopupBaseOptions {
cancelText?: string;
cancelType?: string;
okText?: string;
okType?: string;
}
interface IonicPopupPromptOptions extends IonicPopupBaseOptions {
inputType?: string;
inputPlaceholder?: string;
cancelText?: string;
cancelType?: string;
okText?: string;
okType?: string;
}
}
module scroll {
interface IonicScrollDelegate {
resize(): void;
scrollTop(shouldAnimate?: boolean): void;
scrollBottom(shouldAnimate?: boolean): void;
scrollTo(left: number, top: number, shouldAnimate?: boolean): void;
scrollBy(left: number, top: number, shouldAnimate?: boolean): void;
zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void;
zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void;
getScrollPosition(): {left: number; top: number};
anchorScroll(shouldAnimate?: boolean): void;
freezeScroll(shouldFreeze?: boolean): boolean;
freezeAllScrolls(shouldFreeze?: boolean): boolean;
getScrollView(): any;
$getByHandle(handle: string): IonicScrollDelegate;
}
}
module sideMenu {
interface IonicSideMenuDelegate {
toggleLeft(isOpen?: boolean): void;
toggleRight(isOpen?: boolean): void;
getOpenRatio(): number;
isOpen(): boolean;
isOpenLeft(): boolean;
isOpenRight(): boolean;
canDragContent(canDrag?: boolean): boolean;
edgeDragThreshold(value?: boolean|number): boolean;
$getByHandle(handle: string): IonicSideMenuDelegate;
}
}
module slideBox {
interface IonicSlideBoxDelegate {
update(): void;
slide(to: number, speed?: number): void;
enableSlide(shouldEnable?: boolean): boolean;
previous(speed?: number): void;
next(speed?: number): void;
stop(): void;
start(): void;
currentIndex(): number;
slidesCount(): number;
$getByHandle(handle: string): IonicSlideBoxDelegate;
}
}
module tabs {
interface IonicTabsDelegate {
select(index: number): void;
selectedIndex(): number;
$getByHandle(handle: string): IonicTabsDelegate;
showBar(show?: boolean): boolean;
}
}
module utility {
interface IonicConfigProvider {
views: {
transition(transition?: string): string;
maxCache(maxNumber?: number): number;
forwardCache(value?: boolean): boolean;
};
scrolling: {
jsScrolling(value?: boolean): boolean;
};
backButton: {
icon(value?: string): string;
text(value?: string): string;
previousTitleText(value?: boolean): boolean;
};
form: {
checkbox(value?: string): string;
toggle(value?: string): string;
};
spinner: {
icon(value?: string): string;
};
tabs: {
style(value?: string): string;
position(value?: string): string;
};
templates: {
maxPrefetch(value?: number): number;
};
navBar: {
alignTitle(value?: string): string;
positionPrimaryButtons(value?: string): string;
positionSecondaryButtons(value?: string): string;
};
}
interface IonicPositionService {
position(element: any): {top: number; left: number; width: number; height: number};
offset(element: any): {top: number; left: number; width: number; height: number};
}
}
}