cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject js commit: Allow platform.initialize and cordovaReady to fire before DOMContentLoaded
Date Thu, 18 Apr 2013 15:30:02 GMT
Updated Branches:
  refs/heads/master 3fe2dbc75 -> 2ba3bae46


Allow platform.initialize and cordovaReady to fire before DOMContentLoaded


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

Branch: refs/heads/master
Commit: 2ba3bae4696784437f73002511a8ec40dd0dff34
Parents: 3fe2dbc
Author: Ian Clelland <iclelland@chromium.org>
Authored: Thu Apr 18 10:24:44 2013 -0400
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Thu Apr 18 11:06:39 2013 -0400

----------------------------------------------------------------------
 lib/common/channel.js    |    1 +
 lib/scripts/bootstrap.js |   20 +++++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2ba3bae4/lib/common/channel.js
----------------------------------------------------------------------
diff --git a/lib/common/channel.js b/lib/common/channel.js
index d22e57d..23d1d66 100644
--- a/lib/common/channel.js
+++ b/lib/common/channel.js
@@ -260,5 +260,6 @@ channel.createSticky('onDestroy');
 // Channels that must fire before "deviceready" is fired.
 channel.waitForInitialization('onCordovaReady');
 channel.waitForInitialization('onCordovaConnectionReady');
+channel.waitForInitialization('onDOMContentLoaded');
 
 module.exports = channel;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2ba3bae4/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 98c4bfa..31979fa 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -21,7 +21,7 @@
 
 (function (context) {
     var channel = require('cordova/channel');
-    var platfromInitChannels = [channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady];
+    var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
 
     function logUnfiredChannels(arr) {
         for (var i = 0; i < arr.length; ++i) {
@@ -34,7 +34,7 @@
     window.setTimeout(function() {
         if (channel.onDeviceReady.state != 2) {
             console.log('deviceready has not fired after 5 seconds.');
-            logUnfiredChannels(platfromInitChannels);
+            logUnfiredChannels(platformInitChannelsArray);
             logUnfiredChannels(channel.deviceReadyChannelsArray);
         }
     }, 5000);
@@ -68,23 +68,25 @@
     }
 
     /**
-     * Create all cordova objects once page has fully loaded and native side is ready.
+     * Create all cordova objects once native side is ready.
      */
     channel.join(function() {
-        var platform = require('cordova/platform');
-
         // Call the platform-specific initialization
-        platform.initialize();
+        require('cordova/platform').initialize();
 
         // Fire event to notify that all objects are created
         channel.onCordovaReady.fire();
 
-        // Fire onDeviceReady event once all constructors have run and
-        // cordova info has been received from native side.
+        // Fire onDeviceReady event once page has fully loaded, all
+        // constructors have run and cordova info has been received from native
+        // side.
+        // This join call is deliberately made after platform.initialize() in
+        // order that plugins may manipulate channel.deviceReadyChannelsArray
+        // if necessary.
         channel.join(function() {
             require('cordova').fireDocumentEvent('deviceready');
         }, channel.deviceReadyChannelsArray);
 
-    }, platfromInitChannels);
+    }, platformInitChannelsArray);
 
 }(window));


Mime
View raw message