cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject ios commit: updated cordovajs to include proper plugin loading
Date Fri, 17 May 2013 17:52:30 GMT
Updated Branches:
  refs/heads/3.0.0 98edd9277 -> 7b92ef5c1


updated cordovajs to include proper plugin loading


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

Branch: refs/heads/3.0.0
Commit: 7b92ef5c14f3c8a609b9bcbfa116a2c0f8094b38
Parents: 98edd92
Author: Steven Gill <stevengill97@gmail.com>
Authored: Fri May 17 10:52:23 2013 -0700
Committer: Steven Gill <stevengill97@gmail.com>
Committed: Fri May 17 10:52:23 2013 -0700

----------------------------------------------------------------------
 CordovaLib/cordova.js |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7b92ef5c/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 7e56d7b..75a23da 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
 // Platform: ios
-// 2.7.0rc1-52-g75b136a
+// 2.7.0rc1-72-g6ec24b1
 /*
  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 = '2.7.0rc1-52-g75b136a';
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-72-g6ec24b1';
 // file: lib/scripts/require.js
 
 var require,
@@ -5932,7 +5932,7 @@ require('cordova/channel').onNativeReady.fire();
     // See plugman's plugin_loader.js for the details of this object.
     // This function is only called if the really is a plugins array that isn't empty.
     // Otherwise the XHR response handler will just call finishPluginLoading().
-    function handlePluginsObject(modules) {
+    function handlePluginsObject(modules, path) {
         // First create the callback for when all plugins are loaded.
         var mapper = context.cordova.require('cordova/modulemapper');
         onScriptLoadingComplete = function() {
@@ -5966,11 +5966,21 @@ require('cordova/channel').onNativeReady.fire();
 
         // Now inject the scripts.
         for (var i = 0; i < modules.length; i++) {
-            injectScript(modules[i].file);
+            injectScript(path + modules[i].file);
         }
     }
 
-
+    // Find the root of the app
+    var path = '';
+    var scripts = document.getElementsByTagName('script');
+    var term = 'cordova.js';
+    for (var n = scripts.length-1; n>-1; n--) {
+        var src = scripts[n].src;
+        if (src.indexOf(term) == (src.length - term.length)) {
+            path = src.substring(0, src.length - term.length);
+            break;
+        }
+    }
     // Try to XHR the cordova_plugins.json file asynchronously.
     var xhr = new XMLHttpRequest();
     xhr.onload = function() {
@@ -5983,7 +5993,7 @@ require('cordova/channel').onNativeReady.fire();
             // obj will be undefined.
         }
         if (Array.isArray(obj) && obj.length > 0) {
-            handlePluginsObject(obj);
+            handlePluginsObject(obj, path);
         } else {
             finishPluginLoading();
         }
@@ -5991,8 +6001,9 @@ require('cordova/channel').onNativeReady.fire();
     xhr.onerror = function() {
         finishPluginLoading();
     };
+    var plugins_json = path + 'cordova_plugins.json';
     try { // we commented we were going to try, so let us actually try and catch
-        xhr.open('GET', 'cordova_plugins.json', true); // Async
+        xhr.open('GET', plugins_json, true); // Async
         xhr.send();
     } catch(err){
         finishPluginLoading();


Mime
View raw message