Bug 448107 – Revise EnableTextbox to be more element generic
authorIan Neal <iann_cvs@blueyonder.co.uk>
Fri, 01 Aug 2008 23:07:29 +0100
changeset 52 4a777e17bf3005264042c2000f537b3bd284f715
parent 51 cbc5d52cd47e3aa9623b7a7ef80f15042d1c1be9
child 53 74b5b7c1efcea0241c59b7168b2239d625d8e90a
push idunknown
push userunknown
push dateunknown
bugs448107
Bug 448107 – Revise EnableTextbox to be more element generic p=me r=mnyromyr sr=neil
mailnews/base/prefs/resources/content/pref-offline.js
mailnews/base/prefs/resources/content/pref-viewing_messages.js
suite/common/pref/preferences.js
--- a/mailnews/base/prefs/resources/content/pref-offline.js
+++ b/mailnews/base/prefs/resources/content/pref-offline.js
@@ -36,16 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 // The contents of this file will be loaded into the scope of the object
 // <prefpane id="offline_pane">!
 
 function Startup()
 {
   var value = document.getElementById("mail.prompt_purge_threshhold").value;
-  EnableTextbox("offlineCompactFolderMin", value, false);
+  EnableElementById("offlineCompactFolderMin", value, false);
 }
 
 function EnableMailPurgeThreshhold(aValue)
 {
   var focus = (document.getElementById("offlineCompactFolder") == document.commandDispatcher.focusedElement);
-  EnableTextbox("offlineCompactFolderMin", aValue, focus);
+  EnableElementById("offlineCompactFolderMin", aValue, focus);
 }
--- a/mailnews/base/prefs/resources/content/pref-viewing_messages.js
+++ b/mailnews/base/prefs/resources/content/pref-viewing_messages.js
@@ -42,18 +42,18 @@
 function Startup()
 {
   var autoPref = document.getElementById("mailnews.mark_message_read.auto");
   UpdateMarkAsReadOptions(autoPref.value);
 }
 
 function UpdateMarkAsReadOptions(aEnableRadioGroup)
 {
-  EnableTextbox("markAsReadAutoPreferences", aEnableRadioGroup, false);
+  EnableElementById("markAsReadAutoPreferences", aEnableRadioGroup, false);
   // ... and the extras!
   var delayPref = document.getElementById("mailnews.mark_message_read.delay");
   UpdateMarkAsReadTextbox(aEnableRadioGroup && delayPref.value, false);
 }
 
 function UpdateMarkAsReadTextbox(aEnable, aFocus)
 {
-  EnableTextbox("markAsReadDelay", aEnable, aFocus);
+  EnableElementById("markAsReadDelay", aEnable, aFocus);
 }
--- a/suite/common/pref/preferences.js
+++ b/suite/common/pref/preferences.js
@@ -15,16 +15,17 @@
  * The Original Code is SeaMonkey Project Code.
  *
  * The Initial Developer of the Original Code is
  * Bruno Escherl <aqualon@aquachan.de>.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ *   Ian Neal <iann_bugzilla@blueyonder.co.uk>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -33,19 +34,23 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // The content of this file is loaded into the scope of the
 // prefwindow and will be available to all prefpanes!
 
-function EnableTextbox(aTextboxId, aEnable, aFocus)
+function EnableElementById(aElementId, aEnable, aFocus)
 {
-  let textbox = document.getElementById(aTextboxId);
-  let pref = document.getElementById(textbox.getAttribute("preference"));
+  EnableElement(document.getElementById(aElementId), aEnable, aFocus);
+}
+
+function EnableElement(aElement, aEnable, aFocus)
+{
+  let pref = document.getElementById(aElement.getAttribute("preference"));
   let enabled = aEnable && !pref.locked;
 
-  textbox.disabled = !enabled;
+  aElement.disabled = !enabled;
 
   if (enabled && aFocus)
-    textbox.focus();
+    aElement.focus();
 }