]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Rework old UI's to support custom/connect windows.
authorChris Porter <redacted>
Sat, 18 Oct 2008 17:40:02 +0000 (18:40 +0100)
committerChris Porter <redacted>
Sat, 18 Oct 2008 17:40:02 +0000 (18:40 +0100)
Fix null dereference bug in selectWindow.

js/ui/baseui.js
js/ui/mochaui.js
js/ui/swmlayout.js
js/ui/swmui.js
js/ui/uglyui.js

index f90b9b6de2ec8709abefce023453d12d6260ce5c..838c21fd86d013a8bdf10562a06d7e4cd089fcfe 100644 (file)
@@ -66,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]);
@@ -190,3 +192,17 @@ var UI = new Class({
     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);
+  }
+});
index bd0299f6b7ea4e97f4b6a68bc5ed3b98d0643936..710e0732303f61c8325f7516ee9726d92e0de6b9 100644 (file)
@@ -6,34 +6,37 @@ var QMochaUIWindow = new Class({
 
     this.lines = new Element("div", {styles: {overflow: "auto", "width": "90"}});
 
-    this.form = new Element("form");
-    this.inputbox = new Element("input", {styles: {border: 0, width: "100%"}});
-    this.inputbox.addClass("input");
-    
-    this.inputbox.addEvent("focus", function() {
-      /* TODO: bring to top */
-      //alert(":O");
-      //alert(this.windowObject.windowEl);
-      //MochaUI.focusWindow.pass(this.windowObject.windowEl, this.windowObject);
-      //this.windowObject.focusWindow();
-      this.parentObject.selectWindow(this);
-    }.bind(this));
-    
-    this.form.addEvent("submit", function(e) {
-      new Event(e).stop();
-    
-      this.client.exec(this.inputbox.value);
-      this.inputbox.value = "";
-    }.bind(this));
-    //this.container.appendChild(form);  
-    this.form.appendChild(this.inputbox);
+    var toolbar = type != WINDOW_CUSTOM && type != WINDOW_CONNECT;
+    
+    if(toolbar) {
+      this.form = new Element("form");
+      this.inputbox = new Element("input", {styles: {border: 0, width: "100%"}});
+      this.inputbox.addClass("input");
+    
+      this.inputbox.addEvent("focus", function() {
+        /* TODO: bring to top */
+        //alert(":O");
+        //alert(this.windowObject.windowEl);
+        //MochaUI.focusWindow.pass(this.windowObject.windowEl, this.windowObject);
+        //this.windowObject.focusWindow();
+        this.parentObject.selectWindow(this);
+      }.bind(this));
+    
+      this.form.addEvent("submit", function(e) {
+        new Event(e).stop();
+      
+        this.client.exec(this.inputbox.value);
+        this.inputbox.value = "";
+      }.bind(this));
+      //this.container.appendChild(form);  
+      this.form.appendChild(this.inputbox);
+    }
     
     var prefs = {
       width: 800,
       height: 400,
       title: name,
       footerHeight: 0,
-      toolbar: true,
       container: $("pageWrapper"),
       toolbarHeight: parentObject.inputHeight,
       toolbarPosition: "bottom",
@@ -53,8 +56,8 @@ var QMochaUIWindow = new Class({
       }.bind(this)
     };
     
-    if(type == WINDOW_STATUS)
-      prefs.closable = false;
+    prefs.toolbar = toolbar;
+    prefs.closable = type != WINDOW_STATUS && type != WINDOW_CONNECT;
     
     /* HACK */
 /*    var oldIndexLevel = MochaUI.Windows.indexLevel;
@@ -67,6 +70,7 @@ var QMochaUIWindow = new Class({
     }
   */  
     var nw = new MochaUI.Window(prefs);
+    this.window = nw;
     
     /*if(!focus) {
       MochaUI.Windows.indexLevel = oldIndexLevel;
@@ -74,13 +78,15 @@ var QMochaUIWindow = new Class({
     }*/
     
     /* HACK */
-    var toolbar = $(nw.options.id + "_toolbar");
+    if(toolbar) {
+      var toolbar = $(nw.options.id + "_toolbar");
+      toolbar.appendChild(this.form);
+    }
     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;
@@ -146,7 +152,8 @@ var QMochaUIWindow = new Class({
   select: function() {
     this.parent();
     
-    this.inputbox.focus();
+    if(this.inputbox)
+      this.inputbox.focus();
   },
   setHilighted: function(state) {
     this.parent(state);
@@ -160,11 +167,16 @@ var QMochaUIWindow = new Class({
       this.tabText.setStyle("background-color", null);
       this.tabText.setStyle("color", null);
     }    
-  }
+  },
+  close: function() {
+    this.parent();
+    
+    MochaUI.closeWindow(this.window.windowEl);
+  },
 });
 
 var QMochaUI = new Class({
-  Extends: UI,
+  Extends: NewLoginUI,
     initialize: function(parentElement, theme) {
     this.parent(parentElement, QMochaUIWindow, "mochaui");
     this.theme = theme;
@@ -216,11 +228,5 @@ var QMochaUI = new Class({
     this.parentElement.appendChild(form);  
     form.appendChild(inputbox);
     inputbox.focus();
-  },
-  loginBox: function(callbackfn, intialNickname, initialChannels, autoConnect, autoNick) {
-    this.parent(function(options) {
-      this.postInitialize();
-      callbackfn(options);
-    }.bind(this), intialNickname, initialChannels, autoConnect);
   }
 });
index dae0b0187395cd871c604d226084ae2cc7e122a7..bde6d05296e365a8f84f7dcdd999c4886946e575 100644 (file)
@@ -133,7 +133,7 @@ var SWMFrame = new Class({
       "top": "0px",
       "left": "0px",
       "height": "100%",
-      "width": "100%"
+      "width": "100%",
     }}); 
     this.element.wmpanel = this;
 
index c353cca672efbf52b1444566a24319581c118f53..ce257ee03185d5bfd55283aa60128254fa79748c 100644 (file)
@@ -30,7 +30,7 @@ var SWMUIWindow = new Class({
     parentObject.tabPanel.appendChild(this.tab);
     parentObject.resize();
     
-    if(type != WINDOW_STATUS) {
+    if(type != WINDOW_STATUS && type != WINDOW_CONNECT) {
       tabclose = new Element("span");
       tabclose.addClass("tabclose");
       tabclose.addEvent("click", function(e) {
@@ -72,6 +72,7 @@ var SWMUIWindow = new Class({
     this.parentObject.resize();
     this.tab.removeClass("tab-unselected");
     this.tab.addClass("tab-selected");
+    this.parentObject.showInput(this.type == WINDOW_CONNECT || this.type == WINDOW_CUSTOM);
   },
   deselect: function() {
     this.parent();
@@ -114,7 +115,7 @@ var SWMUIWindow = new Class({
 });
 
 var SWMUI = new Class({
-  Extends: UI,
+  Extends: NewLoginUI,
   initialize: function(parentElement, theme) {
     this.parent(parentElement, SWMUIWindow, "swmui");
 
@@ -158,13 +159,11 @@ var SWMUI = new Class({
 
     this.resize();
   },
+  showInput: function(state) {
+    this.entryPanel.setHidden(state);
+    this.resize();
+  },
   resize: function() {
     window.fireEvent("resize");
-  },
-  loginBox: function(callback, initialNickname, initialChannels, autoConnect) {
-    this.parent(function(options) {
-      this.postInitialize();
-      callbackfn(options);
-    }.bind(this), intialNickname, initialChannels, autoConnect);
   }
 });
index de3e6a34971bf8983ebc4e666435cc0e5754590b..d2ebd51127a07b8d121007ee7b2e3045245c5df2 100644 (file)
@@ -41,7 +41,7 @@ var UglyUIWindow = new Class({
 
     parentObject.tabs.appendChild(this.tab);
     
-    if(type != WINDOW_STATUS) {
+    if(type != WINDOW_STATUS && type != WINDOW_CONNECT) {
       tabclose = new Element("span");
       tabclose.addClass("tabclose");
       tabclose.addEvent("click", function(e) {
@@ -85,6 +85,7 @@ var UglyUIWindow = new Class({
     this.outerContainer.removeClass("tab-invisible");
     this.tab.removeClass("tab-unselected");    
     this.tab.addClass("tab-selected");
+    this.parentObject.showInput(this.type != WINDOW_CONNECT && this.type != WINDOW_CUSTOM);
   },
   deselect: function() {
     this.parent();
@@ -125,7 +126,7 @@ var UglyUIWindow = new Class({
 });
 
 var UglyUI = new Class({
-  Extends: UI,
+  Extends: NewLoginUI,
   initialize: function(parentElement, theme) {
     this.parent(parentElement, UglyUIWindow, "uglyui");
     this.theme = theme;
@@ -143,6 +144,8 @@ var UglyUI = new Class({
     this.parentElement.appendChild(this.container);
   
     var form = new Element("form");
+    this.form = form;
+    
     var inputbox = new Element("input");
     inputbox.addClass("input");
   
@@ -156,11 +159,8 @@ var UglyUI = new Class({
     form.appendChild(inputbox);
     inputbox.focus();
   },
-  loginBox: function(callbackfn, intialNickname, initialChannels, autoConnect, autoNick) {
-    this.parent(function(options) {
-      this.postInitialize();
-      callbackfn(options);
-    }.bind(this), intialNickname, initialChannels, autoConnect, autoNick);
+  showInput: function(state) {
+    this.form.setStyle("display", state?"block":"none");
   }
 });