mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
40 lines
970 B
JavaScript
40 lines
970 B
JavaScript
(function(ionic) {
|
|
|
|
ionic.Platform = {
|
|
detect: function() {
|
|
var platforms = [];
|
|
|
|
this._checkPlatforms(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 (window.cordova || window.PhoneGap || window.phonegap);
|
|
//&& /^file:\/{3}[^\/]/i.test(window.location.href)
|
|
//&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent);
|
|
},
|
|
isIOS7: function() {
|
|
if(!window.device) {
|
|
return false;
|
|
}
|
|
return parseFloat(window.device.version) >= 7.0;
|
|
}
|
|
}
|
|
|
|
ionic.Platform.detect();
|
|
})(window.ionic);
|