From 7ca9b69f1cdff8bb1807210e86273da958783bb9 Mon Sep 17 00:00:00 2001 From: Julien Evano Date: Tue, 3 Nov 2015 19:43:16 +1100 Subject: [PATCH 1/3] ionic framework: static ionic.Platform utility Add the static ionic.Platform utility according to the API documentation (http://ionicframework.com/docs/api/utility/ionic.Platform/) --- ionic/ionic-tests.ts | 55 +++++++++++++++++++++++------ ionic/ionic.d.ts | 82 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 11 deletions(-) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index 45d8c2d669..34dfade4aa 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -102,7 +102,7 @@ class IonicTestController { } private testGesture(): void { var gesture: ionic.gestures.IonicGesture = this.$ionicGesture.on( - 'eventType', + 'eventType', (e)=>{ return e; }, angular.element("body"), {} @@ -226,7 +226,7 @@ class IonicTestController { cssClass: "cssClass", template: "template", templateUrl: "templateUrl", - okText: "OK", + okText: "OK", okType: "okType" }).then(() => console.log("popover shown")) this.$ionicPopup.alert({ @@ -235,7 +235,7 @@ class IonicTestController { cssClass: "cssClass", template: "template", templateUrl: "templateUrl", - okText: "OK", + okText: "OK", okType: "okType" }).close(); @@ -245,9 +245,9 @@ class IonicTestController { cssClass: "cssClass", template: "template", templateUrl: "templateUrl", - okText: "OK", + okText: "OK", okType: "okType", - cancelText: "Cancel", + cancelText: "Cancel", cancelType: "cancelType" }).then(() => console.log("popover shown")) this.$ionicPopup.confirm({ @@ -256,9 +256,9 @@ class IonicTestController { cssClass: "cssClass", template: "template", templateUrl: "templateUrl", - okText: "OK", + okText: "OK", okType: "okType", - cancelText: "Cancel", + cancelText: "Cancel", cancelType: "cancelType" }).close(); @@ -268,9 +268,9 @@ class IonicTestController { cssClass: "cssClass", template: "template", templateUrl: "templateUrl", - okText: "OK", + okText: "OK", okType: "okType", - cancelText: "Cancel", + cancelText: "Cancel", cancelType: "cancelType", inputType: "text", inputPlaceholder: "Type some text..." @@ -281,9 +281,9 @@ class IonicTestController { cssClass: "cssClass", template: "template", templateUrl: "templateUrl", - okText: "OK", + okText: "OK", okType: "okType", - cancelText: "Cancel", + cancelText: "Cancel", cancelType: "cancelType", inputType: "text", inputPlaceholder: "Type some text..." @@ -359,6 +359,39 @@ class IonicTestController { var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.position(angular.element("body")); var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.offset(angular.element("body")); } + + /** + * ionic.version + */ + private testStaticVersion(): void { + var version: string = ionic.version; + } + + /** + * ionic.Platform + */ + private testStaticPlaform(): void { + var ready: void = ionic.Platform.ready(function() { + }); + var setGrade: void = ionic.Platform.setGrade('iOS'); + var deviceInformation: string = ionic.Platform.device(); + var isWebView: boolean = ionic.Platform.isWebView(); + var isIPad: boolean = ionic.Platform.isIPad(); + var isIOS: boolean = ionic.Platform.isIOS(); + var isAndroid: boolean = ionic.Platform.isAndroid(); + var isWindowsPhone: boolean = ionic.Platform.isWindowsPhone(); + var currentPlatform: string = ionic.Platform.platform(); + var currentPlatformVersion: number = ionic.Platform.version(); + var exitApp: void = ionic.Platform.exitApp(); + var showStatusBar: void = ionic.Platform.showStatusBar(true); + var showStatusBar: void = ionic.Platform.fullScreen(); + showStatusBar = ionic.Platform.fullScreen(true); + showStatusBar = ionic.Platform.fullScreen(true, true); + var isReady: boolean = ionic.Platform.isReady; + var isFullScreen: boolean = ionic.Platform.isFullScreen; + var platforms: Array = ionic.Platform.platforms; + var grade: string = ionic.Platform.grade; + } } testIonic.controller('ionicTestController', IonicTestController); diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index 239f775c5d..774102c95e 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -6,7 +6,89 @@ /// 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: ()=>void): 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; + /** + * What grade the current platform is. + */ + grade: string; + }; } declare var ionic: IonicStatic; From bba57a40b89062582a9a23248e625c75db0392c6 Mon Sep 17 00:00:00 2001 From: Julien Evano Date: Tue, 3 Nov 2015 19:46:56 +1100 Subject: [PATCH 2/3] style(ionic framework): adjust 4 spaces identation --- ionic/ionic-tests.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index 34dfade4aa..e6e8ab0d5c 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -364,33 +364,33 @@ class IonicTestController { * ionic.version */ private testStaticVersion(): void { - var version: string = ionic.version; + var version: string = ionic.version; } /** * ionic.Platform */ private testStaticPlaform(): void { - var ready: void = ionic.Platform.ready(function() { - }); - var setGrade: void = ionic.Platform.setGrade('iOS'); - var deviceInformation: string = ionic.Platform.device(); - var isWebView: boolean = ionic.Platform.isWebView(); - var isIPad: boolean = ionic.Platform.isIPad(); - var isIOS: boolean = ionic.Platform.isIOS(); - var isAndroid: boolean = ionic.Platform.isAndroid(); - var isWindowsPhone: boolean = ionic.Platform.isWindowsPhone(); - var currentPlatform: string = ionic.Platform.platform(); - var currentPlatformVersion: number = ionic.Platform.version(); - var exitApp: void = ionic.Platform.exitApp(); - var showStatusBar: void = ionic.Platform.showStatusBar(true); - var showStatusBar: void = ionic.Platform.fullScreen(); - showStatusBar = ionic.Platform.fullScreen(true); - showStatusBar = ionic.Platform.fullScreen(true, true); - var isReady: boolean = ionic.Platform.isReady; - var isFullScreen: boolean = ionic.Platform.isFullScreen; - var platforms: Array = ionic.Platform.platforms; - var grade: string = ionic.Platform.grade; + var ready: void = ionic.Platform.ready(function() { + }); + var setGrade: void = ionic.Platform.setGrade('iOS'); + var deviceInformation: string = ionic.Platform.device(); + var isWebView: boolean = ionic.Platform.isWebView(); + var isIPad: boolean = ionic.Platform.isIPad(); + var isIOS: boolean = ionic.Platform.isIOS(); + var isAndroid: boolean = ionic.Platform.isAndroid(); + var isWindowsPhone: boolean = ionic.Platform.isWindowsPhone(); + var currentPlatform: string = ionic.Platform.platform(); + var currentPlatformVersion: number = ionic.Platform.version(); + var exitApp: void = ionic.Platform.exitApp(); + var showStatusBar: void = ionic.Platform.showStatusBar(true); + var showStatusBar: void = ionic.Platform.fullScreen(); + showStatusBar = ionic.Platform.fullScreen(true); + showStatusBar = ionic.Platform.fullScreen(true, true); + var isReady: boolean = ionic.Platform.isReady; + var isFullScreen: boolean = ionic.Platform.isFullScreen; + var platforms: Array = ionic.Platform.platforms; + var grade: string = ionic.Platform.grade; } } From 352ad8af4020f9105734dd828773acd26b92cfac Mon Sep 17 00:00:00 2001 From: Julien Evano Date: Fri, 6 Nov 2015 06:29:28 +1100 Subject: [PATCH 3/3] refactor(Ionic framework): update ionic.Platform.ready callback to accept any return To be more generic, the ionic.Platform.ready callback has been updated to accept any return. --- ionic/ionic-tests.ts | 6 ++++-- ionic/ionic.d.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index e6e8ab0d5c..ee8647b08c 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -371,8 +371,10 @@ class IonicTestController { * ionic.Platform */ private testStaticPlaform(): void { - var ready: void = ionic.Platform.ready(function() { - }); + var callbackWithoutReturn: ()=>void; + var callbackWithReturn: ()=>boolean; + var ready: void = ionic.Platform.ready(callbackWithoutReturn); + ready = ionic.Platform.ready(callbackWithReturn); var setGrade: void = ionic.Platform.setGrade('iOS'); var deviceInformation: string = ionic.Platform.device(); var isWebView: boolean = ionic.Platform.isWebView(); diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index 774102c95e..688a253edd 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -21,7 +21,7 @@ interface IonicStatic { * Please remember that Cordova features (Camera, FileSystem, etc) still * will not work in a web browser. */ - ready(callback: ()=>void): void; + 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