Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Set up our custom parser hooks when initializing parser. |
79 | | - * |
| 79 | + * |
80 | 80 | * @param Parser $parser |
81 | 81 | * @return boolean hook return value |
82 | 82 | */ |
— | — | @@ -324,7 +324,7 @@ |
325 | 325 | return true; |
326 | 326 | } |
327 | 327 | |
328 | | - if ( $isEdit && $out->getTitle()->getNamespace() == self::getIndexNamespaceId() ) { |
| 328 | + if ( $isEdit && ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $out->getTitle()->getPrefixedText(), $m ) ) ) { |
329 | 329 | self::prepareIndex( $out ); |
330 | 330 | return true; |
331 | 331 | } |
— | — | @@ -339,13 +339,10 @@ |
340 | 340 | |
341 | 341 | private static function prepareIndex( $out ) { |
342 | 342 | $out->addModules( 'ext.proofreadpage.index' ); |
343 | | - |
344 | | - $jsVars = array( |
345 | | - 'prp_index_attributes' => wfMsgForContent( 'proofreadpage_index_attributes' ), |
346 | | - 'prp_default_header' => wfMsgForContentNoTrans( 'proofreadpage_default_header' ), |
347 | | - 'prp_default_footer' => wfMsgForContentNoTrans( 'proofreadpage_default_footer' ), |
348 | | - ); |
349 | | - $out->addInlineScript( ResourceLoader::makeConfigSetScript( $jsVars ) ); |
| 343 | + $out->addInlineScript(" |
| 344 | +var prp_index_attributes = \"" . Xml::escapeJsString( wfMsgForContent( 'proofreadpage_index_attributes' ) ) . "\"; |
| 345 | +var prp_default_header = \"" . Xml::escapeJsString( wfMsgForContentNoTrans( 'proofreadpage_default_header' ) ) . "\"; |
| 346 | +var prp_default_footer = \"" . Xml::escapeJsString( wfMsgForContentNoTrans( 'proofreadpage_default_footer' ) ) . "\";" ); |
350 | 347 | } |
351 | 348 | |
352 | 349 | private static function preparePage( $out, $m, $isEdit ) { |
— | — | @@ -360,32 +357,31 @@ |
361 | 358 | return true; |
362 | 359 | } |
363 | 360 | |
364 | | - $fileName = null; |
365 | | - $filePage = null; |
366 | | - $fileWidth = 0; |
367 | | - $fileHeight = 0; |
368 | | - $fileFullUrl = null; |
369 | | - $scanLink = null; |
370 | | - |
371 | 361 | $image = wfFindFile( $imageTitle ); |
372 | | - |
373 | 362 | if ( $image && $image->exists() ) { |
374 | | - $fileName = $imageTitle->getPrefixedText(); |
375 | | - $fileWidth = $image->getWidth(); |
376 | | - $fileHeight = $image->getHeight(); |
377 | | - |
| 363 | + $width = $image->getWidth(); |
| 364 | + $height = $image->getHeight(); |
378 | 365 | if ( $m[2] ) { |
379 | | - $filePage = $m[3]; |
380 | | - |
381 | | - $thumbName = $image->thumbName( array( 'width' => $fileWidth, 'page' => $filePage ) ); |
382 | | - $fileFullUrl = $image->getThumbUrl( $thumbName ); |
| 366 | + $thumbName = $image->thumbName( array( 'width' => '##WIDTH##', 'page' => $m[3] ) ); |
| 367 | + $thumbURL = $image->getThumbUrl( $thumbName ); |
| 368 | + $thumbURL = str_replace( '%23', '#', $thumbURL ); |
| 369 | + $fullURL = str_replace( '##WIDTH##', "$width", $thumbURL ); |
383 | 370 | } else { |
384 | | - $fileFullUrl = $image->getViewURL(); |
| 371 | + $thumbName = $image->thumbName( array( 'width' => '##WIDTH##' ) ); |
| 372 | + $thumbURL = $image->getThumbUrl( $thumbName ); |
| 373 | + $thumbURL = str_replace( '%23', '#', $thumbURL ); |
| 374 | + $fullURL = $image->getURL(); |
385 | 375 | } |
386 | | - $scanLink = Html::element( 'a', |
387 | | - array( 'href' => $fileFullUrl, |
388 | | - 'title' => wfMsg( 'proofreadpage_image' ) ), |
| 376 | + $scan_link = Html::element( 'a', |
| 377 | + array( 'href' => $fullURL, |
| 378 | + 'title' => wfMsg( 'proofreadpage_image' ) ), |
389 | 379 | wfMsg( 'proofreadpage_image' ) ); |
| 380 | + } else { |
| 381 | + $width = 0; |
| 382 | + $height = 0; |
| 383 | + $thumbURL = ''; |
| 384 | + $fullURL = ''; |
| 385 | + $scan_link = ''; |
390 | 386 | } |
391 | 387 | |
392 | 388 | list( $index_title, $prev_title, $next_title, $header, $footer, $css, $edit_width ) = self::navigation( $out->getTitle() ); |
— | — | @@ -393,33 +389,32 @@ |
394 | 390 | $sk = $wgUser->getSkin(); |
395 | 391 | $path = $wgExtensionAssetsPath . '/ProofreadPage'; |
396 | 392 | |
397 | | - $nextLink = $next_title ? $sk->link( $next_title, |
| 393 | + $next_link = $next_title ? $sk->link( $next_title, |
398 | 394 | Html::element( 'img', array( 'src' => $path . '/rightarrow.png', |
399 | 395 | 'alt' => wfMsg( 'proofreadpage_nextpage' ), 'width' => 15, 'height' => 15 ) ), |
400 | | - array( 'title' => wfMsg( 'proofreadpage_nextpage' ) ) ) : null; |
| 396 | + array( 'title' => wfMsg( 'proofreadpage_nextpage' ) ) ) : ''; |
401 | 397 | |
402 | | - $prevLink = $prev_title ? $sk->link( $prev_title, |
403 | | - Html::element( 'img', array( 'src' => $path . '/leftarrow.png', |
404 | | - 'alt' => wfMsg( 'proofreadpage_prevpage' ), 'width' => 15, 'height' => 15 ) ), |
405 | | - array( 'title' => wfMsg( 'proofreadpage_prevpage' ) ) ): null; |
| 398 | + $prev_link = $prev_title ? $sk->link( $prev_title, |
| 399 | + Html::element( 'img', array( 'src' => $path . '/leftarrow.png', |
| 400 | + 'alt' => wfMsg( 'proofreadpage_prevpage' ), 'width' => 15, 'height' => 15 ) ), |
| 401 | + array( 'title' => wfMsg( 'proofreadpage_prevpage' ) ) ): ''; |
406 | 402 | |
407 | | - $indexLink = $index_title ? $sk->link( $index_title, |
408 | | - Html::element( 'img', array( 'src' => $path . '/uparrow.png', |
| 403 | + $index_link = $index_title ? $sk->link( $index_title, |
| 404 | + Html::element( 'img', array( 'src' => $path . '/uparrow.png', |
409 | 405 | 'alt' => wfMsg( 'proofreadpage_index' ), 'width' => 15, 'height' => 15 ) ), |
410 | | - array( 'title' => wfMsg( 'proofreadpage_index' ) ) ) : null; |
| 406 | + array( 'title' => wfMsg( 'proofreadpage_index' ) ) ) : ''; |
411 | 407 | |
412 | 408 | $jsVars = array( |
413 | | - 'proofreadPageWidth' => intval( $fileWidth ), |
414 | | - 'proofreadPageHeight' => intval( $fileHeight ), |
| 409 | + 'proofreadPageWidth' => intval( $width ), |
| 410 | + 'proofreadPageHeight' => intval( $height ), |
415 | 411 | 'proofreadPageEditWidth' => $edit_width, |
416 | | - 'proofreadPageURL' => $fileFullUrl, |
417 | | - 'proofreadPageFileName' => $fileName, |
418 | | - 'proofreadPageFilePage' => $filePage, |
| 412 | + 'proofreadPageThumbURL' => $thumbURL, |
| 413 | + 'proofreadPageURL' => $fullURL, |
419 | 414 | 'proofreadPageIsEdit' => intval( $isEdit ), |
420 | | - 'proofreadPageIndexLink' => $indexLink, |
421 | | - 'proofreadPageNextLink' => $nextLink, |
422 | | - 'proofreadPagePrevLink' => $prevLink, |
423 | | - 'proofreadPageScanLink' => $scanLink, |
| 415 | + 'proofreadPageIndexLink' => $index_link, |
| 416 | + 'proofreadPageNextLink' => $next_link, |
| 417 | + 'proofreadPagePrevLink' => $prev_link, |
| 418 | + 'proofreadPageScanLink' => $scan_link, |
424 | 419 | 'proofreadPageHeader' => $header, |
425 | 420 | 'proofreadPageFooter' => $footer, |
426 | 421 | 'proofreadPageAddButtons' => $wgUser->isAllowed( 'pagequality' ), |
— | — | @@ -857,7 +852,7 @@ |
858 | 853 | null, |
859 | 854 | array( 'categorylinks' => array( 'LEFT JOIN', 'cl_from=page_id' ) ) |
860 | 855 | ); |
861 | | - |
| 856 | + |
862 | 857 | if( $res ) { |
863 | 858 | foreach ( $res as $o ) { |
864 | 859 | array_push( $q0_pages, $o->page_title ); |
— | — | @@ -1549,7 +1544,7 @@ |
1550 | 1545 | if( $indextitle ) { |
1551 | 1546 | $sk = $wgUser->getSkin(); |
1552 | 1547 | $nt = Title::makeTitleSafe( $index_ns_index, $indextitle ); |
1553 | | - $indexlink = $sk->link( $nt, wfMsg( 'proofreadpage_source' ), |
| 1548 | + $indexlink = $sk->link( $nt, wfMsg( 'proofreadpage_source' ), |
1554 | 1549 | array( 'title' => wfMsg( 'proofreadpage_source_message' ) ) ); |
1555 | 1550 | $out->addInlineScript( ResourceLoader::makeConfigSetScript( array( 'proofreadpage_source_href' => $indexlink ) ) ); |
1556 | 1551 | $out->addModules( 'ext.proofreadpage.article' ); |
Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -1,70 +1,30 @@ |
2 | 2 | // Author : ThomasV - License : GPL |
3 | 3 | |
4 | 4 | function pr_init_tabs() { |
5 | | - if( mw.config.get( 'proofreadPagePrevLink' ) != null ) { |
6 | | - $( '#ca-talk' ).prev().before( '<li id="ca-prev"><span>' + mw.config.get( 'proofreadPagePrevLink' ) + '</span></li>' ); |
7 | | - } |
8 | | - if( mw.config.get( 'proofreadPageNextLink' ) != null ) { |
9 | | - $( '#ca-talk' ).prev().before( '<li id="ca-next"><span>' + mw.config.get( 'proofreadPageNextLink' ) + '</span></li>' ); |
10 | | - } |
11 | | - if( mw.config.get( 'proofreadPageIndexLink' ) != null ) { |
12 | | - $( '#ca-talk' ).after( '<li id="ca-index"><span>' + mw.config.get( 'proofreadPageIndexLink' ) + '</span></li>' ); |
13 | | - } |
14 | | - if( mw.config.get( 'proofreadPageScanLink' ) != null ) { |
15 | | - $( '#ca-talk' ).after( '<li id="ca-image"><span>' + mw.config.get( 'proofreadPageScanLink' ) + '</span></li>' ); |
16 | | - } |
| 5 | + $( '#ca-talk' ).prev().before( '<li id="ca-prev"><span>' + self.proofreadPagePrevLink + '</span></li>' ); |
| 6 | + $( '#ca-talk' ).prev().before( '<li id="ca-next"><span>' + self.proofreadPageNextLink + '</span></li>' ); |
| 7 | + $( '#ca-talk' ).after( '<li id="ca-index"><span>' + self.proofreadPageIndexLink + '</span></li>' ); |
| 8 | + $( '#ca-talk' ).after( '<li id="ca-image"><span>' + self.proofreadPageScanLink + '</span></li>' ); |
17 | 9 | } |
18 | 10 | |
19 | | -function pr_fetch_thumb_url( requestedWidth, callback ) { |
20 | | - var fullWidth = mw.config.get( 'proofreadPageWidth' ); |
21 | | - var fullHeight = mw.config.get( 'proofreadPageHeight' ); |
22 | | - |
23 | | - // enforce quantization: width must be multiple of 100px |
24 | | - var quantizedWidth = 100 * Math.round( requestedWidth / 100 ); |
25 | | - |
26 | | - // compare to the width of the image |
27 | | - if( quantizedWidth < fullWidth ) { |
28 | | - // Send request to fetch thumbnail url |
29 | | - var request = { |
30 | | - action: 'query', |
31 | | - titles: mw.config.get( 'proofreadPageFileName' ), |
32 | | - prop: 'imageinfo', |
33 | | - iiprop: 'url|size', |
34 | | - iiurlwidth: quantizedWidth, |
35 | | - format: 'json' |
36 | | - }; |
37 | | - |
38 | | - if( mw.config.get( 'proofreadPageFilePage' ) != null ) { |
39 | | - request['iiurlparam'] = 'page' + mw.config.get( 'proofreadPageFilePage' ) + '-' + quantizedWidth + 'px'; |
40 | | - } |
41 | | - |
42 | | - $.getJSON( mw.util.wikiScript( 'api' ) ,request, function(data) { |
43 | | - if( data && data.query && data.query.pages ) { |
44 | | - for( var i in data.query.pages ) { |
45 | | - var page = data.query.pages[i]; |
46 | | - if( !page.imageinfo || page.imageinfo.length < 1 ) { |
47 | | - continue; |
48 | | - } |
49 | | - var imageinfo = page.imageinfo[0]; |
50 | | - |
51 | | - if( !imageinfo.thumburl ) { |
52 | | - // Unable to fetch thumbnail, use image without scaling |
53 | | - // This works only for non-paged files and may mess up the layout of the page |
54 | | - if ( mw.config.get( 'proofreadPageFilePage' ) == null ) { |
55 | | - callback( imageinfo.url, imageinfo.width, imageinfo.height ); |
56 | | - } |
57 | | - } |
58 | | - else { |
59 | | - callback( imageinfo.thumburl, imageinfo.thumbwidth, imageinfo.thumbheight ); |
60 | | - } |
61 | | - |
62 | | - return; |
63 | | - } |
64 | | - } |
65 | | - }); |
| 11 | +function pr_image_url( requested_width ) { |
| 12 | + if( self.proofreadPageExternalURL ) { |
| 13 | + self.DisplayWidth = requested_width; |
| 14 | + self.DisplayHeight = ''; |
| 15 | + return self.proofreadPageExternalURL; |
66 | 16 | } else { |
67 | | - // Image without scaling |
68 | | - callback( mw.config.get( 'proofreadPageURL' ), fullWidth, fullHeight ); |
| 17 | + // enforce quantization: width must be multiple of 100px |
| 18 | + var width = 100 * Math.round( requested_width / 100 ); |
| 19 | + // compare to the width of the image |
| 20 | + if( width < proofreadPageWidth ) { |
| 21 | + self.DisplayWidth = width; |
| 22 | + self.DisplayHeight = width * proofreadPageHeight / proofreadPageWidth; |
| 23 | + return proofreadPageThumbURL.replace( '##WIDTH##', '' + width ); |
| 24 | + } else { |
| 25 | + self.DisplayWidth = proofreadPageWidth; |
| 26 | + self.DisplayHeight = proofreadPageHeight; |
| 27 | + return proofreadPageURL; |
| 28 | + } |
69 | 29 | } |
70 | 30 | } |
71 | 31 | |
— | — | @@ -130,7 +90,7 @@ |
131 | 91 | } |
132 | 92 | self.proofreadpage_username = m4[2]; |
133 | 93 | pageHeader = pageHeader.replace( reg, '' ); |
134 | | - } else if( old_m4 ) { |
| 94 | + } else if ( old_m4 ) { |
135 | 95 | switch( old_m4[1] ) { |
136 | 96 | case '0': |
137 | 97 | self.proofreadpage_quality = 0; |
— | — | @@ -182,7 +142,6 @@ |
183 | 143 | var box = document.getElementById( 'wpTextbox1' ); |
184 | 144 | var h = document.getElementById( 'prp_header' ); |
185 | 145 | var f = document.getElementById( 'prp_footer' ); |
186 | | - |
187 | 146 | if( h.style.cssText == 'display:none;' ) { |
188 | 147 | box.style.cssText = 'height:' + ( self.DisplayHeight - 6 ) + 'px'; |
189 | 148 | } else { |
— | — | @@ -358,32 +317,35 @@ |
359 | 318 | return false; |
360 | 319 | } |
361 | 320 | |
362 | | -//zoom using two images (magnification glass) |
363 | | -function pr_initzoom( width, height ) { |
364 | | - var maxWidth = 800; |
365 | 321 | |
366 | | - if( width > maxWidth ) { |
| 322 | +//zoom using two images (magnification glass) |
| 323 | +function pr_initzoom() { |
| 324 | + if( proofreadPageIsEdit ) { |
367 | 325 | return; |
368 | 326 | } |
369 | | - |
370 | | - zp = document.getElementById( 'pr_container' ); |
371 | | - if( !zp ) { |
| 327 | + if( !self.proofreadPageThumbURL ) { |
372 | 328 | return; |
373 | 329 | } |
374 | | - pr_fetch_thumb_url( maxWidth, function( largeUrl, largeWidth, largeHeight ) { |
375 | | - self.objw = width; |
376 | | - self.objh = height; |
| 330 | + if( self.DisplayWidth > 800 ) { |
| 331 | + return; |
| 332 | + } |
377 | 333 | |
| 334 | + zp = document.getElementById( 'pr_container' ); |
| 335 | + if( zp ) { |
| 336 | + var hires_url = pr_image_url( 800 ); |
| 337 | + self.objw = zp.firstChild.width; |
| 338 | + self.objh = zp.firstChild.height; |
| 339 | + |
378 | 340 | zp.onmouseup = zoom_mouseup; |
379 | 341 | zp.onmousemove = zoom_move; |
380 | 342 | zp_container = document.createElement( 'div' ); |
381 | 343 | zp_container.style.cssText = 'position:absolute; width:0; height:0; overflow:hidden;'; |
382 | 344 | zp_clip = document.createElement( 'img' ); |
383 | | - zp_clip.setAttribute( 'src', largeUrl ); |
| 345 | + zp_clip.setAttribute( 'src', hires_url ); |
384 | 346 | zp_clip.style.cssText = 'padding:0;margin:0;border:0;'; |
385 | 347 | zp_container.appendChild( zp_clip ); |
386 | 348 | zp.insertBefore( zp_container, zp.firstChild ); |
387 | | - } ); |
| 349 | + } |
388 | 350 | } |
389 | 351 | |
390 | 352 | /******************************** |
— | — | @@ -570,7 +532,7 @@ |
571 | 533 | boxHeight + 'px;background:#000000;'; |
572 | 534 | } |
573 | 535 | } |
574 | | - if( evt.preventDefault ) { |
| 536 | + if ( evt.preventDefault ) { |
575 | 537 | evt.preventDefault(); |
576 | 538 | } |
577 | 539 | evt.returnValue = false; |
— | — | @@ -594,7 +556,7 @@ |
595 | 557 | } |
596 | 558 | |
597 | 559 | self.pr_zoom = function( delta ) { |
598 | | - if( delta == 0 ) { |
| 560 | + if ( delta == 0 ) { |
599 | 561 | // reduce width by 20 pixels in order to prevent horizontal scrollbar |
600 | 562 | // from showing up |
601 | 563 | pr_set_margins( 0, 0, pr_container.offsetWidth - 20 ); |
— | — | @@ -625,10 +587,10 @@ |
626 | 588 | return false; |
627 | 589 | } |
628 | 590 | var delta = 0; |
629 | | - if( evt.wheelDelta ) { |
| 591 | + if ( evt.wheelDelta ) { |
630 | 592 | /* IE/Opera. */ |
631 | 593 | delta = evt.wheelDelta / 120; |
632 | | - } else if( evt.detail ) { |
| 594 | + } else if ( evt.detail ) { |
633 | 595 | /** |
634 | 596 | * Mozilla case. |
635 | 597 | * In Mozilla, sign of delta is different than in IE. |
— | — | @@ -704,9 +666,9 @@ |
705 | 667 | pr_zoom( 0 ); |
706 | 668 | } |
707 | 669 | |
708 | | -function pr_load_image( url ) { |
| 670 | +function pr_load_image( ) { |
709 | 671 | pr_container.innerHTML = '<img id="ProofReadImage" src="' + |
710 | | - escapeQuotesHTML( url ) + '" width="' + img_width + '" />'; |
| 672 | + escapeQuotesHTML( self.proofreadPageViewURL ) + '" width="' + img_width + '" />'; |
711 | 673 | pr_zoom( 0 ); |
712 | 674 | } |
713 | 675 | |
— | — | @@ -742,16 +704,15 @@ |
743 | 705 | |
744 | 706 | // fill the image container |
745 | 707 | if( !proofreadPageIsEdit ) { |
746 | | - pr_fetch_thumb_url( parseInt( pr_width / 2 - 70 ), function( url, width, height ) { |
747 | | - var image = document.createElement( 'img' ); |
748 | | - image.setAttribute( 'id', 'ProofReadImage' ); |
749 | | - image.setAttribute( 'src', url ); |
750 | | - image.setAttribute( 'width', width ); |
751 | | - image.style.cssText = 'padding:0;margin:0;border:0;'; |
752 | | - pr_container.appendChild( image ); |
753 | | - pr_container.style.cssText = 'overflow:hidden;width:' + width + 'px;'; |
754 | | - pr_initzoom( width, height ); |
755 | | - } ); |
| 708 | + // this sets DisplayWidth and DisplayHeight |
| 709 | + var thumb_url = pr_image_url( parseInt( pr_width / 2 - 70 ) ); |
| 710 | + var image = document.createElement( 'img' ); |
| 711 | + image.setAttribute( 'id', 'ProofReadImage' ); |
| 712 | + image.setAttribute( 'src', thumb_url ); |
| 713 | + image.setAttribute( 'width', self.DisplayWidth ); |
| 714 | + image.style.cssText = 'padding:0;margin:0;border:0;'; |
| 715 | + pr_container.appendChild( image ); |
| 716 | + pr_container.style.cssText = 'overflow:hidden;width:' + self.DisplayWidth + 'px;'; |
756 | 717 | } else { |
757 | 718 | var w = parseInt( self.proofreadPageEditWidth ); |
758 | 719 | if( !w ) { |
— | — | @@ -760,20 +721,17 @@ |
761 | 722 | if( !w ) { |
762 | 723 | w = 1024; /* Default size in edit mode */ |
763 | 724 | } |
764 | | - |
| 725 | + self.proofreadPageViewURL = pr_image_url( Math.min( w, self.proofreadPageWidth ) ); |
765 | 726 | // prevent the container from being resized once the image is downloaded. |
766 | 727 | img_width = pr_horiz ? 0 : parseInt( pr_width / 2 - 70 ) - 20; |
767 | 728 | pr_container.onmousedown = pr_grab; |
768 | 729 | pr_container.onmousemove = pr_move; |
769 | | - if( pr_container.addEventListener ) { |
| 730 | + if ( pr_container.addEventListener ) { |
770 | 731 | pr_container.addEventListener( 'DOMMouseScroll', pr_zoom_wheel, false ); |
771 | 732 | } |
772 | 733 | pr_container.onmousewheel = pr_zoom_wheel; // IE, Opera. |
773 | | - |
774 | | - pr_fetch_thumb_url( Math.min( w, self.proofreadPageWidth ), function( url, width, height ) { |
775 | | - // Load the image after page setup, so that user-defined hooks do not have to wait for it. |
776 | | - $( function() { pr_load_image( url ) } ); |
777 | | - } ); |
| 734 | + /* Load the image after page setup, so that user-defined hooks do not have to wait for it. */ |
| 735 | + hookEvent( 'load', pr_load_image ); |
778 | 736 | } |
779 | 737 | |
780 | 738 | table.setAttribute( 'id', 'textBoxTable' ); |
— | — | @@ -797,7 +755,7 @@ |
798 | 756 | pr_make_edit_area( self.text_container, new_text.value ); |
799 | 757 | var copywarn = document.getElementById( 'editpage-copywarn' ); |
800 | 758 | f.insertBefore( table, copywarn ); |
801 | | - if( !self.proofreadpage_show_headers ) { |
| 759 | + if ( !self.proofreadpage_show_headers ) { |
802 | 760 | hookEvent( 'load', pr_toggle_visibility ); |
803 | 761 | } else { |
804 | 762 | hookEvent( 'load', pr_reset_size ); |
— | — | @@ -938,36 +896,69 @@ |
939 | 897 | return; |
940 | 898 | } |
941 | 899 | |
942 | | - if( $.inArray( mw.util.getParamValue( 'action' ), ['protect', 'unprotect', 'delete', 'undelete', 'watch', 'unwatch', 'history'] ) > -1 ) { |
| 900 | + if( document.URL.indexOf( 'action=protect' ) > 0 || document.URL.indexOf( 'action=unprotect' ) > 0 ) { |
943 | 901 | return; |
944 | 902 | } |
| 903 | + if( document.URL.indexOf( 'action=delete' ) > 0 || document.URL.indexOf( 'action=undelete' ) > 0 ) { |
| 904 | + return; |
| 905 | + } |
| 906 | + if( document.URL.indexOf( 'action=watch' ) > 0 || document.URL.indexOf( 'action=unwatch' ) > 0 ) { |
| 907 | + return; |
| 908 | + } |
| 909 | + if( document.URL.indexOf( 'action=history' ) > 0 ) { |
| 910 | + return; |
| 911 | + } |
945 | 912 | |
946 | | - if( mw.config.get( 'proofreadPageFileName' ) == null ) { |
947 | | - // File does not exist |
| 913 | + /* check if external URL is provided */ |
| 914 | + if( !self.proofreadPageThumbURL ) { |
| 915 | + var text = document.getElementById( 'wpTextbox1' ); |
| 916 | + if ( text ) { |
| 917 | + var proofreadPageIsEdit = true; |
| 918 | + re = /<span class="hiddenStructure" id="pageURL">\[http:\/\/(.*?)\]<\/span>/; |
| 919 | + m = re.exec( text.value ); |
| 920 | + if( m ) { |
| 921 | + self.proofreadPageExternalURL = 'http://' + m[1]; |
| 922 | + } |
| 923 | + } else { |
| 924 | + var proofreadPageIsEdit = false; |
| 925 | + text = document.getElementById( 'bodyContent' ); |
| 926 | + try { |
| 927 | + var a = document.getElementById( 'pageURL' ); |
| 928 | + var b = a.firstChild; |
| 929 | + self.proofreadPageExternalURL = b.getAttribute( 'href' ); |
| 930 | + } catch( err ) { |
| 931 | + }; |
| 932 | + } |
| 933 | + // set to dummy values, not used |
| 934 | + self.proofreadPageWidth = 400; |
| 935 | + self.proofreadPageHeight = 400; |
| 936 | + } |
| 937 | + |
| 938 | + if( !self.proofreadPageThumbURL ) { |
948 | 939 | return; |
949 | 940 | } |
950 | 941 | |
951 | 942 | if( self.proofreadpage_setup ) { |
952 | | - // Run site/user setup code |
953 | 943 | proofreadpage_setup( |
954 | | - mw.config.get( 'proofreadPageWidth' ), |
955 | | - mw.config.get( 'proofreadPageHeight' ), |
956 | | - mw.config.get( 'proofreadPageIsEdit' ) |
| 944 | + proofreadPageWidth, |
| 945 | + proofreadPageHeight, |
| 946 | + proofreadPageIsEdit |
957 | 947 | ); |
958 | 948 | } else { |
959 | | - // Run extension setup code |
960 | 949 | pr_setup(); |
961 | 950 | } |
962 | 951 | |
963 | 952 | // add CSS classes to the container div |
964 | | - if( mw.config.get( 'proofreadPageCss' ) != null ) { |
965 | | - $( 'div.pagetext' ).addClass( mw.config.get( 'proofreadPageCss' ) ); |
| 953 | + if( self.proofreadPageCss) { |
| 954 | + $( 'div.pagetext' ).addClass( self.proofreadPageCss ); |
966 | 955 | } |
967 | 956 | } |
968 | 957 | |
969 | 958 | $(document).ready( pr_init ); |
970 | 959 | $(document).ready( pr_init_tabs ); |
| 960 | +$(document).ready( pr_initzoom ); |
971 | 961 | |
| 962 | + |
972 | 963 | /* Quality buttons */ |
973 | 964 | self.pr_add_quality = function( form, value ) { |
974 | 965 | self.proofreadpage_quality = value; |