X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/85449eee7cbb5c314a3f615e44474386985c5e2e..c0f2f36718c47c1e61645ea3c20b641428de0899:/js/ui/panes/options.js diff --git a/js/ui/panes/options.js b/js/ui/panes/options.js index 221d105..2422f75 100644 --- a/js/ui/panes/options.js +++ b/js/ui/panes/options.js @@ -1,7 +1,3 @@ -qwebirc.config.CHECK_BOX = 1; -qwebirc.config.TEXT_BOX = 2; -qwebirc.config.RADIO_BUTTONS = 3; - qwebirc.ui.supportsFocus = function() { var ua = navigator.userAgent; if(!$defined(ua)) @@ -13,6 +9,10 @@ qwebirc.ui.supportsFocus = function() { return [true]; } +/** + * Note that options are settable by the uioptions url arg by default unless you specifiy + * settableByURL... + */ qwebirc.config.DEFAULT_OPTIONS = [ [1, "BEEP_ON_MENTION", "Beep when nick mentioned or on query activity (requires Flash)", true, { enabled: function() { @@ -30,13 +30,25 @@ qwebirc.config.DEFAULT_OPTIONS = [ }], [2, "DEDICATED_MSG_WINDOW", "Send privmsgs to dedicated messages window", false], [4, "DEDICATED_NOTICE_WINDOW", "Send notices to dedicated message window", false], - [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames in nicklist", true], - [5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true], - [6, "USE_HIDDENHOST", "Hide your hostmask when authed to Q (+x)", true], + [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames in channel lines", true], + [5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true, { + settableByURL: false + }], + [6, "USE_HIDDENHOST", "Hide your hostmask when authed to Q (+x)", true, { + settableByURL: false + }], [8, "LASTPOS_LINE", "Show a last position indicator for each window", true, { enabled: qwebirc.ui.supportsFocus }], - [9, "NICK_COLOURS", "Automatically colour nicknames", false] + [9, "NICK_COLOURS", "Automatically colour nicknames", false], + [10, "HIDE_JOINPARTS", "Hide JOINS/PARTS/QUITS", false], + [11, "STYLE_HUE", "Adjust user interface hue", function() { + return {class_: qwebirc.config.HueOption, default_: 210}; + }, { + get: function(value, ui) { + ui.setModifiableStylesheetValues(value, 0, 0); + } + }] ]; qwebirc.config.DefaultOptions = null; @@ -84,6 +96,8 @@ qwebirc.config.Input = new Class({ return; t.pass(x, this)(); + }, + cancel: function() { } }); @@ -103,6 +117,47 @@ qwebirc.config.TextInput = new Class({ } }); +qwebirc.config.HueInput = new Class({ + Extends: qwebirc.config.Input, + render: function() { + var i = new Element("div"); + i.addClass("qwebirc-optionspane"); + i.addClass("hue-slider"); + this.parentElement.appendChild(i); + + var k = new Element("div"); + k.addClass("knob"); + if(Browser.Engine.trident) { + k.setStyle("top", "0px"); + k.setStyle("background-color", "black"); + } + + i.appendChild(k); + + var slider = new Slider(i, k, {steps: 36, range: [0, 369], wheel: true}); + slider.set(this.value); + this.startValue = this.value; + + slider.addEvent("change", function(step) { + this.value = step; + this.get(); + }.bind(this)); + this.mainElement = i; + + if(!this.enabled) + slider.detach(); + + this.parent(); + }, + get: function() { + return this.parent(this.value); + }, + cancel: function() { + this.value = this.startValue; + this.get(); + } +}); + qwebirc.config.CheckInput = new Class({ Extends: qwebirc.config.Input, render: function() { @@ -166,7 +221,13 @@ qwebirc.config.Option = new Class({ this.default_ = enabledResult[1]; } else { this.enabled = true; - } + } + + if($defined(extras) && $defined(extras.settableByURL)) { + this.settableByURL = extras.settableByURL; + } else { + this.settableByURL = true; + } }, setSavedValue: function(x) { if(this.enabled) @@ -211,6 +272,11 @@ qwebirc.config.CheckOption = new Class({ Element: qwebirc.config.CheckInput }); +qwebirc.config.HueOption = new Class({ + Extends: qwebirc.config.Option, + Element: qwebirc.config.HueInput +}); + qwebirc.ui.Options = new Class({ initialize: function(ui) { if(!$defined(qwebirc.config.DefaultOptions)) @@ -243,6 +309,10 @@ qwebirc.ui.Options = new Class({ var type; if(stype == "boolean") { type = qwebirc.config.CheckOption; + } else if(stype == "function") { + var options = default_(); + type = options.class_; + default_ = options.default_; } else { type = qwebirc.config.TextOption; } @@ -313,6 +383,7 @@ qwebirc.ui.OptionsPane = new Class({ var cancel = qwebirc.util.createInput("submit", cellb); cancel.value = "Cancel"; cancel.addEvent("click", function() { + this.cancel(); this.fireEvent("close"); }.bind(this)); }, @@ -323,6 +394,11 @@ qwebirc.ui.OptionsPane = new Class({ this.optionObject.setValue(option, box.get()); }.bind(this)); this.optionObject.flush(); + }, + cancel: function() { + this.boxList.forEach(function(x) { + x[1].cancel(); + }.bind(this)); } }); @@ -349,6 +425,41 @@ qwebirc.ui.CookieOptions = new Class({ } }); +qwebirc.ui.SuppliedArgOptions = new Class({ + Extends: qwebirc.ui.CookieOptions, + initialize: function(ui, arg) { + var p = {}; + + if($defined(arg) && arg != "") { + var decoded = qwebirc.util.b64Decode(arg); + if(decoded) + p = qwebirc.util.parseURI("?" + decoded); + } + + this.parsedOptions = p; + this.parent(ui); + }, + _get: function(x) { + if(x.settableByURL !== true) + return this.parent(x); + + var opt = this.parsedOptions[x.optionId]; + if(!$defined(opt)) + return this.parent(x); + + return opt; + }, + serialise: function() { + var result = []; + this.getOptionList().forEach(function(x) { + if(x.settableByURL && x.default_ != x.value) + result.push(x.optionId + "=" + x.value); + }.bind(this)); + + return qwebirc.util.b64Encode(result.join("&")).replaceAll("=", ""); + } +}); + qwebirc.ui.DefaultOptionsClass = new Class({ - Extends: qwebirc.ui.CookieOptions + Extends: qwebirc.ui.SuppliedArgOptions });