]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Fixes issue 49, also option widgets can now have a default disabled value, rather...
authorChris Porter <redacted>
Sun, 21 Jun 2009 16:18:10 +0000 (17:18 +0100)
committerChris Porter <redacted>
Sun, 21 Jun 2009 16:18:10 +0000 (17:18 +0100)
js/ui/panes/options.js

index 7da215ef2d742d6c7edbe882956382fbb2d7b134..da7020c62ed4c8e680ba2e6b26fbd90e56c493f0 100644 (file)
@@ -4,18 +4,28 @@ qwebirc.config.RADIO_BUTTONS = 3;
 
 qwebirc.config.DEFAULT_OPTIONS = [
   [1, "BEEP_ON_MENTION", "Beep when nick mentioned or on query activity (requires Flash)", true, {
-    render: function(input) {
-      if(!$defined(Browser.Plugins.Flash) || Browser.Plugins.Flash.version < 8) {
-        input.disabled = true;
-        input.checked = false;
-      }
+    enabled: function() {
+      if(!$defined(Browser.Plugins.Flash) || Browser.Plugins.Flash.version < 8)
+        return [false, false]; /* [disabled, default_value] */
+      return [true];
     },
     get: function(value, ui) {
       if(ui.setBeepOnMention)
         ui.setBeepOnMention(value);
     }
   }],
-  [7, "FLASH_ON_MENTION", "Flash titlebar when nick mentioned or on query activity", true],
+  [7, "FLASH_ON_MENTION", "Flash titlebar when nick mentioned or on query activity", true, {
+    enabled: function() {
+      var ua = navigator.userAgent;
+      if(!$defined(ua))
+        return [true];
+        
+      if(Browser.Engine.ipod || ua.indexOf("KHTML") != -1)
+        return [false, false];
+
+      return [true];
+    }
+  }],
   [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],
@@ -29,6 +39,7 @@ qwebirc.config.Input = new Class({
   initialize: function(parent, option, position, parentObject) {
     this.option = option;
     this.value = option.value;
+    this.enabled = this.option.enabled;
     this.position = position;
     this.parentElement = parent;
     this.parentObject = parentObject;
@@ -77,7 +88,8 @@ qwebirc.config.TextInput = new Class({
     this.mainElement = i;
     
     i.value = this.value;
-
+    i.disabled = !this.enabled;
+    
     this.parent();
   },
   get: function() {
@@ -92,7 +104,8 @@ qwebirc.config.CheckInput = new Class({
     this.mainElement = i;
     
     i.checked = this.value;
-    
+    i.disabled = !this.enabled;
+
     this.parent();
   },
   get: function() {
@@ -106,12 +119,13 @@ qwebirc.config.RadioInput = new Class({
     var value = this.option.options;
     
     this.elements = [];
-    
+     
     for(var i=0;i<value.length;i++) {
       var d = this.FE("div", this.parentObject);
       var e = this.createInput("radio", d, "options_radio" + this.position, i == this.option.position);
       this.elements.push(e);
-      
+      e.disabled = !this.enabled;
+   
       if(i == 0)
         this.mainElement = e;
       
@@ -137,6 +151,16 @@ qwebirc.config.Option = new Class({
     this.default_ = default_;
     this.optionId = optionId;
     this.extras = extras;
+    
+    if($defined(extras) && $defined(extras.enabled)) {
+      var enabledResult = extras.enabled();
+      this.enabled = enabledResult[0];
+      
+      if(!enabledResult[0] && enabledResult.length > 1)
+        this.default_ = enabledResult[1];
+    } else {
+      this.enabled = true;
+    }    
   },
   setSavedValue: function(x) {
     this.value = x;