add setDefaultValues instead of doing two things in setDefaultValue

This commit is contained in:
nightwing 2013-02-13 12:03:31 +04:00
commit a6a26864df

View file

@ -260,15 +260,18 @@ exports.resetOptions = function(obj) {
exports.setDefaultValue = function(path, name, value) {
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;
} 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]);
});
};
});