From 77cf3e227a77f49a98ec3180eb1c3adfe5dbb090 Mon Sep 17 00:00:00 2001 From: dmh Date: Tue, 19 Jul 2016 16:37:20 +0300 Subject: [PATCH] [FEATURE] Android/iOS detection --- dev/templates/parts/head/headScripts.hbs | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dev/templates/parts/head/headScripts.hbs b/dev/templates/parts/head/headScripts.hbs index 78087b5..d3e9dea 100644 --- a/dev/templates/parts/head/headScripts.hbs +++ b/dev/templates/parts/head/headScripts.hbs @@ -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();