allow returning full class config data, merged with defaults

and merge object config values with defaults (e.g. Cell.cm_config)
This commit is contained in:
Min RK 2016-09-12 14:42:48 +02:00
parent d7a095c206
commit 0e5047e75d

View File

@ -102,7 +102,21 @@ function(utils) {
*/
ConfigWithDefaults.prototype.get_sync = function(key) {
var data = this._class_data();
return key in data ? data[key] : this.defaults[key];
if (key === undefined) {
// no key specified, return full config data
return $.extend(true, {}, this.defaults, data);
}
var value = data[key];
if (value !== undefined) {
if (typeof value == 'object') {
// merge with defaults if it's an object
return $.extend(true, {}, this.defaults[key], value);
} else {
return value;
}
}
return this.defaults[key];
};
/**