-var SWMUIWindow = new Class({\r
- Extends: UIWindow,\r
- \r
- initialize: function(parentObject, client, type, name) {\r
- this.parent(parentObject, client, type, name);\r
- this.contentPanel = new SWMPanel(parentObject.mainPanel.element, true);\r
- this.contentPanel.element.addClass("content");\r
- this.contentPanel.element.setStyle("overflow", "auto");\r
-\r
- if(type == WINDOW_CHANNEL) {\r
- this.nickList = new SWMPanel(this.contentPanel.element);\r
- this.nickList.anchor = SWM_ANCHOR_RIGHT;\r
- this.nickList.element.setStyle("overflow", "auto");\r
- this.nickList.element.addClass("nicklist");\r
- }\r
-\r
- if(type == WINDOW_CHANNEL) {\r
- this.topic = new SWMPanel(this.contentPanel.element);\r
- this.topic.anchor = SWM_ANCHOR_TOP;\r
- this.topic.element.addClass("topic");\r
- }\r
- \r
- this.lines = new SWMPanel(this.contentPanel.element);\r
- this.lines.element.setStyle("overflow", "auto");\r
- \r
- this.tab = new Element("span");\r
- this.tab.addClass("tab");\r
- \r
- this.tab.appendText(name);\r
- this.tab.addEvent("click", function() {\r
- parentObject.selectWindow(this);\r
- }.bind(this));\r
-\r
- parentObject.tabPanel.element.appendChild(this.tab);\r
- parentObject.resize();\r
- \r
- if(type != WINDOW_STATUS) {\r
- tabclose = new Element("span");\r
- tabclose.addClass("tabclose");\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.element;\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
- this.parentObject.resize();\r
- },\r
- updateTopic: function(topic) {\r
- this.parent(topic);\r
- var t = this.topic.element;\r
- \r
- while(t.firstChild)\r
- t.removeChild(t.firstChild);\r
-\r
- Colourise(topic, t);\r
-\r
- this.parentObject.resize();\r
- },\r
- select: function() {\r
- this.parent();\r
-\r
- this.contentPanel.setHidden(false);\r
- this.parentObject.resize();\r
- this.tab.removeClass("tab-highlighted");\r
- this.tab.removeClass("tab-unselected");\r
- this.tab.addClass("tab-selected");\r
- },\r
- deselect: function() {\r
- this.parent();\r
-\r
- this.contentPanel.setHidden(true);\r
- this.parentObject.resize();\r
- this.tab.removeClass("tab-selected");\r
- this.tab.addClass("tab-unselected");\r
- },\r
- close: function() {\r
- this.parent();\r
-\r
- this.parentObject.mainPanel.element.removeChild(this.contentPanel.element);\r
- this.parentObject.tabPanel.element.removeChild(this.tab);\r
- },\r
- addLine: function(type, line, colour) {\r
- this.parent(type, line, colour);\r
- \r
- var e = new Element("div");\r
-\r
- if(colour) {\r
- e.addStyle("background", colour);\r
- } else if(this.lastcolour) {\r
- e.addClass("linestyle1");\r
- } else {\r
- e.addClass("linestyle2");\r
- }\r
- \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.element.getScroll();\r
- var prevbottom = this.lines.element.getScrollSize().y;\r
- var prevsize = this.lines.element.getSize();\r
- this.lines.element.appendChild(e);\r
- \r
- if(prev.y + prevsize.y == prevbottom)\r
- this.lines.element.scrollTo(prev.x, this.lines.element.getScrollSize().y);\r
- \r
- if(!this.active)\r
- this.tab.addClass("tab-highlighted");\r
- }\r
-});\r
-\r
-var SWMUI = new Class({\r
- Extends: UI,\r
- initialize: function(parentElement, theme) {\r
- this.parent(parentElement, SWMUIWindow, "swmui");\r
- this.theme = theme;\r
- \r
- this.tabPanel = new SWMPanel(parentElement);\r
- this.tabPanel.anchor = SWM_ANCHOR_TOP;\r
- this.tabPanel.element.addClass("tabs");\r
- \r
- this.mainPanel = new SWMPanel(parentElement);\r
- this.mainPanel.element.addClass("main");\r
- \r
- this.entryPanel = new SWMPanel(parentElement);\r
- this.entryPanel.anchor = SWM_ANCHOR_BOTTOM;\r
- this.entryPanel.element.addClass("entry");\r
-\r
- var form = new Element("form");\r
- \r
- var inputbox = new Element("input");\r
- \r
- window.addEvent("resize", function() {\r
- var s = this.entryPanel.element.getSize().x - 4;\r
- inputbox.setStyle("width", s + "px");\r
- }.bind(this));\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
-\r
- this.entryPanel.element.appendChild(form);\r
- form.appendChild(inputbox);\r
- inputbox.focus();\r
-\r
- this.resize();\r
- },\r
- resize: function() {\r
- window.fireEvent("resize");\r
- }\r
-});\r
+var SWMUIWindow = new Class({
+ Extends: UIWindow,
+
+ initialize: function(parentObject, client, type, name) {
+ this.parent(parentObject, client, type, name);
+ this.contentPanel = new SWMPanel(parentObject.mainPanel, true);
+ this.contentPanel.addClass("content");
+
+ if(type == WINDOW_CHANNEL) {
+ this.nickList = new SWMPanel(this.contentPanel);
+ this.nickList.anchor = SWM_ANCHOR_RIGHT;
+ this.nickList.addClass("nicklist");
+
+ this.topic = new SWMPanel(this.contentPanel);
+ this.topic.anchor = SWM_ANCHOR_TOP;
+ this.topic.addClass("topic");
+ }
+
+ this.xlines = new SWMPanel(this.contentPanel);
+ this.lines = this.xlines.element;
+
+ this.tab = new Element("span");
+ this.tab.addClass("tab");
+
+ this.tab.appendText(name);
+ this.tab.addEvent("click", function() {
+ parentObject.selectWindow(this);
+ }.bind(this));
+
+ parentObject.tabPanel.appendChild(this.tab);
+ parentObject.resize();
+
+ if(type != WINDOW_STATUS) {
+ tabclose = new Element("span");
+ tabclose.addClass("tabclose");
+ tabclose.addEvent("click", function(e) {
+ new Event(e).stop();
+
+ if(type == 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);
+
+ this.nickList.removeAllChildren();
+ nicks.each(function(nick) {
+ var e = new Element("div");
+ this.nickList.appendChild(e);
+ e.appendChild(document.createTextNode(nick));
+ }.bind(this));
+
+ this.parentObject.resize();
+ },
+ updateTopic: function(topic) {
+ this.parent(topic);
+
+ this.topic.removeAllChildren();
+ Colourise(topic, this.topic.element);
+
+ this.parentObject.resize();
+ },
+ select: function() {
+ this.parent();
+
+ this.contentPanel.setHidden(false);
+ this.parentObject.resize();
+ this.tab.removeClass("tab-unselected");
+ this.tab.addClass("tab-selected");
+ },
+ deselect: function() {
+ this.parent();
+
+ this.contentPanel.setHidden(true);
+ this.parentObject.resize();
+ this.tab.removeClass("tab-selected");
+ this.tab.addClass("tab-unselected");
+ },
+ close: function() {
+ this.parent();
+
+ this.parentObject.mainPanel.removeChild(this.contentPanel.element);
+ this.parentObject.tabPanel.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");
+ }
+ }
+});
+
+var SWMUI = new Class({
+ Extends: UI,
+ initialize: function(parentElement, theme) {
+ this.parent(parentElement, SWMUIWindow, "swmui");
+
+ this.parentElement = parentElement;
+ this.theme = theme;
+ },
+ postInitialize: function() {
+ this.rootFrame = new SWMFrame(this.parentElement);
+
+ this.tabPanel = new SWMPanel(this.rootFrame);
+ this.tabPanel.anchor = SWM_ANCHOR_TOP;
+ this.tabPanel.addClass("tabs");
+
+ this.mainPanel = new SWMPanel(this.rootFrame);
+ this.mainPanel.addClass("main");
+
+ this.entryPanel = new SWMPanel(this.rootFrame);
+ this.entryPanel.anchor = SWM_ANCHOR_BOTTOM;
+ this.entryPanel.addClass("entry");
+
+ var form = new Element("form");
+
+ var inputbox = new Element("input");
+ inputbox.setStyle("border", "0px");
+
+ window.addEvent("resize", function() {
+ var s = this.entryPanel.getInnerSize().x;
+ inputbox.setStyle("width", s + "px");
+ }.bind(this));
+
+ form.addEvent("submit", function(e) {
+ new Event(e).stop();
+
+ this.getActiveWindow().client.exec(inputbox.value);
+ inputbox.value = "";
+ }.bind(this));
+
+ this.entryPanel.appendChild(form);
+ form.appendChild(inputbox);
+ inputbox.focus();
+
+ this.resize();
+ },
+ resize: function() {
+ window.fireEvent("resize");
+ },
+ loginBox: function(callback, initialNickname, initialChannels) {
+ var box = new Element("div");
+ this.parentElement.appendChild(box);
+
+ var header = new Element("h1");
+ header.set("text", "qwebirc");
+ box.appendChild(header);
+
+ var form = new Element("form");
+ box.appendChild(form);
+
+ var boxtable = new Element("table");
+ form.appendChild(boxtable);
+
+ var tbody = new Element("tbody");
+ boxtable.appendChild(tbody); /* stupid IE */
+
+ function createRow(label, e2) {
+ var r = new Element("tr");
+ tbody.appendChild(r);
+
+ var d1 = new Element("td");
+ if(label)
+ d1.set("text", label);
+ r.appendChild(d1);
+
+ var d2 = new Element("td");
+ r.appendChild(d2);
+ d2.appendChild(e2);
+ return d1;
+ }
+
+ var nick = new Element("input");
+ createRow("Nickname:", nick);
+ var chan = new Element("input");
+ createRow("Channels (comma seperated):", chan);
+
+ var connbutton = new Element("input", {"type": "submit"});
+ connbutton.set("value", "Connect");
+ createRow(undefined, connbutton)
+
+ form.addEvent("submit", function(e) {
+ new Event(e).stop();
+ var nickname = nick.value;
+ var chans = chan.value;
+ if(chans == "#") /* sorry channel "#" :P */
+ chans = "";
+
+ if(!nickname) {
+ alert("You must supply a nickname.");
+ nick.focus();
+ return;
+ }
+
+ this.parentElement.removeChild(box);
+ this.postInitialize();
+ callback({"nickname": nickname, "autojoin": chans});
+ }.bind(this));
+
+ nick.set("value", initialNickname);
+ chan.set("value", initialChannels);
+
+ nick.focus();
+ }
+});