You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/10/19 00:23:41 UTC

[3/3] js commit: [windows8] ensures WinJS is included, via script tag if required

[windows8] ensures WinJS is included, via script tag if required


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

Branch: refs/heads/master
Commit: 6a642e6643c7bbba30269202a61eafec1f12de6e
Parents: b0890aa
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Oct 18 15:03:39 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Oct 18 15:03:39 2012 -0700

----------------------------------------------------------------------
 lib/windows8/platform.js |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/6a642e66/lib/windows8/platform.js
----------------------------------------------------------------------
diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js
index a70766d..6532b63 100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@ -44,19 +44,32 @@ require('cordova/plugin/windows8/NotificationProxy');
 module.exports = {
     id: "windows8",
     initialize:function() {
-        var app = WinJS.Application;
-                
-        app.addEventListener("checkpoint", checkpointHandler);
-        function checkpointHandler(eventArgs) {
-            cordova.fireDocumentEvent('pause');
+
+        var onWinJSReady = function () {
+            var app = WinJS.Application;
+
+            app.addEventListener("checkpoint", checkpointHandler);
+            function checkpointHandler(eventArgs) {
+                cordova.fireDocumentEvent('pause');
+            };
+
+            Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
+            function resumingHandler() {
+                cordova.fireDocumentEvent('resume');
+            }
+
+            app.start();
         };
 
-        Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
-        function resumingHandler() {
-            cordova.fireDocumentEvent('resume');
-        }
+        if (!window.WinJS) {
+            // <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
+            var scriptElem = document.createElement("script");
+            scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
+            scriptElem.addEventListener("load", onWinJSReady);
+            document.head.appendChild(scriptElem);
 
-        app.start();
+            console.log("added WinJS ... ");
+        }
     },
     objects: {
         cordova: {
@@ -70,7 +83,7 @@ module.exports = {
         navigator: {
             children: {
                 device: {
-                    path: "cordova/plugin/windows8/device",
+
                     children: {
                         capture: {
                             path: "cordova/plugin/capture"