]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/swmui.js
1 var SWMUIWindow
= new Class({
4 initialize: function(parentObject
, client
, type
, name
) {
5 this.parent(parentObject
, client
, type
, name
);
6 this.contentPanel
= new SWMPanel(parentObject
.mainPanel
, true);
7 this.contentPanel
.addClass("content");
9 if(type
== WINDOW_CHANNEL
) {
10 this.nickList
= new SWMPanel(this.contentPanel
);
11 this.nickList
.anchor
= SWM_ANCHOR_RIGHT
;
12 this.nickList
.addClass("nicklist");
14 this.topic
= new SWMPanel(this.contentPanel
);
15 this.topic
.anchor
= SWM_ANCHOR_TOP
;
16 this.topic
.addClass("topic");
19 this.xlines
= new SWMPanel(this.contentPanel
);
20 this.lines
= this.xlines
.element
;
22 this.tab
= new Element("span");
23 this.tab
.addClass("tab");
25 this.tab
.appendText(name
);
26 this.tab
.addEvent("click", function() {
27 parentObject
.selectWindow(this);
30 parentObject
.tabPanel
.appendChild(this.tab
);
31 parentObject
.resize();
33 if(type
!= WINDOW_STATUS
) {
34 tabclose
= new Element("span");
35 tabclose
.addClass("tabclose");
36 tabclose
.addEvent("click", function(e
) {
39 if(type
== WINDOW_CHANNEL
)
40 this.client
.exec("/PART " + name
);
44 tabclose
.set("text", "X");
45 this.tab
.appendChild(tabclose
);
48 updateNickList: function(nicks
) {
51 this.nickList
.removeAllChildren();
52 nicks
.each(function(nick
) {
53 var e
= new Element("div");
54 this.nickList
.appendChild(e
);
55 e
.appendChild(document
.createTextNode(nick
));
58 this.parentObject
.resize();
60 updateTopic: function(topic
) {
63 this.topic
.removeAllChildren();
64 Colourise(topic
, this.topic
.element
);
66 this.parentObject
.resize();
71 this.contentPanel
.setHidden(false);
72 this.parentObject
.resize();
73 this.tab
.removeClass("tab-unselected");
74 this.tab
.addClass("tab-selected");
76 deselect: function() {
79 this.contentPanel
.setHidden(true);
80 this.parentObject
.resize();
81 this.tab
.removeClass("tab-selected");
82 this.tab
.addClass("tab-unselected");
87 this.parentObject
.mainPanel
.removeChild(this.contentPanel
.element
);
88 this.parentObject
.tabPanel
.removeChild(this.tab
);
90 addLine: function(type
, line
, colour
) {
91 var e
= new Element("div");
94 e
.setStyles({"background": colour
});
95 } else if(this.lastcolour
) {
96 e
.addClass("linestyle1");
98 e
.addClass("linestyle2");
101 this.lastcolour
= !this.lastcolour
;
103 this.parent(type
, line
, colour
, e
);
105 setHilighted: function(state
) {
109 this.tab
.addClass("tab-highlighted");
111 this.tab
.removeClass("tab-highlighted");
116 var SWMUI
= new Class({
118 initialize: function(parentElement
, theme
) {
119 this.parent(parentElement
, SWMUIWindow
, "swmui");
121 this.parentElement
= parentElement
;
124 postInitialize: function() {
125 this.rootFrame
= new SWMFrame(this.parentElement
);
127 this.tabPanel
= new SWMPanel(this.rootFrame
);
128 this.tabPanel
.anchor
= SWM_ANCHOR_TOP
;
129 this.tabPanel
.addClass("tabs");
131 this.mainPanel
= new SWMPanel(this.rootFrame
);
132 this.mainPanel
.addClass("main");
134 this.entryPanel
= new SWMPanel(this.rootFrame
);
135 this.entryPanel
.anchor
= SWM_ANCHOR_BOTTOM
;
136 this.entryPanel
.addClass("entry");
138 var form
= new Element("form");
140 var inputbox
= new Element("input");
141 inputbox
.setStyle("border", "0px");
143 window
.addEvent("resize", function() {
144 var s
= this.entryPanel
.getInnerSize().x
;
145 inputbox
.setStyle("width", s
+ "px");
148 form
.addEvent("submit", function(e
) {
151 this.getActiveWindow().client
.exec(inputbox
.value
);
155 this.entryPanel
.appendChild(form
);
156 form
.appendChild(inputbox
);
162 window
.fireEvent("resize");
164 loginBox: function(callback
, initialNickname
, initialChannels
, autoConnect
) {
165 this.parent(function(options
) {
166 this.postInitialize();
168 }.bind(this), intialNickname
, initialChannels
, autoConnect
);