mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
add the ngCordova type definitions for network,deviceOrientation,deviceMotion, appAvailability,geolocation,emailComposer and dialogs
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.appavailability {
|
||||
'use strict';
|
||||
|
||||
export class AppAvailabilityController {
|
||||
|
||||
isAvailable:boolean;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDevice", "$cordovaAppAvailability"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService,
|
||||
private $cordovaDevice:ngCordova.IDeviceService,
|
||||
private $cordovaAppAvailability:ngCordova.IAppAvailabilityService) {
|
||||
|
||||
this.isAvailable = false;
|
||||
|
||||
var scheme = "com.twitter.android";
|
||||
|
||||
if ($cordovaDevice.getPlatform() == 'iOS') {
|
||||
scheme = "twitter://";
|
||||
}
|
||||
|
||||
$ionicPlatform.ready(() => {
|
||||
$cordovaAppAvailability.check(scheme).then(() => {
|
||||
this.isAvailable = true;
|
||||
}, (err) => {
|
||||
// bad api design in plugin as well as in ngCordova !!
|
||||
this.isAvailable = false;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module("demo.appavailability").controller("AppAvailabilityController", AppAvailabilityController);
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for ngCordova AppAvailability plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface IAppAvailabilityService {
|
||||
check(urlScheme: string): ng.IPromise<any>;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.devicemotion {
|
||||
'use strict';
|
||||
|
||||
export class DeviceMotionController {
|
||||
|
||||
motion:ngCordova.IDeviceMotionAcceleration;
|
||||
this_watch:ngCordova.IDeviceMotionWatchPromise;
|
||||
msg:string;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDeviceMotion"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDeviceMotion:ngCordova.IDeviceMotionService) {
|
||||
$ionicPlatform.ready(() => {
|
||||
this.getAcceleration();
|
||||
});
|
||||
}
|
||||
|
||||
getAcceleration () {
|
||||
this.$cordovaDeviceMotion.getCurrentAcceleration().then( (motion) => {
|
||||
this.motion = motion;
|
||||
console.log(motion);
|
||||
}, function (err) {
|
||||
this.msg = err.message;
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
watchAcceleration () {
|
||||
var options = { frequency: 3000 }; // Update every 3 seconds
|
||||
|
||||
this.this_watch = this.$cordovaDeviceMotion.watchAcceleration(options);
|
||||
|
||||
this.this_watch.then(
|
||||
() => { /* unused */
|
||||
},
|
||||
(err) => {
|
||||
this.msg = err.message;
|
||||
},
|
||||
(motion) => {
|
||||
this.motion = motion;
|
||||
});
|
||||
};
|
||||
|
||||
clearWatch () {
|
||||
// use watchID from watchAccelaration()
|
||||
this.$cordovaDeviceMotion.clearWatch(this.this_watch.watchID);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
angular.module("demo.devicemotion").controller("DeviceMotionController", DeviceMotionController);
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// Type definitions for ngCordova device motion plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Michel Vidailhet <https://github.com/mvidailhet>
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface IDeviceMotionAcceleration {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export interface IDeviceMotionAccelerometerOptions {
|
||||
frequency: number;
|
||||
}
|
||||
|
||||
export interface IDeviceMotionWatchPromise extends ng.IPromise<IDeviceMotionAcceleration> {
|
||||
watchID: number;
|
||||
cancel: () => void;
|
||||
clearWatch: (watchId?: number) => void;
|
||||
}
|
||||
|
||||
export interface IDeviceMotionService {
|
||||
getCurrentAcceleration(): ng.IPromise<IDeviceMotionAcceleration>;
|
||||
watchAcceleration(options: IDeviceMotionAccelerometerOptions): IDeviceMotionWatchPromise;
|
||||
clearWatch(watchId: number): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.deviceorientation {
|
||||
'use strict';
|
||||
|
||||
export class DeviceOrientationController {
|
||||
|
||||
msg:string;
|
||||
heading:ngCordova.IDeviceOrientationHeading;
|
||||
this_watch:ngCordova.IDeviceOrientationWatchPromise;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$timeout", "$cordovaDeviceOrientation"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService,
|
||||
private $timeout:ng.ITimeoutService,
|
||||
private $cordovaDeviceOrientation:ngCordova.IDeviceOrientationService) {
|
||||
|
||||
$ionicPlatform.ready(() => {
|
||||
this.getHeading();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
getHeading() {
|
||||
this.$cordovaDeviceOrientation
|
||||
.getCurrentHeading()
|
||||
.then((position) => {
|
||||
this.heading = position;
|
||||
}, (err) => {
|
||||
this.msg = err.message;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
watchHeading () {
|
||||
this.this_watch = this.$cordovaDeviceOrientation.watchHeading({frequency: 1000});
|
||||
|
||||
this.this_watch.then(
|
||||
() => {
|
||||
/* unused */
|
||||
},
|
||||
(err) => {
|
||||
this.msg = err.message;
|
||||
},
|
||||
(position) => {
|
||||
this.$timeout(() => {
|
||||
this.heading = position;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
clearWatch () {
|
||||
this.$cordovaDeviceOrientation.clearWatch(this.this_watch.watchID);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
angular.module("demo.deviceorientation").controller("DeviceOrientationController", DeviceOrientationController);
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for ngCordova device orientation plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Michel Vidailhet <https://github.com/mvidailhet>
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface IDeviceOrientationHeading {
|
||||
magneticHeading: number;
|
||||
trueHeading?: number;
|
||||
headingAccuracy?: number;
|
||||
timestamp?: number;
|
||||
}
|
||||
|
||||
export interface IDeviceOrientationWatchOptions {
|
||||
frequency?: number;
|
||||
filter?: number;
|
||||
}
|
||||
|
||||
export interface IDeviceOrientationWatchPromise extends ng.IPromise<IDeviceOrientationHeading> {
|
||||
watchID: number;
|
||||
cancel: () => void;
|
||||
clearWatch: (watchId?: number) => void;
|
||||
}
|
||||
|
||||
export interface IDeviceOrientationService {
|
||||
getCurrentHeading(): ng.IPromise<IDeviceOrientationHeading>;
|
||||
watchHeading(options: IDeviceOrientationWatchOptions): IDeviceOrientationWatchPromise;
|
||||
clearWatch(watchID: number): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.dialog {
|
||||
'use strict';
|
||||
|
||||
export class DialogController {
|
||||
|
||||
action:string;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDialogs"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDialogs:ngCordova.IDialogsService) {
|
||||
this.action = "Press any button !";
|
||||
}
|
||||
|
||||
alert() {
|
||||
this.action = "Alert";
|
||||
this.$cordovaDialogs.alert('Wow!');
|
||||
}
|
||||
|
||||
confirm() {
|
||||
this.action = "Confirm";
|
||||
this.$cordovaDialogs.confirm('Are you sure?', "Custom title").then(function (buttonIndex) {
|
||||
this.$cordovaDialogs.alert("Button index : " + buttonIndex);
|
||||
});
|
||||
}
|
||||
|
||||
prompt() {
|
||||
this.action = "Prompt";
|
||||
this.$cordovaDialogs.prompt('Please Login', "Custom title").then(function (result) {
|
||||
this.$cordovaDialogs.alert("Input: " + result.input1 + "\n Button index : " + result.buttonIndex);
|
||||
});
|
||||
}
|
||||
|
||||
beep() {
|
||||
this.action = "Beep";
|
||||
this.$cordovaDialogs.beep(3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module("demo.dialog").controller("DialogController", DialogController);
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for ngCordova dialogs plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Michel Vidailhet <https://github.com/mvidailhet>
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface IDialogsPromptResult {
|
||||
input1: string;
|
||||
buttonIndex: number;
|
||||
}
|
||||
|
||||
export interface IDialogsService {
|
||||
alert(message: string, title?: string, buttonName?: string): ng.IPromise<void>;
|
||||
confirm(message: string, title?: string, buttonArray?: Array<string>): ng.IPromise<number>;
|
||||
prompt(message: string, title?: string, buttonArray?: Array<string>, defaultText?: string): ng.IPromise<IDialogsPromptResult>;
|
||||
beep(repetitions: number): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.email {
|
||||
'use strict';
|
||||
|
||||
export class EmailComposerController {
|
||||
|
||||
isAvailable:boolean;
|
||||
status:string;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaEmailComposer"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, $cordovaEmailComposer:ngCordova.IEmailComposerService) {
|
||||
|
||||
this.status = "";
|
||||
|
||||
$ionicPlatform.ready(() => {
|
||||
|
||||
$cordovaEmailComposer.isAvailable().then((available) => {
|
||||
this.isAvailable = available;
|
||||
});
|
||||
|
||||
let email = <ngCordova.IEmailComposerOptions>{
|
||||
to: 'max@mustermann.de',
|
||||
cc: 'erika@mustermann.de',
|
||||
bcc: ['john@doe.com', 'jane@doe.com'],
|
||||
subject: 'Cordova Icons',
|
||||
body: 'How are you? Nice greetings from Leipzig',
|
||||
isHtml: true
|
||||
};
|
||||
|
||||
$cordovaEmailComposer.open(email).then(null, () => {
|
||||
// user cancelled email
|
||||
this.status = "User Cancelled Email";
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module("demo.email").controller("EmailComposerController", EmailComposerController);
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// Type definitions for ngCordova emailComposer plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface IEmailComposerOptions {
|
||||
to: string | Array<string>;
|
||||
cc?: string | Array<string>;
|
||||
bcc?: string | Array<string>;
|
||||
attachments?: Array<any>;
|
||||
subject?: string;
|
||||
body?: string;
|
||||
isHtml?: boolean;
|
||||
}
|
||||
|
||||
export interface IEmailComposerService {
|
||||
|
||||
isAvailable(): ng.IPromise<boolean>;
|
||||
open(properties: IEmailComposerOptions);
|
||||
addAlias(app: string, schema: string);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.geolocation {
|
||||
'use strict';
|
||||
|
||||
export class GeolocationController {
|
||||
|
||||
erroMsg:string;
|
||||
position:ngCordova.IGeoPosition;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaGeolocation"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaGeolocation:ngCordova.IGeolocationService) {
|
||||
|
||||
}
|
||||
|
||||
getLocation = function () {
|
||||
|
||||
this.$cordovaGeolocation
|
||||
.getCurrentPosition(<ngCordova.IGeolocationOptions>{timeout: 10000, enableHighAccuracy: false})
|
||||
.then((position) => {
|
||||
console.log("position found");
|
||||
this.position = position;
|
||||
// long = position.coords.longitude
|
||||
// lat = position.coords.latitude
|
||||
}, (err) => {
|
||||
console.log("unable to find location");
|
||||
this.errorMsg = "Error : " + err.message;
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
angular.module("demo.geolocation").controller("GeolocationController", GeolocationController);
|
||||
}
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for ngCordova geolocation plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface IGeoPositionError {
|
||||
code:number;
|
||||
message:string;
|
||||
}
|
||||
|
||||
export interface IGeoCoordinates {
|
||||
latitude?:number;
|
||||
longitude?:number;
|
||||
accuracy?:number;
|
||||
altitude?:number;
|
||||
heading?:number;
|
||||
speed?:number;
|
||||
altitudeAccuracy?:number;
|
||||
}
|
||||
|
||||
export interface IGeoPosition {
|
||||
coords:IGeoCoordinates;
|
||||
timestamp:Date;
|
||||
}
|
||||
|
||||
export interface IGeolocationOptions {
|
||||
timeout?: number;
|
||||
maximumAge?: number;
|
||||
enableHighAccuracy?: boolean;
|
||||
}
|
||||
|
||||
export interface IGeolocationService {
|
||||
getCurrentPosition(options?: IGeolocationOptions) : ng.IPromise<IGeoPosition>;
|
||||
watchPosition(options?: IGeolocationOptions) : ng.IPromise<IGeoPosition>;
|
||||
clearWatch(watchID: {[key: string]: any}) : void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="tsd.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ionic/ionic.d.ts" />
|
||||
|
||||
// For the full application demo please see following repo :
|
||||
// https://github.com/ksachdeva/ngCordova-typescript-demo
|
||||
|
||||
namespace demo.network {
|
||||
'use strict';
|
||||
|
||||
export class NetworkController {
|
||||
|
||||
networkType:string;
|
||||
connectionType:string;
|
||||
errorMsg:string;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaNetwork"];
|
||||
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaNetwork:ngCordova.INetworkInformationService) {
|
||||
|
||||
$ionicPlatform.ready(() => {
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.networkType = this.$cordovaNetwork.getNetwork();
|
||||
if (this.$cordovaNetwork.isOnline()) {
|
||||
this.connectionType = 'Online';
|
||||
}
|
||||
else if (this.$cordovaNetwork.isOffline()) {
|
||||
this.connectionType = 'Offline';
|
||||
}
|
||||
else {
|
||||
this.errorMsg = 'Error getting isOffline / isOnline methods';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
angular.module("demo.network").controller("NetworkController", NetworkController);
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for ngCordova network plugin
|
||||
// Project: https://github.com/driftyco/ng-cordova
|
||||
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
|
||||
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ngCordova {
|
||||
|
||||
export interface INetworkInformationService {
|
||||
|
||||
getNetwork(): string;
|
||||
isOnline(): boolean;
|
||||
isOffline(): boolean;
|
||||
clearOfflineWatch(): void;
|
||||
clearOnlineWatch(): void;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+7
@@ -5,3 +5,10 @@
|
||||
|
||||
/// <reference path="device.d.ts"/>
|
||||
/// <reference path="toast.d.ts"/>
|
||||
/// <reference path="network.d.ts"/>
|
||||
/// <reference path="emailComposer.d.ts"/>
|
||||
/// <reference path="dialogs.d.ts"/>
|
||||
/// <reference path="geolocation.d.ts"/>
|
||||
/// <reference path="deviceMotion.d.ts"/>
|
||||
/// <reference path="deviceOrientation.d.ts"/>
|
||||
/// <reference path="appAvailability.d.ts"/>
|
||||
|
||||
Reference in New Issue
Block a user