-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathserializeView.js
52 lines (41 loc) · 1.56 KB
/
serializeView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;(function(Agent) {
Agent.serializeView = function(view) {
var data = {};
// debug.log('serializeView', view)
if (!_.isObject(view)) {
return data;
}
var knownType = Agent.knownType(view);
data.cid = view.cid;
data.isLoading = false; // set when a view is registered, but not serialized
data.options = Agent.serializeObject(view.options);
data.ui = Agent.serializeUI(view.ui);
data.el = Agent.serializeElement(view.el, 'el', false);
data.events = Agent.serializeEventsHash(view.events);
data._events = Agent.serializeEvents(view._events);
data.listeningTo = Agent.serializeListeningTo(view, view._listeningTo);
data.modelEvents = Agent.serializeEventsHash(view.modelEvents);
data.collectionEvents = Agent.serializeEventsHash(view.collectionEvents);
data.triggers = Agent.serializeEventsHash(view.triggers);
data.properties = Agent.serializeObjectProperties(view);
data.ancestorInfo = Agent.ancestorInfo(view);
data._requirePath = view._requirePath;
data._className = Agent.serializeClassName(view);
data.parentClass = knownType ? knownType.name : '';
data.inspect = Agent.inspectValue(view, undefined, knownType);
data.classId = Agent.getHiddenProperty(view, 'classId');
if (view.model) {
data.model = {
cid: view.model.cid
};
}
return data;
};
Agent.serializeUI = function(ui) {
var data = {};
_.each(ui, function(element, uiName) {
data[uiName] = Agent.serializeElement(element, uiName, false);
});
return data;
};
}(Agent));