add setDefaultValues instead of doing two things in setDefaultValue
This commit is contained in:
parent
38ca543035
commit
a6a26864df
1 changed files with 10 additions and 7 deletions
|
|
@ -260,15 +260,18 @@ exports.resetOptions = function(obj) {
|
||||||
|
|
||||||
exports.setDefaultValue = function(path, name, value) {
|
exports.setDefaultValue = function(path, name, value) {
|
||||||
var opts = defaultOptions[path] || (defaultOptions[path] = {});
|
var opts = defaultOptions[path] || (defaultOptions[path] = {});
|
||||||
if (typeof name == "string") {
|
if (opts[name]) {
|
||||||
if (opts[name])
|
if (opts.forwardTo)
|
||||||
|
exports.setDefaultValue(opts.forwardTo, name, value)
|
||||||
|
else
|
||||||
opts[name].value = value;
|
opts[name].value = value;
|
||||||
} else {
|
|
||||||
Object.keys(name).forEach(function(key) {
|
|
||||||
if (opts[key])
|
|
||||||
opts[key].value = name[key];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.setDefaultValues = function(path, optionHash) {
|
||||||
|
Object.keys(optionHash).forEach(function(key) {
|
||||||
|
exports.setDefaultValue(path, key, optionHash[key]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue