You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2012/09/21 17:37:18 UTC
[1/2] ios commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-cordova-ios
Updated Branches:
refs/heads/master 6fa7f3d24 -> 1f13eb693
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-ios
Conflicts:
CordovaLib/Classes/CDVPlugin.h
CordovaLib/Classes/CDVPlugin.m
CordovaLib/Classes/CDVViewController.m
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/1f13eb69
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/1f13eb69
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/1f13eb69
Branch: refs/heads/master
Commit: 1f13eb693a5f4ecfbdf4eb856dda6b15984779a9
Parents: 4fe0e8b 6fa7f3d
Author: Braden Shepherdson <br...@chromium.org>
Authored: Fri Sep 21 11:35:34 2012 -0400
Committer: Braden Shepherdson <br...@chromium.org>
Committed: Fri Sep 21 11:35:34 2012 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 5 +-
CordovaLib/Classes/CDVAccelerometer.h | 14 +-
CordovaLib/Classes/CDVAccelerometer.m | 75 +-
CordovaLib/Classes/CDVAvailability.h | 51 +-
CordovaLib/Classes/CDVBattery.h | 19 +-
CordovaLib/Classes/CDVBattery.m | 71 +-
CordovaLib/Classes/CDVCamera.h | 33 +-
CordovaLib/Classes/CDVCamera.m | 535 ++--
CordovaLib/Classes/CDVCapture.h | 51 +-
CordovaLib/Classes/CDVCapture.m | 661 ++--
CordovaLib/Classes/CDVCommandDelegate.h | 12 +-
CordovaLib/Classes/CDVConnection.h | 11 +-
CordovaLib/Classes/CDVConnection.m | 127 +-
CordovaLib/Classes/CDVContact.h | 107 +-
CordovaLib/Classes/CDVContact.m | 2622 ++++++++-------
CordovaLib/Classes/CDVContacts.h | 79 +-
CordovaLib/Classes/CDVContacts.m | 671 ++--
CordovaLib/Classes/CDVCordovaView.h | 10 +-
CordovaLib/Classes/CDVCordovaView.m | 15 +-
CordovaLib/Classes/CDVDebug.h | 8 +-
CordovaLib/Classes/CDVDebugConsole.h | 8 +-
CordovaLib/Classes/CDVDebugConsole.m | 8 +-
CordovaLib/Classes/CDVDevice.h | 11 +-
CordovaLib/Classes/CDVDevice.m | 35 +-
CordovaLib/Classes/CDVEcho.h | 4 +-
CordovaLib/Classes/CDVEcho.m | 6 +-
CordovaLib/Classes/CDVFile.h | 119 +-
CordovaLib/Classes/CDVFile.m | 1785 +++++-----
CordovaLib/Classes/CDVFileTransfer.h | 47 +-
CordovaLib/Classes/CDVFileTransfer.m | 442 ++-
CordovaLib/Classes/CDVInvokedUrlCommand.h | 38 +-
CordovaLib/Classes/CDVInvokedUrlCommand.m | 26 +-
CordovaLib/Classes/CDVLocalStorage.h | 32 +-
CordovaLib/Classes/CDVLocalStorage.m | 299 +-
CordovaLib/Classes/CDVLocation.h | 68 +-
CordovaLib/Classes/CDVLocation.m | 434 ++--
CordovaLib/Classes/CDVLogger.h | 6 +-
CordovaLib/Classes/CDVLogger.m | 13 +-
CordovaLib/Classes/CDVNotification.h | 15 +-
CordovaLib/Classes/CDVNotification.m | 100 +-
CordovaLib/Classes/CDVPlugin.h | 29 +-
CordovaLib/Classes/CDVPlugin.m | 116 +-
CordovaLib/Classes/CDVPluginResult.h | 67 +-
CordovaLib/Classes/CDVPluginResult.m | 129 +-
CordovaLib/Classes/CDVReachability.h | 61 +-
CordovaLib/Classes/CDVReachability.m | 327 +-
CordovaLib/Classes/CDVSound.h | 101 +-
CordovaLib/Classes/CDVSound.m | 615 ++--
CordovaLib/Classes/CDVSplashScreen.h | 12 +-
CordovaLib/Classes/CDVSplashScreen.m | 20 +-
CordovaLib/Classes/CDVURLProtocol.h | 28 +-
CordovaLib/Classes/CDVURLProtocol.m | 77 +-
CordovaLib/Classes/CDVViewController.h | 39 +-
CordovaLib/Classes/CDVViewController.m | 650 ++--
CordovaLib/Classes/CDVWhitelist.h | 12 +-
CordovaLib/Classes/CDVWhitelist.m | 101 +-
CordovaLib/Classes/NSArray+Comparisons.h | 7 +-
CordovaLib/Classes/NSArray+Comparisons.m | 13 +-
CordovaLib/Classes/NSData+Base64.h | 18 +-
CordovaLib/Classes/NSData+Base64.m | 374 +--
CordovaLib/Classes/NSDictionary+Extensions.h | 26 +-
CordovaLib/Classes/NSDictionary+Extensions.m | 176 +-
CordovaLib/Classes/NSMutableArray+QueueAdditions.h | 13 +-
CordovaLib/Classes/NSMutableArray+QueueAdditions.m | 30 +-
CordovaLib/Classes/UIDevice+Extensions.h | 10 +-
CordovaLib/Classes/UIDevice+Extensions.m | 19 +-
CordovaLib/Classes/compatibility/0.9.6/CDV.h | 9 +-
CordovaLib/Classes/compatibility/0.9.6/CDVPlugin.h | 27 +-
CordovaLib/Classes/compatibility/0.9.6/CDVPlugin.m | 5 +-
CordovaLib/Classes/compatibility/1.5.0/CDV.h | 9 +-
CordovaLib/Classes/compatibility/1.5.0/CDVPlugin.h | 5 +-
CordovaLib/Classes/debugview/CDVDebugWebView.h | 23 +-
CordovaLib/Classes/debugview/CDVDebugWebView.m | 121 +-
.../Classes/debugview/WebScriptDebugDelegate.h | 87 +-
CordovaLib/Classes/deprecated/CDVDeprecated.h | 22 +-
CordovaLib/Classes/deprecated/CDVDeprecated.m | 6 +-
CordovaLib/CordovaLibApp/AppDelegate.h | 8 +-
CordovaLib/CordovaLibApp/AppDelegate.m | 49 +-
CordovaLib/CordovaLibApp/ViewController.h | 4 +-
CordovaLib/CordovaLibApp/ViewController.m | 8 +-
CordovaLib/CordovaLibApp/main.m | 7 +-
CordovaLib/CordovaLibTests/CDVBase64Tests.m | 14 +-
CordovaLib/CordovaLibTests/CDVContactsTests.m | 20 +-
CordovaLib/CordovaLibTests/CDVFakeFileManager.h | 8 +-
CordovaLib/CordovaLibTests/CDVFakeFileManager.m | 16 +-
CordovaLib/CordovaLibTests/CDVFileTransferTests.m | 54 +-
.../CordovaLibTests/CDVInvokedUrlCommandTests.m | 23 +-
CordovaLib/CordovaLibTests/CDVLocalStorageTests.m | 65 +-
.../CDVPluginResultJSONSerializationTests.m | 134 +-
CordovaLib/CordovaLibTests/CDVWebViewTest.h | 16 +-
CordovaLib/CordovaLibTests/CDVWebViewTest.m | 44 +-
CordovaLib/CordovaLibTests/CDVWhitelistTests.m | 222 +-
CordovaLib/javascript/cordova.ios.js | 632 ++++-
.../project/__TESTING__/Classes/AppDelegate.h | 13 +-
.../project/__TESTING__/Classes/AppDelegate.m | 82 +-
.../__TESTING__/Classes/MainViewController.h | 4 +-
.../__TESTING__/Classes/MainViewController.m | 59 +-
.../Resources/Capture.bundle/microphone-568h.png | Bin 516905 -> 0 bytes
.../Capture.bundle/microphone-568h@2x~iphone.png | Bin 0 -> 516760 bytes
bin/templates/project/__TESTING__/main.m | 12 +-
bin/templates/project/www/cordova-2.1.0.js | 528 ++--
101 files changed, 7369 insertions(+), 6710 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/1f13eb69/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --cc CordovaLib/Classes/CDVPlugin.h
index 2af034f,3079334..59d3a5c
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@@ -23,11 -23,9 +23,10 @@@
#import "NSMutableArray+QueueAdditions.h"
#import "CDVCommandDelegate.h"
- #define CDVPluginHandleOpenURLNotification @"CDVPluginHandleOpenURLNotification"
+ #define CDVPluginHandleOpenURLNotification @"CDVPluginHandleOpenURLNotification"
+#define CDVPluginResetNotification @"CDVPluginResetNotification"
- @interface CDVPlugin : NSObject {
- }
+ @interface CDVPlugin : NSObject {}
@property (nonatomic, strong) UIWebView* webView;
@property (nonatomic, strong) NSDictionary* settings;
@@@ -36,13 -34,12 +35,13 @@@
@property (readonly, assign) BOOL hasPendingOperation;
- - (CDVPlugin*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
- - (CDVPlugin*) initWithWebView:(UIWebView*)theWebView;
+ - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
+ - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView;
- - (void) handleOpenURL:(NSNotification*)notification;
- - (void) onAppTerminate;
- - (void) onMemoryWarning;
+ - (void)handleOpenURL:(NSNotification*)notification;
+ - (void)onAppTerminate;
+ - (void)onMemoryWarning;
+- (void) onReset;
/*
// see initWithWebView implementation
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/1f13eb69/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --cc CordovaLib/Classes/CDVPlugin.m
index ea813cf,67babb4..2f8b4f2
--- a/CordovaLib/Classes/CDVPlugin.m
+++ b/CordovaLib/Classes/CDVPlugin.m
@@@ -44,24 -42,23 +42,24 @@@
{
self = [super init];
if (self) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:nil];
-
- NSLog(@"Plugin loaded");
- self.webView = theWebView;
-
- // You can listen to more app notifications, see:
- // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
- /*
- // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler, and also the removeObserver in dealloc
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
- */
- }
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
++ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:nil];
+
+ self.webView = theWebView;
+
+ // You can listen to more app notifications, see:
+ // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
+
+ /*
+ // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler, and also the removeObserver in dealloc
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
+ */
+ }
return self;
}
@@@ -87,54 -84,48 +85,54 @@@
}
/* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
- - (void) onAppTerminate
+ - (void)onAppTerminate
{
- // override this if you need to do any cleanup on app exit
+ // override this if you need to do any cleanup on app exit
}
- - (void) onMemoryWarning
+ - (void)onMemoryWarning
{
- // override to remove caches, etc
+ // override to remove caches, etc
}
+- (void) onReset
+{
+ // Override to cancel any long-running requests when the WebView navigates or refreshes.
+}
+
- - (void) dealloc
+ - (void)dealloc
{
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginHandleOpenURLNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginResetNotification object:nil];
-
- /*
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
- */
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginHandleOpenURLNotification object:nil];
++ [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginResetNotification object:nil];
+
+ /*
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
+ */
}
- - (id) appDelegate
+ - (id)appDelegate
{
- return [[UIApplication sharedApplication] delegate];
+ return [[UIApplication sharedApplication] delegate];
}
- - (NSString*) writeJavascript:(NSString*)javascript
+ - (NSString*)writeJavascript:(NSString*)javascript
{
- return [self.webView stringByEvaluatingJavaScriptFromString:javascript];
+ return [self.webView stringByEvaluatingJavaScriptFromString:javascript];
}
- - (NSString*) success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
+ - (NSString*)success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
{
- return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toSuccessCallbackString:callbackId]]];
+ return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toSuccessCallbackString:callbackId]]];
}
- - (NSString*) error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
+ - (NSString*)error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
{
- return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toErrorCallbackString:callbackId]]];
+ return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toErrorCallbackString:callbackId]]];
}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/1f13eb69/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --cc CordovaLib/Classes/CDVViewController.m
index 027c05b,2121363..c8db901
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@@ -475,10 -481,8 +481,10 @@@
When web application loads Add stuff to the DOM, mainly the user-defined settings from the Settings.plist file, and
the device's data such as device ID, platform version, etc.
*/
- - (void) webViewDidStartLoad:(UIWebView*)theWebView
+ - (void)webViewDidStartLoad:(UIWebView*)theWebView
-{}
+{
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginResetNotification object:nil]];
+}
/**
Called when the webview finishes loading. This stops the activity view and closes the imageview
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/1f13eb69/bin/templates/project/www/cordova-2.1.0.js
----------------------------------------------------------------------
diff --cc bin/templates/project/www/cordova-2.1.0.js
index e96ef50,e96ef50..cce90a9
--- a/bin/templates/project/www/cordova-2.1.0.js
+++ b/bin/templates/project/www/cordova-2.1.0.js
@@@ -1,6 -1,6 +1,6 @@@
--// commit 143f5221a6251c9cbccdedc57005c61551b97f12
++// commit d30179b30152b9383a80637e609cf2d785e1aa3e
--// File generated at :: Wed Sep 12 2012 15:26:58 GMT-0700 (PDT)
++// File generated at :: Tue Sep 18 2012 11:34:26 GMT-0400 (EDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@@ -24,11 -24,11 +24,16 @@@
;(function() {
// file: lib/scripts/require.js
++
var require,
define;
(function () {
var modules = {};
++ // Stack of moduleIds currently being built.
++ var requireStack = [];
++ // Map of module ID -> index into requireStack of modules currently being built.
++ var inProgressModules = {};
function build(module) {
var factory = module.factory;
@@@ -41,8 -41,8 +46,21 @@@
require = function (id) {
if (!modules[id]) {
throw "module " + id + " not found";
++ } else if (id in inProgressModules) {
++ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
++ throw "Cycle in require graph: " + cycle;
++ }
++ if (modules[id].factory) {
++ try {
++ inProgressModules[id] = requireStack.length;
++ requireStack.push(id);
++ return build(modules[id]);
++ } finally {
++ delete inProgressModules[id];
++ requireStack.pop();
++ }
}
-- return modules[id].factory ? build(modules[id]) : modules[id].exports;
++ return modules[id].exports;
};
define = function (id, factory) {
@@@ -67,8 -67,8 +85,11 @@@ if (typeof module === "object" && typeo
module.exports.require = require;
module.exports.define = define;
}
++
// file: lib/cordova.js
define("cordova", function(require, exports, module) {
++
++
var channel = require('cordova/channel');
/**
@@@ -99,11 -99,11 +120,7 @@@ var documentEventHandlers = {}
document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (typeof documentEventHandlers[e] != 'undefined') {
-- if (evt === 'deviceready') {
-- documentEventHandlers[e].subscribeOnce(handler);
-- } else {
-- documentEventHandlers[e].subscribe(handler);
-- }
++ documentEventHandlers[e].subscribe(handler);
} else {
m_document_addEventListener.call(document, evt, handler, capture);
}
@@@ -163,11 -163,11 +180,14 @@@ var cordova =
/**
* Methods to add/remove your own addEventListener hijacking on document + window.
*/
-- addWindowEventHandler:function(event, opts) {
-- return (windowEventHandlers[event] = channel.create(event, opts));
++ addWindowEventHandler:function(event) {
++ return (windowEventHandlers[event] = channel.create(event));
++ },
++ addStickyDocumentEventHandler:function(event) {
++ return (documentEventHandlers[event] = channel.createSticky(event));
},
-- addDocumentEventHandler:function(event, opts) {
-- return (documentEventHandlers[event] = channel.create(event, opts));
++ addDocumentEventHandler:function(event) {
++ return (documentEventHandlers[event] = channel.create(event));
},
removeWindowEventHandler:function(event) {
delete windowEventHandlers[event];
@@@ -242,57 -242,57 +262,48 @@@
/**
* Called by native code when returning successful result from an action.
-- *
-- * @param callbackId
-- * @param args
*/
callbackSuccess: function(callbackId, args) {
-- if (cordova.callbacks[callbackId]) {
--
-- // If result is to be sent to callback
-- if (args.status == cordova.callbackStatus.OK) {
-- try {
-- if (cordova.callbacks[callbackId].success) {
-- cordova.callbacks[callbackId].success(args.message);
-- }
-- }
-- catch (e) {
-- console.log("Error in success callback: "+callbackId+" = "+e);
-- }
-- }
--
-- // Clear callback if not expecting any more results
-- if (!args.keepCallback) {
-- delete cordova.callbacks[callbackId];
-- }
++ try {
++ cordova.callbackFromNative(callbackId, true, args.status, args.message, args.keepCallback);
++ } catch (e) {
++ console.log("Error in error callback: " + callbackId + " = "+e);
}
},
/**
* Called by native code when returning error result from an action.
-- *
-- * @param callbackId
-- * @param args
*/
callbackError: function(callbackId, args) {
-- if (cordova.callbacks[callbackId]) {
-- try {
-- if (cordova.callbacks[callbackId].fail) {
-- cordova.callbacks[callbackId].fail(args.message);
-- }
-- }
-- catch (e) {
-- console.log("Error in error callback: "+callbackId+" = "+e);
++ // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
++ // Derive success from status.
++ try {
++ cordova.callbackFromNative(callbackId, false, args.status, args.message, args.keepCallback);
++ } catch (e) {
++ console.log("Error in error callback: " + callbackId + " = "+e);
++ }
++ },
++
++ /**
++ * Called by native code when returning the result from an action.
++ */
++ callbackFromNative: function(callbackId, success, status, message, keepCallback) {
++ var callback = cordova.callbacks[callbackId];
++ if (callback) {
++ if (success && status == cordova.callbackStatus.OK) {
++ callback.success && callback.success(message);
++ } else if (!success) {
++ callback.fail && callback.fail(message);
}
// Clear callback if not expecting any more results
-- if (!args.keepCallback) {
++ if (!keepCallback) {
delete cordova.callbacks[callbackId];
}
}
},
addConstructor: function(func) {
-- channel.onCordovaReady.subscribeOnce(function() {
++ channel.onCordovaReady.subscribe(function() {
try {
func();
} catch(e) {
@@@ -305,7 -305,7 +316,7 @@@
// Register pause, resume and deviceready channels as events on document.
channel.onPause = cordova.addDocumentEventHandler('pause');
channel.onResume = cordova.addDocumentEventHandler('resume');
--channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
++channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
module.exports = cordova;
@@@ -313,6 -313,6 +324,7 @@@
// file: lib/common/builder.js
define("cordova/builder", function(require, exports, module) {
++
var utils = require('cordova/utils');
function each(objects, func, context) {
@@@ -323,6 -323,6 +335,17 @@@
}
}
++function assignOrWrapInDeprecateGetter(obj, key, value, message) {
++ if (message) {
++ utils.defineGetter(obj, key, function() {
++ window.console && console.log(message);
++ return value;
++ });
++ } else {
++ obj[key] = value;
++ }
++}
++
function include(parent, objects, clobber, merge) {
each(objects, function (obj, key) {
try {
@@@ -331,20 -331,20 +354,20 @@@
if (clobber) {
// Clobber if it doesn't exist.
if (typeof parent[key] === 'undefined') {
-- parent[key] = result;
++ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
} else if (typeof obj.path !== 'undefined') {
// If merging, merge properties onto parent, otherwise, clobber.
if (merge) {
recursiveMerge(parent[key], result);
} else {
-- parent[key] = result;
++ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
}
}
result = parent[key];
} else {
// Overwrite if not currently defined.
if (typeof parent[key] == 'undefined') {
-- parent[key] = result;
++ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
} else if (merge && typeof obj.path !== 'undefined') {
// If merging, merge parent onto result
recursiveMerge(result, parent[key]);
@@@ -406,25 -406,25 +429,29 @@@ module.exports =
// file: lib/common/channel.js
define("cordova/channel", function(require, exports, module) {
++
var utils = require('cordova/utils'),
nextGuid = 1;
/**
* Custom pub-sub "channel" that can have functions subscribed to it
* This object is used to define and control firing of events for
-- * cordova initialization.
++ * cordova initialization, as well as for custom events thereafter.
*
* The order of events during page load and Cordova startup is as follows:
*
-- * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
-- * onNativeReady Internal event that indicates the Cordova native side is ready.
-- * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created.
-- * onCordovaInfoReady Internal event fired when device properties are available.
-- * onCordovaConnectionReady Internal event fired when the connection property has been set.
-- * onDeviceReady User event fired to indicate that Cordova is ready
-- * onResume User event fired to indicate a start/resume lifecycle event
-- * onPause User event fired to indicate a pause lifecycle event
-- * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
++ * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
++ * onNativeReady* Internal event that indicates the Cordova native side is ready.
++ * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
++ * onCordovaInfoReady* Internal event fired when device properties are available.
++ * onCordovaConnectionReady* Internal event fired when the connection property has been set.
++ * onDeviceReady* User event fired to indicate that Cordova is ready
++ * onResume User event fired to indicate a start/resume lifecycle event
++ * onPause User event fired to indicate a pause lifecycle event
++ * onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
++ *
++ * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
++ * All listeners that subscribe after the event is fired will be executed right away.
*
* The only Cordova events that user code should register for are:
* deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
@@@ -446,49 -446,49 +473,45 @@@
* Channel
* @constructor
* @param type String the channel name
-- * @param opts Object options to pass into the channel, currently
-- * supports:
-- * onSubscribe: callback that fires when
-- * something subscribes to the Channel. Sets
-- * context to the Channel.
-- * onUnsubscribe: callback that fires when
-- * something unsubscribes to the Channel. Sets
-- * context to the Channel.
*/
--var Channel = function(type, opts) {
++var Channel = function(type, sticky) {
this.type = type;
++ // Map of guid -> function.
this.handlers = {};
++ // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
++ this.state = sticky ? 1 : 0;
++ // Used in sticky mode to remember args passed to fire().
++ this.fireArgs = null;
++ // Used by onHasSubscribersChange to know if there are any listeners.
this.numHandlers = 0;
-- this.fired = false;
-- this.enabled = true;
-- this.events = {
-- onSubscribe:null,
-- onUnsubscribe:null
-- };
-- if (opts) {
-- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
-- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
-- }
++ // Function that is called when the first listener is subscribed, or when
++ // the last listener is unsubscribed.
++ this.onHasSubscribersChange = null;
},
channel = {
/**
* Calls the provided function only after all of the channels specified
-- * have been fired.
++ * have been fired. All channels must be sticky channels.
*/
-- join: function (h, c) {
-- var i = c.length;
-- var len = i;
-- var f = function() {
-- if (!(--i)) h();
-- };
++ join: function(h, c) {
++ var len = c.length,
++ i = len,
++ f = function() {
++ if (!(--i)) h();
++ };
for (var j=0; j<len; j++) {
-- !c[j].fired?c[j].subscribeOnce(f):i--;
++ if (c[j].state == 0) {
++ throw Error('Can only use join with sticky channels.')
++ }
++ c[j].subscribe(f);
}
-- if (!i) h();
++ if (!len) h();
++ },
++ create: function(type) {
++ return channel[type] = new Channel(type, false);
},
-- create: function (type, opts) {
-- channel[type] = new Channel(type, opts);
-- return channel[type];
++ createSticky: function(type) {
++ return channel[type] = new Channel(type, true);
},
/**
@@@ -506,13 -506,13 +529,7 @@@
*/
waitForInitialization: function(feature) {
if (feature) {
-- var c = null;
-- if (this[feature]) {
-- c = this[feature];
-- }
-- else {
-- c = this.create(feature);
-- }
++ var c = channel[feature] || this.createSticky(feature);
this.deviceReadyChannelsMap[feature] = c;
this.deviceReadyChannelsArray.push(c);
}
@@@ -532,7 -532,7 +549,7 @@@
};
function forceFunction(f) {
-- if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
++ if (typeof f != 'function') throw "Function required as first argument!";
}
/**
@@@ -542,67 -542,67 +559,50 @@@
* and a guid that can be used to stop subscribing to the channel.
* Returns the guid.
*/
--Channel.prototype.subscribe = function(f, c, g) {
++Channel.prototype.subscribe = function(f, c) {
// need a function to call
forceFunction(f);
++ if (this.state == 2) {
++ f.apply(c || this, this.fireArgs);
++ return;
++ }
-- var func = f;
++ var func = f,
++ guid = f.observer_guid;
if (typeof c == "object") { func = utils.close(c, f); }
-- g = g || func.observer_guid || f.observer_guid;
-- if (!g) {
++ if (!guid) {
// first time any channel has seen this subscriber
-- g = nextGuid++;
++ guid = '' + nextGuid++;
}
-- func.observer_guid = g;
-- f.observer_guid = g;
++ func.observer_guid = guid;
++ f.observer_guid = guid;
// Don't add the same handler more than once.
-- if (!this.handlers[g]) {
-- this.handlers[g] = func;
++ if (!this.handlers[guid]) {
++ this.handlers[guid] = func;
this.numHandlers++;
-- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
-- if (this.fired) func.apply(this, this.fireArgs);
-- }
-- return g;
--};
--
--/**
-- * Like subscribe but the function is only called once and then it
-- * auto-unsubscribes itself.
-- */
--Channel.prototype.subscribeOnce = function(f, c) {
-- // need a function to call
-- forceFunction(f);
--
-- var g = null;
-- var _this = this;
-- if (this.fired) {
-- f.apply(c || null, this.fireArgs);
-- } else {
-- g = this.subscribe(function() {
-- _this.unsubscribe(g);
-- f.apply(c || null, arguments);
-- });
-- f.observer_guid = g;
++ if (this.numHandlers == 1) {
++ this.onHasSubscribersChange && this.onHasSubscribersChange();
++ }
}
-- return g;
};
/**
* Unsubscribes the function with the given guid from the channel.
*/
--Channel.prototype.unsubscribe = function(g) {
++Channel.prototype.unsubscribe = function(f) {
// need a function to unsubscribe
-- if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
++ forceFunction(f);
-- if (typeof g == 'function') { g = g.observer_guid; }
-- var handler = this.handlers[g];
++ var guid = f.observer_guid,
++ handler = this.handlers[guid];
if (handler) {
-- if (handler.observer_guid) handler.observer_guid=null;
-- delete this.handlers[g];
++ delete this.handlers[guid];
this.numHandlers--;
-- if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
++ if (this.numHandlers == 0) {
++ this.onHasSubscribersChange && this.onHasSubscribersChange();
++ }
}
};
@@@ -610,10 -610,10 +610,14 @@@
* Calls all functions subscribed to this channel.
*/
Channel.prototype.fire = function(e) {
-- if (this.enabled) {
-- var fail = false;
-- this.fired = true;
-- this.fireArgs = arguments;
++ var fail = false,
++ fireArgs = Array.prototype.slice.call(arguments);
++ // Apply stickiness.
++ if (this.state == 1) {
++ this.state = 2;
++ this.fireArgs = fireArgs;
++ }
++ if (this.numHandlers) {
// Copy the values first so that it is safe to modify it from within
// callbacks.
var toCall = [];
@@@ -621,33 -621,33 +625,36 @@@
toCall.push(this.handlers[item]);
}
for (var i = 0; i < toCall.length; ++i) {
-- var rv = (toCall[i].apply(this, arguments)===false);
-- fail = fail || rv;
++ toCall[i].apply(this, fireArgs);
++ }
++ if (this.state == 2 && this.numHandlers) {
++ this.numHandlers = 0;
++ this.handlers = {};
++ this.onHasSubscribersChange && this.onHasSubscribersChange();
}
-- return !fail;
}
-- return true;
};
++
// defining them here so they are ready super fast!
// DOM event that is received when the web page is loaded and parsed.
--channel.create('onDOMContentLoaded');
++channel.createSticky('onDOMContentLoaded');
// Event to indicate the Cordova native side is ready.
--channel.create('onNativeReady');
++channel.createSticky('onNativeReady');
// Event to indicate that all Cordova JavaScript objects have been created
// and it's time to run plugin constructors.
--channel.create('onCordovaReady');
++channel.createSticky('onCordovaReady');
// Event to indicate that device properties are available
--channel.create('onCordovaInfoReady');
++channel.createSticky('onCordovaInfoReady');
// Event to indicate that the connection property has been set.
--channel.create('onCordovaConnectionReady');
++channel.createSticky('onCordovaConnectionReady');
// Event to indicate that Cordova is ready
--channel.create('onDeviceReady');
++channel.createSticky('onDeviceReady');
// Event to indicate a resume lifecycle event
channel.create('onResume');
@@@ -656,7 -656,7 +663,7 @@@
channel.create('onPause');
// Event to indicate a destroy lifecycle event
--channel.create('onDestroy');
++channel.createSticky('onDestroy');
// Channels that must fire before "deviceready" is fired.
channel.waitForInitialization('onCordovaReady');
@@@ -668,6 -668,6 +675,7 @@@ module.exports = channel
// file: lib/common/common.js
define("cordova/common", function(require, exports, module) {
++
module.exports = {
objects: {
cordova: {
@@@ -705,6 -705,6 +713,9 @@@
compass:{
path: 'cordova/plugin/compass'
},
++ connection: {
++ path: 'cordova/plugin/network'
++ },
contacts: {
path: 'cordova/plugin/contacts'
},
@@@ -721,7 -721,7 +732,8 @@@
network: {
children: {
connection: {
-- path: 'cordova/plugin/network'
++ path: 'cordova/plugin/network',
++ deprecated: 'navigator.network.connection is deprecated. Use navigator.connection instead.'
}
}
},
@@@ -872,6 -872,6 +884,7 @@@
// file: lib/ios/exec.js
define("cordova/exec", function(require, exports, module) {
++
/**
* Creates a gap bridge iframe used to notify the native code about queued
* commands.
@@@ -918,7 -918,7 +931,7 @@@ function shouldBundleCommandJson()
}
function iOSExec() {
-- if (!channel.onCordovaReady.fired) {
++ if (channel.onCordovaReady.state != 2) {
utils.alert("ERROR: Attempting to call cordova.exec()" +
" before 'deviceready'. Ignoring.");
return;
@@@ -1003,6 -1003,6 +1016,7 @@@ module.exports = iOSExec
// file: lib/ios/platform.js
define("cordova/platform", function(require, exports, module) {
++
module.exports = {
id: "ios",
initialize:function() {
@@@ -1059,6 -1059,6 +1073,7 @@@ logger.useConsole(false)
// file: lib/common/plugin/Acceleration.js
define("cordova/plugin/Acceleration", function(require, exports, module) {
++
var Acceleration = function(x, y, z, timestamp) {
this.x = x;
this.y = y;
@@@ -1072,6 -1072,6 +1087,7 @@@ module.exports = Acceleration
// file: lib/common/plugin/Camera.js
define("cordova/plugin/Camera", function(require, exports, module) {
++
var exec = require('cordova/exec'),
Camera = require('cordova/plugin/CameraConstants');
@@@ -1188,10 -1188,10 +1204,12 @@@ cameraExport.cleanup = function(success
};
module.exports = cameraExport;
++
});
// file: lib/common/plugin/CameraConstants.js
define("cordova/plugin/CameraConstants", function(require, exports, module) {
++
module.exports = {
DestinationType:{
DATA_URL: 0, // Return base64 encoded string
@@@ -1219,10 -1219,10 +1237,12 @@@
ARROW_ANY : 15
}
};
++
});
// file: lib/common/plugin/CameraPopoverOptions.js
define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
++
var Camera = require('cordova/plugin/CameraConstants');
/**
@@@ -1239,10 -1239,10 +1259,12 @@@ var CameraPopoverOptions = function(x,y
};
module.exports = CameraPopoverOptions;
++
});
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
++
/**
* Encapsulates all audio capture operation configuration options.
*/
@@@ -1256,10 -1256,10 +1278,12 @@@ var CaptureAudioOptions = function()
};
module.exports = CaptureAudioOptions;
++
});
// file: lib/common/plugin/CaptureError.js
define("cordova/plugin/CaptureError", function(require, exports, module) {
++
/**
* The CaptureError interface encapsulates all errors in the Capture API.
*/
@@@ -1279,10 -1279,10 +1303,12 @@@ CaptureError.CAPTURE_NO_MEDIA_FILES = 3
CaptureError.CAPTURE_NOT_SUPPORTED = 20;
module.exports = CaptureError;
++
});
// file: lib/common/plugin/CaptureImageOptions.js
define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
++
/**
* Encapsulates all image capture operation configuration options.
*/
@@@ -1294,10 -1294,10 +1320,12 @@@ var CaptureImageOptions = function()
};
module.exports = CaptureImageOptions;
++
});
// file: lib/common/plugin/CaptureVideoOptions.js
define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
++
/**
* Encapsulates all video capture operation configuration options.
*/
@@@ -1311,10 -1311,10 +1339,12 @@@ var CaptureVideoOptions = function()
};
module.exports = CaptureVideoOptions;
++
});
// file: lib/common/plugin/CompassError.js
define("cordova/plugin/CompassError", function(require, exports, module) {
++
/**
* CompassError.
* An error code assigned by an implementation when an error has occured
@@@ -1328,10 -1328,10 +1358,12 @@@ CompassError.COMPASS_INTERNAL_ERR = 0
CompassError.COMPASS_NOT_SUPPORTED = 20;
module.exports = CompassError;
++
});
// file: lib/common/plugin/CompassHeading.js
define("cordova/plugin/CompassHeading", function(require, exports, module) {
++
var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
@@@ -1340,10 -1340,10 +1372,12 @@@
};
module.exports = CompassHeading;
++
});
// file: lib/common/plugin/ConfigurationData.js
define("cordova/plugin/ConfigurationData", function(require, exports, module) {
++
/**
* Encapsulates a set of parameters that the capture device supports.
*/
@@@ -1359,10 -1359,10 +1393,12 @@@ function ConfigurationData()
}
module.exports = ConfigurationData;
++
});
// file: lib/common/plugin/Connection.js
define("cordova/plugin/Connection", function(require, exports, module) {
++
/**
* Network status
*/
@@@ -1375,10 -1375,10 +1411,12 @@@ module.exports =
CELL_4G: "4g",
NONE: "none"
};
++
});
// file: lib/common/plugin/Contact.js
define("cordova/plugin/Contact", function(require, exports, module) {
++
var exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils');
@@@ -1561,6 -1561,6 +1599,7 @@@ module.exports = Contact
// file: lib/common/plugin/ContactAddress.js
define("cordova/plugin/ContactAddress", function(require, exports, module) {
++
/**
* Contact address.
* @constructor
@@@ -1586,10 -1586,10 +1625,12 @@@ var ContactAddress = function(pref, typ
};
module.exports = ContactAddress;
++
});
// file: lib/common/plugin/ContactError.js
define("cordova/plugin/ContactError", function(require, exports, module) {
++
/**
* ContactError.
* An error code assigned by an implementation when an error has occured
@@@ -1611,10 -1611,10 +1652,12 @@@ ContactError.NOT_SUPPORTED_ERROR = 5
ContactError.PERMISSION_DENIED_ERROR = 20;
module.exports = ContactError;
++
});
// file: lib/common/plugin/ContactField.js
define("cordova/plugin/ContactField", function(require, exports, module) {
++
/**
* Generic contact field.
* @constructor
@@@ -1631,10 -1631,10 +1674,12 @@@ var ContactField = function(type, value
};
module.exports = ContactField;
++
});
// file: lib/common/plugin/ContactFindOptions.js
define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
++
/**
* ContactFindOptions.
* @constructor
@@@ -1648,10 -1648,10 +1693,12 @@@ var ContactFindOptions = function(filte
};
module.exports = ContactFindOptions;
++
});
// file: lib/common/plugin/ContactName.js
define("cordova/plugin/ContactName", function(require, exports, module) {
++
/**
* Contact name.
* @constructor
@@@ -1672,10 -1672,10 +1719,12 @@@ var ContactName = function(formatted, f
};
module.exports = ContactName;
++
});
// file: lib/common/plugin/ContactOrganization.js
define("cordova/plugin/ContactOrganization", function(require, exports, module) {
++
/**
* Contact organization.
* @constructor
@@@ -1699,10 -1699,10 +1748,12 @@@ var ContactOrganization = function(pref
};
module.exports = ContactOrganization;
++
});
// file: lib/common/plugin/Coordinates.js
define("cordova/plugin/Coordinates", function(require, exports, module) {
++
/**
* This class contains position information.
* @param {Object} lat
@@@ -1756,6 -1756,6 +1807,7 @@@ module.exports = Coordinates
// file: lib/common/plugin/DirectoryEntry.js
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
++
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
Entry = require('cordova/plugin/Entry'),
@@@ -1842,6 -1842,6 +1894,7 @@@ module.exports = DirectoryEntry
// file: lib/common/plugin/DirectoryReader.js
define("cordova/plugin/DirectoryReader", function(require, exports, module) {
++
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError') ;
@@@ -1889,6 -1889,6 +1942,7 @@@ module.exports = DirectoryReader
// file: lib/common/plugin/Entry.js
define("cordova/plugin/Entry", function(require, exports, module) {
++
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError'),
Metadata = require('cordova/plugin/Metadata');
@@@ -2107,10 -2107,10 +2161,12 @@@ Entry.prototype.getParent = function(su
};
module.exports = Entry;
++
});
// file: lib/common/plugin/File.js
define("cordova/plugin/File", function(require, exports, module) {
++
/**
* Constructor.
* name {DOMString} name of the file, without path information
@@@ -2129,10 -2129,10 +2185,12 @@@ var File = function(name, fullPath, typ
};
module.exports = File;
++
});
// file: lib/common/plugin/FileEntry.js
define("cordova/plugin/FileEntry", function(require, exports, module) {
++
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
Entry = require('cordova/plugin/Entry'),
@@@ -2196,10 -2196,10 +2254,12 @@@ FileEntry.prototype.file = function(suc
module.exports = FileEntry;
++
});
// file: lib/common/plugin/FileError.js
define("cordova/plugin/FileError", function(require, exports, module) {
++
/**
* FileError
*/
@@@ -2225,10 -2225,10 +2285,12 @@@ FileError.TYPE_MISMATCH_ERR = 11
FileError.PATH_EXISTS_ERR = 12;
module.exports = FileError;
++
});
// file: lib/common/plugin/FileReader.js
define("cordova/plugin/FileReader", function(require, exports, module) {
++
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError'),
ProgressEvent = require('cordova/plugin/ProgressEvent');
@@@ -2478,10 -2478,10 +2540,12 @@@ FileReader.prototype.readAsArrayBuffer
};
module.exports = FileReader;
++
});
// file: lib/common/plugin/FileSystem.js
define("cordova/plugin/FileSystem", function(require, exports, module) {
++
var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
/**
@@@ -2504,6 -2504,6 +2568,7 @@@ module.exports = FileSystem
// file: lib/common/plugin/FileTransfer.js
define("cordova/plugin/FileTransfer", function(require, exports, module) {
++
var exec = require('cordova/exec'),
FileTransferError = require('cordova/plugin/FileTransferError');
@@@ -2596,6 -2596,6 +2661,7 @@@ module.exports = FileTransfer
// file: lib/common/plugin/FileTransferError.js
define("cordova/plugin/FileTransferError", function(require, exports, module) {
++
/**
* FileTransferError
* @constructor
@@@ -2617,6 -2617,6 +2683,7 @@@ module.exports = FileTransferError
// file: lib/common/plugin/FileUploadOptions.js
define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
++
/**
* Options to customize the HTTP request used to upload files.
* @constructor
@@@ -2641,6 -2641,6 +2708,7 @@@ module.exports = FileUploadOptions
// file: lib/common/plugin/FileUploadResult.js
define("cordova/plugin/FileUploadResult", function(require, exports, module) {
++
/**
* FileUploadResult
* @constructor
@@@ -2652,10 -2652,10 +2720,12 @@@ var FileUploadResult = function()
};
module.exports = FileUploadResult;
++
});
// file: lib/common/plugin/FileWriter.js
define("cordova/plugin/FileWriter", function(require, exports, module) {
++
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError'),
ProgressEvent = require('cordova/plugin/ProgressEvent');
@@@ -2914,6 -2914,6 +2984,7 @@@ module.exports = FileWriter
// file: lib/common/plugin/Flags.js
define("cordova/plugin/Flags", function(require, exports, module) {
++
/**
* Supplies arguments to methods that lookup or create files and directories.
*
@@@ -2929,10 -2929,10 +3000,12 @@@ function Flags(create, exclusive)
}
module.exports = Flags;
++
});
// file: lib/common/plugin/LocalFileSystem.js
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
++
var exec = require('cordova/exec');
/**
@@@ -2946,10 -2946,10 +3019,12 @@@ LocalFileSystem.TEMPORARY = 0; //tempor
LocalFileSystem.PERSISTENT = 1; //persistent
module.exports = LocalFileSystem;
++
});
// file: lib/common/plugin/Media.js
define("cordova/plugin/Media", function(require, exports, module) {
++
var utils = require('cordova/utils'),
exec = require('cordova/exec');
@@@ -3141,10 -3141,10 +3216,12 @@@ Media.onStatus = function(id, msgType,
};
module.exports = Media;
++
});
// file: lib/common/plugin/MediaError.js
define("cordova/plugin/MediaError", function(require, exports, module) {
++
/**
* This class contains information about any Media errors.
*/
@@@ -3181,6 -3181,6 +3258,7 @@@ module.exports = MediaError
// file: lib/common/plugin/MediaFile.js
define("cordova/plugin/MediaFile", function(require, exports, module) {
++
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
File = require('cordova/plugin/File'),
@@@ -3220,6 -3220,6 +3298,7 @@@ module.exports = MediaFile
// file: lib/common/plugin/MediaFileData.js
define("cordova/plugin/MediaFileData", function(require, exports, module) {
++
/**
* MediaFileData encapsulates format information of a media file.
*
@@@ -3238,10 -3238,10 +3317,12 @@@ var MediaFileData = function(codecs, bi
};
module.exports = MediaFileData;
++
});
// file: lib/common/plugin/Metadata.js
define("cordova/plugin/Metadata", function(require, exports, module) {
++
/**
* Information about the state of the file or directory
*
@@@ -3252,10 -3252,10 +3333,12 @@@ var Metadata = function(time)
};
module.exports = Metadata;
++
});
// file: lib/common/plugin/Position.js
define("cordova/plugin/Position", function(require, exports, module) {
++
var Coordinates = require('cordova/plugin/Coordinates');
var Position = function(coords, timestamp) {
@@@ -3273,6 -3273,6 +3356,7 @@@ module.exports = Position
// file: lib/common/plugin/PositionError.js
define("cordova/plugin/PositionError", function(require, exports, module) {
++
/**
* Position error object
*
@@@ -3290,10 -3290,10 +3374,12 @@@ PositionError.POSITION_UNAVAILABLE = 2
PositionError.TIMEOUT = 3;
module.exports = PositionError;
++
});
// file: lib/common/plugin/ProgressEvent.js
define("cordova/plugin/ProgressEvent", function(require, exports, module) {
++
// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
// Feature test: See if we can instantiate a native ProgressEvent;
// if so, use that approach,
@@@ -3340,10 -3340,10 +3426,12 @@@ var ProgressEvent = (function()
})();
module.exports = ProgressEvent;
++
});
// file: lib/common/plugin/accelerometer.js
define("cordova/plugin/accelerometer", function(require, exports, module) {
++
/**
* This class provides access to device accelerometer data.
* @constructor
@@@ -3504,6 -3504,6 +3592,7 @@@ module.exports = accelerometer
// file: lib/common/plugin/battery.js
define("cordova/plugin/battery", function(require, exports, module) {
++
/**
* This class contains information about the current battery status.
* @constructor
@@@ -3521,34 -3521,34 +3610,26 @@@ var Battery = function()
this._level = null;
this._isPlugged = null;
// Create new event handlers on the window (returns a channel instance)
-- var subscriptionEvents = {
-- onSubscribe:this.onSubscribe,
-- onUnsubscribe:this.onUnsubscribe
-- };
this.channels = {
-- batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
-- batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
-- batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
++ batterystatus:cordova.addWindowEventHandler("batterystatus"),
++ batterylow:cordova.addWindowEventHandler("batterylow"),
++ batterycritical:cordova.addWindowEventHandler("batterycritical")
};
++ for (var key in this.channels) {
++ this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
++ }
++
};
/**
* Event handlers for when callbacks get registered for the battery.
* Keep track of how many handlers we have so we can start and stop the native battery listener
* appropriately (and hopefully save on battery life!).
*/
--Battery.prototype.onSubscribe = function() {
-- var me = battery;
++Battery.onHasSubscribersChange = function() {
// If we just registered the first handler, make sure native listener is started.
-- if (handlers() === 1) {
-- exec(me._status, me._error, "Battery", "start", []);
-- }
--};
--
--Battery.prototype.onUnsubscribe = function() {
-- var me = battery;
--
-- // If we just unregistered the last handler, make sure native listener is stopped.
-- if (handlers() === 0) {
++ if (this.numHandlers === 1 && handlers() === 1) {
++ exec(battery._status, battery._error, "Battery", "start", []);
++ } else if (handlers() === 0) {
exec(null, null, "Battery", "stop", []);
}
};
@@@ -3591,10 -3591,10 +3672,12 @@@ Battery.prototype._error = function(e)
var battery = new Battery();
module.exports = battery;
++
});
// file: lib/common/plugin/capture.js
define("cordova/plugin/capture", function(require, exports, module) {
++
var exec = require('cordova/exec'),
MediaFile = require('cordova/plugin/MediaFile');
@@@ -3672,6 -3672,6 +3755,7 @@@ module.exports = new Capture()
// file: lib/common/plugin/compass.js
define("cordova/plugin/compass", function(require, exports, module) {
++
var exec = require('cordova/exec'),
utils = require('cordova/utils'),
CompassHeading = require('cordova/plugin/CompassHeading'),
@@@ -3773,10 -3773,10 +3857,12 @@@
};
module.exports = compass;
++
});
// file: lib/common/plugin/console-via-logger.js
define("cordova/plugin/console-via-logger", function(require, exports, module) {
++
//------------------------------------------------------------------------------
var logger = require("cordova/plugin/logger");
@@@ -3948,6 -3948,6 +4034,7 @@@ for (var key in console)
// file: lib/common/plugin/contacts.js
define("cordova/plugin/contacts", function(require, exports, module) {
++
var exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils'),
@@@ -4011,6 -4011,6 +4098,7 @@@ module.exports = contacts
// file: lib/common/plugin/device.js
define("cordova/plugin/device", function(require, exports, module) {
++
var channel = require('cordova/channel'),
utils = require('cordova/utils'),
exec = require('cordova/exec');
@@@ -4033,7 -4033,7 +4121,7 @@@ function Device()
var me = this;
-- channel.onCordovaReady.subscribeOnce(function() {
++ channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.available = true;
me.platform = info.platform;
@@@ -4079,6 -4079,6 +4167,7 @@@ module.exports = new Device()
// file: lib/common/plugin/echo.js
define("cordova/plugin/echo", function(require, exports, module) {
++
var exec = require('cordova/exec');
/**
@@@ -4098,6 -4098,6 +4187,7 @@@ module.exports = function(successCallba
// file: lib/common/plugin/geolocation.js
define("cordova/plugin/geolocation", function(require, exports, module) {
++
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
PositionError = require('cordova/plugin/PositionError'),
@@@ -4162,11 -4162,11 +4252,11 @@@ var geolocation =
// Timer var that will fire an error callback if no position is retrieved from native
// before the "timeout" param provided expires
-- var timeoutTimer = null;
++ var timeoutTimer = {timer:null};
var win = function(p) {
-- clearTimeout(timeoutTimer);
-- if (!timeoutTimer) {
++ clearTimeout(timeoutTimer.timer);
++ if (!(timeoutTimer.timer)) {
// Timeout already happened, or native fired error callback for
// this geo request.
// Don't continue with success callback.
@@@ -4188,8 -4188,8 +4278,8 @@@
successCallback(pos);
};
var fail = function(e) {
-- clearTimeout(timeoutTimer);
-- timeoutTimer = null;
++ clearTimeout(timeoutTimer.timer);
++ timeoutTimer.timer = null;
var err = new PositionError(e.code, e.message);
if (errorCallback) {
errorCallback(err);
@@@ -4212,12 -4212,12 +4302,12 @@@
// If the timeout value was not set to Infinity (default), then
// set up a timeout function that will fire the error callback
// if no successful position was retrieved before timeout expired.
-- timeoutTimer = createTimeout(fail, options.timeout);
++ timeoutTimer.timer = createTimeout(fail, options.timeout);
} else {
// This is here so the check in the win function doesn't mess stuff up
// may seem weird but this guarantees timeoutTimer is
// always truthy before we call into native
-- timeoutTimer = true;
++ timeoutTimer.timer = true;
}
exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
}
@@@ -4244,7 -4244,7 +4334,7 @@@
timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
var fail = function(e) {
-- clearTimeout(timers[id]);
++ clearTimeout(timers[id].timer);
var err = new PositionError(e.code, e.message);
if (errorCallback) {
errorCallback(err);
@@@ -4252,9 -4252,9 +4342,9 @@@
};
var win = function(p) {
-- clearTimeout(timers[id]);
++ clearTimeout(timers[id].timer);
if (options.timeout !== Infinity) {
-- timers[id] = createTimeout(fail, options.timeout);
++ timers[id].timer = createTimeout(fail, options.timeout);
}
var pos = new Position(
{
@@@ -4283,8 -4283,8 +4373,8 @@@
*/
clearWatch:function(id) {
if (id && timers[id] !== undefined) {
-- clearTimeout(timers[id]);
-- delete timers[id];
++ clearTimeout(timers[id].timer);
++ timers[id].timer = false;
exec(null, null, "Geolocation", "clearWatch", [id]);
}
}
@@@ -4296,6 -4296,6 +4386,7 @@@ module.exports = geolocation
// file: lib/ios/plugin/ios/Contact.js
define("cordova/plugin/ios/Contact", function(require, exports, module) {
++
var exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError');
@@@ -4326,10 -4326,10 +4417,12 @@@ module.exports =
}
}
};
++
});
// file: lib/ios/plugin/ios/Entry.js
define("cordova/plugin/ios/Entry", function(require, exports, module) {
++
module.exports = {
toURL:function() {
// TODO: refactor path in a cross-platform way so we can eliminate
@@@ -4341,10 -4341,10 +4434,12 @@@
return "file://localhost" + this.fullPath;
}
};
++
});
// file: lib/ios/plugin/ios/FileReader.js
define("cordova/plugin/ios/FileReader", function(require, exports, module) {
++
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError'),
FileReader = require('cordova/plugin/FileReader'),
@@@ -4432,10 -4432,10 +4527,12 @@@ module.exports =
"File", "readAsText", [this.fileName, enc]);
}
};
++
});
// file: lib/ios/plugin/ios/console.js
define("cordova/plugin/ios/console", function(require, exports, module) {
++
var exec = require('cordova/exec');
/**
@@@ -4515,10 -4515,10 +4612,12 @@@ DebugConsole.prototype.error = function
};
module.exports = new DebugConsole();
++
});
// file: lib/ios/plugin/ios/contacts.js
define("cordova/plugin/ios/contacts", function(require, exports, module) {
++
var exec = require('cordova/exec');
/**
@@@ -4560,10 -4560,10 +4659,12 @@@ module.exports =
exec(win, null, "Contacts","chooseContact", [options]);
}
};
++
});
// file: lib/ios/plugin/ios/nativecomm.js
define("cordova/plugin/ios/nativecomm", function(require, exports, module) {
++
var cordova = require('cordova');
/**
@@@ -4580,6 -4580,6 +4681,7 @@@ module.exports = function()
// file: lib/ios/plugin/ios/notification.js
define("cordova/plugin/ios/notification", function(require, exports, module) {
++
var Media = require('cordova/plugin/Media');
module.exports = {
@@@ -4587,10 -4587,10 +4689,12 @@@
(new Media('beep.wav')).play();
}
};
++
});
// file: lib/common/plugin/logger.js
define("cordova/plugin/logger", function(require, exports, module) {
++
//------------------------------------------------------------------------------
// The logger module exports the following properties/functions:
//
@@@ -4818,9 -4818,9 +4922,20 @@@ document.addEventListener("deviceready"
// file: lib/common/plugin/network.js
define("cordova/plugin/network", function(require, exports, module) {
++
var exec = require('cordova/exec'),
cordova = require('cordova'),
-- channel = require('cordova/channel');
++ channel = require('cordova/channel'),
++ utils = require('cordova/utils');
++
++// Link the onLine property with the Cordova-supplied network info.
++// This works because we clobber the naviagtor object with our own
++// object in bootstrap.js.
++if (typeof navigator != 'undefined') {
++ utils.defineGetter(navigator, 'onLine', function() {
++ return this.connection.type != 'none';
++ });
++}
var NetworkConnection = function () {
this.type = null;
@@@ -4830,7 -4830,7 +4945,7 @@@
var me = this;
-- channel.onCordovaReady.subscribeOnce(function() {
++ channel.onCordovaReady.subscribe(function() {
me.getInfo(function (info) {
me.type = info;
if (info === "none") {
@@@ -4878,10 -4878,10 +4993,12 @@@ NetworkConnection.prototype.getInfo = f
};
module.exports = new NetworkConnection();
++
});
// file: lib/common/plugin/notification.js
define("cordova/plugin/notification", function(require, exports, module) {
++
var exec = require('cordova/exec');
/**
@@@ -4938,10 -4938,10 +5055,12 @@@ module.exports =
exec(null, null, "Notification", "beep", [count]);
}
};
++
});
// file: lib/common/plugin/requestFileSystem.js
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
++
var FileError = require('cordova/plugin/FileError'),
FileSystem = require('cordova/plugin/FileSystem'),
exec = require('cordova/exec');
@@@ -4982,10 -4982,10 +5101,12 @@@ var requestFileSystem = function(type,
};
module.exports = requestFileSystem;
++
});
// file: lib/common/plugin/resolveLocalFileSystemURI.js
define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
++
var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
FileEntry = require('cordova/plugin/FileEntry'),
FileError = require('cordova/plugin/FileError'),
@@@ -5039,6 -5039,6 +5160,7 @@@ module.exports = function(uri, successC
// file: lib/common/plugin/splashscreen.js
define("cordova/plugin/splashscreen", function(require, exports, module) {
++
var exec = require('cordova/exec');
var splashscreen = {
@@@ -5051,13 -5051,13 +5173,26 @@@
};
module.exports = splashscreen;
++
});
// file: lib/common/utils.js
define("cordova/utils", function(require, exports, module) {
++
var utils = exports;
/**
++ * Defines a property getter for obj[key].
++ */
++utils.defineGetter = function(obj, key, func) {
++ if (Object.defineProperty) {
++ Object.defineProperty(obj, key, { get: func });
++ } else {
++ obj.__defineGetter__(key, func);
++ }
++};
++
++/**
* Returns an indication of whether the argument is an array or not
*/
utils.isArray = function(a) {
@@@ -5248,7 -5248,7 +5383,16 @@@ function formatted(object, formatChar)
window.cordova = require('cordova');
// file: lib/scripts/bootstrap.js
++
(function (context) {
++ // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
++ // We replace it so that properties that can't be clobbered can instead be overridden.
++ if (typeof navigator != 'undefined') {
++ function CordovaNavigator() {}
++ CordovaNavigator.prototype = navigator;
++ navigator = new CordovaNavigator();
++ }
++
var channel = require("cordova/channel"),
_self = {
boot: function () {
@@@ -5290,7 -5290,7 +5434,7 @@@
};
// boot up once native side is ready
-- channel.onNativeReady.subscribeOnce(_self.boot);
++ channel.onNativeReady.subscribe(_self.boot);
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since