removed contact code from js

This commit is contained in:
Steven Gill 2013-05-22 17:12:13 -07:00
parent f7c97cb1d0
commit 75f358d01e

View File

@ -1,5 +1,5 @@
// Platform: android
// 2.7.0rc1-82-g32587e6
// 2.7.0rc1-83-g658fd32
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@ -19,7 +19,7 @@
under the License.
*/
;(function() {
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-82-g32587e6';
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-83-g658fd32';
// file: lib/scripts/require.js
var require,
@ -1409,322 +1409,6 @@ module.exports = {
});
// file: lib/common/plugin/Contact.js
define("cordova/plugin/Contact", function(require, exports, module) {
var argscheck = require('cordova/argscheck'),
exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils');
/**
* Converts primitives into Complex Object
* Currently only used for Date fields
*/
function convertIn(contact) {
var value = contact.birthday;
try {
contact.birthday = new Date(parseFloat(value));
} catch (exception){
console.log("Cordova Contact convertIn error: exception creating date.");
}
return contact;
}
/**
* Converts Complex objects into primitives
* Only conversion at present is for Dates.
**/
function convertOut(contact) {
var value = contact.birthday;
if (value !== null) {
// try to make it a Date object if it is not already
if (!utils.isDate(value)){
try {
value = new Date(value);
} catch(exception){
value = null;
}
}
if (utils.isDate(value)){
value = value.valueOf(); // convert to milliseconds
}
contact.birthday = value;
}
return contact;
}
/**
* Contains information about a single contact.
* @constructor
* @param {DOMString} id unique identifier
* @param {DOMString} displayName
* @param {ContactName} name
* @param {DOMString} nickname
* @param {Array.<ContactField>} phoneNumbers array of phone numbers
* @param {Array.<ContactField>} emails array of email addresses
* @param {Array.<ContactAddress>} addresses array of addresses
* @param {Array.<ContactField>} ims instant messaging user ids
* @param {Array.<ContactOrganization>} organizations
* @param {DOMString} birthday contact's birthday
* @param {DOMString} note user notes about contact
* @param {Array.<ContactField>} photos
* @param {Array.<ContactField>} categories
* @param {Array.<ContactField>} urls contact's web sites
*/
var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
ims, organizations, birthday, note, photos, categories, urls) {
this.id = id || null;
this.rawId = null;
this.displayName = displayName || null;
this.name = name || null; // ContactName
this.nickname = nickname || null;
this.phoneNumbers = phoneNumbers || null; // ContactField[]
this.emails = emails || null; // ContactField[]
this.addresses = addresses || null; // ContactAddress[]
this.ims = ims || null; // ContactField[]
this.organizations = organizations || null; // ContactOrganization[]
this.birthday = birthday || null;
this.note = note || null;
this.photos = photos || null; // ContactField[]
this.categories = categories || null; // ContactField[]
this.urls = urls || null; // ContactField[]
};
/**
* Removes contact from device storage.
* @param successCB success callback
* @param errorCB error callback
*/
Contact.prototype.remove = function(successCB, errorCB) {
argscheck.checkArgs('FF', 'Contact.remove', arguments);
var fail = errorCB && function(code) {
errorCB(new ContactError(code));
};
if (this.id === null) {
fail(ContactError.UNKNOWN_ERROR);
}
else {
exec(successCB, fail, "Contacts", "remove", [this.id]);
}
};
/**
* Creates a deep copy of this Contact.
* With the contact ID set to null.
* @return copy of this Contact
*/
Contact.prototype.clone = function() {
var clonedContact = utils.clone(this);
clonedContact.id = null;
clonedContact.rawId = null;
function nullIds(arr) {
if (arr) {
for (var i = 0; i < arr.length; ++i) {
arr[i].id = null;
}
}
}
// Loop through and clear out any id's in phones, emails, etc.
nullIds(clonedContact.phoneNumbers);
nullIds(clonedContact.emails);
nullIds(clonedContact.addresses);
nullIds(clonedContact.ims);
nullIds(clonedContact.organizations);
nullIds(clonedContact.categories);
nullIds(clonedContact.photos);
nullIds(clonedContact.urls);
return clonedContact;
};
/**
* Persists contact to device storage.
* @param successCB success callback
* @param errorCB error callback
*/
Contact.prototype.save = function(successCB, errorCB) {
argscheck.checkArgs('FFO', 'Contact.save', arguments);
var fail = errorCB && function(code) {
errorCB(new ContactError(code));
};
var success = function(result) {
if (result) {
if (successCB) {
var fullContact = require('cordova/plugin/contacts').create(result);
successCB(convertIn(fullContact));
}
}
else {
// no Entry object returned
fail(ContactError.UNKNOWN_ERROR);
}
};
var dupContact = convertOut(utils.clone(this));
exec(success, fail, "Contacts", "save", [dupContact]);
};
module.exports = Contact;
});
// file: lib/common/plugin/ContactAddress.js
define("cordova/plugin/ContactAddress", function(require, exports, module) {
/**
* Contact address.
* @constructor
* @param {DOMString} id unique identifier, should only be set by native code
* @param formatted // NOTE: not a W3C standard
* @param streetAddress
* @param locality
* @param region
* @param postalCode
* @param country
*/
var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
this.id = null;
this.pref = (typeof pref != 'undefined' ? pref : false);
this.type = type || null;
this.formatted = formatted || null;
this.streetAddress = streetAddress || null;
this.locality = locality || null;
this.region = region || null;
this.postalCode = postalCode || null;
this.country = country || null;
};
module.exports = ContactAddress;
});
// file: lib/common/plugin/ContactError.js
define("cordova/plugin/ContactError", function(require, exports, module) {
/**
* ContactError.
* An error code assigned by an implementation when an error has occurred
* @constructor
*/
var ContactError = function(err) {
this.code = (typeof err != 'undefined' ? err : null);
};
/**
* Error codes
*/
ContactError.UNKNOWN_ERROR = 0;
ContactError.INVALID_ARGUMENT_ERROR = 1;
ContactError.TIMEOUT_ERROR = 2;
ContactError.PENDING_OPERATION_ERROR = 3;
ContactError.IO_ERROR = 4;
ContactError.NOT_SUPPORTED_ERROR = 5;
ContactError.PERMISSION_DENIED_ERROR = 20;
module.exports = ContactError;
});
// file: lib/common/plugin/ContactField.js
define("cordova/plugin/ContactField", function(require, exports, module) {
/**
* Generic contact field.
* @constructor
* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
* @param type
* @param value
* @param pref
*/
var ContactField = function(type, value, pref) {
this.id = null;
this.type = (type && type.toString()) || null;
this.value = (value && value.toString()) || null;
this.pref = (typeof pref != 'undefined' ? pref : false);
};
module.exports = ContactField;
});
// file: lib/common/plugin/ContactFindOptions.js
define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
/**
* ContactFindOptions.
* @constructor
* @param filter used to match contacts against
* @param multiple boolean used to determine if more than one contact should be returned
*/
var ContactFindOptions = function(filter, multiple) {
this.filter = filter || '';
this.multiple = (typeof multiple != 'undefined' ? multiple : false);
};
module.exports = ContactFindOptions;
});
// file: lib/common/plugin/ContactName.js
define("cordova/plugin/ContactName", function(require, exports, module) {
/**
* Contact name.
* @constructor
* @param formatted // NOTE: not part of W3C standard
* @param familyName
* @param givenName
* @param middle
* @param prefix
* @param suffix
*/
var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
this.formatted = formatted || null;
this.familyName = familyName || null;
this.givenName = givenName || null;
this.middleName = middle || null;
this.honorificPrefix = prefix || null;
this.honorificSuffix = suffix || null;
};
module.exports = ContactName;
});
// file: lib/common/plugin/ContactOrganization.js
define("cordova/plugin/ContactOrganization", function(require, exports, module) {
/**
* Contact organization.
* @constructor
* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
* @param name
* @param dept
* @param title
* @param startDate
* @param endDate
* @param location
* @param desc
*/
var ContactOrganization = function(pref, type, name, dept, title) {
this.id = null;
this.pref = (typeof pref != 'undefined' ? pref : false);
this.type = type || null;
this.name = name || null;
this.department = dept || null;
this.title = title || null;
};
module.exports = ContactOrganization;
});
// file: lib/common/plugin/Coordinates.js
define("cordova/plugin/Coordinates", function(require, exports, module) {
@ -4392,84 +4076,6 @@ for (var key in console) {
});
// file: lib/common/plugin/contacts.js
define("cordova/plugin/contacts", function(require, exports, module) {
var argscheck = require('cordova/argscheck'),
exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils'),
Contact = require('cordova/plugin/Contact');
/**
* Represents a group of Contacts.
* @constructor
*/
var contacts = {
/**
* Returns an array of Contacts matching the search criteria.
* @param fields that should be searched
* @param successCB success callback
* @param errorCB error callback
* @param {ContactFindOptions} options that can be applied to contact searching
* @return array of Contacts matching search criteria
*/
find:function(fields, successCB, errorCB, options) {
argscheck.checkArgs('afFO', 'contacts.find', arguments);
if (!fields.length) {
errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
} else {
var win = function(result) {
var cs = [];
for (var i = 0, l = result.length; i < l; i++) {
cs.push(contacts.create(result[i]));
}
successCB(cs);
};
exec(win, errorCB, "Contacts", "search", [fields, options]);
}
},
/**
* This function creates a new contact, but it does not persist the contact
* to device storage. To persist the contact to device storage, invoke
* contact.save().
* @param properties an object whose properties will be examined to create a new Contact
* @returns new Contact object
*/
create:function(properties) {
argscheck.checkArgs('O', 'contacts.create', arguments);
var contact = new Contact();
for (var i in properties) {
if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
contact[i] = properties[i];
}
}
return contact;
}
};
module.exports = contacts;
});
// file: lib/common/plugin/contacts/symbols.js
define("cordova/plugin/contacts/symbols", function(require, exports, module) {
var modulemapper = require('cordova/modulemapper');
modulemapper.clobbers('cordova/plugin/contacts', 'navigator.contacts');
modulemapper.clobbers('cordova/plugin/Contact', 'Contact');
modulemapper.clobbers('cordova/plugin/ContactAddress', 'ContactAddress');
modulemapper.clobbers('cordova/plugin/ContactError', 'ContactError');
modulemapper.clobbers('cordova/plugin/ContactField', 'ContactField');
modulemapper.clobbers('cordova/plugin/ContactFindOptions', 'ContactFindOptions');
modulemapper.clobbers('cordova/plugin/ContactName', 'ContactName');
modulemapper.clobbers('cordova/plugin/ContactOrganization', 'ContactOrganization');
});
// file: lib/common/plugin/device.js
define("cordova/plugin/device", function(require, exports, module) {