kanna 0.0.3 → 0.0.4

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.
@@ -41,8 +41,8 @@ Root
41
41
  ├── js
42
42
  ├── css
43
43
  └── vendor
44
- ├── cordova-2.1.0.js
45
- ├── jquery-1.8.1.min.js
44
+ ├── cordova-2.3.0.js
45
+ ├── jquery-1.8.3.min.js
46
46
  ├── json2.js
47
47
  └── rails_ujs_custom.js
48
48
  ````
@@ -36,6 +36,11 @@ module Kanna
36
36
  gem 'rb-fsevent', require: false
37
37
  end
38
38
  end
39
+
40
+ def copy_kanna_config_file
41
+ copy_file "config/kanna.yml"
42
+ end
43
+
39
44
  private
40
45
 
41
46
  def create_base_dir_and_copy_files(base)
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ #
4
+ # Licensed to the Apache Software Foundation (ASF) under one
5
+ # or more contributor license agreements. See the NOTICE file
6
+ # distributed with this work for additional information
7
+ # regarding copyright ownership. The ASF licenses this file
8
+ # to you under the Apache License, Version 2.0 (the
9
+ # "License"); you may not use this file except in compliance
10
+ # with the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing,
15
+ # software distributed under the License is distributed on an
16
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ # KIND, either express or implied. See the License for the
18
+ # specific language governing permissions and limitations
19
+ # under the License.
20
+ #
21
+ -->
22
+ <cordova>
23
+ <preference name="KeyboardDisplayRequiresUserAction" value="true" />
24
+ <preference name="SuppressesIncrementalRendering" value="false" />
25
+ <preference name="UIWebViewBounce" value="true" />
26
+ <preference name="TopActivityIndicator" value="gray" />
27
+ <preference name="EnableLocation" value="false" />
28
+ <preference name="EnableViewportScale" value="false" />
29
+ <preference name="AutoHideSplashScreen" value="true" />
30
+ <preference name="ShowSplashScreenSpinner" value="true" />
31
+ <preference name="MediaPlaybackRequiresUserAction" value="false" />
32
+ <preference name="AllowInlineMediaPlayback" value="false" />
33
+ <preference name="OpenAllWhitelistURLsInWebView" value="false" />
34
+ <preference name="BackupWebStorage" value="cloud" />
35
+
36
+ <plugins>
37
+ <plugin name="Device" value="CDVDevice" />
38
+ <plugin name="Logger" value="CDVLogger" />
39
+ <plugin name="Compass" value="CDVLocation" />
40
+ <plugin name="Accelerometer" value="CDVAccelerometer" />
41
+ <plugin name="Camera" value="CDVCamera" />
42
+ <plugin name="NetworkStatus" value="CDVConnection" />
43
+ <plugin name="Contacts" value="CDVContacts" />
44
+ <plugin name="Debug Console" value="CDVDebugConsole" />
45
+ <plugin name="Echo" value="CDVEcho" />
46
+ <plugin name="File" value="CDVFile" />
47
+ <plugin name="FileTransfer" value="CDVFileTransfer" />
48
+ <plugin name="Geolocation" value="CDVLocation" />
49
+ <plugin name="Notification" value="CDVNotification" />
50
+ <plugin name="Media" value="CDVSound" />
51
+ <plugin name="Capture" value="CDVCapture" />
52
+ <plugin name="SplashScreen" value="CDVSplashScreen" />
53
+ <plugin name="Battery" value="CDVBattery" />
54
+ <plugin name="Globalization" value="CDVGlobalization" />
55
+ <plugin name="InAppBrowser" value="CDVInAppBrowser" />
56
+ </plugins>
57
+
58
+ <access origin="*" />
59
+ </cordova>
@@ -9,9 +9,9 @@
9
9
  %meta{name: "csrf-token"}
10
10
  %link{rel: "stylesheet", href: "css/application.css"}
11
11
  %body
12
- %script{:charset => "utf-8", :src => "vendor/cordova-2.1.0.js", :type => "text/javascript"}
12
+ %script{:charset => "utf-8", :src => "vendor/cordova-2.3.0.js", :type => "text/javascript"}
13
13
  %script{:charset => "utf-8", :src => "vendor/json2.js", :type => "text/javascript"}
14
- %script{:charset => "utf-8", :src => "vendor/jquery-1.8.1.min.js", :type => "text/javascript"}
14
+ %script{:charset => "utf-8", :src => "vendor/jquery-1.8.3.min.js", :type => "text/javascript"}
15
15
  %script{:charset => "utf-8", :src => "vendor/rails_ujs_custom.js", :type => "text/javascript"}
16
16
  %script{:charset => "utf-8", :src => "js/kanna.js", :type => "text/javascript"}
17
17
  %script{:charset => "utf-8", :src => "js/application.js", :type => "text/javascript"}
@@ -1,6 +1,6 @@
1
- // commit 143f5221a6251c9cbccdedc57005c61551b97f12
1
+ // commit 24d65ab645742e8360c3dd16d7a36411cc3383e0
2
2
 
3
- // File generated at :: Wed Sep 12 2012 15:26:58 GMT-0700 (PDT)
3
+ // File generated at :: Thu Jan 03 2013 16:57:26 GMT-0800 (PST)
4
4
 
5
5
  /*
6
6
  Licensed to the Apache Software Foundation (ASF) under one
@@ -24,11 +24,16 @@
24
24
  ;(function() {
25
25
 
26
26
  // file: lib/scripts/require.js
27
+
27
28
  var require,
28
29
  define;
29
30
 
30
31
  (function () {
31
32
  var modules = {};
33
+ // Stack of moduleIds currently being built.
34
+ var requireStack = [];
35
+ // Map of module ID -> index into requireStack of modules currently being built.
36
+ var inProgressModules = {};
32
37
 
33
38
  function build(module) {
34
39
  var factory = module.factory;
@@ -41,8 +46,21 @@ var require,
41
46
  require = function (id) {
42
47
  if (!modules[id]) {
43
48
  throw "module " + id + " not found";
49
+ } else if (id in inProgressModules) {
50
+ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
51
+ throw "Cycle in require graph: " + cycle;
52
+ }
53
+ if (modules[id].factory) {
54
+ try {
55
+ inProgressModules[id] = requireStack.length;
56
+ requireStack.push(id);
57
+ return build(modules[id]);
58
+ } finally {
59
+ delete inProgressModules[id];
60
+ requireStack.pop();
61
+ }
44
62
  }
45
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
63
+ return modules[id].exports;
46
64
  };
47
65
 
48
66
  define = function (id, factory) {
@@ -67,8 +85,11 @@ if (typeof module === "object" && typeof require === "function") {
67
85
  module.exports.require = require;
68
86
  module.exports.define = define;
69
87
  }
88
+
70
89
  // file: lib/cordova.js
71
90
  define("cordova", function(require, exports, module) {
91
+
92
+
72
93
  var channel = require('cordova/channel');
73
94
 
74
95
  /**
@@ -99,11 +120,7 @@ var documentEventHandlers = {},
99
120
  document.addEventListener = function(evt, handler, capture) {
100
121
  var e = evt.toLowerCase();
101
122
  if (typeof documentEventHandlers[e] != 'undefined') {
102
- if (evt === 'deviceready') {
103
- documentEventHandlers[e].subscribeOnce(handler);
104
- } else {
105
- documentEventHandlers[e].subscribe(handler);
106
- }
123
+ documentEventHandlers[e].subscribe(handler);
107
124
  } else {
108
125
  m_document_addEventListener.call(document, evt, handler, capture);
109
126
  }
@@ -120,7 +137,7 @@ window.addEventListener = function(evt, handler, capture) {
120
137
 
121
138
  document.removeEventListener = function(evt, handler, capture) {
122
139
  var e = evt.toLowerCase();
123
- // If unsubcribing from an event that is handled by a plugin
140
+ // If unsubscribing from an event that is handled by a plugin
124
141
  if (typeof documentEventHandlers[e] != "undefined") {
125
142
  documentEventHandlers[e].unsubscribe(handler);
126
143
  } else {
@@ -130,7 +147,7 @@ document.removeEventListener = function(evt, handler, capture) {
130
147
 
131
148
  window.removeEventListener = function(evt, handler, capture) {
132
149
  var e = evt.toLowerCase();
133
- // If unsubcribing from an event that is handled by a plugin
150
+ // If unsubscribing from an event that is handled by a plugin
134
151
  if (typeof windowEventHandlers[e] != "undefined") {
135
152
  windowEventHandlers[e].unsubscribe(handler);
136
153
  } else {
@@ -163,11 +180,14 @@ var cordova = {
163
180
  /**
164
181
  * Methods to add/remove your own addEventListener hijacking on document + window.
165
182
  */
166
- addWindowEventHandler:function(event, opts) {
167
- return (windowEventHandlers[event] = channel.create(event, opts));
183
+ addWindowEventHandler:function(event) {
184
+ return (windowEventHandlers[event] = channel.create(event));
185
+ },
186
+ addStickyDocumentEventHandler:function(event) {
187
+ return (documentEventHandlers[event] = channel.createSticky(event));
168
188
  },
169
- addDocumentEventHandler:function(event, opts) {
170
- return (documentEventHandlers[event] = channel.create(event, opts));
189
+ addDocumentEventHandler:function(event) {
190
+ return (documentEventHandlers[event] = channel.create(event));
171
191
  },
172
192
  removeWindowEventHandler:function(event) {
173
193
  delete windowEventHandlers[event];
@@ -176,7 +196,7 @@ var cordova = {
176
196
  delete documentEventHandlers[event];
177
197
  },
178
198
  /**
179
- * Retreive original event handlers that were replaced by Cordova
199
+ * Retrieve original event handlers that were replaced by Cordova
180
200
  *
181
201
  * @return object
182
202
  */
@@ -186,7 +206,7 @@ var cordova = {
186
206
  },
187
207
  /**
188
208
  * Method to fire event from native code
189
- * bNoDetach is required for events which cause an exception which needs to be caught in native code
209
+ * bNoDetach is required for events which cause an exception which needs to be caught in native code
190
210
  */
191
211
  fireDocumentEvent: function(type, data, bNoDetach) {
192
212
  var evt = createEvent(type, data);
@@ -214,18 +234,12 @@ var cordova = {
214
234
  }
215
235
  },
216
236
 
217
- // TODO: iOS only
218
- // This queue holds the currently executing command and all pending
219
- // commands executed with cordova.exec().
220
- commandQueue:[],
221
- // Indicates if we're currently in the middle of flushing the command
222
- // queue on the native side.
223
- commandQueueFlushing:false,
224
- // END TODO
225
237
  /**
226
238
  * Plugin callback mechanism.
227
239
  */
228
- callbackId: 0,
240
+ // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
241
+ // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
242
+ callbackId: Math.floor(Math.random() * 2000000000),
229
243
  callbacks: {},
230
244
  callbackStatus: {
231
245
  NO_RESULT: 0,
@@ -242,57 +256,48 @@ var cordova = {
242
256
 
243
257
  /**
244
258
  * Called by native code when returning successful result from an action.
245
- *
246
- * @param callbackId
247
- * @param args
248
259
  */
249
260
  callbackSuccess: function(callbackId, args) {
250
- if (cordova.callbacks[callbackId]) {
251
-
252
- // If result is to be sent to callback
253
- if (args.status == cordova.callbackStatus.OK) {
254
- try {
255
- if (cordova.callbacks[callbackId].success) {
256
- cordova.callbacks[callbackId].success(args.message);
257
- }
258
- }
259
- catch (e) {
260
- console.log("Error in success callback: "+callbackId+" = "+e);
261
- }
262
- }
263
-
264
- // Clear callback if not expecting any more results
265
- if (!args.keepCallback) {
266
- delete cordova.callbacks[callbackId];
267
- }
261
+ try {
262
+ cordova.callbackFromNative(callbackId, true, args.status, args.message, args.keepCallback);
263
+ } catch (e) {
264
+ console.log("Error in error callback: " + callbackId + " = "+e);
268
265
  }
269
266
  },
270
267
 
271
268
  /**
272
269
  * Called by native code when returning error result from an action.
273
- *
274
- * @param callbackId
275
- * @param args
276
270
  */
277
271
  callbackError: function(callbackId, args) {
278
- if (cordova.callbacks[callbackId]) {
279
- try {
280
- if (cordova.callbacks[callbackId].fail) {
281
- cordova.callbacks[callbackId].fail(args.message);
282
- }
283
- }
284
- catch (e) {
285
- console.log("Error in error callback: "+callbackId+" = "+e);
272
+ // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
273
+ // Derive success from status.
274
+ try {
275
+ cordova.callbackFromNative(callbackId, false, args.status, args.message, args.keepCallback);
276
+ } catch (e) {
277
+ console.log("Error in error callback: " + callbackId + " = "+e);
278
+ }
279
+ },
280
+
281
+ /**
282
+ * Called by native code when returning the result from an action.
283
+ */
284
+ callbackFromNative: function(callbackId, success, status, message, keepCallback) {
285
+ var callback = cordova.callbacks[callbackId];
286
+ if (callback) {
287
+ if (success && status == cordova.callbackStatus.OK) {
288
+ callback.success && callback.success(message);
289
+ } else if (!success) {
290
+ callback.fail && callback.fail(message);
286
291
  }
287
292
 
288
293
  // Clear callback if not expecting any more results
289
- if (!args.keepCallback) {
294
+ if (!keepCallback) {
290
295
  delete cordova.callbacks[callbackId];
291
296
  }
292
297
  }
293
298
  },
294
299
  addConstructor: function(func) {
295
- channel.onCordovaReady.subscribeOnce(function() {
300
+ channel.onCordovaReady.subscribe(function() {
296
301
  try {
297
302
  func();
298
303
  } catch(e) {
@@ -305,14 +310,74 @@ var cordova = {
305
310
  // Register pause, resume and deviceready channels as events on document.
306
311
  channel.onPause = cordova.addDocumentEventHandler('pause');
307
312
  channel.onResume = cordova.addDocumentEventHandler('resume');
308
- channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
313
+ channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
309
314
 
310
315
  module.exports = cordova;
311
316
 
317
+ });
318
+
319
+ // file: lib/common/argscheck.js
320
+ define("cordova/argscheck", function(require, exports, module) {
321
+
322
+ var exec = require('cordova/exec');
323
+ var moduleExports = module.exports;
324
+
325
+ var typeMap = {
326
+ 'A': 'Array',
327
+ 'D': 'Date',
328
+ 'N': 'Number',
329
+ 'S': 'String',
330
+ 'F': 'Function',
331
+ 'O': 'Object'
332
+ };
333
+
334
+ function extractParamName(callee, argIndex) {
335
+ return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex];
336
+ }
337
+
338
+ function checkArgs(spec, functionName, args, opt_callee) {
339
+ if (!moduleExports.enableChecks) {
340
+ return;
341
+ }
342
+ var errMsg = null;
343
+ var type;
344
+ for (var i = 0; i < spec.length; ++i) {
345
+ var c = spec.charAt(i),
346
+ cUpper = c.toUpperCase(),
347
+ arg = args[i];
348
+ // Asterix means allow anything.
349
+ if (c == '*') {
350
+ continue;
351
+ }
352
+ type = Object.prototype.toString.call(arg).slice(8, -1);
353
+ if ((arg === null || arg === undefined) && c == cUpper) {
354
+ continue;
355
+ }
356
+ if (type != typeMap[cUpper]) {
357
+ errMsg = 'Expected ' + typeMap[cUpper];
358
+ break;
359
+ }
360
+ }
361
+ if (errMsg) {
362
+ errMsg += ', but got ' + type + '.';
363
+ errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
364
+ // Don't log when running jake test.
365
+ if (typeof jasmine == 'undefined') {
366
+ console.error(errMsg);
367
+ }
368
+ throw TypeError(errMsg);
369
+ }
370
+ }
371
+
372
+ moduleExports.checkArgs = checkArgs;
373
+ moduleExports.enableChecks = true;
374
+
375
+
312
376
  });
313
377
 
314
378
  // file: lib/common/builder.js
315
379
  define("cordova/builder", function(require, exports, module) {
380
+
316
381
  var utils = require('cordova/utils');
317
382
 
318
383
  function each(objects, func, context) {
@@ -323,6 +388,27 @@ function each(objects, func, context) {
323
388
  }
324
389
  }
325
390
 
391
+ function clobber(obj, key, value) {
392
+ obj[key] = value;
393
+ // Getters can only be overridden by getters.
394
+ if (obj[key] !== value) {
395
+ utils.defineGetter(obj, key, function() {
396
+ return value;
397
+ });
398
+ }
399
+ }
400
+
401
+ function assignOrWrapInDeprecateGetter(obj, key, value, message) {
402
+ if (message) {
403
+ utils.defineGetter(obj, key, function() {
404
+ console.log(message);
405
+ return value;
406
+ });
407
+ } else {
408
+ clobber(obj, key, value);
409
+ }
410
+ }
411
+
326
412
  function include(parent, objects, clobber, merge) {
327
413
  each(objects, function (obj, key) {
328
414
  try {
@@ -331,20 +417,20 @@ function include(parent, objects, clobber, merge) {
331
417
  if (clobber) {
332
418
  // Clobber if it doesn't exist.
333
419
  if (typeof parent[key] === 'undefined') {
334
- parent[key] = result;
420
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
335
421
  } else if (typeof obj.path !== 'undefined') {
336
422
  // If merging, merge properties onto parent, otherwise, clobber.
337
423
  if (merge) {
338
424
  recursiveMerge(parent[key], result);
339
425
  } else {
340
- parent[key] = result;
426
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
341
427
  }
342
428
  }
343
429
  result = parent[key];
344
430
  } else {
345
431
  // Overwrite if not currently defined.
346
432
  if (typeof parent[key] == 'undefined') {
347
- parent[key] = result;
433
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
348
434
  } else if (merge && typeof obj.path !== 'undefined') {
349
435
  // If merging, merge parent onto result
350
436
  recursiveMerge(result, parent[key]);
@@ -378,8 +464,11 @@ function recursiveMerge(target, src) {
378
464
  // If the target object is a constructor override off prototype.
379
465
  target.prototype[prop] = src[prop];
380
466
  } else {
381
- target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
382
- target[prop], src[prop]) : src[prop];
467
+ if (typeof src[prop] === 'object') {
468
+ target[prop] = recursiveMerge(target[prop], src[prop]);
469
+ } else {
470
+ clobber(target, prop, src[prop]);
471
+ }
383
472
  }
384
473
  }
385
474
  }
@@ -387,18 +476,14 @@ function recursiveMerge(target, src) {
387
476
  }
388
477
 
389
478
  module.exports = {
390
- build: function (objects) {
391
- return {
392
- intoButDontClobber: function (target) {
393
- include(target, objects, false, false);
394
- },
395
- intoAndClobber: function(target) {
396
- include(target, objects, true, false);
397
- },
398
- intoAndMerge: function(target) {
399
- include(target, objects, true, true);
400
- }
401
- };
479
+ buildIntoButDoNotClobber: function(objects, target) {
480
+ include(target, objects, false, false);
481
+ },
482
+ buildIntoAndClobber: function(objects, target) {
483
+ include(target, objects, true, false);
484
+ },
485
+ buildIntoAndMerge: function(objects, target) {
486
+ include(target, objects, true, true);
402
487
  }
403
488
  };
404
489
 
@@ -406,25 +491,29 @@ module.exports = {
406
491
 
407
492
  // file: lib/common/channel.js
408
493
  define("cordova/channel", function(require, exports, module) {
494
+
409
495
  var utils = require('cordova/utils'),
410
496
  nextGuid = 1;
411
497
 
412
498
  /**
413
499
  * Custom pub-sub "channel" that can have functions subscribed to it
414
500
  * This object is used to define and control firing of events for
415
- * cordova initialization.
501
+ * cordova initialization, as well as for custom events thereafter.
416
502
  *
417
503
  * The order of events during page load and Cordova startup is as follows:
418
504
  *
419
- * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
420
- * onNativeReady Internal event that indicates the Cordova native side is ready.
421
- * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created.
422
- * onCordovaInfoReady Internal event fired when device properties are available.
423
- * onCordovaConnectionReady Internal event fired when the connection property has been set.
424
- * onDeviceReady User event fired to indicate that Cordova is ready
425
- * onResume User event fired to indicate a start/resume lifecycle event
426
- * onPause User event fired to indicate a pause lifecycle event
427
- * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
505
+ * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
506
+ * onNativeReady* Internal event that indicates the Cordova native side is ready.
507
+ * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
508
+ * onCordovaInfoReady* Internal event fired when device properties are available.
509
+ * onCordovaConnectionReady* Internal event fired when the connection property has been set.
510
+ * onDeviceReady* User event fired to indicate that Cordova is ready
511
+ * onResume User event fired to indicate a start/resume lifecycle event
512
+ * onPause User event fired to indicate a pause lifecycle event
513
+ * onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
514
+ *
515
+ * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
516
+ * All listeners that subscribe after the event is fired will be executed right away.
428
517
  *
429
518
  * The only Cordova events that user code should register for are:
430
519
  * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
@@ -446,49 +535,45 @@ var utils = require('cordova/utils'),
446
535
  * Channel
447
536
  * @constructor
448
537
  * @param type String the channel name
449
- * @param opts Object options to pass into the channel, currently
450
- * supports:
451
- * onSubscribe: callback that fires when
452
- * something subscribes to the Channel. Sets
453
- * context to the Channel.
454
- * onUnsubscribe: callback that fires when
455
- * something unsubscribes to the Channel. Sets
456
- * context to the Channel.
457
538
  */
458
- var Channel = function(type, opts) {
539
+ var Channel = function(type, sticky) {
459
540
  this.type = type;
541
+ // Map of guid -> function.
460
542
  this.handlers = {};
543
+ // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
544
+ this.state = sticky ? 1 : 0;
545
+ // Used in sticky mode to remember args passed to fire().
546
+ this.fireArgs = null;
547
+ // Used by onHasSubscribersChange to know if there are any listeners.
461
548
  this.numHandlers = 0;
462
- this.fired = false;
463
- this.enabled = true;
464
- this.events = {
465
- onSubscribe:null,
466
- onUnsubscribe:null
467
- };
468
- if (opts) {
469
- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
470
- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
471
- }
549
+ // Function that is called when the first listener is subscribed, or when
550
+ // the last listener is unsubscribed.
551
+ this.onHasSubscribersChange = null;
472
552
  },
473
553
  channel = {
474
554
  /**
475
555
  * Calls the provided function only after all of the channels specified
476
- * have been fired.
556
+ * have been fired. All channels must be sticky channels.
477
557
  */
478
- join: function (h, c) {
479
- var i = c.length;
480
- var len = i;
481
- var f = function() {
482
- if (!(--i)) h();
483
- };
558
+ join: function(h, c) {
559
+ var len = c.length,
560
+ i = len,
561
+ f = function() {
562
+ if (!(--i)) h();
563
+ };
484
564
  for (var j=0; j<len; j++) {
485
- !c[j].fired?c[j].subscribeOnce(f):i--;
565
+ if (c[j].state === 0) {
566
+ throw Error('Can only use join with sticky channels.');
567
+ }
568
+ c[j].subscribe(f);
486
569
  }
487
- if (!i) h();
570
+ if (!len) h();
571
+ },
572
+ create: function(type) {
573
+ return channel[type] = new Channel(type, false);
488
574
  },
489
- create: function (type, opts) {
490
- channel[type] = new Channel(type, opts);
491
- return channel[type];
575
+ createSticky: function(type) {
576
+ return channel[type] = new Channel(type, true);
492
577
  },
493
578
 
494
579
  /**
@@ -506,13 +591,7 @@ var Channel = function(type, opts) {
506
591
  */
507
592
  waitForInitialization: function(feature) {
508
593
  if (feature) {
509
- var c = null;
510
- if (this[feature]) {
511
- c = this[feature];
512
- }
513
- else {
514
- c = this.create(feature);
515
- }
594
+ var c = channel[feature] || this.createSticky(feature);
516
595
  this.deviceReadyChannelsMap[feature] = c;
517
596
  this.deviceReadyChannelsArray.push(c);
518
597
  }
@@ -532,7 +611,7 @@ var Channel = function(type, opts) {
532
611
  };
533
612
 
534
613
  function forceFunction(f) {
535
- if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
614
+ if (typeof f != 'function') throw "Function required as first argument!";
536
615
  }
537
616
 
538
617
  /**
@@ -542,67 +621,50 @@ function forceFunction(f) {
542
621
  * and a guid that can be used to stop subscribing to the channel.
543
622
  * Returns the guid.
544
623
  */
545
- Channel.prototype.subscribe = function(f, c, g) {
624
+ Channel.prototype.subscribe = function(f, c) {
546
625
  // need a function to call
547
626
  forceFunction(f);
627
+ if (this.state == 2) {
628
+ f.apply(c || this, this.fireArgs);
629
+ return;
630
+ }
548
631
 
549
- var func = f;
632
+ var func = f,
633
+ guid = f.observer_guid;
550
634
  if (typeof c == "object") { func = utils.close(c, f); }
551
635
 
552
- g = g || func.observer_guid || f.observer_guid;
553
- if (!g) {
636
+ if (!guid) {
554
637
  // first time any channel has seen this subscriber
555
- g = nextGuid++;
638
+ guid = '' + nextGuid++;
556
639
  }
557
- func.observer_guid = g;
558
- f.observer_guid = g;
640
+ func.observer_guid = guid;
641
+ f.observer_guid = guid;
559
642
 
560
643
  // Don't add the same handler more than once.
561
- if (!this.handlers[g]) {
562
- this.handlers[g] = func;
644
+ if (!this.handlers[guid]) {
645
+ this.handlers[guid] = func;
563
646
  this.numHandlers++;
564
- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
565
- if (this.fired) func.apply(this, this.fireArgs);
566
- }
567
- return g;
568
- };
569
-
570
- /**
571
- * Like subscribe but the function is only called once and then it
572
- * auto-unsubscribes itself.
573
- */
574
- Channel.prototype.subscribeOnce = function(f, c) {
575
- // need a function to call
576
- forceFunction(f);
577
-
578
- var g = null;
579
- var _this = this;
580
- if (this.fired) {
581
- f.apply(c || null, this.fireArgs);
582
- } else {
583
- g = this.subscribe(function() {
584
- _this.unsubscribe(g);
585
- f.apply(c || null, arguments);
586
- });
587
- f.observer_guid = g;
647
+ if (this.numHandlers == 1) {
648
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
649
+ }
588
650
  }
589
- return g;
590
651
  };
591
652
 
592
653
  /**
593
654
  * Unsubscribes the function with the given guid from the channel.
594
655
  */
595
- Channel.prototype.unsubscribe = function(g) {
656
+ Channel.prototype.unsubscribe = function(f) {
596
657
  // need a function to unsubscribe
597
- if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
658
+ forceFunction(f);
598
659
 
599
- if (typeof g == 'function') { g = g.observer_guid; }
600
- var handler = this.handlers[g];
660
+ var guid = f.observer_guid,
661
+ handler = this.handlers[guid];
601
662
  if (handler) {
602
- if (handler.observer_guid) handler.observer_guid=null;
603
- delete this.handlers[g];
663
+ delete this.handlers[guid];
604
664
  this.numHandlers--;
605
- if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
665
+ if (this.numHandlers === 0) {
666
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
667
+ }
606
668
  }
607
669
  };
608
670
 
@@ -610,10 +672,14 @@ Channel.prototype.unsubscribe = function(g) {
610
672
  * Calls all functions subscribed to this channel.
611
673
  */
612
674
  Channel.prototype.fire = function(e) {
613
- if (this.enabled) {
614
- var fail = false;
615
- this.fired = true;
616
- this.fireArgs = arguments;
675
+ var fail = false,
676
+ fireArgs = Array.prototype.slice.call(arguments);
677
+ // Apply stickiness.
678
+ if (this.state == 1) {
679
+ this.state = 2;
680
+ this.fireArgs = fireArgs;
681
+ }
682
+ if (this.numHandlers) {
617
683
  // Copy the values first so that it is safe to modify it from within
618
684
  // callbacks.
619
685
  var toCall = [];
@@ -621,33 +687,36 @@ Channel.prototype.fire = function(e) {
621
687
  toCall.push(this.handlers[item]);
622
688
  }
623
689
  for (var i = 0; i < toCall.length; ++i) {
624
- var rv = (toCall[i].apply(this, arguments)===false);
625
- fail = fail || rv;
690
+ toCall[i].apply(this, fireArgs);
691
+ }
692
+ if (this.state == 2 && this.numHandlers) {
693
+ this.numHandlers = 0;
694
+ this.handlers = {};
695
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
626
696
  }
627
- return !fail;
628
697
  }
629
- return true;
630
698
  };
631
699
 
700
+
632
701
  // defining them here so they are ready super fast!
633
702
  // DOM event that is received when the web page is loaded and parsed.
634
- channel.create('onDOMContentLoaded');
703
+ channel.createSticky('onDOMContentLoaded');
635
704
 
636
705
  // Event to indicate the Cordova native side is ready.
637
- channel.create('onNativeReady');
706
+ channel.createSticky('onNativeReady');
638
707
 
639
708
  // Event to indicate that all Cordova JavaScript objects have been created
640
709
  // and it's time to run plugin constructors.
641
- channel.create('onCordovaReady');
710
+ channel.createSticky('onCordovaReady');
642
711
 
643
712
  // Event to indicate that device properties are available
644
- channel.create('onCordovaInfoReady');
713
+ channel.createSticky('onCordovaInfoReady');
645
714
 
646
715
  // Event to indicate that the connection property has been set.
647
- channel.create('onCordovaConnectionReady');
716
+ channel.createSticky('onCordovaConnectionReady');
648
717
 
649
718
  // Event to indicate that Cordova is ready
650
- channel.create('onDeviceReady');
719
+ channel.createSticky('onDeviceReady');
651
720
 
652
721
  // Event to indicate a resume lifecycle event
653
722
  channel.create('onResume');
@@ -656,7 +725,7 @@ channel.create('onResume');
656
725
  channel.create('onPause');
657
726
 
658
727
  // Event to indicate a destroy lifecycle event
659
- channel.create('onDestroy');
728
+ channel.createSticky('onDestroy');
660
729
 
661
730
  // Channels that must fire before "deviceready" is fired.
662
731
  channel.waitForInitialization('onCordovaReady');
@@ -666,10 +735,41 @@ module.exports = channel;
666
735
 
667
736
  });
668
737
 
738
+ // file: lib/common/commandProxy.js
739
+ define("cordova/commandProxy", function(require, exports, module) {
740
+
741
+
742
+ // internal map of proxy function
743
+ var CommandProxyMap = {};
744
+
745
+ module.exports = {
746
+
747
+ // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
748
+ add:function(id,proxyObj) {
749
+ console.log("adding proxy for " + id);
750
+ CommandProxyMap[id] = proxyObj;
751
+ return proxyObj;
752
+ },
753
+
754
+ // cordova.commandProxy.remove("Accelerometer");
755
+ remove:function(id) {
756
+ var proxy = CommandProxyMap[id];
757
+ delete CommandProxyMap[id];
758
+ CommandProxyMap[id] = null;
759
+ return proxy;
760
+ },
761
+
762
+ get:function(service,action) {
763
+ return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
764
+ }
765
+ };
766
+ });
767
+
669
768
  // file: lib/common/common.js
670
769
  define("cordova/common", function(require, exports, module) {
770
+
671
771
  module.exports = {
672
- objects: {
772
+ defaults: {
673
773
  cordova: {
674
774
  path: 'cordova',
675
775
  children: {
@@ -688,6 +788,9 @@ module.exports = {
688
788
  }
689
789
  }
690
790
  },
791
+ open : {
792
+ path: 'cordova/plugin/InAppBrowser'
793
+ },
691
794
  navigator: {
692
795
  children: {
693
796
  notification: {
@@ -718,10 +821,14 @@ module.exports = {
718
821
  geolocation: {
719
822
  path: 'cordova/plugin/geolocation'
720
823
  },
824
+ globalization: {
825
+ path: 'cordova/plugin/globalization'
826
+ },
721
827
  network: {
722
828
  children: {
723
829
  connection: {
724
- path: 'cordova/plugin/network'
830
+ path: 'cordova/plugin/network',
831
+ deprecated: 'navigator.network.connection is deprecated. Use navigator.connection instead.'
725
832
  }
726
833
  }
727
834
  },
@@ -832,6 +939,9 @@ module.exports = {
832
939
  Flags: {
833
940
  path: 'cordova/plugin/Flags'
834
941
  },
942
+ GlobalizationError: {
943
+ path: 'cordova/plugin/GlobalizationError'
944
+ },
835
945
  LocalFileSystem: {
836
946
  path: 'cordova/plugin/LocalFileSystem'
837
947
  },
@@ -865,6 +975,15 @@ module.exports = {
865
975
  resolveLocalFileSystemURI:{
866
976
  path: 'cordova/plugin/resolveLocalFileSystemURI'
867
977
  }
978
+ },
979
+ clobbers: {
980
+ navigator: {
981
+ children: {
982
+ connection: {
983
+ path: 'cordova/plugin/network'
984
+ }
985
+ }
986
+ }
868
987
  }
869
988
  };
870
989
 
@@ -872,15 +991,15 @@ module.exports = {
872
991
 
873
992
  // file: lib/ios/exec.js
874
993
  define("cordova/exec", function(require, exports, module) {
875
- /**
876
- * Creates a gap bridge iframe used to notify the native code about queued
877
- * commands.
878
- *
879
- * @private
880
- */
994
+
995
+ /**
996
+ * Creates a gap bridge iframe used to notify the native code about queued
997
+ * commands.
998
+ *
999
+ * @private
1000
+ */
881
1001
  var cordova = require('cordova'),
882
1002
  channel = require('cordova/channel'),
883
- nativecomm = require('cordova/plugin/ios/nativecomm'),
884
1003
  utils = require('cordova/utils'),
885
1004
  jsToNativeModes = {
886
1005
  IFRAME_NAV: 0,
@@ -888,12 +1007,13 @@ var cordova = require('cordova'),
888
1007
  XHR_WITH_PAYLOAD: 2,
889
1008
  XHR_OPTIONAL_PAYLOAD: 3
890
1009
  },
891
- // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
892
- // XHR mode's main advantage is working around a bug in -webkit-scroll, which
893
- // doesn't exist in 4.X devices anyways.
894
- bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_NO_PAYLOAD : jsToNativeModes.IFRAME_NAV,
1010
+ bridgeMode,
895
1011
  execIframe,
896
- execXhr;
1012
+ execXhr,
1013
+ requestCount = 0,
1014
+ vcHeaderValue = null,
1015
+ commandQueue = [], // Contains pending JS->Native messages.
1016
+ isInContextOfEvalJs = 0;
897
1017
 
898
1018
  function createExecIframe() {
899
1019
  var iframe = document.createElement("iframe");
@@ -903,13 +1023,13 @@ function createExecIframe() {
903
1023
  }
904
1024
 
905
1025
  function shouldBundleCommandJson() {
906
- if (bridgeMode == 2) {
1026
+ if (bridgeMode == jsToNativeModes.XHR_WITH_PAYLOAD) {
907
1027
  return true;
908
1028
  }
909
- if (bridgeMode == 3) {
1029
+ if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD) {
910
1030
  var payloadLength = 0;
911
- for (var i = 0; i < cordova.commandQueue.length; ++i) {
912
- payloadLength += cordova.commandQueue[i].length;
1031
+ for (var i = 0; i < commandQueue.length; ++i) {
1032
+ payloadLength += commandQueue[i].length;
913
1033
  }
914
1034
  // The value here was determined using the benchmark within CordovaLibApp on an iPad 3.
915
1035
  return payloadLength < 4500;
@@ -918,10 +1038,11 @@ function shouldBundleCommandJson() {
918
1038
  }
919
1039
 
920
1040
  function iOSExec() {
921
- if (!channel.onCordovaReady.fired) {
922
- utils.alert("ERROR: Attempting to call cordova.exec()" +
923
- " before 'deviceready'. Ignoring.");
924
- return;
1041
+ // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
1042
+ // XHR mode's main advantage is working around a bug in -webkit-scroll, which
1043
+ // doesn't exist in 4.X devices anyways.
1044
+ if (bridgeMode === undefined) {
1045
+ bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_NO_PAYLOAD : jsToNativeModes.IFRAME_NAV;
925
1046
  }
926
1047
 
927
1048
  var successCallback, failCallback, service, action, actionArgs, splitCommand;
@@ -960,21 +1081,31 @@ function iOSExec() {
960
1081
  // Stringify and queue the command. We stringify to command now to
961
1082
  // effectively clone the command arguments in case they are mutated before
962
1083
  // the command is executed.
963
- cordova.commandQueue.push(JSON.stringify(command));
964
-
965
- // If the queue length is 1, then that means it was empty before we queued
966
- // the given command, so let the native side know that we have some
967
- // commands to execute, unless the queue is currently being flushed, in
968
- // which case the command will be picked up without notification.
969
- if (cordova.commandQueue.length == 1 && !cordova.commandQueueFlushing) {
970
- if (bridgeMode) {
1084
+ commandQueue.push(JSON.stringify(command));
1085
+
1086
+ // If we're in the context of a stringByEvaluatingJavaScriptFromString call,
1087
+ // then the queue will be flushed when it returns; no need for a poke.
1088
+ // Also, if there is already a command in the queue, then we've already
1089
+ // poked the native side, so there is no reason to do so again.
1090
+ if (!isInContextOfEvalJs && commandQueue.length == 1) {
1091
+ if (bridgeMode != jsToNativeModes.IFRAME_NAV) {
1092
+ // This prevents sending an XHR when there is already one being sent.
1093
+ // This should happen only in rare circumstances (refer to unit tests).
1094
+ if (execXhr && execXhr.readyState != 4) {
1095
+ execXhr = null;
1096
+ }
1097
+ // Re-using the XHR improves exec() performance by about 10%.
971
1098
  execXhr = execXhr || new XMLHttpRequest();
972
- // Changeing this to a GET will make the XHR reach the URIProtocol on 4.2.
1099
+ // Changing this to a GET will make the XHR reach the URIProtocol on 4.2.
973
1100
  // For some reason it still doesn't work though...
974
- execXhr.open('HEAD', "file:///!gap_exec", true);
975
- execXhr.setRequestHeader('vc', cordova.iOSVCAddr);
1101
+ execXhr.open('HEAD', "/!gap_exec", true);
1102
+ if (!vcHeaderValue) {
1103
+ vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
1104
+ }
1105
+ execXhr.setRequestHeader('vc', vcHeaderValue);
1106
+ execXhr.setRequestHeader('rc', ++requestCount);
976
1107
  if (shouldBundleCommandJson()) {
977
- execXhr.setRequestHeader('cmds', nativecomm());
1108
+ execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());
978
1109
  }
979
1110
  execXhr.send(null);
980
1111
  } else {
@@ -997,24 +1128,46 @@ iOSExec.setJsToNativeBridgeMode = function(mode) {
997
1128
  bridgeMode = mode;
998
1129
  };
999
1130
 
1131
+ iOSExec.nativeFetchMessages = function() {
1132
+ // Each entry in commandQueue is a JSON string already.
1133
+ if (!commandQueue.length) {
1134
+ return '';
1135
+ }
1136
+ var json = '[' + commandQueue.join(',') + ']';
1137
+ commandQueue.length = 0;
1138
+ return json;
1139
+ };
1140
+
1141
+ iOSExec.nativeCallback = function(callbackId, status, payload, keepCallback) {
1142
+ return iOSExec.nativeEvalAndFetch(function() {
1143
+ var success = status === 0 || status === 1;
1144
+ cordova.callbackFromNative(callbackId, success, status, payload, keepCallback);
1145
+ });
1146
+ };
1147
+
1148
+ iOSExec.nativeEvalAndFetch = function(func) {
1149
+ // This shouldn't be nested, but better to be safe.
1150
+ isInContextOfEvalJs++;
1151
+ try {
1152
+ func();
1153
+ return iOSExec.nativeFetchMessages();
1154
+ } finally {
1155
+ isInContextOfEvalJs--;
1156
+ }
1157
+ };
1158
+
1000
1159
  module.exports = iOSExec;
1001
1160
 
1002
1161
  });
1003
1162
 
1004
1163
  // file: lib/ios/platform.js
1005
1164
  define("cordova/platform", function(require, exports, module) {
1165
+
1006
1166
  module.exports = {
1007
1167
  id: "ios",
1008
1168
  initialize:function() {
1009
- // iOS doesn't allow reassigning / overriding navigator.geolocation object.
1010
- // So clobber its methods here instead :)
1011
- var geo = require('cordova/plugin/geolocation');
1012
-
1013
- navigator.geolocation.getCurrentPosition = geo.getCurrentPosition;
1014
- navigator.geolocation.watchPosition = geo.watchPosition;
1015
- navigator.geolocation.clearWatch = geo.clearWatch;
1016
1169
  },
1017
- objects: {
1170
+ clobbers: {
1018
1171
  File: { // exists natively, override
1019
1172
  path: "cordova/plugin/File"
1020
1173
  },
@@ -1026,6 +1179,9 @@ module.exports = {
1026
1179
  },
1027
1180
  console: {
1028
1181
  path: 'cordova/plugin/ios/console'
1182
+ },
1183
+ open : {
1184
+ path: 'cordova/plugin/InAppBrowser'
1029
1185
  }
1030
1186
  },
1031
1187
  merges:{
@@ -1045,6 +1201,9 @@ module.exports = {
1045
1201
  },
1046
1202
  contacts:{
1047
1203
  path:"cordova/plugin/ios/contacts"
1204
+ },
1205
+ geolocation: {
1206
+ path: 'cordova/plugin/geolocation'
1048
1207
  }
1049
1208
  }
1050
1209
  }
@@ -1059,6 +1218,7 @@ logger.useConsole(false);
1059
1218
 
1060
1219
  // file: lib/common/plugin/Acceleration.js
1061
1220
  define("cordova/plugin/Acceleration", function(require, exports, module) {
1221
+
1062
1222
  var Acceleration = function(x, y, z, timestamp) {
1063
1223
  this.x = x;
1064
1224
  this.y = y;
@@ -1072,6 +1232,7 @@ module.exports = Acceleration;
1072
1232
 
1073
1233
  // file: lib/common/plugin/Camera.js
1074
1234
  define("cordova/plugin/Camera", function(require, exports, module) {
1235
+
1075
1236
  var exec = require('cordova/exec'),
1076
1237
  Camera = require('cordova/plugin/CameraConstants');
1077
1238
 
@@ -1093,6 +1254,7 @@ for (var key in Camera) {
1093
1254
  * @param {Object} options
1094
1255
  */
1095
1256
  cameraExport.getPicture = function(successCallback, errorCallback, options) {
1257
+ options = options || {};
1096
1258
  // successCallback required
1097
1259
  if (typeof successCallback != "function") {
1098
1260
  console.log("Camera Error: successCallback is not a function");
@@ -1106,9 +1268,9 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) {
1106
1268
  }
1107
1269
 
1108
1270
  var quality = 50;
1109
- if (options && typeof options.quality == "number") {
1271
+ if (typeof options.quality == "number") {
1110
1272
  quality = options.quality;
1111
- } else if (options && typeof options.quality == "string") {
1273
+ } else if (typeof options.quality == "string") {
1112
1274
  var qlity = parseInt(options.quality, 10);
1113
1275
  if (isNaN(qlity) === false) {
1114
1276
  quality = qlity.valueOf();
@@ -1188,10 +1350,12 @@ cameraExport.cleanup = function(successCallback, errorCallback) {
1188
1350
  };
1189
1351
 
1190
1352
  module.exports = cameraExport;
1353
+
1191
1354
  });
1192
1355
 
1193
1356
  // file: lib/common/plugin/CameraConstants.js
1194
1357
  define("cordova/plugin/CameraConstants", function(require, exports, module) {
1358
+
1195
1359
  module.exports = {
1196
1360
  DestinationType:{
1197
1361
  DATA_URL: 0, // Return base64 encoded string
@@ -1219,10 +1383,12 @@ module.exports = {
1219
1383
  ARROW_ANY : 15
1220
1384
  }
1221
1385
  };
1386
+
1222
1387
  });
1223
1388
 
1224
1389
  // file: lib/common/plugin/CameraPopoverOptions.js
1225
1390
  define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
1391
+
1226
1392
  var Camera = require('cordova/plugin/CameraConstants');
1227
1393
 
1228
1394
  /**
@@ -1239,10 +1405,12 @@ var CameraPopoverOptions = function(x,y,width,height,arrowDir){
1239
1405
  };
1240
1406
 
1241
1407
  module.exports = CameraPopoverOptions;
1408
+
1242
1409
  });
1243
1410
 
1244
1411
  // file: lib/common/plugin/CaptureAudioOptions.js
1245
1412
  define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
1413
+
1246
1414
  /**
1247
1415
  * Encapsulates all audio capture operation configuration options.
1248
1416
  */
@@ -1256,10 +1424,12 @@ var CaptureAudioOptions = function(){
1256
1424
  };
1257
1425
 
1258
1426
  module.exports = CaptureAudioOptions;
1427
+
1259
1428
  });
1260
1429
 
1261
1430
  // file: lib/common/plugin/CaptureError.js
1262
1431
  define("cordova/plugin/CaptureError", function(require, exports, module) {
1432
+
1263
1433
  /**
1264
1434
  * The CaptureError interface encapsulates all errors in the Capture API.
1265
1435
  */
@@ -1279,10 +1449,12 @@ CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
1279
1449
  CaptureError.CAPTURE_NOT_SUPPORTED = 20;
1280
1450
 
1281
1451
  module.exports = CaptureError;
1452
+
1282
1453
  });
1283
1454
 
1284
1455
  // file: lib/common/plugin/CaptureImageOptions.js
1285
1456
  define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
1457
+
1286
1458
  /**
1287
1459
  * Encapsulates all image capture operation configuration options.
1288
1460
  */
@@ -1294,10 +1466,12 @@ var CaptureImageOptions = function(){
1294
1466
  };
1295
1467
 
1296
1468
  module.exports = CaptureImageOptions;
1469
+
1297
1470
  });
1298
1471
 
1299
1472
  // file: lib/common/plugin/CaptureVideoOptions.js
1300
1473
  define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
1474
+
1301
1475
  /**
1302
1476
  * Encapsulates all video capture operation configuration options.
1303
1477
  */
@@ -1311,13 +1485,15 @@ var CaptureVideoOptions = function(){
1311
1485
  };
1312
1486
 
1313
1487
  module.exports = CaptureVideoOptions;
1488
+
1314
1489
  });
1315
1490
 
1316
1491
  // file: lib/common/plugin/CompassError.js
1317
1492
  define("cordova/plugin/CompassError", function(require, exports, module) {
1493
+
1318
1494
  /**
1319
1495
  * CompassError.
1320
- * An error code assigned by an implementation when an error has occured
1496
+ * An error code assigned by an implementation when an error has occurred
1321
1497
  * @constructor
1322
1498
  */
1323
1499
  var CompassError = function(err) {
@@ -1328,10 +1504,12 @@ CompassError.COMPASS_INTERNAL_ERR = 0;
1328
1504
  CompassError.COMPASS_NOT_SUPPORTED = 20;
1329
1505
 
1330
1506
  module.exports = CompassError;
1507
+
1331
1508
  });
1332
1509
 
1333
1510
  // file: lib/common/plugin/CompassHeading.js
1334
1511
  define("cordova/plugin/CompassHeading", function(require, exports, module) {
1512
+
1335
1513
  var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
1336
1514
  this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
1337
1515
  this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
@@ -1340,10 +1518,12 @@ var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, tim
1340
1518
  };
1341
1519
 
1342
1520
  module.exports = CompassHeading;
1521
+
1343
1522
  });
1344
1523
 
1345
1524
  // file: lib/common/plugin/ConfigurationData.js
1346
1525
  define("cordova/plugin/ConfigurationData", function(require, exports, module) {
1526
+
1347
1527
  /**
1348
1528
  * Encapsulates a set of parameters that the capture device supports.
1349
1529
  */
@@ -1359,10 +1539,12 @@ function ConfigurationData() {
1359
1539
  }
1360
1540
 
1361
1541
  module.exports = ConfigurationData;
1542
+
1362
1543
  });
1363
1544
 
1364
1545
  // file: lib/common/plugin/Connection.js
1365
1546
  define("cordova/plugin/Connection", function(require, exports, module) {
1547
+
1366
1548
  /**
1367
1549
  * Network status
1368
1550
  */
@@ -1375,10 +1557,12 @@ module.exports = {
1375
1557
  CELL_4G: "4g",
1376
1558
  NONE: "none"
1377
1559
  };
1560
+
1378
1561
  });
1379
1562
 
1380
1563
  // file: lib/common/plugin/Contact.js
1381
1564
  define("cordova/plugin/Contact", function(require, exports, module) {
1565
+
1382
1566
  var exec = require('cordova/exec'),
1383
1567
  ContactError = require('cordova/plugin/ContactError'),
1384
1568
  utils = require('cordova/utils');
@@ -1561,6 +1745,7 @@ module.exports = Contact;
1561
1745
 
1562
1746
  // file: lib/common/plugin/ContactAddress.js
1563
1747
  define("cordova/plugin/ContactAddress", function(require, exports, module) {
1748
+
1564
1749
  /**
1565
1750
  * Contact address.
1566
1751
  * @constructor
@@ -1586,13 +1771,15 @@ var ContactAddress = function(pref, type, formatted, streetAddress, locality, re
1586
1771
  };
1587
1772
 
1588
1773
  module.exports = ContactAddress;
1774
+
1589
1775
  });
1590
1776
 
1591
1777
  // file: lib/common/plugin/ContactError.js
1592
1778
  define("cordova/plugin/ContactError", function(require, exports, module) {
1779
+
1593
1780
  /**
1594
1781
  * ContactError.
1595
- * An error code assigned by an implementation when an error has occured
1782
+ * An error code assigned by an implementation when an error has occurred
1596
1783
  * @constructor
1597
1784
  */
1598
1785
  var ContactError = function(err) {
@@ -1611,10 +1798,12 @@ ContactError.NOT_SUPPORTED_ERROR = 5;
1611
1798
  ContactError.PERMISSION_DENIED_ERROR = 20;
1612
1799
 
1613
1800
  module.exports = ContactError;
1801
+
1614
1802
  });
1615
1803
 
1616
1804
  // file: lib/common/plugin/ContactField.js
1617
1805
  define("cordova/plugin/ContactField", function(require, exports, module) {
1806
+
1618
1807
  /**
1619
1808
  * Generic contact field.
1620
1809
  * @constructor
@@ -1631,10 +1820,12 @@ var ContactField = function(type, value, pref) {
1631
1820
  };
1632
1821
 
1633
1822
  module.exports = ContactField;
1823
+
1634
1824
  });
1635
1825
 
1636
1826
  // file: lib/common/plugin/ContactFindOptions.js
1637
1827
  define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
1828
+
1638
1829
  /**
1639
1830
  * ContactFindOptions.
1640
1831
  * @constructor
@@ -1648,10 +1839,12 @@ var ContactFindOptions = function(filter, multiple) {
1648
1839
  };
1649
1840
 
1650
1841
  module.exports = ContactFindOptions;
1842
+
1651
1843
  });
1652
1844
 
1653
1845
  // file: lib/common/plugin/ContactName.js
1654
1846
  define("cordova/plugin/ContactName", function(require, exports, module) {
1847
+
1655
1848
  /**
1656
1849
  * Contact name.
1657
1850
  * @constructor
@@ -1672,10 +1865,12 @@ var ContactName = function(formatted, familyName, givenName, middle, prefix, suf
1672
1865
  };
1673
1866
 
1674
1867
  module.exports = ContactName;
1868
+
1675
1869
  });
1676
1870
 
1677
1871
  // file: lib/common/plugin/ContactOrganization.js
1678
1872
  define("cordova/plugin/ContactOrganization", function(require, exports, module) {
1873
+
1679
1874
  /**
1680
1875
  * Contact organization.
1681
1876
  * @constructor
@@ -1699,10 +1894,12 @@ var ContactOrganization = function(pref, type, name, dept, title) {
1699
1894
  };
1700
1895
 
1701
1896
  module.exports = ContactOrganization;
1897
+
1702
1898
  });
1703
1899
 
1704
1900
  // file: lib/common/plugin/Coordinates.js
1705
1901
  define("cordova/plugin/Coordinates", function(require, exports, module) {
1902
+
1706
1903
  /**
1707
1904
  * This class contains position information.
1708
1905
  * @param {Object} lat
@@ -1756,6 +1953,7 @@ module.exports = Coordinates;
1756
1953
 
1757
1954
  // file: lib/common/plugin/DirectoryEntry.js
1758
1955
  define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
1956
+
1759
1957
  var utils = require('cordova/utils'),
1760
1958
  exec = require('cordova/exec'),
1761
1959
  Entry = require('cordova/plugin/Entry'),
@@ -1788,7 +1986,7 @@ DirectoryEntry.prototype.createReader = function() {
1788
1986
  * Creates or looks up a directory
1789
1987
  *
1790
1988
  * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
1791
- * @param {Flags} options to create or excluively create the directory
1989
+ * @param {Flags} options to create or exclusively create the directory
1792
1990
  * @param {Function} successCallback is called with the new entry
1793
1991
  * @param {Function} errorCallback is called with a FileError
1794
1992
  */
@@ -1820,7 +2018,7 @@ DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCall
1820
2018
  * Creates or looks up a file
1821
2019
  *
1822
2020
  * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
1823
- * @param {Flags} options to create or excluively create the file
2021
+ * @param {Flags} options to create or exclusively create the file
1824
2022
  * @param {Function} successCallback is called with the new entry
1825
2023
  * @param {Function} errorCallback is called with a FileError
1826
2024
  */
@@ -1842,6 +2040,7 @@ module.exports = DirectoryEntry;
1842
2040
 
1843
2041
  // file: lib/common/plugin/DirectoryReader.js
1844
2042
  define("cordova/plugin/DirectoryReader", function(require, exports, module) {
2043
+
1845
2044
  var exec = require('cordova/exec'),
1846
2045
  FileError = require('cordova/plugin/FileError') ;
1847
2046
 
@@ -1889,6 +2088,7 @@ module.exports = DirectoryReader;
1889
2088
 
1890
2089
  // file: lib/common/plugin/Entry.js
1891
2090
  define("cordova/plugin/Entry", function(require, exports, module) {
2091
+
1892
2092
  var exec = require('cordova/exec'),
1893
2093
  FileError = require('cordova/plugin/FileError'),
1894
2094
  Metadata = require('cordova/plugin/Metadata');
@@ -2107,10 +2307,12 @@ Entry.prototype.getParent = function(successCallback, errorCallback) {
2107
2307
  };
2108
2308
 
2109
2309
  module.exports = Entry;
2310
+
2110
2311
  });
2111
2312
 
2112
2313
  // file: lib/common/plugin/File.js
2113
2314
  define("cordova/plugin/File", function(require, exports, module) {
2315
+
2114
2316
  /**
2115
2317
  * Constructor.
2116
2318
  * name {DOMString} name of the file, without path information
@@ -2129,10 +2331,12 @@ var File = function(name, fullPath, type, lastModifiedDate, size){
2129
2331
  };
2130
2332
 
2131
2333
  module.exports = File;
2334
+
2132
2335
  });
2133
2336
 
2134
2337
  // file: lib/common/plugin/FileEntry.js
2135
2338
  define("cordova/plugin/FileEntry", function(require, exports, module) {
2339
+
2136
2340
  var utils = require('cordova/utils'),
2137
2341
  exec = require('cordova/exec'),
2138
2342
  Entry = require('cordova/plugin/Entry'),
@@ -2196,10 +2400,12 @@ FileEntry.prototype.file = function(successCallback, errorCallback) {
2196
2400
 
2197
2401
 
2198
2402
  module.exports = FileEntry;
2403
+
2199
2404
  });
2200
2405
 
2201
2406
  // file: lib/common/plugin/FileError.js
2202
2407
  define("cordova/plugin/FileError", function(require, exports, module) {
2408
+
2203
2409
  /**
2204
2410
  * FileError
2205
2411
  */
@@ -2225,10 +2431,12 @@ FileError.TYPE_MISMATCH_ERR = 11;
2225
2431
  FileError.PATH_EXISTS_ERR = 12;
2226
2432
 
2227
2433
  module.exports = FileError;
2434
+
2228
2435
  });
2229
2436
 
2230
2437
  // file: lib/common/plugin/FileReader.js
2231
2438
  define("cordova/plugin/FileReader", function(require, exports, module) {
2439
+
2232
2440
  var exec = require('cordova/exec'),
2233
2441
  FileError = require('cordova/plugin/FileError'),
2234
2442
  ProgressEvent = require('cordova/plugin/ProgressEvent');
@@ -2254,7 +2462,7 @@ var FileReader = function() {
2254
2462
 
2255
2463
  // Event handlers
2256
2464
  this.onloadstart = null; // When the read starts.
2257
- this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progess.loaded/progress.total)
2465
+ this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
2258
2466
  this.onload = null; // When the read has successfully completed.
2259
2467
  this.onerror = null; // When the read has failed (see errors).
2260
2468
  this.onloadend = null; // When the request has completed (either in success or failure).
@@ -2478,10 +2686,12 @@ FileReader.prototype.readAsArrayBuffer = function(file) {
2478
2686
  };
2479
2687
 
2480
2688
  module.exports = FileReader;
2689
+
2481
2690
  });
2482
2691
 
2483
2692
  // file: lib/common/plugin/FileSystem.js
2484
2693
  define("cordova/plugin/FileSystem", function(require, exports, module) {
2694
+
2485
2695
  var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
2486
2696
 
2487
2697
  /**
@@ -2504,14 +2714,29 @@ module.exports = FileSystem;
2504
2714
 
2505
2715
  // file: lib/common/plugin/FileTransfer.js
2506
2716
  define("cordova/plugin/FileTransfer", function(require, exports, module) {
2717
+
2507
2718
  var exec = require('cordova/exec'),
2508
- FileTransferError = require('cordova/plugin/FileTransferError');
2719
+ FileTransferError = require('cordova/plugin/FileTransferError'),
2720
+ ProgressEvent = require('cordova/plugin/ProgressEvent');
2721
+
2722
+ function newProgressEvent(result) {
2723
+ var pe = new ProgressEvent();
2724
+ pe.lengthComputable = result.lengthComputable;
2725
+ pe.loaded = result.loaded;
2726
+ pe.total = result.total;
2727
+ return pe;
2728
+ }
2729
+
2730
+ var idCounter = 0;
2509
2731
 
2510
2732
  /**
2511
2733
  * FileTransfer uploads a file to a remote server.
2512
2734
  * @constructor
2513
2735
  */
2514
- var FileTransfer = function() {};
2736
+ var FileTransfer = function() {
2737
+ this._id = ++idCounter;
2738
+ this.onprogress = null; // optional callback
2739
+ };
2515
2740
 
2516
2741
  /**
2517
2742
  * Given an absolute file path, uploads a file on the device to a remote server
@@ -2554,7 +2779,17 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
2554
2779
  errorCallback(error);
2555
2780
  };
2556
2781
 
2557
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers]);
2782
+ var self = this;
2783
+ var win = function(result) {
2784
+ if (typeof result.lengthComputable != "undefined") {
2785
+ if (self.onprogress) {
2786
+ return self.onprogress(newProgressEvent(result));
2787
+ }
2788
+ } else {
2789
+ return successCallback(result);
2790
+ }
2791
+ };
2792
+ exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id]);
2558
2793
  };
2559
2794
 
2560
2795
  /**
@@ -2563,23 +2798,31 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
2563
2798
  * @param target {String} Full path of the file on the device
2564
2799
  * @param successCallback (Function} Callback to be invoked when upload has completed
2565
2800
  * @param errorCallback {Function} Callback to be invoked upon error
2801
+ * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
2566
2802
  */
2567
- FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
2803
+ FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts) {
2568
2804
  // sanity parameter checking
2569
2805
  if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
2806
+ var self = this;
2570
2807
  var win = function(result) {
2571
- var entry = null;
2572
- if (result.isDirectory) {
2573
- entry = new (require('cordova/plugin/DirectoryEntry'))();
2574
- }
2575
- else if (result.isFile) {
2576
- entry = new (require('cordova/plugin/FileEntry'))();
2808
+ if (typeof result.lengthComputable != "undefined") {
2809
+ if (self.onprogress) {
2810
+ return self.onprogress(newProgressEvent(result));
2811
+ }
2812
+ } else {
2813
+ var entry = null;
2814
+ if (result.isDirectory) {
2815
+ entry = new (require('cordova/plugin/DirectoryEntry'))();
2816
+ }
2817
+ else if (result.isFile) {
2818
+ entry = new (require('cordova/plugin/FileEntry'))();
2819
+ }
2820
+ entry.isDirectory = result.isDirectory;
2821
+ entry.isFile = result.isFile;
2822
+ entry.name = result.name;
2823
+ entry.fullPath = result.fullPath;
2824
+ successCallback(entry);
2577
2825
  }
2578
- entry.isDirectory = result.isDirectory;
2579
- entry.isFile = result.isFile;
2580
- entry.name = result.name;
2581
- entry.fullPath = result.fullPath;
2582
- successCallback(entry);
2583
2826
  };
2584
2827
 
2585
2828
  var fail = function(e) {
@@ -2587,7 +2830,16 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
2587
2830
  errorCallback(error);
2588
2831
  };
2589
2832
 
2590
- exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
2833
+ exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id]);
2834
+ };
2835
+
2836
+ /**
2837
+ * Aborts the ongoing file transfer on this object
2838
+ * @param successCallback {Function} Callback to be invoked upon success
2839
+ * @param errorCallback {Function} Callback to be invoked upon error
2840
+ */
2841
+ FileTransfer.prototype.abort = function(successCallback, errorCallback) {
2842
+ exec(successCallback, errorCallback, 'FileTransfer', 'abort', [this._id]);
2591
2843
  };
2592
2844
 
2593
2845
  module.exports = FileTransfer;
@@ -2596,6 +2848,7 @@ module.exports = FileTransfer;
2596
2848
 
2597
2849
  // file: lib/common/plugin/FileTransferError.js
2598
2850
  define("cordova/plugin/FileTransferError", function(require, exports, module) {
2851
+
2599
2852
  /**
2600
2853
  * FileTransferError
2601
2854
  * @constructor
@@ -2610,6 +2863,7 @@ var FileTransferError = function(code, source, target, status) {
2610
2863
  FileTransferError.FILE_NOT_FOUND_ERR = 1;
2611
2864
  FileTransferError.INVALID_URL_ERR = 2;
2612
2865
  FileTransferError.CONNECTION_ERR = 3;
2866
+ FileTransferError.ABORT_ERR = 4;
2613
2867
 
2614
2868
  module.exports = FileTransferError;
2615
2869
 
@@ -2617,6 +2871,7 @@ module.exports = FileTransferError;
2617
2871
 
2618
2872
  // file: lib/common/plugin/FileUploadOptions.js
2619
2873
  define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
2874
+
2620
2875
  /**
2621
2876
  * Options to customize the HTTP request used to upload files.
2622
2877
  * @constructor
@@ -2641,6 +2896,7 @@ module.exports = FileUploadOptions;
2641
2896
 
2642
2897
  // file: lib/common/plugin/FileUploadResult.js
2643
2898
  define("cordova/plugin/FileUploadResult", function(require, exports, module) {
2899
+
2644
2900
  /**
2645
2901
  * FileUploadResult
2646
2902
  * @constructor
@@ -2652,10 +2908,12 @@ var FileUploadResult = function() {
2652
2908
  };
2653
2909
 
2654
2910
  module.exports = FileUploadResult;
2911
+
2655
2912
  });
2656
2913
 
2657
2914
  // file: lib/common/plugin/FileWriter.js
2658
2915
  define("cordova/plugin/FileWriter", function(require, exports, module) {
2916
+
2659
2917
  var exec = require('cordova/exec'),
2660
2918
  FileError = require('cordova/plugin/FileError'),
2661
2919
  ProgressEvent = require('cordova/plugin/ProgressEvent');
@@ -2914,6 +3172,7 @@ module.exports = FileWriter;
2914
3172
 
2915
3173
  // file: lib/common/plugin/Flags.js
2916
3174
  define("cordova/plugin/Flags", function(require, exports, module) {
3175
+
2917
3176
  /**
2918
3177
  * Supplies arguments to methods that lookup or create files and directories.
2919
3178
  *
@@ -2929,29 +3188,115 @@ function Flags(create, exclusive) {
2929
3188
  }
2930
3189
 
2931
3190
  module.exports = Flags;
3191
+
2932
3192
  });
2933
3193
 
2934
- // file: lib/common/plugin/LocalFileSystem.js
2935
- define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
2936
- var exec = require('cordova/exec');
3194
+ // file: lib/common/plugin/GlobalizationError.js
3195
+ define("cordova/plugin/GlobalizationError", function(require, exports, module) {
3196
+
2937
3197
 
2938
3198
  /**
2939
- * Represents a local file system.
3199
+ * Globalization error object
3200
+ *
3201
+ * @constructor
3202
+ * @param code
3203
+ * @param message
2940
3204
  */
2941
- var LocalFileSystem = function() {
2942
-
3205
+ var GlobalizationError = function(code, message) {
3206
+ this.code = code || null;
3207
+ this.message = message || '';
2943
3208
  };
2944
3209
 
2945
- LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
2946
- LocalFileSystem.PERSISTENT = 1; //persistent
3210
+ // Globalization error codes
3211
+ GlobalizationError.UNKNOWN_ERROR = 0;
3212
+ GlobalizationError.FORMATTING_ERROR = 1;
3213
+ GlobalizationError.PARSING_ERROR = 2;
3214
+ GlobalizationError.PATTERN_ERROR = 3;
3215
+
3216
+ module.exports = GlobalizationError;
2947
3217
 
2948
- module.exports = LocalFileSystem;
2949
3218
  });
2950
3219
 
2951
- // file: lib/common/plugin/Media.js
2952
- define("cordova/plugin/Media", function(require, exports, module) {
2953
- var utils = require('cordova/utils'),
2954
- exec = require('cordova/exec');
3220
+ // file: lib/common/plugin/InAppBrowser.js
3221
+ define("cordova/plugin/InAppBrowser", function(require, exports, module) {
3222
+
3223
+ var exec = require('cordova/exec');
3224
+
3225
+ function InAppBrowser()
3226
+ {
3227
+ var _channel = require('cordova/channel');
3228
+ this.channels = {
3229
+ 'loadstart': _channel.create('loadstart'),
3230
+ 'loadstop' : _channel.create('loadstop'),
3231
+ 'exit' : _channel.create('exit')
3232
+ };
3233
+ }
3234
+
3235
+ InAppBrowser.prototype._eventHandler = function(event)
3236
+ {
3237
+ if (event.type in this.channels) {
3238
+ this.channels[event.type].fire(event);
3239
+ }
3240
+ }
3241
+
3242
+ InAppBrowser.open = function(strUrl, strWindowName, strWindowFeatures)
3243
+ {
3244
+ var iab = new InAppBrowser();
3245
+ var cb = function(eventname) {
3246
+ iab._eventHandler(eventname);
3247
+ }
3248
+ exec(cb, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
3249
+ return iab;
3250
+ }
3251
+
3252
+ InAppBrowser.prototype.close = function(eventname, f)
3253
+ {
3254
+ exec(null, null, "InAppBrowser", "close", []);
3255
+ }
3256
+
3257
+ InAppBrowser.prototype.addEventListener = function(eventname, f)
3258
+ {
3259
+ if (eventname in this.channels) {
3260
+ this.channels[eventname].subscribe(f);
3261
+ }
3262
+ }
3263
+
3264
+ InAppBrowser.prototype.removeEventListener = function(eventname, f)
3265
+ {
3266
+ if (eventname in this.channels) {
3267
+ this.channels[eventname].unsubscribe(f);
3268
+ }
3269
+ }
3270
+
3271
+ module.exports = InAppBrowser.open;
3272
+
3273
+
3274
+ });
3275
+
3276
+ // file: lib/common/plugin/LocalFileSystem.js
3277
+ define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
3278
+
3279
+ var exec = require('cordova/exec');
3280
+
3281
+ /**
3282
+ * Represents a local file system.
3283
+ */
3284
+ var LocalFileSystem = function() {
3285
+
3286
+ };
3287
+
3288
+ LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
3289
+ LocalFileSystem.PERSISTENT = 1; //persistent
3290
+
3291
+ module.exports = LocalFileSystem;
3292
+
3293
+ });
3294
+
3295
+ // file: lib/common/plugin/Media.js
3296
+ define("cordova/plugin/Media", function(require, exports, module) {
3297
+
3298
+ var utils = require('cordova/utils'),
3299
+ exec = require('cordova/exec');
2955
3300
 
2956
3301
  var mediaObjects = {};
2957
3302
 
@@ -3124,13 +3469,13 @@ Media.onStatus = function(id, msgType, value) {
3124
3469
  media._duration = value;
3125
3470
  break;
3126
3471
  case Media.MEDIA_ERROR :
3127
- media.errorCallback && media.errorCallback(value);
3472
+ media.errorCallback && media.errorCallback(value);
3128
3473
  break;
3129
3474
  case Media.MEDIA_POSITION :
3130
3475
  media._position = Number(value);
3131
3476
  break;
3132
3477
  default :
3133
- console && console.error && console.error("Unhandled Media.onStatus :: " + msgType);
3478
+ console && console.error && console.error("Unhandled Media.onStatus :: " + msgType);
3134
3479
  break;
3135
3480
  }
3136
3481
  }
@@ -3141,10 +3486,12 @@ Media.onStatus = function(id, msgType, value) {
3141
3486
  };
3142
3487
 
3143
3488
  module.exports = Media;
3489
+
3144
3490
  });
3145
3491
 
3146
3492
  // file: lib/common/plugin/MediaError.js
3147
3493
  define("cordova/plugin/MediaError", function(require, exports, module) {
3494
+
3148
3495
  /**
3149
3496
  * This class contains information about any Media errors.
3150
3497
  */
@@ -3159,28 +3506,32 @@ we should simply use a literal :
3159
3506
  errorCallbackFunction( {'code':3} );
3160
3507
  */
3161
3508
 
3162
- if(!MediaError) {
3163
- var MediaError = function(code, msg) {
3509
+ var _MediaError = window.MediaError;
3510
+
3511
+
3512
+ if(!_MediaError) {
3513
+ window.MediaError = _MediaError = function(code, msg) {
3164
3514
  this.code = (typeof code != 'undefined') ? code : null;
3165
3515
  this.message = msg || ""; // message is NON-standard! do not use!
3166
3516
  };
3167
3517
  }
3168
3518
 
3169
- MediaError.MEDIA_ERR_NONE_ACTIVE = MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
3170
- MediaError.MEDIA_ERR_ABORTED = MediaError.MEDIA_ERR_ABORTED || 1;
3171
- MediaError.MEDIA_ERR_NETWORK = MediaError.MEDIA_ERR_NETWORK || 2;
3172
- MediaError.MEDIA_ERR_DECODE = MediaError.MEDIA_ERR_DECODE || 3;
3173
- MediaError.MEDIA_ERR_NONE_SUPPORTED = MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
3174
- // TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
3519
+ _MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
3520
+ _MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
3521
+ _MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
3522
+ _MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
3523
+ _MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
3524
+ // TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
3175
3525
  // as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
3176
- MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
3526
+ _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
3177
3527
 
3178
- module.exports = MediaError;
3528
+ module.exports = _MediaError;
3179
3529
 
3180
3530
  });
3181
3531
 
3182
3532
  // file: lib/common/plugin/MediaFile.js
3183
3533
  define("cordova/plugin/MediaFile", function(require, exports, module) {
3534
+
3184
3535
  var utils = require('cordova/utils'),
3185
3536
  exec = require('cordova/exec'),
3186
3537
  File = require('cordova/plugin/File'),
@@ -3220,6 +3571,7 @@ module.exports = MediaFile;
3220
3571
 
3221
3572
  // file: lib/common/plugin/MediaFileData.js
3222
3573
  define("cordova/plugin/MediaFileData", function(require, exports, module) {
3574
+
3223
3575
  /**
3224
3576
  * MediaFileData encapsulates format information of a media file.
3225
3577
  *
@@ -3238,10 +3590,12 @@ var MediaFileData = function(codecs, bitrate, height, width, duration){
3238
3590
  };
3239
3591
 
3240
3592
  module.exports = MediaFileData;
3593
+
3241
3594
  });
3242
3595
 
3243
3596
  // file: lib/common/plugin/Metadata.js
3244
3597
  define("cordova/plugin/Metadata", function(require, exports, module) {
3598
+
3245
3599
  /**
3246
3600
  * Information about the state of the file or directory
3247
3601
  *
@@ -3252,10 +3606,12 @@ var Metadata = function(time) {
3252
3606
  };
3253
3607
 
3254
3608
  module.exports = Metadata;
3609
+
3255
3610
  });
3256
3611
 
3257
3612
  // file: lib/common/plugin/Position.js
3258
3613
  define("cordova/plugin/Position", function(require, exports, module) {
3614
+
3259
3615
  var Coordinates = require('cordova/plugin/Coordinates');
3260
3616
 
3261
3617
  var Position = function(coords, timestamp) {
@@ -3273,6 +3629,7 @@ module.exports = Position;
3273
3629
 
3274
3630
  // file: lib/common/plugin/PositionError.js
3275
3631
  define("cordova/plugin/PositionError", function(require, exports, module) {
3632
+
3276
3633
  /**
3277
3634
  * Position error object
3278
3635
  *
@@ -3290,10 +3647,12 @@ PositionError.POSITION_UNAVAILABLE = 2;
3290
3647
  PositionError.TIMEOUT = 3;
3291
3648
 
3292
3649
  module.exports = PositionError;
3650
+
3293
3651
  });
3294
3652
 
3295
3653
  // file: lib/common/plugin/ProgressEvent.js
3296
3654
  define("cordova/plugin/ProgressEvent", function(require, exports, module) {
3655
+
3297
3656
  // If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
3298
3657
  // Feature test: See if we can instantiate a native ProgressEvent;
3299
3658
  // if so, use that approach,
@@ -3340,15 +3699,18 @@ var ProgressEvent = (function() {
3340
3699
  })();
3341
3700
 
3342
3701
  module.exports = ProgressEvent;
3702
+
3343
3703
  });
3344
3704
 
3345
3705
  // file: lib/common/plugin/accelerometer.js
3346
3706
  define("cordova/plugin/accelerometer", function(require, exports, module) {
3707
+
3347
3708
  /**
3348
3709
  * This class provides access to device accelerometer data.
3349
3710
  * @constructor
3350
3711
  */
3351
- var utils = require("cordova/utils"),
3712
+ var argscheck = require('cordova/argscheck'),
3713
+ utils = require("cordova/utils"),
3352
3714
  exec = require("cordova/exec"),
3353
3715
  Acceleration = require('cordova/plugin/Acceleration');
3354
3716
 
@@ -3405,17 +3767,14 @@ function removeListeners(l) {
3405
3767
 
3406
3768
  var accelerometer = {
3407
3769
  /**
3408
- * Asynchronously aquires the current acceleration.
3770
+ * Asynchronously acquires the current acceleration.
3409
3771
  *
3410
3772
  * @param {Function} successCallback The function to call when the acceleration data is available
3411
3773
  * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
3412
3774
  * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
3413
3775
  */
3414
3776
  getCurrentAcceleration: function(successCallback, errorCallback, options) {
3415
- // successCallback required
3416
- if (typeof successCallback !== "function") {
3417
- throw "getCurrentAcceleration must be called with at least a success callback function as first parameter.";
3418
- }
3777
+ argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
3419
3778
 
3420
3779
  var p;
3421
3780
  var win = function(a) {
@@ -3424,7 +3783,7 @@ var accelerometer = {
3424
3783
  };
3425
3784
  var fail = function(e) {
3426
3785
  removeListeners(p);
3427
- errorCallback(e);
3786
+ errorCallback && errorCallback(e);
3428
3787
  };
3429
3788
 
3430
3789
  p = createCallbackPair(win, fail);
@@ -3436,7 +3795,7 @@ var accelerometer = {
3436
3795
  },
3437
3796
 
3438
3797
  /**
3439
- * Asynchronously aquires the acceleration repeatedly at a given interval.
3798
+ * Asynchronously acquires the acceleration repeatedly at a given interval.
3440
3799
  *
3441
3800
  * @param {Function} successCallback The function to call each time the acceleration data is available
3442
3801
  * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
@@ -3444,20 +3803,16 @@ var accelerometer = {
3444
3803
  * @return String The watch id that must be passed to #clearWatch to stop watching.
3445
3804
  */
3446
3805
  watchAcceleration: function(successCallback, errorCallback, options) {
3806
+ argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
3447
3807
  // Default interval (10 sec)
3448
3808
  var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
3449
3809
 
3450
- // successCallback required
3451
- if (typeof successCallback !== "function") {
3452
- throw "watchAcceleration must be called with at least a success callback function as first parameter.";
3453
- }
3454
-
3455
3810
  // Keep reference to watch id, and report accel readings as often as defined in frequency
3456
3811
  var id = utils.createUUID();
3457
3812
 
3458
3813
  var p = createCallbackPair(function(){}, function(e) {
3459
3814
  removeListeners(p);
3460
- errorCallback(e);
3815
+ errorCallback && errorCallback(e);
3461
3816
  });
3462
3817
  listeners.push(p);
3463
3818
 
@@ -3473,7 +3828,7 @@ var accelerometer = {
3473
3828
  if (running) {
3474
3829
  // If we're already running then immediately invoke the success callback
3475
3830
  // but only if we have retrieved a value, sample code does not check for null ...
3476
- if(accel) {
3831
+ if (accel) {
3477
3832
  successCallback(accel);
3478
3833
  }
3479
3834
  } else {
@@ -3504,6 +3859,7 @@ module.exports = accelerometer;
3504
3859
 
3505
3860
  // file: lib/common/plugin/battery.js
3506
3861
  define("cordova/plugin/battery", function(require, exports, module) {
3862
+
3507
3863
  /**
3508
3864
  * This class contains information about the current battery status.
3509
3865
  * @constructor
@@ -3521,34 +3877,25 @@ var Battery = function() {
3521
3877
  this._level = null;
3522
3878
  this._isPlugged = null;
3523
3879
  // Create new event handlers on the window (returns a channel instance)
3524
- var subscriptionEvents = {
3525
- onSubscribe:this.onSubscribe,
3526
- onUnsubscribe:this.onUnsubscribe
3527
- };
3528
3880
  this.channels = {
3529
- batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
3530
- batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
3531
- batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
3881
+ batterystatus:cordova.addWindowEventHandler("batterystatus"),
3882
+ batterylow:cordova.addWindowEventHandler("batterylow"),
3883
+ batterycritical:cordova.addWindowEventHandler("batterycritical")
3532
3884
  };
3885
+ for (var key in this.channels) {
3886
+ this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
3887
+ }
3533
3888
  };
3534
3889
  /**
3535
3890
  * Event handlers for when callbacks get registered for the battery.
3536
3891
  * Keep track of how many handlers we have so we can start and stop the native battery listener
3537
3892
  * appropriately (and hopefully save on battery life!).
3538
3893
  */
3539
- Battery.prototype.onSubscribe = function() {
3540
- var me = battery;
3894
+ Battery.onHasSubscribersChange = function() {
3541
3895
  // If we just registered the first handler, make sure native listener is started.
3542
- if (handlers() === 1) {
3543
- exec(me._status, me._error, "Battery", "start", []);
3544
- }
3545
- };
3546
-
3547
- Battery.prototype.onUnsubscribe = function() {
3548
- var me = battery;
3549
-
3550
- // If we just unregistered the last handler, make sure native listener is stopped.
3551
- if (handlers() === 0) {
3896
+ if (this.numHandlers === 1 && handlers() === 1) {
3897
+ exec(battery._status, battery._error, "Battery", "start", []);
3898
+ } else if (handlers() === 0) {
3552
3899
  exec(null, null, "Battery", "stop", []);
3553
3900
  }
3554
3901
  };
@@ -3591,10 +3938,12 @@ Battery.prototype._error = function(e) {
3591
3938
  var battery = new Battery();
3592
3939
 
3593
3940
  module.exports = battery;
3941
+
3594
3942
  });
3595
3943
 
3596
3944
  // file: lib/common/plugin/capture.js
3597
3945
  define("cordova/plugin/capture", function(require, exports, module) {
3946
+
3598
3947
  var exec = require('cordova/exec'),
3599
3948
  MediaFile = require('cordova/plugin/MediaFile');
3600
3949
 
@@ -3672,7 +4021,9 @@ module.exports = new Capture();
3672
4021
 
3673
4022
  // file: lib/common/plugin/compass.js
3674
4023
  define("cordova/plugin/compass", function(require, exports, module) {
3675
- var exec = require('cordova/exec'),
4024
+
4025
+ var argscheck = require('cordova/argscheck'),
4026
+ exec = require('cordova/exec'),
3676
4027
  utils = require('cordova/utils'),
3677
4028
  CompassHeading = require('cordova/plugin/CompassHeading'),
3678
4029
  CompassError = require('cordova/plugin/CompassError'),
@@ -3687,23 +4038,13 @@ var exec = require('cordova/exec'),
3687
4038
  * @param {CompassOptions} options The options for getting the heading data (not used).
3688
4039
  */
3689
4040
  getCurrentHeading:function(successCallback, errorCallback, options) {
3690
- // successCallback required
3691
- if (typeof successCallback !== "function") {
3692
- console.log("Compass Error: successCallback is not a function");
3693
- return;
3694
- }
3695
-
3696
- // errorCallback optional
3697
- if (errorCallback && (typeof errorCallback !== "function")) {
3698
- console.log("Compass Error: errorCallback is not a function");
3699
- return;
3700
- }
4041
+ argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments);
3701
4042
 
3702
4043
  var win = function(result) {
3703
4044
  var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
3704
4045
  successCallback(ch);
3705
4046
  };
3706
- var fail = function(code) {
4047
+ var fail = errorCallback && function(code) {
3707
4048
  var ce = new CompassError(code);
3708
4049
  errorCallback(ce);
3709
4050
  };
@@ -3723,22 +4064,11 @@ var exec = require('cordova/exec'),
3723
4064
  * specifies to watch via a distance filter rather than time.
3724
4065
  */
3725
4066
  watchHeading:function(successCallback, errorCallback, options) {
4067
+ argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
3726
4068
  // Default interval (100 msec)
3727
4069
  var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
3728
4070
  var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
3729
4071
 
3730
- // successCallback required
3731
- if (typeof successCallback !== "function") {
3732
- console.log("Compass Error: successCallback is not a function");
3733
- return;
3734
- }
3735
-
3736
- // errorCallback optional
3737
- if (errorCallback && (typeof errorCallback !== "function")) {
3738
- console.log("Compass Error: errorCallback is not a function");
3739
- return;
3740
- }
3741
-
3742
4072
  var id = utils.createUUID();
3743
4073
  if (filter > 0) {
3744
4074
  // is an iOS request for watch by filter, no timer needed
@@ -3762,8 +4092,8 @@ var exec = require('cordova/exec'),
3762
4092
  // Stop javascript timer & remove from timer list
3763
4093
  if (id && timers[id]) {
3764
4094
  if (timers[id] != "iOS") {
3765
- clearInterval(timers[id]);
3766
- } else {
4095
+ clearInterval(timers[id]);
4096
+ } else {
3767
4097
  // is iOS watch by filter so call into device to stop
3768
4098
  exec(null, null, "Compass", "stopHeading", []);
3769
4099
  }
@@ -3773,10 +4103,12 @@ var exec = require('cordova/exec'),
3773
4103
  };
3774
4104
 
3775
4105
  module.exports = compass;
4106
+
3776
4107
  });
3777
4108
 
3778
4109
  // file: lib/common/plugin/console-via-logger.js
3779
4110
  define("cordova/plugin/console-via-logger", function(require, exports, module) {
4111
+
3780
4112
  //------------------------------------------------------------------------------
3781
4113
 
3782
4114
  var logger = require("cordova/plugin/logger");
@@ -3925,7 +4257,7 @@ console.table = function(data, columns) {
3925
4257
  //------------------------------------------------------------------------------
3926
4258
  // return a new function that calls both functions passed as args
3927
4259
  //------------------------------------------------------------------------------
3928
- function wrapperedOrigCall(orgFunc, newFunc) {
4260
+ function wrappedOrigCall(orgFunc, newFunc) {
3929
4261
  return function() {
3930
4262
  var args = [].slice.call(arguments);
3931
4263
  try { orgFunc.apply(WinConsole, args); } catch (e) {}
@@ -3940,7 +4272,7 @@ function wrapperedOrigCall(orgFunc, newFunc) {
3940
4272
  //------------------------------------------------------------------------------
3941
4273
  for (var key in console) {
3942
4274
  if (typeof WinConsole[key] == "function") {
3943
- console[key] = wrapperedOrigCall(WinConsole[key], console[key]);
4275
+ console[key] = wrappedOrigCall(WinConsole[key], console[key]);
3944
4276
  }
3945
4277
  }
3946
4278
 
@@ -3948,7 +4280,9 @@ for (var key in console) {
3948
4280
 
3949
4281
  // file: lib/common/plugin/contacts.js
3950
4282
  define("cordova/plugin/contacts", function(require, exports, module) {
3951
- var exec = require('cordova/exec'),
4283
+
4284
+ var argscheck = require('cordova/argscheck'),
4285
+ exec = require('cordova/exec'),
3952
4286
  ContactError = require('cordova/plugin/ContactError'),
3953
4287
  utils = require('cordova/utils'),
3954
4288
  Contact = require('cordova/plugin/Contact');
@@ -3967,13 +4301,9 @@ var contacts = {
3967
4301
  * @return array of Contacts matching search criteria
3968
4302
  */
3969
4303
  find:function(fields, successCB, errorCB, options) {
3970
- if (!successCB) {
3971
- throw new TypeError("You must specify a success callback for the find command.");
3972
- }
3973
- if (!fields || (utils.isArray(fields) && fields.length === 0)) {
3974
- if (typeof errorCB === "function") {
3975
- errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
3976
- }
4304
+ argscheck.checkArgs('afFO', 'contacts.find', arguments);
4305
+ if (!fields.length) {
4306
+ errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
3977
4307
  } else {
3978
4308
  var win = function(result) {
3979
4309
  var cs = [];
@@ -3994,9 +4324,9 @@ var contacts = {
3994
4324
  * @returns new Contact object
3995
4325
  */
3996
4326
  create:function(properties) {
3997
- var i;
4327
+ argscheck.checkArgs('O', 'contacts.create', arguments);
3998
4328
  var contact = new Contact();
3999
- for (i in properties) {
4329
+ for (var i in properties) {
4000
4330
  if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
4001
4331
  contact[i] = properties[i];
4002
4332
  }
@@ -4011,7 +4341,9 @@ module.exports = contacts;
4011
4341
 
4012
4342
  // file: lib/common/plugin/device.js
4013
4343
  define("cordova/plugin/device", function(require, exports, module) {
4014
- var channel = require('cordova/channel'),
4344
+
4345
+ var argscheck = require('cordova/argscheck'),
4346
+ channel = require('cordova/channel'),
4015
4347
  utils = require('cordova/utils'),
4016
4348
  exec = require('cordova/exec');
4017
4349
 
@@ -4030,10 +4362,11 @@ function Device() {
4030
4362
  this.name = null;
4031
4363
  this.uuid = null;
4032
4364
  this.cordova = null;
4365
+ this.model = null;
4033
4366
 
4034
4367
  var me = this;
4035
4368
 
4036
- channel.onCordovaReady.subscribeOnce(function() {
4369
+ channel.onCordovaReady.subscribe(function() {
4037
4370
  me.getInfo(function(info) {
4038
4371
  me.available = true;
4039
4372
  me.platform = info.platform;
@@ -4041,6 +4374,7 @@ function Device() {
4041
4374
  me.name = info.name;
4042
4375
  me.uuid = info.uuid;
4043
4376
  me.cordova = info.cordova;
4377
+ me.model = info.model;
4044
4378
  channel.onCordovaInfoReady.fire();
4045
4379
  },function(e) {
4046
4380
  me.available = false;
@@ -4056,20 +4390,7 @@ function Device() {
4056
4390
  * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
4057
4391
  */
4058
4392
  Device.prototype.getInfo = function(successCallback, errorCallback) {
4059
-
4060
- // successCallback required
4061
- if (typeof successCallback !== "function") {
4062
- console.log("Device Error: successCallback is not a function");
4063
- return;
4064
- }
4065
-
4066
- // errorCallback optional
4067
- if (errorCallback && (typeof errorCallback !== "function")) {
4068
- console.log("Device Error: errorCallback is not a function");
4069
- return;
4070
- }
4071
-
4072
- // Get info
4393
+ argscheck.checkArgs('fF', 'Device.getInfo', arguments);
4073
4394
  exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
4074
4395
  };
4075
4396
 
@@ -4079,10 +4400,11 @@ module.exports = new Device();
4079
4400
 
4080
4401
  // file: lib/common/plugin/echo.js
4081
4402
  define("cordova/plugin/echo", function(require, exports, module) {
4403
+
4082
4404
  var exec = require('cordova/exec');
4083
4405
 
4084
4406
  /**
4085
- * Sends the given message through exec() to the Echo plugink, which sends it back to the successCallback.
4407
+ * Sends the given message through exec() to the Echo plugin, which sends it back to the successCallback.
4086
4408
  * @param successCallback invoked with a FileSystem object
4087
4409
  * @param errorCallback invoked if error occurs retrieving file system
4088
4410
  * @param message The string to be echoed.
@@ -4098,7 +4420,9 @@ module.exports = function(successCallback, errorCallback, message, forceAsync) {
4098
4420
 
4099
4421
  // file: lib/common/plugin/geolocation.js
4100
4422
  define("cordova/plugin/geolocation", function(require, exports, module) {
4101
- var utils = require('cordova/utils'),
4423
+
4424
+ var argscheck = require('cordova/argscheck'),
4425
+ utils = require('cordova/utils'),
4102
4426
  exec = require('cordova/exec'),
4103
4427
  PositionError = require('cordova/plugin/PositionError'),
4104
4428
  Position = require('cordova/plugin/Position');
@@ -4148,25 +4472,23 @@ function createTimeout(errorCallback, timeout) {
4148
4472
  var geolocation = {
4149
4473
  lastPosition:null, // reference to last known (cached) position returned
4150
4474
  /**
4151
- * Asynchronously aquires the current position.
4475
+ * Asynchronously acquires the current position.
4152
4476
  *
4153
4477
  * @param {Function} successCallback The function to call when the position data is available
4154
4478
  * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
4155
4479
  * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
4156
4480
  */
4157
4481
  getCurrentPosition:function(successCallback, errorCallback, options) {
4158
- if (arguments.length === 0) {
4159
- throw new Error("getCurrentPosition must be called with at least one argument.");
4160
- }
4482
+ argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
4161
4483
  options = parseParameters(options);
4162
4484
 
4163
4485
  // Timer var that will fire an error callback if no position is retrieved from native
4164
4486
  // before the "timeout" param provided expires
4165
- var timeoutTimer = null;
4487
+ var timeoutTimer = {timer:null};
4166
4488
 
4167
4489
  var win = function(p) {
4168
- clearTimeout(timeoutTimer);
4169
- if (!timeoutTimer) {
4490
+ clearTimeout(timeoutTimer.timer);
4491
+ if (!(timeoutTimer.timer)) {
4170
4492
  // Timeout already happened, or native fired error callback for
4171
4493
  // this geo request.
4172
4494
  // Don't continue with success callback.
@@ -4188,8 +4510,8 @@ var geolocation = {
4188
4510
  successCallback(pos);
4189
4511
  };
4190
4512
  var fail = function(e) {
4191
- clearTimeout(timeoutTimer);
4192
- timeoutTimer = null;
4513
+ clearTimeout(timeoutTimer.timer);
4514
+ timeoutTimer.timer = null;
4193
4515
  var err = new PositionError(e.code, e.message);
4194
4516
  if (errorCallback) {
4195
4517
  errorCallback(err);
@@ -4212,12 +4534,12 @@ var geolocation = {
4212
4534
  // If the timeout value was not set to Infinity (default), then
4213
4535
  // set up a timeout function that will fire the error callback
4214
4536
  // if no successful position was retrieved before timeout expired.
4215
- timeoutTimer = createTimeout(fail, options.timeout);
4537
+ timeoutTimer.timer = createTimeout(fail, options.timeout);
4216
4538
  } else {
4217
4539
  // This is here so the check in the win function doesn't mess stuff up
4218
4540
  // may seem weird but this guarantees timeoutTimer is
4219
4541
  // always truthy before we call into native
4220
- timeoutTimer = true;
4542
+ timeoutTimer.timer = true;
4221
4543
  }
4222
4544
  exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
4223
4545
  }
@@ -4233,9 +4555,7 @@ var geolocation = {
4233
4555
  * @return String The watch id that must be passed to #clearWatch to stop watching.
4234
4556
  */
4235
4557
  watchPosition:function(successCallback, errorCallback, options) {
4236
- if (arguments.length === 0) {
4237
- throw new Error("watchPosition must be called with at least one argument.");
4238
- }
4558
+ argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
4239
4559
  options = parseParameters(options);
4240
4560
 
4241
4561
  var id = utils.createUUID();
@@ -4244,7 +4564,7 @@ var geolocation = {
4244
4564
  timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
4245
4565
 
4246
4566
  var fail = function(e) {
4247
- clearTimeout(timers[id]);
4567
+ clearTimeout(timers[id].timer);
4248
4568
  var err = new PositionError(e.code, e.message);
4249
4569
  if (errorCallback) {
4250
4570
  errorCallback(err);
@@ -4252,9 +4572,9 @@ var geolocation = {
4252
4572
  };
4253
4573
 
4254
4574
  var win = function(p) {
4255
- clearTimeout(timers[id]);
4575
+ clearTimeout(timers[id].timer);
4256
4576
  if (options.timeout !== Infinity) {
4257
- timers[id] = createTimeout(fail, options.timeout);
4577
+ timers[id].timer = createTimeout(fail, options.timeout);
4258
4578
  }
4259
4579
  var pos = new Position(
4260
4580
  {
@@ -4283,8 +4603,8 @@ var geolocation = {
4283
4603
  */
4284
4604
  clearWatch:function(id) {
4285
4605
  if (id && timers[id] !== undefined) {
4286
- clearTimeout(timers[id]);
4287
- delete timers[id];
4606
+ clearTimeout(timers[id].timer);
4607
+ timers[id].timer = false;
4288
4608
  exec(null, null, "Geolocation", "clearWatch", [id]);
4289
4609
  }
4290
4610
  }
@@ -4294,8 +4614,385 @@ module.exports = geolocation;
4294
4614
 
4295
4615
  });
4296
4616
 
4617
+ // file: lib/common/plugin/globalization.js
4618
+ define("cordova/plugin/globalization", function(require, exports, module) {
4619
+
4620
+ var argscheck = require('cordova/argscheck'),
4621
+ exec = require('cordova/exec'),
4622
+ GlobalizationError = require('cordova/plugin/GlobalizationError');
4623
+
4624
+ var globalization = {
4625
+
4626
+ /**
4627
+ * Returns the string identifier for the client's current language.
4628
+ * It returns the language identifier string to the successCB callback with a
4629
+ * properties object as a parameter. If there is an error getting the language,
4630
+ * then the errorCB callback is invoked.
4631
+ *
4632
+ * @param {Function} successCB
4633
+ * @param {Function} errorCB
4634
+ *
4635
+ * @return Object.value {String}: The language identifier
4636
+ *
4637
+ * @error GlobalizationError.UNKNOWN_ERROR
4638
+ *
4639
+ * Example
4640
+ * globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
4641
+ * function () {});
4642
+ */
4643
+ getPreferredLanguage:function(successCB, failureCB) {
4644
+ argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
4645
+ exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
4646
+ },
4647
+
4648
+ /**
4649
+ * Returns the string identifier for the client's current locale setting.
4650
+ * It returns the locale identifier string to the successCB callback with a
4651
+ * properties object as a parameter. If there is an error getting the locale,
4652
+ * then the errorCB callback is invoked.
4653
+ *
4654
+ * @param {Function} successCB
4655
+ * @param {Function} errorCB
4656
+ *
4657
+ * @return Object.value {String}: The locale identifier
4658
+ *
4659
+ * @error GlobalizationError.UNKNOWN_ERROR
4660
+ *
4661
+ * Example
4662
+ * globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
4663
+ * function () {});
4664
+ */
4665
+ getLocaleName:function(successCB, failureCB) {
4666
+ argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
4667
+ exec(successCB, failureCB, "Globalization","getLocaleName", []);
4668
+ },
4669
+
4670
+
4671
+ /**
4672
+ * Returns a date formatted as a string according to the client's user preferences and
4673
+ * calendar using the time zone of the client. It returns the formatted date string to the
4674
+ * successCB callback with a properties object as a parameter. If there is an error
4675
+ * formatting the date, then the errorCB callback is invoked.
4676
+ *
4677
+ * The defaults are: formatLenght="short" and selector="date and time"
4678
+ *
4679
+ * @param {Date} date
4680
+ * @param {Function} successCB
4681
+ * @param {Function} errorCB
4682
+ * @param {Object} options {optional}
4683
+ * formatLength {String}: 'short', 'medium', 'long', or 'full'
4684
+ * selector {String}: 'date', 'time', or 'date and time'
4685
+ *
4686
+ * @return Object.value {String}: The localized date string
4687
+ *
4688
+ * @error GlobalizationError.FORMATTING_ERROR
4689
+ *
4690
+ * Example
4691
+ * globalization.dateToString(new Date(),
4692
+ * function (date) {alert('date:' + date.value + '\n');},
4693
+ * function (errorCode) {alert(errorCode);},
4694
+ * {formatLength:'short'});
4695
+ */
4696
+ dateToString:function(date, successCB, failureCB, options) {
4697
+ argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
4698
+ var dateValue = date.valueOf();
4699
+ exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);
4700
+ },
4701
+
4702
+
4703
+ /**
4704
+ * Parses a date formatted as a string according to the client's user
4705
+ * preferences and calendar using the time zone of the client and returns
4706
+ * the corresponding date object. It returns the date to the successCB
4707
+ * callback with a properties object as a parameter. If there is an error
4708
+ * parsing the date string, then the errorCB callback is invoked.
4709
+ *
4710
+ * The defaults are: formatLength="short" and selector="date and time"
4711
+ *
4712
+ * @param {String} dateString
4713
+ * @param {Function} successCB
4714
+ * @param {Function} errorCB
4715
+ * @param {Object} options {optional}
4716
+ * formatLength {String}: 'short', 'medium', 'long', or 'full'
4717
+ * selector {String}: 'date', 'time', or 'date and time'
4718
+ *
4719
+ * @return Object.year {Number}: The four digit year
4720
+ * Object.month {Number}: The month from (0 - 11)
4721
+ * Object.day {Number}: The day from (1 - 31)
4722
+ * Object.hour {Number}: The hour from (0 - 23)
4723
+ * Object.minute {Number}: The minute from (0 - 59)
4724
+ * Object.second {Number}: The second from (0 - 59)
4725
+ * Object.millisecond {Number}: The milliseconds (from 0 - 999),
4726
+ * not available on all platforms
4727
+ *
4728
+ * @error GlobalizationError.PARSING_ERROR
4729
+ *
4730
+ * Example
4731
+ * globalization.stringToDate('4/11/2011',
4732
+ * function (date) { alert('Month:' + date.month + '\n' +
4733
+ * 'Day:' + date.day + '\n' +
4734
+ * 'Year:' + date.year + '\n');},
4735
+ * function (errorCode) {alert(errorCode);},
4736
+ * {selector:'date'});
4737
+ */
4738
+ stringToDate:function(dateString, successCB, failureCB, options) {
4739
+ argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
4740
+ exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);
4741
+ },
4742
+
4743
+
4744
+ /**
4745
+ * Returns a pattern string for formatting and parsing dates according to the client's
4746
+ * user preferences. It returns the pattern to the successCB callback with a
4747
+ * properties object as a parameter. If there is an error obtaining the pattern,
4748
+ * then the errorCB callback is invoked.
4749
+ *
4750
+ * The defaults are: formatLength="short" and selector="date and time"
4751
+ *
4752
+ * @param {Function} successCB
4753
+ * @param {Function} errorCB
4754
+ * @param {Object} options {optional}
4755
+ * formatLength {String}: 'short', 'medium', 'long', or 'full'
4756
+ * selector {String}: 'date', 'time', or 'date and time'
4757
+ *
4758
+ * @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
4759
+ * The patterns follow Unicode Technical Standard #35
4760
+ * http://unicode.org/reports/tr35/tr35-4.html
4761
+ * Object.timezone {String}: The abbreviated name of the time zone on the client
4762
+ * Object.utc_offset {Number}: The current difference in seconds between the client's
4763
+ * time zone and coordinated universal time.
4764
+ * Object.dst_offset {Number}: The current daylight saving time offset in seconds
4765
+ * between the client's non-daylight saving's time zone
4766
+ * and the client's daylight saving's time zone.
4767
+ *
4768
+ * @error GlobalizationError.PATTERN_ERROR
4769
+ *
4770
+ * Example
4771
+ * globalization.getDatePattern(
4772
+ * function (date) {alert('pattern:' + date.pattern + '\n');},
4773
+ * function () {},
4774
+ * {formatLength:'short'});
4775
+ */
4776
+ getDatePattern:function(successCB, failureCB, options) {
4777
+ argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
4778
+ exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);
4779
+ },
4780
+
4781
+
4782
+ /**
4783
+ * Returns an array of either the names of the months or days of the week
4784
+ * according to the client's user preferences and calendar. It returns the array of names to the
4785
+ * successCB callback with a properties object as a parameter. If there is an error obtaining the
4786
+ * names, then the errorCB callback is invoked.
4787
+ *
4788
+ * The defaults are: type="wide" and item="months"
4789
+ *
4790
+ * @param {Function} successCB
4791
+ * @param {Function} errorCB
4792
+ * @param {Object} options {optional}
4793
+ * type {String}: 'narrow' or 'wide'
4794
+ * item {String}: 'months', or 'days'
4795
+ *
4796
+ * @return Object.value {Array{String}}: The array of names starting from either
4797
+ * the first month in the year or the
4798
+ * first day of the week.
4799
+ * @error GlobalizationError.UNKNOWN_ERROR
4800
+ *
4801
+ * Example
4802
+ * globalization.getDateNames(function (names) {
4803
+ * for(var i = 0; i < names.value.length; i++) {
4804
+ * alert('Month:' + names.value[i] + '\n');}},
4805
+ * function () {});
4806
+ */
4807
+ getDateNames:function(successCB, failureCB, options) {
4808
+ argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
4809
+ exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);
4810
+ },
4811
+
4812
+ /**
4813
+ * Returns whether daylight savings time is in effect for a given date using the client's
4814
+ * time zone and calendar. It returns whether or not daylight savings time is in effect
4815
+ * to the successCB callback with a properties object as a parameter. If there is an error
4816
+ * reading the date, then the errorCB callback is invoked.
4817
+ *
4818
+ * @param {Date} date
4819
+ * @param {Function} successCB
4820
+ * @param {Function} errorCB
4821
+ *
4822
+ * @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
4823
+ * in effect for the given date and "false" indicate that it is not.
4824
+ *
4825
+ * @error GlobalizationError.UNKNOWN_ERROR
4826
+ *
4827
+ * Example
4828
+ * globalization.isDayLightSavingsTime(new Date(),
4829
+ * function (date) {alert('dst:' + date.dst + '\n');}
4830
+ * function () {});
4831
+ */
4832
+ isDayLightSavingsTime:function(date, successCB, failureCB) {
4833
+ argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
4834
+ var dateValue = date.valueOf();
4835
+ exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);
4836
+ },
4837
+
4838
+ /**
4839
+ * Returns the first day of the week according to the client's user preferences and calendar.
4840
+ * The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
4841
+ * It returns the day to the successCB callback with a properties object as a parameter.
4842
+ * If there is an error obtaining the pattern, then the errorCB callback is invoked.
4843
+ *
4844
+ * @param {Function} successCB
4845
+ * @param {Function} errorCB
4846
+ *
4847
+ * @return Object.value {Number}: The number of the first day of the week.
4848
+ *
4849
+ * @error GlobalizationError.UNKNOWN_ERROR
4850
+ *
4851
+ * Example
4852
+ * globalization.getFirstDayOfWeek(function (day)
4853
+ * { alert('Day:' + day.value + '\n');},
4854
+ * function () {});
4855
+ */
4856
+ getFirstDayOfWeek:function(successCB, failureCB) {
4857
+ argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
4858
+ exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
4859
+ },
4860
+
4861
+
4862
+ /**
4863
+ * Returns a number formatted as a string according to the client's user preferences.
4864
+ * It returns the formatted number string to the successCB callback with a properties object as a
4865
+ * parameter. If there is an error formatting the number, then the errorCB callback is invoked.
4866
+ *
4867
+ * The defaults are: type="decimal"
4868
+ *
4869
+ * @param {Number} number
4870
+ * @param {Function} successCB
4871
+ * @param {Function} errorCB
4872
+ * @param {Object} options {optional}
4873
+ * type {String}: 'decimal', "percent", or 'currency'
4874
+ *
4875
+ * @return Object.value {String}: The formatted number string.
4876
+ *
4877
+ * @error GlobalizationError.FORMATTING_ERROR
4878
+ *
4879
+ * Example
4880
+ * globalization.numberToString(3.25,
4881
+ * function (number) {alert('number:' + number.value + '\n');},
4882
+ * function () {},
4883
+ * {type:'decimal'});
4884
+ */
4885
+ numberToString:function(number, successCB, failureCB, options) {
4886
+ argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
4887
+ exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);
4888
+ },
4889
+
4890
+ /**
4891
+ * Parses a number formatted as a string according to the client's user preferences and
4892
+ * returns the corresponding number. It returns the number to the successCB callback with a
4893
+ * properties object as a parameter. If there is an error parsing the number string, then
4894
+ * the errorCB callback is invoked.
4895
+ *
4896
+ * The defaults are: type="decimal"
4897
+ *
4898
+ * @param {String} numberString
4899
+ * @param {Function} successCB
4900
+ * @param {Function} errorCB
4901
+ * @param {Object} options {optional}
4902
+ * type {String}: 'decimal', "percent", or 'currency'
4903
+ *
4904
+ * @return Object.value {Number}: The parsed number.
4905
+ *
4906
+ * @error GlobalizationError.PARSING_ERROR
4907
+ *
4908
+ * Example
4909
+ * globalization.stringToNumber('1234.56',
4910
+ * function (number) {alert('Number:' + number.value + '\n');},
4911
+ * function () { alert('Error parsing number');});
4912
+ */
4913
+ stringToNumber:function(numberString, successCB, failureCB, options) {
4914
+ argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
4915
+ exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);
4916
+ },
4917
+
4918
+ /**
4919
+ * Returns a pattern string for formatting and parsing numbers according to the client's user
4920
+ * preferences. It returns the pattern to the successCB callback with a properties object as a
4921
+ * parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
4922
+ *
4923
+ * The defaults are: type="decimal"
4924
+ *
4925
+ * @param {Function} successCB
4926
+ * @param {Function} errorCB
4927
+ * @param {Object} options {optional}
4928
+ * type {String}: 'decimal', "percent", or 'currency'
4929
+ *
4930
+ * @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
4931
+ * The patterns follow Unicode Technical Standard #35.
4932
+ * http://unicode.org/reports/tr35/tr35-4.html
4933
+ * Object.symbol {String}: The symbol to be used when formatting and parsing
4934
+ * e.g., percent or currency symbol.
4935
+ * Object.fraction {Number}: The number of fractional digits to use when parsing and
4936
+ * formatting numbers.
4937
+ * Object.rounding {Number}: The rounding increment to use when parsing and formatting.
4938
+ * Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
4939
+ * Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
4940
+ * Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
4941
+ * Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
4942
+ *
4943
+ * @error GlobalizationError.PATTERN_ERROR
4944
+ *
4945
+ * Example
4946
+ * globalization.getNumberPattern(
4947
+ * function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
4948
+ * function () {});
4949
+ */
4950
+ getNumberPattern:function(successCB, failureCB, options) {
4951
+ argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
4952
+ exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);
4953
+ },
4954
+
4955
+ /**
4956
+ * Returns a pattern string for formatting and parsing currency values according to the client's
4957
+ * user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
4958
+ * properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
4959
+ * callback is invoked.
4960
+ *
4961
+ * @param {String} currencyCode
4962
+ * @param {Function} successCB
4963
+ * @param {Function} errorCB
4964
+ *
4965
+ * @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
4966
+ * The patterns follow Unicode Technical Standard #35
4967
+ * http://unicode.org/reports/tr35/tr35-4.html
4968
+ * Object.code {String}: The ISO 4217 currency code for the pattern.
4969
+ * Object.fraction {Number}: The number of fractional digits to use when parsing and
4970
+ * formatting currency.
4971
+ * Object.rounding {Number}: The rounding increment to use when parsing and formatting.
4972
+ * Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
4973
+ * Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
4974
+ *
4975
+ * @error GlobalizationError.FORMATTING_ERROR
4976
+ *
4977
+ * Example
4978
+ * globalization.getCurrencyPattern('EUR',
4979
+ * function (currency) {alert('Pattern:' + currency.pattern + '\n');}
4980
+ * function () {});
4981
+ */
4982
+ getCurrencyPattern:function(currencyCode, successCB, failureCB) {
4983
+ argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
4984
+ exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);
4985
+ }
4986
+
4987
+ };
4988
+
4989
+ module.exports = globalization;
4990
+
4991
+ });
4992
+
4297
4993
  // file: lib/ios/plugin/ios/Contact.js
4298
4994
  define("cordova/plugin/ios/Contact", function(require, exports, module) {
4995
+
4299
4996
  var exec = require('cordova/exec'),
4300
4997
  ContactError = require('cordova/plugin/ContactError');
4301
4998
 
@@ -4326,10 +5023,12 @@ module.exports = {
4326
5023
  }
4327
5024
  }
4328
5025
  };
5026
+
4329
5027
  });
4330
5028
 
4331
5029
  // file: lib/ios/plugin/ios/Entry.js
4332
5030
  define("cordova/plugin/ios/Entry", function(require, exports, module) {
5031
+
4333
5032
  module.exports = {
4334
5033
  toURL:function() {
4335
5034
  // TODO: refactor path in a cross-platform way so we can eliminate
@@ -4341,10 +5040,12 @@ module.exports = {
4341
5040
  return "file://localhost" + this.fullPath;
4342
5041
  }
4343
5042
  };
5043
+
4344
5044
  });
4345
5045
 
4346
5046
  // file: lib/ios/plugin/ios/FileReader.js
4347
5047
  define("cordova/plugin/ios/FileReader", function(require, exports, module) {
5048
+
4348
5049
  var exec = require('cordova/exec'),
4349
5050
  FileError = require('cordova/plugin/FileError'),
4350
5051
  FileReader = require('cordova/plugin/FileReader'),
@@ -4432,33 +5133,18 @@ module.exports = {
4432
5133
  "File", "readAsText", [this.fileName, enc]);
4433
5134
  }
4434
5135
  };
5136
+
4435
5137
  });
4436
5138
 
4437
5139
  // file: lib/ios/plugin/ios/console.js
4438
5140
  define("cordova/plugin/ios/console", function(require, exports, module) {
5141
+
4439
5142
  var exec = require('cordova/exec');
4440
5143
 
4441
5144
  /**
4442
- * This class provides access to the debugging console.
4443
- * @constructor
5145
+ * create a nice string for an object
4444
5146
  */
4445
- var DebugConsole = function() {
4446
- this.winConsole = window.console;
4447
- this.logLevel = DebugConsole.INFO_LEVEL;
4448
- };
4449
-
4450
- // from most verbose, to least verbose
4451
- DebugConsole.ALL_LEVEL = 1; // same as first level
4452
- DebugConsole.INFO_LEVEL = 1;
4453
- DebugConsole.WARN_LEVEL = 2;
4454
- DebugConsole.ERROR_LEVEL = 4;
4455
- DebugConsole.NONE_LEVEL = 8;
4456
-
4457
- DebugConsole.prototype.setLevel = function(level) {
4458
- this.logLevel = level;
4459
- };
4460
-
4461
- var stringify = function(message) {
5147
+ function stringify(message) {
4462
5148
  try {
4463
5149
  if (typeof message === "object" && JSON && JSON.stringify) {
4464
5150
  try {
@@ -4473,52 +5159,54 @@ var stringify = function(message) {
4473
5159
  } catch (e) {
4474
5160
  return e.toString();
4475
5161
  }
4476
- };
5162
+ }
4477
5163
 
4478
5164
  /**
4479
- * Print a normal log message to the console
4480
- * @param {Object|String} message Message or object to print to the console
5165
+ * Wrapper one of the console logging methods, so that
5166
+ * the Cordova logging native is called, then the original.
4481
5167
  */
4482
- DebugConsole.prototype.log = function(message) {
4483
- if (this.logLevel <= DebugConsole.INFO_LEVEL) {
4484
- exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'INFO' } ]);
4485
- }
4486
- else if (this.winConsole && this.winConsole.log) {
4487
- this.winConsole.log(message);
4488
- }
4489
- };
5168
+ function wrappedMethod(console, method) {
5169
+ var origMethod = console[method];
4490
5170
 
4491
- /**
4492
- * Print a warning message to the console
4493
- * @param {Object|String} message Message or object to print to the console
4494
- */
4495
- DebugConsole.prototype.warn = function(message) {
4496
- if (this.logLevel <= DebugConsole.WARN_LEVEL) {
4497
- exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'WARN' } ]);
4498
- }
4499
- else if (this.winConsole && this.winConsole.warn) {
4500
- this.winConsole.warn(message);
4501
- }
4502
- };
5171
+ return function(message) {
5172
+ exec(null, null,
5173
+ 'Debug Console', 'log',
5174
+ [ stringify(message), { logLevel: method.toUpperCase() } ]
5175
+ );
4503
5176
 
4504
- /**
4505
- * Print an error message to the console
4506
- * @param {Object|String} message Message or object to print to the console
4507
- */
4508
- DebugConsole.prototype.error = function(message) {
4509
- if (this.logLevel <= DebugConsole.ERROR_LEVEL) {
4510
- exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'ERROR' } ]);
4511
- }
4512
- else if (this.winConsole && this.winConsole.error){
4513
- this.winConsole.error(message);
4514
- }
4515
- };
5177
+ if (!origMethod) return;
5178
+
5179
+ origMethod.apply(console, arguments);
5180
+ };
5181
+ }
5182
+
5183
+ var console = window.console || {};
5184
+
5185
+ // 2012-10-06 pmuellr - marking setLevel() method and logLevel property
5186
+ // on console as deprecated;
5187
+ // it didn't do anything useful, since the level constants weren't accessible
5188
+ // to anyone
5189
+
5190
+ console.setLevel = function() {};
5191
+ console.logLevel = 0;
5192
+
5193
+ // wrapper the logging messages
5194
+
5195
+ var methods = ["log", "debug", "info", "warn", "error"];
5196
+
5197
+ for (var i=0; i<methods.length; i++) {
5198
+ var method = methods[i];
5199
+
5200
+ console[method] = wrappedMethod(console, method);
5201
+ }
5202
+
5203
+ module.exports = console;
4516
5204
 
4517
- module.exports = new DebugConsole();
4518
5205
  });
4519
5206
 
4520
5207
  // file: lib/ios/plugin/ios/contacts.js
4521
5208
  define("cordova/plugin/ios/contacts", function(require, exports, module) {
5209
+
4522
5210
  var exec = require('cordova/exec');
4523
5211
 
4524
5212
  /**
@@ -4560,26 +5248,12 @@ module.exports = {
4560
5248
  exec(win, null, "Contacts","chooseContact", [options]);
4561
5249
  }
4562
5250
  };
4563
- });
4564
-
4565
- // file: lib/ios/plugin/ios/nativecomm.js
4566
- define("cordova/plugin/ios/nativecomm", function(require, exports, module) {
4567
- var cordova = require('cordova');
4568
-
4569
- /**
4570
- * Called by native code to retrieve all queued commands and clear the queue.
4571
- */
4572
- module.exports = function() {
4573
- // Each entry in commandQueue is a JSON string already.
4574
- var json = '[' + cordova.commandQueue.join(',') + ']';
4575
- cordova.commandQueue.length = 0;
4576
- return json;
4577
- };
4578
5251
 
4579
5252
  });
4580
5253
 
4581
5254
  // file: lib/ios/plugin/ios/notification.js
4582
5255
  define("cordova/plugin/ios/notification", function(require, exports, module) {
5256
+
4583
5257
  var Media = require('cordova/plugin/Media');
4584
5258
 
4585
5259
  module.exports = {
@@ -4587,10 +5261,12 @@ module.exports = {
4587
5261
  (new Media('beep.wav')).play();
4588
5262
  }
4589
5263
  };
5264
+
4590
5265
  });
4591
5266
 
4592
5267
  // file: lib/common/plugin/logger.js
4593
5268
  define("cordova/plugin/logger", function(require, exports, module) {
5269
+
4594
5270
  //------------------------------------------------------------------------------
4595
5271
  // The logger module exports the following properties/functions:
4596
5272
  //
@@ -4818,53 +5494,24 @@ document.addEventListener("deviceready", logger.__onDeviceReady, false);
4818
5494
 
4819
5495
  // file: lib/common/plugin/network.js
4820
5496
  define("cordova/plugin/network", function(require, exports, module) {
5497
+
4821
5498
  var exec = require('cordova/exec'),
4822
5499
  cordova = require('cordova'),
4823
- channel = require('cordova/channel');
4824
-
4825
- var NetworkConnection = function () {
4826
- this.type = null;
4827
- this._firstRun = true;
4828
- this._timer = null;
4829
- this.timeout = 500;
4830
-
4831
- var me = this;
4832
-
4833
- channel.onCordovaReady.subscribeOnce(function() {
4834
- me.getInfo(function (info) {
4835
- me.type = info;
4836
- if (info === "none") {
4837
- // set a timer if still offline at the end of timer send the offline event
4838
- me._timer = setTimeout(function(){
4839
- cordova.fireDocumentEvent("offline");
4840
- me._timer = null;
4841
- }, me.timeout);
4842
- } else {
4843
- // If there is a current offline event pending clear it
4844
- if (me._timer !== null) {
4845
- clearTimeout(me._timer);
4846
- me._timer = null;
4847
- }
4848
- cordova.fireDocumentEvent("online");
4849
- }
5500
+ channel = require('cordova/channel'),
5501
+ utils = require('cordova/utils');
4850
5502
 
4851
- // should only fire this once
4852
- if (me._firstRun) {
4853
- me._firstRun = false;
4854
- channel.onCordovaConnectionReady.fire();
4855
- }
4856
- },
4857
- function (e) {
4858
- // If we can't get the network info we should still tell Cordova
4859
- // to fire the deviceready event.
4860
- if (me._firstRun) {
4861
- me._firstRun = false;
4862
- channel.onCordovaConnectionReady.fire();
4863
- }
4864
- console.log("Error initializing Network Connection: " + e);
4865
- });
5503
+ // Link the onLine property with the Cordova-supplied network info.
5504
+ // This works because we clobber the naviagtor object with our own
5505
+ // object in bootstrap.js.
5506
+ if (typeof navigator != 'undefined') {
5507
+ utils.defineGetter(navigator, 'onLine', function() {
5508
+ return this.connection.type != 'none';
4866
5509
  });
4867
- };
5510
+ }
5511
+
5512
+ function NetworkConnection() {
5513
+ this.type = 'unknown';
5514
+ }
4868
5515
 
4869
5516
  /**
4870
5517
  * Get connection info
@@ -4872,16 +5519,54 @@ var NetworkConnection = function () {
4872
5519
  * @param {Function} successCallback The function to call when the Connection data is available
4873
5520
  * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
4874
5521
  */
4875
- NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
4876
- // Get info
5522
+ NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
4877
5523
  exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
4878
5524
  };
4879
5525
 
4880
- module.exports = new NetworkConnection();
5526
+ var me = new NetworkConnection();
5527
+ var timerId = null;
5528
+ var timeout = 500;
5529
+
5530
+ channel.onCordovaReady.subscribe(function() {
5531
+ me.getInfo(function(info) {
5532
+ me.type = info;
5533
+ if (info === "none") {
5534
+ // set a timer if still offline at the end of timer send the offline event
5535
+ timerId = setTimeout(function(){
5536
+ cordova.fireDocumentEvent("offline");
5537
+ timerId = null;
5538
+ }, timeout);
5539
+ } else {
5540
+ // If there is a current offline event pending clear it
5541
+ if (timerId !== null) {
5542
+ clearTimeout(timerId);
5543
+ timerId = null;
5544
+ }
5545
+ cordova.fireDocumentEvent("online");
5546
+ }
5547
+
5548
+ // should only fire this once
5549
+ if (channel.onCordovaConnectionReady.state !== 2) {
5550
+ channel.onCordovaConnectionReady.fire();
5551
+ }
5552
+ },
5553
+ function (e) {
5554
+ // If we can't get the network info we should still tell Cordova
5555
+ // to fire the deviceready event.
5556
+ if (channel.onCordovaConnectionReady.state !== 2) {
5557
+ channel.onCordovaConnectionReady.fire();
5558
+ }
5559
+ console.log("Error initializing Network Connection: " + e);
5560
+ });
5561
+ });
5562
+
5563
+ module.exports = me;
5564
+
4881
5565
  });
4882
5566
 
4883
5567
  // file: lib/common/plugin/notification.js
4884
5568
  define("cordova/plugin/notification", function(require, exports, module) {
5569
+
4885
5570
  var exec = require('cordova/exec');
4886
5571
 
4887
5572
  /**
@@ -4938,11 +5623,14 @@ module.exports = {
4938
5623
  exec(null, null, "Notification", "beep", [count]);
4939
5624
  }
4940
5625
  };
5626
+
4941
5627
  });
4942
5628
 
4943
5629
  // file: lib/common/plugin/requestFileSystem.js
4944
5630
  define("cordova/plugin/requestFileSystem", function(require, exports, module) {
4945
- var FileError = require('cordova/plugin/FileError'),
5631
+
5632
+ var argscheck = require('cordova/argscheck'),
5633
+ FileError = require('cordova/plugin/FileError'),
4946
5634
  FileSystem = require('cordova/plugin/FileSystem'),
4947
5635
  exec = require('cordova/exec');
4948
5636
 
@@ -4954,10 +5642,9 @@ var FileError = require('cordova/plugin/FileError'),
4954
5642
  * @param errorCallback invoked if error occurs retrieving file system
4955
5643
  */
4956
5644
  var requestFileSystem = function(type, size, successCallback, errorCallback) {
5645
+ argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
4957
5646
  var fail = function(code) {
4958
- if (typeof errorCallback === 'function') {
4959
- errorCallback(new FileError(code));
4960
- }
5647
+ errorCallback && errorCallback(new FileError(code));
4961
5648
  };
4962
5649
 
4963
5650
  if (type < 0 || type > 3) {
@@ -4966,7 +5653,7 @@ var requestFileSystem = function(type, size, successCallback, errorCallback) {
4966
5653
  // if successful, return a FileSystem object
4967
5654
  var success = function(file_system) {
4968
5655
  if (file_system) {
4969
- if (typeof successCallback === 'function') {
5656
+ if (successCallback) {
4970
5657
  // grab the name and root from the file system object
4971
5658
  var result = new FileSystem(file_system.name, file_system.root);
4972
5659
  successCallback(result);
@@ -4982,11 +5669,14 @@ var requestFileSystem = function(type, size, successCallback, errorCallback) {
4982
5669
  };
4983
5670
 
4984
5671
  module.exports = requestFileSystem;
5672
+
4985
5673
  });
4986
5674
 
4987
5675
  // file: lib/common/plugin/resolveLocalFileSystemURI.js
4988
5676
  define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
4989
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
5677
+
5678
+ var argscheck = require('cordova/argscheck'),
5679
+ DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
4990
5680
  FileEntry = require('cordova/plugin/FileEntry'),
4991
5681
  FileError = require('cordova/plugin/FileError'),
4992
5682
  exec = require('cordova/exec');
@@ -4998,11 +5688,10 @@ var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
4998
5688
  * @param errorCallback invoked if error occurs retrieving file system entry
4999
5689
  */
5000
5690
  module.exports = function(uri, successCallback, errorCallback) {
5691
+ argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
5001
5692
  // error callback
5002
5693
  var fail = function(error) {
5003
- if (typeof errorCallback === 'function') {
5004
- errorCallback(new FileError(error));
5005
- }
5694
+ errorCallback && errorCallback(new FileError(error));
5006
5695
  };
5007
5696
  // sanity check for 'not:valid:filename'
5008
5697
  if(!uri || uri.split(":").length > 2) {
@@ -5015,15 +5704,10 @@ module.exports = function(uri, successCallback, errorCallback) {
5015
5704
  var success = function(entry) {
5016
5705
  var result;
5017
5706
  if (entry) {
5018
- if (typeof successCallback === 'function') {
5707
+ if (successCallback) {
5019
5708
  // create appropriate Entry object
5020
5709
  result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
5021
- try {
5022
- successCallback(result);
5023
- }
5024
- catch (e) {
5025
- console.log('Error invoking callback: ' + e);
5026
- }
5710
+ successCallback(result);
5027
5711
  }
5028
5712
  }
5029
5713
  else {
@@ -5039,6 +5723,7 @@ module.exports = function(uri, successCallback, errorCallback) {
5039
5723
 
5040
5724
  // file: lib/common/plugin/splashscreen.js
5041
5725
  define("cordova/plugin/splashscreen", function(require, exports, module) {
5726
+
5042
5727
  var exec = require('cordova/exec');
5043
5728
 
5044
5729
  var splashscreen = {
@@ -5051,12 +5736,49 @@ var splashscreen = {
5051
5736
  };
5052
5737
 
5053
5738
  module.exports = splashscreen;
5739
+
5054
5740
  });
5055
5741
 
5056
5742
  // file: lib/common/utils.js
5057
5743
  define("cordova/utils", function(require, exports, module) {
5744
+
5058
5745
  var utils = exports;
5059
5746
 
5747
+ /**
5748
+ * Defines a property getter for obj[key].
5749
+ */
5750
+ utils.defineGetter = function(obj, key, func) {
5751
+ if (Object.defineProperty) {
5752
+ Object.defineProperty(obj, key, { get: func });
5753
+ } else {
5754
+ obj.__defineGetter__(key, func);
5755
+ }
5756
+ };
5757
+
5758
+ utils.arrayIndexOf = function(a, item) {
5759
+ if (a.indexOf) {
5760
+ return a.indexOf(item);
5761
+ }
5762
+ var len = a.length;
5763
+ for (var i = 0; i < len; ++i) {
5764
+ if (a[i] == item) {
5765
+ return i;
5766
+ }
5767
+ }
5768
+ return -1;
5769
+ };
5770
+
5771
+ /**
5772
+ * Returns whether the item was found in the array.
5773
+ */
5774
+ utils.arrayRemove = function(a, item) {
5775
+ var index = utils.arrayIndexOf(a, item);
5776
+ if (index != -1) {
5777
+ a.splice(index, 1);
5778
+ }
5779
+ return index != -1;
5780
+ };
5781
+
5060
5782
  /**
5061
5783
  * Returns an indication of whether the argument is an array or not
5062
5784
  */
@@ -5099,7 +5821,7 @@ utils.clone = function(obj) {
5099
5821
  };
5100
5822
 
5101
5823
  /**
5102
- * Returns a wrappered version of the function
5824
+ * Returns a wrapped version of the function
5103
5825
  */
5104
5826
  utils.close = function(context, func, params) {
5105
5827
  if (typeof params == 'undefined') {
@@ -5144,8 +5866,8 @@ utils.extend = (function() {
5144
5866
  * Alerts a message in any available way: alert or console.log.
5145
5867
  */
5146
5868
  utils.alert = function(msg) {
5147
- if (alert) {
5148
- alert(msg);
5869
+ if (window.alert) {
5870
+ window.alert(msg);
5149
5871
  } else if (console && console.log) {
5150
5872
  console.log(msg);
5151
5873
  }
@@ -5248,7 +5970,16 @@ function formatted(object, formatChar) {
5248
5970
  window.cordova = require('cordova');
5249
5971
 
5250
5972
  // file: lib/scripts/bootstrap.js
5973
+
5251
5974
  (function (context) {
5975
+ // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
5976
+ // We replace it so that properties that can't be clobbered can instead be overridden.
5977
+ if (context.navigator) {
5978
+ function CordovaNavigator() {}
5979
+ CordovaNavigator.prototype = context.navigator;
5980
+ context.navigator = new CordovaNavigator();
5981
+ }
5982
+
5252
5983
  var channel = require("cordova/channel"),
5253
5984
  _self = {
5254
5985
  boot: function () {
@@ -5261,17 +5992,13 @@ window.cordova = require('cordova');
5261
5992
  platform = require('cordova/platform');
5262
5993
 
5263
5994
  // Drop the common globals into the window object, but be nice and don't overwrite anything.
5264
- builder.build(base.objects).intoButDontClobber(window);
5995
+ builder.buildIntoButDoNotClobber(base.defaults, context);
5996
+ builder.buildIntoAndClobber(base.clobbers, context);
5997
+ builder.buildIntoAndMerge(base.merges, context);
5265
5998
 
5266
- // Drop the platform-specific globals into the window object
5267
- // and clobber any existing object.
5268
- builder.build(platform.objects).intoAndClobber(window);
5269
-
5270
- // Merge the platform-specific overrides/enhancements into
5271
- // the window object.
5272
- if (typeof platform.merges !== 'undefined') {
5273
- builder.build(platform.merges).intoAndMerge(window);
5274
- }
5999
+ builder.buildIntoButDoNotClobber(platform.defaults, context);
6000
+ builder.buildIntoAndClobber(platform.clobbers, context);
6001
+ builder.buildIntoAndMerge(platform.merges, context);
5275
6002
 
5276
6003
  // Call the platform-specific initialization
5277
6004
  platform.initialize();
@@ -5290,7 +6017,7 @@ window.cordova = require('cordova');
5290
6017
  };
5291
6018
 
5292
6019
  // boot up once native side is ready
5293
- channel.onNativeReady.subscribeOnce(_self.boot);
6020
+ channel.onNativeReady.subscribe(_self.boot);
5294
6021
 
5295
6022
  // _nativeReady is global variable that the native side can set
5296
6023
  // to signify that the native code is ready. It is a global since
@@ -5302,4 +6029,4 @@ window.cordova = require('cordova');
5302
6029
  }(window));
5303
6030
 
5304
6031
 
5305
- })();var PhoneGap = cordova;
6032
+ })();