mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-22 01:19:36 +08:00
pre-final plugin rewrite
This commit is contained in:
parent
937138378b
commit
ab9af2bdc4
@ -1,6 +1,13 @@
|
|||||||
import {Plugin, Cordova, InstanceProperty, CordovaInstance} from './plugin';
|
import {Plugin, Cordova, InstanceProperty, CordovaInstance} from './plugin';
|
||||||
|
declare var window: any = {
|
||||||
export interface ContactProperties {
|
ContactAddress: (...args) => {},
|
||||||
|
ContactProperties: (...args) => {},
|
||||||
|
ContactOrganization: (...args) => {},
|
||||||
|
ContactName: (...args) => {},
|
||||||
|
ContactField: (...args) => {},
|
||||||
|
ContactFindOptions: (...args) => {}
|
||||||
|
};
|
||||||
|
export interface IContactProperties {
|
||||||
/** A globally unique identifier. */
|
/** A globally unique identifier. */
|
||||||
id?: string;
|
id?: string;
|
||||||
/** The name of this Contact, suitable for display to end users. */
|
/** The name of this Contact, suitable for display to end users. */
|
||||||
@ -10,13 +17,13 @@ export interface ContactProperties {
|
|||||||
/** A casual name by which to address the contact. */
|
/** A casual name by which to address the contact. */
|
||||||
nickname?: string;
|
nickname?: string;
|
||||||
/** An array of all the contact's phone numbers. */
|
/** An array of all the contact's phone numbers. */
|
||||||
phoneNumbers?: ContactField[];
|
phoneNumbers?: IContactField[];
|
||||||
/** An array of all the contact's email addresses. */
|
/** An array of all the contact's email addresses. */
|
||||||
emails?: ContactField[];
|
emails?: IContactField[];
|
||||||
/** An array of all the contact's addresses. */
|
/** An array of all the contact's addresses. */
|
||||||
addresses?: ContactAddress[];
|
addresses?: ContactAddress[];
|
||||||
/** An array of all the contact's IM addresses. */
|
/** An array of all the contact's IM addresses. */
|
||||||
ims?: ContactField[];
|
ims?: IContactField[];
|
||||||
/** An array of all the contact's organizations. */
|
/** An array of all the contact's organizations. */
|
||||||
organizations?: ContactOrganization[];
|
organizations?: ContactOrganization[];
|
||||||
/** The birthday of the contact. */
|
/** The birthday of the contact. */
|
||||||
@ -24,36 +31,13 @@ export interface ContactProperties {
|
|||||||
/** A note about the contact. */
|
/** A note about the contact. */
|
||||||
note?: string;
|
note?: string;
|
||||||
/** An array of the contact's photos. */
|
/** An array of the contact's photos. */
|
||||||
photos?: ContactField[];
|
photos?: IContactField[];
|
||||||
/** An array of all the user-defined categories associated with the contact. */
|
/** An array of all the user-defined categories associated with the contact. */
|
||||||
categories?: ContactField[];
|
categories?: IContactField[];
|
||||||
/** An array of web pages associated with the contact. */
|
/** An array of web pages associated with the contact. */
|
||||||
urls?: ContactField[];
|
urls?: IContactField[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// export interface Contact extends ContactProperties {
|
|
||||||
// /**
|
|
||||||
// * Returns a new Contact object that is a deep copy of the calling object, with the id property set to null
|
|
||||||
// */
|
|
||||||
// clone(): Contact;
|
|
||||||
// /**
|
|
||||||
// * Removes the contact from the device contacts database, otherwise executes an error callback with a ContactError object.
|
|
||||||
// * @param onSuccess Success callback function invoked on success operation.
|
|
||||||
// * @param onError Error callback function, invoked when an error occurs.
|
|
||||||
// */
|
|
||||||
// remove(
|
|
||||||
// onSuccess?: () => void,
|
|
||||||
// onError?: (error: Error) => void): void;
|
|
||||||
// /**
|
|
||||||
// * Saves a new contact to the device contacts database, or updates an existing contact if a contact with the same id already exists.
|
|
||||||
// * @param onSuccess Success callback function invoked on success operation with che Contact object.
|
|
||||||
// * @param onError Error callback function, invoked when an error occurs.
|
|
||||||
// */
|
|
||||||
// save(
|
|
||||||
// onSuccess?: (contact: Contact) => void,
|
|
||||||
// onError?: (error: Error) => void): void;
|
|
||||||
// }
|
|
||||||
|
|
||||||
export class Contact {
|
export class Contact {
|
||||||
|
|
||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
@ -115,7 +99,7 @@ export class Contact {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ContactError {
|
interface IContactError {
|
||||||
/** Error code */
|
/** Error code */
|
||||||
code: number;
|
code: number;
|
||||||
/** Error message */
|
/** Error message */
|
||||||
@ -123,7 +107,7 @@ interface ContactError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare var ContactError: {
|
declare var ContactError: {
|
||||||
new(code: number): ContactError;
|
new(code: number): IContactError;
|
||||||
UNKNOWN_ERROR: number;
|
UNKNOWN_ERROR: number;
|
||||||
INVALID_ARGUMENT_ERROR: number;
|
INVALID_ARGUMENT_ERROR: number;
|
||||||
TIMEOUT_ERROR: number;
|
TIMEOUT_ERROR: number;
|
||||||
@ -133,7 +117,7 @@ declare var ContactError: {
|
|||||||
PERMISSION_DENIED_ERROR: number
|
PERMISSION_DENIED_ERROR: number
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ContactName {
|
export interface IContactName {
|
||||||
/** The complete name of the contact. */
|
/** The complete name of the contact. */
|
||||||
formatted?: string;
|
formatted?: string;
|
||||||
/** The contact's family name. */
|
/** The contact's family name. */
|
||||||
@ -148,32 +132,28 @@ export interface ContactName {
|
|||||||
honorificSuffix?: string;
|
honorificSuffix?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// declare var ContactName: {
|
export class ContactName implements IContactName {
|
||||||
// /** Constructor for ContactName object */
|
|
||||||
// new(formatted?: string,
|
|
||||||
// familyName?: string,
|
|
||||||
// givenName?: string,
|
|
||||||
// middleName?: string,
|
|
||||||
// honorificPrefix?: string,
|
|
||||||
// honorificSuffix?: string): ContactName
|
|
||||||
// };
|
|
||||||
|
|
||||||
export class ContactName {
|
|
||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
|
|
||||||
constructor() { }
|
constructor(formatted?: string, familyName?: string, givenName?: string, middleName?: string, honorificPrefix?: string, honorificSuffix?: string) {
|
||||||
|
this._objectInstance = new window.ContactName(formatted, familyName, givenName, middleName, honorificPrefix, honorificSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
public set givenName(val: string) {
|
@InstanceProperty
|
||||||
this._objectInstance.givenName = val;
|
get formatted(): string {return; }
|
||||||
}
|
@InstanceProperty
|
||||||
public set familyName(val: string) {
|
get familyName(): string {return; }
|
||||||
this._objectInstance.familyName = val;
|
@InstanceProperty
|
||||||
}
|
get givenName(): string {return; }
|
||||||
public get givenName(): string {return this._objectInstance.givenName; }
|
@InstanceProperty
|
||||||
public get familyName(): string {return this._objectInstance.familyName; }
|
get middleName(): string {return; }
|
||||||
|
@InstanceProperty
|
||||||
|
get honorificPrefix(): string {return; }
|
||||||
|
@InstanceProperty
|
||||||
|
get honorificSuffix(): string {return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContactField {
|
export interface IContactField {
|
||||||
/** A string that indicates what type of field this is, home for example. */
|
/** A string that indicates what type of field this is, home for example. */
|
||||||
type: string;
|
type: string;
|
||||||
/** The value of the field, such as a phone number or email address. */
|
/** The value of the field, such as a phone number or email address. */
|
||||||
@ -182,14 +162,20 @@ export interface ContactField {
|
|||||||
pref: boolean;
|
pref: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var ContactField: {
|
export class ContactField implements IContactField {
|
||||||
/** Constructor for ContactField object */
|
private _objectInstance: any;
|
||||||
new(type?: string,
|
constructor(type?: string, value?: string, pref?: boolean) {
|
||||||
value?: string,
|
this._objectInstance = new window.ContactField(type, value, pref);
|
||||||
pref?: boolean): ContactField
|
}
|
||||||
};
|
@InstanceProperty
|
||||||
|
get type(): string {return; }
|
||||||
|
@InstanceProperty
|
||||||
|
get value(): string {return; }
|
||||||
|
@InstanceProperty
|
||||||
|
get pref(): boolean {return; }
|
||||||
|
}
|
||||||
|
|
||||||
export interface ContactAddress {
|
export interface IContactAddress {
|
||||||
/** Set to true if this ContactAddress contains the user's preferred value. */
|
/** Set to true if this ContactAddress contains the user's preferred value. */
|
||||||
pref?: boolean;
|
pref?: boolean;
|
||||||
/** A string indicating what type of field this is, home for example. */
|
/** A string indicating what type of field this is, home for example. */
|
||||||
@ -208,19 +194,46 @@ export interface ContactAddress {
|
|||||||
country?: string;
|
country?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var ContactAddress: {
|
export class ContactAddress implements IContactAddress {
|
||||||
/** Constructor of ContactAddress object */
|
private _objectInstance: any;
|
||||||
new(pref?: boolean,
|
|
||||||
type?: string,
|
|
||||||
formatted?: string,
|
|
||||||
streetAddress?: string,
|
|
||||||
locality?: string,
|
|
||||||
region?: string,
|
|
||||||
postalCode?: string,
|
|
||||||
country?: string): ContactAddress
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface ContactOrganization {
|
constructor (pref?: boolean,
|
||||||
|
type?: string,
|
||||||
|
formatted?: string,
|
||||||
|
streetAddress?: string,
|
||||||
|
locality?: string,
|
||||||
|
region?: string,
|
||||||
|
postalCode?: string,
|
||||||
|
country?: string) {
|
||||||
|
this._objectInstance = new window.ContactAddress(pref, type, formatted, streetAddress, locality, region, postalCode, country);
|
||||||
|
}
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get pref(): boolean {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get type(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get formatted(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get streetAddress(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get locality(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get region(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get postalCode(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get country(): string {return; }
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IContactOrganization {
|
||||||
/** Set to true if this ContactOrganization contains the user's preferred value. */
|
/** Set to true if this ContactOrganization contains the user's preferred value. */
|
||||||
pref?: boolean;
|
pref?: boolean;
|
||||||
/** A string that indicates what type of field this is, home for example. */
|
/** A string that indicates what type of field this is, home for example. */
|
||||||
@ -233,17 +246,29 @@ export interface ContactOrganization {
|
|||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var ContactOrganization: {
|
export class ContactOrganization implements IContactOrganization {
|
||||||
/** Constructor for ContactOrganization object */
|
private _objectInstance: any;
|
||||||
new(pref?: boolean,
|
constructor () {
|
||||||
type?: string,
|
this._objectInstance = new window.ContactOrganization();
|
||||||
name?: string,
|
}
|
||||||
department?: string,
|
@InstanceProperty
|
||||||
title?: string): ContactOrganization
|
get pref(): boolean {return; }
|
||||||
};
|
|
||||||
|
@InstanceProperty
|
||||||
|
get type(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get name(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get department(): string {return; }
|
||||||
|
|
||||||
|
@InstanceProperty
|
||||||
|
get title(): string {return; }
|
||||||
|
}
|
||||||
|
|
||||||
/** Search options to filter navigator.contacts. */
|
/** Search options to filter navigator.contacts. */
|
||||||
interface ContactFindOptions {
|
interface IContactFindOptions {
|
||||||
/** The search string used to find navigator.contacts. */
|
/** The search string used to find navigator.contacts. */
|
||||||
filter?: string;
|
filter?: string;
|
||||||
/** Determines if the find operation returns multiple navigator.contacts. */
|
/** Determines if the find operation returns multiple navigator.contacts. */
|
||||||
@ -252,36 +277,24 @@ interface ContactFindOptions {
|
|||||||
desiredFields?: string[];
|
desiredFields?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var ContactFindOptions: {
|
export class ContactFindOptions implements IContactFindOptions {
|
||||||
/** Constructor for ContactFindOptions object */
|
|
||||||
new(filter?: string,
|
|
||||||
multiple?: boolean,
|
|
||||||
desiredFields?: string[]): ContactFindOptions
|
|
||||||
};
|
|
||||||
|
|
||||||
export class ContactFindOptions {
|
|
||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
public set filter(val: string) {
|
constructor () {
|
||||||
this._objectInstance.filter = val;
|
this._objectInstance = new window.ContactFindOptions();
|
||||||
}
|
}
|
||||||
|
@InstanceProperty
|
||||||
|
public get filter(): string {return; }
|
||||||
|
|
||||||
public set multiple(val: boolean) {
|
@InstanceProperty
|
||||||
this._objectInstance.multiple = val;
|
public get multiple(): boolean {return; }
|
||||||
}
|
|
||||||
|
|
||||||
public set desiredFields(val) {
|
@InstanceProperty
|
||||||
this._objectInstance.desiredFields = val;
|
public get desiredFields(): any {return; }
|
||||||
}
|
|
||||||
|
|
||||||
public set hasPhoneNumber(val: boolean) {
|
@InstanceProperty
|
||||||
this._objectInstance.hasPhoneNumber = val;
|
public get hasPhoneNumber(): boolean {return; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// declare var Contact: {
|
|
||||||
// new(): Contact
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Contacts
|
* @name Contacts
|
||||||
* @description
|
* @description
|
||||||
@ -311,28 +324,11 @@ export class ContactFindOptions {
|
|||||||
})
|
})
|
||||||
export class Contacts {
|
export class Contacts {
|
||||||
|
|
||||||
private _objectInstance: any;
|
static create(): Contact {
|
||||||
|
return new Contact();
|
||||||
public set displayName(val: string) {
|
|
||||||
this._objectInstance.displayName = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public set nickname(val: boolean) {
|
// TODO add fieldType options
|
||||||
this._objectInstance.nickname = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
get displayName() {return this._objectInstance.displayName; }
|
|
||||||
get nickname() {return this._objectInstance.nickname; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Contact object.
|
|
||||||
*
|
|
||||||
* @param options {Object} Object whose properties the created Contact should have.
|
|
||||||
* @return {Contact} Returns the created contact
|
|
||||||
*/
|
|
||||||
constructor (options?: ContactProperties) {
|
|
||||||
this._objectInstance = navigator.contacts(options);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for contacts in the Contacts list.
|
* Search for contacts in the Contacts list.
|
||||||
|
Loading…
Reference in New Issue
Block a user