r50361 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50360‎ | r50361 | r50362 >
Date:10:16, 9 May 2009
Author:thomasv
Status:ok
Tags:
Comment:
simplification
Modified paths:
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/proofread.js
@@ -173,11 +173,11 @@
174174 if( h.style.cssText == ''){
175175 h.style.cssText = 'display:none';
176176 f.style.cssText = 'display:none';
177 - if(self.vertHeight) box.style.cssText = "height:"+(vertHeight-7)+"px";
 177+ if(self.DisplayHeight) box.style.cssText = "height:"+(self.DisplayHeight-7)+"px";
178178 } else {
179179 h.style.cssText = '';
180180 f.style.cssText = '';
181 - if(self.vertHeight) box.style.cssText = "height:"+(vertHeight-190)+"px";
 181+ if(self.DisplayHeight) box.style.cssText = "height:"+(self.DisplayHeight-190)+"px";
182182 }
183183 }
184184
@@ -448,7 +448,7 @@
449449
450450 function pr_zoom(delta){
451451
452 - image_container = document.getElementById("pr_container");
 452+ var image_container = document.getElementById("pr_container");
453453 zp_img = document.getElementById("ProofReadImage");
454454 if(!zp_img) return;
455455
@@ -529,7 +529,6 @@
530530 //create image container
531531 var image_container = document.createElement("div");
532532 image_container.setAttribute("id", "pr_container");
533 - image_container.style.cssText = "background:#0000ff; overflow:hidden;";
534533
535534 //setup the layout
536535 if(!horizontal_layout) {
@@ -560,54 +559,49 @@
561560
562561 self.pr_horiz = horizontal_layout;
563562
564 - //compute the dimensions of the image container
565 - if(!horizontal_layout){
566 -
567 - var desired_width = 400;
568 - if (parseInt(navigator.appVersion)>3) {
569 - if (navigator.appName.indexOf("Microsoft")!=-1)
570 - desired_width = parseInt(document.body.offsetWidth/2-70);
571 - else
572 - desired_width = parseInt(window.innerWidth/2-70);
 563+ //get the size of the window
 564+ var width, height;
 565+ if (parseInt(navigator.appVersion)>3) {
 566+ if (navigator.appName.indexOf("Microsoft")!=-1) {
 567+ height = document.body.clientHeight;
 568+ width = document.body.offsetWidth;
573569 }
574 - //this sets DisplayWidth and DisplayHeight
575 - var thumb_url = pr_image_url(desired_width);
576 -
577 - //self.DisplayHeight is known if the image is not external
578 - if(self.DisplayHeight)
579 - self.vertHeight = self.DisplayHeight;
580 - else
581 - self.vertHeight = 700;
 570+ else{
 571+ height = window.innerHeight;
 572+ width = window.innerWidth;
 573+ }
582574 }
583 - else{
584 - if (navigator.appName.indexOf("Microsoft")!=-1)
585 - self.vertHeight = Math.ceil(document.body.clientHeight*0.4);
586 - else
587 - self.vertHeight = Math.ceil(window.innerHeight*0.4);
 575+ else {
 576+ width = 800; height = 600;
588577 }
589578
590 -
591579 //fill the image container
592580 if(!proofreadPageIsEdit) {
 581+ //this sets DisplayWidth and DisplayHeight
 582+ var thumb_url = pr_image_url(parseInt(width/2-70));
593583 var image = document.createElement("img");
594584 image_container.appendChild(image);
595585 image.setAttribute("id", "ProofReadImage");
596586 image.setAttribute("src", thumb_url);
597587 image.setAttribute("width", self.DisplayWidth);
598588 image.style.cssText = "padding:0;margin:0;border:0;";
 589+ image_container.style.cssText = "background:#0000ff; overflow:hidden;width:"+self.DisplayWidth+"px;";
599590 }
600591 else{
601592 if(!horizontal_layout){
 593+ self.DisplayHeight = Math.ceil(height*0.9);
 594+ self.DisplayWidth = parseInt(width/2-70);
602595 img_w = self.DisplayWidth;
603 - self.container_css = "background:#000000; overflow:hidden; width:"+self.DisplayWidth+"px; height:"+self.vertHeight+"px;";
 596+ self.container_css = "background:#000000; overflow:hidden; width:"+self.DisplayWidth+"px; height:"+self.DisplayHeight+"px;";
604597 }
605598 else{
 599+ self.DisplayHeight = Math.ceil(height*0.4);
606600 img_w = 0; //prevent the container from being resized when the image is downloaded.
607 - self.container_css = "background:#000000; overflow:auto; width:100%; height:"+self.vertHeight+"px;";
 601+ self.container_css = "background:#000000; overflow:auto; width:100%; height:"+self.DisplayHeight+"px;";
608602 }
609603 image_container.innerHTML = "<img id=\"ProofReadImage\" src=\""+proofreadPageViewURL+"\" width=\""+img_w+"\" />";
610604 image_container.style.cssText = self.container_css;
611 - document.getElementById("wpTextbox1").style.cssText = "height:"+self.vertHeight+"px";
 605+ document.getElementById("wpTextbox1").style.cssText = "height:"+self.DisplayHeight+"px";
612606 pr_zoom(0);
613607 }
614608
@@ -818,9 +812,9 @@
819813 function pr_initzoom(){
820814 if(document.getElementById("wpTextbox1")){
821815 if(self.pr_horiz)
822 - document.getElementById("wpTextbox1").style.cssText = "height:"+self.vertHeight+"px";
 816+ document.getElementById("wpTextbox1").style.cssText = "height:"+self.DisplayHeight+"px";
823817 else
824 - document.getElementById("wpTextbox1").style.cssText = "height:"+self.vertHeight+"px";
 818+ document.getElementById("wpTextbox1").style.cssText = "height:"+self.DisplayHeight+"px";
825819 pr_zoom(0);
826820 }
827821 else proofreadPageZoom();

Status & tagging log