sdc_client 0.58.5 → 0.158.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.js.yml +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +17 -0
- package/.idea/workspace.xml +122 -23
- package/.readthedocs.yaml +13 -0
- package/dist/index.js +70 -51
- package/dist/ugly.index.js +1 -1
- package/docs/api-reference.rst +225 -0
- package/docs/conf.py +11 -0
- package/docs/controllers.rst +228 -0
- package/docs/events-and-dom.rst +120 -0
- package/docs/getting-started.rst +143 -0
- package/docs/index.rst +22 -0
- package/docs/models.rst +351 -0
- package/docs/overview.rst +66 -0
- package/docs/requirements.txt +1 -0
- package/eslint.config.js +60 -0
- package/gulp/gulp.jsx +15 -13
- package/package.json +13 -3
- package/src/index.js +44 -11
- package/src/simpleDomControl/AbstractSDC.js +287 -286
- package/src/simpleDomControl/sdc_controller.js +157 -132
- package/src/simpleDomControl/sdc_dom_events.js +99 -88
- package/src/simpleDomControl/sdc_events.js +39 -40
- package/src/simpleDomControl/sdc_main.js +88 -67
- package/src/simpleDomControl/sdc_model.js +1510 -0
- package/src/simpleDomControl/sdc_params.js +44 -29
- package/src/simpleDomControl/sdc_server_call.js +153 -154
- package/src/simpleDomControl/sdc_socket.js +8 -821
- package/src/simpleDomControl/sdc_test_utils.js +77 -80
- package/src/simpleDomControl/sdc_utils.js +295 -176
- package/src/simpleDomControl/sdc_view.js +245 -177
- package/test/model.test.js +332 -0
- package/test/models/Author.js +145 -0
- package/test/models/Book.js +112 -0
- package/test/models/BookContent.js +114 -0
- package/test/models/SdcUser.js +75 -0
- package/test/models/src.js +8 -0
- package/test/sdc_model_dates.ai.test.js +57 -0
- package/test/sdc_server_call.ai.test.js +267 -0
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
import {promiseDummyFactory, tagNameToCamelCase, agileAggregation} from "./sdc_utils.js";
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
promiseDummyFactory,
|
|
3
|
+
tagNameToCamelCase,
|
|
4
|
+
agileAggregation,
|
|
5
|
+
} from "./sdc_utils.js";
|
|
6
|
+
import {
|
|
7
|
+
CONTROLLER_CLASS,
|
|
8
|
+
getController,
|
|
9
|
+
loadFilesFromController,
|
|
10
|
+
refresh,
|
|
11
|
+
runControllerFillContent,
|
|
8
12
|
} from "./sdc_view.js";
|
|
9
13
|
|
|
10
|
-
import {runOnInitWithParameter} from "./sdc_params.js";
|
|
11
|
-
import {setControllerEvents} from "./sdc_dom_events.js";
|
|
12
|
-
import {app} from "./sdc_main.js";
|
|
14
|
+
import { runOnInitWithParameter } from "./sdc_params.js";
|
|
15
|
+
import { setControllerEvents } from "./sdc_dom_events.js";
|
|
16
|
+
import { app } from "./sdc_main.js";
|
|
13
17
|
|
|
14
18
|
export let Global = [];
|
|
15
19
|
export let controllerList = {};
|
|
16
20
|
|
|
17
21
|
export function tagList() {
|
|
18
|
-
|
|
22
|
+
return Object.keys(controllerList);
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
22
25
|
function prepareMixins(superTagNameList, tagName) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
26
|
+
superTagNameList = superTagNameList.concat(controllerList[tagName][1]);
|
|
27
|
+
superTagNameList = superTagNameList.filter((value, index, self) => {
|
|
28
|
+
return self.indexOf(value) === index;
|
|
29
|
+
});
|
|
30
|
+
let hasAdded = true;
|
|
31
|
+
while (hasAdded) {
|
|
32
|
+
hasAdded = false;
|
|
33
|
+
for (let tag of superTagNameList) {
|
|
34
|
+
for (let newTag of controllerList[tag][1]) {
|
|
35
|
+
if (!superTagNameList.includes(newTag)) {
|
|
36
|
+
superTagNameList.push(newTag);
|
|
37
|
+
hasAdded = true;
|
|
37
38
|
}
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
|
|
41
|
+
}
|
|
42
|
+
return superTagNameList;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/**
|
|
@@ -49,16 +52,16 @@ function prepareMixins(superTagNameList, tagName) {
|
|
|
49
52
|
* @return {AbstractSDC} - parentController
|
|
50
53
|
*/
|
|
51
54
|
function setParentController(parentController, controller) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
parentController._childController[controllerName].push(controller);
|
|
55
|
+
if (parentController) {
|
|
56
|
+
let controllerName = tagNameToCamelCase(controller._tagName);
|
|
57
|
+
if (!parentController._childController[controllerName]) {
|
|
58
|
+
parentController._childController[controllerName] = [];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
parentController._childController[controllerName].push(controller);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (controller._parentController = parentController);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
/**
|
|
@@ -67,14 +70,14 @@ function setParentController(parentController, controller) {
|
|
|
67
70
|
* @param {AbstractSDC} parentController
|
|
68
71
|
*/
|
|
69
72
|
export function resetChildren(parentController) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
parentController._childController = {};
|
|
74
|
+
parentController.find(`.${CONTROLLER_CLASS}`).each(function () {
|
|
75
|
+
const $this = $(this);
|
|
76
|
+
const cController = getController($this);
|
|
77
|
+
if (cController === parentController) {
|
|
78
|
+
setParentController(parentController, cController);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
/**
|
|
@@ -92,24 +95,30 @@ export function resetChildren(parentController) {
|
|
|
92
95
|
* @param {Array<string>} superTagNameList - tag names of super controller
|
|
93
96
|
* @return {AbstractSDC} - new Controller
|
|
94
97
|
*/
|
|
95
|
-
function controllerFactoryInstance(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
function controllerFactoryInstance(
|
|
99
|
+
parentController,
|
|
100
|
+
$element,
|
|
101
|
+
tagName,
|
|
102
|
+
superTagNameList,
|
|
103
|
+
) {
|
|
104
|
+
let mixinControllerClass = [];
|
|
105
|
+
superTagNameList = prepareMixins(superTagNameList, tagName);
|
|
106
|
+
for (let superTagName of superTagNameList) {
|
|
107
|
+
mixinControllerClass.push(controllerList[superTagName][0]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let controllerClass = controllerList[tagName][0];
|
|
111
|
+
let controller = new (agileAggregation(
|
|
112
|
+
controllerClass,
|
|
113
|
+
...mixinControllerClass,
|
|
114
|
+
))();
|
|
115
|
+
controller._tagName = tagName;
|
|
116
|
+
|
|
117
|
+
setParentController(parentController, controller);
|
|
118
|
+
controller.$container = $element;
|
|
119
|
+
runOnInitWithParameter($element, controller);
|
|
120
|
+
|
|
121
|
+
return controller;
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
/**
|
|
@@ -125,19 +134,33 @@ function controllerFactoryInstance(parentController, $element, tagName, superTag
|
|
|
125
134
|
* @param {Array<string>} superTagNameList - tag names of super controller
|
|
126
135
|
* @return {AbstractSDC} - new Controller
|
|
127
136
|
*/
|
|
128
|
-
export function controllerFactory(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
export function controllerFactory(
|
|
138
|
+
parentController,
|
|
139
|
+
$element,
|
|
140
|
+
tagName,
|
|
141
|
+
superTagNameList,
|
|
142
|
+
) {
|
|
143
|
+
if (Global.includes(tagName)) {
|
|
144
|
+
let gTagName = tagNameToCamelCase(tagName);
|
|
145
|
+
if (!window[gTagName]) {
|
|
146
|
+
window[gTagName] = controllerFactoryInstance(
|
|
147
|
+
parentController,
|
|
148
|
+
$element,
|
|
149
|
+
tagName,
|
|
150
|
+
superTagNameList,
|
|
151
|
+
);
|
|
138
152
|
}
|
|
139
153
|
|
|
140
|
-
|
|
154
|
+
window[gTagName].$container = $element;
|
|
155
|
+
return window[gTagName];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return controllerFactoryInstance(
|
|
159
|
+
parentController,
|
|
160
|
+
$element,
|
|
161
|
+
tagName,
|
|
162
|
+
superTagNameList,
|
|
163
|
+
);
|
|
141
164
|
}
|
|
142
165
|
|
|
143
166
|
/**
|
|
@@ -150,22 +173,21 @@ export function controllerFactory(parentController, $element, tagName, superTagN
|
|
|
150
173
|
* @return {Promise<*>} - return of the onLoad function
|
|
151
174
|
*/
|
|
152
175
|
function runControllerShow(controller, $html) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
176
|
+
return runControllerFillContent(controller, $html).then(function (args) {
|
|
177
|
+
args = args || true;
|
|
178
|
+
if (controller.willShow) {
|
|
179
|
+
let loadPromiseOrContent = controller.willShow();
|
|
180
|
+
if (loadPromiseOrContent instanceof Promise) {
|
|
181
|
+
return loadPromiseOrContent.then(function () {
|
|
182
|
+
return args;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
163
186
|
|
|
164
|
-
|
|
165
|
-
|
|
187
|
+
return args;
|
|
188
|
+
});
|
|
166
189
|
}
|
|
167
190
|
|
|
168
|
-
|
|
169
191
|
/**
|
|
170
192
|
* runControllerLoad Calls the onLoad function of the controller.
|
|
171
193
|
* This function is called before the HTML is set to the page.
|
|
@@ -175,17 +197,17 @@ function runControllerShow(controller, $html) {
|
|
|
175
197
|
* @return {Promise<*>} - return of the onLoad function
|
|
176
198
|
*/
|
|
177
199
|
function runControllerLoad(controller) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
200
|
+
return loadFilesFromController(controller).then((html) => {
|
|
201
|
+
if (!controller.onLoad || controller._onLoadDone) {
|
|
202
|
+
return html;
|
|
203
|
+
}
|
|
182
204
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
});
|
|
205
|
+
controller._onLoadDone = true;
|
|
206
|
+
let loadPromise = controller.onLoad(html);
|
|
207
|
+
return (loadPromise || promiseDummyFactory()).then(() => {
|
|
208
|
+
return html;
|
|
188
209
|
});
|
|
210
|
+
});
|
|
189
211
|
}
|
|
190
212
|
|
|
191
213
|
/**
|
|
@@ -198,21 +220,23 @@ function runControllerLoad(controller) {
|
|
|
198
220
|
* @param controller
|
|
199
221
|
* @param {Object} process - Process object containing the refresh process
|
|
200
222
|
*/
|
|
201
|
-
export function runControlFlowFunctions(controller, process
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
223
|
+
export function runControlFlowFunctions(controller, process) {
|
|
224
|
+
const prom_controller = runControllerLoad(controller)
|
|
225
|
+
.then(function ($html) {
|
|
226
|
+
return runControllerShow(controller, $html);
|
|
227
|
+
})
|
|
228
|
+
.then(() => {
|
|
229
|
+
return runRefresh(controller, process);
|
|
230
|
+
})
|
|
231
|
+
.catch(function ($html) {
|
|
232
|
+
return runControllerFillContent(controller, $html);
|
|
233
|
+
});
|
|
210
234
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
235
|
+
if (controller.load_async) {
|
|
236
|
+
return Promise.resolve();
|
|
237
|
+
}
|
|
214
238
|
|
|
215
|
-
|
|
239
|
+
return prom_controller;
|
|
216
240
|
}
|
|
217
241
|
|
|
218
242
|
/**
|
|
@@ -221,17 +245,17 @@ export function runControlFlowFunctions(controller, process ) {
|
|
|
221
245
|
* @param {Object} process - Process object containing the refresh process
|
|
222
246
|
*/
|
|
223
247
|
export function runRefresh(controller, process) {
|
|
224
|
-
|
|
248
|
+
return refresh(null, controller, process);
|
|
225
249
|
}
|
|
226
250
|
|
|
227
251
|
function getParentList(controller) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
252
|
+
let controllerList = [];
|
|
253
|
+
while (controller) {
|
|
254
|
+
controller._isEventsSet = false;
|
|
255
|
+
controllerList.unshift(controller);
|
|
256
|
+
controller = controller._parentController;
|
|
257
|
+
}
|
|
258
|
+
return controllerList;
|
|
235
259
|
}
|
|
236
260
|
|
|
237
261
|
/**
|
|
@@ -239,26 +263,27 @@ function getParentList(controller) {
|
|
|
239
263
|
* @param {Object} process - Process object containing the refresh process
|
|
240
264
|
*/
|
|
241
265
|
export function updateEventAndTriggerOnRefresh(process) {
|
|
242
|
-
|
|
243
|
-
|
|
266
|
+
const parentList = getParentList(process.controller[0]);
|
|
267
|
+
const controllerList = parentList.concat(process.controller.slice(1));
|
|
244
268
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
269
|
+
for (let con of controllerList) {
|
|
270
|
+
setControllerEvents(con);
|
|
271
|
+
con.onRefresh(process.controller[0]);
|
|
272
|
+
}
|
|
249
273
|
}
|
|
250
274
|
|
|
251
|
-
|
|
252
275
|
export function prepareRefreshProcess(refreshProcess, controller) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
276
|
+
let isRunningProcess = Boolean(refreshProcess);
|
|
277
|
+
|
|
278
|
+
if (!isRunningProcess) {
|
|
279
|
+
refreshProcess = {
|
|
280
|
+
uuids: new Set([controller._uuid]),
|
|
281
|
+
controller: [controller],
|
|
282
|
+
};
|
|
283
|
+
} else if (!refreshProcess.uuids.has(controller._uuid)) {
|
|
284
|
+
refreshProcess.uuids.add(controller._uuid);
|
|
285
|
+
refreshProcess.controller.push(controller);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return { isRunningProcess, refreshProcess };
|
|
263
289
|
}
|
|
264
|
-
|
|
@@ -1,116 +1,127 @@
|
|
|
1
|
-
import {getController} from
|
|
1
|
+
import { getController } from "./sdc_view.js";
|
|
2
2
|
|
|
3
|
-
export const STD_EVENT_BLACK_LIST = [
|
|
4
|
-
export const STD_EVENT_LIST = Object.keys(window)
|
|
3
|
+
export const STD_EVENT_BLACK_LIST = ["onbeforeunload", "onunload"];
|
|
4
|
+
export const STD_EVENT_LIST = Object.keys(window)
|
|
5
|
+
.filter((key) => /^on/.test(key) && !STD_EVENT_BLACK_LIST.includes(key))
|
|
6
|
+
.map((x) => x.slice(2));
|
|
5
7
|
|
|
6
8
|
function checkIfEventFits(ev_type, e, target) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
let elementUnderMouse;
|
|
10
|
+
switch (ev_type) {
|
|
11
|
+
case "mouseleave":
|
|
12
|
+
case "mouseout":
|
|
13
|
+
elementUnderMouse = document.elementFromPoint(e.clientX, e.clientY);
|
|
14
|
+
return (
|
|
15
|
+
target !== elementUnderMouse && !target.contains(elementUnderMouse)
|
|
16
|
+
);
|
|
17
|
+
case "mouseenter":
|
|
18
|
+
case "mousein":
|
|
19
|
+
elementUnderMouse = document.elementFromPoint(e.clientX, e.clientY);
|
|
20
|
+
return (
|
|
21
|
+
target !== elementUnderMouse && !target.contains(elementUnderMouse)
|
|
22
|
+
);
|
|
23
|
+
default:
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
export function windowEventHandler(event) {
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
let ev_type = event.type;
|
|
30
|
+
if (
|
|
31
|
+
event.hasOwnProperty("namespace") &&
|
|
32
|
+
event.namespace &&
|
|
33
|
+
event.namespace.length
|
|
34
|
+
)
|
|
35
|
+
ev_type += `.${event.namespace}`;
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
let $elm = $(event.target);
|
|
38
|
+
let controller = null;
|
|
39
|
+
let is_done = false;
|
|
40
|
+
let is_last_elem = false;
|
|
41
|
+
event.stopImmediatePropagation = () => (is_last_elem = true);
|
|
42
|
+
event.stopPropagation = () => (is_last_elem = is_done = true);
|
|
43
|
+
while ($elm.length) {
|
|
44
|
+
let attrs = $elm.attr(`sdc_${ev_type}`);
|
|
45
|
+
if (attrs && checkIfEventFits(ev_type, event, $elm[0])) {
|
|
46
|
+
if (!controller) {
|
|
47
|
+
controller = getController($elm);
|
|
48
|
+
if (!controller) return;
|
|
49
|
+
}
|
|
50
|
+
while (controller) {
|
|
51
|
+
attrs.split(" ").forEach((attr) => {
|
|
52
|
+
if (is_done) return;
|
|
53
|
+
let handler = null;
|
|
54
|
+
if (typeof attr === "function") {
|
|
55
|
+
handler = attr;
|
|
56
|
+
} else if (typeof controller[attr] === "function") {
|
|
57
|
+
handler = controller[attr];
|
|
58
|
+
} else if (
|
|
59
|
+
typeof attr === "string" &&
|
|
60
|
+
attr.startsWith("this.event_")
|
|
61
|
+
) {
|
|
62
|
+
handler = controller.getEvents()[ev_type];
|
|
63
|
+
if (!handler) {
|
|
64
|
+
return;
|
|
38
65
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let handler = null;
|
|
43
|
-
if (typeof attr === 'function') {
|
|
44
|
-
handler = attr;
|
|
45
|
-
} else if (typeof controller[attr] === 'function') {
|
|
46
|
-
handler = controller[attr];
|
|
47
|
-
} else if (typeof attr === 'string' && attr.startsWith('this.event_')) {
|
|
48
|
-
handler = controller.getEvents()[ev_type];
|
|
49
|
-
if (!handler) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
handler = handler[attr.slice('this.event_'.length)];
|
|
53
|
-
if (!handler) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
handler && handler.call(controller, $elm, event);
|
|
59
|
-
});
|
|
60
|
-
if (is_last_elem) return;
|
|
61
|
-
controller = controller._parentController
|
|
66
|
+
handler = handler[attr.slice("this.event_".length)];
|
|
67
|
+
if (!handler) {
|
|
68
|
+
return;
|
|
62
69
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
handler && handler.call(controller, $elm, event);
|
|
73
|
+
});
|
|
74
|
+
if (is_last_elem) return;
|
|
75
|
+
controller = controller._parentController;
|
|
76
|
+
}
|
|
66
77
|
}
|
|
78
|
+
if (is_done) return;
|
|
79
|
+
$elm = $elm.parent();
|
|
80
|
+
}
|
|
67
81
|
|
|
68
|
-
|
|
82
|
+
return { res: true };
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
/**
|
|
72
86
|
*
|
|
73
87
|
*/
|
|
74
88
|
export function initEvents() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
const $window = $(window);
|
|
90
|
+
STD_EVENT_LIST.forEach((ev_type) => {
|
|
91
|
+
$window.off(ev_type).on(ev_type, windowEventHandler);
|
|
92
|
+
});
|
|
79
93
|
}
|
|
80
94
|
|
|
81
|
-
|
|
82
95
|
/**
|
|
83
96
|
*
|
|
84
97
|
* @param {AbstractSDC} controller
|
|
85
98
|
*/
|
|
86
99
|
export function setControllerEvents(controller) {
|
|
100
|
+
if (controller._isEventsSet) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const new_key = `this.event_${domSelector}`;
|
|
104
|
-
if (event_list.indexOf(new_key) === -1) {
|
|
105
|
-
event_list.push(new_key);
|
|
106
|
-
$elements.attr(`sdc_${ev_type}`, event_list.join(' '))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
}
|
|
104
|
+
const events = controller.getEvents();
|
|
105
|
+
for (let ev_type in events) {
|
|
106
|
+
if (events.hasOwnProperty(ev_type)) {
|
|
107
|
+
let eventList = events[ev_type];
|
|
108
|
+
for (let domSelector in eventList) {
|
|
109
|
+
if (eventList.hasOwnProperty(domSelector)) {
|
|
110
|
+
controller.find(domSelector).each(function () {
|
|
111
|
+
let $elements = $(this);
|
|
112
|
+
let event_list = $elements.attr(`sdc_${ev_type}`) || null;
|
|
113
|
+
if (!event_list) event_list = [];
|
|
114
|
+
else event_list = event_list.split(" ");
|
|
115
|
+
const new_key = `this.event_${domSelector}`;
|
|
116
|
+
if (event_list.indexOf(new_key) === -1) {
|
|
117
|
+
event_list.push(new_key);
|
|
118
|
+
$elements.attr(`sdc_${ev_type}`, event_list.join(" "));
|
|
111
119
|
}
|
|
120
|
+
});
|
|
112
121
|
}
|
|
122
|
+
}
|
|
113
123
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
}
|
|
125
|
+
// TODO: Is it needed
|
|
126
|
+
//controller._isEventsSet = true;
|
|
127
|
+
}
|