diff options
author | Chris Porter <slug@qwebirc.org> | 2011-02-19 23:24:51 (GMT) |
---|---|---|
committer | Chris Porter <slug@qwebirc.org> | 2011-02-19 23:24:51 (GMT) |
commit | fe474b25f1a57d2765404415ccb2f7c3034292d1 (patch) | |
tree | 104e373e5b1082589c6846cf31be1fa829e77dd7 | |
parent | 69d40f107f1ec15436e4dce047e75bda05c80bd4 (diff) |
Tidy up style internals somewhat, and add ability for option based CSS.
-rw-r--r-- | css/qui.mcss | 42 | ||||
-rw-r--r-- | js/jslib.js | 11 | ||||
-rw-r--r-- | js/ui/baseui.js | 32 | ||||
-rw-r--r-- | js/ui/panes/options.js | 2 | ||||
-rw-r--r-- | js/ui/style.js | 8 |
5 files changed, 53 insertions, 42 deletions
diff --git a/css/qui.mcss b/css/qui.mcss index 8a6566b..ed4ec81 100644 --- a/css/qui.mcss +++ b/css/qui.mcss @@ -1,24 +1,24 @@ -topic_background=f2f0ff -lines_background=f2f0ff -topic_border=c8d2dc -tabbar_border=c3cee0 -tabbar_background=e2ecf9 -tabbar_text=000000 -tab_border=c8d2dc -tab_text=000000 -tab_hover=ffffff -tab_selected=ffffff -tab_selected_border=c8d2dc -tab_selected_text=333333 -input_border=c3cee0 -nicklist_border=c8d2dc -nicklist_background=f2f0ff -nicklist_text=000000 -nicklist_selected_border=c8d2dc -menu_border=c8d2dc -menu_background=f2f0ff -menu_hover_background=FFFFFE -lastpositionbar=C8D2DC +topic_background=c,f2f0ff +lines_background=c,f2f0ff +topic_border=c,c8d2dc +tabbar_border=c,c3cee0 +tabbar_background=c,e2ecf9 +tabbar_text=c,000000 +tab_border=c,c8d2dc +tab_text=c,000000 +tab_hover=c,ffffff +tab_selected=c,ffffff +tab_selected_border=c,c8d2dc +tab_selected_text=c,333333 +input_border=c,c3cee0 +nicklist_border=c,c8d2dc +nicklist_background=c,f2f0ff +nicklist_text=c,000000 +nicklist_selected_border=c,c8d2dc +menu_border=c,c8d2dc +menu_background=c,f2f0ff +menu_hover_background=c,FFFFFE +lastpositionbar=c,C8D2DC body { margin: 0; diff --git a/js/jslib.js b/js/jslib.js index ba9acf0..994bf41 100644 --- a/js/jslib.js +++ b/js/jslib.js @@ -17,6 +17,7 @@ qwebirc.util.dictCopy = function(d) { /* how horribly inefficient */ String.prototype.replaceAll = function(f, t) { + //return new RegExp("/" + RegExp.escape(f) + "/g").replace(f, RegExp.escape(t)); var i = this.indexOf(f); var c = this; @@ -117,15 +118,7 @@ qwebirc.util.pad = function(x) { } RegExp.escape = function(text) { - if(!arguments.callee.sRE) { - var specials = [ - '/', '.', '*', '+', '?', '|', - '(', ')', '[', ']', '{', '}', '\\' - ]; - arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g'); - } - - return text.replace(arguments.callee.sRE, '\\$1'); + return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); } qwebirc.ui.insertAt = function(position, parent, element) { diff --git a/js/ui/baseui.js b/js/ui/baseui.js index 2dfe7c0..deb3a04 100644 --- a/js/ui/baseui.js +++ b/js/ui/baseui.js @@ -193,6 +193,11 @@ qwebirc.ui.StandardUI = new Class({ this.uiOptions = new qwebirc.ui.DefaultOptionsClass(this, options.uiOptionsArg); this.customWindows = {}; + this.__styleValues = {hue: this.uiOptions.STYLE_HUE, saturation: 0, lightness: 0}; + if($defined(this.options.hue)) this.__styleValues.hue = this.options.hue; + if($defined(this.options.saturation)) this.__styleValues.saturation = this.options.saturation; + if($defined(this.options.lightness)) this.__styleValues.lightness = this.options.lightness; + var ev; if(Browser.Engine.trident) { ev = "keydown"; @@ -340,15 +345,30 @@ qwebirc.ui.StandardUI = new Class({ }, setModifiableStylesheet: function(name) { this.__styleSheet = new qwebirc.ui.style.ModifiableStylesheet(qwebirc.global.staticBaseURL + "css/" + name + qwebirc.FILE_SUFFIX + ".mcss"); - - this.setModifiableStylesheetValues($defined(this.options.hue) ? this.options.hue : this.uiOptions.STYLE_HUE, $defined(this.options.saturation) ? this.options.saturation : 0, $defined(this.options.lightness) ? this.options.lightness : 0); + this.setModifiableStylesheetValues({}); }, - setModifiableStylesheetValues: function(hue, saturation, lightness) { + setModifiableStylesheetValues: function(values) { + for(var k in values) + this.__styleValues[k] = values[k]; + if(!$defined(this.__styleSheet)) return; - this.__styleSheet.set(function(x) { - return x.setHue(hue).setSaturation(x.hsb[1] + saturation).setBrightness(x.hsb[2] + lightness); - }); + + var hue = this.__styleValues.hue, lightness = this.__styleValues.lightness, saturation = this.__styleValues.saturation; + + this.__styleSheet.set(function() { + var mode = arguments[0]; + if(mode == "c") { + var x = new Color(arguments[1]); + var c = x.setHue(hue).setSaturation(x.hsb[1] + saturation).setBrightness(x.hsb[2] + lightness); + if(c == "255,255,255") /* IE confuses white with transparent... */ + c = "255,255,254"; + + return "rgb(" + c + ")"; + } else if(mode == "o") { + return this.uiOptions[arguments[1]] ? arguments[2] : arguments[3]; + } + }.bind(this)); } }); diff --git a/js/ui/panes/options.js b/js/ui/panes/options.js index 512c0fd..c407110 100644 --- a/js/ui/panes/options.js +++ b/js/ui/panes/options.js @@ -46,7 +46,7 @@ qwebirc.config.DEFAULT_OPTIONS = [ return {class_: qwebirc.config.HueOption, default_: 210}; }, { applyChanges: function(value, ui) { - ui.setModifiableStylesheetValues(value, 0, 0); + ui.setModifiableStylesheetValues({hue: value}); } }], [12, "QUERY_ON_NICK_CLICK", "Query on nickname click in channel", false], diff --git a/js/ui/style.js b/js/ui/style.js index f3ef8dc..2ba10e5 100644 --- a/js/ui/style.js +++ b/js/ui/style.js @@ -66,12 +66,10 @@ qwebirc.ui.style.ModifiableStylesheet = new Class({ var text = this.__cssText; for(var key in this.rules) { - var value = mutator(new Color(this.rules[key])); + var s = this.rules[key].split(","); + var value = mutator.pass(s); - if(value == "255,255,255") /* IE confuses white with transparent... */ - value = "255,255,254"; - - text = text.replaceAll("$(" + key + ")", "rgb(" + value + ")"); + text = text.replaceAll("$(" + key + ")", value); } this.__setStylesheet(text); |