]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseui.js
Add about pane.
[irc/quakenet/qwebirc.git] / js / ui / baseui.js
index 627a55b871301aaef6d4817c767f290351fde4d0..1d4e9d856c3027ecc4355aa61e866f49498757af 100644 (file)
@@ -3,6 +3,7 @@ qwebirc.ui.WINDOW_QUERY = 2;
 qwebirc.ui.WINDOW_CHANNEL = 3;
 qwebirc.ui.WINDOW_CUSTOM = 4;
 qwebirc.ui.WINDOW_CONNECT = 5;
+qwebirc.ui.WINDOW_MESSAGES = 6;
 qwebirc.ui.CUSTOM_CLIENT = "custom";
 
 qwebirc.ui.BaseUI = new Class({
@@ -50,22 +51,37 @@ qwebirc.ui.BaseUI = new Class({
       return client.id;
     }
   },
-  newWindow: function(client, type, name) {
-    var identifier = name;
+  getWindowIdentifier: function(type, name) {
+    if(type == qwebirc.ui.WINDOW_MESSAGES)
+      return "-M";
     if(type == qwebirc.ui.WINDOW_STATUS)
-      identifier = "";
+      return "";
+    return "_" + name.toIRCLower();
+  },
+  newWindow: function(client, type, name) {
+    var w = this.getWindow(client, type, name);
+    if($defined(w))
+      return w;
       
-    var w = this.windows[this.getClientId(client)][identifier] = new this.windowClass(this, client, type, name, identifier);
+    var wId = this.getWindowIdentifier(type, name);
+    var w = this.windows[this.getClientId(client)][wId] = new this.windowClass(this, client, type, name, wId);
     this.windowArray.push(w);
     
     return w;
   },
+  getWindow: function(client, type, name) {
+    var c = this.windows[this.getClientId(client)];
+    if(!$defined(c))
+      return null;
+      
+    return c[this.getWindowIdentifier(type, name)];
+  },
   getActiveWindow: function() {
     return this.active;
   },
   getActiveIRCWindow: function(client) {
     if(!this.active || this.active.type == qwebirc.ui.WINDOW_CUSTOM) {
-      return this.windows[this.getClientId(client)][""];
+      return this.windows[this.getClientId(client)][this.getWindowIdentifier(qwebirc.ui.WINDOW_STATUS)];
     } else {
       return this.active;
     }
@@ -193,7 +209,7 @@ qwebirc.ui.StandardUI = new Class({
       
     var w = this.newWindow(qwebirc.ui.CUSTOM_CLIENT, type, name);
     w.addEvent("close", function(w) {
-      delete this.windows[qwebirc.ui.CUSTOM_CLIENT][name];
+      delete this.windows[qwebirc.ui.CUSTOM_CLIENT][w.identifier];
     }.bind(this));
     
     if(select)
@@ -218,7 +234,7 @@ qwebirc.ui.StandardUI = new Class({
     }.bind(this));
         
     if(cssClass)
-      d.lines.addClass(cssClass);
+      d.lines.addClass("qwebirc-" + cssClass);
       
     var ew = new class_(d.lines, options);
     ew.addEvent("close", function() {
@@ -231,6 +247,9 @@ qwebirc.ui.StandardUI = new Class({
   optionsWindow: function() {
     this.addCustomWindow("Options", qwebirc.ui.OptionsPane, "optionspane", this.uiOptions);
   },
+  aboutWindow: function() {
+    this.addCustomWindow("About", qwebirc.ui.AboutPane, "aboutpane", this.uiOptions);
+  },
   urlDispatcher: function(name) {
     if(name == "embedded")
       return ["a", this.embeddedWindow.bind(this)];