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