targetj 1.0.2
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/.jshintrc +3 -0
- package/Gruntfile.js +42 -0
- package/package.json +27 -0
- package/src/$Dom.js +358 -0
- package/src/App.js +142 -0
- package/src/Bracket.js +201 -0
- package/src/Browser.js +297 -0
- package/src/Dim.js +19 -0
- package/src/EventListener.js +454 -0
- package/src/LoadingManager.js +348 -0
- package/src/LocationManager.js +156 -0
- package/src/PageManager.js +104 -0
- package/src/SearchUtil.js +179 -0
- package/src/TModel.js +761 -0
- package/src/TModelManager.js +378 -0
- package/src/TUtil.js +202 -0
- package/src/TargetManager.js +228 -0
- package/src/TargetUtil.js +221 -0
- package/src/Viewport.js +184 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
function SearchUtil() {}
|
|
2
|
+
|
|
3
|
+
SearchUtil.foundParentWithType = {};
|
|
4
|
+
SearchUtil.foundParentWithTarget = {};
|
|
5
|
+
SearchUtil.foundTypeMap = {};
|
|
6
|
+
SearchUtil.foundTargetMap = {};
|
|
7
|
+
SearchUtil.foundOids = {};
|
|
8
|
+
|
|
9
|
+
SearchUtil.findFirstPinchHandler = function(tmodel) {
|
|
10
|
+
return SearchUtil.findEventHandler(tmodel, 'pinch');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
SearchUtil.findFirstScrollTopHandler = function(tmodel) {
|
|
14
|
+
return SearchUtil.findEventHandler(tmodel, 'scrollTop');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
SearchUtil.findFirstScrollLeftHandler = function(tmodel) {
|
|
18
|
+
return SearchUtil.findEventHandler(tmodel, 'scrollLeft');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
SearchUtil.findFirstTouchHandler = function(tmodel) {
|
|
22
|
+
return SearchUtil.findEventHandler(tmodel, 'touch');
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
SearchUtil.findEventHandler = function(tmodel, eventName) {
|
|
26
|
+
while (tmodel) {
|
|
27
|
+
if (tmodel.canHandleEvents() === true || tmodel.canHandleEvents() === eventName || (Array.isArray(tmodel.canHandleEvents()) && tmodel.canHandleEvents().includes(eventName))) {
|
|
28
|
+
return tmodel;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
tmodel = tmodel.getParent();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
SearchUtil.findParentWithType = function(child, type) {
|
|
36
|
+
var parent;
|
|
37
|
+
|
|
38
|
+
function search() {
|
|
39
|
+
parent = child.getParent();
|
|
40
|
+
while (parent) {
|
|
41
|
+
if (parent.type === type) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
parent = parent.getParent();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var indexKey = child.oid + "__" + type;
|
|
49
|
+
|
|
50
|
+
if (!TUtil.isDefined(SearchUtil.foundParentWithType[indexKey])) {
|
|
51
|
+
search();
|
|
52
|
+
|
|
53
|
+
if (parent) {
|
|
54
|
+
SearchUtil.foundParentWithType[indexKey] = parent;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return SearchUtil.foundParentWithType[indexKey];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
SearchUtil.findParentWithTarget = function(child, targetName) {
|
|
62
|
+
var parent;
|
|
63
|
+
|
|
64
|
+
function search() {
|
|
65
|
+
parent = child.getParent();
|
|
66
|
+
while (parent) {
|
|
67
|
+
if (TUtil.isDefined(parent.targets[targetName]) || TUtil.isDefined(parent.targetValues[targetName])) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
parent = parent.getParent();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var indexKey = child.oid + "__" + targetName;
|
|
75
|
+
|
|
76
|
+
if (!TUtil.isDefined(SearchUtil.foundParentWithTarget[indexKey])) {
|
|
77
|
+
search();
|
|
78
|
+
|
|
79
|
+
if (parent) {
|
|
80
|
+
SearchUtil.foundParentWithTarget[indexKey] = parent;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return SearchUtil.foundParentWithTarget[indexKey];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
SearchUtil.findByType = function (type) {
|
|
88
|
+
var tmodel;
|
|
89
|
+
|
|
90
|
+
function search(container) {
|
|
91
|
+
var children = container.getChildren();
|
|
92
|
+
var found;
|
|
93
|
+
|
|
94
|
+
for (var i = 0; children && i < children.length && !found; i++) {
|
|
95
|
+
|
|
96
|
+
tmodel = children[i];
|
|
97
|
+
|
|
98
|
+
if (tmodel && tmodel.type === type) {
|
|
99
|
+
found = tmodel;
|
|
100
|
+
} else if (tmodel.hasChildren()) {
|
|
101
|
+
found = search(tmodel);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return found;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!TUtil.isDefined(SearchUtil.foundTypeMap[type])) {
|
|
109
|
+
tmodel = search(tapp.ui);
|
|
110
|
+
if (tmodel) {
|
|
111
|
+
SearchUtil.foundTypeMap[type] = tmodel;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return SearchUtil.foundTypeMap[type];
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
SearchUtil.findByTarget = function (target) {
|
|
119
|
+
var tmodel;
|
|
120
|
+
|
|
121
|
+
function search(container) {
|
|
122
|
+
|
|
123
|
+
var children = container.getChildren();
|
|
124
|
+
var found;
|
|
125
|
+
|
|
126
|
+
for (var i = 0; children && i < children.length && !found; i++) {
|
|
127
|
+
|
|
128
|
+
tmodel = children[i];
|
|
129
|
+
|
|
130
|
+
if (tmodel && tmodel.targets[target]) {
|
|
131
|
+
found = tmodel;
|
|
132
|
+
} else if (tmodel.hasChildren()) {
|
|
133
|
+
found = search(tmodel);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return found;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!TUtil.isDefined(SearchUtil.foundTargetMap[target])) {
|
|
141
|
+
tmodel = search(tapp.ui);
|
|
142
|
+
if (tmodel) {
|
|
143
|
+
SearchUtil.foundTargetMap[target] = tmodel;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return SearchUtil.foundTargetMap[target];
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
SearchUtil.find = function (oid) {
|
|
151
|
+
var tmodel;
|
|
152
|
+
|
|
153
|
+
function search(container) {
|
|
154
|
+
|
|
155
|
+
var children = container.getChildren();
|
|
156
|
+
var found;
|
|
157
|
+
|
|
158
|
+
for (var i = 0; children && i < children.length && !found; i++) {
|
|
159
|
+
tmodel = children[i];
|
|
160
|
+
|
|
161
|
+
if (tmodel.oid === oid) {
|
|
162
|
+
found = tmodel;
|
|
163
|
+
} else if (tmodel.hasChildren()) {
|
|
164
|
+
found = search(tmodel);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return found;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!TUtil.isDefined(SearchUtil.foundOids[oid])) {
|
|
172
|
+
tmodel = search(tapp.ui);
|
|
173
|
+
if (tmodel) {
|
|
174
|
+
SearchUtil.foundOids[oid] = tmodel;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return SearchUtil.foundOids[oid];
|
|
179
|
+
};
|