]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseui.js
Whoops.
[irc/quakenet/qwebirc.git] / js / ui / baseui.js
index bec674b2e357ba9c30da096350afec43607e88dc..838c21fd86d013a8bdf10562a06d7e4cd089fcfe 100644 (file)
@@ -1,6 +1,9 @@
 var WINDOW_STATUS = 1;
 var WINDOW_QUERY = 2;
 var WINDOW_CHANNEL = 3;
+var WINDOW_CUSTOM = 4;
+var WINDOW_CONNECT = 5;
+var CUSTOM_CLIENT = "custom";
 
 var BaseUI = new Class({
   Implements: [Events, Options],
@@ -12,6 +15,7 @@ var BaseUI = new Class({
     this.setOptions(options);
     
     this.windows = {};
+    this.windows[CUSTOM_CLIENT] = {};
     this.windowArray = [];
     this.windowClass = windowClass;
     this.parentElement = parentElement;
@@ -62,7 +66,9 @@ var BaseUI = new Class({
         this.windowArray = [];
       } else {
         var index = this.windowArray.indexOf(window);
-        if(index == 0) {
+        if(index == -1) {
+          return;
+        } else if(index == 0) {
           this.selectWindow(this.windowArray[1]);
         } else {
           this.selectWindow(this.windowArray[index - 1]);
@@ -148,5 +154,55 @@ var UI = new Class({
         this.selectWindow(this.windowArray[number]);
       }
     }.bind(this));
+  },
+  newCustomWindow: function(name, select, type) {
+    if(!type)
+      type = WINDOW_CUSTOM;
+      
+    var w = this.newWindow(CUSTOM_CLIENT, type, name);
+    w.addEvent("close", function(w) {
+      delete this.windows[name];
+    }.bind(this));
+    
+    if(select)
+      this.selectWindow(w);  
+      
+    return w;
+  },
+  embeddedWindow: function() {
+    if(this.embedded) {
+      this.selectWindow(this.embedded)
+      return;
+    }
+    
+    this.embedded = this.newCustomWindow("Embedded wizard", true);
+    this.embedded.addEvent("close", function() {
+      this.embedded = null;
+    }.bind(this));
+        
+    var ew = new WebmasterGuide({parent: this.embedded.lines});
+    ew.addEvent("close", function() {
+      this.embedded.close();
+    }.bind(this));
+  },
+  urlDispatcher: function(name) {
+    if(name == "embedded")
+      return this.embeddedWindow.bind(this);
+
+    return null;
+  }
+});
+
+var NewLoginUI = new Class({
+  Extends: UI,
+  loginBox: function(callbackfn, initialNickname, initialChannels, autoConnect, autoNick) {
+    this.postInitialize();
+    var w = this.newCustomWindow("Connect", true, WINDOW_CONNECT);
+    var callback = function(args) {
+      w.close();
+      callbackfn(args);
+    };
+    
+    GenericLoginBox(w.lines, callback, initialNickname, initialChannels, autoConnect, autoNick);
   }
 });