Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -37,9 +37,6 @@ |
38 | 38 | # Group allowed to modify pagequality |
39 | 39 | $wgGroupPermissions['user']['pagequality'] = true; |
40 | 40 | |
41 | | -# Max width of zoomable image |
42 | | -$wgProofreadPageMaxWidth = 2048; |
43 | | - |
44 | 41 | $wgExtensionCredits['other'][] = array( |
45 | 42 | 'path' => __FILE__, |
46 | 43 | 'name' => 'ProofreadPage', |
— | — | @@ -232,8 +229,9 @@ |
233 | 230 | $footer = str_replace( "{{{{$key}}}}", $val, $footer ); |
234 | 231 | } |
235 | 232 | $css = $attributes['css'] ? $attributes['css'] : ""; |
| 233 | + $edit_width = $attributes['width'] ? $attributes['width'] : ""; |
236 | 234 | |
237 | | - return array( $index_url, $prev_url, $next_url, $header, $footer, $css ); |
| 235 | + return array( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ); |
238 | 236 | |
239 | 237 | } |
240 | 238 | |
— | — | @@ -394,37 +392,27 @@ |
395 | 393 | if ( $image && $image->exists() ) { |
396 | 394 | $width = $image->getWidth(); |
397 | 395 | $height = $image->getHeight(); |
398 | | - if( $width > $wgProofreadPageMaxWidth ) { |
399 | | - $width = $wgProofreadPageMaxWidth; |
400 | | - $height = $image->getHeight() * $wgProofreadPageMaxWidth / $image->getWidth(); |
401 | | - } |
402 | 396 | if ( $m[2] ) { |
403 | | - $viewName = $image->thumbName( array( 'width' => $width, 'page' => $m[3] ) ); |
404 | | - $viewURL = $image->getThumbUrl( $viewName ); |
405 | | - |
406 | 397 | $thumbName = $image->thumbName( array( 'width' => '##WIDTH##', 'page' => $m[3] ) ); |
407 | | - $thumbURL = $image->getThumbUrl( $thumbName ); |
408 | 398 | } else { |
409 | | - $viewURL = $image->getViewURL(); |
410 | 399 | $thumbName = $image->thumbName( array( 'width' => '##WIDTH##' ) ); |
411 | | - $thumbURL = $image->getThumbUrl( $thumbName ); |
412 | 400 | } |
| 401 | + $thumbURL = $image->getThumbUrl( $thumbName ); |
413 | 402 | $thumbURL = str_replace( '%23', '#', $thumbURL ); |
414 | 403 | } else { |
415 | 404 | $width = 0; |
416 | 405 | $height = 0; |
417 | | - $viewURL = ''; |
418 | 406 | $thumbURL = ''; |
419 | 407 | } |
420 | 408 | |
421 | | - list( $index_url, $prev_url, $next_url, $header, $footer, $css ) = pr_navigation( $wgTitle ); |
| 409 | + list( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ) = pr_navigation( $wgTitle ); |
422 | 410 | |
423 | 411 | $jsFile = htmlspecialchars( "$wgScriptPath/extensions/ProofreadPage/proofread.js?$wgProofreadPageVersion" ); |
424 | 412 | |
425 | 413 | $jsVars = array( |
426 | 414 | 'proofreadPageWidth' => intval( $width ), |
427 | 415 | 'proofreadPageHeight' => intval( $height ), |
428 | | - 'proofreadPageViewURL' => $viewURL, |
| 416 | + 'proofreadPageEditWidth' => $edit_width, |
429 | 417 | 'proofreadPageThumbURL' => $thumbURL, |
430 | 418 | 'proofreadPageIsEdit' => intval( $isEdit ), |
431 | 419 | 'proofreadPageIndexURL' => $index_url, |
— | — | @@ -893,7 +881,7 @@ |
894 | 882 | $page_regexp = "/^<noinclude>(.*?)<\/noinclude>(.*?)<noinclude>(.*?)<\/noinclude>$/s"; |
895 | 883 | if( !preg_match( $page_regexp, $text, $m ) ) { |
896 | 884 | pr_load_index( $wgTitle ); |
897 | | - list( $index_url, $prev_url, $next_url, $header, $footer, $css ) = pr_navigation( $wgTitle ); |
| 885 | + list( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ) = pr_navigation( $wgTitle ); |
898 | 886 | $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />" |
899 | 887 | ."$header\n\n\n</noinclude>$text<noinclude>\n$footer</noinclude>"; |
900 | 888 | return array( -1, null, $new_text ); |
Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -1,6 +1,10 @@ |
2 | 2 | // Author : ThomasV - License : GPL |
3 | 3 | |
4 | 4 | |
| 5 | +/* Default size of the high resolution image in edit mode */ |
| 6 | +self.proofreadPageDefaultEditWidth = 1024; |
| 7 | + |
| 8 | + |
5 | 9 | function pr_init_tabs(){ |
6 | 10 | var a = document.getElementById("p-namespaces"); |
7 | 11 | if(!a) a = document.getElementById("p-cactions"); |
— | — | @@ -9,10 +13,11 @@ |
10 | 14 | var b = a.getElementsByTagName("ul"); |
11 | 15 | if (!b) return; |
12 | 16 | |
13 | | - if(self.proofreadPageViewURL) { |
| 17 | + if( self.proofreadPageThumbURL ) { |
| 18 | + var view_url = self.proofreadPageThumbURL.replace('##WIDTH##',"" + self.proofreadPageWidth ); |
14 | 19 | b[0].innerHTML = b[0].innerHTML |
15 | 20 | + '<li id="ca-image">' |
16 | | - + '<a href="' + escapeQuotesHTML(proofreadPageViewURL) + '"><span>' |
| 21 | + + '<a href="' + escapeQuotesHTML( view_url ) + '"><span>' |
17 | 22 | + escapeQuotesHTML(proofreadPageMessageImage) + '</span></a></li>'; |
18 | 23 | } |
19 | 24 | |
— | — | @@ -53,29 +58,20 @@ |
54 | 59 | |
55 | 60 | |
56 | 61 | function pr_image_url(requested_width){ |
57 | | - var thumb_url; |
58 | | - |
59 | 62 | if(self.proofreadPageExternalURL) { |
60 | | - thumb_url = proofreadPageViewURL; |
61 | 63 | self.DisplayWidth = requested_width; |
62 | 64 | self.DisplayHeight = ""; |
| 65 | + return self.proofreadPageExternalURL; |
63 | 66 | } |
64 | 67 | else { |
65 | 68 | //enforce quantization: width must be multiple of 100px |
66 | 69 | var width = 100 * Math.round( requested_width /100 ); |
67 | 70 | //compare to the width of the image |
68 | | - if(width < proofreadPageWidth) { |
69 | | - thumb_url = proofreadPageThumbURL.replace('##WIDTH##',""+width); |
70 | | - self.DisplayWidth = requested_width; |
71 | | - self.DisplayHeight = requested_width*proofreadPageHeight/proofreadPageWidth; |
72 | | - } |
73 | | - else { |
74 | | - thumb_url = proofreadPageViewURL; |
75 | | - self.DisplayWidth = proofreadPageWidth; |
76 | | - self.DisplayHeight = proofreadPageHeight; |
77 | | - } |
| 71 | + width = Math.min( width, proofreadPageWidth ); |
| 72 | + self.DisplayWidth = width; |
| 73 | + self.DisplayHeight = width*proofreadPageHeight/proofreadPageWidth; |
| 74 | + return proofreadPageThumbURL.replace( '##WIDTH##', "" + width ); |
78 | 75 | } |
79 | | - return thumb_url; |
80 | 76 | } |
81 | 77 | |
82 | 78 | |
— | — | @@ -368,7 +364,7 @@ |
369 | 365 | //zoom using two images (magnification glass) |
370 | 366 | function pr_initzoom(){ |
371 | 367 | if(proofreadPageIsEdit) return; |
372 | | - if(!self.proofreadPageViewURL) return; |
| 368 | + if( !self.proofreadPageThumbURL ) return; |
373 | 369 | if(self.DisplayWidth>800) return; |
374 | 370 | |
375 | 371 | zp = document.getElementById("pr_container"); |
— | — | @@ -661,9 +657,9 @@ |
662 | 658 | |
663 | 659 | |
664 | 660 | |
665 | | -function pr_load_image() { |
| 661 | +function pr_load_image( view_url ) { |
666 | 662 | pr_container.innerHTML = "<img id=\"ProofReadImage\" src=\"" |
667 | | - + escapeQuotesHTML(proofreadPageViewURL) |
| 663 | + + escapeQuotesHTML( view_url ) |
668 | 664 | + "\" width=\"" + img_width + "\" />"; |
669 | 665 | } |
670 | 666 | |
— | — | @@ -710,6 +706,9 @@ |
711 | 707 | pr_container.appendChild(image); |
712 | 708 | pr_container.style.cssText = "overflow:hidden;width:"+self.DisplayWidth+"px;"; |
713 | 709 | } else { |
| 710 | + var w = parseInt(self.proofreadPageEditWidth); |
| 711 | + if( !w ) w = self.proofreadPageDefaultEditWidth; |
| 712 | + var view_url = pr_image_url( Math.min( w, self.proofreadPageWidth ) ); |
714 | 713 | //prevent the container from being resized once the image is downloaded. |
715 | 714 | img_width = pr_horiz?0:parseInt(pr_width/2-70)-20; |
716 | 715 | pr_container.onmousedown = pr_grab; |
— | — | @@ -717,7 +716,7 @@ |
718 | 717 | if (pr_container.addEventListener) |
719 | 718 | pr_container.addEventListener('DOMMouseScroll', pr_zoom_wheel, false); |
720 | 719 | pr_container.onmousewheel = pr_zoom_wheel;//IE,Opera. |
721 | | - hookEvent( 'load', pr_load_image ); |
| 720 | + hookEvent( 'load', function() { pr_load_image(view_url); } ); |
722 | 721 | } |
723 | 722 | |
724 | 723 | table.setAttribute("id", "textBoxTable"); |
— | — | @@ -839,15 +838,14 @@ |
840 | 839 | if(document.URL.indexOf("action=history") > 0 ) return; |
841 | 840 | |
842 | 841 | /*check if external url is provided*/ |
843 | | - if(!self.proofreadPageViewURL) { |
| 842 | + if( !self.proofreadPageThumbURL ) { |
844 | 843 | var text = document.getElementById("wpTextbox1"); |
845 | 844 | if (text) { |
846 | 845 | var proofreadPageIsEdit = true; |
847 | 846 | re = /<span class="hiddenStructure" id="pageURL">\[http:\/\/(.*?)\]<\/span>/; |
848 | 847 | m = re.exec(text.value); |
849 | 848 | if( m ) { |
850 | | - self.proofreadPageViewURL = "http://"+m[1]; |
851 | | - self.proofreadPageExternalURL = true; |
| 849 | + self.proofreadPageExternalURL = "http://"+m[1]; |
852 | 850 | } |
853 | 851 | } |
854 | 852 | else { |
— | — | @@ -856,8 +854,7 @@ |
857 | 855 | try { |
858 | 856 | var a = document.getElementById("pageURL"); |
859 | 857 | var b = a.firstChild; |
860 | | - self.proofreadPageViewURL = b.getAttribute("href"); |
861 | | - self.proofreadPageExternalURL = true; |
| 858 | + self.proofreadPageExternalURL = b.getAttribute("href"); |
862 | 859 | } catch(err){}; |
863 | 860 | } |
864 | 861 | //set to dummy values, not used |
— | — | @@ -865,7 +862,7 @@ |
866 | 863 | self.proofreadPageHeight = 400; |
867 | 864 | } |
868 | 865 | |
869 | | - if(!self.proofreadPageViewURL) return; |
| 866 | + if( !self.proofreadPageThumbURL ) return; |
870 | 867 | |
871 | 868 | if( self.proofreadpage_setup ) { |
872 | 869 | |