cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [10/50] ios commit: CB-2520 - built interim js from cordova-js for custom user agent support
Date Fri, 31 Oct 2014 23:43:30 GMT
CB-2520 - built interim js from cordova-js for custom user agent support


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c4ece0e7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c4ece0e7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c4ece0e7

Branch: refs/heads/wkwebview
Commit: c4ece0e7af320246c164b97b00ac78567dbfbfc4
Parents: 78ca06e
Author: Shazron Abdullah <shazron@apache.org>
Authored: Mon Oct 13 15:23:57 2014 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Mon Oct 13 15:23:57 2014 -0700

----------------------------------------------------------------------
 CordovaLib/cordova.js | 80 +++++++++++++++++++++++++++-------------------
 1 file changed, 47 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c4ece0e7/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 3153482..963dfe6 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
 // Platform: ios
-// 3.7.0-dev-1258511
+// d9e2a1c2401b986b5af09ecd6b4be60df2cbf131
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -19,7 +19,7 @@
  under the License.
 */
 ;(function() {
-var CORDOVA_JS_BUILD_LABEL = '3.7.0-dev-1258511';
+var PLATFORM_VERSION_BUILD_LABEL = '3.7.0-dev';
 // file: src/scripts/require.js
 
 /*jshint -W079 */
@@ -175,7 +175,8 @@ function createEvent(type, data) {
 var cordova = {
     define:define,
     require:require,
-    version:CORDOVA_JS_BUILD_LABEL,
+    version:PLATFORM_VERSION_BUILD_LABEL,
+    platformVersion:PLATFORM_VERSION_BUILD_LABEL,
     platformId:platform.id,
     /**
      * Methods to add/remove your own addEventListener hijacking on document + window.
@@ -262,11 +263,7 @@ var cordova = {
      * Called by native code when returning successful result from an action.
      */
     callbackSuccess: function(callbackId, args) {
-        try {
-            cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
-        } catch (e) {
-            console.log("Error in success callback: " + callbackId + " = "+e);
-        }
+        cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
     },
 
     /**
@@ -275,30 +272,34 @@ var cordova = {
     callbackError: function(callbackId, args) {
         // 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);
-        }
+        cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
     },
 
     /**
      * Called by native code when returning the result from an action.
      */
-    callbackFromNative: function(callbackId, success, status, args, keepCallback) {
-        var callback = cordova.callbacks[callbackId];
-        if (callback) {
-            if (success && status == cordova.callbackStatus.OK) {
-                callback.success && callback.success.apply(null, args);
-            } else if (!success) {
-                callback.fail && callback.fail.apply(null, args);
-            }
+    callbackFromNative: function(callbackId, isSuccess, status, args, keepCallback) {
+        try {
+            var callback = cordova.callbacks[callbackId];
+            if (callback) {
+                if (isSuccess && status == cordova.callbackStatus.OK) {
+                    callback.success && callback.success.apply(null, args);
+                } else {
+                    callback.fail && callback.fail.apply(null, args);
+                }
 
-            // Clear callback if not expecting any more results
-            if (!keepCallback) {
-                delete cordova.callbacks[callbackId];
+                // Clear callback if not expecting any more results
+                if (!keepCallback) {
+                    delete cordova.callbacks[callbackId];
+                }
             }
         }
+        catch (err) {
+            var msg = "Error in " + (isSuccess ? "Success" : "Error") + " callbackId: " +
callbackId + " : " + err;
+            console && console.log && console.log(msg);
+            cordova.fireWindowEvent("cordovacallbackerror", { 'message': msg });
+            throw err;
+        }
     },
     addConstructor: function(func) {
         channel.onCordovaReady.subscribe(function() {
@@ -918,15 +919,8 @@ function convertMessageToArgsNativeToJs(message) {
 }
 
 function iOSExec() {
-    // Use XHR for iOS 5 to work around a bug in -webkit-scroll.
-    // Use IFRAME_NAV elsewhere since it's faster and XHR bridge
-    // seems to have bugs in newer OS's (CB-3900, CB-3359, CB-5457, CB-4970, CB-4998, CB-5134)
     if (bridgeMode === undefined) {
-        if (navigator.userAgent) {
-            bridgeMode = navigator.userAgent.indexOf(' 5_') == -1 ? jsToNativeModes.IFRAME_NAV:
jsToNativeModes.XHR_NO_PAYLOAD;
-        } else {
-            bridgeMode = jsToNativeModes.IFRAME_NAV;
-        }
+        bridgeMode = jsToNativeModes.IFRAME_NAV;
     }
 
     if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova
&& window.webkit.messageHandlers.cordova.postMessage) {
@@ -1017,7 +1011,7 @@ function pokeNativeViaXhr() {
     // Add a timestamp to the query param to prevent caching.
     execXhr.open('HEAD', "/!gap_exec?" + (+new Date()), true);
     if (!vcHeaderValue) {
-        vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
+        vcHeaderValue = /.*\((.*)\)$/.exec(navigator.userAgent)[1];
     }
     execXhr.setRequestHeader('vc', vcHeaderValue);
     execXhr.setRequestHeader('rc', ++requestCount);
@@ -1171,6 +1165,16 @@ function replaceNavigator(origNavigator) {
         for (var key in origNavigator) {
             if (typeof origNavigator[key] == 'function') {
                 newNavigator[key] = origNavigator[key].bind(origNavigator);
+            } else {
+                (function(k) {
+                        Object.defineProperty(newNavigator, k, {
+                            get: function() {
+                                return origNavigator[k];
+                            },
+                            configurable: true,
+                            enumerable: true
+                        });
+                    })(key);
             }
         }
     }
@@ -1290,6 +1294,16 @@ function replaceNavigator(origNavigator) {
         for (var key in origNavigator) {
             if (typeof origNavigator[key] == 'function') {
                 newNavigator[key] = origNavigator[key].bind(origNavigator);
+            } else {
+                (function(k) {
+                        Object.defineProperty(newNavigator, k, {
+                            get: function() {
+                                return origNavigator[k];
+                            },
+                            configurable: true,
+                            enumerable: true
+                        });
+                    })(key);
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message