r114202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114201‎ | r114202 | r114203 >
Date:22:23, 19 March 2012
Author:awjrichards
Status:reverted
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png (added) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/close-button-beta.png (added) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js
@@ -1,16 +1,8 @@
2 -function applyCss() {
3 - $(".hide").show();
4 - $(".show").hide();
5 - $(".openSection .hide").hide();
6 - $(".openSection .show").show();
7 -}
8 -
92 module("MobileFrontend toggle.js: wm_toggle_section", {
103 setup: function() {
114 MFET.createFixtures();
125 MFE.toggle.init();
13 - $("#section_1").addClass("openSection");
14 - $("#content_1,#anchor_1,#section_1 .hide").hide();
 6+ $("#section_1,#content_1,#anchor_1").addClass("openSection");
157 },
168 teardown: function() {
179 MFET.cleanFixtures();
@@ -21,20 +13,15 @@
2214 test("wm_toggle_section", function() {
2315 strictEqual($("#section_1").hasClass("openSection"), true, "openSection class present");
2416 MFE.toggle.wm_toggle_section("1");
25 - applyCss();
26 - strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle");
27 - strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle");
28 - strictEqual($("#section_1").hasClass("openSection"), false, "openSection class removed");
29 - strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible");
30 - strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden");
 17+ strictEqual($("#content_1").hasClass("openSection"), false, "check content is closed on a toggle");
 18+ strictEqual($("#anchor_1").hasClass("openSection"), false, "check anchor is closed on toggle");
 19+ strictEqual($("#section_1").hasClass("openSection"), false, "check section is closed");
3120
3221 // perform second toggle
3322 MFE.toggle.wm_toggle_section("1");
34 - applyCss();
35 - strictEqual($("#content_1").is(":visible"), false, "check content is hidden on a toggle");
36 - strictEqual($("#anchor_1").is(":visible"), false, "check anchor is hidden on toggle");
37 - strictEqual($("#section_1 .hide").is(":visible"), false, "check hide button now hidden");
38 - strictEqual($("#section_1 .show").is(":visible"), true, "check show button now visible");
 23+ strictEqual($("#content_1").hasClass("openSection"), true, "check content reopened");
 24+ strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor reopened");
 25+ strictEqual($("#section_1").hasClass("openSection"), true, "check section has reopened");
3926 });
4027
4128 test("wm_reveal_for_hash", function() {
@@ -48,26 +35,21 @@
4936
5037 test("wm_reveal_for_hash", function() {
5138 MFE.toggle.wm_reveal_for_hash("#First_Section_2");
52 - applyCss();
53 - strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle");
54 - strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle");
55 - strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible");
56 - strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden");
 39+ strictEqual($("#content_1").hasClass("openSection"), true, "check content is visible on a toggle");
 40+ strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor is visible on toggle");
 41+ strictEqual($("#section_1").hasClass("openSection"), true, "check section is marked as open");
5742 });
5843
5944 test("clicking hash links", function() {
6045 MFET.triggerEvent($("[href=#First_Section_2]")[0], "click");
61 - applyCss();
62 - strictEqual($("#content_1").is(":visible"), true, "check content is visible on a toggle");
63 - strictEqual($("#anchor_1").is(":visible"), true, "check anchor is visible on toggle");
64 - strictEqual($("#section_1 .hide").is(":visible"), true, "check hide button now visible");
65 - strictEqual($("#section_1 .show").is(":visible"), false, "check show button now hidden");
 46+ strictEqual($("#content_1").hasClass("openSection"), true, "check content is visible on a toggle");
 47+ strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor is visible on toggle");
 48+ strictEqual($("#section_1").hasClass("openSection"), true, "check section marked as open");
6649 });
6750
6851 test("clicking a heading toggles it", function() {
69 - var visibilityStart = $("#content_1").is(":visible");
70 - MFET.triggerEvent($("#section_1")[0], "click");
71 - applyCss();
 52+ var visibilityStart = $("#content_2").hasClass("openSection");
 53+ MFET.triggerEvent($("#section_2")[0], "click");
7254 strictEqual(visibilityStart, false, "check content is hidden at start");
73 - strictEqual($("#content_1").is(":visible"), true, "check content is hidden on a toggle");
 55+ strictEqual($("#content_2").hasClass("openSection"), true, "check content is shown on a toggle");
7456 });
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
@@ -1,14 +1,22 @@
22 var MFE = MobileFrontend;
33 var MFET = window.MobileFrontendTests;
44
5 -module("MobileFrontend application.js: utils");
 5+module("MobileFrontend application.js: utils", {
 6+ setup: function() {
 7+ var section = '<div class="t_section_heading"></div>';
 8+ $('<div id="mfetest">' + section + '<div id="t_section_1">' + section + '</div>').appendTo(document.body);
 9+ },
 10+ teardown: function() {
 11+ $("#mfetest").remove();
 12+ }
 13+});
614
715 test("Basic selector support (#id)", function() {
8 - strictEqual(MFE.utils("#section_1").length, 1, "only one element matches this selector");
 16+ strictEqual(MFE.utils("#t_section_1").length, 1, "only one element matches this selector");
917 });
1018
1119 test("Basic selector support (.className)", function() {
12 - strictEqual(MFE.utils(".section_heading").length, 2, "only two elements matches this selector");
 20+ strictEqual(MFE.utils(".t_section_heading").length, 2, "only two elements matches this selector");
1321 });
1422
1523 test("Basic selector support (tag name)", function() {
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php
@@ -219,15 +219,14 @@
220220 array( false, null, array() ),
221221 array( true, 'webkit', array() ),
222222 array( false, 'webkit', array( 'action' => 'edit' ) ),
223 - array( false, 'webkit', array( 'mobileaction' => 'view_normal_site' ) ),
 223+ array( false, 'webkit', array( 'useformat' => 'desktop' ) ),
224224 array( true, null, array( 'useformat' => 'mobile-wap' ) ),
225225 array( false, null, array( 'useformat' => 'mobile-wap', 'action' => 'edit' ) ),
226226 array( false, null, array( 'useformat' => 'mobile-wap', 'action' => 'history' ) ),
227 - array( false, null, array( 'useformat' => 'mobile-wap', 'mobileaction' => 'view_normal_site' ) ),
 227+ array( false, null, array( 'useformat' => 'desktop' ) ),
228228 array( true, null, array( 'useformat' => 'mobile' ) ),
229229 array( false, null, array( 'useformat' => 'mobile', 'action' => 'edit' ) ),
230230 array( false, null, array( 'useformat' => 'mobile', 'action' => 'history' ) ),
231 - array( false, null, array( 'useformat' => 'mobile', 'mobileaction' => 'view_normal_site' ) ),
232231 );
233232 }
234233
@@ -302,4 +301,65 @@
303302 array( 'edit' ),
304303 );
305304 }
 305+
 306+ /**
 307+ * @dataProvider getUseFormatProvider
 308+ */
 309+ public function testGetUseFormat( $explicit, $requestParam, $expected ) {
 310+ global $wgRequest, $wgExtMobileFrontend;
 311+ $wgRequest->setVal( 'useformat', $requestParam );
 312+ $wgExtMobileFrontend->setUseFormat( $explicit );
 313+ $this->assertEquals( $expected, $wgExtMobileFrontend->getUseFormat() );
 314+ }
 315+
 316+ public function getUseFormatProvider() {
 317+ return array(
 318+ array( 'mobile', null, 'mobile' ),
 319+ array( null, 'mobile', 'mobile' ),
 320+ array( null, null, '' ),
 321+ array( 'desktop', 'mobile', 'desktop' ),
 322+ );
 323+ }
 324+
 325+ public function testGetUseFormatCookieExpiry() {
 326+ global $wgExtMobileFrontend, $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry;
 327+ $getUseFormatCookieExpiry = self::getMethod( 'getUseFormatCookieExpiry' );
 328+
 329+ $origMFCookieExpiry = $wgMobileFrontendFormatCookieExpiry;
 330+ $startTime = time();
 331+ $wgMobileFrontendFormatCookieExpiry = 60;
 332+ $mfCookieExpected = $startTime + 60;
 333+ $this->assertTrue( $mfCookieExpected == $getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime ) ), 'Using MobileFrontend expiry.' );
 334+
 335+ $wgMobileFrontendFormatCookieExpiry = null;
 336+ $defaultMWCookieExpected = $startTime + $wgCookieExpiration;
 337+ $this->assertTrue( $defaultMWCookieExpected == $getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime ) ), 'Using default MediaWiki cookie expiry.' );
 338+
 339+ // reset global back to original value
 340+ $wgMobileFrontendFormatCookieExpiry = $origMFCookieExpiry;
 341+ }
 342+
 343+ /**
 344+ * @outputBuffering enabled
 345+ */
 346+ /*public function testCookie() {
 347+ global $wgRequest;
 348+ $wgRequest->response()->setCookie( 'foo', 'bar' );
 349+ $this->assertEquals( $wgRequest->getCookie( 'foo' ), 'bar' );
 350+ setcookie( 'foobar', 'pants' );
 351+ $this->asertEquals( $_COOKIE[ 'foobar' ], 'pants' );
 352+ }
 353+
 354+ /**
 355+ * NB this will not work as PHPUnit seems to not make it possible to set
 356+ * and retrieve cookies. Note above test, testCookie() - both assertions
 357+ * currently fail, making testing ExtMobileFrontend::checkUserFormatCookie()
 358+ * impossible.
 359+ *
 360+ * @outputBuffering enabled
 361+ */
 362+ /*public function testCheckUseFormatCookie() {
 363+
 364+ }
 365+ */
306366 }
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
@@ -26,7 +26,6 @@
2727 public static $searchField;
2828 public static $disableImagesURL;
2929 public static $enableImagesURL;
30 - public static $disableMobileSiteURL;
3130 public static $viewNormalSiteURL;
3231 public static $currentURL;
3332 public static $displayNoticeId;
@@ -72,7 +71,6 @@
7372 'mobile-frontend-hide-button',
7473 'mobile-frontend-back-to-top-of-section',
7574 'mobile-frontend-regular-site',
76 - 'mobile-frontend-perm-stop-redirect',
7775 'mobile-frontend-home-button',
7876 'mobile-frontend-random-button',
7977 'mobile-frontend-are-you-sure',
@@ -231,8 +229,7 @@
232230
233231 self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' );
234232 self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' );
235 - self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=disable_mobile_site' );
236 - self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=view_normal_site' );
 233+ self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'useformat=desktop' );
237234 self::$currentURL = $wgRequest->getFullRequestURL();
238235 self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 'mobileaction=leave_feedback' );
239236
@@ -477,12 +474,6 @@
478475 exit();
479476 }
480477
481 - if ( $mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML' ) {
482 - echo $this->renderDisableMobileSiteXHTML();
483 - wfProfileOut( __METHOD__ );
484 - exit();
485 - }
486 -
487478 if ( $mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML' ) {
488479 echo $this->renderOptInMobileSiteXHTML();
489480 wfProfileOut( __METHOD__ );
@@ -716,6 +707,7 @@
717708 }
718709 $wgOut->addVaryHeader( 'Cookie' );
719710 $wgOut->addVaryHeader( 'X-Carrier' );
 711+ $wgOut->addVaryHeader( 'X-Images' );
720712 wfProfileOut( __METHOD__ );
721713 return true;
722714 }
@@ -857,54 +849,6 @@
858850 }
859851
860852 /**
861 - * @return string
862 - */
863 - private function renderDisableMobileSiteXHTML() {
864 - wfProfileIn( __METHOD__ );
865 - if ( $this->contentFormat == 'XHTML' ) {
866 - $this->getMsg();
867 - $areYouSure = self::$messages['mobile-frontend-are-you-sure'];
868 - $explainDisable = self::$messages['mobile-frontend-explain-disable'];
869 - $disableButton = self::$messages['mobile-frontend-disable-button'];
870 - $backButton = self::$messages['mobile-frontend-back-button'];
871 - $htmlTitle = $areYouSure;
872 - $title = $areYouSure;
873 - $searchTemplate = $this->getSearchTemplate();
874 - $searchWebkitHtml = $searchTemplate->getHTML();
875 - $footerTemplate = $this->getFooterTemplate();
876 - $footerHtml = $footerTemplate->getHTML();
877 - $disableTemplate = new DisableTemplate();
878 - $options = array(
879 - 'currentURL' => self::$currentURL,
880 - 'mobileRedirectFormAction' => self::$mobileRedirectFormAction,
881 - 'areYouSure' => $areYouSure,
882 - 'explainDisable' => $explainDisable,
883 - 'disableButton' => $disableButton,
884 - 'backButton' => $backButton,
885 - 'htmlTitle' => $htmlTitle,
886 - 'title' => $title,
887 - );
888 - $disableTemplate->setByArray( $options );
889 - $disableHtml = $disableTemplate->getHTML();
890 -
891 - $contentHtml = $disableHtml;
892 - $applicationTemplate = $this->getApplicationTemplate();
893 - $options = array(
894 - 'htmlTitle' => $htmlTitle,
895 - 'searchWebkitHtml' => $searchWebkitHtml,
896 - 'contentHtml' => $contentHtml,
897 - 'footerHtml' => $footerHtml,
898 - );
899 - $applicationTemplate->setByArray( $options );
900 - $applicationHtml = $applicationTemplate->getHTML();
901 - wfProfileOut( __METHOD__ );
902 - return $applicationHtml;
903 - }
904 - wfProfileOut( __METHOD__ );
905 - return '';
906 - }
907 -
908 - /**
909853 * @return DomElement
910854 */
911855 public function renderLogin() {
@@ -1164,7 +1108,6 @@
11651109 $options = array(
11661110 'messages' => self::$messages,
11671111 'leaveFeedbackURL' => self::$leaveFeedbackURL,
1168 - 'disableMobileSiteURL' => self::$disableMobileSiteURL,
11691112 'viewNormalSiteURL' => self::$viewNormalSiteURL,
11701113 'disableImages' => self::$disableImages,
11711114 'disableImagesURL' => self::$disableImagesURL,
@@ -1441,15 +1384,20 @@
14421385 }
14431386
14441387 protected function shouldDisplayMobileView() {
1445 - if ( !$this->isMobileDevice() && !$this->isFauxMobileDevice() ) {
 1388+ // always display desktop view if it's explicitly requested
 1389+ $useFormat = $this->getUseFormat();
 1390+ if ( $useFormat == 'desktop' ) {
14461391 return false;
14471392 }
 1393+
 1394+ if ( !$this->isMobileDevice() && !$this->isFauxMobileDevice() ) {
 1395+ return false;
 1396+ }
14481397
14491398 $action = $this->getAction();
1450 - $mobileAction = $this->getMobileAction();
14511399
1452 - if ( $action === 'edit' || $action === 'history' ||
1453 - $mobileAction === 'view_normal_site' ) {
 1400+
 1401+ if ( $action === 'edit' || $action === 'history' ) {
14541402 return false;
14551403 }
14561404
@@ -1501,29 +1449,49 @@
15021450
15031451 $useFormat = $this->getUseFormat();
15041452 $useFormatFromCookie = $wgRequest->getCookie( 'mf_useformat' );
 1453+
 1454+ // fetch format from cookie and set it if one is not otherwise specified
15051455 if( !strlen( $useFormat ) && !is_null( $useFormatFromCookie ) ) {
15061456 $this->setUseFormat( $useFormatFromCookie );
15071457 }
15081458
1509 - // if we should not be displaying the mobile view, make sure cookies are unset etc.
1510 - if ( !$this->shouldDisplayMobileView() ) {
1511 - // make sure cookie is unset for appropriate mobile actions
1512 - $mobileAction = $this->getMobileAction();
1513 - if ( in_array( $mobileAction, array( 'view_normal_site', 'disable_mobile_site' ) ) ) {
1514 - $wgRequest->response()->setCookie( 'mf_useformat', false, time() - 3600 );
1515 - }
1516 -
1517 - // make sure useformat is unset
1518 - $this->setUseFormat( '' );
1519 - return;
 1459+ // set appropriate cookie if necessary
 1460+ if ( ( $useFormatFromCookie != 'mobile' && $useFormat == 'mobile' ) ||
 1461+ ( $useFormatFromCookie != 'desktop' && $useFormat == 'desktop' ) ) {
 1462+ $this->setUseFormatCookie( $useFormat );
15201463 }
1521 -
1522 - // if getUseFormat and no cookie set, set the cookie
1523 - if ( is_null( $useFormatFromCookie ) && strlen( $useFormat ) ) {
1524 - $wgRequest->response()->setCookie( 'mf_useformat', $useFormat, 0 );
1525 - }
15261464 }
15271465
 1466+ /**
 1467+ * Set the mf_useformat cookie
 1468+ *
 1469+ * This cookie can determine whether or not a user should see the mobile
 1470+ * version of pages.
 1471+ *
 1472+ * @param string The format to store in the cookie
 1473+ */
 1474+ protected function setUseFormatCookie( $useFormat ) {
 1475+ global $wgRequest;
 1476+ $expiry = $this->getUseFormatCookieExpiry();
 1477+ $wgRequest->response()->setCookie( 'mf_useformat', $useFormat, $expiry );
 1478+ }
 1479+
 1480+ /**
 1481+ * Get the expiration time for the mf_useformat cookie
 1482+ *
 1483+ * If $wgMobileFrontendFormatCookieExpiry as a non-0 value,
 1484+ * @param int The base time (in seconds since Epoch) from which to calculate
 1485+ * cookie expiration. If null, time() is used.
 1486+ */
 1487+ protected function getUseFormatCookieExpiry( $startTime=null ) {
 1488+ global $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry;
 1489+ $cookieDuration = ( abs( intval( $wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ?
 1490+ $wgMobileFrontendFormatCookieExpiry : $wgCookieExpiration;
 1491+ if ( intval( $startTime ) === 0 ) $startTime = time();
 1492+ $expiry = $startTime + $cookieDuration;
 1493+ return $expiry;
 1494+ }
 1495+
15281496 public function getVersion() {
15291497 return __CLASS__ . ': $Id$';
15301498 }
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
@@ -79,8 +79,10 @@
8080 }
8181 for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
8282 e = document.getElementById( d[i] + section_id );
83 - if ( e ) {
84 - e.style.display = e.style.display === 'block' ? 'none' : 'block';
 83+ if ( e && u( e ).hasClass( 'openSection' ) ) {
 84+ u( e ).removeClass( 'openSection' )
 85+ } else {
 86+ u( e ).addClass( 'openSection' )
8587 }
8688 }
8789 }
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
@@ -4,12 +4,12 @@
55 var apiUrl = '/api.php', timer = -1, typingDelay = 500,
66 numResults = 15, term,
77 search = document.getElementById( 'search' ),
8 - sq = document.getElementById( 'sq' ),
98 sb = document.getElementById( 'searchbox' ),
109 content = document.getElementById( 'content' ),
1110 footer = document.getElementById( 'footer' ),
1211 clearSearch = document.getElementById( 'clearsearch' ),
1312 focused = false,
 13+ viewportmeta, originalViewport,
1414 u = MobileFrontend.utils;
1515
1616 apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
@@ -17,16 +17,19 @@
1818 function hideResults() {
1919 results.style.display = 'none';
2020 }
 21+
 22+ viewportmeta = u( 'meta[name="viewport"]' )
 23+ if ( viewportmeta ) {
 24+ viewportmeta = viewportmeta[0];
 25+ originalViewport = viewportmeta.getAttribute( 'content' );
 26+ }
 27+ // prevent auto-zoom in on clicking search for certain browsers e.g. palm pre and ipad
2128 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 - }
 29+ if ( viewportmeta ) {
 30+ viewportmeta.setAttribute( 'content', 'minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0');
 31+ u( document.body ).bind( 'gesturestart', function () {
 32+ viewportmeta.setAttribute( 'content', originalViewport );
 33+ } );
3134 }
3235 }
3336
@@ -35,7 +38,7 @@
3639 search.onfocus = function() {
3740 var rrd, rrdD;
3841 sb = document.getElementById( 'searchbox' );
39 - sq = document.getElementById( 'sq' );
 42+ header = document.getElementById( 'header' );
4043 content = document.getElementById( 'content' );
4144 footer = document.getElementById( 'footer' );
4245 resetViewPort();
@@ -52,7 +55,7 @@
5356 rrdD = document.createElement( 'div' );
5457 rrdD.setAttribute( 'id', 'left-arrow' );
5558 rrd.appendChild( rrdD );
56 - sq.insertBefore( rrd, sq.firstChild );
 59+ header.insertBefore( rrd, header.firstChild );
5760 }
5861 focused = true;
5962 }
@@ -108,14 +111,14 @@
109112 window.onload = function () {
110113 u( search ).bind( 'keyup',
111114 function() {
112 - clearTimeout( timer );
113 - term = this.value;
114 - if ( term.length < 1 ) {
115 - results.innerHTML = '';
116 - } else {
117 - term = encodeURIComponent( term );
118 - timer = setTimeout( function () { searchApi( term ); }, typingDelay );
119 - }
 115+ clearTimeout( timer );
 116+ term = search.value;
 117+ if ( term.length < 1 ) {
 118+ results.innerHTML = '';
 119+ } else {
 120+ term = encodeURIComponent( term );
 121+ timer = setTimeout( function () { searchApi( term ); }, typingDelay );
 122+ }
120123 } );
121124 };
122125
@@ -142,15 +145,6 @@
143146 return sections;
144147 }
145148
146 - function sqValUpdate( sqValue ) {
147 - var search = document.getElementById( 'search' );
148 - if ( search ) {
149 - search.value = sqValue + ' ';
150 - search.focus();
151 - searchApi( search.value );
152 - }
153 - }
154 -
155149 function htmlEntities( str ) {
156150 var text = document.createTextNode( str ),
157151 el = document.createElement( 'div' );
@@ -165,7 +159,7 @@
166160 function writeResults( sections ) {
167161 var results = document.getElementById( 'results' ), suggestions, i,
168162 term = htmlEntities( document.getElementById( 'search' ).value ),
169 - suggestionListener, section, escapedTerm, suggestionsResult, link, label;
 163+ section, escapedTerm, suggestionsResult, link, label;
170164
171165 results.style.display = 'block';
172166 if ( search ) {
@@ -180,22 +174,12 @@
181175 suggestions = document.createElement( 'ul' );
182176 suggestions.className = 'suggestions-results';
183177 results.appendChild( suggestions );
184 - suggestionListener = function() {
185 - var title = this.parentNode.getAttribute( 'title' );
186 - sqValUpdate( title );
187 - };
188178
189179 for ( i = 0; i < sections.length; i++ ) {
190180 section = sections[i];
191181 suggestionsResult = document.createElement( 'li' );
192 - link = document.createElement( 'a' );
193182 suggestionsResult.setAttribute( 'title', section.label );
194183 suggestionsResult.className = 'suggestions-result';
195 - label = document.createTextNode( '+' );
196 - link.appendChild(label);
197 - link.className = 'sq-val-update';
198 - u( link ).bind( 'click', suggestionListener );
199 - suggestionsResult.appendChild( link );
200184
201185 link = document.createElement( 'a' );
202186 link.setAttribute( 'href', section.value.replace( /^(?:\/\/|[^\/]+)*\//, '/' ) );
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php
@@ -26,8 +26,7 @@
2727 'mobile-frontend-hide-button' => 'Hide',
2828 'mobile-frontend-disable-button' => 'Disable',
2929 'mobile-frontend-back-button' => 'Back',
30 - 'mobile-frontend-regular-site' => 'View this page on regular {{SITENAME}}',
31 - 'mobile-frontend-perm-stop-redirect' => 'Permanently disable mobile site',
 30+ 'mobile-frontend-regular-site' => 'Desktop view',
3231 'mobile-frontend-error-page-title' => 'We have a problem!',
3332 'mobile-frontend-error-page-text' => '{{SITENAME}} mobile is still under active development and we are working hard to fix all of our internal errors. We have been notified about this error and will be fixing it soon. Please check back!',
3433 'mobile-frontend-are-you-sure' => 'Are you sure?',
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
@@ -352,6 +352,10 @@
353353 display: none;
354354 }
355355
 356+.togglingEnabled .openSection {
 357+ display: block;
 358+}
 359+
356360 .mwm-notice {
357361 padding: 5px;
358362 background: #dddddd;
@@ -582,6 +586,7 @@
583587 #footer {
584588 margin: 0 8px;
585589 clear: both;
 590+ font-size: 0.8em;
586591 }
587592
588593 #logo {
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/close-button-beta.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/close-button-beta.png
___________________________________________________________________
Added: svn:mime-type
589594 + application/octet-stream
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png
___________________________________________________________________
Added: svn:mime-type
590595 + application/octet-stream
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
@@ -10,7 +10,7 @@
1111 }
1212
1313 body {
14 - font-size: 0.8em;
 14+ font-size: 1em;
1515 line-height: 1;
1616 color: black;
1717 background: white;
@@ -19,24 +19,21 @@
2020 }
2121
2222 .clearlink {
23 - background: url(images/close-button.png?v=1) no-repeat scroll 0 0 transparent;
24 - background-position: center center;
 23+ top: 9px;
 24+ right: -18px;
 25+ width: 18px;
 26+ height: 20px;
 27+ background: url(images/close-button-beta.png) no-repeat scroll 0 0 transparent;
 28+ margin: 0;
 29+ display: block;
 30+ background-position: right center;
 31+ background-size: auto 12px;
2532 cursor: pointer;
26 - zoom: 1;
2733 position: absolute;
28 - right: 0.25em;
29 - top: 10%;
30 - margin: 1px;
31 - height: 42px;
32 - width: 42px;
33 - margin-top: -6px;
34 - z-index: 99;
35 - border: 0px solid;
36 - display: none;
3734 }
3835
3936 html[dir="rtl"] .clearlink {
40 - left: 0.25em;
 37+ left: 0;
4138 right: auto;
4239 }
4340
@@ -129,33 +126,8 @@
130127 background-color: #ACD1E9;
131128 }
132129
133 -a.sq-val-update {
134 - font-size: 1.3em;
135 - display: block;
136 - font-weight: normal;
137 - text-decoration: none;
138 - color: #666;
139 - position: absolute;
140 - right: 0;
141 - width: 1.5em;
142 - text-align: center;
143 -}
144 -
145 -a.sq-val-update:visited {
146 - text-decoration: none;
147 -}
148 -
149 -a.sq-val-update:hover {
150 - text-decoration: none;
151 -}
152 -
153 -a.sq-val-update:active {
154 - text-decoration: none;
155 -}
156 -
157130 a.search-result-item {
158131 display: block;
159 - margin-right: 2em;
160132 }
161133
162134 /* TODO: support browsers which do not support data uris */
@@ -164,18 +136,7 @@
165137 padding-right: 13px;
166138 }
167139
168 -#results {
169 - display: none;
170 - background-color: #ffffff;
171 - border-top: none;
172 - z-index: 2;
173 - position: absolute;
174 - left: 53px;
175 - top: 35px;
176 -}
177 -
178140 .search_bar .search {
179 - width: 90%;
180141 -webkit-appearance: none;
181142 border-top-width: 0px;
182143 border-right-width: 0px;
@@ -185,6 +146,10 @@
186147 outline-width: initial;
187148 outline-color: initial;
188149 padding: 0;
 150+ font-size: 1.2em;
 151+ padding-right: 16px;
 152+ width: 100%;
 153+ vertical-align: middle; /* don't use line height here as placeholder on ripple positions incorrectly */
189154 }
190155
191156 #search::-webkit-search-cancel-button {
@@ -318,6 +283,10 @@
319284 margin: 0px;
320285 }
321286
 287+.section_heading {
 288+ cursor: pointer;
 289+}
 290+
322291 button.show,
323292 button.hide { /* for non-js browsers */
324293 display: none;
@@ -333,11 +302,35 @@
334303 display: inline-block;
335304 }
336305
337 -.togglingEnabled .content_block,
 306+.openSection button.hide,
 307+.openSection button.show {
 308+ opacity: 1;
 309+}
 310+
338311 .togglingEnabled .section_anchors {
339312 display: none;
340313 }
341314
 315+.togglingEnabled .content_block {
 316+ max-height: 0;
 317+ position: relative;
 318+ overflow: hidden;
 319+ -webkit-transition: max-height 0.2s ease-in;
 320+ -moz-transition: max-height 0.2s ease-in;
 321+ -o-transition: max-height 0.2s ease-in;
 322+ transition: max-height 0.2s ease-in;
 323+}
 324+
 325+.togglingEnabled .openSection.section_anchors {
 326+ display: block;
 327+}
 328+
 329+.togglingEnabled .openSection.content_block {
 330+ max-height: 9999px; /* large number as height: auto is not effected by transitions */
 331+ -webkit-transition: max-height 0.7s ease-in;
 332+ transition: max-height 0.7s ease-in;
 333+}
 334+
342335 .mwm-notice {
343336 padding: 5px;
344337 background: #dddddd;
@@ -542,13 +535,14 @@
543536 }
544537
545538 #header {
546 - margin: 8px 8px 0 8px;
 539+ margin: 0;
547540 position: relative;
 541+ border-bottom: solid 1px #CCC;
548542 }
549543
550544 #content_wrapper {
551545 clear: both;
552 - margin: 0 8px;
 546+ margin: 22px 22px;
553547 }
554548
555549 #footer {
@@ -558,51 +552,60 @@
559553
560554 #logo {
561555 position: absolute;
562 - top: 4px;
563 - left: 5px;
 556+ height: 22px;
 557+ cursor: pointer;
 558+ left: 22px;
 559+ top: 9px;
 560+ width: 35px;
564561 }
565562
 563+html[dir="rtl"] #searchbox {
 564+ padding: 0px 54px 0px 20px;
 565+}
 566+
566567 #zero-language-search.search_bar,
567568 #searchbox {
568569 width: auto;
569570 position: relative;
570 - padding: 8px 32px 8px 44px;
571 - border: 1px solid #cccccc;
 571+ padding: 0px 40px 0px 73px; /* right = width of #logo (35px) + 22px + 16px
 572+ left = width of close button + 22px */
572573 -webkit-border-radius: 2px;
573574 -moz-border-radius: 2px;
 575+ -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
574576 }
575577
 578+.full-screen-search #searchbox {
 579+ padding: 0px 40px 0px 54px; /* right = width of #logo (18px) + 22px + 16px */
 580+}
 581+
576582 #zero-language-search.search_bar {
577583 padding: 8px 32px 8px 0px;
578584 }
579585
580 -#searchbox #form {
581 - padding-right: 34px;
582 - width: 100%;
583 - margin-bottom: 0;
 586+html[dir="rtl"] #remove-results,
 587+html[dir="rtl"] #logo {
 588+ right: 18px;
 589+ left: auto;
584590 }
585591
586 -html[dir="rtl"] #logo,
587592 .goButton {
588593 position: absolute;
589 - right: 2px;
 594+ right: -18px;
590595 left: auto;
591 -}
592 -
593 -.goButton {
594 - top: 2px;
 596+ top: 0px;
595597 border: 0;
596 - background: url(images/s.gif) no-repeat top left;
 598+ background: url(images/s.gif) no-repeat center left;
597599 background-size: 27px 25px;
598 - height: 25px;
 600+ height: 40px;
599601 width: 27px;
600602 padding-bottom: 0;
601603 text-indent: -999px;
 604+ cursor: pointer;
602605 }
603606
604607 html[dir="rtl"] .goButton {
605608 right: auto;
606 - left: 2px;
 609+ left: 0;
607610 }
608611
609612 #searchbox a,
@@ -711,44 +714,67 @@
712715 full screen search css
713716 */
714717 .full-screen-search #header {
 718+ -webkit-box-shadow: 3px 1px 8px #333;
 719+ -moz-box-shadow: 3px 1px 8px #333;
 720+ -o-box-shadow: 3px 1px 8px #333;
 721+ box-shadow: 3px 1px 8px #333;
 722+ z-index: 2;
715723 margin: 0;
 724+ background-color: white;
716725 }
717726
718 -.full-screen-search #content,
 727+#results,
 728+#content_wrapper {
 729+ transition: all 0.3s ease-in-out;
 730+ -webkit-transition: all 0.3s ease-in-out;
 731+ -moz-transition: all 0.3s ease-in-out;
 732+ -o-transition: all 0.3s ease-in-out;
 733+}
 734+
 735+#content_wrapper,
 736+.full-screen-search #results {
 737+ opacity: 1;
 738+ height: auto;
 739+}
 740+
 741+#results,
 742+.full-screen-search #content_wrapper {
 743+ height: 0;
 744+ overflow: hidden;
 745+ opacity: 0;
 746+}
 747+
719748 .full-screen-search #footer,
720749 .full-screen-search #zero-rated-banner-red,
721750 .full-screen-search #zero-rated-banner {
722751 display: none;
723752 }
724753
725 -.full-screen-search #search {
726 - height: 30px; /* height of #sq - 2px border */
727 - font-size: 1.2em;
 754+#search::-webkit-search-decoration {
 755+ display: none;
728756 }
729757
730 -html[dir="rtl"] .full-screen-search #sq {
731 - padding-left: 0;
732 - padding-right: 44px;
 758+#header,
 759+#search,
 760+#sq,
 761+form,
 762+#searchbox {
 763+ position: relative;
 764+ right: 0;
 765+ top: 0;
 766+ left: 0;
 767+ height: 40px;
733768 }
734769
 770+#searchbox {
 771+ margin: 0;
 772+}
 773+
735774 .full-screen-search #sq {
736 - position: relative;
737 - padding-left: 44px;
738775 margin-right: 0;
739776 font-size: 16px;
740 - border: none;
741 - background-color: transparent;
742777 }
743778
744 -.full-screen-search #searchbox {
745 - position: absolute;
746 - width: 100%;
747 - padding: 0;
748 - top: 0;
749 - left: 0;
750 - border: none;
751 -}
752 -
753779 .full-screen-search #logo,
754780 .full-screen-search .goButton {
755781 display: none;
@@ -757,34 +783,32 @@
758784 .full-screen-search #results {
759785 left: 0px;
760786 width: 100% !important;
761 - min-height: 100%;
762 - border-bottom: none;
763 - border-left: none;
764 - border-right: none;
765 - border-top: 1px solid #A6A6A6;
 787+ max-height: 99999px;
 788+ border: none;
 789+ z-index: 1;
766790 background-color: #E6E6E6;
767 - display: block;
 791+ position: relative;
 792+ opacity: 1;
768793 }
769794
770795 .full-screen-search .suggestions-results {
771 - line-height: 2.6em;
772796 padding: 0;
773797 position: relative;
774 - border-bottom: solid 1px #999;
 798+ padding-bottom: 20px;
775799 font-size: 1.4em;
776800 cursor: pointer;
777801 margin: 0;
 802+ background-color: white;
778803 }
779804
780805 .full-screen-search .suggestions-result {
781 - line-height: 2.6em;
 806+ color: #666;
782807 border: none;
783 - color: black;
784 - margin: 0;
785 - line-height: 2.6em;
786 - padding: 0.01em 0.25em;
787808 position: relative;
788809 border-bottom: solid 1px #999999;
 810+ border-bottom: solid 1px #eee;
 811+ padding: 12px 56px;
 812+ font-size: 0.9em;
789813 }
790814
791815 .full-screen-search .suggestions-result a:visited {
@@ -794,16 +818,16 @@
795819 #remove-results {
796820 display: none;
797821 position: absolute;
798 - width: 40px;
 822+ width: 18px;
799823 height: 40px;
800824 text-align: center;
801825 line-height: 40px;
802 - background: url(images/arrow-left.png) no-repeat scroll 0 0 transparent;
803 - background-position: center center;
 826+ background: url(images/arrow-left-beta.png) no-repeat scroll 0 0 transparent;
 827+ background-position: left center;
 828+ background-size: auto 18px;
804829 cursor: pointer;
805 - zoom: 1;
806 - left: -3px;
807 - top: 3px;
 830+ left: 24px;
 831+ top: 6px; /* (#header height - background height) / 2 */
808832 margin: 1px;
809833 margin-top: -6px;
810834 z-index: 99;
@@ -812,27 +836,10 @@
813837 overflow: hidden;
814838 }
815839
816 -html[dir="rtl"] #remove-results {
817 - right: 0px;
818 - left: auto;
819 -}
820 -
821 -.full-screen-search #results {
822 - display: block !important;
823 -}
824 -
825840 .full-screen-search #remove-results {
826841 display: block;
827842 }
828843
829 -.full-screen-search .clearlink {
830 - background: url(images/close-button.png?v=1) no-repeat scroll 0 0 transparent;
831 - top: 0px;
832 - right: 0px;
833 - height: 42px;
834 - width: 42px;
835 -}
836 -
837844 .full-screen-search #nav {
838845 display: none !important;
839846 }
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css
@@ -31,5 +31,3 @@
3232 span.idx {
3333 display: none;
3434 }
35 -
36 -
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -103,6 +103,16 @@
104104 $wgMobileUrlTemplate = '';
105105
106106 /**
 107+ * The number of seconds the 'useformat' cookie should be valid
 108+ *
 109+ * The useformat cookie gets set when a user manually elects to view
 110+ * either the mobile or desktop view of the site.
 111+ *
 112+ * If this value is not set, it will default to $wgCookieExpiration
 113+ */
 114+$wgMobileFrontendFormatCookieExpiry;
 115+
 116+/**
107117 * URL for script used to disable mobile site
108118 * (protocol, host, optional port; path portion)
109119 *
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php
@@ -9,14 +9,12 @@
1010 public function getHTML() {
1111
1212 $regularSite = $this->data['messages']['mobile-frontend-regular-site'];
13 - $permStopRedirect = $this->data['messages']['mobile-frontend-perm-stop-redirect'];
1413 $copyright = $this->data['messages']['mobile-frontend-copyright'];
1514 $disableImages = $this->data['messages']['mobile-frontend-disable-images'];
1615 $enableImages = $this->data['messages']['mobile-frontend-enable-images'];
1716 $leaveFeedback = $this->data['messages']['mobile-frontend-leave-feedback'];
1817
1918 $leaveFeedbackURL = $this->data['leaveFeedbackURL'];
20 - $disableMobileSiteURL = $this->data['disableMobileSiteURL'];
2119 $viewNormalSiteURL = $this->data['viewNormalSiteURL'];
2220
2321 if ( $this->data['disableImages'] == 0 ) {
@@ -39,9 +37,6 @@
4038 <div class='nav' id='footmenu'>
4139 <div class='mwm-notice'>
4240 <a href="{$viewNormalSiteURL}">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink}
43 - <div id="perm">
44 - <a href="{$disableMobileSiteURL}">{$permStopRedirect}</a>
45 - </div>
4641 </div>
4742 </div>
4843 <div id='copyright'>{$copyright}</div>
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php
@@ -26,10 +26,9 @@
2727
2828 $languageSelection = $this->data['buildLanguageSelection'] . '<br/>';
2929 $languageSelectionText = '<b>' . $this->data['messages']['mobile-frontend-language'] . ':</b><br/>';
30 - $languageSelectionDiv = '<div id="languageselectionsection">' . $languageSelectionText . $languageSelection . '</div>';
 30+ $languageSelectionDiv = '<div id="languageselection">' . $languageSelectionText . $languageSelection . '</div>';
3131
3232 $searchWebkitHtml = <<<HTML
33 - {$openSearchResults}
3433 <div id='header'>
3534 <div id='searchbox' {$logoDisplayNone}>
3635 <img width="35" height="22" alt='Logo' id='logo' src='{$this->data['wgMobileFrontendLogo']}' {$logoDisplayNone} />
@@ -48,6 +47,7 @@
4948 <a href="{$randomPageUrl}" id="randomButton" class="button">{$randomButton}</a>
5049 </div>
5150 </div>
 51+ {$openSearchResults}
5252 HTML;
5353 return $searchWebkitHtml;
5454 }
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend
___________________________________________________________________
Modified: svn:mergeinfo
5555 Merged /trunk/extensions/MobileFrontend:r113807,113831-113832,113865-113866,113870-113872,113876,113880-113883,113885,113887,113897-113901

Follow-up revisions

RevisionCommit summaryAuthorDate
r114223Revert r114221,r114216,r114213,r114207,r114206,r114205,r114203,r114202,r11420...awjrichards00:26, 20 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113807correct id of language selection...jdlrobson11:55, 14 March 2012
r113831follow up to r113830...jdlrobson18:38, 14 March 2012
r113832add support for varying on image support in zeropreilly18:56, 14 March 2012
r113865* Changing how 'sticky cookies' work as well as how manually switching betwee...awjrichards21:55, 14 March 2012
r113866Followup r113865, fixing unit tests I brokeawjrichards22:14, 14 March 2012
r113870Followup r113865, removing 'disable mobile site permanantly' elements from fo...awjrichards22:50, 14 March 2012
r113871Revert r113870, accidentally checked in codeawjrichards22:53, 14 March 2012
r113872Follow up r113870, r113865, checking in only what I meant to the first time! ...awjrichards22:56, 14 March 2012
r113876Followup r113871, finishing revert of r113870awjrichards23:24, 14 March 2012
r113880redefine toggle behaviour...jdlrobson00:12, 15 March 2012
r113881correct viewport resetting...jdlrobson00:27, 15 March 2012
r113882remove autocomplete from search results...jdlrobson00:35, 15 March 2012
r113883add cursor pointer for section headings...jdlrobson00:41, 15 March 2012
r113885remove trailing whitespace on operamini.cssjdlrobson01:07, 15 March 2012
r113887* Abstracted cookie expiration time handling to its own method...awjrichards01:43, 15 March 2012
r113897adjust utils tests...jdlrobson07:56, 15 March 2012
r113898restyle header...jdlrobson09:44, 15 March 2012
r113899follow up to r113898...jdlrobson09:47, 15 March 2012
r113900style search results for full screen search...jdlrobson10:00, 15 March 2012
r113901font size tweaks...jdlrobson10:03, 15 March 2012

Status & tagging log