Index: trunk/extensions/MobileFrontend/javascripts/filepage.js |
— | — | @@ -0,0 +1,107 @@ |
| 2 | +(function() { |
| 3 | + |
| 4 | +function select(selector) { |
| 5 | + if (selector.substr(0, 1) === '#') { |
| 6 | + var node = document.getElementById(selector.substr(1)); |
| 7 | + if (node === null) { |
| 8 | + return []; |
| 9 | + } else { |
| 10 | + return [node]; |
| 11 | + } |
| 12 | + } else if (selector.substr(0, 1) === '.') { |
| 13 | + return document.getElementsByClassName(selector.substr(1)); |
| 14 | + } else { |
| 15 | + throw new Error("Unrecognized selector " + selector); |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +function setDisplay(selector, display) { |
| 20 | + var nodes = select(selector); |
| 21 | + for (var i = 0; i < nodes.length; i++) { |
| 22 | + nodes[i].style.display = display; |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +function show(selector) { |
| 27 | + setDisplay(selector, 'block'); |
| 28 | +} |
| 29 | + |
| 30 | +function hide(selector) { |
| 31 | + setDisplay(selector, 'none'); |
| 32 | +} |
| 33 | + |
| 34 | +var chunks = { |
| 35 | + file: [ |
| 36 | + '#file', |
| 37 | + '.fullMedia', |
| 38 | + '#mw-imagepage-content' |
| 39 | + ], |
| 40 | + filehistory: [ |
| 41 | + '#filehistory', |
| 42 | + '#mw-imagepage-section-filehistory', |
| 43 | + '#mw-imagepage-reupload-link', |
| 44 | + '#mw-imagepage-edit-external' |
| 45 | + ], |
| 46 | + filelinks: [ |
| 47 | + '#filelinks', |
| 48 | + '#mw-imagepage-section-linkstoimage' |
| 49 | + ], |
| 50 | + metadata: [ |
| 51 | + '#metadata', |
| 52 | + '.mw-imagepage-section-metadata', |
| 53 | + ] |
| 54 | +} |
| 55 | + |
| 56 | +function makeToggle(thisId) { |
| 57 | + return function(event) { |
| 58 | + for (id in chunks) { |
| 59 | + if (chunks.hasOwnProperty(id)) { |
| 60 | + var selectors = chunks[id], act; |
| 61 | + if (id === thisId) { |
| 62 | + act = show; |
| 63 | + } else { |
| 64 | + act = hide; |
| 65 | + } |
| 66 | + for (var i = 0; i < selectors.length; i++) { |
| 67 | + act(selectors[i]); |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + return false; |
| 72 | + }; |
| 73 | +} |
| 74 | + |
| 75 | +function addToggle(id) { |
| 76 | + var filetoc = document.getElementById('filetoc'), |
| 77 | + items = filetoc.getElementsByTagName('a'); |
| 78 | + for (var i = 0; i < items.length; i++) { |
| 79 | + var item = items[i], |
| 80 | + href = item.href, |
| 81 | + hashPos = href.search('#'), |
| 82 | + hash = href.substr(hashPos + 1); |
| 83 | + if (hash == id) { |
| 84 | + items[i].onclick = makeToggle(id); |
| 85 | + } |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +for (id in chunks) { |
| 90 | + if (chunks.hasOwnProperty(id)) { |
| 91 | + addToggle(id); |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +function stopClickThrough() { |
| 96 | + var file = document.getElementById('file'), |
| 97 | + links = file.getElementsByTagName('a'); |
| 98 | + if (links.length) { |
| 99 | + links[0].onclick = function() { |
| 100 | + return false; |
| 101 | + }; |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +stopClickThrough(); |
| 106 | +makeToggle('file')(); |
| 107 | + |
| 108 | +})(); |
Index: trunk/extensions/MobileFrontend/stylesheets/filepage.css |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +#filetoc { |
| 3 | + display: block; |
| 4 | + background-color: black; |
| 5 | + background-image: -moz-linear-gradient(center top, #3E3E3E 0%, #393939 14%, #2E2E2E 32%, #151515 64%, #080808 84%, #010101 100%); |
| 6 | + background-image: -webkit-linear-gradient(center top, #3E3E3E 0%, #393939 14%, #2E2E2E 32%, #151515 64%, #080808 84%, #010101 100%); |
| 7 | + background-image: -o-linear-gradient(center top, #3E3E3E 0%, #393939 14%, #2E2E2E 32%, #151515 64%, #080808 84%, #010101 100%); |
| 8 | + background-image: -ms-linear-gradient(center top, #3E3E3E 0%, #393939 14%, #2E2E2E 32%, #151515 64%, #080808 84%, #010101 100%); |
| 9 | + background-image: linear-gradient(center top, #3E3E3E 0%, #393939 14%, #2E2E2E 32%, #151515 64%, #080808 84%, #010101 100%); |
| 10 | + color: white; |
| 11 | + text-align: center; |
| 12 | + |
| 13 | + padding: 0; |
| 14 | + margin: 0; |
| 15 | +} |
| 16 | + |
| 17 | +#filetoc a { |
| 18 | + color: white; |
| 19 | +} |
| 20 | + |
| 21 | +#filetoc li { |
| 22 | + display: inline-block; |
| 23 | + padding: 8px; |
| 24 | + margin: 0; |
| 25 | +} |
| 26 | + |
| 27 | +#file img { |
| 28 | + max-width: 100%; |
| 29 | + height: auto; |
| 30 | +} |
| 31 | + |
| 32 | + |
Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | public static $languageUrls; |
134 | 134 | public static $wsLoginToken = ''; |
135 | 135 | public static $wsLoginFormAction = ''; |
| 136 | + public static $isFilePage; |
136 | 137 | |
137 | 138 | public static $messageKeys = array( |
138 | 139 | 'mobile-frontend-show-button', |
— | — | @@ -458,6 +459,9 @@ |
459 | 460 | if ( Title::newMainPage()->equals( self::$title ) ) { |
460 | 461 | self::$isMainPage = true; |
461 | 462 | } |
| 463 | + if ( self::$title->getNamespace() == NS_FILE ) { |
| 464 | + self::$isFilePage = true; |
| 465 | + } |
462 | 466 | |
463 | 467 | self::$htmlTitle = $out->getHTMLTitle(); |
464 | 468 | self::$disableImages = $wgRequest->getText( 'disableImages', 0 ); |
Index: trunk/extensions/MobileFrontend/views/layout/application.html.php |
— | — | @@ -23,7 +23,12 @@ |
24 | 24 | |
25 | 25 | $openSearchScript = $startScriptTag . $javaScriptPath . $betaPrefix . 'opensearch.js?version=12012011126437' . $endScriptTag; |
26 | 26 | $jQueryScript = ( self::$device['supports_jquery'] ) ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; |
| 27 | +$filePageScript = ( self::$isFilePage ) ? $startScriptTag . $javaScriptPath . 'filepage.js' . $endScriptTag : ''; |
27 | 28 | |
| 29 | +$startLinkTag = "<link href='{$wgExtensionAssetsPath}/MobileFrontend/stylesheets/"; |
| 30 | +$endLinkTag = "' media='all' rel='Stylesheet' type='text/css' />"; |
| 31 | +$filePageStyle = ( self::$isFilePage ) ? $startLinkTag . 'filepage.css' . $endLinkTag : ''; |
| 32 | + |
28 | 33 | $applicationHtml = <<<HTML |
29 | 34 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
30 | 35 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
— | — | @@ -33,6 +38,7 @@ |
34 | 39 | <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> |
35 | 40 | <link href='{$wgExtensionAssetsPath}/MobileFrontend/stylesheets/{$betaPrefix}common.css?version=12012011121954' media='all' rel='Stylesheet' type='text/css' /> |
36 | 41 | <link href='{$wgExtensionAssetsPath}/MobileFrontend/stylesheets/{$cssFileName}.css?version=12012011120715' media='all' rel='Stylesheet' type='text/css' /> |
| 42 | + {$filePageStyle} |
37 | 43 | <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> |
38 | 44 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
39 | 45 | {$appleTouchIconTag} |
— | — | @@ -54,6 +60,7 @@ |
55 | 61 | {$footerHtml} |
56 | 62 | {$startScriptTag}{$javaScriptPath}{$betaPrefix}application.js?version=12012011120915{$endScriptTag} |
57 | 63 | {$openSearchScript} |
| 64 | + {$filePageScript} |
58 | 65 | </body> |
59 | 66 | </html> |
60 | 67 | HTML; |