r60207 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60206‎ | r60207 | r60208 >
Date:16:52, 18 December 2009
Author:thomasv
Status:deferred
Tags:
Comment:
capability to switch between zoom and scroll with mouse wheel
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -33,7 +33,7 @@
3434 $wgSpecialPageGroups['IndexPages'] = 'pages';
3535
3636 # Bump the version number every time you change proofread.js
37 -$wgProofreadPageVersion = 24;
 37+$wgProofreadPageVersion = 25;
3838
3939 # Max width of zoomable image
4040 $wgProofreadPageMaxWidth = 2048;
Index: trunk/extensions/ProofreadPage/proofread.js
@@ -402,8 +402,8 @@
403403 var prev_margin_y = 0;
404404 var init_x = 0;
405405 var init_y = 0;
 406+var is_drag = false;
406407
407 -
408408 function pr_drop(evt){
409409 prev_margin_x = margin_x;
410410 prev_margin_y = margin_y;
@@ -411,6 +411,24 @@
412412 document.onmousemove = null;
413413 document.onmousedown = null;
414414 zp_container.onmousemove = pr_move;
 415+
 416+ var image_container = document.getElementById("pr_container");
 417+ if( is_drag==false ) {
 418+ if( self.container_css.search("overflow:hidden") > -1 ) {
 419+ self.container_css = self.container_css.replace("overflow:hidden","overflow:auto");
 420+ self.container_css = self.container_css.replace("cursor:crosshair","cursor:default");
 421+ image_container.style.cssText = self.container_css;
 422+ if (image_container.removeEventListener)
 423+ image_container.removeEventListener('DOMMouseScroll', pr_zoom_wheel, false);
 424+ } else {
 425+ self.container_css = self.container_css.replace("overflow:auto","overflow:hidden");
 426+ self.container_css = self.container_css.replace("cursor:default","cursor:crosshair");
 427+ image_container.style.cssText = self.container_css;
 428+ if (image_container.addEventListener)
 429+ image_container.addEventListener('DOMMouseScroll', pr_zoom_wheel, false);
 430+ }
 431+ }
 432+ is_drag = false;
415433 return false;
416434 }
417435
@@ -431,7 +449,7 @@
432450 document.onmousemove = pr_drag;
433451 document.onmouseup = pr_drop;
434452 zp_container.onmousemove = pr_drag;
435 -
 453+
436454 if(evt.pageX) {
437455 countoffset();
438456 lastxx=evt.pageX - ffox;
@@ -445,6 +463,7 @@
446464
447465 init_x = lastxx;
448466 init_y = lastyy;
 467+ is_drag = false;
449468
450469 return false;
451470
@@ -467,6 +486,7 @@
468487
469488 if (evt.preventDefault) evt.preventDefault();
470489 evt.returnValue = false;
 490+ is_drag = true;
471491 return false;
472492 }
473493
@@ -579,8 +599,10 @@
580600 }
581601 else {
582602 self.table.appendChild(self.text_container);
583 - var tb = document.getElementById("toolbar");
584 - tb.parentNode.insertBefore(image_container,tb);
 603+ form = document.getElementById("editform");
 604+ tb = document.getElementById("toolbar");
 605+ if(tb) tb.parentNode.insertBefore(image_container,tb);
 606+ else form.parentNode.insertBefore(image_container,form);
585607 }
586608
587609 self.pr_horiz = horizontal_layout;
@@ -618,13 +640,14 @@
619641 self.DisplayHeight = Math.ceil(height*0.85);
620642 self.DisplayWidth = parseInt(width/2-70);
621643 img_w = self.DisplayWidth;
622 - self.container_css = "background:#000000; overflow:hidden; width:"+self.DisplayWidth+"px; height:"+self.DisplayHeight+"px;";
 644+ css_wh = "width:"+self.DisplayWidth+"px; height:"+self.DisplayHeight+"px;";
623645 }
624646 else{
625647 self.DisplayHeight = Math.ceil(height*0.4);
626648 img_w = 0; //prevent the container from being resized when the image is downloaded.
627 - self.container_css = "background:#000000; overflow:auto; width:100%; height:"+self.DisplayHeight+"px;";
 649+ css_wh = "width:100%; height:"+self.DisplayHeight+"px;";
628650 }
 651+ self.container_css = "cursor:default; background:#000000; overflow:auto; " + css_wh;
629652 image_container.innerHTML =
630653 "<img id=\"ProofReadImage\" src=\""
631654 + escapeQuotesHTML(proofreadPageViewURL)
@@ -632,14 +655,7 @@
633656
634657 image_container.style.cssText = self.container_css;
635658 pr_zoom(0);
636 - }
637659
638 - //setup the mouse wheel listener
639 - if(proofreadPageIsEdit) {
640 - if(!horizontal_layout){
641 - if (image_container.addEventListener) image_container.addEventListener('DOMMouseScroll', pr_zoom_wheel, false);
642 - image_container.onmousewheel = pr_zoom_wheel;
643 - }
644660 image_container.onmousedown = pr_grab;
645661 image_container.onmousemove = pr_move;
646662

Status & tagging log