platform detect updates

This commit is contained in:
Adam Bradley
2014-01-14 00:59:25 -06:00
parent 41a7b45f0e
commit 64d8fd207a
6 changed files with 49 additions and 57 deletions

View File

@@ -435,15 +435,7 @@ angular.module('ionic.service.platform', [])
// We need to do some stuff as soon as we know the platform,
// like adjust header margins for iOS 7, etc.
setTimeout(function afterReadyWait() {
if(isReady() && ionic.Platform.detect()) {
return;
} else {
setTimeout(afterReadyWait, 50);
}
}, 10);
ionic.Platform.detect();
return {

View File

File diff suppressed because one or more lines are too long

40
dist/js/ionic.js vendored
View File

@@ -1737,27 +1737,34 @@ window.ionic = {
(function(ionic) {
ionic.Platform = {
detect: function() {
var platforms = [];
var domReady = function() {
// run when the DOM is ready
document.addEventListener("deviceready", deviceReady, false);
document.removeEventListener("DOMContentLoaded", domReady, false);
};
document.addEventListener("DOMContentLoaded", domReady, false);
var didDetect = this._checkPlatforms(platforms);
var deviceReady = function() {
// run when cordova is fully loaded
var platforms = [];
ionic.Platform._checkPlatforms(platforms);
var classify = function() {
if(!document.body) { return; }
for(var i = 0; i < platforms.length; i++) {
document.body.classList.add('platform-' + platforms[i]);
if(platforms.length) {
// only change the body class if we got platform info
var bodyClass = document.body.className;
for(var i = 0; i < platforms.length; i++) {
bodyClass += ' platform-' + platforms[i];
}
document.body.className = bodyClass;
}
document.removeEventListener("deviceready", deviceReady, false);
};
document.addEventListener( "DOMContentLoaded", function(){
classify();
});
classify();
return didDetect;
},
_checkPlatforms: function(platforms) {
if(this.isCordova()) {
platforms.push('cordova');
@@ -1773,10 +1780,7 @@ window.ionic = {
}
// Return whether we detected anything
if(platforms.length === 0) {
return false;
}
return true;
return (platforms.length > 0);
},
// Check if we are running in Cordova, which will have

View File

File diff suppressed because one or more lines are too long

View File

@@ -27,15 +27,7 @@ angular.module('ionic.service.platform', [])
// We need to do some stuff as soon as we know the platform,
// like adjust header margins for iOS 7, etc.
setTimeout(function afterReadyWait() {
if(isReady() && ionic.Platform.detect()) {
return;
} else {
setTimeout(afterReadyWait, 50);
}
}, 10);
ionic.Platform.detect();
return {

View File

@@ -1,27 +1,34 @@
(function(ionic) {
ionic.Platform = {
detect: function() {
var platforms = [];
var domReady = function() {
// run when the DOM is ready
document.addEventListener("deviceready", deviceReady, false);
document.removeEventListener("DOMContentLoaded", domReady, false);
};
document.addEventListener("DOMContentLoaded", domReady, false);
var didDetect = this._checkPlatforms(platforms);
var deviceReady = function() {
// run when cordova is fully loaded
var platforms = [];
ionic.Platform._checkPlatforms(platforms);
var classify = function() {
if(!document.body) { return; }
for(var i = 0; i < platforms.length; i++) {
document.body.classList.add('platform-' + platforms[i]);
if(platforms.length) {
// only change the body class if we got platform info
var bodyClass = document.body.className;
for(var i = 0; i < platforms.length; i++) {
bodyClass += ' platform-' + platforms[i];
}
document.body.className = bodyClass;
}
document.removeEventListener("deviceready", deviceReady, false);
};
document.addEventListener( "DOMContentLoaded", function(){
classify();
});
classify();
return didDetect;
},
_checkPlatforms: function(platforms) {
if(this.isCordova()) {
platforms.push('cordova');
@@ -37,10 +44,7 @@
}
// Return whether we detected anything
if(platforms.length === 0) {
return false;
}
return true;
return (platforms.length > 0);
},
// Check if we are running in Cordova, which will have