Detect if mobile layout is used and display wallets accordingly (thanks @harding)

This commit is contained in:
Saivann 2014-07-17 15:29:10 -04:00
parent 851e146230
commit 90b9e63026
4 changed files with 19 additions and 3 deletions

View file

@ -14,6 +14,7 @@
<link rel="apple-touch-icon-precomposed" href="/img/logo_ios.png"/>
</head>
<body>
<div id="detectmobile" class="detectmobile"></div>
{% if site.ALERT %}
<div class="alert-message">
<div><div>{{ site.ALERT }}</div></div>

View file

@ -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;
}
}

View file

@ -406,7 +406,7 @@ wallets:
<div class="wallets walletsmobile" id="walletsmobile"></div>
<script>walletShowPlatform('mobile');</script>
<script>if(isMobile())walletShowPlatform('mobile');else walletShowPlatform('desktop');</script>
<script>walletRotate();</script>
<div class="walletsdisclaimer">

View file

@ -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);
}
}