Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | public static $logoutHtml; |
45 | 45 | public static $loginHtml; |
46 | 46 | public static $zeroRatedBanner; |
| 47 | + public static $useFormatCookieName; |
47 | 48 | |
48 | 49 | protected $useFormat; |
49 | 50 | |
— | — | @@ -190,7 +191,7 @@ |
191 | 192 | * @return bool |
192 | 193 | */ |
193 | 194 | public function addMobileFooter( &$obj, &$tpl ) { |
194 | | - global $wgRequest; |
| 195 | + global $wgRequest, $wgServer; |
195 | 196 | wfProfileIn( __METHOD__ ); |
196 | 197 | |
197 | 198 | $title = $obj->getTitle(); |
— | — | @@ -202,6 +203,7 @@ |
203 | 204 | $this->removeQueryStringParameter( $wgRequest->appendQuery( 'useformat=mobile' ), 'mobileaction' ) |
204 | 205 | ); |
205 | 206 | |
| 207 | + $mobileViewUrl = $this->getMobileUrl( $wgServer . $mobileViewUrl ); |
206 | 208 | $tpl->set( 'mobileview', "<a href='{$mobileViewUrl}' class='noprint'>" . wfMsg( 'mobile-frontend-view' ) . "</a>" ); |
207 | 209 | $footerlinks['places'][] = 'mobileview'; |
208 | 210 | $tpl->set( 'footerlinks', $footerlinks ); |
— | — | @@ -1163,6 +1165,8 @@ |
1164 | 1166 | 'zeroRatedBanner' => self::$zeroRatedBanner, |
1165 | 1167 | 'showText' => self::$messages[ 'mobile-frontend-show-button' ], |
1166 | 1168 | 'hideText' => self::$messages[ 'mobile-frontend-hide-button' ], |
| 1169 | + 'useFormatCookieName' => self::$useFormatCookieName, |
| 1170 | + 'useFormatCookieDuration' => $this->getUseFormatCookieDuration(), |
1167 | 1171 | ); |
1168 | 1172 | $applicationTemplate->setByArray( $options ); |
1169 | 1173 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1445,8 +1449,12 @@ |
1446 | 1450 | } |
1447 | 1451 | |
1448 | 1452 | public function checkUseFormatCookie() { |
1449 | | - global $wgRequest; |
| 1453 | + global $wgRequest, $wgCookiePrefix; |
1450 | 1454 | |
| 1455 | + if ( !isset( self::$useFormatCookieName )) { |
| 1456 | + self::$useFormatCookieName = $wgCookiePrefix . 'mf_useformat'; |
| 1457 | + } |
| 1458 | + |
1451 | 1459 | $useFormat = $this->getUseFormat(); |
1452 | 1460 | $useFormatFromCookie = $wgRequest->getCookie( 'mf_useformat' ); |
1453 | 1461 | |
— | — | @@ -1471,27 +1479,44 @@ |
1472 | 1480 | * @param string The format to store in the cookie |
1473 | 1481 | */ |
1474 | 1482 | protected function setUseFormatCookie( $useFormat ) { |
1475 | | - global $wgRequest; |
| 1483 | + global $wgRequest, $wgCookiePath, $wgCookieSecure, $wgCookieDomain; |
1476 | 1484 | $expiry = $this->getUseFormatCookieExpiry(); |
1477 | | - $wgRequest->response()->setCookie( 'mf_useformat', $useFormat, $expiry ); |
| 1485 | + |
| 1486 | + // use regular php setcookie() rather than WebResponse::setCookie |
| 1487 | + // so we can ignore $wgCookieHttpOnly since the protection it provides |
| 1488 | + // is irrelevant for this cookie. |
| 1489 | + setcookie( self::$useFormatCookieName, $useFormat, $expiry, $wgCookiePath, $wgCookieDomain, $wgCookieSecure ); |
1478 | 1490 | } |
1479 | 1491 | |
1480 | 1492 | /** |
1481 | 1493 | * Get the expiration time for the mf_useformat cookie |
1482 | 1494 | * |
1483 | | - * If $wgMobileFrontendFormatCookieExpiry as a non-0 value, |
1484 | 1495 | * @param int The base time (in seconds since Epoch) from which to calculate |
1485 | 1496 | * cookie expiration. If null, time() is used. |
| 1497 | + * @return int The time (in seconds since Epoch) that the cookie should expire |
1486 | 1498 | */ |
1487 | 1499 | protected function getUseFormatCookieExpiry( $startTime=null ) { |
1488 | | - global $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry; |
1489 | | - $cookieDuration = ( abs( intval( $wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ? |
1490 | | - $wgMobileFrontendFormatCookieExpiry : $wgCookieExpiration; |
| 1500 | + $cookieDuration = $this->getUseFormatCookieDuration(); |
1491 | 1501 | if ( intval( $startTime ) === 0 ) $startTime = time(); |
1492 | 1502 | $expiry = $startTime + $cookieDuration; |
1493 | 1503 | return $expiry; |
1494 | 1504 | } |
1495 | 1505 | |
| 1506 | + /** |
| 1507 | + * Determine the duration the cookie should last. |
| 1508 | + * |
| 1509 | + * If $wgMobileFrontendFormatcookieExpiry has a non-0 value, use that |
| 1510 | + * for the duration. Otherwise, fall back to $wgCookieExpiration. |
| 1511 | + * |
| 1512 | + * @return int The number of seconds for which the cookie should last. |
| 1513 | + */ |
| 1514 | + protected function getUseFormatCookieDuration() { |
| 1515 | + global $wgMobileFrontendFormatCookieExpiry, $wgCookieExpiration; |
| 1516 | + $cookieDuration = ( abs( intval( $wgMobileFrontendFormatCookieExpiry ) ) > 0 ) ? |
| 1517 | + $wgMobileFrontendFormatCookieExpiry : $wgCookieExpiration; |
| 1518 | + return $cookieDuration; |
| 1519 | + } |
| 1520 | + |
1496 | 1521 | public function getVersion() { |
1497 | 1522 | return __CLASS__ . ': $Id$'; |
1498 | 1523 | } |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -26,6 +26,15 @@ |
27 | 27 | } |
28 | 28 | utilities( document.getElementById( 'logo' ) ).bind( 'click', logoClick ); |
29 | 29 | |
| 30 | + function desktopViewClick() { |
| 31 | + var cookieName = MobileFrontend.setting( 'useFormatCookieName' ); |
| 32 | + var cookieDuration = MobileFrontend.setting( 'useFormatCookieDuration' ); |
| 33 | + // convert from seconds to days |
| 34 | + cookieDuration = cookieDuration / ( 24 * 60 * 60 ); |
| 35 | + MobileFrontend.banner.writeCookie( cookieName, 'desktop', cookieDuration ); |
| 36 | + } |
| 37 | + utilities( document.getElementById( 'mf-display-toggle' ) ).bind( 'click', desktopViewClick ); |
| 38 | + |
30 | 39 | // Try to scroll and hide URL bar |
31 | 40 | window.scrollTo( 0, 1 ); |
32 | 41 | } |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js |
— | — | @@ -1 +1 @@ |
2 | | -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 |
| 2 | +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 |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +if( typeof jQuery !== 'undefined' ) { |
| 3 | + MobileFrontend.references = (function($) { |
| 4 | + var calculatePosition; |
| 5 | + |
| 6 | + function collect() { |
| 7 | + var references = {}; |
| 8 | + $( 'ol.references li' ).each(function(i, el) { |
| 9 | + references[ $(el).attr( 'id' ) ] = { |
| 10 | + html: $(el).html(), |
| 11 | + label: i + 1 |
| 12 | + }; |
| 13 | + }); |
| 14 | + return references; |
| 15 | + } |
| 16 | + |
| 17 | + // TODO: only apply to places that need it |
| 18 | + // http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html |
| 19 | + // https://github.com/Modernizr/Modernizr/issues/167 |
| 20 | + calculatePosition = function() { |
| 21 | + var h = $( '#mf-references' ).outerHeight(); |
| 22 | + $( '#mf-references' ).css( { |
| 23 | + top: ( window.innerHeight + window.pageYOffset ) - h, |
| 24 | + bottom: 'auto', |
| 25 | + position: 'absolute' |
| 26 | + } ); |
| 27 | + }; |
| 28 | + $( document ).scroll(calculatePosition); |
| 29 | + |
| 30 | + function init() { |
| 31 | + $( '<div id="mf-references"><div></div></div>' ).hide().appendTo( document.body ); |
| 32 | + var close = function( ev ) { |
| 33 | + $( '#mf-references' ).fadeOut( 500 ); |
| 34 | + }; |
| 35 | + $( '<button>close</button>' ).click( close ).appendTo( '#mf-references' ); |
| 36 | + $( '.mw-cite-backlink a' ).click( close ); |
| 37 | + |
| 38 | + var data, html, href, references = collect(); |
| 39 | + $( 'sup a' ).click( function(ev) { |
| 40 | + href = $(this).attr( 'href' ); |
| 41 | + data = href && href.charAt(0) === '#' ? |
| 42 | + references[ href.substr( 1, href.length ) ] : null; |
| 43 | + |
| 44 | + if( data ) { |
| 45 | + html = '<h3>[' + data.label + ']</h3>' + data.html; |
| 46 | + } else { |
| 47 | + html = $( '<a />' ).text( $(this).text() ). |
| 48 | + attr( 'href', href ).appendTo('<div />').parent().html(); |
| 49 | + } |
| 50 | + $( '#mf-references div' ).html( html ); |
| 51 | + $( '#mf-references' ).fadeIn( 1000 ); |
| 52 | + calculatePosition(); |
| 53 | + ev.preventDefault(); |
| 54 | + }); |
| 55 | + } |
| 56 | + init(); |
| 57 | + })(jQuery); |
| 58 | +} |
\ No newline at end of file |
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/references.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css |
— | — | @@ -757,7 +757,7 @@ |
758 | 758 | #header, |
759 | 759 | #search, |
760 | 760 | #sq, |
761 | | -form, |
| 761 | +#header form, |
762 | 762 | #searchbox { |
763 | 763 | position: relative; |
764 | 764 | right: 0; |
— | — | @@ -843,3 +843,50 @@ |
844 | 844 | .full-screen-search #nav { |
845 | 845 | display: none !important; |
846 | 846 | } |
| 847 | + |
| 848 | +#mf-references { |
| 849 | + -webkit-transition: bottom 0.1s ease-in-out; |
| 850 | + -moz-transition: bottom 0.1s ease-in-out; |
| 851 | + -o-transition: bottom 0.1s ease-in-out; |
| 852 | + transition: bottom 0.1s ease-in-out; |
| 853 | + position: fixed; |
| 854 | + bottom: 0; |
| 855 | + left: 0; |
| 856 | + right: 0; |
| 857 | + background-color: #E4E4E4; |
| 858 | + padding: 22px 34px; |
| 859 | + -webkit-box-shadow: 0px -20px 10px -16px #aaa; |
| 860 | + -moz-box-shadow: 0px -20px 10px -16px #aaa; |
| 861 | + -o-box-shadow: 0px -20px 10px -16px #aaa; |
| 862 | + box-shadow: 0px -20px 10px -16px #aaa; |
| 863 | + word-break: break-word; |
| 864 | + line-height: 1.4em; |
| 865 | + font-size: 0.8em; |
| 866 | +} |
| 867 | + |
| 868 | +#mf-references button { |
| 869 | + top: 22px; |
| 870 | + right: 16px; /* padding of mf-references - width 18 */ |
| 871 | + width: 18px; |
| 872 | + height: 12px; |
| 873 | + background: url(images/close-button-beta.png) no-repeat scroll 0 0 transparent; |
| 874 | + margin: 0; |
| 875 | + background-position: right center; |
| 876 | + background-size: auto 12px; |
| 877 | + cursor: pointer; |
| 878 | + position: absolute; |
| 879 | + text-indent: -999px; |
| 880 | + border: none; |
| 881 | +} |
| 882 | + |
| 883 | +#mf-references h3 { |
| 884 | + margin: 0; |
| 885 | + padding-right: 4px; |
| 886 | + line-height: 1em; |
| 887 | + display: inline; |
| 888 | +} |
| 889 | + |
| 890 | +#mf-references a:visited, |
| 891 | +#mf-references a { |
| 892 | + color: #3354C0; |
| 893 | +} |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile |
— | — | @@ -3,4 +3,5 @@ |
4 | 4 | java -jar yuicompressor-2.4.6.jar javascripts/banner.js -o javascripts/banner.min.js |
5 | 5 | java -jar yuicompressor-2.4.6.jar javascripts/opensearch.js -o javascripts/opensearch.min.js |
6 | 6 | java -jar yuicompressor-2.4.6.jar javascripts/toggle.js -o javascripts/toggle.min.js |
| 7 | + java -jar yuicompressor-2.4.6.jar javascripts/references.js -o javascripts/references.min.js |
7 | 8 | java -jar yuicompressor-2.4.6.jar javascripts/beta_opensearch.js -o javascripts/beta_opensearch.min.js |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/FooterTemplate.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | <div id='footer' {$footerDisplayNone}> |
38 | 38 | <div class='nav' id='footmenu'> |
39 | 39 | <div class='mwm-notice'> |
40 | | - <a href="{$viewNormalSiteURL}">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink} |
| 40 | + <a href="{$viewNormalSiteURL}" id="mf-display-toggle">{$regularSite}</a> | <a href="{$imagesURL}">{$imagesToggle}</a> {$feedbackLink} {$logoutLink} |
41 | 41 | </div> |
42 | 42 | </div> |
43 | 43 | <div id='copyright'>{$copyright}</div> |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php |
— | — | @@ -34,7 +34,8 @@ |
35 | 35 | $endScriptTag = '"></script>'; |
36 | 36 | $javaScriptPath = $this->data['wgExtensionAssetsPath'] . '/MobileFrontend/javascripts/'; |
37 | 37 | |
38 | | - $jQueryScript = ( $this->data['device']['supports_jquery'] ) ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
| 38 | + $jQuerySupport = $this->data['device']['supports_jquery']; |
| 39 | + $jQueryScript = $jQuerySupport ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
39 | 40 | $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js?version=122920111241' . $endScriptTag : ''; |
40 | 41 | |
41 | 42 | $startLinkTag = "<link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/"; |
— | — | @@ -50,10 +51,19 @@ |
51 | 52 | ), |
52 | 53 | 'settings' => array( |
53 | 54 | 'scriptPath' => ( $this->data['wgScriptPath'] ), |
| 55 | + 'useFormatCookieName' => ( $this->data['useFormatCookieName'] ), |
| 56 | + 'useFormatCookieDuration' => ( $this->data['useFormatCookieDuration'] ), |
54 | 57 | ), |
55 | 58 | ); |
56 | 59 | $configuration = FormatJSON::encode( $jsconfig ); |
57 | 60 | |
| 61 | + if( $this->data['isBetaGroupMember'] && $jQuerySupport ) { |
| 62 | + $betajs = <<<HTML |
| 63 | + {$startScriptTag}{$javaScriptPath}references.{$resourceSuffix}js?version=1331257310{$endScriptTag} |
| 64 | +HTML; |
| 65 | + } else { |
| 66 | + $betajs = ""; |
| 67 | + } |
58 | 68 | $applicationHtml = <<<HTML |
59 | 69 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
60 | 70 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
— | — | @@ -84,6 +94,7 @@ |
85 | 95 | {$startScriptTag}{$javaScriptPath}toggle.{$resourceSuffix}js?version=1331257310{$endScriptTag} |
86 | 96 | {$startScriptTag}{$javaScriptPath}banner.{$resourceSuffix}js?version=1331257310{$endScriptTag} |
87 | 97 | {$startScriptTag}{$javaScriptPath}{$betaPrefix}opensearch.{$resourceSuffix}js?version=1331250599{$endScriptTag} |
| 98 | + {$betajs} |
88 | 99 | {$filePageScript} |
89 | 100 | <!--[endif]--> |
90 | 101 | </body> |
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/DisableTemplate.php |
— | — | @@ -8,7 +8,9 @@ |
9 | 9 | |
10 | 10 | public function getHTML() { |
11 | 11 | |
12 | | - $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $this->data['currentURL'] ); // TODO: $currentURl is unused |
| 12 | + |
| 13 | + $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $this->data['currentURL'] ); |
| 14 | + $currentURL = str_replace( '&useformat=mobile', '', $currentURL ); |
13 | 15 | $mobileRedirectFormAction = $this->data['mobileRedirectFormAction']; |
14 | 16 | |
15 | 17 | $disableHtml = <<<HTML |
— | — | @@ -20,7 +22,7 @@ |
21 | 23 | </p> |
22 | 24 | <div id='disableButtons'> |
23 | 25 | <form action='{$mobileRedirectFormAction}' method='get'> |
24 | | - <input name='to' type='hidden' value='{$this->data['currentURL']}' /> |
| 26 | + <input name='to' type='hidden' value='{$currentURL}' /> |
25 | 27 | <input name='expires_in_days' type='hidden' value='3650' /> |
26 | 28 | <button id='disableButton' type='submit'>{$this->data['disableButton']}</button> |
27 | 29 | </form> |
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend |
___________________________________________________________________ |
Modified: svn:mergeinfo |
28 | 30 | Merged /trunk/extensions/MobileFrontend:r113942,113971,113987,114005,114025,114100 |