From 9dd8ca470f59f70be35f189750c42b94ac8e7437 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 3 Sep 2008 03:50:36 +0000 Subject: [PATCH] use extraInfo 'hash' as the last parameter to the Option constructor function --- content/options.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/content/options.js b/content/options.js index 3c3978bb..a8fcf0d5 100644 --- a/content/options.js +++ b/content/options.js @@ -26,36 +26,38 @@ 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 *****/ -// Do NOT create instances of this class yourself, use the helper method +// do NOT create instances of this class yourself, use the helper method // liberator.options.add() instead -// FIXME: why is this arg list not reflecting that of Command, or vice versa? -liberator.Option = function (names, description, type, defaultValue, scope, getter, setter, validator, completer) //{{{ +liberator.Option = function (names, description, type, defaultValue, extraInfo) //{{{ { if (!names || !type) return null; + if (!extraInfo) + extraInfo = {}; + var value = null; this.name = names[0]; this.names = names; this.type = type; - this.scope = (scope & liberator.options.OPTION_SCOPE_BOTH) || liberator.options.OPTION_SCOPE_GLOBAL; // XXX set to BOTH by default someday? - kstep + this.scope = (extraInfo.scope & liberator.options.OPTION_SCOPE_BOTH) || liberator.options.OPTION_SCOPE_GLOBAL; // XXX set to BOTH by default someday? - kstep this.description = description || ""; // "", 0 are valid default values this.defaultValue = (defaultValue === undefined) ? null : defaultValue; value = this.defaultValue; - this.setter = setter || null; - this.getter = getter || null; - this.completer = completer || null; - this.validator = validator || null; + this.setter = extraInfo.setter || null; + this.getter = extraInfo.getter || null; + this.completer = extraInfo.completer || null; + this.validator = extraInfo.validator || null; // this property is set to true whenever the option is first set // useful to see whether it was changed by some rc file this.hasChanged = false; - // add noOPTION variant of boolean OPTION to this.names + // add no{option} variant of boolean {option} to this.names if (this.type == "boolean") { this.names = []; // reset since order is important @@ -203,7 +205,7 @@ liberator.Options = function () //{{{ { case prefService.PREF_STRING: var value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data; - // Try in case it's a localized string (will throw an exception if not) + // try in case it's a localized string (will throw an exception if not) if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) && /^chrome:\/\/.+\/locale\/.+\.properties/.test(value)) value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data; @@ -775,8 +777,7 @@ liberator.Options = function () //{{{ if (!extraInfo) extraInfo = {}; - var option = new liberator.Option(names, description, type, defaultValue, extraInfo.scope, - extraInfo.getter, extraInfo.setter, extraInfo.validator, extraInfo.completer); + var option = new liberator.Option(names, description, type, defaultValue, extraInfo); if (!option) return false;