Skip to content

Instantly share code, notes, and snippets.

@EionRobb
Created May 14, 2015 10:21
Show Gist options
  • Save EionRobb/b77d188887c8f017219d to your computer and use it in GitHub Desktop.
Save EionRobb/b77d188887c8f017219d to your computer and use it in GitHub Desktop.
Removing WinJS from Cordova.js
//Replace
var onWinJSReady = function () {
var app = WinJS.Application;
var checkpointHandler = function checkpointHandler() {
cordova.fireDocumentEvent('pause');
};
var resumingHandler = function resumingHandler() {
cordova.fireDocumentEvent('resume');
};
app.addEventListener("checkpoint", checkpointHandler);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
app.start();
};
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);
console.log("added WinJS ... ");
}
else {
onWinJSReady();
}
// With
var suspendingHandler = function suspendingHandler() {
cordova.fireDocumentEvent('pause');
};
var resumingHandler = function resumingHandler() {
cordova.fireDocumentEvent('resume');
};
var activatedHandler = function activatedHandler(e) {
if (typeof handleOpenURL == 'function' && e.uri) {
handleOpenURL(e.uri.rawUri);
}
};
var wui = Windows.UI.WebUI.WebUIApplication;
wui.addEventListener("activated", activatedHandler, false);
wui.addEventListener("suspending", suspendingHandler, false);
wui.addEventListener("resuming", resumingHandler, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment