Skip to content

Commit

Permalink
[FEATURE] Android/iOS detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dmh committed Jul 19, 2016
1 parent a93d564 commit 77cf3e2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions dev/templates/parts/head/headScripts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,40 @@
} else{
document.documentElement.className += (' ' + (ie + ' ' + 'IE'));
};
var isIOS = false;
function detectIOS() {
var iDevices = [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
];
if (!!navigator.platform) {
while(iDevices.length) {
if (navigator.platform === iDevices.pop()) {
isIOS = true;
// In case if should be in DOM
// for now can be omitted - no styles by default attached to this class name ' iOS'
document.documentElement.className += " iOS";
}
}
}
}
detectIOS();
var isAndroid = false;
var android = uA.indexOf('Android ');
function detectAndroid() {
if (android > 0) {
isAndroid = true;
// In case if should be in DOM
// for now can be omitted - no styles by default attached to this class name ' android'
document.documentElement.className += " android";
}
}
detectAndroid();
</script>

0 comments on commit 77cf3e2

Please sign in to comment.