]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add hue slider to options.
authorChris Porter <redacted>
Sun, 26 Jul 2009 03:40:31 +0000 (04:40 +0100)
committerChris Porter <redacted>
Sun, 26 Jul 2009 03:40:31 +0000 (04:40 +0100)
css/dialogs.css
js/ui/baseui.js
js/ui/panes/options.js
static/images/hue.png [new file with mode: 0644]

index 0efb1b0d8ab78c4d6f1a35802e821845b5f3f67b..3a6248b6142ea8e1d6e07584bdf3a6586a76d25b 100644 (file)
   font-size: 0.8em;
 }
 
+/************* OPTIONS *****************/
+
+.qwebirc-optionspane div.hue-slider {
+  border: 0px solid black;
+  width: 360px;
+  height: 8px;
+  background-image: url(/images/hue.png);
+}
+
+.qwebirc-optionspane div.hue-slider .knob {
+  width: 8px;
+  height: 16px;
+  top: -5px;
+  opacity: 0.75;
+  background: grey;
+  border: 1px solid black;
+}
+
index 8485043e09d302f9dbcf90b78b63f599267964bc..93e371b4dcac67c3a9c21ee9677079e7284381c9 100644 (file)
@@ -338,7 +338,7 @@ qwebirc.ui.StandardUI = new Class({
     if($defined(this.options.hue)) {
       this.setModifiableStylesheetValues(this.options.hue, 0, 0);
     } else {
-      this.setModifiableStylesheetValues(210, 0, 0);
+      this.setModifiableStylesheetValues(this.uiOptions.STYLE_HUE, 0, 0);
     }
   },
   setModifiableStylesheetValues: function(hue, saturation, lightness) {
index b93698e4af19b84c624920646a2e8ee30cfc312e..21e8f7a8dcfcb20e7fa0954d77932f7bd7243ac9 100644 (file)
@@ -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))
@@ -37,7 +33,14 @@ qwebirc.config.DEFAULT_OPTIONS = [
     enabled: qwebirc.ui.supportsFocus
   }],
   [9, "NICK_COLOURS", "Automatically colour nicknames", false],
-  [10, "HIDE_JOINPARTS", "Hide JOINS/PARTS/QUITS", 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;
@@ -85,6 +88,8 @@ qwebirc.config.Input = new Class({
       return;
       
     t.pass(x, this)();
+  },
+  cancel: function() {
   }
 });
 
@@ -104,6 +109,43 @@ 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");
+    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() {
@@ -172,7 +214,7 @@ qwebirc.config.Option = new Class({
   setSavedValue: function(x) {
     if(this.enabled)
       this.value = x;
-  }
+  },
 });
 
 qwebirc.config.RadioOption = new Class({
@@ -212,6 +254,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))
@@ -245,7 +292,9 @@ qwebirc.ui.Options = new Class({
         if(stype == "boolean") {
           type = qwebirc.config.CheckOption;
         } else {
-          type = qwebirc.config.TextOption;
+          var options = default_();
+          type = options.class_;
+          defualt_ = options.default_;
         }
         return new type(optionId, prefix, label, default_, moreextras);
       }
@@ -314,6 +363,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));
   },
@@ -324,6 +374,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));
   }
 });
 
diff --git a/static/images/hue.png b/static/images/hue.png
new file mode 100644 (file)
index 0000000..88a8e40
Binary files /dev/null and b/static/images/hue.png differ