]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/uglyui.js
Try not to corrupt the namespaces.
[irc/quakenet/qwebirc.git] / js / ui / uglyui.js
index b7818a7c9eb92621a1ddf5f4551103b1d23c5102..d9ce39bb28a4560af7a3e439182091c0d219d4f1 100644 (file)
@@ -1,5 +1,44 @@
-var UglyUIWindow = new Class({
-  Extends: UIWindow,
+qwebirc.ui.UglyUI = new Class({
+  Extends: qwebirc.ui.NewLoginUI,
+  initialize: function(parentElement, theme) {
+    this.parent(parentElement, qwebirc.ui.UglyUI.Window, "uglyui");
+    this.theme = theme;
+    this.parentElement = parentElement;
+  },
+  postInitialize: function() {    
+    this.tabs = new Element("div");
+    this.tabs.addClass("tabbar");
+    
+    this.parentElement.appendChild(this.tabs);
+    
+    this.container = new Element("div");
+    this.container.addClass("container");
+    
+    this.parentElement.appendChild(this.container);
+  
+    var form = new Element("form");
+    this.form = form;
+    
+    var inputbox = new Element("input");
+    inputbox.addClass("input");
+  
+    form.addEvent("submit", function(e) {
+      new Event(e).stop();
+    
+      this.getActiveWindow().client.exec(inputbox.value);
+      inputbox.value = "";
+    }.bind(this));
+    this.parentElement.appendChild(form);  
+    form.appendChild(inputbox);
+    inputbox.focus();
+  },
+  showInput: function(state) {
+    this.form.setStyle("display", state?"block":"none");
+  }
+});
+
+qwebirc.ui.UglyUI.Window = new Class({
+  Extends: qwebirc.ui.Window,
   
   initialize: function(parentObject, client, type, name) {
     this.parent(parentObject, client, type, name);
@@ -10,7 +49,7 @@ var UglyUIWindow = new Class({
     
     parentObject.container.appendChild(this.outerContainer);
     
-    if(type == WINDOW_CHANNEL) {
+    if(type == qwebirc.ui.WINDOW_CHANNEL) {
       this.nicklist = new Element("div");
       this.nicklist.addClass("nicklist");
       
@@ -21,7 +60,7 @@ var UglyUIWindow = new Class({
     innerContainer.addClass("innercontainer");
     this.outerContainer.appendChild(innerContainer);
     
-    if(type == WINDOW_CHANNEL) {
+    if(type == qwebirc.ui.WINDOW_CHANNEL) {
       this.topic = new Element("div");
       this.topic.addClass("topic");
       innerContainer.appendChild(this.topic);
@@ -41,13 +80,13 @@ var UglyUIWindow = new Class({
 
     parentObject.tabs.appendChild(this.tab);
     
-    if(type != WINDOW_STATUS) {
+    if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) {
       tabclose = new Element("span");
       tabclose.addClass("tabclose");
       tabclose.addEvent("click", function(e) {
         new Event(e).stop();
         
-        if(type == WINDOW_CHANNEL)
+        if(type == qwebirc.ui.WINDOW_CHANNEL)
           this.client.exec("/PART " + name);
 
         this.close();
@@ -83,9 +122,9 @@ var UglyUIWindow = new Class({
     this.parent();
     
     this.outerContainer.removeClass("tab-invisible");
-    this.tab.removeClass("tab-unselected");
-    this.tab.removeClass("tab-highlighted");
+    this.tab.removeClass("tab-unselected");    
     this.tab.addClass("tab-selected");
+    this.parentObject.showInput(this.type != qwebirc.ui.WINDOW_CONNECT && this.type != qwebirc.ui.WINDOW_CUSTOM);
   },
   deselect: function() {
     this.parent();
@@ -101,75 +140,27 @@ var UglyUIWindow = new Class({
     this.parentObject.tabs.removeChild(this.tab);
   },
   addLine: function(type, line, colour) {
-    this.parent(type, line, colour);
-    
     var e = new Element("div");
 
     if(colour) {
-      e.addStyle("background", colour);
+      e.setStyles({"background": colour});
     } else if(this.lastcolour) {
       e.addClass("linestyle1");
     } else {
       e.addClass("linestyle2");
     }
-    
-    if(type)
-      line = this.parentObject.theme.message(type, line);
-    
-    Colourise(IRCTimestamp(new Date()) + " " + line, e);
-    
     this.lastcolour = !this.lastcolour;
     
-    var prev = this.lines.getScroll();
-    var prevbottom = this.lines.getScrollSize().y;
-    var prevsize = this.lines.getSize();
-    this.lines.appendChild(e);
-    
-    if(prev.y + prevsize.y == prevbottom)
-      this.lines.scrollTo(prev.x, this.lines.getScrollSize().y);
-      
-    if(!this.active)
-      this.tab.addClass("tab-highlighted");
-  }
-});
-
-var UglyUI = new Class({
-  Extends: UI,
-  initialize: function(parentElement, theme) {
-    this.parent(parentElement, UglyUIWindow, "uglyui");
-    this.theme = theme;
-    this.parentElement = parentElement;
+    this.parent(type, line, colour, e);
   },
-  postInitialize: function() {    
-    this.tabs = new Element("div");
-    this.tabs.addClass("tabbar");
+  setHilighted: function(state) {
+    this.parent(state);
     
-    this.parentElement.appendChild(this.tabs);
-    
-    this.container = new Element("div");
-    this.container.addClass("container");
-    
-    this.parentElement.appendChild(this.container);
-  
-    var form = new Element("form");
-    var inputbox = new Element("input");
-    inputbox.addClass("input");
-  
-    form.addEvent("submit", function(e) {
-      new Event(e).stop();
-    
-      this.getActiveWindow().client.exec(inputbox.value);
-      inputbox.value = "";
-    }.bind(this));
-    this.parentElement.appendChild(form);  
-    form.appendChild(inputbox);
-    inputbox.focus();
-  },
-  loginBox: function(callbackfn) {
-    this.parent(function(options) {
-      this.postInitialize();
-      callbackfn(options);
-    }.bind(this));
+    if(state) {
+      this.tab.addClass("tab-highlighted");
+    } else {
+      this.tab.removeClass("tab-highlighted");
+    }
   }
 });