]> 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 a1474dc7061260d03f310bacef2554778df172bf..d9ce39bb28a4560af7a3e439182091c0d219d4f1 100644 (file)
-var UglyUIWindow = new Class({\r
-  Extends: UIWindow,\r
-  \r
-  initialize: function(parentObject, client, type, name) {\r
-    this.parent(parentObject, client, type, name);\r
-        \r
-    this.outerContainer = new Element("div", { "styles": { "display": "none", "font-family": "Lucida Console" } });\r
-    parentObject.container.appendChild(this.outerContainer);\r
-    \r
-    if(type == WINDOW_CHANNEL) {\r
-      this.nicklist = new Element("div", {"styles": { "border-left": "1px solid black", "width": "125px", "float": "right", "height": "480px", "clear": "both", "overflow": "auto", "background": "white"} });\r
-      this.outerContainer.appendChild(this.nicklist);\r
-    }\r
-    \r
-    var innerContainer = new Element("div", {"styles": { "height": "480px" }});\r
-    this.outerContainer.appendChild(innerContainer);\r
-    \r
-    if(type == WINDOW_CHANNEL) {\r
-      this.topic = new Element("div", {"styles": { "background": "#fef", "height": "20px" } });\r
-      innerContainer.appendChild(this.topic);\r
-    }\r
-    \r
-    this.lines = new Element("div", {"styles": { "height": "460px", "overflow": "auto", "word-wrap": "break-word" }});\r
-    innerContainer.appendChild(this.lines);\r
-    \r
-    this.tab = new Element("span", {"styles": { "border": "1px black solid", "padding": "2px", "cursor": "default", "margin-right": "2px", "background": "#eee", "clear": "both" } });\r
-    this.tab.appendText(name);\r
-    this.tab.addEvent("click", function() {\r
-      parentObject.selectWindow(this);\r
-    }.bind(this));\r
-\r
-    parentObject.tabs.appendChild(this.tab);\r
-    \r
-    if(type != WINDOW_STATUS) {\r
-      tabclose = new Element("span", {"styles": { "border": "1px black solid", "margin-left": "5px", "padding": "2px", "font-size": "0.5em" } });\r
-      tabclose.addEvent("click", function(e) {\r
-        new Event(e).stop();\r
-        \r
-        if(type == WINDOW_CHANNEL)\r
-          this.client.exec("/PART " + name);\r
-\r
-        this.close();\r
-      }.bind(this));\r
-      tabclose.set("text", "X");\r
-      this.tab.appendChild(tabclose);\r
-    }\r
-  },\r
-  updateNickList: function(nicks) {\r
-    this.parent(nicks);\r
-    \r
-    var n = this.nicklist;\r
-    while(n.firstChild)\r
-      n.removeChild(n.firstChild);\r
-\r
-    nicks.each(function(nick) {\r
-      var e = new Element("div");\r
-      n.appendChild(e);\r
-      e.appendChild(document.createTextNode(nick));\r
-    });\r
-  },\r
-  updateTopic: function(topic) {\r
-    this.parent(topic);\r
-    \r
-    var t = this.topic;\r
-    \r
-    while(t.firstChild)\r
-      t.removeChild(t.firstChild);\r
-\r
-    Colourise(topic, t);\r
-  },\r
-  select: function() {\r
-    this.parent();\r
-    \r
-    this.outerContainer.setStyle("display", "block");\r
-    this.tab.setStyle("background", "#dff");\r
-    this.tab.setStyle("color", "");\r
-  },\r
-  deselect: function() {\r
-    this.parent();\r
-    \r
-    this.outerContainer.setStyle("display", "none");\r
-    this.tab.setStyle("background", "#eee");\r
-  },\r
-  close: function() {\r
-    this.parent();\r
-    \r
-    this.parentObject.container.removeChild(this.outerContainer);\r
-    this.parentObject.tabs.removeChild(this.tab);\r
-  },\r
-  addLine: function(type, line, colour) {\r
-    this.parent(type, line, colour);\r
-    \r
-    var c;\r
-    if(colour) {\r
-      c = colour;\r
-    } else if(this.lastcolour) {\r
-      c = "#efefef";\r
-    } else {\r
-      c = "#eeffff";\r
-    }\r
-    \r
-    var e = new Element("div", { "styles": { "background": c } });\r
-    if(type)\r
-      line = this.parentObject.theme.message(type, line);\r
-    \r
-    Colourise(IRCTimestamp(new Date()) + " " + line, e);\r
-    \r
-    this.lastcolour = !this.lastcolour;\r
-    \r
-    var prev = this.lines.getScroll();\r
-    var prevbottom = this.lines.getScrollSize().y;\r
-    var prevsize = this.lines.getSize();\r
-    this.lines.appendChild(e);\r
-    \r
-    if(prev.y + prevsize.y == prevbottom)\r
-      this.lines.scrollTo(prev.x, this.lines.getScrollSize().y);\r
-      \r
-    if(!this.active)\r
-      this.tab.setStyle("color", "red");\r
-  }\r
-});\r
-\r
-var UglyUI = new Class({\r
-  Extends: UI,\r
-  initialize: function(parentElement, theme) {\r
-    this.parent(UglyUIWindow);\r
-    \r
-    this.parentElement = parentElement;\r
-    this.theme = theme;\r
-    \r
-    this.tabs = new Element("div", {"styles": { "border": "1px solid black", "padding": "4px", "font-family": "Lucida Console" } });\r
-    parentElement.appendChild(this.tabs);\r
-    \r
-    this.container = new Element("div", {"styles": { "border": "1px solid black", "margin": "2px 0px 0px 0px", "height": "480px" } });\r
-    parentElement.appendChild(this.container);\r
-  \r
-    var form = new Element("form");\r
-    var inputbox = new Element("input", {"styles": { "width": "400px", "border": "1px solid black", "margin": "2px 0px 0px 0px"} });\r
-  \r
-    form.addEvent("submit", function(e) {\r
-      new Event(e).stop();\r
-    \r
-      this.getActiveWindow().client.exec(inputbox.value);\r
-      inputbox.value = "";\r
-    }.bind(this));\r
-    parentElement.appendChild(form);  \r
-    form.appendChild(inputbox);\r
-    inputbox.focus();\r
-  }\r
-});
\ No newline at end of file
+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);
+        
+    this.outerContainer = new Element("div");
+    this.outerContainer.addClass("outercontainer");
+    this.outerContainer.addClass("tab-invisible");
+    
+    parentObject.container.appendChild(this.outerContainer);
+    
+    if(type == qwebirc.ui.WINDOW_CHANNEL) {
+      this.nicklist = new Element("div");
+      this.nicklist.addClass("nicklist");
+      
+      this.outerContainer.appendChild(this.nicklist);
+    }
+    
+    var innerContainer = new Element("div");
+    innerContainer.addClass("innercontainer");
+    this.outerContainer.appendChild(innerContainer);
+    
+    if(type == qwebirc.ui.WINDOW_CHANNEL) {
+      this.topic = new Element("div");
+      this.topic.addClass("topic");
+      innerContainer.appendChild(this.topic);
+    }
+    
+    this.lines = new Element("div");
+    this.lines.addClass("lines");
+    innerContainer.appendChild(this.lines);
+    
+    this.tab = new Element("span");
+    this.tab.addClass("tab");
+    
+    this.tab.appendText(name);
+    this.tab.addEvent("click", function() {
+      parentObject.selectWindow(this);
+    }.bind(this));
+
+    parentObject.tabs.appendChild(this.tab);
+    
+    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 == qwebirc.ui.WINDOW_CHANNEL)
+          this.client.exec("/PART " + name);
+
+        this.close();
+      }.bind(this));
+      tabclose.set("text", "X");
+      this.tab.appendChild(tabclose);
+    }
+  },
+  updateNickList: function(nicks) {
+    this.parent(nicks);
+    
+    var n = this.nicklist;
+    while(n.firstChild)
+      n.removeChild(n.firstChild);
+
+    nicks.each(function(nick) {
+      var e = new Element("div");
+      n.appendChild(e);
+      e.appendChild(document.createTextNode(nick));
+    });
+  },
+  updateTopic: function(topic) {
+    this.parent(topic);
+    
+    var t = this.topic;
+    
+    while(t.firstChild)
+      t.removeChild(t.firstChild);
+
+    Colourise(topic, t);
+  },
+  select: function() {
+    this.parent();
+    
+    this.outerContainer.removeClass("tab-invisible");
+    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();
+    
+    this.outerContainer.addClass("tab-invisible");
+    this.tab.removeClass("tab-selected");
+    this.tab.addClass("tab-unselected");
+  },
+  close: function() {
+    this.parent();
+    
+    this.parentObject.container.removeChild(this.outerContainer);
+    this.parentObject.tabs.removeChild(this.tab);
+  },
+  addLine: function(type, line, colour) {
+    var e = new Element("div");
+
+    if(colour) {
+      e.setStyles({"background": colour});
+    } else if(this.lastcolour) {
+      e.addClass("linestyle1");
+    } else {
+      e.addClass("linestyle2");
+    }
+    this.lastcolour = !this.lastcolour;
+    
+    this.parent(type, line, colour, e);
+  },
+  setHilighted: function(state) {
+    this.parent(state);
+    
+    if(state) {
+      this.tab.addClass("tab-highlighted");
+    } else {
+      this.tab.removeClass("tab-highlighted");
+    }
+  }
+});
+