efront 3.15.6 → 3.16.1
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/apps/pivot/log/boot.js +32 -3
- package/coms/basic/JSAM.js +72 -19
- package/coms/basic/cross_.js +1 -1
- package/coms/basic/loader.js +2 -2
- package/coms/basic/matrix.js +51 -28
- package/coms/basic/parseYML.js +1 -1
- package/coms/basic/renderExpress.js +3 -3
- package/coms/frame/route.js +54 -17
- package/coms/zimoli/data.js +1 -6
- package/coms/zimoli/dispatch.js +13 -1
- package/coms/zimoli/getValue.js +1 -1
- package/coms/zimoli/menu.js +24 -0
- package/coms/zimoli/menuItem.html +4 -1
- package/coms/zimoli/menuItem.js +7 -0
- package/coms/zimoli/menuItem.less +23 -2
- package/coms/zimoli/menuList.js +24 -18
- package/coms/zimoli/moveupon.js +6 -4
- package/coms/zimoli/on.js +173 -162
- package/coms/zimoli/render.js +1 -1
- package/data/packexe-setup.sfx +0 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/zimoli/menu.js
CHANGED
|
@@ -91,6 +91,28 @@ var getTreeNodes = function (elem) {
|
|
|
91
91
|
return nodes;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
function bindGlobalkey(elem, keymap, emit) {
|
|
95
|
+
if (elem.keymap) {
|
|
96
|
+
for (var off of elem.keyoff) {
|
|
97
|
+
off();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!keymap) return;
|
|
101
|
+
var keyoff = [];
|
|
102
|
+
var emitEvent = function (item, event) {
|
|
103
|
+
event.preventDefault(true);
|
|
104
|
+
var $scope = {};
|
|
105
|
+
var { itemName } = this.$src;
|
|
106
|
+
if (itemName) $scope[itemName] = item;
|
|
107
|
+
else $scope.menu = item, $scope.$item = item;
|
|
108
|
+
emit(item, { $scope });
|
|
109
|
+
}
|
|
110
|
+
for (let k in keymap) {
|
|
111
|
+
keyoff.push(bind("keydown." + k)(elem, emitEvent.bind(elem, keymap[k])));
|
|
112
|
+
}
|
|
113
|
+
elem.keyoff = keyoff;
|
|
114
|
+
}
|
|
115
|
+
|
|
94
116
|
function main(elem, mode) {
|
|
95
117
|
if (isElement(elem)) {
|
|
96
118
|
// var os = /Samsung|Firefox|Chrome|MSIE|Safari/i.exec(navigator.userAgent);
|
|
@@ -184,6 +206,7 @@ function main(elem, mode) {
|
|
|
184
206
|
var src0 = [];
|
|
185
207
|
menuList(elem, src0, emit, direction);
|
|
186
208
|
care(elem, function (src) {
|
|
209
|
+
bindGlobalkey(elem, src.keymap, emit);
|
|
187
210
|
src0.splice(0, src0.length);
|
|
188
211
|
var s = getTreeFromData(src);
|
|
189
212
|
var i = 0;
|
|
@@ -208,6 +231,7 @@ function main(elem, mode) {
|
|
|
208
231
|
}
|
|
209
232
|
if (!elem.hasAttribute('mode')) elem.setAttribute('mode', mode);
|
|
210
233
|
if (!elem.hasAttribute(mode)) elem.setAttribute(mode, '');
|
|
234
|
+
|
|
211
235
|
return elem;
|
|
212
236
|
|
|
213
237
|
}
|
package/coms/zimoli/menuItem.js
CHANGED
|
@@ -11,7 +11,14 @@ function main(elem, scope, hasIcon) {
|
|
|
11
11
|
var name = scope.name;
|
|
12
12
|
var icon = scope.icon;
|
|
13
13
|
if (hasIcon === undefined) hasIcon = !!icon;
|
|
14
|
+
if (scope.disabled || scope.enabled === false) {
|
|
15
|
+
item.setAttribute('disabled', '');
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
item.removeAttribute("disabled");
|
|
19
|
+
}
|
|
14
20
|
render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon, name, icon }]);
|
|
15
21
|
if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
|
|
22
|
+
if (scope.hotkey) bindAccesskey(item, scope.hotkey);
|
|
16
23
|
return item;
|
|
17
24
|
}
|
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
i{
|
|
1
|
+
i {
|
|
2
2
|
display: inline-block;
|
|
3
3
|
width: 1em;
|
|
4
4
|
}
|
|
5
|
+
|
|
6
|
+
.hotkey {
|
|
7
|
+
margin-left: 12px;
|
|
8
|
+
font-size: 12px;
|
|
9
|
+
float: right;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&[disabled] {
|
|
13
|
+
background: #0000;
|
|
14
|
+
|
|
15
|
+
&>.track {
|
|
16
|
+
opacity: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
border-radius: 0;
|
|
20
|
+
color: #999;
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
&.line,
|
|
6
24
|
&[line] {
|
|
7
25
|
box-shadow: none;
|
|
8
|
-
|
|
26
|
+
|
|
27
|
+
>.track {
|
|
9
28
|
display: none;
|
|
10
29
|
}
|
|
30
|
+
|
|
11
31
|
line-height: 0;
|
|
12
32
|
font-size: 0;
|
|
33
|
+
|
|
13
34
|
&:after {
|
|
14
35
|
content: "";
|
|
15
36
|
display: block;
|
package/coms/zimoli/menuList.js
CHANGED
|
@@ -14,6 +14,7 @@ var unfocus = function () {
|
|
|
14
14
|
this.setFocus(null);
|
|
15
15
|
};
|
|
16
16
|
var setFocus = function (focused) {
|
|
17
|
+
if (focused && focused.hasAttribute("disabled")) return;
|
|
17
18
|
var page = this;
|
|
18
19
|
if (focused) {
|
|
19
20
|
if (page.focused !== focused) {
|
|
@@ -40,16 +41,17 @@ var moveFocus = function (delta) {
|
|
|
40
41
|
else {
|
|
41
42
|
var newIndex = focused.index + delta;
|
|
42
43
|
var total = page.total;
|
|
43
|
-
if (page !== root_menu) {
|
|
44
|
-
total++;
|
|
45
|
-
}
|
|
46
44
|
if (newIndex < 0) newIndex = total + newIndex;
|
|
47
45
|
if (newIndex > total - 1) newIndex = newIndex - total;
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
do {
|
|
48
|
+
var e = page.getIndexedElement(newIndex);
|
|
49
|
+
if (newIndex < 0) newIndex = total + newIndex;
|
|
50
|
+
newIndex += delta;
|
|
51
|
+
} while (e && (e.hasAttribute("disabled") || e.hasAttribute("line")));
|
|
51
52
|
if (!e) page.setFocus(null);
|
|
52
|
-
else page.open(e);
|
|
53
|
+
else if (page.ispop !== true) page.setFocus(e), page.open(e);
|
|
54
|
+
else page.setFocus(e);
|
|
53
55
|
};
|
|
54
56
|
var openFocus = function () {
|
|
55
57
|
var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
|
|
@@ -68,15 +70,20 @@ var keyAction = function (deltax, deltay) {
|
|
|
68
70
|
|
|
69
71
|
if (menu.direction === 'y') {
|
|
70
72
|
if (deltax === 1) {
|
|
71
|
-
|
|
73
|
+
// right
|
|
74
|
+
if (menu.focused) var fmenu = menu.focused.menu;
|
|
75
|
+
if (fmenu && fmenu.children && fmenu.children.length) {
|
|
76
|
+
openFocus();
|
|
77
|
+
}
|
|
72
78
|
else if (parent && parent.direction !== 'y') {
|
|
73
79
|
parent.moveFocus(deltax);
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
else if (deltax === -1) {
|
|
83
|
+
// left
|
|
77
84
|
if (parent) {
|
|
78
85
|
if (parent.direction === 'y') remove(mounted_menus.pop());
|
|
79
|
-
else
|
|
86
|
+
else parent.moveFocus(deltax);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
89
|
else {
|
|
@@ -85,15 +92,18 @@ var keyAction = function (deltax, deltay) {
|
|
|
85
92
|
}
|
|
86
93
|
else {
|
|
87
94
|
if (deltay === 1) {
|
|
88
|
-
|
|
95
|
+
// down
|
|
96
|
+
if (menu.focused) var fmenu = menu.focused.menu;
|
|
97
|
+
if (fmenu && fmenu.children && fmenu.children.length) openFocus();
|
|
89
98
|
else if (parent && parent.direction === 'y') {
|
|
90
99
|
parent.moveFocus(deltay);
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
else if (deltay === -1) {
|
|
103
|
+
// up
|
|
94
104
|
if (parent) {
|
|
95
105
|
if (parent.direction !== 'y') remove(mounted_menus.pop());
|
|
96
|
-
else
|
|
106
|
+
else parent.moveFocus(deltay);
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
else {
|
|
@@ -178,11 +188,8 @@ function main(page, items, active, direction = 'y') {
|
|
|
178
188
|
page.actived = menu;
|
|
179
189
|
menu.root = page.root || page;
|
|
180
190
|
popup(menu, target);
|
|
191
|
+
menu.setFocus(menu.firstMenu);
|
|
181
192
|
if (page.ispop === true) {
|
|
182
|
-
var offleave0 = on("mouseleave")(target, release);
|
|
183
|
-
var offleave1 = on("mouseleave")(menu, release);
|
|
184
|
-
var offenter0 = on("mouseenter")(target, clear);
|
|
185
|
-
var offenter1 = on("mouseenter")(menu, clear);
|
|
186
193
|
} else {
|
|
187
194
|
page.ispop = 1;
|
|
188
195
|
page.tabIndex = 0;
|
|
@@ -191,10 +198,6 @@ function main(page, items, active, direction = 'y') {
|
|
|
191
198
|
on("mousedown")(menu, e => e.preventDefault());
|
|
192
199
|
once("remove")(menu, function () {
|
|
193
200
|
removeFromList(mounted_menus, this);
|
|
194
|
-
if (offleave0) offleave0();
|
|
195
|
-
if (offleave1) offleave1();
|
|
196
|
-
if (offenter0) offenter0();
|
|
197
|
-
if (offenter1) offenter1();
|
|
198
201
|
});
|
|
199
202
|
}
|
|
200
203
|
on("blur")(page, unfocus);
|
|
@@ -220,12 +223,14 @@ function main(page, items, active, direction = 'y') {
|
|
|
220
223
|
}, time || 60);
|
|
221
224
|
};
|
|
222
225
|
var cancel = function () {
|
|
226
|
+
clear();
|
|
223
227
|
clearTimeout(popTimer);
|
|
224
228
|
}
|
|
225
229
|
var fire = function () {
|
|
226
230
|
cancel();
|
|
227
231
|
if (this.menu.line) return;
|
|
228
232
|
if (byMousedown) return;
|
|
233
|
+
if (this.hasAttribute("disabled") || this.hasAttribute('line')) return;
|
|
229
234
|
var pop = active(this.menu, this);
|
|
230
235
|
if (pop === false) return;
|
|
231
236
|
var root = page.root || page;
|
|
@@ -285,6 +290,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
285
290
|
);
|
|
286
291
|
if (!page.firstMenu) {
|
|
287
292
|
page.firstMenu = a;
|
|
293
|
+
page.total = items.length;
|
|
288
294
|
}
|
|
289
295
|
a.menu = s.menu;
|
|
290
296
|
return a;
|
package/coms/zimoli/moveupon.js
CHANGED
|
@@ -3,13 +3,15 @@ function mousemove(event) {
|
|
|
3
3
|
moveListeners.forEach(a => a(event));
|
|
4
4
|
}
|
|
5
5
|
function addHookListener(on, hook, isroot) {
|
|
6
|
-
var index = moveListeners.indexOf(hook);
|
|
7
|
-
if (~index) {
|
|
8
|
-
moveListeners.splice(index, 1);
|
|
9
|
-
}
|
|
10
6
|
if (!moveListeners.length) {
|
|
11
7
|
offhook = on(window, mousemove);
|
|
12
8
|
}
|
|
9
|
+
else {
|
|
10
|
+
var index = moveListeners.indexOf(hook);
|
|
11
|
+
if (~index) {
|
|
12
|
+
moveListeners.splice(index, 1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
13
15
|
if (isroot) {
|
|
14
16
|
moveListeners.unshift(hook);
|
|
15
17
|
} else {
|
package/coms/zimoli/on.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
if (document.efronton) return document.efronton;
|
|
2
3
|
var is_addEventListener_enabled = "addEventListener" in window;
|
|
3
4
|
var handlersMap = {};
|
|
4
5
|
var changes_key = 'changes';
|
|
@@ -6,8 +7,10 @@ var eventtypereg = /(?:\.once|\.prevent|\.stop|\.capture|\.self|\.passive|\.[a-z
|
|
|
6
7
|
var keyCodeMap = {
|
|
7
8
|
backspace: 8,
|
|
8
9
|
tab: 9,
|
|
10
|
+
"⇄": 9,
|
|
9
11
|
ceter: 12,// num5 when numlock is off.
|
|
10
12
|
enter: 13,
|
|
13
|
+
"↵": 13,
|
|
11
14
|
shift: 16,
|
|
12
15
|
ctrl: 17,
|
|
13
16
|
control: 17,
|
|
@@ -23,11 +26,17 @@ var keyCodeMap = {
|
|
|
23
26
|
end: 35,
|
|
24
27
|
home: 36,
|
|
25
28
|
left: 37,
|
|
29
|
+
"←": 37,
|
|
26
30
|
up: 38,
|
|
31
|
+
"↑": 38,
|
|
27
32
|
right: 39,
|
|
33
|
+
"→": 39,
|
|
28
34
|
down: 40,
|
|
35
|
+
"↓": 40,
|
|
29
36
|
insert: 45,
|
|
37
|
+
"ins": 45,
|
|
30
38
|
delete: 46,
|
|
39
|
+
del: 46,
|
|
31
40
|
key0: 47,
|
|
32
41
|
key1: 48,
|
|
33
42
|
key2: 49,
|
|
@@ -54,10 +63,14 @@ var keyCodeMap = {
|
|
|
54
63
|
num8: 104,
|
|
55
64
|
num9: 105,
|
|
56
65
|
times: 106,
|
|
66
|
+
"⨉": 106,
|
|
57
67
|
numplus: 107,
|
|
58
68
|
numminus: 109,
|
|
59
69
|
dot: 110,
|
|
60
|
-
|
|
70
|
+
numdot: 110,
|
|
71
|
+
divide: 111,
|
|
72
|
+
div: 111,
|
|
73
|
+
"/": 111,
|
|
61
74
|
f1: 112,
|
|
62
75
|
f2: 113,
|
|
63
76
|
f3: 114,
|
|
@@ -74,17 +87,39 @@ var keyCodeMap = {
|
|
|
74
87
|
numlock: 144,
|
|
75
88
|
scrolllock: 145,
|
|
76
89
|
semicolon: 186,
|
|
90
|
+
";": 186,
|
|
91
|
+
":": 186,
|
|
77
92
|
equal: 187,
|
|
93
|
+
"=": 187,
|
|
78
94
|
plus: 187,
|
|
95
|
+
"+": 187,
|
|
79
96
|
comma: 188,
|
|
97
|
+
",": 188,
|
|
98
|
+
"<": 188,
|
|
80
99
|
minus: 189,
|
|
100
|
+
"-": 189,
|
|
101
|
+
"_": 189,
|
|
81
102
|
period: 190,
|
|
103
|
+
".": 110,
|
|
104
|
+
">": 110,
|
|
82
105
|
slash: 191,
|
|
106
|
+
"/": 191,
|
|
107
|
+
">": 191,
|
|
83
108
|
backquote: 192,
|
|
109
|
+
"`": 192,
|
|
110
|
+
"~": 192,
|
|
84
111
|
bracketleft: 219,
|
|
112
|
+
"[": 219,
|
|
113
|
+
"{": 219,
|
|
85
114
|
backslash: 220,
|
|
115
|
+
"\\": 220,
|
|
116
|
+
"|": 220,
|
|
86
117
|
bracketright: 221,
|
|
118
|
+
"]": 221,
|
|
119
|
+
"}": 221,
|
|
87
120
|
quote: 222,
|
|
121
|
+
"'": 222,
|
|
122
|
+
"\"": 222,
|
|
88
123
|
bright: 255,
|
|
89
124
|
};
|
|
90
125
|
var parseEventTypes = function (eventtypes) {
|
|
@@ -156,180 +191,158 @@ function checkKeyNeed(eventtypes, e) {
|
|
|
156
191
|
return true;
|
|
157
192
|
}
|
|
158
193
|
var pendingid = 0;
|
|
159
|
-
function
|
|
194
|
+
function pending(h, event) {
|
|
160
195
|
if (h instanceof Function) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
res.then(removePending, removePending);
|
|
170
|
-
}
|
|
171
|
-
return res;
|
|
196
|
+
var res = h.call(this, event);
|
|
197
|
+
if (res && isFunction(res.then) && this.setAttribute) {
|
|
198
|
+
var id = ++pendingid & 0x1fffffffffffff;
|
|
199
|
+
this.setAttribute('pending', id);
|
|
200
|
+
var removePending = () => {
|
|
201
|
+
if (+this.getAttribute('pending') === id) this.removeAttribute('pending');
|
|
202
|
+
};
|
|
203
|
+
res.then(removePending, removePending);
|
|
172
204
|
}
|
|
205
|
+
return res;
|
|
173
206
|
}
|
|
174
207
|
return h;
|
|
175
208
|
}
|
|
176
|
-
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (eventtypes.capture) firstmost = true;
|
|
186
|
-
if (target && element !== target) {
|
|
187
|
-
handler = handler.bind(element);
|
|
188
|
-
element = target;
|
|
209
|
+
var remove = function (k, hk, [eventtypes, handler, context]) {
|
|
210
|
+
var element = this;
|
|
211
|
+
var hs = element[hk];
|
|
212
|
+
if (hs) {
|
|
213
|
+
for (var cx = hs.length - 1; cx >= 0; cx--) {
|
|
214
|
+
var [e, h, c] = hs[cx];
|
|
215
|
+
if (h === handler && e === eventtypes && c === context) {
|
|
216
|
+
hs.splice(cx, 1);
|
|
217
|
+
if (k === changes_key) element.needchanges--;
|
|
189
218
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
219
|
+
}
|
|
220
|
+
if (!hs.length && hs.h) {
|
|
221
|
+
element[hk] = null;
|
|
222
|
+
if (is_addEventListener_enabled) {
|
|
223
|
+
element.removeEventListener(k, hs.h, /1$/.test(hk));
|
|
224
|
+
} else {
|
|
225
|
+
if (element["on" + k] === hs.h) element["on" + k] = null;
|
|
193
226
|
}
|
|
194
|
-
var h = function (e) {
|
|
195
|
-
if (eventtypes.self && e.target !== this) return;
|
|
196
|
-
if (!checkKeyNeed(eventtypes, e)) return;
|
|
197
|
-
if (eventtypes.stop) e.stopPropagation();
|
|
198
|
-
if (eventtypes.passive) e.preventDefault = function () { };
|
|
199
|
-
if (eventtypes.prevent) e.preventDefault();
|
|
200
|
-
if (handler instanceof Array) {
|
|
201
|
-
handler.forEach(function (h) {
|
|
202
|
-
h.call(this, e);
|
|
203
|
-
}, this);
|
|
204
|
-
} else {
|
|
205
|
-
handler.call(this, e);
|
|
206
|
-
}
|
|
207
|
-
if (eventtypes.once) remove();
|
|
208
|
-
};
|
|
209
|
-
var remove = function () {
|
|
210
|
-
if (k === changes_key) element.needchanges--;
|
|
211
|
-
element.removeEventListener(k, h, firstmost);
|
|
212
|
-
};
|
|
213
|
-
element.addEventListener(k, h, firstmost);
|
|
214
|
-
return remove;
|
|
215
227
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var broadcast = function (k, hk, event) {
|
|
231
|
+
var element = this;
|
|
232
|
+
var handlers = element[hk];
|
|
233
|
+
if (handlers.length > 1) handlers = handlers.slice();
|
|
234
|
+
for (var [eventtypes, handler, context] of handlers) {
|
|
235
|
+
if (eventtypes.self && event.target !== element) continue;
|
|
236
|
+
if (!checkKeyNeed(eventtypes, event)) continue;
|
|
237
|
+
if (eventtypes.stop) event.stopPropagation();
|
|
238
|
+
if (eventtypes.passive) event.preventDefault = function () { };
|
|
239
|
+
if (eventtypes.prevent) event.preventDefault();
|
|
240
|
+
if (handler instanceof Array) {
|
|
241
|
+
for (var h of handler) {
|
|
242
|
+
h.call(context, event);
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
pending.call(context, handler, event);
|
|
246
|
+
}
|
|
247
|
+
if (eventtypes.once) remove.call(element, k, hk, eventtypes, handler);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
222
250
|
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
var checkroot = function (element, k) {
|
|
252
|
+
k = "on" + k;
|
|
253
|
+
if (!(k in element)) {
|
|
254
|
+
if (element === window && k in document) {
|
|
255
|
+
element = document;
|
|
256
|
+
if (!checkroot[k]) checkroot[k] = true, console.warn("use ", k, "on document instead of on window");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return element;
|
|
260
|
+
}
|
|
225
261
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
element.needchanges++;
|
|
241
|
-
}
|
|
242
|
-
// 仅在hack事件中使用firstmost参数
|
|
243
|
-
if (!(on_event_path in element)) {
|
|
244
|
-
if (element === window && on_event_path in document) {
|
|
245
|
-
element = document;
|
|
246
|
-
if (!addhandler.logged) addhandler.logged = true, console.warn("use", on_event_path, "on document instead of on window");
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (element[handler_path] instanceof Array) {
|
|
250
|
-
if (~element[handler_path].indexOf(handler)) return;
|
|
251
|
-
if (firstmost) element[handler_path].unshift(handler);
|
|
252
|
-
else element[handler_path].push(handler);
|
|
253
|
-
} else {
|
|
254
|
-
element[handler_path] = element[on_event_path] && element[on_event_path] !== handler ? [element[on_event_path], handler] : [handler];
|
|
255
|
-
element[on_event_path] = function (e) {
|
|
256
|
-
if (!e) e = window.event || {};
|
|
257
|
-
if (!e.target && e.srcElement) {
|
|
258
|
-
e.target = e.srcElement;
|
|
259
|
-
}
|
|
260
|
-
if (eventtypes.self && e.target !== this) return;
|
|
261
|
-
if (!checkKeyNeed(eventtypes, e)) return;
|
|
262
|
-
if (e.stopedPropagation) return;
|
|
263
|
-
if (!e.stopPropagation) {
|
|
264
|
-
e.stopPropagation = function () {
|
|
265
|
-
this.stopedPropagation = true;
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
if (eventtypes.stop) {
|
|
269
|
-
e.stopPropagation();
|
|
270
|
-
}
|
|
271
|
-
if (!e.preventDefault) {
|
|
272
|
-
e.preventDefault = function () {
|
|
273
|
-
e.returnValue = false;
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
if (e.button) {
|
|
277
|
-
if (e.buttons === undefined) e.buttons = e.button;
|
|
278
|
-
if (e.which === undefined) e.which = e.button + 1;
|
|
279
|
-
}
|
|
280
|
-
if (e.keyCode) {
|
|
281
|
-
if (e.which === undefined) e.which = e.keyCode;
|
|
282
|
-
}
|
|
283
|
-
if (eventtypes.passive) {
|
|
284
|
-
e.preventDefault = function () { };
|
|
285
|
-
}
|
|
286
|
-
if (eventtypes.prevent) {
|
|
287
|
-
e.preventDefault();
|
|
288
|
-
}
|
|
262
|
+
var append = function (k, hk, listener2, firstmost) {
|
|
263
|
+
var [eventtypes, handler, context] = listener2;
|
|
264
|
+
var element = this;
|
|
265
|
+
var handlers = element[hk];
|
|
266
|
+
for (var [h, e, c] of handlers) {
|
|
267
|
+
if (h === handler && eventtypes === e && c === context) return;
|
|
268
|
+
}
|
|
269
|
+
if (k === changes_key) {
|
|
270
|
+
if (!element.needchanges) element.needchanges = 0;
|
|
271
|
+
element.needchanges++;
|
|
272
|
+
}
|
|
273
|
+
if (firstmost) handlers.unshift(listener2);
|
|
274
|
+
else handlers.push(listener2);
|
|
275
|
+
};
|
|
289
276
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
277
|
+
var on = document.efronton = function (k) {
|
|
278
|
+
var on_event_path = "on" + k;
|
|
279
|
+
if (handlersMap[on_event_path]) return handlersMap[on_event_path];
|
|
280
|
+
var eventtypes = parseEventTypes(k);
|
|
281
|
+
k = k.replace(eventtypereg, '');
|
|
282
|
+
var handler_path = k + "handlers";
|
|
283
|
+
var hk = handler_path + +!!eventtypes.capture;
|
|
284
|
+
if (is_addEventListener_enabled) var addhandler = function (context, handler, firstmost = false) {
|
|
285
|
+
var target = this || context;
|
|
286
|
+
target = checkroot(target, k);
|
|
287
|
+
if (target[hk] instanceof Array) {
|
|
288
|
+
} else {
|
|
289
|
+
var h = broadcast.bind(target, k, hk);
|
|
290
|
+
target[hk] = [];
|
|
291
|
+
target[hk].h = h;
|
|
292
|
+
target.addEventListener(k, h, eventtypes.capture);
|
|
293
|
+
}
|
|
294
|
+
var listener = [eventtypes, handler, context];
|
|
295
|
+
append.call(target, k, hk, listener, firstmost);
|
|
296
|
+
return remove.bind(target, k, hk, listener);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
else var addhandler = function (context, handler, firstmost = false) {
|
|
300
|
+
var target = this || context;
|
|
301
|
+
if (eventtypes.capture) {
|
|
302
|
+
console.warn("当前运行环境不支持事件capture");
|
|
303
|
+
firstmost = true;
|
|
304
|
+
}
|
|
305
|
+
target = checkroot(target, k);
|
|
306
|
+
if (target[handler_path] instanceof Array) {
|
|
307
|
+
} else {
|
|
308
|
+
var h = function (e) {
|
|
309
|
+
if (!e) e = window.event || {};
|
|
310
|
+
if (!e.target && e.srcElement) {
|
|
311
|
+
e.target = e.srcElement;
|
|
312
|
+
}
|
|
313
|
+
if (e.stopedPropagation) return;
|
|
314
|
+
if (!e.stopPropagation) {
|
|
315
|
+
e.stopPropagation = function () {
|
|
316
|
+
this.stopedPropagation = true;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
if (!e.preventDefault) {
|
|
320
|
+
e.preventDefault = function () {
|
|
321
|
+
e.returnValue = false;
|
|
322
|
+
e.defaultPrevented = true;
|
|
323
|
+
};
|
|
313
324
|
}
|
|
314
|
-
if (
|
|
315
|
-
|
|
316
|
-
|
|
325
|
+
if (e.button) {
|
|
326
|
+
if (e.buttons === undefined) e.buttons = e.button;
|
|
327
|
+
if (e.which === undefined) e.which = e.button + 1;
|
|
317
328
|
}
|
|
329
|
+
if (e.keyCode) {
|
|
330
|
+
if (e.which === undefined) e.which = e.keyCode;
|
|
331
|
+
}
|
|
332
|
+
broadcast.call(target, k, handler_path, e);
|
|
333
|
+
return e.returnValue;
|
|
318
334
|
};
|
|
319
|
-
|
|
335
|
+
target[handler_path] = target["on" + k] && target["on" + k] !== handler ? [[{}, target["on" + k]]] : [];
|
|
336
|
+
target[handler_path].h = h;
|
|
337
|
+
target["on" + k] = h;
|
|
320
338
|
}
|
|
321
|
-
|
|
339
|
+
var listener = [eventtypes, handler, context];
|
|
340
|
+
append.call(target, k, handler_path, listener, firstmost);
|
|
341
|
+
return remove.bind(target, k, handler_path, listener);
|
|
322
342
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
cancelup();
|
|
327
|
-
}, true);
|
|
328
|
-
var cancelmove = on("mousemove")(document, function (event) {
|
|
329
|
-
if (!event.which) dispatch("mouseup", document)/* ,console.warn("dispatch mouseup nanually.")*/;
|
|
330
|
-
}, true);
|
|
331
|
-
});
|
|
332
|
-
}
|
|
343
|
+
handlersMap[on_event_path] = addhandler;
|
|
344
|
+
return addhandler;
|
|
345
|
+
};
|
|
333
346
|
var invoke = function (event, type, pointerType) {
|
|
334
347
|
var target = event.target;
|
|
335
348
|
var touch = event.changedTouches ? event.changedTouches[0] : event;
|
|
@@ -342,7 +355,7 @@ var invoke = function (event, type, pointerType) {
|
|
|
342
355
|
|
|
343
356
|
(function () {
|
|
344
357
|
var pointeractive = null;
|
|
345
|
-
if ("onpointerdown" in window) return;
|
|
358
|
+
if ("onpointerdown" in window || document.efronton) return;
|
|
346
359
|
var getPointerType = function (event) {
|
|
347
360
|
return event.type.replace(/(start|move|end|cancel|down|up|leave|out|over|enter)$/i, '');
|
|
348
361
|
};
|
|
@@ -373,8 +386,6 @@ var invoke = function (event, type, pointerType) {
|
|
|
373
386
|
(function () {
|
|
374
387
|
// fastclick
|
|
375
388
|
if (window.fastclick) return;
|
|
376
|
-
if (document.efronton) return on = document.efronton;
|
|
377
|
-
document.efronton = on;
|
|
378
389
|
var onclick = on("click");
|
|
379
390
|
var onmousedown = on("mousedown");
|
|
380
391
|
var onmousemove = on("mousemove");
|