From c1a87ebaaa61cef60900d313deb634addda326ce Mon Sep 17 00:00:00 2001 From: macdonst Date: Thu, 18 Nov 2010 06:37:27 +0800 Subject: [PATCH] Adding and optional call to cast Plugin Result --- framework/assets/js/contact.js | 18 +++++++++++++++++- framework/assets/js/phonegap.js.base | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/framework/assets/js/contact.js b/framework/assets/js/contact.js index ee99e0d4..984ca37f 100755 --- a/framework/assets/js/contact.js +++ b/framework/assets/js/contact.js @@ -242,7 +242,7 @@ var Contacts = function() { * @return array of Contacts matching search criteria */ Contacts.prototype.find = function(fields, successCB, errorCB, options) { - PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options]); + PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options], navigator.service.contacts.cast); }; /** @@ -262,6 +262,22 @@ Contacts.prototype.create = function(properties) { return contact; }; +/** +* This function returns and array of contacts. It is required as we need to convert raw +* JSON objects into concrete Contact objects. Currently this method is called after +* navigator.service.contacts.find but before the find methods success call back. +* +* @param jsonArray an array of JSON Objects that need to be converted to Contact objects. +* @returns an array of Contact objects +*/ +Contacts.prototype.cast = function(jsonArray) { + var contacts = new Array(); + for (var i=0; i