Index: trunk/extensions/MobileFrontend/ApplicationTemplate.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | if( !defined( 'MEDIAWIKI' ) ) { |
5 | | - die( -1 ); |
| 5 | + die( -1 ); |
6 | 6 | } |
7 | 7 | |
8 | 8 | class ApplicationTemplate extends MobileFrontendTemplate { |
— | — | @@ -13,10 +13,12 @@ |
14 | 14 | } else { |
15 | 15 | $appleTouchIconTag = ''; |
16 | 16 | } |
| 17 | + |
| 18 | + $zeroRatedBanner = ( isset( $this->data['zeroRatedBanner'] ) ) ? str_replace( 'style="display:none;"', '', $this->data['zeroRatedBanner'] ) : ''; |
17 | 19 | |
18 | 20 | $betaPrefix = ( $this->data['isBetaGroupMember'] ) ? 'beta_' : ''; |
19 | 21 | |
20 | | - $noticeHtml = empty( $this->data['noticeHtml'] ) ? '' : $this->data['noticeHtml']; |
| 22 | + $noticeHtml = ( isset( $this->data['noticeHtml'] ) ) ? $this->data['noticeHtml'] : ''; |
21 | 23 | |
22 | 24 | $cssFileName = ( isset( $this->data['device']['css_file_name'] ) ) ? $this->data['device']['css_file_name'] : 'default'; |
23 | 25 | |
— | — | @@ -26,7 +28,7 @@ |
27 | 29 | |
28 | 30 | $openSearchScript = $startScriptTag . $javaScriptPath . $betaPrefix . 'opensearch.js?version=12142011129437' . $endScriptTag; |
29 | 31 | $jQueryScript = ( $this->data['device']['supports_jquery'] ) ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
30 | | - $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js' . $endScriptTag : ''; |
| 32 | + $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js?version=122920111241' . $endScriptTag : ''; |
31 | 33 | |
32 | 34 | $startLinkTag = "<link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/"; |
33 | 35 | $endLinkTag = "' media='all' rel='Stylesheet' type='text/css' />"; |
— | — | @@ -55,6 +57,7 @@ |
56 | 58 | </script> |
57 | 59 | </head> |
58 | 60 | <body> |
| 61 | + {$zeroRatedBanner} |
59 | 62 | {$this->data['searchWebkitHtml']} |
60 | 63 | <div class='show' id='content_wrapper'> |
61 | 64 | {$noticeHtml} |
Index: trunk/extensions/MobileFrontend/javascripts/filepage.js |
— | — | @@ -71,15 +71,19 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | function addToggle(id) { |
75 | | - var filetoc = document.getElementById('filetoc'), |
76 | | - items = filetoc.getElementsByTagName('a'); |
77 | | - for (var i = 0; i < items.length; i++) { |
78 | | - var item = items[i], |
79 | | - href = item.href, |
80 | | - hashPos = href.search('#'), |
81 | | - hash = href.substr(hashPos + 1); |
82 | | - if (hash == id) { |
83 | | - items[i].onclick = makeToggle(id); |
| 75 | + var filetoc = document.getElementById('filetoc'); |
| 76 | + if ( filetoc ) { |
| 77 | + var items = filetoc.getElementsByTagName('a'); |
| 78 | + if ( items ) { |
| 79 | + for (var i = 0; i < items.length; i++) { |
| 80 | + var item = items[i], |
| 81 | + href = item.href, |
| 82 | + hashPos = href.search('#'), |
| 83 | + hash = href.substr(hashPos + 1); |
| 84 | + if (hash == id) { |
| 85 | + items[i].onclick = makeToggle(id); |
| 86 | + } |
| 87 | + } |
84 | 88 | } |
85 | 89 | } |
86 | 90 | } |
— | — | @@ -91,12 +95,14 @@ |
92 | 96 | } |
93 | 97 | |
94 | 98 | function stopClickThrough() { |
95 | | - var file = document.getElementById('file'), |
96 | | - links = file.getElementsByTagName('a'); |
97 | | - if (links.length) { |
98 | | - links[0].onclick = function() { |
99 | | - return false; |
100 | | - }; |
| 99 | + var file = document.getElementById('file'); |
| 100 | + if ( file ) { |
| 101 | + var links = file.getElementsByTagName('a'); |
| 102 | + if (links.length) { |
| 103 | + links[0].onclick = function() { |
| 104 | + return false; |
| 105 | + }; |
| 106 | + } |
101 | 107 | } |
102 | 108 | } |
103 | 109 | |
Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js |
— | — | @@ -3,6 +3,12 @@ |
4 | 4 | var results = document.getElementById( 'results' ); |
5 | 5 | var languageSelection = document.getElementById( 'languageselection' ); |
6 | 6 | |
| 7 | +var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
| 8 | + |
| 9 | +if ( !zeroRatedBanner ) { |
| 10 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner-red' ); |
| 11 | +} |
| 12 | + |
7 | 13 | initClearSearchLink(); |
8 | 14 | |
9 | 15 | function initClearSearchLink() { |
Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js |
— | — | @@ -41,6 +41,10 @@ |
42 | 42 | search.onfocus = function() { |
43 | 43 | |
44 | 44 | resetViewPort(); |
| 45 | + |
| 46 | + if ( zeroRatedBanner ) { |
| 47 | + zeroRatedBanner.style.display = 'none'; |
| 48 | + } |
45 | 49 | |
46 | 50 | if ( !focused ) { |
47 | 51 | content.style.display = 'none'; |
— | — | @@ -131,6 +135,10 @@ |
132 | 136 | if ( pE ) { |
133 | 137 | pE.style.display = 'none'; |
134 | 138 | } |
| 139 | + |
| 140 | + if ( zeroRatedBanner ) { |
| 141 | + zeroRatedBanner.style.display = 'block'; |
| 142 | + } |
135 | 143 | |
136 | 144 | if ( ol ) { |
137 | 145 | if ( sq ) { |
Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -153,6 +153,7 @@ |
154 | 154 | public static $isFilePage; |
155 | 155 | public static $logoutHtml; |
156 | 156 | public static $loginHtml; |
| 157 | + public static $zeroRatedBanner; |
157 | 158 | |
158 | 159 | public static $messageKeys = array( |
159 | 160 | 'mobile-frontend-show-button', |
— | — | @@ -824,15 +825,14 @@ |
825 | 826 | private function sendApplicationVersionVaryHeader() { |
826 | 827 | global $wgOut, $wgRequest; |
827 | 828 | wfProfileIn( __METHOD__ ); |
| 829 | + $wgOut->addVaryHeader( 'Application_Version' ); |
828 | 830 | if ( isset( $_SERVER['HTTP_APPLICATION_VERSION'] ) ) { |
829 | 831 | $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_APPLICATION_VERSION'] ); |
830 | | - $wgOut->addVaryHeader( 'Application_Version' ); |
831 | 832 | } else { |
832 | 833 | if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) { |
833 | 834 | if ( stripos( $_SERVER['HTTP_X_DEVICE'], 'iphone' ) !== false || |
834 | 835 | stripos( $_SERVER['HTTP_X_DEVICE'], 'android' ) !== false ) { |
835 | 836 | $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_X_DEVICE'] ); |
836 | | - $wgOut->addVaryHeader( 'Application_Version' ); |
837 | 837 | } |
838 | 838 | } |
839 | 839 | } |
— | — | @@ -1202,6 +1202,7 @@ |
1203 | 1203 | $this->mainPage->strictErrorChecking = false; |
1204 | 1204 | $this->mainPage->encoding = 'UTF-8'; |
1205 | 1205 | |
| 1206 | + $zeroLandingPage = $this->mainPage->getElementById( 'zero-landing-page' ); |
1206 | 1207 | $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' ); |
1207 | 1208 | $newsItems = $this->mainPage->getElementById( 'mp-itn' ); |
1208 | 1209 | |
— | — | @@ -1212,6 +1213,10 @@ |
1213 | 1214 | |
1214 | 1215 | $content = $this->mainPage->createElement( 'div' ); |
1215 | 1216 | $content->setAttribute( 'id', 'content' ); |
| 1217 | + |
| 1218 | + if ( $zeroLandingPage ) { |
| 1219 | + $content->appendChild( $zeroLandingPage ); |
| 1220 | + } |
1216 | 1221 | |
1217 | 1222 | if ( $featuredArticle ) { |
1218 | 1223 | $h2FeaturedArticle = $this->mainPage->createElement( 'h2', self::$messages['mobile-frontend-featured-article'] ); |
— | — | @@ -1347,6 +1352,16 @@ |
1348 | 1353 | |
1349 | 1354 | $itemToRemoveRecords = $this->parseItemsToRemove(); |
1350 | 1355 | |
| 1356 | + $zeroRatedBannerElement = $this->doc->getElementById( 'zero-rated-banner' ); |
| 1357 | + |
| 1358 | + if ( !$zeroRatedBannerElement ) { |
| 1359 | + $zeroRatedBannerElement = $this->doc->getElementById( 'zero-rated-banner-red' ); |
| 1360 | + } |
| 1361 | + |
| 1362 | + if ( $zeroRatedBannerElement ) { |
| 1363 | + self::$zeroRatedBanner = $this->doc->saveXML( $zeroRatedBannerElement, LIBXML_NOEMPTYTAG ); |
| 1364 | + } |
| 1365 | + |
1351 | 1366 | if ( self::$isBetaGroupMember ) { |
1352 | 1367 | $ptLogout = $this->doc->getElementById( 'pt-logout' ); |
1353 | 1368 | |
— | — | @@ -1354,9 +1369,8 @@ |
1355 | 1370 | $ptLogoutLink = $ptLogout->firstChild; |
1356 | 1371 | self::$logoutHtml = $this->doc->saveXML( $ptLogoutLink, LIBXML_NOEMPTYTAG ); |
1357 | 1372 | } |
1358 | | - |
1359 | 1373 | $ptAnonLogin = $this->doc->getElementById( 'pt-anonlogin' ); |
1360 | | - |
| 1374 | + |
1361 | 1375 | if ( !$ptAnonLogin ) { |
1362 | 1376 | $ptAnonLogin = $this->doc->getElementById( 'pt-login' ); |
1363 | 1377 | } |
— | — | @@ -1409,14 +1423,22 @@ |
1410 | 1424 | $itemToRemoveRecords['CLASS'][] = "thumbcaption"; |
1411 | 1425 | $itemToRemoveRecords['CLASS'][] = "gallery"; |
1412 | 1426 | } |
| 1427 | + |
| 1428 | + $tagToRemoveNodeIdAttributeValues = array( 'zero-language-search' ); |
1413 | 1429 | |
1414 | 1430 | $domElemsToRemove = array(); |
1415 | 1431 | foreach ( $itemToRemoveRecords['TAG'] as $tagToRemove ) { |
1416 | 1432 | $tagToRemoveNodes = $this->doc->getElementsByTagName( $tagToRemove ); |
1417 | | - |
1418 | 1433 | foreach ( $tagToRemoveNodes as $tagToRemoveNode ) { |
| 1434 | + $tagToRemoveNodeIdAttributeValue = ''; |
1419 | 1435 | if ( $tagToRemoveNode ) { |
1420 | | - $domElemsToRemove[] = $tagToRemoveNode; |
| 1436 | + $tagToRemoveNodeIdAttribute = $tagToRemoveNode->getAttributeNode( 'id' ); |
| 1437 | + if ( $tagToRemoveNodeIdAttribute ) { |
| 1438 | + $tagToRemoveNodeIdAttributeValue = $tagToRemoveNodeIdAttribute->value; |
| 1439 | + } |
| 1440 | + if ( !in_array( $tagToRemoveNodeIdAttributeValue, $tagToRemoveNodeIdAttributeValues ) ) { |
| 1441 | + $domElemsToRemove[] = $tagToRemoveNode; |
| 1442 | + } |
1421 | 1443 | } |
1422 | 1444 | } |
1423 | 1445 | } |
— | — | @@ -1556,7 +1578,7 @@ |
1557 | 1579 | } |
1558 | 1580 | |
1559 | 1581 | if ( self::$format === 'json' ) { |
1560 | | - header( 'Content-Type: application/json' ); |
| 1582 | + header( 'Content-Type: application/javascript' ); |
1561 | 1583 | header( 'Content-Disposition: attachment; filename="data.js";' ); |
1562 | 1584 | $json_data = array(); |
1563 | 1585 | $json_data['title'] = htmlspecialchars ( self::$title->getText() ); |
— | — | @@ -1635,6 +1657,7 @@ |
1636 | 1658 | 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, |
1637 | 1659 | 'wgScriptPath' => $wgScriptPath, |
1638 | 1660 | 'isFilePage' => self::$isFilePage, |
| 1661 | + 'zeroRatedBanner' => self::$zeroRatedBanner, |
1639 | 1662 | ); |
1640 | 1663 | $applicationTemplate->setByArray( $options ); |
1641 | 1664 | wfProfileOut( __METHOD__ ); |
Index: trunk/extensions/MobileFrontend/stylesheets/common.css |
— | — | @@ -15,6 +15,32 @@ |
16 | 16 | display: none; |
17 | 17 | } |
18 | 18 | |
| 19 | +#zero-rated-banner { |
| 20 | + position: relative; |
| 21 | + height: 20px; |
| 22 | + width: 100%; |
| 23 | + z-index: 99; |
| 24 | + background: #EE8833; |
| 25 | + display: block; |
| 26 | + border-bottom: 1px solid; |
| 27 | + border-color: #000000; |
| 28 | +} |
| 29 | + |
| 30 | +#zero-rated-banner-red { |
| 31 | + position: relative; |
| 32 | + height: 20px; |
| 33 | + width: 100%; |
| 34 | + z-index: 99; |
| 35 | + background: #FF0000; |
| 36 | + display: block; |
| 37 | + border-bottom: 1px solid; |
| 38 | + border-color: #000000; |
| 39 | +} |
| 40 | + |
| 41 | +#zero-rated-banner-text { |
| 42 | + margin: 0px; |
| 43 | +} |
| 44 | + |
19 | 45 | .suggestions-results { |
20 | 46 | font-size: 1.2em; |
21 | 47 | cursor: pointer; |
Index: trunk/extensions/MobileFrontend/stylesheets/beta_common.css |
— | — | @@ -21,6 +21,32 @@ |
22 | 22 | display: none; |
23 | 23 | } |
24 | 24 | |
| 25 | +#zero-rated-banner { |
| 26 | + position: relative; |
| 27 | + height: 20px; |
| 28 | + width: 100%; |
| 29 | + z-index: 99; |
| 30 | + background: #EE8833; |
| 31 | + display: block; |
| 32 | + border-bottom: 1px solid; |
| 33 | + border-color: #000000; |
| 34 | +} |
| 35 | + |
| 36 | +#zero-rated-banner-red { |
| 37 | + position: relative; |
| 38 | + height: 20px; |
| 39 | + width: 100%; |
| 40 | + z-index: 99; |
| 41 | + background: #FF0000; |
| 42 | + display: block; |
| 43 | + border-bottom: 1px solid; |
| 44 | + border-color: #000000; |
| 45 | +} |
| 46 | + |
| 47 | +#zero-rated-banner-text { |
| 48 | + margin: 0px; |
| 49 | +} |
| 50 | + |
25 | 51 | .suggestions-results { |
26 | 52 | font-size: 1.4em; |
27 | 53 | cursor: pointer; |