r101433 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101432‎ | r101433 | r101434 >
Date:23:36, 31 October 2011
Author:preilly
Status:ok (Comments)
Tags:
Comment:
fix on orientation change issue
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/opensearch.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/opensearch.js
@@ -63,7 +63,7 @@
6464 var iw = ( document.documentElement.clientWidth ) ? document.documentElement.clientWidth : document.body.clientWidth;
6565 sb.style.width = ( iw - 30 ) + pixels;
6666 sq.style.width = ( iw - 110 ) + pixels;
67 - search.style.width = ( iw - 140 ) + pixels;
 67+ search.style.width = ( iw - 130 ) + pixels;
6868 if ( results ) {
6969 results.style.width = ( sq.offsetWidth - 2 ) + pixels;
7070 results.style.left = sq.offsetLeft + pixels;
@@ -77,13 +77,13 @@
7878 function updateOrientationSearchWidth() {
7979 switch( window.orientation ) {
8080 case 0:
81 - updateSearchWidth();
 81+ setTimeout( "updateSearchWidth()", 200 );
8282 break;
8383 case 90:
84 - updateSearchWidth();
 84+ setTimeout( "updateSearchWidth()", 200 );
8585 break;
8686 case -90:
87 - updateSearchWidth();
 87+ setTimeout( "updateSearchWidth()", 200 );
8888 break;
8989 }
9090 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r1014351.18wmf1: MFT r101433preilly23:37, 31 October 2011

Comments

#Comment by Yair rand (talk | contribs)   01:33, 3 November 2011

The setTimeouts really shouldn't use quotes.

#Comment by Brion VIBBER (talk | contribs)   01:45, 13 December 2011

By passing a string in we're doing an eval; it should be replaced with 'updateSearchWidth' without quotes -- so just the symbol name, passing the function direct. Slightly more efficient, and less eval()-y. :)

#Comment by Preilly (talk | contribs)   01:51, 13 December 2011

Fixed in r105967.

#Comment by Dantman (talk | contribs)   01:50, 13 December 2011

@_@ Really? This could be done with 5 less lines.

<script lang=javascript> function updateOrientationSearchWidth() { switch( window.orientation ) { case 0: case 90: case -90: setTimeout( updateSearchWidth, 200 ); break; } } </script>

Shouldn't we just run this on any orientation where window.orientation % 90 === 0.

#Comment by Brion VIBBER (talk | contribs)   22:17, 13 December 2011

It could but.... it makes little difference. Probably the thing to do is to improve the styles to the point where there's no need to go poking this anyway. :)

Status & tagging log