2021-12-20 04:11:04 +01:00
|
|
|
import merge from 'lodash/merge';
|
2021-12-17 18:13:47 +01:00
|
|
|
|
2021-12-05 00:39:20 +01:00
|
|
|
class Options {
|
2021-12-14 18:06:09 +01:00
|
|
|
setOptions(...args) {
|
2021-12-17 18:13:47 +01:00
|
|
|
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) {
|
2021-12-20 21:54:31 +01:00
|
|
|
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;
|