Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -397,6 +397,7 @@ |
398 | 398 | var is_drag = false; |
399 | 399 | var is_zoom = false; |
400 | 400 | var pr_container = false; |
| 401 | +var pr_rect = false; |
401 | 402 | |
402 | 403 | /* size of the window */ |
403 | 404 | var pr_width = 0, pr_height = 0; |
— | — | @@ -429,8 +430,20 @@ |
430 | 431 | pr_container.onmousemove = pr_move; |
431 | 432 | if( is_drag==false ) { |
432 | 433 | is_zoom = !is_zoom; |
| 434 | + } else { |
| 435 | + if(is_zoom) { |
| 436 | + is_zoom=false; |
| 437 | + if(boxWidth*boxWidth+boxHeight*boxHeight >= 2500){ |
| 438 | + var zp_img = document.getElementById("ProofReadImage"); |
| 439 | + ratio_x = Math.abs( pr_container.offsetWidth/self.boxWidth ); |
| 440 | + zp_img.width = zp_img.width*ratio_x; |
| 441 | + pr_container.scrollLeft = (pr_container.scrollLeft + xMin)*ratio_x; |
| 442 | + pr_container.scrollTop = (pr_container.scrollTop + yMin)*ratio_x; |
| 443 | + } |
| 444 | + } |
433 | 445 | } |
434 | 446 | is_drag = false; |
| 447 | + pr_rect.style.cssText = "display:none"; |
435 | 448 | set_container_css(!is_zoom,!is_zoom); |
436 | 449 | return false; |
437 | 450 | } |
— | — | @@ -482,12 +495,33 @@ |
483 | 496 | evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
484 | 497 | get_xy(evt); if(xx>pr_container.offsetWidth-20 || yy>pr_container.offsetHeight-20) return false; |
485 | 498 | |
486 | | - pr_container.scrollLeft = (init_x-xx); |
487 | | - pr_container.scrollTop = (init_y-yy); |
| 499 | + if(!is_zoom) { |
| 500 | + pr_container.scrollLeft = (init_x-xx); |
| 501 | + pr_container.scrollTop = (init_y-yy); |
| 502 | + } else { |
| 503 | + self.xMin = Math.min( init_x - pr_container.scrollLeft, xx ); |
| 504 | + self.yMin = Math.min( init_y - pr_container.scrollTop , yy ); |
| 505 | + self.xMax = Math.max( init_x - pr_container.scrollLeft, xx ); |
| 506 | + self.yMax = Math.max( init_y - pr_container.scrollTop , yy ); |
| 507 | + self.boxWidth = Math.max( xMax-xMin, 1 ); |
| 508 | + self.boxHeight = Math.max( yMax-yMin, 1 ); |
| 509 | + if(boxWidth*boxWidth+boxHeight*boxHeight < 2500){ |
| 510 | + pr_rect.style.cssText = "display:none;"; |
| 511 | + } else { |
| 512 | + ratio = pr_container.offsetWidth/pr_container.offsetHeight; |
| 513 | + if(boxWidth/boxHeight < ratio ) { |
| 514 | + boxWidth = boxHeight*ratio; |
| 515 | + if(xx==xMin) xMin = init_x - pr_container.scrollLeft - boxWidth; |
| 516 | + } else { |
| 517 | + boxHeight = boxWidth/ratio; |
| 518 | + if(yy==yMin) yMin = init_y - pr_container.scrollTop - boxHeight; |
| 519 | + } |
| 520 | + pr_rect.style.cssText = "cursor:crosshair;opacity:0.5;position:absolute;left:"+ xMin +"px;top:"+ yMin +"px;width:"+boxWidth+"px;height:"+boxHeight+"px;background:#000000;"; |
| 521 | + } |
| 522 | + } |
488 | 523 | if (evt.preventDefault) evt.preventDefault(); |
489 | 524 | evt.returnValue = false; |
490 | 525 | is_drag = true; |
491 | | - set_container_css(true,!is_zoom); |
492 | 526 | return false; |
493 | 527 | } |
494 | 528 | |
— | — | @@ -522,7 +556,6 @@ |
523 | 557 | pr_container.scrollTop = Math.round(lambda*pty - yy); |
524 | 558 | } |
525 | 559 | } |
526 | | - |
527 | 560 | } |
528 | 561 | } |
529 | 562 | |
— | — | @@ -541,11 +574,12 @@ |
542 | 575 | delta = -evt.detail/3; |
543 | 576 | } |
544 | 577 | if(is_zoom && delta) { |
545 | | - pr_zoom(delta); |
| 578 | + //disable wheel zoom for IE6. |
| 579 | + if( navigator.appName.indexOf("Microsoft")==-1 || navigator.appVersion.indexOf("MSIE 6.")==-1) |
| 580 | + pr_zoom(delta); |
546 | 581 | if(evt.preventDefault) evt.preventDefault(); |
547 | 582 | evt.returnValue = false; |
548 | 583 | } |
549 | | - |
550 | 584 | } |
551 | 585 | |
552 | 586 | |
— | — | @@ -572,15 +606,14 @@ |
573 | 607 | t_row.setAttribute("valign","top"); |
574 | 608 | cell_left.style.cssText = "width:50%; padding-right:0.5em;vertical-align:top;"; |
575 | 609 | cell_right.setAttribute("rowspan","3"); |
| 610 | + cell_right.style.cssText = "vertical-align:top;"; |
576 | 611 | t_row.appendChild(cell_left); |
577 | 612 | t_row.appendChild(cell_right); |
578 | 613 | t_body.appendChild(t_row); |
579 | | - |
580 | 614 | cell_right.appendChild(pr_container_parent); |
581 | 615 | cell_left.appendChild(self.text_container); |
582 | 616 | self.table.appendChild(t_table); |
583 | | - } |
584 | | - else { |
| 617 | + } else { |
585 | 618 | self.table.appendChild(self.text_container); |
586 | 619 | form = document.getElementById("editform"); |
587 | 620 | tb = document.getElementById("toolbar"); |
— | — | @@ -592,14 +625,14 @@ |
593 | 626 | if(!pr_horiz){ |
594 | 627 | self.DisplayHeight = Math.ceil(pr_height*0.85); |
595 | 628 | self.DisplayWidth = parseInt(pr_width/2-70); |
596 | | - img_w = self.DisplayWidth-20; |
597 | 629 | css_wh = "width:"+self.DisplayWidth+"px; height:"+self.DisplayHeight+"px;"; |
| 630 | + pr_container_parent.style.cssText="position:relative;width:"+self.DisplayWidth+"px;"; |
598 | 631 | } else { |
599 | 632 | self.DisplayHeight = Math.ceil(pr_height*0.4); |
600 | | - img_w = 0; //prevent the container from being resized when the image is downloaded. |
601 | 633 | css_wh = "width:100%; height:"+self.DisplayHeight+"px;"; |
| 634 | + pr_container_parent.style.cssText="position:relative;height:"+self.DisplayHeight+"px;"; |
602 | 635 | } |
603 | | - self.container_css = "cursor:default; background:#000000; overflow:auto; " + css_wh; |
| 636 | + self.container_css = "position:absolute;top:0px;cursor:default; background:#000000; overflow:auto; " + css_wh; |
604 | 637 | pr_container.style.cssText = self.container_css; |
605 | 638 | } |
606 | 639 | pr_zoom(0); |
— | — | @@ -652,16 +685,8 @@ |
653 | 686 | pr_container.appendChild(image); |
654 | 687 | pr_container.style.cssText = "overflow:hidden;width:"+self.DisplayWidth+"px;"; |
655 | 688 | } else { |
656 | | - if(!pr_horiz){ |
657 | | - self.DisplayHeight = Math.ceil(pr_height*0.85); |
658 | | - self.DisplayWidth = parseInt(pr_width/2-70); |
659 | | - img_w = self.DisplayWidth-20; |
660 | | - } |
661 | | - else{ |
662 | | - self.DisplayHeight = Math.ceil(pr_height*0.4); |
663 | | - img_w = 0; //prevent the container from being resized once the image is downloaded. |
664 | | - } |
665 | | - |
| 689 | + //prevent the container from being resized once the image is downloaded. |
| 690 | + img_w = pr_horiz?0:parseInt(pr_width/2-70)-20; |
666 | 691 | pr_container.innerHTML = "<img id=\"ProofReadImage\" src=\"" |
667 | 692 | + escapeQuotesHTML(proofreadPageViewURL) |
668 | 693 | + "\" width=\"" + img_w + "\" />"; |
— | — | @@ -761,14 +786,13 @@ |
762 | 787 | image1.style.cursor = "pointer"; |
763 | 788 | image1.onclick = pr_toggle_layout; |
764 | 789 | |
| 790 | + pr_rect = document.createElement("div"); |
| 791 | + pr_container_parent.appendChild(pr_rect); |
| 792 | + |
765 | 793 | if( (!toolbar) || (self.wgWikiEditorPreferences && self.wgWikiEditorPreferences["toolbar"] ) ) { |
766 | | - var mb = document.createElement("div"); |
767 | | - mb.style.cssText="position:relative;"; |
768 | 794 | toolbar = document.createElement("div"); |
769 | 795 | toolbar.style.cssText="position:absolute;"; |
770 | | - mb.appendChild(toolbar); |
771 | | - var p = pr_container.parentNode; |
772 | | - p.insertBefore(mb,p.firstChild); |
| 796 | + pr_container_parent.appendChild(toolbar); |
773 | 797 | } |
774 | 798 | toolbar.appendChild(image); |
775 | 799 | toolbar.appendChild(image3); |