| 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 && ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $out->getTitle()->getPrefixedText(), $m ) ) ) { |
| | 328 | + if ( $isEdit && $out->getTitle()->getNamespace() == self::getIndexNamespaceId() ) { |
| 329 | 329 | self::prepareIndex( $out ); |
| 330 | 330 | return true; |
| 331 | 331 | } |
| — | — | @@ -339,10 +339,13 @@ |
| 340 | 340 | |
| 341 | 341 | private static function prepareIndex( $out ) { |
| 342 | 342 | $out->addModules( 'ext.proofreadpage.index' ); |
| 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' ) ) . "\";" ); |
| | 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 ) ); |
| 347 | 350 | } |
| 348 | 351 | |
| 349 | 352 | private static function preparePage( $out, $m, $isEdit ) { |
| — | — | @@ -357,31 +360,32 @@ |
| 358 | 361 | return true; |
| 359 | 362 | } |
| 360 | 363 | |
| | 364 | + $fileName = null; |
| | 365 | + $filePage = null; |
| | 366 | + $fileWidth = 0; |
| | 367 | + $fileHeight = 0; |
| | 368 | + $fileFullUrl = null; |
| | 369 | + $scanLink = null; |
| | 370 | + |
| 361 | 371 | $image = wfFindFile( $imageTitle ); |
| | 372 | + |
| 362 | 373 | if ( $image && $image->exists() ) { |
| 363 | | - $width = $image->getWidth(); |
| 364 | | - $height = $image->getHeight(); |
| | 374 | + $fileName = $imageTitle->getPrefixedText(); |
| | 375 | + $fileWidth = $image->getWidth(); |
| | 376 | + $fileHeight = $image->getHeight(); |
| | 377 | + |
| 365 | 378 | if ( $m[2] ) { |
| 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 ); |
| | 379 | + $filePage = $m[3]; |
| | 380 | + |
| | 381 | + $thumbName = $image->thumbName( array( 'width' => $fileWidth, 'page' => $filePage ) ); |
| | 382 | + $fileFullUrl = $image->getThumbUrl( $thumbName ); |
| 370 | 383 | } else { |
| 371 | | - $thumbName = $image->thumbName( array( 'width' => '##WIDTH##' ) ); |
| 372 | | - $thumbURL = $image->getThumbUrl( $thumbName ); |
| 373 | | - $thumbURL = str_replace( '%23', '#', $thumbURL ); |
| 374 | | - $fullURL = $image->getURL(); |
| | 384 | + $fileFullUrl = $image->getViewURL(); |
| 375 | 385 | } |
| 376 | | - $scan_link = Html::element( 'a', |
| 377 | | - array( 'href' => $fullURL, |
| 378 | | - 'title' => wfMsg( 'proofreadpage_image' ) ), |
| | 386 | + $scanLink = Html::element( 'a', |
| | 387 | + array( 'href' => $fileFullUrl, |
| | 388 | + 'title' => wfMsg( 'proofreadpage_image' ) ), |
| 379 | 389 | wfMsg( 'proofreadpage_image' ) ); |
| 380 | | - } else { |
| 381 | | - $width = 0; |
| 382 | | - $height = 0; |
| 383 | | - $thumbURL = ''; |
| 384 | | - $fullURL = ''; |
| 385 | | - $scan_link = ''; |
| 386 | 390 | } |
| 387 | 391 | |
| 388 | 392 | list( $index_title, $prev_title, $next_title, $header, $footer, $css, $edit_width ) = self::navigation( $out->getTitle() ); |
| — | — | @@ -389,32 +393,33 @@ |
| 390 | 394 | $sk = $wgUser->getSkin(); |
| 391 | 395 | $path = $wgExtensionAssetsPath . '/ProofreadPage'; |
| 392 | 396 | |
| 393 | | - $next_link = $next_title ? $sk->link( $next_title, |
| | 397 | + $nextLink = $next_title ? $sk->link( $next_title, |
| 394 | 398 | Html::element( 'img', array( 'src' => $path . '/rightarrow.png', |
| 395 | 399 | 'alt' => wfMsg( 'proofreadpage_nextpage' ), 'width' => 15, 'height' => 15 ) ), |
| 396 | | - array( 'title' => wfMsg( 'proofreadpage_nextpage' ) ) ) : ''; |
| | 400 | + array( 'title' => wfMsg( 'proofreadpage_nextpage' ) ) ) : null; |
| 397 | 401 | |
| 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' ) ) ): ''; |
| | 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; |
| 402 | 406 | |
| 403 | | - $index_link = $index_title ? $sk->link( $index_title, |
| 404 | | - Html::element( 'img', array( 'src' => $path . '/uparrow.png', |
| | 407 | + $indexLink = $index_title ? $sk->link( $index_title, |
| | 408 | + Html::element( 'img', array( 'src' => $path . '/uparrow.png', |
| 405 | 409 | 'alt' => wfMsg( 'proofreadpage_index' ), 'width' => 15, 'height' => 15 ) ), |
| 406 | | - array( 'title' => wfMsg( 'proofreadpage_index' ) ) ) : ''; |
| | 410 | + array( 'title' => wfMsg( 'proofreadpage_index' ) ) ) : null; |
| 407 | 411 | |
| 408 | 412 | $jsVars = array( |
| 409 | | - 'proofreadPageWidth' => intval( $width ), |
| 410 | | - 'proofreadPageHeight' => intval( $height ), |
| | 413 | + 'proofreadPageWidth' => intval( $fileWidth ), |
| | 414 | + 'proofreadPageHeight' => intval( $fileHeight ), |
| 411 | 415 | 'proofreadPageEditWidth' => $edit_width, |
| 412 | | - 'proofreadPageThumbURL' => $thumbURL, |
| 413 | | - 'proofreadPageURL' => $fullURL, |
| | 416 | + 'proofreadPageURL' => $fileFullUrl, |
| | 417 | + 'proofreadPageFileName' => $fileName, |
| | 418 | + 'proofreadPageFilePage' => $filePage, |
| 414 | 419 | 'proofreadPageIsEdit' => intval( $isEdit ), |
| 415 | | - 'proofreadPageIndexLink' => $index_link, |
| 416 | | - 'proofreadPageNextLink' => $next_link, |
| 417 | | - 'proofreadPagePrevLink' => $prev_link, |
| 418 | | - 'proofreadPageScanLink' => $scan_link, |
| | 420 | + 'proofreadPageIndexLink' => $indexLink, |
| | 421 | + 'proofreadPageNextLink' => $nextLink, |
| | 422 | + 'proofreadPagePrevLink' => $prevLink, |
| | 423 | + 'proofreadPageScanLink' => $scanLink, |
| 419 | 424 | 'proofreadPageHeader' => $header, |
| 420 | 425 | 'proofreadPageFooter' => $footer, |
| 421 | 426 | 'proofreadPageAddButtons' => $wgUser->isAllowed( 'pagequality' ), |
| — | — | @@ -852,7 +857,7 @@ |
| 853 | 858 | null, |
| 854 | 859 | array( 'categorylinks' => array( 'LEFT JOIN', 'cl_from=page_id' ) ) |
| 855 | 860 | ); |
| 856 | | - |
| | 861 | + |
| 857 | 862 | if( $res ) { |
| 858 | 863 | foreach ( $res as $o ) { |
| 859 | 864 | array_push( $q0_pages, $o->page_title ); |
| — | — | @@ -1544,7 +1549,7 @@ |
| 1545 | 1550 | if( $indextitle ) { |
| 1546 | 1551 | $sk = $wgUser->getSkin(); |
| 1547 | 1552 | $nt = Title::makeTitleSafe( $index_ns_index, $indextitle ); |
| 1548 | | - $indexlink = $sk->link( $nt, wfMsg( 'proofreadpage_source' ), |
| | 1553 | + $indexlink = $sk->link( $nt, wfMsg( 'proofreadpage_source' ), |
| 1549 | 1554 | array( 'title' => wfMsg( 'proofreadpage_source_message' ) ) ); |
| 1550 | 1555 | $out->addInlineScript( ResourceLoader::makeConfigSetScript( array( 'proofreadpage_source_href' => $indexlink ) ) ); |
| 1551 | 1556 | $out->addModules( 'ext.proofreadpage.article' ); |
| Index: trunk/extensions/ProofreadPage/proofread.js |
| — | — | @@ -1,30 +1,70 @@ |
| 2 | 2 | // Author : ThomasV - License : GPL |
| 3 | 3 | |
| 4 | 4 | function pr_init_tabs() { |
| 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>' ); |
| | 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 | + } |
| 9 | 17 | } |
| 10 | 18 | |
| 11 | | -function pr_image_url( requested_width ) { |
| 12 | | - if( self.proofreadPageExternalURL ) { |
| 13 | | - self.DisplayWidth = requested_width; |
| 14 | | - self.DisplayHeight = ''; |
| 15 | | - return self.proofreadPageExternalURL; |
| | 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 | + }); |
| 16 | 66 | } else { |
| 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 | | - } |
| | 67 | + // Image without scaling |
| | 68 | + callback( mw.config.get( 'proofreadPageURL' ), fullWidth, fullHeight ); |
| 29 | 69 | } |
| 30 | 70 | } |
| 31 | 71 | |
| — | — | @@ -90,7 +130,7 @@ |
| 91 | 131 | } |
| 92 | 132 | self.proofreadpage_username = m4[2]; |
| 93 | 133 | pageHeader = pageHeader.replace( reg, '' ); |
| 94 | | - } else if ( old_m4 ) { |
| | 134 | + } else if( old_m4 ) { |
| 95 | 135 | switch( old_m4[1] ) { |
| 96 | 136 | case '0': |
| 97 | 137 | self.proofreadpage_quality = 0; |
| — | — | @@ -142,6 +182,7 @@ |
| 143 | 183 | var box = document.getElementById( 'wpTextbox1' ); |
| 144 | 184 | var h = document.getElementById( 'prp_header' ); |
| 145 | 185 | var f = document.getElementById( 'prp_footer' ); |
| | 186 | + |
| 146 | 187 | if( h.style.cssText == 'display:none;' ) { |
| 147 | 188 | box.style.cssText = 'height:' + ( self.DisplayHeight - 6 ) + 'px'; |
| 148 | 189 | } else { |
| — | — | @@ -317,35 +358,32 @@ |
| 318 | 359 | return false; |
| 319 | 360 | } |
| 320 | 361 | |
| | 362 | +//zoom using two images (magnification glass) |
| | 363 | +function pr_initzoom( width, height ) { |
| | 364 | + var maxWidth = 800; |
| 321 | 365 | |
| 322 | | -//zoom using two images (magnification glass) |
| 323 | | -function pr_initzoom() { |
| 324 | | - if( proofreadPageIsEdit ) { |
| | 366 | + if( width > maxWidth ) { |
| 325 | 367 | return; |
| 326 | 368 | } |
| 327 | | - if( !self.proofreadPageThumbURL ) { |
| | 369 | + |
| | 370 | + zp = document.getElementById( 'pr_container' ); |
| | 371 | + if( !zp ) { |
| 328 | 372 | return; |
| 329 | 373 | } |
| 330 | | - if( self.DisplayWidth > 800 ) { |
| 331 | | - return; |
| 332 | | - } |
| | 374 | + pr_fetch_thumb_url( maxWidth, function( largeUrl, largeWidth, largeHeight ) { |
| | 375 | + self.objw = width; |
| | 376 | + self.objh = height; |
| 333 | 377 | |
| 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 | | - |
| 340 | 378 | zp.onmouseup = zoom_mouseup; |
| 341 | 379 | zp.onmousemove = zoom_move; |
| 342 | 380 | zp_container = document.createElement( 'div' ); |
| 343 | 381 | zp_container.style.cssText = 'position:absolute; width:0; height:0; overflow:hidden;'; |
| 344 | 382 | zp_clip = document.createElement( 'img' ); |
| 345 | | - zp_clip.setAttribute( 'src', hires_url ); |
| | 383 | + zp_clip.setAttribute( 'src', largeUrl ); |
| 346 | 384 | zp_clip.style.cssText = 'padding:0;margin:0;border:0;'; |
| 347 | 385 | zp_container.appendChild( zp_clip ); |
| 348 | 386 | zp.insertBefore( zp_container, zp.firstChild ); |
| 349 | | - } |
| | 387 | + } ); |
| 350 | 388 | } |
| 351 | 389 | |
| 352 | 390 | /******************************** |
| — | — | @@ -532,7 +570,7 @@ |
| 533 | 571 | boxHeight + 'px;background:#000000;'; |
| 534 | 572 | } |
| 535 | 573 | } |
| 536 | | - if ( evt.preventDefault ) { |
| | 574 | + if( evt.preventDefault ) { |
| 537 | 575 | evt.preventDefault(); |
| 538 | 576 | } |
| 539 | 577 | evt.returnValue = false; |
| — | — | @@ -556,7 +594,7 @@ |
| 557 | 595 | } |
| 558 | 596 | |
| 559 | 597 | self.pr_zoom = function( delta ) { |
| 560 | | - if ( delta == 0 ) { |
| | 598 | + if( delta == 0 ) { |
| 561 | 599 | // reduce width by 20 pixels in order to prevent horizontal scrollbar |
| 562 | 600 | // from showing up |
| 563 | 601 | pr_set_margins( 0, 0, pr_container.offsetWidth - 20 ); |
| — | — | @@ -587,10 +625,10 @@ |
| 588 | 626 | return false; |
| 589 | 627 | } |
| 590 | 628 | var delta = 0; |
| 591 | | - if ( evt.wheelDelta ) { |
| | 629 | + if( evt.wheelDelta ) { |
| 592 | 630 | /* IE/Opera. */ |
| 593 | 631 | delta = evt.wheelDelta / 120; |
| 594 | | - } else if ( evt.detail ) { |
| | 632 | + } else if( evt.detail ) { |
| 595 | 633 | /** |
| 596 | 634 | * Mozilla case. |
| 597 | 635 | * In Mozilla, sign of delta is different than in IE. |
| — | — | @@ -666,9 +704,9 @@ |
| 667 | 705 | pr_zoom( 0 ); |
| 668 | 706 | } |
| 669 | 707 | |
| 670 | | -function pr_load_image( ) { |
| | 708 | +function pr_load_image( url ) { |
| 671 | 709 | pr_container.innerHTML = '<img id="ProofReadImage" src="' + |
| 672 | | - escapeQuotesHTML( self.proofreadPageViewURL ) + '" width="' + img_width + '" />'; |
| | 710 | + escapeQuotesHTML( url ) + '" width="' + img_width + '" />'; |
| 673 | 711 | pr_zoom( 0 ); |
| 674 | 712 | } |
| 675 | 713 | |
| — | — | @@ -704,15 +742,16 @@ |
| 705 | 743 | |
| 706 | 744 | // fill the image container |
| 707 | 745 | if( !proofreadPageIsEdit ) { |
| 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;'; |
| | 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 | + } ); |
| 717 | 756 | } else { |
| 718 | 757 | var w = parseInt( self.proofreadPageEditWidth ); |
| 719 | 758 | if( !w ) { |
| — | — | @@ -721,17 +760,20 @@ |
| 722 | 761 | if( !w ) { |
| 723 | 762 | w = 1024; /* Default size in edit mode */ |
| 724 | 763 | } |
| 725 | | - self.proofreadPageViewURL = pr_image_url( Math.min( w, self.proofreadPageWidth ) ); |
| | 764 | + |
| 726 | 765 | // prevent the container from being resized once the image is downloaded. |
| 727 | 766 | img_width = pr_horiz ? 0 : parseInt( pr_width / 2 - 70 ) - 20; |
| 728 | 767 | pr_container.onmousedown = pr_grab; |
| 729 | 768 | pr_container.onmousemove = pr_move; |
| 730 | | - if ( pr_container.addEventListener ) { |
| | 769 | + if( pr_container.addEventListener ) { |
| 731 | 770 | pr_container.addEventListener( 'DOMMouseScroll', pr_zoom_wheel, false ); |
| 732 | 771 | } |
| 733 | 772 | pr_container.onmousewheel = pr_zoom_wheel; // IE, Opera. |
| 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 ); |
| | 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 | + } ); |
| 736 | 778 | } |
| 737 | 779 | |
| 738 | 780 | table.setAttribute( 'id', 'textBoxTable' ); |
| — | — | @@ -755,7 +797,7 @@ |
| 756 | 798 | pr_make_edit_area( self.text_container, new_text.value ); |
| 757 | 799 | var copywarn = document.getElementById( 'editpage-copywarn' ); |
| 758 | 800 | f.insertBefore( table, copywarn ); |
| 759 | | - if ( !self.proofreadpage_show_headers ) { |
| | 801 | + if( !self.proofreadpage_show_headers ) { |
| 760 | 802 | hookEvent( 'load', pr_toggle_visibility ); |
| 761 | 803 | } else { |
| 762 | 804 | hookEvent( 'load', pr_reset_size ); |
| — | — | @@ -896,69 +938,36 @@ |
| 897 | 939 | return; |
| 898 | 940 | } |
| 899 | 941 | |
| 900 | | - if( document.URL.indexOf( 'action=protect' ) > 0 || document.URL.indexOf( 'action=unprotect' ) > 0 ) { |
| | 942 | + if( $.inArray( mw.util.getParamValue( 'action' ), ['protect', 'unprotect', 'delete', 'undelete', 'watch', 'unwatch', 'history'] ) > -1 ) { |
| 901 | 943 | return; |
| 902 | 944 | } |
| 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 | | - } |
| 912 | 945 | |
| 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 ) { |
| | 946 | + if( mw.config.get( 'proofreadPageFileName' ) == null ) { |
| | 947 | + // File does not exist |
| 939 | 948 | return; |
| 940 | 949 | } |
| 941 | 950 | |
| 942 | 951 | if( self.proofreadpage_setup ) { |
| | 952 | + // Run site/user setup code |
| 943 | 953 | proofreadpage_setup( |
| 944 | | - proofreadPageWidth, |
| 945 | | - proofreadPageHeight, |
| 946 | | - proofreadPageIsEdit |
| | 954 | + mw.config.get( 'proofreadPageWidth' ), |
| | 955 | + mw.config.get( 'proofreadPageHeight' ), |
| | 956 | + mw.config.get( 'proofreadPageIsEdit' ) |
| 947 | 957 | ); |
| 948 | 958 | } else { |
| | 959 | + // Run extension setup code |
| 949 | 960 | pr_setup(); |
| 950 | 961 | } |
| 951 | 962 | |
| 952 | 963 | // add CSS classes to the container div |
| 953 | | - if( self.proofreadPageCss) { |
| 954 | | - $( 'div.pagetext' ).addClass( self.proofreadPageCss ); |
| | 964 | + if( mw.config.get( 'proofreadPageCss' ) != null ) { |
| | 965 | + $( 'div.pagetext' ).addClass( mw.config.get( 'proofreadPageCss' ) ); |
| 955 | 966 | } |
| 956 | 967 | } |
| 957 | 968 | |
| 958 | 969 | $(document).ready( pr_init ); |
| 959 | 970 | $(document).ready( pr_init_tabs ); |
| 960 | | -$(document).ready( pr_initzoom ); |
| 961 | 971 | |
| 962 | | - |
| 963 | 972 | /* Quality buttons */ |
| 964 | 973 | self.pr_add_quality = function( form, value ) { |
| 965 | 974 | self.proofreadpage_quality = value; |