r61051 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61050‎ | r61051 | r61052 >
Date:15:34, 14 January 2010
Author:thomasv
Status:ok
Tags:
Comment:
set container css in a separate function; show scrollbars during mouse drag
Modified paths:
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/proofread.js
@@ -401,6 +401,23 @@
402402 /* size of the window */
403403 var pr_width = 0, pr_height = 0;
404404
 405+function set_container_css(show_scrollbars,default_cursor){
 406+ if(show_scrollbars) {
 407+ self.container_css = self.container_css.replace("overflow:hidden","overflow:auto");
 408+ } else {
 409+ self.container_css = self.container_css.replace("overflow:auto","overflow:hidden");
 410+ }
 411+ if(default_cursor) {
 412+ self.container_css = self.container_css.replace("cursor:crosshair","cursor:default");
 413+ } else {
 414+ self.container_css = self.container_css.replace("cursor:default","cursor:crosshair");
 415+ }
 416+ sl = pr_container.scrollLeft;//save scrollbar value for Opera, Chrome
 417+ st = pr_container.scrollTop;
 418+ pr_container.style.cssText = self.container_css;
 419+ pr_container.scrollLeft = sl;
 420+ pr_container.scrollTop = st;
 421+}
405422
406423 function pr_drop(evt){
407424 evt = evt?evt:window.event?window.event:null; if(!evt){ return false;}
@@ -410,29 +427,11 @@
411428 document.onmousemove = null;
412429 document.onmousedown = null;
413430 pr_container.onmousemove = pr_move;
414 -
415431 if( is_drag==false ) {
416 - if( is_zoom ) {
417 - is_zoom = false;
418 - self.container_css = self.container_css.replace("overflow:hidden","overflow:auto");
419 - self.container_css = self.container_css.replace("cursor:crosshair","cursor:default");
420 - sl = pr_container.scrollLeft;//save scrollbar value for Opera, Chrome
421 - st = pr_container.scrollTop;
422 - pr_container.style.cssText = self.container_css;
423 - pr_container.scrollLeft = sl;
424 - pr_container.scrollTop = st;
425 - } else {
426 - is_zoom = true;
427 - self.container_css = self.container_css.replace("overflow:auto","overflow:hidden");
428 - self.container_css = self.container_css.replace("cursor:default","cursor:crosshair");
429 - sl = pr_container.scrollLeft;
430 - st = pr_container.scrollTop;
431 - pr_container.style.cssText = self.container_css;
432 - pr_container.scrollLeft = sl;
433 - pr_container.scrollTop = st;
434 - }
 432+ is_zoom = !is_zoom;
435433 }
436434 is_drag = false;
 435+ set_container_css(!is_zoom,!is_zoom);
437436 return false;
438437 }
439438
@@ -467,7 +466,7 @@
468467 init_x = pr_container.scrollLeft + lastxx;
469468 init_y = pr_container.scrollTop + lastyy;
470469 is_drag = false;
471 -
 470+ set_container_css(!is_zoom,!is_zoom);
472471 return false;
473472
474473 }
@@ -488,6 +487,7 @@
489488 if (evt.preventDefault) evt.preventDefault();
490489 evt.returnValue = false;
491490 is_drag = true;
 491+ set_container_css(true,!is_zoom);
492492 return false;
493493 }
494494

Status & tagging log