mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Initial platform detection stuff.
This commit is contained in:
@ -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 || {});
|
||||
|
||||
Reference in New Issue
Block a user