+ loginBox: function(callback, initialNickname, initialChannels, autoConnect, autoNick) {
+ qwebirc.ui.GenericLoginBox(this.parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick, this.options.networkName);
+ },
+ focusChange: function(newValue) {
+ var window_ = this.getActiveWindow();
+ if($defined(window_))
+ window_.focusChange(newValue);
+ }
+});
+
+qwebirc.ui.StandardUI = new Class({
+ Extends: qwebirc.ui.BaseUI,
+ UICommands: qwebirc.ui.UI_COMMANDS,
+ initialize: function(parentElement, windowClass, uiName, options) {
+ this.parent(parentElement, windowClass, uiName, options);
+
+ this.__styleValues = {hue: qwebirc.ui.DEFAULT_HUE, saturation: 0, lightness: 0, textHue: null, textSaturation: null, textLightness: null};
+ if($defined(this.options.hue)) this.__styleValues.hue = this.options.hue;
+ this.tabCompleter = new qwebirc.ui.TabCompleterFactory(this);
+ this.uiOptions = new qwebirc.ui.DefaultOptionsClass(this, options.uiOptionsArg);
+ this.customWindows = new QHash();
+
+ if($defined(this.options.saturation)) this.__styleValues.saturation = this.options.saturation;
+ if($defined(this.options.lightness)) this.__styleValues.lightness = this.options.lightness;
+ if($defined(this.options.tsaturation)) this.__styleValues.textSaturation = this.options.tsaturation;
+ if($defined(this.options.tlightness)) this.__styleValues.textLightness = this.options.tlightness;
+
+ if($defined(this.options.hue)) { /* overridden in url */
+ /* ugh... this will go away when we add proper options for hue/sat/light for text and background */
+ this.uiOptions.setValueByPrefix("STYLE_HUE", this.__styleValues.hue);
+ } else {
+ this.__styleValues.hue = this.uiOptions.STYLE_HUE; /* otherwise copy from serialised store */
+ }
+ this.__styleValues.textHue = $defined(this.options.thue) ? this.options.thue : this.__styleValues.hue;
+
+ document.addEvent("keydown", this.__handleHotkey.bind(this));
+ },
+ __handleHotkey: function(x) {
+ var success = false;
+ if(!x.alt && !x.control && !x.shift && !x.meta) {
+ if((x.key == "backspace" || x.key == "/") && !this.getInputFocused(x)) {
+ success = true;
+ }
+ } else if(!x.alt || x.control || x.meta) {
+ /* do nothing */
+ } else if(x.key == "a" || x.key == "A") {
+ var highestNum = 0;
+ var highestIndex = -1;
+ success = true;
+
+ for(var i=0;i<this.windowArray.length;i++) {
+ var h = this.windowArray[i].hilighted;
+ if(h > highestNum) {
+ highestIndex = i;
+ highestNum = h;
+ }
+ }
+ if(highestIndex > -1)
+ this.selectWindow(this.windowArray[highestIndex]);
+ } else if((x.key >= '0' && x.key <= '9') && !x.shift) {
+ success = true;
+
+ number = x.key - '0';
+ if(number == 0)
+ number = 10
+
+ number = number - 1;
+
+ if(number >= this.windowArray.length)
+ return;
+
+ this.selectWindow(this.windowArray[number]);
+ } else if((x.key == "left" || x.key == "up") && !x.shift) {
+ this.prevWindow();
+ success = true;
+ } else if((x.key == "right" || x.key == "down") && !x.shift) {
+ this.nextWindow();
+ success = true;
+ }
+
+ if(success) {
+ new Event(x).stop();
+ x.preventDefault();
+ }
+ },
+ getInputFocused: function(x) {
+ if($$("input").indexOf(x.target) == -1 && $$("textarea").indexOf(x.target) == -1)
+ return false;
+ return true;
+ },
+ newCustomWindow: function(name, select, type) {
+ if(!type)
+ type = qwebirc.ui.WINDOW_CUSTOM;
+
+ var w = this.newWindow(qwebirc.ui.CUSTOM_CLIENT, type, name);
+ w.addEvent("close", function(w) {
+ this.windows.get(qwebirc.ui.CUSTOM_CLIENT).remove(w.identifier);
+ }.bind(this));
+
+ if(select)
+ this.selectWindow(w);
+
+ return w;
+ },
+ addCustomWindow: function(windowName, class_, cssClass, options) {
+ if(!$defined(options))
+ options = {};
+
+ if(this.customWindows.contains(windowName)) {
+ this.selectWindow(this.customWindows.get(windowName));
+ return;
+ }
+
+ var d = this.newCustomWindow(windowName, true);
+ this.customWindows.put(windowName, d);
+
+ d.addEvent("close", function() {
+ this.customWindows.remove(windowName);
+ }.bind(this));
+
+ if(cssClass)
+ d.lines.addClass("qwebirc-" + cssClass);
+
+ var ew = new class_(d.lines, options);
+ ew.addEvent("close", function() {
+ d.close();
+ }.bind(this));
+
+ d.setSubWindow(ew);
+ },
+ embeddedWindow: function() {
+ this.addCustomWindow("Add webchat to your site", qwebirc.ui.EmbedWizard, "embeddedwizard", {baseURL: this.options.baseURL, uiOptions: this.uiOptions, optionsCallback: function() {
+ this.optionsWindow();
+ }.bind(this)});
+ },
+ optionsWindow: function() {
+ this.addCustomWindow("Options", qwebirc.ui.OptionsPane, "optionspane", this.uiOptions);
+ },
+ aboutWindow: function() {
+ this.addCustomWindow("About", qwebirc.ui.AboutPane, "aboutpane", this.uiOptions);
+ },
+ privacyWindow: function() {
+ this.addCustomWindow("Privacy policy", qwebirc.ui.PrivacyPolicyPane, "privacypolicypane", this.uiOptions);
+ },
+ feedbackWindow: function() {
+ this.addCustomWindow("Feedback", qwebirc.ui.FeedbackPane, "feedbackpane", this.uiOptions);
+ },
+ helpWindow: function() {
+ this.addCustomWindow("Help!", qwebirc.ui.HelpPane, "helppane", this.uiOptions);
+ },
+ urlDispatcher: function(name, window) {
+ if(name == "embedded")
+ return ["a", this.embeddedWindow.bind(this)];
+
+ if(name == "options")
+ return ["a", this.optionsWindow.bind(this)];