]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Tidy up style internals somewhat, and add ability for option based CSS.
authorChris Porter <redacted>
Sat, 19 Feb 2011 23:24:51 +0000 (23:24 +0000)
committerChris Porter <redacted>
Sat, 19 Feb 2011 23:24:51 +0000 (23:24 +0000)
css/qui.mcss
js/jslib.js
js/ui/baseui.js
js/ui/panes/options.js
js/ui/style.js

index 8a6566b534dc821f96c0a808f323a9530b0b1dfe..ed4ec81d96c7c688f4b3c189efeba55d62ef6c7b 100644 (file)
@@ -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;
index ba9acf0e3478d188f1b1f562334dee79e4708552..994bf419901aaf80947e1b49f54103b4b4b5f6c0 100644 (file)
@@ -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) {
index 2dfe7c09bf54673c5498388ae00967ba8c733b5a..deb3a04a4039ee1606856a393bd5a57acc07592a 100644 (file)
@@ -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));
   }
 });
 
index 512c0fd170ca5f02880030e9683cb74bd980382e..c40711023cebd2d4628c0349104ea8e7a611224b 100644 (file)
@@ -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],
index f3ef8dcb855320c92baca143f6472704a415ddce..2ba10e5d28927824eca346e4e4752c417c2fe248 100644 (file)
@@ -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);