https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114202

Revision: 114202
Author:   awjrichards
Date:     2012-03-19 22:23:33 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
MFT r113807, r113831, r113832, r113865, r113866, r113870, r113871, r113872, 
r113876, r113880, r113881, r113882, r113883, r113885, r113887, r113897, 
r113898, r113899, r113900, r113901

Modified Paths:
--------------
    branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php
    
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
    branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
    branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
    branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
    branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css
    branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
    branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js

Added Paths:
-----------
    
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png
    
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/close-button-beta.png

Property Changed:
----------------
    branches/wmf/1.19wmf1/extensions/MobileFrontend/


Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk/extensions/MobileFrontend:99727,113463,113465-113466,113469-113472,113486,113488,113512,113553,113640,113642,113644-113645,113685,113693,113695,113714,113720-113721,113726,113730,113769-113771,113778
   + 
/trunk/extensions/MobileFrontend:99727,113463,113465-113466,113469-113472,113486,113488,113512,113553,113640,113642,113644-113645,113685,113693,113695,113714,113720-113721,113726,113730,113769-113771,113778,113807,113831-113832,113865-113866,113870-113872,113876,113880-113883,113885,113887,113897-113901

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php     
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php     
2012-03-19 22:23:33 UTC (rev 114202)
@@ -26,7 +26,6 @@
        public static $searchField;
        public static $disableImagesURL;
        public static $enableImagesURL;
-       public static $disableMobileSiteURL;
        public static $viewNormalSiteURL;
        public static $currentURL;
        public static $displayNoticeId;
@@ -72,7 +71,6 @@
                'mobile-frontend-hide-button',
                'mobile-frontend-back-to-top-of-section',
                'mobile-frontend-regular-site',
-               'mobile-frontend-perm-stop-redirect',
                'mobile-frontend-home-button',
                'mobile-frontend-random-button',
                'mobile-frontend-are-you-sure',
@@ -231,8 +229,7 @@
 
                self::$disableImagesURL = $wgRequest->escapeAppendQuery( 
'disableImages=1' );
                self::$enableImagesURL = $wgRequest->escapeAppendQuery( 
'enableImages=1' );
-               self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 
'mobileaction=disable_mobile_site' );
-               self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 
'mobileaction=view_normal_site' );
+               self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 
'useformat=desktop' );
                self::$currentURL = $wgRequest->getFullRequestURL();
                self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 
'mobileaction=leave_feedback' );
 
@@ -477,12 +474,6 @@
                        exit();
                }
 
-               if ( $mobileAction == 'disable_mobile_site' && 
$this->contentFormat == 'XHTML' ) {
-                       echo $this->renderDisableMobileSiteXHTML();
-                       wfProfileOut( __METHOD__ );
-                       exit();
-               }
-
                if ( $mobileAction == 'opt_in_mobile_site' && 
$this->contentFormat == 'XHTML' ) {
                        echo $this->renderOptInMobileSiteXHTML();
                        wfProfileOut( __METHOD__ );
@@ -716,6 +707,7 @@
                }
                $wgOut->addVaryHeader( 'Cookie' );
                $wgOut->addVaryHeader( 'X-Carrier' );
+               $wgOut->addVaryHeader( 'X-Images' );
                wfProfileOut( __METHOD__ );
                return true;
        }
@@ -857,54 +849,6 @@
        }
 
        /**
-        * @return string
-        */
-       private function renderDisableMobileSiteXHTML() {
-               wfProfileIn( __METHOD__ );
-               if ( $this->contentFormat == 'XHTML' ) {
-                       $this->getMsg();
-                       $areYouSure = 
self::$messages['mobile-frontend-are-you-sure'];
-                       $explainDisable = 
self::$messages['mobile-frontend-explain-disable'];
-                       $disableButton = 
self::$messages['mobile-frontend-disable-button'];
-                       $backButton = 
self::$messages['mobile-frontend-back-button'];
-                       $htmlTitle = $areYouSure;
-                       $title = $areYouSure;
-                       $searchTemplate = $this->getSearchTemplate();
-                       $searchWebkitHtml = $searchTemplate->getHTML();
-                       $footerTemplate = $this->getFooterTemplate();
-                       $footerHtml = $footerTemplate->getHTML();
-                       $disableTemplate = new DisableTemplate();
-                       $options = array(
-                                                       'currentURL' => 
self::$currentURL,
-                                                       
'mobileRedirectFormAction' => self::$mobileRedirectFormAction,
-                                                       'areYouSure' => 
$areYouSure,
-                                                       'explainDisable' => 
$explainDisable,
-                                                       'disableButton' => 
$disableButton,
-                                                       'backButton' => 
$backButton,
-                                                       'htmlTitle' => 
$htmlTitle,
-                                                       'title' => $title,
-                                                       );
-                       $disableTemplate->setByArray( $options );
-                       $disableHtml = $disableTemplate->getHTML();
-
-                       $contentHtml = $disableHtml;
-                       $applicationTemplate = $this->getApplicationTemplate();
-                       $options = array(
-                                                       'htmlTitle' => 
$htmlTitle,
-                                                       'searchWebkitHtml' => 
$searchWebkitHtml,
-                                                       'contentHtml' => 
$contentHtml,
-                                                       'footerHtml' => 
$footerHtml,
-                                                       );
-                       $applicationTemplate->setByArray( $options );
-                       $applicationHtml = $applicationTemplate->getHTML();
-                       wfProfileOut( __METHOD__ );
-                       return $applicationHtml;
-               }
-               wfProfileOut( __METHOD__ );
-               return '';
-       }
-
-       /**
         * @return DomElement
         */
        public function renderLogin() {
@@ -1164,7 +1108,6 @@
                $options = array(
                                                'messages' => self::$messages,
                                                'leaveFeedbackURL' => 
self::$leaveFeedbackURL,
-                                               'disableMobileSiteURL' => 
self::$disableMobileSiteURL,
                                                'viewNormalSiteURL' => 
self::$viewNormalSiteURL,
                                                'disableImages' => 
self::$disableImages,
                                                'disableImagesURL' => 
self::$disableImagesURL,
@@ -1441,15 +1384,20 @@
        }
        
        protected function shouldDisplayMobileView() {
-               if ( !$this->isMobileDevice() && !$this->isFauxMobileDevice() ) 
{
+               // always display desktop view if it's explicitly requested
+               $useFormat = $this->getUseFormat();
+               if ( $useFormat == 'desktop' ) {
                        return false;
                }
+
+               if ( !$this->isMobileDevice() && !$this->isFauxMobileDevice() ) 
{
+                       return false;
+               }               
                
                $action = $this->getAction();
-               $mobileAction = $this->getMobileAction();
                
-               if ( $action === 'edit' || $action === 'history' ||
-                        $mobileAction === 'view_normal_site' ) {
+               
+               if ( $action === 'edit' || $action === 'history' ) {
                        return false;
                }
                                
@@ -1501,29 +1449,49 @@
                
                $useFormat = $this->getUseFormat();
                $useFormatFromCookie = $wgRequest->getCookie( 'mf_useformat' );
+               
+               // fetch format from cookie and set it if one is not otherwise 
specified
                if( !strlen( $useFormat ) && !is_null( $useFormatFromCookie ) ) 
{
                        $this->setUseFormat( $useFormatFromCookie );
                }
                
-               // if we should not be displaying the mobile view, make sure 
cookies are unset etc.
-               if ( !$this->shouldDisplayMobileView() ) {
-                       // make sure cookie is unset for appropriate mobile 
actions
-                       $mobileAction = $this->getMobileAction();
-                       if ( in_array( $mobileAction, array( 
'view_normal_site', 'disable_mobile_site' ) ) ) {
-                               $wgRequest->response()->setCookie( 
'mf_useformat', false, time() - 3600 );
-                       }
-                       
-                       // make sure useformat is unset
-                       $this->setUseFormat( '' );
-                       return;
+               // set appropriate cookie if necessary
+               if ( ( $useFormatFromCookie != 'mobile' && $useFormat == 
'mobile' ) ||
+                               ( $useFormatFromCookie != 'desktop' && 
$useFormat == 'desktop' ) ) {
+                       $this->setUseFormatCookie( $useFormat );
                }
-               
-               // if getUseFormat and no cookie set, set the cookie
-               if ( is_null( $useFormatFromCookie ) && strlen( $useFormat ) ) {
-                       $wgRequest->response()->setCookie( 'mf_useformat', 
$useFormat, 0 );
-               }
        }
        
+       /**
+        * Set the mf_useformat cookie
+        * 
+        * This cookie can determine whether or not a user should see the mobile
+        * version of pages.
+        *
+        * @param string The format to store in the cookie
+        */
+       protected function setUseFormatCookie( $useFormat ) {
+               global $wgRequest;
+               $expiry = $this->getUseFormatCookieExpiry();
+               $wgRequest->response()->setCookie( 'mf_useformat', $useFormat, 
$expiry );
+       }
+       
+       /**
+        * Get the expiration time for the mf_useformat cookie
+        *
+        * If $wgMobileFrontendFormatCookieExpiry as a non-0 value, 
+        * @param int The base time (in seconds since Epoch) from which to 
calculate
+        *              cookie expiration. If null, time() is used.
+        */
+       protected function getUseFormatCookieExpiry( $startTime=null ) {
+               global $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry;
+               $cookieDuration = ( abs( intval( 
$wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ? 
+                               $wgMobileFrontendFormatCookieExpiry : 
$wgCookieExpiration;
+               if ( intval( $startTime ) === 0 ) $startTime = time();
+               $expiry = $startTime + $cookieDuration;
+               return $expiry;
+       }
+       
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php     
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.i18n.php     
2012-03-19 22:23:33 UTC (rev 114202)
@@ -26,8 +26,7 @@
        'mobile-frontend-hide-button' => 'Hide',
        'mobile-frontend-disable-button' => 'Disable',
        'mobile-frontend-back-button' => 'Back',
-       'mobile-frontend-regular-site' => 'View this page on regular 
{{SITENAME}}',
-       'mobile-frontend-perm-stop-redirect' => 'Permanently disable mobile 
site',
+       'mobile-frontend-regular-site' => 'Desktop view',
        'mobile-frontend-error-page-title' => 'We have a problem!',
        '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!',
        'mobile-frontend-are-you-sure' => 'Are you sure?',

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php  
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php  
2012-03-19 22:23:33 UTC (rev 114202)
@@ -103,6 +103,16 @@
 $wgMobileUrlTemplate = '';
 
 /**
+ * The number of seconds the 'useformat' cookie should be valid
+ * 
+ * The useformat cookie gets set when a user manually elects to view
+ * either the mobile or desktop view of the site.
+ *
+ * If this value is not set, it will default to $wgCookieExpiration
+ */
+$wgMobileFrontendFormatCookieExpiry;
+
+/**
  * URL for script used to disable mobile site
  * (protocol, host, optional port; path portion)
  *

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js  
    2012-03-19 22:18:07 UTC (rev 114201)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js  
    2012-03-19 22:23:33 UTC (rev 114202)
@@ -4,12 +4,12 @@
        var apiUrl = '/api.php', timer = -1, typingDelay = 500,
                numResults = 15, term,
                search = document.getElementById( 'search' ),
-               sq = document.getElementById( 'sq' ),
                sb = document.getElementById( 'searchbox' ),
                content = document.getElementById( 'content' ),
                footer = document.getElementById( 'footer' ),
                clearSearch = document.getElementById( 'clearsearch' ),
                focused = false,
+               viewportmeta, originalViewport,
                u = MobileFrontend.utils;
 
        apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
@@ -17,16 +17,19 @@
        function hideResults() {
                results.style.display = 'none';
        }
+       
+       viewportmeta = u( 'meta[name="viewport"]' )
+       if ( viewportmeta ) {
+               viewportmeta = viewportmeta[0];
+               originalViewport = viewportmeta.getAttribute( 'content' );
+       }
+       // prevent auto-zoom in on clicking search for certain browsers e.g. 
palm pre and ipad
        function resetViewPort() {
-               if ( navigator.userAgent.match( /iPhone/i ) || 
navigator.userAgent.match( /iPad/i ) ) {
-                       var viewportmeta = u( 'meta[name="viewport"]' );
-                       if ( viewportmeta ) {
-                               viewportmeta = viewportmeta[0];
-                               viewportmeta.content = 'width=device-width, 
minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
-                               u( document.body ).bind( 'gesturestart', 
function () {
-                                       viewportmeta.content = 
'width=device-width, initial-scale=1.0';
-                               } );
-                   }
+               if ( viewportmeta ) {
+                       viewportmeta.setAttribute( 'content', 
'minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0');
+                       u( document.body ).bind( 'gesturestart', function () {
+                               viewportmeta.setAttribute( 'content', 
originalViewport );
+                       } );
                }
        }
 
@@ -35,7 +38,7 @@
        search.onfocus = function() {
                var rrd, rrdD;
                sb = document.getElementById( 'searchbox' );
-               sq = document.getElementById( 'sq' );
+               header = document.getElementById( 'header' );
                content = document.getElementById( 'content' );
                footer = document.getElementById( 'footer' );
                resetViewPort();
@@ -52,7 +55,7 @@
                                rrdD = document.createElement( 'div' );
                                rrdD.setAttribute( 'id', 'left-arrow' );
                                rrd.appendChild( rrdD );
-                               sq.insertBefore( rrd, sq.firstChild );
+                               header.insertBefore( rrd, header.firstChild );
                        }
                        focused = true;
                }
@@ -108,14 +111,14 @@
        window.onload = function () {
                u( search ).bind( 'keyup',
                        function() {
-                               clearTimeout( timer );
-                               term = this.value;
-                               if ( term.length < 1 ) {
-                                       results.innerHTML = '';
-                               } else {
-                                       term = encodeURIComponent( term );
-                                       timer = setTimeout( function () { 
searchApi( term ); }, typingDelay );
-                               }
+               clearTimeout( timer );
+               term = search.value;
+               if ( term.length < 1 ) {
+                       results.innerHTML = '';
+               } else {
+                       term = encodeURIComponent( term );
+                       timer = setTimeout( function () { searchApi( term ); }, 
typingDelay );
+               }
                        } );
        };
 
@@ -142,15 +145,6 @@
                return sections;
        }
 
-       function sqValUpdate( sqValue ) {
-               var search = document.getElementById( 'search' );
-               if ( search ) {
-                       search.value = sqValue + ' ';
-                       search.focus();
-                       searchApi( search.value );
-               }
-       }
-
        function htmlEntities( str ) {
                var text = document.createTextNode( str ),
                        el = document.createElement( 'div' );
@@ -165,7 +159,7 @@
        function writeResults( sections ) {
                var results = document.getElementById( 'results' ), 
suggestions, i,
                        term = htmlEntities( document.getElementById( 'search' 
).value ),
-                       suggestionListener, section, escapedTerm, 
suggestionsResult, link, label;
+                       section, escapedTerm, suggestionsResult, link, label;
 
                results.style.display = 'block';
                if ( search ) {
@@ -180,22 +174,12 @@
                        suggestions = document.createElement( 'ul' );
                        suggestions.className = 'suggestions-results';
                        results.appendChild( suggestions );
-                       suggestionListener = function() {
-                               var title = this.parentNode.getAttribute( 
'title' );
-                               sqValUpdate( title );
-                       };
 
                        for ( i = 0; i < sections.length; i++ ) {
                                section = sections[i];
                                suggestionsResult = document.createElement( 
'li' );
-                               link = document.createElement( 'a' );
                                suggestionsResult.setAttribute( 'title', 
section.label );
                                suggestionsResult.className = 
'suggestions-result';
-                               label = document.createTextNode( '+' );
-                               link.appendChild(label);
-                               link.className = 'sq-val-update';
-                               u( link ).bind( 'click', suggestionListener );
-                               suggestionsResult.appendChild( link );
 
                                link = document.createElement( 'a' );
                                link.setAttribute( 'href', 
section.value.replace( /^(?:\/\/|[^\/]+)*\//, '/' ) );

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js       
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js       
2012-03-19 22:23:33 UTC (rev 114202)
@@ -79,8 +79,10 @@
                }
                for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
                        e = document.getElementById( d[i] + section_id );
-                       if ( e ) {
-                               e.style.display = e.style.display === 'block' ? 
'none' : 'block';
+                       if ( e && u( e ).hasClass( 'openSection' ) ) {
+                               u( e ).removeClass( 'openSection' )
+                       } else {
+                               u( e ).addClass( 'openSection' )
                        }
                }
        }

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css 
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css 
2012-03-19 22:23:33 UTC (rev 114202)
@@ -10,7 +10,7 @@
 }
 
 body {
-       font-size: 0.8em;
+       font-size: 1em;
        line-height: 1;
        color: black;
        background: white;
@@ -19,24 +19,21 @@
 }
 
 .clearlink {
-       background: url(images/close-button.png?v=1) no-repeat scroll 0 0 
transparent;
-       background-position: center center;
+       top: 9px;
+       right: -18px;
+       width: 18px;
+       height: 20px;
+       background: url(images/close-button-beta.png) no-repeat scroll 0 0 
transparent;
+       margin: 0;
+       display: block;
+       background-position: right center;
+       background-size: auto 12px;
        cursor: pointer;
-       zoom: 1;
        position: absolute;
-       right: 0.25em;
-       top: 10%;
-       margin: 1px;
-       height: 42px;
-       width: 42px;
-       margin-top: -6px;
-       z-index: 99;
-       border: 0px solid;
-       display: none;
 }
 
 html[dir="rtl"] .clearlink {
-       left: 0.25em;
+       left: 0;
        right: auto;
 }
 
@@ -129,33 +126,8 @@
        background-color: #ACD1E9;
 }
 
-a.sq-val-update {
-       font-size: 1.3em;
-       display: block;
-       font-weight: normal;
-       text-decoration: none;
-       color: #666;
-       position: absolute;
-       right: 0;
-       width: 1.5em;
-       text-align: center;
-}
-
-a.sq-val-update:visited {
-       text-decoration: none;
-}
-
-a.sq-val-update:hover {
-       text-decoration: none;
-}
-
-a.sq-val-update:active {
-       text-decoration: none;
-}
-
 a.search-result-item {
        display: block;
-       margin-right: 2em;
 }
 
 /* TODO: support browsers which do not support data uris */
@@ -164,18 +136,7 @@
        padding-right: 13px;
 }
 
-#results {
-       display: none;
-       background-color: #ffffff;
-       border-top: none;
-       z-index: 2;
-       position: absolute;
-       left: 53px;
-       top: 35px;
-}
-
 .search_bar .search {
-       width: 90%;
        -webkit-appearance: none;
        border-top-width: 0px;
        border-right-width: 0px;
@@ -185,6 +146,10 @@
        outline-width: initial;
        outline-color: initial;
        padding: 0;
+       font-size: 1.2em;
+       padding-right: 16px;
+       width: 100%;
+       vertical-align: middle; /* don't use line height here as placeholder on 
ripple positions incorrectly */
 }
 
 #search::-webkit-search-cancel-button {
@@ -318,6 +283,10 @@
        margin: 0px;
 }
 
+.section_heading {
+       cursor: pointer;
+}
+
 button.show,
 button.hide { /* for non-js browsers */
        display: none;
@@ -333,11 +302,35 @@
        display: inline-block;
 }
 
-.togglingEnabled .content_block,
+.openSection button.hide,
+.openSection button.show {
+       opacity: 1;
+}
+
 .togglingEnabled .section_anchors {
        display: none;
 }
 
+.togglingEnabled .content_block {
+       max-height: 0;
+       position: relative;
+       overflow: hidden;
+       -webkit-transition: max-height 0.2s ease-in;
+       -moz-transition: max-height 0.2s ease-in;
+       -o-transition: max-height 0.2s ease-in;
+       transition: max-height 0.2s ease-in;
+}
+
+.togglingEnabled .openSection.section_anchors {
+       display: block;
+}
+
+.togglingEnabled .openSection.content_block {
+       max-height: 9999px; /* large number as height: auto is not effected by 
transitions */
+       -webkit-transition: max-height 0.7s ease-in;
+       transition: max-height 0.7s ease-in;
+}
+
 .mwm-notice {
        padding: 5px;
        background: #dddddd;
@@ -542,13 +535,14 @@
 }
 
 #header {
-       margin: 8px 8px 0 8px;
+       margin: 0;
        position: relative;
+       border-bottom: solid 1px #CCC;
 }
 
 #content_wrapper {
        clear: both;
-       margin: 0 8px;
+       margin: 22px 22px;
 }
 
 #footer {
@@ -558,51 +552,60 @@
 
 #logo {
        position: absolute;
-       top: 4px;
-       left: 5px;
+       height: 22px;
+       cursor: pointer;
+       left: 22px;
+       top: 9px;
+       width: 35px;
 }
 
+html[dir="rtl"] #searchbox {
+       padding: 0px 54px 0px 20px;
+}
+
 #zero-language-search.search_bar,
 #searchbox {
        width: auto;
        position: relative;
-       padding: 8px 32px 8px 44px;
-       border: 1px solid #cccccc;
+       padding: 0px 40px 0px 73px; /* right = width of #logo (35px) + 22px + 
16px
+       left = width of close button + 22px */
        -webkit-border-radius: 2px;
        -moz-border-radius: 2px;
+       -webkit-tap-highlight-color: rgba(255, 255, 255, 0); 
 }
 
+.full-screen-search #searchbox {
+       padding: 0px 40px 0px 54px; /* right = width of #logo (18px) + 22px + 
16px */
+}
+
 #zero-language-search.search_bar {
        padding: 8px 32px 8px 0px;
 }
 
-#searchbox #form {
-       padding-right: 34px;
-       width: 100%;
-       margin-bottom: 0;
+html[dir="rtl"] #remove-results,
+html[dir="rtl"] #logo {
+       right: 18px;
+       left: auto;
 }
 
-html[dir="rtl"] #logo,
 .goButton {
        position: absolute;
-       right: 2px;
+       right: -18px;
        left: auto;
-}
-
-.goButton {
-       top: 2px;
+       top: 0px;
        border: 0;
-       background: url(images/s.gif) no-repeat top left;
+       background: url(images/s.gif) no-repeat center left;
        background-size: 27px 25px;
-       height: 25px;
+       height: 40px;
        width: 27px;
        padding-bottom: 0;
        text-indent: -999px;
+       cursor: pointer;
 }
 
 html[dir="rtl"] .goButton {
        right: auto;
-       left: 2px;
+       left: 0;
 }
 
 #searchbox a,
@@ -711,44 +714,67 @@
 full screen search css
 */
 .full-screen-search #header {
+       -webkit-box-shadow: 3px 1px 8px #333;
+       -moz-box-shadow: 3px 1px 8px #333;
+       -o-box-shadow: 3px 1px 8px #333;
+       box-shadow: 3px 1px 8px #333;
+       z-index: 2;
        margin: 0;
+       background-color: white;
 }
 
-.full-screen-search #content,
+#results,
+#content_wrapper {
+       transition: all 0.3s ease-in-out;
+       -webkit-transition: all 0.3s ease-in-out;
+       -moz-transition: all 0.3s ease-in-out;
+       -o-transition: all 0.3s ease-in-out;
+}
+
+#content_wrapper,
+.full-screen-search #results {
+       opacity: 1;
+       height: auto;
+}
+
+#results,
+.full-screen-search #content_wrapper {
+       height: 0;
+       overflow: hidden;
+       opacity: 0;
+}
+
 .full-screen-search #footer,
 .full-screen-search #zero-rated-banner-red,
 .full-screen-search #zero-rated-banner {
        display: none;
 }
 
-.full-screen-search #search {
-       height: 30px; /* height of #sq - 2px border */
-       font-size: 1.2em;
+#search::-webkit-search-decoration {
+       display: none;
 }
 
-html[dir="rtl"] .full-screen-search #sq {
-       padding-left: 0;
-       padding-right: 44px;
+#header,
+#search,
+#sq,
+form,
+#searchbox {
+       position: relative;
+       right: 0;
+       top: 0;
+       left: 0;
+       height: 40px;
 }
 
+#searchbox {
+       margin: 0;
+}
+
 .full-screen-search #sq {
-       position: relative;
-       padding-left: 44px;
        margin-right: 0;
        font-size: 16px;
-       border: none;
-       background-color: transparent;
 }
 
-.full-screen-search #searchbox {
-       position: absolute;
-       width: 100%;
-       padding: 0;
-       top: 0;
-       left: 0;
-       border: none;
-}
-
 .full-screen-search #logo,
 .full-screen-search .goButton {
        display: none;
@@ -757,34 +783,32 @@
 .full-screen-search #results {
        left: 0px;
        width: 100% !important;
-       min-height: 100%;
-       border-bottom: none;
-       border-left: none;
-       border-right: none;
-       border-top: 1px solid #A6A6A6;
+       max-height: 99999px;
+       border: none;
+       z-index: 1;
        background-color: #E6E6E6;
-       display: block;
+       position: relative;
+       opacity: 1;
 }
 
 .full-screen-search .suggestions-results {
-       line-height: 2.6em;
        padding: 0;
        position: relative;
-       border-bottom: solid 1px #999;
+       padding-bottom: 20px;
        font-size: 1.4em;
        cursor: pointer;
        margin: 0;
+       background-color: white;
 }
 
 .full-screen-search .suggestions-result {
-       line-height: 2.6em;
+       color: #666;
        border: none;
-       color: black;
-       margin: 0;
-       line-height: 2.6em;
-       padding: 0.01em 0.25em;
        position: relative;
        border-bottom: solid 1px #999999;
+       border-bottom: solid 1px #eee;
+       padding: 12px 56px;
+       font-size: 0.9em;
 }
 
 .full-screen-search .suggestions-result a:visited {
@@ -794,16 +818,16 @@
 #remove-results {
        display: none;
        position: absolute;
-       width: 40px;
+       width: 18px;
        height: 40px;
        text-align: center;
        line-height: 40px;
-       background: url(images/arrow-left.png) no-repeat scroll 0 0 transparent;
-       background-position: center center;
+       background: url(images/arrow-left-beta.png) no-repeat scroll 0 0 
transparent;
+       background-position: left center;
+       background-size: auto 18px;
        cursor: pointer;
-       zoom: 1;
-       left: -3px;
-       top: 3px;
+       left: 24px;
+       top: 6px; /* (#header height - background height) / 2 */
        margin: 1px;
        margin-top: -6px;
        z-index: 99;
@@ -812,27 +836,10 @@
        overflow: hidden;
 }
 
-html[dir="rtl"] #remove-results {
-       right: 0px;
-       left: auto;
-}
-
-.full-screen-search #results {
-       display: block !important;
-}
-
 .full-screen-search #remove-results {
        display: block;
 }
 
-.full-screen-search .clearlink {
-       background: url(images/close-button.png?v=1) no-repeat scroll 0 0 
transparent;
-       top: 0px;
-       right: 0px;
-       height: 42px;
-       width: 42px;
-}
-
 .full-screen-search #nav {
        display: none !important;
 }

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css      
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css      
2012-03-19 22:23:33 UTC (rev 114202)
@@ -352,6 +352,10 @@
        display: none;
 }
 
+.togglingEnabled .openSection {
+       display: block;
+}
+
 .mwm-notice {
        padding: 5px;
        background: #dddddd;
@@ -582,6 +586,7 @@
 #footer {
        margin: 0 8px;
        clear: both;
+       font-size: 0.8em;
 }
 
 #logo {

Copied: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png
 (from rev 113898, 
trunk/extensions/MobileFrontend/stylesheets/images/arrow-left-beta.png)
===================================================================
(Binary files differ)

Copied: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/close-button-beta.png
 (from rev 113898, 
trunk/extensions/MobileFrontend/stylesheets/images/close-button-beta.png)
===================================================================
(Binary files differ)

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css   
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/operamini.css   
2012-03-19 22:23:33 UTC (rev 114202)
@@ -31,5 +31,3 @@
 span.idx {
        display: none;
 }
-
-

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php    
    2012-03-19 22:18:07 UTC (rev 114201)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php    
    2012-03-19 22:23:33 UTC (rev 114202)
@@ -9,14 +9,12 @@
        public function getHTML() {
 
                $regularSite = 
$this->data['messages']['mobile-frontend-regular-site'];
-               $permStopRedirect = 
$this->data['messages']['mobile-frontend-perm-stop-redirect'];
                $copyright = 
$this->data['messages']['mobile-frontend-copyright'];
                $disableImages = 
$this->data['messages']['mobile-frontend-disable-images'];
                $enableImages = 
$this->data['messages']['mobile-frontend-enable-images'];
                $leaveFeedback = 
$this->data['messages']['mobile-frontend-leave-feedback'];
 
                $leaveFeedbackURL = $this->data['leaveFeedbackURL'];
-               $disableMobileSiteURL = $this->data['disableMobileSiteURL'];
                $viewNormalSiteURL = $this->data['viewNormalSiteURL'];
 
                if ( $this->data['disableImages'] == 0 ) {
@@ -39,9 +37,6 @@
                          <div class='nav' id='footmenu'>
                                <div class='mwm-notice'>
                                  <a 
href="{$viewNormalSiteURL}">{$regularSite}</a> | <a 
href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink}
-                                       <div id="perm">
-                                               <a 
href="{$disableMobileSiteURL}">{$permStopRedirect}</a>
-                                       </div>
                                </div>
                          </div>
                          <div id='copyright'>{$copyright}</div>

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php    
    2012-03-19 22:18:07 UTC (rev 114201)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php    
    2012-03-19 22:23:33 UTC (rev 114202)
@@ -26,10 +26,9 @@
 
                $languageSelection = $this->data['buildLanguageSelection'] . 
'<br/>';
                $languageSelectionText = '<b>' . 
$this->data['messages']['mobile-frontend-language'] . ':</b><br/>';
-               $languageSelectionDiv = '<div id="languageselectionsection">' . 
$languageSelectionText . $languageSelection . '</div>';
+               $languageSelectionDiv = '<div id="languageselection">' . 
$languageSelectionText . $languageSelection . '</div>';
 
                $searchWebkitHtml = <<<HTML
-                       {$openSearchResults}
                <div id='header'>
                        <div id='searchbox' {$logoDisplayNone}>
                        <img width="35" height="22" alt='Logo' id='logo' 
src='{$this->data['wgMobileFrontendLogo']}' {$logoDisplayNone} />
@@ -48,6 +47,7 @@
                        <a href="{$randomPageUrl}" id="randomButton" 
class="button">{$randomButton}</a>
                  </div>
                </div>
+               {$openSearchResults}
 HTML;
                return $searchWebkitHtml;
        }

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php    
    2012-03-19 22:18:07 UTC (rev 114201)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php    
    2012-03-19 22:23:33 UTC (rev 114202)
@@ -219,15 +219,14 @@
                        array( false, null, array() ),
                        array( true, 'webkit', array() ),
                        array( false, 'webkit', array( 'action' => 'edit' ) ),
-                       array( false, 'webkit', array( 'mobileaction' => 
'view_normal_site' ) ),
+                       array( false, 'webkit', array( 'useformat' => 'desktop' 
) ),
                        array( true, null, array( 'useformat' => 'mobile-wap' ) 
),
                        array( false, null, array( 'useformat' => 'mobile-wap', 
'action' => 'edit' ) ),
                        array( false, null, array( 'useformat' => 'mobile-wap', 
'action' => 'history' ) ),
-                       array( false, null, array( 'useformat' => 'mobile-wap', 
'mobileaction' => 'view_normal_site' ) ),
+                       array( false, null, array( 'useformat' => 'desktop' ) ),
                        array( true, null, array( 'useformat' => 'mobile' ) ),
                        array( false, null, array( 'useformat' => 'mobile', 
'action' => 'edit' ) ),
                        array( false, null, array( 'useformat' => 'mobile', 
'action' => 'history' ) ),
-                       array( false, null, array( 'useformat' => 'mobile', 
'mobileaction' => 'view_normal_site' ) ),
                );
        }
        
@@ -302,4 +301,65 @@
                        array( 'edit' ),
                );
        }
+       
+       /**
+        * @dataProvider getUseFormatProvider
+        */
+       public function testGetUseFormat( $explicit, $requestParam, $expected ) 
{
+               global $wgRequest, $wgExtMobileFrontend;
+               $wgRequest->setVal( 'useformat', $requestParam );
+               $wgExtMobileFrontend->setUseFormat( $explicit );
+               $this->assertEquals( $expected, 
$wgExtMobileFrontend->getUseFormat() );
+       }
+       
+       public function getUseFormatProvider() {
+               return array(
+                       array( 'mobile', null, 'mobile' ),
+                       array( null, 'mobile', 'mobile' ),
+                       array( null, null, '' ),
+                       array( 'desktop', 'mobile', 'desktop' ),
+               );
+       }
+       
+       public function testGetUseFormatCookieExpiry() {
+               global $wgExtMobileFrontend, $wgCookieExpiration, 
$wgMobileFrontendFormatCookieExpiry;
+               $getUseFormatCookieExpiry = self::getMethod( 
'getUseFormatCookieExpiry' );
+               
+               $origMFCookieExpiry = $wgMobileFrontendFormatCookieExpiry;
+               $startTime = time();
+               $wgMobileFrontendFormatCookieExpiry = 60;
+               $mfCookieExpected = $startTime + 60;
+               $this->assertTrue( $mfCookieExpected == 
$getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime 
) ), 'Using MobileFrontend expiry.' );
+               
+               $wgMobileFrontendFormatCookieExpiry = null;
+               $defaultMWCookieExpected = $startTime + $wgCookieExpiration;
+               $this->assertTrue( $defaultMWCookieExpected == 
$getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime 
) ), 'Using default MediaWiki cookie expiry.' );
+
+               // reset global back to original value
+               $wgMobileFrontendFormatCookieExpiry = $origMFCookieExpiry;
+       }
+       
+       /**
+     * @outputBuffering enabled
+        */
+       /*public function testCookie() {
+               global $wgRequest;
+               $wgRequest->response()->setCookie( 'foo', 'bar' );
+               $this->assertEquals( $wgRequest->getCookie( 'foo' ), 'bar' );
+               setcookie( 'foobar', 'pants' );
+               $this->asertEquals( $_COOKIE[ 'foobar' ], 'pants' );
+       }
+       
+       /**
+        * NB this will not work as PHPUnit seems to not make it possible to set
+        * and retrieve cookies. Note above test, testCookie() - both assertions
+        * currently fail, making testing 
ExtMobileFrontend::checkUserFormatCookie()
+        * impossible.
+        *
+     * @outputBuffering enabled
+        */
+       /*public function testCheckUseFormatCookie() {
+       
+       }
+       */
 }

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js    
    2012-03-19 22:18:07 UTC (rev 114201)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js    
    2012-03-19 22:23:33 UTC (rev 114202)
@@ -1,14 +1,22 @@
 var MFE = MobileFrontend;
 var MFET = window.MobileFrontendTests;
 
-module("MobileFrontend application.js: utils");
+module("MobileFrontend application.js: utils", {
+       setup: function() {
+               var section = '<div class="t_section_heading"></div>';
+               $('<div id="mfetest">' + section + '<div id="t_section_1">' + 
section + '</div>').appendTo(document.body);
+       },
+       teardown: function() {
+               $("#mfetest").remove();
+       }
+});
 
 test("Basic selector support (#id)", function() {
-       strictEqual(MFE.utils("#section_1").length, 1, "only one element 
matches this selector");
+       strictEqual(MFE.utils("#t_section_1").length, 1, "only one element 
matches this selector");
 });
 
 test("Basic selector support (.className)", function() {
-       strictEqual(MFE.utils(".section_heading").length, 2, "only two elements 
matches this selector");
+       strictEqual(MFE.utils(".t_section_heading").length, 2, "only two 
elements matches this selector");
 });
 
 test("Basic selector support (tag name)", function() {

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js     
2012-03-19 22:18:07 UTC (rev 114201)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js     
2012-03-19 22:23:33 UTC (rev 114202)
@@ -1,16 +1,8 @@
-function applyCss() {
-       $(".hide").show();
-       $(".show").hide();
-       $(".openSection .hide").hide();
-       $(".openSection .show").show();
-}
-
 module("MobileFrontend toggle.js: wm_toggle_section", {
        setup: function() {
                MFET.createFixtures();
                MFE.toggle.init();
-               $("#section_1").addClass("openSection");
-               $("#content_1,#anchor_1,#section_1 .hide").hide();
+               $("#section_1,#content_1,#anchor_1").addClass("openSection");
        },
        teardown: function() {
                MFET.cleanFixtures();
@@ -21,20 +13,15 @@
 test("wm_toggle_section", function() {
        strictEqual($("#section_1").hasClass("openSection"), true, "openSection 
class present");
        MFE.toggle.wm_toggle_section("1");
-       applyCss();
-       strictEqual($("#content_1").is(":visible"), true, "check content is 
visible on a toggle");
-       strictEqual($("#anchor_1").is(":visible"), true, "check anchor is 
visible on toggle");
-       strictEqual($("#section_1").hasClass("openSection"), false, 
"openSection class removed");
-       strictEqual($("#section_1 .hide").is(":visible"), true, "check hide 
button now visible");
-       strictEqual($("#section_1 .show").is(":visible"), false, "check show 
button now hidden");
+       strictEqual($("#content_1").hasClass("openSection"), false, "check 
content is closed on a toggle");
+       strictEqual($("#anchor_1").hasClass("openSection"), false, "check 
anchor is closed on toggle");
+       strictEqual($("#section_1").hasClass("openSection"), false, "check 
section is closed");
        
        // perform second toggle
        MFE.toggle.wm_toggle_section("1");
-       applyCss();
-       strictEqual($("#content_1").is(":visible"), false, "check content is 
hidden on a toggle");
-       strictEqual($("#anchor_1").is(":visible"), false, "check anchor is 
hidden on toggle");
-       strictEqual($("#section_1 .hide").is(":visible"), false, "check hide 
button now hidden");
-       strictEqual($("#section_1 .show").is(":visible"), true, "check show 
button now visible");
+       strictEqual($("#content_1").hasClass("openSection"), true, "check 
content reopened");
+       strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor 
reopened");
+       strictEqual($("#section_1").hasClass("openSection"), true, "check 
section has reopened");
 });
 
 test("wm_reveal_for_hash", function() {
@@ -48,26 +35,21 @@
 
 test("wm_reveal_for_hash", function() {
        MFE.toggle.wm_reveal_for_hash("#First_Section_2");
-       applyCss();
-       strictEqual($("#content_1").is(":visible"), true, "check content is 
visible on a toggle");
-       strictEqual($("#anchor_1").is(":visible"), true, "check anchor is 
visible on toggle");
-       strictEqual($("#section_1 .hide").is(":visible"), true, "check hide 
button now visible");
-       strictEqual($("#section_1 .show").is(":visible"), false, "check show 
button now hidden");
+       strictEqual($("#content_1").hasClass("openSection"), true, "check 
content is visible on a toggle");
+       strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor 
is visible on toggle");
+       strictEqual($("#section_1").hasClass("openSection"), true, "check 
section is marked as open");
 });
 
 test("clicking hash links", function() {
        MFET.triggerEvent($("[href=#First_Section_2]")[0], "click");
-       applyCss();
-       strictEqual($("#content_1").is(":visible"), true, "check content is 
visible on a toggle");
-       strictEqual($("#anchor_1").is(":visible"), true, "check anchor is 
visible on toggle");
-       strictEqual($("#section_1 .hide").is(":visible"), true, "check hide 
button now visible");
-       strictEqual($("#section_1 .show").is(":visible"), false, "check show 
button now hidden");
+       strictEqual($("#content_1").hasClass("openSection"), true, "check 
content is visible on a toggle");
+       strictEqual($("#anchor_1").hasClass("openSection"), true, "check anchor 
is visible on toggle");
+       strictEqual($("#section_1").hasClass("openSection"), true, "check 
section marked as open");
 });
 
 test("clicking a heading toggles it", function() {
-       var visibilityStart = $("#content_1").is(":visible");
-       MFET.triggerEvent($("#section_1")[0], "click");
-       applyCss();
+       var visibilityStart = $("#content_2").hasClass("openSection");
+       MFET.triggerEvent($("#section_2")[0], "click");
        strictEqual(visibilityStart, false, "check content is hidden at start");
-       strictEqual($("#content_1").is(":visible"), true, "check content is 
hidden on a toggle");
+       strictEqual($("#content_2").hasClass("openSection"), true, "check 
content is shown on a toggle");
 });


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to