mobile_template 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. data/lib/mobile_template/version.rb +1 -1
  2. data/mobile_template.gemspec +1 -1
  3. data/templates/assets/Gemfile +1 -1
  4. data/templates/assets/source/javascripts/vendor/cordova.js +2106 -1975
  5. data/templates/assets/source/javascripts/vendor/jquery.js +614 -477
  6. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +519 -378
  7. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +683 -502
  8. data/templates/cordova_android/VERSION +1 -1
  9. data/templates/cordova_android/bin/create +5 -1
  10. data/templates/cordova_android/bin/templates/project/cordova/create +5 -0
  11. data/templates/cordova_android/bin/templates/project/cordova/debug +1 -1
  12. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +18 -25
  13. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +6 -6
  14. data/templates/cordova_android/framework/assets/js/cordova.android.js +2106 -1975
  15. data/templates/cordova_android/framework/assets/www/index.html +1 -1
  16. data/templates/cordova_android/framework/build.xml +2 -42
  17. data/templates/cordova_android/framework/project.properties +1 -1
  18. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  19. data/templates/cordova_android/framework/res/drawable-hdpi/icon.png +0 -0
  20. data/templates/cordova_android/framework/res/drawable-ldpi/icon.png +0 -0
  21. data/templates/cordova_android/framework/res/drawable-mdpi/icon.png +0 -0
  22. data/templates/cordova_android/framework/res/xml/plugins.xml +2 -1
  23. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +1 -0
  24. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +24 -16
  25. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +35 -10
  26. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +2 -1
  27. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +67 -65
  28. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +51 -63
  29. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +3 -0
  30. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +6 -2
  31. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +108 -108
  32. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +110 -77
  33. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +90 -44
  34. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +20 -20
  35. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +2 -2
  36. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +7 -8
  37. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +2 -2
  38. data/templates/cordova_android/framework/src/org/apache/cordova/SplashScreen.java +23 -0
  39. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +3 -3
  40. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +2 -0
  41. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginEntry.java +119 -0
  42. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +260 -258
  43. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +2 -2
  44. data/templates/cordova_android/releasenotes.md +42 -0
  45. data/templates/cordova_android/test/.classpath +8 -0
  46. data/templates/cordova_android/test/.project +33 -0
  47. data/templates/cordova_android/test/AndroidManifest.xml +87 -0
  48. data/templates/cordova_android/test/README.md +23 -0
  49. data/templates/cordova_android/test/ant.properties +17 -0
  50. data/templates/cordova_android/test/assets/www/backbuttonmultipage/index.html +23 -0
  51. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample2.html +23 -0
  52. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample3.html +26 -0
  53. data/templates/cordova_android/test/assets/www/background/index.html +99 -0
  54. data/templates/cordova_android/test/assets/www/background/index2.html +98 -0
  55. data/templates/cordova_android/test/assets/www/cordova-1.6.0.js +4985 -0
  56. data/templates/cordova_android/test/assets/www/cordova.js +2 -0
  57. data/templates/cordova_android/test/assets/www/htmlnotfound/error.html +1 -0
  58. data/templates/cordova_android/test/assets/www/iframe/index.html +33 -0
  59. data/templates/cordova_android/test/assets/www/iframe/index2.html +24 -0
  60. data/templates/cordova_android/test/assets/www/index.html +47 -0
  61. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/index.html +49 -0
  62. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab1.html +29 -0
  63. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab2.html +30 -0
  64. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab3.html +30 -0
  65. data/templates/cordova_android/test/assets/www/lifecycle/index.html +108 -0
  66. data/templates/cordova_android/test/assets/www/lifecycle/index2.html +104 -0
  67. data/templates/cordova_android/test/assets/www/main.js +150 -0
  68. data/templates/cordova_android/test/assets/www/master.css +117 -0
  69. data/templates/cordova_android/test/assets/www/menus/index.html +29 -0
  70. data/templates/cordova_android/test/assets/www/splashscreen/index.html +22 -0
  71. data/templates/cordova_android/test/assets/www/userwebview/index.html +49 -0
  72. data/templates/cordova_android/test/assets/www/whitelist/index.html +29 -0
  73. data/templates/cordova_android/test/assets/www/whitelist/index2.html +23 -0
  74. data/templates/cordova_android/test/assets/www/xhr/index.html +48 -0
  75. data/templates/cordova_android/test/build.xml +85 -0
  76. data/templates/cordova_android/test/libs/cordova-1.6.0.jar +0 -0
  77. data/templates/cordova_android/test/project.properties +11 -0
  78. data/templates/cordova_android/{framework → test}/res/drawable/icon.png +0 -0
  79. data/templates/cordova_android/test/res/drawable/sandy.jpg +0 -0
  80. data/templates/cordova_android/test/res/drawable-hdpi/ic_launcher.png +0 -0
  81. data/templates/cordova_android/test/res/drawable-ldpi/ic_launcher.png +0 -0
  82. data/templates/cordova_android/test/res/drawable-mdpi/ic_launcher.png +0 -0
  83. data/templates/cordova_android/test/res/layout/main.xml +13 -0
  84. data/templates/cordova_android/test/res/values/strings.xml +4 -0
  85. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/cordova.xml +0 -0
  86. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/plugins.xml +1 -1
  87. data/templates/cordova_android/test/src/org/apache/cordova/test/ActivityPlugin.java +81 -0
  88. data/templates/cordova_android/test/src/org/apache/cordova/test/FixWebView.java +43 -0
  89. data/templates/cordova_android/test/src/org/apache/cordova/test/backbuttonmultipage.java +30 -0
  90. data/templates/cordova_android/test/src/org/apache/cordova/test/background.java +34 -0
  91. data/templates/cordova_android/test/src/org/apache/cordova/test/errorurl.java +32 -0
  92. data/templates/cordova_android/test/src/org/apache/cordova/test/htmlnotfound.java +31 -0
  93. data/templates/cordova_android/test/src/org/apache/cordova/test/iframe.java +30 -0
  94. data/templates/cordova_android/test/src/org/apache/cordova/test/jqmtabbackbutton.java +30 -0
  95. data/templates/cordova_android/test/src/org/apache/cordova/test/lifecycle.java +30 -0
  96. data/templates/cordova_android/test/src/org/apache/cordova/test/loading.java +31 -0
  97. data/templates/cordova_android/test/src/org/apache/cordova/test/menus.java +80 -0
  98. data/templates/cordova_android/test/src/org/apache/cordova/test/splashscreen.java +35 -0
  99. data/templates/cordova_android/test/src/org/apache/cordova/test/tests.java +32 -0
  100. data/templates/cordova_android/test/src/org/apache/cordova/test/timeout.java +34 -0
  101. data/templates/cordova_android/test/src/org/apache/cordova/test/userwebview.java +72 -0
  102. data/templates/cordova_android/test/src/org/apache/cordova/test/whitelist.java +51 -0
  103. data/templates/cordova_android/test/src/org/apache/cordova/test/xhr.java +30 -0
  104. metadata +83 -30
  105. data/templates/cordova_android/framework/assets/js/accelerometer.js +0 -137
  106. data/templates/cordova_android/framework/assets/js/app.js +0 -89
  107. data/templates/cordova_android/framework/assets/js/battery.js +0 -134
  108. data/templates/cordova_android/framework/assets/js/camera.js +0 -168
  109. data/templates/cordova_android/framework/assets/js/capture.js +0 -203
  110. data/templates/cordova_android/framework/assets/js/compass.js +0 -168
  111. data/templates/cordova_android/framework/assets/js/contact.js +0 -310
  112. data/templates/cordova_android/framework/assets/js/cordova.js.base +0 -924
  113. data/templates/cordova_android/framework/assets/js/crypto.js +0 -54
  114. data/templates/cordova_android/framework/assets/js/device.js +0 -83
  115. data/templates/cordova_android/framework/assets/js/file.js +0 -1082
  116. data/templates/cordova_android/framework/assets/js/filetransfer.js +0 -125
  117. data/templates/cordova_android/framework/assets/js/geolocation.js +0 -209
  118. data/templates/cordova_android/framework/assets/js/header.txt +0 -19
  119. data/templates/cordova_android/framework/assets/js/media.js +0 -233
  120. data/templates/cordova_android/framework/assets/js/network.js +0 -100
  121. data/templates/cordova_android/framework/assets/js/notification.js +0 -133
  122. data/templates/cordova_android/framework/assets/js/position.js +0 -100
  123. data/templates/cordova_android/framework/assets/js/storage.js +0 -439
@@ -1,301 +1,29 @@
1
- /*
2
-
3
- Apache License
4
- Version 2.0, January 2004
5
- http://www.apache.org/licenses/
6
-
7
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
-
9
- 1. Definitions.
10
-
11
- "License" shall mean the terms and conditions for use, reproduction,
12
- and distribution as defined by Sections 1 through 9 of this document.
13
-
14
- "Licensor" shall mean the copyright owner or entity authorized by
15
- the copyright owner that is granting the License.
16
-
17
- "Legal Entity" shall mean the union of the acting entity and all
18
- other entities that control, are controlled by, or are under common
19
- control with that entity. For the purposes of this definition,
20
- "control" means (i) the power, direct or indirect, to cause the
21
- direction or management of such entity, whether by contract or
22
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
- outstanding shares, or (iii) beneficial ownership of such entity.
24
-
25
- "You" (or "Your") shall mean an individual or Legal Entity
26
- exercising permissions granted by this License.
27
-
28
- "Source" form shall mean the preferred form for making modifications,
29
- including but not limited to software source code, documentation
30
- source, and configuration files.
31
-
32
- "Object" form shall mean any form resulting from mechanical
33
- transformation or translation of a Source form, including but
34
- not limited to compiled object code, generated documentation,
35
- and conversions to other media types.
36
-
37
- "Work" shall mean the work of authorship, whether in Source or
38
- Object form, made available under the License, as indicated by a
39
- copyright notice that is included in or attached to the work
40
- (an example is provided in the Appendix below).
41
-
42
- "Derivative Works" shall mean any work, whether in Source or Object
43
- form, that is based on (or derived from) the Work and for which the
44
- editorial revisions, annotations, elaborations, or other modifications
45
- represent, as a whole, an original work of authorship. For the purposes
46
- of this License, Derivative Works shall not include works that remain
47
- separable from, or merely link (or bind by name) to the interfaces of,
48
- the Work and Derivative Works thereof.
49
-
50
- "Contribution" shall mean any work of authorship, including
51
- the original version of the Work and any modifications or additions
52
- to that Work or Derivative Works thereof, that is intentionally
53
- submitted to Licensor for inclusion in the Work by the copyright owner
54
- or by an individual or Legal Entity authorized to submit on behalf of
55
- the copyright owner. For the purposes of this definition, "submitted"
56
- means any form of electronic, verbal, or written communication sent
57
- to the Licensor or its representatives, including but not limited to
58
- communication on electronic mailing lists, source code control systems,
59
- and issue tracking systems that are managed by, or on behalf of, the
60
- Licensor for the purpose of discussing and improving the Work, but
61
- excluding communication that is conspicuously marked or otherwise
62
- designated in writing by the copyright owner as "Not a Contribution."
63
-
64
- "Contributor" shall mean Licensor and any individual or Legal Entity
65
- on behalf of whom a Contribution has been received by Licensor and
66
- subsequently incorporated within the Work.
67
-
68
- 2. Grant of Copyright License. Subject to the terms and conditions of
69
- this License, each Contributor hereby grants to You a perpetual,
70
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
- copyright license to reproduce, prepare Derivative Works of,
72
- publicly display, publicly perform, sublicense, and distribute the
73
- Work and such Derivative Works in Source or Object form.
74
-
75
- 3. Grant of Patent License. Subject to the terms and conditions of
76
- this License, each Contributor hereby grants to You a perpetual,
77
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
- (except as stated in this section) patent license to make, have made,
79
- use, offer to sell, sell, import, and otherwise transfer the Work,
80
- where such license applies only to those patent claims licensable
81
- by such Contributor that are necessarily infringed by their
82
- Contribution(s) alone or by combination of their Contribution(s)
83
- with the Work to which such Contribution(s) was submitted. If You
84
- institute patent litigation against any entity (including a
85
- cross-claim or counterclaim in a lawsuit) alleging that the Work
86
- or a Contribution incorporated within the Work constitutes direct
87
- or contributory patent infringement, then any patent licenses
88
- granted to You under this License for that Work shall terminate
89
- as of the date such litigation is filed.
90
-
91
- 4. Redistribution. You may reproduce and distribute copies of the
92
- Work or Derivative Works thereof in any medium, with or without
93
- modifications, and in Source or Object form, provided that You
94
- meet the following conditions:
95
-
96
- (a) You must give any other recipients of the Work or
97
- Derivative Works a copy of this License; and
98
-
99
- (b) You must cause any modified files to carry prominent notices
100
- stating that You changed the files; and
101
-
102
- (c) You must retain, in the Source form of any Derivative Works
103
- that You distribute, all copyright, patent, trademark, and
104
- attribution notices from the Source form of the Work,
105
- excluding those notices that do not pertain to any part of
106
- the Derivative Works; and
107
-
108
- (d) If the Work includes a "NOTICE" text file as part of its
109
- distribution, then any Derivative Works that You distribute must
110
- include a readable copy of the attribution notices contained
111
- within such NOTICE file, excluding those notices that do not
112
- pertain to any part of the Derivative Works, in at least one
113
- of the following places: within a NOTICE text file distributed
114
- as part of the Derivative Works; within the Source form or
115
- documentation, if provided along with the Derivative Works; or,
116
- within a display generated by the Derivative Works, if and
117
- wherever such third-party notices normally appear. The contents
118
- of the NOTICE file are for informational purposes only and
119
- do not modify the License. You may add Your own attribution
120
- notices within Derivative Works that You distribute, alongside
121
- or as an addendum to the NOTICE text from the Work, provided
122
- that such additional attribution notices cannot be construed
123
- as modifying the License.
124
-
125
- You may add Your own copyright statement to Your modifications and
126
- may provide additional or different license terms and conditions
127
- for use, reproduction, or distribution of Your modifications, or
128
- for any such Derivative Works as a whole, provided Your use,
129
- reproduction, and distribution of the Work otherwise complies with
130
- the conditions stated in this License.
131
-
132
- 5. Submission of Contributions. Unless You explicitly state otherwise,
133
- any Contribution intentionally submitted for inclusion in the Work
134
- by You to the Licensor shall be under the terms and conditions of
135
- this License, without any additional terms or conditions.
136
- Notwithstanding the above, nothing herein shall supersede or modify
137
- the terms of any separate license agreement you may have executed
138
- with Licensor regarding such Contributions.
139
-
140
- 6. Trademarks. This License does not grant permission to use the trade
141
- names, trademarks, service marks, or product names of the Licensor,
142
- except as required for reasonable and customary use in describing the
143
- origin of the Work and reproducing the content of the NOTICE file.
144
-
145
- 7. Disclaimer of Warranty. Unless required by applicable law or
146
- agreed to in writing, Licensor provides the Work (and each
147
- Contributor provides its Contributions) on an "AS IS" BASIS,
148
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
- implied, including, without limitation, any warranties or conditions
150
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
- PARTICULAR PURPOSE. You are solely responsible for determining the
152
- appropriateness of using or redistributing the Work and assume any
153
- risks associated with Your exercise of permissions under this License.
154
-
155
- 8. Limitation of Liability. In no event and under no legal theory,
156
- whether in tort (including negligence), contract, or otherwise,
157
- unless required by applicable law (such as deliberate and grossly
158
- negligent acts) or agreed to in writing, shall any Contributor be
159
- liable to You for damages, including any direct, indirect, special,
160
- incidental, or consequential damages of any character arising as a
161
- result of this License or out of the use or inability to use the
162
- Work (including but not limited to damages for loss of goodwill,
163
- work stoppage, computer failure or malfunction, or any and all
164
- other commercial damages or losses), even if such Contributor
165
- has been advised of the possibility of such damages.
166
-
167
- 9. Accepting Warranty or Additional Liability. While redistributing
168
- the Work or Derivative Works thereof, You may choose to offer,
169
- and charge a fee for, acceptance of support, warranty, indemnity,
170
- or other liability obligations and/or rights consistent with this
171
- License. However, in accepting such obligations, You may act only
172
- on Your own behalf and on Your sole responsibility, not on behalf
173
- of any other Contributor, and only if You agree to indemnify,
174
- defend, and hold each Contributor harmless for any liability
175
- incurred by, or claims asserted against, such Contributor by reason
176
- of your accepting any such warranty or additional liability.
177
-
178
- END OF TERMS AND CONDITIONS
179
-
180
- APPENDIX: How to apply the Apache License to your work.
181
-
182
- To apply the Apache License to your work, attach the following
183
- boilerplate notice, with the fields enclosed by brackets "[]"
184
- replaced with your own identifying information. (Don't include
185
- the brackets!) The text should be enclosed in the appropriate
186
- comment syntax for the file format. We also recommend that a
187
- file or class name and description of purpose be included on the
188
- same "printed page" as the copyright notice for easier
189
- identification within third-party archives.
190
-
191
- Copyright [yyyy] [name of copyright owner]
192
-
193
- Licensed under the Apache License, Version 2.0 (the "License");
194
- you may not use this file except in compliance with the License.
195
- You may obtain a copy of the License at
196
-
197
- http://www.apache.org/licenses/LICENSE-2.0
198
-
199
- Unless required by applicable law or agreed to in writing, software
200
- distributed under the License is distributed on an "AS IS" BASIS,
201
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
- See the License for the specific language governing permissions and
203
- limitations under the License.
204
-
205
- ==============================================================
206
- This product also include the following software:
207
- ==============================================================
208
-
209
- --------------------------------------------------------------
210
- jasmine from GitHub
211
-
212
- https://github.com/pivotal/jasmine
213
-
214
- MIT-style license
215
-
216
- license available from:
217
-
218
- https://github.com/pivotal/jasmine/blob/master/MIT.LICENSE
219
-
220
- -----------------------------
221
-
222
- Copyright (c) 2008-2011 Pivotal Labs
223
-
224
- Permission is hereby granted, free of charge, to any person obtaining
225
- a copy of this software and associated documentation files (the
226
- "Software"), to deal in the Software without restriction, including
227
- without limitation the rights to use, copy, modify, merge, publish,
228
- distribute, sublicense, and/or sell copies of the Software, and to
229
- permit persons to whom the Software is furnished to do so, subject to
230
- the following conditions:
231
-
232
- The above copyright notice and this permission notice shall be
233
- included in all copies or substantial portions of the Software.
234
-
235
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
236
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
237
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
238
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
239
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
240
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
241
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
242
-
243
-
244
- --------------------------------------------------------------
245
- commonjs tests from the commonjs organization at GitHub
246
-
247
- https://github.com/commonjs/commonjs
248
-
249
- MIT-style license
250
-
251
- license available from:
252
-
253
- https://github.com/commonjs/commonjs/blob/master/docs/license.html.markdown
254
-
255
- contributor list available from:
256
-
257
- https://github.com/commonjs/commonjs/blob/master/docs/contributors.html.markdown
258
-
259
- -----------------------------
260
-
261
- Copyright 2009 Kevin Dangoor
262
- Copyright 2009 Ihab Awad
263
- Copyright 2009 Ash Berlin
264
- Copyright 2009 Aristid Breitkreuz
265
- Copyright 2009 Kevin Dangoor
266
- Copyright 2009 Daniel Friesen
267
- Copyright 2009 Wes Garland
268
- Copyright 2009 Kris Kowal
269
- Copyright 2009 Dean Landolt
270
- Copyright 2009 Peter Michaux
271
- Copyright 2009 George Moschovitis
272
- Copyright 2009 Michael O'Brien
273
- Copyright 2009 Tom Robinson
274
- Copyright 2009 Hannes Wallnoefer
275
- Copyright 2009 Mike Wilson
276
- Copyright 2009 Ondrej Zara
277
- Copyright 2009 Chris Zumbrunn
278
- Copyright 2009 Kris Zyp
1
+ // commit cb7a4c7a4a680eccaef768a2e0c6e4631d39fcaf
279
2
 
280
- Permission is hereby granted, free of charge, to any person obtaining a copy
281
- of this software and associated documentation files (the "Software"), to deal
282
- in the Software without restriction, including without limitation the rights
283
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
284
- copies of the Software, and to permit persons to whom the Software is
285
- furnished to do so, subject to the following conditions:
3
+ // File generated at :: Mon Apr 30 2012 13:28:32 GMT-0700 (PDT)
286
4
 
287
- The above copyright notice and this permission notice shall be included in
288
- all copies or substantial portions of the Software.
5
+ /*
6
+ Licensed to the Apache Software Foundation (ASF) under one
7
+ or more contributor license agreements. See the NOTICE file
8
+ distributed with this work for additional information
9
+ regarding copyright ownership. The ASF licenses this file
10
+ to you under the Apache License, Version 2.0 (the
11
+ "License"); you may not use this file except in compliance
12
+ with the License. You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing,
17
+ software distributed under the License is distributed on an
18
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+ KIND, either express or implied. See the License for the
20
+ specific language governing permissions and limitations
21
+ under the License.
22
+ */
289
23
 
290
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
291
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
292
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
293
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
294
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
295
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
296
- THE SOFTWARE.
24
+ ;(function() {
297
25
 
298
- */
26
+ // file: lib/scripts/require.js
299
27
  var require,
300
28
  define;
301
29
 
@@ -315,7 +43,7 @@ var require,
315
43
  throw "module " + id + " not found";
316
44
  }
317
45
  return modules[id].factory ? build(modules[id]) : modules[id].exports;
318
- }
46
+ };
319
47
 
320
48
  define = function (id, factory) {
321
49
  if (modules[id]) {
@@ -326,7 +54,7 @@ var require,
326
54
  id: id,
327
55
  factory: factory
328
56
  };
329
- }
57
+ };
330
58
 
331
59
  define.remove = function (id) {
332
60
  delete modules[id];
@@ -339,156 +67,20 @@ if (typeof module === "object" && typeof require === "function") {
339
67
  module.exports.require = require;
340
68
  module.exports.define = define;
341
69
  }
342
-
343
- define('cordova/channel', function(require, exports, module) {
344
- /**
345
- * Custom pub-sub channel that can have functions subscribed to it
346
- * @constructor
347
- * @param type String the channel name
348
- * @param opts Object options to pass into the channel, currently
349
- * supports:
350
- * onSubscribe: callback that fires when
351
- * something subscribes to the Channel. Sets
352
- * context to the Channel.
353
- * onUnsubscribe: callback that fires when
354
- * something unsubscribes to the Channel. Sets
355
- * context to the Channel.
356
- */
357
- var Channel = function(type, opts) {
358
- this.type = type;
359
- this.handlers = {};
360
- this.numHandlers = 0;
361
- this.guid = 0;
362
- this.fired = false;
363
- this.enabled = true;
364
- this.events = {
365
- onSubscribe:null,
366
- onUnsubscribe:null
367
- };
368
- if (opts) {
369
- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
370
- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
371
- }
372
- },
373
- channel = {
374
- /**
375
- * Calls the provided function only after all of the channels specified
376
- * have been fired.
377
- */
378
- join: function (h, c) {
379
- var i = c.length;
380
- var len = i;
381
- var f = function() {
382
- if (!(--i)) h();
383
- };
384
- for (var j=0; j<len; j++) {
385
- !c[j].fired?c[j].subscribeOnce(f):i--;
386
- }
387
- if (!i) h();
388
- },
389
- create: function (type, opts) {
390
- channel[type] = new Channel(type, opts);
391
- return channel[type];
392
- }
393
- },
394
- utils = require('cordova/utils');
395
-
396
- /**
397
- * Subscribes the given function to the channel. Any time that
398
- * Channel.fire is called so too will the function.
399
- * Optionally specify an execution context for the function
400
- * and a guid that can be used to stop subscribing to the channel.
401
- * Returns the guid.
402
- */
403
- Channel.prototype.subscribe = function(f, c, g) {
404
- // need a function to call
405
- if (f === null || f === undefined) { return; }
406
-
407
- var func = f;
408
- if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
409
-
410
- g = g || func.observer_guid || f.observer_guid || this.guid++;
411
- func.observer_guid = g;
412
- f.observer_guid = g;
413
- this.handlers[g] = func;
414
- this.numHandlers++;
415
- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
416
- return g;
417
- };
70
+ // file: lib/cordova.js
71
+ define("cordova", function(require, exports, module) {
72
+ var channel = require('cordova/channel');
418
73
 
419
74
  /**
420
- * Like subscribe but the function is only called once and then it
421
- * auto-unsubscribes itself.
422
- */
423
- Channel.prototype.subscribeOnce = function(f, c) {
424
- // need a function to call
425
- if (f === null || f === undefined) { return; }
426
-
427
- var g = null;
428
- var _this = this;
429
- var m = function() {
430
- f.apply(c || null, arguments);
431
- _this.unsubscribe(g);
432
- };
433
- if (this.fired) {
434
- if (typeof c == "object" && f instanceof Function) { f = utils.close(c, f); }
435
- f.apply(this, this.fireArgs);
436
- } else {
437
- g = this.subscribe(m);
438
- }
439
- return g;
440
- };
441
-
442
- /**
443
- * Unsubscribes the function with the given guid from the channel.
444
- */
445
- Channel.prototype.unsubscribe = function(g) {
446
- // need a function to unsubscribe
447
- if (g === null || g === undefined) { return; }
448
-
449
- if (g instanceof Function) { g = g.observer_guid; }
450
- this.handlers[g] = null;
451
- delete this.handlers[g];
452
- this.numHandlers--;
453
- if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
454
- };
455
-
456
- /**
457
- * Calls all functions subscribed to this channel.
75
+ * Listen for DOMContentLoaded and notify our channel subscribers.
458
76
  */
459
- Channel.prototype.fire = function(e) {
460
- if (this.enabled) {
461
- var fail = false;
462
- this.fired = true;
463
- for (var item in this.handlers) {
464
- var handler = this.handlers[item];
465
- if (handler instanceof Function) {
466
- var rv = (handler.apply(this, arguments)===false);
467
- fail = fail || rv;
468
- }
469
- }
470
- this.fireArgs = arguments;
471
- return !fail;
472
- }
473
- return true;
474
- };
475
-
476
- //HACK: defining them here so they are ready super fast!
477
- channel.create('onDOMContentLoaded');
478
- channel.create('onNativeReady');
479
- channel.create('onCordovaReady');
480
- channel.create('onCordovaInfoReady');
481
- channel.create('onCordovaConnectionReady');
482
- channel.create('onResume');
483
- channel.create('onPause');
484
- channel.create('onDeviceReady');
485
- channel.create('onDestroy');
486
-
487
- module.exports = channel;
77
+ document.addEventListener('DOMContentLoaded', function() {
78
+ channel.onDOMContentLoaded.fire();
79
+ }, false);
80
+ if (document.readyState == 'complete') {
81
+ channel.onDOMContentLoaded.fire();
82
+ }
488
83
 
489
- });
490
- define('cordova', function(require, exports, module) {
491
- var channel = require('cordova/channel');
492
84
  /**
493
85
  * Intercept calls to addEventListener + removeEventListener and handle deviceready,
494
86
  * resume, and pause events.
@@ -509,96 +101,118 @@ document.addEventListener = function(evt, handler, capture) {
509
101
  if (e == 'deviceready') {
510
102
  channel.onDeviceReady.subscribeOnce(handler);
511
103
  } else if (e == 'resume') {
512
- channel.onResume.subscribe(handler);
513
- // if subscribing listener after event has already fired, invoke the handler
514
- if (channel.onResume.fired && handler instanceof Function) {
515
- handler();
516
- }
104
+ channel.onResume.subscribe(handler);
105
+ // if subscribing listener after event has already fired, invoke the handler
106
+ if (channel.onResume.fired && typeof handler == 'function') {
107
+ handler();
108
+ }
517
109
  } else if (e == 'pause') {
518
- channel.onPause.subscribe(handler);
110
+ channel.onPause.subscribe(handler);
519
111
  } else if (typeof documentEventHandlers[e] != 'undefined') {
520
- documentEventHandlers[e].subscribe(handler);
112
+ documentEventHandlers[e].subscribe(handler);
521
113
  } else {
522
- m_document_addEventListener.call(document, evt, handler, capture);
114
+ m_document_addEventListener.call(document, evt, handler, capture);
523
115
  }
524
116
  };
525
117
 
526
118
  window.addEventListener = function(evt, handler, capture) {
527
- var e = evt.toLowerCase();
528
- if (typeof windowEventHandlers[e] != 'undefined') {
529
- windowEventHandlers[e].subscribe(handler);
530
- } else {
531
- m_window_addEventListener.call(window, evt, handler, capture);
532
- }
119
+ var e = evt.toLowerCase();
120
+ if (typeof windowEventHandlers[e] != 'undefined') {
121
+ windowEventHandlers[e].subscribe(handler);
122
+ } else {
123
+ m_window_addEventListener.call(window, evt, handler, capture);
124
+ }
533
125
  };
534
126
 
535
127
  document.removeEventListener = function(evt, handler, capture) {
536
- var e = evt.toLowerCase();
537
- // If unsubcribing from an event that is handled by a plugin
538
- if (typeof documentEventHandlers[e] != "undefined") {
539
- documentEventHandlers[e].unsubscribe(handler);
540
- } else {
541
- m_document_removeEventListener.call(document, evt, handler, capture);
542
- }
128
+ var e = evt.toLowerCase();
129
+ // Check for pause/resume events first.
130
+ if (e == 'resume') {
131
+ channel.onResume.unsubscribe(handler);
132
+ } else if (e == 'pause') {
133
+ channel.onPause.unsubscribe(handler);
134
+ // If unsubcribing from an event that is handled by a plugin
135
+ } else if (typeof documentEventHandlers[e] != "undefined") {
136
+ documentEventHandlers[e].unsubscribe(handler);
137
+ } else {
138
+ m_document_removeEventListener.call(document, evt, handler, capture);
139
+ }
543
140
  };
544
141
 
545
142
  window.removeEventListener = function(evt, handler, capture) {
546
- var e = evt.toLowerCase();
547
- // If unsubcribing from an event that is handled by a plugin
548
- if (typeof windowEventHandlers[e] != "undefined") {
549
- windowEventHandlers[e].unsubscribe(handler);
550
- } else {
551
- m_window_removeEventListener.call(window, evt, handler, capture);
552
- }
143
+ var e = evt.toLowerCase();
144
+ // If unsubcribing from an event that is handled by a plugin
145
+ if (typeof windowEventHandlers[e] != "undefined") {
146
+ windowEventHandlers[e].unsubscribe(handler);
147
+ } else {
148
+ m_window_removeEventListener.call(window, evt, handler, capture);
149
+ }
553
150
  };
554
151
 
555
152
  function createEvent(type, data) {
556
- var event = document.createEvent('Events');
557
- event.initEvent(type, false, false);
558
- if (data) {
559
- for (var i in data) {
560
- if (data.hasOwnProperty(i)) {
561
- event[i] = data[i];
562
- }
153
+ var event = document.createEvent('Events');
154
+ event.initEvent(type, false, false);
155
+ if (data) {
156
+ for (var i in data) {
157
+ if (data.hasOwnProperty(i)) {
158
+ event[i] = data[i];
159
+ }
160
+ }
563
161
  }
564
- }
565
- return event;
162
+ return event;
163
+ }
164
+
165
+ if(typeof window.console === "undefined") {
166
+ window.console = {
167
+ log:function(){}
168
+ };
566
169
  }
567
170
 
568
171
  var cordova = {
172
+ define:define,
173
+ require:require,
569
174
  /**
570
175
  * Methods to add/remove your own addEventListener hijacking on document + window.
571
176
  */
572
177
  addWindowEventHandler:function(event, opts) {
573
- return (windowEventHandlers[event] = channel.create(event, opts));
178
+ return (windowEventHandlers[event] = channel.create(event, opts));
574
179
  },
575
180
  addDocumentEventHandler:function(event, opts) {
576
- return (documentEventHandlers[event] = channel.create(event, opts));
181
+ return (documentEventHandlers[event] = channel.create(event, opts));
577
182
  },
578
183
  removeWindowEventHandler:function(event) {
579
- delete windowEventHandlers[event];
184
+ delete windowEventHandlers[event];
580
185
  },
581
186
  removeDocumentEventHandler:function(event) {
582
- delete documentEventHandlers[event];
187
+ delete documentEventHandlers[event];
188
+ },
189
+ /**
190
+ * Retreive original event handlers that were replaced by Cordova
191
+ *
192
+ * @return object
193
+ */
194
+ getOriginalHandlers: function() {
195
+ return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
196
+ 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
583
197
  },
584
198
  /**
585
199
  * Method to fire event from native code
586
200
  */
587
201
  fireDocumentEvent: function(type, data) {
588
- var evt = createEvent(type, data);
589
- if (typeof documentEventHandlers[type] != 'undefined') {
590
- documentEventHandlers[type].fire(evt);
591
- } else {
592
- document.dispatchEvent(evt);
593
- }
202
+ var evt = createEvent(type, data);
203
+ if (typeof documentEventHandlers[type] != 'undefined') {
204
+ documentEventHandlers[type].fire(evt);
205
+ } else {
206
+ document.dispatchEvent(evt);
207
+ }
594
208
  },
595
209
  fireWindowEvent: function(type, data) {
596
- var evt = createEvent(type,data);
597
- if (typeof windowEventHandlers[type] != 'undefined') {
598
- windowEventHandlers[type].fire(evt);
599
- } else {
600
- window.dispatchEvent(evt);
601
- }
210
+ var evt = createEvent(type,data);
211
+ if (typeof windowEventHandlers[type] != 'undefined') {
212
+ windowEventHandlers[type].fire(evt);
213
+ } else {
214
+ window.dispatchEvent(evt);
215
+ }
602
216
  },
603
217
  // TODO: this is Android only; think about how to do this better
604
218
  shuttingDown:false,
@@ -682,8 +296,9 @@ var cordova = {
682
296
  }
683
297
  }
684
298
  },
685
-
299
+ // TODO: remove in 2.0.
686
300
  addPlugin: function(name, obj) {
301
+ console.log("[DEPRECATION NOTICE] window.addPlugin and window.plugins will be removed in version 2.0.");
687
302
  if (!window.plugins[name]) {
688
303
  window.plugins[name] = obj;
689
304
  }
@@ -691,7 +306,7 @@ var cordova = {
691
306
  console.log("Error: Plugin "+name+" already exists.");
692
307
  }
693
308
  },
694
-
309
+
695
310
  addConstructor: function(func) {
696
311
  channel.onCordovaReady.subscribeOnce(function() {
697
312
  try {
@@ -703,15 +318,46 @@ var cordova = {
703
318
  }
704
319
  };
705
320
 
706
- /**
321
+ // Adds deprecation warnings to functions of an object (but only logs a message once)
322
+ function deprecateFunctions(obj, objLabel) {
323
+ var newObj = {};
324
+ var logHash = {};
325
+ for (var i in obj) {
326
+ if (obj.hasOwnProperty(i)) {
327
+ if (typeof obj[i] == 'function') {
328
+ newObj[i] = (function(prop){
329
+ var oldFunk = obj[prop];
330
+ var funkId = objLabel + '_' + prop;
331
+ return function() {
332
+ if (!logHash[funkId]) {
333
+ console.log('[DEPRECATION NOTICE] The "' + objLabel + '" global will be removed in version 2.0, please use lowercase "cordova".');
334
+ logHash[funkId] = true;
335
+ }
336
+ oldFunk.apply(obj, arguments);
337
+ };
338
+ })(i);
339
+ } else {
340
+ newObj[i] = (function(prop) { return obj[prop]; })(i);
341
+ }
342
+ }
343
+ }
344
+ return newObj;
345
+ }
346
+
347
+ /**
707
348
  * Legacy variable for plugin support
349
+ * TODO: remove in 2.0.
708
350
  */
709
351
  if (!window.PhoneGap) {
710
- window.PhoneGap = cordova;
352
+ window.PhoneGap = deprecateFunctions(cordova, 'PhoneGap');
353
+ }
354
+ if (!window.Cordova) {
355
+ window.Cordova = deprecateFunctions(cordova, 'Cordova');
711
356
  }
712
357
 
713
358
  /**
714
359
  * Plugins object
360
+ * TODO: remove in 2.0.
715
361
  */
716
362
  if (!window.plugins) {
717
363
  window.plugins = {};
@@ -720,92 +366,351 @@ if (!window.plugins) {
720
366
  module.exports = cordova;
721
367
 
722
368
  });
723
- define('cordova/exec', function(require, exports, module) {
724
- /**
725
- * Execute a cordova command. It is up to the native side whether this action
726
- * is synchronous or asynchronous. The native side can return:
727
- * Synchronous: PluginResult object as a JSON string
728
- * Asynchrounous: Empty string ""
729
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
730
- * depending upon the result of the action.
731
- *
732
- * @param {Function} success The success callback
733
- * @param {Function} fail The fail callback
734
- * @param {String} service The name of the service to use
735
- * @param {String} action Action to be run in cordova
736
- * @param {String[]} [args] Zero or more arguments to pass to the method
737
- */
738
- var cordova = require('cordova');
739
-
740
- module.exports = function(success, fail, service, action, args) {
741
- try {
742
- var callbackId = service + cordova.callbackId++;
743
- if (success || fail) {
744
- cordova.callbacks[callbackId] = {success:success, fail:fail};
745
- }
746
-
747
- var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
748
369
 
749
- // If a result was returned
750
- if (r.length > 0) {
751
- eval("var v="+r+";");
370
+ // file: lib/common/builder.js
371
+ define("cordova/builder", function(require, exports, module) {
372
+ var utils = require('cordova/utils');
752
373
 
753
- // If status is OK, then return value back to caller
754
- if (v.status === cordova.callbackStatus.OK) {
374
+ function each(objects, func, context) {
375
+ for (var prop in objects) {
376
+ if (objects.hasOwnProperty(prop)) {
377
+ func.apply(context, [objects[prop], prop]);
378
+ }
379
+ }
380
+ }
755
381
 
756
- // If there is a success callback, then call it now with
757
- // returned value
758
- if (success) {
759
- try {
760
- success(v.message);
761
- } catch (e) {
762
- console.log("Error in success callback: " + callbackId + " = " + e);
763
- }
382
+ function include(parent, objects, clobber, merge) {
383
+ each(objects, function (obj, key) {
384
+ try {
385
+ var result = obj.path ? require(obj.path) : {};
764
386
 
765
- // Clear callback if not expecting any more results
766
- if (!v.keepCallback) {
767
- delete cordova.callbacks[callbackId];
768
- }
387
+ if (clobber) {
388
+ // Clobber if it doesn't exist.
389
+ if (typeof parent[key] === 'undefined') {
390
+ parent[key] = result;
391
+ } else if (typeof obj.path !== 'undefined') {
392
+ // If merging, merge properties onto parent, otherwise, clobber.
393
+ if (merge) {
394
+ recursiveMerge(parent[key], result);
395
+ } else {
396
+ parent[key] = result;
397
+ }
398
+ }
399
+ result = parent[key];
400
+ } else {
401
+ // Overwrite if not currently defined.
402
+ if (typeof parent[key] == 'undefined') {
403
+ parent[key] = result;
404
+ } else if (merge && typeof obj.path !== 'undefined') {
405
+ // If merging, merge parent onto result
406
+ recursiveMerge(result, parent[key]);
407
+ parent[key] = result;
408
+ } else {
409
+ // Set result to what already exists, so we can build children into it if they exist.
410
+ result = parent[key];
769
411
  }
770
- return v.message;
412
+ }
413
+
414
+ if (obj.children) {
415
+ include(result, obj.children, clobber, merge);
416
+ }
417
+ } catch(e) {
418
+ utils.alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
771
419
  }
420
+ });
421
+ }
772
422
 
773
- // If no result
774
- else if (v.status === cordova.callbackStatus.NO_RESULT) {
775
- // Clear callback if not expecting any more results
776
- if (!v.keepCallback) {
777
- delete cordova.callbacks[callbackId];
423
+ /**
424
+ * Merge properties from one object onto another recursively. Properties from
425
+ * the src object will overwrite existing target property.
426
+ *
427
+ * @param target Object to merge properties into.
428
+ * @param src Object to merge properties from.
429
+ */
430
+ function recursiveMerge(target, src) {
431
+ for (var prop in src) {
432
+ if (src.hasOwnProperty(prop)) {
433
+ if (typeof target.prototype !== 'undefined' && target.prototype.constructor === target) {
434
+ // If the target object is a constructor override off prototype.
435
+ target.prototype[prop] = src[prop];
436
+ } else {
437
+ target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
438
+ target[prop], src[prop]) : src[prop];
778
439
  }
779
440
  }
441
+ }
442
+ return target;
443
+ }
780
444
 
781
- // If error, then display error
782
- else {
783
- console.log("Error: Status="+v.status+" Message="+v.message);
445
+ module.exports = {
446
+ build: function (objects) {
447
+ return {
448
+ intoButDontClobber: function (target) {
449
+ include(target, objects, false, false);
450
+ },
451
+ intoAndClobber: function(target) {
452
+ include(target, objects, true, false);
453
+ },
454
+ intoAndMerge: function(target) {
455
+ include(target, objects, true, true);
456
+ }
457
+ };
458
+ }
459
+ };
784
460
 
785
- // If there is a fail callback, then call it now with returned value
786
- if (fail) {
787
- try {
788
- fail(v.message);
461
+ });
462
+
463
+ // file: lib/common/channel.js
464
+ define("cordova/channel", function(require, exports, module) {
465
+ var utils = require('cordova/utils');
466
+
467
+ /**
468
+ * Custom pub-sub "channel" that can have functions subscribed to it
469
+ * This object is used to define and control firing of events for
470
+ * cordova initialization.
471
+ *
472
+ * The order of events during page load and Cordova startup is as follows:
473
+ *
474
+ * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
475
+ * onNativeReady Internal event that indicates the Cordova native side is ready.
476
+ * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created.
477
+ * onCordovaInfoReady Internal event fired when device properties are available.
478
+ * onCordovaConnectionReady Internal event fired when the connection property has been set.
479
+ * onDeviceReady User event fired to indicate that Cordova is ready
480
+ * onResume User event fired to indicate a start/resume lifecycle event
481
+ * onPause User event fired to indicate a pause lifecycle event
482
+ * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
483
+ *
484
+ * The only Cordova events that user code should register for are:
485
+ * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
486
+ * pause App has moved to background
487
+ * resume App has returned to foreground
488
+ *
489
+ * Listeners can be registered as:
490
+ * document.addEventListener("deviceready", myDeviceReadyListener, false);
491
+ * document.addEventListener("resume", myResumeListener, false);
492
+ * document.addEventListener("pause", myPauseListener, false);
493
+ *
494
+ * The DOM lifecycle events should be used for saving and restoring state
495
+ * window.onload
496
+ * window.onunload
497
+ *
498
+ */
499
+
500
+ /**
501
+ * Channel
502
+ * @constructor
503
+ * @param type String the channel name
504
+ * @param opts Object options to pass into the channel, currently
505
+ * supports:
506
+ * onSubscribe: callback that fires when
507
+ * something subscribes to the Channel. Sets
508
+ * context to the Channel.
509
+ * onUnsubscribe: callback that fires when
510
+ * something unsubscribes to the Channel. Sets
511
+ * context to the Channel.
512
+ */
513
+ var Channel = function(type, opts) {
514
+ this.type = type;
515
+ this.handlers = {};
516
+ this.numHandlers = 0;
517
+ this.guid = 0;
518
+ this.fired = false;
519
+ this.enabled = true;
520
+ this.events = {
521
+ onSubscribe:null,
522
+ onUnsubscribe:null
523
+ };
524
+ if (opts) {
525
+ if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
526
+ if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
527
+ }
528
+ },
529
+ channel = {
530
+ /**
531
+ * Calls the provided function only after all of the channels specified
532
+ * have been fired.
533
+ */
534
+ join: function (h, c) {
535
+ var i = c.length;
536
+ var len = i;
537
+ var f = function() {
538
+ if (!(--i)) h();
539
+ };
540
+ for (var j=0; j<len; j++) {
541
+ !c[j].fired?c[j].subscribeOnce(f):i--;
542
+ }
543
+ if (!i) h();
544
+ },
545
+ create: function (type, opts) {
546
+ channel[type] = new Channel(type, opts);
547
+ return channel[type];
548
+ },
549
+
550
+ /**
551
+ * cordova Channels that must fire before "deviceready" is fired.
552
+ */
553
+ deviceReadyChannelsArray: [],
554
+ deviceReadyChannelsMap: {},
555
+
556
+ /**
557
+ * Indicate that a feature needs to be initialized before it is ready to be used.
558
+ * This holds up Cordova's "deviceready" event until the feature has been initialized
559
+ * and Cordova.initComplete(feature) is called.
560
+ *
561
+ * @param feature {String} The unique feature name
562
+ */
563
+ waitForInitialization: function(feature) {
564
+ if (feature) {
565
+ var c = null;
566
+ if (this[feature]) {
567
+ c = this[feature];
789
568
  }
790
- catch (e1) {
791
- console.log("Error in error callback: "+callbackId+" = "+e1);
569
+ else {
570
+ c = this.create(feature);
792
571
  }
572
+ this.deviceReadyChannelsMap[feature] = c;
573
+ this.deviceReadyChannelsArray.push(c);
574
+ }
575
+ },
793
576
 
794
- // Clear callback if not expecting any more results
795
- if (!v.keepCallback) {
796
- delete cordova.callbacks[callbackId];
797
- }
577
+ /**
578
+ * Indicate that initialization code has completed and the feature is ready to be used.
579
+ *
580
+ * @param feature {String} The unique feature name
581
+ */
582
+ initializationComplete: function(feature) {
583
+ var c = this.deviceReadyChannelsMap[feature];
584
+ if (c) {
585
+ c.fire();
798
586
  }
799
- return null;
800
587
  }
588
+ };
589
+
590
+ function forceFunction(f) {
591
+ if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
592
+ }
593
+
594
+ /**
595
+ * Subscribes the given function to the channel. Any time that
596
+ * Channel.fire is called so too will the function.
597
+ * Optionally specify an execution context for the function
598
+ * and a guid that can be used to stop subscribing to the channel.
599
+ * Returns the guid.
600
+ */
601
+ Channel.prototype.subscribe = function(f, c, g) {
602
+ // need a function to call
603
+ forceFunction(f);
604
+
605
+ var func = f;
606
+ if (typeof c == "object") { func = utils.close(c, f); }
607
+
608
+ g = g || func.observer_guid || f.observer_guid || this.guid++;
609
+ func.observer_guid = g;
610
+ f.observer_guid = g;
611
+ this.handlers[g] = func;
612
+ this.numHandlers++;
613
+ if (this.events.onSubscribe) this.events.onSubscribe.call(this);
614
+ return g;
615
+ };
616
+
617
+ /**
618
+ * Like subscribe but the function is only called once and then it
619
+ * auto-unsubscribes itself.
620
+ */
621
+ Channel.prototype.subscribeOnce = function(f, c) {
622
+ // need a function to call
623
+ forceFunction(f);
624
+
625
+ var g = null;
626
+ var _this = this;
627
+ var m = function() {
628
+ f.apply(c || null, arguments);
629
+ _this.unsubscribe(g);
630
+ };
631
+ if (this.fired) {
632
+ if (typeof c == "object") { f = utils.close(c, f); }
633
+ f.apply(this, this.fireArgs);
634
+ } else {
635
+ g = this.subscribe(m);
801
636
  }
802
- } catch (e2) {
803
- console.log("Error: "+e2);
804
- }
637
+ return g;
638
+ };
639
+
640
+ /**
641
+ * Unsubscribes the function with the given guid from the channel.
642
+ */
643
+ Channel.prototype.unsubscribe = function(g) {
644
+ // need a function to unsubscribe
645
+ if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
646
+
647
+ if (typeof g == 'function') { g = g.observer_guid; }
648
+ this.handlers[g] = null;
649
+ delete this.handlers[g];
650
+ this.numHandlers--;
651
+ if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
652
+ };
653
+
654
+ /**
655
+ * Calls all functions subscribed to this channel.
656
+ */
657
+ Channel.prototype.fire = function(e) {
658
+ if (this.enabled) {
659
+ var fail = false;
660
+ this.fired = true;
661
+ for (var item in this.handlers) {
662
+ var handler = this.handlers[item];
663
+ if (typeof handler == 'function') {
664
+ var rv = (handler.apply(this, arguments)===false);
665
+ fail = fail || rv;
666
+ }
667
+ }
668
+ this.fireArgs = arguments;
669
+ return !fail;
670
+ }
671
+ return true;
805
672
  };
806
673
 
674
+ // defining them here so they are ready super fast!
675
+ // DOM event that is received when the web page is loaded and parsed.
676
+ channel.create('onDOMContentLoaded');
677
+
678
+ // Event to indicate the Cordova native side is ready.
679
+ channel.create('onNativeReady');
680
+
681
+ // Event to indicate that all Cordova JavaScript objects have been created
682
+ // and it's time to run plugin constructors.
683
+ channel.create('onCordovaReady');
684
+
685
+ // Event to indicate that device properties are available
686
+ channel.create('onCordovaInfoReady');
687
+
688
+ // Event to indicate that the connection property has been set.
689
+ channel.create('onCordovaConnectionReady');
690
+
691
+ // Event to indicate that Cordova is ready
692
+ channel.create('onDeviceReady');
693
+
694
+ // Event to indicate a resume lifecycle event
695
+ channel.create('onResume');
696
+
697
+ // Event to indicate a pause lifecycle event
698
+ channel.create('onPause');
699
+
700
+ // Event to indicate a destroy lifecycle event
701
+ channel.create('onDestroy');
702
+
703
+ // Channels that must fire before "deviceready" is fired.
704
+ channel.waitForInitialization('onCordovaReady');
705
+ channel.waitForInitialization('onCordovaInfoReady');
706
+ channel.waitForInitialization('onCordovaConnectionReady');
707
+
708
+ module.exports = channel;
709
+
807
710
  });
808
- define('cordova/common', function(require, exports, module) {
711
+
712
+ // file: lib/common/common.js
713
+ define("cordova/common", function(require, exports, module) {
809
714
  module.exports = {
810
715
  objects: {
811
716
  cordova: {
@@ -986,548 +891,310 @@ module.exports = {
986
891
  }
987
892
  }
988
893
  };
989
-
990
894
  });
991
- define('cordova/platform', function(require, exports, module) {
992
- module.exports = {
993
- id: "android",
994
- initialize:function() {
995
- var channel = require("cordova/channel"),
996
- cordova = require('cordova'),
997
- callback = require('cordova/plugin/android/callback'),
998
- polling = require('cordova/plugin/android/polling'),
999
- exec = require('cordova/exec');
1000
895
 
1001
- channel.onDestroy.subscribe(function() {
1002
- cordova.shuttingDown = true;
1003
- });
1004
-
1005
- // Start listening for XHR callbacks
1006
- // Figure out which bridge approach will work on this Android
1007
- // device: polling or XHR-based callbacks
1008
- setTimeout(function() {
1009
- if (cordova.UsePolling) {
1010
- polling();
1011
- }
1012
- else {
1013
- var isPolling = prompt("usePolling", "gap_callbackServer:");
1014
- cordova.UsePolling = isPolling;
1015
- if (isPolling == "true") {
1016
- cordova.UsePolling = true;
1017
- polling();
1018
- } else {
1019
- cordova.UsePolling = false;
1020
- callback();
1021
- }
1022
- }
1023
- }, 1);
1024
-
1025
- // Inject a listener for the backbutton on the document.
1026
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
1027
- onSubscribe:function() {
1028
- // If we just attached the first handler, let native know we need to override the back button.
1029
- if (this.numHandlers === 1) {
1030
- exec(null, null, "App", "overrideBackbutton", [true]);
1031
- }
1032
- },
1033
- onUnsubscribe:function() {
1034
- // If we just detached the last handler, let native know we no longer override the back button.
1035
- if (this.numHandlers === 0) {
1036
- exec(null, null, "App", "overrideBackbutton", [false]);
1037
- }
1038
- }
1039
- });
896
+ // file: lib/android/exec.js
897
+ define("cordova/exec", function(require, exports, module) {
898
+ /**
899
+ * Execute a cordova command. It is up to the native side whether this action
900
+ * is synchronous or asynchronous. The native side can return:
901
+ * Synchronous: PluginResult object as a JSON string
902
+ * Asynchrounous: Empty string ""
903
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
904
+ * depending upon the result of the action.
905
+ *
906
+ * @param {Function} success The success callback
907
+ * @param {Function} fail The fail callback
908
+ * @param {String} service The name of the service to use
909
+ * @param {String} action Action to be run in cordova
910
+ * @param {String[]} [args] Zero or more arguments to pass to the method
911
+ */
912
+ var cordova = require('cordova');
1040
913
 
1041
- // Add hardware MENU and SEARCH button handlers
1042
- cordova.addDocumentEventHandler('menubutton');
1043
- cordova.addDocumentEventHandler('searchbutton');
914
+ module.exports = function(success, fail, service, action, args) {
915
+ try {
916
+ var callbackId = service + cordova.callbackId++;
917
+ if (success || fail) {
918
+ cordova.callbacks[callbackId] = {success:success, fail:fail};
919
+ }
1044
920
 
1045
- // Let native code know we are all done on the JS side.
1046
- // Native code will then un-hide the WebView.
1047
- channel.join(function() {
1048
- prompt("", "gap_init:");
1049
- }, [channel.onCordovaReady]);
921
+ var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
1050
922
 
1051
- // Figure out if we need to shim-in localStorage and WebSQL
1052
- // support from the native side.
1053
- var storage = require('cordova/plugin/android/storage');
923
+ // If a result was returned
924
+ if (r.length > 0) {
925
+ var v;
926
+ eval("v="+r+";");
1054
927
 
1055
- // First patch WebSQL if necessary
1056
- if (typeof window.openDatabase == 'undefined') {
1057
- // Not defined, create an openDatabase function for all to use!
1058
- window.openDatabase = storage.openDatabase;
1059
- } else {
1060
- // Defined, but some Android devices will throw a SECURITY_ERR -
1061
- // so we wrap the whole thing in a try-catch and shim in our own
1062
- // if the device has Android bug 16175.
1063
- var originalOpenDatabase = window.openDatabase;
1064
- window.openDatabase = function(name, version, desc, size) {
1065
- var db = null;
1066
- try {
1067
- db = originalOpenDatabase(name, version, desc, size);
1068
- }
1069
- catch (ex) {
1070
- db = null;
1071
- }
928
+ // If status is OK, then return value back to caller
929
+ if (v.status === cordova.callbackStatus.OK) {
1072
930
 
1073
- if (db === null) {
1074
- return storage.openDatabase(name, version, desc, size);
1075
- }
1076
- else {
1077
- return db;
1078
- }
1079
-
1080
- };
1081
- }
931
+ // If there is a success callback, then call it now with
932
+ // returned value
933
+ if (success) {
934
+ try {
935
+ success(v.message);
936
+ } catch (e) {
937
+ console.log("Error in success callback: " + callbackId + " = " + e);
938
+ }
1082
939
 
1083
- // Patch localStorage if necessary
1084
- if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
1085
- window.localStorage = new storage.CupCakeLocalStorage();
1086
- }
1087
- },
1088
- objects: {
1089
- cordova: {
1090
- children: {
1091
- JSCallback:{
1092
- path:"cordova/plugin/android/callback"
1093
- },
1094
- JSCallbackPolling:{
1095
- path:"cordova/plugin/android/polling"
1096
- }
1097
- }
1098
- },
1099
- navigator: {
1100
- children: {
1101
- app:{
1102
- path: "cordova/plugin/android/app"
940
+ // Clear callback if not expecting any more results
941
+ if (!v.keepCallback) {
942
+ delete cordova.callbacks[callbackId];
943
+ }
944
+ }
945
+ return v.message;
1103
946
  }
1104
- }
1105
- },
1106
- device:{
1107
- path: "cordova/plugin/android/device"
1108
- },
1109
- File: { // exists natively on Android WebView, override
1110
- path: "cordova/plugin/File"
1111
- },
1112
- FileReader: { // exists natively on Android WebView, override
1113
- path: "cordova/plugin/FileReader"
1114
- },
1115
- FileError: { //exists natively on Android WebView on Android 4.x
1116
- path: "cordova/plugin/FileError"
1117
- }
1118
- }
1119
- };
1120
947
 
1121
- });
1122
- define('cordova/utils', function(require, exports, module) {
1123
- function UUIDcreatePart(length) {
1124
- var uuidpart = "";
1125
- for (var i=0; i<length; i++) {
1126
- var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
1127
- if (uuidchar.length == 1) {
1128
- uuidchar = "0" + uuidchar;
1129
- }
1130
- uuidpart += uuidchar;
1131
- }
1132
- return uuidpart;
1133
- }
1134
-
1135
- var _self = {
1136
- /**
1137
- * Does a deep clone of the object.
1138
- */
1139
- clone: function(obj) {
1140
- if(!obj) {
1141
- return obj;
1142
- }
1143
-
1144
- var retVal, i;
1145
-
1146
- if(obj instanceof Array){
1147
- retVal = [];
1148
- for(i = 0; i < obj.length; ++i){
1149
- retVal.push(_self.clone(obj[i]));
948
+ // If no result
949
+ else if (v.status === cordova.callbackStatus.NO_RESULT) {
950
+ // Clear callback if not expecting any more results
951
+ if (!v.keepCallback) {
952
+ delete cordova.callbacks[callbackId];
1150
953
  }
1151
- return retVal;
1152
- }
1153
-
1154
- if (obj instanceof Function) {
1155
- return obj;
1156
- }
1157
-
1158
- if(!(obj instanceof Object)){
1159
- return obj;
1160
- }
1161
-
1162
- if(obj instanceof Date){
1163
- return obj;
1164
954
  }
1165
955
 
1166
- retVal = {};
1167
- for(i in obj){
1168
- if(!(i in retVal) || retVal[i] != obj[i]) {
1169
- retVal[i] = _self.clone(obj[i]);
956
+ // If error, then display error
957
+ else {
958
+ console.log("Error: Status="+v.status+" Message="+v.message);
959
+
960
+ // If there is a fail callback, then call it now with returned value
961
+ if (fail) {
962
+ try {
963
+ fail(v.message);
964
+ }
965
+ catch (e1) {
966
+ console.log("Error in error callback: "+callbackId+" = "+e1);
967
+ }
968
+
969
+ // Clear callback if not expecting any more results
970
+ if (!v.keepCallback) {
971
+ delete cordova.callbacks[callbackId];
972
+ }
1170
973
  }
974
+ return null;
1171
975
  }
1172
- return retVal;
1173
- },
976
+ }
977
+ } catch (e2) {
978
+ console.log("Error: "+e2);
979
+ }
980
+ };
1174
981
 
1175
- close: function(context, func, params) {
1176
- if (typeof params === 'undefined') {
1177
- return function() {
1178
- return func.apply(context, arguments);
1179
- };
1180
- } else {
1181
- return function() {
1182
- return func.apply(context, params);
1183
- };
1184
- }
1185
- },
982
+ });
1186
983
 
1187
- /**
1188
- * Create a UUID
1189
- */
1190
- createUUID: function() {
1191
- return UUIDcreatePart(4) + '-' +
1192
- UUIDcreatePart(2) + '-' +
1193
- UUIDcreatePart(2) + '-' +
1194
- UUIDcreatePart(2) + '-' +
1195
- UUIDcreatePart(6);
1196
- },
984
+ // file: lib/android/platform.js
985
+ define("cordova/platform", function(require, exports, module) {
986
+ module.exports = {
987
+ id: "android",
988
+ initialize:function() {
989
+ var channel = require("cordova/channel"),
990
+ cordova = require('cordova'),
991
+ callback = require('cordova/plugin/android/callback'),
992
+ polling = require('cordova/plugin/android/polling'),
993
+ exec = require('cordova/exec');
994
+
995
+ channel.onDestroy.subscribe(function() {
996
+ cordova.shuttingDown = true;
997
+ });
1197
998
 
1198
- /**
1199
- * Extends a child object from a parent object using classical inheritance
1200
- * pattern.
1201
- */
1202
- extend: (function() {
1203
- // proxy used to establish prototype chain
1204
- var F = function() {};
1205
- // extend Child from Parent
1206
- return function(Child, Parent) {
1207
- F.prototype = Parent.prototype;
1208
- Child.prototype = new F();
1209
- Child.__super__ = Parent.prototype;
1210
- Child.prototype.constructor = Child;
1211
- };
1212
- }())
999
+ // Start listening for XHR callbacks
1000
+ // Figure out which bridge approach will work on this Android
1001
+ // device: polling or XHR-based callbacks
1002
+ setTimeout(function() {
1003
+ if (cordova.UsePolling) {
1004
+ polling();
1005
+ }
1006
+ else {
1007
+ var isPolling = prompt("usePolling", "gap_callbackServer:");
1008
+ cordova.UsePolling = isPolling;
1009
+ if (isPolling == "true") {
1010
+ cordova.UsePolling = true;
1011
+ polling();
1012
+ } else {
1013
+ cordova.UsePolling = false;
1014
+ callback();
1015
+ }
1016
+ }
1017
+ }, 1);
1018
+
1019
+ // Inject a listener for the backbutton on the document.
1020
+ var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
1021
+ onSubscribe:function() {
1022
+ // If we just attached the first handler, let native know we need to override the back button.
1023
+ if (this.numHandlers === 1) {
1024
+ exec(null, null, "App", "overrideBackbutton", [true]);
1025
+ }
1026
+ },
1027
+ onUnsubscribe:function() {
1028
+ // If we just detached the last handler, let native know we no longer override the back button.
1029
+ if (this.numHandlers === 0) {
1030
+ exec(null, null, "App", "overrideBackbutton", [false]);
1031
+ }
1032
+ }
1033
+ });
1213
1034
 
1214
- };
1035
+ // Add hardware MENU and SEARCH button handlers
1036
+ cordova.addDocumentEventHandler('menubutton');
1037
+ cordova.addDocumentEventHandler('searchbutton');
1215
1038
 
1216
- module.exports = _self;
1039
+ // Figure out if we need to shim-in localStorage and WebSQL
1040
+ // support from the native side.
1041
+ var storage = require('cordova/plugin/android/storage');
1217
1042
 
1218
- });
1043
+ // First patch WebSQL if necessary
1044
+ if (typeof window.openDatabase == 'undefined') {
1045
+ // Not defined, create an openDatabase function for all to use!
1046
+ window.openDatabase = storage.openDatabase;
1047
+ } else {
1048
+ // Defined, but some Android devices will throw a SECURITY_ERR -
1049
+ // so we wrap the whole thing in a try-catch and shim in our own
1050
+ // if the device has Android bug 16175.
1051
+ var originalOpenDatabase = window.openDatabase;
1052
+ window.openDatabase = function(name, version, desc, size) {
1053
+ var db = null;
1054
+ try {
1055
+ db = originalOpenDatabase(name, version, desc, size);
1056
+ }
1057
+ catch (ex) {
1058
+ if (ex.code === 18) {
1059
+ db = null;
1060
+ } else {
1061
+ throw ex;
1062
+ }
1063
+ }
1219
1064
 
1220
- define('cordova/builder', function(require, exports, module) {
1221
- function each(objects, func, context) {
1222
- for (var prop in objects) {
1223
- if (objects.hasOwnProperty(prop)) {
1224
- func.apply(context, [objects[prop], prop]);
1065
+ if (db === null) {
1066
+ return storage.openDatabase(name, version, desc, size);
1067
+ }
1068
+ else {
1069
+ return db;
1070
+ }
1071
+
1072
+ };
1225
1073
  }
1226
- }
1227
- }
1228
1074
 
1229
- function include(parent, objects, clobber) {
1230
- each(objects, function (obj, key) {
1231
- try {
1232
- var result = obj.path ? require(obj.path) : {};
1075
+ // Patch localStorage if necessary
1076
+ if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
1077
+ window.localStorage = new storage.CupCakeLocalStorage();
1078
+ }
1233
1079
 
1234
- if (clobber) {
1235
- // Clobber if it doesn't exist or if an override is specified.
1236
- if (typeof parent[key] === 'undefined' || typeof obj.path !== 'undefined') {
1237
- parent[key] = result;
1238
- }
1239
- result = parent[key];
1240
- } else {
1241
- // Don't clobber if something already exists there
1242
- if (typeof parent[key] == 'undefined') {
1243
- parent[key] = result;
1244
- } else {
1245
- // Set result to what already exists, so we can build children into it if they exist.
1246
- result = parent[key];
1080
+ // Let native code know we are all done on the JS side.
1081
+ // Native code will then un-hide the WebView.
1082
+ channel.join(function() {
1083
+ prompt("", "gap_init:");
1084
+ }, [channel.onCordovaReady]);
1085
+ },
1086
+ objects: {
1087
+ cordova: {
1088
+ children: {
1089
+ JSCallback:{
1090
+ path:"cordova/plugin/android/callback"
1091
+ },
1092
+ JSCallbackPolling:{
1093
+ path:"cordova/plugin/android/polling"
1094
+ }
1247
1095
  }
1248
- }
1249
-
1250
- if (obj.children) {
1251
- include(result, obj.children, clobber);
1252
- }
1253
- } catch(e) {
1254
- alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
1096
+ },
1097
+ navigator: {
1098
+ children: {
1099
+ app:{
1100
+ path: "cordova/plugin/android/app"
1101
+ }
1102
+ }
1103
+ },
1104
+ device:{
1105
+ path: "cordova/plugin/android/device"
1106
+ },
1107
+ File: { // exists natively on Android WebView, override
1108
+ path: "cordova/plugin/File"
1109
+ },
1110
+ FileReader: { // exists natively on Android WebView, override
1111
+ path: "cordova/plugin/FileReader"
1112
+ },
1113
+ FileError: { //exists natively on Android WebView on Android 4.x
1114
+ path: "cordova/plugin/FileError"
1115
+ },
1116
+ MediaError: { // exists natively on Android WebView on Android 4.x
1117
+ path: "cordova/plugin/MediaError"
1255
1118
  }
1256
- });
1257
- }
1258
-
1259
- module.exports = {
1260
- build: function (objects) {
1261
- return {
1262
- intoButDontClobber: function (target) {
1263
- include(target, objects, false);
1264
- },
1265
- intoAndClobberTheFOutOf: function(target) {
1266
- include(target, objects, true);
1119
+ },
1120
+ merges: {
1121
+ navigator: {
1122
+ children: {
1123
+ notification: {
1124
+ path: 'cordova/plugin/android/notification'
1125
+ }
1267
1126
  }
1268
- };
1127
+ }
1269
1128
  }
1270
1129
  };
1271
-
1272
1130
  });
1273
1131
 
1274
- define('cordova/plugin/Acceleration', function(require, exports, module) {
1275
- var Acceleration = function(x, y, z) {
1132
+ // file: lib/common/plugin/Acceleration.js
1133
+ define("cordova/plugin/Acceleration", function(require, exports, module) {
1134
+ var Acceleration = function(x, y, z, timestamp) {
1276
1135
  this.x = x;
1277
1136
  this.y = y;
1278
1137
  this.z = z;
1279
- this.timestamp = new Date().getTime();
1138
+ this.timestamp = timestamp || (new Date()).getTime();
1280
1139
  };
1281
1140
 
1282
1141
  module.exports = Acceleration;
1283
-
1284
1142
  });
1285
1143
 
1286
- define('cordova/plugin/accelerometer', function(require, exports, module) {
1144
+ // file: lib/common/plugin/Camera.js
1145
+ define("cordova/plugin/Camera", function(require, exports, module) {
1146
+ var exec = require('cordova/exec'),
1147
+ Camera = require('cordova/plugin/CameraConstants');
1148
+
1149
+ var cameraExport = {};
1150
+
1151
+ // Tack on the Camera Constants to the base camera plugin.
1152
+ for (var key in Camera) {
1153
+ cameraExport[key] = Camera[key];
1154
+ }
1155
+
1287
1156
  /**
1288
- * This class provides access to device accelerometer data.
1289
- * @constructor
1290
- */
1291
- var utils = require("cordova/utils"),
1292
- exec = require("cordova/exec");
1157
+ * Gets a picture from source defined by "options.sourceType", and returns the
1158
+ * image as defined by the "options.destinationType" option.
1293
1159
 
1294
- // Local singleton variables.
1295
- var timers = {};
1160
+ * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
1161
+ *
1162
+ * @param {Function} successCallback
1163
+ * @param {Function} errorCallback
1164
+ * @param {Object} options
1165
+ */
1166
+ cameraExport.getPicture = function(successCallback, errorCallback, options) {
1167
+ // successCallback required
1168
+ if (typeof successCallback != "function") {
1169
+ console.log("Camera Error: successCallback is not a function");
1170
+ return;
1171
+ }
1296
1172
 
1297
- var accelerometer = {
1298
- /**
1299
- * Asynchronously aquires the current acceleration.
1300
- *
1301
- * @param {Function} successCallback The function to call when the acceleration data is available
1302
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
1303
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
1304
- */
1305
- getCurrentAcceleration: function(successCallback, errorCallback, options) {
1173
+ // errorCallback optional
1174
+ if (errorCallback && (typeof errorCallback != "function")) {
1175
+ console.log("Camera Error: errorCallback is not a function");
1176
+ return;
1177
+ }
1306
1178
 
1307
- // successCallback required
1308
- if (typeof successCallback !== "function") {
1309
- console.log("Accelerometer Error: successCallback is not a function");
1310
- return;
1179
+ var quality = 50;
1180
+ if (options && typeof options.quality == "number") {
1181
+ quality = options.quality;
1182
+ } else if (options && typeof options.quality == "string") {
1183
+ var qlity = parseInt(options.quality, 10);
1184
+ if (isNaN(qlity) === false) {
1185
+ quality = qlity.valueOf();
1311
1186
  }
1187
+ }
1312
1188
 
1313
- // errorCallback optional
1314
- if (errorCallback && (typeof errorCallback !== "function")) {
1315
- console.log("Accelerometer Error: errorCallback is not a function");
1316
- return;
1317
- }
1189
+ var destinationType = Camera.DestinationType.FILE_URI;
1190
+ if (typeof options.destinationType == "number") {
1191
+ destinationType = options.destinationType;
1192
+ }
1318
1193
 
1319
- // Get acceleration
1320
- exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
1321
- },
1322
-
1323
- /**
1324
- * Asynchronously aquires the acceleration repeatedly at a given interval.
1325
- *
1326
- * @param {Function} successCallback The function to call each time the acceleration data is available
1327
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
1328
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
1329
- * @return String The watch id that must be passed to #clearWatch to stop watching.
1330
- */
1331
- watchAcceleration: function(successCallback, errorCallback, options) {
1332
-
1333
- // Default interval (10 sec)
1334
- var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000;
1335
-
1336
- // successCallback required
1337
- if (typeof successCallback !== "function") {
1338
- console.log("Accelerometer Error: successCallback is not a function");
1339
- return;
1340
- }
1341
-
1342
- // errorCallback optional
1343
- if (errorCallback && (typeof errorCallback !== "function")) {
1344
- console.log("Accelerometer Error: errorCallback is not a function");
1345
- return;
1346
- }
1347
-
1348
- // Make sure accelerometer timeout > frequency + 10 sec
1349
- exec(
1350
- function(timeout) {
1351
- if (timeout < (frequency + 10000)) {
1352
- exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
1353
- }
1354
- },
1355
- function(e) { }, "Accelerometer", "getTimeout", []);
1356
-
1357
- // Start watch timer
1358
- var id = utils.createUUID();
1359
- timers[id] = window.setInterval(function() {
1360
- exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
1361
- }, (frequency ? frequency : 1));
1362
-
1363
- return id;
1364
- },
1365
-
1366
- /**
1367
- * Clears the specified accelerometer watch.
1368
- *
1369
- * @param {String} id The id of the watch returned from #watchAcceleration.
1370
- */
1371
- clearWatch: function(id) {
1372
-
1373
- // Stop javascript timer & remove from timer list
1374
- if (id && timers[id] !== undefined) {
1375
- window.clearInterval(timers[id]);
1376
- delete timers[id];
1377
- }
1378
- }
1379
- };
1380
-
1381
- module.exports = accelerometer;
1382
-
1383
- });
1384
-
1385
-
1386
- define('cordova/plugin/battery', function(require, exports, module) {
1387
- /**
1388
- * This class contains information about the current battery status.
1389
- * @constructor
1390
- */
1391
- var cordova = require('cordova'),
1392
- exec = require('cordova/exec');
1393
-
1394
- function handlers() {
1395
- return battery.channels.batterystatus.numHandlers +
1396
- battery.channels.batterylow.numHandlers +
1397
- battery.channels.batterycritical.numHandlers;
1398
- }
1399
-
1400
- var Battery = function() {
1401
- this._level = null;
1402
- this._isPlugged = null;
1403
- // Create new event handlers on the window (returns a channel instance)
1404
- var subscriptionEvents = {
1405
- onSubscribe:this.onSubscribe,
1406
- onUnsubscribe:this.onUnsubscribe
1407
- };
1408
- this.channels = {
1409
- batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
1410
- batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
1411
- batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
1412
- };
1413
- };
1414
- /**
1415
- * Event handlers for when callbacks get registered for the battery.
1416
- * Keep track of how many handlers we have so we can start and stop the native battery listener
1417
- * appropriately (and hopefully save on battery life!).
1418
- */
1419
- Battery.prototype.onSubscribe = function() {
1420
- var me = battery;
1421
- // If we just registered the first handler, make sure native listener is started.
1422
- if (handlers() === 1) {
1423
- exec(me._status, me._error, "Battery", "start", []);
1424
- }
1425
- };
1426
-
1427
- Battery.prototype.onUnsubscribe = function() {
1428
- var me = battery;
1429
-
1430
- // If we just unregistered the last handler, make sure native listener is stopped.
1431
- if (handlers() === 0) {
1432
- exec(null, null, "Battery", "stop", []);
1433
- }
1434
- };
1435
-
1436
- /**
1437
- * Callback for battery status
1438
- *
1439
- * @param {Object} info keys: level, isPlugged
1440
- */
1441
- Battery.prototype._status = function(info) {
1442
- if (info) {
1443
- var me = battery;
1444
- var level = info.level;
1445
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
1446
- // Fire batterystatus event
1447
- cordova.fireWindowEvent("batterystatus", info);
1448
-
1449
- // Fire low battery event
1450
- if (level === 20 || level === 5) {
1451
- if (level === 20) {
1452
- cordova.fireWindowEvent("batterylow", info);
1453
- }
1454
- else {
1455
- cordova.fireWindowEvent("batterycritical", info);
1456
- }
1457
- }
1458
- }
1459
- me._level = level;
1460
- me._isPlugged = info.isPlugged;
1461
- }
1462
- };
1463
-
1464
- /**
1465
- * Error callback for battery start
1466
- */
1467
- Battery.prototype._error = function(e) {
1468
- console.log("Error initializing Battery: " + e);
1469
- };
1470
-
1471
- var battery = new Battery();
1472
-
1473
- module.exports = battery;
1474
-
1475
- });
1476
-
1477
-
1478
- define('cordova/plugin/Camera', function(require, exports, module) {
1479
- var exec = require('cordova/exec'),
1480
- Camera = require('cordova/plugin/CameraConstants');
1481
-
1482
- var cameraExport = {};
1483
-
1484
- // Tack on the Camera Constants to the base camera plugin.
1485
- for (var key in Camera) {
1486
- cameraExport[key] = Camera[key];
1487
- }
1488
-
1489
- /**
1490
- * Gets a picture from source defined by "options.sourceType", and returns the
1491
- * image as defined by the "options.destinationType" option.
1492
-
1493
- * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
1494
- *
1495
- * @param {Function} successCallback
1496
- * @param {Function} errorCallback
1497
- * @param {Object} options
1498
- */
1499
- cameraExport.getPicture = function(successCallback, errorCallback, options) {
1500
- // successCallback required
1501
- if (typeof successCallback != "function") {
1502
- console.log("Camera Error: successCallback is not a function");
1503
- return;
1504
- }
1505
-
1506
- // errorCallback optional
1507
- if (errorCallback && (typeof errorCallback != "function")) {
1508
- console.log("Camera Error: errorCallback is not a function");
1509
- return;
1510
- }
1511
-
1512
- var quality = 50;
1513
- if (options && typeof options.quality == "number") {
1514
- quality = options.quality;
1515
- } else if (options && typeof options.quality == "string") {
1516
- var qlity = parseInt(options.quality, 10);
1517
- if (isNaN(qlity) === false) {
1518
- quality = qlity.valueOf();
1519
- }
1520
- }
1521
-
1522
- var destinationType = Camera.DestinationType.FILE_URL;
1523
- if (typeof options.destinationType == "number") {
1524
- destinationType = options.destinationType;
1525
- }
1526
-
1527
- var sourceType = Camera.PictureSourceType.CAMERA;
1528
- if (typeof options.sourceType == "number") {
1529
- sourceType = options.sourceType;
1530
- }
1194
+ var sourceType = Camera.PictureSourceType.CAMERA;
1195
+ if (typeof options.sourceType == "number") {
1196
+ sourceType = options.sourceType;
1197
+ }
1531
1198
 
1532
1199
  var targetWidth = -1;
1533
1200
  if (typeof options.targetWidth == "number") {
@@ -1553,17 +1220,38 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) {
1553
1220
  if (typeof options.encodingType == "number") {
1554
1221
  encodingType = options.encodingType;
1555
1222
  }
1556
- // TODO: parse MediaType
1557
- // TODO: enable allow edit?
1558
1223
 
1559
- exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
1560
- }
1224
+ var mediaType = Camera.MediaType.PICTURE;
1225
+ if (typeof options.mediaType == "number") {
1226
+ mediaType = options.mediaType;
1227
+ }
1228
+ var allowEdit = false;
1229
+ if (typeof options.allowEdit == "boolean") {
1230
+ allowEdit = options.allowEdit;
1231
+ } else if (typeof options.allowEdit == "number") {
1232
+ allowEdit = options.allowEdit <= 0 ? false : true;
1233
+ }
1234
+ var correctOrientation = false;
1235
+ if (typeof options.correctOrientation == "boolean") {
1236
+ correctOrientation = options.correctOrientation;
1237
+ } else if (typeof options.correctOrientation == "number") {
1238
+ correctOrientation = options.correctOrientation <=0 ? false : true;
1239
+ }
1240
+ var saveToPhotoAlbum = false;
1241
+ if (typeof options.saveToPhotoAlbum == "boolean") {
1242
+ saveToPhotoAlbum = options.saveToPhotoAlbum;
1243
+ } else if (typeof options.saveToPhotoAlbum == "number") {
1244
+ saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
1245
+ }
1561
1246
 
1562
- module.exports = cameraExport;
1247
+ exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum]);
1248
+ };
1563
1249
 
1250
+ module.exports = cameraExport;
1564
1251
  });
1565
1252
 
1566
- define('cordova/plugin/CameraConstants', function(require, exports, module) {
1253
+ // file: lib/common/plugin/CameraConstants.js
1254
+ define("cordova/plugin/CameraConstants", function(require, exports, module) {
1567
1255
  module.exports = {
1568
1256
  DestinationType:{
1569
1257
  DATA_URL: 0, // Return base64 encoded string
@@ -1584,332 +1272,188 @@ module.exports = {
1584
1272
  SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
1585
1273
  }
1586
1274
  };
1587
-
1588
1275
  });
1589
1276
 
1590
- define('cordova/plugin/capture', function(require, exports, module) {
1591
- var exec = require('cordova/exec'),
1592
- MediaFile = require('cordova/plugin/MediaFile');
1593
-
1594
- /**
1595
- * Launches a capture of different types.
1596
- *
1597
- * @param (DOMString} type
1598
- * @param {Function} successCB
1599
- * @param {Function} errorCB
1600
- * @param {CaptureVideoOptions} options
1601
- */
1602
- function _capture(type, successCallback, errorCallback, options) {
1603
- var win = function(pluginResult) {
1604
- var mediaFiles = [];
1605
- var i;
1606
- for (i = 0; i < pluginResult.length; i++) {
1607
- var mediaFile = new MediaFile();
1608
- mediaFile.name = pluginResult[i].name;
1609
- mediaFile.fullPath = pluginResult[i].fullPath;
1610
- mediaFile.type = pluginResult[i].type;
1611
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
1612
- mediaFile.size = pluginResult[i].size;
1613
- mediaFiles.push(mediaFile);
1614
- }
1615
- successCallback(mediaFiles);
1616
- };
1617
- exec(win, errorCallback, "Capture", type, [options]);
1618
- }
1277
+ // file: lib/common/plugin/CaptureAudioOptions.js
1278
+ define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
1619
1279
  /**
1620
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
1280
+ * Encapsulates all audio capture operation configuration options.
1621
1281
  */
1622
- function Capture() {
1623
- this.supportedAudioModes = [];
1624
- this.supportedImageModes = [];
1625
- this.supportedVideoModes = [];
1626
- }
1282
+ var CaptureAudioOptions = function(){
1283
+ // Upper limit of sound clips user can record. Value must be equal or greater than 1.
1284
+ this.limit = 1;
1285
+ // Maximum duration of a single sound clip in seconds.
1286
+ this.duration = 0;
1287
+ // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
1288
+ this.mode = null;
1289
+ };
1627
1290
 
1291
+ module.exports = CaptureAudioOptions;
1292
+ });
1293
+
1294
+ // file: lib/common/plugin/CaptureError.js
1295
+ define("cordova/plugin/CaptureError", function(require, exports, module) {
1628
1296
  /**
1629
- * Launch audio recorder application for recording audio clip(s).
1630
- *
1631
- * @param {Function} successCB
1632
- * @param {Function} errorCB
1633
- * @param {CaptureAudioOptions} options
1297
+ * The CaptureError interface encapsulates all errors in the Capture API.
1634
1298
  */
1635
- Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
1636
- _capture("captureAudio", successCallback, errorCallback, options);
1299
+ var CaptureError = function(c) {
1300
+ this.code = c || null;
1637
1301
  };
1638
1302
 
1303
+ // Camera or microphone failed to capture image or sound.
1304
+ CaptureError.CAPTURE_INTERNAL_ERR = 0;
1305
+ // Camera application or audio capture application is currently serving other capture request.
1306
+ CaptureError.CAPTURE_APPLICATION_BUSY = 1;
1307
+ // Invalid use of the API (e.g. limit parameter has value less than one).
1308
+ CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
1309
+ // User exited camera application or audio capture application before capturing anything.
1310
+ CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
1311
+ // The requested capture operation is not supported.
1312
+ CaptureError.CAPTURE_NOT_SUPPORTED = 20;
1313
+
1314
+ module.exports = CaptureError;
1315
+ });
1316
+
1317
+ // file: lib/common/plugin/CaptureImageOptions.js
1318
+ define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
1639
1319
  /**
1640
- * Launch camera application for taking image(s).
1641
- *
1642
- * @param {Function} successCB
1643
- * @param {Function} errorCB
1644
- * @param {CaptureImageOptions} options
1320
+ * Encapsulates all image capture operation configuration options.
1645
1321
  */
1646
- Capture.prototype.captureImage = function(successCallback, errorCallback, options){
1647
- _capture("captureImage", successCallback, errorCallback, options);
1648
- };
1649
-
1650
- /**
1651
- * Launch device camera application for recording video(s).
1652
- *
1653
- * @param {Function} successCB
1654
- * @param {Function} errorCB
1655
- * @param {CaptureVideoOptions} options
1656
- */
1657
- Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
1658
- _capture("captureVideo", successCallback, errorCallback, options);
1659
- };
1660
-
1661
-
1662
- module.exports = new Capture();
1663
-
1664
- });
1665
-
1666
- define('cordova/plugin/CaptureAudioOptions', function(require, exports, module) {
1667
- /**
1668
- * Encapsulates all audio capture operation configuration options.
1669
- */
1670
- var CaptureAudioOptions = function(){
1671
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
1672
- this.limit = 1;
1673
- // Maximum duration of a single sound clip in seconds.
1674
- this.duration = 0;
1675
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
1676
- this.mode = null;
1677
- };
1678
-
1679
- module.exports = CaptureAudioOptions;
1680
-
1681
- });
1682
-
1683
- define('cordova/plugin/CaptureError', function(require, exports, module) {
1684
- /**
1685
- * The CaptureError interface encapsulates all errors in the Capture API.
1686
- */
1687
- var CaptureError = function(c) {
1688
- this.code = c || null;
1689
- };
1690
-
1691
- // Camera or microphone failed to capture image or sound.
1692
- CaptureError.CAPTURE_INTERNAL_ERR = 0;
1693
- // Camera application or audio capture application is currently serving other capture request.
1694
- CaptureError.CAPTURE_APPLICATION_BUSY = 1;
1695
- // Invalid use of the API (e.g. limit parameter has value less than one).
1696
- CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
1697
- // User exited camera application or audio capture application before capturing anything.
1698
- CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
1699
- // The requested capture operation is not supported.
1700
- CaptureError.CAPTURE_NOT_SUPPORTED = 20;
1701
-
1702
- module.exports = CaptureError;
1703
-
1704
- });
1705
-
1706
- define('cordova/plugin/CaptureImageOptions', function(require, exports, module) {
1707
- /**
1708
- * Encapsulates all image capture operation configuration options.
1709
- */
1710
- var CaptureImageOptions = function(){
1711
- // Upper limit of images user can take. Value must be equal or greater than 1.
1712
- this.limit = 1;
1713
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
1714
- this.mode = null;
1322
+ var CaptureImageOptions = function(){
1323
+ // Upper limit of images user can take. Value must be equal or greater than 1.
1324
+ this.limit = 1;
1325
+ // The selected image mode. Must match with one of the elements in supportedImageModes array.
1326
+ this.mode = null;
1715
1327
  };
1716
1328
 
1717
1329
  module.exports = CaptureImageOptions;
1718
-
1719
1330
  });
1720
1331
 
1721
- define('cordova/plugin/CaptureVideoOptions', function(require, exports, module) {
1332
+ // file: lib/common/plugin/CaptureVideoOptions.js
1333
+ define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
1722
1334
  /**
1723
1335
  * Encapsulates all video capture operation configuration options.
1724
1336
  */
1725
1337
  var CaptureVideoOptions = function(){
1726
- // Upper limit of videos user can record. Value must be equal or greater than 1.
1727
- this.limit = 1;
1728
- // Maximum duration of a single video clip in seconds.
1729
- this.duration = 0;
1730
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
1731
- this.mode = null;
1338
+ // Upper limit of videos user can record. Value must be equal or greater than 1.
1339
+ this.limit = 1;
1340
+ // Maximum duration of a single video clip in seconds.
1341
+ this.duration = 0;
1342
+ // The selected video mode. Must match with one of the elements in supportedVideoModes array.
1343
+ this.mode = null;
1732
1344
  };
1733
1345
 
1734
1346
  module.exports = CaptureVideoOptions;
1735
-
1736
- });
1737
-
1738
- define('cordova/plugin/compass', function(require, exports, module) {
1739
- var exec = require('cordova/exec'),
1740
- utils = require('cordova/utils'),
1741
- CompassHeading = require('cordova/plugin/CompassHeading'),
1742
- CompassError = require('cordova/plugin/CompassError'),
1743
- timers = {},
1744
- compass = {
1745
- /**
1746
- * Asynchronously acquires the current heading.
1747
- * @param {Function} successCallback The function to call when the heading
1748
- * data is available
1749
- * @param {Function} errorCallback The function to call when there is an error
1750
- * getting the heading data.
1751
- * @param {CompassOptions} options The options for getting the heading data (not used).
1752
- */
1753
- getCurrentHeading:function(successCallback, errorCallback, options) {
1754
- // successCallback required
1755
- if (typeof successCallback !== "function") {
1756
- console.log("Compass Error: successCallback is not a function");
1757
- return;
1758
- }
1759
-
1760
- // errorCallback optional
1761
- if (errorCallback && (typeof errorCallback !== "function")) {
1762
- console.log("Compass Error: errorCallback is not a function");
1763
- return;
1764
- }
1765
-
1766
- var win = function(result) {
1767
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
1768
- successCallback(ch);
1769
- };
1770
- var fail = function(code) {
1771
- var ce = new CompassError(code);
1772
- errorCallback(ce);
1773
- }
1774
-
1775
- // Get heading
1776
- exec(win, fail, "Compass", "getHeading", []);
1777
- },
1778
-
1779
- /**
1780
- * Asynchronously acquires the heading repeatedly at a given interval.
1781
- * @param {Function} successCallback The function to call each time the heading
1782
- * data is available
1783
- * @param {Function} errorCallback The function to call when there is an error
1784
- * getting the heading data.
1785
- * @param {HeadingOptions} options The options for getting the heading data
1786
- * such as timeout and the frequency of the watch.
1787
- */
1788
- watchHeading:function(successCallback, errorCallback, options) {
1789
- // Default interval (100 msec)
1790
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
1791
-
1792
- // successCallback required
1793
- if (typeof successCallback !== "function") {
1794
- console.log("Compass Error: successCallback is not a function");
1795
- return;
1796
- }
1797
-
1798
- // errorCallback optional
1799
- if (errorCallback && (typeof errorCallback !== "function")) {
1800
- console.log("Compass Error: errorCallback is not a function");
1801
- return;
1802
- }
1803
-
1804
- // Start watch timer to get headings
1805
- var id = utils.createUUID();
1806
- var win = function(result) {
1807
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
1808
- successCallback(ch);
1809
- };
1810
- var fail = function(code) {
1811
- var ce = new CompassError(code);
1812
- errorCallback(ce);
1813
- };
1814
-
1815
- timers[id] = window.setInterval(function() {
1816
- exec(win, fail, "Compass", "getHeading", []);
1817
- }, frequency);
1818
-
1819
- return id;
1820
- },
1821
-
1822
- /**
1823
- * Clears the specified heading watch.
1824
- * @param {String} watchId The ID of the watch returned from #watchHeading.
1825
- */
1826
- clearWatch:function(id) {
1827
- // Stop javascript timer & remove from timer list
1828
- if (id && timers[id]) {
1829
- clearInterval(timers[id]);
1830
- delete timers[id];
1831
- }
1832
- }
1833
- // TODO: add the filter-based iOS-only methods
1834
- };
1835
-
1836
- module.exports = compass;
1837
-
1838
1347
  });
1839
1348
 
1840
- define('cordova/plugin/CompassError', function(require, exports, module) {
1349
+ // file: lib/common/plugin/CompassError.js
1350
+ define("cordova/plugin/CompassError", function(require, exports, module) {
1841
1351
  /**
1842
1352
  * CompassError.
1843
1353
  * An error code assigned by an implementation when an error has occured
1844
1354
  * @constructor
1845
1355
  */
1846
1356
  var CompassError = function(err) {
1847
- this.code = (typeof err != 'undefined' ? err : null);
1357
+ this.code = (err !== undefined ? err : null);
1848
1358
  };
1849
1359
 
1850
- /**
1851
- * Error codes
1852
- */
1853
1360
  CompassError.COMPASS_INTERNAL_ERR = 0;
1854
1361
  CompassError.COMPASS_NOT_SUPPORTED = 20;
1855
1362
 
1856
1363
  module.exports = CompassError;
1857
-
1858
-
1859
1364
  });
1860
1365
 
1861
- define('cordova/plugin/CompassHeading', function(require, exports, module) {
1366
+ // file: lib/common/plugin/CompassHeading.js
1367
+ define("cordova/plugin/CompassHeading", function(require, exports, module) {
1862
1368
  var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
1863
- this.magneticHeading = magneticHeading !== undefined ? magneticHeading : null;
1864
- this.trueHeading = trueHeading !== undefined ? trueHeading : null;
1865
- this.headingAccuracy = headingAccuracy !== undefined ? headingAccuracy : null;
1866
- this.timestamp = timestamp !== undefined ? new Date(timestamp) : new Date();
1369
+ this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
1370
+ this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
1371
+ this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
1372
+ this.timestamp = (timestamp !== undefined ? timestamp : new Date().getTime());
1867
1373
  };
1868
1374
 
1869
1375
  module.exports = CompassHeading;
1870
-
1871
1376
  });
1872
1377
 
1873
- define('cordova/plugin/ConfigurationData', function(require, exports, module) {
1378
+ // file: lib/common/plugin/ConfigurationData.js
1379
+ define("cordova/plugin/ConfigurationData", function(require, exports, module) {
1874
1380
  /**
1875
1381
  * Encapsulates a set of parameters that the capture device supports.
1876
1382
  */
1877
1383
  function ConfigurationData() {
1878
- // The ASCII-encoded string in lower case representing the media type.
1879
- this.type = null;
1880
- // The height attribute represents height of the image or video in pixels.
1881
- // In the case of a sound clip this attribute has value 0.
1384
+ // The ASCII-encoded string in lower case representing the media type.
1385
+ this.type = null;
1386
+ // The height attribute represents height of the image or video in pixels.
1387
+ // In the case of a sound clip this attribute has value 0.
1882
1388
  this.height = 0;
1883
- // The width attribute represents width of the image or video in pixels.
1389
+ // The width attribute represents width of the image or video in pixels.
1884
1390
  // In the case of a sound clip this attribute has value 0
1885
1391
  this.width = 0;
1886
1392
  }
1887
1393
 
1888
1394
  module.exports = ConfigurationData;
1889
-
1890
1395
  });
1891
1396
 
1892
- define('cordova/plugin/Connection', function(require, exports, module) {
1397
+ // file: lib/common/plugin/Connection.js
1398
+ define("cordova/plugin/Connection", function(require, exports, module) {
1893
1399
  /**
1894
1400
  * Network status
1895
1401
  */
1896
1402
  module.exports = {
1897
- UNKNOWN: "unknown",
1898
- ETHERNET: "ethernet",
1899
- WIFI: "wifi",
1900
- CELL_2G: "2g",
1901
- CELL_3G: "3g",
1902
- CELL_4G: "4g",
1903
- NONE: "none"
1403
+ UNKNOWN: "unknown",
1404
+ ETHERNET: "ethernet",
1405
+ WIFI: "wifi",
1406
+ CELL_2G: "2g",
1407
+ CELL_3G: "3g",
1408
+ CELL_4G: "4g",
1409
+ NONE: "none"
1904
1410
  };
1905
-
1906
1411
  });
1907
1412
 
1908
- define('cordova/plugin/Contact', function(require, exports, module) {
1413
+ // file: lib/common/plugin/Contact.js
1414
+ define("cordova/plugin/Contact", function(require, exports, module) {
1909
1415
  var exec = require('cordova/exec'),
1910
1416
  ContactError = require('cordova/plugin/ContactError'),
1911
1417
  utils = require('cordova/utils');
1912
1418
 
1419
+ /**
1420
+ * Converts primitives into Complex Object
1421
+ * Currently only used for Date fields
1422
+ */
1423
+ function convertIn(contact) {
1424
+ var value = contact.birthday;
1425
+ try {
1426
+ contact.birthday = new Date(parseFloat(value));
1427
+ } catch (exception){
1428
+ console.log("Cordova Contact convertIn error: exception creating date.");
1429
+ }
1430
+ return contact;
1431
+ }
1432
+
1433
+ /**
1434
+ * Converts Complex objects into primitives
1435
+ * Only conversion at present is for Dates.
1436
+ **/
1437
+
1438
+ function convertOut(contact) {
1439
+ var value = contact.birthday;
1440
+ if (value !== null) {
1441
+ // try to make it a Date object if it is not already
1442
+ if (!utils.isDate(value)){
1443
+ try {
1444
+ value = new Date(value);
1445
+ } catch(exception){
1446
+ value = null;
1447
+ }
1448
+ }
1449
+ if (utils.isDate(value)){
1450
+ value = value.valueOf(); // convert to milliseconds
1451
+ }
1452
+ contact.birthday = value;
1453
+ }
1454
+ return contact;
1455
+ }
1456
+
1913
1457
  /**
1914
1458
  * Contains information about a single contact.
1915
1459
  * @constructor
@@ -1935,16 +1479,16 @@ var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, a
1935
1479
  this.displayName = displayName || null;
1936
1480
  this.name = name || null; // ContactName
1937
1481
  this.nickname = nickname || null;
1938
- this.phoneNumbers = phoneNumbers || []; // ContactField[]
1939
- this.emails = emails || []; // ContactField[]
1940
- this.addresses = addresses || []; // ContactAddress[]
1941
- this.ims = ims || []; // ContactField[]
1942
- this.organizations = organizations || []; // ContactOrganization[]
1482
+ this.phoneNumbers = phoneNumbers || null; // ContactField[]
1483
+ this.emails = emails || null; // ContactField[]
1484
+ this.addresses = addresses || null; // ContactAddress[]
1485
+ this.ims = ims || null; // ContactField[]
1486
+ this.organizations = organizations || null; // ContactOrganization[]
1943
1487
  this.birthday = birthday || null;
1944
1488
  this.note = note || null;
1945
- this.photos = photos || []; // ContactField[]
1946
- this.categories = categories || []; // ContactField[]
1947
- this.urls = urls || []; // ContactField[]
1489
+ this.photos = photos || null; // ContactField[]
1490
+ this.categories = categories || null; // ContactField[]
1491
+ this.urls = urls || null; // ContactField[]
1948
1492
  };
1949
1493
 
1950
1494
  /**
@@ -1953,12 +1497,14 @@ var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, a
1953
1497
  * @param errorCB error callback
1954
1498
  */
1955
1499
  Contact.prototype.remove = function(successCB, errorCB) {
1500
+ var fail = function(code) {
1501
+ errorCB(new ContactError(code));
1502
+ };
1956
1503
  if (this.id === null) {
1957
- var errorObj = new ContactError(ContactError.UNKNOWN_ERROR);
1958
- errorCB(errorObj);
1504
+ fail(ContactError.UNKNOWN_ERROR);
1959
1505
  }
1960
1506
  else {
1961
- exec(successCB, errorCB, "Contacts", "remove", [this.id]);
1507
+ exec(successCB, fail, "Contacts", "remove", [this.id]);
1962
1508
  }
1963
1509
  };
1964
1510
 
@@ -2022,7 +1568,23 @@ Contact.prototype.clone = function() {
2022
1568
  * @param errorCB error callback
2023
1569
  */
2024
1570
  Contact.prototype.save = function(successCB, errorCB) {
2025
- exec(successCB, errorCB, "Contacts", "save", [this]);
1571
+ var fail = function(code) {
1572
+ errorCB(new ContactError(code));
1573
+ };
1574
+ var success = function(result) {
1575
+ if (result) {
1576
+ if (typeof successCB === 'function') {
1577
+ var fullContact = require('cordova/plugin/contacts').create(result);
1578
+ successCB(convertIn(fullContact));
1579
+ }
1580
+ }
1581
+ else {
1582
+ // no Entry object returned
1583
+ fail(ContactError.UNKNOWN_ERROR);
1584
+ }
1585
+ };
1586
+ var dupContact = convertOut(utils.clone(this));
1587
+ exec(success, fail, "Contacts", "save", [dupContact]);
2026
1588
  };
2027
1589
 
2028
1590
 
@@ -2030,7 +1592,8 @@ module.exports = Contact;
2030
1592
 
2031
1593
  });
2032
1594
 
2033
- define('cordova/plugin/ContactAddress', function(require, exports, module) {
1595
+ // file: lib/common/plugin/ContactAddress.js
1596
+ define("cordova/plugin/ContactAddress", function(require, exports, module) {
2034
1597
  /**
2035
1598
  * Contact address.
2036
1599
  * @constructor
@@ -2056,10 +1619,10 @@ var ContactAddress = function(pref, type, formatted, streetAddress, locality, re
2056
1619
  };
2057
1620
 
2058
1621
  module.exports = ContactAddress;
2059
-
2060
1622
  });
2061
1623
 
2062
- define('cordova/plugin/ContactError', function(require, exports, module) {
1624
+ // file: lib/common/plugin/ContactError.js
1625
+ define("cordova/plugin/ContactError", function(require, exports, module) {
2063
1626
  /**
2064
1627
  * ContactError.
2065
1628
  * An error code assigned by an implementation when an error has occured
@@ -2081,10 +1644,10 @@ ContactError.NOT_SUPPORTED_ERROR = 5;
2081
1644
  ContactError.PERMISSION_DENIED_ERROR = 20;
2082
1645
 
2083
1646
  module.exports = ContactError;
2084
-
2085
1647
  });
2086
1648
 
2087
- define('cordova/plugin/ContactField', function(require, exports, module) {
1649
+ // file: lib/common/plugin/ContactField.js
1650
+ define("cordova/plugin/ContactField", function(require, exports, module) {
2088
1651
  /**
2089
1652
  * Generic contact field.
2090
1653
  * @constructor
@@ -2095,16 +1658,16 @@ define('cordova/plugin/ContactField', function(require, exports, module) {
2095
1658
  */
2096
1659
  var ContactField = function(type, value, pref) {
2097
1660
  this.id = null;
2098
- this.type = type || null;
2099
- this.value = value || null;
1661
+ this.type = (type && type.toString()) || null;
1662
+ this.value = (value && value.toString()) || null;
2100
1663
  this.pref = (typeof pref != 'undefined' ? pref : false);
2101
1664
  };
2102
1665
 
2103
1666
  module.exports = ContactField;
2104
-
2105
1667
  });
2106
1668
 
2107
- define('cordova/plugin/ContactFindOptions', function(require, exports, module) {
1669
+ // file: lib/common/plugin/ContactFindOptions.js
1670
+ define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
2108
1671
  /**
2109
1672
  * ContactFindOptions.
2110
1673
  * @constructor
@@ -2118,10 +1681,10 @@ var ContactFindOptions = function(filter, multiple) {
2118
1681
  };
2119
1682
 
2120
1683
  module.exports = ContactFindOptions;
2121
-
2122
1684
  });
2123
1685
 
2124
- define('cordova/plugin/ContactName', function(require, exports, module) {
1686
+ // file: lib/common/plugin/ContactName.js
1687
+ define("cordova/plugin/ContactName", function(require, exports, module) {
2125
1688
  /**
2126
1689
  * Contact name.
2127
1690
  * @constructor
@@ -2142,10 +1705,10 @@ var ContactName = function(formatted, familyName, givenName, middle, prefix, suf
2142
1705
  };
2143
1706
 
2144
1707
  module.exports = ContactName;
2145
-
2146
1708
  });
2147
1709
 
2148
- define('cordova/plugin/ContactOrganization', function(require, exports, module) {
1710
+ // file: lib/common/plugin/ContactOrganization.js
1711
+ define("cordova/plugin/ContactOrganization", function(require, exports, module) {
2149
1712
  /**
2150
1713
  * Contact organization.
2151
1714
  * @constructor
@@ -2169,71 +1732,10 @@ var ContactOrganization = function(pref, type, name, dept, title) {
2169
1732
  };
2170
1733
 
2171
1734
  module.exports = ContactOrganization;
2172
-
2173
- });
2174
-
2175
- define('cordova/plugin/contacts', function(require, exports, module) {
2176
- var exec = require('cordova/exec'),
2177
- ContactError = require('cordova/plugin/ContactError'),
2178
- Contact = require('cordova/plugin/Contact');
2179
-
2180
- /**
2181
- * Represents a group of Contacts.
2182
- * @constructor
2183
- */
2184
- var contacts = {
2185
- /**
2186
- * Returns an array of Contacts matching the search criteria.
2187
- * @param fields that should be searched
2188
- * @param successCB success callback
2189
- * @param errorCB error callback
2190
- * @param {ContactFindOptions} options that can be applied to contact searching
2191
- * @return array of Contacts matching search criteria
2192
- */
2193
- find:function(fields, successCB, errorCB, options) {
2194
- if (!successCB) {
2195
- throw new TypeError("You must specify a success callback for the find command.");
2196
- }
2197
- if (!fields || (fields instanceof Array && fields.length === 0)) {
2198
- if (typeof errorCB === "function") {
2199
- errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
2200
- }
2201
- } else {
2202
- var win = function(result) {
2203
- var cs = [];
2204
- for (var i = 0, l = result.length; i < l; i++) {
2205
- cs.push(contacts.create(result[i]));
2206
- }
2207
- successCB(cs);
2208
- };
2209
- exec(win, errorCB, "Contacts", "search", [fields, options]);
2210
- }
2211
- },
2212
-
2213
- /**
2214
- * This function creates a new contact, but it does not persist the contact
2215
- * to device storage. To persist the contact to device storage, invoke
2216
- * contact.save().
2217
- * @param properties an object who's properties will be examined to create a new Contact
2218
- * @returns new Contact object
2219
- */
2220
- create:function(properties) {
2221
- var i;
2222
- var contact = new Contact();
2223
- for (i in properties) {
2224
- if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
2225
- contact[i] = properties[i];
2226
- }
2227
- }
2228
- return contact;
2229
- }
2230
- };
2231
-
2232
- module.exports = contacts;
2233
-
2234
1735
  });
2235
1736
 
2236
- define('cordova/plugin/Coordinates', function(require, exports, module) {
1737
+ // file: lib/common/plugin/Coordinates.js
1738
+ define("cordova/plugin/Coordinates", function(require, exports, module) {
2237
1739
  /**
2238
1740
  * This class contains position information.
2239
1741
  * @param {Object} lat
@@ -2277,13 +1779,14 @@ var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
2277
1779
  };
2278
1780
 
2279
1781
  module.exports = Coordinates;
2280
-
2281
1782
  });
2282
1783
 
2283
- define('cordova/plugin/DirectoryEntry', function(require, exports, module) {
1784
+ // file: lib/common/plugin/DirectoryEntry.js
1785
+ define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
2284
1786
  var utils = require('cordova/utils'),
2285
1787
  exec = require('cordova/exec'),
2286
1788
  Entry = require('cordova/plugin/Entry'),
1789
+ FileError = require('cordova/plugin/FileError'),
2287
1790
  DirectoryReader = require('cordova/plugin/DirectoryReader');
2288
1791
 
2289
1792
  /**
@@ -2364,8 +1867,10 @@ module.exports = DirectoryEntry;
2364
1867
 
2365
1868
  });
2366
1869
 
2367
- define('cordova/plugin/DirectoryReader', function(require, exports, module) {
2368
- var exec = require('cordova/exec');
1870
+ // file: lib/common/plugin/DirectoryReader.js
1871
+ define("cordova/plugin/DirectoryReader", function(require, exports, module) {
1872
+ var exec = require('cordova/exec'),
1873
+ FileError = require('cordova/plugin/FileError') ;
2369
1874
 
2370
1875
  /**
2371
1876
  * An interface that lists the files and directories in a directory.
@@ -2386,10 +1891,10 @@ DirectoryReader.prototype.readEntries = function(successCallback, errorCallback)
2386
1891
  for (var i=0; i<result.length; i++) {
2387
1892
  var entry = null;
2388
1893
  if (result[i].isDirectory) {
2389
- entry = new DirectoryEntry();
1894
+ entry = new (require('cordova/plugin/DirectoryEntry'))();
2390
1895
  }
2391
1896
  else if (result[i].isFile) {
2392
- entry = new FileEntry();
1897
+ entry = new (require('cordova/plugin/FileEntry'))();
2393
1898
  }
2394
1899
  entry.isDirectory = result[i].isDirectory;
2395
1900
  entry.isFile = result[i].isFile;
@@ -2409,7 +1914,8 @@ module.exports = DirectoryReader;
2409
1914
 
2410
1915
  });
2411
1916
 
2412
- define('cordova/plugin/Entry', function(require, exports, module) {
1917
+ // file: lib/common/plugin/Entry.js
1918
+ define("cordova/plugin/Entry", function(require, exports, module) {
2413
1919
  var exec = require('cordova/exec'),
2414
1920
  FileError = require('cordova/plugin/FileError'),
2415
1921
  Metadata = require('cordova/plugin/Metadata');
@@ -2601,17 +2107,22 @@ Entry.prototype.remove = function(successCallback, errorCallback) {
2601
2107
  * @param errorCallback {Function} called with a FileError
2602
2108
  */
2603
2109
  Entry.prototype.getParent = function(successCallback, errorCallback) {
2110
+ var win = typeof successCallback !== 'function' ? null : function(result) {
2111
+ var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
2112
+ var entry = new DirectoryEntry(result.name, result.fullPath);
2113
+ successCallback(entry);
2114
+ };
2604
2115
  var fail = typeof errorCallback !== 'function' ? null : function(code) {
2605
2116
  errorCallback(new FileError(code));
2606
2117
  };
2607
- exec(successCallback, fail, "File", "getParent", [this.fullPath]);
2118
+ exec(win, fail, "File", "getParent", [this.fullPath]);
2608
2119
  };
2609
2120
 
2610
2121
  module.exports = Entry;
2611
-
2612
2122
  });
2613
2123
 
2614
- define('cordova/plugin/File', function(require, exports, module) {
2124
+ // file: lib/common/plugin/File.js
2125
+ define("cordova/plugin/File", function(require, exports, module) {
2615
2126
  /**
2616
2127
  * Constructor.
2617
2128
  * name {DOMString} name of the file, without path information
@@ -2622,18 +2133,18 @@ define('cordova/plugin/File', function(require, exports, module) {
2622
2133
  */
2623
2134
 
2624
2135
  var File = function(name, fullPath, type, lastModifiedDate, size){
2625
- this.name = name || '';
2626
- this.fullPath = fullPath || null;
2627
- this.type = type || null;
2628
- this.lastModifiedDate = lastModifiedDate || null;
2629
- this.size = size || 0;
2136
+ this.name = name || '';
2137
+ this.fullPath = fullPath || null;
2138
+ this.type = type || null;
2139
+ this.lastModifiedDate = lastModifiedDate || null;
2140
+ this.size = size || 0;
2630
2141
  };
2631
2142
 
2632
2143
  module.exports = File;
2633
-
2634
2144
  });
2635
2145
 
2636
- define('cordova/plugin/FileEntry', function(require, exports, module) {
2146
+ // file: lib/common/plugin/FileEntry.js
2147
+ define("cordova/plugin/FileEntry", function(require, exports, module) {
2637
2148
  var utils = require('cordova/utils'),
2638
2149
  exec = require('cordova/exec'),
2639
2150
  Entry = require('cordova/plugin/Entry'),
@@ -2697,10 +2208,10 @@ FileEntry.prototype.file = function(successCallback, errorCallback) {
2697
2208
 
2698
2209
 
2699
2210
  module.exports = FileEntry;
2700
-
2701
2211
  });
2702
2212
 
2703
- define('cordova/plugin/FileError', function(require, exports, module) {
2213
+ // file: lib/common/plugin/FileError.js
2214
+ define("cordova/plugin/FileError", function(require, exports, module) {
2704
2215
  /**
2705
2216
  * FileError
2706
2217
  */
@@ -2726,10 +2237,10 @@ FileError.TYPE_MISMATCH_ERR = 11;
2726
2237
  FileError.PATH_EXISTS_ERR = 12;
2727
2238
 
2728
2239
  module.exports = FileError;
2729
-
2730
2240
  });
2731
2241
 
2732
- define('cordova/plugin/FileReader', function(require, exports, module) {
2242
+ // file: lib/common/plugin/FileReader.js
2243
+ define("cordova/plugin/FileReader", function(require, exports, module) {
2733
2244
  var exec = require('cordova/exec'),
2734
2245
  FileError = require('cordova/plugin/FileError'),
2735
2246
  ProgressEvent = require('cordova/plugin/ProgressEvent');
@@ -2830,6 +2341,7 @@ FileReader.prototype.readAsText = function(file, encoding) {
2830
2341
  if (me.readyState === FileReader.DONE) {
2831
2342
  return;
2832
2343
  }
2344
+
2833
2345
  // Save result
2834
2346
  me.result = r;
2835
2347
 
@@ -2964,7 +2476,7 @@ FileReader.prototype.readAsDataURL = function(file) {
2964
2476
  */
2965
2477
  FileReader.prototype.readAsBinaryString = function(file) {
2966
2478
  // TODO - Can't return binary data to browser.
2967
- console.log('This method is not supported at this time.');
2479
+ console.log('method "readAsBinaryString" is not supported at this time.');
2968
2480
  };
2969
2481
 
2970
2482
  /**
@@ -2978,10 +2490,10 @@ FileReader.prototype.readAsArrayBuffer = function(file) {
2978
2490
  };
2979
2491
 
2980
2492
  module.exports = FileReader;
2981
-
2982
2493
  });
2983
2494
 
2984
- define('cordova/plugin/FileSystem', function(require, exports, module) {
2495
+ // file: lib/common/plugin/FileSystem.js
2496
+ define("cordova/plugin/FileSystem", function(require, exports, module) {
2985
2497
  var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
2986
2498
 
2987
2499
  /**
@@ -2999,10 +2511,10 @@ var FileSystem = function(name, root) {
2999
2511
  };
3000
2512
 
3001
2513
  module.exports = FileSystem;
3002
-
3003
2514
  });
3004
2515
 
3005
- define('cordova/plugin/FileTransfer', function(require, exports, module) {
2516
+ // file: lib/common/plugin/FileTransfer.js
2517
+ define("cordova/plugin/FileTransfer", function(require, exports, module) {
3006
2518
  var exec = require('cordova/exec');
3007
2519
 
3008
2520
  /**
@@ -3019,8 +2531,9 @@ var FileTransfer = function() {};
3019
2531
  * @param successCallback (Function} Callback to be invoked when upload has completed
3020
2532
  * @param errorCallback {Function} Callback to be invoked upon error
3021
2533
  * @param options {FileUploadOptions} Optional parameters such as file name and mimetype
2534
+ * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
3022
2535
  */
3023
- FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, debug) {
2536
+ FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
3024
2537
  // check for options
3025
2538
  var fileKey = null;
3026
2539
  var fileName = null;
@@ -3031,7 +2544,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
3031
2544
  fileKey = options.fileKey;
3032
2545
  fileName = options.fileName;
3033
2546
  mimeType = options.mimeType;
3034
- if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
2547
+ if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
3035
2548
  chunkedMode = options.chunkedMode;
3036
2549
  }
3037
2550
  if (options.params) {
@@ -3042,7 +2555,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
3042
2555
  }
3043
2556
  }
3044
2557
 
3045
- exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
2558
+ exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
3046
2559
  };
3047
2560
 
3048
2561
  /**
@@ -3056,16 +2569,16 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
3056
2569
  var win = function(result) {
3057
2570
  var entry = null;
3058
2571
  if (result.isDirectory) {
3059
- entry = new DirectoryEntry();
2572
+ entry = new (require('cordova/plugin/DirectoryEntry'))();
3060
2573
  }
3061
2574
  else if (result.isFile) {
3062
- entry = new FileEntry();
2575
+ entry = new (require('cordova/plugin/FileEntry'))();
3063
2576
  }
3064
2577
  entry.isDirectory = result.isDirectory;
3065
2578
  entry.isFile = result.isFile;
3066
2579
  entry.name = result.name;
3067
2580
  entry.fullPath = result.fullPath;
3068
- successCallback(entry);
2581
+ successCallback(entry);
3069
2582
  };
3070
2583
  exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
3071
2584
  };
@@ -3074,7 +2587,8 @@ module.exports = FileTransfer;
3074
2587
 
3075
2588
  });
3076
2589
 
3077
- define('cordova/plugin/FileTransferError', function(require, exports, module) {
2590
+ // file: lib/common/plugin/FileTransferError.js
2591
+ define("cordova/plugin/FileTransferError", function(require, exports, module) {
3078
2592
  /**
3079
2593
  * FileTransferError
3080
2594
  * @constructor
@@ -3088,10 +2602,10 @@ FileTransferError.INVALID_URL_ERR = 2;
3088
2602
  FileTransferError.CONNECTION_ERR = 3;
3089
2603
 
3090
2604
  module.exports = FileTransferError;
3091
-
3092
2605
  });
3093
2606
 
3094
- define('cordova/plugin/FileUploadOptions', function(require, exports, module) {
2607
+ // file: lib/common/plugin/FileUploadOptions.js
2608
+ define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
3095
2609
  /**
3096
2610
  * Options to customize the HTTP request used to upload files.
3097
2611
  * @constructor
@@ -3108,10 +2622,10 @@ var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
3108
2622
  };
3109
2623
 
3110
2624
  module.exports = FileUploadOptions;
3111
-
3112
2625
  });
3113
2626
 
3114
- define('cordova/plugin/FileUploadResult', function(require, exports, module) {
2627
+ // file: lib/common/plugin/FileUploadResult.js
2628
+ define("cordova/plugin/FileUploadResult", function(require, exports, module) {
3115
2629
  /**
3116
2630
  * FileUploadResult
3117
2631
  * @constructor
@@ -3123,12 +2637,12 @@ var FileUploadResult = function() {
3123
2637
  };
3124
2638
 
3125
2639
  module.exports = FileUploadResult;
3126
-
3127
2640
  });
3128
2641
 
3129
- define('cordova/plugin/FileWriter', function(require, exports, module) {
2642
+ // file: lib/common/plugin/FileWriter.js
2643
+ define("cordova/plugin/FileWriter", function(require, exports, module) {
3130
2644
  var exec = require('cordova/exec'),
3131
- FileError = require('cordova/plugin/FileError');
2645
+ FileError = require('cordova/plugin/FileError'),
3132
2646
  ProgressEvent = require('cordova/plugin/ProgressEvent');
3133
2647
 
3134
2648
  /**
@@ -3287,7 +2801,7 @@ FileWriter.prototype.seek = function(offset) {
3287
2801
  throw new FileError(FileError.INVALID_STATE_ERR);
3288
2802
  }
3289
2803
 
3290
- if (!offset) {
2804
+ if (!offset && offset !== 0) {
3291
2805
  return;
3292
2806
  }
3293
2807
 
@@ -3383,10 +2897,11 @@ module.exports = FileWriter;
3383
2897
 
3384
2898
  });
3385
2899
 
3386
- define('cordova/plugin/Flags', function(require, exports, module) {
2900
+ // file: lib/common/plugin/Flags.js
2901
+ define("cordova/plugin/Flags", function(require, exports, module) {
3387
2902
  /**
3388
2903
  * Supplies arguments to methods that lookup or create files and directories.
3389
- *
2904
+ *
3390
2905
  * @param create
3391
2906
  * {boolean} file or directory if it doesn't exist
3392
2907
  * @param exclusive
@@ -3399,88 +2914,10 @@ function Flags(create, exclusive) {
3399
2914
  }
3400
2915
 
3401
2916
  module.exports = Flags;
3402
-
3403
- });
3404
-
3405
- define('cordova/plugin/geolocation', function(require, exports, module) {
3406
- var utils = require('cordova/utils'),
3407
- exec = require('cordova/exec'),
3408
- PositionError = require('cordova/plugin/PositionError');
3409
-
3410
- var timers = {}; // list of timers in use
3411
-
3412
- // Returns default params, overrides if provided with values
3413
- function parseParameters(options) {
3414
- var opt = {
3415
- maximumAge: 10000,
3416
- enableHighAccuracy: false,
3417
- timeout: 10000
3418
- };
3419
-
3420
- if (options) {
3421
- if (typeof options.maximumAge !== "undefined") {
3422
- opt.maximumAge = options.maximumAge;
3423
- }
3424
- if (typeof options.enableHighAccuracy !== "undefined") {
3425
- opt.enableHighAccuracy = options.enableHighAccuracy;
3426
- }
3427
- if (typeof options.timeout !== "undefined") {
3428
- opt.timeout = options.timeout;
3429
- }
3430
- }
3431
-
3432
- return opt;
3433
- }
3434
-
3435
- var geolocation = {
3436
- /**
3437
- * Asynchronously aquires the current position.
3438
- *
3439
- * @param {Function} successCallback The function to call when the position data is available
3440
- * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
3441
- * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
3442
- */
3443
- getCurrentPosition:function(successCallback, errorCallback, options) {
3444
- options = parseParameters(options);
3445
- exec(successCallback, errorCallback, "Geolocation", "getLocation", [options.enableHighAccuracy, options.timeout, options.maximumAge]);
3446
- },
3447
- /**
3448
- * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
3449
- * the successCallback is called with the new location.
3450
- *
3451
- * @param {Function} successCallback The function to call each time the location data is available
3452
- * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
3453
- * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
3454
- * @return String The watch id that must be passed to #clearWatch to stop watching.
3455
- */
3456
- watchPosition:function(successCallback, errorCallback, options) {
3457
- options = parseParameters(options);
3458
- var id = utils.createUUID();
3459
- timers[id] = window.setInterval(function() {
3460
- exec(successCallback, errorCallback, "Geolocation", "getLocation", [options.enableHighAccuracy, options.timeout, options.maximumAge]);
3461
- }, options.timeout);
3462
-
3463
- return id;
3464
- },
3465
- /**
3466
- * Clears the specified heading watch.
3467
- *
3468
- * @param {String} id The ID of the watch returned from #watchPosition
3469
- */
3470
- clearWatch:function(id) {
3471
- if (id && timers[id] !== undefined) {
3472
- window.clearInterval(timers[id]);
3473
- delete timers[id];
3474
- }
3475
- }
3476
- };
3477
-
3478
- module.exports = geolocation;
3479
-
3480
2917
  });
3481
2918
 
3482
-
3483
- define('cordova/plugin/LocalFileSystem', function(require, exports, module) {
2919
+ // file: lib/common/plugin/LocalFileSystem.js
2920
+ define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
3484
2921
  var exec = require('cordova/exec');
3485
2922
 
3486
2923
  /**
@@ -3494,10 +2931,10 @@ LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
3494
2931
  LocalFileSystem.PERSISTENT = 1; //persistent
3495
2932
 
3496
2933
  module.exports = LocalFileSystem;
3497
-
3498
2934
  });
3499
2935
 
3500
- define('cordova/plugin/Media', function(require, exports, module) {
2936
+ // file: lib/common/plugin/Media.js
2937
+ define("cordova/plugin/Media", function(require, exports, module) {
3501
2938
  var utils = require('cordova/utils'),
3502
2939
  exec = require('cordova/exec');
3503
2940
 
@@ -3568,8 +3005,8 @@ Media.get = function(id) {
3568
3005
  /**
3569
3006
  * Start or resume playing audio file.
3570
3007
  */
3571
- Media.prototype.play = function() {
3572
- exec(this.successCallback, this.errorCallback, "Media", "startPlayingAudio", [this.id, this.src]);
3008
+ Media.prototype.play = function(options) {
3009
+ exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
3573
3010
  };
3574
3011
 
3575
3012
  /**
@@ -3675,7 +3112,8 @@ Media.onStatus = function(id, msg, value) {
3675
3112
  }
3676
3113
  else if (msg === Media.MEDIA_ERROR) {
3677
3114
  if (media.errorCallback) {
3678
- media.errorCallback({"code":value});
3115
+ // value should be a MediaError object when msg == MEDIA_ERROR
3116
+ media.errorCallback(value);
3679
3117
  }
3680
3118
  }
3681
3119
  else if (msg === Media.MEDIA_POSITION) {
@@ -3684,16 +3122,16 @@ Media.onStatus = function(id, msg, value) {
3684
3122
  };
3685
3123
 
3686
3124
  module.exports = Media;
3687
-
3688
3125
  });
3689
3126
 
3690
- define('cordova/plugin/MediaError', function(require, exports, module) {
3127
+ // file: lib/common/plugin/MediaError.js
3128
+ define("cordova/plugin/MediaError", function(require, exports, module) {
3691
3129
  /**
3692
3130
  * This class contains information about any Media errors.
3693
3131
  * @constructor
3694
3132
  */
3695
3133
  var MediaError = function(code, msg) {
3696
- this.code = code || null;
3134
+ this.code = (code !== undefined ? code : null);
3697
3135
  this.message = msg || "";
3698
3136
  };
3699
3137
 
@@ -3704,10 +3142,10 @@ MediaError.MEDIA_ERR_DECODE = 3;
3704
3142
  MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
3705
3143
 
3706
3144
  module.exports = MediaError;
3707
-
3708
3145
  });
3709
3146
 
3710
- define('cordova/plugin/MediaFile', function(require, exports, module) {
3147
+ // file: lib/common/plugin/MediaFile.js
3148
+ define("cordova/plugin/MediaFile", function(require, exports, module) {
3711
3149
  var utils = require('cordova/utils'),
3712
3150
  exec = require('cordova/exec'),
3713
3151
  File = require('cordova/plugin/File'),
@@ -3722,25 +3160,26 @@ var utils = require('cordova/utils'),
3722
3160
  * size {Number} size of the file in bytes
3723
3161
  */
3724
3162
  var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
3725
- MediaFile.__super__.constructor.apply(this, arguments);
3163
+ MediaFile.__super__.constructor.apply(this, arguments);
3726
3164
  };
3727
3165
 
3728
3166
  utils.extend(MediaFile, File);
3729
3167
 
3730
3168
  /**
3731
3169
  * Request capture format data for a specific file and type
3732
- *
3170
+ *
3733
3171
  * @param {Function} successCB
3734
3172
  * @param {Function} errorCB
3735
3173
  */
3736
3174
  MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
3737
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
3738
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
3739
- } else {
3740
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
3741
- }
3175
+ if (typeof this.fullPath === "undefined" || this.fullPath === null) {
3176
+ errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
3177
+ } else {
3178
+ exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
3179
+ }
3742
3180
  };
3743
3181
 
3182
+ // TODO: can we axe this?
3744
3183
  /**
3745
3184
  * Casts a PluginResult message property (array of objects) to an array of MediaFile objects
3746
3185
  * (used in Objective-C and Android)
@@ -3748,26 +3187,26 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
3748
3187
  * @param {PluginResult} pluginResult
3749
3188
  */
3750
3189
  MediaFile.cast = function(pluginResult) {
3751
- var mediaFiles = [];
3752
- var i;
3753
- for (i=0; i<pluginResult.message.length; i++) {
3754
- var mediaFile = new MediaFile();
3755
- mediaFile.name = pluginResult.message[i].name;
3756
- mediaFile.fullPath = pluginResult.message[i].fullPath;
3757
- mediaFile.type = pluginResult.message[i].type;
3758
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
3759
- mediaFile.size = pluginResult.message[i].size;
3760
- mediaFiles.push(mediaFile);
3761
- }
3762
- pluginResult.message = mediaFiles;
3763
- return pluginResult;
3190
+ var mediaFiles = [];
3191
+ for (var i=0; i<pluginResult.message.length; i++) {
3192
+ var mediaFile = new MediaFile();
3193
+ mediaFile.name = pluginResult.message[i].name;
3194
+ mediaFile.fullPath = pluginResult.message[i].fullPath;
3195
+ mediaFile.type = pluginResult.message[i].type;
3196
+ mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
3197
+ mediaFile.size = pluginResult.message[i].size;
3198
+ mediaFiles.push(mediaFile);
3199
+ }
3200
+ pluginResult.message = mediaFiles;
3201
+ return pluginResult;
3764
3202
  };
3765
3203
 
3766
3204
  module.exports = MediaFile;
3767
3205
 
3768
3206
  });
3769
3207
 
3770
- define('cordova/plugin/MediaFileData', function(require, exports, module) {
3208
+ // file: lib/common/plugin/MediaFileData.js
3209
+ define("cordova/plugin/MediaFileData", function(require, exports, module) {
3771
3210
  /**
3772
3211
  * MediaFileData encapsulates format information of a media file.
3773
3212
  *
@@ -3778,21 +3217,21 @@ define('cordova/plugin/MediaFileData', function(require, exports, module) {
3778
3217
  * @param {float} duration
3779
3218
  */
3780
3219
  var MediaFileData = function(codecs, bitrate, height, width, duration){
3781
- this.codecs = codecs || null;
3782
- this.bitrate = bitrate || 0;
3783
- this.height = height || 0;
3784
- this.width = width || 0;
3785
- this.duration = duration || 0;
3220
+ this.codecs = codecs || null;
3221
+ this.bitrate = bitrate || 0;
3222
+ this.height = height || 0;
3223
+ this.width = width || 0;
3224
+ this.duration = duration || 0;
3786
3225
  };
3787
3226
 
3788
3227
  module.exports = MediaFileData;
3789
-
3790
3228
  });
3791
3229
 
3792
- define('cordova/plugin/Metadata', function(require, exports, module) {
3230
+ // file: lib/common/plugin/Metadata.js
3231
+ define("cordova/plugin/Metadata", function(require, exports, module) {
3793
3232
  /**
3794
3233
  * Information about the state of the file or directory
3795
- *
3234
+ *
3796
3235
  * {Date} modificationTime (readonly)
3797
3236
  */
3798
3237
  var Metadata = function(time) {
@@ -3800,144 +3239,22 @@ var Metadata = function(time) {
3800
3239
  };
3801
3240
 
3802
3241
  module.exports = Metadata;
3803
-
3804
- });
3805
-
3806
- define('cordova/plugin/network', function(require, exports, module) {
3807
- var exec = require('cordova/exec'),
3808
- cordova = require('cordova'),
3809
- channel = require('cordova/channel');
3810
-
3811
- var NetworkConnection = function () {
3812
- this.type = null;
3813
- this._firstRun = true;
3814
- this._timer = null;
3815
- this.timeout = 500;
3816
-
3817
- var me = this;
3818
-
3819
- this.getInfo(
3820
- function (info) {
3821
- me.type = info;
3822
- if (info === "none") {
3823
- // set a timer if still offline at the end of timer send the offline event
3824
- me._timer = setTimeout(function(){
3825
- cordova.fireWindowEvent("offline");
3826
- me._timer = null;
3827
- }, me.timeout);
3828
- } else {
3829
- // If there is a current offline event pending clear it
3830
- if (me._timer !== null) {
3831
- clearTimeout(me._timer);
3832
- me._timer = null;
3833
- }
3834
- cordova.fireWindowEvent("online");
3835
- }
3836
-
3837
- // should only fire this once
3838
- if (me._firstRun) {
3839
- me._firstRun = false;
3840
- channel.onCordovaConnectionReady.fire();
3841
- }
3842
- },
3843
- function (e) {
3844
- // If we can't get the network info we should still tell Cordova
3845
- // to fire the deviceready event.
3846
- if (me._firstRun) {
3847
- me._firstRun = false;
3848
- channel.onCordovaConnectionReady.fire();
3849
- }
3850
- console.log("Error initializing Network Connection: " + e);
3851
- });
3852
- };
3853
-
3854
- /**
3855
- * Get connection info
3856
- *
3857
- * @param {Function} successCallback The function to call when the Connection data is available
3858
- * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
3859
- */
3860
- NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
3861
- // Get info
3862
- exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
3863
- };
3864
-
3865
- module.exports = new NetworkConnection();
3866
-
3867
- });
3868
-
3869
- define('cordova/plugin/notification', function(require, exports, module) {
3870
- var exec = require('cordova/exec');
3871
-
3872
- /**
3873
- * Provides access to notifications on the device.
3874
- */
3875
-
3876
- module.exports = {
3877
-
3878
- /**
3879
- * Open a native alert dialog, with a customizable title and button text.
3880
- *
3881
- * @param {String} message Message to print in the body of the alert
3882
- * @param {Function} completeCallback The callback that is called when user clicks on a button.
3883
- * @param {String} title Title of the alert dialog (default: Alert)
3884
- * @param {String} buttonLabel Label of the close button (default: OK)
3885
- */
3886
- alert: function(message, completeCallback, title, buttonLabel) {
3887
- var _title = (title || "Alert");
3888
- var _buttonLabel = (buttonLabel || "OK");
3889
- exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
3890
- },
3891
-
3892
- /**
3893
- * Open a native confirm dialog, with a customizable title and button text.
3894
- * The result that the user selects is returned to the result callback.
3895
- *
3896
- * @param {String} message Message to print in the body of the alert
3897
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
3898
- * @param {String} title Title of the alert dialog (default: Confirm)
3899
- * @param {String} buttonLabels Comma separated list of the labels of the buttons (default: 'OK,Cancel')
3900
- */
3901
- confirm: function(message, resultCallback, title, buttonLabels) {
3902
- var _title = (title || "Confirm");
3903
- var _buttonLabels = (buttonLabels || "OK,Cancel");
3904
- exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
3905
- },
3906
-
3907
- /**
3908
- * Causes the device to vibrate.
3909
- *
3910
- * @param {Integer} mills The number of milliseconds to vibrate for.
3911
- */
3912
- vibrate: function(mills) {
3913
- exec(null, null, "Notification", "vibrate", [mills]);
3914
- },
3915
-
3916
- /**
3917
- * Causes the device to beep.
3918
- * On Android, the default notification ringtone is played "count" times.
3919
- *
3920
- * @param {Integer} count The number of beeps.
3921
- */
3922
- beep: function(count) {
3923
- exec(null, null, "Notification", "beep", [count]);
3924
- }
3925
- };
3926
-
3927
3242
  });
3928
3243
 
3244
+ // file: lib/common/plugin/Position.js
3245
+ define("cordova/plugin/Position", function(require, exports, module) {
3246
+ var Coordinates = require('cordova/plugin/Coordinates');
3929
3247
 
3930
- define('cordova/plugin/Position', function(require, exports, module) {
3931
3248
  var Position = function(coords, timestamp) {
3932
- this.coords = coords;
3933
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
3249
+ this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
3250
+ this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
3934
3251
  };
3935
3252
 
3936
3253
  module.exports = Position;
3937
-
3938
3254
  });
3939
3255
 
3940
- define('cordova/plugin/PositionError', function(require, exports, module) {
3256
+ // file: lib/common/plugin/PositionError.js
3257
+ define("cordova/plugin/PositionError", function(require, exports, module) {
3941
3258
  /**
3942
3259
  * Position error object
3943
3260
  *
@@ -3955,10 +3272,10 @@ PositionError.POSITION_UNAVAILABLE = 2;
3955
3272
  PositionError.TIMEOUT = 3;
3956
3273
 
3957
3274
  module.exports = PositionError;
3958
-
3959
3275
  });
3960
3276
 
3961
- define('cordova/plugin/ProgressEvent', function(require, exports, module) {
3277
+ // file: lib/common/plugin/ProgressEvent.js
3278
+ define("cordova/plugin/ProgressEvent", function(require, exports, module) {
3962
3279
  // If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
3963
3280
  // Feature test: See if we can instantiate a native ProgressEvent;
3964
3281
  // if so, use that approach,
@@ -4005,100 +3322,109 @@ var ProgressEvent = (function() {
4005
3322
  })();
4006
3323
 
4007
3324
  module.exports = ProgressEvent;
4008
-
4009
3325
  });
4010
3326
 
4011
- define('cordova/plugin/requestFileSystem', function(require, exports, module) {
4012
- var FileError = require('cordova/plugin/FileError'),
4013
- FileSystem = require('cordova/plugin/FileSystem'),
4014
- exec = require('cordova/exec');
4015
-
3327
+ // file: lib/common/plugin/accelerometer.js
3328
+ define("cordova/plugin/accelerometer", function(require, exports, module) {
4016
3329
  /**
4017
- * Request a file system in which to store application data.
4018
- * @param type local file system type
4019
- * @param size indicates how much storage space, in bytes, the application expects to need
4020
- * @param successCallback invoked with a FileSystem object
4021
- * @param errorCallback invoked if error occurs retrieving file system
3330
+ * This class provides access to device accelerometer data.
3331
+ * @constructor
4022
3332
  */
4023
- var requestFileSystem = function(type, size, successCallback, errorCallback) {
4024
- var fail = function(code) {
4025
- if (typeof errorCallback === 'function') {
4026
- errorCallback(new FileError(code));
4027
- }
4028
- };
3333
+ var utils = require("cordova/utils"),
3334
+ exec = require("cordova/exec");
4029
3335
 
4030
- if (type < 0 || type > 3) {
4031
- fail(FileError.SYNTAX_ERR);
4032
- } else {
4033
- // if successful, return a FileSystem object
4034
- var success = function(file_system) {
4035
- if (file_system) {
4036
- if (typeof successCallback === 'function') {
4037
- // grab the name and root from the file system object
4038
- var result = new FileSystem(file_system.name, file_system.root);
4039
- successCallback(result);
4040
- }
4041
- }
4042
- else {
4043
- // no FileSystem object returned
4044
- fail(FileError.NOT_FOUND_ERR);
4045
- }
4046
- };
4047
- exec(success, fail, "File", "requestFileSystem", [type, size]);
4048
- }
4049
- };
3336
+ // Local singleton variables.
3337
+ var timers = {};
4050
3338
 
4051
- module.exports = requestFileSystem;
3339
+ var accelerometer = {
3340
+ /**
3341
+ * Asynchronously aquires the current acceleration.
3342
+ *
3343
+ * @param {Function} successCallback The function to call when the acceleration data is available
3344
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
3345
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
3346
+ */
3347
+ getCurrentAcceleration: function(successCallback, errorCallback, options) {
4052
3348
 
4053
- });
3349
+ // successCallback required
3350
+ if (typeof successCallback !== "function") {
3351
+ console.log("Accelerometer Error: successCallback is not a function");
3352
+ return;
3353
+ }
4054
3354
 
4055
- define('cordova/plugin/resolveLocalFileSystemURI', function(require, exports, module) {
4056
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
4057
- FileEntry = require('cordova/plugin/FileEntry'),
4058
- exec = require('cordova/exec');
3355
+ // errorCallback optional
3356
+ if (errorCallback && (typeof errorCallback !== "function")) {
3357
+ console.log("Accelerometer Error: errorCallback is not a function");
3358
+ return;
3359
+ }
4059
3360
 
4060
- /**
4061
- * Look up file system Entry referred to by local URI.
4062
- * @param {DOMString} uri URI referring to a local file or directory
4063
- * @param successCallback invoked with Entry object corresponding to URI
4064
- * @param errorCallback invoked if error occurs retrieving file system entry
4065
- */
4066
- module.exports = function(uri, successCallback, errorCallback) {
4067
- // error callback
4068
- var fail = function(error) {
4069
- if (typeof errorCallback === 'function') {
4070
- errorCallback(new FileError(error));
4071
- }
4072
- };
4073
- // if successful, return either a file or directory entry
4074
- var success = function(entry) {
4075
- var result;
3361
+ // Get acceleration
3362
+ exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
3363
+ },
4076
3364
 
4077
- if (entry) {
4078
- if (typeof successCallback === 'function') {
4079
- // create appropriate Entry object
4080
- result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
4081
- try {
4082
- successCallback(result);
4083
- }
4084
- catch (e) {
4085
- console.log('Error invoking callback: ' + e);
4086
- }
4087
- }
3365
+ /**
3366
+ * Asynchronously aquires the acceleration repeatedly at a given interval.
3367
+ *
3368
+ * @param {Function} successCallback The function to call each time the acceleration data is available
3369
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
3370
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
3371
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
3372
+ */
3373
+ watchAcceleration: function(successCallback, errorCallback, options) {
3374
+
3375
+ // Default interval (10 sec)
3376
+ var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000;
3377
+
3378
+ // successCallback required
3379
+ if (typeof successCallback !== "function") {
3380
+ console.log("Accelerometer Error: successCallback is not a function");
3381
+ return;
4088
3382
  }
4089
- else {
4090
- // no Entry object returned
4091
- fail(FileError.NOT_FOUND_ERR);
3383
+
3384
+ // errorCallback optional
3385
+ if (errorCallback && (typeof errorCallback !== "function")) {
3386
+ console.log("Accelerometer Error: errorCallback is not a function");
3387
+ return;
4092
3388
  }
4093
- };
4094
3389
 
4095
- exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
3390
+ // Make sure accelerometer timeout > frequency + 10 sec
3391
+ exec(
3392
+ function(timeout) {
3393
+ if (timeout < (frequency + 10000)) {
3394
+ exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
3395
+ }
3396
+ },
3397
+ function(e) { }, "Accelerometer", "getTimeout", []);
3398
+
3399
+ // Start watch timer
3400
+ var id = utils.createUUID();
3401
+ timers[id] = window.setInterval(function() {
3402
+ exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
3403
+ }, (frequency ? frequency : 1));
3404
+
3405
+ return id;
3406
+ },
3407
+
3408
+ /**
3409
+ * Clears the specified accelerometer watch.
3410
+ *
3411
+ * @param {String} id The id of the watch returned from #watchAcceleration.
3412
+ */
3413
+ clearWatch: function(id) {
3414
+
3415
+ // Stop javascript timer & remove from timer list
3416
+ if (id && timers[id] !== undefined) {
3417
+ window.clearInterval(timers[id]);
3418
+ delete timers[id];
3419
+ }
3420
+ }
4096
3421
  };
4097
3422
 
3423
+ module.exports = accelerometer;
4098
3424
  });
4099
3425
 
4100
-
4101
- define('cordova/plugin/android/app', function(require, exports, module) {
3426
+ // file: lib/android/plugin/android/app.js
3427
+ define("cordova/plugin/android/app", function(require, exports, module) {
4102
3428
  var exec = require('cordova/exec');
4103
3429
 
4104
3430
  module.exports = {
@@ -4157,7 +3483,7 @@ module.exports = {
4157
3483
  * Note: The user should not have to call this method. Instead, when the user
4158
3484
  * registers for the "backbutton" event, this is automatically done.
4159
3485
  *
4160
- * @param override T=override, F=cancel override
3486
+ * @param override T=override, F=cancel override
4161
3487
  */
4162
3488
  overrideBackbutton:function(override) {
4163
3489
  exec(null, null, "App", "overrideBackbutton", [override]);
@@ -4168,12 +3494,12 @@ module.exports = {
4168
3494
  */
4169
3495
  exitApp:function() {
4170
3496
  return exec(null, null, "App", "exitApp", []);
4171
- }
3497
+ }
4172
3498
  };
4173
-
4174
3499
  });
4175
3500
 
4176
- define('cordova/plugin/android/callback', function(require, exports, module) {
3501
+ // file: lib/android/plugin/android/callback.js
3502
+ define("cordova/plugin/android/callback", function(require, exports, module) {
4177
3503
  var port = null,
4178
3504
  token = null,
4179
3505
  cordova = require('cordova'),
@@ -4259,11 +3585,12 @@ var port = null,
4259
3585
  };
4260
3586
 
4261
3587
  module.exports = callback;
4262
-
4263
3588
  });
4264
3589
 
4265
- define('cordova/plugin/android/device', function(require, exports, module) {
3590
+ // file: lib/android/plugin/android/device.js
3591
+ define("cordova/plugin/android/device", function(require, exports, module) {
4266
3592
  var channel = require('cordova/channel'),
3593
+ utils = require('cordova/utils'),
4267
3594
  exec = require('cordova/exec');
4268
3595
 
4269
3596
  /**
@@ -4280,8 +3607,9 @@ function Device() {
4280
3607
  this.cordova = null;
4281
3608
 
4282
3609
  var me = this;
4283
- this.getInfo(
4284
- function(info) {
3610
+
3611
+ channel.onCordovaReady.subscribeOnce(function() {
3612
+ me.getInfo(function(info) {
4285
3613
  me.available = true;
4286
3614
  me.platform = info.platform;
4287
3615
  me.version = info.version;
@@ -4289,12 +3617,11 @@ function Device() {
4289
3617
  me.uuid = info.uuid;
4290
3618
  me.cordova = info.cordova;
4291
3619
  channel.onCordovaInfoReady.fire();
4292
- },
4293
- function(e) {
3620
+ },function(e) {
4294
3621
  me.available = false;
4295
- console.log("Error initializing Cordova: " + e);
4296
- alert("Error initializing Cordova: "+e);
3622
+ utils.alert("[ERROR] Error initializing Cordova: " + e);
4297
3623
  });
3624
+ });
4298
3625
  }
4299
3626
 
4300
3627
  /**
@@ -4328,8 +3655,8 @@ Device.prototype.getInfo = function(successCallback, errorCallback) {
4328
3655
  * You must explicitly override the back button.
4329
3656
  */
4330
3657
  Device.prototype.overrideBackButton = function() {
4331
- console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
4332
- navigator.app.overrideBackbutton(true);
3658
+ console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
3659
+ navigator.app.overrideBackbutton(true);
4333
3660
  };
4334
3661
 
4335
3662
  /*
@@ -4339,8 +3666,8 @@ Device.prototype.overrideBackButton = function() {
4339
3666
  * This resets the back button to the default behaviour
4340
3667
  */
4341
3668
  Device.prototype.resetBackButton = function() {
4342
- console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
4343
- navigator.app.overrideBackbutton(false);
3669
+ console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
3670
+ navigator.app.overrideBackbutton(false);
4344
3671
  };
4345
3672
 
4346
3673
  /*
@@ -4350,15 +3677,72 @@ Device.prototype.resetBackButton = function() {
4350
3677
  * This terminates the activity!
4351
3678
  */
4352
3679
  Device.prototype.exitApp = function() {
4353
- console.log("Device.exitApp() is deprecated. Use App.exitApp().");
4354
- navigator.app.exitApp();
3680
+ console.log("Device.exitApp() is deprecated. Use App.exitApp().");
3681
+ navigator.app.exitApp();
4355
3682
  };
4356
3683
 
4357
3684
  module.exports = new Device();
3685
+ });
3686
+
3687
+ // file: lib/android/plugin/android/notification.js
3688
+ define("cordova/plugin/android/notification", function(require, exports, module) {
3689
+ var exec = require('cordova/exec');
3690
+
3691
+ /**
3692
+ * Provides Android enhanced notification API.
3693
+ */
3694
+ module.exports = {
3695
+ activityStart : function(title, message) {
3696
+ // If title and message not specified then mimic Android behavior of
3697
+ // using default strings.
3698
+ if (typeof title === "undefined" && typeof message == "undefined") {
3699
+ title = "Busy";
3700
+ message = 'Please wait...';
3701
+ }
3702
+
3703
+ exec(null, null, 'Notification', 'activityStart', [ title, message ]);
3704
+ },
3705
+
3706
+ /**
3707
+ * Close an activity dialog
3708
+ */
3709
+ activityStop : function() {
3710
+ exec(null, null, 'Notification', 'activityStop', []);
3711
+ },
3712
+
3713
+ /**
3714
+ * Display a progress dialog with progress bar that goes from 0 to 100.
3715
+ *
3716
+ * @param {String}
3717
+ * title Title of the progress dialog.
3718
+ * @param {String}
3719
+ * message Message to display in the dialog.
3720
+ */
3721
+ progressStart : function(title, message) {
3722
+ exec(null, null, 'Notification', 'progressStart', [ title, message ]);
3723
+ },
3724
+
3725
+ /**
3726
+ * Close the progress dialog.
3727
+ */
3728
+ progressStop : function() {
3729
+ exec(null, null, 'Notification', 'progressStop', []);
3730
+ },
4358
3731
 
3732
+ /**
3733
+ * Set the progress dialog value.
3734
+ *
3735
+ * @param {Number}
3736
+ * value 0-100
3737
+ */
3738
+ progressValue : function(value) {
3739
+ exec(null, null, 'Notification', 'progressValue', [ value ]);
3740
+ }
3741
+ };
4359
3742
  });
4360
3743
 
4361
- define('cordova/plugin/android/polling', function(require, exports, module) {
3744
+ // file: lib/android/plugin/android/polling.js
3745
+ define("cordova/plugin/android/polling", function(require, exports, module) {
4362
3746
  var cordova = require('cordova'),
4363
3747
  period = 50,
4364
3748
  polling = function() {
@@ -4392,12 +3776,13 @@ var cordova = require('cordova'),
4392
3776
  };
4393
3777
 
4394
3778
  module.exports = polling;
4395
-
4396
3779
  });
4397
3780
 
4398
- define('cordova/plugin/android/storage', function(require, exports, module) {
3781
+ // file: lib/android/plugin/android/storage.js
3782
+ define("cordova/plugin/android/storage", function(require, exports, module) {
4399
3783
  var utils = require('cordova/utils'),
4400
- exec = require('cordova/exec');
3784
+ exec = require('cordova/exec'),
3785
+ channel = require('cordova/channel');
4401
3786
 
4402
3787
  var queryQueue = {};
4403
3788
 
@@ -4609,192 +3994,932 @@ DroidDB_Tx.prototype.queryFailed = function(id, reason) {
4609
3994
  };
4610
3995
 
4611
3996
  /**
4612
- * Execute SQL statement
4613
- *
4614
- * @param sql SQL statement to execute
4615
- * @param params Statement parameters
4616
- * @param successCallback Success callback
4617
- * @param errorCallback Error callback
3997
+ * Execute SQL statement
3998
+ *
3999
+ * @param sql SQL statement to execute
4000
+ * @param params Statement parameters
4001
+ * @param successCallback Success callback
4002
+ * @param errorCallback Error callback
4003
+ */
4004
+ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
4005
+
4006
+ // Init params array
4007
+ if (typeof params === 'undefined') {
4008
+ params = [];
4009
+ }
4010
+
4011
+ // Create query and add to queue
4012
+ var query = new DroidDB_Query(this);
4013
+ queryQueue[query.id] = query;
4014
+
4015
+ // Save callbacks
4016
+ query.successCallback = successCallback;
4017
+ query.errorCallback = errorCallback;
4018
+
4019
+ // Call native code
4020
+ exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
4021
+ };
4022
+
4023
+ var DatabaseShell = function() {
4024
+ };
4025
+
4026
+ /**
4027
+ * Start a transaction.
4028
+ * Does not support rollback in event of failure.
4029
+ *
4030
+ * @param process {Function} The transaction function
4031
+ * @param successCallback {Function}
4032
+ * @param errorCallback {Function}
4033
+ */
4034
+ DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
4035
+ var tx = new DroidDB_Tx();
4036
+ tx.successCallback = successCallback;
4037
+ tx.errorCallback = errorCallback;
4038
+ try {
4039
+ process(tx);
4040
+ } catch (e) {
4041
+ console.log("Transaction error: "+e);
4042
+ if (tx.errorCallback) {
4043
+ try {
4044
+ tx.errorCallback(e);
4045
+ } catch (ex) {
4046
+ console.log("Transaction error calling user error callback: "+e);
4047
+ }
4048
+ }
4049
+ }
4050
+ };
4051
+
4052
+ /**
4053
+ * Open database
4054
+ *
4055
+ * @param name Database name
4056
+ * @param version Database version
4057
+ * @param display_name Database display name
4058
+ * @param size Database size in bytes
4059
+ * @return Database object
4060
+ */
4061
+ var DroidDB_openDatabase = function(name, version, display_name, size) {
4062
+ exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
4063
+ var db = new DatabaseShell();
4064
+ return db;
4065
+ };
4066
+
4067
+ /**
4068
+ * For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
4069
+ * TODO: Do similar for sessionStorage.
4070
+ * @constructor
4071
+ */
4072
+ var CupcakeLocalStorage = function() {
4073
+ channel.waitForInitialization("cupcakeStorage");
4074
+
4075
+ try {
4076
+
4077
+ this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
4078
+ var storage = {};
4079
+ this.length = 0;
4080
+ function setLength (length) {
4081
+ this.length = length;
4082
+ localStorage.length = length;
4083
+ }
4084
+ this.db.transaction(
4085
+ function (transaction) {
4086
+ var i;
4087
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4088
+ transaction.executeSql('SELECT * FROM storage', [], function(tx, result) {
4089
+ for(var i = 0; i < result.rows.length; i++) {
4090
+ storage[result.rows.item(i).id] = result.rows.item(i).body;
4091
+ }
4092
+ setLength(result.rows.length);
4093
+ channel.initializationComplete("cupcakeStorage");
4094
+ });
4095
+
4096
+ },
4097
+ function (err) {
4098
+ utils.alert(err.message);
4099
+ }
4100
+ );
4101
+ this.setItem = function(key, val) {
4102
+ if (typeof(storage[key])=='undefined') {
4103
+ this.length++;
4104
+ }
4105
+ storage[key] = val;
4106
+ this.db.transaction(
4107
+ function (transaction) {
4108
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4109
+ transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key,val]);
4110
+ }
4111
+ );
4112
+ };
4113
+ this.getItem = function(key) {
4114
+ return storage[key];
4115
+ };
4116
+ this.removeItem = function(key) {
4117
+ delete storage[key];
4118
+ this.length--;
4119
+ this.db.transaction(
4120
+ function (transaction) {
4121
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4122
+ transaction.executeSql('DELETE FROM storage where id=?', [key]);
4123
+ }
4124
+ );
4125
+ };
4126
+ this.clear = function() {
4127
+ storage = {};
4128
+ this.length = 0;
4129
+ this.db.transaction(
4130
+ function (transaction) {
4131
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4132
+ transaction.executeSql('DELETE FROM storage', []);
4133
+ }
4134
+ );
4135
+ };
4136
+ this.key = function(index) {
4137
+ var i = 0;
4138
+ for (var j in storage) {
4139
+ if (i==index) {
4140
+ return j;
4141
+ } else {
4142
+ i++;
4143
+ }
4144
+ }
4145
+ return null;
4146
+ };
4147
+
4148
+ } catch(e) {
4149
+ utils.alert("Database error "+e+".");
4150
+ return;
4151
+ }
4152
+ };
4153
+
4154
+ module.exports = {
4155
+ openDatabase:DroidDB_openDatabase,
4156
+ CupcakeLocalStorage:CupcakeLocalStorage,
4157
+ failQuery:failQuery,
4158
+ completeQuery:completeQuery
4159
+ };
4160
+
4161
+ });
4162
+
4163
+ // file: lib/common/plugin/battery.js
4164
+ define("cordova/plugin/battery", function(require, exports, module) {
4165
+ /**
4166
+ * This class contains information about the current battery status.
4167
+ * @constructor
4168
+ */
4169
+ var cordova = require('cordova'),
4170
+ exec = require('cordova/exec');
4171
+
4172
+ function handlers() {
4173
+ return battery.channels.batterystatus.numHandlers +
4174
+ battery.channels.batterylow.numHandlers +
4175
+ battery.channels.batterycritical.numHandlers;
4176
+ }
4177
+
4178
+ var Battery = function() {
4179
+ this._level = null;
4180
+ this._isPlugged = null;
4181
+ // Create new event handlers on the window (returns a channel instance)
4182
+ var subscriptionEvents = {
4183
+ onSubscribe:this.onSubscribe,
4184
+ onUnsubscribe:this.onUnsubscribe
4185
+ };
4186
+ this.channels = {
4187
+ batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
4188
+ batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
4189
+ batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
4190
+ };
4191
+ };
4192
+ /**
4193
+ * Event handlers for when callbacks get registered for the battery.
4194
+ * Keep track of how many handlers we have so we can start and stop the native battery listener
4195
+ * appropriately (and hopefully save on battery life!).
4196
+ */
4197
+ Battery.prototype.onSubscribe = function() {
4198
+ var me = battery;
4199
+ // If we just registered the first handler, make sure native listener is started.
4200
+ if (handlers() === 1) {
4201
+ exec(me._status, me._error, "Battery", "start", []);
4202
+ }
4203
+ };
4204
+
4205
+ Battery.prototype.onUnsubscribe = function() {
4206
+ var me = battery;
4207
+
4208
+ // If we just unregistered the last handler, make sure native listener is stopped.
4209
+ if (handlers() === 0) {
4210
+ exec(null, null, "Battery", "stop", []);
4211
+ }
4212
+ };
4213
+
4214
+ /**
4215
+ * Callback for battery status
4216
+ *
4217
+ * @param {Object} info keys: level, isPlugged
4218
+ */
4219
+ Battery.prototype._status = function(info) {
4220
+ if (info) {
4221
+ var me = battery;
4222
+ var level = info.level;
4223
+ if (me._level !== level || me._isPlugged !== info.isPlugged) {
4224
+ // Fire batterystatus event
4225
+ cordova.fireWindowEvent("batterystatus", info);
4226
+
4227
+ // Fire low battery event
4228
+ if (level === 20 || level === 5) {
4229
+ if (level === 20) {
4230
+ cordova.fireWindowEvent("batterylow", info);
4231
+ }
4232
+ else {
4233
+ cordova.fireWindowEvent("batterycritical", info);
4234
+ }
4235
+ }
4236
+ }
4237
+ me._level = level;
4238
+ me._isPlugged = info.isPlugged;
4239
+ }
4240
+ };
4241
+
4242
+ /**
4243
+ * Error callback for battery start
4244
+ */
4245
+ Battery.prototype._error = function(e) {
4246
+ console.log("Error initializing Battery: " + e);
4247
+ };
4248
+
4249
+ var battery = new Battery();
4250
+
4251
+ module.exports = battery;
4252
+ });
4253
+
4254
+ // file: lib/common/plugin/capture.js
4255
+ define("cordova/plugin/capture", function(require, exports, module) {
4256
+ var exec = require('cordova/exec'),
4257
+ MediaFile = require('cordova/plugin/MediaFile');
4258
+
4259
+ /**
4260
+ * Launches a capture of different types.
4261
+ *
4262
+ * @param (DOMString} type
4263
+ * @param {Function} successCB
4264
+ * @param {Function} errorCB
4265
+ * @param {CaptureVideoOptions} options
4266
+ */
4267
+ function _capture(type, successCallback, errorCallback, options) {
4268
+ var win = function(pluginResult) {
4269
+ var mediaFiles = [];
4270
+ var i;
4271
+ for (i = 0; i < pluginResult.length; i++) {
4272
+ var mediaFile = new MediaFile();
4273
+ mediaFile.name = pluginResult[i].name;
4274
+ mediaFile.fullPath = pluginResult[i].fullPath;
4275
+ mediaFile.type = pluginResult[i].type;
4276
+ mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
4277
+ mediaFile.size = pluginResult[i].size;
4278
+ mediaFiles.push(mediaFile);
4279
+ }
4280
+ successCallback(mediaFiles);
4281
+ };
4282
+ exec(win, errorCallback, "Capture", type, [options]);
4283
+ }
4284
+ /**
4285
+ * The Capture interface exposes an interface to the camera and microphone of the hosting device.
4286
+ */
4287
+ function Capture() {
4288
+ this.supportedAudioModes = [];
4289
+ this.supportedImageModes = [];
4290
+ this.supportedVideoModes = [];
4291
+ }
4292
+
4293
+ /**
4294
+ * Launch audio recorder application for recording audio clip(s).
4295
+ *
4296
+ * @param {Function} successCB
4297
+ * @param {Function} errorCB
4298
+ * @param {CaptureAudioOptions} options
4299
+ */
4300
+ Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
4301
+ _capture("captureAudio", successCallback, errorCallback, options);
4302
+ };
4303
+
4304
+ /**
4305
+ * Launch camera application for taking image(s).
4306
+ *
4307
+ * @param {Function} successCB
4308
+ * @param {Function} errorCB
4309
+ * @param {CaptureImageOptions} options
4310
+ */
4311
+ Capture.prototype.captureImage = function(successCallback, errorCallback, options){
4312
+ _capture("captureImage", successCallback, errorCallback, options);
4313
+ };
4314
+
4315
+ /**
4316
+ * Launch device camera application for recording video(s).
4317
+ *
4318
+ * @param {Function} successCB
4319
+ * @param {Function} errorCB
4320
+ * @param {CaptureVideoOptions} options
4321
+ */
4322
+ Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
4323
+ _capture("captureVideo", successCallback, errorCallback, options);
4324
+ };
4325
+
4326
+
4327
+ module.exports = new Capture();
4328
+
4329
+ });
4330
+
4331
+ // file: lib/common/plugin/compass.js
4332
+ define("cordova/plugin/compass", function(require, exports, module) {
4333
+ var exec = require('cordova/exec'),
4334
+ utils = require('cordova/utils'),
4335
+ CompassHeading = require('cordova/plugin/CompassHeading'),
4336
+ CompassError = require('cordova/plugin/CompassError'),
4337
+ timers = {},
4338
+ compass = {
4339
+ /**
4340
+ * Asynchronously acquires the current heading.
4341
+ * @param {Function} successCallback The function to call when the heading
4342
+ * data is available
4343
+ * @param {Function} errorCallback The function to call when there is an error
4344
+ * getting the heading data.
4345
+ * @param {CompassOptions} options The options for getting the heading data (not used).
4346
+ */
4347
+ getCurrentHeading:function(successCallback, errorCallback, options) {
4348
+ // successCallback required
4349
+ if (typeof successCallback !== "function") {
4350
+ console.log("Compass Error: successCallback is not a function");
4351
+ return;
4352
+ }
4353
+
4354
+ // errorCallback optional
4355
+ if (errorCallback && (typeof errorCallback !== "function")) {
4356
+ console.log("Compass Error: errorCallback is not a function");
4357
+ return;
4358
+ }
4359
+
4360
+ var win = function(result) {
4361
+ var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
4362
+ successCallback(ch);
4363
+ };
4364
+ var fail = function(code) {
4365
+ var ce = new CompassError(code);
4366
+ errorCallback(ce);
4367
+ };
4368
+
4369
+ // Get heading
4370
+ exec(win, fail, "Compass", "getHeading", [options]);
4371
+ },
4372
+
4373
+ /**
4374
+ * Asynchronously acquires the heading repeatedly at a given interval.
4375
+ * @param {Function} successCallback The function to call each time the heading
4376
+ * data is available
4377
+ * @param {Function} errorCallback The function to call when there is an error
4378
+ * getting the heading data.
4379
+ * @param {HeadingOptions} options The options for getting the heading data
4380
+ * such as timeout and the frequency of the watch. For iOS, filter parameter
4381
+ * specifies to watch via a distance filter rather than time.
4382
+ */
4383
+ watchHeading:function(successCallback, errorCallback, options) {
4384
+ // Default interval (100 msec)
4385
+ var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
4386
+ var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
4387
+
4388
+ // successCallback required
4389
+ if (typeof successCallback !== "function") {
4390
+ console.log("Compass Error: successCallback is not a function");
4391
+ return;
4392
+ }
4393
+
4394
+ // errorCallback optional
4395
+ if (errorCallback && (typeof errorCallback !== "function")) {
4396
+ console.log("Compass Error: errorCallback is not a function");
4397
+ return;
4398
+ }
4399
+
4400
+ var id = utils.createUUID();
4401
+ if (filter > 0) {
4402
+ // is an iOS request for watch by filter, no timer needed
4403
+ timers[id] = "iOS";
4404
+ compass.getCurrentHeading(successCallback, errorCallback, options);
4405
+ } else {
4406
+ // Start watch timer to get headings
4407
+ timers[id] = window.setInterval(function() {
4408
+ compass.getCurrentHeading(successCallback, errorCallback);
4409
+ }, frequency);
4410
+ }
4411
+
4412
+ return id;
4413
+ },
4414
+
4415
+ /**
4416
+ * Clears the specified heading watch.
4417
+ * @param {String} watchId The ID of the watch returned from #watchHeading.
4418
+ */
4419
+ clearWatch:function(id) {
4420
+ // Stop javascript timer & remove from timer list
4421
+ if (id && timers[id]) {
4422
+ if (timers[id] != "iOS") {
4423
+ clearInterval(timers[id]);
4424
+ } else {
4425
+ // is iOS watch by filter so call into device to stop
4426
+ exec(null, null, "Compass", "stopHeading", []);
4427
+ }
4428
+ delete timers[id];
4429
+ }
4430
+ }
4431
+ };
4432
+
4433
+ module.exports = compass;
4434
+ });
4435
+
4436
+ // file: lib/common/plugin/contacts.js
4437
+ define("cordova/plugin/contacts", function(require, exports, module) {
4438
+ var exec = require('cordova/exec'),
4439
+ ContactError = require('cordova/plugin/ContactError'),
4440
+ utils = require('cordova/utils'),
4441
+ Contact = require('cordova/plugin/Contact');
4442
+
4443
+ /**
4444
+ * Represents a group of Contacts.
4445
+ * @constructor
4446
+ */
4447
+ var contacts = {
4448
+ /**
4449
+ * Returns an array of Contacts matching the search criteria.
4450
+ * @param fields that should be searched
4451
+ * @param successCB success callback
4452
+ * @param errorCB error callback
4453
+ * @param {ContactFindOptions} options that can be applied to contact searching
4454
+ * @return array of Contacts matching search criteria
4455
+ */
4456
+ find:function(fields, successCB, errorCB, options) {
4457
+ if (!successCB) {
4458
+ throw new TypeError("You must specify a success callback for the find command.");
4459
+ }
4460
+ if (!fields || (utils.isArray(fields) && fields.length === 0)) {
4461
+ if (typeof errorCB === "function") {
4462
+ errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
4463
+ }
4464
+ } else {
4465
+ var win = function(result) {
4466
+ var cs = [];
4467
+ for (var i = 0, l = result.length; i < l; i++) {
4468
+ cs.push(contacts.create(result[i]));
4469
+ }
4470
+ successCB(cs);
4471
+ };
4472
+ exec(win, errorCB, "Contacts", "search", [fields, options]);
4473
+ }
4474
+ },
4475
+
4476
+ /**
4477
+ * This function creates a new contact, but it does not persist the contact
4478
+ * to device storage. To persist the contact to device storage, invoke
4479
+ * contact.save().
4480
+ * @param properties an object who's properties will be examined to create a new Contact
4481
+ * @returns new Contact object
4482
+ */
4483
+ create:function(properties) {
4484
+ var i;
4485
+ var contact = new Contact();
4486
+ for (i in properties) {
4487
+ if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
4488
+ contact[i] = properties[i];
4489
+ }
4490
+ }
4491
+ return contact;
4492
+ }
4493
+ };
4494
+
4495
+ module.exports = contacts;
4496
+
4497
+ });
4498
+
4499
+ // file: lib/common/plugin/geolocation.js
4500
+ define("cordova/plugin/geolocation", function(require, exports, module) {
4501
+ var utils = require('cordova/utils'),
4502
+ exec = require('cordova/exec'),
4503
+ PositionError = require('cordova/plugin/PositionError'),
4504
+ Position = require('cordova/plugin/Position');
4505
+
4506
+ var timers = {}; // list of timers in use
4507
+
4508
+ // Returns default params, overrides if provided with values
4509
+ function parseParameters(options) {
4510
+ var opt = {
4511
+ maximumAge: 10000,
4512
+ enableHighAccuracy: false,
4513
+ timeout: 10000
4514
+ };
4515
+
4516
+ if (options) {
4517
+ if (options.maximumAge !== undefined) {
4518
+ opt.maximumAge = options.maximumAge;
4519
+ }
4520
+ if (options.enableHighAccuracy !== undefined) {
4521
+ opt.enableHighAccuracy = options.enableHighAccuracy;
4522
+ }
4523
+ if (options.timeout !== undefined) {
4524
+ opt.timeout = options.timeout;
4525
+ }
4526
+ }
4527
+
4528
+ return opt;
4529
+ }
4530
+
4531
+ var geolocation = {
4532
+ /**
4533
+ * Asynchronously aquires the current position.
4534
+ *
4535
+ * @param {Function} successCallback The function to call when the position data is available
4536
+ * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
4537
+ * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
4538
+ */
4539
+ getCurrentPosition:function(successCallback, errorCallback, options) {
4540
+ options = parseParameters(options);
4541
+
4542
+ var win = function(p) {
4543
+ successCallback(new Position(
4544
+ {
4545
+ latitude:p.latitude,
4546
+ longitude:p.longitude,
4547
+ altitude:p.altitude,
4548
+ accuracy:p.accuracy,
4549
+ heading:p.heading,
4550
+ velocity:p.velocity,
4551
+ altitudeAccuracy:p.altitudeAccuracy
4552
+ },
4553
+ p.timestamp || new Date()
4554
+ ));
4555
+ };
4556
+ var fail = function(e) {
4557
+ errorCallback(new PositionError(e.code, e.message));
4558
+ };
4559
+
4560
+ exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.timeout, options.maximumAge]);
4561
+ },
4562
+ /**
4563
+ * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
4564
+ * the successCallback is called with the new location.
4565
+ *
4566
+ * @param {Function} successCallback The function to call each time the location data is available
4567
+ * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
4568
+ * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
4569
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
4570
+ */
4571
+ watchPosition:function(successCallback, errorCallback, options) {
4572
+ options = parseParameters(options);
4573
+
4574
+ var id = utils.createUUID();
4575
+ timers[id] = window.setInterval(function() {
4576
+ geolocation.getCurrentPosition(successCallback, errorCallback, options);
4577
+ }, options.timeout);
4578
+
4579
+ return id;
4580
+ },
4581
+ /**
4582
+ * Clears the specified heading watch.
4583
+ *
4584
+ * @param {String} id The ID of the watch returned from #watchPosition
4585
+ */
4586
+ clearWatch:function(id) {
4587
+ if (id && timers[id] !== undefined) {
4588
+ window.clearInterval(timers[id]);
4589
+ delete timers[id];
4590
+ }
4591
+ }
4592
+ };
4593
+
4594
+ module.exports = geolocation;
4595
+ });
4596
+
4597
+ // file: lib/common/plugin/network.js
4598
+ define("cordova/plugin/network", function(require, exports, module) {
4599
+ var exec = require('cordova/exec'),
4600
+ cordova = require('cordova'),
4601
+ channel = require('cordova/channel');
4602
+
4603
+ var NetworkConnection = function () {
4604
+ this.type = null;
4605
+ this._firstRun = true;
4606
+ this._timer = null;
4607
+ this.timeout = 500;
4608
+
4609
+ var me = this;
4610
+
4611
+ channel.onCordovaReady.subscribeOnce(function() {
4612
+ me.getInfo(function (info) {
4613
+ me.type = info;
4614
+ if (info === "none") {
4615
+ // set a timer if still offline at the end of timer send the offline event
4616
+ me._timer = setTimeout(function(){
4617
+ cordova.fireDocumentEvent("offline");
4618
+ me._timer = null;
4619
+ }, me.timeout);
4620
+ } else {
4621
+ // If there is a current offline event pending clear it
4622
+ if (me._timer !== null) {
4623
+ clearTimeout(me._timer);
4624
+ me._timer = null;
4625
+ }
4626
+ cordova.fireDocumentEvent("online");
4627
+ }
4628
+
4629
+ // should only fire this once
4630
+ if (me._firstRun) {
4631
+ me._firstRun = false;
4632
+ channel.onCordovaConnectionReady.fire();
4633
+ }
4634
+ },
4635
+ function (e) {
4636
+ // If we can't get the network info we should still tell Cordova
4637
+ // to fire the deviceready event.
4638
+ if (me._firstRun) {
4639
+ me._firstRun = false;
4640
+ channel.onCordovaConnectionReady.fire();
4641
+ }
4642
+ console.log("Error initializing Network Connection: " + e);
4643
+ });
4644
+ });
4645
+ };
4646
+
4647
+ /**
4648
+ * Get connection info
4649
+ *
4650
+ * @param {Function} successCallback The function to call when the Connection data is available
4651
+ * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
4652
+ */
4653
+ NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
4654
+ // Get info
4655
+ exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
4656
+ };
4657
+
4658
+ module.exports = new NetworkConnection();
4659
+ });
4660
+
4661
+ // file: lib/common/plugin/notification.js
4662
+ define("cordova/plugin/notification", function(require, exports, module) {
4663
+ var exec = require('cordova/exec');
4664
+
4665
+ /**
4666
+ * Provides access to notifications on the device.
4667
+ */
4668
+
4669
+ module.exports = {
4670
+
4671
+ /**
4672
+ * Open a native alert dialog, with a customizable title and button text.
4673
+ *
4674
+ * @param {String} message Message to print in the body of the alert
4675
+ * @param {Function} completeCallback The callback that is called when user clicks on a button.
4676
+ * @param {String} title Title of the alert dialog (default: Alert)
4677
+ * @param {String} buttonLabel Label of the close button (default: OK)
4678
+ */
4679
+ alert: function(message, completeCallback, title, buttonLabel) {
4680
+ var _title = (title || "Alert");
4681
+ var _buttonLabel = (buttonLabel || "OK");
4682
+ exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
4683
+ },
4684
+
4685
+ /**
4686
+ * Open a native confirm dialog, with a customizable title and button text.
4687
+ * The result that the user selects is returned to the result callback.
4688
+ *
4689
+ * @param {String} message Message to print in the body of the alert
4690
+ * @param {Function} resultCallback The callback that is called when user clicks on a button.
4691
+ * @param {String} title Title of the alert dialog (default: Confirm)
4692
+ * @param {String} buttonLabels Comma separated list of the labels of the buttons (default: 'OK,Cancel')
4693
+ */
4694
+ confirm: function(message, resultCallback, title, buttonLabels) {
4695
+ var _title = (title || "Confirm");
4696
+ var _buttonLabels = (buttonLabels || "OK,Cancel");
4697
+ exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
4698
+ },
4699
+
4700
+ /**
4701
+ * Causes the device to vibrate.
4702
+ *
4703
+ * @param {Integer} mills The number of milliseconds to vibrate for.
4704
+ */
4705
+ vibrate: function(mills) {
4706
+ exec(null, null, "Notification", "vibrate", [mills]);
4707
+ },
4708
+
4709
+ /**
4710
+ * Causes the device to beep.
4711
+ * On Android, the default notification ringtone is played "count" times.
4712
+ *
4713
+ * @param {Integer} count The number of beeps.
4714
+ */
4715
+ beep: function(count) {
4716
+ exec(null, null, "Notification", "beep", [count]);
4717
+ }
4718
+ };
4719
+ });
4720
+
4721
+ // file: lib/common/plugin/requestFileSystem.js
4722
+ define("cordova/plugin/requestFileSystem", function(require, exports, module) {
4723
+ var FileError = require('cordova/plugin/FileError'),
4724
+ FileSystem = require('cordova/plugin/FileSystem'),
4725
+ exec = require('cordova/exec');
4726
+
4727
+ /**
4728
+ * Request a file system in which to store application data.
4729
+ * @param type local file system type
4730
+ * @param size indicates how much storage space, in bytes, the application expects to need
4731
+ * @param successCallback invoked with a FileSystem object
4732
+ * @param errorCallback invoked if error occurs retrieving file system
4733
+ */
4734
+ var requestFileSystem = function(type, size, successCallback, errorCallback) {
4735
+ var fail = function(code) {
4736
+ if (typeof errorCallback === 'function') {
4737
+ errorCallback(new FileError(code));
4738
+ }
4739
+ };
4740
+
4741
+ if (type < 0 || type > 3) {
4742
+ fail(FileError.SYNTAX_ERR);
4743
+ } else {
4744
+ // if successful, return a FileSystem object
4745
+ var success = function(file_system) {
4746
+ if (file_system) {
4747
+ if (typeof successCallback === 'function') {
4748
+ // grab the name and root from the file system object
4749
+ var result = new FileSystem(file_system.name, file_system.root);
4750
+ successCallback(result);
4751
+ }
4752
+ }
4753
+ else {
4754
+ // no FileSystem object returned
4755
+ fail(FileError.NOT_FOUND_ERR);
4756
+ }
4757
+ };
4758
+ exec(success, fail, "File", "requestFileSystem", [type, size]);
4759
+ }
4760
+ };
4761
+
4762
+ module.exports = requestFileSystem;
4763
+ });
4764
+
4765
+ // file: lib/common/plugin/resolveLocalFileSystemURI.js
4766
+ define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
4767
+ var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
4768
+ FileEntry = require('cordova/plugin/FileEntry'),
4769
+ FileError = require('cordova/plugin/FileError'),
4770
+ exec = require('cordova/exec');
4771
+
4772
+ /**
4773
+ * Look up file system Entry referred to by local URI.
4774
+ * @param {DOMString} uri URI referring to a local file or directory
4775
+ * @param successCallback invoked with Entry object corresponding to URI
4776
+ * @param errorCallback invoked if error occurs retrieving file system entry
4618
4777
  */
4619
- DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
4620
-
4621
- // Init params array
4622
- if (typeof params === 'undefined') {
4623
- params = [];
4624
- }
4625
-
4626
- // Create query and add to queue
4627
- var query = new DroidDB_Query(this);
4628
- queryQueue[query.id] = query;
4778
+ module.exports = function(uri, successCallback, errorCallback) {
4779
+ // error callback
4780
+ var fail = function(error) {
4781
+ if (typeof errorCallback === 'function') {
4782
+ errorCallback(new FileError(error));
4783
+ }
4784
+ };
4785
+ // if successful, return either a file or directory entry
4786
+ var success = function(entry) {
4787
+ var result;
4629
4788
 
4630
- // Save callbacks
4631
- query.successCallback = successCallback;
4632
- query.errorCallback = errorCallback;
4789
+ if (entry) {
4790
+ if (typeof successCallback === 'function') {
4791
+ // create appropriate Entry object
4792
+ result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
4793
+ try {
4794
+ successCallback(result);
4795
+ }
4796
+ catch (e) {
4797
+ console.log('Error invoking callback: ' + e);
4798
+ }
4799
+ }
4800
+ }
4801
+ else {
4802
+ // no Entry object returned
4803
+ fail(FileError.NOT_FOUND_ERR);
4804
+ }
4805
+ };
4633
4806
 
4634
- // Call native code
4635
- exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
4807
+ exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
4636
4808
  };
4637
4809
 
4638
- var DatabaseShell = function() {
4639
- };
4810
+ });
4640
4811
 
4641
- /**
4642
- * Start a transaction.
4643
- * Does not support rollback in event of failure.
4644
- *
4645
- * @param process {Function} The transaction function
4646
- * @param successCallback {Function}
4647
- * @param errorCallback {Function}
4648
- */
4649
- DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
4650
- var tx = new DroidDB_Tx();
4651
- tx.successCallback = successCallback;
4652
- tx.errorCallback = errorCallback;
4653
- try {
4654
- process(tx);
4655
- } catch (e) {
4656
- console.log("Transaction error: "+e);
4657
- if (tx.errorCallback) {
4658
- try {
4659
- tx.errorCallback(e);
4660
- } catch (ex) {
4661
- console.log("Transaction error calling user error callback: "+e);
4662
- }
4812
+ // file: lib/common/utils.js
4813
+ define("cordova/utils", function(require, exports, module) {
4814
+ function UUIDcreatePart(length) {
4815
+ var uuidpart = "";
4816
+ for (var i=0; i<length; i++) {
4817
+ var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
4818
+ if (uuidchar.length == 1) {
4819
+ uuidchar = "0" + uuidchar;
4663
4820
  }
4821
+ uuidpart += uuidchar;
4664
4822
  }
4665
- };
4823
+ return uuidpart;
4824
+ }
4666
4825
 
4667
- /**
4668
- * Open database
4669
- *
4670
- * @param name Database name
4671
- * @param version Database version
4672
- * @param display_name Database display name
4673
- * @param size Database size in bytes
4674
- * @return Database object
4675
- */
4676
- var DroidDB_openDatabase = function(name, version, display_name, size) {
4677
- exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
4678
- var db = new DatabaseShell();
4679
- return db;
4680
- };
4826
+ var _self = {
4827
+ isArray:function(a) {
4828
+ return Object.prototype.toString.call(a) == '[object Array]';
4829
+ },
4830
+ isDate:function(d) {
4831
+ return Object.prototype.toString.call(d) == '[object Date]';
4832
+ },
4833
+ /**
4834
+ * Does a deep clone of the object.
4835
+ */
4836
+ clone: function(obj) {
4837
+ if(!obj || typeof obj == 'function' || _self.isDate(obj) || typeof obj != 'object') {
4838
+ return obj;
4839
+ }
4681
4840
 
4682
- /**
4683
- * For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
4684
- * TODO: Do similar for sessionStorage.
4685
- * @constructor
4686
- */
4687
- var CupcakeLocalStorage = function() {
4688
- try {
4841
+ var retVal, i;
4689
4842
 
4690
- this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
4691
- var storage = {};
4692
- this.length = 0;
4693
- function setLength (length) {
4694
- this.length = length;
4695
- localStorage.length = length;
4696
- }
4697
- this.db.transaction(
4698
- function (transaction) {
4699
- var i;
4700
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4701
- transaction.executeSql('SELECT * FROM storage', [], function(tx, result) {
4702
- for(var i = 0; i < result.rows.length; i++) {
4703
- storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
4843
+ if(_self.isArray(obj)){
4844
+ retVal = [];
4845
+ for(i = 0; i < obj.length; ++i){
4846
+ retVal.push(_self.clone(obj[i]));
4704
4847
  }
4705
- setLength(result.rows.length);
4706
- });
4707
-
4708
- },
4709
- function (err) {
4710
- alert(err.message);
4848
+ return retVal;
4711
4849
  }
4712
- );
4713
- this.setItem = function(key, val) {
4714
- if (typeof(storage[key])=='undefined') {
4715
- this.length++;
4850
+
4851
+ retVal = {};
4852
+ for(i in obj){
4853
+ if(!(i in retVal) || retVal[i] != obj[i]) {
4854
+ retVal[i] = _self.clone(obj[i]);
4855
+ }
4716
4856
  }
4717
- storage[key] = val;
4718
- this.db.transaction(
4719
- function (transaction) {
4720
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4721
- transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key,val]);
4722
- }
4723
- );
4724
- };
4725
- this.getItem = function(key) {
4726
- return storage[key];
4727
- };
4728
- this.removeItem = function(key) {
4729
- delete storage[key];
4730
- this.length--;
4731
- this.db.transaction(
4732
- function (transaction) {
4733
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4734
- transaction.executeSql('DELETE FROM storage where id=?', [key]);
4735
- }
4736
- );
4737
- };
4738
- this.clear = function() {
4739
- storage = {};
4740
- this.length = 0;
4741
- this.db.transaction(
4742
- function (transaction) {
4743
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4744
- transaction.executeSql('DELETE FROM storage', []);
4745
- }
4746
- );
4747
- };
4748
- this.key = function(index) {
4749
- var i = 0;
4750
- for (var j in storage) {
4751
- if (i==index) {
4752
- return j;
4753
- } else {
4754
- i++;
4755
- }
4857
+ return retVal;
4858
+ },
4859
+
4860
+ close: function(context, func, params) {
4861
+ if (typeof params == 'undefined') {
4862
+ return function() {
4863
+ return func.apply(context, arguments);
4864
+ };
4865
+ } else {
4866
+ return function() {
4867
+ return func.apply(context, params);
4868
+ };
4756
4869
  }
4757
- return null;
4758
- };
4870
+ },
4759
4871
 
4760
- } catch(e) {
4761
- alert("Database error "+e+".");
4762
- return;
4872
+ /**
4873
+ * Create a UUID
4874
+ */
4875
+ createUUID: function() {
4876
+ return UUIDcreatePart(4) + '-' +
4877
+ UUIDcreatePart(2) + '-' +
4878
+ UUIDcreatePart(2) + '-' +
4879
+ UUIDcreatePart(2) + '-' +
4880
+ UUIDcreatePart(6);
4881
+ },
4882
+
4883
+ /**
4884
+ * Extends a child object from a parent object using classical inheritance
4885
+ * pattern.
4886
+ */
4887
+ extend: (function() {
4888
+ // proxy used to establish prototype chain
4889
+ var F = function() {};
4890
+ // extend Child from Parent
4891
+ return function(Child, Parent) {
4892
+ F.prototype = Parent.prototype;
4893
+ Child.prototype = new F();
4894
+ Child.__super__ = Parent.prototype;
4895
+ Child.prototype.constructor = Child;
4896
+ };
4897
+ }()),
4898
+
4899
+ /**
4900
+ * Alerts a message in any available way: alert or console.log.
4901
+ */
4902
+ alert:function(msg) {
4903
+ if (alert) {
4904
+ alert(msg);
4905
+ } else if (console && console.log) {
4906
+ console.log(msg);
4907
+ }
4763
4908
  }
4764
4909
  };
4765
4910
 
4766
- module.exports = {
4767
- openDatabase:DroidDB_openDatabase,
4768
- CupcakeLocalStorage:CupcakeLocalStorage,
4769
- failQuery:failQuery,
4770
- completeQuery:completeQuery
4771
- };
4911
+ module.exports = _self;
4772
4912
 
4773
4913
  });
4914
+
4915
+
4774
4916
  window.cordova = require('cordova');
4917
+
4918
+ // file: lib/scripts/bootstrap.js
4775
4919
  (function (context) {
4776
4920
  var channel = require("cordova/channel"),
4777
- /**
4778
- * cordova Channels that must fire before "deviceready" is fired.
4779
- */
4780
- deviceReadyChannelsArray = [channel.onCordovaReady, channel.onCordovaInfoReady, channel.onCordovaConnectionReady],
4781
- deviceReadyChannelsMap = {},
4782
4921
  _self = {
4783
4922
  boot: function () {
4784
- //---------------
4785
- // Event handling
4786
- //---------------
4787
-
4788
- /**
4789
- * Listen for DOMContentLoaded and notify our channel subscribers.
4790
- */
4791
- document.addEventListener('DOMContentLoaded', function() {
4792
- channel.onDOMContentLoaded.fire();
4793
- }, false);
4794
- if (document.readyState == 'complete') {
4795
- channel.onDOMContentLoaded.fire();
4796
- }
4797
-
4798
4923
  /**
4799
4924
  * Create all cordova objects once page has fully loaded and native side is ready.
4800
4925
  */
@@ -4806,8 +4931,15 @@ window.cordova = require('cordova');
4806
4931
  // Drop the common globals into the window object, but be nice and don't overwrite anything.
4807
4932
  builder.build(base.objects).intoButDontClobber(window);
4808
4933
 
4809
- // Drop the platform-specific globals into the window object and do it like a honey badger does it.
4810
- builder.build(platform.objects).intoAndClobberTheFOutOf(window);
4934
+ // Drop the platform-specific globals into the window object
4935
+ // and clobber any existing object.
4936
+ builder.build(platform.objects).intoAndClobber(window);
4937
+
4938
+ // Merge the platform-specific overrides/enhancements into
4939
+ // the window object.
4940
+ if (typeof platform.merges !== 'undefined') {
4941
+ builder.build(platform.merges).intoAndMerge(window);
4942
+ }
4811
4943
 
4812
4944
  // Call the platform-specific initialization
4813
4945
  platform.initialize();
@@ -4815,27 +4947,26 @@ window.cordova = require('cordova');
4815
4947
  // Fire event to notify that all objects are created
4816
4948
  channel.onCordovaReady.fire();
4817
4949
 
4818
- // Fire onDeviceReady event once all constructors have run and
4950
+ // Fire onDeviceReady event once all constructors have run and
4819
4951
  // cordova info has been received from native side.
4820
4952
  channel.join(function() {
4821
4953
  channel.onDeviceReady.fire();
4822
-
4823
- // Fire the onresume event, since first one happens before JavaScript is loaded
4824
- channel.onResume.fire();
4825
- }, deviceReadyChannelsArray);
4826
-
4954
+ }, channel.deviceReadyChannelsArray);
4955
+
4827
4956
  }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
4828
4957
  }
4829
4958
  };
4959
+
4830
4960
  // boot up once native side is ready
4831
- channel.onNativeReady.subscribe(_self.boot);
4961
+ channel.onNativeReady.subscribeOnce(_self.boot);
4832
4962
 
4833
4963
  // _nativeReady is global variable that the native side can set
4834
- // to signify that the native code is ready. It is a global since
4964
+ // to signify that the native code is ready. It is a global since
4835
4965
  // it may be called before any cordova JS is ready.
4836
4966
  if (window._nativeReady) {
4837
- channel.onNativeReady.fire();
4967
+ channel.onNativeReady.fire();
4838
4968
  }
4839
4969
 
4840
4970
  }(window));
4841
4971
 
4972
+ })();