]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/mochaui.js
Add resize scroll position saving.
[irc/quakenet/qwebirc.git] / js / ui / mochaui.js
index 3ee9e48fa29c7745ea572e80fd53a8e65791c686..655240de80fa6dcb3ab5f28eedc8e81b31c03a6d 100644 (file)
@@ -9,7 +9,6 @@ var QMochaUIWindow = new Class({
     this.form = new Element("form");
     this.inputbox = new Element("input", {styles: {border: 0, width: "100%"}});
     this.inputbox.addClass("input");
-    this.scrolltimeout = null;
     
     this.inputbox.addEvent("focus", function() {
       /* TODO: bring to top */
@@ -42,16 +41,14 @@ var QMochaUIWindow = new Class({
       //toolbarURL: "",
       toolbarLoadMethod: "html",
       content: this.lines,
+      minimized: true,
+      addClass: "hidenewwin",
       onFocus: function() {
         parentObject.selectWindow(this);
       }.bind(this),
       onClose: function() {
         if(type == WINDOW_CHANNEL)
           this.client.exec("/PART " + name);
-        if($defined(this.scrolltimeout)) {
-          $clear(this.scrolltimeout);
-          this.scrolltimeout = null;
-        }
         this.close();
       }.bind(this)
     };
@@ -59,14 +56,35 @@ var QMochaUIWindow = new Class({
     if(type == WINDOW_STATUS)
       prefs.closable = false;
     
+    /* HACK */
+/*    var oldIndexLevel = MochaUI.Windows.indexLevel;
+    
+    var focus = false;
+    var oldfocus = MochaUI.focusWindow;
+    if(!focus) {
+      MochaUI.Windows.indexLevel = 0;
+      MochaUI.focusWindow = null;
+    }
+  */  
     var nw = new MochaUI.Window(prefs);
+    
+    /*if(!focus) {
+      MochaUI.Windows.indexLevel = oldIndexLevel;
+      MochaUI.focusWindow = oldfocus;
+    }*/
+    
     /* HACK */
     var toolbar = $(nw.options.id + "_toolbar");
+    this.titleText = $(nw.options.id + "_title");
+    this.tabText = $(nw.options.id + "_dockTabText");
+    
     /*alert(toolbar.parentNode.getStyle("background"));*/
     /*this.inputbox.setStyle("background", toolbar.parentNode.getStyle("background"));*/
     toolbar.appendChild(this.form);
     this.windowObject = nw;
     
+    this.scroller = this.lines.parentNode.parentNode;
+    
     return;
 /*    
     if(type == WINDOW_CHANNEL) {
@@ -112,8 +130,6 @@ var QMochaUIWindow = new Class({
     Colourise(topic, t);
   },
   addLine: function(type, line, colour) {
-    this.parent(type, line, colour);
-    
     var e = new Element("div");
 
     if(colour) {
@@ -123,43 +139,27 @@ var QMochaUIWindow = new Class({
     } else {
       e.addClass("linestyle2");
     }
-    
-    if(type)
-      line = this.parentObject.theme.message(type, line);
-    
-    Colourise(IRCTimestamp(new Date()) + " " + line, e);
-    
     this.lastcolour = !this.lastcolour;
 
-    this.__scrollbottom(false, e);    
-    /*if(!this.active)
-      this.lines.showLoadingIcon();
-      */
-  },
-  __scrollbottom: function(timed, element) {
-    var pe = this.lines.parentNode.parentNode;
-    //alert(pe);
-    var prev = pe.getScroll();
-    var prevbottom = pe.getScrollSize().y;
-    var prevsize = pe.getSize();
-    
-    /* scroll in bursts, else the browser gets really slow */
-    if(!timed) {
-      this.lines.appendChild(element);
-      if(this.scrolltimeout || (prev.y + prevsize.y == prevbottom)) {
-        if(this.scrolltimeout)
-          $clear(this.scrolltimeout);
-        this.scrolltimeout = this.__scrollbottom.delay(10, this, true);
-      }
-    } else {
-      pe.scrollTo(prev.x, pe.getScrollSize().y);
-      this.scrolltimeout = null;
-    }
+    this.parent(type, line, colour, e, this.lines);
   },
   select: function() {
     this.parent();
     
     this.inputbox.focus();
+  },
+  setHilighted: function(state) {
+    this.parent(state);
+    
+    if(state) {
+      this.titleText.setStyle("color", "#ff0000");
+      this.tabText.setStyle("background-color", "#ff0000");
+      this.tabText.setStyle("color", "#000000");
+    } else {
+      this.titleText.setStyle("color", null);
+      this.tabText.setStyle("background-color", null);
+      this.tabText.setStyle("color", null);
+    }    
   }
 });