mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
@@ -0,0 +1,310 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
if (!Cordova.hasResource("contact")) {
|
21
|
+
Cordova.addResource("contact");
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Contains information about a single contact.
|
25
|
+
* @constructor
|
26
|
+
* @param {DOMString} id unique identifier
|
27
|
+
* @param {DOMString} displayName
|
28
|
+
* @param {ContactName} name
|
29
|
+
* @param {DOMString} nickname
|
30
|
+
* @param {Array.<ContactField>} phoneNumbers array of phone numbers
|
31
|
+
* @param {Array.<ContactField>} emails array of email addresses
|
32
|
+
* @param {Array.<ContactAddress>} addresses array of addresses
|
33
|
+
* @param {Array.<ContactField>} ims instant messaging user ids
|
34
|
+
* @param {Array.<ContactOrganization>} organizations
|
35
|
+
* @param {DOMString} birthday contact's birthday
|
36
|
+
* @param {DOMString} note user notes about contact
|
37
|
+
* @param {Array.<ContactField>} photos
|
38
|
+
* @param {Array.<ContactField>} categories
|
39
|
+
* @param {Array.<ContactField>} urls contact's web sites
|
40
|
+
*/
|
41
|
+
var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
|
42
|
+
ims, organizations, birthday, note, photos, categories, urls) {
|
43
|
+
this.id = id || null;
|
44
|
+
this.rawId = null;
|
45
|
+
this.displayName = displayName || null;
|
46
|
+
this.name = name || null; // ContactName
|
47
|
+
this.nickname = nickname || null;
|
48
|
+
this.phoneNumbers = phoneNumbers || null; // ContactField[]
|
49
|
+
this.emails = emails || null; // ContactField[]
|
50
|
+
this.addresses = addresses || null; // ContactAddress[]
|
51
|
+
this.ims = ims || null; // ContactField[]
|
52
|
+
this.organizations = organizations || null; // ContactOrganization[]
|
53
|
+
this.birthday = birthday || null;
|
54
|
+
this.note = note || null;
|
55
|
+
this.photos = photos || null; // ContactField[]
|
56
|
+
this.categories = categories || null; // ContactField[]
|
57
|
+
this.urls = urls || null; // ContactField[]
|
58
|
+
};
|
59
|
+
|
60
|
+
/**
|
61
|
+
* ContactError.
|
62
|
+
* An error code assigned by an implementation when an error has occurreds
|
63
|
+
* @constructor
|
64
|
+
*/
|
65
|
+
var ContactError = function() {
|
66
|
+
this.code=null;
|
67
|
+
};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Error codes
|
71
|
+
*/
|
72
|
+
ContactError.UNKNOWN_ERROR = 0;
|
73
|
+
ContactError.INVALID_ARGUMENT_ERROR = 1;
|
74
|
+
ContactError.TIMEOUT_ERROR = 2;
|
75
|
+
ContactError.PENDING_OPERATION_ERROR = 3;
|
76
|
+
ContactError.IO_ERROR = 4;
|
77
|
+
ContactError.NOT_SUPPORTED_ERROR = 5;
|
78
|
+
ContactError.PERMISSION_DENIED_ERROR = 20;
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Removes contact from device storage.
|
82
|
+
* @param successCB success callback
|
83
|
+
* @param errorCB error callback
|
84
|
+
*/
|
85
|
+
Contact.prototype.remove = function(successCB, errorCB) {
|
86
|
+
if (this.id === null) {
|
87
|
+
var errorObj = new ContactError();
|
88
|
+
errorObj.code = ContactError.UNKNOWN_ERROR;
|
89
|
+
errorCB(errorObj);
|
90
|
+
}
|
91
|
+
else {
|
92
|
+
Cordova.exec(successCB, errorCB, "Contacts", "remove", [this.id]);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Creates a deep copy of this Contact.
|
98
|
+
* With the contact ID set to null.
|
99
|
+
* @return copy of this Contact
|
100
|
+
*/
|
101
|
+
Contact.prototype.clone = function() {
|
102
|
+
var clonedContact = Cordova.clone(this);
|
103
|
+
var i;
|
104
|
+
clonedContact.id = null;
|
105
|
+
clonedContact.rawId = null;
|
106
|
+
// Loop through and clear out any id's in phones, emails, etc.
|
107
|
+
if (clonedContact.phoneNumbers) {
|
108
|
+
for (i = 0; i < clonedContact.phoneNumbers.length; i++) {
|
109
|
+
clonedContact.phoneNumbers[i].id = null;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
if (clonedContact.emails) {
|
113
|
+
for (i = 0; i < clonedContact.emails.length; i++) {
|
114
|
+
clonedContact.emails[i].id = null;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
if (clonedContact.addresses) {
|
118
|
+
for (i = 0; i < clonedContact.addresses.length; i++) {
|
119
|
+
clonedContact.addresses[i].id = null;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
if (clonedContact.ims) {
|
123
|
+
for (i = 0; i < clonedContact.ims.length; i++) {
|
124
|
+
clonedContact.ims[i].id = null;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
if (clonedContact.organizations) {
|
128
|
+
for (i = 0; i < clonedContact.organizations.length; i++) {
|
129
|
+
clonedContact.organizations[i].id = null;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
if (clonedContact.tags) {
|
133
|
+
for (i = 0; i < clonedContact.tags.length; i++) {
|
134
|
+
clonedContact.tags[i].id = null;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
if (clonedContact.photos) {
|
138
|
+
for (i = 0; i < clonedContact.photos.length; i++) {
|
139
|
+
clonedContact.photos[i].id = null;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
if (clonedContact.urls) {
|
143
|
+
for (i = 0; i < clonedContact.urls.length; i++) {
|
144
|
+
clonedContact.urls[i].id = null;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
return clonedContact;
|
148
|
+
};
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Persists contact to device storage.
|
152
|
+
* @param successCB success callback
|
153
|
+
* @param errorCB error callback
|
154
|
+
*/
|
155
|
+
Contact.prototype.save = function(successCB, errorCB) {
|
156
|
+
Cordova.exec(successCB, errorCB, "Contacts", "save", [this]);
|
157
|
+
};
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Contact name.
|
161
|
+
* @constructor
|
162
|
+
* @param formatted
|
163
|
+
* @param familyName
|
164
|
+
* @param givenName
|
165
|
+
* @param middle
|
166
|
+
* @param prefix
|
167
|
+
* @param suffix
|
168
|
+
*/
|
169
|
+
var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
|
170
|
+
this.formatted = formatted || null;
|
171
|
+
this.familyName = familyName || null;
|
172
|
+
this.givenName = givenName || null;
|
173
|
+
this.middleName = middle || null;
|
174
|
+
this.honorificPrefix = prefix || null;
|
175
|
+
this.honorificSuffix = suffix || null;
|
176
|
+
};
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Generic contact field.
|
180
|
+
* @constructor
|
181
|
+
* @param {DOMString} id unique identifier, should only be set by native code
|
182
|
+
* @param type
|
183
|
+
* @param value
|
184
|
+
* @param pref
|
185
|
+
*/
|
186
|
+
var ContactField = function(type, value, pref) {
|
187
|
+
this.id = null;
|
188
|
+
this.type = type || null;
|
189
|
+
this.value = value || null;
|
190
|
+
this.pref = pref || null;
|
191
|
+
};
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Contact address.
|
195
|
+
* @constructor
|
196
|
+
* @param {DOMString} id unique identifier, should only be set by native code
|
197
|
+
* @param formatted
|
198
|
+
* @param streetAddress
|
199
|
+
* @param locality
|
200
|
+
* @param region
|
201
|
+
* @param postalCode
|
202
|
+
* @param country
|
203
|
+
*/
|
204
|
+
var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
|
205
|
+
this.id = null;
|
206
|
+
this.pref = pref || null;
|
207
|
+
this.type = type || null;
|
208
|
+
this.formatted = formatted || null;
|
209
|
+
this.streetAddress = streetAddress || null;
|
210
|
+
this.locality = locality || null;
|
211
|
+
this.region = region || null;
|
212
|
+
this.postalCode = postalCode || null;
|
213
|
+
this.country = country || null;
|
214
|
+
};
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Contact organization.
|
218
|
+
* @constructor
|
219
|
+
* @param {DOMString} id unique identifier, should only be set by native code
|
220
|
+
* @param name
|
221
|
+
* @param dept
|
222
|
+
* @param title
|
223
|
+
* @param startDate
|
224
|
+
* @param endDate
|
225
|
+
* @param location
|
226
|
+
* @param desc
|
227
|
+
*/
|
228
|
+
var ContactOrganization = function(pref, type, name, dept, title) {
|
229
|
+
this.id = null;
|
230
|
+
this.pref = pref || null;
|
231
|
+
this.type = type || null;
|
232
|
+
this.name = name || null;
|
233
|
+
this.department = dept || null;
|
234
|
+
this.title = title || null;
|
235
|
+
};
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Represents a group of Contacts.
|
239
|
+
* @constructor
|
240
|
+
*/
|
241
|
+
var Contacts = function() {
|
242
|
+
this.inProgress = false;
|
243
|
+
this.records = [];
|
244
|
+
};
|
245
|
+
/**
|
246
|
+
* Returns an array of Contacts matching the search criteria.
|
247
|
+
* @param fields that should be searched
|
248
|
+
* @param successCB success callback
|
249
|
+
* @param errorCB error callback
|
250
|
+
* @param {ContactFindOptions} options that can be applied to contact searching
|
251
|
+
* @return array of Contacts matching search criteria
|
252
|
+
*/
|
253
|
+
Contacts.prototype.find = function(fields, successCB, errorCB, options) {
|
254
|
+
if (successCB === null) {
|
255
|
+
throw new TypeError("You must specify a success callback for the find command.");
|
256
|
+
}
|
257
|
+
if (fields === null || fields === "undefined" || fields.length === "undefined" || fields.length <= 0) {
|
258
|
+
if (typeof errorCB === "function") {
|
259
|
+
errorCB({"code": ContactError.INVALID_ARGUMENT_ERROR});
|
260
|
+
}
|
261
|
+
} else {
|
262
|
+
var win = function(result) {
|
263
|
+
var cs = [];
|
264
|
+
for (var i = 0, l = result.length; i < l; i++) {
|
265
|
+
cs.push(navigator.contacts.create(result[i]));
|
266
|
+
}
|
267
|
+
successCB(cs);
|
268
|
+
};
|
269
|
+
Cordova.exec(win, errorCB, "Contacts", "search", [fields, options]);
|
270
|
+
}
|
271
|
+
};
|
272
|
+
|
273
|
+
/**
|
274
|
+
* This function creates a new contact, but it does not persist the contact
|
275
|
+
* to device storage. To persist the contact to device storage, invoke
|
276
|
+
* contact.save().
|
277
|
+
* @param properties an object who's properties will be examined to create a new Contact
|
278
|
+
* @returns new Contact object
|
279
|
+
*/
|
280
|
+
Contacts.prototype.create = function(properties) {
|
281
|
+
var i;
|
282
|
+
var contact = new Contact();
|
283
|
+
for (i in properties) {
|
284
|
+
if (contact[i] !== 'undefined') {
|
285
|
+
contact[i] = properties[i];
|
286
|
+
}
|
287
|
+
}
|
288
|
+
return contact;
|
289
|
+
};
|
290
|
+
|
291
|
+
/**
|
292
|
+
* ContactFindOptions.
|
293
|
+
* @constructor
|
294
|
+
* @param filter used to match contacts against
|
295
|
+
* @param multiple boolean used to determine if more than one contact should be returned
|
296
|
+
*/
|
297
|
+
var ContactFindOptions = function(filter, multiple) {
|
298
|
+
this.filter = filter || '';
|
299
|
+
this.multiple = multiple || false;
|
300
|
+
};
|
301
|
+
|
302
|
+
/**
|
303
|
+
* Add the contact interface into the browser.
|
304
|
+
*/
|
305
|
+
Cordova.addConstructor(function() {
|
306
|
+
if(typeof navigator.contacts === "undefined") {
|
307
|
+
navigator.contacts = new Contacts();
|
308
|
+
}
|
309
|
+
});
|
310
|
+
}
|