]> jfr.im git - irc/quakenet/qwebirc.git/blob - static/js/mochaui.js
Add MochaUI.
[irc/quakenet/qwebirc.git] / static / js / mochaui.js
1 /* qwebirc -- Copyright (C) 2008 Chris Porter --- All rights reserved. */
2
3 var QMochaUIWindow=new Class({Extends:UIWindow,initialize:function(G,B,E,D){this.parent(G,B,E,D);this.lines=new Element("div",{styles:{overflow:"auto",width:"90"}});this.form=new Element("form");this.inputbox=new Element("input",{styles:{border:0,width:"100%"}});this.inputbox.addClass("input");this.form.addEvent("submit",function(H){new Event(H).stop();this.client.exec(this.inputbox.value);this.inputbox.value=""}.bind(this));this.form.appendChild(this.inputbox);var C={width:500,height:400,title:D,footerHeight:0,toolbar:true,container:$("pageWrapper"),toolbarHeight:G.inputHeight,toolbarPosition:"bottom",toolbarContent:"",content:this.lines,onFocus:function(){G.selectWindow(this)}.bind(this),onClose:function(){if(E==WINDOW_CHANNEL){this.client.exec("/PART "+D)}this.close()}.bind(this)};if(E==WINDOW_STATUS){C.closable=false}var A=new MochaUI.Window(C);var F=$(A.options.id+"_toolbar");F.appendChild(this.form);return },updateNickList:function(A){this.parent(A);return ;var B=this.nicklist;while(B.firstChild){B.removeChild(B.firstChild)}A.each(function(C){var D=new Element("div");B.appendChild(D);D.appendChild(document.createTextNode(C))})},updateTopic:function(A){this.parent(A);return ;var B=this.topic;while(B.firstChild){B.removeChild(B.firstChild)}Colourise(A,B)},addLine:function(D,A,G){this.parent(D,A,G);var F=new Element("div");if(G){F.setStyles({background:G})}else{if(this.lastcolour){F.addClass("linestyle1")}else{F.addClass("linestyle2")}}if(D){A=this.parentObject.theme.message(D,A)}Colourise(IRCTimestamp(new Date())+" "+A,F);this.lastcolour=!this.lastcolour;var E=this.lines.getScroll();var C=this.lines.getScrollSize().y;var B=this.lines.getSize();this.lines.appendChild(F);this.lines.scrollTo(E.x,this.lines.getScrollSize().y);if(!this.active){this.lines.showLoadingIcon()}}});var QMochaUI=new Class({Extends:UI,initialize:function(A,B){this.parent(A,QMochaUIWindow,"mochaui");this.theme=B;this.parentElement=A;window.addEvent("domready",function(){var C=new Element("input",{styles:{border:0}});this.parentElement.appendChild(C);this.inputHeight=C.getSize().y;this.parentElement.removeChild(C);MochaUI.Desktop=new MochaUI.Desktop();MochaUI.Dock=new MochaUI.Dock();MochaUI.Modal=new MochaUI.Modal();MochaUI.options.useEffects=false}.bind(this));window.addEvent("unload",function(){if(MochaUI){MochaUI.garbageCleanUp()}})},postInitialize:function(){return ;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 B=new Element("form");var A=new Element("input");A.addClass("input");B.addEvent("submit",function(C){new Event(C).stop();this.getActiveWindow().client.exec(A.value);A.value=""}.bind(this));this.parentElement.appendChild(B);B.appendChild(A);A.focus()},loginBox:function(B,C,A){this.parent(function(D){this.postInitialize();B(D)}.bind(this),C,A)}});