Permalink
Browse files

Use string replacement in setScale

  • Loading branch information...
1 parent 296bf3e commit 80157f583853cbe9c70f6550152b2a958cedd43f @afarber afarber committed Jun 25, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −0 index.html
  2. +2 −2 js/Viewport.js
View
@@ -34,6 +34,7 @@
<meta name='HandheldFriendly' content='True' />
<meta name="viewport" id="viewport" content="initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5, user-scalable=no" />
<meta name="viewport" content="width=device-width" />
+ <meta name="viewport" content="height=device-height" />
<meta name="format-detection" content="telephone=no" />
<script>
View
@@ -13,9 +13,9 @@
return wooga.castle.capabilities.iPad && (0.5 === scale)? 0.75 : scale;
},
setScale: function(to){
- // Instead of copying the whole content here, string replacement could be used instead.
setTimeout(function(){
- document.querySelector("#viewport").setAttribute("content", "width=device-width, height=device-height, initial-scale=" + to + ", minimum-scale=" + to + ", maximum-scale=" + to + ", user-scalable=no");
+ var content = document.querySelector("#viewport").getAttribute("content");
+ document.querySelector("#viewport").setAttribute("content", content.replace(/-scale\s*=\s*[.0-9]+/g, '-scale=' + to));
}, 0);
},
reset: function(){

0 comments on commit 80157f5

Please sign in to comment.