Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -7,8 +7,8 @@ |
8 | 8 | $wgHooks['OutputPageParserOutput'][] = 'wfProofreadPageParserOutput'; |
9 | 9 | |
10 | 10 | function wfProofreadPageParserOutput( &$out, &$pout ) { |
11 | | - global $wgTitle, $wgJsMimeType; |
12 | | - if ( !isset( $wgTitle ) ) { |
| 11 | + global $wgTitle, $wgJsMimeType, $wgScriptPath; |
| 12 | + if ( !isset( $wgTitle ) || !$out->isArticle() ) { |
13 | 13 | return true; |
14 | 14 | } |
15 | 15 | if ( !preg_match( '/^Page:(.*)$/', $wgTitle->getPrefixedText(), $m ) ) { |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | $viewURL = Xml::escapeJsString( $image->getViewURL() ); |
29 | 29 | list( $isScript, $thumbURL ) = $image->thumbUrl( '##WIDTH##' ); |
30 | 30 | $thumbURL = Xml::escapeJsString( str_replace( '%23', '#', $thumbURL ) ); |
| 31 | + $jsFile = htmlspecialchars( "$wgScriptPath/extensions/ProofreadPage/proofread.js" ); |
31 | 32 | |
32 | 33 | $out->addScript( <<<EOT |
33 | 34 | <script type="$wgJsMimeType"> |
— | — | @@ -35,6 +36,7 @@ |
36 | 37 | var proofreadPageViewURL = "$viewURL"; |
37 | 38 | var proofreadPageThumbURL = "$thumbURL"; |
38 | 39 | </script> |
| 40 | +<script type="$wgJsMimeType" src="$jsFile"></script> |
39 | 41 | |
40 | 42 | EOT |
41 | 43 | ); |
Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -0,0 +1,76 @@ |
| 2 | +/* Author : ThomasV - License : GPL */ |
| 3 | + |
| 4 | +function proofreadPageSetup() { |
| 5 | + if(self.proofreadPageViewURL) { |
| 6 | + |
| 7 | + if(document.URL.indexOf("action=protect") > 0 || document.URL.indexOf("action=unprotect") > 0) return; |
| 8 | + if(document.URL.indexOf("action=delete") > 0 || document.URL.indexOf("action=undelete") > 0) return; |
| 9 | + if(document.URL.indexOf("action=watch") > 0 || document.URL.indexOf("action=unwatch") > 0) return; |
| 10 | + if(document.URL.indexOf("action=history") > 0 ) return; |
| 11 | + if(document.URL.indexOf("&diff=") > 0 ) return; |
| 12 | + |
| 13 | + var displayWidth = 400; //default value |
| 14 | + //quantization: displayWidth must be multiple of 100px |
| 15 | + if (parseInt(navigator.appVersion)>3) { |
| 16 | + if (navigator.appName=="Netscape") { |
| 17 | + displayWidth = 100*parseInt((window.innerWidth/2-70)/100); |
| 18 | + } |
| 19 | + if (navigator.appName.indexOf("Microsoft")!=-1) { |
| 20 | + displayWidth = 100*parseInt((document.body.offsetWidth/2-70)/100); |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + if(displayWidth<proofreadPageWidth) { |
| 25 | + image_url = proofreadPageThumbURL.replace('##WIDTH##',""+displayWidth); |
| 26 | + } |
| 27 | + else { |
| 28 | + image_url = proofreadPageViewURL; |
| 29 | + displayWidth = proofreadPageWidth; |
| 30 | + } |
| 31 | + |
| 32 | + //image |
| 33 | + image = document.createElement("img"); |
| 34 | + image.setAttribute("src", image_url); |
| 35 | + image.setAttribute("style","padding:0;margin:0;border:0;"); |
| 36 | + image.setAttribute("width",displayWidth); |
| 37 | + |
| 38 | + //container |
| 39 | + //useful for hooking elements to the image, eg href or zoom. |
| 40 | + container = document.createElement("div"); |
| 41 | + container.setAttribute("id", "proofreadImage"); |
| 42 | + container.appendChild(image); |
| 43 | + |
| 44 | + table = document.createElement("table"); |
| 45 | + table.setAttribute("id", "textBoxTable"); |
| 46 | + t_body = document.createElement("tbody"); |
| 47 | + t_row = document.createElement("tr"); |
| 48 | + t_row.setAttribute("valign","top"); |
| 49 | + cell0 = document.createElement("td"); |
| 50 | + cell1 = document.createElement("td"); |
| 51 | + cell1.setAttribute("style","width:1em"); |
| 52 | + cell2 = document.createElement("td"); |
| 53 | + cell2.appendChild(container); |
| 54 | + cell2.setAttribute("valign","top"); |
| 55 | + t_row.appendChild(cell0); |
| 56 | + t_row.appendChild(cell1); |
| 57 | + t_row.appendChild(cell2); |
| 58 | + t_body.appendChild(t_row); |
| 59 | + table.appendChild(t_body); |
| 60 | + |
| 61 | + isEditing = document.URL.indexOf("action=edit") > 0 || document.URL.indexOf("action=submit") > 0; |
| 62 | + if(isEditing) { |
| 63 | + text = document.getElementById("wpTextbox1"); |
| 64 | + text.setAttribute("style", "width:100%"); //this seems to be set by monobook already... |
| 65 | + text.setAttribute("style", "height:100%"); |
| 66 | + } |
| 67 | + else { text = document.getElementById("bodyContent"); } |
| 68 | + if(!text) return; |
| 69 | + |
| 70 | + f = text.parentNode; |
| 71 | + new_text = f.removeChild(text); |
| 72 | + cell0.appendChild(new_text); |
| 73 | + copywarn = document.getElementById("editpage-copywarn"); |
| 74 | + if(copywarn){ f.insertBefore(table,copywarn);} else {f.appendChild(table);} |
| 75 | + } |
| 76 | +} |
| 77 | +addOnloadHook(proofreadPageSetup); |
Property changes on: trunk/extensions/ProofreadPage/proofread.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 78 | + native |