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) { (function(ionic) {
ionic.Platform = { ionic.Platform = {
PLATFORM_CLASS_MAP: { detect: function() {
'ios7': 'ios7' var platforms = [];
},
annotate: function() { console.log('Checking platforms');
var platform = this._checkPlatforms(); var platform = this._checkPlatforms(platforms);
platform && document.body.classList.add('platform-' + platform); console.log('Got platforms', platforms);
},
_checkPlatforms: function() { for(var i = 0; i < platforms.length; i++) {
if(this.isIOS7()) { document.body.classList.add('platform-' + platforms[i]);
return 'ios7';
} }
},
_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() { isIOS7: function() {
if(!window.device) { if(!window.device) {
@ -21,6 +35,5 @@
} }
} }
ionic.Platform.annotate(); ionic.Platform.detect();
})(ionic = window.ionic || {}); })(ionic = window.ionic || {});