ionic.d.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. // Type definitions for Ionic
  2. // Project: http://ionicframework.com
  3. // Definitions by: Spencer Williams <https://github.com/spencerwi/>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. /// <reference path="../angularjs/angular.d.ts" />
  6. interface IonicStatic {
  7. /**
  8. * What Ionic package version is.
  9. */
  10. version: string;
  11. Platform: {
  12. /**
  13. * Trigger a callback once the device is ready, or immediately
  14. * if the device is already ready. This method can be run from
  15. * anywhere and does not need to be wrapped by any additonal methods.
  16. * When the app is within a WebView (Cordova), it’ll fire
  17. * the callback once the device is ready. If the app is within
  18. * a web browser, it’ll fire the callback after window.load.
  19. * Please remember that Cordova features (Camera, FileSystem, etc) still
  20. * will not work in a web browser.
  21. */
  22. ready(callback: ()=>any): void;
  23. /**
  24. * Set the grade of the device: ‘a’, ‘b’, or ‘c’. ‘a’ is the best
  25. * (most css features enabled), ‘c’ is the worst. By default, sets the grade
  26. * depending on the current device.
  27. */
  28. setGrade(grade: string): void;
  29. /**
  30. * Return the current device (given by cordova).
  31. */
  32. device(): any;
  33. /**
  34. * Check if we are running within a WebView (such as Cordova).
  35. */
  36. isWebView(): boolean;
  37. /**
  38. * Whether we are running on iPad.
  39. */
  40. isIPad(): boolean;
  41. /**
  42. * Whether we are running on iOS.
  43. */
  44. isIOS(): boolean;
  45. /**
  46. * Whether we are running on Android.
  47. */
  48. isAndroid(): boolean;
  49. /**
  50. * Whether we are running on Windows Phone.
  51. */
  52. isWindowsPhone(): boolean;
  53. /**
  54. * The name of the current platform.
  55. */
  56. platform(): string;
  57. /**
  58. * The version of the current device platform.
  59. */
  60. version(): number;
  61. /**
  62. * Exit the app.
  63. */
  64. exitApp(): void;
  65. /**
  66. * Shows or hides the device status bar (in Cordova). Requires cordova plugin add org.apache.cordova.statusbar
  67. */
  68. showStatusBar(shouldShow: boolean): void;
  69. /**
  70. * Sets whether the app is fullscreen or not (in Cordova).
  71. */
  72. fullScreen(showFullScreen?: boolean, showStatusBar?: boolean): void;
  73. /**
  74. * Whether the device is ready.
  75. */
  76. isReady: boolean;
  77. /**
  78. * Whether the device is fullscreen.
  79. */
  80. isFullScreen: boolean;
  81. /**
  82. * An array of all platforms found.
  83. */
  84. platforms: Array<string>;
  85. /**
  86. * What grade the current platform is.
  87. */
  88. grade: string;
  89. };
  90. }
  91. declare var ionic: IonicStatic;
  92. declare module 'ionic' {
  93. export = ionic;
  94. }
  95. declare module ionic {
  96. module actionSheet {
  97. interface IonicActionSheetService {
  98. show(options: IonicActionSheetOptions): ()=>void;
  99. }
  100. interface IonicActionSheetButton {
  101. text: string;
  102. }
  103. interface IonicActionSheetOptions {
  104. buttons?: Array<IonicActionSheetButton>;
  105. titleText?: string;
  106. cancelText?: string;
  107. destructiveText?: string;
  108. cancel?: ()=>any;
  109. buttonClicked?: (index: number)=>boolean;
  110. destructiveButtonClicked?: ()=>boolean;
  111. cancelOnStateChange?: boolean;
  112. cssClass?: string;
  113. }
  114. }
  115. module backdrop {
  116. interface IonicBackdropService {
  117. retain(): void;
  118. release(): void;
  119. }
  120. }
  121. module gestures {
  122. interface IonicGestureService {
  123. on(eventType: string, callback: (e: any)=>any, $element: angular.IAugmentedJQuery, options: any): IonicGesture;
  124. off(gesture: IonicGesture, eventType: string, callback: (e: any)=>any): void;
  125. }
  126. interface IonicGesture {
  127. element: Element;
  128. enabled: boolean;
  129. options: {stop_browser_behavior: string };
  130. on(gesture: string, handler: Function): IonicGesture;
  131. off(gesture: string, handler: Function): IonicGesture;
  132. trigger(gesture: string, eventData: any): IonicGesture;
  133. enable(state: boolean): IonicGesture;
  134. }
  135. }
  136. module list {
  137. interface IonicListDelegate {
  138. showReorder(showReorder?: boolean): boolean;
  139. showDelete(showDelete?: boolean): boolean;
  140. canSwipeItems(canSwipeItems?: boolean): boolean;
  141. closeOptionButtons(): void;
  142. $getByHandle(handle: string): IonicListDelegate;
  143. }
  144. }
  145. module loading {
  146. interface IonicLoadingService {
  147. show(opts?: IonicLoadingOptions): void;
  148. hide(): void;
  149. }
  150. interface IonicLoadingOptions {
  151. template?: string;
  152. templateUrl?: string;
  153. scope?: any;
  154. noBackdrop?: boolean;
  155. hideOnStateChange?: boolean;
  156. delay?: number;
  157. duration?: number;
  158. }
  159. }
  160. module modal {
  161. interface IonicModalService {
  162. fromTemplate(templateString: string, options?: IonicModalOptions): IonicModalController;
  163. fromTemplateUrl(templateUrl: string, options?: IonicModalOptions): angular.IPromise<IonicModalController>;
  164. }
  165. interface IonicModalController {
  166. initialize(options: IonicModalOptions): void;
  167. show(): angular.IPromise<void>;
  168. hide(): angular.IPromise<void>;
  169. remove(): angular.IPromise<void>;
  170. isShown(): boolean;
  171. }
  172. interface IonicModalOptions {
  173. scope?: any;
  174. animation?: string;
  175. focusFirstInput?: boolean;
  176. backdropClickToClose?: boolean;
  177. hardwareBackButtonClose?: boolean;
  178. }
  179. }
  180. module navigation {
  181. interface IonicNavBarDelegate {
  182. align(direction?: string): void;
  183. showBackButton(show?: boolean): boolean;
  184. showBar(show?: boolean): boolean;
  185. title(title: string): void;
  186. }
  187. interface IonicHistoryService {
  188. viewHistory(): any;
  189. currentView(): any;
  190. currentHistoryId(): string;
  191. currentTitle(val?: string): string;
  192. backView(): any;
  193. backTitle(): string;
  194. forwardView(): any;
  195. currentStateName(): string;
  196. goBack(backCount?: number): void;
  197. clearHistory(): void;
  198. clearCache(): angular.IPromise<any>;
  199. nextViewOptions(options: IonicHistoryNextViewOptions): void;
  200. }
  201. interface IonicHistoryNextViewOptions {
  202. disableAnimate?: boolean;
  203. disableBack?: boolean;
  204. historyRoot?: boolean;
  205. }
  206. }
  207. module platform {
  208. interface IonicPlatformService {
  209. onHardwareBackButton(callback: Function): void;
  210. offHardwareBackButton(callback: Function): void;
  211. registerBackButtonAction(callback: Function, priority: number, actionId?: any): Function;
  212. on(type: string, callback: Function): Function;
  213. ready(callback?: Function): angular.IPromise<any>;
  214. }
  215. }
  216. module popover {
  217. interface IonicPopoverService {
  218. fromTemplate(templateString: string, options: IonicPopoverOptions): IonicPopoverController;
  219. fromTemplateUrl(templateUrl: string, options: IonicPopoverOptions): angular.IPromise<IonicPopoverController>;
  220. }
  221. interface IonicPopoverController {
  222. initialize(options: IonicPopoverOptions): void;
  223. show($event?: any): angular.IPromise<any>;
  224. hide(): angular.IPromise<any>;
  225. isShown(): boolean;
  226. remove(): angular.IPromise<any>;
  227. }
  228. interface IonicPopoverOptions {
  229. scope?: any;
  230. focusFirstInput?: boolean;
  231. backdropClickToClose?: boolean;
  232. hardwareBackButtonClose?: boolean;
  233. }
  234. }
  235. module popup {
  236. interface IonicPopupService {
  237. show(options: IonicPopupFullOptions): IonicPopupPromise;
  238. alert(options: IonicPopupAlertOptions): IonicPopupPromise;
  239. confirm(options: IonicPopupConfirmOptions): IonicPopupConfirmPromise;
  240. prompt(options: IonicPopupPromptOptions): IonicPopupPromise;
  241. }
  242. interface IonicPopupConfirmPromise extends angular.IPromise<boolean> {
  243. close(value?: boolean): void;
  244. }
  245. interface IonicPopupPromise extends angular.IPromise<any> {
  246. close(value?: any): any;
  247. }
  248. interface IonicPopupBaseOptions {
  249. title?: string;
  250. cssClass?: string;
  251. subTitle?: string;
  252. template?: string;
  253. templateUrl?: string;
  254. }
  255. interface IonicPopupFullOptions extends IonicPopupBaseOptions {
  256. scope?: any;
  257. buttons?: Array<IonicPopupButton>;
  258. }
  259. interface IonicPopupButton {
  260. text: string;
  261. type?: string;
  262. onTap?(event?: any): void;
  263. }
  264. interface IonicPopupAlertOptions extends IonicPopupBaseOptions {
  265. okText?: string;
  266. okType?: string;
  267. }
  268. interface IonicPopupConfirmOptions extends IonicPopupBaseOptions {
  269. cancelText?: string;
  270. cancelType?: string;
  271. okText?: string;
  272. okType?: string;
  273. }
  274. interface IonicPopupPromptOptions extends IonicPopupBaseOptions {
  275. inputType?: string;
  276. inputPlaceholder?: string;
  277. cancelText?: string;
  278. cancelType?: string;
  279. okText?: string;
  280. okType?: string;
  281. }
  282. }
  283. module scroll {
  284. interface IonicScrollDelegate {
  285. resize(): void;
  286. scrollTop(shouldAnimate?: boolean): void;
  287. scrollBottom(shouldAnimate?: boolean): void;
  288. scrollTo(left: number, top: number, shouldAnimate?: boolean): void;
  289. scrollBy(left: number, top: number, shouldAnimate?: boolean): void;
  290. zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void;
  291. zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void;
  292. getScrollPosition(): {left: number; top: number};
  293. anchorScroll(shouldAnimate?: boolean): void;
  294. freezeScroll(shouldFreeze?: boolean): boolean;
  295. freezeAllScrolls(shouldFreeze?: boolean): boolean;
  296. getScrollView(): any;
  297. $getByHandle(handle: string): IonicScrollDelegate;
  298. }
  299. }
  300. module sideMenu {
  301. interface IonicSideMenuDelegate {
  302. toggleLeft(isOpen?: boolean): void;
  303. toggleRight(isOpen?: boolean): void;
  304. getOpenRatio(): number;
  305. isOpen(): boolean;
  306. isOpenLeft(): boolean;
  307. isOpenRight(): boolean;
  308. canDragContent(canDrag?: boolean): boolean;
  309. edgeDragThreshold(value?: boolean|number): boolean;
  310. $getByHandle(handle: string): IonicSideMenuDelegate;
  311. }
  312. }
  313. module slideBox {
  314. interface IonicSlideBoxDelegate {
  315. update(): void;
  316. slide(to: number, speed?: number): void;
  317. enableSlide(shouldEnable?: boolean): boolean;
  318. previous(speed?: number): void;
  319. next(speed?: number): void;
  320. stop(): void;
  321. start(): void;
  322. currentIndex(): number;
  323. slidesCount(): number;
  324. $getByHandle(handle: string): IonicSlideBoxDelegate;
  325. }
  326. }
  327. module tabs {
  328. interface IonicTabsDelegate {
  329. select(index: number): void;
  330. selectedIndex(): number;
  331. $getByHandle(handle: string): IonicTabsDelegate;
  332. showBar(show?: boolean): boolean;
  333. }
  334. }
  335. module utility {
  336. interface IonicConfigProvider {
  337. views: {
  338. transition(transition?: string): string;
  339. maxCache(maxNumber?: number): number;
  340. forwardCache(value?: boolean): boolean;
  341. };
  342. scrolling: {
  343. jsScrolling(value?: boolean): boolean;
  344. };
  345. backButton: {
  346. icon(value?: string): string;
  347. text(value?: string): string;
  348. previousTitleText(value?: boolean): boolean;
  349. };
  350. form: {
  351. checkbox(value?: string): string;
  352. toggle(value?: string): string;
  353. };
  354. spinner: {
  355. icon(value?: string): string;
  356. };
  357. tabs: {
  358. style(value?: string): string;
  359. position(value?: string): string;
  360. };
  361. templates: {
  362. maxPrefetch(value?: number): number;
  363. };
  364. navBar: {
  365. alignTitle(value?: string): string;
  366. positionPrimaryButtons(value?: string): string;
  367. positionSecondaryButtons(value?: string): string;
  368. };
  369. }
  370. interface IonicPositionService {
  371. position(element: any): {top: number; left: number; width: number; height: number};
  372. offset(element: any): {top: number; left: number; width: number; height: number};
  373. }
  374. }
  375. }