Initial platform detection stuff.

This commit is contained in:
Max Lynch
2013-09-23 10:16:16 -05:00
parent e59ddfc529
commit 5e248a3ec9

View File

@ -1,17 +1,31 @@
(function(ionic) {
ionic.Platform = {
PLATFORM_CLASS_MAP: {
'ios7': 'ios7'
},
annotate: function() {
var platform = this._checkPlatforms();
platform && document.body.classList.add('platform-' + platform);
},
_checkPlatforms: function() {
if(this.isIOS7()) {
return 'ios7';
detect: function() {
var platforms = [];
console.log('Checking platforms');
var platform = this._checkPlatforms(platforms);
console.log('Got platforms', platforms);
for(var i = 0; i < platforms.length; i++) {
document.body.classList.add('platform-' + platforms[i]);
}
},
_checkPlatforms: function(platforms) {
if(this.isCordova()) {
platforms.push('cordova');
}
if(this.isIOS7()) {
platforms.push('ios7');
}
},
// Check if we are running in Cordova, which will have
// window.device available.
isCordova: function() {
return 'device' in window;
},
isIOS7: function() {
if(!window.device) {
@ -21,6 +35,5 @@
}
}
ionic.Platform.annotate();
ionic.Platform.detect();
})(ionic = window.ionic || {});