1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export default function configPrep(config, type, nest) {
|
9 | var this$1 = this;
|
10 | if ( config === void 0 ) config = this._shapeConfig;
|
11 | if ( type === void 0 ) type = "shape";
|
12 | if ( nest === void 0 ) nest = false;
|
13 |
|
14 |
|
15 | var newConfig = {duration: this._duration, on: {}};
|
16 |
|
17 | var wrapFunction = function (func) { return function (d, i, s) {
|
18 | var parent;
|
19 | while (d.__d3plus__) {
|
20 | if (parent) { d.__d3plusParent__ = parent; }
|
21 | parent = d;
|
22 | i = d.i;
|
23 | d = d.data || d.feature;
|
24 | }
|
25 | return func.bind(this$1)(d, i, s || parent);
|
26 | }; };
|
27 |
|
28 | var parseEvents = function (newObj, on) {
|
29 |
|
30 | for (var event in on) {
|
31 |
|
32 | if ({}.hasOwnProperty.call(on, event) && !event.includes(".") || event.includes(("." + type))) {
|
33 | newObj.on[event] = wrapFunction(on[event]);
|
34 | }
|
35 |
|
36 | }
|
37 |
|
38 | };
|
39 |
|
40 | var keyEval = function (newObj, obj) {
|
41 |
|
42 | for (var key in obj) {
|
43 |
|
44 | if ({}.hasOwnProperty.call(obj, key)) {
|
45 |
|
46 | if (key === "on") { parseEvents(newObj, obj[key]); }
|
47 | else if (typeof obj[key] === "function") {
|
48 | newObj[key] = wrapFunction(obj[key]);
|
49 | }
|
50 | else if (typeof obj[key] === "object" && !(obj instanceof Array)) {
|
51 | newObj[key] = {on: {}};
|
52 | keyEval(newObj[key], obj[key]);
|
53 | }
|
54 | else { newObj[key] = obj[key]; }
|
55 |
|
56 | }
|
57 |
|
58 | }
|
59 |
|
60 | };
|
61 |
|
62 | keyEval(newConfig, config);
|
63 | if (this._on) { parseEvents(newConfig, this._on); }
|
64 | if (nest && config[nest]) {
|
65 | keyEval(newConfig, config[nest]);
|
66 | if (config[nest].on) { parseEvents(newConfig, config[nest].on); }
|
67 | }
|
68 |
|
69 | return newConfig;
|
70 |
|
71 | }
|
72 |
|
73 |
|
\ | No newline at end of file |