r113881 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113880‎ | r113881 | r113882 >
Date:00:27, 15 March 2012
Author:jdlrobson
Status:ok
Tags:
Comment:
correct viewport resetting

viewport should be set for anything that can support it
not just iphone/ipad (palm pre for example)
also when we do reset it make sure we reset to the initial
value
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js
@@ -10,6 +10,7 @@
1111 footer = document.getElementById( 'footer' ),
1212 clearSearch = document.getElementById( 'clearsearch' ),
1313 focused = false,
 14+ viewportmeta, originalViewport,
1415 u = MobileFrontend.utils;
1516
1617 apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
@@ -17,16 +18,19 @@
1819 function hideResults() {
1920 results.style.display = 'none';
2021 }
 22+
 23+ viewportmeta = u( 'meta[name="viewport"]' )
 24+ if ( viewportmeta ) {
 25+ viewportmeta = viewportmeta[0];
 26+ originalViewport = viewportmeta.getAttribute( 'content' );
 27+ }
 28+ // prevent auto-zoom in on clicking search for certain browsers e.g. palm pre and ipad
2129 function resetViewPort() {
22 - if ( navigator.userAgent.match( /iPhone/i ) || navigator.userAgent.match( /iPad/i ) ) {
23 - var viewportmeta = u( 'meta[name="viewport"]' );
24 - if ( viewportmeta ) {
25 - viewportmeta = viewportmeta[0];
26 - viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
27 - u( document.body ).bind( 'gesturestart', function () {
28 - viewportmeta.content = 'width=device-width, initial-scale=1.0';
29 - } );
30 - }
 30+ if ( viewportmeta ) {
 31+ viewportmeta.setAttribute( 'content', 'minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0');
 32+ u( document.body ).bind( 'gesturestart', function () {
 33+ viewportmeta.setAttribute( 'content', originalViewport );
 34+ } );
3135 }
3236 }
3337

Follow-up revisions

RevisionCommit summaryAuthorDate
r114202MFT r113807, r113831, r113832, r113865, r113866, r113870, r113871, r113872, r...awjrichards22:23, 19 March 2012

Status & tagging log