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

Revision: 114205
Author:   awjrichards
Date:     2012-03-19 22:25:24 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
MFT r113942, r113971, r113987, r114005, r114025, r114100

Modified Paths:
--------------
    branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile
    branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
    
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js
    branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
    
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
    
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/DisableTemplate.php
    branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php

Added Paths:
-----------
    branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js

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,113807,113831-113832,113865-113866,113870-113872,113876,113880-113883,113885,113887,113897-113901,113930
   + 
/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,113930,113942,113971,113987,114005,114025,114100

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile    2012-03-19 
22:25:17 UTC (rev 114204)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile    2012-03-19 
22:25:24 UTC (rev 114205)
@@ -3,4 +3,5 @@
        java -jar yuicompressor-2.4.6.jar javascripts/banner.js -o 
javascripts/banner.min.js
        java -jar yuicompressor-2.4.6.jar javascripts/opensearch.js -o 
javascripts/opensearch.min.js
        java -jar yuicompressor-2.4.6.jar javascripts/toggle.js -o 
javascripts/toggle.min.js
+       java -jar yuicompressor-2.4.6.jar javascripts/references.js -o 
javascripts/references.min.js
        java -jar yuicompressor-2.4.6.jar javascripts/beta_opensearch.js -o 
javascripts/beta_opensearch.min.js

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php     
2012-03-19 22:25:17 UTC (rev 114204)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php     
2012-03-19 22:25:24 UTC (rev 114205)
@@ -43,6 +43,7 @@
        public static $logoutHtml;
        public static $loginHtml;
        public static $zeroRatedBanner;
+       public static $useFormatCookieName;
        
        protected $useFormat;
        
@@ -190,7 +191,7 @@
         * @return bool
         */
        public function addMobileFooter( &$obj, &$tpl ) {
-               global $wgRequest;
+               global $wgRequest, $wgServer;
                wfProfileIn( __METHOD__ );
 
                $title = $obj->getTitle();
@@ -202,6 +203,7 @@
                                        $this->removeQueryStringParameter( 
$wgRequest->appendQuery( 'useformat=mobile' ), 'mobileaction' )
                                        );
 
+                       $mobileViewUrl = $this->getMobileUrl( $wgServer . 
$mobileViewUrl );
                        $tpl->set( 'mobileview', "<a href='{$mobileViewUrl}' 
class='noprint'>" . wfMsg( 'mobile-frontend-view' ) . "</a>" );
                        $footerlinks['places'][] = 'mobileview';
                        $tpl->set( 'footerlinks', $footerlinks );
@@ -1163,6 +1165,8 @@
                                                'zeroRatedBanner' => 
self::$zeroRatedBanner,
                                                'showText' => self::$messages[ 
'mobile-frontend-show-button' ],
                                                'hideText' => self::$messages[ 
'mobile-frontend-hide-button' ],
+                                               'useFormatCookieName' => 
self::$useFormatCookieName,
+                                               'useFormatCookieDuration' => 
$this->getUseFormatCookieDuration(),
                                                );
                $applicationTemplate->setByArray( $options );
                wfProfileOut( __METHOD__ );
@@ -1445,8 +1449,12 @@
        }
        
        public function checkUseFormatCookie() {
-               global $wgRequest;
+               global $wgRequest, $wgCookiePrefix;
                
+               if ( !isset( self::$useFormatCookieName )) {
+                       self::$useFormatCookieName = $wgCookiePrefix . 
'mf_useformat';
+               }
+               
                $useFormat = $this->getUseFormat();
                $useFormatFromCookie = $wgRequest->getCookie( 'mf_useformat' );
                
@@ -1471,27 +1479,44 @@
         * @param string The format to store in the cookie
         */
        protected function setUseFormatCookie( $useFormat ) {
-               global $wgRequest;
+               global $wgRequest, $wgCookiePath, $wgCookieSecure, 
$wgCookieDomain;
                $expiry = $this->getUseFormatCookieExpiry();
-               $wgRequest->response()->setCookie( 'mf_useformat', $useFormat, 
$expiry );
+               
+               // use regular php setcookie() rather than 
WebResponse::setCookie
+               // so we can ignore $wgCookieHttpOnly since the protection it 
provides
+               // is irrelevant for this cookie.
+               setcookie( self::$useFormatCookieName, $useFormat, $expiry, 
$wgCookiePath, $wgCookieDomain, $wgCookieSecure );
        }
        
        /**
         * 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.
+        * @return int The time (in seconds since Epoch) that the cookie should 
expire
         */
        protected function getUseFormatCookieExpiry( $startTime=null ) {
-               global $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry;
-               $cookieDuration = ( abs( intval( 
$wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ? 
-                               $wgMobileFrontendFormatCookieExpiry : 
$wgCookieExpiration;
+               $cookieDuration = $this->getUseFormatCookieDuration();
                if ( intval( $startTime ) === 0 ) $startTime = time();
                $expiry = $startTime + $cookieDuration;
                return $expiry;
        }
        
+       /**
+        * Determine the duration the cookie should last.
+        * 
+        * If $wgMobileFrontendFormatcookieExpiry has a non-0 value, use that
+        * for the duration. Otherwise, fall back to $wgCookieExpiration.
+        * 
+        * @return int The number of seconds for which the cookie should last.
+        */
+       protected function getUseFormatCookieDuration() {
+               global $wgMobileFrontendFormatCookieExpiry, $wgCookieExpiration;
+               $cookieDuration = ( abs( intval( 
$wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ? 
+                               $wgMobileFrontendFormatCookieExpiry : 
$wgCookieExpiration;
+               return $cookieDuration;
+       }
+       
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js  
2012-03-19 22:25:17 UTC (rev 114204)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js  
2012-03-19 22:25:24 UTC (rev 114205)
@@ -26,6 +26,15 @@
                }
                utilities( document.getElementById( 'logo' ) ).bind( 'click', 
logoClick );
 
+               function desktopViewClick() {
+                       var cookieName = MobileFrontend.setting( 
'useFormatCookieName' );
+                       var cookieDuration = MobileFrontend.setting( 
'useFormatCookieDuration' );
+                       // convert from seconds to days
+                       cookieDuration = cookieDuration / ( 24 * 60 * 60 );
+                       MobileFrontend.banner.writeCookie( cookieName, 
'desktop', cookieDuration );
+               }
+               utilities( document.getElementById( 'mf-display-toggle' ) 
).bind( 'click', desktopViewClick );
+
                // Try to scroll and hide URL bar
                window.scrollTo( 0, 1 );
        }

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js  
    2012-03-19 22:25:17 UTC (rev 114204)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js  
    2012-03-19 22:25:24 UTC (rev 114205)
@@ -1 +1 @@
-MobileFrontend=(function(){var a;function b(){var 
e;a(document.body).addClass("jsEnabled");e=document.getElementById("languageselection");function
 c(){var 
f;if(e){f=e.options[e.selectedIndex].value;if(f){location.href=f}}}a(e).bind("change",c);function
 d(){var 
f=document.getElementById("nav").style;f.display=f.display==="block"?"none":"block"}a(document.getElementById("logo")).bind("click",d);window.scrollTo(0,1)}a=typeof
 
jQuery!=="undefined"?jQuery:function(e){if(typeof(e)==="string"){if(document.querySelectorAll){return[].slice.call(document.querySelectorAll(e))}}function
 d(i){var j=e.className.split("");return j.indexOf(i)>-1}function f(i){var 
j=e.className,k=j.split(" ");k.push(i);e.className=k.join(" ")}function 
g(j){var l=e.className,m=l.split(" 
"),n=[],k;for(k=0;k<m.length;k++){if(m[k]!==j){n.push(m[k])}}e.className=n.join("
 ")}function h(j,i){e.addEventListener(j,i,false)}function 
c(){e.parentNode.removeChild(e)}return{addClass:f,bind:h,hasClass:d,remove:c,removeClass:g}};a.ajax=a.ajax||function(e){var
 c,d;if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new 
ActiveXObject("Microsoft.XMLHTTP")}if(c.overrideMimeType){c.overrideMimeType("text/xml")}c.onreadystatechange=function(){if(c.readyState===4&&c.status===200){e.success(c.responseXML)}};c.open("GET",e.url,true);c.send()};b();return{init:b,message:function(c){return
 mwMobileFrontendConfig.messages[c]||""},setting:function(c){return 
mwMobileFrontendConfig.settings[c]||""},utils:a}}());
\ No newline at end of file
+MobileFrontend=(function(){var a;function b(){var 
e;a(document.body).addClass("jsEnabled");e=document.getElementById("languageselection");function
 c(){var 
g;if(e){g=e.options[e.selectedIndex].value;if(g){location.href=g}}}a(e).bind("change",c);function
 d(){var 
g=document.getElementById("nav").style;g.display=g.display==="block"?"none":"block"}a(document.getElementById("logo")).bind("click",d);function
 f(){var h=MobileFrontend.setting("useFormatCookieName");var 
g=MobileFrontend.setting("useFormatCookieDuration");g=g/(24*60*60);MobileFrontend.banner.writeCookie(h,"desktop",g)}a(document.getElementById("mf-display-toggle")).bind("click",f);window.scrollTo(0,1)}a=typeof
 
jQuery!=="undefined"?jQuery:function(e){if(typeof(e)==="string"){if(document.querySelectorAll){return[].slice.call(document.querySelectorAll(e))}}else{if(!e){e=document.createElement("div")}}function
 d(i){var j=e.className.split(" ");return j.indexOf(i)>-1}function f(i){var 
j=e.className,k=j.split(" ");k.push(i);e.className=k.join(" ")}function 
g(j){var l=e.className,m=l.split(" 
"),n=[],k;for(k=0;k<m.length;k++){if(m[k]!==j){n.push(m[k])}}e.className=n.join("
 ")}function h(j,i){e.addEventListener(j,i,false)}function 
c(){e.parentNode.removeChild(e)}return{addClass:f,bind:h,hasClass:d,remove:c,removeClass:g}};a.ajax=a.ajax||function(e){var
 c,d;if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new 
ActiveXObject("Microsoft.XMLHTTP")}if(c.overrideMimeType){c.overrideMimeType("text/xml")}c.onreadystatechange=function(){if(c.readyState===4&&c.status===200){e.success(c.responseXML)}};c.open("GET",e.url,true);c.send()};b();return{init:b,message:function(c){return
 mwMobileFrontendConfig.messages[c]||""},setting:function(c){return 
mwMobileFrontendConfig.settings[c]||""},utils:a}}());
\ No newline at end of file

Copied: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js (from 
rev 113942, trunk/extensions/MobileFrontend/javascripts/references.js)
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js   
                        (rev 0)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js   
2012-03-19 22:25:24 UTC (rev 114205)
@@ -0,0 +1,57 @@
+if( typeof jQuery !== 'undefined' ) {
+       MobileFrontend.references = (function($) {
+               var calculatePosition;
+
+               function collect() {
+                       var references = {};
+                       $( 'ol.references li' ).each(function(i, el) {
+                               references[ $(el).attr( 'id' ) ] = {
+                                       html: $(el).html(),
+                                       label: i + 1
+                               };
+                       });
+                       return references;
+               }
+
+               // TODO: only apply to places that need it
+               // 
http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html
+               // https://github.com/Modernizr/Modernizr/issues/167
+               calculatePosition = function() {
+                       var h = $( '#mf-references' ).outerHeight();
+                       $( '#mf-references' ).css( {
+                               top:  ( window.innerHeight + window.pageYOffset 
) - h,
+                               bottom: 'auto',
+                               position: 'absolute'
+                       } );
+               };
+               $( document ).scroll(calculatePosition);
+
+               function init() {
+                       $( '<div id="mf-references"><div></div></div>' 
).hide().appendTo( document.body );
+                       var close = function( ev ) {
+                               $( '#mf-references' ).fadeOut( 500 );
+                       };
+                       $( '<button>close</button>' ).click( close ).appendTo( 
'#mf-references' );
+                       $( '.mw-cite-backlink a' ).click( close );
+                       
+                       var data, html, href, references = collect();
+                       $( 'sup a' ).click( function(ev) {
+                               href = $(this).attr( 'href' );
+                               data = href && href.charAt(0) === '#' ?
+                                       references[ href.substr( 1, href.length 
) ] : null;
+
+                               if( data ) {
+                                       html = '<h3>[' + data.label + ']</h3>' 
+ data.html;
+                               } else {
+                                       html = $( '<a />' ).text( 
$(this).text() ).
+                                               attr( 'href', href 
).appendTo('<div />').parent().html();
+                               }
+                               $( '#mf-references div' ).html( html );
+                               $( '#mf-references' ).fadeIn( 1000 );
+                               calculatePosition();
+                               ev.preventDefault();
+                       });
+               }
+               init();
+       })(jQuery);
+}
\ No newline at end of file


Property changes on: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js
___________________________________________________________________
Added: svn:eol-style
   + native

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:25:17 UTC (rev 114204)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css 
2012-03-19 22:25:24 UTC (rev 114205)
@@ -757,7 +757,7 @@
 #header,
 #search,
 #sq,
-form,
+#header form,
 #searchbox {
        position: relative;
        right: 0;
@@ -843,3 +843,50 @@
 .full-screen-search #nav {
        display: none !important;
 }
+
+#mf-references {
+       -webkit-transition: bottom 0.1s ease-in-out;
+       -moz-transition: bottom 0.1s ease-in-out;
+       -o-transition: bottom 0.1s ease-in-out;
+       transition: bottom 0.1s ease-in-out;
+       position: fixed;
+       bottom: 0;
+       left: 0;
+       right: 0;
+       background-color: #E4E4E4;
+       padding: 22px 34px;
+       -webkit-box-shadow: 0px -20px 10px -16px #aaa;
+       -moz-box-shadow: 0px -20px 10px -16px #aaa;
+       -o-box-shadow: 0px -20px 10px -16px #aaa;
+       box-shadow: 0px -20px 10px -16px #aaa;
+       word-break: break-word;
+       line-height: 1.4em;
+       font-size: 0.8em;
+}
+
+#mf-references button {
+       top: 22px;
+       right: 16px; /* padding of mf-references - width 18 */
+       width: 18px;
+       height: 12px;
+       background: url(images/close-button-beta.png) no-repeat scroll 0 0 
transparent;
+       margin: 0;
+       background-position: right center;
+       background-size: auto 12px;
+       cursor: pointer;
+       position: absolute;
+       text-indent: -999px;
+       border: none;
+}
+
+#mf-references h3 {
+       margin: 0;
+       padding-right: 4px;
+       line-height: 1em;
+       display: inline;
+}
+
+#mf-references a:visited,
+#mf-references a {
+       color: #3354C0;
+}

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
   2012-03-19 22:25:17 UTC (rev 114204)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
   2012-03-19 22:25:24 UTC (rev 114205)
@@ -34,7 +34,8 @@
                $endScriptTag = '"></script>';
                $javaScriptPath =  $this->data['wgExtensionAssetsPath'] . 
'/MobileFrontend/javascripts/';
 
-               $jQueryScript = ( $this->data['device']['supports_jquery'] ) ? 
$startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : '';
+               $jQuerySupport = $this->data['device']['supports_jquery'];
+               $jQueryScript = $jQuerySupport ? $startScriptTag . 
$javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : '';
                $filePageScript = ( $this->data['isFilePage'] ) ? 
$startScriptTag . $javaScriptPath . 'filepage.js?version=122920111241' . 
$endScriptTag : '';
 
                $startLinkTag = "<link 
href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/";
@@ -50,10 +51,19 @@
                                ),
                        'settings' => array(
                                'scriptPath' => ( $this->data['wgScriptPath'] ),
+                               'useFormatCookieName' => ( 
$this->data['useFormatCookieName'] ),
+                               'useFormatCookieDuration' => ( 
$this->data['useFormatCookieDuration'] ),
                        ),
                );
                $configuration = FormatJSON::encode( $jsconfig );
 
+               if( $this->data['isBetaGroupMember'] && $jQuerySupport ) {
+                       $betajs = <<<HTML
+                       
{$startScriptTag}{$javaScriptPath}references.{$resourceSuffix}js?version=1331257310{$endScriptTag}
+HTML;
+               } else {
+                       $betajs = "";
+               }
                $applicationHtml = <<<HTML
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
@@ -84,6 +94,7 @@
                        
{$startScriptTag}{$javaScriptPath}toggle.{$resourceSuffix}js?version=1331257310{$endScriptTag}
                        
{$startScriptTag}{$javaScriptPath}banner.{$resourceSuffix}js?version=1331257310{$endScriptTag}
                        
{$startScriptTag}{$javaScriptPath}{$betaPrefix}opensearch.{$resourceSuffix}js?version=1331250599{$endScriptTag}
+                       {$betajs}
                        {$filePageScript}
                        <!--[endif]-->
                  </body>

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/DisableTemplate.php
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/DisableTemplate.php   
    2012-03-19 22:25:17 UTC (rev 114204)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/DisableTemplate.php   
    2012-03-19 22:25:24 UTC (rev 114205)
@@ -8,7 +8,9 @@
 
        public function getHTML() {
 
-               $currentURL = str_replace( '&mobileaction=disable_mobile_site', 
'', $this->data['currentURL'] ); // TODO: $currentURl is unused
+               
+               $currentURL = str_replace( '&mobileaction=disable_mobile_site', 
'', $this->data['currentURL'] ); 
+               $currentURL = str_replace( '&useformat=mobile', '', $currentURL 
);
                $mobileRedirectFormAction = 
$this->data['mobileRedirectFormAction'];
 
                $disableHtml = <<<HTML
@@ -20,7 +22,7 @@
                                </p>
                                <div id='disableButtons'>
                                <form action='{$mobileRedirectFormAction}' 
method='get'>
-                                       <input name='to' type='hidden' 
value='{$this->data['currentURL']}' />
+                                       <input name='to' type='hidden' 
value='{$currentURL}' />
                                        <input name='expires_in_days' 
type='hidden' value='3650' />
                                        <button id='disableButton' 
type='submit'>{$this->data['disableButton']}</button>
                                </form>

Modified: 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php    
    2012-03-19 22:25:17 UTC (rev 114204)
+++ 
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php    
    2012-03-19 22:25:24 UTC (rev 114205)
@@ -36,7 +36,7 @@
                        <div id='footer' {$footerDisplayNone}>
                          <div class='nav' id='footmenu'>
                                <div class='mwm-notice'>
-                                 <a 
href="{$viewNormalSiteURL}">{$regularSite}</a> | <a 
href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink}
+                                 <a href="{$viewNormalSiteURL}" 
id="mf-display-toggle">{$regularSite}</a> | <a 
href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink}
                                </div>
                          </div>
                          <div id='copyright'>{$copyright}</div>


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

Reply via email to