wisemapping-frontend/packages/mindplot/src/components/Options.js

23 lines
579 B
JavaScript
Raw Normal View History

2021-12-20 04:11:04 +01:00
import merge from 'lodash/merge';
2021-12-05 00:39:20 +01:00
class Options {
2021-12-14 18:06:09 +01:00
setOptions(...args) {
const options = merge({}, this.options, ...args);
this.options = options;
2021-12-14 18:06:09 +01:00
2021-10-05 02:05:34 +02:00
if (this.addEvent) {
const optionsKeys = Object.keys(options);
for (let index = 0; index < optionsKeys.length; index++) {
const option = optionsKeys[index];
if (typeof (options[option]) === 'function' && (/^on[A-Z]/).test(option)) {
this.addEvent(option, options[option]);
delete options[option];
2021-12-14 18:06:09 +01:00
}
2021-10-05 02:05:34 +02:00
}
2021-07-16 16:41:58 +02:00
}
2021-10-05 02:05:34 +02:00
return this;
2021-12-05 00:39:20 +01:00
}
}
2021-07-16 16:41:58 +02:00
export default Options;