You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/07/30 20:58:09 UTC
[02/13] js commit: [all] Move some start-up logic from cordova.js ->
bootstrap.js
[all] Move some start-up logic from cordova.js -> bootstrap.js
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/b248abfe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/b248abfe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/b248abfe
Branch: refs/heads/master
Commit: b248abfe980c3a452d28e17227bbe112eddbdef4
Parents: 853a5fc
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 29 22:39:32 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 29 22:39:32 2013 -0400
----------------------------------------------------------------------
lib/cordova.js | 25 -------------------------
lib/scripts/bootstrap.js | 31 +++++++++++++++++++++++++++----
2 files changed, 27 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b248abfe/lib/cordova.js
----------------------------------------------------------------------
diff --git a/lib/cordova.js b/lib/cordova.js
index c6a37fd..77a1d23 100644
--- a/lib/cordova.js
+++ b/lib/cordova.js
@@ -23,16 +23,6 @@
var channel = require('cordova/channel');
/**
- * Listen for DOMContentLoaded and notify our channel subscribers.
- */
-document.addEventListener('DOMContentLoaded', function() {
- channel.onDOMContentLoaded.fire();
-}, false);
-if (document.readyState == 'complete' || document.readyState == 'interactive') {
- channel.onDOMContentLoaded.fire();
-}
-
-/**
* Intercept calls to addEventListener + removeEventListener and handle deviceready,
* resume, and pause events.
*/
@@ -98,17 +88,6 @@ function createEvent(type, data) {
return event;
}
-if(typeof window.console === "undefined") {
- window.console = {
- log:function(){}
- };
-}
-// there are places in the framework where we call `warn` also, so we should make sure it exists
-if(typeof window.console.warn === "undefined") {
- window.console.warn = function(msg) {
- this.log("warn: " + msg);
- };
-}
var cordova = {
define:define,
@@ -247,9 +226,5 @@ var cordova = {
}
};
-// Register pause, resume and deviceready channels as events on document.
-channel.onPause = cordova.addDocumentEventHandler('pause');
-channel.onResume = cordova.addDocumentEventHandler('resume');
-channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
module.exports = cordova;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b248abfe/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 27d653c..197816d 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -26,6 +26,7 @@
context._cordovaJsLoaded = true;
var channel = require('cordova/channel');
+ var cordova = require('cordova');
var pluginloader = require('cordova/pluginloader');
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
@@ -67,6 +68,31 @@
context.navigator = replaceNavigator(context.navigator);
}
+ if (!window.console) {
+ window.console = {
+ log: function(){}
+ };
+ }
+ if (!window.console.warn) {
+ window.console.warn = function(msg) {
+ this.log("warn: " + msg);
+ };
+ }
+
+ // Register pause, resume and deviceready channels as events on document.
+ channel.onPause = cordova.addDocumentEventHandler('pause');
+ channel.onResume = cordova.addDocumentEventHandler('resume');
+ channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
+
+ // Listen for DOMContentLoaded and notify our channel subscribers.
+ if (document.readyState == 'complete' || document.readyState == 'interactive') {
+ channel.onDOMContentLoaded.fire();
+ } else {
+ document.addEventListener('DOMContentLoaded', function() {
+ channel.onDOMContentLoaded.fire();
+ }, false);
+ }
+
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
// it may be called before any cordova JS is ready.
@@ -96,8 +122,5 @@
}, platformInitChannelsArray);
- // Don't attempt to load when running unit tests.
- if (typeof XMLHttpRequest != 'undefined') {
- pluginloader.load();
- }
+ pluginloader.load();
}(window));