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