]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/panes/options.js
make hue overridding more logical
[irc/quakenet/qwebirc.git] / js / ui / panes / options.js
index 1ed73e466438372d5702238bc7fdd35e6a81054d..e3fd86ca90db67c83a9840bfb2797d2dd76ac61b 100644 (file)
@@ -14,12 +14,23 @@ qwebirc.ui.supportsFocus = function() {
  * settableByURL...
  */
 qwebirc.config.DEFAULT_OPTIONS = [
-  [1, "BEEP_ON_MENTION", "Beep when nick mentioned or on query activity", true, {
+  [1, "BEEP_ON_MENTION", "Beep on activity", true, {
     applyChanges: function(value, ui) {
       if(ui.setBeepOnMention)
         ui.setBeepOnMention(value);
     }
   }],
+  [16, "NOTIFICATIONS", "Emit HTML5 notifications on activity", false, {
+    enabled: function() {
+      if(!("Notification" in window))
+        return [false, false]; /* [disabled, default_value] */
+      return [true];
+    },
+    applyChanges: function(value, ui) {
+      if(ui.setNotifications)
+        ui.setNotifications(value);
+    }
+  }],
   [7, "FLASH_ON_MENTION", "Flash titlebar when nick mentioned or on query activity", true, {
     enabled: qwebirc.ui.supportsFocus
   }],
@@ -37,15 +48,15 @@ qwebirc.config.DEFAULT_OPTIONS = [
   }],
   [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};
+  [11, "STYLE_HUE", "Adjust user interface hue", function(ui) {
+    return {class_: qwebirc.config.HueOption, default_: ui.__styleValues.hue};
   }, {
     applyChanges: function(value, ui) {
       ui.setModifiableStylesheetValues({hue: value});
     }
   }],
   [12, "QUERY_ON_NICK_CLICK", "Query on nickname click in channel", false],
-  [13, "SHOW_NICKLIST", "Show nickname list in channels", true],
+  [13, "SHOW_NICKLIST", "Show nickname list in channels", qwebirc.util.deviceHasKeyboard()],
   [14, "SHOW_TIMESTAMPS", "Show timestamps", true], /* we rely on the hue update */
   [15, "SIDE_TABS", "Show tabs on the side", false, {
     enabled: function() {
@@ -286,13 +297,14 @@ qwebirc.config.HueOption = new Class({
 
 qwebirc.ui.Options = new Class({
   initialize: function(ui) {
+    this.ui = ui;
+
     if(!$defined(qwebirc.config.DefaultOptions))
       this.__configureDefaults();
     
     this.optionList = qwebirc.config.DefaultOptions.slice();
-    this.optionHash = {}
-    this.ui = ui;
-    
+    this.optionHash = {};
+
     this._setup();
     this.optionList.forEach(function(x) {
       x.setSavedValue(this._get(x));
@@ -317,7 +329,7 @@ qwebirc.ui.Options = new Class({
         if(stype == "boolean") {
           type = qwebirc.config.CheckOption;
         } else if(stype == "function") {
-          var options = default_();
+          var options = default_.call(this, this.ui);
           type = options.class_;
           default_ = options.default_;
         } else {
@@ -325,12 +337,16 @@ qwebirc.ui.Options = new Class({
         }
         return new type(optionId, prefix, label, default_, moreextras);
       }
-    });
+    }, this);
   },
   setValue: function(option, value) {
     this.optionHash[option.prefix].value = value;
     this[option.prefix] = value;
   },
+  setValueByPrefix: function(prefix, value) {
+    this.optionHash[prefix].value = value;
+    this[prefix] = value;
+  },
   getOptionList: function() {
     return this.optionList;
   },