Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -45,31 +45,24 @@ |
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | | - |
50 | 49 | function pr_image_url(requested_width){ |
51 | | - var image_url; |
| 50 | + var thumb_url; |
52 | 51 | |
53 | 52 | if(self.proofreadPageExternalURL) { |
54 | | - image_url = proofreadPageExternalURL; |
| 53 | + thumb_url = proofreadPageViewURL; |
55 | 54 | } |
56 | 55 | else { |
57 | | - |
58 | 56 | //enforce quantization: width must be multiple of 100px |
59 | 57 | var width = (100*requested_width)/100; |
60 | | - |
| 58 | + //compare to the width of the image |
61 | 59 | if(width < proofreadPageWidth) { |
62 | | - self.DisplayWidth = width; |
63 | | - self.DisplayHeight = width*proofreadPageHeight/proofreadPageWidth; |
64 | | - image_url = proofreadPageThumbURL.replace('##WIDTH##',""+width); |
| 60 | + thumb_url = proofreadPageThumbURL.replace('##WIDTH##',""+width); |
65 | 61 | } |
66 | 62 | else { |
67 | | - self.DisplayWidth = proofreadPageWidth; |
68 | | - self.DisplayHeight = proofreadPageHeight; |
69 | | - image_url = proofreadPageViewURL; |
| 63 | + thumb_url = proofreadPageViewURL; |
70 | 64 | } |
71 | 65 | } |
72 | | - |
73 | | - return image_url; |
| 66 | + return thumb_url; |
74 | 67 | } |
75 | 68 | |
76 | 69 | |
— | — | @@ -187,10 +180,7 @@ |
188 | 181 | var ffox=0; var ffoy=0; |
189 | 182 | |
190 | 183 | |
191 | | -var zoomw=160; |
192 | | -var zoomh=120; |
193 | 184 | |
194 | | - |
195 | 185 | /*relative coordinates of the mouse pointer*/ |
196 | 186 | function get_xy(evt){ |
197 | 187 | if(typeof(evt) == 'object') { |
— | — | @@ -547,9 +537,9 @@ |
548 | 538 | desired_width = parseInt(window.innerWidth/2-70); |
549 | 539 | } |
550 | 540 | } |
551 | | - //this function sets self.DisplayWidth and self.DisplayHeight |
552 | 541 | var thumb_url = pr_image_url(desired_width); |
553 | 542 | |
| 543 | + //self.DisplayHeight is known if the image is not external |
554 | 544 | if(self.DisplayHeight) |
555 | 545 | self.TextBoxHeight = self.DisplayHeight; |
556 | 546 | else |
— | — | @@ -560,14 +550,14 @@ |
561 | 551 | var image = document.createElement("img"); |
562 | 552 | image.setAttribute("src", thumb_url); |
563 | 553 | image.setAttribute("id", "ProofReadImage"); |
| 554 | + image.setAttribute("width", desired_width); |
564 | 555 | image.style.cssText = "padding:0;margin:0;border:0;"; |
565 | 556 | image_container.appendChild(image); |
566 | 557 | } |
567 | 558 | else{ |
568 | | - var image_url = proofreadPageViewURL; |
569 | | - var s = "<div id=\"pr_container\" style=\"background:#000000; overflow: auto; width: 100%; height:"+self.DisplayHeight+"px;\">"; |
570 | | - s = s + "<img id=\"ProofReadImage\" src=\""+ image_url +"\" alt=\""+ image_url +"\""; |
571 | | - s = s + " width=\"" + self.DisplayWidth +"\"></div>"; |
| 559 | + var s = "<div id=\"pr_container\" style=\"background:#000000; overflow: auto; width: "+desired_width+"px;\">"; |
| 560 | + s = s + "<img id=\"ProofReadImage\" src=\""+ proofreadPageViewURL +"\" alt=\""+ proofreadPageViewURL +"\""; |
| 561 | + s = s + " width=\"" + desired_width +"\"></div>"; |
572 | 562 | image_container.innerHTML = s; |
573 | 563 | document.getElementById("wpTextbox1").style.cssText = "height:"+(self.TextBoxHeight-7)+"px"; |
574 | 564 | pr_zoom(0); |
— | — | @@ -582,7 +572,8 @@ |
583 | 573 | else |
584 | 574 | self.vertHeight=Math.ceil(window.innerHeight*0.4); |
585 | 575 | |
586 | | - var s = "<div id=\"pr_container\" style= \"background:#000000; overflow: auto; height: " + self.vertHeight + "px; width: 100%;\">"; |
| 576 | + var s = "<div id=\"pr_container\" style= \"background:#000000; overflow: auto; height: " |
| 577 | + + self.vertHeight + "px; width: 100%;\">"; |
587 | 578 | s = s + "<img id=\"ProofReadImage\" src=\""+ proofreadPageViewURL +"\" alt=\""+ proofreadPageViewURL +"\""; |
588 | 579 | s = s + "\"></div>"; |
589 | 580 | |
— | — | @@ -764,7 +755,8 @@ |
765 | 756 | re = /<span class="hiddenStructure" id="pageURL">\[http:\/\/(.*?)\]<\/span>/; |
766 | 757 | m = re.exec(text.value); |
767 | 758 | if( m ) { |
768 | | - self.proofreadPageExternalURL = "http://"+m[1]; |
| 759 | + self.proofreadPageViewURL = "http://"+m[1]; |
| 760 | + self.proofreadPageExternalURL = true; |
769 | 761 | } |
770 | 762 | } |
771 | 763 | else { |
— | — | @@ -773,7 +765,8 @@ |
774 | 766 | try { |
775 | 767 | var a = document.getElementById("pageURL"); |
776 | 768 | var b = a.firstChild; |
777 | | - self.proofreadPageExternalURL = b.getAttribute("href"); |
| 769 | + self.proofreadPageViewURL = b.getAttribute("href"); |
| 770 | + self.proofreadPageExternalURL = true; |
778 | 771 | } catch(err){}; |
779 | 772 | } |
780 | 773 | //set to dummy values, not used |
— | — | @@ -781,7 +774,7 @@ |
782 | 775 | self.proofreadPageHeight = 400; |
783 | 776 | } |
784 | 777 | |
785 | | - if(!self.proofreadPageViewURL && !self.proofreadPageExternalURL) return; |
| 778 | + if(!self.proofreadPageViewURL) return; |
786 | 779 | |
787 | 780 | if( self.proofreadpage_setup ) { |
788 | 781 | |