1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 23:42:27 +01:00

use extraInfo 'hash' as the last parameter to the Option constructor function

This commit is contained in:
Doug Kearns
2008-09-03 03:50:36 +00:00
parent 6a4abdff1b
commit 9dd8ca470f

View File

@@ -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. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** 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 // 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, extraInfo) //{{{
liberator.Option = function (names, description, type, defaultValue, scope, getter, setter, validator, completer) //{{{
{ {
if (!names || !type) if (!names || !type)
return null; return null;
if (!extraInfo)
extraInfo = {};
var value = null; var value = null;
this.name = names[0]; this.name = names[0];
this.names = names; this.names = names;
this.type = type; 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 || ""; this.description = description || "";
// "", 0 are valid default values // "", 0 are valid default values
this.defaultValue = (defaultValue === undefined) ? null : defaultValue; this.defaultValue = (defaultValue === undefined) ? null : defaultValue;
value = this.defaultValue; value = this.defaultValue;
this.setter = setter || null; this.setter = extraInfo.setter || null;
this.getter = getter || null; this.getter = extraInfo.getter || null;
this.completer = completer || null; this.completer = extraInfo.completer || null;
this.validator = validator || null; this.validator = extraInfo.validator || null;
// this property is set to true whenever the option is first set // this property is set to true whenever the option is first set
// useful to see whether it was changed by some rc file // useful to see whether it was changed by some rc file
this.hasChanged = false; 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") if (this.type == "boolean")
{ {
this.names = []; // reset since order is important this.names = []; // reset since order is important
@@ -203,7 +205,7 @@ liberator.Options = function () //{{{
{ {
case prefService.PREF_STRING: case prefService.PREF_STRING:
var value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data; 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) && if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) &&
/^chrome:\/\/.+\/locale\/.+\.properties/.test(value)) /^chrome:\/\/.+\/locale\/.+\.properties/.test(value))
value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data; value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data;
@@ -775,8 +777,7 @@ liberator.Options = function () //{{{
if (!extraInfo) if (!extraInfo)
extraInfo = {}; extraInfo = {};
var option = new liberator.Option(names, description, type, defaultValue, extraInfo.scope, var option = new liberator.Option(names, description, type, defaultValue, extraInfo);
extraInfo.getter, extraInfo.setter, extraInfo.validator, extraInfo.completer);
if (!option) if (!option)
return false; return false;