]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/baseuiwindow.js
IE6 fix.
[irc/quakenet/qwebirc.git] / js / ui / baseuiwindow.js
CommitLineData
e20e5a6b 1qwebirc.ui.Window = new Class({
94b18192
CP
2 Implements: [Events],
3 initialize: function(parentObject, client, type, name, identifier) {
4 this.parentObject = parentObject;
5 this.type = type;
6 this.name = name;
7 this.active = false;
8 this.client = client;
9 this.identifier = identifier;
381fddfd
CP
10 this.hilighted = false;
11 this.scrolltimer = null;
9b63b053 12 this.commandhistory = this.parentObject.commandhistory;
25be5960 13 this.scrolleddown = true;
9b63b053 14 //new CommandHistory();
94b18192
CP
15 },
16 updateNickList: function(nicks) {
17 },
1f06a70a 18 updateTopic: function(topic, element) {
2cd9e32d 19 qwebirc.ui.Colourise("[" + topic + "]", element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this);
94b18192
CP
20 },
21 close: function() {
381fddfd
CP
22 if($defined(this.scrolltimer)) {
23 $clear(this.scrolltimer);
24 this.scrolltimer = null;
25 }
26
94b18192
CP
27 this.parentObject.__closed(this);
28 this.fireEvent("close", this);
29 },
30 select: function() {
31 this.active = true;
32 this.parentObject.__setActiveWindow(this);
381fddfd 33 if(this.hilighted)
349b99ed 34 this.setHilighted(false);
7c633700 35 if(this.scrolleddown)
25be5960 36 this.scrollToBottom();
94b18192
CP
37 },
38 deselect: function() {
7c633700 39 if(!this.parentObject.singleWindow)
25be5960 40 this.scrolleddown = this.scrolledDown();
7c633700
CP
41 if($defined(this.scrolltimer)) {
42 $clear(this.scrolltimer);
43 this.scrolltimer = null;
44 }
45
94b18192
CP
46 this.active = false;
47 },
30bd2620 48 addLine: function(type, line, colour, element) {
381fddfd 49 if(!this.active && !this.hilighted)
349b99ed 50 this.setHilighted(true);
381fddfd
CP
51 if(type)
52 line = this.parentObject.theme.message(type, line);
53
2cd9e32d 54 qwebirc.ui.Colourise(qwebirc.irc.IRCTimestamp(new Date()) + " " + line, element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this);
381fddfd
CP
55
56 this.scrollAdd(element);
94b18192
CP
57 },
58 errorMessage: function(message) {
59 this.addLine("", message, "red");
381fddfd
CP
60 },
61 setHilighted: function(state) {
62 this.hilighted = state;
63 },
25be5960 64 scrolledDown: function() {
7c633700
CP
65 if(this.scrolltimer)
66 return true;
67
381fddfd 68 var parent = this.lines;
381fddfd 69
381fddfd
CP
70 var prev = parent.getScroll();
71 var prevbottom = parent.getScrollSize().y;
72 var prevsize = parent.getSize();
25be5960 73
fccb1dac
CP
74 /* fixes an IE bug */
75 if(prevbottom < prevsize.y)
76 prevbottom = prevsize.y;
77
7c633700
CP
78 return prev.y + prevsize.y == prevbottom;
79 },
25be5960 80 scrollToBottom: function() {
7c633700
CP
81 var parent = this.lines;
82 var scrollparent = parent;
83
84 if($defined(this.scroller))
85 scrollparent = this.scroller;
86
87 scrollparent.scrollTo(parent.getScroll().x, parent.getScrollSize().y);
88 },
89 scrollAdd: function(element) {
90 var parent = this.lines;
381fddfd
CP
91
92 /* scroll in bursts, else the browser gets really slow */
93 if($defined(element)) {
25be5960 94 var sd = this.scrolledDown();
381fddfd 95 parent.appendChild(element);
7c633700 96 if(sd) {
381fddfd
CP
97 if(this.scrolltimer)
98 $clear(this.scrolltimer);
7c633700 99 this.scrolltimer = this.scrollAdd.delay(50, this, [null]);
381fddfd
CP
100 }
101 } else {
25be5960 102 this.scrollToBottom();
381fddfd
CP
103 this.scrolltimer = null;
104 }
9b63b053
CP
105 },
106 historyExec: function(line) {
107 this.commandhistory.addLine(line);
108 this.client.exec(line);
94b18192
CP
109 }
110});