]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Fix scrollpos not being saved between tab switches if not at bottom.
authorChris Porter <redacted>
Sun, 9 Nov 2008 10:02:38 +0000 (10:02 +0000)
committerChris Porter <redacted>
Sun, 9 Nov 2008 10:02:38 +0000 (10:02 +0000)
TODO.txt
js/ui/baseuiwindow.js

index f90e6b1fa6b89b84bc134cdb8f62a84248a6d001..e19de2b8f63371a0f1d2ae124430de9e395fa75c 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -2,7 +2,6 @@ O sound
 tab dragging\r
 O options pane (notices, sound, query behaviour, @+ in nick shown in chantext, etc)\r
 O authgate integration\r
-scroll pos isn't saved when you go between tabs if not at bottom.\r
 scroll pos not saved on resize (percentage)\r
 undo closed tab\r
 memory leaks\r
index ed6d4a523794c791881ee0243d4ae2ea185979e5..cc05e9009aaa6476e61207c6ae9265b5eb94ba78 100644 (file)
@@ -16,6 +16,7 @@ qwebirc.ui.Window = new Class({
     this.scrolltimer = null;
     this.commandhistory = this.parentObject.commandhistory;
     this.scrolleddown = true;
+    this.scrollpos = null;
     this.lastNickHash = {};
     this.lastSelected = null;
   },
@@ -38,13 +39,12 @@ qwebirc.ui.Window = new Class({
     this.parentObject.__setActiveWindow(this);
     if(this.hilighted)
       this.setHilighted(qwebirc.ui.HILIGHT_NONE);
-    if(this.scrolleddown)
-      this.scrollToBottom();
+      
+    this.resetScrollPos();
     this.lastSelected = new Date();
   },
   deselect: function() {
-    if(!this.parentObject.singleWindow)
-      this.scrolleddown = this.scrolledDown();
+    this.setScrollPos();
     if($defined(this.scrolltimer)) {
       $clear(this.scrolltimer);
       this.scrolltimer = null;
@@ -52,6 +52,19 @@ qwebirc.ui.Window = new Class({
 
     this.active = false;
   },
+  resetScrollPos: function() {
+    if(this.scrolleddown) {
+      this.scrollToBottom();
+    } else if($defined(this.scrollpos)) {
+      this.getScrollParent().scrollTo(this.scrollpos.x, this.scrollpos.y);
+    }
+  },
+  setScrollPos: function() {
+    if(!this.parentObject.singleWindow) {
+      this.scrolleddown = this.scrolledDown();
+      this.scrollpos = this.lines.getScroll();
+    }
+  },
   addLine: function(type, line, colour, element) {
     var hilight = qwebirc.ui.HILIGHT_NONE;
     var lhilight = false;
@@ -104,12 +117,16 @@ qwebirc.ui.Window = new Class({
       
     return prev.y + prevsize.y == prevbottom;
   },
-  scrollToBottom: function() {
-    var parent = this.lines;
-    var scrollparent = parent;
+  getScrollParent: function() {
+    var scrollparent = this.lines;
 
     if($defined(this.scroller))
       scrollparent = this.scroller;
+    return scrollparent;
+  },
+  scrollToBottom: function() {
+    var parent = this.lines;
+    var scrollparent = this.getScrollParent();
       
     scrollparent.scrollTo(parent.getScroll().x, parent.getScrollSize().y);
   },