From 90b9e63026f5adc102fe07147a35792328ebdbd8 Mon Sep 17 00:00:00 2001 From: Saivann Date: Thu, 17 Jul 2014 15:29:10 -0400 Subject: [PATCH] Detect if mobile layout is used and display wallets accordingly (thanks @harding) --- _layouts/base.html | 1 + _less/screen.less | 9 +++++++++ _templates/choose-your-wallet.html | 2 +- js/main.js | 10 ++++++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/_layouts/base.html b/_layouts/base.html index 5d25898d..e1815bf9 100644 --- a/_layouts/base.html +++ b/_layouts/base.html @@ -14,6 +14,7 @@ +
{% if site.ALERT %}
{{ site.ALERT }}
diff --git a/_less/screen.less b/_less/screen.less index 3230463f..1a0226ab 100644 --- a/_less/screen.less +++ b/_less/screen.less @@ -1708,6 +1708,12 @@ h2 .rssicon{ width:300px; } +.detectmobile{ + width:0; + height:0; + display:none; +} + .summary{ font-size:125%; margin-bottom:40px; @@ -2330,4 +2336,7 @@ h2 .rssicon{ .eventmap{ height:200px; } + .detectmobile{ + display:block; + } } diff --git a/_templates/choose-your-wallet.html b/_templates/choose-your-wallet.html index 26f1bf1b..84845bf7 100755 --- a/_templates/choose-your-wallet.html +++ b/_templates/choose-your-wallet.html @@ -406,7 +406,7 @@ wallets:
- +
diff --git a/js/main.js b/js/main.js index 8599ff35..e215de91 100644 --- a/js/main.js +++ b/js/main.js @@ -93,6 +93,12 @@ function getWindowX(){ return (window.innerWidth)?window.innerWidth:document.documentElement.clientWidth; } +function isMobile(){ +//Return true if the mobile CSS stylesheet is used. +if(getStyle(document.getElementById('detectmobile'),'display')!='none')return true; +return false; +} + function addClass(node,data){ //Add class to node. var cl=node.className.split(' '); @@ -420,8 +426,8 @@ if(t.parentNode.parentNode.parentNode.nodeName!='DIV'){ t.setAttribute('data-select','1'); addClass(t.parentNode,'select'); } -if(getStyle(document.getElementById('walletsmobile'),'display')!='none'){ - if(t.parentNode.getElementsByTagName('UL').length==0)setTimeout(function(){scrollToNode(document.getElementById('wallets'));},10); +if(isMobile()&&t.parentNode.getElementsByTagName('UL').length==0){ + setTimeout(function(){scrollToNode(document.getElementById('wallets'));},10); } }