@joint/core 4.0.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/LICENSE +376 -0
- package/README.md +49 -0
- package/dist/geometry.js +6486 -0
- package/dist/geometry.min.js +8 -0
- package/dist/joint.d.ts +5536 -0
- package/dist/joint.js +39629 -0
- package/dist/joint.min.js +8 -0
- package/dist/joint.nowrap.js +39626 -0
- package/dist/joint.nowrap.min.js +8 -0
- package/dist/vectorizer.js +9135 -0
- package/dist/vectorizer.min.js +8 -0
- package/dist/version.mjs +3 -0
- package/index.js +3 -0
- package/joint.mjs +27 -0
- package/package.json +192 -0
- package/src/V/annotation.mjs +0 -0
- package/src/V/index.mjs +2642 -0
- package/src/anchors/index.mjs +123 -0
- package/src/config/index.mjs +12 -0
- package/src/connectionPoints/index.mjs +202 -0
- package/src/connectionStrategies/index.mjs +73 -0
- package/src/connectors/curve.mjs +553 -0
- package/src/connectors/index.mjs +6 -0
- package/src/connectors/jumpover.mjs +452 -0
- package/src/connectors/normal.mjs +12 -0
- package/src/connectors/rounded.mjs +17 -0
- package/src/connectors/smooth.mjs +44 -0
- package/src/connectors/straight.mjs +110 -0
- package/src/dia/Cell.mjs +945 -0
- package/src/dia/CellView.mjs +1316 -0
- package/src/dia/Element.mjs +519 -0
- package/src/dia/ElementView.mjs +859 -0
- package/src/dia/Graph.mjs +1112 -0
- package/src/dia/HighlighterView.mjs +319 -0
- package/src/dia/Link.mjs +565 -0
- package/src/dia/LinkView.mjs +2207 -0
- package/src/dia/Paper.mjs +3171 -0
- package/src/dia/PaperLayer.mjs +75 -0
- package/src/dia/ToolView.mjs +69 -0
- package/src/dia/ToolsView.mjs +128 -0
- package/src/dia/attributes/calc.mjs +128 -0
- package/src/dia/attributes/connection.mjs +75 -0
- package/src/dia/attributes/defs.mjs +76 -0
- package/src/dia/attributes/eval.mjs +64 -0
- package/src/dia/attributes/index.mjs +69 -0
- package/src/dia/attributes/legacy.mjs +148 -0
- package/src/dia/attributes/offset.mjs +53 -0
- package/src/dia/attributes/props.mjs +30 -0
- package/src/dia/attributes/shape.mjs +92 -0
- package/src/dia/attributes/text.mjs +180 -0
- package/src/dia/index.mjs +13 -0
- package/src/dia/layers/GridLayer.mjs +176 -0
- package/src/dia/ports.mjs +874 -0
- package/src/elementTools/Control.mjs +153 -0
- package/src/elementTools/HoverConnect.mjs +37 -0
- package/src/elementTools/index.mjs +5 -0
- package/src/env/index.mjs +43 -0
- package/src/g/bezier.mjs +175 -0
- package/src/g/curve.mjs +956 -0
- package/src/g/ellipse.mjs +245 -0
- package/src/g/extend.mjs +64 -0
- package/src/g/geometry.helpers.mjs +58 -0
- package/src/g/index.mjs +17 -0
- package/src/g/intersection.mjs +511 -0
- package/src/g/line.bearing.mjs +30 -0
- package/src/g/line.length.mjs +5 -0
- package/src/g/line.mjs +356 -0
- package/src/g/line.squaredLength.mjs +10 -0
- package/src/g/path.mjs +2260 -0
- package/src/g/point.mjs +375 -0
- package/src/g/points.mjs +247 -0
- package/src/g/polygon.mjs +51 -0
- package/src/g/polyline.mjs +523 -0
- package/src/g/rect.mjs +556 -0
- package/src/g/types.mjs +10 -0
- package/src/highlighters/addClass.mjs +27 -0
- package/src/highlighters/index.mjs +5 -0
- package/src/highlighters/list.mjs +111 -0
- package/src/highlighters/mask.mjs +220 -0
- package/src/highlighters/opacity.mjs +17 -0
- package/src/highlighters/stroke.mjs +100 -0
- package/src/layout/index.mjs +4 -0
- package/src/layout/ports/port.mjs +188 -0
- package/src/layout/ports/portLabel.mjs +224 -0
- package/src/linkAnchors/index.mjs +76 -0
- package/src/linkTools/Anchor.mjs +235 -0
- package/src/linkTools/Arrowhead.mjs +103 -0
- package/src/linkTools/Boundary.mjs +48 -0
- package/src/linkTools/Button.mjs +121 -0
- package/src/linkTools/Connect.mjs +85 -0
- package/src/linkTools/HoverConnect.mjs +161 -0
- package/src/linkTools/Segments.mjs +393 -0
- package/src/linkTools/Vertices.mjs +253 -0
- package/src/linkTools/helpers.mjs +33 -0
- package/src/linkTools/index.mjs +8 -0
- package/src/mvc/Collection.mjs +560 -0
- package/src/mvc/Data.mjs +46 -0
- package/src/mvc/Dom/Dom.mjs +587 -0
- package/src/mvc/Dom/Event.mjs +130 -0
- package/src/mvc/Dom/animations.mjs +122 -0
- package/src/mvc/Dom/events.mjs +69 -0
- package/src/mvc/Dom/index.mjs +13 -0
- package/src/mvc/Dom/methods.mjs +392 -0
- package/src/mvc/Dom/props.mjs +77 -0
- package/src/mvc/Dom/vars.mjs +5 -0
- package/src/mvc/Events.mjs +337 -0
- package/src/mvc/Listener.mjs +33 -0
- package/src/mvc/Model.mjs +239 -0
- package/src/mvc/View.mjs +323 -0
- package/src/mvc/ViewBase.mjs +182 -0
- package/src/mvc/index.mjs +9 -0
- package/src/mvc/mvcUtils.mjs +90 -0
- package/src/polyfills/array.js +4 -0
- package/src/polyfills/base64.js +68 -0
- package/src/polyfills/index.mjs +5 -0
- package/src/polyfills/number.js +3 -0
- package/src/polyfills/string.js +3 -0
- package/src/polyfills/typedArray.js +47 -0
- package/src/routers/index.mjs +6 -0
- package/src/routers/manhattan.mjs +856 -0
- package/src/routers/metro.mjs +91 -0
- package/src/routers/normal.mjs +6 -0
- package/src/routers/oneSide.mjs +60 -0
- package/src/routers/orthogonal.mjs +323 -0
- package/src/routers/rightAngle.mjs +1056 -0
- package/src/shapes/index.mjs +3 -0
- package/src/shapes/standard.mjs +755 -0
- package/src/util/cloneCells.mjs +67 -0
- package/src/util/getRectPoint.mjs +65 -0
- package/src/util/index.mjs +5 -0
- package/src/util/svgTagTemplate.mjs +110 -0
- package/src/util/util.mjs +1754 -0
- package/src/util/utilHelpers.mjs +2402 -0
- package/src/util/wrappers.mjs +56 -0
- package/types/geometry.d.ts +815 -0
- package/types/index.d.ts +53 -0
- package/types/joint.d.ts +4391 -0
- package/types/joint.head.d.ts +12 -0
- package/types/vectorizer.d.ts +327 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* jQuery JavaScript Library v4.0.0-pre+c98597ea.dirty
|
|
4
|
+
* https://jquery.com/
|
|
5
|
+
*
|
|
6
|
+
* Copyright OpenJS Foundation and other contributors
|
|
7
|
+
* Released under the MIT license
|
|
8
|
+
* https://jquery.org/license
|
|
9
|
+
*
|
|
10
|
+
* Date: 2023-11-24T14:04Z
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { uniq, isEmpty } from '../../util/utilHelpers.mjs';
|
|
14
|
+
import { dataPriv, dataUser } from './vars.mjs';
|
|
15
|
+
import { Event } from './Event.mjs';
|
|
16
|
+
|
|
17
|
+
const document = (typeof window !== 'undefined') ? window.document : null;
|
|
18
|
+
const documentElement = document && document.documentElement;
|
|
19
|
+
|
|
20
|
+
const rTypeNamespace = /^([^.]*)(?:\.(.+)|)/;
|
|
21
|
+
|
|
22
|
+
// Only count HTML whitespace
|
|
23
|
+
// Other whitespace should count in values
|
|
24
|
+
// https://infra.spec.whatwg.org/#ascii-whitespace
|
|
25
|
+
const rNotHtmlWhite = /[^\x20\t\r\n\f]+/g;
|
|
26
|
+
|
|
27
|
+
// Define a local copy of $
|
|
28
|
+
const $ = function(selector) {
|
|
29
|
+
// The $ object is actually just the init constructor 'enhanced'
|
|
30
|
+
// Need init if $ is called (just allow error to be thrown if not included)
|
|
31
|
+
return new $.Dom(selector);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
$.fn = $.prototype = {
|
|
35
|
+
constructor: $,
|
|
36
|
+
// The default length of a $ object is 0
|
|
37
|
+
length: 0,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// A global GUID counter for objects
|
|
41
|
+
$.guid = 1;
|
|
42
|
+
|
|
43
|
+
// User data storage
|
|
44
|
+
$.data = dataUser;
|
|
45
|
+
|
|
46
|
+
$.merge = function(first, second) {
|
|
47
|
+
let len = +second.length;
|
|
48
|
+
let i = first.length;
|
|
49
|
+
for (let j = 0; j < len; j++) {
|
|
50
|
+
first[i++] = second[j];
|
|
51
|
+
}
|
|
52
|
+
first.length = i;
|
|
53
|
+
return first;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
$.parseHTML = function(string) {
|
|
57
|
+
// Inline events will not execute when the HTML is parsed; this includes, for example, sending GET requests for images.
|
|
58
|
+
const context = document.implementation.createHTMLDocument();
|
|
59
|
+
// Set the base href for the created document so any parsed elements with URLs
|
|
60
|
+
// are based on the document's URL
|
|
61
|
+
const base = context.createElement('base');
|
|
62
|
+
base.href = document.location.href;
|
|
63
|
+
context.head.appendChild(base);
|
|
64
|
+
|
|
65
|
+
context.body.innerHTML = string;
|
|
66
|
+
// remove scripts
|
|
67
|
+
const scripts = context.getElementsByTagName('script');
|
|
68
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
69
|
+
scripts[i].remove();
|
|
70
|
+
}
|
|
71
|
+
return Array.from(context.body.childNodes);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (typeof Symbol === 'function') {
|
|
75
|
+
$.fn[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$.fn.toArray = function() {
|
|
79
|
+
return Array.from(this);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Take an array of elements and push it onto the stack
|
|
83
|
+
// (returning the new matched element set)
|
|
84
|
+
$.fn.pushStack = function(elements) {
|
|
85
|
+
// Build a new $ matched element set
|
|
86
|
+
const ret = $.merge(this.constructor(), elements);
|
|
87
|
+
// Add the old object onto the stack (as a reference)
|
|
88
|
+
ret.prevObject = this;
|
|
89
|
+
// Return the newly-formed element set
|
|
90
|
+
return ret;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
$.fn.find = function(selector) {
|
|
94
|
+
const [el] = this;
|
|
95
|
+
const ret = this.pushStack([]);
|
|
96
|
+
if (!el) return ret;
|
|
97
|
+
// Early return if context is not an element, document or document fragment
|
|
98
|
+
const { nodeType } = el;
|
|
99
|
+
if (nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
|
|
100
|
+
return ret;
|
|
101
|
+
}
|
|
102
|
+
if (typeof selector !== 'string') {
|
|
103
|
+
if (el !== selector && el.contains(selector)) {
|
|
104
|
+
$.merge(ret, [selector]);
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
$.merge(ret, el.querySelectorAll(selector));
|
|
108
|
+
}
|
|
109
|
+
return ret;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
$.fn.add = function(selector, context) {
|
|
113
|
+
const newElements = $(selector, context).toArray();
|
|
114
|
+
const prevElements = this.toArray();
|
|
115
|
+
const ret = this.pushStack([]);
|
|
116
|
+
$.merge(ret, uniq(prevElements.concat(newElements)));
|
|
117
|
+
return ret;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
$.fn.addBack = function() {
|
|
121
|
+
return this.add(this.prevObject);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
$.fn.filter = function(selector) {
|
|
125
|
+
const matches = [];
|
|
126
|
+
for (let i = 0; i < this.length; i++) {
|
|
127
|
+
const node = this[i];
|
|
128
|
+
if (!node.matches(selector)) continue;
|
|
129
|
+
matches.push(node);
|
|
130
|
+
}
|
|
131
|
+
return this.pushStack(matches);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// A simple way to check for HTML strings
|
|
135
|
+
// Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)
|
|
136
|
+
// Strict HTML recognition (trac-11290: must start with <)
|
|
137
|
+
// Shortcut simple #id case for speed
|
|
138
|
+
const rQuickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;
|
|
139
|
+
|
|
140
|
+
function isObviousHtml(input) {
|
|
141
|
+
return (
|
|
142
|
+
input[0] === '<' && input[input.length - 1] === '>' && input.length >= 3
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const Dom = function(selector) {
|
|
147
|
+
if (!selector) {
|
|
148
|
+
// HANDLE: $(""), $(null), $(undefined), $(false)
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
if (typeof selector === 'function') {
|
|
152
|
+
// HANDLE: $(function)
|
|
153
|
+
// Shortcut for document ready
|
|
154
|
+
throw new Error('function not supported');
|
|
155
|
+
}
|
|
156
|
+
if (arguments.length > 1) {
|
|
157
|
+
throw new Error('selector with context not supported');
|
|
158
|
+
}
|
|
159
|
+
if (selector.nodeType) {
|
|
160
|
+
// HANDLE: $(DOMElement)
|
|
161
|
+
this[0] = selector;
|
|
162
|
+
this.length = 1;
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
let match;
|
|
166
|
+
if (isObviousHtml(selector + '')) {
|
|
167
|
+
// Handle obvious HTML strings
|
|
168
|
+
// Assume that strings that start and end with <> are HTML and skip
|
|
169
|
+
// the regex check. This also handles browser-supported HTML wrappers
|
|
170
|
+
// like TrustedHTML.
|
|
171
|
+
match = [null, selector, null];
|
|
172
|
+
} else if (typeof selector === 'string') {
|
|
173
|
+
// Handle HTML strings or selectors
|
|
174
|
+
match = rQuickExpr.exec(selector);
|
|
175
|
+
} else {
|
|
176
|
+
// Array-like
|
|
177
|
+
return $.merge(this, selector);
|
|
178
|
+
}
|
|
179
|
+
if (!match || !match[1]) {
|
|
180
|
+
// HANDLE: $(expr)
|
|
181
|
+
return $root.find(selector);
|
|
182
|
+
}
|
|
183
|
+
// Match html or make sure no context is specified for #id
|
|
184
|
+
// Note: match[1] may be a string or a TrustedHTML wrapper
|
|
185
|
+
if (match[1]) {
|
|
186
|
+
// HANDLE: $(html) -> $(array)
|
|
187
|
+
$.merge(this, $.parseHTML(match[1]));
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
// HANDLE: $(#id)
|
|
191
|
+
const el = document.getElementById(match[2]);
|
|
192
|
+
if (el) {
|
|
193
|
+
// Inject the element directly into the $ object
|
|
194
|
+
this[0] = el;
|
|
195
|
+
this.length = 1;
|
|
196
|
+
}
|
|
197
|
+
return this;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
$.Dom = Dom;
|
|
201
|
+
|
|
202
|
+
// Give the init function the $ prototype for later instantiation
|
|
203
|
+
Dom.prototype = $.fn;
|
|
204
|
+
|
|
205
|
+
// Events
|
|
206
|
+
|
|
207
|
+
$.Event = Event;
|
|
208
|
+
|
|
209
|
+
$.event = {
|
|
210
|
+
special: Object.create(null),
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
$.event.has = function(elem, eventType) {
|
|
214
|
+
const events = dataPriv.get(elem, 'events');
|
|
215
|
+
if (!events) return false;
|
|
216
|
+
if (!eventType) return true;
|
|
217
|
+
return Array.isArray(events[eventType]) && events[eventType].length > 0;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
$.event.on = function(elem, types, selector, data, fn, one) {
|
|
221
|
+
|
|
222
|
+
// Types can be a map of types/handlers
|
|
223
|
+
if (typeof types === 'object') {
|
|
224
|
+
// ( types-Object, selector, data )
|
|
225
|
+
if (typeof selector !== 'string') {
|
|
226
|
+
// ( types-Object, data )
|
|
227
|
+
data = data || selector;
|
|
228
|
+
selector = undefined;
|
|
229
|
+
}
|
|
230
|
+
for (let type in types) {
|
|
231
|
+
$.event.on(elem, type, selector, data, types[type], one);
|
|
232
|
+
}
|
|
233
|
+
return elem;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (data == null && fn == null) {
|
|
237
|
+
// ( types, fn )
|
|
238
|
+
fn = selector;
|
|
239
|
+
data = selector = undefined;
|
|
240
|
+
} else if (fn == null) {
|
|
241
|
+
if (typeof selector === 'string') {
|
|
242
|
+
// ( types, selector, fn )
|
|
243
|
+
fn = data;
|
|
244
|
+
data = undefined;
|
|
245
|
+
} else {
|
|
246
|
+
// ( types, data, fn )
|
|
247
|
+
fn = data;
|
|
248
|
+
data = selector;
|
|
249
|
+
selector = undefined;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (!fn) {
|
|
253
|
+
return elem;
|
|
254
|
+
}
|
|
255
|
+
if (one === 1) {
|
|
256
|
+
const origFn = fn;
|
|
257
|
+
fn = function(event) {
|
|
258
|
+
// Can use an empty set, since event contains the info
|
|
259
|
+
$().off(event);
|
|
260
|
+
return origFn.apply(this, arguments);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// Use same guid so caller can remove using origFn
|
|
264
|
+
fn.guid = origFn.guid || (origFn.guid = $.guid++);
|
|
265
|
+
}
|
|
266
|
+
for (let i = 0; i < elem.length; i++) {
|
|
267
|
+
$.event.add(elem[i], types, fn, data, selector);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
$.event.add = function(elem, types, handler, data, selector) {
|
|
272
|
+
// Only attach events to objects for which we can store data
|
|
273
|
+
if (typeof elem != 'object') {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const elemData = dataPriv.create(elem);
|
|
278
|
+
|
|
279
|
+
// Caller can pass in an object of custom data in lieu of the handler
|
|
280
|
+
let handleObjIn;
|
|
281
|
+
if (handler.handler) {
|
|
282
|
+
handleObjIn = handler;
|
|
283
|
+
handler = handleObjIn.handler;
|
|
284
|
+
selector = handleObjIn.selector;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Ensure that invalid selectors throw exceptions at attach time
|
|
288
|
+
// Evaluate against documentElement in case elem is a non-element node (e.g., document)
|
|
289
|
+
if (selector) {
|
|
290
|
+
documentElement.matches(selector);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Make sure that the handler has a unique ID, used to find/remove it later
|
|
294
|
+
if (!handler.guid) {
|
|
295
|
+
handler.guid = $.guid++;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Init the element's event structure and main handler, if this is the first
|
|
299
|
+
let events;
|
|
300
|
+
if (!(events = elemData.events)) {
|
|
301
|
+
events = elemData.events = Object.create(null);
|
|
302
|
+
}
|
|
303
|
+
let eventHandle;
|
|
304
|
+
if (!(eventHandle = elemData.handle)) {
|
|
305
|
+
eventHandle = elemData.handle = function(e) {
|
|
306
|
+
// Discard the second event of a $.event.trigger() and
|
|
307
|
+
// when an event is called after a page has unloaded
|
|
308
|
+
return (typeof $ !== 'undefined')
|
|
309
|
+
? $.event.dispatch.apply(elem, arguments)
|
|
310
|
+
: undefined;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Handle multiple events separated by a space
|
|
315
|
+
const typesArr = (types || '').match(rNotHtmlWhite) || [''];
|
|
316
|
+
let i = typesArr.length;
|
|
317
|
+
while (i--) {
|
|
318
|
+
const [, origType, ns = ''] = rTypeNamespace.exec(typesArr[i]);
|
|
319
|
+
// There *must* be a type, no attaching namespace-only handlers
|
|
320
|
+
if (!origType) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const namespaces = ns.split('.').sort();
|
|
325
|
+
// If event changes its type, use the special event handlers for the changed type
|
|
326
|
+
let special = $.event.special[origType];
|
|
327
|
+
// If selector defined, determine special event api type, otherwise given type
|
|
328
|
+
const type = (special && (selector ? special.delegateType : special.bindType)) || origType;
|
|
329
|
+
// Update special based on newly reset type
|
|
330
|
+
special = $.event.special[type];
|
|
331
|
+
// handleObj is passed to all event handlers
|
|
332
|
+
const handleObj = Object.assign(
|
|
333
|
+
{
|
|
334
|
+
type: type,
|
|
335
|
+
origType: origType,
|
|
336
|
+
data: data,
|
|
337
|
+
handler: handler,
|
|
338
|
+
guid: handler.guid,
|
|
339
|
+
selector: selector,
|
|
340
|
+
namespace: namespaces.join('.'),
|
|
341
|
+
},
|
|
342
|
+
handleObjIn
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
let handlers;
|
|
346
|
+
// Init the event handler queue if we're the first
|
|
347
|
+
if (!(handlers = events[type])) {
|
|
348
|
+
handlers = events[type] = [];
|
|
349
|
+
handlers.delegateCount = 0;
|
|
350
|
+
|
|
351
|
+
// Only use addEventListener if the special events handler returns false
|
|
352
|
+
if (
|
|
353
|
+
!special || !special.setup ||
|
|
354
|
+
special.setup.call(elem, data, namespaces, eventHandle) === false
|
|
355
|
+
) {
|
|
356
|
+
if (elem.addEventListener) {
|
|
357
|
+
elem.addEventListener(type, eventHandle);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (special && special.add) {
|
|
363
|
+
special.add.call(elem, handleObj);
|
|
364
|
+
if (!handleObj.handler.guid) {
|
|
365
|
+
handleObj.handler.guid = handler.guid;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Add to the element's handler list, delegates in front
|
|
370
|
+
if (selector) {
|
|
371
|
+
handlers.splice(handlers.delegateCount++, 0, handleObj);
|
|
372
|
+
} else {
|
|
373
|
+
handlers.push(handleObj);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// Detach an event or set of events from an element
|
|
379
|
+
$.event.remove = function(elem, types, handler, selector, mappedTypes) {
|
|
380
|
+
|
|
381
|
+
const elemData = dataPriv.get(elem);
|
|
382
|
+
if (!elemData || !elemData.events) return;
|
|
383
|
+
const events = elemData.events;
|
|
384
|
+
|
|
385
|
+
// Once for each type.namespace in types; type may be omitted
|
|
386
|
+
const typesArr = (types || '').match(rNotHtmlWhite) || [''];
|
|
387
|
+
let i = typesArr.length;
|
|
388
|
+
while (i--) {
|
|
389
|
+
const [, origType, ns = ''] = rTypeNamespace.exec(typesArr[i]);
|
|
390
|
+
// Unbind all events (on this namespace, if provided) for the element
|
|
391
|
+
if (!origType) {
|
|
392
|
+
for (const type in events) {
|
|
393
|
+
$.event.remove(
|
|
394
|
+
elem,
|
|
395
|
+
type + typesArr[i],
|
|
396
|
+
handler,
|
|
397
|
+
selector,
|
|
398
|
+
true
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const special = $.event.special[origType];
|
|
405
|
+
const type = (special && (selector ? special.delegateType : special.bindType)) || origType;
|
|
406
|
+
const handlers = events[type];
|
|
407
|
+
if (!handlers || handlers.length === 0) continue;
|
|
408
|
+
|
|
409
|
+
const namespaces = ns.split('.').sort();
|
|
410
|
+
const rNamespace = ns
|
|
411
|
+
? new RegExp('(^|\\.)' + namespaces.join('\\.(?:.*\\.|)') + '(\\.|$)')
|
|
412
|
+
: null;
|
|
413
|
+
|
|
414
|
+
// Remove matching events
|
|
415
|
+
const origCount = handlers.length;
|
|
416
|
+
let j = origCount;
|
|
417
|
+
while (j--) {
|
|
418
|
+
const handleObj = handlers[j];
|
|
419
|
+
|
|
420
|
+
if (
|
|
421
|
+
(mappedTypes || origType === handleObj.origType) &&
|
|
422
|
+
(!handler || handler.guid === handleObj.guid) &&
|
|
423
|
+
(!rNamespace || rNamespace.test(handleObj.namespace)) &&
|
|
424
|
+
(!selector ||
|
|
425
|
+
selector === handleObj.selector ||
|
|
426
|
+
(selector === '**' && handleObj.selector))
|
|
427
|
+
) {
|
|
428
|
+
handlers.splice(j, 1);
|
|
429
|
+
if (handleObj.selector) {
|
|
430
|
+
handlers.delegateCount--;
|
|
431
|
+
}
|
|
432
|
+
if (special && special.remove) {
|
|
433
|
+
special.remove.call(elem, handleObj);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Remove generic event handler if we removed something and no more handlers exist
|
|
439
|
+
// (avoids potential for endless recursion during removal of special event handlers)
|
|
440
|
+
if (origCount && handlers.length === 0) {
|
|
441
|
+
if (
|
|
442
|
+
!special || !special.teardown ||
|
|
443
|
+
special.teardown.call(elem, namespaces, elemData.handle) === false
|
|
444
|
+
) {
|
|
445
|
+
// This "if" is needed for plain objects
|
|
446
|
+
if (elem.removeEventListener) {
|
|
447
|
+
elem.removeEventListener(type, elemData.handle);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
delete events[type];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Remove data if it's no longer used
|
|
455
|
+
if (isEmpty(events)) {
|
|
456
|
+
dataPriv.remove(elem, 'handle');
|
|
457
|
+
dataPriv.remove(elem, 'events');
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
$.event.dispatch = function(nativeEvent) {
|
|
462
|
+
|
|
463
|
+
const elem = this;
|
|
464
|
+
// Make a writable $.Event from the native event object
|
|
465
|
+
const event = $.event.fix(nativeEvent);
|
|
466
|
+
event.delegateTarget = elem;
|
|
467
|
+
// Use the fix-ed $.Event rather than the (read-only) native event
|
|
468
|
+
const args = Array.from(arguments);
|
|
469
|
+
args[0] = event;
|
|
470
|
+
|
|
471
|
+
const eventsData = dataPriv.get(elem, 'events');
|
|
472
|
+
const handlers = (eventsData && eventsData[event.type]) || [];
|
|
473
|
+
const special = $.event.special[event.type];
|
|
474
|
+
|
|
475
|
+
// Call the preDispatch hook for the mapped type, and let it bail if desired
|
|
476
|
+
if (special && special.preDispatch) {
|
|
477
|
+
if (special.preDispatch.call(elem, event) === false) return;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Determine handlers
|
|
481
|
+
const handlerQueue = $.event.handlers.call(elem, event, handlers);
|
|
482
|
+
|
|
483
|
+
// Run delegates first; they may want to stop propagation beneath us
|
|
484
|
+
let i = 0;
|
|
485
|
+
let matched;
|
|
486
|
+
while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
|
|
487
|
+
event.currentTarget = matched.elem;
|
|
488
|
+
let j = 0;
|
|
489
|
+
let handleObj;
|
|
490
|
+
while (
|
|
491
|
+
(handleObj = matched.handlers[j++]) &&
|
|
492
|
+
!event.isImmediatePropagationStopped()
|
|
493
|
+
) {
|
|
494
|
+
|
|
495
|
+
event.handleObj = handleObj;
|
|
496
|
+
event.data = handleObj.data;
|
|
497
|
+
|
|
498
|
+
const origSpecial = $.event.special[handleObj.origType];
|
|
499
|
+
let handler;
|
|
500
|
+
if (origSpecial && origSpecial.handle) {
|
|
501
|
+
handler = origSpecial.handle;
|
|
502
|
+
} else {
|
|
503
|
+
handler = handleObj.handler;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const ret = handler.apply(matched.elem, args);
|
|
507
|
+
if (ret !== undefined) {
|
|
508
|
+
if ((event.result = ret) === false) {
|
|
509
|
+
event.preventDefault();
|
|
510
|
+
event.stopPropagation();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// Call the postDispatch hook for the mapped type
|
|
517
|
+
if (special && special.postDispatch) {
|
|
518
|
+
special.postDispatch.call(elem, event);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return event.result;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
$.event.handlers = function(event, handlers) {
|
|
525
|
+
|
|
526
|
+
const delegateCount = handlers.delegateCount;
|
|
527
|
+
const handlerQueue = [];
|
|
528
|
+
|
|
529
|
+
// Find delegate handlers
|
|
530
|
+
if (
|
|
531
|
+
delegateCount &&
|
|
532
|
+
// Support: Firefox <=42 - 66+
|
|
533
|
+
// Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
|
|
534
|
+
// https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
|
|
535
|
+
// Support: IE 11+
|
|
536
|
+
// ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
|
|
537
|
+
!(event.type === 'click' && event.button >= 1)
|
|
538
|
+
) {
|
|
539
|
+
for (let cur = event.target; cur !== this; cur = cur.parentNode || this) {
|
|
540
|
+
// Don't check non-elements (trac-13208)
|
|
541
|
+
// Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)
|
|
542
|
+
if (
|
|
543
|
+
cur.nodeType === 1 &&
|
|
544
|
+
!(event.type === 'click' && cur.disabled === true)
|
|
545
|
+
) {
|
|
546
|
+
const matchedHandlers = [];
|
|
547
|
+
const matchedSelectors = {};
|
|
548
|
+
for (let i = 0; i < delegateCount; i++) {
|
|
549
|
+
const handleObj = handlers[i];
|
|
550
|
+
// Don't conflict with Object.prototype properties (trac-13203)
|
|
551
|
+
const sel = handleObj.selector + ' ';
|
|
552
|
+
if (matchedSelectors[sel] === undefined) {
|
|
553
|
+
matchedSelectors[sel] = cur.matches(sel);
|
|
554
|
+
}
|
|
555
|
+
if (matchedSelectors[sel]) {
|
|
556
|
+
matchedHandlers.push(handleObj);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (matchedHandlers.length) {
|
|
560
|
+
handlerQueue.push({
|
|
561
|
+
elem: cur,
|
|
562
|
+
handlers: matchedHandlers,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Add the remaining (directly-bound) handlers
|
|
570
|
+
if (delegateCount < handlers.length) {
|
|
571
|
+
handlerQueue.push({
|
|
572
|
+
elem: this,
|
|
573
|
+
handlers: handlers.slice(delegateCount),
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return handlerQueue;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
$.event.fix = function(originalEvent) {
|
|
581
|
+
return originalEvent.envelope ? originalEvent : new Event(originalEvent);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
// A central reference to the root $(document)
|
|
585
|
+
const $root = $(document);
|
|
586
|
+
|
|
587
|
+
export { $ as default };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export const Event = function(src, props) {
|
|
2
|
+
// Allow instantiation without the 'new' keyword
|
|
3
|
+
if (!(this instanceof Event)) {
|
|
4
|
+
return new Event(src, props);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// Event object
|
|
8
|
+
if (src && src.type) {
|
|
9
|
+
this.originalEvent = src;
|
|
10
|
+
this.type = src.type;
|
|
11
|
+
|
|
12
|
+
// Events bubbling up the document may have been marked as prevented
|
|
13
|
+
// by a handler lower down the tree; reflect the correct value.
|
|
14
|
+
this.isDefaultPrevented = src.defaultPrevented
|
|
15
|
+
? returnTrue
|
|
16
|
+
: returnFalse;
|
|
17
|
+
|
|
18
|
+
// Create target properties
|
|
19
|
+
this.target = src.target;
|
|
20
|
+
this.currentTarget = src.currentTarget;
|
|
21
|
+
this.relatedTarget = src.relatedTarget;
|
|
22
|
+
|
|
23
|
+
// Event type
|
|
24
|
+
} else {
|
|
25
|
+
this.type = src;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Put explicitly provided properties onto the event object
|
|
29
|
+
if (props) {
|
|
30
|
+
Object.assign(this, props);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Create a timestamp if incoming event doesn't have one
|
|
34
|
+
this.timeStamp = (src && src.timeStamp) || Date.now();
|
|
35
|
+
|
|
36
|
+
// Mark it as fixed
|
|
37
|
+
this.envelope = true;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// $.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
|
41
|
+
// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
|
42
|
+
Event.prototype = {
|
|
43
|
+
constructor: Event,
|
|
44
|
+
isDefaultPrevented: returnFalse,
|
|
45
|
+
isPropagationStopped: returnFalse,
|
|
46
|
+
isImmediatePropagationStopped: returnFalse,
|
|
47
|
+
preventDefault: function() {
|
|
48
|
+
const evt = this.originalEvent;
|
|
49
|
+
this.isDefaultPrevented = returnTrue;
|
|
50
|
+
if (evt) {
|
|
51
|
+
evt.preventDefault();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
stopPropagation: function() {
|
|
55
|
+
const evt = this.originalEvent;
|
|
56
|
+
this.isPropagationStopped = returnTrue;
|
|
57
|
+
if (evt) {
|
|
58
|
+
evt.stopPropagation();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
stopImmediatePropagation: function() {
|
|
62
|
+
const evt = this.originalEvent;
|
|
63
|
+
this.isImmediatePropagationStopped = returnTrue;
|
|
64
|
+
if (evt) {
|
|
65
|
+
evt.stopImmediatePropagation();
|
|
66
|
+
}
|
|
67
|
+
this.stopPropagation();
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Includes all common event props including KeyEvent and MouseEvent specific props
|
|
72
|
+
[
|
|
73
|
+
'altKey',
|
|
74
|
+
'bubbles',
|
|
75
|
+
'cancelable',
|
|
76
|
+
'changedTouches',
|
|
77
|
+
'ctrlKey',
|
|
78
|
+
'detail',
|
|
79
|
+
'eventPhase',
|
|
80
|
+
'metaKey',
|
|
81
|
+
'pageX',
|
|
82
|
+
'pageY',
|
|
83
|
+
'shiftKey',
|
|
84
|
+
'view',
|
|
85
|
+
'char',
|
|
86
|
+
'code',
|
|
87
|
+
'charCode',
|
|
88
|
+
'key',
|
|
89
|
+
'keyCode',
|
|
90
|
+
'button',
|
|
91
|
+
'buttons',
|
|
92
|
+
'clientX',
|
|
93
|
+
'clientY',
|
|
94
|
+
'offsetX',
|
|
95
|
+
'offsetY',
|
|
96
|
+
'pointerId',
|
|
97
|
+
'pointerType',
|
|
98
|
+
'screenX',
|
|
99
|
+
'screenY',
|
|
100
|
+
'targetTouches',
|
|
101
|
+
'toElement',
|
|
102
|
+
'touches',
|
|
103
|
+
'which',
|
|
104
|
+
].forEach((name) => addProp(name));
|
|
105
|
+
|
|
106
|
+
function addProp(name) {
|
|
107
|
+
Object.defineProperty(Event.prototype, name, {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
configurable: true,
|
|
110
|
+
get: function() {
|
|
111
|
+
return this.originalEvent ? this.originalEvent[name] : undefined;
|
|
112
|
+
},
|
|
113
|
+
set: function(value) {
|
|
114
|
+
Object.defineProperty(this, name, {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
configurable: true,
|
|
117
|
+
writable: true,
|
|
118
|
+
value: value,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function returnTrue() {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function returnFalse() {
|
|
129
|
+
return false;
|
|
130
|
+
}
|