ionic.Platform.exitApp(), always run onPlatformReady()

This commit is contained in:
Adam Bradley
2014-01-31 11:55:31 -06:00
parent 2add26afbb
commit 25a9e527af
7 changed files with 46 additions and 22 deletions

View File

@@ -4,6 +4,8 @@
- CustomEvent polyfill improvements for Android
- Fix tab icon alignments
- Fix $ionicPlatform.ready()
- Fire off ionic.Platform.ready() callbacks for both Cordova and non-cordova
- Created ionic.Platform.exitApp();
## 0.9.22 "Alpha Narwhal" (2014-01-30)

View File

@@ -672,7 +672,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform'])
$rootScope.$viewHistory.backView.go();
} else {
// there is no back view, so close the app instead
navigator.app.exitApp();
ionic.Platform.exitApp();
}
e.preventDefault();
return false;

View File

File diff suppressed because one or more lines are too long

27
dist/js/ionic.js vendored
View File

@@ -1788,7 +1788,7 @@ window.ionic = {
device: function() {
if(window.device) return window.device;
console.error('device plugin required');
if(this.isCordova()) console.error('device plugin required');
return {};
},
@@ -1853,6 +1853,10 @@ window.ionic = {
return navigator.userAgent.toLowerCase().indexOf(type.toLowerCase()) >= 0;
},
exitApp: function() {
navigator.app && navigator.app.exitApp && navigator.app.exitApp();
},
showStatusBar: function(val) {
// Only useful when run within cordova
this.showStatusBar = val;
@@ -1891,19 +1895,26 @@ window.ionic = {
};
var readyCallbacks = [];
var platformName;
var platformVersion;
var platformName,
platformVersion,
readyCallbacks = [];
// setup listeners to know when the device is ready to go
function onWindowLoad() {
// window is loaded, now lets listen for when the device is ready
document.addEventListener("deviceready", onCordovaReady, false);
if(ionic.Platform.isCordova()) {
// the window and scripts are fully loaded, and a cordova/phonegap
// object exists then let's listen for the deviceready
document.addEventListener("deviceready", onPlatformReady, false);
} else {
// the window and scripts are fully loaded, but the window object doesn't have the
// cordova/phonegap object, so its just a browser, not a webview wrapped w/ cordova
onPlatformReady();
}
window.removeEventListener("load", onWindowLoad, false);
}
window.addEventListener("load", onWindowLoad, false);
function onCordovaReady() {
function onPlatformReady() {
// the device is all set to go, init our own stuff then fire off our event
ionic.Platform.isReady = true;
ionic.Platform.detect();
@@ -1913,7 +1924,7 @@ window.ionic = {
}
readyCallbacks = [];
ionic.trigger('platformready', { target: document });
document.removeEventListener("deviceready", onCordovaReady, false);
document.removeEventListener("deviceready", onPlatformReady, false);
}
})(window.ionic);

View File

File diff suppressed because one or more lines are too long

View File

@@ -57,7 +57,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform'])
$rootScope.$viewHistory.backView.go();
} else {
// there is no back view, so close the app instead
navigator.app.exitApp();
ionic.Platform.exitApp();
}
e.preventDefault();
return false;

View File

@@ -32,7 +32,7 @@
device: function() {
if(window.device) return window.device;
console.error('device plugin required');
if(this.isCordova()) console.error('device plugin required');
return {};
},
@@ -97,6 +97,10 @@
return navigator.userAgent.toLowerCase().indexOf(type.toLowerCase()) >= 0;
},
exitApp: function() {
navigator.app && navigator.app.exitApp && navigator.app.exitApp();
},
showStatusBar: function(val) {
// Only useful when run within cordova
this.showStatusBar = val;
@@ -135,19 +139,26 @@
};
var readyCallbacks = [];
var platformName;
var platformVersion;
var platformName,
platformVersion,
readyCallbacks = [];
// setup listeners to know when the device is ready to go
function onWindowLoad() {
// window is loaded, now lets listen for when the device is ready
document.addEventListener("deviceready", onCordovaReady, false);
if(ionic.Platform.isCordova()) {
// the window and scripts are fully loaded, and a cordova/phonegap
// object exists then let's listen for the deviceready
document.addEventListener("deviceready", onPlatformReady, false);
} else {
// the window and scripts are fully loaded, but the window object doesn't have the
// cordova/phonegap object, so its just a browser, not a webview wrapped w/ cordova
onPlatformReady();
}
window.removeEventListener("load", onWindowLoad, false);
}
window.addEventListener("load", onWindowLoad, false);
function onCordovaReady() {
function onPlatformReady() {
// the device is all set to go, init our own stuff then fire off our event
ionic.Platform.isReady = true;
ionic.Platform.detect();
@@ -157,7 +168,7 @@
}
readyCallbacks = [];
ionic.trigger('platformready', { target: document });
document.removeEventListener("deviceready", onCordovaReady, false);
document.removeEventListener("deviceready", onPlatformReady, false);
}
})(window.ionic);