mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 18:47:58 +01:00
Only call update() in (Command|Option|Map)#init if the extra config map was specified.
This commit is contained in:
@@ -39,21 +39,18 @@ const Command = Class("Command", {
|
|||||||
|
|
||||||
init: function (specs, description, action, extraInfo) {
|
init: function (specs, description, action, extraInfo) {
|
||||||
specs = Array.concat(specs); // XXX
|
specs = Array.concat(specs); // XXX
|
||||||
let expandedSpecs = Command.parseSpecs(specs);
|
let parsedSpecs = Command.parseSpecs(specs);
|
||||||
|
|
||||||
if (!extraInfo)
|
|
||||||
extraInfo = {};
|
|
||||||
|
|
||||||
this.specs = specs;
|
this.specs = specs;
|
||||||
this.shortNames = array(expandedSpecs).map(function (n) n[1]).compact();
|
this.shortNames = array(parsedSpecs).map(function (n) n[1]).compact();
|
||||||
this.longNames = expandedSpecs.map(function (n) n[0]);
|
this.longNames = parsedSpecs.map(function (n) n[0]);
|
||||||
this.name = this.longNames[0];
|
this.name = this.longNames[0];
|
||||||
this.names = array(expandedSpecs).flatten();
|
this.names = array(parsedSpecs).flatten();
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
|
||||||
extraInfo.privateData = Boolean(extraInfo.privateData); // XXX
|
if (extraInfo)
|
||||||
update(this, extraInfo);
|
update(this, extraInfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||||
|
// Copyright (c) 2007-2009 by Doug Kearns <dougkearns@gmail.com>
|
||||||
|
// Copyright (c) 2008-2009 by Kris Maglione <maglione.k at Gmail>
|
||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
@@ -31,15 +33,13 @@ const Map = Class("Map", {
|
|||||||
init: function (modes, keys, description, action, extraInfo) {
|
init: function (modes, keys, description, action, extraInfo) {
|
||||||
modes = Array.concat(modes).map(function (m) isobject(m) ? m.mask : m);
|
modes = Array.concat(modes).map(function (m) isobject(m) ? m.mask : m);
|
||||||
|
|
||||||
if (!extraInfo)
|
|
||||||
extraInfo = {};
|
|
||||||
|
|
||||||
this.modes = modes;
|
this.modes = modes;
|
||||||
this.names = keys.map(events.canonicalKeys);
|
this.names = keys.map(events.canonicalKeys);
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
||||||
update(this, extraInfo);
|
if (extraInfo)
|
||||||
|
update(this, extraInfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @property {number[]} All of the modes for which this mapping applies. */
|
/** @property {number[]} All of the modes for which this mapping applies. */
|
||||||
|
|||||||
@@ -28,9 +28,6 @@
|
|||||||
*/
|
*/
|
||||||
const Option = Class("Option", {
|
const Option = Class("Option", {
|
||||||
init: function (names, description, type, defaultValue, extraInfo) {
|
init: function (names, description, type, defaultValue, extraInfo) {
|
||||||
if (!extraInfo)
|
|
||||||
extraInfo = {};
|
|
||||||
|
|
||||||
this.name = names[0];
|
this.name = names[0];
|
||||||
this.names = names;
|
this.names = names;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -39,7 +36,8 @@ const Option = Class("Option", {
|
|||||||
if (arguments.length > 3)
|
if (arguments.length > 3)
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
|
|
||||||
update(this, extraInfo);
|
if (extraInfo)
|
||||||
|
update(this, extraInfo);
|
||||||
|
|
||||||
// add no{option} 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")
|
||||||
@@ -165,7 +163,8 @@ const Option = Class("Option", {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {value} The option's current value. The option's local value,
|
* @property {value} The option's current value. The option's local value,
|
||||||
* or if no local value is set, this is equal to the (@link #globalValue).
|
* or if no local value is set, this is equal to the
|
||||||
|
* (@link #globalValue).
|
||||||
*/
|
*/
|
||||||
get value() this.get(),
|
get value() this.get(),
|
||||||
set value(val) this.set(val),
|
set value(val) this.set(val),
|
||||||
@@ -330,7 +329,7 @@ const Option = Class("Option", {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} The scope of the option. This can be local, global,
|
* @property {number} The scope of the option. This can be local, global,
|
||||||
* or both.
|
* or both.
|
||||||
* @see Option#SCOPE_LOCAL
|
* @see Option#SCOPE_LOCAL
|
||||||
* @see Option#SCOPE_GLOBAL
|
* @see Option#SCOPE_GLOBAL
|
||||||
* @see Option#SCOPE_BOTH
|
* @see Option#SCOPE_BOTH
|
||||||
@@ -344,8 +343,8 @@ const Option = Class("Option", {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {value} The option's default value. This value will be used
|
* @property {value} The option's default value. This value will be used
|
||||||
* unless the option is explicitly set either interactively or in an RC
|
* unless the option is explicitly set either interactively or in an RC
|
||||||
* file or plugin.
|
* file or plugin.
|
||||||
*/
|
*/
|
||||||
defaultValue: null,
|
defaultValue: null,
|
||||||
|
|
||||||
@@ -364,7 +363,7 @@ const Option = Class("Option", {
|
|||||||
completer: null,
|
completer: null,
|
||||||
/**
|
/**
|
||||||
* @property {function} The function called to validate the option's value
|
* @property {function} The function called to validate the option's value
|
||||||
* when set.
|
* when set.
|
||||||
*/
|
*/
|
||||||
validator: function () {
|
validator: function () {
|
||||||
if (this.completer)
|
if (this.completer)
|
||||||
@@ -373,15 +372,15 @@ const Option = Class("Option", {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @property The function called to determine whether the option already
|
* @property The function called to determine whether the option already
|
||||||
* contains a specified value.
|
* contains a specified value.
|
||||||
* @see #has
|
* @see #has
|
||||||
*/
|
*/
|
||||||
checkHas: null,
|
checkHas: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {boolean} Set to true whenever the option is first set. This
|
* @property {boolean} Set to true whenever the option is first set. This
|
||||||
* is useful to see whether it was changed from its default value
|
* is useful to see whether it was changed from its default value
|
||||||
* interactively or by some RC file.
|
* interactively or by some RC file.
|
||||||
*/
|
*/
|
||||||
hasChanged: false,
|
hasChanged: false,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user