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 | import moment$3 from 'moment';
|
28 | import { isDataViewLike as isDataViewLike$1, DataSet, createNewDataPipeFrom, DataView } from 'vis-data/peer/esm/vis-data.js';
|
29 |
|
30 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
31 |
|
32 | function getDefaultExportFromCjs (x) {
|
33 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
34 | }
|
35 |
|
36 | var construct$4 = {exports: {}};
|
37 |
|
38 | var check = function (it) {
|
39 | return it && it.Math == Math && it;
|
40 | };
|
41 |
|
42 |
|
43 | var global$N =
|
44 | check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) ||
|
45 | check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
|
46 | function () {
|
47 | return this;
|
48 | }() || Function('return this')();
|
49 |
|
50 | var fails$s = function (exec) {
|
51 | try {
|
52 | return !!exec();
|
53 | } catch (error) {
|
54 | return true;
|
55 | }
|
56 | };
|
57 |
|
58 | var fails$r = fails$s;
|
59 | var functionBindNative = !fails$r(function () {
|
60 | var test = function () {
|
61 |
|
62 | }.bind();
|
63 |
|
64 |
|
65 | return typeof test != 'function' || test.hasOwnProperty('prototype');
|
66 | });
|
67 |
|
68 | var NATIVE_BIND$4 = functionBindNative;
|
69 | var FunctionPrototype$3 = Function.prototype;
|
70 | var apply$6 = FunctionPrototype$3.apply;
|
71 | var call$c = FunctionPrototype$3.call;
|
72 |
|
73 | var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND$4 ? call$c.bind(apply$6) : function () {
|
74 | return call$c.apply(apply$6, arguments);
|
75 | });
|
76 |
|
77 | var NATIVE_BIND$3 = functionBindNative;
|
78 | var FunctionPrototype$2 = Function.prototype;
|
79 | var bind$f = FunctionPrototype$2.bind;
|
80 | var call$b = FunctionPrototype$2.call;
|
81 | var uncurryThis$u = NATIVE_BIND$3 && bind$f.bind(call$b, call$b);
|
82 | var functionUncurryThis = NATIVE_BIND$3 ? function (fn) {
|
83 | return fn && uncurryThis$u(fn);
|
84 | } : function (fn) {
|
85 | return fn && function () {
|
86 | return call$b.apply(fn, arguments);
|
87 | };
|
88 | };
|
89 |
|
90 |
|
91 |
|
92 | var isCallable$h = function (argument) {
|
93 | return typeof argument == 'function';
|
94 | };
|
95 |
|
96 | var objectGetOwnPropertyDescriptor = {};
|
97 |
|
98 | var fails$q = fails$s;
|
99 |
|
100 | var descriptors = !fails$q(function () {
|
101 |
|
102 | return Object.defineProperty({}, 1, {
|
103 | get: function () {
|
104 | return 7;
|
105 | }
|
106 | })[1] != 7;
|
107 | });
|
108 |
|
109 | var NATIVE_BIND$2 = functionBindNative;
|
110 | var call$a = Function.prototype.call;
|
111 | var functionCall = NATIVE_BIND$2 ? call$a.bind(call$a) : function () {
|
112 | return call$a.apply(call$a, arguments);
|
113 | };
|
114 |
|
115 | var objectPropertyIsEnumerable = {};
|
116 |
|
117 | var $propertyIsEnumerable$2 = {}.propertyIsEnumerable;
|
118 |
|
119 | var getOwnPropertyDescriptor$5 = Object.getOwnPropertyDescriptor;
|
120 |
|
121 | var NASHORN_BUG = getOwnPropertyDescriptor$5 && !$propertyIsEnumerable$2.call({
|
122 | 1: 2
|
123 | }, 1);
|
124 |
|
125 |
|
126 | objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
|
127 | var descriptor = getOwnPropertyDescriptor$5(this, V);
|
128 | return !!descriptor && descriptor.enumerable;
|
129 | } : $propertyIsEnumerable$2;
|
130 |
|
131 | var createPropertyDescriptor$5 = function (bitmap, value) {
|
132 | return {
|
133 | enumerable: !(bitmap & 1),
|
134 | configurable: !(bitmap & 2),
|
135 | writable: !(bitmap & 4),
|
136 | value: value
|
137 | };
|
138 | };
|
139 |
|
140 | var uncurryThis$t = functionUncurryThis;
|
141 | var toString$b = uncurryThis$t({}.toString);
|
142 | var stringSlice$1 = uncurryThis$t(''.slice);
|
143 |
|
144 | var classofRaw$1 = function (it) {
|
145 | return stringSlice$1(toString$b(it), 8, -1);
|
146 | };
|
147 |
|
148 | var global$M = global$N;
|
149 | var uncurryThis$s = functionUncurryThis;
|
150 | var fails$p = fails$s;
|
151 | var classof$c = classofRaw$1;
|
152 | var Object$9 = global$M.Object;
|
153 | var split = uncurryThis$s(''.split);
|
154 |
|
155 | var indexedObject = fails$p(function () {
|
156 |
|
157 |
|
158 | return !Object$9('z').propertyIsEnumerable(0);
|
159 | }) ? function (it) {
|
160 | return classof$c(it) == 'String' ? split(it, '') : Object$9(it);
|
161 | } : Object$9;
|
162 |
|
163 | var global$L = global$N;
|
164 | var TypeError$i = global$L.TypeError;
|
165 |
|
166 |
|
167 | var requireObjectCoercible$6 = function (it) {
|
168 | if (it == undefined) throw TypeError$i("Can't call method on " + it);
|
169 | return it;
|
170 | };
|
171 |
|
172 | var IndexedObject$3 = indexedObject;
|
173 | var requireObjectCoercible$5 = requireObjectCoercible$6;
|
174 |
|
175 | var toIndexedObject$b = function (it) {
|
176 | return IndexedObject$3(requireObjectCoercible$5(it));
|
177 | };
|
178 |
|
179 | var isCallable$g = isCallable$h;
|
180 |
|
181 | var isObject$g = function (it) {
|
182 | return typeof it == 'object' ? it !== null : isCallable$g(it);
|
183 | };
|
184 |
|
185 | var path$r = {};
|
186 |
|
187 | var path$q = path$r;
|
188 | var global$K = global$N;
|
189 | var isCallable$f = isCallable$h;
|
190 |
|
191 | var aFunction = function (variable) {
|
192 | return isCallable$f(variable) ? variable : undefined;
|
193 | };
|
194 |
|
195 | var getBuiltIn$9 = function (namespace, method) {
|
196 | return arguments.length < 2 ? aFunction(path$q[namespace]) || aFunction(global$K[namespace]) : path$q[namespace] && path$q[namespace][method] || global$K[namespace] && global$K[namespace][method];
|
197 | };
|
198 |
|
199 | var uncurryThis$r = functionUncurryThis;
|
200 | var objectIsPrototypeOf = uncurryThis$r({}.isPrototypeOf);
|
201 |
|
202 | var getBuiltIn$8 = getBuiltIn$9;
|
203 | var engineUserAgent = getBuiltIn$8('navigator', 'userAgent') || '';
|
204 |
|
205 | var global$J = global$N;
|
206 | var userAgent$3 = engineUserAgent;
|
207 | var process = global$J.process;
|
208 | var Deno = global$J.Deno;
|
209 | var versions = process && process.versions || Deno && Deno.version;
|
210 | var v8 = versions && versions.v8;
|
211 | var match, version;
|
212 |
|
213 | if (v8) {
|
214 | match = v8.split('.');
|
215 |
|
216 |
|
217 | version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
|
218 | }
|
219 |
|
220 |
|
221 |
|
222 | if (!version && userAgent$3) {
|
223 | match = userAgent$3.match(/Edge\/(\d+)/);
|
224 |
|
225 | if (!match || match[1] >= 74) {
|
226 | match = userAgent$3.match(/Chrome\/(\d+)/);
|
227 | if (match) version = +match[1];
|
228 | }
|
229 | }
|
230 |
|
231 | var engineV8Version = version;
|
232 |
|
233 |
|
234 | var V8_VERSION$2 = engineV8Version;
|
235 | var fails$o = fails$s;
|
236 |
|
237 | var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$o(function () {
|
238 | var symbol = Symbol();
|
239 |
|
240 |
|
241 | return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
|
242 | !Symbol.sham && V8_VERSION$2 && V8_VERSION$2 < 41;
|
243 | });
|
244 |
|
245 |
|
246 | var NATIVE_SYMBOL$2 = nativeSymbol;
|
247 | var useSymbolAsUid = NATIVE_SYMBOL$2 && !Symbol.sham && typeof Symbol.iterator == 'symbol';
|
248 |
|
249 | var global$I = global$N;
|
250 | var getBuiltIn$7 = getBuiltIn$9;
|
251 | var isCallable$e = isCallable$h;
|
252 | var isPrototypeOf$m = objectIsPrototypeOf;
|
253 | var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
|
254 | var Object$8 = global$I.Object;
|
255 | var isSymbol$3 = USE_SYMBOL_AS_UID$1 ? function (it) {
|
256 | return typeof it == 'symbol';
|
257 | } : function (it) {
|
258 | var $Symbol = getBuiltIn$7('Symbol');
|
259 | return isCallable$e($Symbol) && isPrototypeOf$m($Symbol.prototype, Object$8(it));
|
260 | };
|
261 |
|
262 | var global$H = global$N;
|
263 | var String$4 = global$H.String;
|
264 |
|
265 | var tryToString$4 = function (argument) {
|
266 | try {
|
267 | return String$4(argument);
|
268 | } catch (error) {
|
269 | return 'Object';
|
270 | }
|
271 | };
|
272 |
|
273 | var global$G = global$N;
|
274 | var isCallable$d = isCallable$h;
|
275 | var tryToString$3 = tryToString$4;
|
276 | var TypeError$h = global$G.TypeError;
|
277 |
|
278 | var aCallable$6 = function (argument) {
|
279 | if (isCallable$d(argument)) return argument;
|
280 | throw TypeError$h(tryToString$3(argument) + ' is not a function');
|
281 | };
|
282 |
|
283 | var aCallable$5 = aCallable$6;
|
284 |
|
285 |
|
286 | var getMethod$3 = function (V, P) {
|
287 | var func = V[P];
|
288 | return func == null ? undefined : aCallable$5(func);
|
289 | };
|
290 |
|
291 | var global$F = global$N;
|
292 | var call$9 = functionCall;
|
293 | var isCallable$c = isCallable$h;
|
294 | var isObject$f = isObject$g;
|
295 | var TypeError$g = global$F.TypeError;
|
296 |
|
297 |
|
298 | var ordinaryToPrimitive$1 = function (input, pref) {
|
299 | var fn, val;
|
300 | if (pref === 'string' && isCallable$c(fn = input.toString) && !isObject$f(val = call$9(fn, input))) return val;
|
301 | if (isCallable$c(fn = input.valueOf) && !isObject$f(val = call$9(fn, input))) return val;
|
302 | if (pref !== 'string' && isCallable$c(fn = input.toString) && !isObject$f(val = call$9(fn, input))) return val;
|
303 | throw TypeError$g("Can't convert object to primitive value");
|
304 | };
|
305 |
|
306 | var shared$4 = {exports: {}};
|
307 |
|
308 | var global$E = global$N;
|
309 |
|
310 | var defineProperty$e = Object.defineProperty;
|
311 |
|
312 | var setGlobal$1 = function (key, value) {
|
313 | try {
|
314 | defineProperty$e(global$E, key, {
|
315 | value: value,
|
316 | configurable: true,
|
317 | writable: true
|
318 | });
|
319 | } catch (error) {
|
320 | global$E[key] = value;
|
321 | }
|
322 |
|
323 | return value;
|
324 | };
|
325 |
|
326 | var global$D = global$N;
|
327 | var setGlobal = setGlobal$1;
|
328 | var SHARED = '__core-js_shared__';
|
329 | var store$3 = global$D[SHARED] || setGlobal(SHARED, {});
|
330 | var sharedStore = store$3;
|
331 |
|
332 | var store$2 = sharedStore;
|
333 | (shared$4.exports = function (key, value) {
|
334 | return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
335 | })('versions', []).push({
|
336 | version: '3.21.1',
|
337 | mode: 'pure' ,
|
338 | copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
339 | license: 'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',
|
340 | source: 'https://github.com/zloirock/core-js'
|
341 | });
|
342 |
|
343 | var global$C = global$N;
|
344 | var requireObjectCoercible$4 = requireObjectCoercible$6;
|
345 | var Object$7 = global$C.Object;
|
346 |
|
347 |
|
348 | var toObject$d = function (argument) {
|
349 | return Object$7(requireObjectCoercible$4(argument));
|
350 | };
|
351 |
|
352 | var uncurryThis$q = functionUncurryThis;
|
353 | var toObject$c = toObject$d;
|
354 | var hasOwnProperty = uncurryThis$q({}.hasOwnProperty);
|
355 |
|
356 |
|
357 | var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
|
358 | return hasOwnProperty(toObject$c(it), key);
|
359 | };
|
360 |
|
361 | var uncurryThis$p = functionUncurryThis;
|
362 | var id$1 = 0;
|
363 | var postfix = Math.random();
|
364 | var toString$a = uncurryThis$p(1.0.toString);
|
365 |
|
366 | var uid$4 = function (key) {
|
367 | return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$a(++id$1 + postfix, 36);
|
368 | };
|
369 |
|
370 | var global$B = global$N;
|
371 | var shared$3 = shared$4.exports;
|
372 | var hasOwn$c = hasOwnProperty_1;
|
373 | var uid$3 = uid$4;
|
374 | var NATIVE_SYMBOL$1 = nativeSymbol;
|
375 | var USE_SYMBOL_AS_UID = useSymbolAsUid;
|
376 | var WellKnownSymbolsStore$1 = shared$3('wks');
|
377 | var Symbol$3 = global$B.Symbol;
|
378 | var symbolFor = Symbol$3 && Symbol$3['for'];
|
379 | var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$3 : Symbol$3 && Symbol$3.withoutSetter || uid$3;
|
380 |
|
381 | var wellKnownSymbol$j = function (name) {
|
382 | if (!hasOwn$c(WellKnownSymbolsStore$1, name) || !(NATIVE_SYMBOL$1 || typeof WellKnownSymbolsStore$1[name] == 'string')) {
|
383 | var description = 'Symbol.' + name;
|
384 |
|
385 | if (NATIVE_SYMBOL$1 && hasOwn$c(Symbol$3, name)) {
|
386 | WellKnownSymbolsStore$1[name] = Symbol$3[name];
|
387 | } else if (USE_SYMBOL_AS_UID && symbolFor) {
|
388 | WellKnownSymbolsStore$1[name] = symbolFor(description);
|
389 | } else {
|
390 | WellKnownSymbolsStore$1[name] = createWellKnownSymbol(description);
|
391 | }
|
392 | }
|
393 |
|
394 | return WellKnownSymbolsStore$1[name];
|
395 | };
|
396 |
|
397 | var global$A = global$N;
|
398 | var call$8 = functionCall;
|
399 | var isObject$e = isObject$g;
|
400 | var isSymbol$2 = isSymbol$3;
|
401 | var getMethod$2 = getMethod$3;
|
402 | var ordinaryToPrimitive = ordinaryToPrimitive$1;
|
403 | var wellKnownSymbol$i = wellKnownSymbol$j;
|
404 | var TypeError$f = global$A.TypeError;
|
405 | var TO_PRIMITIVE$1 = wellKnownSymbol$i('toPrimitive');
|
406 |
|
407 |
|
408 | var toPrimitive$1 = function (input, pref) {
|
409 | if (!isObject$e(input) || isSymbol$2(input)) return input;
|
410 | var exoticToPrim = getMethod$2(input, TO_PRIMITIVE$1);
|
411 | var result;
|
412 |
|
413 | if (exoticToPrim) {
|
414 | if (pref === undefined) pref = 'default';
|
415 | result = call$8(exoticToPrim, input, pref);
|
416 | if (!isObject$e(result) || isSymbol$2(result)) return result;
|
417 | throw TypeError$f("Can't convert object to primitive value");
|
418 | }
|
419 |
|
420 | if (pref === undefined) pref = 'number';
|
421 | return ordinaryToPrimitive(input, pref);
|
422 | };
|
423 |
|
424 | var toPrimitive = toPrimitive$1;
|
425 | var isSymbol$1 = isSymbol$3;
|
426 |
|
427 |
|
428 | var toPropertyKey$4 = function (argument) {
|
429 | var key = toPrimitive(argument, 'string');
|
430 | return isSymbol$1(key) ? key : key + '';
|
431 | };
|
432 |
|
433 | var global$z = global$N;
|
434 | var isObject$d = isObject$g;
|
435 | var document$1 = global$z.document;
|
436 |
|
437 | var EXISTS$1 = isObject$d(document$1) && isObject$d(document$1.createElement);
|
438 |
|
439 | var documentCreateElement$1 = function (it) {
|
440 | return EXISTS$1 ? document$1.createElement(it) : {};
|
441 | };
|
442 |
|
443 | var DESCRIPTORS$h = descriptors;
|
444 | var fails$n = fails$s;
|
445 | var createElement = documentCreateElement$1;
|
446 |
|
447 | var ie8DomDefine = !DESCRIPTORS$h && !fails$n(function () {
|
448 |
|
449 | return Object.defineProperty(createElement('div'), 'a', {
|
450 | get: function () {
|
451 | return 7;
|
452 | }
|
453 | }).a != 7;
|
454 | });
|
455 |
|
456 | var DESCRIPTORS$g = descriptors;
|
457 | var call$7 = functionCall;
|
458 | var propertyIsEnumerableModule$2 = objectPropertyIsEnumerable;
|
459 | var createPropertyDescriptor$4 = createPropertyDescriptor$5;
|
460 | var toIndexedObject$a = toIndexedObject$b;
|
461 | var toPropertyKey$3 = toPropertyKey$4;
|
462 | var hasOwn$b = hasOwnProperty_1;
|
463 | var IE8_DOM_DEFINE$1 = ie8DomDefine;
|
464 |
|
465 | var $getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor;
|
466 |
|
467 |
|
468 | objectGetOwnPropertyDescriptor.f = DESCRIPTORS$g ? $getOwnPropertyDescriptor$2 : function getOwnPropertyDescriptor(O, P) {
|
469 | O = toIndexedObject$a(O);
|
470 | P = toPropertyKey$3(P);
|
471 | if (IE8_DOM_DEFINE$1) try {
|
472 | return $getOwnPropertyDescriptor$2(O, P);
|
473 | } catch (error) {
|
474 |
|
475 | }
|
476 | if (hasOwn$b(O, P)) return createPropertyDescriptor$4(!call$7(propertyIsEnumerableModule$2.f, O, P), O[P]);
|
477 | };
|
478 |
|
479 | var fails$m = fails$s;
|
480 | var isCallable$b = isCallable$h;
|
481 | var replacement = /#|\.prototype\./;
|
482 |
|
483 | var isForced$1 = function (feature, detection) {
|
484 | var value = data[normalize(feature)];
|
485 | return value == POLYFILL ? true : value == NATIVE ? false : isCallable$b(detection) ? fails$m(detection) : !!detection;
|
486 | };
|
487 |
|
488 | var normalize = isForced$1.normalize = function (string) {
|
489 | return String(string).replace(replacement, '.').toLowerCase();
|
490 | };
|
491 |
|
492 | var data = isForced$1.data = {};
|
493 | var NATIVE = isForced$1.NATIVE = 'N';
|
494 | var POLYFILL = isForced$1.POLYFILL = 'P';
|
495 | var isForced_1 = isForced$1;
|
496 |
|
497 | var uncurryThis$o = functionUncurryThis;
|
498 | var aCallable$4 = aCallable$6;
|
499 | var NATIVE_BIND$1 = functionBindNative;
|
500 | var bind$e = uncurryThis$o(uncurryThis$o.bind);
|
501 |
|
502 | var functionBindContext = function (fn, that) {
|
503 | aCallable$4(fn);
|
504 | return that === undefined ? fn : NATIVE_BIND$1 ? bind$e(fn, that) : function
|
505 | /* ...args */
|
506 | () {
|
507 | return fn.apply(that, arguments);
|
508 | };
|
509 | };
|
510 |
|
511 | var objectDefineProperty = {};
|
512 |
|
513 | var DESCRIPTORS$f = descriptors;
|
514 | var fails$l = fails$s;
|
515 |
|
516 |
|
517 | var v8PrototypeDefineBug = DESCRIPTORS$f && fails$l(function () {
|
518 |
|
519 | return Object.defineProperty(function () {
|
520 |
|
521 | }, 'prototype', {
|
522 | value: 42,
|
523 | writable: false
|
524 | }).prototype != 42;
|
525 | });
|
526 |
|
527 | var global$y = global$N;
|
528 | var isObject$c = isObject$g;
|
529 | var String$3 = global$y.String;
|
530 | var TypeError$e = global$y.TypeError;
|
531 |
|
532 | var anObject$b = function (argument) {
|
533 | if (isObject$c(argument)) return argument;
|
534 | throw TypeError$e(String$3(argument) + ' is not an object');
|
535 | };
|
536 |
|
537 | var global$x = global$N;
|
538 | var DESCRIPTORS$e = descriptors;
|
539 | var IE8_DOM_DEFINE = ie8DomDefine;
|
540 | var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
|
541 | var anObject$a = anObject$b;
|
542 | var toPropertyKey$2 = toPropertyKey$4;
|
543 | var TypeError$d = global$x.TypeError;
|
544 |
|
545 | var $defineProperty$1 = Object.defineProperty;
|
546 |
|
547 | var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
548 | var ENUMERABLE = 'enumerable';
|
549 | var CONFIGURABLE$1 = 'configurable';
|
550 | var WRITABLE = 'writable';
|
551 |
|
552 |
|
553 | objectDefineProperty.f = DESCRIPTORS$e ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
|
554 | anObject$a(O);
|
555 | P = toPropertyKey$2(P);
|
556 | anObject$a(Attributes);
|
557 |
|
558 | if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
|
559 | var current = $getOwnPropertyDescriptor$1(O, P);
|
560 |
|
561 | if (current && current[WRITABLE]) {
|
562 | O[P] = Attributes.value;
|
563 | Attributes = {
|
564 | configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
|
565 | enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
|
566 | writable: false
|
567 | };
|
568 | }
|
569 | }
|
570 |
|
571 | return $defineProperty$1(O, P, Attributes);
|
572 | } : $defineProperty$1 : function defineProperty(O, P, Attributes) {
|
573 | anObject$a(O);
|
574 | P = toPropertyKey$2(P);
|
575 | anObject$a(Attributes);
|
576 | if (IE8_DOM_DEFINE) try {
|
577 | return $defineProperty$1(O, P, Attributes);
|
578 | } catch (error) {
|
579 |
|
580 | }
|
581 | if ('get' in Attributes || 'set' in Attributes) throw TypeError$d('Accessors not supported');
|
582 | if ('value' in Attributes) O[P] = Attributes.value;
|
583 | return O;
|
584 | };
|
585 |
|
586 | var DESCRIPTORS$d = descriptors;
|
587 | var definePropertyModule$4 = objectDefineProperty;
|
588 | var createPropertyDescriptor$3 = createPropertyDescriptor$5;
|
589 | var createNonEnumerableProperty$6 = DESCRIPTORS$d ? function (object, key, value) {
|
590 | return definePropertyModule$4.f(object, key, createPropertyDescriptor$3(1, value));
|
591 | } : function (object, key, value) {
|
592 | object[key] = value;
|
593 | return object;
|
594 | };
|
595 |
|
596 | var global$w = global$N;
|
597 | var apply$5 = functionApply;
|
598 | var uncurryThis$n = functionUncurryThis;
|
599 | var isCallable$a = isCallable$h;
|
600 | var getOwnPropertyDescriptor$4 = objectGetOwnPropertyDescriptor.f;
|
601 | var isForced = isForced_1;
|
602 | var path$p = path$r;
|
603 | var bind$d = functionBindContext;
|
604 | var createNonEnumerableProperty$5 = createNonEnumerableProperty$6;
|
605 | var hasOwn$a = hasOwnProperty_1;
|
606 |
|
607 | var wrapConstructor = function (NativeConstructor) {
|
608 | var Wrapper = function (a, b, c) {
|
609 | if (this instanceof Wrapper) {
|
610 | switch (arguments.length) {
|
611 | case 0:
|
612 | return new NativeConstructor();
|
613 |
|
614 | case 1:
|
615 | return new NativeConstructor(a);
|
616 |
|
617 | case 2:
|
618 | return new NativeConstructor(a, b);
|
619 | }
|
620 |
|
621 | return new NativeConstructor(a, b, c);
|
622 | }
|
623 |
|
624 | return apply$5(NativeConstructor, this, arguments);
|
625 | };
|
626 |
|
627 | Wrapper.prototype = NativeConstructor.prototype;
|
628 | return Wrapper;
|
629 | };
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 | var _export = function (options, source) {
|
648 | var TARGET = options.target;
|
649 | var GLOBAL = options.global;
|
650 | var STATIC = options.stat;
|
651 | var PROTO = options.proto;
|
652 | var nativeSource = GLOBAL ? global$w : STATIC ? global$w[TARGET] : (global$w[TARGET] || {}).prototype;
|
653 | var target = GLOBAL ? path$p : path$p[TARGET] || createNonEnumerableProperty$5(path$p, TARGET, {})[TARGET];
|
654 | var targetPrototype = target.prototype;
|
655 | var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
|
656 | var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
|
657 |
|
658 | for (key in source) {
|
659 | FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
660 |
|
661 | USE_NATIVE = !FORCED && nativeSource && hasOwn$a(nativeSource, key);
|
662 | targetProperty = target[key];
|
663 | if (USE_NATIVE) if (options.noTargetGet) {
|
664 | descriptor = getOwnPropertyDescriptor$4(nativeSource, key);
|
665 | nativeProperty = descriptor && descriptor.value;
|
666 | } else nativeProperty = nativeSource[key];
|
667 |
|
668 | sourceProperty = USE_NATIVE && nativeProperty ? nativeProperty : source[key];
|
669 | if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
|
670 |
|
671 | if (options.bind && USE_NATIVE) resultProperty = bind$d(sourceProperty, global$w);
|
672 | else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
|
673 | else if (PROTO && isCallable$a(sourceProperty)) resultProperty = uncurryThis$n(sourceProperty);
|
674 | else resultProperty = sourceProperty;
|
675 |
|
676 | if (options.sham || sourceProperty && sourceProperty.sham || targetProperty && targetProperty.sham) {
|
677 | createNonEnumerableProperty$5(resultProperty, 'sham', true);
|
678 | }
|
679 |
|
680 | createNonEnumerableProperty$5(target, key, resultProperty);
|
681 |
|
682 | if (PROTO) {
|
683 | VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
|
684 |
|
685 | if (!hasOwn$a(path$p, VIRTUAL_PROTOTYPE)) {
|
686 | createNonEnumerableProperty$5(path$p, VIRTUAL_PROTOTYPE, {});
|
687 | }
|
688 |
|
689 |
|
690 | createNonEnumerableProperty$5(path$p[VIRTUAL_PROTOTYPE], key, sourceProperty);
|
691 |
|
692 | if (options.real && targetPrototype && !targetPrototype[key]) {
|
693 | createNonEnumerableProperty$5(targetPrototype, key, sourceProperty);
|
694 | }
|
695 | }
|
696 | }
|
697 | };
|
698 |
|
699 | var uncurryThis$m = functionUncurryThis;
|
700 | var arraySlice$5 = uncurryThis$m([].slice);
|
701 |
|
702 | var global$v = global$N;
|
703 | var uncurryThis$l = functionUncurryThis;
|
704 | var aCallable$3 = aCallable$6;
|
705 | var isObject$b = isObject$g;
|
706 | var hasOwn$9 = hasOwnProperty_1;
|
707 | var arraySlice$4 = arraySlice$5;
|
708 | var NATIVE_BIND = functionBindNative;
|
709 | var Function$2 = global$v.Function;
|
710 | var concat$6 = uncurryThis$l([].concat);
|
711 | var join = uncurryThis$l([].join);
|
712 | var factories = {};
|
713 |
|
714 | var construct$3 = function (C, argsLength, args) {
|
715 | if (!hasOwn$9(factories, argsLength)) {
|
716 | for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
|
717 |
|
718 | factories[argsLength] = Function$2('C,a', 'return new C(' + join(list, ',') + ')');
|
719 | }
|
720 |
|
721 | return factories[argsLength](C, args);
|
722 | };
|
723 |
|
724 |
|
725 |
|
726 | var functionBind = NATIVE_BIND ? Function$2.bind : function bind(that
|
727 | /* , ...args */
|
728 | ) {
|
729 | var F = aCallable$3(this);
|
730 | var Prototype = F.prototype;
|
731 | var partArgs = arraySlice$4(arguments, 1);
|
732 |
|
733 | var boundFunction = function
|
734 | /* args... */
|
735 | bound() {
|
736 | var args = concat$6(partArgs, arraySlice$4(arguments));
|
737 | return this instanceof boundFunction ? construct$3(F, args.length, args) : F.apply(that, args);
|
738 | };
|
739 |
|
740 | if (isObject$b(Prototype)) boundFunction.prototype = Prototype;
|
741 | return boundFunction;
|
742 | };
|
743 |
|
744 | var wellKnownSymbol$h = wellKnownSymbol$j;
|
745 | var TO_STRING_TAG$3 = wellKnownSymbol$h('toStringTag');
|
746 | var test$2 = {};
|
747 | test$2[TO_STRING_TAG$3] = 'z';
|
748 | var toStringTagSupport = String(test$2) === '[object z]';
|
749 |
|
750 | var global$u = global$N;
|
751 | var TO_STRING_TAG_SUPPORT$2 = toStringTagSupport;
|
752 | var isCallable$9 = isCallable$h;
|
753 | var classofRaw = classofRaw$1;
|
754 | var wellKnownSymbol$g = wellKnownSymbol$j;
|
755 | var TO_STRING_TAG$2 = wellKnownSymbol$g('toStringTag');
|
756 | var Object$6 = global$u.Object;
|
757 |
|
758 | var CORRECT_ARGUMENTS = classofRaw(function () {
|
759 | return arguments;
|
760 | }()) == 'Arguments';
|
761 |
|
762 | var tryGet = function (it, key) {
|
763 | try {
|
764 | return it[key];
|
765 | } catch (error) {
|
766 |
|
767 | }
|
768 | };
|
769 |
|
770 |
|
771 | var classof$b = TO_STRING_TAG_SUPPORT$2 ? classofRaw : function (it) {
|
772 | var O, tag, result;
|
773 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
774 | : typeof (tag = tryGet(O = Object$6(it), TO_STRING_TAG$2)) == 'string' ? tag
|
775 | : CORRECT_ARGUMENTS ? classofRaw(O)
|
776 | : (result = classofRaw(O)) == 'Object' && isCallable$9(O.callee) ? 'Arguments' : result;
|
777 | };
|
778 |
|
779 | var uncurryThis$k = functionUncurryThis;
|
780 | var isCallable$8 = isCallable$h;
|
781 | var store$1 = sharedStore;
|
782 | var functionToString = uncurryThis$k(Function.toString);
|
783 |
|
784 | if (!isCallable$8(store$1.inspectSource)) {
|
785 | store$1.inspectSource = function (it) {
|
786 | return functionToString(it);
|
787 | };
|
788 | }
|
789 |
|
790 | var inspectSource$2 = store$1.inspectSource;
|
791 |
|
792 | var uncurryThis$j = functionUncurryThis;
|
793 | var fails$k = fails$s;
|
794 | var isCallable$7 = isCallable$h;
|
795 | var classof$a = classof$b;
|
796 | var getBuiltIn$6 = getBuiltIn$9;
|
797 | var inspectSource$1 = inspectSource$2;
|
798 |
|
799 | var noop = function () {
|
800 |
|
801 | };
|
802 |
|
803 | var empty = [];
|
804 | var construct$2 = getBuiltIn$6('Reflect', 'construct');
|
805 | var constructorRegExp = /^\s*(?:class|function)\b/;
|
806 | var exec$2 = uncurryThis$j(constructorRegExp.exec);
|
807 | var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
|
808 |
|
809 | var isConstructorModern = function isConstructor(argument) {
|
810 | if (!isCallable$7(argument)) return false;
|
811 |
|
812 | try {
|
813 | construct$2(noop, empty, argument);
|
814 | return true;
|
815 | } catch (error) {
|
816 | return false;
|
817 | }
|
818 | };
|
819 |
|
820 | var isConstructorLegacy = function isConstructor(argument) {
|
821 | if (!isCallable$7(argument)) return false;
|
822 |
|
823 | switch (classof$a(argument)) {
|
824 | case 'AsyncFunction':
|
825 | case 'GeneratorFunction':
|
826 | case 'AsyncGeneratorFunction':
|
827 | return false;
|
828 | }
|
829 |
|
830 | try {
|
831 |
|
832 |
|
833 |
|
834 | return INCORRECT_TO_STRING || !!exec$2(constructorRegExp, inspectSource$1(argument));
|
835 | } catch (error) {
|
836 | return true;
|
837 | }
|
838 | };
|
839 |
|
840 | isConstructorLegacy.sham = true;
|
841 |
|
842 |
|
843 | var isConstructor$4 = !construct$2 || fails$k(function () {
|
844 | var called;
|
845 | return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () {
|
846 | called = true;
|
847 | }) || called;
|
848 | }) ? isConstructorLegacy : isConstructorModern;
|
849 |
|
850 | var global$t = global$N;
|
851 | var isConstructor$3 = isConstructor$4;
|
852 | var tryToString$2 = tryToString$4;
|
853 | var TypeError$c = global$t.TypeError;
|
854 |
|
855 | var aConstructor$1 = function (argument) {
|
856 | if (isConstructor$3(argument)) return argument;
|
857 | throw TypeError$c(tryToString$2(argument) + ' is not a constructor');
|
858 | };
|
859 |
|
860 | var objectDefineProperties = {};
|
861 |
|
862 | var ceil = Math.ceil;
|
863 | var floor$1 = Math.floor;
|
864 |
|
865 |
|
866 | var toIntegerOrInfinity$5 = function (argument) {
|
867 | var number = +argument;
|
868 |
|
869 | return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
|
870 | };
|
871 |
|
872 | var toIntegerOrInfinity$4 = toIntegerOrInfinity$5;
|
873 | var max$3 = Math.max;
|
874 | var min$2 = Math.min;
|
875 |
|
876 |
|
877 |
|
878 | var toAbsoluteIndex$5 = function (index, length) {
|
879 | var integer = toIntegerOrInfinity$4(index);
|
880 | return integer < 0 ? max$3(integer + length, 0) : min$2(integer, length);
|
881 | };
|
882 |
|
883 | var toIntegerOrInfinity$3 = toIntegerOrInfinity$5;
|
884 | var min$1 = Math.min;
|
885 |
|
886 |
|
887 | var toLength$1 = function (argument) {
|
888 | return argument > 0 ? min$1(toIntegerOrInfinity$3(argument), 0x1FFFFFFFFFFFFF) : 0;
|
889 | };
|
890 |
|
891 | var toLength = toLength$1;
|
892 |
|
893 |
|
894 | var lengthOfArrayLike$b = function (obj) {
|
895 | return toLength(obj.length);
|
896 | };
|
897 |
|
898 | var toIndexedObject$9 = toIndexedObject$b;
|
899 | var toAbsoluteIndex$4 = toAbsoluteIndex$5;
|
900 | var lengthOfArrayLike$a = lengthOfArrayLike$b;
|
901 |
|
902 | var createMethod$5 = function (IS_INCLUDES) {
|
903 | return function ($this, el, fromIndex) {
|
904 | var O = toIndexedObject$9($this);
|
905 | var length = lengthOfArrayLike$a(O);
|
906 | var index = toAbsoluteIndex$4(fromIndex, length);
|
907 | var value;
|
908 |
|
909 |
|
910 | if (IS_INCLUDES && el != el) while (length > index) {
|
911 | value = O[index++];
|
912 |
|
913 | if (value != value) return true;
|
914 | } else for (; length > index; index++) {
|
915 | if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
|
916 | }
|
917 | return !IS_INCLUDES && -1;
|
918 | };
|
919 | };
|
920 |
|
921 | var arrayIncludes = {
|
922 |
|
923 |
|
924 | includes: createMethod$5(true),
|
925 |
|
926 |
|
927 | indexOf: createMethod$5(false)
|
928 | };
|
929 |
|
930 | var hiddenKeys$6 = {};
|
931 |
|
932 | var uncurryThis$i = functionUncurryThis;
|
933 | var hasOwn$8 = hasOwnProperty_1;
|
934 | var toIndexedObject$8 = toIndexedObject$b;
|
935 | var indexOf$4 = arrayIncludes.indexOf;
|
936 | var hiddenKeys$5 = hiddenKeys$6;
|
937 | var push$5 = uncurryThis$i([].push);
|
938 |
|
939 | var objectKeysInternal = function (object, names) {
|
940 | var O = toIndexedObject$8(object);
|
941 | var i = 0;
|
942 | var result = [];
|
943 | var key;
|
944 |
|
945 | for (key in O) !hasOwn$8(hiddenKeys$5, key) && hasOwn$8(O, key) && push$5(result, key);
|
946 |
|
947 |
|
948 | while (names.length > i) if (hasOwn$8(O, key = names[i++])) {
|
949 | ~indexOf$4(result, key) || push$5(result, key);
|
950 | }
|
951 |
|
952 | return result;
|
953 | };
|
954 |
|
955 | var enumBugKeys$3 = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'];
|
956 |
|
957 | var internalObjectKeys$1 = objectKeysInternal;
|
958 | var enumBugKeys$2 = enumBugKeys$3;
|
959 |
|
960 |
|
961 |
|
962 | var objectKeys$4 = Object.keys || function keys(O) {
|
963 | return internalObjectKeys$1(O, enumBugKeys$2);
|
964 | };
|
965 |
|
966 | var DESCRIPTORS$c = descriptors;
|
967 | var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
|
968 | var definePropertyModule$3 = objectDefineProperty;
|
969 | var anObject$9 = anObject$b;
|
970 | var toIndexedObject$7 = toIndexedObject$b;
|
971 | var objectKeys$3 = objectKeys$4;
|
972 |
|
973 |
|
974 |
|
975 | objectDefineProperties.f = DESCRIPTORS$c && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
|
976 | anObject$9(O);
|
977 | var props = toIndexedObject$7(Properties);
|
978 | var keys = objectKeys$3(Properties);
|
979 | var length = keys.length;
|
980 | var index = 0;
|
981 | var key;
|
982 |
|
983 | while (length > index) definePropertyModule$3.f(O, key = keys[index++], props[key]);
|
984 |
|
985 | return O;
|
986 | };
|
987 |
|
988 | var getBuiltIn$5 = getBuiltIn$9;
|
989 | var html$1 = getBuiltIn$5('document', 'documentElement');
|
990 |
|
991 | var shared$2 = shared$4.exports;
|
992 | var uid$2 = uid$4;
|
993 | var keys$3 = shared$2('keys');
|
994 |
|
995 | var sharedKey$4 = function (key) {
|
996 | return keys$3[key] || (keys$3[key] = uid$2(key));
|
997 | };
|
998 |
|
999 |
|
1000 | var anObject$8 = anObject$b;
|
1001 | var definePropertiesModule$1 = objectDefineProperties;
|
1002 | var enumBugKeys$1 = enumBugKeys$3;
|
1003 | var hiddenKeys$4 = hiddenKeys$6;
|
1004 | var html = html$1;
|
1005 | var documentCreateElement = documentCreateElement$1;
|
1006 | var sharedKey$3 = sharedKey$4;
|
1007 | var GT = '>';
|
1008 | var LT = '<';
|
1009 | var PROTOTYPE$1 = 'prototype';
|
1010 | var SCRIPT = 'script';
|
1011 | var IE_PROTO$1 = sharedKey$3('IE_PROTO');
|
1012 |
|
1013 | var EmptyConstructor = function () {
|
1014 |
|
1015 | };
|
1016 |
|
1017 | var scriptTag = function (content) {
|
1018 | return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
|
1019 | };
|
1020 |
|
1021 |
|
1022 | var NullProtoObjectViaActiveX = function (activeXDocument) {
|
1023 | activeXDocument.write(scriptTag(''));
|
1024 | activeXDocument.close();
|
1025 | var temp = activeXDocument.parentWindow.Object;
|
1026 | activeXDocument = null;
|
1027 |
|
1028 | return temp;
|
1029 | };
|
1030 |
|
1031 |
|
1032 | var NullProtoObjectViaIFrame = function () {
|
1033 |
|
1034 | var iframe = documentCreateElement('iframe');
|
1035 | var JS = 'java' + SCRIPT + ':';
|
1036 | var iframeDocument;
|
1037 | iframe.style.display = 'none';
|
1038 | html.appendChild(iframe);
|
1039 |
|
1040 | iframe.src = String(JS);
|
1041 | iframeDocument = iframe.contentWindow.document;
|
1042 | iframeDocument.open();
|
1043 | iframeDocument.write(scriptTag('document.F=Object'));
|
1044 | iframeDocument.close();
|
1045 | return iframeDocument.F;
|
1046 | };
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 | var activeXDocument;
|
1054 |
|
1055 | var NullProtoObject = function () {
|
1056 | try {
|
1057 | activeXDocument = new ActiveXObject('htmlfile');
|
1058 | } catch (error) {
|
1059 |
|
1060 | }
|
1061 |
|
1062 | NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument)
|
1063 | : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument);
|
1064 |
|
1065 | var length = enumBugKeys$1.length;
|
1066 |
|
1067 | while (length--) delete NullProtoObject[PROTOTYPE$1][enumBugKeys$1[length]];
|
1068 |
|
1069 | return NullProtoObject();
|
1070 | };
|
1071 |
|
1072 | hiddenKeys$4[IE_PROTO$1] = true;
|
1073 |
|
1074 |
|
1075 | var objectCreate = Object.create || function create(O, Properties) {
|
1076 | var result;
|
1077 |
|
1078 | if (O !== null) {
|
1079 | EmptyConstructor[PROTOTYPE$1] = anObject$8(O);
|
1080 | result = new EmptyConstructor();
|
1081 | EmptyConstructor[PROTOTYPE$1] = null;
|
1082 |
|
1083 | result[IE_PROTO$1] = O;
|
1084 | } else result = NullProtoObject();
|
1085 |
|
1086 | return Properties === undefined ? result : definePropertiesModule$1.f(result, Properties);
|
1087 | };
|
1088 |
|
1089 | var $$G = _export;
|
1090 | var getBuiltIn$4 = getBuiltIn$9;
|
1091 | var apply$4 = functionApply;
|
1092 | var bind$c = functionBind;
|
1093 | var aConstructor = aConstructor$1;
|
1094 | var anObject$7 = anObject$b;
|
1095 | var isObject$a = isObject$g;
|
1096 | var create$a = objectCreate;
|
1097 | var fails$j = fails$s;
|
1098 | var nativeConstruct = getBuiltIn$4('Reflect', 'construct');
|
1099 | var ObjectPrototype$2 = Object.prototype;
|
1100 | var push$4 = [].push;
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 | var NEW_TARGET_BUG = fails$j(function () {
|
1106 | function F() {
|
1107 |
|
1108 | }
|
1109 |
|
1110 | return !(nativeConstruct(function () {
|
1111 |
|
1112 | }, [], F) instanceof F);
|
1113 | });
|
1114 | var ARGS_BUG = !fails$j(function () {
|
1115 | nativeConstruct(function () {
|
1116 |
|
1117 | });
|
1118 | });
|
1119 | var FORCED$6 = NEW_TARGET_BUG || ARGS_BUG;
|
1120 | $$G({
|
1121 | target: 'Reflect',
|
1122 | stat: true,
|
1123 | forced: FORCED$6,
|
1124 | sham: FORCED$6
|
1125 | }, {
|
1126 | construct: function construct(Target, args
|
1127 | /* , newTarget */
|
1128 | ) {
|
1129 | aConstructor(Target);
|
1130 | anObject$7(args);
|
1131 | var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
|
1132 | if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
|
1133 |
|
1134 | if (Target == newTarget) {
|
1135 |
|
1136 | switch (args.length) {
|
1137 | case 0:
|
1138 | return new Target();
|
1139 |
|
1140 | case 1:
|
1141 | return new Target(args[0]);
|
1142 |
|
1143 | case 2:
|
1144 | return new Target(args[0], args[1]);
|
1145 |
|
1146 | case 3:
|
1147 | return new Target(args[0], args[1], args[2]);
|
1148 |
|
1149 | case 4:
|
1150 | return new Target(args[0], args[1], args[2], args[3]);
|
1151 | }
|
1152 |
|
1153 |
|
1154 | var $args = [null];
|
1155 | apply$4(push$4, $args, args);
|
1156 | return new (apply$4(bind$c, Target, $args))();
|
1157 | }
|
1158 |
|
1159 |
|
1160 | var proto = newTarget.prototype;
|
1161 | var instance = create$a(isObject$a(proto) ? proto : ObjectPrototype$2);
|
1162 | var result = apply$4(Target, instance, args);
|
1163 | return isObject$a(result) ? result : instance;
|
1164 | }
|
1165 | });
|
1166 |
|
1167 | var path$o = path$r;
|
1168 | var construct$1 = path$o.Reflect.construct;
|
1169 |
|
1170 | var parent$$ = construct$1;
|
1171 | var construct = parent$$;
|
1172 |
|
1173 | (function (module) {
|
1174 | module.exports = construct;
|
1175 | })(construct$4);
|
1176 |
|
1177 | var _Reflect$construct = getDefaultExportFromCjs(construct$4.exports);
|
1178 |
|
1179 | function _classCallCheck(instance, Constructor) {
|
1180 | if (!(instance instanceof Constructor)) {
|
1181 | throw new TypeError("Cannot call a class as a function");
|
1182 | }
|
1183 | }
|
1184 |
|
1185 | var defineProperty$d = {exports: {}};
|
1186 |
|
1187 | var defineProperty$c = {exports: {}};
|
1188 |
|
1189 | var $$F = _export;
|
1190 | var DESCRIPTORS$b = descriptors;
|
1191 | var defineProperty$b = objectDefineProperty.f;
|
1192 |
|
1193 |
|
1194 |
|
1195 | $$F({
|
1196 | target: 'Object',
|
1197 | stat: true,
|
1198 | forced: Object.defineProperty !== defineProperty$b,
|
1199 | sham: !DESCRIPTORS$b
|
1200 | }, {
|
1201 | defineProperty: defineProperty$b
|
1202 | });
|
1203 |
|
1204 | var path$n = path$r;
|
1205 | var Object$5 = path$n.Object;
|
1206 |
|
1207 | var defineProperty$a = defineProperty$c.exports = function defineProperty(it, key, desc) {
|
1208 | return Object$5.defineProperty(it, key, desc);
|
1209 | };
|
1210 |
|
1211 | if (Object$5.defineProperty.sham) defineProperty$a.sham = true;
|
1212 |
|
1213 | var parent$_ = defineProperty$c.exports;
|
1214 | var defineProperty$9 = parent$_;
|
1215 |
|
1216 | var parent$Z = defineProperty$9;
|
1217 | var defineProperty$8 = parent$Z;
|
1218 |
|
1219 | var parent$Y = defineProperty$8;
|
1220 | var defineProperty$7 = parent$Y;
|
1221 |
|
1222 | (function (module) {
|
1223 | module.exports = defineProperty$7;
|
1224 | })(defineProperty$d);
|
1225 |
|
1226 | var _Object$defineProperty$1 = getDefaultExportFromCjs(defineProperty$d.exports);
|
1227 |
|
1228 | function _defineProperties(target, props) {
|
1229 | for (var i = 0; i < props.length; i++) {
|
1230 | var descriptor = props[i];
|
1231 | descriptor.enumerable = descriptor.enumerable || false;
|
1232 | descriptor.configurable = true;
|
1233 | if ("value" in descriptor) descriptor.writable = true;
|
1234 |
|
1235 | _Object$defineProperty$1(target, descriptor.key, descriptor);
|
1236 | }
|
1237 | }
|
1238 |
|
1239 | function _createClass(Constructor, protoProps, staticProps) {
|
1240 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
1241 | if (staticProps) _defineProperties(Constructor, staticProps);
|
1242 |
|
1243 | _Object$defineProperty$1(Constructor, "prototype", {
|
1244 | writable: false
|
1245 | });
|
1246 |
|
1247 | return Constructor;
|
1248 | }
|
1249 |
|
1250 | function _assertThisInitialized$1(self) {
|
1251 | if (self === void 0) {
|
1252 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
1253 | }
|
1254 |
|
1255 | return self;
|
1256 | }
|
1257 |
|
1258 | var create$9 = {exports: {}};
|
1259 |
|
1260 | var $$E = _export;
|
1261 | var DESCRIPTORS$a = descriptors;
|
1262 | var create$8 = objectCreate;
|
1263 |
|
1264 |
|
1265 | $$E({
|
1266 | target: 'Object',
|
1267 | stat: true,
|
1268 | sham: !DESCRIPTORS$a
|
1269 | }, {
|
1270 | create: create$8
|
1271 | });
|
1272 |
|
1273 | var path$m = path$r;
|
1274 | var Object$4 = path$m.Object;
|
1275 |
|
1276 | var create$7 = function create(P, D) {
|
1277 | return Object$4.create(P, D);
|
1278 | };
|
1279 |
|
1280 | var parent$X = create$7;
|
1281 | var create$6 = parent$X;
|
1282 |
|
1283 | var parent$W = create$6;
|
1284 | var create$5 = parent$W;
|
1285 |
|
1286 | var parent$V = create$5;
|
1287 | var create$4 = parent$V;
|
1288 |
|
1289 | (function (module) {
|
1290 | module.exports = create$4;
|
1291 | })(create$9);
|
1292 |
|
1293 | var _Object$create$1 = getDefaultExportFromCjs(create$9.exports);
|
1294 |
|
1295 | var setPrototypeOf$5 = {exports: {}};
|
1296 |
|
1297 | var global$s = global$N;
|
1298 | var isCallable$6 = isCallable$h;
|
1299 | var String$2 = global$s.String;
|
1300 | var TypeError$b = global$s.TypeError;
|
1301 |
|
1302 | var aPossiblePrototype$1 = function (argument) {
|
1303 | if (typeof argument == 'object' || isCallable$6(argument)) return argument;
|
1304 | throw TypeError$b("Can't set " + String$2(argument) + ' as a prototype');
|
1305 | };
|
1306 |
|
1307 |
|
1308 | var uncurryThis$h = functionUncurryThis;
|
1309 | var anObject$6 = anObject$b;
|
1310 | var aPossiblePrototype = aPossiblePrototype$1;
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 | var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
|
1316 | var CORRECT_SETTER = false;
|
1317 | var test = {};
|
1318 | var setter;
|
1319 |
|
1320 | try {
|
1321 |
|
1322 | setter = uncurryThis$h(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
|
1323 | setter(test, []);
|
1324 | CORRECT_SETTER = test instanceof Array;
|
1325 | } catch (error) {
|
1326 |
|
1327 | }
|
1328 |
|
1329 | return function setPrototypeOf(O, proto) {
|
1330 | anObject$6(O);
|
1331 | aPossiblePrototype(proto);
|
1332 | if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto;
|
1333 | return O;
|
1334 | };
|
1335 | }() : undefined);
|
1336 |
|
1337 | var $$D = _export;
|
1338 | var setPrototypeOf$4 = objectSetPrototypeOf;
|
1339 |
|
1340 |
|
1341 | $$D({
|
1342 | target: 'Object',
|
1343 | stat: true
|
1344 | }, {
|
1345 | setPrototypeOf: setPrototypeOf$4
|
1346 | });
|
1347 |
|
1348 | var path$l = path$r;
|
1349 | var setPrototypeOf$3 = path$l.Object.setPrototypeOf;
|
1350 |
|
1351 | var parent$U = setPrototypeOf$3;
|
1352 | var setPrototypeOf$2 = parent$U;
|
1353 |
|
1354 | var parent$T = setPrototypeOf$2;
|
1355 | var setPrototypeOf$1 = parent$T;
|
1356 |
|
1357 | var parent$S = setPrototypeOf$1;
|
1358 | var setPrototypeOf = parent$S;
|
1359 |
|
1360 | (function (module) {
|
1361 | module.exports = setPrototypeOf;
|
1362 | })(setPrototypeOf$5);
|
1363 |
|
1364 | var _Object$setPrototypeOf = getDefaultExportFromCjs(setPrototypeOf$5.exports);
|
1365 |
|
1366 | var bind$b = {exports: {}};
|
1367 |
|
1368 | var $$C = _export;
|
1369 | var bind$a = functionBind;
|
1370 |
|
1371 |
|
1372 | $$C({
|
1373 | target: 'Function',
|
1374 | proto: true,
|
1375 | forced: Function.bind !== bind$a
|
1376 | }, {
|
1377 | bind: bind$a
|
1378 | });
|
1379 |
|
1380 | var path$k = path$r;
|
1381 |
|
1382 | var entryVirtual$k = function (CONSTRUCTOR) {
|
1383 | return path$k[CONSTRUCTOR + 'Prototype'];
|
1384 | };
|
1385 |
|
1386 | var entryVirtual$j = entryVirtual$k;
|
1387 | var bind$9 = entryVirtual$j('Function').bind;
|
1388 |
|
1389 | var isPrototypeOf$l = objectIsPrototypeOf;
|
1390 | var method$h = bind$9;
|
1391 | var FunctionPrototype$1 = Function.prototype;
|
1392 |
|
1393 | var bind$8 = function (it) {
|
1394 | var own = it.bind;
|
1395 | return it === FunctionPrototype$1 || isPrototypeOf$l(FunctionPrototype$1, it) && own === FunctionPrototype$1.bind ? method$h : own;
|
1396 | };
|
1397 |
|
1398 | var parent$R = bind$8;
|
1399 | var bind$7 = parent$R;
|
1400 |
|
1401 | var parent$Q = bind$7;
|
1402 | var bind$6 = parent$Q;
|
1403 |
|
1404 | var parent$P = bind$6;
|
1405 | var bind$5 = parent$P;
|
1406 |
|
1407 | (function (module) {
|
1408 | module.exports = bind$5;
|
1409 | })(bind$b);
|
1410 |
|
1411 | var _bindInstanceProperty$1 = getDefaultExportFromCjs(bind$b.exports);
|
1412 |
|
1413 | function _setPrototypeOf(o, p) {
|
1414 | var _context;
|
1415 |
|
1416 | _setPrototypeOf = _Object$setPrototypeOf ? _bindInstanceProperty$1(_context = _Object$setPrototypeOf).call(_context) : function _setPrototypeOf(o, p) {
|
1417 | o.__proto__ = p;
|
1418 | return o;
|
1419 | };
|
1420 | return _setPrototypeOf(o, p);
|
1421 | }
|
1422 |
|
1423 | function _inherits(subClass, superClass) {
|
1424 | if (typeof superClass !== "function" && superClass !== null) {
|
1425 | throw new TypeError("Super expression must either be null or a function");
|
1426 | }
|
1427 |
|
1428 | subClass.prototype = _Object$create$1(superClass && superClass.prototype, {
|
1429 | constructor: {
|
1430 | value: subClass,
|
1431 | writable: true,
|
1432 | configurable: true
|
1433 | }
|
1434 | });
|
1435 |
|
1436 | _Object$defineProperty$1(subClass, "prototype", {
|
1437 | writable: false
|
1438 | });
|
1439 |
|
1440 | if (superClass) _setPrototypeOf(subClass, superClass);
|
1441 | }
|
1442 |
|
1443 | var symbol$5 = {exports: {}};
|
1444 |
|
1445 | var classof$9 = classofRaw$1;
|
1446 |
|
1447 |
|
1448 |
|
1449 | var isArray$c = Array.isArray || function isArray(argument) {
|
1450 | return classof$9(argument) == 'Array';
|
1451 | };
|
1452 |
|
1453 | var toPropertyKey$1 = toPropertyKey$4;
|
1454 | var definePropertyModule$2 = objectDefineProperty;
|
1455 | var createPropertyDescriptor$2 = createPropertyDescriptor$5;
|
1456 |
|
1457 | var createProperty$6 = function (object, key, value) {
|
1458 | var propertyKey = toPropertyKey$1(key);
|
1459 | if (propertyKey in object) definePropertyModule$2.f(object, propertyKey, createPropertyDescriptor$2(0, value));else object[propertyKey] = value;
|
1460 | };
|
1461 |
|
1462 | var global$r = global$N;
|
1463 | var isArray$b = isArray$c;
|
1464 | var isConstructor$2 = isConstructor$4;
|
1465 | var isObject$9 = isObject$g;
|
1466 | var wellKnownSymbol$f = wellKnownSymbol$j;
|
1467 | var SPECIES$3 = wellKnownSymbol$f('species');
|
1468 | var Array$5 = global$r.Array;
|
1469 |
|
1470 |
|
1471 | var arraySpeciesConstructor$1 = function (originalArray) {
|
1472 | var C;
|
1473 |
|
1474 | if (isArray$b(originalArray)) {
|
1475 | C = originalArray.constructor;
|
1476 |
|
1477 | if (isConstructor$2(C) && (C === Array$5 || isArray$b(C.prototype))) C = undefined;else if (isObject$9(C)) {
|
1478 | C = C[SPECIES$3];
|
1479 | if (C === null) C = undefined;
|
1480 | }
|
1481 | }
|
1482 |
|
1483 | return C === undefined ? Array$5 : C;
|
1484 | };
|
1485 |
|
1486 | var arraySpeciesConstructor = arraySpeciesConstructor$1;
|
1487 |
|
1488 |
|
1489 | var arraySpeciesCreate$3 = function (originalArray, length) {
|
1490 | return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
|
1491 | };
|
1492 |
|
1493 | var fails$i = fails$s;
|
1494 | var wellKnownSymbol$e = wellKnownSymbol$j;
|
1495 | var V8_VERSION$1 = engineV8Version;
|
1496 | var SPECIES$2 = wellKnownSymbol$e('species');
|
1497 |
|
1498 | var arrayMethodHasSpeciesSupport$5 = function (METHOD_NAME) {
|
1499 |
|
1500 |
|
1501 |
|
1502 | return V8_VERSION$1 >= 51 || !fails$i(function () {
|
1503 | var array = [];
|
1504 | var constructor = array.constructor = {};
|
1505 |
|
1506 | constructor[SPECIES$2] = function () {
|
1507 | return {
|
1508 | foo: 1
|
1509 | };
|
1510 | };
|
1511 |
|
1512 | return array[METHOD_NAME](Boolean).foo !== 1;
|
1513 | });
|
1514 | };
|
1515 |
|
1516 | var $$B = _export;
|
1517 | var global$q = global$N;
|
1518 | var fails$h = fails$s;
|
1519 | var isArray$a = isArray$c;
|
1520 | var isObject$8 = isObject$g;
|
1521 | var toObject$b = toObject$d;
|
1522 | var lengthOfArrayLike$9 = lengthOfArrayLike$b;
|
1523 | var createProperty$5 = createProperty$6;
|
1524 | var arraySpeciesCreate$2 = arraySpeciesCreate$3;
|
1525 | var arrayMethodHasSpeciesSupport$4 = arrayMethodHasSpeciesSupport$5;
|
1526 | var wellKnownSymbol$d = wellKnownSymbol$j;
|
1527 | var V8_VERSION = engineV8Version;
|
1528 | var IS_CONCAT_SPREADABLE = wellKnownSymbol$d('isConcatSpreadable');
|
1529 | var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF;
|
1530 | var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
|
1531 | var TypeError$a = global$q.TypeError;
|
1532 |
|
1533 |
|
1534 |
|
1535 | var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails$h(function () {
|
1536 | var array = [];
|
1537 | array[IS_CONCAT_SPREADABLE] = false;
|
1538 | return array.concat()[0] !== array;
|
1539 | });
|
1540 | var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$4('concat');
|
1541 |
|
1542 | var isConcatSpreadable = function (O) {
|
1543 | if (!isObject$8(O)) return false;
|
1544 | var spreadable = O[IS_CONCAT_SPREADABLE];
|
1545 | return spreadable !== undefined ? !!spreadable : isArray$a(O);
|
1546 | };
|
1547 |
|
1548 | var FORCED$5 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
|
1549 |
|
1550 |
|
1551 |
|
1552 | $$B({
|
1553 | target: 'Array',
|
1554 | proto: true,
|
1555 | forced: FORCED$5
|
1556 | }, {
|
1557 |
|
1558 | concat: function concat(arg) {
|
1559 | var O = toObject$b(this);
|
1560 | var A = arraySpeciesCreate$2(O, 0);
|
1561 | var n = 0;
|
1562 | var i, k, length, len, E;
|
1563 |
|
1564 | for (i = -1, length = arguments.length; i < length; i++) {
|
1565 | E = i === -1 ? O : arguments[i];
|
1566 |
|
1567 | if (isConcatSpreadable(E)) {
|
1568 | len = lengthOfArrayLike$9(E);
|
1569 | if (n + len > MAX_SAFE_INTEGER$1) throw TypeError$a(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
|
1570 |
|
1571 | for (k = 0; k < len; k++, n++) if (k in E) createProperty$5(A, n, E[k]);
|
1572 | } else {
|
1573 | if (n >= MAX_SAFE_INTEGER$1) throw TypeError$a(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
|
1574 | createProperty$5(A, n++, E);
|
1575 | }
|
1576 | }
|
1577 |
|
1578 | A.length = n;
|
1579 | return A;
|
1580 | }
|
1581 | });
|
1582 |
|
1583 | var global$p = global$N;
|
1584 | var classof$8 = classof$b;
|
1585 | var String$1 = global$p.String;
|
1586 |
|
1587 | var toString$9 = function (argument) {
|
1588 | if (classof$8(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
|
1589 | return String$1(argument);
|
1590 | };
|
1591 |
|
1592 | var objectGetOwnPropertyNames = {};
|
1593 |
|
1594 | var internalObjectKeys = objectKeysInternal;
|
1595 | var enumBugKeys = enumBugKeys$3;
|
1596 | var hiddenKeys$3 = enumBugKeys.concat('length', 'prototype');
|
1597 |
|
1598 |
|
1599 |
|
1600 | objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
1601 | return internalObjectKeys(O, hiddenKeys$3);
|
1602 | };
|
1603 |
|
1604 | var objectGetOwnPropertyNamesExternal = {};
|
1605 |
|
1606 | var global$o = global$N;
|
1607 | var toAbsoluteIndex$3 = toAbsoluteIndex$5;
|
1608 | var lengthOfArrayLike$8 = lengthOfArrayLike$b;
|
1609 | var createProperty$4 = createProperty$6;
|
1610 | var Array$4 = global$o.Array;
|
1611 | var max$2 = Math.max;
|
1612 |
|
1613 | var arraySliceSimple = function (O, start, end) {
|
1614 | var length = lengthOfArrayLike$8(O);
|
1615 | var k = toAbsoluteIndex$3(start, length);
|
1616 | var fin = toAbsoluteIndex$3(end === undefined ? length : end, length);
|
1617 | var result = Array$4(max$2(fin - k, 0));
|
1618 |
|
1619 | for (var n = 0; k < fin; k++, n++) createProperty$4(result, n, O[k]);
|
1620 |
|
1621 | result.length = n;
|
1622 | return result;
|
1623 | };
|
1624 |
|
1625 |
|
1626 | var classof$7 = classofRaw$1;
|
1627 | var toIndexedObject$6 = toIndexedObject$b;
|
1628 | var $getOwnPropertyNames$1 = objectGetOwnPropertyNames.f;
|
1629 | var arraySlice$3 = arraySliceSimple;
|
1630 | var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
|
1631 |
|
1632 | var getWindowNames = function (it) {
|
1633 | try {
|
1634 | return $getOwnPropertyNames$1(it);
|
1635 | } catch (error) {
|
1636 | return arraySlice$3(windowNames);
|
1637 | }
|
1638 | };
|
1639 |
|
1640 |
|
1641 | objectGetOwnPropertyNamesExternal.f = function getOwnPropertyNames(it) {
|
1642 | return windowNames && classof$7(it) == 'Window' ? getWindowNames(it) : $getOwnPropertyNames$1(toIndexedObject$6(it));
|
1643 | };
|
1644 |
|
1645 | var objectGetOwnPropertySymbols = {};
|
1646 |
|
1647 | objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
|
1648 |
|
1649 | var createNonEnumerableProperty$4 = createNonEnumerableProperty$6;
|
1650 |
|
1651 | var redefine$4 = function (target, key, value, options) {
|
1652 | if (options && options.enumerable) target[key] = value;else createNonEnumerableProperty$4(target, key, value);
|
1653 | };
|
1654 |
|
1655 | var wellKnownSymbolWrapped = {};
|
1656 |
|
1657 | var wellKnownSymbol$c = wellKnownSymbol$j;
|
1658 | wellKnownSymbolWrapped.f = wellKnownSymbol$c;
|
1659 |
|
1660 | var path$j = path$r;
|
1661 | var hasOwn$7 = hasOwnProperty_1;
|
1662 | var wrappedWellKnownSymbolModule$1 = wellKnownSymbolWrapped;
|
1663 | var defineProperty$6 = objectDefineProperty.f;
|
1664 |
|
1665 | var defineWellKnownSymbol$l = function (NAME) {
|
1666 | var Symbol = path$j.Symbol || (path$j.Symbol = {});
|
1667 | if (!hasOwn$7(Symbol, NAME)) defineProperty$6(Symbol, NAME, {
|
1668 | value: wrappedWellKnownSymbolModule$1.f(NAME)
|
1669 | });
|
1670 | };
|
1671 |
|
1672 | var TO_STRING_TAG_SUPPORT$1 = toStringTagSupport;
|
1673 | var classof$6 = classof$b;
|
1674 |
|
1675 |
|
1676 | var objectToString = TO_STRING_TAG_SUPPORT$1 ? {}.toString : function toString() {
|
1677 | return '[object ' + classof$6(this) + ']';
|
1678 | };
|
1679 |
|
1680 | var TO_STRING_TAG_SUPPORT = toStringTagSupport;
|
1681 | var defineProperty$5 = objectDefineProperty.f;
|
1682 | var createNonEnumerableProperty$3 = createNonEnumerableProperty$6;
|
1683 | var hasOwn$6 = hasOwnProperty_1;
|
1684 | var toString$8 = objectToString;
|
1685 | var wellKnownSymbol$b = wellKnownSymbol$j;
|
1686 | var TO_STRING_TAG$1 = wellKnownSymbol$b('toStringTag');
|
1687 |
|
1688 | var setToStringTag$5 = function (it, TAG, STATIC, SET_METHOD) {
|
1689 | if (it) {
|
1690 | var target = STATIC ? it : it.prototype;
|
1691 |
|
1692 | if (!hasOwn$6(target, TO_STRING_TAG$1)) {
|
1693 | defineProperty$5(target, TO_STRING_TAG$1, {
|
1694 | configurable: true,
|
1695 | value: TAG
|
1696 | });
|
1697 | }
|
1698 |
|
1699 | if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
|
1700 | createNonEnumerableProperty$3(target, 'toString', toString$8);
|
1701 | }
|
1702 | }
|
1703 | };
|
1704 |
|
1705 | var global$n = global$N;
|
1706 | var isCallable$5 = isCallable$h;
|
1707 | var inspectSource = inspectSource$2;
|
1708 | var WeakMap$1 = global$n.WeakMap;
|
1709 | var nativeWeakMap = isCallable$5(WeakMap$1) && /native code/.test(inspectSource(WeakMap$1));
|
1710 |
|
1711 | var NATIVE_WEAK_MAP = nativeWeakMap;
|
1712 | var global$m = global$N;
|
1713 | var uncurryThis$g = functionUncurryThis;
|
1714 | var isObject$7 = isObject$g;
|
1715 | var createNonEnumerableProperty$2 = createNonEnumerableProperty$6;
|
1716 | var hasOwn$5 = hasOwnProperty_1;
|
1717 | var shared$1 = sharedStore;
|
1718 | var sharedKey$2 = sharedKey$4;
|
1719 | var hiddenKeys$2 = hiddenKeys$6;
|
1720 | var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
|
1721 | var TypeError$9 = global$m.TypeError;
|
1722 | var WeakMap = global$m.WeakMap;
|
1723 | var set$3, get, has;
|
1724 |
|
1725 | var enforce = function (it) {
|
1726 | return has(it) ? get(it) : set$3(it, {});
|
1727 | };
|
1728 |
|
1729 | var getterFor = function (TYPE) {
|
1730 | return function (it) {
|
1731 | var state;
|
1732 |
|
1733 | if (!isObject$7(it) || (state = get(it)).type !== TYPE) {
|
1734 | throw TypeError$9('Incompatible receiver, ' + TYPE + ' required');
|
1735 | }
|
1736 |
|
1737 | return state;
|
1738 | };
|
1739 | };
|
1740 |
|
1741 | if (NATIVE_WEAK_MAP || shared$1.state) {
|
1742 | var store = shared$1.state || (shared$1.state = new WeakMap());
|
1743 | var wmget = uncurryThis$g(store.get);
|
1744 | var wmhas = uncurryThis$g(store.has);
|
1745 | var wmset = uncurryThis$g(store.set);
|
1746 |
|
1747 | set$3 = function (it, metadata) {
|
1748 | if (wmhas(store, it)) throw new TypeError$9(OBJECT_ALREADY_INITIALIZED);
|
1749 | metadata.facade = it;
|
1750 | wmset(store, it, metadata);
|
1751 | return metadata;
|
1752 | };
|
1753 |
|
1754 | get = function (it) {
|
1755 | return wmget(store, it) || {};
|
1756 | };
|
1757 |
|
1758 | has = function (it) {
|
1759 | return wmhas(store, it);
|
1760 | };
|
1761 | } else {
|
1762 | var STATE = sharedKey$2('state');
|
1763 | hiddenKeys$2[STATE] = true;
|
1764 |
|
1765 | set$3 = function (it, metadata) {
|
1766 | if (hasOwn$5(it, STATE)) throw new TypeError$9(OBJECT_ALREADY_INITIALIZED);
|
1767 | metadata.facade = it;
|
1768 | createNonEnumerableProperty$2(it, STATE, metadata);
|
1769 | return metadata;
|
1770 | };
|
1771 |
|
1772 | get = function (it) {
|
1773 | return hasOwn$5(it, STATE) ? it[STATE] : {};
|
1774 | };
|
1775 |
|
1776 | has = function (it) {
|
1777 | return hasOwn$5(it, STATE);
|
1778 | };
|
1779 | }
|
1780 |
|
1781 | var internalState = {
|
1782 | set: set$3,
|
1783 | get: get,
|
1784 | has: has,
|
1785 | enforce: enforce,
|
1786 | getterFor: getterFor
|
1787 | };
|
1788 |
|
1789 | var bind$4 = functionBindContext;
|
1790 | var uncurryThis$f = functionUncurryThis;
|
1791 | var IndexedObject$2 = indexedObject;
|
1792 | var toObject$a = toObject$d;
|
1793 | var lengthOfArrayLike$7 = lengthOfArrayLike$b;
|
1794 | var arraySpeciesCreate$1 = arraySpeciesCreate$3;
|
1795 | var push$3 = uncurryThis$f([].push); // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
|
1796 |
|
1797 | var createMethod$4 = function (TYPE) {
|
1798 | var IS_MAP = TYPE == 1;
|
1799 | var IS_FILTER = TYPE == 2;
|
1800 | var IS_SOME = TYPE == 3;
|
1801 | var IS_EVERY = TYPE == 4;
|
1802 | var IS_FIND_INDEX = TYPE == 6;
|
1803 | var IS_FILTER_REJECT = TYPE == 7;
|
1804 | var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
1805 | return function ($this, callbackfn, that, specificCreate) {
|
1806 | var O = toObject$a($this);
|
1807 | var self = IndexedObject$2(O);
|
1808 | var boundFunction = bind$4(callbackfn, that);
|
1809 | var length = lengthOfArrayLike$7(self);
|
1810 | var index = 0;
|
1811 | var create = specificCreate || arraySpeciesCreate$1;
|
1812 | var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
|
1813 | var value, result;
|
1814 |
|
1815 | for (; length > index; index++) if (NO_HOLES || index in self) {
|
1816 | value = self[index];
|
1817 | result = boundFunction(value, index, O);
|
1818 |
|
1819 | if (TYPE) {
|
1820 | if (IS_MAP) target[index] = result; // map
|
1821 | else if (result) switch (TYPE) {
|
1822 | case 3:
|
1823 | return true;
|
1824 | // some
|
1825 |
|
1826 | case 5:
|
1827 | return value;
|
1828 | // find
|
1829 |
|
1830 | case 6:
|
1831 | return index;
|
1832 | // findIndex
|
1833 |
|
1834 | case 2:
|
1835 | push$3(target, value);
|
1836 | // filter
|
1837 | } else switch (TYPE) {
|
1838 | case 4:
|
1839 | return false;
|
1840 | // every
|
1841 |
|
1842 | case 7:
|
1843 | push$3(target, value);
|
1844 | // filterReject
|
1845 | }
|
1846 | }
|
1847 | }
|
1848 |
|
1849 | return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
|
1850 | };
|
1851 | };
|
1852 |
|
1853 | var arrayIteration = {
|
1854 | // `Array.prototype.forEach` method
|
1855 | // https://tc39.es/ecma262/#sec-array.prototype.foreach
|
1856 | forEach: createMethod$4(0),
|
1857 | // `Array.prototype.map` method
|
1858 | // https://tc39.es/ecma262/#sec-array.prototype.map
|
1859 | map: createMethod$4(1),
|
1860 | // `Array.prototype.filter` method
|
1861 | // https://tc39.es/ecma262/#sec-array.prototype.filter
|
1862 | filter: createMethod$4(2),
|
1863 | // `Array.prototype.some` method
|
1864 | // https://tc39.es/ecma262/#sec-array.prototype.some
|
1865 | some: createMethod$4(3),
|
1866 | // `Array.prototype.every` method
|
1867 | // https://tc39.es/ecma262/#sec-array.prototype.every
|
1868 | every: createMethod$4(4),
|
1869 | // `Array.prototype.find` method
|
1870 | // https://tc39.es/ecma262/#sec-array.prototype.find
|
1871 | find: createMethod$4(5),
|
1872 | // `Array.prototype.findIndex` method
|
1873 | // https://tc39.es/ecma262/#sec-array.prototype.findIndex
|
1874 | findIndex: createMethod$4(6),
|
1875 | // `Array.prototype.filterReject` method
|
1876 | // https://github.com/tc39/proposal-array-filtering
|
1877 | filterReject: createMethod$4(7)
|
1878 | };
|
1879 |
|
1880 | var $$A = _export;
|
1881 | var global$l = global$N;
|
1882 | var getBuiltIn$3 = getBuiltIn$9;
|
1883 | var apply$3 = functionApply;
|
1884 | var call$6 = functionCall;
|
1885 | var uncurryThis$e = functionUncurryThis;
|
1886 | var DESCRIPTORS$9 = descriptors;
|
1887 | var NATIVE_SYMBOL = nativeSymbol;
|
1888 | var fails$g = fails$s;
|
1889 | var hasOwn$4 = hasOwnProperty_1;
|
1890 | var isArray$9 = isArray$c;
|
1891 | var isCallable$4 = isCallable$h;
|
1892 | var isObject$6 = isObject$g;
|
1893 | var isPrototypeOf$k = objectIsPrototypeOf;
|
1894 | var isSymbol = isSymbol$3;
|
1895 | var anObject$5 = anObject$b;
|
1896 | var toObject$9 = toObject$d;
|
1897 | var toIndexedObject$5 = toIndexedObject$b;
|
1898 | var toPropertyKey = toPropertyKey$4;
|
1899 | var $toString = toString$9;
|
1900 | var createPropertyDescriptor$1 = createPropertyDescriptor$5;
|
1901 | var nativeObjectCreate = objectCreate;
|
1902 | var objectKeys$2 = objectKeys$4;
|
1903 | var getOwnPropertyNamesModule$2 = objectGetOwnPropertyNames;
|
1904 | var getOwnPropertyNamesExternal = objectGetOwnPropertyNamesExternal;
|
1905 | var getOwnPropertySymbolsModule$2 = objectGetOwnPropertySymbols;
|
1906 | var getOwnPropertyDescriptorModule$1 = objectGetOwnPropertyDescriptor;
|
1907 | var definePropertyModule$1 = objectDefineProperty;
|
1908 | var definePropertiesModule = objectDefineProperties;
|
1909 | var propertyIsEnumerableModule$1 = objectPropertyIsEnumerable;
|
1910 | var arraySlice$2 = arraySlice$5;
|
1911 | var redefine$3 = redefine$4;
|
1912 | var shared = shared$4.exports;
|
1913 | var sharedKey$1 = sharedKey$4;
|
1914 | var hiddenKeys$1 = hiddenKeys$6;
|
1915 | var uid$1 = uid$4;
|
1916 | var wellKnownSymbol$a = wellKnownSymbol$j;
|
1917 | var wrappedWellKnownSymbolModule = wellKnownSymbolWrapped;
|
1918 | var defineWellKnownSymbol$k = defineWellKnownSymbol$l;
|
1919 | var setToStringTag$4 = setToStringTag$5;
|
1920 | var InternalStateModule$4 = internalState;
|
1921 | var $forEach$1 = arrayIteration.forEach;
|
1922 | var HIDDEN = sharedKey$1('hidden');
|
1923 | var SYMBOL = 'Symbol';
|
1924 | var PROTOTYPE = 'prototype';
|
1925 | var TO_PRIMITIVE = wellKnownSymbol$a('toPrimitive');
|
1926 | var setInternalState$4 = InternalStateModule$4.set;
|
1927 | var getInternalState$2 = InternalStateModule$4.getterFor(SYMBOL);
|
1928 | var ObjectPrototype$1 = Object[PROTOTYPE];
|
1929 | var $Symbol = global$l.Symbol;
|
1930 | var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
|
1931 | var TypeError$8 = global$l.TypeError;
|
1932 | var QObject = global$l.QObject;
|
1933 | var $stringify$1 = getBuiltIn$3('JSON', 'stringify');
|
1934 | var nativeGetOwnPropertyDescriptor$1 = getOwnPropertyDescriptorModule$1.f;
|
1935 | var nativeDefineProperty = definePropertyModule$1.f;
|
1936 | var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
|
1937 | var nativePropertyIsEnumerable = propertyIsEnumerableModule$1.f;
|
1938 | var push$2 = uncurryThis$e([].push);
|
1939 | var AllSymbols = shared('symbols');
|
1940 | var ObjectPrototypeSymbols = shared('op-symbols');
|
1941 | var StringToSymbolRegistry = shared('string-to-symbol-registry');
|
1942 | var SymbolToStringRegistry = shared('symbol-to-string-registry');
|
1943 | var WellKnownSymbolsStore = shared('wks'); // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
|
1944 |
|
1945 | var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
|
1946 |
|
1947 | var setSymbolDescriptor = DESCRIPTORS$9 && fails$g(function () {
|
1948 | return nativeObjectCreate(nativeDefineProperty({}, 'a', {
|
1949 | get: function () {
|
1950 | return nativeDefineProperty(this, 'a', {
|
1951 | value: 7
|
1952 | }).a;
|
1953 | }
|
1954 | })).a != 7;
|
1955 | }) ? function (O, P, Attributes) {
|
1956 | var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$1(ObjectPrototype$1, P);
|
1957 | if (ObjectPrototypeDescriptor) delete ObjectPrototype$1[P];
|
1958 | nativeDefineProperty(O, P, Attributes);
|
1959 |
|
1960 | if (ObjectPrototypeDescriptor && O !== ObjectPrototype$1) {
|
1961 | nativeDefineProperty(ObjectPrototype$1, P, ObjectPrototypeDescriptor);
|
1962 | }
|
1963 | } : nativeDefineProperty;
|
1964 |
|
1965 | var wrap$1 = function (tag, description) {
|
1966 | var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
|
1967 | setInternalState$4(symbol, {
|
1968 | type: SYMBOL,
|
1969 | tag: tag,
|
1970 | description: description
|
1971 | });
|
1972 | if (!DESCRIPTORS$9) symbol.description = description;
|
1973 | return symbol;
|
1974 | };
|
1975 |
|
1976 | var $defineProperty = function defineProperty(O, P, Attributes) {
|
1977 | if (O === ObjectPrototype$1) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
|
1978 | anObject$5(O);
|
1979 | var key = toPropertyKey(P);
|
1980 | anObject$5(Attributes);
|
1981 |
|
1982 | if (hasOwn$4(AllSymbols, key)) {
|
1983 | if (!Attributes.enumerable) {
|
1984 | if (!hasOwn$4(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor$1(1, {}));
|
1985 | O[HIDDEN][key] = true;
|
1986 | } else {
|
1987 | if (hasOwn$4(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
|
1988 | Attributes = nativeObjectCreate(Attributes, {
|
1989 | enumerable: createPropertyDescriptor$1(0, false)
|
1990 | });
|
1991 | }
|
1992 |
|
1993 | return setSymbolDescriptor(O, key, Attributes);
|
1994 | }
|
1995 |
|
1996 | return nativeDefineProperty(O, key, Attributes);
|
1997 | };
|
1998 |
|
1999 | var $defineProperties = function defineProperties(O, Properties) {
|
2000 | anObject$5(O);
|
2001 | var properties = toIndexedObject$5(Properties);
|
2002 | var keys = objectKeys$2(properties).concat($getOwnPropertySymbols(properties));
|
2003 | $forEach$1(keys, function (key) {
|
2004 | if (!DESCRIPTORS$9 || call$6($propertyIsEnumerable$1, properties, key)) $defineProperty(O, key, properties[key]);
|
2005 | });
|
2006 | return O;
|
2007 | };
|
2008 |
|
2009 | var $create = function create(O, Properties) {
|
2010 | return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
|
2011 | };
|
2012 |
|
2013 | var $propertyIsEnumerable$1 = function propertyIsEnumerable(V) {
|
2014 | var P = toPropertyKey(V);
|
2015 | var enumerable = call$6(nativePropertyIsEnumerable, this, P);
|
2016 | if (this === ObjectPrototype$1 && hasOwn$4(AllSymbols, P) && !hasOwn$4(ObjectPrototypeSymbols, P)) return false;
|
2017 | return enumerable || !hasOwn$4(this, P) || !hasOwn$4(AllSymbols, P) || hasOwn$4(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
|
2018 | };
|
2019 |
|
2020 | var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
|
2021 | var it = toIndexedObject$5(O);
|
2022 | var key = toPropertyKey(P);
|
2023 | if (it === ObjectPrototype$1 && hasOwn$4(AllSymbols, key) && !hasOwn$4(ObjectPrototypeSymbols, key)) return;
|
2024 | var descriptor = nativeGetOwnPropertyDescriptor$1(it, key);
|
2025 |
|
2026 | if (descriptor && hasOwn$4(AllSymbols, key) && !(hasOwn$4(it, HIDDEN) && it[HIDDEN][key])) {
|
2027 | descriptor.enumerable = true;
|
2028 | }
|
2029 |
|
2030 | return descriptor;
|
2031 | };
|
2032 |
|
2033 | var $getOwnPropertyNames = function getOwnPropertyNames(O) {
|
2034 | var names = nativeGetOwnPropertyNames(toIndexedObject$5(O));
|
2035 | var result = [];
|
2036 | $forEach$1(names, function (key) {
|
2037 | if (!hasOwn$4(AllSymbols, key) && !hasOwn$4(hiddenKeys$1, key)) push$2(result, key);
|
2038 | });
|
2039 | return result;
|
2040 | };
|
2041 |
|
2042 | var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
|
2043 | var IS_OBJECT_PROTOTYPE = O === ObjectPrototype$1;
|
2044 | var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject$5(O));
|
2045 | var result = [];
|
2046 | $forEach$1(names, function (key) {
|
2047 | if (hasOwn$4(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn$4(ObjectPrototype$1, key))) {
|
2048 | push$2(result, AllSymbols[key]);
|
2049 | }
|
2050 | });
|
2051 | return result;
|
2052 | }; // `Symbol` constructor
|
2053 | // https://tc39.es/ecma262/#sec-symbol-constructor
|
2054 |
|
2055 |
|
2056 | if (!NATIVE_SYMBOL) {
|
2057 | $Symbol = function Symbol() {
|
2058 | if (isPrototypeOf$k(SymbolPrototype, this)) throw TypeError$8('Symbol is not a constructor');
|
2059 | var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
|
2060 | var tag = uid$1(description);
|
2061 |
|
2062 | var setter = function (value) {
|
2063 | if (this === ObjectPrototype$1) call$6(setter, ObjectPrototypeSymbols, value);
|
2064 | if (hasOwn$4(this, HIDDEN) && hasOwn$4(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
|
2065 | setSymbolDescriptor(this, tag, createPropertyDescriptor$1(1, value));
|
2066 | };
|
2067 |
|
2068 | if (DESCRIPTORS$9 && USE_SETTER) setSymbolDescriptor(ObjectPrototype$1, tag, {
|
2069 | configurable: true,
|
2070 | set: setter
|
2071 | });
|
2072 | return wrap$1(tag, description);
|
2073 | };
|
2074 |
|
2075 | SymbolPrototype = $Symbol[PROTOTYPE];
|
2076 | redefine$3(SymbolPrototype, 'toString', function toString() {
|
2077 | return getInternalState$2(this).tag;
|
2078 | });
|
2079 | redefine$3($Symbol, 'withoutSetter', function (description) {
|
2080 | return wrap$1(uid$1(description), description);
|
2081 | });
|
2082 | propertyIsEnumerableModule$1.f = $propertyIsEnumerable$1;
|
2083 | definePropertyModule$1.f = $defineProperty;
|
2084 | definePropertiesModule.f = $defineProperties;
|
2085 | getOwnPropertyDescriptorModule$1.f = $getOwnPropertyDescriptor;
|
2086 | getOwnPropertyNamesModule$2.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
|
2087 | getOwnPropertySymbolsModule$2.f = $getOwnPropertySymbols;
|
2088 |
|
2089 | wrappedWellKnownSymbolModule.f = function (name) {
|
2090 | return wrap$1(wellKnownSymbol$a(name), name);
|
2091 | };
|
2092 |
|
2093 | if (DESCRIPTORS$9) {
|
2094 | // https://github.com/tc39/proposal-Symbol-description
|
2095 | nativeDefineProperty(SymbolPrototype, 'description', {
|
2096 | configurable: true,
|
2097 | get: function description() {
|
2098 | return getInternalState$2(this).description;
|
2099 | }
|
2100 | });
|
2101 | }
|
2102 | }
|
2103 |
|
2104 | $$A({
|
2105 | global: true,
|
2106 | wrap: true,
|
2107 | forced: !NATIVE_SYMBOL,
|
2108 | sham: !NATIVE_SYMBOL
|
2109 | }, {
|
2110 | Symbol: $Symbol
|
2111 | });
|
2112 | $forEach$1(objectKeys$2(WellKnownSymbolsStore), function (name) {
|
2113 | defineWellKnownSymbol$k(name);
|
2114 | });
|
2115 | $$A({
|
2116 | target: SYMBOL,
|
2117 | stat: true,
|
2118 | forced: !NATIVE_SYMBOL
|
2119 | }, {
|
2120 | // `Symbol.for` method
|
2121 | // https://tc39.es/ecma262/#sec-symbol.for
|
2122 | 'for': function (key) {
|
2123 | var string = $toString(key);
|
2124 | if (hasOwn$4(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
|
2125 | var symbol = $Symbol(string);
|
2126 | StringToSymbolRegistry[string] = symbol;
|
2127 | SymbolToStringRegistry[symbol] = string;
|
2128 | return symbol;
|
2129 | },
|
2130 | // `Symbol.keyFor` method
|
2131 | // https://tc39.es/ecma262/#sec-symbol.keyfor
|
2132 | keyFor: function keyFor(sym) {
|
2133 | if (!isSymbol(sym)) throw TypeError$8(sym + ' is not a symbol');
|
2134 | if (hasOwn$4(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
|
2135 | },
|
2136 | useSetter: function () {
|
2137 | USE_SETTER = true;
|
2138 | },
|
2139 | useSimple: function () {
|
2140 | USE_SETTER = false;
|
2141 | }
|
2142 | });
|
2143 | $$A({
|
2144 | target: 'Object',
|
2145 | stat: true,
|
2146 | forced: !NATIVE_SYMBOL,
|
2147 | sham: !DESCRIPTORS$9
|
2148 | }, {
|
2149 | // `Object.create` method
|
2150 | // https://tc39.es/ecma262/#sec-object.create
|
2151 | create: $create,
|
2152 | // `Object.defineProperty` method
|
2153 | // https://tc39.es/ecma262/#sec-object.defineproperty
|
2154 | defineProperty: $defineProperty,
|
2155 | // `Object.defineProperties` method
|
2156 | // https://tc39.es/ecma262/#sec-object.defineproperties
|
2157 | defineProperties: $defineProperties,
|
2158 | // `Object.getOwnPropertyDescriptor` method
|
2159 | // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
|
2160 | getOwnPropertyDescriptor: $getOwnPropertyDescriptor
|
2161 | });
|
2162 | $$A({
|
2163 | target: 'Object',
|
2164 | stat: true,
|
2165 | forced: !NATIVE_SYMBOL
|
2166 | }, {
|
2167 | // `Object.getOwnPropertyNames` method
|
2168 | // https://tc39.es/ecma262/#sec-object.getownpropertynames
|
2169 | getOwnPropertyNames: $getOwnPropertyNames,
|
2170 | // `Object.getOwnPropertySymbols` method
|
2171 | // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
|
2172 | getOwnPropertySymbols: $getOwnPropertySymbols
|
2173 | }); // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
|
2174 | // https://bugs.chromium.org/p/v8/issues/detail?id=3443
|
2175 |
|
2176 | $$A({
|
2177 | target: 'Object',
|
2178 | stat: true,
|
2179 | forced: fails$g(function () {
|
2180 | getOwnPropertySymbolsModule$2.f(1);
|
2181 | })
|
2182 | }, {
|
2183 | getOwnPropertySymbols: function getOwnPropertySymbols(it) {
|
2184 | return getOwnPropertySymbolsModule$2.f(toObject$9(it));
|
2185 | }
|
2186 | }); // `JSON.stringify` method behavior with symbols
|
2187 | // https://tc39.es/ecma262/#sec-json.stringify
|
2188 |
|
2189 | if ($stringify$1) {
|
2190 | var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails$g(function () {
|
2191 | var symbol = $Symbol(); // MS Edge converts symbol values to JSON as {}
|
2192 |
|
2193 | return $stringify$1([symbol]) != '[null]' // WebKit converts symbol values to JSON as null
|
2194 | || $stringify$1({
|
2195 | a: symbol
|
2196 | }) != '{}' // V8 throws on boxed symbols
|
2197 | || $stringify$1(Object(symbol)) != '{}';
|
2198 | });
|
2199 | $$A({
|
2200 | target: 'JSON',
|
2201 | stat: true,
|
2202 | forced: FORCED_JSON_STRINGIFY
|
2203 | }, {
|
2204 | // eslint-disable-next-line no-unused-vars -- required for `.length`
|
2205 | stringify: function stringify(it, replacer, space) {
|
2206 | var args = arraySlice$2(arguments);
|
2207 | var $replacer = replacer;
|
2208 | if (!isObject$6(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
|
2209 |
|
2210 | if (!isArray$9(replacer)) replacer = function (key, value) {
|
2211 | if (isCallable$4($replacer)) value = call$6($replacer, this, key, value);
|
2212 | if (!isSymbol(value)) return value;
|
2213 | };
|
2214 | args[1] = replacer;
|
2215 | return apply$3($stringify$1, null, args);
|
2216 | }
|
2217 | });
|
2218 | } // `Symbol.prototype[@@toPrimitive]` method
|
2219 | // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
|
2220 |
|
2221 |
|
2222 | if (!SymbolPrototype[TO_PRIMITIVE]) {
|
2223 | var valueOf = SymbolPrototype.valueOf; // eslint-disable-next-line no-unused-vars -- required for .length
|
2224 |
|
2225 | redefine$3(SymbolPrototype, TO_PRIMITIVE, function (hint) {
|
2226 | // TODO: improve hint logic
|
2227 | return call$6(valueOf, this);
|
2228 | });
|
2229 | } // `Symbol.prototype[@@toStringTag]` property
|
2230 | // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
|
2231 |
|
2232 |
|
2233 | setToStringTag$4($Symbol, SYMBOL);
|
2234 | hiddenKeys$1[HIDDEN] = true;
|
2235 |
|
2236 | var defineWellKnownSymbol$j = defineWellKnownSymbol$l; // `Symbol.asyncIterator` well-known symbol
|
2237 | // https://tc39.es/ecma262/#sec-symbol.asynciterator
|
2238 |
|
2239 | defineWellKnownSymbol$j('asyncIterator');
|
2240 |
|
2241 | var defineWellKnownSymbol$i = defineWellKnownSymbol$l; // `Symbol.hasInstance` well-known symbol
|
2242 | // https://tc39.es/ecma262/#sec-symbol.hasinstance
|
2243 |
|
2244 | defineWellKnownSymbol$i('hasInstance');
|
2245 |
|
2246 | var defineWellKnownSymbol$h = defineWellKnownSymbol$l; // `Symbol.isConcatSpreadable` well-known symbol
|
2247 | // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
|
2248 |
|
2249 | defineWellKnownSymbol$h('isConcatSpreadable');
|
2250 |
|
2251 | var defineWellKnownSymbol$g = defineWellKnownSymbol$l; // `Symbol.iterator` well-known symbol
|
2252 | // https://tc39.es/ecma262/#sec-symbol.iterator
|
2253 |
|
2254 | defineWellKnownSymbol$g('iterator');
|
2255 |
|
2256 | var defineWellKnownSymbol$f = defineWellKnownSymbol$l; // `Symbol.match` well-known symbol
|
2257 | // https://tc39.es/ecma262/#sec-symbol.match
|
2258 |
|
2259 | defineWellKnownSymbol$f('match');
|
2260 |
|
2261 | var defineWellKnownSymbol$e = defineWellKnownSymbol$l; // `Symbol.matchAll` well-known symbol
|
2262 | // https://tc39.es/ecma262/#sec-symbol.matchall
|
2263 |
|
2264 | defineWellKnownSymbol$e('matchAll');
|
2265 |
|
2266 | var defineWellKnownSymbol$d = defineWellKnownSymbol$l; // `Symbol.replace` well-known symbol
|
2267 | // https://tc39.es/ecma262/#sec-symbol.replace
|
2268 |
|
2269 | defineWellKnownSymbol$d('replace');
|
2270 |
|
2271 | var defineWellKnownSymbol$c = defineWellKnownSymbol$l; // `Symbol.search` well-known symbol
|
2272 | // https://tc39.es/ecma262/#sec-symbol.search
|
2273 |
|
2274 | defineWellKnownSymbol$c('search');
|
2275 |
|
2276 | var defineWellKnownSymbol$b = defineWellKnownSymbol$l; // `Symbol.species` well-known symbol
|
2277 | // https://tc39.es/ecma262/#sec-symbol.species
|
2278 |
|
2279 | defineWellKnownSymbol$b('species');
|
2280 |
|
2281 | var defineWellKnownSymbol$a = defineWellKnownSymbol$l; // `Symbol.split` well-known symbol
|
2282 | // https://tc39.es/ecma262/#sec-symbol.split
|
2283 |
|
2284 | defineWellKnownSymbol$a('split');
|
2285 |
|
2286 | var defineWellKnownSymbol$9 = defineWellKnownSymbol$l; // `Symbol.toPrimitive` well-known symbol
|
2287 | // https://tc39.es/ecma262/#sec-symbol.toprimitive
|
2288 |
|
2289 | defineWellKnownSymbol$9('toPrimitive');
|
2290 |
|
2291 | var defineWellKnownSymbol$8 = defineWellKnownSymbol$l; // `Symbol.toStringTag` well-known symbol
|
2292 | // https://tc39.es/ecma262/#sec-symbol.tostringtag
|
2293 |
|
2294 | defineWellKnownSymbol$8('toStringTag');
|
2295 |
|
2296 | var defineWellKnownSymbol$7 = defineWellKnownSymbol$l; // `Symbol.unscopables` well-known symbol
|
2297 | // https://tc39.es/ecma262/#sec-symbol.unscopables
|
2298 |
|
2299 | defineWellKnownSymbol$7('unscopables');
|
2300 |
|
2301 | var global$k = global$N;
|
2302 | var setToStringTag$3 = setToStringTag$5; // JSON[@@toStringTag] property
|
2303 | // https://tc39.es/ecma262/#sec-json-@@tostringtag
|
2304 |
|
2305 | setToStringTag$3(global$k.JSON, 'JSON', true);
|
2306 |
|
2307 | var path$i = path$r;
|
2308 | var symbol$4 = path$i.Symbol;
|
2309 |
|
2310 | var iterators = {};
|
2311 |
|
2312 | var DESCRIPTORS$8 = descriptors;
|
2313 | var hasOwn$3 = hasOwnProperty_1;
|
2314 | var FunctionPrototype = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
2315 |
|
2316 | var getDescriptor = DESCRIPTORS$8 && Object.getOwnPropertyDescriptor;
|
2317 | var EXISTS = hasOwn$3(FunctionPrototype, 'name'); // additional protection from minified / mangled / dropped function names
|
2318 |
|
2319 | var PROPER = EXISTS && function something() {
|
2320 | /* empty */
|
2321 | }.name === 'something';
|
2322 |
|
2323 | var CONFIGURABLE = EXISTS && (!DESCRIPTORS$8 || DESCRIPTORS$8 && getDescriptor(FunctionPrototype, 'name').configurable);
|
2324 | var functionName = {
|
2325 | EXISTS: EXISTS,
|
2326 | PROPER: PROPER,
|
2327 | CONFIGURABLE: CONFIGURABLE
|
2328 | };
|
2329 |
|
2330 | var fails$f = fails$s;
|
2331 | var correctPrototypeGetter = !fails$f(function () {
|
2332 | function F() {
|
2333 | /* empty */
|
2334 | }
|
2335 |
|
2336 | F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
|
2337 |
|
2338 | return Object.getPrototypeOf(new F()) !== F.prototype;
|
2339 | });
|
2340 |
|
2341 | var global$j = global$N;
|
2342 | var hasOwn$2 = hasOwnProperty_1;
|
2343 | var isCallable$3 = isCallable$h;
|
2344 | var toObject$8 = toObject$d;
|
2345 | var sharedKey = sharedKey$4;
|
2346 | var CORRECT_PROTOTYPE_GETTER$1 = correctPrototypeGetter;
|
2347 | var IE_PROTO = sharedKey('IE_PROTO');
|
2348 | var Object$3 = global$j.Object;
|
2349 | var ObjectPrototype = Object$3.prototype; // `Object.getPrototypeOf` method
|
2350 | // https://tc39.es/ecma262/#sec-object.getprototypeof
|
2351 |
|
2352 | var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER$1 ? Object$3.getPrototypeOf : function (O) {
|
2353 | var object = toObject$8(O);
|
2354 | if (hasOwn$2(object, IE_PROTO)) return object[IE_PROTO];
|
2355 | var constructor = object.constructor;
|
2356 |
|
2357 | if (isCallable$3(constructor) && object instanceof constructor) {
|
2358 | return constructor.prototype;
|
2359 | }
|
2360 |
|
2361 | return object instanceof Object$3 ? ObjectPrototype : null;
|
2362 | };
|
2363 |
|
2364 | var fails$e = fails$s;
|
2365 | var isCallable$2 = isCallable$h;
|
2366 | var create$3 = objectCreate;
|
2367 | var getPrototypeOf$7 = objectGetPrototypeOf;
|
2368 | var redefine$2 = redefine$4;
|
2369 | var wellKnownSymbol$9 = wellKnownSymbol$j;
|
2370 | var ITERATOR$6 = wellKnownSymbol$9('iterator');
|
2371 | var BUGGY_SAFARI_ITERATORS$1 = false; // `%IteratorPrototype%` object
|
2372 | // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
|
2373 |
|
2374 | var IteratorPrototype$1, PrototypeOfArrayIteratorPrototype, arrayIterator;
|
2375 | /* eslint-disable es/no-array-prototype-keys -- safe */
|
2376 |
|
2377 | if ([].keys) {
|
2378 | arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next`
|
2379 |
|
2380 | if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;else {
|
2381 | PrototypeOfArrayIteratorPrototype = getPrototypeOf$7(getPrototypeOf$7(arrayIterator));
|
2382 | if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$1 = PrototypeOfArrayIteratorPrototype;
|
2383 | }
|
2384 | }
|
2385 |
|
2386 | var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$1 == undefined || fails$e(function () {
|
2387 | var test = {}; // FF44- legacy iterators case
|
2388 |
|
2389 | return IteratorPrototype$1[ITERATOR$6].call(test) !== test;
|
2390 | });
|
2391 | if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$1 = {};else IteratorPrototype$1 = create$3(IteratorPrototype$1); // `%IteratorPrototype%[@@iterator]()` method
|
2392 | // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
|
2393 |
|
2394 | if (!isCallable$2(IteratorPrototype$1[ITERATOR$6])) {
|
2395 | redefine$2(IteratorPrototype$1, ITERATOR$6, function () {
|
2396 | return this;
|
2397 | });
|
2398 | }
|
2399 |
|
2400 | var iteratorsCore = {
|
2401 | IteratorPrototype: IteratorPrototype$1,
|
2402 | BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
|
2403 | };
|
2404 |
|
2405 | var IteratorPrototype = iteratorsCore.IteratorPrototype;
|
2406 | var create$2 = objectCreate;
|
2407 | var createPropertyDescriptor = createPropertyDescriptor$5;
|
2408 | var setToStringTag$2 = setToStringTag$5;
|
2409 | var Iterators$5 = iterators;
|
2410 |
|
2411 | var returnThis$1 = function () {
|
2412 | return this;
|
2413 | };
|
2414 |
|
2415 | var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
|
2416 | var TO_STRING_TAG = NAME + ' Iterator';
|
2417 | IteratorConstructor.prototype = create$2(IteratorPrototype, {
|
2418 | next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next)
|
2419 | });
|
2420 | setToStringTag$2(IteratorConstructor, TO_STRING_TAG, false, true);
|
2421 | Iterators$5[TO_STRING_TAG] = returnThis$1;
|
2422 | return IteratorConstructor;
|
2423 | };
|
2424 |
|
2425 | var $$z = _export;
|
2426 | var call$5 = functionCall;
|
2427 | var FunctionName = functionName;
|
2428 | var createIteratorConstructor = createIteratorConstructor$1;
|
2429 | var getPrototypeOf$6 = objectGetPrototypeOf;
|
2430 | var setToStringTag$1 = setToStringTag$5;
|
2431 | var redefine$1 = redefine$4;
|
2432 | var wellKnownSymbol$8 = wellKnownSymbol$j;
|
2433 | var Iterators$4 = iterators;
|
2434 | var IteratorsCore = iteratorsCore;
|
2435 | var PROPER_FUNCTION_NAME$1 = FunctionName.PROPER;
|
2436 | var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
|
2437 | var ITERATOR$5 = wellKnownSymbol$8('iterator');
|
2438 | var KEYS = 'keys';
|
2439 | var VALUES = 'values';
|
2440 | var ENTRIES = 'entries';
|
2441 |
|
2442 | var returnThis = function () {
|
2443 | return this;
|
2444 | };
|
2445 |
|
2446 | var defineIterator$3 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
|
2447 | createIteratorConstructor(IteratorConstructor, NAME, next);
|
2448 |
|
2449 | var getIterationMethod = function (KIND) {
|
2450 | if (KIND === DEFAULT && defaultIterator) return defaultIterator;
|
2451 | if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
|
2452 |
|
2453 | switch (KIND) {
|
2454 | case KEYS:
|
2455 | return function keys() {
|
2456 | return new IteratorConstructor(this, KIND);
|
2457 | };
|
2458 |
|
2459 | case VALUES:
|
2460 | return function values() {
|
2461 | return new IteratorConstructor(this, KIND);
|
2462 | };
|
2463 |
|
2464 | case ENTRIES:
|
2465 | return function entries() {
|
2466 | return new IteratorConstructor(this, KIND);
|
2467 | };
|
2468 | }
|
2469 |
|
2470 | return function () {
|
2471 | return new IteratorConstructor(this);
|
2472 | };
|
2473 | };
|
2474 |
|
2475 | var TO_STRING_TAG = NAME + ' Iterator';
|
2476 | var INCORRECT_VALUES_NAME = false;
|
2477 | var IterablePrototype = Iterable.prototype;
|
2478 | var nativeIterator = IterablePrototype[ITERATOR$5] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
|
2479 | var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
|
2480 | var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
|
2481 | var CurrentIteratorPrototype, methods, KEY; // fix native
|
2482 |
|
2483 | if (anyNativeIterator) {
|
2484 | CurrentIteratorPrototype = getPrototypeOf$6(anyNativeIterator.call(new Iterable()));
|
2485 |
|
2486 | if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
|
2487 |
|
2488 |
|
2489 | setToStringTag$1(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
|
2490 | Iterators$4[TO_STRING_TAG] = returnThis;
|
2491 | }
|
2492 | } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
|
2493 |
|
2494 |
|
2495 | if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
|
2496 | {
|
2497 | INCORRECT_VALUES_NAME = true;
|
2498 |
|
2499 | defaultIterator = function values() {
|
2500 | return call$5(nativeIterator, this);
|
2501 | };
|
2502 | }
|
2503 | } // export additional methods
|
2504 |
|
2505 |
|
2506 | if (DEFAULT) {
|
2507 | methods = {
|
2508 | values: getIterationMethod(VALUES),
|
2509 | keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
|
2510 | entries: getIterationMethod(ENTRIES)
|
2511 | };
|
2512 | if (FORCED) for (KEY in methods) {
|
2513 | if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
2514 | redefine$1(IterablePrototype, KEY, methods[KEY]);
|
2515 | }
|
2516 | } else $$z({
|
2517 | target: NAME,
|
2518 | proto: true,
|
2519 | forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
|
2520 | }, methods);
|
2521 | } // define iterator
|
2522 |
|
2523 |
|
2524 | if ((FORCED) && IterablePrototype[ITERATOR$5] !== defaultIterator) {
|
2525 | redefine$1(IterablePrototype, ITERATOR$5, defaultIterator, {
|
2526 | name: DEFAULT
|
2527 | });
|
2528 | }
|
2529 |
|
2530 | Iterators$4[NAME] = defaultIterator;
|
2531 | return methods;
|
2532 | };
|
2533 |
|
2534 | var toIndexedObject$4 = toIndexedObject$b;
|
2535 | var Iterators$3 = iterators;
|
2536 | var InternalStateModule$3 = internalState;
|
2537 | objectDefineProperty.f;
|
2538 | var defineIterator$2 = defineIterator$3;
|
2539 | var ARRAY_ITERATOR = 'Array Iterator';
|
2540 | var setInternalState$3 = InternalStateModule$3.set;
|
2541 | var getInternalState$1 = InternalStateModule$3.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method
|
2542 | // https://tc39.es/ecma262/#sec-array.prototype.entries
|
2543 | // `Array.prototype.keys` method
|
2544 | // https://tc39.es/ecma262/#sec-array.prototype.keys
|
2545 | // `Array.prototype.values` method
|
2546 | // https://tc39.es/ecma262/#sec-array.prototype.values
|
2547 | // `Array.prototype[@@iterator]` method
|
2548 | // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
|
2549 | // `CreateArrayIterator` internal method
|
2550 | // https://tc39.es/ecma262/#sec-createarrayiterator
|
2551 |
|
2552 | defineIterator$2(Array, 'Array', function (iterated, kind) {
|
2553 | setInternalState$3(this, {
|
2554 | type: ARRAY_ITERATOR,
|
2555 | target: toIndexedObject$4(iterated),
|
2556 | // target
|
2557 | index: 0,
|
2558 | // next index
|
2559 | kind: kind // kind
|
2560 |
|
2561 | }); // `%ArrayIteratorPrototype%.next` method
|
2562 | // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
|
2563 | }, function () {
|
2564 | var state = getInternalState$1(this);
|
2565 | var target = state.target;
|
2566 | var kind = state.kind;
|
2567 | var index = state.index++;
|
2568 |
|
2569 | if (!target || index >= target.length) {
|
2570 | state.target = undefined;
|
2571 | return {
|
2572 | value: undefined,
|
2573 | done: true
|
2574 | };
|
2575 | }
|
2576 |
|
2577 | if (kind == 'keys') return {
|
2578 | value: index,
|
2579 | done: false
|
2580 | };
|
2581 | if (kind == 'values') return {
|
2582 | value: target[index],
|
2583 | done: false
|
2584 | };
|
2585 | return {
|
2586 | value: [index, target[index]],
|
2587 | done: false
|
2588 | };
|
2589 | }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values%
|
2590 | // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
|
2591 | // https://tc39.es/ecma262/#sec-createmappedargumentsobject
|
2592 |
|
2593 | Iterators$3.Arguments = Iterators$3.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
2594 |
|
2595 | // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
|
2596 |
|
2597 | var domIterables = {
|
2598 | CSSRuleList: 0,
|
2599 | CSSStyleDeclaration: 0,
|
2600 | CSSValueList: 0,
|
2601 | ClientRectList: 0,
|
2602 | DOMRectList: 0,
|
2603 | DOMStringList: 0,
|
2604 | DOMTokenList: 1,
|
2605 | DataTransferItemList: 0,
|
2606 | FileList: 0,
|
2607 | HTMLAllCollection: 0,
|
2608 | HTMLCollection: 0,
|
2609 | HTMLFormElement: 0,
|
2610 | HTMLSelectElement: 0,
|
2611 | MediaList: 0,
|
2612 | MimeTypeArray: 0,
|
2613 | NamedNodeMap: 0,
|
2614 | NodeList: 1,
|
2615 | PaintRequestList: 0,
|
2616 | Plugin: 0,
|
2617 | PluginArray: 0,
|
2618 | SVGLengthList: 0,
|
2619 | SVGNumberList: 0,
|
2620 | SVGPathSegList: 0,
|
2621 | SVGPointList: 0,
|
2622 | SVGStringList: 0,
|
2623 | SVGTransformList: 0,
|
2624 | SourceBufferList: 0,
|
2625 | StyleSheetList: 0,
|
2626 | TextTrackCueList: 0,
|
2627 | TextTrackList: 0,
|
2628 | TouchList: 0
|
2629 | };
|
2630 |
|
2631 | var DOMIterables$1 = domIterables;
|
2632 | var global$i = global$N;
|
2633 | var classof$5 = classof$b;
|
2634 | var createNonEnumerableProperty$1 = createNonEnumerableProperty$6;
|
2635 | var Iterators$2 = iterators;
|
2636 | var wellKnownSymbol$7 = wellKnownSymbol$j;
|
2637 | var TO_STRING_TAG = wellKnownSymbol$7('toStringTag');
|
2638 |
|
2639 | for (var COLLECTION_NAME in DOMIterables$1) {
|
2640 | var Collection = global$i[COLLECTION_NAME];
|
2641 | var CollectionPrototype = Collection && Collection.prototype;
|
2642 |
|
2643 | if (CollectionPrototype && classof$5(CollectionPrototype) !== TO_STRING_TAG) {
|
2644 | createNonEnumerableProperty$1(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
|
2645 | }
|
2646 |
|
2647 | Iterators$2[COLLECTION_NAME] = Iterators$2.Array;
|
2648 | }
|
2649 |
|
2650 | var parent$O = symbol$4;
|
2651 | var symbol$3 = parent$O;
|
2652 |
|
2653 | var parent$N = symbol$3;
|
2654 | var symbol$2 = parent$N;
|
2655 |
|
2656 | var defineWellKnownSymbol$6 = defineWellKnownSymbol$l; // `Symbol.asyncDispose` well-known symbol
|
2657 | // https://github.com/tc39/proposal-using-statement
|
2658 |
|
2659 | defineWellKnownSymbol$6('asyncDispose');
|
2660 |
|
2661 | var defineWellKnownSymbol$5 = defineWellKnownSymbol$l; // `Symbol.dispose` well-known symbol
|
2662 | // https://github.com/tc39/proposal-using-statement
|
2663 |
|
2664 | defineWellKnownSymbol$5('dispose');
|
2665 |
|
2666 | var defineWellKnownSymbol$4 = defineWellKnownSymbol$l; // `Symbol.matcher` well-known symbol
|
2667 | // https://github.com/tc39/proposal-pattern-matching
|
2668 |
|
2669 | defineWellKnownSymbol$4('matcher');
|
2670 |
|
2671 | var defineWellKnownSymbol$3 = defineWellKnownSymbol$l; // `Symbol.metadata` well-known symbol
|
2672 | // https://github.com/tc39/proposal-decorators
|
2673 |
|
2674 | defineWellKnownSymbol$3('metadata');
|
2675 |
|
2676 | var defineWellKnownSymbol$2 = defineWellKnownSymbol$l; // `Symbol.observable` well-known symbol
|
2677 | // https://github.com/tc39/proposal-observable
|
2678 |
|
2679 | defineWellKnownSymbol$2('observable');
|
2680 |
|
2681 | var defineWellKnownSymbol$1 = defineWellKnownSymbol$l; // `Symbol.patternMatch` well-known symbol
|
2682 | // https://github.com/tc39/proposal-pattern-matching
|
2683 |
|
2684 | defineWellKnownSymbol$1('patternMatch');
|
2685 |
|
2686 | var defineWellKnownSymbol = defineWellKnownSymbol$l;
|
2687 | defineWellKnownSymbol('replaceAll');
|
2688 |
|
2689 | var parent$M = symbol$2; // TODO: Remove from `core-js@4`
|
2690 | // TODO: Remove from `core-js@4`
|
2691 |
|
2692 | var symbol$1 = parent$M;
|
2693 |
|
2694 | (function (module) {
|
2695 | module.exports = symbol$1;
|
2696 | })(symbol$5);
|
2697 |
|
2698 | var _Symbol$1 = /*@__PURE__*/getDefaultExportFromCjs(symbol$5.exports);
|
2699 |
|
2700 | var iterator$4 = {exports: {}};
|
2701 |
|
2702 | var uncurryThis$d = functionUncurryThis;
|
2703 | var toIntegerOrInfinity$2 = toIntegerOrInfinity$5;
|
2704 | var toString$7 = toString$9;
|
2705 | var requireObjectCoercible$3 = requireObjectCoercible$6;
|
2706 | var charAt$3 = uncurryThis$d(''.charAt);
|
2707 | var charCodeAt$1 = uncurryThis$d(''.charCodeAt);
|
2708 | var stringSlice = uncurryThis$d(''.slice);
|
2709 |
|
2710 | var createMethod$3 = function (CONVERT_TO_STRING) {
|
2711 | return function ($this, pos) {
|
2712 | var S = toString$7(requireObjectCoercible$3($this));
|
2713 | var position = toIntegerOrInfinity$2(pos);
|
2714 | var size = S.length;
|
2715 | var first, second;
|
2716 | if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
|
2717 | first = charCodeAt$1(S, position);
|
2718 | return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? charAt$3(S, position) : first : CONVERT_TO_STRING ? stringSlice(S, position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
|
2719 | };
|
2720 | };
|
2721 |
|
2722 | var stringMultibyte = {
|
2723 | // `String.prototype.codePointAt` method
|
2724 | // https://tc39.es/ecma262/#sec-string.prototype.codepointat
|
2725 | codeAt: createMethod$3(false),
|
2726 | // `String.prototype.at` method
|
2727 | // https://github.com/mathiasbynens/String.prototype.at
|
2728 | charAt: createMethod$3(true)
|
2729 | };
|
2730 |
|
2731 | var charAt$2 = stringMultibyte.charAt;
|
2732 | var toString$6 = toString$9;
|
2733 | var InternalStateModule$2 = internalState;
|
2734 | var defineIterator$1 = defineIterator$3;
|
2735 | var STRING_ITERATOR = 'String Iterator';
|
2736 | var setInternalState$2 = InternalStateModule$2.set;
|
2737 | var getInternalState = InternalStateModule$2.getterFor(STRING_ITERATOR); // `String.prototype[@@iterator]` method
|
2738 | // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
|
2739 |
|
2740 | defineIterator$1(String, 'String', function (iterated) {
|
2741 | setInternalState$2(this, {
|
2742 | type: STRING_ITERATOR,
|
2743 | string: toString$6(iterated),
|
2744 | index: 0
|
2745 | }); // `%StringIteratorPrototype%.next` method
|
2746 | // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
|
2747 | }, function next() {
|
2748 | var state = getInternalState(this);
|
2749 | var string = state.string;
|
2750 | var index = state.index;
|
2751 | var point;
|
2752 | if (index >= string.length) return {
|
2753 | value: undefined,
|
2754 | done: true
|
2755 | };
|
2756 | point = charAt$2(string, index);
|
2757 | state.index += point.length;
|
2758 | return {
|
2759 | value: point,
|
2760 | done: false
|
2761 | };
|
2762 | });
|
2763 |
|
2764 | var WrappedWellKnownSymbolModule = wellKnownSymbolWrapped;
|
2765 | var iterator$3 = WrappedWellKnownSymbolModule.f('iterator');
|
2766 |
|
2767 | var parent$L = iterator$3;
|
2768 | var iterator$2 = parent$L;
|
2769 |
|
2770 | var parent$K = iterator$2;
|
2771 | var iterator$1 = parent$K;
|
2772 |
|
2773 | var parent$J = iterator$1;
|
2774 | var iterator = parent$J;
|
2775 |
|
2776 | (function (module) {
|
2777 | module.exports = iterator;
|
2778 | })(iterator$4);
|
2779 |
|
2780 | var _Symbol$iterator = /*@__PURE__*/getDefaultExportFromCjs(iterator$4.exports);
|
2781 |
|
2782 | function _typeof(obj) {
|
2783 | "@babel/helpers - typeof";
|
2784 |
|
2785 | return _typeof = "function" == typeof _Symbol$1 && "symbol" == typeof _Symbol$iterator ? function (obj) {
|
2786 | return typeof obj;
|
2787 | } : function (obj) {
|
2788 | return obj && "function" == typeof _Symbol$1 && obj.constructor === _Symbol$1 && obj !== _Symbol$1.prototype ? "symbol" : typeof obj;
|
2789 | }, _typeof(obj);
|
2790 | }
|
2791 |
|
2792 | function _possibleConstructorReturn(self, call) {
|
2793 | if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
2794 | return call;
|
2795 | } else if (call !== void 0) {
|
2796 | throw new TypeError("Derived constructors may only return object or undefined");
|
2797 | }
|
2798 |
|
2799 | return _assertThisInitialized$1(self);
|
2800 | }
|
2801 |
|
2802 | var getPrototypeOf$5 = {exports: {}};
|
2803 |
|
2804 | var $$y = _export;
|
2805 | var fails$d = fails$s;
|
2806 | var toObject$7 = toObject$d;
|
2807 | var nativeGetPrototypeOf = objectGetPrototypeOf;
|
2808 | var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
|
2809 | var FAILS_ON_PRIMITIVES$3 = fails$d(function () {
|
2810 | nativeGetPrototypeOf(1);
|
2811 | }); // `Object.getPrototypeOf` method
|
2812 | // https://tc39.es/ecma262/#sec-object.getprototypeof
|
2813 |
|
2814 | $$y({
|
2815 | target: 'Object',
|
2816 | stat: true,
|
2817 | forced: FAILS_ON_PRIMITIVES$3,
|
2818 | sham: !CORRECT_PROTOTYPE_GETTER
|
2819 | }, {
|
2820 | getPrototypeOf: function getPrototypeOf(it) {
|
2821 | return nativeGetPrototypeOf(toObject$7(it));
|
2822 | }
|
2823 | });
|
2824 |
|
2825 | var path$h = path$r;
|
2826 | var getPrototypeOf$4 = path$h.Object.getPrototypeOf;
|
2827 |
|
2828 | var parent$I = getPrototypeOf$4;
|
2829 | var getPrototypeOf$3 = parent$I;
|
2830 |
|
2831 | var parent$H = getPrototypeOf$3;
|
2832 | var getPrototypeOf$2 = parent$H;
|
2833 |
|
2834 | var parent$G = getPrototypeOf$2;
|
2835 | var getPrototypeOf$1 = parent$G;
|
2836 |
|
2837 | (function (module) {
|
2838 | module.exports = getPrototypeOf$1;
|
2839 | })(getPrototypeOf$5);
|
2840 |
|
2841 | var _Object$getPrototypeOf$1 = /*@__PURE__*/getDefaultExportFromCjs(getPrototypeOf$5.exports);
|
2842 |
|
2843 | function _getPrototypeOf(o) {
|
2844 | var _context;
|
2845 |
|
2846 | _getPrototypeOf = _Object$setPrototypeOf ? _bindInstanceProperty$1(_context = _Object$getPrototypeOf$1).call(_context) : function _getPrototypeOf(o) {
|
2847 | return o.__proto__ || _Object$getPrototypeOf$1(o);
|
2848 | };
|
2849 | return _getPrototypeOf(o);
|
2850 | }
|
2851 |
|
2852 | var isArray$8 = {exports: {}};
|
2853 |
|
2854 | var $$x = _export;
|
2855 | var isArray$7 = isArray$c; // `Array.isArray` method
|
2856 | // https://tc39.es/ecma262/#sec-array.isarray
|
2857 |
|
2858 | $$x({
|
2859 | target: 'Array',
|
2860 | stat: true
|
2861 | }, {
|
2862 | isArray: isArray$7
|
2863 | });
|
2864 |
|
2865 | var path$g = path$r;
|
2866 | var isArray$6 = path$g.Array.isArray;
|
2867 |
|
2868 | var parent$F = isArray$6;
|
2869 | var isArray$5 = parent$F;
|
2870 |
|
2871 | (function (module) {
|
2872 | module.exports = isArray$5;
|
2873 | })(isArray$8);
|
2874 |
|
2875 | var _Array$isArray$1 = /*@__PURE__*/getDefaultExportFromCjs(isArray$8.exports);
|
2876 |
|
2877 | var bind$3 = {exports: {}};
|
2878 |
|
2879 | (function (module) {
|
2880 | module.exports = bind$7;
|
2881 | })(bind$3);
|
2882 |
|
2883 | var _bindInstanceProperty = /*@__PURE__*/getDefaultExportFromCjs(bind$3.exports);
|
2884 |
|
2885 | var setTimeout$2 = {exports: {}};
|
2886 |
|
2887 | var global$h = global$N;
|
2888 | var TypeError$7 = global$h.TypeError;
|
2889 |
|
2890 | var validateArgumentsLength$1 = function (passed, required) {
|
2891 | if (passed < required) throw TypeError$7('Not enough arguments');
|
2892 | return passed;
|
2893 | };
|
2894 |
|
2895 | var $$w = _export;
|
2896 | var global$g = global$N;
|
2897 | var apply$2 = functionApply;
|
2898 | var isCallable$1 = isCallable$h;
|
2899 | var userAgent$2 = engineUserAgent;
|
2900 | var arraySlice$1 = arraySlice$5;
|
2901 | var validateArgumentsLength = validateArgumentsLength$1;
|
2902 | var MSIE = /MSIE .\./.test(userAgent$2); // <- dirty ie9- check
|
2903 |
|
2904 | var Function$1 = global$g.Function;
|
2905 |
|
2906 | var wrap = function (scheduler) {
|
2907 | return function (handler, timeout
|
2908 | /* , ...arguments */
|
2909 | ) {
|
2910 | var boundArgs = validateArgumentsLength(arguments.length, 1) > 2;
|
2911 | var fn = isCallable$1(handler) ? handler : Function$1(handler);
|
2912 | var args = boundArgs ? arraySlice$1(arguments, 2) : undefined;
|
2913 | return scheduler(boundArgs ? function () {
|
2914 | apply$2(fn, this, args);
|
2915 | } : fn, timeout);
|
2916 | };
|
2917 | }; // ie9- setTimeout & setInterval additional parameters fix
|
2918 | // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
|
2919 |
|
2920 |
|
2921 | $$w({
|
2922 | global: true,
|
2923 | bind: true,
|
2924 | forced: MSIE
|
2925 | }, {
|
2926 | // `setTimeout` method
|
2927 | // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
|
2928 | setTimeout: wrap(global$g.setTimeout),
|
2929 | // `setInterval` method
|
2930 | // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
|
2931 | setInterval: wrap(global$g.setInterval)
|
2932 | });
|
2933 |
|
2934 | var path$f = path$r;
|
2935 | var setTimeout$1 = path$f.setTimeout;
|
2936 |
|
2937 | (function (module) {
|
2938 | module.exports = setTimeout$1;
|
2939 | })(setTimeout$2);
|
2940 |
|
2941 | var _setTimeout = /*@__PURE__*/getDefaultExportFromCjs(setTimeout$2.exports);
|
2942 |
|
2943 | var forEach$6 = {exports: {}};
|
2944 |
|
2945 | var fails$c = fails$s;
|
2946 |
|
2947 | var arrayMethodIsStrict$6 = function (METHOD_NAME, argument) {
|
2948 | var method = [][METHOD_NAME];
|
2949 | return !!method && fails$c(function () {
|
2950 | // eslint-disable-next-line no-useless-call -- required for testing
|
2951 | method.call(null, argument || function () {
|
2952 | return 1;
|
2953 | }, 1);
|
2954 | });
|
2955 | };
|
2956 |
|
2957 | var $forEach = arrayIteration.forEach;
|
2958 | var arrayMethodIsStrict$5 = arrayMethodIsStrict$6;
|
2959 | var STRICT_METHOD$5 = arrayMethodIsStrict$5('forEach'); // `Array.prototype.forEach` method implementation
|
2960 | // https://tc39.es/ecma262/#sec-array.prototype.foreach
|
2961 |
|
2962 | var arrayForEach = !STRICT_METHOD$5 ? function forEach(callbackfn
|
2963 | /* , thisArg */
|
2964 | ) {
|
2965 | return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); // eslint-disable-next-line es/no-array-prototype-foreach -- safe
|
2966 | } : [].forEach;
|
2967 |
|
2968 | var $$v = _export;
|
2969 | var forEach$5 = arrayForEach; // `Array.prototype.forEach` method
|
2970 | // https://tc39.es/ecma262/#sec-array.prototype.foreach
|
2971 | // eslint-disable-next-line es/no-array-prototype-foreach -- safe
|
2972 |
|
2973 | $$v({
|
2974 | target: 'Array',
|
2975 | proto: true,
|
2976 | forced: [].forEach != forEach$5
|
2977 | }, {
|
2978 | forEach: forEach$5
|
2979 | });
|
2980 |
|
2981 | var entryVirtual$i = entryVirtual$k;
|
2982 | var forEach$4 = entryVirtual$i('Array').forEach;
|
2983 |
|
2984 | var parent$E = forEach$4;
|
2985 | var forEach$3 = parent$E;
|
2986 |
|
2987 | var classof$4 = classof$b;
|
2988 | var hasOwn$1 = hasOwnProperty_1;
|
2989 | var isPrototypeOf$j = objectIsPrototypeOf;
|
2990 | var method$g = forEach$3;
|
2991 | var ArrayPrototype$g = Array.prototype;
|
2992 | var DOMIterables = {
|
2993 | DOMTokenList: true,
|
2994 | NodeList: true
|
2995 | };
|
2996 |
|
2997 | var forEach$2 = function (it) {
|
2998 | var own = it.forEach;
|
2999 | return it === ArrayPrototype$g || isPrototypeOf$j(ArrayPrototype$g, it) && own === ArrayPrototype$g.forEach || hasOwn$1(DOMIterables, classof$4(it)) ? method$g : own;
|
3000 | };
|
3001 |
|
3002 | (function (module) {
|
3003 | module.exports = forEach$2;
|
3004 | })(forEach$6);
|
3005 |
|
3006 | var _forEachInstanceProperty = /*@__PURE__*/getDefaultExportFromCjs(forEach$6.exports);
|
3007 |
|
3008 | // use this instance. Else, load via commonjs.
|
3009 | //
|
3010 | // Note: This doesn't work in ESM.
|
3011 |
|
3012 | var moment$2 = typeof window !== 'undefined' && window['moment'] || moment$3;
|
3013 |
|
3014 | var getOwnPropertySymbols$2 = {exports: {}};
|
3015 |
|
3016 | var path$e = path$r;
|
3017 | var getOwnPropertySymbols$1 = path$e.Object.getOwnPropertySymbols;
|
3018 |
|
3019 | var parent$D = getOwnPropertySymbols$1;
|
3020 | var getOwnPropertySymbols = parent$D;
|
3021 |
|
3022 | (function (module) {
|
3023 | module.exports = getOwnPropertySymbols;
|
3024 | })(getOwnPropertySymbols$2);
|
3025 |
|
3026 | var _Object$getOwnPropertySymbols = /*@__PURE__*/getDefaultExportFromCjs(getOwnPropertySymbols$2.exports);
|
3027 |
|
3028 | var filter$3 = {exports: {}};
|
3029 |
|
3030 | var $$u = _export;
|
3031 | var $filter = arrayIteration.filter;
|
3032 | var arrayMethodHasSpeciesSupport$3 = arrayMethodHasSpeciesSupport$5;
|
3033 | var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport$3('filter'); // `Array.prototype.filter` method
|
3034 | // https://tc39.es/ecma262/#sec-array.prototype.filter
|
3035 | // with adding support of @@species
|
3036 |
|
3037 | $$u({
|
3038 | target: 'Array',
|
3039 | proto: true,
|
3040 | forced: !HAS_SPECIES_SUPPORT$3
|
3041 | }, {
|
3042 | filter: function filter(callbackfn
|
3043 | /* , thisArg */
|
3044 | ) {
|
3045 | return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
3046 | }
|
3047 | });
|
3048 |
|
3049 | var entryVirtual$h = entryVirtual$k;
|
3050 | var filter$2 = entryVirtual$h('Array').filter;
|
3051 |
|
3052 | var isPrototypeOf$i = objectIsPrototypeOf;
|
3053 | var method$f = filter$2;
|
3054 | var ArrayPrototype$f = Array.prototype;
|
3055 |
|
3056 | var filter$1 = function (it) {
|
3057 | var own = it.filter;
|
3058 | return it === ArrayPrototype$f || isPrototypeOf$i(ArrayPrototype$f, it) && own === ArrayPrototype$f.filter ? method$f : own;
|
3059 | };
|
3060 |
|
3061 | var parent$C = filter$1;
|
3062 | var filter = parent$C;
|
3063 |
|
3064 | (function (module) {
|
3065 | module.exports = filter;
|
3066 | })(filter$3);
|
3067 |
|
3068 | var _filterInstanceProperty = /*@__PURE__*/getDefaultExportFromCjs(filter$3.exports);
|
3069 |
|
3070 | var getOwnPropertyDescriptor$3 = {exports: {}};
|
3071 |
|
3072 | var getOwnPropertyDescriptor$2 = {exports: {}};
|
3073 |
|
3074 | var $$t = _export;
|
3075 | var fails$b = fails$s;
|
3076 | var toIndexedObject$3 = toIndexedObject$b;
|
3077 | var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
3078 | var DESCRIPTORS$7 = descriptors;
|
3079 | var FAILS_ON_PRIMITIVES$2 = fails$b(function () {
|
3080 | nativeGetOwnPropertyDescriptor(1);
|
3081 | });
|
3082 | var FORCED$4 = !DESCRIPTORS$7 || FAILS_ON_PRIMITIVES$2; // `Object.getOwnPropertyDescriptor` method
|
3083 | // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
|
3084 |
|
3085 | $$t({
|
3086 | target: 'Object',
|
3087 | stat: true,
|
3088 | forced: FORCED$4,
|
3089 | sham: !DESCRIPTORS$7
|
3090 | }, {
|
3091 | getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
|
3092 | return nativeGetOwnPropertyDescriptor(toIndexedObject$3(it), key);
|
3093 | }
|
3094 | });
|
3095 |
|
3096 | var path$d = path$r;
|
3097 | var Object$2 = path$d.Object;
|
3098 |
|
3099 | var getOwnPropertyDescriptor$1 = getOwnPropertyDescriptor$2.exports = function getOwnPropertyDescriptor(it, key) {
|
3100 | return Object$2.getOwnPropertyDescriptor(it, key);
|
3101 | };
|
3102 |
|
3103 | if (Object$2.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor$1.sham = true;
|
3104 |
|
3105 | var parent$B = getOwnPropertyDescriptor$2.exports;
|
3106 | var getOwnPropertyDescriptor = parent$B;
|
3107 |
|
3108 | (function (module) {
|
3109 | module.exports = getOwnPropertyDescriptor;
|
3110 | })(getOwnPropertyDescriptor$3);
|
3111 |
|
3112 | var _Object$getOwnPropertyDescriptor = /*@__PURE__*/getDefaultExportFromCjs(getOwnPropertyDescriptor$3.exports);
|
3113 |
|
3114 | var getOwnPropertyDescriptors$2 = {exports: {}};
|
3115 |
|
3116 | var getBuiltIn$2 = getBuiltIn$9;
|
3117 | var uncurryThis$c = functionUncurryThis;
|
3118 | var getOwnPropertyNamesModule$1 = objectGetOwnPropertyNames;
|
3119 | var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
|
3120 | var anObject$4 = anObject$b;
|
3121 | var concat$5 = uncurryThis$c([].concat); // all object keys, includes non-enumerable and symbols
|
3122 |
|
3123 | var ownKeys$7 = getBuiltIn$2('Reflect', 'ownKeys') || function ownKeys(it) {
|
3124 | var keys = getOwnPropertyNamesModule$1.f(anObject$4(it));
|
3125 | var getOwnPropertySymbols = getOwnPropertySymbolsModule$1.f;
|
3126 | return getOwnPropertySymbols ? concat$5(keys, getOwnPropertySymbols(it)) : keys;
|
3127 | };
|
3128 |
|
3129 | var $$s = _export;
|
3130 | var DESCRIPTORS$6 = descriptors;
|
3131 | var ownKeys$6 = ownKeys$7;
|
3132 | var toIndexedObject$2 = toIndexedObject$b;
|
3133 | var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
|
3134 | var createProperty$3 = createProperty$6; // `Object.getOwnPropertyDescriptors` method
|
3135 | // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
|
3136 |
|
3137 | $$s({
|
3138 | target: 'Object',
|
3139 | stat: true,
|
3140 | sham: !DESCRIPTORS$6
|
3141 | }, {
|
3142 | getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
|
3143 | var O = toIndexedObject$2(object);
|
3144 | var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
|
3145 | var keys = ownKeys$6(O);
|
3146 | var result = {};
|
3147 | var index = 0;
|
3148 | var key, descriptor;
|
3149 |
|
3150 | while (keys.length > index) {
|
3151 | descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
|
3152 | if (descriptor !== undefined) createProperty$3(result, key, descriptor);
|
3153 | }
|
3154 |
|
3155 | return result;
|
3156 | }
|
3157 | });
|
3158 |
|
3159 | var path$c = path$r;
|
3160 | var getOwnPropertyDescriptors$1 = path$c.Object.getOwnPropertyDescriptors;
|
3161 |
|
3162 | var parent$A = getOwnPropertyDescriptors$1;
|
3163 | var getOwnPropertyDescriptors = parent$A;
|
3164 |
|
3165 | (function (module) {
|
3166 | module.exports = getOwnPropertyDescriptors;
|
3167 | })(getOwnPropertyDescriptors$2);
|
3168 |
|
3169 | var _Object$getOwnPropertyDescriptors = /*@__PURE__*/getDefaultExportFromCjs(getOwnPropertyDescriptors$2.exports);
|
3170 |
|
3171 | var defineProperties$4 = {exports: {}};
|
3172 |
|
3173 | var defineProperties$3 = {exports: {}};
|
3174 |
|
3175 | var $$r = _export;
|
3176 | var DESCRIPTORS$5 = descriptors;
|
3177 | var defineProperties$2 = objectDefineProperties.f; // `Object.defineProperties` method
|
3178 | // https://tc39.es/ecma262/#sec-object.defineproperties
|
3179 | // eslint-disable-next-line es/no-object-defineproperties -- safe
|
3180 |
|
3181 | $$r({
|
3182 | target: 'Object',
|
3183 | stat: true,
|
3184 | forced: Object.defineProperties !== defineProperties$2,
|
3185 | sham: !DESCRIPTORS$5
|
3186 | }, {
|
3187 | defineProperties: defineProperties$2
|
3188 | });
|
3189 |
|
3190 | var path$b = path$r;
|
3191 | var Object$1 = path$b.Object;
|
3192 |
|
3193 | var defineProperties$1 = defineProperties$3.exports = function defineProperties(T, D) {
|
3194 | return Object$1.defineProperties(T, D);
|
3195 | };
|
3196 |
|
3197 | if (Object$1.defineProperties.sham) defineProperties$1.sham = true;
|
3198 |
|
3199 | var parent$z = defineProperties$3.exports;
|
3200 | var defineProperties = parent$z;
|
3201 |
|
3202 | (function (module) {
|
3203 | module.exports = defineProperties;
|
3204 | })(defineProperties$4);
|
3205 |
|
3206 | var _Object$defineProperties = /*@__PURE__*/getDefaultExportFromCjs(defineProperties$4.exports);
|
3207 |
|
3208 | function _defineProperty(obj, key, value) {
|
3209 | if (key in obj) {
|
3210 | _Object$defineProperty$1(obj, key, {
|
3211 | value: value,
|
3212 | enumerable: true,
|
3213 | configurable: true,
|
3214 | writable: true
|
3215 | });
|
3216 | } else {
|
3217 | obj[key] = value;
|
3218 | }
|
3219 |
|
3220 | return obj;
|
3221 | }
|
3222 |
|
3223 | var map$3 = {exports: {}};
|
3224 |
|
3225 | var $$q = _export;
|
3226 | var $map = arrayIteration.map;
|
3227 | var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5;
|
3228 | var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$2('map'); // `Array.prototype.map` method
|
3229 | // https://tc39.es/ecma262/#sec-array.prototype.map
|
3230 | // with adding support of @@species
|
3231 |
|
3232 | $$q({
|
3233 | target: 'Array',
|
3234 | proto: true,
|
3235 | forced: !HAS_SPECIES_SUPPORT$2
|
3236 | }, {
|
3237 | map: function map(callbackfn
|
3238 | /* , thisArg */
|
3239 | ) {
|
3240 | return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
3241 | }
|
3242 | });
|
3243 |
|
3244 | var entryVirtual$g = entryVirtual$k;
|
3245 | var map$2 = entryVirtual$g('Array').map;
|
3246 |
|
3247 | var isPrototypeOf$h = objectIsPrototypeOf;
|
3248 | var method$e = map$2;
|
3249 | var ArrayPrototype$e = Array.prototype;
|
3250 |
|
3251 | var map$1 = function (it) {
|
3252 | var own = it.map;
|
3253 | return it === ArrayPrototype$e || isPrototypeOf$h(ArrayPrototype$e, it) && own === ArrayPrototype$e.map ? method$e : own;
|
3254 | };
|
3255 |
|
3256 | var parent$y = map$1;
|
3257 | var map = parent$y;
|
3258 |
|
3259 | (function (module) {
|
3260 | module.exports = map;
|
3261 | })(map$3);
|
3262 |
|
3263 | var _mapInstanceProperty = /*@__PURE__*/getDefaultExportFromCjs(map$3.exports);
|
3264 |
|
3265 | var reduce$3 = {exports: {}};
|
3266 |
|
3267 | var global$f = global$N;
|
3268 | var aCallable$2 = aCallable$6;
|
3269 | var toObject$6 = toObject$d;
|
3270 | var IndexedObject$1 = indexedObject;
|
3271 | var lengthOfArrayLike$6 = lengthOfArrayLike$b;
|
3272 | var TypeError$6 = global$f.TypeError; // `Array.prototype.{ reduce, reduceRight }` methods implementation
|
3273 |
|
3274 | var createMethod$2 = function (IS_RIGHT) {
|
3275 | return function (that, callbackfn, argumentsLength, memo) {
|
3276 | aCallable$2(callbackfn);
|
3277 | var O = toObject$6(that);
|
3278 | var self = IndexedObject$1(O);
|
3279 | var length = lengthOfArrayLike$6(O);
|
3280 | var index = IS_RIGHT ? length - 1 : 0;
|
3281 | var i = IS_RIGHT ? -1 : 1;
|
3282 | if (argumentsLength < 2) while (true) {
|
3283 | if (index in self) {
|
3284 | memo = self[index];
|
3285 | index += i;
|
3286 | break;
|
3287 | }
|
3288 |
|
3289 | index += i;
|
3290 |
|
3291 | if (IS_RIGHT ? index < 0 : length <= index) {
|
3292 | throw TypeError$6('Reduce of empty array with no initial value');
|
3293 | }
|
3294 | }
|
3295 |
|
3296 | for (; IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
|
3297 | memo = callbackfn(memo, self[index], index, O);
|
3298 | }
|
3299 |
|
3300 | return memo;
|
3301 | };
|
3302 | };
|
3303 |
|
3304 | var arrayReduce = {
|
3305 | // `Array.prototype.reduce` method
|
3306 | // https://tc39.es/ecma262/#sec-array.prototype.reduce
|
3307 | left: createMethod$2(false),
|
3308 | // `Array.prototype.reduceRight` method
|
3309 | // https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
3310 | right: createMethod$2(true)
|
3311 | };
|
3312 |
|
3313 | var classof$3 = classofRaw$1;
|
3314 | var global$e = global$N;
|
3315 | var engineIsNode = classof$3(global$e.process) == 'process';
|
3316 |
|
3317 | var $$p = _export;
|
3318 | var $reduce = arrayReduce.left;
|
3319 | var arrayMethodIsStrict$4 = arrayMethodIsStrict$6;
|
3320 | var CHROME_VERSION = engineV8Version;
|
3321 | var IS_NODE = engineIsNode;
|
3322 | var STRICT_METHOD$4 = arrayMethodIsStrict$4('reduce'); // Chrome 80-82 has a critical bug
|
3323 | // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
3324 |
|
3325 | var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; // `Array.prototype.reduce` method
|
3326 | // https://tc39.es/ecma262/#sec-array.prototype.reduce
|
3327 |
|
3328 | $$p({
|
3329 | target: 'Array',
|
3330 | proto: true,
|
3331 | forced: !STRICT_METHOD$4 || CHROME_BUG
|
3332 | }, {
|
3333 | reduce: function reduce(callbackfn
|
3334 | /* , initialValue */
|
3335 | ) {
|
3336 | var length = arguments.length;
|
3337 | return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
|
3338 | }
|
3339 | });
|
3340 |
|
3341 | var entryVirtual$f = entryVirtual$k;
|
3342 | var reduce$2 = entryVirtual$f('Array').reduce;
|
3343 |
|
3344 | var isPrototypeOf$g = objectIsPrototypeOf;
|
3345 | var method$d = reduce$2;
|
3346 | var ArrayPrototype$d = Array.prototype;
|
3347 |
|
3348 | var reduce$1 = function (it) {
|
3349 | var own = it.reduce;
|
3350 | return it === ArrayPrototype$d || isPrototypeOf$g(ArrayPrototype$d, it) && own === ArrayPrototype$d.reduce ? method$d : own;
|
3351 | };
|
3352 |
|
3353 | var parent$x = reduce$1;
|
3354 | var reduce = parent$x;
|
3355 |
|
3356 | (function (module) {
|
3357 | module.exports = reduce;
|
3358 | })(reduce$3);
|
3359 |
|
3360 | var _reduceInstanceProperty = /*@__PURE__*/getDefaultExportFromCjs(reduce$3.exports);
|
3361 |
|
3362 | var keys$2 = {exports: {}};
|
3363 |
|
3364 | var $$o = _export;
|
3365 | var toObject$5 = toObject$d;
|
3366 | var nativeKeys = objectKeys$4;
|
3367 | var fails$a = fails$s;
|
3368 | var FAILS_ON_PRIMITIVES$1 = fails$a(function () {
|
3369 | nativeKeys(1);
|
3370 | }); // `Object.keys` method
|
3371 | // https://tc39.es/ecma262/#sec-object.keys
|
3372 |
|
3373 | $$o({
|
3374 | target: 'Object',
|
3375 | stat: true,
|
3376 | forced: FAILS_ON_PRIMITIVES$1
|
3377 | }, {
|
3378 | keys: function keys(it) {
|
3379 | return nativeKeys(toObject$5(it));
|
3380 | }
|
3381 | });
|
3382 |
|
3383 | var path$a = path$r;
|
3384 | var keys$1 = path$a.Object.keys;
|
3385 |
|
3386 | var parent$w = keys$1;
|
3387 | var keys = parent$w;
|
3388 |
|
3389 | (function (module) {
|
3390 | module.exports = keys;
|
3391 | })(keys$2);
|
3392 |
|
3393 | var _Object$keys = /*@__PURE__*/getDefaultExportFromCjs(keys$2.exports);
|
3394 |
|
3395 | var defineProperty$4 = {exports: {}};
|
3396 |
|
3397 | (function (module) {
|
3398 | module.exports = defineProperty$9;
|
3399 | })(defineProperty$4);
|
3400 |
|
3401 | var _Object$defineProperty = /*@__PURE__*/getDefaultExportFromCjs(defineProperty$4.exports);
|
3402 |
|
3403 | var from$6 = {exports: {}};
|
3404 |
|
3405 | var call$4 = functionCall;
|
3406 | var anObject$3 = anObject$b;
|
3407 | var getMethod$1 = getMethod$3;
|
3408 |
|
3409 | var iteratorClose$2 = function (iterator, kind, value) {
|
3410 | var innerResult, innerError;
|
3411 | anObject$3(iterator);
|
3412 |
|
3413 | try {
|
3414 | innerResult = getMethod$1(iterator, 'return');
|
3415 |
|
3416 | if (!innerResult) {
|
3417 | if (kind === 'throw') throw value;
|
3418 | return value;
|
3419 | }
|
3420 |
|
3421 | innerResult = call$4(innerResult, iterator);
|
3422 | } catch (error) {
|
3423 | innerError = true;
|
3424 | innerResult = error;
|
3425 | }
|
3426 |
|
3427 | if (kind === 'throw') throw value;
|
3428 | if (innerError) throw innerResult;
|
3429 | anObject$3(innerResult);
|
3430 | return value;
|
3431 | };
|
3432 |
|
3433 | var anObject$2 = anObject$b;
|
3434 | var iteratorClose$1 = iteratorClose$2; // call something on iterator step with safe closing on error
|
3435 |
|
3436 | var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
|
3437 | try {
|
3438 | return ENTRIES ? fn(anObject$2(value)[0], value[1]) : fn(value);
|
3439 | } catch (error) {
|
3440 | iteratorClose$1(iterator, 'throw', error);
|
3441 | }
|
3442 | };
|
3443 |
|
3444 | var wellKnownSymbol$6 = wellKnownSymbol$j;
|
3445 | var Iterators$1 = iterators;
|
3446 | var ITERATOR$4 = wellKnownSymbol$6('iterator');
|
3447 | var ArrayPrototype$c = Array.prototype; // check on default Array iterator
|
3448 |
|
3449 | var isArrayIteratorMethod$2 = function (it) {
|
3450 | return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$c[ITERATOR$4] === it);
|
3451 | };
|
3452 |
|
3453 | var classof$2 = classof$b;
|
3454 | var getMethod = getMethod$3;
|
3455 | var Iterators = iterators;
|
3456 | var wellKnownSymbol$5 = wellKnownSymbol$j;
|
3457 | var ITERATOR$3 = wellKnownSymbol$5('iterator');
|
3458 |
|
3459 | var getIteratorMethod$8 = function (it) {
|
3460 | if (it != undefined) return getMethod(it, ITERATOR$3) || getMethod(it, '@@iterator') || Iterators[classof$2(it)];
|
3461 | };
|
3462 |
|
3463 | var global$d = global$N;
|
3464 | var call$3 = functionCall;
|
3465 | var aCallable$1 = aCallable$6;
|
3466 | var anObject$1 = anObject$b;
|
3467 | var tryToString$1 = tryToString$4;
|
3468 | var getIteratorMethod$7 = getIteratorMethod$8;
|
3469 | var TypeError$5 = global$d.TypeError;
|
3470 |
|
3471 | var getIterator$2 = function (argument, usingIterator) {
|
3472 | var iteratorMethod = arguments.length < 2 ? getIteratorMethod$7(argument) : usingIterator;
|
3473 | if (aCallable$1(iteratorMethod)) return anObject$1(call$3(iteratorMethod, argument));
|
3474 | throw TypeError$5(tryToString$1(argument) + ' is not iterable');
|
3475 | };
|
3476 |
|
3477 | var global$c = global$N;
|
3478 | var bind$2 = functionBindContext;
|
3479 | var call$2 = functionCall;
|
3480 | var toObject$4 = toObject$d;
|
3481 | var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
|
3482 | var isArrayIteratorMethod$1 = isArrayIteratorMethod$2;
|
3483 | var isConstructor$1 = isConstructor$4;
|
3484 | var lengthOfArrayLike$5 = lengthOfArrayLike$b;
|
3485 | var createProperty$2 = createProperty$6;
|
3486 | var getIterator$1 = getIterator$2;
|
3487 | var getIteratorMethod$6 = getIteratorMethod$8;
|
3488 | var Array$3 = global$c.Array; // `Array.from` method implementation
|
3489 | // https://tc39.es/ecma262/#sec-array.from
|
3490 |
|
3491 | var arrayFrom = function from(arrayLike
|
3492 | /* , mapfn = undefined, thisArg = undefined */
|
3493 | ) {
|
3494 | var O = toObject$4(arrayLike);
|
3495 | var IS_CONSTRUCTOR = isConstructor$1(this);
|
3496 | var argumentsLength = arguments.length;
|
3497 | var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
|
3498 | var mapping = mapfn !== undefined;
|
3499 | if (mapping) mapfn = bind$2(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
|
3500 | var iteratorMethod = getIteratorMethod$6(O);
|
3501 | var index = 0;
|
3502 | var length, result, step, iterator, next, value; // if the target is not iterable or it's an array with the default iterator - use a simple case
|
3503 |
|
3504 | if (iteratorMethod && !(this == Array$3 && isArrayIteratorMethod$1(iteratorMethod))) {
|
3505 | iterator = getIterator$1(O, iteratorMethod);
|
3506 | next = iterator.next;
|
3507 | result = IS_CONSTRUCTOR ? new this() : [];
|
3508 |
|
3509 | for (; !(step = call$2(next, iterator)).done; index++) {
|
3510 | value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
|
3511 | createProperty$2(result, index, value);
|
3512 | }
|
3513 | } else {
|
3514 | length = lengthOfArrayLike$5(O);
|
3515 | result = IS_CONSTRUCTOR ? new this(length) : Array$3(length);
|
3516 |
|
3517 | for (; length > index; index++) {
|
3518 | value = mapping ? mapfn(O[index], index) : O[index];
|
3519 | createProperty$2(result, index, value);
|
3520 | }
|
3521 | }
|
3522 |
|
3523 | result.length = index;
|
3524 | return result;
|
3525 | };
|
3526 |
|
3527 | var wellKnownSymbol$4 = wellKnownSymbol$j;
|
3528 | var ITERATOR$2 = wellKnownSymbol$4('iterator');
|
3529 | var SAFE_CLOSING = false;
|
3530 |
|
3531 | try {
|
3532 | var called = 0;
|
3533 | var iteratorWithReturn = {
|
3534 | next: function () {
|
3535 | return {
|
3536 | done: !!called++
|
3537 | };
|
3538 | },
|
3539 | 'return': function () {
|
3540 | SAFE_CLOSING = true;
|
3541 | }
|
3542 | };
|
3543 |
|
3544 | iteratorWithReturn[ITERATOR$2] = function () {
|
3545 | return this;
|
3546 | }; // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
|
3547 |
|
3548 |
|
3549 | Array.from(iteratorWithReturn, function () {
|
3550 | throw 2;
|
3551 | });
|
3552 | } catch (error) {
|
3553 | /* empty */
|
3554 | }
|
3555 |
|
3556 | var checkCorrectnessOfIteration$1 = function (exec, SKIP_CLOSING) {
|
3557 | if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
|
3558 | var ITERATION_SUPPORT = false;
|
3559 |
|
3560 | try {
|
3561 | var object = {};
|
3562 |
|
3563 | object[ITERATOR$2] = function () {
|
3564 | return {
|
3565 | next: function () {
|
3566 | return {
|
3567 | done: ITERATION_SUPPORT = true
|
3568 | };
|
3569 | }
|
3570 | };
|
3571 | };
|
3572 |
|
3573 | exec(object);
|
3574 | } catch (error) {
|
3575 | /* empty */
|
3576 | }
|
3577 |
|
3578 | return ITERATION_SUPPORT;
|
3579 | };
|
3580 |
|
3581 | var $$n = _export;
|
3582 | var from$5 = arrayFrom;
|
3583 | var checkCorrectnessOfIteration = checkCorrectnessOfIteration$1;
|
3584 | var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
|
3585 | // eslint-disable-next-line es/no-array-from -- required for testing
|
3586 | Array.from(iterable);
|
3587 | }); // `Array.from` method
|
3588 | // https://tc39.es/ecma262/#sec-array.from
|
3589 |
|
3590 | $$n({
|
3591 | target: 'Array',
|
3592 | stat: true,
|
3593 | forced: INCORRECT_ITERATION
|
3594 | }, {
|
3595 | from: from$5
|
3596 | });
|
3597 |
|
3598 | var path$9 = path$r;
|
3599 | var from$4 = path$9.Array.from;
|
3600 |
|
3601 | var parent$v = from$4;
|
3602 | var from$3 = parent$v;
|
3603 |
|
3604 | (function (module) {
|
3605 | module.exports = from$3;
|
3606 | })(from$6);
|
3607 |
|
3608 | var _Array$from$1 = /*@__PURE__*/getDefaultExportFromCjs(from$6.exports);
|
3609 |
|
3610 | var getIteratorMethod$5 = {exports: {}};
|
3611 |
|
3612 | var getIteratorMethod$4 = getIteratorMethod$8;
|
3613 | var getIteratorMethod_1 = getIteratorMethod$4;
|
3614 |
|
3615 | var parent$u = getIteratorMethod_1;
|
3616 | var getIteratorMethod$3 = parent$u;
|
3617 |
|
3618 | var parent$t = getIteratorMethod$3;
|
3619 | var getIteratorMethod$2 = parent$t;
|
3620 |
|
3621 | var parent$s = getIteratorMethod$2;
|
3622 | var getIteratorMethod$1 = parent$s;
|
3623 |
|
3624 | (function (module) {
|
3625 | module.exports = getIteratorMethod$1;
|
3626 | })(getIteratorMethod$5);
|
3627 |
|
3628 | var _getIteratorMethod = /*@__PURE__*/getDefaultExportFromCjs(getIteratorMethod$5.exports);
|
3629 |
|
3630 | var isArray$4 = {exports: {}};
|
3631 |
|
3632 | var parent$r = isArray$5;
|
3633 | var isArray$3 = parent$r;
|
3634 |
|
3635 | var parent$q = isArray$3;
|
3636 | var isArray$2 = parent$q;
|
3637 |
|
3638 | (function (module) {
|
3639 | module.exports = isArray$2;
|
3640 | })(isArray$4);
|
3641 |
|
3642 | var _Array$isArray = /*@__PURE__*/getDefaultExportFromCjs(isArray$4.exports);
|
3643 |
|
3644 | function _arrayWithHoles(arr) {
|
3645 | if (_Array$isArray(arr)) return arr;
|
3646 | }
|
3647 |
|
3648 | function _iterableToArrayLimit(arr, i) {
|
3649 | var _i = arr == null ? null : typeof _Symbol$1 !== "undefined" && _getIteratorMethod(arr) || arr["@@iterator"];
|
3650 |
|
3651 | if (_i == null) return;
|
3652 | var _arr = [];
|
3653 | var _n = true;
|
3654 | var _d = false;
|
3655 |
|
3656 | var _s, _e;
|
3657 |
|
3658 | try {
|
3659 | for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
3660 | _arr.push(_s.value);
|
3661 |
|
3662 | if (i && _arr.length === i) break;
|
3663 | }
|
3664 | } catch (err) {
|
3665 | _d = true;
|
3666 | _e = err;
|
3667 | } finally {
|
3668 | try {
|
3669 | if (!_n && _i["return"] != null) _i["return"]();
|
3670 | } finally {
|
3671 | if (_d) throw _e;
|
3672 | }
|
3673 | }
|
3674 |
|
3675 | return _arr;
|
3676 | }
|
3677 |
|
3678 | var slice$6 = {exports: {}};
|
3679 |
|
3680 | var $$m = _export;
|
3681 | var global$b = global$N;
|
3682 | var isArray$1 = isArray$c;
|
3683 | var isConstructor = isConstructor$4;
|
3684 | var isObject$5 = isObject$g;
|
3685 | var toAbsoluteIndex$2 = toAbsoluteIndex$5;
|
3686 | var lengthOfArrayLike$4 = lengthOfArrayLike$b;
|
3687 | var toIndexedObject$1 = toIndexedObject$b;
|
3688 | var createProperty$1 = createProperty$6;
|
3689 | var wellKnownSymbol$3 = wellKnownSymbol$j;
|
3690 | var arrayMethodHasSpeciesSupport$1 = arrayMethodHasSpeciesSupport$5;
|
3691 | var un$Slice = arraySlice$5;
|
3692 | var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport$1('slice');
|
3693 | var SPECIES$1 = wellKnownSymbol$3('species');
|
3694 | var Array$2 = global$b.Array;
|
3695 | var max$1 = Math.max; // `Array.prototype.slice` method
|
3696 | // https://tc39.es/ecma262/#sec-array.prototype.slice
|
3697 | // fallback for not array-like ES3 strings and DOM objects
|
3698 |
|
3699 | $$m({
|
3700 | target: 'Array',
|
3701 | proto: true,
|
3702 | forced: !HAS_SPECIES_SUPPORT$1
|
3703 | }, {
|
3704 | slice: function slice(start, end) {
|
3705 | var O = toIndexedObject$1(this);
|
3706 | var length = lengthOfArrayLike$4(O);
|
3707 | var k = toAbsoluteIndex$2(start, length);
|
3708 | var fin = toAbsoluteIndex$2(end === undefined ? length : end, length); // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
|
3709 |
|
3710 | var Constructor, result, n;
|
3711 |
|
3712 | if (isArray$1(O)) {
|
3713 | Constructor = O.constructor;
|
3714 |
|
3715 | if (isConstructor(Constructor) && (Constructor === Array$2 || isArray$1(Constructor.prototype))) {
|
3716 | Constructor = undefined;
|
3717 | } else if (isObject$5(Constructor)) {
|
3718 | Constructor = Constructor[SPECIES$1];
|
3719 | if (Constructor === null) Constructor = undefined;
|
3720 | }
|
3721 |
|
3722 | if (Constructor === Array$2 || Constructor === undefined) {
|
3723 | return un$Slice(O, k, fin);
|
3724 | }
|
3725 | }
|
3726 |
|
3727 | result = new (Constructor === undefined ? Array$2 : Constructor)(max$1(fin - k, 0));
|
3728 |
|
3729 | for (n = 0; k < fin; k++, n++) if (k in O) createProperty$1(result, n, O[k]);
|
3730 |
|
3731 | result.length = n;
|
3732 | return result;
|
3733 | }
|
3734 | });
|
3735 |
|
3736 | var entryVirtual$e = entryVirtual$k;
|
3737 | var slice$5 = entryVirtual$e('Array').slice;
|
3738 |
|
3739 | var isPrototypeOf$f = objectIsPrototypeOf;
|
3740 | var method$c = slice$5;
|
3741 | var ArrayPrototype$b = Array.prototype;
|
3742 |
|
3743 | var slice$4 = function (it) {
|
3744 | var own = it.slice;
|
3745 | return it === ArrayPrototype$b || isPrototypeOf$f(ArrayPrototype$b, it) && own === ArrayPrototype$b.slice ? method$c : own;
|
3746 | };
|
3747 |
|
3748 | var parent$p = slice$4;
|
3749 | var slice$3 = parent$p;
|
3750 |
|
3751 | var parent$o = slice$3;
|
3752 | var slice$2 = parent$o;
|
3753 |
|
3754 | var parent$n = slice$2;
|
3755 | var slice$1 = parent$n;
|
3756 |
|
3757 | (function (module) {
|
3758 | module.exports = slice$1;
|
3759 | })(slice$6);
|
3760 |
|
3761 | var _sliceInstanceProperty$1 = getDefaultExportFromCjs(slice$6.exports);
|
3762 |
|
3763 | var from$2 = {exports: {}};
|
3764 |
|
3765 | var parent$m = from$3;
|
3766 | var from$1 = parent$m;
|
3767 |
|
3768 | var parent$l = from$1;
|
3769 | var from = parent$l;
|
3770 |
|
3771 | (function (module) {
|
3772 | module.exports = from;
|
3773 | })(from$2);
|
3774 |
|
3775 | var _Array$from = getDefaultExportFromCjs(from$2.exports);
|
3776 |
|
3777 | function _arrayLikeToArray$7(arr, len) {
|
3778 | if (len == null || len > arr.length) len = arr.length;
|
3779 |
|
3780 | for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
3781 | arr2[i] = arr[i];
|
3782 | }
|
3783 |
|
3784 | return arr2;
|
3785 | }
|
3786 |
|
3787 | function _unsupportedIterableToArray$7(o, minLen) {
|
3788 | var _context;
|
3789 |
|
3790 | if (!o) return;
|
3791 | if (typeof o === "string") return _arrayLikeToArray$7(o, minLen);
|
3792 |
|
3793 | var n = _sliceInstanceProperty$1(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
|
3794 |
|
3795 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
3796 | if (n === "Map" || n === "Set") return _Array$from(o);
|
3797 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen);
|
3798 | }
|
3799 |
|
3800 | function _nonIterableRest() {
|
3801 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
3802 | }
|
3803 |
|
3804 | function _slicedToArray(arr, i) {
|
3805 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$7(arr, i) || _nonIterableRest();
|
3806 | }
|
3807 |
|
3808 | function _arrayWithoutHoles(arr) {
|
3809 | if (_Array$isArray(arr)) return _arrayLikeToArray$7(arr);
|
3810 | }
|
3811 |
|
3812 | function _iterableToArray(iter) {
|
3813 | if (typeof _Symbol$1 !== "undefined" && _getIteratorMethod(iter) != null || iter["@@iterator"] != null) return _Array$from(iter);
|
3814 | }
|
3815 |
|
3816 | function _nonIterableSpread() {
|
3817 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
3818 | }
|
3819 |
|
3820 | function _toConsumableArray(arr) {
|
3821 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$7(arr) || _nonIterableSpread();
|
3822 | }
|
3823 |
|
3824 | var symbol = {exports: {}};
|
3825 |
|
3826 | (function (module) {
|
3827 | module.exports = symbol$3;
|
3828 | })(symbol);
|
3829 |
|
3830 | var _Symbol = getDefaultExportFromCjs(symbol.exports);
|
3831 |
|
3832 | var concat$4 = {exports: {}};
|
3833 |
|
3834 | var entryVirtual$d = entryVirtual$k;
|
3835 | var concat$3 = entryVirtual$d('Array').concat;
|
3836 |
|
3837 | var isPrototypeOf$e = objectIsPrototypeOf;
|
3838 | var method$b = concat$3;
|
3839 | var ArrayPrototype$a = Array.prototype;
|
3840 |
|
3841 | var concat$2 = function (it) {
|
3842 | var own = it.concat;
|
3843 | return it === ArrayPrototype$a || isPrototypeOf$e(ArrayPrototype$a, it) && own === ArrayPrototype$a.concat ? method$b : own;
|
3844 | };
|
3845 |
|
3846 | var parent$k = concat$2;
|
3847 | var concat$1 = parent$k;
|
3848 |
|
3849 | (function (module) {
|
3850 | module.exports = concat$1;
|
3851 | })(concat$4);
|
3852 |
|
3853 | var _concatInstanceProperty = getDefaultExportFromCjs(concat$4.exports);
|
3854 |
|
3855 | var slice = {exports: {}};
|
3856 |
|
3857 | (function (module) {
|
3858 | module.exports = slice$3;
|
3859 | })(slice);
|
3860 |
|
3861 | var _sliceInstanceProperty = getDefaultExportFromCjs(slice.exports);
|
3862 |
|
3863 | var ownKeys$5 = {exports: {}};
|
3864 |
|
3865 | var $$l = _export;
|
3866 | var ownKeys$4 = ownKeys$7;
|
3867 |
|
3868 |
|
3869 | $$l({
|
3870 | target: 'Reflect',
|
3871 | stat: true
|
3872 | }, {
|
3873 | ownKeys: ownKeys$4
|
3874 | });
|
3875 |
|
3876 | var path$8 = path$r;
|
3877 | var ownKeys$3 = path$8.Reflect.ownKeys;
|
3878 |
|
3879 | var parent$j = ownKeys$3;
|
3880 | var ownKeys$2 = parent$j;
|
3881 |
|
3882 | (function (module) {
|
3883 | module.exports = ownKeys$2;
|
3884 | })(ownKeys$5);
|
3885 |
|
3886 | var _Reflect$ownKeys = getDefaultExportFromCjs(ownKeys$5.exports);
|
3887 |
|
3888 | var now$3 = {exports: {}};
|
3889 |
|
3890 | var $$k = _export;
|
3891 | var global$a = global$N;
|
3892 | var uncurryThis$b = functionUncurryThis;
|
3893 | var Date$1 = global$a.Date;
|
3894 | var getTime = uncurryThis$b(Date$1.prototype.getTime);
|
3895 |
|
3896 |
|
3897 | $$k({
|
3898 | target: 'Date',
|
3899 | stat: true
|
3900 | }, {
|
3901 | now: function now() {
|
3902 | return getTime(new Date$1());
|
3903 | }
|
3904 | });
|
3905 |
|
3906 | var path$7 = path$r;
|
3907 | var now$2 = path$7.Date.now;
|
3908 |
|
3909 | var parent$i = now$2;
|
3910 | var now$1 = parent$i;
|
3911 |
|
3912 | (function (module) {
|
3913 | module.exports = now$1;
|
3914 | })(now$3);
|
3915 |
|
3916 | var _Date$now = getDefaultExportFromCjs(now$3.exports);
|
3917 |
|
3918 | var reverse$3 = {exports: {}};
|
3919 |
|
3920 | var $$j = _export;
|
3921 | var uncurryThis$a = functionUncurryThis;
|
3922 | var isArray = isArray$c;
|
3923 | var un$Reverse = uncurryThis$a([].reverse);
|
3924 | var test$1 = [1, 2];
|
3925 |
|
3926 |
|
3927 |
|
3928 |
|
3929 | $$j({
|
3930 | target: 'Array',
|
3931 | proto: true,
|
3932 | forced: String(test$1) === String(test$1.reverse())
|
3933 | }, {
|
3934 | reverse: function reverse() {
|
3935 |
|
3936 | if (isArray(this)) this.length = this.length;
|
3937 | return un$Reverse(this);
|
3938 | }
|
3939 | });
|
3940 |
|
3941 | var entryVirtual$c = entryVirtual$k;
|
3942 | var reverse$2 = entryVirtual$c('Array').reverse;
|
3943 |
|
3944 | var isPrototypeOf$d = objectIsPrototypeOf;
|
3945 | var method$a = reverse$2;
|
3946 | var ArrayPrototype$9 = Array.prototype;
|
3947 |
|
3948 | var reverse$1 = function (it) {
|
3949 | var own = it.reverse;
|
3950 | return it === ArrayPrototype$9 || isPrototypeOf$d(ArrayPrototype$9, it) && own === ArrayPrototype$9.reverse ? method$a : own;
|
3951 | };
|
3952 |
|
3953 | var parent$h = reverse$1;
|
3954 | var reverse = parent$h;
|
3955 |
|
3956 | (function (module) {
|
3957 | module.exports = reverse;
|
3958 | })(reverse$3);
|
3959 |
|
3960 | var _reverseInstanceProperty = getDefaultExportFromCjs(reverse$3.exports);
|
3961 |
|
3962 | var splice$3 = {exports: {}};
|
3963 |
|
3964 | var $$i = _export;
|
3965 | var global$9 = global$N;
|
3966 | var toAbsoluteIndex$1 = toAbsoluteIndex$5;
|
3967 | var toIntegerOrInfinity$1 = toIntegerOrInfinity$5;
|
3968 | var lengthOfArrayLike$3 = lengthOfArrayLike$b;
|
3969 | var toObject$3 = toObject$d;
|
3970 | var arraySpeciesCreate = arraySpeciesCreate$3;
|
3971 | var createProperty = createProperty$6;
|
3972 | var arrayMethodHasSpeciesSupport = arrayMethodHasSpeciesSupport$5;
|
3973 | var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
|
3974 | var TypeError$4 = global$9.TypeError;
|
3975 | var max = Math.max;
|
3976 | var min = Math.min;
|
3977 | var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
|
3978 | var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
|
3979 |
|
3980 |
|
3981 |
|
3982 | $$i({
|
3983 | target: 'Array',
|
3984 | proto: true,
|
3985 | forced: !HAS_SPECIES_SUPPORT
|
3986 | }, {
|
3987 | splice: function splice(start, deleteCount
|
3988 | /* , ...items */
|
3989 | ) {
|
3990 | var O = toObject$3(this);
|
3991 | var len = lengthOfArrayLike$3(O);
|
3992 | var actualStart = toAbsoluteIndex$1(start, len);
|
3993 | var argumentsLength = arguments.length;
|
3994 | var insertCount, actualDeleteCount, A, k, from, to;
|
3995 |
|
3996 | if (argumentsLength === 0) {
|
3997 | insertCount = actualDeleteCount = 0;
|
3998 | } else if (argumentsLength === 1) {
|
3999 | insertCount = 0;
|
4000 | actualDeleteCount = len - actualStart;
|
4001 | } else {
|
4002 | insertCount = argumentsLength - 2;
|
4003 | actualDeleteCount = min(max(toIntegerOrInfinity$1(deleteCount), 0), len - actualStart);
|
4004 | }
|
4005 |
|
4006 | if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
|
4007 | throw TypeError$4(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
|
4008 | }
|
4009 |
|
4010 | A = arraySpeciesCreate(O, actualDeleteCount);
|
4011 |
|
4012 | for (k = 0; k < actualDeleteCount; k++) {
|
4013 | from = actualStart + k;
|
4014 | if (from in O) createProperty(A, k, O[from]);
|
4015 | }
|
4016 |
|
4017 | A.length = actualDeleteCount;
|
4018 |
|
4019 | if (insertCount < actualDeleteCount) {
|
4020 | for (k = actualStart; k < len - actualDeleteCount; k++) {
|
4021 | from = k + actualDeleteCount;
|
4022 | to = k + insertCount;
|
4023 | if (from in O) O[to] = O[from];else delete O[to];
|
4024 | }
|
4025 |
|
4026 | for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
|
4027 | } else if (insertCount > actualDeleteCount) {
|
4028 | for (k = len - actualDeleteCount; k > actualStart; k--) {
|
4029 | from = k + actualDeleteCount - 1;
|
4030 | to = k + insertCount - 1;
|
4031 | if (from in O) O[to] = O[from];else delete O[to];
|
4032 | }
|
4033 | }
|
4034 |
|
4035 | for (k = 0; k < insertCount; k++) {
|
4036 | O[k + actualStart] = arguments[k + 2];
|
4037 | }
|
4038 |
|
4039 | O.length = len - actualDeleteCount + insertCount;
|
4040 | return A;
|
4041 | }
|
4042 | });
|
4043 |
|
4044 | var entryVirtual$b = entryVirtual$k;
|
4045 | var splice$2 = entryVirtual$b('Array').splice;
|
4046 |
|
4047 | var isPrototypeOf$c = objectIsPrototypeOf;
|
4048 | var method$9 = splice$2;
|
4049 | var ArrayPrototype$8 = Array.prototype;
|
4050 |
|
4051 | var splice$1 = function (it) {
|
4052 | var own = it.splice;
|
4053 | return it === ArrayPrototype$8 || isPrototypeOf$c(ArrayPrototype$8, it) && own === ArrayPrototype$8.splice ? method$9 : own;
|
4054 | };
|
4055 |
|
4056 | var parent$g = splice$1;
|
4057 | var splice = parent$g;
|
4058 |
|
4059 | (function (module) {
|
4060 | module.exports = splice;
|
4061 | })(splice$3);
|
4062 |
|
4063 | var _spliceInstanceProperty = getDefaultExportFromCjs(splice$3.exports);
|
4064 |
|
4065 | var assign$5 = {exports: {}};
|
4066 |
|
4067 | var DESCRIPTORS$4 = descriptors;
|
4068 | var uncurryThis$9 = functionUncurryThis;
|
4069 | var call$1 = functionCall;
|
4070 | var fails$9 = fails$s;
|
4071 | var objectKeys$1 = objectKeys$4;
|
4072 | var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
|
4073 | var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
4074 | var toObject$2 = toObject$d;
|
4075 | var IndexedObject = indexedObject;
|
4076 |
|
4077 | var $assign = Object.assign;
|
4078 |
|
4079 | var defineProperty$3 = Object.defineProperty;
|
4080 | var concat = uncurryThis$9([].concat);
|
4081 |
|
4082 |
|
4083 | var objectAssign = !$assign || fails$9(function () {
|
4084 |
|
4085 | if (DESCRIPTORS$4 && $assign({
|
4086 | b: 1
|
4087 | }, $assign(defineProperty$3({}, 'a', {
|
4088 | enumerable: true,
|
4089 | get: function () {
|
4090 | defineProperty$3(this, 'b', {
|
4091 | value: 3,
|
4092 | enumerable: false
|
4093 | });
|
4094 | }
|
4095 | }), {
|
4096 | b: 2
|
4097 | })).b !== 1) return true;
|
4098 |
|
4099 | var A = {};
|
4100 | var B = {};
|
4101 |
|
4102 | var symbol = Symbol();
|
4103 | var alphabet = 'abcdefghijklmnopqrst';
|
4104 | A[symbol] = 7;
|
4105 | alphabet.split('').forEach(function (chr) {
|
4106 | B[chr] = chr;
|
4107 | });
|
4108 | return $assign({}, A)[symbol] != 7 || objectKeys$1($assign({}, B)).join('') != alphabet;
|
4109 | }) ? function assign(target, source) {
|
4110 |
|
4111 | var T = toObject$2(target);
|
4112 | var argumentsLength = arguments.length;
|
4113 | var index = 1;
|
4114 | var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
4115 | var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
4116 |
|
4117 | while (argumentsLength > index) {
|
4118 | var S = IndexedObject(arguments[index++]);
|
4119 | var keys = getOwnPropertySymbols ? concat(objectKeys$1(S), getOwnPropertySymbols(S)) : objectKeys$1(S);
|
4120 | var length = keys.length;
|
4121 | var j = 0;
|
4122 | var key;
|
4123 |
|
4124 | while (length > j) {
|
4125 | key = keys[j++];
|
4126 | if (!DESCRIPTORS$4 || call$1(propertyIsEnumerable, S, key)) T[key] = S[key];
|
4127 | }
|
4128 | }
|
4129 |
|
4130 | return T;
|
4131 | } : $assign;
|
4132 |
|
4133 | var $$h = _export;
|
4134 | var assign$4 = objectAssign;
|
4135 |
|
4136 |
|
4137 |
|
4138 | $$h({
|
4139 | target: 'Object',
|
4140 | stat: true,
|
4141 | forced: Object.assign !== assign$4
|
4142 | }, {
|
4143 | assign: assign$4
|
4144 | });
|
4145 |
|
4146 | var path$6 = path$r;
|
4147 | var assign$3 = path$6.Object.assign;
|
4148 |
|
4149 | var parent$f = assign$3;
|
4150 | var assign$2 = parent$f;
|
4151 |
|
4152 | (function (module) {
|
4153 | module.exports = assign$2;
|
4154 | })(assign$5);
|
4155 |
|
4156 | var _Object$assign = getDefaultExportFromCjs(assign$5.exports);
|
4157 |
|
4158 | var includes$4 = {exports: {}};
|
4159 |
|
4160 | var $$g = _export;
|
4161 | var $includes = arrayIncludes.includes;
|
4162 |
|
4163 |
|
4164 | $$g({
|
4165 | target: 'Array',
|
4166 | proto: true
|
4167 | }, {
|
4168 | includes: function includes(el
|
4169 | /* , fromIndex = 0 */
|
4170 | ) {
|
4171 | return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
4172 | }
|
4173 | });
|
4174 |
|
4175 | var entryVirtual$a = entryVirtual$k;
|
4176 | var includes$3 = entryVirtual$a('Array').includes;
|
4177 |
|
4178 | var isObject$4 = isObject$g;
|
4179 | var classof$1 = classofRaw$1;
|
4180 | var wellKnownSymbol$2 = wellKnownSymbol$j;
|
4181 | var MATCH$1 = wellKnownSymbol$2('match');
|
4182 |
|
4183 |
|
4184 | var isRegexp = function (it) {
|
4185 | var isRegExp;
|
4186 | return isObject$4(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
|
4187 | };
|
4188 |
|
4189 | var global$8 = global$N;
|
4190 | var isRegExp = isRegexp;
|
4191 | var TypeError$3 = global$8.TypeError;
|
4192 |
|
4193 | var notARegexp = function (it) {
|
4194 | if (isRegExp(it)) {
|
4195 | throw TypeError$3("The method doesn't accept regular expressions");
|
4196 | }
|
4197 |
|
4198 | return it;
|
4199 | };
|
4200 |
|
4201 | var wellKnownSymbol$1 = wellKnownSymbol$j;
|
4202 | var MATCH = wellKnownSymbol$1('match');
|
4203 |
|
4204 | var correctIsRegexpLogic = function (METHOD_NAME) {
|
4205 | var regexp = /./;
|
4206 |
|
4207 | try {
|
4208 | '/./'[METHOD_NAME](regexp);
|
4209 | } catch (error1) {
|
4210 | try {
|
4211 | regexp[MATCH] = false;
|
4212 | return '/./'[METHOD_NAME](regexp);
|
4213 | } catch (error2) {
|
4214 |
|
4215 | }
|
4216 | }
|
4217 |
|
4218 | return false;
|
4219 | };
|
4220 |
|
4221 | var $$f = _export;
|
4222 | var uncurryThis$8 = functionUncurryThis;
|
4223 | var notARegExp = notARegexp;
|
4224 | var requireObjectCoercible$2 = requireObjectCoercible$6;
|
4225 | var toString$5 = toString$9;
|
4226 | var correctIsRegExpLogic = correctIsRegexpLogic;
|
4227 | var stringIndexOf = uncurryThis$8(''.indexOf);
|
4228 |
|
4229 |
|
4230 | $$f({
|
4231 | target: 'String',
|
4232 | proto: true,
|
4233 | forced: !correctIsRegExpLogic('includes')
|
4234 | }, {
|
4235 | includes: function includes(searchString
|
4236 | /* , position = 0 */
|
4237 | ) {
|
4238 | return !!~stringIndexOf(toString$5(requireObjectCoercible$2(this)), toString$5(notARegExp(searchString)), arguments.length > 1 ? arguments[1] : undefined);
|
4239 | }
|
4240 | });
|
4241 |
|
4242 | var entryVirtual$9 = entryVirtual$k;
|
4243 | var includes$2 = entryVirtual$9('String').includes;
|
4244 |
|
4245 | var isPrototypeOf$b = objectIsPrototypeOf;
|
4246 | var arrayMethod = includes$3;
|
4247 | var stringMethod = includes$2;
|
4248 | var ArrayPrototype$7 = Array.prototype;
|
4249 | var StringPrototype$2 = String.prototype;
|
4250 |
|
4251 | var includes$1 = function (it) {
|
4252 | var own = it.includes;
|
4253 | if (it === ArrayPrototype$7 || isPrototypeOf$b(ArrayPrototype$7, it) && own === ArrayPrototype$7.includes) return arrayMethod;
|
4254 |
|
4255 | if (typeof it == 'string' || it === StringPrototype$2 || isPrototypeOf$b(StringPrototype$2, it) && own === StringPrototype$2.includes) {
|
4256 | return stringMethod;
|
4257 | }
|
4258 |
|
4259 | return own;
|
4260 | };
|
4261 |
|
4262 | var parent$e = includes$1;
|
4263 | var includes = parent$e;
|
4264 |
|
4265 | (function (module) {
|
4266 | module.exports = includes;
|
4267 | })(includes$4);
|
4268 |
|
4269 | var _includesInstanceProperty = getDefaultExportFromCjs(includes$4.exports);
|
4270 |
|
4271 | var getPrototypeOf = {exports: {}};
|
4272 |
|
4273 | (function (module) {
|
4274 | module.exports = getPrototypeOf$3;
|
4275 | })(getPrototypeOf);
|
4276 |
|
4277 | var _Object$getPrototypeOf = getDefaultExportFromCjs(getPrototypeOf.exports);
|
4278 |
|
4279 | var values$2 = {exports: {}};
|
4280 |
|
4281 | var DESCRIPTORS$3 = descriptors;
|
4282 | var uncurryThis$7 = functionUncurryThis;
|
4283 | var objectKeys = objectKeys$4;
|
4284 | var toIndexedObject = toIndexedObject$b;
|
4285 | var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
4286 | var propertyIsEnumerable = uncurryThis$7($propertyIsEnumerable);
|
4287 | var push$1 = uncurryThis$7([].push);
|
4288 |
|
4289 | var createMethod$1 = function (TO_ENTRIES) {
|
4290 | return function (it) {
|
4291 | var O = toIndexedObject(it);
|
4292 | var keys = objectKeys(O);
|
4293 | var length = keys.length;
|
4294 | var i = 0;
|
4295 | var result = [];
|
4296 | var key;
|
4297 |
|
4298 | while (length > i) {
|
4299 | key = keys[i++];
|
4300 |
|
4301 | if (!DESCRIPTORS$3 || propertyIsEnumerable(O, key)) {
|
4302 | push$1(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
4303 | }
|
4304 | }
|
4305 |
|
4306 | return result;
|
4307 | };
|
4308 | };
|
4309 |
|
4310 | var objectToArray = {
|
4311 |
|
4312 |
|
4313 | entries: createMethod$1(true),
|
4314 |
|
4315 |
|
4316 | values: createMethod$1(false)
|
4317 | };
|
4318 |
|
4319 | var $$e = _export;
|
4320 | var $values = objectToArray.values;
|
4321 |
|
4322 |
|
4323 | $$e({
|
4324 | target: 'Object',
|
4325 | stat: true
|
4326 | }, {
|
4327 | values: function values(O) {
|
4328 | return $values(O);
|
4329 | }
|
4330 | });
|
4331 |
|
4332 | var path$5 = path$r;
|
4333 | var values$1 = path$5.Object.values;
|
4334 |
|
4335 | var parent$d = values$1;
|
4336 | var values = parent$d;
|
4337 |
|
4338 | (function (module) {
|
4339 | module.exports = values;
|
4340 | })(values$2);
|
4341 |
|
4342 | var _Object$values2 = getDefaultExportFromCjs(values$2.exports);
|
4343 |
|
4344 | var _parseInt$3 = {exports: {}};
|
4345 |
|
4346 | var whitespaces$4 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
4347 |
|
4348 | var uncurryThis$6 = functionUncurryThis;
|
4349 | var requireObjectCoercible$1 = requireObjectCoercible$6;
|
4350 | var toString$4 = toString$9;
|
4351 | var whitespaces$3 = whitespaces$4;
|
4352 | var replace$1 = uncurryThis$6(''.replace);
|
4353 | var whitespace = '[' + whitespaces$3 + ']';
|
4354 | var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
4355 | var rtrim = RegExp(whitespace + whitespace + '*$');
|
4356 |
|
4357 | var createMethod = function (TYPE) {
|
4358 | return function ($this) {
|
4359 | var string = toString$4(requireObjectCoercible$1($this));
|
4360 | if (TYPE & 1) string = replace$1(string, ltrim, '');
|
4361 | if (TYPE & 2) string = replace$1(string, rtrim, '');
|
4362 | return string;
|
4363 | };
|
4364 | };
|
4365 |
|
4366 | var stringTrim = {
|
4367 |
|
4368 |
|
4369 | start: createMethod(1),
|
4370 |
|
4371 |
|
4372 | end: createMethod(2),
|
4373 |
|
4374 |
|
4375 | trim: createMethod(3)
|
4376 | };
|
4377 |
|
4378 | var global$7 = global$N;
|
4379 | var fails$8 = fails$s;
|
4380 | var uncurryThis$5 = functionUncurryThis;
|
4381 | var toString$3 = toString$9;
|
4382 | var trim$5 = stringTrim.trim;
|
4383 | var whitespaces$2 = whitespaces$4;
|
4384 | var $parseInt$1 = global$7.parseInt;
|
4385 | var Symbol$2 = global$7.Symbol;
|
4386 | var ITERATOR$1 = Symbol$2 && Symbol$2.iterator;
|
4387 | var hex = /^[+-]?0x/i;
|
4388 | var exec$1 = uncurryThis$5(hex.exec);
|
4389 | var FORCED$3 = $parseInt$1(whitespaces$2 + '08') !== 8 || $parseInt$1(whitespaces$2 + '0x16') !== 22
|
4390 | || ITERATOR$1 && !fails$8(function () {
|
4391 | $parseInt$1(Object(ITERATOR$1));
|
4392 | });
|
4393 |
|
4394 |
|
4395 | var numberParseInt = FORCED$3 ? function parseInt(string, radix) {
|
4396 | var S = trim$5(toString$3(string));
|
4397 | return $parseInt$1(S, radix >>> 0 || (exec$1(hex, S) ? 16 : 10));
|
4398 | } : $parseInt$1;
|
4399 |
|
4400 | var $$d = _export;
|
4401 | var $parseInt = numberParseInt;
|
4402 |
|
4403 |
|
4404 | $$d({
|
4405 | global: true,
|
4406 | forced: parseInt != $parseInt
|
4407 | }, {
|
4408 | parseInt: $parseInt
|
4409 | });
|
4410 |
|
4411 | var path$4 = path$r;
|
4412 | var _parseInt$2 = path$4.parseInt;
|
4413 |
|
4414 | var parent$c = _parseInt$2;
|
4415 | var _parseInt$1 = parent$c;
|
4416 |
|
4417 | (function (module) {
|
4418 | module.exports = _parseInt$1;
|
4419 | })(_parseInt$3);
|
4420 |
|
4421 | var _parseInt = getDefaultExportFromCjs(_parseInt$3.exports);
|
4422 |
|
4423 | var indexOf$3 = {exports: {}};
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 | var $$c = _export;
|
4429 | var uncurryThis$4 = functionUncurryThis;
|
4430 | var $IndexOf = arrayIncludes.indexOf;
|
4431 | var arrayMethodIsStrict$3 = arrayMethodIsStrict$6;
|
4432 | var un$IndexOf = uncurryThis$4([].indexOf);
|
4433 | var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0;
|
4434 | var STRICT_METHOD$3 = arrayMethodIsStrict$3('indexOf');
|
4435 |
|
4436 |
|
4437 | $$c({
|
4438 | target: 'Array',
|
4439 | proto: true,
|
4440 | forced: NEGATIVE_ZERO || !STRICT_METHOD$3
|
4441 | }, {
|
4442 | indexOf: function indexOf(searchElement
|
4443 | /* , fromIndex = 0 */
|
4444 | ) {
|
4445 | var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
|
4446 | return NEGATIVE_ZERO
|
4447 | ? un$IndexOf(this, searchElement, fromIndex) || 0 : $IndexOf(this, searchElement, fromIndex);
|
4448 | }
|
4449 | });
|
4450 |
|
4451 | var entryVirtual$8 = entryVirtual$k;
|
4452 | var indexOf$2 = entryVirtual$8('Array').indexOf;
|
4453 |
|
4454 | var isPrototypeOf$a = objectIsPrototypeOf;
|
4455 | var method$8 = indexOf$2;
|
4456 | var ArrayPrototype$6 = Array.prototype;
|
4457 |
|
4458 | var indexOf$1 = function (it) {
|
4459 | var own = it.indexOf;
|
4460 | return it === ArrayPrototype$6 || isPrototypeOf$a(ArrayPrototype$6, it) && own === ArrayPrototype$6.indexOf ? method$8 : own;
|
4461 | };
|
4462 |
|
4463 | var parent$b = indexOf$1;
|
4464 | var indexOf = parent$b;
|
4465 |
|
4466 | (function (module) {
|
4467 | module.exports = indexOf;
|
4468 | })(indexOf$3);
|
4469 |
|
4470 | var _indexOfInstanceProperty = getDefaultExportFromCjs(indexOf$3.exports);
|
4471 |
|
4472 | var trim$4 = {exports: {}};
|
4473 |
|
4474 | var PROPER_FUNCTION_NAME = functionName.PROPER;
|
4475 | var fails$7 = fails$s;
|
4476 | var whitespaces$1 = whitespaces$4;
|
4477 | var non = '\u200B\u0085\u180E';
|
4478 |
|
4479 |
|
4480 | var stringTrimForced = function (METHOD_NAME) {
|
4481 | return fails$7(function () {
|
4482 | return !!whitespaces$1[METHOD_NAME]() || non[METHOD_NAME]() !== non || PROPER_FUNCTION_NAME && whitespaces$1[METHOD_NAME].name !== METHOD_NAME;
|
4483 | });
|
4484 | };
|
4485 |
|
4486 | var $$b = _export;
|
4487 | var $trim = stringTrim.trim;
|
4488 | var forcedStringTrimMethod = stringTrimForced;
|
4489 |
|
4490 |
|
4491 | $$b({
|
4492 | target: 'String',
|
4493 | proto: true,
|
4494 | forced: forcedStringTrimMethod('trim')
|
4495 | }, {
|
4496 | trim: function trim() {
|
4497 | return $trim(this);
|
4498 | }
|
4499 | });
|
4500 |
|
4501 | var entryVirtual$7 = entryVirtual$k;
|
4502 | var trim$3 = entryVirtual$7('String').trim;
|
4503 |
|
4504 | var isPrototypeOf$9 = objectIsPrototypeOf;
|
4505 | var method$7 = trim$3;
|
4506 | var StringPrototype$1 = String.prototype;
|
4507 |
|
4508 | var trim$2 = function (it) {
|
4509 | var own = it.trim;
|
4510 | return typeof it == 'string' || it === StringPrototype$1 || isPrototypeOf$9(StringPrototype$1, it) && own === StringPrototype$1.trim ? method$7 : own;
|
4511 | };
|
4512 |
|
4513 | var parent$a = trim$2;
|
4514 | var trim$1 = parent$a;
|
4515 |
|
4516 | (function (module) {
|
4517 | module.exports = trim$1;
|
4518 | })(trim$4);
|
4519 |
|
4520 | var _trimInstanceProperty = getDefaultExportFromCjs(trim$4.exports);
|
4521 |
|
4522 | var create$1 = {exports: {}};
|
4523 |
|
4524 | (function (module) {
|
4525 | module.exports = create$6;
|
4526 | })(create$1);
|
4527 |
|
4528 | var _Object$create = getDefaultExportFromCjs(create$1.exports);
|
4529 |
|
4530 | var stringify$2 = {exports: {}};
|
4531 |
|
4532 | var $$a = _export;
|
4533 | var global$6 = global$N;
|
4534 | var getBuiltIn$1 = getBuiltIn$9;
|
4535 | var apply$1 = functionApply;
|
4536 | var uncurryThis$3 = functionUncurryThis;
|
4537 | var fails$6 = fails$s;
|
4538 | var Array$1 = global$6.Array;
|
4539 | var $stringify = getBuiltIn$1('JSON', 'stringify');
|
4540 | var exec = uncurryThis$3(/./.exec);
|
4541 | var charAt$1 = uncurryThis$3(''.charAt);
|
4542 | var charCodeAt = uncurryThis$3(''.charCodeAt);
|
4543 | var replace = uncurryThis$3(''.replace);
|
4544 | var numberToString = uncurryThis$3(1.0.toString);
|
4545 | var tester = /[\uD800-\uDFFF]/g;
|
4546 | var low = /^[\uD800-\uDBFF]$/;
|
4547 | var hi = /^[\uDC00-\uDFFF]$/;
|
4548 |
|
4549 | var fix = function (match, offset, string) {
|
4550 | var prev = charAt$1(string, offset - 1);
|
4551 | var next = charAt$1(string, offset + 1);
|
4552 |
|
4553 | if (exec(low, match) && !exec(hi, next) || exec(hi, match) && !exec(low, prev)) {
|
4554 | return '\\u' + numberToString(charCodeAt(match, 0), 16);
|
4555 | }
|
4556 |
|
4557 | return match;
|
4558 | };
|
4559 |
|
4560 | var FORCED$2 = fails$6(function () {
|
4561 | return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' || $stringify('\uDEAD') !== '"\\udead"';
|
4562 | });
|
4563 |
|
4564 | if ($stringify) {
|
4565 |
|
4566 |
|
4567 |
|
4568 | $$a({
|
4569 | target: 'JSON',
|
4570 | stat: true,
|
4571 | forced: FORCED$2
|
4572 | }, {
|
4573 |
|
4574 | stringify: function stringify(it, replacer, space) {
|
4575 | for (var i = 0, l = arguments.length, args = Array$1(l); i < l; i++) args[i] = arguments[i];
|
4576 |
|
4577 | var result = apply$1($stringify, null, args);
|
4578 | return typeof result == 'string' ? replace(result, tester, fix) : result;
|
4579 | }
|
4580 | });
|
4581 | }
|
4582 |
|
4583 | var path$3 = path$r;
|
4584 | var apply = functionApply;
|
4585 |
|
4586 | if (!path$3.JSON) path$3.JSON = {
|
4587 | stringify: JSON.stringify
|
4588 | };
|
4589 |
|
4590 | var stringify$1 = function stringify(it, replacer, space) {
|
4591 | return apply(path$3.JSON.stringify, null, arguments);
|
4592 | };
|
4593 |
|
4594 | var parent$9 = stringify$1;
|
4595 | var stringify = parent$9;
|
4596 |
|
4597 | (function (module) {
|
4598 | module.exports = stringify;
|
4599 | })(stringify$2);
|
4600 |
|
4601 | var _JSON$stringify = getDefaultExportFromCjs(stringify$2.exports);
|
4602 |
|
4603 | var fill$4 = {exports: {}};
|
4604 |
|
4605 | var toObject$1 = toObject$d;
|
4606 | var toAbsoluteIndex = toAbsoluteIndex$5;
|
4607 | var lengthOfArrayLike$2 = lengthOfArrayLike$b;
|
4608 |
|
4609 |
|
4610 | var arrayFill = function fill(value
|
4611 | /* , start = 0, end = @length */
|
4612 | ) {
|
4613 | var O = toObject$1(this);
|
4614 | var length = lengthOfArrayLike$2(O);
|
4615 | var argumentsLength = arguments.length;
|
4616 | var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
|
4617 | var end = argumentsLength > 2 ? arguments[2] : undefined;
|
4618 | var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
|
4619 |
|
4620 | while (endPos > index) O[index++] = value;
|
4621 |
|
4622 | return O;
|
4623 | };
|
4624 |
|
4625 | var $$9 = _export;
|
4626 | var fill$3 = arrayFill;
|
4627 |
|
4628 |
|
4629 | $$9({
|
4630 | target: 'Array',
|
4631 | proto: true
|
4632 | }, {
|
4633 | fill: fill$3
|
4634 | });
|
4635 |
|
4636 | var entryVirtual$6 = entryVirtual$k;
|
4637 | var fill$2 = entryVirtual$6('Array').fill;
|
4638 |
|
4639 | var isPrototypeOf$8 = objectIsPrototypeOf;
|
4640 | var method$6 = fill$2;
|
4641 | var ArrayPrototype$5 = Array.prototype;
|
4642 |
|
4643 | var fill$1 = function (it) {
|
4644 | var own = it.fill;
|
4645 | return it === ArrayPrototype$5 || isPrototypeOf$8(ArrayPrototype$5, it) && own === ArrayPrototype$5.fill ? method$6 : own;
|
4646 | };
|
4647 |
|
4648 | var parent$8 = fill$1;
|
4649 | var fill = parent$8;
|
4650 |
|
4651 | (function (module) {
|
4652 | module.exports = fill;
|
4653 | })(fill$4);
|
4654 |
|
4655 | var _fillInstanceProperty = getDefaultExportFromCjs(fill$4.exports);
|
4656 |
|
4657 | var componentEmitter = {exports: {}};
|
4658 |
|
4659 | (function (module) {
|
4660 | |
4661 |
|
4662 |
|
4663 | {
|
4664 | module.exports = Emitter;
|
4665 | }
|
4666 | |
4667 |
|
4668 |
|
4669 |
|
4670 |
|
4671 |
|
4672 |
|
4673 | function Emitter(obj) {
|
4674 | if (obj) return mixin(obj);
|
4675 | }
|
4676 | |
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 | function mixin(obj) {
|
4685 | for (var key in Emitter.prototype) {
|
4686 | obj[key] = Emitter.prototype[key];
|
4687 | }
|
4688 |
|
4689 | return obj;
|
4690 | }
|
4691 | |
4692 |
|
4693 |
|
4694 |
|
4695 |
|
4696 |
|
4697 |
|
4698 |
|
4699 |
|
4700 |
|
4701 | Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
|
4702 | this._callbacks = this._callbacks || {};
|
4703 | (this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
|
4704 | return this;
|
4705 | };
|
4706 | |
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 |
|
4712 |
|
4713 |
|
4714 |
|
4715 |
|
4716 |
|
4717 | Emitter.prototype.once = function (event, fn) {
|
4718 | function on() {
|
4719 | this.off(event, on);
|
4720 | fn.apply(this, arguments);
|
4721 | }
|
4722 |
|
4723 | on.fn = fn;
|
4724 | this.on(event, on);
|
4725 | return this;
|
4726 | };
|
4727 | |
4728 |
|
4729 |
|
4730 |
|
4731 |
|
4732 |
|
4733 |
|
4734 |
|
4735 |
|
4736 |
|
4737 |
|
4738 | Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
|
4739 | this._callbacks = this._callbacks || {};
|
4740 |
|
4741 | if (0 == arguments.length) {
|
4742 | this._callbacks = {};
|
4743 | return this;
|
4744 | }
|
4745 |
|
4746 |
|
4747 | var callbacks = this._callbacks['$' + event];
|
4748 | if (!callbacks) return this;
|
4749 |
|
4750 | if (1 == arguments.length) {
|
4751 | delete this._callbacks['$' + event];
|
4752 | return this;
|
4753 | }
|
4754 |
|
4755 |
|
4756 | var cb;
|
4757 |
|
4758 | for (var i = 0; i < callbacks.length; i++) {
|
4759 | cb = callbacks[i];
|
4760 |
|
4761 | if (cb === fn || cb.fn === fn) {
|
4762 | callbacks.splice(i, 1);
|
4763 | break;
|
4764 | }
|
4765 | }
|
4766 |
|
4767 |
|
4768 |
|
4769 | if (callbacks.length === 0) {
|
4770 | delete this._callbacks['$' + event];
|
4771 | }
|
4772 |
|
4773 | return this;
|
4774 | };
|
4775 | |
4776 |
|
4777 |
|
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 |
|
4783 |
|
4784 | Emitter.prototype.emit = function (event) {
|
4785 | this._callbacks = this._callbacks || {};
|
4786 | var args = new Array(arguments.length - 1),
|
4787 | callbacks = this._callbacks['$' + event];
|
4788 |
|
4789 | for (var i = 1; i < arguments.length; i++) {
|
4790 | args[i - 1] = arguments[i];
|
4791 | }
|
4792 |
|
4793 | if (callbacks) {
|
4794 | callbacks = callbacks.slice(0);
|
4795 |
|
4796 | for (var i = 0, len = callbacks.length; i < len; ++i) {
|
4797 | callbacks[i].apply(this, args);
|
4798 | }
|
4799 | }
|
4800 |
|
4801 | return this;
|
4802 | };
|
4803 | |
4804 |
|
4805 |
|
4806 |
|
4807 |
|
4808 |
|
4809 |
|
4810 |
|
4811 |
|
4812 | Emitter.prototype.listeners = function (event) {
|
4813 | this._callbacks = this._callbacks || {};
|
4814 | return this._callbacks['$' + event] || [];
|
4815 | };
|
4816 | |
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 |
|
4822 |
|
4823 |
|
4824 |
|
4825 | Emitter.prototype.hasListeners = function (event) {
|
4826 | return !!this.listeners(event).length;
|
4827 | };
|
4828 | })(componentEmitter);
|
4829 |
|
4830 | var Emitter = componentEmitter.exports;
|
4831 |
|
4832 |
|
4833 |
|
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 | function _extends() {
|
4839 | _extends = Object.assign || function (target) {
|
4840 | for (var i = 1; i < arguments.length; i++) {
|
4841 | var source = arguments[i];
|
4842 |
|
4843 | for (var key in source) {
|
4844 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
4845 | target[key] = source[key];
|
4846 | }
|
4847 | }
|
4848 | }
|
4849 |
|
4850 | return target;
|
4851 | };
|
4852 |
|
4853 | return _extends.apply(this, arguments);
|
4854 | }
|
4855 |
|
4856 | function _inheritsLoose(subClass, superClass) {
|
4857 | subClass.prototype = Object.create(superClass.prototype);
|
4858 | subClass.prototype.constructor = subClass;
|
4859 | subClass.__proto__ = superClass;
|
4860 | }
|
4861 |
|
4862 | function _assertThisInitialized(self) {
|
4863 | if (self === void 0) {
|
4864 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
4865 | }
|
4866 |
|
4867 | return self;
|
4868 | }
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 |
|
4874 |
|
4875 |
|
4876 |
|
4877 |
|
4878 |
|
4879 | var assign;
|
4880 |
|
4881 | if (typeof Object.assign !== 'function') {
|
4882 | assign = function assign(target) {
|
4883 | if (target === undefined || target === null) {
|
4884 | throw new TypeError('Cannot convert undefined or null to object');
|
4885 | }
|
4886 |
|
4887 | var output = Object(target);
|
4888 |
|
4889 | for (var index = 1; index < arguments.length; index++) {
|
4890 | var source = arguments[index];
|
4891 |
|
4892 | if (source !== undefined && source !== null) {
|
4893 | for (var nextKey in source) {
|
4894 | if (source.hasOwnProperty(nextKey)) {
|
4895 | output[nextKey] = source[nextKey];
|
4896 | }
|
4897 | }
|
4898 | }
|
4899 | }
|
4900 |
|
4901 | return output;
|
4902 | };
|
4903 | } else {
|
4904 | assign = Object.assign;
|
4905 | }
|
4906 |
|
4907 | var assign$1 = assign;
|
4908 | var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
4909 | var TEST_ELEMENT = typeof document === "undefined" ? {
|
4910 | style: {}
|
4911 | } : document.createElement('div');
|
4912 | var TYPE_FUNCTION = 'function';
|
4913 | var round = Math.round,
|
4914 | abs = Math.abs;
|
4915 | var now = Date.now;
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 | function prefixed(obj, property) {
|
4925 | var prefix;
|
4926 | var prop;
|
4927 | var camelProp = property[0].toUpperCase() + property.slice(1);
|
4928 | var i = 0;
|
4929 |
|
4930 | while (i < VENDOR_PREFIXES.length) {
|
4931 | prefix = VENDOR_PREFIXES[i];
|
4932 | prop = prefix ? prefix + camelProp : property;
|
4933 |
|
4934 | if (prop in obj) {
|
4935 | return prop;
|
4936 | }
|
4937 |
|
4938 | i++;
|
4939 | }
|
4940 |
|
4941 | return undefined;
|
4942 | }
|
4943 |
|
4944 |
|
4945 |
|
4946 | var win;
|
4947 |
|
4948 | if (typeof window === "undefined") {
|
4949 |
|
4950 | win = {};
|
4951 | } else {
|
4952 | win = window;
|
4953 | }
|
4954 |
|
4955 | var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
4956 | var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
4957 |
|
4958 | function getTouchActionProps() {
|
4959 | if (!NATIVE_TOUCH_ACTION) {
|
4960 | return false;
|
4961 | }
|
4962 |
|
4963 | var touchMap = {};
|
4964 | var cssSupports = win.CSS && win.CSS.supports;
|
4965 | ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function (val) {
|
4966 |
|
4967 |
|
4968 | return touchMap[val] = cssSupports ? win.CSS.supports('touch-action', val) : true;
|
4969 | });
|
4970 | return touchMap;
|
4971 | }
|
4972 |
|
4973 | var TOUCH_ACTION_COMPUTE = 'compute';
|
4974 | var TOUCH_ACTION_AUTO = 'auto';
|
4975 | var TOUCH_ACTION_MANIPULATION = 'manipulation';
|
4976 |
|
4977 | var TOUCH_ACTION_NONE = 'none';
|
4978 | var TOUCH_ACTION_PAN_X = 'pan-x';
|
4979 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
4980 | var TOUCH_ACTION_MAP = getTouchActionProps();
|
4981 | var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
4982 | var SUPPORT_TOUCH = ('ontouchstart' in win);
|
4983 | var SUPPORT_POINTER_EVENTS = prefixed(win, 'PointerEvent') !== undefined;
|
4984 | var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
4985 | var INPUT_TYPE_TOUCH = 'touch';
|
4986 | var INPUT_TYPE_PEN = 'pen';
|
4987 | var INPUT_TYPE_MOUSE = 'mouse';
|
4988 | var INPUT_TYPE_KINECT = 'kinect';
|
4989 | var COMPUTE_INTERVAL = 25;
|
4990 | var INPUT_START = 1;
|
4991 | var INPUT_MOVE = 2;
|
4992 | var INPUT_END = 4;
|
4993 | var INPUT_CANCEL = 8;
|
4994 | var DIRECTION_NONE = 1;
|
4995 | var DIRECTION_LEFT = 2;
|
4996 | var DIRECTION_RIGHT = 4;
|
4997 | var DIRECTION_UP = 8;
|
4998 | var DIRECTION_DOWN = 16;
|
4999 | var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
5000 | var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
5001 | var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
5002 | var PROPS_XY = ['x', 'y'];
|
5003 | var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
5004 |
|
5005 |
|
5006 |
|
5007 |
|
5008 |
|
5009 |
|
5010 |
|
5011 |
|
5012 | function each(obj, iterator, context) {
|
5013 | var i;
|
5014 |
|
5015 | if (!obj) {
|
5016 | return;
|
5017 | }
|
5018 |
|
5019 | if (obj.forEach) {
|
5020 | obj.forEach(iterator, context);
|
5021 | } else if (obj.length !== undefined) {
|
5022 | i = 0;
|
5023 |
|
5024 | while (i < obj.length) {
|
5025 | iterator.call(context, obj[i], i, obj);
|
5026 | i++;
|
5027 | }
|
5028 | } else {
|
5029 | for (i in obj) {
|
5030 | obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
5031 | }
|
5032 | }
|
5033 | }
|
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 |
|
5041 |
|
5042 |
|
5043 |
|
5044 | function boolOrFn(val, args) {
|
5045 | if (typeof val === TYPE_FUNCTION) {
|
5046 | return val.apply(args ? args[0] || undefined : undefined, args);
|
5047 | }
|
5048 |
|
5049 | return val;
|
5050 | }
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 |
|
5058 |
|
5059 |
|
5060 | function inStr(str, find) {
|
5061 | return str.indexOf(find) > -1;
|
5062 | }
|
5063 |
|
5064 |
|
5065 |
|
5066 |
|
5067 |
|
5068 |
|
5069 |
|
5070 |
|
5071 | function cleanTouchActions(actions) {
|
5072 |
|
5073 | if (inStr(actions, TOUCH_ACTION_NONE)) {
|
5074 | return TOUCH_ACTION_NONE;
|
5075 | }
|
5076 |
|
5077 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
5078 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
5079 |
|
5080 |
|
5081 |
|
5082 |
|
5083 | if (hasPanX && hasPanY) {
|
5084 | return TOUCH_ACTION_NONE;
|
5085 | }
|
5086 |
|
5087 |
|
5088 | if (hasPanX || hasPanY) {
|
5089 | return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
5090 | }
|
5091 |
|
5092 |
|
5093 | if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
5094 | return TOUCH_ACTION_MANIPULATION;
|
5095 | }
|
5096 |
|
5097 | return TOUCH_ACTION_AUTO;
|
5098 | }
|
5099 |
|
5100 |
|
5101 |
|
5102 |
|
5103 |
|
5104 |
|
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 | var TouchAction = function () {
|
5110 | function TouchAction(manager, value) {
|
5111 | this.manager = manager;
|
5112 | this.set(value);
|
5113 | }
|
5114 | |
5115 |
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 |
|
5121 | var _proto = TouchAction.prototype;
|
5122 |
|
5123 | _proto.set = function set(value) {
|
5124 |
|
5125 | if (value === TOUCH_ACTION_COMPUTE) {
|
5126 | value = this.compute();
|
5127 | }
|
5128 |
|
5129 | if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
5130 | this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
5131 | }
|
5132 |
|
5133 | this.actions = value.toLowerCase().trim();
|
5134 | };
|
5135 | |
5136 |
|
5137 |
|
5138 |
|
5139 |
|
5140 |
|
5141 | _proto.update = function update() {
|
5142 | this.set(this.manager.options.touchAction);
|
5143 | };
|
5144 | |
5145 |
|
5146 |
|
5147 |
|
5148 |
|
5149 |
|
5150 |
|
5151 | _proto.compute = function compute() {
|
5152 | var actions = [];
|
5153 | each(this.manager.recognizers, function (recognizer) {
|
5154 | if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
5155 | actions = actions.concat(recognizer.getTouchAction());
|
5156 | }
|
5157 | });
|
5158 | return cleanTouchActions(actions.join(' '));
|
5159 | };
|
5160 | |
5161 |
|
5162 |
|
5163 |
|
5164 |
|
5165 |
|
5166 |
|
5167 | _proto.preventDefaults = function preventDefaults(input) {
|
5168 | var srcEvent = input.srcEvent;
|
5169 | var direction = input.offsetDirection;
|
5170 |
|
5171 | if (this.manager.session.prevented) {
|
5172 | srcEvent.preventDefault();
|
5173 | return;
|
5174 | }
|
5175 |
|
5176 | var actions = this.actions;
|
5177 | var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
5178 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
5179 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
5180 |
|
5181 | if (hasNone) {
|
5182 |
|
5183 | var isTapPointer = input.pointers.length === 1;
|
5184 | var isTapMovement = input.distance < 2;
|
5185 | var isTapTouchTime = input.deltaTime < 250;
|
5186 |
|
5187 | if (isTapPointer && isTapMovement && isTapTouchTime) {
|
5188 | return;
|
5189 | }
|
5190 | }
|
5191 |
|
5192 | if (hasPanX && hasPanY) {
|
5193 |
|
5194 | return;
|
5195 | }
|
5196 |
|
5197 | if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
|
5198 | return this.preventSrc(srcEvent);
|
5199 | }
|
5200 | };
|
5201 | |
5202 |
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 | _proto.preventSrc = function preventSrc(srcEvent) {
|
5209 | this.manager.session.prevented = true;
|
5210 | srcEvent.preventDefault();
|
5211 | };
|
5212 |
|
5213 | return TouchAction;
|
5214 | }();
|
5215 |
|
5216 |
|
5217 |
|
5218 |
|
5219 |
|
5220 |
|
5221 |
|
5222 |
|
5223 |
|
5224 |
|
5225 | function hasParent$1(node, parent) {
|
5226 | while (node) {
|
5227 | if (node === parent) {
|
5228 | return true;
|
5229 | }
|
5230 |
|
5231 | node = node.parentNode;
|
5232 | }
|
5233 |
|
5234 | return false;
|
5235 | }
|
5236 |
|
5237 |
|
5238 |
|
5239 |
|
5240 |
|
5241 |
|
5242 |
|
5243 |
|
5244 | function getCenter(pointers) {
|
5245 | var pointersLength = pointers.length;
|
5246 |
|
5247 | if (pointersLength === 1) {
|
5248 | return {
|
5249 | x: round(pointers[0].clientX),
|
5250 | y: round(pointers[0].clientY)
|
5251 | };
|
5252 | }
|
5253 |
|
5254 | var x = 0;
|
5255 | var y = 0;
|
5256 | var i = 0;
|
5257 |
|
5258 | while (i < pointersLength) {
|
5259 | x += pointers[i].clientX;
|
5260 | y += pointers[i].clientY;
|
5261 | i++;
|
5262 | }
|
5263 |
|
5264 | return {
|
5265 | x: round(x / pointersLength),
|
5266 | y: round(y / pointersLength)
|
5267 | };
|
5268 | }
|
5269 |
|
5270 |
|
5271 |
|
5272 |
|
5273 |
|
5274 |
|
5275 |
|
5276 |
|
5277 | function simpleCloneInputData(input) {
|
5278 |
|
5279 |
|
5280 | var pointers = [];
|
5281 | var i = 0;
|
5282 |
|
5283 | while (i < input.pointers.length) {
|
5284 | pointers[i] = {
|
5285 | clientX: round(input.pointers[i].clientX),
|
5286 | clientY: round(input.pointers[i].clientY)
|
5287 | };
|
5288 | i++;
|
5289 | }
|
5290 |
|
5291 | return {
|
5292 | timeStamp: now(),
|
5293 | pointers: pointers,
|
5294 | center: getCenter(pointers),
|
5295 | deltaX: input.deltaX,
|
5296 | deltaY: input.deltaY
|
5297 | };
|
5298 | }
|
5299 |
|
5300 |
|
5301 |
|
5302 |
|
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 | function getDistance(p1, p2, props) {
|
5310 | if (!props) {
|
5311 | props = PROPS_XY;
|
5312 | }
|
5313 |
|
5314 | var x = p2[props[0]] - p1[props[0]];
|
5315 | var y = p2[props[1]] - p1[props[1]];
|
5316 | return Math.sqrt(x * x + y * y);
|
5317 | }
|
5318 |
|
5319 |
|
5320 |
|
5321 |
|
5322 |
|
5323 |
|
5324 |
|
5325 |
|
5326 |
|
5327 |
|
5328 | function getAngle(p1, p2, props) {
|
5329 | if (!props) {
|
5330 | props = PROPS_XY;
|
5331 | }
|
5332 |
|
5333 | var x = p2[props[0]] - p1[props[0]];
|
5334 | var y = p2[props[1]] - p1[props[1]];
|
5335 | return Math.atan2(y, x) * 180 / Math.PI;
|
5336 | }
|
5337 |
|
5338 |
|
5339 |
|
5340 |
|
5341 |
|
5342 |
|
5343 |
|
5344 |
|
5345 |
|
5346 | function getDirection(x, y) {
|
5347 | if (x === y) {
|
5348 | return DIRECTION_NONE;
|
5349 | }
|
5350 |
|
5351 | if (abs(x) >= abs(y)) {
|
5352 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
5353 | }
|
5354 |
|
5355 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
5356 | }
|
5357 |
|
5358 | function computeDeltaXY(session, input) {
|
5359 | var center = input.center;
|
5360 |
|
5361 |
|
5362 | var offset = session.offsetDelta || {};
|
5363 | var prevDelta = session.prevDelta || {};
|
5364 | var prevInput = session.prevInput || {};
|
5365 |
|
5366 | if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
5367 | prevDelta = session.prevDelta = {
|
5368 | x: prevInput.deltaX || 0,
|
5369 | y: prevInput.deltaY || 0
|
5370 | };
|
5371 | offset = session.offsetDelta = {
|
5372 | x: center.x,
|
5373 | y: center.y
|
5374 | };
|
5375 | }
|
5376 |
|
5377 | input.deltaX = prevDelta.x + (center.x - offset.x);
|
5378 | input.deltaY = prevDelta.y + (center.y - offset.y);
|
5379 | }
|
5380 |
|
5381 |
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 |
|
5387 |
|
5388 |
|
5389 |
|
5390 | function getVelocity(deltaTime, x, y) {
|
5391 | return {
|
5392 | x: x / deltaTime || 0,
|
5393 | y: y / deltaTime || 0
|
5394 | };
|
5395 | }
|
5396 |
|
5397 |
|
5398 |
|
5399 |
|
5400 |
|
5401 |
|
5402 |
|
5403 |
|
5404 |
|
5405 |
|
5406 | function getScale(start, end) {
|
5407 | return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
5408 | }
|
5409 |
|
5410 |
|
5411 |
|
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 |
|
5417 |
|
5418 | function getRotation(start, end) {
|
5419 | return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
5420 | }
|
5421 |
|
5422 |
|
5423 |
|
5424 |
|
5425 |
|
5426 |
|
5427 |
|
5428 |
|
5429 | function computeIntervalInputData(session, input) {
|
5430 | var last = session.lastInterval || input;
|
5431 | var deltaTime = input.timeStamp - last.timeStamp;
|
5432 | var velocity;
|
5433 | var velocityX;
|
5434 | var velocityY;
|
5435 | var direction;
|
5436 |
|
5437 | if (input.eventType !== INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
|
5438 | var deltaX = input.deltaX - last.deltaX;
|
5439 | var deltaY = input.deltaY - last.deltaY;
|
5440 | var v = getVelocity(deltaTime, deltaX, deltaY);
|
5441 | velocityX = v.x;
|
5442 | velocityY = v.y;
|
5443 | velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
|
5444 | direction = getDirection(deltaX, deltaY);
|
5445 | session.lastInterval = input;
|
5446 | } else {
|
5447 |
|
5448 | velocity = last.velocity;
|
5449 | velocityX = last.velocityX;
|
5450 | velocityY = last.velocityY;
|
5451 | direction = last.direction;
|
5452 | }
|
5453 |
|
5454 | input.velocity = velocity;
|
5455 | input.velocityX = velocityX;
|
5456 | input.velocityY = velocityY;
|
5457 | input.direction = direction;
|
5458 | }
|
5459 |
|
5460 |
|
5461 |
|
5462 |
|
5463 |
|
5464 |
|
5465 |
|
5466 |
|
5467 | function computeInputData(manager, input) {
|
5468 | var session = manager.session;
|
5469 | var pointers = input.pointers;
|
5470 | var pointersLength = pointers.length;
|
5471 |
|
5472 | if (!session.firstInput) {
|
5473 | session.firstInput = simpleCloneInputData(input);
|
5474 | }
|
5475 |
|
5476 |
|
5477 | if (pointersLength > 1 && !session.firstMultiple) {
|
5478 | session.firstMultiple = simpleCloneInputData(input);
|
5479 | } else if (pointersLength === 1) {
|
5480 | session.firstMultiple = false;
|
5481 | }
|
5482 |
|
5483 | var firstInput = session.firstInput,
|
5484 | firstMultiple = session.firstMultiple;
|
5485 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
5486 | var center = input.center = getCenter(pointers);
|
5487 | input.timeStamp = now();
|
5488 | input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
5489 | input.angle = getAngle(offsetCenter, center);
|
5490 | input.distance = getDistance(offsetCenter, center);
|
5491 | computeDeltaXY(session, input);
|
5492 | input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
5493 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
5494 | input.overallVelocityX = overallVelocity.x;
|
5495 | input.overallVelocityY = overallVelocity.y;
|
5496 | input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
|
5497 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
5498 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
5499 | input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
|
5500 | computeIntervalInputData(session, input);
|
5501 |
|
5502 | var target = manager.element;
|
5503 | var srcEvent = input.srcEvent;
|
5504 | var srcEventTarget;
|
5505 |
|
5506 | if (srcEvent.composedPath) {
|
5507 | srcEventTarget = srcEvent.composedPath()[0];
|
5508 | } else if (srcEvent.path) {
|
5509 | srcEventTarget = srcEvent.path[0];
|
5510 | } else {
|
5511 | srcEventTarget = srcEvent.target;
|
5512 | }
|
5513 |
|
5514 | if (hasParent$1(srcEventTarget, target)) {
|
5515 | target = srcEventTarget;
|
5516 | }
|
5517 |
|
5518 | input.target = target;
|
5519 | }
|
5520 |
|
5521 |
|
5522 |
|
5523 |
|
5524 |
|
5525 |
|
5526 |
|
5527 |
|
5528 |
|
5529 | function inputHandler(manager, eventType, input) {
|
5530 | var pointersLen = input.pointers.length;
|
5531 | var changedPointersLen = input.changedPointers.length;
|
5532 | var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
|
5533 | var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
|
5534 | input.isFirst = !!isFirst;
|
5535 | input.isFinal = !!isFinal;
|
5536 |
|
5537 | if (isFirst) {
|
5538 | manager.session = {};
|
5539 | }
|
5540 |
|
5541 |
|
5542 |
|
5543 | input.eventType = eventType;
|
5544 |
|
5545 | computeInputData(manager, input);
|
5546 |
|
5547 | manager.emit('hammer.input', input);
|
5548 | manager.recognize(input);
|
5549 | manager.session.prevInput = input;
|
5550 | }
|
5551 |
|
5552 |
|
5553 |
|
5554 |
|
5555 |
|
5556 |
|
5557 |
|
5558 |
|
5559 | function splitStr(str) {
|
5560 | return str.trim().split(/\s+/g);
|
5561 | }
|
5562 |
|
5563 |
|
5564 |
|
5565 |
|
5566 |
|
5567 |
|
5568 |
|
5569 |
|
5570 |
|
5571 | function addEventListeners(target, types, handler) {
|
5572 | each(splitStr(types), function (type) {
|
5573 | target.addEventListener(type, handler, false);
|
5574 | });
|
5575 | }
|
5576 |
|
5577 |
|
5578 |
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 |
|
5584 |
|
5585 | function removeEventListeners(target, types, handler) {
|
5586 | each(splitStr(types), function (type) {
|
5587 | target.removeEventListener(type, handler, false);
|
5588 | });
|
5589 | }
|
5590 |
|
5591 |
|
5592 |
|
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 |
|
5598 | function getWindowForElement(element) {
|
5599 | var doc = element.ownerDocument || element;
|
5600 | return doc.defaultView || doc.parentWindow || window;
|
5601 | }
|
5602 |
|
5603 |
|
5604 |
|
5605 |
|
5606 |
|
5607 |
|
5608 |
|
5609 |
|
5610 |
|
5611 |
|
5612 | var Input = function () {
|
5613 | function Input(manager, callback) {
|
5614 | var self = this;
|
5615 | this.manager = manager;
|
5616 | this.callback = callback;
|
5617 | this.element = manager.element;
|
5618 | this.target = manager.options.inputTarget;
|
5619 |
|
5620 |
|
5621 | this.domHandler = function (ev) {
|
5622 | if (boolOrFn(manager.options.enable, [manager])) {
|
5623 | self.handler(ev);
|
5624 | }
|
5625 | };
|
5626 |
|
5627 | this.init();
|
5628 | }
|
5629 | |
5630 |
|
5631 |
|
5632 |
|
5633 |
|
5634 |
|
5635 |
|
5636 | var _proto = Input.prototype;
|
5637 |
|
5638 | _proto.handler = function handler() {};
|
5639 | |
5640 |
|
5641 |
|
5642 |
|
5643 |
|
5644 |
|
5645 | _proto.init = function init() {
|
5646 | this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
5647 | this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
5648 | this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
5649 | };
|
5650 | |
5651 |
|
5652 |
|
5653 |
|
5654 |
|
5655 |
|
5656 | _proto.destroy = function destroy() {
|
5657 | this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
5658 | this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
5659 | this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
5660 | };
|
5661 |
|
5662 | return Input;
|
5663 | }();
|
5664 |
|
5665 |
|
5666 |
|
5667 |
|
5668 |
|
5669 |
|
5670 |
|
5671 |
|
5672 |
|
5673 |
|
5674 | function inArray(src, find, findByKey) {
|
5675 | if (src.indexOf && !findByKey) {
|
5676 | return src.indexOf(find);
|
5677 | } else {
|
5678 | var i = 0;
|
5679 |
|
5680 | while (i < src.length) {
|
5681 | if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
|
5682 |
|
5683 | return i;
|
5684 | }
|
5685 |
|
5686 | i++;
|
5687 | }
|
5688 |
|
5689 | return -1;
|
5690 | }
|
5691 | }
|
5692 |
|
5693 | var POINTER_INPUT_MAP = {
|
5694 | pointerdown: INPUT_START,
|
5695 | pointermove: INPUT_MOVE,
|
5696 | pointerup: INPUT_END,
|
5697 | pointercancel: INPUT_CANCEL,
|
5698 | pointerout: INPUT_CANCEL
|
5699 | };
|
5700 |
|
5701 | var IE10_POINTER_TYPE_ENUM = {
|
5702 | 2: INPUT_TYPE_TOUCH,
|
5703 | 3: INPUT_TYPE_PEN,
|
5704 | 4: INPUT_TYPE_MOUSE,
|
5705 | 5: INPUT_TYPE_KINECT
|
5706 |
|
5707 | };
|
5708 | var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
5709 | var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
5710 |
|
5711 | if (win.MSPointerEvent && !win.PointerEvent) {
|
5712 | POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
5713 | POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
5714 | }
|
5715 |
|
5716 |
|
5717 |
|
5718 |
|
5719 |
|
5720 |
|
5721 |
|
5722 |
|
5723 | var PointerEventInput = function (_Input) {
|
5724 | _inheritsLoose(PointerEventInput, _Input);
|
5725 |
|
5726 | function PointerEventInput() {
|
5727 | var _this;
|
5728 |
|
5729 | var proto = PointerEventInput.prototype;
|
5730 | proto.evEl = POINTER_ELEMENT_EVENTS;
|
5731 | proto.evWin = POINTER_WINDOW_EVENTS;
|
5732 | _this = _Input.apply(this, arguments) || this;
|
5733 | _this.store = _this.manager.session.pointerEvents = [];
|
5734 | return _this;
|
5735 | }
|
5736 | |
5737 |
|
5738 |
|
5739 |
|
5740 |
|
5741 |
|
5742 |
|
5743 | var _proto = PointerEventInput.prototype;
|
5744 |
|
5745 | _proto.handler = function handler(ev) {
|
5746 | var store = this.store;
|
5747 | var removePointer = false;
|
5748 | var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
|
5749 | var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
5750 | var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
5751 | var isTouch = pointerType === INPUT_TYPE_TOUCH;
|
5752 |
|
5753 | var storeIndex = inArray(store, ev.pointerId, 'pointerId');
|
5754 |
|
5755 | if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
5756 | if (storeIndex < 0) {
|
5757 | store.push(ev);
|
5758 | storeIndex = store.length - 1;
|
5759 | }
|
5760 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
5761 | removePointer = true;
|
5762 | }
|
5763 |
|
5764 |
|
5765 | if (storeIndex < 0) {
|
5766 | return;
|
5767 | }
|
5768 |
|
5769 |
|
5770 | store[storeIndex] = ev;
|
5771 | this.callback(this.manager, eventType, {
|
5772 | pointers: store,
|
5773 | changedPointers: [ev],
|
5774 | pointerType: pointerType,
|
5775 | srcEvent: ev
|
5776 | });
|
5777 |
|
5778 | if (removePointer) {
|
5779 |
|
5780 | store.splice(storeIndex, 1);
|
5781 | }
|
5782 | };
|
5783 |
|
5784 | return PointerEventInput;
|
5785 | }(Input);
|
5786 |
|
5787 |
|
5788 |
|
5789 |
|
5790 |
|
5791 |
|
5792 |
|
5793 |
|
5794 | function toArray$1(obj) {
|
5795 | return Array.prototype.slice.call(obj, 0);
|
5796 | }
|
5797 |
|
5798 |
|
5799 |
|
5800 |
|
5801 |
|
5802 |
|
5803 |
|
5804 |
|
5805 |
|
5806 |
|
5807 | function uniqueArray(src, key, sort) {
|
5808 | var results = [];
|
5809 | var values = [];
|
5810 | var i = 0;
|
5811 |
|
5812 | while (i < src.length) {
|
5813 | var val = key ? src[i][key] : src[i];
|
5814 |
|
5815 | if (inArray(values, val) < 0) {
|
5816 | results.push(src[i]);
|
5817 | }
|
5818 |
|
5819 | values[i] = val;
|
5820 | i++;
|
5821 | }
|
5822 |
|
5823 | if (sort) {
|
5824 | if (!key) {
|
5825 | results = results.sort();
|
5826 | } else {
|
5827 | results = results.sort(function (a, b) {
|
5828 | return a[key] > b[key];
|
5829 | });
|
5830 | }
|
5831 | }
|
5832 |
|
5833 | return results;
|
5834 | }
|
5835 |
|
5836 | var TOUCH_INPUT_MAP = {
|
5837 | touchstart: INPUT_START,
|
5838 | touchmove: INPUT_MOVE,
|
5839 | touchend: INPUT_END,
|
5840 | touchcancel: INPUT_CANCEL
|
5841 | };
|
5842 | var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 |
|
5849 |
|
5850 | var TouchInput = function (_Input) {
|
5851 | _inheritsLoose(TouchInput, _Input);
|
5852 |
|
5853 | function TouchInput() {
|
5854 | var _this;
|
5855 |
|
5856 | TouchInput.prototype.evTarget = TOUCH_TARGET_EVENTS;
|
5857 | _this = _Input.apply(this, arguments) || this;
|
5858 | _this.targetIds = {};
|
5859 |
|
5860 | return _this;
|
5861 | }
|
5862 |
|
5863 | var _proto = TouchInput.prototype;
|
5864 |
|
5865 | _proto.handler = function handler(ev) {
|
5866 | var type = TOUCH_INPUT_MAP[ev.type];
|
5867 | var touches = getTouches.call(this, ev, type);
|
5868 |
|
5869 | if (!touches) {
|
5870 | return;
|
5871 | }
|
5872 |
|
5873 | this.callback(this.manager, type, {
|
5874 | pointers: touches[0],
|
5875 | changedPointers: touches[1],
|
5876 | pointerType: INPUT_TYPE_TOUCH,
|
5877 | srcEvent: ev
|
5878 | });
|
5879 | };
|
5880 |
|
5881 | return TouchInput;
|
5882 | }(Input);
|
5883 |
|
5884 | function getTouches(ev, type) {
|
5885 | var allTouches = toArray$1(ev.touches);
|
5886 | var targetIds = this.targetIds;
|
5887 |
|
5888 | if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
5889 | targetIds[allTouches[0].identifier] = true;
|
5890 | return [allTouches, allTouches];
|
5891 | }
|
5892 |
|
5893 | var i;
|
5894 | var targetTouches;
|
5895 | var changedTouches = toArray$1(ev.changedTouches);
|
5896 | var changedTargetTouches = [];
|
5897 | var target = this.target;
|
5898 |
|
5899 | targetTouches = allTouches.filter(function (touch) {
|
5900 | return hasParent$1(touch.target, target);
|
5901 | });
|
5902 |
|
5903 | if (type === INPUT_START) {
|
5904 | i = 0;
|
5905 |
|
5906 | while (i < targetTouches.length) {
|
5907 | targetIds[targetTouches[i].identifier] = true;
|
5908 | i++;
|
5909 | }
|
5910 | }
|
5911 |
|
5912 |
|
5913 | i = 0;
|
5914 |
|
5915 | while (i < changedTouches.length) {
|
5916 | if (targetIds[changedTouches[i].identifier]) {
|
5917 | changedTargetTouches.push(changedTouches[i]);
|
5918 | }
|
5919 |
|
5920 |
|
5921 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
5922 | delete targetIds[changedTouches[i].identifier];
|
5923 | }
|
5924 |
|
5925 | i++;
|
5926 | }
|
5927 |
|
5928 | if (!changedTargetTouches.length) {
|
5929 | return;
|
5930 | }
|
5931 |
|
5932 | return [
|
5933 | uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
|
5934 | }
|
5935 |
|
5936 | var MOUSE_INPUT_MAP = {
|
5937 | mousedown: INPUT_START,
|
5938 | mousemove: INPUT_MOVE,
|
5939 | mouseup: INPUT_END
|
5940 | };
|
5941 | var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
5942 | var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
5943 |
|
5944 |
|
5945 |
|
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 | var MouseInput = function (_Input) {
|
5951 | _inheritsLoose(MouseInput, _Input);
|
5952 |
|
5953 | function MouseInput() {
|
5954 | var _this;
|
5955 |
|
5956 | var proto = MouseInput.prototype;
|
5957 | proto.evEl = MOUSE_ELEMENT_EVENTS;
|
5958 | proto.evWin = MOUSE_WINDOW_EVENTS;
|
5959 | _this = _Input.apply(this, arguments) || this;
|
5960 | _this.pressed = false;
|
5961 |
|
5962 | return _this;
|
5963 | }
|
5964 | |
5965 |
|
5966 |
|
5967 |
|
5968 |
|
5969 |
|
5970 |
|
5971 | var _proto = MouseInput.prototype;
|
5972 |
|
5973 | _proto.handler = function handler(ev) {
|
5974 | var eventType = MOUSE_INPUT_MAP[ev.type];
|
5975 |
|
5976 | if (eventType & INPUT_START && ev.button === 0) {
|
5977 | this.pressed = true;
|
5978 | }
|
5979 |
|
5980 | if (eventType & INPUT_MOVE && ev.which !== 1) {
|
5981 | eventType = INPUT_END;
|
5982 | }
|
5983 |
|
5984 |
|
5985 | if (!this.pressed) {
|
5986 | return;
|
5987 | }
|
5988 |
|
5989 | if (eventType & INPUT_END) {
|
5990 | this.pressed = false;
|
5991 | }
|
5992 |
|
5993 | this.callback(this.manager, eventType, {
|
5994 | pointers: [ev],
|
5995 | changedPointers: [ev],
|
5996 | pointerType: INPUT_TYPE_MOUSE,
|
5997 | srcEvent: ev
|
5998 | });
|
5999 | };
|
6000 |
|
6001 | return MouseInput;
|
6002 | }(Input);
|
6003 |
|
6004 |
|
6005 |
|
6006 |
|
6007 |
|
6008 |
|
6009 |
|
6010 |
|
6011 |
|
6012 |
|
6013 |
|
6014 |
|
6015 | var DEDUP_TIMEOUT = 2500;
|
6016 | var DEDUP_DISTANCE = 25;
|
6017 |
|
6018 | function setLastTouch(eventData) {
|
6019 | var _eventData$changedPoi = eventData.changedPointers,
|
6020 | touch = _eventData$changedPoi[0];
|
6021 |
|
6022 | if (touch.identifier === this.primaryTouch) {
|
6023 | var lastTouch = {
|
6024 | x: touch.clientX,
|
6025 | y: touch.clientY
|
6026 | };
|
6027 | var lts = this.lastTouches;
|
6028 | this.lastTouches.push(lastTouch);
|
6029 |
|
6030 | var removeLastTouch = function removeLastTouch() {
|
6031 | var i = lts.indexOf(lastTouch);
|
6032 |
|
6033 | if (i > -1) {
|
6034 | lts.splice(i, 1);
|
6035 | }
|
6036 | };
|
6037 |
|
6038 | setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
6039 | }
|
6040 | }
|
6041 |
|
6042 | function recordTouches(eventType, eventData) {
|
6043 | if (eventType & INPUT_START) {
|
6044 | this.primaryTouch = eventData.changedPointers[0].identifier;
|
6045 | setLastTouch.call(this, eventData);
|
6046 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
6047 | setLastTouch.call(this, eventData);
|
6048 | }
|
6049 | }
|
6050 |
|
6051 | function isSyntheticEvent(eventData) {
|
6052 | var x = eventData.srcEvent.clientX;
|
6053 | var y = eventData.srcEvent.clientY;
|
6054 |
|
6055 | for (var i = 0; i < this.lastTouches.length; i++) {
|
6056 | var t = this.lastTouches[i];
|
6057 | var dx = Math.abs(x - t.x);
|
6058 | var dy = Math.abs(y - t.y);
|
6059 |
|
6060 | if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
6061 | return true;
|
6062 | }
|
6063 | }
|
6064 |
|
6065 | return false;
|
6066 | }
|
6067 |
|
6068 | var TouchMouseInput = function () {
|
6069 | var TouchMouseInput = function (_Input) {
|
6070 | _inheritsLoose(TouchMouseInput, _Input);
|
6071 |
|
6072 | function TouchMouseInput(_manager, callback) {
|
6073 | var _this;
|
6074 |
|
6075 | _this = _Input.call(this, _manager, callback) || this;
|
6076 |
|
6077 | _this.handler = function (manager, inputEvent, inputData) {
|
6078 | var isTouch = inputData.pointerType === INPUT_TYPE_TOUCH;
|
6079 | var isMouse = inputData.pointerType === INPUT_TYPE_MOUSE;
|
6080 |
|
6081 | if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
6082 | return;
|
6083 | }
|
6084 |
|
6085 |
|
6086 | if (isTouch) {
|
6087 | recordTouches.call(_assertThisInitialized(_assertThisInitialized(_this)), inputEvent, inputData);
|
6088 | } else if (isMouse && isSyntheticEvent.call(_assertThisInitialized(_assertThisInitialized(_this)), inputData)) {
|
6089 | return;
|
6090 | }
|
6091 |
|
6092 | _this.callback(manager, inputEvent, inputData);
|
6093 | };
|
6094 |
|
6095 | _this.touch = new TouchInput(_this.manager, _this.handler);
|
6096 | _this.mouse = new MouseInput(_this.manager, _this.handler);
|
6097 | _this.primaryTouch = null;
|
6098 | _this.lastTouches = [];
|
6099 | return _this;
|
6100 | }
|
6101 | |
6102 |
|
6103 |
|
6104 |
|
6105 |
|
6106 |
|
6107 |
|
6108 |
|
6109 |
|
6110 | var _proto = TouchMouseInput.prototype;
|
6111 | |
6112 |
|
6113 |
|
6114 |
|
6115 |
|
6116 | _proto.destroy = function destroy() {
|
6117 | this.touch.destroy();
|
6118 | this.mouse.destroy();
|
6119 | };
|
6120 |
|
6121 | return TouchMouseInput;
|
6122 | }(Input);
|
6123 |
|
6124 | return TouchMouseInput;
|
6125 | }();
|
6126 |
|
6127 |
|
6128 |
|
6129 |
|
6130 |
|
6131 |
|
6132 |
|
6133 |
|
6134 |
|
6135 | function createInputInstance(manager) {
|
6136 | var Type;
|
6137 |
|
6138 | var inputClass = manager.options.inputClass;
|
6139 |
|
6140 | if (inputClass) {
|
6141 | Type = inputClass;
|
6142 | } else if (SUPPORT_POINTER_EVENTS) {
|
6143 | Type = PointerEventInput;
|
6144 | } else if (SUPPORT_ONLY_TOUCH) {
|
6145 | Type = TouchInput;
|
6146 | } else if (!SUPPORT_TOUCH) {
|
6147 | Type = MouseInput;
|
6148 | } else {
|
6149 | Type = TouchMouseInput;
|
6150 | }
|
6151 |
|
6152 | return new Type(manager, inputHandler);
|
6153 | }
|
6154 |
|
6155 |
|
6156 |
|
6157 |
|
6158 |
|
6159 |
|
6160 |
|
6161 |
|
6162 |
|
6163 |
|
6164 |
|
6165 |
|
6166 | function invokeArrayArg(arg, fn, context) {
|
6167 | if (Array.isArray(arg)) {
|
6168 | each(arg, context[fn], context);
|
6169 | return true;
|
6170 | }
|
6171 |
|
6172 | return false;
|
6173 | }
|
6174 |
|
6175 | var STATE_POSSIBLE = 1;
|
6176 | var STATE_BEGAN = 2;
|
6177 | var STATE_CHANGED = 4;
|
6178 | var STATE_ENDED = 8;
|
6179 | var STATE_RECOGNIZED = STATE_ENDED;
|
6180 | var STATE_CANCELLED = 16;
|
6181 | var STATE_FAILED = 32;
|
6182 |
|
6183 |
|
6184 |
|
6185 |
|
6186 |
|
6187 |
|
6188 | var _uniqueId = 1;
|
6189 |
|
6190 | function uniqueId() {
|
6191 | return _uniqueId++;
|
6192 | }
|
6193 |
|
6194 |
|
6195 |
|
6196 |
|
6197 |
|
6198 |
|
6199 |
|
6200 |
|
6201 |
|
6202 | function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
6203 | var manager = recognizer.manager;
|
6204 |
|
6205 | if (manager) {
|
6206 | return manager.get(otherRecognizer);
|
6207 | }
|
6208 |
|
6209 | return otherRecognizer;
|
6210 | }
|
6211 |
|
6212 |
|
6213 |
|
6214 |
|
6215 |
|
6216 |
|
6217 |
|
6218 |
|
6219 | function stateStr(state) {
|
6220 | if (state & STATE_CANCELLED) {
|
6221 | return 'cancel';
|
6222 | } else if (state & STATE_ENDED) {
|
6223 | return 'end';
|
6224 | } else if (state & STATE_CHANGED) {
|
6225 | return 'move';
|
6226 | } else if (state & STATE_BEGAN) {
|
6227 | return 'start';
|
6228 | }
|
6229 |
|
6230 | return '';
|
6231 | }
|
6232 |
|
6233 |
|
6234 |
|
6235 |
|
6236 |
|
6237 |
|
6238 |
|
6239 |
|
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 |
|
6246 |
|
6247 |
|
6248 |
|
6249 |
|
6250 |
|
6251 |
|
6252 |
|
6253 |
|
6254 |
|
6255 |
|
6256 |
|
6257 |
|
6258 |
|
6259 |
|
6260 |
|
6261 |
|
6262 |
|
6263 |
|
6264 |
|
6265 |
|
6266 |
|
6267 |
|
6268 |
|
6269 |
|
6270 | var Recognizer = function () {
|
6271 | function Recognizer(options) {
|
6272 | if (options === void 0) {
|
6273 | options = {};
|
6274 | }
|
6275 |
|
6276 | this.options = _extends({
|
6277 | enable: true
|
6278 | }, options);
|
6279 | this.id = uniqueId();
|
6280 | this.manager = null;
|
6281 |
|
6282 | this.state = STATE_POSSIBLE;
|
6283 | this.simultaneous = {};
|
6284 | this.requireFail = [];
|
6285 | }
|
6286 | |
6287 |
|
6288 |
|
6289 |
|
6290 |
|
6291 |
|
6292 |
|
6293 |
|
6294 | var _proto = Recognizer.prototype;
|
6295 |
|
6296 | _proto.set = function set(options) {
|
6297 | assign$1(this.options, options);
|
6298 |
|
6299 | this.manager && this.manager.touchAction.update();
|
6300 | return this;
|
6301 | };
|
6302 | |
6303 |
|
6304 |
|
6305 |
|
6306 |
|
6307 |
|
6308 |
|
6309 |
|
6310 | _proto.recognizeWith = function recognizeWith(otherRecognizer) {
|
6311 | if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
6312 | return this;
|
6313 | }
|
6314 |
|
6315 | var simultaneous = this.simultaneous;
|
6316 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
6317 |
|
6318 | if (!simultaneous[otherRecognizer.id]) {
|
6319 | simultaneous[otherRecognizer.id] = otherRecognizer;
|
6320 | otherRecognizer.recognizeWith(this);
|
6321 | }
|
6322 |
|
6323 | return this;
|
6324 | };
|
6325 | |
6326 |
|
6327 |
|
6328 |
|
6329 |
|
6330 |
|
6331 |
|
6332 |
|
6333 | _proto.dropRecognizeWith = function dropRecognizeWith(otherRecognizer) {
|
6334 | if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
6335 | return this;
|
6336 | }
|
6337 |
|
6338 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
6339 | delete this.simultaneous[otherRecognizer.id];
|
6340 | return this;
|
6341 | };
|
6342 | |
6343 |
|
6344 |
|
6345 |
|
6346 |
|
6347 |
|
6348 |
|
6349 |
|
6350 | _proto.requireFailure = function requireFailure(otherRecognizer) {
|
6351 | if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
6352 | return this;
|
6353 | }
|
6354 |
|
6355 | var requireFail = this.requireFail;
|
6356 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
6357 |
|
6358 | if (inArray(requireFail, otherRecognizer) === -1) {
|
6359 | requireFail.push(otherRecognizer);
|
6360 | otherRecognizer.requireFailure(this);
|
6361 | }
|
6362 |
|
6363 | return this;
|
6364 | };
|
6365 | |
6366 |
|
6367 |
|
6368 |
|
6369 |
|
6370 |
|
6371 |
|
6372 |
|
6373 | _proto.dropRequireFailure = function dropRequireFailure(otherRecognizer) {
|
6374 | if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
6375 | return this;
|
6376 | }
|
6377 |
|
6378 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
6379 | var index = inArray(this.requireFail, otherRecognizer);
|
6380 |
|
6381 | if (index > -1) {
|
6382 | this.requireFail.splice(index, 1);
|
6383 | }
|
6384 |
|
6385 | return this;
|
6386 | };
|
6387 | |
6388 |
|
6389 |
|
6390 |
|
6391 |
|
6392 |
|
6393 |
|
6394 | _proto.hasRequireFailures = function hasRequireFailures() {
|
6395 | return this.requireFail.length > 0;
|
6396 | };
|
6397 | |
6398 |
|
6399 |
|
6400 |
|
6401 |
|
6402 |
|
6403 |
|
6404 |
|
6405 | _proto.canRecognizeWith = function canRecognizeWith(otherRecognizer) {
|
6406 | return !!this.simultaneous[otherRecognizer.id];
|
6407 | };
|
6408 | |
6409 |
|
6410 |
|
6411 |
|
6412 |
|
6413 |
|
6414 |
|
6415 |
|
6416 | _proto.emit = function emit(input) {
|
6417 | var self = this;
|
6418 | var state = this.state;
|
6419 |
|
6420 | function emit(event) {
|
6421 | self.manager.emit(event, input);
|
6422 | }
|
6423 |
|
6424 |
|
6425 | if (state < STATE_ENDED) {
|
6426 | emit(self.options.event + stateStr(state));
|
6427 | }
|
6428 |
|
6429 | emit(self.options.event);
|
6430 |
|
6431 | if (input.additionalEvent) {
|
6432 |
|
6433 | emit(input.additionalEvent);
|
6434 | }
|
6435 |
|
6436 |
|
6437 | if (state >= STATE_ENDED) {
|
6438 | emit(self.options.event + stateStr(state));
|
6439 | }
|
6440 | };
|
6441 | |
6442 |
|
6443 |
|
6444 |
|
6445 |
|
6446 |
|
6447 |
|
6448 |
|
6449 |
|
6450 | _proto.tryEmit = function tryEmit(input) {
|
6451 | if (this.canEmit()) {
|
6452 | return this.emit(input);
|
6453 | }
|
6454 |
|
6455 |
|
6456 | this.state = STATE_FAILED;
|
6457 | };
|
6458 | |
6459 |
|
6460 |
|
6461 |
|
6462 |
|
6463 |
|
6464 |
|
6465 | _proto.canEmit = function canEmit() {
|
6466 | var i = 0;
|
6467 |
|
6468 | while (i < this.requireFail.length) {
|
6469 | if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
6470 | return false;
|
6471 | }
|
6472 |
|
6473 | i++;
|
6474 | }
|
6475 |
|
6476 | return true;
|
6477 | };
|
6478 | |
6479 |
|
6480 |
|
6481 |
|
6482 |
|
6483 |
|
6484 |
|
6485 | _proto.recognize = function recognize(inputData) {
|
6486 |
|
6487 |
|
6488 | var inputDataClone = assign$1({}, inputData);
|
6489 |
|
6490 | if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
6491 | this.reset();
|
6492 | this.state = STATE_FAILED;
|
6493 | return;
|
6494 | }
|
6495 |
|
6496 |
|
6497 | if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
6498 | this.state = STATE_POSSIBLE;
|
6499 | }
|
6500 |
|
6501 | this.state = this.process(inputDataClone);
|
6502 |
|
6503 |
|
6504 | if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
6505 | this.tryEmit(inputDataClone);
|
6506 | }
|
6507 | };
|
6508 | |
6509 |
|
6510 |
|
6511 |
|
6512 |
|
6513 |
|
6514 |
|
6515 |
|
6516 |
|
6517 |
|
6518 |
|
6519 |
|
6520 | _proto.process = function process(inputData) {};
|
6521 |
|
6522 |
|
6523 | |
6524 |
|
6525 |
|
6526 |
|
6527 |
|
6528 |
|
6529 |
|
6530 |
|
6531 | _proto.getTouchAction = function getTouchAction() {};
|
6532 | |
6533 |
|
6534 |
|
6535 |
|
6536 |
|
6537 |
|
6538 |
|
6539 |
|
6540 | _proto.reset = function reset() {};
|
6541 |
|
6542 | return Recognizer;
|
6543 | }();
|
6544 |
|
6545 |
|
6546 |
|
6547 |
|
6548 |
|
6549 |
|
6550 |
|
6551 |
|
6552 |
|
6553 |
|
6554 |
|
6555 |
|
6556 |
|
6557 | var TapRecognizer = function (_Recognizer) {
|
6558 | _inheritsLoose(TapRecognizer, _Recognizer);
|
6559 |
|
6560 | function TapRecognizer(options) {
|
6561 | var _this;
|
6562 |
|
6563 | if (options === void 0) {
|
6564 | options = {};
|
6565 | }
|
6566 |
|
6567 | _this = _Recognizer.call(this, _extends({
|
6568 | event: 'tap',
|
6569 | pointers: 1,
|
6570 | taps: 1,
|
6571 | interval: 300,
|
6572 |
|
6573 | time: 250,
|
6574 |
|
6575 | threshold: 9,
|
6576 |
|
6577 | posThreshold: 10
|
6578 | }, options)) || this;
|
6579 |
|
6580 |
|
6581 | _this.pTime = false;
|
6582 | _this.pCenter = false;
|
6583 | _this._timer = null;
|
6584 | _this._input = null;
|
6585 | _this.count = 0;
|
6586 | return _this;
|
6587 | }
|
6588 |
|
6589 | var _proto = TapRecognizer.prototype;
|
6590 |
|
6591 | _proto.getTouchAction = function getTouchAction() {
|
6592 | return [TOUCH_ACTION_MANIPULATION];
|
6593 | };
|
6594 |
|
6595 | _proto.process = function process(input) {
|
6596 | var _this2 = this;
|
6597 |
|
6598 | var options = this.options;
|
6599 | var validPointers = input.pointers.length === options.pointers;
|
6600 | var validMovement = input.distance < options.threshold;
|
6601 | var validTouchTime = input.deltaTime < options.time;
|
6602 | this.reset();
|
6603 |
|
6604 | if (input.eventType & INPUT_START && this.count === 0) {
|
6605 | return this.failTimeout();
|
6606 | }
|
6607 |
|
6608 |
|
6609 |
|
6610 | if (validMovement && validTouchTime && validPointers) {
|
6611 | if (input.eventType !== INPUT_END) {
|
6612 | return this.failTimeout();
|
6613 | }
|
6614 |
|
6615 | var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
|
6616 | var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
6617 | this.pTime = input.timeStamp;
|
6618 | this.pCenter = input.center;
|
6619 |
|
6620 | if (!validMultiTap || !validInterval) {
|
6621 | this.count = 1;
|
6622 | } else {
|
6623 | this.count += 1;
|
6624 | }
|
6625 |
|
6626 | this._input = input;
|
6627 |
|
6628 |
|
6629 | var tapCount = this.count % options.taps;
|
6630 |
|
6631 | if (tapCount === 0) {
|
6632 |
|
6633 |
|
6634 | if (!this.hasRequireFailures()) {
|
6635 | return STATE_RECOGNIZED;
|
6636 | } else {
|
6637 | this._timer = setTimeout(function () {
|
6638 | _this2.state = STATE_RECOGNIZED;
|
6639 |
|
6640 | _this2.tryEmit();
|
6641 | }, options.interval);
|
6642 | return STATE_BEGAN;
|
6643 | }
|
6644 | }
|
6645 | }
|
6646 |
|
6647 | return STATE_FAILED;
|
6648 | };
|
6649 |
|
6650 | _proto.failTimeout = function failTimeout() {
|
6651 | var _this3 = this;
|
6652 |
|
6653 | this._timer = setTimeout(function () {
|
6654 | _this3.state = STATE_FAILED;
|
6655 | }, this.options.interval);
|
6656 | return STATE_FAILED;
|
6657 | };
|
6658 |
|
6659 | _proto.reset = function reset() {
|
6660 | clearTimeout(this._timer);
|
6661 | };
|
6662 |
|
6663 | _proto.emit = function emit() {
|
6664 | if (this.state === STATE_RECOGNIZED) {
|
6665 | this._input.tapCount = this.count;
|
6666 | this.manager.emit(this.options.event, this._input);
|
6667 | }
|
6668 | };
|
6669 |
|
6670 | return TapRecognizer;
|
6671 | }(Recognizer);
|
6672 |
|
6673 |
|
6674 |
|
6675 |
|
6676 |
|
6677 |
|
6678 |
|
6679 |
|
6680 | var AttrRecognizer = function (_Recognizer) {
|
6681 | _inheritsLoose(AttrRecognizer, _Recognizer);
|
6682 |
|
6683 | function AttrRecognizer(options) {
|
6684 | if (options === void 0) {
|
6685 | options = {};
|
6686 | }
|
6687 |
|
6688 | return _Recognizer.call(this, _extends({
|
6689 | pointers: 1
|
6690 | }, options)) || this;
|
6691 | }
|
6692 | |
6693 |
|
6694 |
|
6695 |
|
6696 |
|
6697 |
|
6698 |
|
6699 |
|
6700 |
|
6701 | var _proto = AttrRecognizer.prototype;
|
6702 |
|
6703 | _proto.attrTest = function attrTest(input) {
|
6704 | var optionPointers = this.options.pointers;
|
6705 | return optionPointers === 0 || input.pointers.length === optionPointers;
|
6706 | };
|
6707 | |
6708 |
|
6709 |
|
6710 |
|
6711 |
|
6712 |
|
6713 |
|
6714 |
|
6715 |
|
6716 | _proto.process = function process(input) {
|
6717 | var state = this.state;
|
6718 | var eventType = input.eventType;
|
6719 | var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
6720 | var isValid = this.attrTest(input);
|
6721 |
|
6722 | if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
6723 | return state | STATE_CANCELLED;
|
6724 | } else if (isRecognized || isValid) {
|
6725 | if (eventType & INPUT_END) {
|
6726 | return state | STATE_ENDED;
|
6727 | } else if (!(state & STATE_BEGAN)) {
|
6728 | return STATE_BEGAN;
|
6729 | }
|
6730 |
|
6731 | return state | STATE_CHANGED;
|
6732 | }
|
6733 |
|
6734 | return STATE_FAILED;
|
6735 | };
|
6736 |
|
6737 | return AttrRecognizer;
|
6738 | }(Recognizer);
|
6739 |
|
6740 |
|
6741 |
|
6742 |
|
6743 |
|
6744 |
|
6745 |
|
6746 |
|
6747 | function directionStr(direction) {
|
6748 | if (direction === DIRECTION_DOWN) {
|
6749 | return 'down';
|
6750 | } else if (direction === DIRECTION_UP) {
|
6751 | return 'up';
|
6752 | } else if (direction === DIRECTION_LEFT) {
|
6753 | return 'left';
|
6754 | } else if (direction === DIRECTION_RIGHT) {
|
6755 | return 'right';
|
6756 | }
|
6757 |
|
6758 | return '';
|
6759 | }
|
6760 |
|
6761 |
|
6762 |
|
6763 |
|
6764 |
|
6765 |
|
6766 |
|
6767 |
|
6768 |
|
6769 | var PanRecognizer = function (_AttrRecognizer) {
|
6770 | _inheritsLoose(PanRecognizer, _AttrRecognizer);
|
6771 |
|
6772 | function PanRecognizer(options) {
|
6773 | var _this;
|
6774 |
|
6775 | if (options === void 0) {
|
6776 | options = {};
|
6777 | }
|
6778 |
|
6779 | _this = _AttrRecognizer.call(this, _extends({
|
6780 | event: 'pan',
|
6781 | threshold: 10,
|
6782 | pointers: 1,
|
6783 | direction: DIRECTION_ALL
|
6784 | }, options)) || this;
|
6785 | _this.pX = null;
|
6786 | _this.pY = null;
|
6787 | return _this;
|
6788 | }
|
6789 |
|
6790 | var _proto = PanRecognizer.prototype;
|
6791 |
|
6792 | _proto.getTouchAction = function getTouchAction() {
|
6793 | var direction = this.options.direction;
|
6794 | var actions = [];
|
6795 |
|
6796 | if (direction & DIRECTION_HORIZONTAL) {
|
6797 | actions.push(TOUCH_ACTION_PAN_Y);
|
6798 | }
|
6799 |
|
6800 | if (direction & DIRECTION_VERTICAL) {
|
6801 | actions.push(TOUCH_ACTION_PAN_X);
|
6802 | }
|
6803 |
|
6804 | return actions;
|
6805 | };
|
6806 |
|
6807 | _proto.directionTest = function directionTest(input) {
|
6808 | var options = this.options;
|
6809 | var hasMoved = true;
|
6810 | var distance = input.distance;
|
6811 | var direction = input.direction;
|
6812 | var x = input.deltaX;
|
6813 | var y = input.deltaY;
|
6814 |
|
6815 | if (!(direction & options.direction)) {
|
6816 | if (options.direction & DIRECTION_HORIZONTAL) {
|
6817 | direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
6818 | hasMoved = x !== this.pX;
|
6819 | distance = Math.abs(input.deltaX);
|
6820 | } else {
|
6821 | direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
6822 | hasMoved = y !== this.pY;
|
6823 | distance = Math.abs(input.deltaY);
|
6824 | }
|
6825 | }
|
6826 |
|
6827 | input.direction = direction;
|
6828 | return hasMoved && distance > options.threshold && direction & options.direction;
|
6829 | };
|
6830 |
|
6831 | _proto.attrTest = function attrTest(input) {
|
6832 | return AttrRecognizer.prototype.attrTest.call(this, input) && (
|
6833 | this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
|
6834 | };
|
6835 |
|
6836 | _proto.emit = function emit(input) {
|
6837 | this.pX = input.deltaX;
|
6838 | this.pY = input.deltaY;
|
6839 | var direction = directionStr(input.direction);
|
6840 |
|
6841 | if (direction) {
|
6842 | input.additionalEvent = this.options.event + direction;
|
6843 | }
|
6844 |
|
6845 | _AttrRecognizer.prototype.emit.call(this, input);
|
6846 | };
|
6847 |
|
6848 | return PanRecognizer;
|
6849 | }(AttrRecognizer);
|
6850 |
|
6851 |
|
6852 |
|
6853 |
|
6854 |
|
6855 |
|
6856 |
|
6857 |
|
6858 |
|
6859 | var SwipeRecognizer = function (_AttrRecognizer) {
|
6860 | _inheritsLoose(SwipeRecognizer, _AttrRecognizer);
|
6861 |
|
6862 | function SwipeRecognizer(options) {
|
6863 | if (options === void 0) {
|
6864 | options = {};
|
6865 | }
|
6866 |
|
6867 | return _AttrRecognizer.call(this, _extends({
|
6868 | event: 'swipe',
|
6869 | threshold: 10,
|
6870 | velocity: 0.3,
|
6871 | direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
6872 | pointers: 1
|
6873 | }, options)) || this;
|
6874 | }
|
6875 |
|
6876 | var _proto = SwipeRecognizer.prototype;
|
6877 |
|
6878 | _proto.getTouchAction = function getTouchAction() {
|
6879 | return PanRecognizer.prototype.getTouchAction.call(this);
|
6880 | };
|
6881 |
|
6882 | _proto.attrTest = function attrTest(input) {
|
6883 | var direction = this.options.direction;
|
6884 | var velocity;
|
6885 |
|
6886 | if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
6887 | velocity = input.overallVelocity;
|
6888 | } else if (direction & DIRECTION_HORIZONTAL) {
|
6889 | velocity = input.overallVelocityX;
|
6890 | } else if (direction & DIRECTION_VERTICAL) {
|
6891 | velocity = input.overallVelocityY;
|
6892 | }
|
6893 |
|
6894 | return _AttrRecognizer.prototype.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers === this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
6895 | };
|
6896 |
|
6897 | _proto.emit = function emit(input) {
|
6898 | var direction = directionStr(input.offsetDirection);
|
6899 |
|
6900 | if (direction) {
|
6901 | this.manager.emit(this.options.event + direction, input);
|
6902 | }
|
6903 |
|
6904 | this.manager.emit(this.options.event, input);
|
6905 | };
|
6906 |
|
6907 | return SwipeRecognizer;
|
6908 | }(AttrRecognizer);
|
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 |
|
6914 |
|
6915 |
|
6916 |
|
6917 |
|
6918 | var PinchRecognizer = function (_AttrRecognizer) {
|
6919 | _inheritsLoose(PinchRecognizer, _AttrRecognizer);
|
6920 |
|
6921 | function PinchRecognizer(options) {
|
6922 | if (options === void 0) {
|
6923 | options = {};
|
6924 | }
|
6925 |
|
6926 | return _AttrRecognizer.call(this, _extends({
|
6927 | event: 'pinch',
|
6928 | threshold: 0,
|
6929 | pointers: 2
|
6930 | }, options)) || this;
|
6931 | }
|
6932 |
|
6933 | var _proto = PinchRecognizer.prototype;
|
6934 |
|
6935 | _proto.getTouchAction = function getTouchAction() {
|
6936 | return [TOUCH_ACTION_NONE];
|
6937 | };
|
6938 |
|
6939 | _proto.attrTest = function attrTest(input) {
|
6940 | return _AttrRecognizer.prototype.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
6941 | };
|
6942 |
|
6943 | _proto.emit = function emit(input) {
|
6944 | if (input.scale !== 1) {
|
6945 | var inOut = input.scale < 1 ? 'in' : 'out';
|
6946 | input.additionalEvent = this.options.event + inOut;
|
6947 | }
|
6948 |
|
6949 | _AttrRecognizer.prototype.emit.call(this, input);
|
6950 | };
|
6951 |
|
6952 | return PinchRecognizer;
|
6953 | }(AttrRecognizer);
|
6954 |
|
6955 |
|
6956 |
|
6957 |
|
6958 |
|
6959 |
|
6960 |
|
6961 |
|
6962 |
|
6963 | var RotateRecognizer = function (_AttrRecognizer) {
|
6964 | _inheritsLoose(RotateRecognizer, _AttrRecognizer);
|
6965 |
|
6966 | function RotateRecognizer(options) {
|
6967 | if (options === void 0) {
|
6968 | options = {};
|
6969 | }
|
6970 |
|
6971 | return _AttrRecognizer.call(this, _extends({
|
6972 | event: 'rotate',
|
6973 | threshold: 0,
|
6974 | pointers: 2
|
6975 | }, options)) || this;
|
6976 | }
|
6977 |
|
6978 | var _proto = RotateRecognizer.prototype;
|
6979 |
|
6980 | _proto.getTouchAction = function getTouchAction() {
|
6981 | return [TOUCH_ACTION_NONE];
|
6982 | };
|
6983 |
|
6984 | _proto.attrTest = function attrTest(input) {
|
6985 | return _AttrRecognizer.prototype.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
6986 | };
|
6987 |
|
6988 | return RotateRecognizer;
|
6989 | }(AttrRecognizer);
|
6990 |
|
6991 |
|
6992 |
|
6993 |
|
6994 |
|
6995 |
|
6996 |
|
6997 |
|
6998 |
|
6999 | var PressRecognizer = function (_Recognizer) {
|
7000 | _inheritsLoose(PressRecognizer, _Recognizer);
|
7001 |
|
7002 | function PressRecognizer(options) {
|
7003 | var _this;
|
7004 |
|
7005 | if (options === void 0) {
|
7006 | options = {};
|
7007 | }
|
7008 |
|
7009 | _this = _Recognizer.call(this, _extends({
|
7010 | event: 'press',
|
7011 | pointers: 1,
|
7012 | time: 251,
|
7013 |
|
7014 | threshold: 9
|
7015 | }, options)) || this;
|
7016 | _this._timer = null;
|
7017 | _this._input = null;
|
7018 | return _this;
|
7019 | }
|
7020 |
|
7021 | var _proto = PressRecognizer.prototype;
|
7022 |
|
7023 | _proto.getTouchAction = function getTouchAction() {
|
7024 | return [TOUCH_ACTION_AUTO];
|
7025 | };
|
7026 |
|
7027 | _proto.process = function process(input) {
|
7028 | var _this2 = this;
|
7029 |
|
7030 | var options = this.options;
|
7031 | var validPointers = input.pointers.length === options.pointers;
|
7032 | var validMovement = input.distance < options.threshold;
|
7033 | var validTime = input.deltaTime > options.time;
|
7034 | this._input = input;
|
7035 |
|
7036 |
|
7037 | if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
|
7038 | this.reset();
|
7039 | } else if (input.eventType & INPUT_START) {
|
7040 | this.reset();
|
7041 | this._timer = setTimeout(function () {
|
7042 | _this2.state = STATE_RECOGNIZED;
|
7043 |
|
7044 | _this2.tryEmit();
|
7045 | }, options.time);
|
7046 | } else if (input.eventType & INPUT_END) {
|
7047 | return STATE_RECOGNIZED;
|
7048 | }
|
7049 |
|
7050 | return STATE_FAILED;
|
7051 | };
|
7052 |
|
7053 | _proto.reset = function reset() {
|
7054 | clearTimeout(this._timer);
|
7055 | };
|
7056 |
|
7057 | _proto.emit = function emit(input) {
|
7058 | if (this.state !== STATE_RECOGNIZED) {
|
7059 | return;
|
7060 | }
|
7061 |
|
7062 | if (input && input.eventType & INPUT_END) {
|
7063 | this.manager.emit(this.options.event + "up", input);
|
7064 | } else {
|
7065 | this._input.timeStamp = now();
|
7066 | this.manager.emit(this.options.event, this._input);
|
7067 | }
|
7068 | };
|
7069 |
|
7070 | return PressRecognizer;
|
7071 | }(Recognizer);
|
7072 |
|
7073 | var defaults = {
|
7074 | |
7075 |
|
7076 |
|
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 | domEvents: false,
|
7082 |
|
7083 | |
7084 |
|
7085 |
|
7086 |
|
7087 |
|
7088 |
|
7089 |
|
7090 | touchAction: TOUCH_ACTION_COMPUTE,
|
7091 |
|
7092 | |
7093 |
|
7094 |
|
7095 |
|
7096 |
|
7097 | enable: true,
|
7098 |
|
7099 | |
7100 |
|
7101 |
|
7102 |
|
7103 |
|
7104 |
|
7105 |
|
7106 |
|
7107 | inputTarget: null,
|
7108 |
|
7109 | |
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 |
|
7115 | inputClass: null,
|
7116 |
|
7117 | |
7118 |
|
7119 |
|
7120 |
|
7121 |
|
7122 |
|
7123 | cssProps: {
|
7124 | |
7125 |
|
7126 |
|
7127 |
|
7128 |
|
7129 |
|
7130 | userSelect: "none",
|
7131 |
|
7132 | |
7133 |
|
7134 |
|
7135 |
|
7136 |
|
7137 |
|
7138 | touchSelect: "none",
|
7139 |
|
7140 | |
7141 |
|
7142 |
|
7143 |
|
7144 |
|
7145 |
|
7146 |
|
7147 |
|
7148 | touchCallout: "none",
|
7149 |
|
7150 | |
7151 |
|
7152 |
|
7153 |
|
7154 |
|
7155 |
|
7156 | contentZooming: "none",
|
7157 |
|
7158 | |
7159 |
|
7160 |
|
7161 |
|
7162 |
|
7163 |
|
7164 | userDrag: "none",
|
7165 |
|
7166 | |
7167 |
|
7168 |
|
7169 |
|
7170 |
|
7171 |
|
7172 |
|
7173 | tapHighlightColor: "rgba(0,0,0,0)"
|
7174 | }
|
7175 | };
|
7176 |
|
7177 |
|
7178 |
|
7179 |
|
7180 |
|
7181 |
|
7182 |
|
7183 |
|
7184 | var preset = [[RotateRecognizer, {
|
7185 | enable: false
|
7186 | }], [PinchRecognizer, {
|
7187 | enable: false
|
7188 | }, ['rotate']], [SwipeRecognizer, {
|
7189 | direction: DIRECTION_HORIZONTAL
|
7190 | }], [PanRecognizer, {
|
7191 | direction: DIRECTION_HORIZONTAL
|
7192 | }, ['swipe']], [TapRecognizer], [TapRecognizer, {
|
7193 | event: 'doubletap',
|
7194 | taps: 2
|
7195 | }, ['tap']], [PressRecognizer]];
|
7196 | var STOP = 1;
|
7197 | var FORCED_STOP = 2;
|
7198 |
|
7199 |
|
7200 |
|
7201 |
|
7202 |
|
7203 |
|
7204 |
|
7205 | function toggleCssProps(manager, add) {
|
7206 | var element = manager.element;
|
7207 |
|
7208 | if (!element.style) {
|
7209 | return;
|
7210 | }
|
7211 |
|
7212 | var prop;
|
7213 | each(manager.options.cssProps, function (value, name) {
|
7214 | prop = prefixed(element.style, name);
|
7215 |
|
7216 | if (add) {
|
7217 | manager.oldCssProps[prop] = element.style[prop];
|
7218 | element.style[prop] = value;
|
7219 | } else {
|
7220 | element.style[prop] = manager.oldCssProps[prop] || "";
|
7221 | }
|
7222 | });
|
7223 |
|
7224 | if (!add) {
|
7225 | manager.oldCssProps = {};
|
7226 | }
|
7227 | }
|
7228 |
|
7229 |
|
7230 |
|
7231 |
|
7232 |
|
7233 |
|
7234 |
|
7235 |
|
7236 | function triggerDomEvent(event, data) {
|
7237 | var gestureEvent = document.createEvent("Event");
|
7238 | gestureEvent.initEvent(event, true, true);
|
7239 | gestureEvent.gesture = data;
|
7240 | data.target.dispatchEvent(gestureEvent);
|
7241 | }
|
7242 |
|
7243 |
|
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 |
|
7249 |
|
7250 |
|
7251 | var Manager = function () {
|
7252 | function Manager(element, options) {
|
7253 | var _this = this;
|
7254 |
|
7255 | this.options = assign$1({}, defaults, options || {});
|
7256 | this.options.inputTarget = this.options.inputTarget || element;
|
7257 | this.handlers = {};
|
7258 | this.session = {};
|
7259 | this.recognizers = [];
|
7260 | this.oldCssProps = {};
|
7261 | this.element = element;
|
7262 | this.input = createInputInstance(this);
|
7263 | this.touchAction = new TouchAction(this, this.options.touchAction);
|
7264 | toggleCssProps(this, true);
|
7265 | each(this.options.recognizers, function (item) {
|
7266 | var recognizer = _this.add(new item[0](item[1]));
|
7267 |
|
7268 | item[2] && recognizer.recognizeWith(item[2]);
|
7269 | item[3] && recognizer.requireFailure(item[3]);
|
7270 | }, this);
|
7271 | }
|
7272 | |
7273 |
|
7274 |
|
7275 |
|
7276 |
|
7277 |
|
7278 |
|
7279 |
|
7280 | var _proto = Manager.prototype;
|
7281 |
|
7282 | _proto.set = function set(options) {
|
7283 | assign$1(this.options, options);
|
7284 |
|
7285 | if (options.touchAction) {
|
7286 | this.touchAction.update();
|
7287 | }
|
7288 |
|
7289 | if (options.inputTarget) {
|
7290 |
|
7291 | this.input.destroy();
|
7292 | this.input.target = options.inputTarget;
|
7293 | this.input.init();
|
7294 | }
|
7295 |
|
7296 | return this;
|
7297 | };
|
7298 | |
7299 |
|
7300 |
|
7301 |
|
7302 |
|
7303 |
|
7304 |
|
7305 |
|
7306 |
|
7307 | _proto.stop = function stop(force) {
|
7308 | this.session.stopped = force ? FORCED_STOP : STOP;
|
7309 | };
|
7310 | |
7311 |
|
7312 |
|
7313 |
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 |
|
7319 | _proto.recognize = function recognize(inputData) {
|
7320 | var session = this.session;
|
7321 |
|
7322 | if (session.stopped) {
|
7323 | return;
|
7324 | }
|
7325 |
|
7326 |
|
7327 | this.touchAction.preventDefaults(inputData);
|
7328 | var recognizer;
|
7329 | var recognizers = this.recognizers;
|
7330 |
|
7331 |
|
7332 |
|
7333 | var curRecognizer = session.curRecognizer;
|
7334 |
|
7335 |
|
7336 | if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
|
7337 | session.curRecognizer = null;
|
7338 | curRecognizer = null;
|
7339 | }
|
7340 |
|
7341 | var i = 0;
|
7342 |
|
7343 | while (i < recognizers.length) {
|
7344 | recognizer = recognizers[i];
|
7345 |
|
7346 |
|
7347 |
|
7348 |
|
7349 |
|
7350 |
|
7351 | if (session.stopped !== FORCED_STOP && (
|
7352 | !curRecognizer || recognizer === curRecognizer ||
|
7353 | recognizer.canRecognizeWith(curRecognizer))) {
|
7354 |
|
7355 | recognizer.recognize(inputData);
|
7356 | } else {
|
7357 | recognizer.reset();
|
7358 | }
|
7359 |
|
7360 |
|
7361 |
|
7362 | if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
7363 | session.curRecognizer = recognizer;
|
7364 | curRecognizer = recognizer;
|
7365 | }
|
7366 |
|
7367 | i++;
|
7368 | }
|
7369 | };
|
7370 | |
7371 |
|
7372 |
|
7373 |
|
7374 |
|
7375 |
|
7376 |
|
7377 |
|
7378 | _proto.get = function get(recognizer) {
|
7379 | if (recognizer instanceof Recognizer) {
|
7380 | return recognizer;
|
7381 | }
|
7382 |
|
7383 | var recognizers = this.recognizers;
|
7384 |
|
7385 | for (var i = 0; i < recognizers.length; i++) {
|
7386 | if (recognizers[i].options.event === recognizer) {
|
7387 | return recognizers[i];
|
7388 | }
|
7389 | }
|
7390 |
|
7391 | return null;
|
7392 | };
|
7393 | |
7394 |
|
7395 |
|
7396 |
|
7397 |
|
7398 |
|
7399 |
|
7400 |
|
7401 | _proto.add = function add(recognizer) {
|
7402 | if (invokeArrayArg(recognizer, "add", this)) {
|
7403 | return this;
|
7404 | }
|
7405 |
|
7406 |
|
7407 | var existing = this.get(recognizer.options.event);
|
7408 |
|
7409 | if (existing) {
|
7410 | this.remove(existing);
|
7411 | }
|
7412 |
|
7413 | this.recognizers.push(recognizer);
|
7414 | recognizer.manager = this;
|
7415 | this.touchAction.update();
|
7416 | return recognizer;
|
7417 | };
|
7418 | |
7419 |
|
7420 |
|
7421 |
|
7422 |
|
7423 |
|
7424 |
|
7425 |
|
7426 | _proto.remove = function remove(recognizer) {
|
7427 | if (invokeArrayArg(recognizer, "remove", this)) {
|
7428 | return this;
|
7429 | }
|
7430 |
|
7431 | var targetRecognizer = this.get(recognizer);
|
7432 |
|
7433 | if (recognizer) {
|
7434 | var recognizers = this.recognizers;
|
7435 | var index = inArray(recognizers, targetRecognizer);
|
7436 |
|
7437 | if (index !== -1) {
|
7438 | recognizers.splice(index, 1);
|
7439 | this.touchAction.update();
|
7440 | }
|
7441 | }
|
7442 |
|
7443 | return this;
|
7444 | };
|
7445 | |
7446 |
|
7447 |
|
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 |
|
7453 |
|
7454 | _proto.on = function on(events, handler) {
|
7455 | if (events === undefined || handler === undefined) {
|
7456 | return this;
|
7457 | }
|
7458 |
|
7459 | var handlers = this.handlers;
|
7460 | each(splitStr(events), function (event) {
|
7461 | handlers[event] = handlers[event] || [];
|
7462 | handlers[event].push(handler);
|
7463 | });
|
7464 | return this;
|
7465 | };
|
7466 | |
7467 |
|
7468 |
|
7469 |
|
7470 |
|
7471 |
|
7472 |
|
7473 |
|
7474 | _proto.off = function off(events, handler) {
|
7475 | if (events === undefined) {
|
7476 | return this;
|
7477 | }
|
7478 |
|
7479 | var handlers = this.handlers;
|
7480 | each(splitStr(events), function (event) {
|
7481 | if (!handler) {
|
7482 | delete handlers[event];
|
7483 | } else {
|
7484 | handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
7485 | }
|
7486 | });
|
7487 | return this;
|
7488 | };
|
7489 | |
7490 |
|
7491 |
|
7492 |
|
7493 |
|
7494 |
|
7495 |
|
7496 | _proto.emit = function emit(event, data) {
|
7497 |
|
7498 | if (this.options.domEvents) {
|
7499 | triggerDomEvent(event, data);
|
7500 | }
|
7501 |
|
7502 |
|
7503 | var handlers = this.handlers[event] && this.handlers[event].slice();
|
7504 |
|
7505 | if (!handlers || !handlers.length) {
|
7506 | return;
|
7507 | }
|
7508 |
|
7509 | data.type = event;
|
7510 |
|
7511 | data.preventDefault = function () {
|
7512 | data.srcEvent.preventDefault();
|
7513 | };
|
7514 |
|
7515 | var i = 0;
|
7516 |
|
7517 | while (i < handlers.length) {
|
7518 | handlers[i](data);
|
7519 | i++;
|
7520 | }
|
7521 | };
|
7522 | |
7523 |
|
7524 |
|
7525 |
|
7526 |
|
7527 |
|
7528 |
|
7529 | _proto.destroy = function destroy() {
|
7530 | this.element && toggleCssProps(this, false);
|
7531 | this.handlers = {};
|
7532 | this.session = {};
|
7533 | this.input.destroy();
|
7534 | this.element = null;
|
7535 | };
|
7536 |
|
7537 | return Manager;
|
7538 | }();
|
7539 |
|
7540 | var SINGLE_TOUCH_INPUT_MAP = {
|
7541 | touchstart: INPUT_START,
|
7542 | touchmove: INPUT_MOVE,
|
7543 | touchend: INPUT_END,
|
7544 | touchcancel: INPUT_CANCEL
|
7545 | };
|
7546 | var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
7547 | var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
7548 |
|
7549 |
|
7550 |
|
7551 |
|
7552 |
|
7553 |
|
7554 |
|
7555 | var SingleTouchInput = function (_Input) {
|
7556 | _inheritsLoose(SingleTouchInput, _Input);
|
7557 |
|
7558 | function SingleTouchInput() {
|
7559 | var _this;
|
7560 |
|
7561 | var proto = SingleTouchInput.prototype;
|
7562 | proto.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
7563 | proto.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
7564 | _this = _Input.apply(this, arguments) || this;
|
7565 | _this.started = false;
|
7566 | return _this;
|
7567 | }
|
7568 |
|
7569 | var _proto = SingleTouchInput.prototype;
|
7570 |
|
7571 | _proto.handler = function handler(ev) {
|
7572 | var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
7573 |
|
7574 | if (type === INPUT_START) {
|
7575 | this.started = true;
|
7576 | }
|
7577 |
|
7578 | if (!this.started) {
|
7579 | return;
|
7580 | }
|
7581 |
|
7582 | var touches = normalizeSingleTouches.call(this, ev, type);
|
7583 |
|
7584 | if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
7585 | this.started = false;
|
7586 | }
|
7587 |
|
7588 | this.callback(this.manager, type, {
|
7589 | pointers: touches[0],
|
7590 | changedPointers: touches[1],
|
7591 | pointerType: INPUT_TYPE_TOUCH,
|
7592 | srcEvent: ev
|
7593 | });
|
7594 | };
|
7595 |
|
7596 | return SingleTouchInput;
|
7597 | }(Input);
|
7598 |
|
7599 | function normalizeSingleTouches(ev, type) {
|
7600 | var all = toArray$1(ev.touches);
|
7601 | var changed = toArray$1(ev.changedTouches);
|
7602 |
|
7603 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
7604 | all = uniqueArray(all.concat(changed), 'identifier', true);
|
7605 | }
|
7606 |
|
7607 | return [all, changed];
|
7608 | }
|
7609 |
|
7610 |
|
7611 |
|
7612 |
|
7613 |
|
7614 |
|
7615 |
|
7616 |
|
7617 |
|
7618 |
|
7619 | function deprecate(method, name, message) {
|
7620 | var deprecationMessage = "DEPRECATED METHOD: " + name + "\n" + message + " AT \n";
|
7621 | return function () {
|
7622 | var e = new Error('get-stack-trace');
|
7623 | var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
|
7624 | var log = window.console && (window.console.warn || window.console.log);
|
7625 |
|
7626 | if (log) {
|
7627 | log.call(window.console, deprecationMessage, stack);
|
7628 | }
|
7629 |
|
7630 | return method.apply(this, arguments);
|
7631 | };
|
7632 | }
|
7633 |
|
7634 |
|
7635 |
|
7636 |
|
7637 |
|
7638 |
|
7639 |
|
7640 |
|
7641 |
|
7642 |
|
7643 |
|
7644 | var extend$1 = deprecate(function (dest, src, merge) {
|
7645 | var keys = Object.keys(src);
|
7646 | var i = 0;
|
7647 |
|
7648 | while (i < keys.length) {
|
7649 | if (!merge || merge && dest[keys[i]] === undefined) {
|
7650 | dest[keys[i]] = src[keys[i]];
|
7651 | }
|
7652 |
|
7653 | i++;
|
7654 | }
|
7655 |
|
7656 | return dest;
|
7657 | }, 'extend', 'Use `assign`.');
|
7658 |
|
7659 |
|
7660 |
|
7661 |
|
7662 |
|
7663 |
|
7664 |
|
7665 |
|
7666 |
|
7667 | var merge$1 = deprecate(function (dest, src) {
|
7668 | return extend$1(dest, src, true);
|
7669 | }, 'merge', 'Use `assign`.');
|
7670 |
|
7671 |
|
7672 |
|
7673 |
|
7674 |
|
7675 |
|
7676 |
|
7677 |
|
7678 | function inherit(child, base, properties) {
|
7679 | var baseP = base.prototype;
|
7680 | var childP;
|
7681 | childP = child.prototype = Object.create(baseP);
|
7682 | childP.constructor = child;
|
7683 | childP._super = baseP;
|
7684 |
|
7685 | if (properties) {
|
7686 | assign$1(childP, properties);
|
7687 | }
|
7688 | }
|
7689 |
|
7690 |
|
7691 |
|
7692 |
|
7693 |
|
7694 |
|
7695 |
|
7696 |
|
7697 |
|
7698 | function bindFn(fn, context) {
|
7699 | return function boundFn() {
|
7700 | return fn.apply(context, arguments);
|
7701 | };
|
7702 | }
|
7703 |
|
7704 |
|
7705 |
|
7706 |
|
7707 |
|
7708 |
|
7709 |
|
7710 |
|
7711 |
|
7712 | var Hammer$3 = function () {
|
7713 | var Hammer =
|
7714 | |
7715 |
|
7716 |
|
7717 |
|
7718 | function Hammer(element, options) {
|
7719 | if (options === void 0) {
|
7720 | options = {};
|
7721 | }
|
7722 |
|
7723 | return new Manager(element, _extends({
|
7724 | recognizers: preset.concat()
|
7725 | }, options));
|
7726 | };
|
7727 |
|
7728 | Hammer.VERSION = "2.0.17-rc";
|
7729 | Hammer.DIRECTION_ALL = DIRECTION_ALL;
|
7730 | Hammer.DIRECTION_DOWN = DIRECTION_DOWN;
|
7731 | Hammer.DIRECTION_LEFT = DIRECTION_LEFT;
|
7732 | Hammer.DIRECTION_RIGHT = DIRECTION_RIGHT;
|
7733 | Hammer.DIRECTION_UP = DIRECTION_UP;
|
7734 | Hammer.DIRECTION_HORIZONTAL = DIRECTION_HORIZONTAL;
|
7735 | Hammer.DIRECTION_VERTICAL = DIRECTION_VERTICAL;
|
7736 | Hammer.DIRECTION_NONE = DIRECTION_NONE;
|
7737 | Hammer.DIRECTION_DOWN = DIRECTION_DOWN;
|
7738 | Hammer.INPUT_START = INPUT_START;
|
7739 | Hammer.INPUT_MOVE = INPUT_MOVE;
|
7740 | Hammer.INPUT_END = INPUT_END;
|
7741 | Hammer.INPUT_CANCEL = INPUT_CANCEL;
|
7742 | Hammer.STATE_POSSIBLE = STATE_POSSIBLE;
|
7743 | Hammer.STATE_BEGAN = STATE_BEGAN;
|
7744 | Hammer.STATE_CHANGED = STATE_CHANGED;
|
7745 | Hammer.STATE_ENDED = STATE_ENDED;
|
7746 | Hammer.STATE_RECOGNIZED = STATE_RECOGNIZED;
|
7747 | Hammer.STATE_CANCELLED = STATE_CANCELLED;
|
7748 | Hammer.STATE_FAILED = STATE_FAILED;
|
7749 | Hammer.Manager = Manager;
|
7750 | Hammer.Input = Input;
|
7751 | Hammer.TouchAction = TouchAction;
|
7752 | Hammer.TouchInput = TouchInput;
|
7753 | Hammer.MouseInput = MouseInput;
|
7754 | Hammer.PointerEventInput = PointerEventInput;
|
7755 | Hammer.TouchMouseInput = TouchMouseInput;
|
7756 | Hammer.SingleTouchInput = SingleTouchInput;
|
7757 | Hammer.Recognizer = Recognizer;
|
7758 | Hammer.AttrRecognizer = AttrRecognizer;
|
7759 | Hammer.Tap = TapRecognizer;
|
7760 | Hammer.Pan = PanRecognizer;
|
7761 | Hammer.Swipe = SwipeRecognizer;
|
7762 | Hammer.Pinch = PinchRecognizer;
|
7763 | Hammer.Rotate = RotateRecognizer;
|
7764 | Hammer.Press = PressRecognizer;
|
7765 | Hammer.on = addEventListeners;
|
7766 | Hammer.off = removeEventListeners;
|
7767 | Hammer.each = each;
|
7768 | Hammer.merge = merge$1;
|
7769 | Hammer.extend = extend$1;
|
7770 | Hammer.bindFn = bindFn;
|
7771 | Hammer.assign = assign$1;
|
7772 | Hammer.inherit = inherit;
|
7773 | Hammer.bindFn = bindFn;
|
7774 | Hammer.prefixed = prefixed;
|
7775 | Hammer.toArray = toArray$1;
|
7776 | Hammer.inArray = inArray;
|
7777 | Hammer.uniqueArray = uniqueArray;
|
7778 | Hammer.splitStr = splitStr;
|
7779 | Hammer.boolOrFn = boolOrFn;
|
7780 | Hammer.hasParent = hasParent$1;
|
7781 | Hammer.addEventListeners = addEventListeners;
|
7782 | Hammer.removeEventListeners = removeEventListeners;
|
7783 | Hammer.defaults = assign$1({}, defaults, {
|
7784 | preset: preset
|
7785 | });
|
7786 | return Hammer;
|
7787 | }();
|
7788 |
|
7789 |
|
7790 | Hammer$3.defaults;
|
7791 |
|
7792 | function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7793 |
|
7794 | function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context22, _context23; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context22 = ownKeys$1(Object(source), !0)).call(_context22, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context23 = ownKeys$1(Object(source))).call(_context23, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7795 |
|
7796 | function _createForOfIteratorHelper$6(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
7797 |
|
7798 | function _unsupportedIterableToArray$6(o, minLen) { var _context21; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = _sliceInstanceProperty(_context21 = Object.prototype.toString.call(o)).call(_context21, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
|
7799 |
|
7800 | function _arrayLikeToArray$6(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
7801 |
|
7802 |
|
7803 |
|
7804 |
|
7805 | var DELETE = _Symbol("DELETE");
|
7806 |
|
7807 |
|
7808 |
|
7809 |
|
7810 |
|
7811 |
|
7812 |
|
7813 |
|
7814 |
|
7815 | function pureDeepObjectAssign(base) {
|
7816 | var _context;
|
7817 |
|
7818 | for (var _len = arguments.length, updates = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
7819 | updates[_key - 1] = arguments[_key];
|
7820 | }
|
7821 |
|
7822 | return deepObjectAssign.apply(void 0, _concatInstanceProperty(_context = [{}, base]).call(_context, updates));
|
7823 | }
|
7824 |
|
7825 |
|
7826 |
|
7827 |
|
7828 |
|
7829 |
|
7830 |
|
7831 |
|
7832 | function deepObjectAssign() {
|
7833 | var merged = deepObjectAssignNonentry.apply(void 0, arguments);
|
7834 | stripDelete(merged);
|
7835 | return merged;
|
7836 | }
|
7837 |
|
7838 |
|
7839 |
|
7840 |
|
7841 |
|
7842 |
|
7843 |
|
7844 |
|
7845 |
|
7846 |
|
7847 | function deepObjectAssignNonentry() {
|
7848 | for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
7849 | values[_key2] = arguments[_key2];
|
7850 | }
|
7851 |
|
7852 | if (values.length < 2) {
|
7853 | return values[0];
|
7854 | } else if (values.length > 2) {
|
7855 | var _context2;
|
7856 |
|
7857 | return deepObjectAssignNonentry.apply(void 0, _concatInstanceProperty(_context2 = [deepObjectAssign(values[0], values[1])]).call(_context2, _toConsumableArray(_sliceInstanceProperty(values).call(values, 2))));
|
7858 | }
|
7859 |
|
7860 | var a = values[0];
|
7861 | var b = values[1];
|
7862 |
|
7863 | var _iterator = _createForOfIteratorHelper$6(_Reflect$ownKeys(b)),
|
7864 | _step;
|
7865 |
|
7866 | try {
|
7867 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
7868 | var prop = _step.value;
|
7869 | if (!Object.prototype.propertyIsEnumerable.call(b, prop)) ;else if (b[prop] === DELETE) {
|
7870 | delete a[prop];
|
7871 | } else if (a[prop] !== null && b[prop] !== null && _typeof(a[prop]) === "object" && _typeof(b[prop]) === "object" && !_Array$isArray$1(a[prop]) && !_Array$isArray$1(b[prop])) {
|
7872 | a[prop] = deepObjectAssignNonentry(a[prop], b[prop]);
|
7873 | } else {
|
7874 | a[prop] = clone(b[prop]);
|
7875 | }
|
7876 | }
|
7877 | } catch (err) {
|
7878 | _iterator.e(err);
|
7879 | } finally {
|
7880 | _iterator.f();
|
7881 | }
|
7882 |
|
7883 | return a;
|
7884 | }
|
7885 |
|
7886 |
|
7887 |
|
7888 |
|
7889 |
|
7890 |
|
7891 |
|
7892 |
|
7893 | function clone(a) {
|
7894 | if (_Array$isArray$1(a)) {
|
7895 | return _mapInstanceProperty(a).call(a, function (value) {
|
7896 | return clone(value);
|
7897 | });
|
7898 | } else if (_typeof(a) === "object" && a !== null) {
|
7899 | return deepObjectAssignNonentry({}, a);
|
7900 | } else {
|
7901 | return a;
|
7902 | }
|
7903 | }
|
7904 |
|
7905 |
|
7906 |
|
7907 |
|
7908 |
|
7909 |
|
7910 |
|
7911 | function stripDelete(a) {
|
7912 | for (var _i = 0, _Object$keys$1 = _Object$keys(a); _i < _Object$keys$1.length; _i++) {
|
7913 | var prop = _Object$keys$1[_i];
|
7914 |
|
7915 | if (a[prop] === DELETE) {
|
7916 | delete a[prop];
|
7917 | } else if (_typeof(a[prop]) === "object" && a[prop] !== null) {
|
7918 | stripDelete(a[prop]);
|
7919 | }
|
7920 | }
|
7921 | }
|
7922 |
|
7923 |
|
7924 |
|
7925 |
|
7926 |
|
7927 |
|
7928 |
|
7929 |
|
7930 |
|
7931 |
|
7932 |
|
7933 |
|
7934 |
|
7935 |
|
7936 |
|
7937 |
|
7938 |
|
7939 |
|
7940 | function Alea() {
|
7941 | for (var _len3 = arguments.length, seed = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
7942 | seed[_key3] = arguments[_key3];
|
7943 | }
|
7944 |
|
7945 | return AleaImplementation(seed.length ? seed : [_Date$now()]);
|
7946 | }
|
7947 |
|
7948 |
|
7949 |
|
7950 |
|
7951 |
|
7952 |
|
7953 |
|
7954 |
|
7955 | function AleaImplementation(seed) {
|
7956 | var _mashSeed = mashSeed(seed),
|
7957 | _mashSeed2 = _slicedToArray(_mashSeed, 3),
|
7958 | s0 = _mashSeed2[0],
|
7959 | s1 = _mashSeed2[1],
|
7960 | s2 = _mashSeed2[2];
|
7961 |
|
7962 | var c = 1;
|
7963 |
|
7964 | var random = function random() {
|
7965 | var t = 2091639 * s0 + c * 2.3283064365386963e-10;
|
7966 |
|
7967 | s0 = s1;
|
7968 | s1 = s2;
|
7969 | return s2 = t - (c = t | 0);
|
7970 | };
|
7971 |
|
7972 | random.uint32 = function () {
|
7973 | return random() * 0x100000000;
|
7974 | };
|
7975 |
|
7976 |
|
7977 | random.fract53 = function () {
|
7978 | return random() + (random() * 0x200000 | 0) * 1.1102230246251565e-16;
|
7979 | };
|
7980 |
|
7981 |
|
7982 | random.algorithm = "Alea";
|
7983 | random.seed = seed;
|
7984 | random.version = "0.9";
|
7985 | return random;
|
7986 | }
|
7987 |
|
7988 |
|
7989 |
|
7990 |
|
7991 |
|
7992 |
|
7993 |
|
7994 |
|
7995 |
|
7996 | function mashSeed() {
|
7997 | var mash = Mash();
|
7998 | var s0 = mash(" ");
|
7999 | var s1 = mash(" ");
|
8000 | var s2 = mash(" ");
|
8001 |
|
8002 | for (var i = 0; i < arguments.length; i++) {
|
8003 | s0 -= mash(i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
8004 |
|
8005 | if (s0 < 0) {
|
8006 | s0 += 1;
|
8007 | }
|
8008 |
|
8009 | s1 -= mash(i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
8010 |
|
8011 | if (s1 < 0) {
|
8012 | s1 += 1;
|
8013 | }
|
8014 |
|
8015 | s2 -= mash(i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
8016 |
|
8017 | if (s2 < 0) {
|
8018 | s2 += 1;
|
8019 | }
|
8020 | }
|
8021 |
|
8022 | return [s0, s1, s2];
|
8023 | }
|
8024 |
|
8025 |
|
8026 |
|
8027 |
|
8028 |
|
8029 |
|
8030 |
|
8031 |
|
8032 | function Mash() {
|
8033 | var n = 0xefc8249d;
|
8034 | return function (data) {
|
8035 | var string = data.toString();
|
8036 |
|
8037 | for (var i = 0; i < string.length; i++) {
|
8038 | n += string.charCodeAt(i);
|
8039 | var h = 0.02519603282416938 * n;
|
8040 | n = h >>> 0;
|
8041 | h -= n;
|
8042 | h *= n;
|
8043 | n = h >>> 0;
|
8044 | h -= n;
|
8045 | n += h * 0x100000000;
|
8046 | }
|
8047 |
|
8048 | return (n >>> 0) * 2.3283064365386963e-10;
|
8049 | };
|
8050 | }
|
8051 |
|
8052 |
|
8053 |
|
8054 |
|
8055 |
|
8056 |
|
8057 |
|
8058 |
|
8059 |
|
8060 | function hammerMock$1() {
|
8061 | var noop = function noop() {};
|
8062 |
|
8063 | return {
|
8064 | on: noop,
|
8065 | off: noop,
|
8066 | destroy: noop,
|
8067 | emit: noop,
|
8068 | get: function get() {
|
8069 | return {
|
8070 | set: noop
|
8071 | };
|
8072 | }
|
8073 | };
|
8074 | }
|
8075 |
|
8076 | var Hammer$1 = typeof window !== "undefined" ? window.Hammer || Hammer$3 : function () {
|
8077 |
|
8078 | return hammerMock$1();
|
8079 | };
|
8080 |
|
8081 |
|
8082 |
|
8083 |
|
8084 |
|
8085 |
|
8086 |
|
8087 |
|
8088 |
|
8089 |
|
8090 |
|
8091 |
|
8092 | function Activator$1(container) {
|
8093 | var _this = this,
|
8094 | _context3;
|
8095 |
|
8096 | this._cleanupQueue = [];
|
8097 | this.active = false;
|
8098 | this._dom = {
|
8099 | container: container,
|
8100 | overlay: document.createElement("div")
|
8101 | };
|
8102 |
|
8103 | this._dom.overlay.classList.add("vis-overlay");
|
8104 |
|
8105 | this._dom.container.appendChild(this._dom.overlay);
|
8106 |
|
8107 | this._cleanupQueue.push(function () {
|
8108 | _this._dom.overlay.parentNode.removeChild(_this._dom.overlay);
|
8109 | });
|
8110 |
|
8111 | var hammer = Hammer$1(this._dom.overlay);
|
8112 | hammer.on("tap", _bindInstanceProperty(_context3 = this._onTapOverlay).call(_context3, this));
|
8113 |
|
8114 | this._cleanupQueue.push(function () {
|
8115 | hammer.destroy();
|
8116 |
|
8117 | });
|
8118 |
|
8119 |
|
8120 | var events = ["tap", "doubletap", "press", "pinch", "pan", "panstart", "panmove", "panend"];
|
8121 |
|
8122 | _forEachInstanceProperty(events).call(events, function (event) {
|
8123 | hammer.on(event, function (event) {
|
8124 | event.srcEvent.stopPropagation();
|
8125 | });
|
8126 | });
|
8127 |
|
8128 |
|
8129 | if (document && document.body) {
|
8130 | this._onClick = function (event) {
|
8131 | if (!_hasParent$1(event.target, container)) {
|
8132 | _this.deactivate();
|
8133 | }
|
8134 | };
|
8135 |
|
8136 | document.body.addEventListener("click", this._onClick);
|
8137 |
|
8138 | this._cleanupQueue.push(function () {
|
8139 | document.body.removeEventListener("click", _this._onClick);
|
8140 | });
|
8141 | }
|
8142 |
|
8143 |
|
8144 | this._escListener = function (event) {
|
8145 | if ("key" in event ? event.key === "Escape" : event.keyCode === 27
|
8146 |
|
8147 | ) {
|
8148 | _this.deactivate();
|
8149 | }
|
8150 | };
|
8151 | }
|
8152 |
|
8153 |
|
8154 | Emitter(Activator$1.prototype);
|
8155 |
|
8156 | Activator$1.current = null;
|
8157 |
|
8158 |
|
8159 |
|
8160 |
|
8161 | Activator$1.prototype.destroy = function () {
|
8162 | var _context4, _context5;
|
8163 |
|
8164 | this.deactivate();
|
8165 |
|
8166 | var _iterator2 = _createForOfIteratorHelper$6(_reverseInstanceProperty(_context4 = _spliceInstanceProperty(_context5 = this._cleanupQueue).call(_context5, 0)).call(_context4)),
|
8167 | _step2;
|
8168 |
|
8169 | try {
|
8170 | for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
8171 | var callback = _step2.value;
|
8172 | callback();
|
8173 | }
|
8174 | } catch (err) {
|
8175 | _iterator2.e(err);
|
8176 | } finally {
|
8177 | _iterator2.f();
|
8178 | }
|
8179 | };
|
8180 |
|
8181 |
|
8182 |
|
8183 |
|
8184 |
|
8185 |
|
8186 | Activator$1.prototype.activate = function () {
|
8187 |
|
8188 | if (Activator$1.current) {
|
8189 | Activator$1.current.deactivate();
|
8190 | }
|
8191 |
|
8192 | Activator$1.current = this;
|
8193 | this.active = true;
|
8194 | this._dom.overlay.style.display = "none";
|
8195 |
|
8196 | this._dom.container.classList.add("vis-active");
|
8197 |
|
8198 | this.emit("change");
|
8199 | this.emit("activate");
|
8200 |
|
8201 |
|
8202 | document.body.addEventListener("keydown", this._escListener);
|
8203 | };
|
8204 |
|
8205 |
|
8206 |
|
8207 |
|
8208 |
|
8209 |
|
8210 | Activator$1.prototype.deactivate = function () {
|
8211 | this.active = false;
|
8212 | this._dom.overlay.style.display = "block";
|
8213 |
|
8214 | this._dom.container.classList.remove("vis-active");
|
8215 |
|
8216 | document.body.removeEventListener("keydown", this._escListener);
|
8217 | this.emit("change");
|
8218 | this.emit("deactivate");
|
8219 | };
|
8220 |
|
8221 |
|
8222 |
|
8223 |
|
8224 |
|
8225 |
|
8226 |
|
8227 |
|
8228 | Activator$1.prototype._onTapOverlay = function (event) {
|
8229 |
|
8230 | this.activate();
|
8231 | event.srcEvent.stopPropagation();
|
8232 | };
|
8233 |
|
8234 |
|
8235 |
|
8236 |
|
8237 |
|
8238 |
|
8239 |
|
8240 |
|
8241 |
|
8242 |
|
8243 |
|
8244 |
|
8245 | function _hasParent$1(element, parent) {
|
8246 | while (element) {
|
8247 | if (element === parent) {
|
8248 | return true;
|
8249 | }
|
8250 |
|
8251 | element = element.parentNode;
|
8252 | }
|
8253 |
|
8254 | return false;
|
8255 | }
|
8256 |
|
8257 |
|
8258 |
|
8259 |
|
8260 |
|
8261 | var ASPDateRegex$1 = /^\/?Date\((-?\d+)/i;
|
8262 |
|
8263 | var fullHexRE = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
8264 | var shortHexRE = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
8265 | var rgbRE = /^rgb\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *\)$/i;
|
8266 | var rgbaRE = /^rgba\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *([01]|0?\.\d+) *\)$/i;
|
8267 |
|
8268 |
|
8269 |
|
8270 |
|
8271 |
|
8272 |
|
8273 |
|
8274 | function isNumber(value) {
|
8275 | return value instanceof Number || typeof value === "number";
|
8276 | }
|
8277 |
|
8278 |
|
8279 |
|
8280 |
|
8281 |
|
8282 |
|
8283 |
|
8284 | function recursiveDOMDelete(DOMobject) {
|
8285 | if (DOMobject) {
|
8286 | while (DOMobject.hasChildNodes() === true) {
|
8287 | var child = DOMobject.firstChild;
|
8288 |
|
8289 | if (child) {
|
8290 | recursiveDOMDelete(child);
|
8291 | DOMobject.removeChild(child);
|
8292 | }
|
8293 | }
|
8294 | }
|
8295 | }
|
8296 |
|
8297 |
|
8298 |
|
8299 |
|
8300 |
|
8301 |
|
8302 |
|
8303 |
|
8304 | function isString(value) {
|
8305 | return value instanceof String || typeof value === "string";
|
8306 | }
|
8307 |
|
8308 |
|
8309 |
|
8310 |
|
8311 |
|
8312 |
|
8313 |
|
8314 |
|
8315 | function isObject$3(value) {
|
8316 | return _typeof(value) === "object" && value !== null;
|
8317 | }
|
8318 |
|
8319 |
|
8320 |
|
8321 |
|
8322 |
|
8323 |
|
8324 |
|
8325 |
|
8326 | function isDate(value) {
|
8327 | if (value instanceof Date) {
|
8328 | return true;
|
8329 | } else if (isString(value)) {
|
8330 |
|
8331 | var match = ASPDateRegex$1.exec(value);
|
8332 |
|
8333 | if (match) {
|
8334 | return true;
|
8335 | } else if (!isNaN(Date.parse(value))) {
|
8336 | return true;
|
8337 | }
|
8338 | }
|
8339 |
|
8340 | return false;
|
8341 | }
|
8342 |
|
8343 |
|
8344 |
|
8345 |
|
8346 |
|
8347 |
|
8348 |
|
8349 |
|
8350 |
|
8351 |
|
8352 |
|
8353 |
|
8354 |
|
8355 | function copyOrDelete(a, b, prop, allowDeletion) {
|
8356 | var doDeletion = false;
|
8357 |
|
8358 | if (allowDeletion === true) {
|
8359 | doDeletion = b[prop] === null && a[prop] !== undefined;
|
8360 | }
|
8361 |
|
8362 | if (doDeletion) {
|
8363 | delete a[prop];
|
8364 | } else {
|
8365 | a[prop] = b[prop];
|
8366 | }
|
8367 | }
|
8368 |
|
8369 |
|
8370 |
|
8371 |
|
8372 |
|
8373 |
|
8374 |
|
8375 |
|
8376 |
|
8377 |
|
8378 |
|
8379 |
|
8380 | function fillIfDefined(a, b) {
|
8381 | var allowDeletion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
8382 |
|
8383 |
|
8384 |
|
8385 | for (var prop in a) {
|
8386 | if (b[prop] !== undefined) {
|
8387 | if (b[prop] === null || _typeof(b[prop]) !== "object") {
|
8388 |
|
8389 | copyOrDelete(a, b, prop, allowDeletion);
|
8390 | } else {
|
8391 | var aProp = a[prop];
|
8392 | var bProp = b[prop];
|
8393 |
|
8394 | if (isObject$3(aProp) && isObject$3(bProp)) {
|
8395 | fillIfDefined(aProp, bProp, allowDeletion);
|
8396 | }
|
8397 | }
|
8398 | }
|
8399 | }
|
8400 | }
|
8401 |
|
8402 |
|
8403 |
|
8404 |
|
8405 |
|
8406 |
|
8407 |
|
8408 |
|
8409 |
|
8410 |
|
8411 | var extend = _Object$assign;
|
8412 |
|
8413 |
|
8414 |
|
8415 |
|
8416 |
|
8417 |
|
8418 |
|
8419 |
|
8420 |
|
8421 |
|
8422 |
|
8423 | function selectiveExtend(props, a) {
|
8424 | if (!_Array$isArray$1(props)) {
|
8425 | throw new Error("Array with property names expected as first argument");
|
8426 | }
|
8427 |
|
8428 | for (var _len4 = arguments.length, others = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
8429 | others[_key4 - 2] = arguments[_key4];
|
8430 | }
|
8431 |
|
8432 | for (var _i2 = 0, _others = others; _i2 < _others.length; _i2++) {
|
8433 | var other = _others[_i2];
|
8434 |
|
8435 | for (var p = 0; p < props.length; p++) {
|
8436 | var prop = props[p];
|
8437 |
|
8438 | if (other && Object.prototype.hasOwnProperty.call(other, prop)) {
|
8439 | a[prop] = other[prop];
|
8440 | }
|
8441 | }
|
8442 | }
|
8443 |
|
8444 | return a;
|
8445 | }
|
8446 |
|
8447 |
|
8448 |
|
8449 |
|
8450 |
|
8451 |
|
8452 |
|
8453 |
|
8454 |
|
8455 |
|
8456 |
|
8457 |
|
8458 |
|
8459 |
|
8460 |
|
8461 |
|
8462 | function selectiveDeepExtend(props, a, b) {
|
8463 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
8464 |
|
8465 |
|
8466 | if (_Array$isArray$1(b)) {
|
8467 | throw new TypeError("Arrays are not supported by deepExtend");
|
8468 | }
|
8469 |
|
8470 | for (var p = 0; p < props.length; p++) {
|
8471 | var prop = props[p];
|
8472 |
|
8473 | if (Object.prototype.hasOwnProperty.call(b, prop)) {
|
8474 | if (b[prop] && b[prop].constructor === Object) {
|
8475 | if (a[prop] === undefined) {
|
8476 | a[prop] = {};
|
8477 | }
|
8478 |
|
8479 | if (a[prop].constructor === Object) {
|
8480 | deepExtend(a[prop], b[prop], false, allowDeletion);
|
8481 | } else {
|
8482 | copyOrDelete(a, b, prop, allowDeletion);
|
8483 | }
|
8484 | } else if (_Array$isArray$1(b[prop])) {
|
8485 | throw new TypeError("Arrays are not supported by deepExtend");
|
8486 | } else {
|
8487 | copyOrDelete(a, b, prop, allowDeletion);
|
8488 | }
|
8489 | }
|
8490 | }
|
8491 |
|
8492 | return a;
|
8493 | }
|
8494 |
|
8495 |
|
8496 |
|
8497 |
|
8498 |
|
8499 |
|
8500 |
|
8501 |
|
8502 |
|
8503 |
|
8504 |
|
8505 |
|
8506 |
|
8507 |
|
8508 |
|
8509 |
|
8510 |
|
8511 | function selectiveNotDeepExtend(propsToExclude, a, b) {
|
8512 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
8513 |
|
8514 |
|
8515 |
|
8516 | if (_Array$isArray$1(b)) {
|
8517 | throw new TypeError("Arrays are not supported by deepExtend");
|
8518 | }
|
8519 |
|
8520 | for (var prop in b) {
|
8521 | if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
8522 | continue;
|
8523 | }
|
8524 |
|
8525 |
|
8526 | if (_includesInstanceProperty(propsToExclude).call(propsToExclude, prop)) {
|
8527 | continue;
|
8528 | }
|
8529 |
|
8530 |
|
8531 | if (b[prop] && b[prop].constructor === Object) {
|
8532 | if (a[prop] === undefined) {
|
8533 | a[prop] = {};
|
8534 | }
|
8535 |
|
8536 | if (a[prop].constructor === Object) {
|
8537 | deepExtend(a[prop], b[prop]);
|
8538 | } else {
|
8539 | copyOrDelete(a, b, prop, allowDeletion);
|
8540 | }
|
8541 | } else if (_Array$isArray$1(b[prop])) {
|
8542 | a[prop] = [];
|
8543 |
|
8544 | for (var i = 0; i < b[prop].length; i++) {
|
8545 | a[prop].push(b[prop][i]);
|
8546 | }
|
8547 | } else {
|
8548 | copyOrDelete(a, b, prop, allowDeletion);
|
8549 | }
|
8550 | }
|
8551 |
|
8552 | return a;
|
8553 | }
|
8554 |
|
8555 |
|
8556 |
|
8557 |
|
8558 |
|
8559 |
|
8560 |
|
8561 |
|
8562 |
|
8563 |
|
8564 |
|
8565 |
|
8566 |
|
8567 | function deepExtend(a, b) {
|
8568 | var protoExtend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
8569 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
8570 |
|
8571 | for (var prop in b) {
|
8572 | if (Object.prototype.hasOwnProperty.call(b, prop) || protoExtend === true) {
|
8573 | if (_typeof(b[prop]) === "object" && b[prop] !== null && _Object$getPrototypeOf(b[prop]) === Object.prototype) {
|
8574 | if (a[prop] === undefined) {
|
8575 | a[prop] = deepExtend({}, b[prop], protoExtend);
|
8576 | } else if (_typeof(a[prop]) === "object" && a[prop] !== null && _Object$getPrototypeOf(a[prop]) === Object.prototype) {
|
8577 | deepExtend(a[prop], b[prop], protoExtend);
|
8578 | } else {
|
8579 | copyOrDelete(a, b, prop, allowDeletion);
|
8580 | }
|
8581 | } else if (_Array$isArray$1(b[prop])) {
|
8582 | var _context6;
|
8583 |
|
8584 | a[prop] = _sliceInstanceProperty(_context6 = b[prop]).call(_context6);
|
8585 | } else {
|
8586 | copyOrDelete(a, b, prop, allowDeletion);
|
8587 | }
|
8588 | }
|
8589 | }
|
8590 |
|
8591 | return a;
|
8592 | }
|
8593 |
|
8594 |
|
8595 |
|
8596 |
|
8597 |
|
8598 |
|
8599 |
|
8600 |
|
8601 |
|
8602 | function equalArray(a, b) {
|
8603 | if (a.length !== b.length) {
|
8604 | return false;
|
8605 | }
|
8606 |
|
8607 | for (var i = 0, len = a.length; i < len; i++) {
|
8608 | if (a[i] != b[i]) {
|
8609 | return false;
|
8610 | }
|
8611 | }
|
8612 |
|
8613 | return true;
|
8614 | }
|
8615 |
|
8616 |
|
8617 |
|
8618 |
|
8619 |
|
8620 |
|
8621 |
|
8622 |
|
8623 | function getType(object) {
|
8624 | var type = _typeof(object);
|
8625 |
|
8626 | if (type === "object") {
|
8627 | if (object === null) {
|
8628 | return "null";
|
8629 | }
|
8630 |
|
8631 | if (object instanceof Boolean) {
|
8632 | return "Boolean";
|
8633 | }
|
8634 |
|
8635 | if (object instanceof Number) {
|
8636 | return "Number";
|
8637 | }
|
8638 |
|
8639 | if (object instanceof String) {
|
8640 | return "String";
|
8641 | }
|
8642 |
|
8643 | if (_Array$isArray$1(object)) {
|
8644 | return "Array";
|
8645 | }
|
8646 |
|
8647 | if (object instanceof Date) {
|
8648 | return "Date";
|
8649 | }
|
8650 |
|
8651 | return "Object";
|
8652 | }
|
8653 |
|
8654 | if (type === "number") {
|
8655 | return "Number";
|
8656 | }
|
8657 |
|
8658 | if (type === "boolean") {
|
8659 | return "Boolean";
|
8660 | }
|
8661 |
|
8662 | if (type === "string") {
|
8663 | return "String";
|
8664 | }
|
8665 |
|
8666 | if (type === undefined) {
|
8667 | return "undefined";
|
8668 | }
|
8669 |
|
8670 | return type;
|
8671 | }
|
8672 |
|
8673 |
|
8674 |
|
8675 |
|
8676 |
|
8677 |
|
8678 |
|
8679 |
|
8680 |
|
8681 | function copyAndExtendArray(arr, newValue) {
|
8682 | var _context7;
|
8683 |
|
8684 | return _concatInstanceProperty(_context7 = []).call(_context7, _toConsumableArray(arr), [newValue]);
|
8685 | }
|
8686 |
|
8687 |
|
8688 |
|
8689 |
|
8690 |
|
8691 |
|
8692 |
|
8693 |
|
8694 | function copyArray(arr) {
|
8695 | return _sliceInstanceProperty(arr).call(arr);
|
8696 | }
|
8697 |
|
8698 |
|
8699 |
|
8700 |
|
8701 |
|
8702 |
|
8703 |
|
8704 |
|
8705 | function getAbsoluteLeft(elem) {
|
8706 | return elem.getBoundingClientRect().left;
|
8707 | }
|
8708 |
|
8709 |
|
8710 |
|
8711 |
|
8712 |
|
8713 |
|
8714 |
|
8715 |
|
8716 | function getAbsoluteRight(elem) {
|
8717 | return elem.getBoundingClientRect().right;
|
8718 | }
|
8719 |
|
8720 |
|
8721 |
|
8722 |
|
8723 |
|
8724 |
|
8725 |
|
8726 |
|
8727 | function getAbsoluteTop(elem) {
|
8728 | return elem.getBoundingClientRect().top;
|
8729 | }
|
8730 |
|
8731 |
|
8732 |
|
8733 |
|
8734 |
|
8735 |
|
8736 |
|
8737 |
|
8738 | function addClassName(elem, classNames) {
|
8739 | var classes = elem.className.split(" ");
|
8740 | var newClasses = classNames.split(" ");
|
8741 | classes = _concatInstanceProperty(classes).call(classes, _filterInstanceProperty(newClasses).call(newClasses, function (className) {
|
8742 | return !_includesInstanceProperty(classes).call(classes, className);
|
8743 | }));
|
8744 | elem.className = classes.join(" ");
|
8745 | }
|
8746 |
|
8747 |
|
8748 |
|
8749 |
|
8750 |
|
8751 |
|
8752 |
|
8753 |
|
8754 | function removeClassName(elem, classNames) {
|
8755 | var classes = elem.className.split(" ");
|
8756 | var oldClasses = classNames.split(" ");
|
8757 | classes = _filterInstanceProperty(classes).call(classes, function (className) {
|
8758 | return !_includesInstanceProperty(oldClasses).call(oldClasses, className);
|
8759 | });
|
8760 | elem.className = classes.join(" ");
|
8761 | }
|
8762 |
|
8763 |
|
8764 |
|
8765 |
|
8766 |
|
8767 |
|
8768 |
|
8769 |
|
8770 |
|
8771 |
|
8772 | function forEach$1(object, callback) {
|
8773 | if (_Array$isArray$1(object)) {
|
8774 |
|
8775 | var len = object.length;
|
8776 |
|
8777 | for (var i = 0; i < len; i++) {
|
8778 | callback(object[i], i, object);
|
8779 | }
|
8780 | } else {
|
8781 |
|
8782 | for (var key in object) {
|
8783 | if (Object.prototype.hasOwnProperty.call(object, key)) {
|
8784 | callback(object[key], key, object);
|
8785 | }
|
8786 | }
|
8787 | }
|
8788 | }
|
8789 |
|
8790 |
|
8791 |
|
8792 |
|
8793 |
|
8794 |
|
8795 |
|
8796 |
|
8797 | var toArray = _Object$values2;
|
8798 |
|
8799 |
|
8800 |
|
8801 |
|
8802 |
|
8803 |
|
8804 |
|
8805 |
|
8806 |
|
8807 | function updateProperty(object, key, value) {
|
8808 | if (object[key] !== value) {
|
8809 | object[key] = value;
|
8810 | return true;
|
8811 | } else {
|
8812 | return false;
|
8813 | }
|
8814 | }
|
8815 |
|
8816 |
|
8817 |
|
8818 |
|
8819 |
|
8820 |
|
8821 |
|
8822 |
|
8823 | function throttle(fn) {
|
8824 | var scheduled = false;
|
8825 | return function () {
|
8826 | if (!scheduled) {
|
8827 | scheduled = true;
|
8828 | requestAnimationFrame(function () {
|
8829 | scheduled = false;
|
8830 | fn();
|
8831 | });
|
8832 | }
|
8833 | };
|
8834 | }
|
8835 |
|
8836 |
|
8837 |
|
8838 |
|
8839 |
|
8840 |
|
8841 |
|
8842 |
|
8843 |
|
8844 |
|
8845 | function addEventListener(element, action, listener, useCapture) {
|
8846 | if (element.addEventListener) {
|
8847 | var _context8;
|
8848 |
|
8849 | if (useCapture === undefined) {
|
8850 | useCapture = false;
|
8851 | }
|
8852 |
|
8853 | if (action === "mousewheel" && _includesInstanceProperty(_context8 = navigator.userAgent).call(_context8, "Firefox")) {
|
8854 | action = "DOMMouseScroll";
|
8855 | }
|
8856 |
|
8857 | element.addEventListener(action, listener, useCapture);
|
8858 | } else {
|
8859 |
|
8860 | element.attachEvent("on" + action, listener);
|
8861 | }
|
8862 | }
|
8863 |
|
8864 |
|
8865 |
|
8866 |
|
8867 |
|
8868 |
|
8869 |
|
8870 |
|
8871 |
|
8872 |
|
8873 | function removeEventListener(element, action, listener, useCapture) {
|
8874 | if (element.removeEventListener) {
|
8875 | var _context9;
|
8876 |
|
8877 |
|
8878 | if (useCapture === undefined) {
|
8879 | useCapture = false;
|
8880 | }
|
8881 |
|
8882 | if (action === "mousewheel" && _includesInstanceProperty(_context9 = navigator.userAgent).call(_context9, "Firefox")) {
|
8883 | action = "DOMMouseScroll";
|
8884 | }
|
8885 |
|
8886 | element.removeEventListener(action, listener, useCapture);
|
8887 | } else {
|
8888 |
|
8889 | element.detachEvent("on" + action, listener);
|
8890 | }
|
8891 | }
|
8892 |
|
8893 |
|
8894 |
|
8895 |
|
8896 |
|
8897 |
|
8898 |
|
8899 | function preventDefault(event) {
|
8900 | if (!event) {
|
8901 | event = window.event;
|
8902 | }
|
8903 |
|
8904 | if (!event) ;else if (event.preventDefault) {
|
8905 | event.preventDefault();
|
8906 | } else {
|
8907 |
|
8908 | event.returnValue = false;
|
8909 | }
|
8910 | }
|
8911 |
|
8912 |
|
8913 |
|
8914 |
|
8915 |
|
8916 |
|
8917 |
|
8918 |
|
8919 | function getTarget() {
|
8920 | var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.event;
|
8921 |
|
8922 |
|
8923 | var target = null;
|
8924 | if (!event) ;else if (event.target) {
|
8925 | target = event.target;
|
8926 | } else if (event.srcElement) {
|
8927 | target = event.srcElement;
|
8928 | }
|
8929 |
|
8930 | if (!(target instanceof Element)) {
|
8931 | return null;
|
8932 | }
|
8933 |
|
8934 | if (target.nodeType != null && target.nodeType == 3) {
|
8935 |
|
8936 | target = target.parentNode;
|
8937 |
|
8938 | if (!(target instanceof Element)) {
|
8939 | return null;
|
8940 | }
|
8941 | }
|
8942 |
|
8943 | return target;
|
8944 | }
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
8949 |
|
8950 |
|
8951 |
|
8952 |
|
8953 |
|
8954 | function hasParent(element, parent) {
|
8955 | var elem = element;
|
8956 |
|
8957 | while (elem) {
|
8958 | if (elem === parent) {
|
8959 | return true;
|
8960 | } else if (elem.parentNode) {
|
8961 | elem = elem.parentNode;
|
8962 | } else {
|
8963 | return false;
|
8964 | }
|
8965 | }
|
8966 |
|
8967 | return false;
|
8968 | }
|
8969 |
|
8970 | var option = {
|
8971 | |
8972 |
|
8973 |
|
8974 |
|
8975 |
|
8976 |
|
8977 |
|
8978 | asBoolean: function asBoolean(value, defaultValue) {
|
8979 | if (typeof value == "function") {
|
8980 | value = value();
|
8981 | }
|
8982 |
|
8983 | if (value != null) {
|
8984 | return value != false;
|
8985 | }
|
8986 |
|
8987 | return defaultValue || null;
|
8988 | },
|
8989 |
|
8990 | |
8991 |
|
8992 |
|
8993 |
|
8994 |
|
8995 |
|
8996 |
|
8997 | asNumber: function asNumber(value, defaultValue) {
|
8998 | if (typeof value == "function") {
|
8999 | value = value();
|
9000 | }
|
9001 |
|
9002 | if (value != null) {
|
9003 | return Number(value) || defaultValue || null;
|
9004 | }
|
9005 |
|
9006 | return defaultValue || null;
|
9007 | },
|
9008 |
|
9009 | |
9010 |
|
9011 |
|
9012 |
|
9013 |
|
9014 |
|
9015 |
|
9016 | asString: function asString(value, defaultValue) {
|
9017 | if (typeof value == "function") {
|
9018 | value = value();
|
9019 | }
|
9020 |
|
9021 | if (value != null) {
|
9022 | return String(value);
|
9023 | }
|
9024 |
|
9025 | return defaultValue || null;
|
9026 | },
|
9027 |
|
9028 | |
9029 |
|
9030 |
|
9031 |
|
9032 |
|
9033 |
|
9034 |
|
9035 | asSize: function asSize(value, defaultValue) {
|
9036 | if (typeof value == "function") {
|
9037 | value = value();
|
9038 | }
|
9039 |
|
9040 | if (isString(value)) {
|
9041 | return value;
|
9042 | } else if (isNumber(value)) {
|
9043 | return value + "px";
|
9044 | } else {
|
9045 | return defaultValue || null;
|
9046 | }
|
9047 | },
|
9048 |
|
9049 | |
9050 |
|
9051 |
|
9052 |
|
9053 |
|
9054 |
|
9055 |
|
9056 | asElement: function asElement(value, defaultValue) {
|
9057 | if (typeof value == "function") {
|
9058 | value = value();
|
9059 | }
|
9060 |
|
9061 | return value || defaultValue || null;
|
9062 | }
|
9063 | };
|
9064 |
|
9065 |
|
9066 |
|
9067 |
|
9068 |
|
9069 |
|
9070 |
|
9071 |
|
9072 |
|
9073 | function hexToRGB(hex) {
|
9074 | var result;
|
9075 |
|
9076 | switch (hex.length) {
|
9077 | case 3:
|
9078 | case 4:
|
9079 | result = shortHexRE.exec(hex);
|
9080 | return result ? {
|
9081 | r: _parseInt(result[1] + result[1], 16),
|
9082 | g: _parseInt(result[2] + result[2], 16),
|
9083 | b: _parseInt(result[3] + result[3], 16)
|
9084 | } : null;
|
9085 |
|
9086 | case 6:
|
9087 | case 7:
|
9088 | result = fullHexRE.exec(hex);
|
9089 | return result ? {
|
9090 | r: _parseInt(result[1], 16),
|
9091 | g: _parseInt(result[2], 16),
|
9092 | b: _parseInt(result[3], 16)
|
9093 | } : null;
|
9094 |
|
9095 | default:
|
9096 | return null;
|
9097 | }
|
9098 | }
|
9099 |
|
9100 |
|
9101 |
|
9102 |
|
9103 |
|
9104 |
|
9105 |
|
9106 |
|
9107 |
|
9108 | function overrideOpacity(color, opacity) {
|
9109 | if (_includesInstanceProperty(color).call(color, "rgba")) {
|
9110 | return color;
|
9111 | } else if (_includesInstanceProperty(color).call(color, "rgb")) {
|
9112 | var rgb = color.substr(_indexOfInstanceProperty(color).call(color, "(") + 1).replace(")", "").split(",");
|
9113 | return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + opacity + ")";
|
9114 | } else {
|
9115 | var _rgb = hexToRGB(color);
|
9116 |
|
9117 | if (_rgb == null) {
|
9118 | return color;
|
9119 | } else {
|
9120 | return "rgba(" + _rgb.r + "," + _rgb.g + "," + _rgb.b + "," + opacity + ")";
|
9121 | }
|
9122 | }
|
9123 | }
|
9124 |
|
9125 |
|
9126 |
|
9127 |
|
9128 |
|
9129 |
|
9130 |
|
9131 |
|
9132 |
|
9133 |
|
9134 | function RGBToHex(red, green, blue) {
|
9135 | var _context10;
|
9136 |
|
9137 | return "#" + _sliceInstanceProperty(_context10 = ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16)).call(_context10, 1);
|
9138 | }
|
9139 |
|
9140 |
|
9141 |
|
9142 |
|
9143 |
|
9144 |
|
9145 |
|
9146 |
|
9147 |
|
9148 | function parseColor(inputColor, defaultColor) {
|
9149 | if (isString(inputColor)) {
|
9150 | var colorStr = inputColor;
|
9151 |
|
9152 | if (isValidRGB(colorStr)) {
|
9153 | var _context11;
|
9154 |
|
9155 | var rgb = _mapInstanceProperty(_context11 = colorStr.substr(4).substr(0, colorStr.length - 5).split(",")).call(_context11, function (value) {
|
9156 | return _parseInt(value);
|
9157 | });
|
9158 |
|
9159 | colorStr = RGBToHex(rgb[0], rgb[1], rgb[2]);
|
9160 | }
|
9161 |
|
9162 | if (isValidHex(colorStr) === true) {
|
9163 | var hsv = hexToHSV(colorStr);
|
9164 | var lighterColorHSV = {
|
9165 | h: hsv.h,
|
9166 | s: hsv.s * 0.8,
|
9167 | v: Math.min(1, hsv.v * 1.02)
|
9168 | };
|
9169 | var darkerColorHSV = {
|
9170 | h: hsv.h,
|
9171 | s: Math.min(1, hsv.s * 1.25),
|
9172 | v: hsv.v * 0.8
|
9173 | };
|
9174 | var darkerColorHex = HSVToHex(darkerColorHSV.h, darkerColorHSV.s, darkerColorHSV.v);
|
9175 | var lighterColorHex = HSVToHex(lighterColorHSV.h, lighterColorHSV.s, lighterColorHSV.v);
|
9176 | return {
|
9177 | background: colorStr,
|
9178 | border: darkerColorHex,
|
9179 | highlight: {
|
9180 | background: lighterColorHex,
|
9181 | border: darkerColorHex
|
9182 | },
|
9183 | hover: {
|
9184 | background: lighterColorHex,
|
9185 | border: darkerColorHex
|
9186 | }
|
9187 | };
|
9188 | } else {
|
9189 | return {
|
9190 | background: colorStr,
|
9191 | border: colorStr,
|
9192 | highlight: {
|
9193 | background: colorStr,
|
9194 | border: colorStr
|
9195 | },
|
9196 | hover: {
|
9197 | background: colorStr,
|
9198 | border: colorStr
|
9199 | }
|
9200 | };
|
9201 | }
|
9202 | } else {
|
9203 | if (defaultColor) {
|
9204 | var color = {
|
9205 | background: inputColor.background || defaultColor.background,
|
9206 | border: inputColor.border || defaultColor.border,
|
9207 | highlight: isString(inputColor.highlight) ? {
|
9208 | border: inputColor.highlight,
|
9209 | background: inputColor.highlight
|
9210 | } : {
|
9211 | background: inputColor.highlight && inputColor.highlight.background || defaultColor.highlight.background,
|
9212 | border: inputColor.highlight && inputColor.highlight.border || defaultColor.highlight.border
|
9213 | },
|
9214 | hover: isString(inputColor.hover) ? {
|
9215 | border: inputColor.hover,
|
9216 | background: inputColor.hover
|
9217 | } : {
|
9218 | border: inputColor.hover && inputColor.hover.border || defaultColor.hover.border,
|
9219 | background: inputColor.hover && inputColor.hover.background || defaultColor.hover.background
|
9220 | }
|
9221 | };
|
9222 | return color;
|
9223 | } else {
|
9224 | var _color = {
|
9225 | background: inputColor.background || undefined,
|
9226 | border: inputColor.border || undefined,
|
9227 | highlight: isString(inputColor.highlight) ? {
|
9228 | border: inputColor.highlight,
|
9229 | background: inputColor.highlight
|
9230 | } : {
|
9231 | background: inputColor.highlight && inputColor.highlight.background || undefined,
|
9232 | border: inputColor.highlight && inputColor.highlight.border || undefined
|
9233 | },
|
9234 | hover: isString(inputColor.hover) ? {
|
9235 | border: inputColor.hover,
|
9236 | background: inputColor.hover
|
9237 | } : {
|
9238 | border: inputColor.hover && inputColor.hover.border || undefined,
|
9239 | background: inputColor.hover && inputColor.hover.background || undefined
|
9240 | }
|
9241 | };
|
9242 | return _color;
|
9243 | }
|
9244 | }
|
9245 | }
|
9246 |
|
9247 |
|
9248 |
|
9249 |
|
9250 |
|
9251 |
|
9252 |
|
9253 |
|
9254 |
|
9255 |
|
9256 |
|
9257 |
|
9258 | function RGBToHSV(red, green, blue) {
|
9259 | red = red / 255;
|
9260 | green = green / 255;
|
9261 | blue = blue / 255;
|
9262 | var minRGB = Math.min(red, Math.min(green, blue));
|
9263 | var maxRGB = Math.max(red, Math.max(green, blue));
|
9264 |
|
9265 | if (minRGB === maxRGB) {
|
9266 | return {
|
9267 | h: 0,
|
9268 | s: 0,
|
9269 | v: minRGB
|
9270 | };
|
9271 | }
|
9272 |
|
9273 |
|
9274 | var d = red === minRGB ? green - blue : blue === minRGB ? red - green : blue - red;
|
9275 | var h = red === minRGB ? 3 : blue === minRGB ? 1 : 5;
|
9276 | var hue = 60 * (h - d / (maxRGB - minRGB)) / 360;
|
9277 | var saturation = (maxRGB - minRGB) / maxRGB;
|
9278 | var value = maxRGB;
|
9279 | return {
|
9280 | h: hue,
|
9281 | s: saturation,
|
9282 | v: value
|
9283 | };
|
9284 | }
|
9285 |
|
9286 | var cssUtil = {
|
9287 |
|
9288 | split: function split(cssText) {
|
9289 | var _context12;
|
9290 |
|
9291 | var styles = {};
|
9292 |
|
9293 | _forEachInstanceProperty(_context12 = cssText.split(";")).call(_context12, function (style) {
|
9294 | if (_trimInstanceProperty(style).call(style) != "") {
|
9295 | var _context13, _context14;
|
9296 |
|
9297 | var parts = style.split(":");
|
9298 |
|
9299 | var key = _trimInstanceProperty(_context13 = parts[0]).call(_context13);
|
9300 |
|
9301 | var value = _trimInstanceProperty(_context14 = parts[1]).call(_context14);
|
9302 |
|
9303 | styles[key] = value;
|
9304 | }
|
9305 | });
|
9306 |
|
9307 | return styles;
|
9308 | },
|
9309 |
|
9310 | join: function join(styles) {
|
9311 | var _context15;
|
9312 |
|
9313 | return _mapInstanceProperty(_context15 = _Object$keys(styles)).call(_context15, function (key) {
|
9314 | return key + ": " + styles[key];
|
9315 | }).join("; ");
|
9316 | }
|
9317 | };
|
9318 |
|
9319 |
|
9320 |
|
9321 |
|
9322 |
|
9323 |
|
9324 |
|
9325 | function addCssText(element, cssText) {
|
9326 | var currentStyles = cssUtil.split(element.style.cssText);
|
9327 | var newStyles = cssUtil.split(cssText);
|
9328 |
|
9329 | var styles = _objectSpread$1(_objectSpread$1({}, currentStyles), newStyles);
|
9330 |
|
9331 | element.style.cssText = cssUtil.join(styles);
|
9332 | }
|
9333 |
|
9334 |
|
9335 |
|
9336 |
|
9337 |
|
9338 |
|
9339 |
|
9340 |
|
9341 | function removeCssText(element, cssText) {
|
9342 | var styles = cssUtil.split(element.style.cssText);
|
9343 | var removeStyles = cssUtil.split(cssText);
|
9344 |
|
9345 | for (var key in removeStyles) {
|
9346 | if (Object.prototype.hasOwnProperty.call(removeStyles, key)) {
|
9347 | delete styles[key];
|
9348 | }
|
9349 | }
|
9350 |
|
9351 | element.style.cssText = cssUtil.join(styles);
|
9352 | }
|
9353 |
|
9354 |
|
9355 |
|
9356 |
|
9357 |
|
9358 |
|
9359 |
|
9360 |
|
9361 |
|
9362 |
|
9363 |
|
9364 |
|
9365 | function HSVToRGB(h, s, v) {
|
9366 | var r;
|
9367 | var g;
|
9368 | var b;
|
9369 | var i = Math.floor(h * 6);
|
9370 | var f = h * 6 - i;
|
9371 | var p = v * (1 - s);
|
9372 | var q = v * (1 - f * s);
|
9373 | var t = v * (1 - (1 - f) * s);
|
9374 |
|
9375 | switch (i % 6) {
|
9376 | case 0:
|
9377 | r = v, g = t, b = p;
|
9378 | break;
|
9379 |
|
9380 | case 1:
|
9381 | r = q, g = v, b = p;
|
9382 | break;
|
9383 |
|
9384 | case 2:
|
9385 | r = p, g = v, b = t;
|
9386 | break;
|
9387 |
|
9388 | case 3:
|
9389 | r = p, g = q, b = v;
|
9390 | break;
|
9391 |
|
9392 | case 4:
|
9393 | r = t, g = p, b = v;
|
9394 | break;
|
9395 |
|
9396 | case 5:
|
9397 | r = v, g = p, b = q;
|
9398 | break;
|
9399 | }
|
9400 |
|
9401 | return {
|
9402 | r: Math.floor(r * 255),
|
9403 | g: Math.floor(g * 255),
|
9404 | b: Math.floor(b * 255)
|
9405 | };
|
9406 | }
|
9407 |
|
9408 |
|
9409 |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 |
|
9415 |
|
9416 |
|
9417 | function HSVToHex(h, s, v) {
|
9418 | var rgb = HSVToRGB(h, s, v);
|
9419 | return RGBToHex(rgb.r, rgb.g, rgb.b);
|
9420 | }
|
9421 |
|
9422 |
|
9423 |
|
9424 |
|
9425 |
|
9426 |
|
9427 |
|
9428 |
|
9429 | function hexToHSV(hex) {
|
9430 | var rgb = hexToRGB(hex);
|
9431 |
|
9432 | if (!rgb) {
|
9433 | throw new TypeError("'".concat(hex, "' is not a valid color."));
|
9434 | }
|
9435 |
|
9436 | return RGBToHSV(rgb.r, rgb.g, rgb.b);
|
9437 | }
|
9438 |
|
9439 |
|
9440 |
|
9441 |
|
9442 |
|
9443 |
|
9444 |
|
9445 |
|
9446 | function isValidHex(hex) {
|
9447 | var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
|
9448 | return isOk;
|
9449 | }
|
9450 |
|
9451 |
|
9452 |
|
9453 |
|
9454 |
|
9455 |
|
9456 |
|
9457 |
|
9458 | function isValidRGB(rgb) {
|
9459 | return rgbRE.test(rgb);
|
9460 | }
|
9461 |
|
9462 |
|
9463 |
|
9464 |
|
9465 |
|
9466 |
|
9467 |
|
9468 |
|
9469 | function isValidRGBA(rgba) {
|
9470 | return rgbaRE.test(rgba);
|
9471 | }
|
9472 |
|
9473 |
|
9474 |
|
9475 |
|
9476 |
|
9477 |
|
9478 |
|
9479 |
|
9480 |
|
9481 |
|
9482 | function selectiveBridgeObject(fields, referenceObject) {
|
9483 | if (referenceObject !== null && _typeof(referenceObject) === "object") {
|
9484 |
|
9485 | var objectTo = _Object$create(referenceObject);
|
9486 |
|
9487 | for (var i = 0; i < fields.length; i++) {
|
9488 | if (Object.prototype.hasOwnProperty.call(referenceObject, fields[i])) {
|
9489 | if (_typeof(referenceObject[fields[i]]) == "object") {
|
9490 | objectTo[fields[i]] = bridgeObject(referenceObject[fields[i]]);
|
9491 | }
|
9492 | }
|
9493 | }
|
9494 |
|
9495 | return objectTo;
|
9496 | } else {
|
9497 | return null;
|
9498 | }
|
9499 | }
|
9500 |
|
9501 |
|
9502 |
|
9503 |
|
9504 |
|
9505 |
|
9506 |
|
9507 |
|
9508 |
|
9509 | function bridgeObject(referenceObject) {
|
9510 | if (referenceObject === null || _typeof(referenceObject) !== "object") {
|
9511 | return null;
|
9512 | }
|
9513 |
|
9514 | if (referenceObject instanceof Element) {
|
9515 |
|
9516 | return referenceObject;
|
9517 | }
|
9518 |
|
9519 | var objectTo = _Object$create(referenceObject);
|
9520 |
|
9521 | for (var i in referenceObject) {
|
9522 | if (Object.prototype.hasOwnProperty.call(referenceObject, i)) {
|
9523 | if (_typeof(referenceObject[i]) == "object") {
|
9524 | objectTo[i] = bridgeObject(referenceObject[i]);
|
9525 | }
|
9526 | }
|
9527 | }
|
9528 |
|
9529 | return objectTo;
|
9530 | }
|
9531 |
|
9532 |
|
9533 |
|
9534 |
|
9535 |
|
9536 |
|
9537 |
|
9538 |
|
9539 |
|
9540 | function insertSort(a, compare) {
|
9541 | for (var i = 0; i < a.length; i++) {
|
9542 | var k = a[i];
|
9543 | var j = void 0;
|
9544 |
|
9545 | for (j = i; j > 0 && compare(k, a[j - 1]) < 0; j--) {
|
9546 | a[j] = a[j - 1];
|
9547 | }
|
9548 |
|
9549 | a[j] = k;
|
9550 | }
|
9551 |
|
9552 | return a;
|
9553 | }
|
9554 |
|
9555 |
|
9556 |
|
9557 |
|
9558 |
|
9559 |
|
9560 |
|
9561 |
|
9562 |
|
9563 |
|
9564 |
|
9565 |
|
9566 |
|
9567 |
|
9568 |
|
9569 | function mergeOptions(mergeTarget, options, option) {
|
9570 | var globalOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
9571 |
|
9572 |
|
9573 | var isPresent = function isPresent(obj) {
|
9574 | return obj !== null && obj !== undefined;
|
9575 | };
|
9576 |
|
9577 | var isObject = function isObject(obj) {
|
9578 | return obj !== null && _typeof(obj) === "object";
|
9579 | };
|
9580 |
|
9581 |
|
9582 | var isEmpty = function isEmpty(obj) {
|
9583 | for (var x in obj) {
|
9584 | if (Object.prototype.hasOwnProperty.call(obj, x)) {
|
9585 | return false;
|
9586 | }
|
9587 | }
|
9588 |
|
9589 | return true;
|
9590 | };
|
9591 |
|
9592 |
|
9593 | if (!isObject(mergeTarget)) {
|
9594 | throw new Error("Parameter mergeTarget must be an object");
|
9595 | }
|
9596 |
|
9597 | if (!isObject(options)) {
|
9598 | throw new Error("Parameter options must be an object");
|
9599 | }
|
9600 |
|
9601 | if (!isPresent(option)) {
|
9602 | throw new Error("Parameter option must have a value");
|
9603 | }
|
9604 |
|
9605 | if (!isObject(globalOptions)) {
|
9606 | throw new Error("Parameter globalOptions must be an object");
|
9607 | }
|
9608 |
|
9609 |
|
9610 |
|
9611 |
|
9612 |
|
9613 | var doMerge = function doMerge(target, options, option) {
|
9614 | if (!isObject(target[option])) {
|
9615 | target[option] = {};
|
9616 | }
|
9617 |
|
9618 | var src = options[option];
|
9619 | var dst = target[option];
|
9620 |
|
9621 | for (var prop in src) {
|
9622 | if (Object.prototype.hasOwnProperty.call(src, prop)) {
|
9623 | dst[prop] = src[prop];
|
9624 | }
|
9625 | }
|
9626 | };
|
9627 |
|
9628 |
|
9629 | var srcOption = options[option];
|
9630 | var globalPassed = isObject(globalOptions) && !isEmpty(globalOptions);
|
9631 | var globalOption = globalPassed ? globalOptions[option] : undefined;
|
9632 | var globalEnabled = globalOption ? globalOption.enabled : undefined;
|
9633 |
|
9634 |
|
9635 |
|
9636 | if (srcOption === undefined) {
|
9637 | return;
|
9638 | }
|
9639 |
|
9640 | if (typeof srcOption === "boolean") {
|
9641 | if (!isObject(mergeTarget[option])) {
|
9642 | mergeTarget[option] = {};
|
9643 | }
|
9644 |
|
9645 | mergeTarget[option].enabled = srcOption;
|
9646 | return;
|
9647 | }
|
9648 |
|
9649 | if (srcOption === null && !isObject(mergeTarget[option])) {
|
9650 |
|
9651 | if (isPresent(globalOption)) {
|
9652 | mergeTarget[option] = _Object$create(globalOption);
|
9653 | } else {
|
9654 | return;
|
9655 | }
|
9656 | }
|
9657 |
|
9658 | if (!isObject(srcOption)) {
|
9659 | return;
|
9660 | }
|
9661 |
|
9662 |
|
9663 |
|
9664 |
|
9665 |
|
9666 | var enabled = true;
|
9667 |
|
9668 | if (srcOption.enabled !== undefined) {
|
9669 | enabled = srcOption.enabled;
|
9670 | } else {
|
9671 |
|
9672 | if (globalEnabled !== undefined) {
|
9673 | enabled = globalOption.enabled;
|
9674 | }
|
9675 | }
|
9676 |
|
9677 | doMerge(mergeTarget, options, option);
|
9678 | mergeTarget[option].enabled = enabled;
|
9679 | }
|
9680 |
|
9681 |
|
9682 |
|
9683 |
|
9684 |
|
9685 |
|
9686 |
|
9687 |
|
9688 |
|
9689 |
|
9690 |
|
9691 |
|
9692 | function binarySearchCustom(orderedItems, comparator, field, field2) {
|
9693 | var maxIterations = 10000;
|
9694 | var iteration = 0;
|
9695 | var low = 0;
|
9696 | var high = orderedItems.length - 1;
|
9697 |
|
9698 | while (low <= high && iteration < maxIterations) {
|
9699 | var middle = Math.floor((low + high) / 2);
|
9700 | var item = orderedItems[middle];
|
9701 | var value = field2 === undefined ? item[field] : item[field][field2];
|
9702 | var searchResult = comparator(value);
|
9703 |
|
9704 | if (searchResult == 0) {
|
9705 |
|
9706 | return middle;
|
9707 | } else if (searchResult == -1) {
|
9708 |
|
9709 | low = middle + 1;
|
9710 | } else {
|
9711 |
|
9712 | high = middle - 1;
|
9713 | }
|
9714 |
|
9715 | iteration++;
|
9716 | }
|
9717 |
|
9718 | return -1;
|
9719 | }
|
9720 |
|
9721 |
|
9722 |
|
9723 |
|
9724 |
|
9725 |
|
9726 |
|
9727 |
|
9728 |
|
9729 |
|
9730 |
|
9731 |
|
9732 |
|
9733 |
|
9734 |
|
9735 | function binarySearchValue(orderedItems, target, field, sidePreference, comparator) {
|
9736 | var maxIterations = 10000;
|
9737 | var iteration = 0;
|
9738 | var low = 0;
|
9739 | var high = orderedItems.length - 1;
|
9740 | var prevValue;
|
9741 | var value;
|
9742 | var nextValue;
|
9743 | var middle;
|
9744 | comparator = comparator != undefined ? comparator : function (a, b) {
|
9745 | return a == b ? 0 : a < b ? -1 : 1;
|
9746 | };
|
9747 |
|
9748 | while (low <= high && iteration < maxIterations) {
|
9749 |
|
9750 | middle = Math.floor(0.5 * (high + low));
|
9751 | prevValue = orderedItems[Math.max(0, middle - 1)][field];
|
9752 | value = orderedItems[middle][field];
|
9753 | nextValue = orderedItems[Math.min(orderedItems.length - 1, middle + 1)][field];
|
9754 |
|
9755 | if (comparator(value, target) == 0) {
|
9756 |
|
9757 | return middle;
|
9758 | } else if (comparator(prevValue, target) < 0 && comparator(value, target) > 0) {
|
9759 |
|
9760 | return sidePreference == "before" ? Math.max(0, middle - 1) : middle;
|
9761 | } else if (comparator(value, target) < 0 && comparator(nextValue, target) > 0) {
|
9762 |
|
9763 | return sidePreference == "before" ? middle : Math.min(orderedItems.length - 1, middle + 1);
|
9764 | } else {
|
9765 |
|
9766 | if (comparator(value, target) < 0) {
|
9767 |
|
9768 | low = middle + 1;
|
9769 | } else {
|
9770 |
|
9771 | high = middle - 1;
|
9772 | }
|
9773 | }
|
9774 |
|
9775 | iteration++;
|
9776 | }
|
9777 |
|
9778 |
|
9779 | return -1;
|
9780 | }
|
9781 |
|
9782 |
|
9783 |
|
9784 |
|
9785 |
|
9786 |
|
9787 |
|
9788 |
|
9789 |
|
9790 | var easingFunctions = {
|
9791 | |
9792 |
|
9793 |
|
9794 |
|
9795 |
|
9796 |
|
9797 | linear: function linear(t) {
|
9798 | return t;
|
9799 | },
|
9800 |
|
9801 | |
9802 |
|
9803 |
|
9804 |
|
9805 |
|
9806 |
|
9807 | easeInQuad: function easeInQuad(t) {
|
9808 | return t * t;
|
9809 | },
|
9810 |
|
9811 | |
9812 |
|
9813 |
|
9814 |
|
9815 |
|
9816 |
|
9817 | easeOutQuad: function easeOutQuad(t) {
|
9818 | return t * (2 - t);
|
9819 | },
|
9820 |
|
9821 | |
9822 |
|
9823 |
|
9824 |
|
9825 |
|
9826 |
|
9827 | easeInOutQuad: function easeInOutQuad(t) {
|
9828 | return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
9829 | },
|
9830 |
|
9831 | |
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 | easeInCubic: function easeInCubic(t) {
|
9838 | return t * t * t;
|
9839 | },
|
9840 |
|
9841 | |
9842 |
|
9843 |
|
9844 |
|
9845 |
|
9846 |
|
9847 | easeOutCubic: function easeOutCubic(t) {
|
9848 | return --t * t * t + 1;
|
9849 | },
|
9850 |
|
9851 | |
9852 |
|
9853 |
|
9854 |
|
9855 |
|
9856 |
|
9857 | easeInOutCubic: function easeInOutCubic(t) {
|
9858 | return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
9859 | },
|
9860 |
|
9861 | |
9862 |
|
9863 |
|
9864 |
|
9865 |
|
9866 |
|
9867 | easeInQuart: function easeInQuart(t) {
|
9868 | return t * t * t * t;
|
9869 | },
|
9870 |
|
9871 | |
9872 |
|
9873 |
|
9874 |
|
9875 |
|
9876 |
|
9877 | easeOutQuart: function easeOutQuart(t) {
|
9878 | return 1 - --t * t * t * t;
|
9879 | },
|
9880 |
|
9881 | |
9882 |
|
9883 |
|
9884 |
|
9885 |
|
9886 |
|
9887 | easeInOutQuart: function easeInOutQuart(t) {
|
9888 | return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
9889 | },
|
9890 |
|
9891 | |
9892 |
|
9893 |
|
9894 |
|
9895 |
|
9896 |
|
9897 | easeInQuint: function easeInQuint(t) {
|
9898 | return t * t * t * t * t;
|
9899 | },
|
9900 |
|
9901 | |
9902 |
|
9903 |
|
9904 |
|
9905 |
|
9906 |
|
9907 | easeOutQuint: function easeOutQuint(t) {
|
9908 | return 1 + --t * t * t * t * t;
|
9909 | },
|
9910 |
|
9911 | |
9912 |
|
9913 |
|
9914 |
|
9915 |
|
9916 |
|
9917 | easeInOutQuint: function easeInOutQuint(t) {
|
9918 | return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
9919 | }
|
9920 | };
|
9921 |
|
9922 |
|
9923 |
|
9924 |
|
9925 |
|
9926 |
|
9927 | function getScrollBarWidth() {
|
9928 | var inner = document.createElement("p");
|
9929 | inner.style.width = "100%";
|
9930 | inner.style.height = "200px";
|
9931 | var outer = document.createElement("div");
|
9932 | outer.style.position = "absolute";
|
9933 | outer.style.top = "0px";
|
9934 | outer.style.left = "0px";
|
9935 | outer.style.visibility = "hidden";
|
9936 | outer.style.width = "200px";
|
9937 | outer.style.height = "150px";
|
9938 | outer.style.overflow = "hidden";
|
9939 | outer.appendChild(inner);
|
9940 | document.body.appendChild(outer);
|
9941 | var w1 = inner.offsetWidth;
|
9942 | outer.style.overflow = "scroll";
|
9943 | var w2 = inner.offsetWidth;
|
9944 |
|
9945 | if (w1 == w2) {
|
9946 | w2 = outer.clientWidth;
|
9947 | }
|
9948 |
|
9949 | document.body.removeChild(outer);
|
9950 | return w1 - w2;
|
9951 | }
|
9952 |
|
9953 |
|
9954 |
|
9955 |
|
9956 |
|
9957 |
|
9958 |
|
9959 |
|
9960 |
|
9961 |
|
9962 |
|
9963 |
|
9964 |
|
9965 |
|
9966 |
|
9967 |
|
9968 |
|
9969 |
|
9970 |
|
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 | function topMost(pile, accessors) {
|
9978 | var candidate;
|
9979 |
|
9980 | if (!_Array$isArray$1(accessors)) {
|
9981 | accessors = [accessors];
|
9982 | }
|
9983 |
|
9984 | var _iterator3 = _createForOfIteratorHelper$6(pile),
|
9985 | _step3;
|
9986 |
|
9987 | try {
|
9988 | for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
9989 | var member = _step3.value;
|
9990 |
|
9991 | if (member) {
|
9992 | candidate = member[accessors[0]];
|
9993 |
|
9994 | for (var i = 1; i < accessors.length; i++) {
|
9995 | if (candidate) {
|
9996 | candidate = candidate[accessors[i]];
|
9997 | }
|
9998 | }
|
9999 |
|
10000 | if (typeof candidate !== "undefined") {
|
10001 | break;
|
10002 | }
|
10003 | }
|
10004 | }
|
10005 | } catch (err) {
|
10006 | _iterator3.e(err);
|
10007 | } finally {
|
10008 | _iterator3.f();
|
10009 | }
|
10010 |
|
10011 | return candidate;
|
10012 | }
|
10013 |
|
10014 | var htmlColors$1 = {
|
10015 | black: "#000000",
|
10016 | navy: "#000080",
|
10017 | darkblue: "#00008B",
|
10018 | mediumblue: "#0000CD",
|
10019 | blue: "#0000FF",
|
10020 | darkgreen: "#006400",
|
10021 | green: "#008000",
|
10022 | teal: "#008080",
|
10023 | darkcyan: "#008B8B",
|
10024 | deepskyblue: "#00BFFF",
|
10025 | darkturquoise: "#00CED1",
|
10026 | mediumspringgreen: "#00FA9A",
|
10027 | lime: "#00FF00",
|
10028 | springgreen: "#00FF7F",
|
10029 | aqua: "#00FFFF",
|
10030 | cyan: "#00FFFF",
|
10031 | midnightblue: "#191970",
|
10032 | dodgerblue: "#1E90FF",
|
10033 | lightseagreen: "#20B2AA",
|
10034 | forestgreen: "#228B22",
|
10035 | seagreen: "#2E8B57",
|
10036 | darkslategray: "#2F4F4F",
|
10037 | limegreen: "#32CD32",
|
10038 | mediumseagreen: "#3CB371",
|
10039 | turquoise: "#40E0D0",
|
10040 | royalblue: "#4169E1",
|
10041 | steelblue: "#4682B4",
|
10042 | darkslateblue: "#483D8B",
|
10043 | mediumturquoise: "#48D1CC",
|
10044 | indigo: "#4B0082",
|
10045 | darkolivegreen: "#556B2F",
|
10046 | cadetblue: "#5F9EA0",
|
10047 | cornflowerblue: "#6495ED",
|
10048 | mediumaquamarine: "#66CDAA",
|
10049 | dimgray: "#696969",
|
10050 | slateblue: "#6A5ACD",
|
10051 | olivedrab: "#6B8E23",
|
10052 | slategray: "#708090",
|
10053 | lightslategray: "#778899",
|
10054 | mediumslateblue: "#7B68EE",
|
10055 | lawngreen: "#7CFC00",
|
10056 | chartreuse: "#7FFF00",
|
10057 | aquamarine: "#7FFFD4",
|
10058 | maroon: "#800000",
|
10059 | purple: "#800080",
|
10060 | olive: "#808000",
|
10061 | gray: "#808080",
|
10062 | skyblue: "#87CEEB",
|
10063 | lightskyblue: "#87CEFA",
|
10064 | blueviolet: "#8A2BE2",
|
10065 | darkred: "#8B0000",
|
10066 | darkmagenta: "#8B008B",
|
10067 | saddlebrown: "#8B4513",
|
10068 | darkseagreen: "#8FBC8F",
|
10069 | lightgreen: "#90EE90",
|
10070 | mediumpurple: "#9370D8",
|
10071 | darkviolet: "#9400D3",
|
10072 | palegreen: "#98FB98",
|
10073 | darkorchid: "#9932CC",
|
10074 | yellowgreen: "#9ACD32",
|
10075 | sienna: "#A0522D",
|
10076 | brown: "#A52A2A",
|
10077 | darkgray: "#A9A9A9",
|
10078 | lightblue: "#ADD8E6",
|
10079 | greenyellow: "#ADFF2F",
|
10080 | paleturquoise: "#AFEEEE",
|
10081 | lightsteelblue: "#B0C4DE",
|
10082 | powderblue: "#B0E0E6",
|
10083 | firebrick: "#B22222",
|
10084 | darkgoldenrod: "#B8860B",
|
10085 | mediumorchid: "#BA55D3",
|
10086 | rosybrown: "#BC8F8F",
|
10087 | darkkhaki: "#BDB76B",
|
10088 | silver: "#C0C0C0",
|
10089 | mediumvioletred: "#C71585",
|
10090 | indianred: "#CD5C5C",
|
10091 | peru: "#CD853F",
|
10092 | chocolate: "#D2691E",
|
10093 | tan: "#D2B48C",
|
10094 | lightgrey: "#D3D3D3",
|
10095 | palevioletred: "#D87093",
|
10096 | thistle: "#D8BFD8",
|
10097 | orchid: "#DA70D6",
|
10098 | goldenrod: "#DAA520",
|
10099 | crimson: "#DC143C",
|
10100 | gainsboro: "#DCDCDC",
|
10101 | plum: "#DDA0DD",
|
10102 | burlywood: "#DEB887",
|
10103 | lightcyan: "#E0FFFF",
|
10104 | lavender: "#E6E6FA",
|
10105 | darksalmon: "#E9967A",
|
10106 | violet: "#EE82EE",
|
10107 | palegoldenrod: "#EEE8AA",
|
10108 | lightcoral: "#F08080",
|
10109 | khaki: "#F0E68C",
|
10110 | aliceblue: "#F0F8FF",
|
10111 | honeydew: "#F0FFF0",
|
10112 | azure: "#F0FFFF",
|
10113 | sandybrown: "#F4A460",
|
10114 | wheat: "#F5DEB3",
|
10115 | beige: "#F5F5DC",
|
10116 | whitesmoke: "#F5F5F5",
|
10117 | mintcream: "#F5FFFA",
|
10118 | ghostwhite: "#F8F8FF",
|
10119 | salmon: "#FA8072",
|
10120 | antiquewhite: "#FAEBD7",
|
10121 | linen: "#FAF0E6",
|
10122 | lightgoldenrodyellow: "#FAFAD2",
|
10123 | oldlace: "#FDF5E6",
|
10124 | red: "#FF0000",
|
10125 | fuchsia: "#FF00FF",
|
10126 | magenta: "#FF00FF",
|
10127 | deeppink: "#FF1493",
|
10128 | orangered: "#FF4500",
|
10129 | tomato: "#FF6347",
|
10130 | hotpink: "#FF69B4",
|
10131 | coral: "#FF7F50",
|
10132 | darkorange: "#FF8C00",
|
10133 | lightsalmon: "#FFA07A",
|
10134 | orange: "#FFA500",
|
10135 | lightpink: "#FFB6C1",
|
10136 | pink: "#FFC0CB",
|
10137 | gold: "#FFD700",
|
10138 | peachpuff: "#FFDAB9",
|
10139 | navajowhite: "#FFDEAD",
|
10140 | moccasin: "#FFE4B5",
|
10141 | bisque: "#FFE4C4",
|
10142 | mistyrose: "#FFE4E1",
|
10143 | blanchedalmond: "#FFEBCD",
|
10144 | papayawhip: "#FFEFD5",
|
10145 | lavenderblush: "#FFF0F5",
|
10146 | seashell: "#FFF5EE",
|
10147 | cornsilk: "#FFF8DC",
|
10148 | lemonchiffon: "#FFFACD",
|
10149 | floralwhite: "#FFFAF0",
|
10150 | snow: "#FFFAFA",
|
10151 | yellow: "#FFFF00",
|
10152 | lightyellow: "#FFFFE0",
|
10153 | ivory: "#FFFFF0",
|
10154 | white: "#FFFFFF"
|
10155 | };
|
10156 |
|
10157 |
|
10158 |
|
10159 |
|
10160 | var ColorPicker$1 = function () {
|
10161 | |
10162 |
|
10163 |
|
10164 | function ColorPicker$1() {
|
10165 | var pixelRatio = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
10166 |
|
10167 | _classCallCheck(this, ColorPicker$1);
|
10168 |
|
10169 | this.pixelRatio = pixelRatio;
|
10170 | this.generated = false;
|
10171 | this.centerCoordinates = {
|
10172 | x: 289 / 2,
|
10173 | y: 289 / 2
|
10174 | };
|
10175 | this.r = 289 * 0.49;
|
10176 | this.color = {
|
10177 | r: 255,
|
10178 | g: 255,
|
10179 | b: 255,
|
10180 | a: 1.0
|
10181 | };
|
10182 | this.hueCircle = undefined;
|
10183 | this.initialColor = {
|
10184 | r: 255,
|
10185 | g: 255,
|
10186 | b: 255,
|
10187 | a: 1.0
|
10188 | };
|
10189 | this.previousColor = undefined;
|
10190 | this.applied = false;
|
10191 |
|
10192 | this.updateCallback = function () {};
|
10193 |
|
10194 | this.closeCallback = function () {};
|
10195 |
|
10196 |
|
10197 | this._create();
|
10198 | }
|
10199 | |
10200 |
|
10201 |
|
10202 |
|
10203 |
|
10204 |
|
10205 |
|
10206 | _createClass(ColorPicker$1, [{
|
10207 | key: "insertTo",
|
10208 | value: function insertTo(container) {
|
10209 | if (this.hammer !== undefined) {
|
10210 | this.hammer.destroy();
|
10211 | this.hammer = undefined;
|
10212 | }
|
10213 |
|
10214 | this.container = container;
|
10215 | this.container.appendChild(this.frame);
|
10216 |
|
10217 | this._bindHammer();
|
10218 |
|
10219 | this._setSize();
|
10220 | }
|
10221 | |
10222 |
|
10223 |
|
10224 |
|
10225 |
|
10226 |
|
10227 | }, {
|
10228 | key: "setUpdateCallback",
|
10229 | value: function setUpdateCallback(callback) {
|
10230 | if (typeof callback === "function") {
|
10231 | this.updateCallback = callback;
|
10232 | } else {
|
10233 | throw new Error("Function attempted to set as colorPicker update callback is not a function.");
|
10234 | }
|
10235 | }
|
10236 | |
10237 |
|
10238 |
|
10239 |
|
10240 |
|
10241 |
|
10242 | }, {
|
10243 | key: "setCloseCallback",
|
10244 | value: function setCloseCallback(callback) {
|
10245 | if (typeof callback === "function") {
|
10246 | this.closeCallback = callback;
|
10247 | } else {
|
10248 | throw new Error("Function attempted to set as colorPicker closing callback is not a function.");
|
10249 | }
|
10250 | }
|
10251 | |
10252 |
|
10253 |
|
10254 |
|
10255 |
|
10256 |
|
10257 |
|
10258 | }, {
|
10259 | key: "_isColorString",
|
10260 | value: function _isColorString(color) {
|
10261 | if (typeof color === "string") {
|
10262 | return htmlColors$1[color];
|
10263 | }
|
10264 | }
|
10265 | |
10266 |
|
10267 |
|
10268 |
|
10269 |
|
10270 |
|
10271 |
|
10272 |
|
10273 |
|
10274 |
|
10275 |
|
10276 |
|
10277 |
|
10278 |
|
10279 | }, {
|
10280 | key: "setColor",
|
10281 | value: function setColor(color) {
|
10282 | var setInitial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
10283 |
|
10284 | if (color === "none") {
|
10285 | return;
|
10286 | }
|
10287 |
|
10288 | var rgba;
|
10289 |
|
10290 | var htmlColor = this._isColorString(color);
|
10291 |
|
10292 | if (htmlColor !== undefined) {
|
10293 | color = htmlColor;
|
10294 | }
|
10295 |
|
10296 |
|
10297 | if (isString(color) === true) {
|
10298 | if (isValidRGB(color) === true) {
|
10299 | var rgbaArray = color.substr(4).substr(0, color.length - 5).split(",");
|
10300 | rgba = {
|
10301 | r: rgbaArray[0],
|
10302 | g: rgbaArray[1],
|
10303 | b: rgbaArray[2],
|
10304 | a: 1.0
|
10305 | };
|
10306 | } else if (isValidRGBA(color) === true) {
|
10307 | var _rgbaArray = color.substr(5).substr(0, color.length - 6).split(",");
|
10308 |
|
10309 | rgba = {
|
10310 | r: _rgbaArray[0],
|
10311 | g: _rgbaArray[1],
|
10312 | b: _rgbaArray[2],
|
10313 | a: _rgbaArray[3]
|
10314 | };
|
10315 | } else if (isValidHex(color) === true) {
|
10316 | var rgbObj = hexToRGB(color);
|
10317 | rgba = {
|
10318 | r: rgbObj.r,
|
10319 | g: rgbObj.g,
|
10320 | b: rgbObj.b,
|
10321 | a: 1.0
|
10322 | };
|
10323 | }
|
10324 | } else {
|
10325 | if (color instanceof Object) {
|
10326 | if (color.r !== undefined && color.g !== undefined && color.b !== undefined) {
|
10327 | var alpha = color.a !== undefined ? color.a : "1.0";
|
10328 | rgba = {
|
10329 | r: color.r,
|
10330 | g: color.g,
|
10331 | b: color.b,
|
10332 | a: alpha
|
10333 | };
|
10334 | }
|
10335 | }
|
10336 | }
|
10337 |
|
10338 |
|
10339 | if (rgba === undefined) {
|
10340 | throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: " + _JSON$stringify(color));
|
10341 | } else {
|
10342 | this._setColor(rgba, setInitial);
|
10343 | }
|
10344 | }
|
10345 | |
10346 |
|
10347 |
|
10348 |
|
10349 |
|
10350 | }, {
|
10351 | key: "show",
|
10352 | value: function show() {
|
10353 | if (this.closeCallback !== undefined) {
|
10354 | this.closeCallback();
|
10355 | this.closeCallback = undefined;
|
10356 | }
|
10357 |
|
10358 | this.applied = false;
|
10359 | this.frame.style.display = "block";
|
10360 |
|
10361 | this._generateHueCircle();
|
10362 | }
|
10363 |
|
10364 | |
10365 |
|
10366 |
|
10367 |
|
10368 |
|
10369 |
|
10370 |
|
10371 |
|
10372 | }, {
|
10373 | key: "_hide",
|
10374 | value: function _hide() {
|
10375 | var _this2 = this;
|
10376 |
|
10377 | var storePrevious = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
10378 |
|
10379 |
|
10380 | if (storePrevious === true) {
|
10381 | this.previousColor = _Object$assign({}, this.color);
|
10382 | }
|
10383 |
|
10384 | if (this.applied === true) {
|
10385 | this.updateCallback(this.initialColor);
|
10386 | }
|
10387 |
|
10388 | this.frame.style.display = "none";
|
10389 |
|
10390 |
|
10391 | _setTimeout(function () {
|
10392 | if (_this2.closeCallback !== undefined) {
|
10393 | _this2.closeCallback();
|
10394 |
|
10395 | _this2.closeCallback = undefined;
|
10396 | }
|
10397 | }, 0);
|
10398 | }
|
10399 | |
10400 |
|
10401 |
|
10402 |
|
10403 |
|
10404 |
|
10405 | }, {
|
10406 | key: "_save",
|
10407 | value: function _save() {
|
10408 | this.updateCallback(this.color);
|
10409 | this.applied = false;
|
10410 |
|
10411 | this._hide();
|
10412 | }
|
10413 | |
10414 |
|
10415 |
|
10416 |
|
10417 |
|
10418 |
|
10419 | }, {
|
10420 | key: "_apply",
|
10421 | value: function _apply() {
|
10422 | this.applied = true;
|
10423 | this.updateCallback(this.color);
|
10424 |
|
10425 | this._updatePicker(this.color);
|
10426 | }
|
10427 | |
10428 |
|
10429 |
|
10430 |
|
10431 |
|
10432 |
|
10433 | }, {
|
10434 | key: "_loadLast",
|
10435 | value: function _loadLast() {
|
10436 | if (this.previousColor !== undefined) {
|
10437 | this.setColor(this.previousColor, false);
|
10438 | } else {
|
10439 | alert("There is no last color to load...");
|
10440 | }
|
10441 | }
|
10442 | |
10443 |
|
10444 |
|
10445 |
|
10446 |
|
10447 |
|
10448 |
|
10449 |
|
10450 | }, {
|
10451 | key: "_setColor",
|
10452 | value: function _setColor(rgba) {
|
10453 | var setInitial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
10454 |
|
10455 |
|
10456 | if (setInitial === true) {
|
10457 | this.initialColor = _Object$assign({}, rgba);
|
10458 | }
|
10459 |
|
10460 | this.color = rgba;
|
10461 | var hsv = RGBToHSV(rgba.r, rgba.g, rgba.b);
|
10462 | var angleConvert = 2 * Math.PI;
|
10463 | var radius = this.r * hsv.s;
|
10464 | var x = this.centerCoordinates.x + radius * Math.sin(angleConvert * hsv.h);
|
10465 | var y = this.centerCoordinates.y + radius * Math.cos(angleConvert * hsv.h);
|
10466 | this.colorPickerSelector.style.left = x - 0.5 * this.colorPickerSelector.clientWidth + "px";
|
10467 | this.colorPickerSelector.style.top = y - 0.5 * this.colorPickerSelector.clientHeight + "px";
|
10468 |
|
10469 | this._updatePicker(rgba);
|
10470 | }
|
10471 | |
10472 |
|
10473 |
|
10474 |
|
10475 |
|
10476 |
|
10477 |
|
10478 | }, {
|
10479 | key: "_setOpacity",
|
10480 | value: function _setOpacity(value) {
|
10481 | this.color.a = value / 100;
|
10482 |
|
10483 | this._updatePicker(this.color);
|
10484 | }
|
10485 | |
10486 |
|
10487 |
|
10488 |
|
10489 |
|
10490 |
|
10491 |
|
10492 | }, {
|
10493 | key: "_setBrightness",
|
10494 | value: function _setBrightness(value) {
|
10495 | var hsv = RGBToHSV(this.color.r, this.color.g, this.color.b);
|
10496 | hsv.v = value / 100;
|
10497 | var rgba = HSVToRGB(hsv.h, hsv.s, hsv.v);
|
10498 | rgba["a"] = this.color.a;
|
10499 | this.color = rgba;
|
10500 |
|
10501 | this._updatePicker();
|
10502 | }
|
10503 | |
10504 |
|
10505 |
|
10506 |
|
10507 |
|
10508 |
|
10509 |
|
10510 | }, {
|
10511 | key: "_updatePicker",
|
10512 | value: function _updatePicker() {
|
10513 | var rgba = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.color;
|
10514 | var hsv = RGBToHSV(rgba.r, rgba.g, rgba.b);
|
10515 | var ctx = this.colorPickerCanvas.getContext("2d");
|
10516 |
|
10517 | if (this.pixelRation === undefined) {
|
10518 | this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
|
10519 | }
|
10520 |
|
10521 | ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
|
10522 |
|
10523 | var w = this.colorPickerCanvas.clientWidth;
|
10524 | var h = this.colorPickerCanvas.clientHeight;
|
10525 | ctx.clearRect(0, 0, w, h);
|
10526 | ctx.putImageData(this.hueCircle, 0, 0);
|
10527 | ctx.fillStyle = "rgba(0,0,0," + (1 - hsv.v) + ")";
|
10528 | ctx.circle(this.centerCoordinates.x, this.centerCoordinates.y, this.r);
|
10529 |
|
10530 | _fillInstanceProperty(ctx).call(ctx);
|
10531 |
|
10532 | this.brightnessRange.value = 100 * hsv.v;
|
10533 | this.opacityRange.value = 100 * rgba.a;
|
10534 | this.initialColorDiv.style.backgroundColor = "rgba(" + this.initialColor.r + "," + this.initialColor.g + "," + this.initialColor.b + "," + this.initialColor.a + ")";
|
10535 | this.newColorDiv.style.backgroundColor = "rgba(" + this.color.r + "," + this.color.g + "," + this.color.b + "," + this.color.a + ")";
|
10536 | }
|
10537 | |
10538 |
|
10539 |
|
10540 |
|
10541 |
|
10542 |
|
10543 | }, {
|
10544 | key: "_setSize",
|
10545 | value: function _setSize() {
|
10546 | this.colorPickerCanvas.style.width = "100%";
|
10547 | this.colorPickerCanvas.style.height = "100%";
|
10548 | this.colorPickerCanvas.width = 289 * this.pixelRatio;
|
10549 | this.colorPickerCanvas.height = 289 * this.pixelRatio;
|
10550 | }
|
10551 | |
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 |
|
10558 | }, {
|
10559 | key: "_create",
|
10560 | value: function _create() {
|
10561 | var _context16, _context17, _context18, _context19;
|
10562 |
|
10563 | this.frame = document.createElement("div");
|
10564 | this.frame.className = "vis-color-picker";
|
10565 | this.colorPickerDiv = document.createElement("div");
|
10566 | this.colorPickerSelector = document.createElement("div");
|
10567 | this.colorPickerSelector.className = "vis-selector";
|
10568 | this.colorPickerDiv.appendChild(this.colorPickerSelector);
|
10569 | this.colorPickerCanvas = document.createElement("canvas");
|
10570 | this.colorPickerDiv.appendChild(this.colorPickerCanvas);
|
10571 |
|
10572 | if (!this.colorPickerCanvas.getContext) {
|
10573 | var noCanvas = document.createElement("DIV");
|
10574 | noCanvas.style.color = "red";
|
10575 | noCanvas.style.fontWeight = "bold";
|
10576 | noCanvas.style.padding = "10px";
|
10577 | noCanvas.innerText = "Error: your browser does not support HTML canvas";
|
10578 | this.colorPickerCanvas.appendChild(noCanvas);
|
10579 | } else {
|
10580 | var ctx = this.colorPickerCanvas.getContext("2d");
|
10581 | this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
|
10582 | this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
|
10583 | }
|
10584 |
|
10585 | this.colorPickerDiv.className = "vis-color";
|
10586 | this.opacityDiv = document.createElement("div");
|
10587 | this.opacityDiv.className = "vis-opacity";
|
10588 | this.brightnessDiv = document.createElement("div");
|
10589 | this.brightnessDiv.className = "vis-brightness";
|
10590 | this.arrowDiv = document.createElement("div");
|
10591 | this.arrowDiv.className = "vis-arrow";
|
10592 | this.opacityRange = document.createElement("input");
|
10593 |
|
10594 | try {
|
10595 | this.opacityRange.type = "range";
|
10596 |
|
10597 | this.opacityRange.min = "0";
|
10598 | this.opacityRange.max = "100";
|
10599 | } catch (err) {
|
10600 | }
|
10601 |
|
10602 | this.opacityRange.value = "100";
|
10603 | this.opacityRange.className = "vis-range";
|
10604 | this.brightnessRange = document.createElement("input");
|
10605 |
|
10606 | try {
|
10607 | this.brightnessRange.type = "range";
|
10608 |
|
10609 | this.brightnessRange.min = "0";
|
10610 | this.brightnessRange.max = "100";
|
10611 | } catch (err) {
|
10612 | }
|
10613 |
|
10614 | this.brightnessRange.value = "100";
|
10615 | this.brightnessRange.className = "vis-range";
|
10616 | this.opacityDiv.appendChild(this.opacityRange);
|
10617 | this.brightnessDiv.appendChild(this.brightnessRange);
|
10618 | var me = this;
|
10619 |
|
10620 | this.opacityRange.onchange = function () {
|
10621 | me._setOpacity(this.value);
|
10622 | };
|
10623 |
|
10624 | this.opacityRange.oninput = function () {
|
10625 | me._setOpacity(this.value);
|
10626 | };
|
10627 |
|
10628 | this.brightnessRange.onchange = function () {
|
10629 | me._setBrightness(this.value);
|
10630 | };
|
10631 |
|
10632 | this.brightnessRange.oninput = function () {
|
10633 | me._setBrightness(this.value);
|
10634 | };
|
10635 |
|
10636 | this.brightnessLabel = document.createElement("div");
|
10637 | this.brightnessLabel.className = "vis-label vis-brightness";
|
10638 | this.brightnessLabel.innerText = "brightness:";
|
10639 | this.opacityLabel = document.createElement("div");
|
10640 | this.opacityLabel.className = "vis-label vis-opacity";
|
10641 | this.opacityLabel.innerText = "opacity:";
|
10642 | this.newColorDiv = document.createElement("div");
|
10643 | this.newColorDiv.className = "vis-new-color";
|
10644 | this.newColorDiv.innerText = "new";
|
10645 | this.initialColorDiv = document.createElement("div");
|
10646 | this.initialColorDiv.className = "vis-initial-color";
|
10647 | this.initialColorDiv.innerText = "initial";
|
10648 | this.cancelButton = document.createElement("div");
|
10649 | this.cancelButton.className = "vis-button vis-cancel";
|
10650 | this.cancelButton.innerText = "cancel";
|
10651 | this.cancelButton.onclick = _bindInstanceProperty(_context16 = this._hide).call(_context16, this, false);
|
10652 | this.applyButton = document.createElement("div");
|
10653 | this.applyButton.className = "vis-button vis-apply";
|
10654 | this.applyButton.innerText = "apply";
|
10655 | this.applyButton.onclick = _bindInstanceProperty(_context17 = this._apply).call(_context17, this);
|
10656 | this.saveButton = document.createElement("div");
|
10657 | this.saveButton.className = "vis-button vis-save";
|
10658 | this.saveButton.innerText = "save";
|
10659 | this.saveButton.onclick = _bindInstanceProperty(_context18 = this._save).call(_context18, this);
|
10660 | this.loadButton = document.createElement("div");
|
10661 | this.loadButton.className = "vis-button vis-load";
|
10662 | this.loadButton.innerText = "load last";
|
10663 | this.loadButton.onclick = _bindInstanceProperty(_context19 = this._loadLast).call(_context19, this);
|
10664 | this.frame.appendChild(this.colorPickerDiv);
|
10665 | this.frame.appendChild(this.arrowDiv);
|
10666 | this.frame.appendChild(this.brightnessLabel);
|
10667 | this.frame.appendChild(this.brightnessDiv);
|
10668 | this.frame.appendChild(this.opacityLabel);
|
10669 | this.frame.appendChild(this.opacityDiv);
|
10670 | this.frame.appendChild(this.newColorDiv);
|
10671 | this.frame.appendChild(this.initialColorDiv);
|
10672 | this.frame.appendChild(this.cancelButton);
|
10673 | this.frame.appendChild(this.applyButton);
|
10674 | this.frame.appendChild(this.saveButton);
|
10675 | this.frame.appendChild(this.loadButton);
|
10676 | }
|
10677 | |
10678 |
|
10679 |
|
10680 |
|
10681 |
|
10682 |
|
10683 | }, {
|
10684 | key: "_bindHammer",
|
10685 | value: function _bindHammer() {
|
10686 | var _this3 = this;
|
10687 |
|
10688 | this.drag = {};
|
10689 | this.pinch = {};
|
10690 | this.hammer = new Hammer$1(this.colorPickerCanvas);
|
10691 | this.hammer.get("pinch").set({
|
10692 | enable: true
|
10693 | });
|
10694 | this.hammer.on("hammer.input", function (event) {
|
10695 | if (event.isFirst) {
|
10696 | _this3._moveSelector(event);
|
10697 | }
|
10698 | });
|
10699 | this.hammer.on("tap", function (event) {
|
10700 | _this3._moveSelector(event);
|
10701 | });
|
10702 | this.hammer.on("panstart", function (event) {
|
10703 | _this3._moveSelector(event);
|
10704 | });
|
10705 | this.hammer.on("panmove", function (event) {
|
10706 | _this3._moveSelector(event);
|
10707 | });
|
10708 | this.hammer.on("panend", function (event) {
|
10709 | _this3._moveSelector(event);
|
10710 | });
|
10711 | }
|
10712 | |
10713 |
|
10714 |
|
10715 |
|
10716 |
|
10717 |
|
10718 | }, {
|
10719 | key: "_generateHueCircle",
|
10720 | value: function _generateHueCircle() {
|
10721 | if (this.generated === false) {
|
10722 | var ctx = this.colorPickerCanvas.getContext("2d");
|
10723 |
|
10724 | if (this.pixelRation === undefined) {
|
10725 | this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
|
10726 | }
|
10727 |
|
10728 | ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
|
10729 |
|
10730 | var w = this.colorPickerCanvas.clientWidth;
|
10731 | var h = this.colorPickerCanvas.clientHeight;
|
10732 | ctx.clearRect(0, 0, w, h);
|
10733 |
|
10734 | var x, y, hue, sat;
|
10735 | this.centerCoordinates = {
|
10736 | x: w * 0.5,
|
10737 | y: h * 0.5
|
10738 | };
|
10739 | this.r = 0.49 * w;
|
10740 | var angleConvert = 2 * Math.PI / 360;
|
10741 | var hfac = 1 / 360;
|
10742 | var sfac = 1 / this.r;
|
10743 | var rgb;
|
10744 |
|
10745 | for (hue = 0; hue < 360; hue++) {
|
10746 | for (sat = 0; sat < this.r; sat++) {
|
10747 | x = this.centerCoordinates.x + sat * Math.sin(angleConvert * hue);
|
10748 | y = this.centerCoordinates.y + sat * Math.cos(angleConvert * hue);
|
10749 | rgb = HSVToRGB(hue * hfac, sat * sfac, 1);
|
10750 | ctx.fillStyle = "rgb(" + rgb.r + "," + rgb.g + "," + rgb.b + ")";
|
10751 | ctx.fillRect(x - 0.5, y - 0.5, 2, 2);
|
10752 | }
|
10753 | }
|
10754 |
|
10755 | ctx.strokeStyle = "rgba(0,0,0,1)";
|
10756 | ctx.circle(this.centerCoordinates.x, this.centerCoordinates.y, this.r);
|
10757 | ctx.stroke();
|
10758 | this.hueCircle = ctx.getImageData(0, 0, w, h);
|
10759 | }
|
10760 |
|
10761 | this.generated = true;
|
10762 | }
|
10763 | |
10764 |
|
10765 |
|
10766 |
|
10767 |
|
10768 |
|
10769 |
|
10770 | }, {
|
10771 | key: "_moveSelector",
|
10772 | value: function _moveSelector(event) {
|
10773 | var rect = this.colorPickerDiv.getBoundingClientRect();
|
10774 | var left = event.center.x - rect.left;
|
10775 | var top = event.center.y - rect.top;
|
10776 | var centerY = 0.5 * this.colorPickerDiv.clientHeight;
|
10777 | var centerX = 0.5 * this.colorPickerDiv.clientWidth;
|
10778 | var x = left - centerX;
|
10779 | var y = top - centerY;
|
10780 | var angle = Math.atan2(x, y);
|
10781 | var radius = 0.98 * Math.min(Math.sqrt(x * x + y * y), centerX);
|
10782 | var newTop = Math.cos(angle) * radius + centerY;
|
10783 | var newLeft = Math.sin(angle) * radius + centerX;
|
10784 | this.colorPickerSelector.style.top = newTop - 0.5 * this.colorPickerSelector.clientHeight + "px";
|
10785 | this.colorPickerSelector.style.left = newLeft - 0.5 * this.colorPickerSelector.clientWidth + "px";
|
10786 |
|
10787 | var h = angle / (2 * Math.PI);
|
10788 | h = h < 0 ? h + 1 : h;
|
10789 | var s = radius / this.r;
|
10790 | var hsv = RGBToHSV(this.color.r, this.color.g, this.color.b);
|
10791 | hsv.h = h;
|
10792 | hsv.s = s;
|
10793 | var rgba = HSVToRGB(hsv.h, hsv.s, hsv.v);
|
10794 | rgba["a"] = this.color.a;
|
10795 | this.color = rgba;
|
10796 |
|
10797 | this.initialColorDiv.style.backgroundColor = "rgba(" + this.initialColor.r + "," + this.initialColor.g + "," + this.initialColor.b + "," + this.initialColor.a + ")";
|
10798 | this.newColorDiv.style.backgroundColor = "rgba(" + this.color.r + "," + this.color.g + "," + this.color.b + "," + this.color.a + ")";
|
10799 | }
|
10800 | }]);
|
10801 |
|
10802 | return ColorPicker$1;
|
10803 | }();
|
10804 |
|
10805 |
|
10806 |
|
10807 |
|
10808 |
|
10809 |
|
10810 |
|
10811 |
|
10812 | function wrapInTag() {
|
10813 | for (var _len5 = arguments.length, rest = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
10814 | rest[_key5] = arguments[_key5];
|
10815 | }
|
10816 |
|
10817 | if (rest.length < 1) {
|
10818 | throw new TypeError("Invalid arguments.");
|
10819 | } else if (rest.length === 1) {
|
10820 | return document.createTextNode(rest[0]);
|
10821 | } else {
|
10822 | var element = document.createElement(rest[0]);
|
10823 | element.appendChild(wrapInTag.apply(void 0, _toConsumableArray(_sliceInstanceProperty(rest).call(rest, 1))));
|
10824 | return element;
|
10825 | }
|
10826 | }
|
10827 |
|
10828 |
|
10829 |
|
10830 |
|
10831 |
|
10832 |
|
10833 |
|
10834 |
|
10835 |
|
10836 |
|
10837 |
|
10838 | var Configurator$1 = function () {
|
10839 | |
10840 |
|
10841 |
|
10842 |
|
10843 |
|
10844 |
|
10845 |
|
10846 | function Configurator$1(parentModule, defaultContainer, configureOptions) {
|
10847 | var pixelRatio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
10848 | var hideOption = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {
|
10849 | return false;
|
10850 | };
|
10851 |
|
10852 | _classCallCheck(this, Configurator$1);
|
10853 |
|
10854 | this.parent = parentModule;
|
10855 | this.changedOptions = [];
|
10856 | this.container = defaultContainer;
|
10857 | this.allowCreation = false;
|
10858 | this.hideOption = hideOption;
|
10859 | this.options = {};
|
10860 | this.initialized = false;
|
10861 | this.popupCounter = 0;
|
10862 | this.defaultOptions = {
|
10863 | enabled: false,
|
10864 | filter: true,
|
10865 | container: undefined,
|
10866 | showButton: true
|
10867 | };
|
10868 |
|
10869 | _Object$assign(this.options, this.defaultOptions);
|
10870 |
|
10871 | this.configureOptions = configureOptions;
|
10872 | this.moduleOptions = {};
|
10873 | this.domElements = [];
|
10874 | this.popupDiv = {};
|
10875 | this.popupLimit = 5;
|
10876 | this.popupHistory = {};
|
10877 | this.colorPicker = new ColorPicker$1(pixelRatio);
|
10878 | this.wrapper = undefined;
|
10879 | }
|
10880 | |
10881 |
|
10882 |
|
10883 |
|
10884 |
|
10885 |
|
10886 |
|
10887 |
|
10888 | _createClass(Configurator$1, [{
|
10889 | key: "setOptions",
|
10890 | value: function setOptions(options) {
|
10891 | if (options !== undefined) {
|
10892 |
|
10893 | this.popupHistory = {};
|
10894 |
|
10895 | this._removePopup();
|
10896 |
|
10897 | var enabled = true;
|
10898 |
|
10899 | if (typeof options === "string") {
|
10900 | this.options.filter = options;
|
10901 | } else if (_Array$isArray$1(options)) {
|
10902 | this.options.filter = options.join();
|
10903 | } else if (_typeof(options) === "object") {
|
10904 | if (options == null) {
|
10905 | throw new TypeError("options cannot be null");
|
10906 | }
|
10907 |
|
10908 | if (options.container !== undefined) {
|
10909 | this.options.container = options.container;
|
10910 | }
|
10911 |
|
10912 | if (_filterInstanceProperty(options) !== undefined) {
|
10913 | this.options.filter = _filterInstanceProperty(options);
|
10914 | }
|
10915 |
|
10916 | if (options.showButton !== undefined) {
|
10917 | this.options.showButton = options.showButton;
|
10918 | }
|
10919 |
|
10920 | if (options.enabled !== undefined) {
|
10921 | enabled = options.enabled;
|
10922 | }
|
10923 | } else if (typeof options === "boolean") {
|
10924 | this.options.filter = true;
|
10925 | enabled = options;
|
10926 | } else if (typeof options === "function") {
|
10927 | this.options.filter = options;
|
10928 | enabled = true;
|
10929 | }
|
10930 |
|
10931 | if (_filterInstanceProperty(this.options) === false) {
|
10932 | enabled = false;
|
10933 | }
|
10934 |
|
10935 | this.options.enabled = enabled;
|
10936 | }
|
10937 |
|
10938 | this._clean();
|
10939 | }
|
10940 | |
10941 |
|
10942 |
|
10943 |
|
10944 |
|
10945 | }, {
|
10946 | key: "setModuleOptions",
|
10947 | value: function setModuleOptions(moduleOptions) {
|
10948 | this.moduleOptions = moduleOptions;
|
10949 |
|
10950 | if (this.options.enabled === true) {
|
10951 | this._clean();
|
10952 |
|
10953 | if (this.options.container !== undefined) {
|
10954 | this.container = this.options.container;
|
10955 | }
|
10956 |
|
10957 | this._create();
|
10958 | }
|
10959 | }
|
10960 | |
10961 |
|
10962 |
|
10963 |
|
10964 |
|
10965 |
|
10966 | }, {
|
10967 | key: "_create",
|
10968 | value: function _create() {
|
10969 | this._clean();
|
10970 |
|
10971 | this.changedOptions = [];
|
10972 |
|
10973 | var filter = _filterInstanceProperty(this.options);
|
10974 |
|
10975 | var counter = 0;
|
10976 | var show = false;
|
10977 |
|
10978 | for (var _option in this.configureOptions) {
|
10979 | if (Object.prototype.hasOwnProperty.call(this.configureOptions, _option)) {
|
10980 | this.allowCreation = false;
|
10981 | show = false;
|
10982 |
|
10983 | if (typeof filter === "function") {
|
10984 | show = filter(_option, []);
|
10985 | show = show || this._handleObject(this.configureOptions[_option], [_option], true);
|
10986 | } else if (filter === true || _indexOfInstanceProperty(filter).call(filter, _option) !== -1) {
|
10987 | show = true;
|
10988 | }
|
10989 |
|
10990 | if (show !== false) {
|
10991 | this.allowCreation = true;
|
10992 |
|
10993 | if (counter > 0) {
|
10994 | this._makeItem([]);
|
10995 | }
|
10996 |
|
10997 |
|
10998 | this._makeHeader(_option);
|
10999 |
|
11000 |
|
11001 | this._handleObject(this.configureOptions[_option], [_option]);
|
11002 | }
|
11003 |
|
11004 | counter++;
|
11005 | }
|
11006 | }
|
11007 |
|
11008 | this._makeButton();
|
11009 |
|
11010 | this._push();
|
11011 |
|
11012 | }
|
11013 | |
11014 |
|
11015 |
|
11016 |
|
11017 |
|
11018 |
|
11019 | }, {
|
11020 | key: "_push",
|
11021 | value: function _push() {
|
11022 | this.wrapper = document.createElement("div");
|
11023 | this.wrapper.className = "vis-configuration-wrapper";
|
11024 | this.container.appendChild(this.wrapper);
|
11025 |
|
11026 | for (var i = 0; i < this.domElements.length; i++) {
|
11027 | this.wrapper.appendChild(this.domElements[i]);
|
11028 | }
|
11029 |
|
11030 | this._showPopupIfNeeded();
|
11031 | }
|
11032 | |
11033 |
|
11034 |
|
11035 |
|
11036 |
|
11037 |
|
11038 | }, {
|
11039 | key: "_clean",
|
11040 | value: function _clean() {
|
11041 | for (var i = 0; i < this.domElements.length; i++) {
|
11042 | this.wrapper.removeChild(this.domElements[i]);
|
11043 | }
|
11044 |
|
11045 | if (this.wrapper !== undefined) {
|
11046 | this.container.removeChild(this.wrapper);
|
11047 | this.wrapper = undefined;
|
11048 | }
|
11049 |
|
11050 | this.domElements = [];
|
11051 |
|
11052 | this._removePopup();
|
11053 | }
|
11054 | |
11055 |
|
11056 |
|
11057 |
|
11058 |
|
11059 |
|
11060 |
|
11061 |
|
11062 | }, {
|
11063 | key: "_getValue",
|
11064 | value: function _getValue(path) {
|
11065 | var base = this.moduleOptions;
|
11066 |
|
11067 | for (var i = 0; i < path.length; i++) {
|
11068 | if (base[path[i]] !== undefined) {
|
11069 | base = base[path[i]];
|
11070 | } else {
|
11071 | base = undefined;
|
11072 | break;
|
11073 | }
|
11074 | }
|
11075 |
|
11076 | return base;
|
11077 | }
|
11078 | |
11079 |
|
11080 |
|
11081 |
|
11082 |
|
11083 |
|
11084 |
|
11085 |
|
11086 |
|
11087 | }, {
|
11088 | key: "_makeItem",
|
11089 | value: function _makeItem(path) {
|
11090 | if (this.allowCreation === true) {
|
11091 | var item = document.createElement("div");
|
11092 | item.className = "vis-configuration vis-config-item vis-config-s" + path.length;
|
11093 |
|
11094 | for (var _len6 = arguments.length, domElements = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
11095 | domElements[_key6 - 1] = arguments[_key6];
|
11096 | }
|
11097 |
|
11098 | _forEachInstanceProperty(domElements).call(domElements, function (element) {
|
11099 | item.appendChild(element);
|
11100 | });
|
11101 |
|
11102 | this.domElements.push(item);
|
11103 | return this.domElements.length;
|
11104 | }
|
11105 |
|
11106 | return 0;
|
11107 | }
|
11108 | |
11109 |
|
11110 |
|
11111 |
|
11112 |
|
11113 |
|
11114 |
|
11115 | }, {
|
11116 | key: "_makeHeader",
|
11117 | value: function _makeHeader(name) {
|
11118 | var div = document.createElement("div");
|
11119 | div.className = "vis-configuration vis-config-header";
|
11120 | div.innerText = name;
|
11121 |
|
11122 | this._makeItem([], div);
|
11123 | }
|
11124 | |
11125 |
|
11126 |
|
11127 |
|
11128 |
|
11129 |
|
11130 |
|
11131 |
|
11132 |
|
11133 |
|
11134 | }, {
|
11135 | key: "_makeLabel",
|
11136 | value: function _makeLabel(name, path) {
|
11137 | var objectLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
11138 | var div = document.createElement("div");
|
11139 | div.className = "vis-configuration vis-config-label vis-config-s" + path.length;
|
11140 |
|
11141 | if (objectLabel === true) {
|
11142 | while (div.firstChild) {
|
11143 | div.removeChild(div.firstChild);
|
11144 | }
|
11145 |
|
11146 | div.appendChild(wrapInTag("i", "b", name));
|
11147 | } else {
|
11148 | div.innerText = name + ":";
|
11149 | }
|
11150 |
|
11151 | return div;
|
11152 | }
|
11153 | |
11154 |
|
11155 |
|
11156 |
|
11157 |
|
11158 |
|
11159 |
|
11160 |
|
11161 |
|
11162 | }, {
|
11163 | key: "_makeDropdown",
|
11164 | value: function _makeDropdown(arr, value, path) {
|
11165 | var select = document.createElement("select");
|
11166 | select.className = "vis-configuration vis-config-select";
|
11167 | var selectedValue = 0;
|
11168 |
|
11169 | if (value !== undefined) {
|
11170 | if (_indexOfInstanceProperty(arr).call(arr, value) !== -1) {
|
11171 | selectedValue = _indexOfInstanceProperty(arr).call(arr, value);
|
11172 | }
|
11173 | }
|
11174 |
|
11175 | for (var i = 0; i < arr.length; i++) {
|
11176 | var _option2 = document.createElement("option");
|
11177 |
|
11178 | _option2.value = arr[i];
|
11179 |
|
11180 | if (i === selectedValue) {
|
11181 | _option2.selected = "selected";
|
11182 | }
|
11183 |
|
11184 | _option2.innerText = arr[i];
|
11185 | select.appendChild(_option2);
|
11186 | }
|
11187 |
|
11188 | var me = this;
|
11189 |
|
11190 | select.onchange = function () {
|
11191 | me._update(this.value, path);
|
11192 | };
|
11193 |
|
11194 | var label = this._makeLabel(path[path.length - 1], path);
|
11195 |
|
11196 | this._makeItem(path, label, select);
|
11197 | }
|
11198 | |
11199 |
|
11200 |
|
11201 |
|
11202 |
|
11203 |
|
11204 |
|
11205 |
|
11206 |
|
11207 | }, {
|
11208 | key: "_makeRange",
|
11209 | value: function _makeRange(arr, value, path) {
|
11210 | var defaultValue = arr[0];
|
11211 | var min = arr[1];
|
11212 | var max = arr[2];
|
11213 | var step = arr[3];
|
11214 | var range = document.createElement("input");
|
11215 | range.className = "vis-configuration vis-config-range";
|
11216 |
|
11217 | try {
|
11218 | range.type = "range";
|
11219 |
|
11220 | range.min = min;
|
11221 | range.max = max;
|
11222 | } catch (err) {
|
11223 | }
|
11224 |
|
11225 | range.step = step;
|
11226 |
|
11227 | var popupString = "";
|
11228 | var popupValue = 0;
|
11229 |
|
11230 | if (value !== undefined) {
|
11231 | var factor = 1.2;
|
11232 |
|
11233 | if (value < 0 && value * factor < min) {
|
11234 | range.min = Math.ceil(value * factor);
|
11235 | popupValue = range.min;
|
11236 | popupString = "range increased";
|
11237 | } else if (value / factor < min) {
|
11238 | range.min = Math.ceil(value / factor);
|
11239 | popupValue = range.min;
|
11240 | popupString = "range increased";
|
11241 | }
|
11242 |
|
11243 | if (value * factor > max && max !== 1) {
|
11244 | range.max = Math.ceil(value * factor);
|
11245 | popupValue = range.max;
|
11246 | popupString = "range increased";
|
11247 | }
|
11248 |
|
11249 | range.value = value;
|
11250 | } else {
|
11251 | range.value = defaultValue;
|
11252 | }
|
11253 |
|
11254 | var input = document.createElement("input");
|
11255 | input.className = "vis-configuration vis-config-rangeinput";
|
11256 | input.value = range.value;
|
11257 | var me = this;
|
11258 |
|
11259 | range.onchange = function () {
|
11260 | input.value = this.value;
|
11261 |
|
11262 | me._update(Number(this.value), path);
|
11263 | };
|
11264 |
|
11265 | range.oninput = function () {
|
11266 | input.value = this.value;
|
11267 | };
|
11268 |
|
11269 | var label = this._makeLabel(path[path.length - 1], path);
|
11270 |
|
11271 | var itemIndex = this._makeItem(path, label, range, input);
|
11272 |
|
11273 |
|
11274 | if (popupString !== "" && this.popupHistory[itemIndex] !== popupValue) {
|
11275 | this.popupHistory[itemIndex] = popupValue;
|
11276 |
|
11277 | this._setupPopup(popupString, itemIndex);
|
11278 | }
|
11279 | }
|
11280 | |
11281 |
|
11282 |
|
11283 |
|
11284 |
|
11285 |
|
11286 | }, {
|
11287 | key: "_makeButton",
|
11288 | value: function _makeButton() {
|
11289 | var _this4 = this;
|
11290 |
|
11291 | if (this.options.showButton === true) {
|
11292 | var generateButton = document.createElement("div");
|
11293 | generateButton.className = "vis-configuration vis-config-button";
|
11294 | generateButton.innerText = "generate options";
|
11295 |
|
11296 | generateButton.onclick = function () {
|
11297 | _this4._printOptions();
|
11298 | };
|
11299 |
|
11300 | generateButton.onmouseover = function () {
|
11301 | generateButton.className = "vis-configuration vis-config-button hover";
|
11302 | };
|
11303 |
|
11304 | generateButton.onmouseout = function () {
|
11305 | generateButton.className = "vis-configuration vis-config-button";
|
11306 | };
|
11307 |
|
11308 | this.optionsContainer = document.createElement("div");
|
11309 | this.optionsContainer.className = "vis-configuration vis-config-option-container";
|
11310 | this.domElements.push(this.optionsContainer);
|
11311 | this.domElements.push(generateButton);
|
11312 | }
|
11313 | }
|
11314 | |
11315 |
|
11316 |
|
11317 |
|
11318 |
|
11319 |
|
11320 |
|
11321 |
|
11322 | }, {
|
11323 | key: "_setupPopup",
|
11324 | value: function _setupPopup(string, index) {
|
11325 | var _this5 = this;
|
11326 |
|
11327 | if (this.initialized === true && this.allowCreation === true && this.popupCounter < this.popupLimit) {
|
11328 | var div = document.createElement("div");
|
11329 | div.id = "vis-configuration-popup";
|
11330 | div.className = "vis-configuration-popup";
|
11331 | div.innerText = string;
|
11332 |
|
11333 | div.onclick = function () {
|
11334 | _this5._removePopup();
|
11335 | };
|
11336 |
|
11337 | this.popupCounter += 1;
|
11338 | this.popupDiv = {
|
11339 | html: div,
|
11340 | index: index
|
11341 | };
|
11342 | }
|
11343 | }
|
11344 | |
11345 |
|
11346 |
|
11347 |
|
11348 |
|
11349 |
|
11350 | }, {
|
11351 | key: "_removePopup",
|
11352 | value: function _removePopup() {
|
11353 | if (this.popupDiv.html !== undefined) {
|
11354 | this.popupDiv.html.parentNode.removeChild(this.popupDiv.html);
|
11355 | clearTimeout(this.popupDiv.hideTimeout);
|
11356 | clearTimeout(this.popupDiv.deleteTimeout);
|
11357 | this.popupDiv = {};
|
11358 | }
|
11359 | }
|
11360 | |
11361 |
|
11362 |
|
11363 |
|
11364 |
|
11365 |
|
11366 | }, {
|
11367 | key: "_showPopupIfNeeded",
|
11368 | value: function _showPopupIfNeeded() {
|
11369 | var _this6 = this;
|
11370 |
|
11371 | if (this.popupDiv.html !== undefined) {
|
11372 | var correspondingElement = this.domElements[this.popupDiv.index];
|
11373 | var rect = correspondingElement.getBoundingClientRect();
|
11374 | this.popupDiv.html.style.left = rect.left + "px";
|
11375 | this.popupDiv.html.style.top = rect.top - 30 + "px";
|
11376 |
|
11377 | document.body.appendChild(this.popupDiv.html);
|
11378 | this.popupDiv.hideTimeout = _setTimeout(function () {
|
11379 | _this6.popupDiv.html.style.opacity = 0;
|
11380 | }, 1500);
|
11381 | this.popupDiv.deleteTimeout = _setTimeout(function () {
|
11382 | _this6._removePopup();
|
11383 | }, 1800);
|
11384 | }
|
11385 | }
|
11386 | |
11387 |
|
11388 |
|
11389 |
|
11390 |
|
11391 |
|
11392 |
|
11393 |
|
11394 |
|
11395 | }, {
|
11396 | key: "_makeCheckbox",
|
11397 | value: function _makeCheckbox(defaultValue, value, path) {
|
11398 | var checkbox = document.createElement("input");
|
11399 | checkbox.type = "checkbox";
|
11400 | checkbox.className = "vis-configuration vis-config-checkbox";
|
11401 | checkbox.checked = defaultValue;
|
11402 |
|
11403 | if (value !== undefined) {
|
11404 | checkbox.checked = value;
|
11405 |
|
11406 | if (value !== defaultValue) {
|
11407 | if (_typeof(defaultValue) === "object") {
|
11408 | if (value !== defaultValue.enabled) {
|
11409 | this.changedOptions.push({
|
11410 | path: path,
|
11411 | value: value
|
11412 | });
|
11413 | }
|
11414 | } else {
|
11415 | this.changedOptions.push({
|
11416 | path: path,
|
11417 | value: value
|
11418 | });
|
11419 | }
|
11420 | }
|
11421 | }
|
11422 |
|
11423 | var me = this;
|
11424 |
|
11425 | checkbox.onchange = function () {
|
11426 | me._update(this.checked, path);
|
11427 | };
|
11428 |
|
11429 | var label = this._makeLabel(path[path.length - 1], path);
|
11430 |
|
11431 | this._makeItem(path, label, checkbox);
|
11432 | }
|
11433 | |
11434 |
|
11435 |
|
11436 |
|
11437 |
|
11438 |
|
11439 |
|
11440 |
|
11441 |
|
11442 | }, {
|
11443 | key: "_makeTextInput",
|
11444 | value: function _makeTextInput(defaultValue, value, path) {
|
11445 | var checkbox = document.createElement("input");
|
11446 | checkbox.type = "text";
|
11447 | checkbox.className = "vis-configuration vis-config-text";
|
11448 | checkbox.value = value;
|
11449 |
|
11450 | if (value !== defaultValue) {
|
11451 | this.changedOptions.push({
|
11452 | path: path,
|
11453 | value: value
|
11454 | });
|
11455 | }
|
11456 |
|
11457 | var me = this;
|
11458 |
|
11459 | checkbox.onchange = function () {
|
11460 | me._update(this.value, path);
|
11461 | };
|
11462 |
|
11463 | var label = this._makeLabel(path[path.length - 1], path);
|
11464 |
|
11465 | this._makeItem(path, label, checkbox);
|
11466 | }
|
11467 | |
11468 |
|
11469 |
|
11470 |
|
11471 |
|
11472 |
|
11473 |
|
11474 |
|
11475 |
|
11476 | }, {
|
11477 | key: "_makeColorField",
|
11478 | value: function _makeColorField(arr, value, path) {
|
11479 | var _this7 = this;
|
11480 |
|
11481 | var defaultColor = arr[1];
|
11482 | var div = document.createElement("div");
|
11483 | value = value === undefined ? defaultColor : value;
|
11484 |
|
11485 | if (value !== "none") {
|
11486 | div.className = "vis-configuration vis-config-colorBlock";
|
11487 | div.style.backgroundColor = value;
|
11488 | } else {
|
11489 | div.className = "vis-configuration vis-config-colorBlock none";
|
11490 | }
|
11491 |
|
11492 | value = value === undefined ? defaultColor : value;
|
11493 |
|
11494 | div.onclick = function () {
|
11495 | _this7._showColorPicker(value, div, path);
|
11496 | };
|
11497 |
|
11498 | var label = this._makeLabel(path[path.length - 1], path);
|
11499 |
|
11500 | this._makeItem(path, label, div);
|
11501 | }
|
11502 | |
11503 |
|
11504 |
|
11505 |
|
11506 |
|
11507 |
|
11508 |
|
11509 |
|
11510 |
|
11511 | }, {
|
11512 | key: "_showColorPicker",
|
11513 | value: function _showColorPicker(value, div, path) {
|
11514 | var _this8 = this;
|
11515 |
|
11516 |
|
11517 | div.onclick = function () {};
|
11518 |
|
11519 | this.colorPicker.insertTo(div);
|
11520 | this.colorPicker.show();
|
11521 | this.colorPicker.setColor(value);
|
11522 | this.colorPicker.setUpdateCallback(function (color) {
|
11523 | var colorString = "rgba(" + color.r + "," + color.g + "," + color.b + "," + color.a + ")";
|
11524 | div.style.backgroundColor = colorString;
|
11525 |
|
11526 | _this8._update(colorString, path);
|
11527 | });
|
11528 |
|
11529 | this.colorPicker.setCloseCallback(function () {
|
11530 | div.onclick = function () {
|
11531 | _this8._showColorPicker(value, div, path);
|
11532 | };
|
11533 | });
|
11534 | }
|
11535 | |
11536 |
|
11537 |
|
11538 |
|
11539 |
|
11540 |
|
11541 |
|
11542 |
|
11543 |
|
11544 |
|
11545 | }, {
|
11546 | key: "_handleObject",
|
11547 | value: function _handleObject(obj) {
|
11548 | var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
11549 | var checkOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
11550 | var show = false;
|
11551 |
|
11552 | var filter = _filterInstanceProperty(this.options);
|
11553 |
|
11554 | var visibleInSet = false;
|
11555 |
|
11556 | for (var subObj in obj) {
|
11557 | if (Object.prototype.hasOwnProperty.call(obj, subObj)) {
|
11558 | show = true;
|
11559 | var item = obj[subObj];
|
11560 | var newPath = copyAndExtendArray(path, subObj);
|
11561 |
|
11562 | if (typeof filter === "function") {
|
11563 | show = filter(subObj, path);
|
11564 |
|
11565 | if (show === false) {
|
11566 | if (!_Array$isArray$1(item) && typeof item !== "string" && typeof item !== "boolean" && item instanceof Object) {
|
11567 | this.allowCreation = false;
|
11568 | show = this._handleObject(item, newPath, true);
|
11569 | this.allowCreation = checkOnly === false;
|
11570 | }
|
11571 | }
|
11572 | }
|
11573 |
|
11574 | if (show !== false) {
|
11575 | visibleInSet = true;
|
11576 |
|
11577 | var value = this._getValue(newPath);
|
11578 |
|
11579 | if (_Array$isArray$1(item)) {
|
11580 | this._handleArray(item, value, newPath);
|
11581 | } else if (typeof item === "string") {
|
11582 | this._makeTextInput(item, value, newPath);
|
11583 | } else if (typeof item === "boolean") {
|
11584 | this._makeCheckbox(item, value, newPath);
|
11585 | } else if (item instanceof Object) {
|
11586 |
|
11587 | if (!this.hideOption(path, subObj, this.moduleOptions)) {
|
11588 |
|
11589 | if (item.enabled !== undefined) {
|
11590 | var enabledPath = copyAndExtendArray(newPath, "enabled");
|
11591 |
|
11592 | var enabledValue = this._getValue(enabledPath);
|
11593 |
|
11594 | if (enabledValue === true) {
|
11595 | var label = this._makeLabel(subObj, newPath, true);
|
11596 |
|
11597 | this._makeItem(newPath, label);
|
11598 |
|
11599 | visibleInSet = this._handleObject(item, newPath) || visibleInSet;
|
11600 | } else {
|
11601 | this._makeCheckbox(item, enabledValue, newPath);
|
11602 | }
|
11603 | } else {
|
11604 | var _label = this._makeLabel(subObj, newPath, true);
|
11605 |
|
11606 | this._makeItem(newPath, _label);
|
11607 |
|
11608 | visibleInSet = this._handleObject(item, newPath) || visibleInSet;
|
11609 | }
|
11610 | }
|
11611 | } else {
|
11612 | console.error("dont know how to handle", item, subObj, newPath);
|
11613 | }
|
11614 | }
|
11615 | }
|
11616 | }
|
11617 |
|
11618 | return visibleInSet;
|
11619 | }
|
11620 | |
11621 |
|
11622 |
|
11623 |
|
11624 |
|
11625 |
|
11626 |
|
11627 |
|
11628 |
|
11629 | }, {
|
11630 | key: "_handleArray",
|
11631 | value: function _handleArray(arr, value, path) {
|
11632 | if (typeof arr[0] === "string" && arr[0] === "color") {
|
11633 | this._makeColorField(arr, value, path);
|
11634 |
|
11635 | if (arr[1] !== value) {
|
11636 | this.changedOptions.push({
|
11637 | path: path,
|
11638 | value: value
|
11639 | });
|
11640 | }
|
11641 | } else if (typeof arr[0] === "string") {
|
11642 | this._makeDropdown(arr, value, path);
|
11643 |
|
11644 | if (arr[0] !== value) {
|
11645 | this.changedOptions.push({
|
11646 | path: path,
|
11647 | value: value
|
11648 | });
|
11649 | }
|
11650 | } else if (typeof arr[0] === "number") {
|
11651 | this._makeRange(arr, value, path);
|
11652 |
|
11653 | if (arr[0] !== value) {
|
11654 | this.changedOptions.push({
|
11655 | path: path,
|
11656 | value: Number(value)
|
11657 | });
|
11658 | }
|
11659 | }
|
11660 | }
|
11661 | |
11662 |
|
11663 |
|
11664 |
|
11665 |
|
11666 |
|
11667 |
|
11668 |
|
11669 | }, {
|
11670 | key: "_update",
|
11671 | value: function _update(value, path) {
|
11672 | var options = this._constructOptions(value, path);
|
11673 |
|
11674 | if (this.parent.body && this.parent.body.emitter && this.parent.body.emitter.emit) {
|
11675 | this.parent.body.emitter.emit("configChange", options);
|
11676 | }
|
11677 |
|
11678 | this.initialized = true;
|
11679 | this.parent.setOptions(options);
|
11680 | }
|
11681 | |
11682 |
|
11683 |
|
11684 |
|
11685 |
|
11686 |
|
11687 |
|
11688 |
|
11689 |
|
11690 | }, {
|
11691 | key: "_constructOptions",
|
11692 | value: function _constructOptions(value, path) {
|
11693 | var optionsObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
11694 | var pointer = optionsObj;
|
11695 |
|
11696 | value = value === "true" ? true : value;
|
11697 | value = value === "false" ? false : value;
|
11698 |
|
11699 | for (var i = 0; i < path.length; i++) {
|
11700 | if (path[i] !== "global") {
|
11701 | if (pointer[path[i]] === undefined) {
|
11702 | pointer[path[i]] = {};
|
11703 | }
|
11704 |
|
11705 | if (i !== path.length - 1) {
|
11706 | pointer = pointer[path[i]];
|
11707 | } else {
|
11708 | pointer[path[i]] = value;
|
11709 | }
|
11710 | }
|
11711 | }
|
11712 |
|
11713 | return optionsObj;
|
11714 | }
|
11715 | |
11716 |
|
11717 |
|
11718 |
|
11719 | }, {
|
11720 | key: "_printOptions",
|
11721 | value: function _printOptions() {
|
11722 | var options = this.getOptions();
|
11723 |
|
11724 | while (this.optionsContainer.firstChild) {
|
11725 | this.optionsContainer.removeChild(this.optionsContainer.firstChild);
|
11726 | }
|
11727 |
|
11728 | this.optionsContainer.appendChild(wrapInTag("pre", "const options = " + _JSON$stringify(options, null, 2)));
|
11729 | }
|
11730 | |
11731 |
|
11732 |
|
11733 |
|
11734 |
|
11735 | }, {
|
11736 | key: "getOptions",
|
11737 | value: function getOptions() {
|
11738 | var options = {};
|
11739 |
|
11740 | for (var i = 0; i < this.changedOptions.length; i++) {
|
11741 | this._constructOptions(this.changedOptions[i].value, this.changedOptions[i].path, options);
|
11742 | }
|
11743 |
|
11744 | return options;
|
11745 | }
|
11746 | }]);
|
11747 |
|
11748 | return Configurator$1;
|
11749 | }();
|
11750 |
|
11751 |
|
11752 |
|
11753 |
|
11754 |
|
11755 | var Popup$1 = function () {
|
11756 | |
11757 |
|
11758 |
|
11759 |
|
11760 | function Popup$1(container, overflowMethod) {
|
11761 | _classCallCheck(this, Popup$1);
|
11762 |
|
11763 | this.container = container;
|
11764 | this.overflowMethod = overflowMethod || "cap";
|
11765 | this.x = 0;
|
11766 | this.y = 0;
|
11767 | this.padding = 5;
|
11768 | this.hidden = false;
|
11769 |
|
11770 | this.frame = document.createElement("div");
|
11771 | this.frame.className = "vis-tooltip";
|
11772 | this.container.appendChild(this.frame);
|
11773 | }
|
11774 | |
11775 |
|
11776 |
|
11777 |
|
11778 |
|
11779 |
|
11780 | _createClass(Popup$1, [{
|
11781 | key: "setPosition",
|
11782 | value: function setPosition(x, y) {
|
11783 | this.x = _parseInt(x);
|
11784 | this.y = _parseInt(y);
|
11785 | }
|
11786 | |
11787 |
|
11788 |
|
11789 |
|
11790 |
|
11791 |
|
11792 | }, {
|
11793 | key: "setText",
|
11794 | value: function setText(content) {
|
11795 | if (content instanceof Element) {
|
11796 | while (this.frame.firstChild) {
|
11797 | this.frame.removeChild(this.frame.firstChild);
|
11798 | }
|
11799 |
|
11800 | this.frame.appendChild(content);
|
11801 | } else {
|
11802 |
|
11803 |
|
11804 | this.frame.innerText = content;
|
11805 | }
|
11806 | }
|
11807 | |
11808 |
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 | }, {
|
11814 | key: "show",
|
11815 | value: function show(doShow) {
|
11816 | if (doShow === undefined) {
|
11817 | doShow = true;
|
11818 | }
|
11819 |
|
11820 | if (doShow === true) {
|
11821 | var height = this.frame.clientHeight;
|
11822 | var width = this.frame.clientWidth;
|
11823 | var maxHeight = this.frame.parentNode.clientHeight;
|
11824 | var maxWidth = this.frame.parentNode.clientWidth;
|
11825 | var left = 0,
|
11826 | top = 0;
|
11827 |
|
11828 | if (this.overflowMethod == "flip") {
|
11829 | var isLeft = false,
|
11830 | isTop = true;
|
11831 |
|
11832 | if (this.y - height < this.padding) {
|
11833 | isTop = false;
|
11834 | }
|
11835 |
|
11836 | if (this.x + width > maxWidth - this.padding) {
|
11837 | isLeft = true;
|
11838 | }
|
11839 |
|
11840 | if (isLeft) {
|
11841 | left = this.x - width;
|
11842 | } else {
|
11843 | left = this.x;
|
11844 | }
|
11845 |
|
11846 | if (isTop) {
|
11847 | top = this.y - height;
|
11848 | } else {
|
11849 | top = this.y;
|
11850 | }
|
11851 | } else {
|
11852 | top = this.y - height;
|
11853 |
|
11854 | if (top + height + this.padding > maxHeight) {
|
11855 | top = maxHeight - height - this.padding;
|
11856 | }
|
11857 |
|
11858 | if (top < this.padding) {
|
11859 | top = this.padding;
|
11860 | }
|
11861 |
|
11862 | left = this.x;
|
11863 |
|
11864 | if (left + width + this.padding > maxWidth) {
|
11865 | left = maxWidth - width - this.padding;
|
11866 | }
|
11867 |
|
11868 | if (left < this.padding) {
|
11869 | left = this.padding;
|
11870 | }
|
11871 | }
|
11872 |
|
11873 | this.frame.style.left = left + "px";
|
11874 | this.frame.style.top = top + "px";
|
11875 | this.frame.style.visibility = "visible";
|
11876 | this.hidden = false;
|
11877 | } else {
|
11878 | this.hide();
|
11879 | }
|
11880 | }
|
11881 | |
11882 |
|
11883 |
|
11884 |
|
11885 | }, {
|
11886 | key: "hide",
|
11887 | value: function hide() {
|
11888 | this.hidden = true;
|
11889 | this.frame.style.left = "0";
|
11890 | this.frame.style.top = "0";
|
11891 | this.frame.style.visibility = "hidden";
|
11892 | }
|
11893 | |
11894 |
|
11895 |
|
11896 |
|
11897 | }, {
|
11898 | key: "destroy",
|
11899 | value: function destroy() {
|
11900 | this.frame.parentNode.removeChild(this.frame);
|
11901 | }
|
11902 | }]);
|
11903 |
|
11904 | return Popup$1;
|
11905 | }();
|
11906 |
|
11907 | var errorFound$1 = false;
|
11908 | var allOptions$3;
|
11909 | var VALIDATOR_PRINT_STYLE$1 = "background: #FFeeee; color: #dd0000";
|
11910 |
|
11911 |
|
11912 |
|
11913 |
|
11914 | var Validator$1 = function () {
|
11915 | function Validator$1() {
|
11916 | _classCallCheck(this, Validator$1);
|
11917 | }
|
11918 |
|
11919 | _createClass(Validator$1, null, [{
|
11920 | key: "validate",
|
11921 | value:
|
11922 | |
11923 |
|
11924 |
|
11925 |
|
11926 |
|
11927 |
|
11928 |
|
11929 |
|
11930 |
|
11931 | function validate(options, referenceOptions, subObject) {
|
11932 | errorFound$1 = false;
|
11933 | allOptions$3 = referenceOptions;
|
11934 | var usedOptions = referenceOptions;
|
11935 |
|
11936 | if (subObject !== undefined) {
|
11937 | usedOptions = referenceOptions[subObject];
|
11938 | }
|
11939 |
|
11940 | Validator$1.parse(options, usedOptions, []);
|
11941 | return errorFound$1;
|
11942 | }
|
11943 | |
11944 |
|
11945 |
|
11946 |
|
11947 |
|
11948 |
|
11949 |
|
11950 |
|
11951 |
|
11952 | }, {
|
11953 | key: "parse",
|
11954 | value: function parse(options, referenceOptions, path) {
|
11955 | for (var _option3 in options) {
|
11956 | if (Object.prototype.hasOwnProperty.call(options, _option3)) {
|
11957 | Validator$1.check(_option3, options, referenceOptions, path);
|
11958 | }
|
11959 | }
|
11960 | }
|
11961 | |
11962 |
|
11963 |
|
11964 |
|
11965 |
|
11966 |
|
11967 |
|
11968 |
|
11969 |
|
11970 |
|
11971 | }, {
|
11972 | key: "check",
|
11973 | value: function check(option, options, referenceOptions, path) {
|
11974 | if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
|
11975 | Validator$1.getSuggestion(option, referenceOptions, path);
|
11976 | return;
|
11977 | }
|
11978 |
|
11979 | var referenceOption = option;
|
11980 | var is_object = true;
|
11981 |
|
11982 | if (referenceOptions[option] === undefined && referenceOptions.__any__ !== undefined) {
|
11983 |
|
11984 |
|
11985 |
|
11986 |
|
11987 | referenceOption = "__any__";
|
11988 |
|
11989 |
|
11990 | is_object = Validator$1.getType(options[option]) === "object";
|
11991 | }
|
11992 |
|
11993 | var refOptionObj = referenceOptions[referenceOption];
|
11994 |
|
11995 | if (is_object && refOptionObj.__type__ !== undefined) {
|
11996 | refOptionObj = refOptionObj.__type__;
|
11997 | }
|
11998 |
|
11999 | Validator$1.checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path);
|
12000 | }
|
12001 | |
12002 |
|
12003 |
|
12004 |
|
12005 |
|
12006 |
|
12007 |
|
12008 |
|
12009 |
|
12010 |
|
12011 |
|
12012 | }, {
|
12013 | key: "checkFields",
|
12014 | value: function checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) {
|
12015 | var log = function log(message) {
|
12016 | console.error("%c" + message + Validator$1.printLocation(path, option), VALIDATOR_PRINT_STYLE$1);
|
12017 | };
|
12018 |
|
12019 | var optionType = Validator$1.getType(options[option]);
|
12020 | var refOptionType = refOptionObj[optionType];
|
12021 |
|
12022 | if (refOptionType !== undefined) {
|
12023 |
|
12024 | if (Validator$1.getType(refOptionType) === "array" && _indexOfInstanceProperty(refOptionType).call(refOptionType, options[option]) === -1) {
|
12025 | log('Invalid option detected in "' + option + '".' + " Allowed values are:" + Validator$1.print(refOptionType) + ' not "' + options[option] + '". ');
|
12026 | errorFound$1 = true;
|
12027 | } else if (optionType === "object" && referenceOption !== "__any__") {
|
12028 | path = copyAndExtendArray(path, option);
|
12029 | Validator$1.parse(options[option], referenceOptions[referenceOption], path);
|
12030 | }
|
12031 | } else if (refOptionObj["any"] === undefined) {
|
12032 |
|
12033 | log('Invalid type received for "' + option + '". Expected: ' + Validator$1.print(_Object$keys(refOptionObj)) + ". Received [" + optionType + '] "' + options[option] + '"');
|
12034 | errorFound$1 = true;
|
12035 | }
|
12036 | }
|
12037 | |
12038 |
|
12039 |
|
12040 |
|
12041 |
|
12042 |
|
12043 |
|
12044 | }, {
|
12045 | key: "getType",
|
12046 | value: function getType(object) {
|
12047 | var type = _typeof(object);
|
12048 |
|
12049 | if (type === "object") {
|
12050 | if (object === null) {
|
12051 | return "null";
|
12052 | }
|
12053 |
|
12054 | if (object instanceof Boolean) {
|
12055 | return "boolean";
|
12056 | }
|
12057 |
|
12058 | if (object instanceof Number) {
|
12059 | return "number";
|
12060 | }
|
12061 |
|
12062 | if (object instanceof String) {
|
12063 | return "string";
|
12064 | }
|
12065 |
|
12066 | if (_Array$isArray$1(object)) {
|
12067 | return "array";
|
12068 | }
|
12069 |
|
12070 | if (object instanceof Date) {
|
12071 | return "date";
|
12072 | }
|
12073 |
|
12074 | if (object.nodeType !== undefined) {
|
12075 | return "dom";
|
12076 | }
|
12077 |
|
12078 | if (object._isAMomentObject === true) {
|
12079 | return "moment";
|
12080 | }
|
12081 |
|
12082 | return "object";
|
12083 | } else if (type === "number") {
|
12084 | return "number";
|
12085 | } else if (type === "boolean") {
|
12086 | return "boolean";
|
12087 | } else if (type === "string") {
|
12088 | return "string";
|
12089 | } else if (type === undefined) {
|
12090 | return "undefined";
|
12091 | }
|
12092 |
|
12093 | return type;
|
12094 | }
|
12095 | |
12096 |
|
12097 |
|
12098 |
|
12099 |
|
12100 |
|
12101 |
|
12102 | }, {
|
12103 | key: "getSuggestion",
|
12104 | value: function getSuggestion(option, options, path) {
|
12105 | var localSearch = Validator$1.findInOptions(option, options, path, false);
|
12106 | var globalSearch = Validator$1.findInOptions(option, allOptions$3, [], true);
|
12107 | var localSearchThreshold = 8;
|
12108 | var globalSearchThreshold = 4;
|
12109 | var msg;
|
12110 |
|
12111 | if (localSearch.indexMatch !== undefined) {
|
12112 | msg = " in " + Validator$1.printLocation(localSearch.path, option, "") + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n';
|
12113 | } else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) {
|
12114 | msg = " in " + Validator$1.printLocation(localSearch.path, option, "") + "Perhaps it was misplaced? Matching option found at: " + Validator$1.printLocation(globalSearch.path, globalSearch.closestMatch, "");
|
12115 | } else if (localSearch.distance <= localSearchThreshold) {
|
12116 | msg = '. Did you mean "' + localSearch.closestMatch + '"?' + Validator$1.printLocation(localSearch.path, option);
|
12117 | } else {
|
12118 | msg = ". Did you mean one of these: " + Validator$1.print(_Object$keys(options)) + Validator$1.printLocation(path, option);
|
12119 | }
|
12120 |
|
12121 | console.error('%cUnknown option detected: "' + option + '"' + msg, VALIDATOR_PRINT_STYLE$1);
|
12122 | errorFound$1 = true;
|
12123 | }
|
12124 | |
12125 |
|
12126 |
|
12127 |
|
12128 |
|
12129 |
|
12130 |
|
12131 |
|
12132 |
|
12133 |
|
12134 |
|
12135 | }, {
|
12136 | key: "findInOptions",
|
12137 | value: function findInOptions(option, options, path) {
|
12138 | var recursive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
12139 | var min = 1e9;
|
12140 | var closestMatch = "";
|
12141 | var closestMatchPath = [];
|
12142 | var lowerCaseOption = option.toLowerCase();
|
12143 | var indexMatch = undefined;
|
12144 |
|
12145 | for (var op in options) {
|
12146 | var distance = void 0;
|
12147 |
|
12148 | if (options[op].__type__ !== undefined && recursive === true) {
|
12149 | var result = Validator$1.findInOptions(option, options[op], copyAndExtendArray(path, op));
|
12150 |
|
12151 | if (min > result.distance) {
|
12152 | closestMatch = result.closestMatch;
|
12153 | closestMatchPath = result.path;
|
12154 | min = result.distance;
|
12155 | indexMatch = result.indexMatch;
|
12156 | }
|
12157 | } else {
|
12158 | var _context20;
|
12159 |
|
12160 | if (_indexOfInstanceProperty(_context20 = op.toLowerCase()).call(_context20, lowerCaseOption) !== -1) {
|
12161 | indexMatch = op;
|
12162 | }
|
12163 |
|
12164 | distance = Validator$1.levenshteinDistance(option, op);
|
12165 |
|
12166 | if (min > distance) {
|
12167 | closestMatch = op;
|
12168 | closestMatchPath = copyArray(path);
|
12169 | min = distance;
|
12170 | }
|
12171 | }
|
12172 | }
|
12173 |
|
12174 | return {
|
12175 | closestMatch: closestMatch,
|
12176 | path: closestMatchPath,
|
12177 | distance: min,
|
12178 | indexMatch: indexMatch
|
12179 | };
|
12180 | }
|
12181 | |
12182 |
|
12183 |
|
12184 |
|
12185 |
|
12186 |
|
12187 |
|
12188 |
|
12189 | }, {
|
12190 | key: "printLocation",
|
12191 | value: function printLocation(path, option) {
|
12192 | var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Problem value found at: \n";
|
12193 | var str = "\n\n" + prefix + "options = {\n";
|
12194 |
|
12195 | for (var i = 0; i < path.length; i++) {
|
12196 | for (var j = 0; j < i + 1; j++) {
|
12197 | str += " ";
|
12198 | }
|
12199 |
|
12200 | str += path[i] + ": {\n";
|
12201 | }
|
12202 |
|
12203 | for (var _j = 0; _j < path.length + 1; _j++) {
|
12204 | str += " ";
|
12205 | }
|
12206 |
|
12207 | str += option + "\n";
|
12208 |
|
12209 | for (var _i3 = 0; _i3 < path.length + 1; _i3++) {
|
12210 | for (var _j2 = 0; _j2 < path.length - _i3; _j2++) {
|
12211 | str += " ";
|
12212 | }
|
12213 |
|
12214 | str += "}\n";
|
12215 | }
|
12216 |
|
12217 | return str + "\n\n";
|
12218 | }
|
12219 | |
12220 |
|
12221 |
|
12222 |
|
12223 |
|
12224 |
|
12225 | }, {
|
12226 | key: "print",
|
12227 | value: function print(options) {
|
12228 | return _JSON$stringify(options).replace(/(")|(\[)|(\])|(,"__type__")/g, "").replace(/(,)/g, ", ");
|
12229 | }
|
12230 | |
12231 |
|
12232 |
|
12233 |
|
12234 |
|
12235 |
|
12236 |
|
12237 |
|
12238 |
|
12239 |
|
12240 |
|
12241 |
|
12242 |
|
12243 |
|
12244 |
|
12245 |
|
12246 |
|
12247 |
|
12248 | }, {
|
12249 | key: "levenshteinDistance",
|
12250 | value: function levenshteinDistance(a, b) {
|
12251 | if (a.length === 0) return b.length;
|
12252 | if (b.length === 0) return a.length;
|
12253 | var matrix = [];
|
12254 |
|
12255 | var i;
|
12256 |
|
12257 | for (i = 0; i <= b.length; i++) {
|
12258 | matrix[i] = [i];
|
12259 | }
|
12260 |
|
12261 |
|
12262 | var j;
|
12263 |
|
12264 | for (j = 0; j <= a.length; j++) {
|
12265 | matrix[0][j] = j;
|
12266 | }
|
12267 |
|
12268 |
|
12269 | for (i = 1; i <= b.length; i++) {
|
12270 | for (j = 1; j <= a.length; j++) {
|
12271 | if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
12272 | matrix[i][j] = matrix[i - 1][j - 1];
|
12273 | } else {
|
12274 | matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1,
|
12275 | Math.min(matrix[i][j - 1] + 1,
|
12276 | matrix[i - 1][j] + 1));
|
12277 | }
|
12278 | }
|
12279 | }
|
12280 |
|
12281 | return matrix[b.length][a.length];
|
12282 | }
|
12283 | }]);
|
12284 |
|
12285 | return Validator$1;
|
12286 | }();
|
12287 |
|
12288 | var Activator$2 = Activator$1;
|
12289 | var ColorPicker$2 = ColorPicker$1;
|
12290 | var Configurator$2 = Configurator$1;
|
12291 | var Hammer$2 = Hammer$1;
|
12292 | var Popup$2 = Popup$1;
|
12293 | var VALIDATOR_PRINT_STYLE = VALIDATOR_PRINT_STYLE$1;
|
12294 | var Validator$2 = Validator$1;
|
12295 |
|
12296 | var util$2 = Object.freeze({
|
12297 | __proto__: null,
|
12298 | Activator: Activator$2,
|
12299 | Alea: Alea,
|
12300 | ColorPicker: ColorPicker$2,
|
12301 | Configurator: Configurator$2,
|
12302 | DELETE: DELETE,
|
12303 | HSVToHex: HSVToHex,
|
12304 | HSVToRGB: HSVToRGB,
|
12305 | Hammer: Hammer$2,
|
12306 | Popup: Popup$2,
|
12307 | RGBToHSV: RGBToHSV,
|
12308 | RGBToHex: RGBToHex,
|
12309 | VALIDATOR_PRINT_STYLE: VALIDATOR_PRINT_STYLE,
|
12310 | Validator: Validator$2,
|
12311 | addClassName: addClassName,
|
12312 | addCssText: addCssText,
|
12313 | addEventListener: addEventListener,
|
12314 | binarySearchCustom: binarySearchCustom,
|
12315 | binarySearchValue: binarySearchValue,
|
12316 | bridgeObject: bridgeObject,
|
12317 | copyAndExtendArray: copyAndExtendArray,
|
12318 | copyArray: copyArray,
|
12319 | deepExtend: deepExtend,
|
12320 | deepObjectAssign: deepObjectAssign,
|
12321 | easingFunctions: easingFunctions,
|
12322 | equalArray: equalArray,
|
12323 | extend: extend,
|
12324 | fillIfDefined: fillIfDefined,
|
12325 | forEach: forEach$1,
|
12326 | getAbsoluteLeft: getAbsoluteLeft,
|
12327 | getAbsoluteRight: getAbsoluteRight,
|
12328 | getAbsoluteTop: getAbsoluteTop,
|
12329 | getScrollBarWidth: getScrollBarWidth,
|
12330 | getTarget: getTarget,
|
12331 | getType: getType,
|
12332 | hasParent: hasParent,
|
12333 | hexToHSV: hexToHSV,
|
12334 | hexToRGB: hexToRGB,
|
12335 | insertSort: insertSort,
|
12336 | isDate: isDate,
|
12337 | isNumber: isNumber,
|
12338 | isObject: isObject$3,
|
12339 | isString: isString,
|
12340 | isValidHex: isValidHex,
|
12341 | isValidRGB: isValidRGB,
|
12342 | isValidRGBA: isValidRGBA,
|
12343 | mergeOptions: mergeOptions,
|
12344 | option: option,
|
12345 | overrideOpacity: overrideOpacity,
|
12346 | parseColor: parseColor,
|
12347 | preventDefault: preventDefault,
|
12348 | pureDeepObjectAssign: pureDeepObjectAssign,
|
12349 | recursiveDOMDelete: recursiveDOMDelete,
|
12350 | removeClassName: removeClassName,
|
12351 | removeCssText: removeCssText,
|
12352 | removeEventListener: removeEventListener,
|
12353 | selectiveBridgeObject: selectiveBridgeObject,
|
12354 | selectiveDeepExtend: selectiveDeepExtend,
|
12355 | selectiveExtend: selectiveExtend,
|
12356 | selectiveNotDeepExtend: selectiveNotDeepExtend,
|
12357 | throttle: throttle,
|
12358 | toArray: toArray,
|
12359 | topMost: topMost,
|
12360 | updateProperty: updateProperty
|
12361 | });
|
12362 |
|
12363 | var lib$1 = {exports: {}};
|
12364 |
|
12365 | var _default$1 = {};
|
12366 |
|
12367 | var lib = {exports: {}};
|
12368 |
|
12369 | var _default = {};
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 | function getDefaultWhiteList$1() {
|
12378 |
|
12379 |
|
12380 |
|
12381 |
|
12382 |
|
12383 | var whiteList = {};
|
12384 | whiteList['align-content'] = false;
|
12385 |
|
12386 | whiteList['align-items'] = false;
|
12387 |
|
12388 | whiteList['align-self'] = false;
|
12389 |
|
12390 | whiteList['alignment-adjust'] = false;
|
12391 |
|
12392 | whiteList['alignment-baseline'] = false;
|
12393 |
|
12394 | whiteList['all'] = false;
|
12395 |
|
12396 | whiteList['anchor-point'] = false;
|
12397 |
|
12398 | whiteList['animation'] = false;
|
12399 |
|
12400 | whiteList['animation-delay'] = false;
|
12401 |
|
12402 | whiteList['animation-direction'] = false;
|
12403 |
|
12404 | whiteList['animation-duration'] = false;
|
12405 |
|
12406 | whiteList['animation-fill-mode'] = false;
|
12407 |
|
12408 | whiteList['animation-iteration-count'] = false;
|
12409 |
|
12410 | whiteList['animation-name'] = false;
|
12411 |
|
12412 | whiteList['animation-play-state'] = false;
|
12413 |
|
12414 | whiteList['animation-timing-function'] = false;
|
12415 |
|
12416 | whiteList['azimuth'] = false;
|
12417 |
|
12418 | whiteList['backface-visibility'] = false;
|
12419 |
|
12420 | whiteList['background'] = true;
|
12421 |
|
12422 | whiteList['background-attachment'] = true;
|
12423 |
|
12424 | whiteList['background-clip'] = true;
|
12425 |
|
12426 | whiteList['background-color'] = true;
|
12427 |
|
12428 | whiteList['background-image'] = true;
|
12429 |
|
12430 | whiteList['background-origin'] = true;
|
12431 |
|
12432 | whiteList['background-position'] = true;
|
12433 |
|
12434 | whiteList['background-repeat'] = true;
|
12435 |
|
12436 | whiteList['background-size'] = true;
|
12437 |
|
12438 | whiteList['baseline-shift'] = false;
|
12439 |
|
12440 | whiteList['binding'] = false;
|
12441 |
|
12442 | whiteList['bleed'] = false;
|
12443 |
|
12444 | whiteList['bookmark-label'] = false;
|
12445 |
|
12446 | whiteList['bookmark-level'] = false;
|
12447 |
|
12448 | whiteList['bookmark-state'] = false;
|
12449 |
|
12450 | whiteList['border'] = true;
|
12451 |
|
12452 | whiteList['border-bottom'] = true;
|
12453 |
|
12454 | whiteList['border-bottom-color'] = true;
|
12455 |
|
12456 | whiteList['border-bottom-left-radius'] = true;
|
12457 |
|
12458 | whiteList['border-bottom-right-radius'] = true;
|
12459 |
|
12460 | whiteList['border-bottom-style'] = true;
|
12461 |
|
12462 | whiteList['border-bottom-width'] = true;
|
12463 |
|
12464 | whiteList['border-collapse'] = true;
|
12465 |
|
12466 | whiteList['border-color'] = true;
|
12467 |
|
12468 | whiteList['border-image'] = true;
|
12469 |
|
12470 | whiteList['border-image-outset'] = true;
|
12471 |
|
12472 | whiteList['border-image-repeat'] = true;
|
12473 |
|
12474 | whiteList['border-image-slice'] = true;
|
12475 |
|
12476 | whiteList['border-image-source'] = true;
|
12477 |
|
12478 | whiteList['border-image-width'] = true;
|
12479 |
|
12480 | whiteList['border-left'] = true;
|
12481 |
|
12482 | whiteList['border-left-color'] = true;
|
12483 |
|
12484 | whiteList['border-left-style'] = true;
|
12485 |
|
12486 | whiteList['border-left-width'] = true;
|
12487 |
|
12488 | whiteList['border-radius'] = true;
|
12489 |
|
12490 | whiteList['border-right'] = true;
|
12491 |
|
12492 | whiteList['border-right-color'] = true;
|
12493 |
|
12494 | whiteList['border-right-style'] = true;
|
12495 |
|
12496 | whiteList['border-right-width'] = true;
|
12497 |
|
12498 | whiteList['border-spacing'] = true;
|
12499 |
|
12500 | whiteList['border-style'] = true;
|
12501 |
|
12502 | whiteList['border-top'] = true;
|
12503 |
|
12504 | whiteList['border-top-color'] = true;
|
12505 |
|
12506 | whiteList['border-top-left-radius'] = true;
|
12507 |
|
12508 | whiteList['border-top-right-radius'] = true;
|
12509 |
|
12510 | whiteList['border-top-style'] = true;
|
12511 |
|
12512 | whiteList['border-top-width'] = true;
|
12513 |
|
12514 | whiteList['border-width'] = true;
|
12515 |
|
12516 | whiteList['bottom'] = false;
|
12517 |
|
12518 | whiteList['box-decoration-break'] = true;
|
12519 |
|
12520 | whiteList['box-shadow'] = true;
|
12521 |
|
12522 | whiteList['box-sizing'] = true;
|
12523 |
|
12524 | whiteList['box-snap'] = true;
|
12525 |
|
12526 | whiteList['box-suppress'] = true;
|
12527 |
|
12528 | whiteList['break-after'] = true;
|
12529 |
|
12530 | whiteList['break-before'] = true;
|
12531 |
|
12532 | whiteList['break-inside'] = true;
|
12533 |
|
12534 | whiteList['caption-side'] = false;
|
12535 |
|
12536 | whiteList['chains'] = false;
|
12537 |
|
12538 | whiteList['clear'] = true;
|
12539 |
|
12540 | whiteList['clip'] = false;
|
12541 |
|
12542 | whiteList['clip-path'] = false;
|
12543 |
|
12544 | whiteList['clip-rule'] = false;
|
12545 |
|
12546 | whiteList['color'] = true;
|
12547 |
|
12548 | whiteList['color-interpolation-filters'] = true;
|
12549 |
|
12550 | whiteList['column-count'] = false;
|
12551 |
|
12552 | whiteList['column-fill'] = false;
|
12553 |
|
12554 | whiteList['column-gap'] = false;
|
12555 |
|
12556 | whiteList['column-rule'] = false;
|
12557 |
|
12558 | whiteList['column-rule-color'] = false;
|
12559 |
|
12560 | whiteList['column-rule-style'] = false;
|
12561 |
|
12562 | whiteList['column-rule-width'] = false;
|
12563 |
|
12564 | whiteList['column-span'] = false;
|
12565 |
|
12566 | whiteList['column-width'] = false;
|
12567 |
|
12568 | whiteList['columns'] = false;
|
12569 |
|
12570 | whiteList['contain'] = false;
|
12571 |
|
12572 | whiteList['content'] = false;
|
12573 |
|
12574 | whiteList['counter-increment'] = false;
|
12575 |
|
12576 | whiteList['counter-reset'] = false;
|
12577 |
|
12578 | whiteList['counter-set'] = false;
|
12579 |
|
12580 | whiteList['crop'] = false;
|
12581 |
|
12582 | whiteList['cue'] = false;
|
12583 |
|
12584 | whiteList['cue-after'] = false;
|
12585 |
|
12586 | whiteList['cue-before'] = false;
|
12587 |
|
12588 | whiteList['cursor'] = false;
|
12589 |
|
12590 | whiteList['direction'] = false;
|
12591 |
|
12592 | whiteList['display'] = true;
|
12593 |
|
12594 | whiteList['display-inside'] = true;
|
12595 |
|
12596 | whiteList['display-list'] = true;
|
12597 |
|
12598 | whiteList['display-outside'] = true;
|
12599 |
|
12600 | whiteList['dominant-baseline'] = false;
|
12601 |
|
12602 | whiteList['elevation'] = false;
|
12603 |
|
12604 | whiteList['empty-cells'] = false;
|
12605 |
|
12606 | whiteList['filter'] = false;
|
12607 |
|
12608 | whiteList['flex'] = false;
|
12609 |
|
12610 | whiteList['flex-basis'] = false;
|
12611 |
|
12612 | whiteList['flex-direction'] = false;
|
12613 |
|
12614 | whiteList['flex-flow'] = false;
|
12615 |
|
12616 | whiteList['flex-grow'] = false;
|
12617 |
|
12618 | whiteList['flex-shrink'] = false;
|
12619 |
|
12620 | whiteList['flex-wrap'] = false;
|
12621 |
|
12622 | whiteList['float'] = false;
|
12623 |
|
12624 | whiteList['float-offset'] = false;
|
12625 |
|
12626 | whiteList['flood-color'] = false;
|
12627 |
|
12628 | whiteList['flood-opacity'] = false;
|
12629 |
|
12630 | whiteList['flow-from'] = false;
|
12631 |
|
12632 | whiteList['flow-into'] = false;
|
12633 |
|
12634 | whiteList['font'] = true;
|
12635 |
|
12636 | whiteList['font-family'] = true;
|
12637 |
|
12638 | whiteList['font-feature-settings'] = true;
|
12639 |
|
12640 | whiteList['font-kerning'] = true;
|
12641 |
|
12642 | whiteList['font-language-override'] = true;
|
12643 |
|
12644 | whiteList['font-size'] = true;
|
12645 |
|
12646 | whiteList['font-size-adjust'] = true;
|
12647 |
|
12648 | whiteList['font-stretch'] = true;
|
12649 |
|
12650 | whiteList['font-style'] = true;
|
12651 |
|
12652 | whiteList['font-synthesis'] = true;
|
12653 |
|
12654 | whiteList['font-variant'] = true;
|
12655 |
|
12656 | whiteList['font-variant-alternates'] = true;
|
12657 |
|
12658 | whiteList['font-variant-caps'] = true;
|
12659 |
|
12660 | whiteList['font-variant-east-asian'] = true;
|
12661 |
|
12662 | whiteList['font-variant-ligatures'] = true;
|
12663 |
|
12664 | whiteList['font-variant-numeric'] = true;
|
12665 |
|
12666 | whiteList['font-variant-position'] = true;
|
12667 |
|
12668 | whiteList['font-weight'] = true;
|
12669 |
|
12670 | whiteList['grid'] = false;
|
12671 |
|
12672 | whiteList['grid-area'] = false;
|
12673 |
|
12674 | whiteList['grid-auto-columns'] = false;
|
12675 |
|
12676 | whiteList['grid-auto-flow'] = false;
|
12677 |
|
12678 | whiteList['grid-auto-rows'] = false;
|
12679 |
|
12680 | whiteList['grid-column'] = false;
|
12681 |
|
12682 | whiteList['grid-column-end'] = false;
|
12683 |
|
12684 | whiteList['grid-column-start'] = false;
|
12685 |
|
12686 | whiteList['grid-row'] = false;
|
12687 |
|
12688 | whiteList['grid-row-end'] = false;
|
12689 |
|
12690 | whiteList['grid-row-start'] = false;
|
12691 |
|
12692 | whiteList['grid-template'] = false;
|
12693 |
|
12694 | whiteList['grid-template-areas'] = false;
|
12695 |
|
12696 | whiteList['grid-template-columns'] = false;
|
12697 |
|
12698 | whiteList['grid-template-rows'] = false;
|
12699 |
|
12700 | whiteList['hanging-punctuation'] = false;
|
12701 |
|
12702 | whiteList['height'] = true;
|
12703 |
|
12704 | whiteList['hyphens'] = false;
|
12705 |
|
12706 | whiteList['icon'] = false;
|
12707 |
|
12708 | whiteList['image-orientation'] = false;
|
12709 |
|
12710 | whiteList['image-resolution'] = false;
|
12711 |
|
12712 | whiteList['ime-mode'] = false;
|
12713 |
|
12714 | whiteList['initial-letters'] = false;
|
12715 |
|
12716 | whiteList['inline-box-align'] = false;
|
12717 |
|
12718 | whiteList['justify-content'] = false;
|
12719 |
|
12720 | whiteList['justify-items'] = false;
|
12721 |
|
12722 | whiteList['justify-self'] = false;
|
12723 |
|
12724 | whiteList['left'] = false;
|
12725 |
|
12726 | whiteList['letter-spacing'] = true;
|
12727 |
|
12728 | whiteList['lighting-color'] = true;
|
12729 |
|
12730 | whiteList['line-box-contain'] = false;
|
12731 |
|
12732 | whiteList['line-break'] = false;
|
12733 |
|
12734 | whiteList['line-grid'] = false;
|
12735 |
|
12736 | whiteList['line-height'] = false;
|
12737 |
|
12738 | whiteList['line-snap'] = false;
|
12739 |
|
12740 | whiteList['line-stacking'] = false;
|
12741 |
|
12742 | whiteList['line-stacking-ruby'] = false;
|
12743 |
|
12744 | whiteList['line-stacking-shift'] = false;
|
12745 |
|
12746 | whiteList['line-stacking-strategy'] = false;
|
12747 |
|
12748 | whiteList['list-style'] = true;
|
12749 |
|
12750 | whiteList['list-style-image'] = true;
|
12751 |
|
12752 | whiteList['list-style-position'] = true;
|
12753 |
|
12754 | whiteList['list-style-type'] = true;
|
12755 |
|
12756 | whiteList['margin'] = true;
|
12757 |
|
12758 | whiteList['margin-bottom'] = true;
|
12759 |
|
12760 | whiteList['margin-left'] = true;
|
12761 |
|
12762 | whiteList['margin-right'] = true;
|
12763 |
|
12764 | whiteList['margin-top'] = true;
|
12765 |
|
12766 | whiteList['marker-offset'] = false;
|
12767 |
|
12768 | whiteList['marker-side'] = false;
|
12769 |
|
12770 | whiteList['marks'] = false;
|
12771 |
|
12772 | whiteList['mask'] = false;
|
12773 |
|
12774 | whiteList['mask-box'] = false;
|
12775 |
|
12776 | whiteList['mask-box-outset'] = false;
|
12777 |
|
12778 | whiteList['mask-box-repeat'] = false;
|
12779 |
|
12780 | whiteList['mask-box-slice'] = false;
|
12781 |
|
12782 | whiteList['mask-box-source'] = false;
|
12783 |
|
12784 | whiteList['mask-box-width'] = false;
|
12785 |
|
12786 | whiteList['mask-clip'] = false;
|
12787 |
|
12788 | whiteList['mask-image'] = false;
|
12789 |
|
12790 | whiteList['mask-origin'] = false;
|
12791 |
|
12792 | whiteList['mask-position'] = false;
|
12793 |
|
12794 | whiteList['mask-repeat'] = false;
|
12795 |
|
12796 | whiteList['mask-size'] = false;
|
12797 |
|
12798 | whiteList['mask-source-type'] = false;
|
12799 |
|
12800 | whiteList['mask-type'] = false;
|
12801 |
|
12802 | whiteList['max-height'] = true;
|
12803 |
|
12804 | whiteList['max-lines'] = false;
|
12805 |
|
12806 | whiteList['max-width'] = true;
|
12807 |
|
12808 | whiteList['min-height'] = true;
|
12809 |
|
12810 | whiteList['min-width'] = true;
|
12811 |
|
12812 | whiteList['move-to'] = false;
|
12813 |
|
12814 | whiteList['nav-down'] = false;
|
12815 |
|
12816 | whiteList['nav-index'] = false;
|
12817 |
|
12818 | whiteList['nav-left'] = false;
|
12819 |
|
12820 | whiteList['nav-right'] = false;
|
12821 |
|
12822 | whiteList['nav-up'] = false;
|
12823 |
|
12824 | whiteList['object-fit'] = false;
|
12825 |
|
12826 | whiteList['object-position'] = false;
|
12827 |
|
12828 | whiteList['opacity'] = false;
|
12829 |
|
12830 | whiteList['order'] = false;
|
12831 |
|
12832 | whiteList['orphans'] = false;
|
12833 |
|
12834 | whiteList['outline'] = false;
|
12835 |
|
12836 | whiteList['outline-color'] = false;
|
12837 |
|
12838 | whiteList['outline-offset'] = false;
|
12839 |
|
12840 | whiteList['outline-style'] = false;
|
12841 |
|
12842 | whiteList['outline-width'] = false;
|
12843 |
|
12844 | whiteList['overflow'] = false;
|
12845 |
|
12846 | whiteList['overflow-wrap'] = false;
|
12847 |
|
12848 | whiteList['overflow-x'] = false;
|
12849 |
|
12850 | whiteList['overflow-y'] = false;
|
12851 |
|
12852 | whiteList['padding'] = true;
|
12853 |
|
12854 | whiteList['padding-bottom'] = true;
|
12855 |
|
12856 | whiteList['padding-left'] = true;
|
12857 |
|
12858 | whiteList['padding-right'] = true;
|
12859 |
|
12860 | whiteList['padding-top'] = true;
|
12861 |
|
12862 | whiteList['page'] = false;
|
12863 |
|
12864 | whiteList['page-break-after'] = false;
|
12865 |
|
12866 | whiteList['page-break-before'] = false;
|
12867 |
|
12868 | whiteList['page-break-inside'] = false;
|
12869 |
|
12870 | whiteList['page-policy'] = false;
|
12871 |
|
12872 | whiteList['pause'] = false;
|
12873 |
|
12874 | whiteList['pause-after'] = false;
|
12875 |
|
12876 | whiteList['pause-before'] = false;
|
12877 |
|
12878 | whiteList['perspective'] = false;
|
12879 |
|
12880 | whiteList['perspective-origin'] = false;
|
12881 |
|
12882 | whiteList['pitch'] = false;
|
12883 |
|
12884 | whiteList['pitch-range'] = false;
|
12885 |
|
12886 | whiteList['play-during'] = false;
|
12887 |
|
12888 | whiteList['position'] = false;
|
12889 |
|
12890 | whiteList['presentation-level'] = false;
|
12891 |
|
12892 | whiteList['quotes'] = false;
|
12893 |
|
12894 | whiteList['region-fragment'] = false;
|
12895 |
|
12896 | whiteList['resize'] = false;
|
12897 |
|
12898 | whiteList['rest'] = false;
|
12899 |
|
12900 | whiteList['rest-after'] = false;
|
12901 |
|
12902 | whiteList['rest-before'] = false;
|
12903 |
|
12904 | whiteList['richness'] = false;
|
12905 |
|
12906 | whiteList['right'] = false;
|
12907 |
|
12908 | whiteList['rotation'] = false;
|
12909 |
|
12910 | whiteList['rotation-point'] = false;
|
12911 |
|
12912 | whiteList['ruby-align'] = false;
|
12913 |
|
12914 | whiteList['ruby-merge'] = false;
|
12915 |
|
12916 | whiteList['ruby-position'] = false;
|
12917 |
|
12918 | whiteList['shape-image-threshold'] = false;
|
12919 |
|
12920 | whiteList['shape-outside'] = false;
|
12921 |
|
12922 | whiteList['shape-margin'] = false;
|
12923 |
|
12924 | whiteList['size'] = false;
|
12925 |
|
12926 | whiteList['speak'] = false;
|
12927 |
|
12928 | whiteList['speak-as'] = false;
|
12929 |
|
12930 | whiteList['speak-header'] = false;
|
12931 |
|
12932 | whiteList['speak-numeral'] = false;
|
12933 |
|
12934 | whiteList['speak-punctuation'] = false;
|
12935 |
|
12936 | whiteList['speech-rate'] = false;
|
12937 |
|
12938 | whiteList['stress'] = false;
|
12939 |
|
12940 | whiteList['string-set'] = false;
|
12941 |
|
12942 | whiteList['tab-size'] = false;
|
12943 |
|
12944 | whiteList['table-layout'] = false;
|
12945 |
|
12946 | whiteList['text-align'] = true;
|
12947 |
|
12948 | whiteList['text-align-last'] = true;
|
12949 |
|
12950 | whiteList['text-combine-upright'] = true;
|
12951 |
|
12952 | whiteList['text-decoration'] = true;
|
12953 |
|
12954 | whiteList['text-decoration-color'] = true;
|
12955 |
|
12956 | whiteList['text-decoration-line'] = true;
|
12957 |
|
12958 | whiteList['text-decoration-skip'] = true;
|
12959 |
|
12960 | whiteList['text-decoration-style'] = true;
|
12961 |
|
12962 | whiteList['text-emphasis'] = true;
|
12963 |
|
12964 | whiteList['text-emphasis-color'] = true;
|
12965 |
|
12966 | whiteList['text-emphasis-position'] = true;
|
12967 |
|
12968 | whiteList['text-emphasis-style'] = true;
|
12969 |
|
12970 | whiteList['text-height'] = true;
|
12971 |
|
12972 | whiteList['text-indent'] = true;
|
12973 |
|
12974 | whiteList['text-justify'] = true;
|
12975 |
|
12976 | whiteList['text-orientation'] = true;
|
12977 |
|
12978 | whiteList['text-overflow'] = true;
|
12979 |
|
12980 | whiteList['text-shadow'] = true;
|
12981 |
|
12982 | whiteList['text-space-collapse'] = true;
|
12983 |
|
12984 | whiteList['text-transform'] = true;
|
12985 |
|
12986 | whiteList['text-underline-position'] = true;
|
12987 |
|
12988 | whiteList['text-wrap'] = true;
|
12989 |
|
12990 | whiteList['top'] = false;
|
12991 |
|
12992 | whiteList['transform'] = false;
|
12993 |
|
12994 | whiteList['transform-origin'] = false;
|
12995 |
|
12996 | whiteList['transform-style'] = false;
|
12997 |
|
12998 | whiteList['transition'] = false;
|
12999 |
|
13000 | whiteList['transition-delay'] = false;
|
13001 |
|
13002 | whiteList['transition-duration'] = false;
|
13003 |
|
13004 | whiteList['transition-property'] = false;
|
13005 |
|
13006 | whiteList['transition-timing-function'] = false;
|
13007 |
|
13008 | whiteList['unicode-bidi'] = false;
|
13009 |
|
13010 | whiteList['vertical-align'] = false;
|
13011 |
|
13012 | whiteList['visibility'] = false;
|
13013 |
|
13014 | whiteList['voice-balance'] = false;
|
13015 |
|
13016 | whiteList['voice-duration'] = false;
|
13017 |
|
13018 | whiteList['voice-family'] = false;
|
13019 |
|
13020 | whiteList['voice-pitch'] = false;
|
13021 |
|
13022 | whiteList['voice-range'] = false;
|
13023 |
|
13024 | whiteList['voice-rate'] = false;
|
13025 |
|
13026 | whiteList['voice-stress'] = false;
|
13027 |
|
13028 | whiteList['voice-volume'] = false;
|
13029 |
|
13030 | whiteList['volume'] = false;
|
13031 |
|
13032 | whiteList['white-space'] = false;
|
13033 |
|
13034 | whiteList['widows'] = false;
|
13035 |
|
13036 | whiteList['width'] = true;
|
13037 |
|
13038 | whiteList['will-change'] = false;
|
13039 |
|
13040 | whiteList['word-break'] = true;
|
13041 |
|
13042 | whiteList['word-spacing'] = true;
|
13043 |
|
13044 | whiteList['word-wrap'] = true;
|
13045 |
|
13046 | whiteList['wrap-flow'] = false;
|
13047 |
|
13048 | whiteList['wrap-through'] = false;
|
13049 |
|
13050 | whiteList['writing-mode'] = false;
|
13051 |
|
13052 | whiteList['z-index'] = false;
|
13053 |
|
13054 | return whiteList;
|
13055 | }
|
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 |
|
13061 |
|
13062 |
|
13063 |
|
13064 |
|
13065 |
|
13066 | function onAttr(name, value, options) {
|
13067 | }
|
13068 |
|
13069 |
|
13070 |
|
13071 |
|
13072 |
|
13073 |
|
13074 |
|
13075 |
|
13076 |
|
13077 |
|
13078 | function onIgnoreAttr(name, value, options) {
|
13079 | }
|
13080 |
|
13081 | var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;
|
13082 |
|
13083 |
|
13084 |
|
13085 |
|
13086 |
|
13087 |
|
13088 |
|
13089 |
|
13090 | function safeAttrValue$1(name, value) {
|
13091 | if (REGEXP_URL_JAVASCRIPT.test(value)) return '';
|
13092 | return value;
|
13093 | }
|
13094 |
|
13095 | _default.whiteList = getDefaultWhiteList$1();
|
13096 | _default.getDefaultWhiteList = getDefaultWhiteList$1;
|
13097 | _default.onAttr = onAttr;
|
13098 | _default.onIgnoreAttr = onIgnoreAttr;
|
13099 | _default.safeAttrValue = safeAttrValue$1;
|
13100 |
|
13101 | var util$1 = {
|
13102 | indexOf: function (arr, item) {
|
13103 | var i, j;
|
13104 |
|
13105 | if (Array.prototype.indexOf) {
|
13106 | return arr.indexOf(item);
|
13107 | }
|
13108 |
|
13109 | for (i = 0, j = arr.length; i < j; i++) {
|
13110 | if (arr[i] === item) {
|
13111 | return i;
|
13112 | }
|
13113 | }
|
13114 |
|
13115 | return -1;
|
13116 | },
|
13117 | forEach: function (arr, fn, scope) {
|
13118 | var i, j;
|
13119 |
|
13120 | if (Array.prototype.forEach) {
|
13121 | return arr.forEach(fn, scope);
|
13122 | }
|
13123 |
|
13124 | for (i = 0, j = arr.length; i < j; i++) {
|
13125 | fn.call(scope, arr[i], i, arr);
|
13126 | }
|
13127 | },
|
13128 | trim: function (str) {
|
13129 | if (String.prototype.trim) {
|
13130 | return str.trim();
|
13131 | }
|
13132 |
|
13133 | return str.replace(/(^\s*)|(\s*$)/g, '');
|
13134 | },
|
13135 | trimRight: function (str) {
|
13136 | if (String.prototype.trimRight) {
|
13137 | return str.trimRight();
|
13138 | }
|
13139 |
|
13140 | return str.replace(/(\s*$)/g, '');
|
13141 | }
|
13142 | };
|
13143 |
|
13144 |
|
13145 |
|
13146 |
|
13147 |
|
13148 |
|
13149 | var _$3 = util$1;
|
13150 |
|
13151 |
|
13152 |
|
13153 |
|
13154 |
|
13155 |
|
13156 |
|
13157 |
|
13158 |
|
13159 | function parseStyle$1(css, onAttr) {
|
13160 | css = _$3.trimRight(css);
|
13161 | if (css[css.length - 1] !== ';') css += ';';
|
13162 | var cssLength = css.length;
|
13163 | var isParenthesisOpen = false;
|
13164 | var lastPos = 0;
|
13165 | var i = 0;
|
13166 | var retCSS = '';
|
13167 |
|
13168 | function addNewAttr() {
|
13169 |
|
13170 | if (!isParenthesisOpen) {
|
13171 | var source = _$3.trim(css.slice(lastPos, i));
|
13172 |
|
13173 | var j = source.indexOf(':');
|
13174 |
|
13175 | if (j !== -1) {
|
13176 | var name = _$3.trim(source.slice(0, j));
|
13177 |
|
13178 | var value = _$3.trim(source.slice(j + 1));
|
13179 |
|
13180 |
|
13181 | if (name) {
|
13182 | var ret = onAttr(lastPos, retCSS.length, name, value, source);
|
13183 | if (ret) retCSS += ret + '; ';
|
13184 | }
|
13185 | }
|
13186 | }
|
13187 |
|
13188 | lastPos = i + 1;
|
13189 | }
|
13190 |
|
13191 | for (; i < cssLength; i++) {
|
13192 | var c = css[i];
|
13193 |
|
13194 | if (c === '/' && css[i + 1] === '*') {
|
13195 |
|
13196 | var j = css.indexOf('*/', i + 2);
|
13197 |
|
13198 | if (j === -1) break;
|
13199 |
|
13200 | i = j + 1;
|
13201 | lastPos = i + 1;
|
13202 | isParenthesisOpen = false;
|
13203 | } else if (c === '(') {
|
13204 | isParenthesisOpen = true;
|
13205 | } else if (c === ')') {
|
13206 | isParenthesisOpen = false;
|
13207 | } else if (c === ';') {
|
13208 | if (isParenthesisOpen) ; else {
|
13209 | addNewAttr();
|
13210 | }
|
13211 | } else if (c === '\n') {
|
13212 | addNewAttr();
|
13213 | }
|
13214 | }
|
13215 |
|
13216 | return _$3.trim(retCSS);
|
13217 | }
|
13218 |
|
13219 | var parser$2 = parseStyle$1;
|
13220 |
|
13221 |
|
13222 |
|
13223 |
|
13224 |
|
13225 |
|
13226 | var DEFAULT$1 = _default;
|
13227 | var parseStyle = parser$2;
|
13228 |
|
13229 |
|
13230 |
|
13231 |
|
13232 |
|
13233 |
|
13234 |
|
13235 | function isNull$1(obj) {
|
13236 | return obj === undefined || obj === null;
|
13237 | }
|
13238 |
|
13239 |
|
13240 |
|
13241 |
|
13242 |
|
13243 |
|
13244 |
|
13245 |
|
13246 | function shallowCopyObject$1(obj) {
|
13247 | var ret = {};
|
13248 |
|
13249 | for (var i in obj) {
|
13250 | ret[i] = obj[i];
|
13251 | }
|
13252 |
|
13253 | return ret;
|
13254 | }
|
13255 |
|
13256 |
|
13257 |
|
13258 |
|
13259 |
|
13260 |
|
13261 |
|
13262 |
|
13263 |
|
13264 |
|
13265 |
|
13266 | function FilterCSS$2(options) {
|
13267 | options = shallowCopyObject$1(options || {});
|
13268 | options.whiteList = options.whiteList || DEFAULT$1.whiteList;
|
13269 | options.onAttr = options.onAttr || DEFAULT$1.onAttr;
|
13270 | options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT$1.onIgnoreAttr;
|
13271 | options.safeAttrValue = options.safeAttrValue || DEFAULT$1.safeAttrValue;
|
13272 | this.options = options;
|
13273 | }
|
13274 |
|
13275 | FilterCSS$2.prototype.process = function (css) {
|
13276 |
|
13277 | css = css || '';
|
13278 | css = css.toString();
|
13279 | if (!css) return '';
|
13280 | var me = this;
|
13281 | var options = me.options;
|
13282 | var whiteList = options.whiteList;
|
13283 | var onAttr = options.onAttr;
|
13284 | var onIgnoreAttr = options.onIgnoreAttr;
|
13285 | var safeAttrValue = options.safeAttrValue;
|
13286 | var retCSS = parseStyle(css, function (sourcePosition, position, name, value, source) {
|
13287 | var check = whiteList[name];
|
13288 | var isWhite = false;
|
13289 | if (check === true) isWhite = check;else if (typeof check === 'function') isWhite = check(value);else if (check instanceof RegExp) isWhite = check.test(value);
|
13290 | if (isWhite !== true) isWhite = false;
|
13291 |
|
13292 | value = safeAttrValue(name, value);
|
13293 | if (!value) return;
|
13294 | var opts = {
|
13295 | position: position,
|
13296 | sourcePosition: sourcePosition,
|
13297 | source: source,
|
13298 | isWhite: isWhite
|
13299 | };
|
13300 |
|
13301 | if (isWhite) {
|
13302 | var ret = onAttr(name, value, opts);
|
13303 |
|
13304 | if (isNull$1(ret)) {
|
13305 | return name + ':' + value;
|
13306 | } else {
|
13307 | return ret;
|
13308 | }
|
13309 | } else {
|
13310 | var ret = onIgnoreAttr(name, value, opts);
|
13311 |
|
13312 | if (!isNull$1(ret)) {
|
13313 | return ret;
|
13314 | }
|
13315 | }
|
13316 | });
|
13317 | return retCSS;
|
13318 | };
|
13319 |
|
13320 | var css = FilterCSS$2;
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 |
|
13326 |
|
13327 |
|
13328 | (function (module, exports) {
|
13329 | var DEFAULT = _default;
|
13330 | var FilterCSS = css;
|
13331 | |
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 |
|
13337 |
|
13338 |
|
13339 | function filterCSS(html, options) {
|
13340 | var xss = new FilterCSS(options);
|
13341 | return xss.process(html);
|
13342 | }
|
13343 |
|
13344 |
|
13345 | exports = module.exports = filterCSS;
|
13346 | exports.FilterCSS = FilterCSS;
|
13347 |
|
13348 | for (var i in DEFAULT) exports[i] = DEFAULT[i];
|
13349 |
|
13350 |
|
13351 | if (typeof window !== 'undefined') {
|
13352 | window.filterCSS = module.exports;
|
13353 | }
|
13354 | })(lib, lib.exports);
|
13355 |
|
13356 | var util = {
|
13357 | indexOf: function (arr, item) {
|
13358 | var i, j;
|
13359 |
|
13360 | if (Array.prototype.indexOf) {
|
13361 | return arr.indexOf(item);
|
13362 | }
|
13363 |
|
13364 | for (i = 0, j = arr.length; i < j; i++) {
|
13365 | if (arr[i] === item) {
|
13366 | return i;
|
13367 | }
|
13368 | }
|
13369 |
|
13370 | return -1;
|
13371 | },
|
13372 | forEach: function (arr, fn, scope) {
|
13373 | var i, j;
|
13374 |
|
13375 | if (Array.prototype.forEach) {
|
13376 | return arr.forEach(fn, scope);
|
13377 | }
|
13378 |
|
13379 | for (i = 0, j = arr.length; i < j; i++) {
|
13380 | fn.call(scope, arr[i], i, arr);
|
13381 | }
|
13382 | },
|
13383 | trim: function (str) {
|
13384 | if (String.prototype.trim) {
|
13385 | return str.trim();
|
13386 | }
|
13387 |
|
13388 | return str.replace(/(^\s*)|(\s*$)/g, "");
|
13389 | },
|
13390 | spaceIndex: function (str) {
|
13391 | var reg = /\s|\n|\t/;
|
13392 | var match = reg.exec(str);
|
13393 | return match ? match.index : -1;
|
13394 | }
|
13395 | };
|
13396 |
|
13397 |
|
13398 |
|
13399 |
|
13400 |
|
13401 |
|
13402 | var FilterCSS$1 = lib.exports.FilterCSS;
|
13403 | var getDefaultCSSWhiteList = lib.exports.getDefaultWhiteList;
|
13404 | var _$2 = util;
|
13405 |
|
13406 | function getDefaultWhiteList() {
|
13407 | return {
|
13408 | a: ["target", "href", "title"],
|
13409 | abbr: ["title"],
|
13410 | address: [],
|
13411 | area: ["shape", "coords", "href", "alt"],
|
13412 | article: [],
|
13413 | aside: [],
|
13414 | audio: ["autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src"],
|
13415 | b: [],
|
13416 | bdi: ["dir"],
|
13417 | bdo: ["dir"],
|
13418 | big: [],
|
13419 | blockquote: ["cite"],
|
13420 | br: [],
|
13421 | caption: [],
|
13422 | center: [],
|
13423 | cite: [],
|
13424 | code: [],
|
13425 | col: ["align", "valign", "span", "width"],
|
13426 | colgroup: ["align", "valign", "span", "width"],
|
13427 | dd: [],
|
13428 | del: ["datetime"],
|
13429 | details: ["open"],
|
13430 | div: [],
|
13431 | dl: [],
|
13432 | dt: [],
|
13433 | em: [],
|
13434 | figcaption: [],
|
13435 | figure: [],
|
13436 | font: ["color", "size", "face"],
|
13437 | footer: [],
|
13438 | h1: [],
|
13439 | h2: [],
|
13440 | h3: [],
|
13441 | h4: [],
|
13442 | h5: [],
|
13443 | h6: [],
|
13444 | header: [],
|
13445 | hr: [],
|
13446 | i: [],
|
13447 | img: ["src", "alt", "title", "width", "height"],
|
13448 | ins: ["datetime"],
|
13449 | li: [],
|
13450 | mark: [],
|
13451 | nav: [],
|
13452 | ol: [],
|
13453 | p: [],
|
13454 | pre: [],
|
13455 | s: [],
|
13456 | section: [],
|
13457 | small: [],
|
13458 | span: [],
|
13459 | sub: [],
|
13460 | summary: [],
|
13461 | sup: [],
|
13462 | strong: [],
|
13463 | strike: [],
|
13464 | table: ["width", "border", "align", "valign"],
|
13465 | tbody: ["align", "valign"],
|
13466 | td: ["width", "rowspan", "colspan", "align", "valign"],
|
13467 | tfoot: ["align", "valign"],
|
13468 | th: ["width", "rowspan", "colspan", "align", "valign"],
|
13469 | thead: ["align", "valign"],
|
13470 | tr: ["rowspan", "align", "valign"],
|
13471 | tt: [],
|
13472 | u: [],
|
13473 | ul: [],
|
13474 | video: ["autoplay", "controls", "crossorigin", "loop", "muted", "playsinline", "poster", "preload", "src", "height", "width"]
|
13475 | };
|
13476 | }
|
13477 |
|
13478 | var defaultCSSFilter = new FilterCSS$1();
|
13479 |
|
13480 |
|
13481 |
|
13482 |
|
13483 |
|
13484 |
|
13485 |
|
13486 |
|
13487 |
|
13488 | function onTag(tag, html, options) {
|
13489 | }
|
13490 |
|
13491 |
|
13492 |
|
13493 |
|
13494 |
|
13495 |
|
13496 |
|
13497 |
|
13498 |
|
13499 |
|
13500 | function onIgnoreTag(tag, html, options) {
|
13501 | }
|
13502 |
|
13503 |
|
13504 |
|
13505 |
|
13506 |
|
13507 |
|
13508 |
|
13509 |
|
13510 |
|
13511 |
|
13512 | function onTagAttr(tag, name, value) {
|
13513 | }
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 |
|
13520 |
|
13521 |
|
13522 |
|
13523 |
|
13524 | function onIgnoreTagAttr(tag, name, value) {
|
13525 | }
|
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 |
|
13532 |
|
13533 | function escapeHtml(html) {
|
13534 | return html.replace(REGEXP_LT, "<").replace(REGEXP_GT, ">");
|
13535 | }
|
13536 |
|
13537 |
|
13538 |
|
13539 |
|
13540 |
|
13541 |
|
13542 |
|
13543 |
|
13544 |
|
13545 |
|
13546 |
|
13547 | function safeAttrValue(tag, name, value, cssFilter) {
|
13548 |
|
13549 | value = friendlyAttrValue(value);
|
13550 |
|
13551 | if (name === "href" || name === "src") {
|
13552 |
|
13553 |
|
13554 | value = _$2.trim(value);
|
13555 | if (value === "#") return "#";
|
13556 |
|
13557 | if (!(value.substr(0, 7) === "http://" || value.substr(0, 8) === "https://" || value.substr(0, 7) === "mailto:" || value.substr(0, 4) === "tel:" || value.substr(0, 11) === "data:image/" || value.substr(0, 6) === "ftp://" || value.substr(0, 2) === "./" || value.substr(0, 3) === "../" || value[0] === "#" || value[0] === "/")) {
|
13558 | return "";
|
13559 | }
|
13560 | } else if (name === "background") {
|
13561 |
|
13562 |
|
13563 | REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
|
13564 |
|
13565 | if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
|
13566 | return "";
|
13567 | }
|
13568 | } else if (name === "style") {
|
13569 |
|
13570 | REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0;
|
13571 |
|
13572 | if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) {
|
13573 | return "";
|
13574 | }
|
13575 |
|
13576 |
|
13577 | REGEXP_DEFAULT_ON_TAG_ATTR_8.lastIndex = 0;
|
13578 |
|
13579 | if (REGEXP_DEFAULT_ON_TAG_ATTR_8.test(value)) {
|
13580 | REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
|
13581 |
|
13582 | if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
|
13583 | return "";
|
13584 | }
|
13585 | }
|
13586 |
|
13587 | if (cssFilter !== false) {
|
13588 | cssFilter = cssFilter || defaultCSSFilter;
|
13589 | value = cssFilter.process(value);
|
13590 | }
|
13591 | }
|
13592 |
|
13593 |
|
13594 | value = escapeAttrValue(value);
|
13595 | return value;
|
13596 | }
|
13597 |
|
13598 |
|
13599 | var REGEXP_LT = /</g;
|
13600 | var REGEXP_GT = />/g;
|
13601 | var REGEXP_QUOTE = /"/g;
|
13602 | var REGEXP_QUOTE_2 = /"/g;
|
13603 | var REGEXP_ATTR_VALUE_1 = /&#([a-zA-Z0-9]*);?/gim;
|
13604 | var REGEXP_ATTR_VALUE_COLON = /:?/gim;
|
13605 | var REGEXP_ATTR_VALUE_NEWLINE = /&newline;?/gim;
|
13606 |
|
13607 | var REGEXP_DEFAULT_ON_TAG_ATTR_4 = /((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi;
|
13608 |
|
13609 |
|
13610 | var REGEXP_DEFAULT_ON_TAG_ATTR_7 = /e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi;
|
13611 | var REGEXP_DEFAULT_ON_TAG_ATTR_8 = /u\s*r\s*l\s*\(.*/gi;
|
13612 |
|
13613 |
|
13614 |
|
13615 |
|
13616 |
|
13617 |
|
13618 |
|
13619 | function escapeQuote(str) {
|
13620 | return str.replace(REGEXP_QUOTE, """);
|
13621 | }
|
13622 |
|
13623 |
|
13624 |
|
13625 |
|
13626 |
|
13627 |
|
13628 |
|
13629 |
|
13630 | function unescapeQuote(str) {
|
13631 | return str.replace(REGEXP_QUOTE_2, '"');
|
13632 | }
|
13633 |
|
13634 |
|
13635 |
|
13636 |
|
13637 |
|
13638 |
|
13639 |
|
13640 |
|
13641 | function escapeHtmlEntities(str) {
|
13642 | return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str, code) {
|
13643 | return code[0] === "x" || code[0] === "X" ? String.fromCharCode(parseInt(code.substr(1), 16)) : String.fromCharCode(parseInt(code, 10));
|
13644 | });
|
13645 | }
|
13646 |
|
13647 |
|
13648 |
|
13649 |
|
13650 |
|
13651 |
|
13652 |
|
13653 |
|
13654 | function escapeDangerHtml5Entities(str) {
|
13655 | return str.replace(REGEXP_ATTR_VALUE_COLON, ":").replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
|
13656 | }
|
13657 |
|
13658 |
|
13659 |
|
13660 |
|
13661 |
|
13662 |
|
13663 |
|
13664 |
|
13665 | function clearNonPrintableCharacter(str) {
|
13666 | var str2 = "";
|
13667 |
|
13668 | for (var i = 0, len = str.length; i < len; i++) {
|
13669 | str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
|
13670 | }
|
13671 |
|
13672 | return _$2.trim(str2);
|
13673 | }
|
13674 |
|
13675 |
|
13676 |
|
13677 |
|
13678 |
|
13679 |
|
13680 |
|
13681 |
|
13682 | function friendlyAttrValue(str) {
|
13683 | str = unescapeQuote(str);
|
13684 | str = escapeHtmlEntities(str);
|
13685 | str = escapeDangerHtml5Entities(str);
|
13686 | str = clearNonPrintableCharacter(str);
|
13687 | return str;
|
13688 | }
|
13689 |
|
13690 |
|
13691 |
|
13692 |
|
13693 |
|
13694 |
|
13695 |
|
13696 |
|
13697 | function escapeAttrValue(str) {
|
13698 | str = escapeQuote(str);
|
13699 | str = escapeHtml(str);
|
13700 | return str;
|
13701 | }
|
13702 |
|
13703 |
|
13704 |
|
13705 |
|
13706 |
|
13707 | function onIgnoreTagStripAll() {
|
13708 | return "";
|
13709 | }
|
13710 |
|
13711 |
|
13712 |
|
13713 |
|
13714 |
|
13715 |
|
13716 |
|
13717 |
|
13718 |
|
13719 | function StripTagBody(tags, next) {
|
13720 | if (typeof next !== "function") {
|
13721 | next = function () {};
|
13722 | }
|
13723 |
|
13724 | var isRemoveAllTag = !Array.isArray(tags);
|
13725 |
|
13726 | function isRemoveTag(tag) {
|
13727 | if (isRemoveAllTag) return true;
|
13728 | return _$2.indexOf(tags, tag) !== -1;
|
13729 | }
|
13730 |
|
13731 | var removeList = [];
|
13732 | var posStart = false;
|
13733 | return {
|
13734 | onIgnoreTag: function (tag, html, options) {
|
13735 | if (isRemoveTag(tag)) {
|
13736 | if (options.isClosing) {
|
13737 | var ret = "[/removed]";
|
13738 | var end = options.position + ret.length;
|
13739 | removeList.push([posStart !== false ? posStart : options.position, end]);
|
13740 | posStart = false;
|
13741 | return ret;
|
13742 | } else {
|
13743 | if (!posStart) {
|
13744 | posStart = options.position;
|
13745 | }
|
13746 |
|
13747 | return "[removed]";
|
13748 | }
|
13749 | } else {
|
13750 | return next(tag, html, options);
|
13751 | }
|
13752 | },
|
13753 | remove: function (html) {
|
13754 | var rethtml = "";
|
13755 | var lastPos = 0;
|
13756 |
|
13757 | _$2.forEach(removeList, function (pos) {
|
13758 | rethtml += html.slice(lastPos, pos[0]);
|
13759 | lastPos = pos[1];
|
13760 | });
|
13761 |
|
13762 | rethtml += html.slice(lastPos);
|
13763 | return rethtml;
|
13764 | }
|
13765 | };
|
13766 | }
|
13767 |
|
13768 |
|
13769 |
|
13770 |
|
13771 |
|
13772 |
|
13773 |
|
13774 |
|
13775 | function stripCommentTag(html) {
|
13776 | var retHtml = "";
|
13777 | var lastPos = 0;
|
13778 |
|
13779 | while (lastPos < html.length) {
|
13780 | var i = html.indexOf("<!--", lastPos);
|
13781 |
|
13782 | if (i === -1) {
|
13783 | retHtml += html.slice(lastPos);
|
13784 | break;
|
13785 | }
|
13786 |
|
13787 | retHtml += html.slice(lastPos, i);
|
13788 | var j = html.indexOf("-->", i);
|
13789 |
|
13790 | if (j === -1) {
|
13791 | break;
|
13792 | }
|
13793 |
|
13794 | lastPos = j + 3;
|
13795 | }
|
13796 |
|
13797 | return retHtml;
|
13798 | }
|
13799 |
|
13800 |
|
13801 |
|
13802 |
|
13803 |
|
13804 |
|
13805 |
|
13806 |
|
13807 | function stripBlankChar(html) {
|
13808 | var chars = html.split("");
|
13809 | chars = chars.filter(function (char) {
|
13810 | var c = char.charCodeAt(0);
|
13811 | if (c === 127) return false;
|
13812 |
|
13813 | if (c <= 31) {
|
13814 | if (c === 10 || c === 13) return true;
|
13815 | return false;
|
13816 | }
|
13817 |
|
13818 | return true;
|
13819 | });
|
13820 | return chars.join("");
|
13821 | }
|
13822 |
|
13823 | _default$1.whiteList = getDefaultWhiteList();
|
13824 | _default$1.getDefaultWhiteList = getDefaultWhiteList;
|
13825 | _default$1.onTag = onTag;
|
13826 | _default$1.onIgnoreTag = onIgnoreTag;
|
13827 | _default$1.onTagAttr = onTagAttr;
|
13828 | _default$1.onIgnoreTagAttr = onIgnoreTagAttr;
|
13829 | _default$1.safeAttrValue = safeAttrValue;
|
13830 | _default$1.escapeHtml = escapeHtml;
|
13831 | _default$1.escapeQuote = escapeQuote;
|
13832 | _default$1.unescapeQuote = unescapeQuote;
|
13833 | _default$1.escapeHtmlEntities = escapeHtmlEntities;
|
13834 | _default$1.escapeDangerHtml5Entities = escapeDangerHtml5Entities;
|
13835 | _default$1.clearNonPrintableCharacter = clearNonPrintableCharacter;
|
13836 | _default$1.friendlyAttrValue = friendlyAttrValue;
|
13837 | _default$1.escapeAttrValue = escapeAttrValue;
|
13838 | _default$1.onIgnoreTagStripAll = onIgnoreTagStripAll;
|
13839 | _default$1.StripTagBody = StripTagBody;
|
13840 | _default$1.stripCommentTag = stripCommentTag;
|
13841 | _default$1.stripBlankChar = stripBlankChar;
|
13842 | _default$1.cssFilter = defaultCSSFilter;
|
13843 | _default$1.getDefaultCSSWhiteList = getDefaultCSSWhiteList;
|
13844 |
|
13845 | var parser$1 = {};
|
13846 |
|
13847 |
|
13848 |
|
13849 |
|
13850 |
|
13851 |
|
13852 | var _$1 = util;
|
13853 |
|
13854 |
|
13855 |
|
13856 |
|
13857 |
|
13858 |
|
13859 |
|
13860 | function getTagName(html) {
|
13861 | var i = _$1.spaceIndex(html);
|
13862 |
|
13863 | var tagName;
|
13864 |
|
13865 | if (i === -1) {
|
13866 | tagName = html.slice(1, -1);
|
13867 | } else {
|
13868 | tagName = html.slice(1, i + 1);
|
13869 | }
|
13870 |
|
13871 | tagName = _$1.trim(tagName).toLowerCase();
|
13872 | if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
|
13873 | if (tagName.slice(-1) === "/") tagName = tagName.slice(0, -1);
|
13874 | return tagName;
|
13875 | }
|
13876 |
|
13877 |
|
13878 |
|
13879 |
|
13880 |
|
13881 |
|
13882 |
|
13883 |
|
13884 | function isClosing(html) {
|
13885 | return html.slice(0, 2) === "</";
|
13886 | }
|
13887 |
|
13888 |
|
13889 |
|
13890 |
|
13891 |
|
13892 |
|
13893 |
|
13894 |
|
13895 |
|
13896 |
|
13897 | function parseTag$1(html, onTag, escapeHtml) {
|
13898 |
|
13899 | var rethtml = "";
|
13900 | var lastPos = 0;
|
13901 | var tagStart = false;
|
13902 | var quoteStart = false;
|
13903 | var currentPos = 0;
|
13904 | var len = html.length;
|
13905 | var currentTagName = "";
|
13906 | var currentHtml = "";
|
13907 |
|
13908 | chariterator: for (currentPos = 0; currentPos < len; currentPos++) {
|
13909 | var c = html.charAt(currentPos);
|
13910 |
|
13911 | if (tagStart === false) {
|
13912 | if (c === "<") {
|
13913 | tagStart = currentPos;
|
13914 | continue;
|
13915 | }
|
13916 | } else {
|
13917 | if (quoteStart === false) {
|
13918 | if (c === "<") {
|
13919 | rethtml += escapeHtml(html.slice(lastPos, currentPos));
|
13920 | tagStart = currentPos;
|
13921 | lastPos = currentPos;
|
13922 | continue;
|
13923 | }
|
13924 |
|
13925 | if (c === ">") {
|
13926 | rethtml += escapeHtml(html.slice(lastPos, tagStart));
|
13927 | currentHtml = html.slice(tagStart, currentPos + 1);
|
13928 | currentTagName = getTagName(currentHtml);
|
13929 | rethtml += onTag(tagStart, rethtml.length, currentTagName, currentHtml, isClosing(currentHtml));
|
13930 | lastPos = currentPos + 1;
|
13931 | tagStart = false;
|
13932 | continue;
|
13933 | }
|
13934 |
|
13935 | if (c === '"' || c === "'") {
|
13936 | var i = 1;
|
13937 | var ic = html.charAt(currentPos - i);
|
13938 |
|
13939 | while (ic.trim() === "" || ic === "=") {
|
13940 | if (ic === "=") {
|
13941 | quoteStart = c;
|
13942 | continue chariterator;
|
13943 | }
|
13944 |
|
13945 | ic = html.charAt(currentPos - ++i);
|
13946 | }
|
13947 | }
|
13948 | } else {
|
13949 | if (c === quoteStart) {
|
13950 | quoteStart = false;
|
13951 | continue;
|
13952 | }
|
13953 | }
|
13954 | }
|
13955 | }
|
13956 |
|
13957 | if (lastPos < html.length) {
|
13958 | rethtml += escapeHtml(html.substr(lastPos));
|
13959 | }
|
13960 |
|
13961 | return rethtml;
|
13962 | }
|
13963 |
|
13964 | var REGEXP_ILLEGAL_ATTR_NAME = /[^a-zA-Z0-9\\_:.-]/gim;
|
13965 |
|
13966 |
|
13967 |
|
13968 |
|
13969 |
|
13970 |
|
13971 |
|
13972 |
|
13973 | function parseAttr$1(html, onAttr) {
|
13974 |
|
13975 | var lastPos = 0;
|
13976 | var lastMarkPos = 0;
|
13977 | var retAttrs = [];
|
13978 | var tmpName = false;
|
13979 | var len = html.length;
|
13980 |
|
13981 | function addAttr(name, value) {
|
13982 | name = _$1.trim(name);
|
13983 | name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
|
13984 | if (name.length < 1) return;
|
13985 | var ret = onAttr(name, value || "");
|
13986 | if (ret) retAttrs.push(ret);
|
13987 | }
|
13988 |
|
13989 |
|
13990 | for (var i = 0; i < len; i++) {
|
13991 | var c = html.charAt(i);
|
13992 | var v, j;
|
13993 |
|
13994 | if (tmpName === false && c === "=") {
|
13995 | tmpName = html.slice(lastPos, i);
|
13996 | lastPos = i + 1;
|
13997 | lastMarkPos = html.charAt(lastPos) === '"' || html.charAt(lastPos) === "'" ? lastPos : findNextQuotationMark(html, i + 1);
|
13998 | continue;
|
13999 | }
|
14000 |
|
14001 | if (tmpName !== false) {
|
14002 | if (i === lastMarkPos) {
|
14003 | j = html.indexOf(c, i + 1);
|
14004 |
|
14005 | if (j === -1) {
|
14006 | break;
|
14007 | } else {
|
14008 | v = _$1.trim(html.slice(lastMarkPos + 1, j));
|
14009 | addAttr(tmpName, v);
|
14010 | tmpName = false;
|
14011 | i = j;
|
14012 | lastPos = i + 1;
|
14013 | continue;
|
14014 | }
|
14015 | }
|
14016 | }
|
14017 |
|
14018 | if (/\s|\n|\t/.test(c)) {
|
14019 | html = html.replace(/\s|\n|\t/g, " ");
|
14020 |
|
14021 | if (tmpName === false) {
|
14022 | j = findNextEqual(html, i);
|
14023 |
|
14024 | if (j === -1) {
|
14025 | v = _$1.trim(html.slice(lastPos, i));
|
14026 | addAttr(v);
|
14027 | tmpName = false;
|
14028 | lastPos = i + 1;
|
14029 | continue;
|
14030 | } else {
|
14031 | i = j - 1;
|
14032 | continue;
|
14033 | }
|
14034 | } else {
|
14035 | j = findBeforeEqual(html, i - 1);
|
14036 |
|
14037 | if (j === -1) {
|
14038 | v = _$1.trim(html.slice(lastPos, i));
|
14039 | v = stripQuoteWrap(v);
|
14040 | addAttr(tmpName, v);
|
14041 | tmpName = false;
|
14042 | lastPos = i + 1;
|
14043 | continue;
|
14044 | } else {
|
14045 | continue;
|
14046 | }
|
14047 | }
|
14048 | }
|
14049 | }
|
14050 |
|
14051 | if (lastPos < html.length) {
|
14052 | if (tmpName === false) {
|
14053 | addAttr(html.slice(lastPos));
|
14054 | } else {
|
14055 | addAttr(tmpName, stripQuoteWrap(_$1.trim(html.slice(lastPos))));
|
14056 | }
|
14057 | }
|
14058 |
|
14059 | return _$1.trim(retAttrs.join(" "));
|
14060 | }
|
14061 |
|
14062 | function findNextEqual(str, i) {
|
14063 | for (; i < str.length; i++) {
|
14064 | var c = str[i];
|
14065 | if (c === " ") continue;
|
14066 | if (c === "=") return i;
|
14067 | return -1;
|
14068 | }
|
14069 | }
|
14070 |
|
14071 | function findNextQuotationMark(str, i) {
|
14072 | for (; i < str.length; i++) {
|
14073 | var c = str[i];
|
14074 | if (c === " ") continue;
|
14075 | if (c === "'" || c === '"') return i;
|
14076 | return -1;
|
14077 | }
|
14078 | }
|
14079 |
|
14080 | function findBeforeEqual(str, i) {
|
14081 | for (; i > 0; i--) {
|
14082 | var c = str[i];
|
14083 | if (c === " ") continue;
|
14084 | if (c === "=") return i;
|
14085 | return -1;
|
14086 | }
|
14087 | }
|
14088 |
|
14089 | function isQuoteWrapString(text) {
|
14090 | if (text[0] === '"' && text[text.length - 1] === '"' || text[0] === "'" && text[text.length - 1] === "'") {
|
14091 | return true;
|
14092 | } else {
|
14093 | return false;
|
14094 | }
|
14095 | }
|
14096 |
|
14097 | function stripQuoteWrap(text) {
|
14098 | if (isQuoteWrapString(text)) {
|
14099 | return text.substr(1, text.length - 2);
|
14100 | } else {
|
14101 | return text;
|
14102 | }
|
14103 | }
|
14104 |
|
14105 | parser$1.parseTag = parseTag$1;
|
14106 | parser$1.parseAttr = parseAttr$1;
|
14107 |
|
14108 |
|
14109 |
|
14110 |
|
14111 |
|
14112 |
|
14113 | var FilterCSS = lib.exports.FilterCSS;
|
14114 | var DEFAULT = _default$1;
|
14115 | var parser = parser$1;
|
14116 | var parseTag = parser.parseTag;
|
14117 | var parseAttr = parser.parseAttr;
|
14118 | var _ = util;
|
14119 |
|
14120 |
|
14121 |
|
14122 |
|
14123 |
|
14124 |
|
14125 |
|
14126 | function isNull(obj) {
|
14127 | return obj === undefined || obj === null;
|
14128 | }
|
14129 |
|
14130 |
|
14131 |
|
14132 |
|
14133 |
|
14134 |
|
14135 |
|
14136 |
|
14137 |
|
14138 |
|
14139 | function getAttrs(html) {
|
14140 | var i = _.spaceIndex(html);
|
14141 |
|
14142 | if (i === -1) {
|
14143 | return {
|
14144 | html: "",
|
14145 | closing: html[html.length - 2] === "/"
|
14146 | };
|
14147 | }
|
14148 |
|
14149 | html = _.trim(html.slice(i + 1, -1));
|
14150 | var isClosing = html[html.length - 1] === "/";
|
14151 | if (isClosing) html = _.trim(html.slice(0, -1));
|
14152 | return {
|
14153 | html: html,
|
14154 | closing: isClosing
|
14155 | };
|
14156 | }
|
14157 |
|
14158 |
|
14159 |
|
14160 |
|
14161 |
|
14162 |
|
14163 |
|
14164 |
|
14165 | function shallowCopyObject(obj) {
|
14166 | var ret = {};
|
14167 |
|
14168 | for (var i in obj) {
|
14169 | ret[i] = obj[i];
|
14170 | }
|
14171 |
|
14172 | return ret;
|
14173 | }
|
14174 |
|
14175 | function keysToLowerCase(obj) {
|
14176 | var ret = {};
|
14177 |
|
14178 | for (var i in obj) {
|
14179 | if (Array.isArray(obj[i])) {
|
14180 | ret[i.toLowerCase()] = obj[i].map(function (item) {
|
14181 | return item.toLowerCase();
|
14182 | });
|
14183 | } else {
|
14184 | ret[i.toLowerCase()] = obj[i];
|
14185 | }
|
14186 | }
|
14187 |
|
14188 | return ret;
|
14189 | }
|
14190 |
|
14191 |
|
14192 |
|
14193 |
|
14194 |
|
14195 |
|
14196 |
|
14197 |
|
14198 |
|
14199 |
|
14200 |
|
14201 | function FilterXSS(options) {
|
14202 | options = shallowCopyObject(options || {});
|
14203 |
|
14204 | if (options.stripIgnoreTag) {
|
14205 | if (options.onIgnoreTag) {
|
14206 | console.error('Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time');
|
14207 | }
|
14208 |
|
14209 | options.onIgnoreTag = DEFAULT.onIgnoreTagStripAll;
|
14210 | }
|
14211 |
|
14212 | if (options.whiteList || options.allowList) {
|
14213 | options.whiteList = keysToLowerCase(options.whiteList || options.allowList);
|
14214 | } else {
|
14215 | options.whiteList = DEFAULT.whiteList;
|
14216 | }
|
14217 |
|
14218 | options.onTag = options.onTag || DEFAULT.onTag;
|
14219 | options.onTagAttr = options.onTagAttr || DEFAULT.onTagAttr;
|
14220 | options.onIgnoreTag = options.onIgnoreTag || DEFAULT.onIgnoreTag;
|
14221 | options.onIgnoreTagAttr = options.onIgnoreTagAttr || DEFAULT.onIgnoreTagAttr;
|
14222 | options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue;
|
14223 | options.escapeHtml = options.escapeHtml || DEFAULT.escapeHtml;
|
14224 | this.options = options;
|
14225 |
|
14226 | if (options.css === false) {
|
14227 | this.cssFilter = false;
|
14228 | } else {
|
14229 | options.css = options.css || {};
|
14230 | this.cssFilter = new FilterCSS(options.css);
|
14231 | }
|
14232 | }
|
14233 |
|
14234 |
|
14235 |
|
14236 |
|
14237 |
|
14238 |
|
14239 |
|
14240 |
|
14241 | FilterXSS.prototype.process = function (html) {
|
14242 |
|
14243 | html = html || "";
|
14244 | html = html.toString();
|
14245 | if (!html) return "";
|
14246 | var me = this;
|
14247 | var options = me.options;
|
14248 | var whiteList = options.whiteList;
|
14249 | var onTag = options.onTag;
|
14250 | var onIgnoreTag = options.onIgnoreTag;
|
14251 | var onTagAttr = options.onTagAttr;
|
14252 | var onIgnoreTagAttr = options.onIgnoreTagAttr;
|
14253 | var safeAttrValue = options.safeAttrValue;
|
14254 | var escapeHtml = options.escapeHtml;
|
14255 | var cssFilter = me.cssFilter;
|
14256 |
|
14257 | if (options.stripBlankChar) {
|
14258 | html = DEFAULT.stripBlankChar(html);
|
14259 | }
|
14260 |
|
14261 |
|
14262 | if (!options.allowCommentTag) {
|
14263 | html = DEFAULT.stripCommentTag(html);
|
14264 | }
|
14265 |
|
14266 |
|
14267 | var stripIgnoreTagBody = false;
|
14268 |
|
14269 | if (options.stripIgnoreTagBody) {
|
14270 | stripIgnoreTagBody = DEFAULT.StripTagBody(options.stripIgnoreTagBody, onIgnoreTag);
|
14271 | onIgnoreTag = stripIgnoreTagBody.onIgnoreTag;
|
14272 | }
|
14273 |
|
14274 | var retHtml = parseTag(html, function (sourcePosition, position, tag, html, isClosing) {
|
14275 | var info = {
|
14276 | sourcePosition: sourcePosition,
|
14277 | position: position,
|
14278 | isClosing: isClosing,
|
14279 | isWhite: Object.prototype.hasOwnProperty.call(whiteList, tag)
|
14280 | };
|
14281 |
|
14282 | var ret = onTag(tag, html, info);
|
14283 | if (!isNull(ret)) return ret;
|
14284 |
|
14285 | if (info.isWhite) {
|
14286 | if (info.isClosing) {
|
14287 | return "</" + tag + ">";
|
14288 | }
|
14289 |
|
14290 | var attrs = getAttrs(html);
|
14291 | var whiteAttrList = whiteList[tag];
|
14292 | var attrsHtml = parseAttr(attrs.html, function (name, value) {
|
14293 |
|
14294 | var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1;
|
14295 | var ret = onTagAttr(tag, name, value, isWhiteAttr);
|
14296 | if (!isNull(ret)) return ret;
|
14297 |
|
14298 | if (isWhiteAttr) {
|
14299 |
|
14300 | value = safeAttrValue(tag, name, value, cssFilter);
|
14301 |
|
14302 | if (value) {
|
14303 | return name + '="' + value + '"';
|
14304 | } else {
|
14305 | return name;
|
14306 | }
|
14307 | } else {
|
14308 |
|
14309 | ret = onIgnoreTagAttr(tag, name, value, isWhiteAttr);
|
14310 | if (!isNull(ret)) return ret;
|
14311 | return;
|
14312 | }
|
14313 | });
|
14314 |
|
14315 | html = "<" + tag;
|
14316 | if (attrsHtml) html += " " + attrsHtml;
|
14317 | if (attrs.closing) html += " /";
|
14318 | html += ">";
|
14319 | return html;
|
14320 | } else {
|
14321 |
|
14322 | ret = onIgnoreTag(tag, html, info);
|
14323 | if (!isNull(ret)) return ret;
|
14324 | return escapeHtml(html);
|
14325 | }
|
14326 | }, escapeHtml);
|
14327 |
|
14328 | if (stripIgnoreTagBody) {
|
14329 | retHtml = stripIgnoreTagBody.remove(retHtml);
|
14330 | }
|
14331 |
|
14332 | return retHtml;
|
14333 | };
|
14334 |
|
14335 | var xss = FilterXSS;
|
14336 |
|
14337 |
|
14338 |
|
14339 |
|
14340 |
|
14341 |
|
14342 |
|
14343 | (function (module, exports) {
|
14344 | var DEFAULT = _default$1;
|
14345 | var parser = parser$1;
|
14346 | var FilterXSS = xss;
|
14347 | |
14348 |
|
14349 |
|
14350 |
|
14351 |
|
14352 |
|
14353 |
|
14354 |
|
14355 | function filterXSS(html, options) {
|
14356 | var xss = new FilterXSS(options);
|
14357 | return xss.process(html);
|
14358 | }
|
14359 |
|
14360 | exports = module.exports = filterXSS;
|
14361 | exports.filterXSS = filterXSS;
|
14362 | exports.FilterXSS = FilterXSS;
|
14363 |
|
14364 | (function () {
|
14365 | for (var i in DEFAULT) {
|
14366 | exports[i] = DEFAULT[i];
|
14367 | }
|
14368 |
|
14369 | for (var j in parser) {
|
14370 | exports[j] = parser[j];
|
14371 | }
|
14372 | })();
|
14373 |
|
14374 |
|
14375 | if (typeof window !== "undefined") {
|
14376 | window.filterXSS = module.exports;
|
14377 | }
|
14378 |
|
14379 |
|
14380 | function isWorkerEnv() {
|
14381 | return typeof self !== "undefined" && typeof DedicatedWorkerGlobalScope !== "undefined" && self instanceof DedicatedWorkerGlobalScope;
|
14382 | }
|
14383 |
|
14384 | if (isWorkerEnv()) {
|
14385 | self.filterXSS = module.exports;
|
14386 | }
|
14387 | })(lib$1, lib$1.exports);
|
14388 |
|
14389 | var xssFilter = lib$1.exports;
|
14390 |
|
14391 |
|
14392 |
|
14393 |
|
14394 |
|
14395 |
|
14396 | var getRandomValues = typeof crypto != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != 'undefined' && typeof msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
14397 | var rnds8 = new Uint8Array(16);
|
14398 |
|
14399 | function rng() {
|
14400 | if (!getRandomValues) {
|
14401 | throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
14402 | }
|
14403 |
|
14404 | return getRandomValues(rnds8);
|
14405 | }
|
14406 |
|
14407 |
|
14408 |
|
14409 |
|
14410 |
|
14411 | var byteToHex = [];
|
14412 |
|
14413 | for (var i$1 = 0; i$1 < 256; ++i$1) {
|
14414 | byteToHex[i$1] = (i$1 + 0x100).toString(16).substr(1);
|
14415 | }
|
14416 |
|
14417 | function bytesToUuid(buf, offset) {
|
14418 | var i = offset || 0;
|
14419 | var bth = byteToHex;
|
14420 |
|
14421 | return [bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]]].join('');
|
14422 | }
|
14423 |
|
14424 | function uuidToBytes(uuid) {
|
14425 |
|
14426 | var bytes = [];
|
14427 | uuid.replace(/[a-fA-F0-9]{2}/g, function (hex) {
|
14428 | bytes.push(parseInt(hex, 16));
|
14429 | });
|
14430 | return bytes;
|
14431 | }
|
14432 |
|
14433 | function stringToBytes(str) {
|
14434 | str = unescape(encodeURIComponent(str));
|
14435 |
|
14436 | var bytes = new Array(str.length);
|
14437 |
|
14438 | for (var i = 0; i < str.length; i++) {
|
14439 | bytes[i] = str.charCodeAt(i);
|
14440 | }
|
14441 |
|
14442 | return bytes;
|
14443 | }
|
14444 |
|
14445 | var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
14446 | var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
14447 | function v35 (name, version, hashfunc) {
|
14448 | var generateUUID = function generateUUID(value, namespace, buf, offset) {
|
14449 | var off = buf && offset || 0;
|
14450 | if (typeof value == 'string') value = stringToBytes(value);
|
14451 | if (typeof namespace == 'string') namespace = uuidToBytes(namespace);
|
14452 | if (!Array.isArray(value)) throw TypeError('value must be an array of bytes');
|
14453 | if (!Array.isArray(namespace) || namespace.length !== 16) throw TypeError('namespace must be uuid string or an Array of 16 byte values');
|
14454 |
|
14455 | var bytes = hashfunc(namespace.concat(value));
|
14456 | bytes[6] = bytes[6] & 0x0f | version;
|
14457 | bytes[8] = bytes[8] & 0x3f | 0x80;
|
14458 |
|
14459 | if (buf) {
|
14460 | for (var idx = 0; idx < 16; ++idx) {
|
14461 | buf[off + idx] = bytes[idx];
|
14462 | }
|
14463 | }
|
14464 |
|
14465 | return buf || bytesToUuid(bytes);
|
14466 | };
|
14467 |
|
14468 |
|
14469 | try {
|
14470 | generateUUID.name = name;
|
14471 | } catch (err) {}
|
14472 |
|
14473 |
|
14474 | generateUUID.DNS = DNS;
|
14475 | generateUUID.URL = URL;
|
14476 | return generateUUID;
|
14477 | }
|
14478 |
|
14479 |
|
14480 |
|
14481 |
|
14482 |
|
14483 |
|
14484 |
|
14485 |
|
14486 |
|
14487 |
|
14488 |
|
14489 |
|
14490 |
|
14491 |
|
14492 |
|
14493 |
|
14494 |
|
14495 |
|
14496 |
|
14497 |
|
14498 |
|
14499 | function md5(bytes) {
|
14500 | if (typeof bytes == 'string') {
|
14501 | var msg = unescape(encodeURIComponent(bytes));
|
14502 |
|
14503 | bytes = new Array(msg.length);
|
14504 |
|
14505 | for (var i = 0; i < msg.length; i++) {
|
14506 | bytes[i] = msg.charCodeAt(i);
|
14507 | }
|
14508 | }
|
14509 |
|
14510 | return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
|
14511 | }
|
14512 |
|
14513 |
|
14514 |
|
14515 |
|
14516 |
|
14517 | function md5ToHexEncodedArray(input) {
|
14518 | var i;
|
14519 | var x;
|
14520 | var output = [];
|
14521 | var length32 = input.length * 32;
|
14522 | var hexTab = '0123456789abcdef';
|
14523 | var hex;
|
14524 |
|
14525 | for (i = 0; i < length32; i += 8) {
|
14526 | x = input[i >> 5] >>> i % 32 & 0xff;
|
14527 | hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
|
14528 | output.push(hex);
|
14529 | }
|
14530 |
|
14531 | return output;
|
14532 | }
|
14533 |
|
14534 |
|
14535 |
|
14536 |
|
14537 |
|
14538 | function wordsToMd5(x, len) {
|
14539 |
|
14540 | x[len >> 5] |= 0x80 << len % 32;
|
14541 | x[(len + 64 >>> 9 << 4) + 14] = len;
|
14542 | var i;
|
14543 | var olda;
|
14544 | var oldb;
|
14545 | var oldc;
|
14546 | var oldd;
|
14547 | var a = 1732584193;
|
14548 | var b = -271733879;
|
14549 | var c = -1732584194;
|
14550 | var d = 271733878;
|
14551 |
|
14552 | for (i = 0; i < x.length; i += 16) {
|
14553 | olda = a;
|
14554 | oldb = b;
|
14555 | oldc = c;
|
14556 | oldd = d;
|
14557 | a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
14558 | d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
14559 | c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
14560 | b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
14561 | a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
14562 | d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
14563 | c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
14564 | b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
14565 | a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
14566 | d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
14567 | c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
14568 | b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
14569 | a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
14570 | d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
14571 | c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
14572 | b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
14573 | a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
14574 | d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
14575 | c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
14576 | b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
14577 | a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
14578 | d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
14579 | c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
14580 | b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
14581 | a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
14582 | d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
14583 | c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
14584 | b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
14585 | a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
14586 | d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
14587 | c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
14588 | b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
14589 | a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
14590 | d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
14591 | c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
14592 | b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
14593 | a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
14594 | d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
14595 | c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
14596 | b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
14597 | a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
14598 | d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
14599 | c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
14600 | b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
14601 | a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
14602 | d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
14603 | c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
14604 | b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
14605 | a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
14606 | d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
14607 | c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
14608 | b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
14609 | a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
14610 | d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
14611 | c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
14612 | b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
14613 | a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
14614 | d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
14615 | c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
14616 | b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
14617 | a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
14618 | d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
14619 | c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
14620 | b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
14621 | a = safeAdd(a, olda);
|
14622 | b = safeAdd(b, oldb);
|
14623 | c = safeAdd(c, oldc);
|
14624 | d = safeAdd(d, oldd);
|
14625 | }
|
14626 |
|
14627 | return [a, b, c, d];
|
14628 | }
|
14629 |
|
14630 |
|
14631 |
|
14632 |
|
14633 |
|
14634 |
|
14635 | function bytesToWords(input) {
|
14636 | var i;
|
14637 | var output = [];
|
14638 | output[(input.length >> 2) - 1] = undefined;
|
14639 |
|
14640 | for (i = 0; i < output.length; i += 1) {
|
14641 | output[i] = 0;
|
14642 | }
|
14643 |
|
14644 | var length8 = input.length * 8;
|
14645 |
|
14646 | for (i = 0; i < length8; i += 8) {
|
14647 | output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
|
14648 | }
|
14649 |
|
14650 | return output;
|
14651 | }
|
14652 |
|
14653 |
|
14654 |
|
14655 |
|
14656 |
|
14657 |
|
14658 | function safeAdd(x, y) {
|
14659 | var lsw = (x & 0xffff) + (y & 0xffff);
|
14660 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
14661 | return msw << 16 | lsw & 0xffff;
|
14662 | }
|
14663 |
|
14664 |
|
14665 |
|
14666 |
|
14667 |
|
14668 | function bitRotateLeft(num, cnt) {
|
14669 | return num << cnt | num >>> 32 - cnt;
|
14670 | }
|
14671 |
|
14672 |
|
14673 |
|
14674 |
|
14675 |
|
14676 | function md5cmn(q, a, b, x, s, t) {
|
14677 | return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
14678 | }
|
14679 |
|
14680 | function md5ff(a, b, c, d, x, s, t) {
|
14681 | return md5cmn(b & c | ~b & d, a, b, x, s, t);
|
14682 | }
|
14683 |
|
14684 | function md5gg(a, b, c, d, x, s, t) {
|
14685 | return md5cmn(b & d | c & ~d, a, b, x, s, t);
|
14686 | }
|
14687 |
|
14688 | function md5hh(a, b, c, d, x, s, t) {
|
14689 | return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
14690 | }
|
14691 |
|
14692 | function md5ii(a, b, c, d, x, s, t) {
|
14693 | return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
14694 | }
|
14695 |
|
14696 | v35('v3', 0x30, md5);
|
14697 |
|
14698 | function v4(options, buf, offset) {
|
14699 | var i = buf && offset || 0;
|
14700 |
|
14701 | if (typeof options == 'string') {
|
14702 | buf = options === 'binary' ? new Array(16) : null;
|
14703 | options = null;
|
14704 | }
|
14705 |
|
14706 | options = options || {};
|
14707 | var rnds = options.random || (options.rng || rng)();
|
14708 |
|
14709 | rnds[6] = rnds[6] & 0x0f | 0x40;
|
14710 | rnds[8] = rnds[8] & 0x3f | 0x80;
|
14711 |
|
14712 | if (buf) {
|
14713 | for (var ii = 0; ii < 16; ++ii) {
|
14714 | buf[i + ii] = rnds[ii];
|
14715 | }
|
14716 | }
|
14717 |
|
14718 | return buf || bytesToUuid(rnds);
|
14719 | }
|
14720 |
|
14721 |
|
14722 |
|
14723 | function f(s, x, y, z) {
|
14724 | switch (s) {
|
14725 | case 0:
|
14726 | return x & y ^ ~x & z;
|
14727 |
|
14728 | case 1:
|
14729 | return x ^ y ^ z;
|
14730 |
|
14731 | case 2:
|
14732 | return x & y ^ x & z ^ y & z;
|
14733 |
|
14734 | case 3:
|
14735 | return x ^ y ^ z;
|
14736 | }
|
14737 | }
|
14738 |
|
14739 | function ROTL(x, n) {
|
14740 | return x << n | x >>> 32 - n;
|
14741 | }
|
14742 |
|
14743 | function sha1(bytes) {
|
14744 | var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
14745 | var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
14746 |
|
14747 | if (typeof bytes == 'string') {
|
14748 | var msg = unescape(encodeURIComponent(bytes));
|
14749 |
|
14750 | bytes = new Array(msg.length);
|
14751 |
|
14752 | for (var i = 0; i < msg.length; i++) {
|
14753 | bytes[i] = msg.charCodeAt(i);
|
14754 | }
|
14755 | }
|
14756 |
|
14757 | bytes.push(0x80);
|
14758 | var l = bytes.length / 4 + 2;
|
14759 | var N = Math.ceil(l / 16);
|
14760 | var M = new Array(N);
|
14761 |
|
14762 | for (var i = 0; i < N; i++) {
|
14763 | M[i] = new Array(16);
|
14764 |
|
14765 | for (var j = 0; j < 16; j++) {
|
14766 | M[i][j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
|
14767 | }
|
14768 | }
|
14769 |
|
14770 | M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
14771 | M[N - 1][14] = Math.floor(M[N - 1][14]);
|
14772 | M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
14773 |
|
14774 | for (var i = 0; i < N; i++) {
|
14775 | var W = new Array(80);
|
14776 |
|
14777 | for (var t = 0; t < 16; t++) {
|
14778 | W[t] = M[i][t];
|
14779 | }
|
14780 |
|
14781 | for (var t = 16; t < 80; t++) {
|
14782 | W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
14783 | }
|
14784 |
|
14785 | var a = H[0];
|
14786 | var b = H[1];
|
14787 | var c = H[2];
|
14788 | var d = H[3];
|
14789 | var e = H[4];
|
14790 |
|
14791 | for (var t = 0; t < 80; t++) {
|
14792 | var s = Math.floor(t / 20);
|
14793 | var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
14794 | e = d;
|
14795 | d = c;
|
14796 | c = ROTL(b, 30) >>> 0;
|
14797 | b = a;
|
14798 | a = T;
|
14799 | }
|
14800 |
|
14801 | H[0] = H[0] + a >>> 0;
|
14802 | H[1] = H[1] + b >>> 0;
|
14803 | H[2] = H[2] + c >>> 0;
|
14804 | H[3] = H[3] + d >>> 0;
|
14805 | H[4] = H[4] + e >>> 0;
|
14806 | }
|
14807 |
|
14808 | return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
|
14809 | }
|
14810 |
|
14811 | v35('v5', 0x50, sha1);
|
14812 |
|
14813 | function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14814 |
|
14815 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context8, _context9; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context9 = ownKeys(Object(source))).call(_context9, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14816 |
|
14817 |
|
14818 |
|
14819 |
|
14820 |
|
14821 | function isDataViewLike(obj) {
|
14822 | var _obj$idProp;
|
14823 |
|
14824 | if (!obj) {
|
14825 | return false;
|
14826 | }
|
14827 |
|
14828 | var idProp = (_obj$idProp = obj.idProp) !== null && _obj$idProp !== void 0 ? _obj$idProp : obj._idProp;
|
14829 |
|
14830 | if (!idProp) {
|
14831 | return false;
|
14832 | }
|
14833 |
|
14834 | return isDataViewLike$1(idProp, obj);
|
14835 | }
|
14836 |
|
14837 |
|
14838 |
|
14839 | var ASPDateRegex = /^\/?Date\((-?\d+)/i;
|
14840 | var NumericRegex = /^\d+$/;
|
14841 |
|
14842 |
|
14843 |
|
14844 |
|
14845 |
|
14846 |
|
14847 |
|
14848 |
|
14849 |
|
14850 |
|
14851 | function convert(object, type) {
|
14852 | var match;
|
14853 |
|
14854 | if (object === undefined) {
|
14855 | return undefined;
|
14856 | }
|
14857 |
|
14858 | if (object === null) {
|
14859 | return null;
|
14860 | }
|
14861 |
|
14862 | if (!type) {
|
14863 | return object;
|
14864 | }
|
14865 |
|
14866 | if (!(typeof type === "string") && !(type instanceof String)) {
|
14867 | throw new Error("Type must be a string");
|
14868 | }
|
14869 |
|
14870 |
|
14871 | switch (type) {
|
14872 | case "boolean":
|
14873 | case "Boolean":
|
14874 | return Boolean(object);
|
14875 |
|
14876 | case "number":
|
14877 | case "Number":
|
14878 | if (isString(object) && !isNaN(Date.parse(object))) {
|
14879 | return moment$3(object).valueOf();
|
14880 | } else {
|
14881 |
|
14882 |
|
14883 |
|
14884 | return Number(object.valueOf());
|
14885 | }
|
14886 |
|
14887 | case "string":
|
14888 | case "String":
|
14889 | return String(object);
|
14890 |
|
14891 | case "Date":
|
14892 | try {
|
14893 | return convert(object, "Moment").toDate();
|
14894 | } catch (e) {
|
14895 | if (e instanceof TypeError) {
|
14896 | throw new TypeError("Cannot convert object of type " + getType(object) + " to type " + type);
|
14897 | } else {
|
14898 | throw e;
|
14899 | }
|
14900 | }
|
14901 |
|
14902 | case "Moment":
|
14903 | if (isNumber(object)) {
|
14904 | return moment$3(object);
|
14905 | }
|
14906 |
|
14907 | if (object instanceof Date) {
|
14908 | return moment$3(object.valueOf());
|
14909 | } else if (moment$3.isMoment(object)) {
|
14910 | return moment$3(object);
|
14911 | }
|
14912 |
|
14913 | if (isString(object)) {
|
14914 | match = ASPDateRegex.exec(object);
|
14915 |
|
14916 | if (match) {
|
14917 |
|
14918 | return moment$3(Number(match[1]));
|
14919 | }
|
14920 |
|
14921 | match = NumericRegex.exec(object);
|
14922 |
|
14923 | if (match) {
|
14924 | return moment$3(Number(object));
|
14925 | }
|
14926 |
|
14927 | return moment$3(object);
|
14928 | } else {
|
14929 | throw new TypeError("Cannot convert object of type " + getType(object) + " to type " + type);
|
14930 | }
|
14931 |
|
14932 | case "ISODate":
|
14933 | if (isNumber(object)) {
|
14934 | return new Date(object);
|
14935 | } else if (object instanceof Date) {
|
14936 | return object.toISOString();
|
14937 | } else if (moment$3.isMoment(object)) {
|
14938 | return object.toDate().toISOString();
|
14939 | } else if (isString(object)) {
|
14940 | match = ASPDateRegex.exec(object);
|
14941 |
|
14942 | if (match) {
|
14943 |
|
14944 | return new Date(Number(match[1])).toISOString();
|
14945 | } else {
|
14946 | return moment$3(object).format();
|
14947 | }
|
14948 | } else {
|
14949 | throw new Error("Cannot convert object of type " + getType(object) + " to type ISODate");
|
14950 | }
|
14951 |
|
14952 | case "ASPDate":
|
14953 | if (isNumber(object)) {
|
14954 | return "/Date(" + object + ")/";
|
14955 | } else if (object instanceof Date || moment$3.isMoment(object)) {
|
14956 | return "/Date(" + object.valueOf() + ")/";
|
14957 | } else if (isString(object)) {
|
14958 | match = ASPDateRegex.exec(object);
|
14959 | var value;
|
14960 |
|
14961 | if (match) {
|
14962 |
|
14963 | value = new Date(Number(match[1])).valueOf();
|
14964 | } else {
|
14965 | value = new Date(object).valueOf();
|
14966 | }
|
14967 |
|
14968 | return "/Date(" + value + ")/";
|
14969 | } else {
|
14970 | throw new Error("Cannot convert object of type " + getType(object) + " to type ASPDate");
|
14971 | }
|
14972 |
|
14973 | default:
|
14974 | throw new Error("Unknown type ".concat(type));
|
14975 | }
|
14976 | }
|
14977 |
|
14978 |
|
14979 |
|
14980 |
|
14981 |
|
14982 |
|
14983 |
|
14984 |
|
14985 |
|
14986 |
|
14987 |
|
14988 |
|
14989 |
|
14990 |
|
14991 |
|
14992 |
|
14993 |
|
14994 |
|
14995 |
|
14996 |
|
14997 |
|
14998 |
|
14999 |
|
15000 |
|
15001 |
|
15002 |
|
15003 |
|
15004 | function typeCoerceDataSet(rawDS) {
|
15005 | var _context, _context3, _context4, _context5, _context6, _context7;
|
15006 |
|
15007 | var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
15008 | start: "Date",
|
15009 | end: "Date"
|
15010 | };
|
15011 | var idProp = rawDS._idProp;
|
15012 | var coercedDS = new DataSet({
|
15013 | fieldId: idProp
|
15014 | });
|
15015 |
|
15016 | var pipe = _mapInstanceProperty(_context = createNewDataPipeFrom(rawDS)).call(_context, function (item) {
|
15017 | var _context2;
|
15018 |
|
15019 | return _reduceInstanceProperty(_context2 = _Object$keys(item)).call(_context2, function (acc, key) {
|
15020 | acc[key] = convert(item[key], type[key]);
|
15021 | return acc;
|
15022 | }, {});
|
15023 | }).to(coercedDS);
|
15024 |
|
15025 | pipe.all().start();
|
15026 | return {
|
15027 |
|
15028 | add: function add() {
|
15029 | var _rawDS$getDataSet;
|
15030 |
|
15031 | return (_rawDS$getDataSet = rawDS.getDataSet()).add.apply(_rawDS$getDataSet, arguments);
|
15032 | },
|
15033 | remove: function remove() {
|
15034 | var _rawDS$getDataSet2;
|
15035 |
|
15036 | return (_rawDS$getDataSet2 = rawDS.getDataSet()).remove.apply(_rawDS$getDataSet2, arguments);
|
15037 | },
|
15038 | update: function update() {
|
15039 | var _rawDS$getDataSet3;
|
15040 |
|
15041 | return (_rawDS$getDataSet3 = rawDS.getDataSet()).update.apply(_rawDS$getDataSet3, arguments);
|
15042 | },
|
15043 | updateOnly: function updateOnly() {
|
15044 | var _rawDS$getDataSet4;
|
15045 |
|
15046 | return (_rawDS$getDataSet4 = rawDS.getDataSet()).updateOnly.apply(_rawDS$getDataSet4, arguments);
|
15047 | },
|
15048 | clear: function clear() {
|
15049 | var _rawDS$getDataSet5;
|
15050 |
|
15051 | return (_rawDS$getDataSet5 = rawDS.getDataSet()).clear.apply(_rawDS$getDataSet5, arguments);
|
15052 | },
|
15053 |
|
15054 | forEach: _bindInstanceProperty(_context3 = _forEachInstanceProperty(coercedDS)).call(_context3, coercedDS),
|
15055 | get: _bindInstanceProperty(_context4 = coercedDS.get).call(_context4, coercedDS),
|
15056 | getIds: _bindInstanceProperty(_context5 = coercedDS.getIds).call(_context5, coercedDS),
|
15057 | off: _bindInstanceProperty(_context6 = coercedDS.off).call(_context6, coercedDS),
|
15058 | on: _bindInstanceProperty(_context7 = coercedDS.on).call(_context7, coercedDS),
|
15059 |
|
15060 | get length() {
|
15061 | return coercedDS.length;
|
15062 | },
|
15063 |
|
15064 |
|
15065 | idProp: idProp,
|
15066 | type: type,
|
15067 | rawDS: rawDS,
|
15068 | coercedDS: coercedDS,
|
15069 | dispose: function dispose() {
|
15070 | return pipe.stop();
|
15071 | }
|
15072 | };
|
15073 | }
|
15074 |
|
15075 | var setupXSSCleaner = function setupXSSCleaner(options) {
|
15076 | var customXSS = new xssFilter.FilterXSS(options);
|
15077 | return function (string) {
|
15078 | return customXSS.process(string);
|
15079 | };
|
15080 | };
|
15081 |
|
15082 | var setupNoOpCleaner = function setupNoOpCleaner(string) {
|
15083 | return string;
|
15084 | };
|
15085 |
|
15086 |
|
15087 | var configuredXSSProtection = setupXSSCleaner();
|
15088 |
|
15089 | var setupXSSProtection = function setupXSSProtection(options) {
|
15090 |
|
15091 | if (!options) {
|
15092 | return;
|
15093 | }
|
15094 |
|
15095 |
|
15096 | if (options.disabled === true) {
|
15097 | configuredXSSProtection = setupNoOpCleaner;
|
15098 | console.warn('You disabled XSS protection for vis-Timeline. I sure hope you know what you\'re doing!');
|
15099 | } else {
|
15100 |
|
15101 |
|
15102 |
|
15103 | if (options.filterOptions) {
|
15104 | configuredXSSProtection = setupXSSCleaner(options.filterOptions);
|
15105 | }
|
15106 | }
|
15107 | };
|
15108 |
|
15109 | var availableUtils = _objectSpread(_objectSpread({}, util$2), {}, {
|
15110 | convert: convert,
|
15111 | setupXSSProtection: setupXSSProtection
|
15112 | });
|
15113 |
|
15114 | _Object$defineProperty(availableUtils, 'xss', {
|
15115 | get: function get() {
|
15116 | return configuredXSSProtection;
|
15117 | }
|
15118 | });
|
15119 |
|
15120 | var _parseFloat$3 = {exports: {}};
|
15121 |
|
15122 | var global$5 = global$N;
|
15123 | var fails$5 = fails$s;
|
15124 | var uncurryThis$2 = functionUncurryThis;
|
15125 | var toString$2 = toString$9;
|
15126 | var trim = stringTrim.trim;
|
15127 | var whitespaces = whitespaces$4;
|
15128 | var charAt = uncurryThis$2(''.charAt);
|
15129 | var n$ParseFloat = global$5.parseFloat;
|
15130 | var Symbol$1 = global$5.Symbol;
|
15131 | var ITERATOR = Symbol$1 && Symbol$1.iterator;
|
15132 | var FORCED$1 = 1 / n$ParseFloat(whitespaces + '-0') !== -Infinity
|
15133 | || ITERATOR && !fails$5(function () {
|
15134 | n$ParseFloat(Object(ITERATOR));
|
15135 | });
|
15136 |
|
15137 |
|
15138 | var numberParseFloat = FORCED$1 ? function parseFloat(string) {
|
15139 | var trimmedString = trim(toString$2(string));
|
15140 | var result = n$ParseFloat(trimmedString);
|
15141 | return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
|
15142 | } : n$ParseFloat;
|
15143 |
|
15144 | var $$8 = _export;
|
15145 | var $parseFloat = numberParseFloat;
|
15146 |
|
15147 |
|
15148 | $$8({
|
15149 | global: true,
|
15150 | forced: parseFloat != $parseFloat
|
15151 | }, {
|
15152 | parseFloat: $parseFloat
|
15153 | });
|
15154 |
|
15155 | var path$2 = path$r;
|
15156 | var _parseFloat$2 = path$2.parseFloat;
|
15157 |
|
15158 | var parent$7 = _parseFloat$2;
|
15159 | var _parseFloat$1 = parent$7;
|
15160 |
|
15161 | (function (module) {
|
15162 | module.exports = _parseFloat$1;
|
15163 | })(_parseFloat$3);
|
15164 |
|
15165 | var _parseFloat = getDefaultExportFromCjs(_parseFloat$3.exports);
|
15166 |
|
15167 |
|
15168 |
|
15169 | var Component = function () {
|
15170 | |
15171 |
|
15172 |
|
15173 |
|
15174 | function Component(body, options) {
|
15175 | _classCallCheck(this, Component);
|
15176 |
|
15177 |
|
15178 | this.options = null;
|
15179 | this.props = null;
|
15180 | }
|
15181 | |
15182 |
|
15183 |
|
15184 |
|
15185 |
|
15186 |
|
15187 |
|
15188 | _createClass(Component, [{
|
15189 | key: "setOptions",
|
15190 | value: function setOptions(options) {
|
15191 | if (options) {
|
15192 | availableUtils.extend(this.options, options);
|
15193 | }
|
15194 | }
|
15195 | |
15196 |
|
15197 |
|
15198 |
|
15199 |
|
15200 | }, {
|
15201 | key: "redraw",
|
15202 | value: function redraw() {
|
15203 |
|
15204 | return false;
|
15205 | }
|
15206 | |
15207 |
|
15208 |
|
15209 |
|
15210 | }, {
|
15211 | key: "destroy",
|
15212 | value: function destroy() {
|
15213 | }
|
15214 | |
15215 |
|
15216 |
|
15217 |
|
15218 |
|
15219 |
|
15220 |
|
15221 | }, {
|
15222 | key: "_isResized",
|
15223 | value: function _isResized() {
|
15224 | var resized = this.props._previousWidth !== this.props.width || this.props._previousHeight !== this.props.height;
|
15225 | this.props._previousWidth = this.props.width;
|
15226 | this.props._previousHeight = this.props.height;
|
15227 | return resized;
|
15228 | }
|
15229 | }]);
|
15230 |
|
15231 | return Component;
|
15232 | }();
|
15233 |
|
15234 | var repeat$4 = {exports: {}};
|
15235 |
|
15236 | var global$4 = global$N;
|
15237 | var toIntegerOrInfinity = toIntegerOrInfinity$5;
|
15238 | var toString$1 = toString$9;
|
15239 | var requireObjectCoercible = requireObjectCoercible$6;
|
15240 | var RangeError = global$4.RangeError;
|
15241 |
|
15242 |
|
15243 | var stringRepeat = function repeat(count) {
|
15244 | var str = toString$1(requireObjectCoercible(this));
|
15245 | var result = '';
|
15246 | var n = toIntegerOrInfinity(count);
|
15247 | if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
|
15248 |
|
15249 | for (; n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
|
15250 |
|
15251 | return result;
|
15252 | };
|
15253 |
|
15254 | var $$7 = _export;
|
15255 | var repeat$3 = stringRepeat;
|
15256 |
|
15257 |
|
15258 | $$7({
|
15259 | target: 'String',
|
15260 | proto: true
|
15261 | }, {
|
15262 | repeat: repeat$3
|
15263 | });
|
15264 |
|
15265 | var entryVirtual$5 = entryVirtual$k;
|
15266 | var repeat$2 = entryVirtual$5('String').repeat;
|
15267 |
|
15268 | var isPrototypeOf$7 = objectIsPrototypeOf;
|
15269 | var method$5 = repeat$2;
|
15270 | var StringPrototype = String.prototype;
|
15271 |
|
15272 | var repeat$1 = function (it) {
|
15273 | var own = it.repeat;
|
15274 | return typeof it == 'string' || it === StringPrototype || isPrototypeOf$7(StringPrototype, it) && own === StringPrototype.repeat ? method$5 : own;
|
15275 | };
|
15276 |
|
15277 | var parent$6 = repeat$1;
|
15278 | var repeat = parent$6;
|
15279 |
|
15280 | (function (module) {
|
15281 | module.exports = repeat;
|
15282 | })(repeat$4);
|
15283 |
|
15284 | var _repeatInstanceProperty = getDefaultExportFromCjs(repeat$4.exports);
|
15285 |
|
15286 | var sort$3 = {exports: {}};
|
15287 |
|
15288 | var arraySlice = arraySliceSimple;
|
15289 | var floor = Math.floor;
|
15290 |
|
15291 | var mergeSort = function (array, comparefn) {
|
15292 | var length = array.length;
|
15293 | var middle = floor(length / 2);
|
15294 | return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySlice(array, 0, middle), comparefn), mergeSort(arraySlice(array, middle), comparefn), comparefn);
|
15295 | };
|
15296 |
|
15297 | var insertionSort = function (array, comparefn) {
|
15298 | var length = array.length;
|
15299 | var i = 1;
|
15300 | var element, j;
|
15301 |
|
15302 | while (i < length) {
|
15303 | j = i;
|
15304 | element = array[i];
|
15305 |
|
15306 | while (j && comparefn(array[j - 1], element) > 0) {
|
15307 | array[j] = array[--j];
|
15308 | }
|
15309 |
|
15310 | if (j !== i++) array[j] = element;
|
15311 | }
|
15312 |
|
15313 | return array;
|
15314 | };
|
15315 |
|
15316 | var merge = function (array, left, right, comparefn) {
|
15317 | var llength = left.length;
|
15318 | var rlength = right.length;
|
15319 | var lindex = 0;
|
15320 | var rindex = 0;
|
15321 |
|
15322 | while (lindex < llength || rindex < rlength) {
|
15323 | array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++];
|
15324 | }
|
15325 |
|
15326 | return array;
|
15327 | };
|
15328 |
|
15329 | var arraySort = mergeSort;
|
15330 |
|
15331 | var userAgent$1 = engineUserAgent;
|
15332 | var firefox = userAgent$1.match(/firefox\/(\d+)/i);
|
15333 | var engineFfVersion = !!firefox && +firefox[1];
|
15334 |
|
15335 | var UA = engineUserAgent;
|
15336 | var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
|
15337 |
|
15338 | var userAgent = engineUserAgent;
|
15339 | var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
|
15340 | var engineWebkitVersion = !!webkit && +webkit[1];
|
15341 |
|
15342 | var $$6 = _export;
|
15343 | var uncurryThis$1 = functionUncurryThis;
|
15344 | var aCallable = aCallable$6;
|
15345 | var toObject = toObject$d;
|
15346 | var lengthOfArrayLike$1 = lengthOfArrayLike$b;
|
15347 | var toString = toString$9;
|
15348 | var fails$4 = fails$s;
|
15349 | var internalSort = arraySort;
|
15350 | var arrayMethodIsStrict$2 = arrayMethodIsStrict$6;
|
15351 | var FF = engineFfVersion;
|
15352 | var IE_OR_EDGE = engineIsIeOrEdge;
|
15353 | var V8 = engineV8Version;
|
15354 | var WEBKIT = engineWebkitVersion;
|
15355 | var test = [];
|
15356 | var un$Sort = uncurryThis$1(test.sort);
|
15357 | var push = uncurryThis$1(test.push);
|
15358 |
|
15359 | var FAILS_ON_UNDEFINED = fails$4(function () {
|
15360 | test.sort(undefined);
|
15361 | });
|
15362 |
|
15363 | var FAILS_ON_NULL = fails$4(function () {
|
15364 | test.sort(null);
|
15365 | });
|
15366 |
|
15367 | var STRICT_METHOD$2 = arrayMethodIsStrict$2('sort');
|
15368 | var STABLE_SORT = !fails$4(function () {
|
15369 |
|
15370 | if (V8) return V8 < 70;
|
15371 | if (FF && FF > 3) return;
|
15372 | if (IE_OR_EDGE) return true;
|
15373 | if (WEBKIT) return WEBKIT < 603;
|
15374 | var result = '';
|
15375 | var code, chr, value, index;
|
15376 |
|
15377 | for (code = 65; code < 76; code++) {
|
15378 | chr = String.fromCharCode(code);
|
15379 |
|
15380 | switch (code) {
|
15381 | case 66:
|
15382 | case 69:
|
15383 | case 70:
|
15384 | case 72:
|
15385 | value = 3;
|
15386 | break;
|
15387 |
|
15388 | case 68:
|
15389 | case 71:
|
15390 | value = 4;
|
15391 | break;
|
15392 |
|
15393 | default:
|
15394 | value = 2;
|
15395 | }
|
15396 |
|
15397 | for (index = 0; index < 47; index++) {
|
15398 | test.push({
|
15399 | k: chr + index,
|
15400 | v: value
|
15401 | });
|
15402 | }
|
15403 | }
|
15404 |
|
15405 | test.sort(function (a, b) {
|
15406 | return b.v - a.v;
|
15407 | });
|
15408 |
|
15409 | for (index = 0; index < test.length; index++) {
|
15410 | chr = test[index].k.charAt(0);
|
15411 | if (result.charAt(result.length - 1) !== chr) result += chr;
|
15412 | }
|
15413 |
|
15414 | return result !== 'DGBEFHACIJK';
|
15415 | });
|
15416 | var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD$2 || !STABLE_SORT;
|
15417 |
|
15418 | var getSortCompare = function (comparefn) {
|
15419 | return function (x, y) {
|
15420 | if (y === undefined) return -1;
|
15421 | if (x === undefined) return 1;
|
15422 | if (comparefn !== undefined) return +comparefn(x, y) || 0;
|
15423 | return toString(x) > toString(y) ? 1 : -1;
|
15424 | };
|
15425 | };
|
15426 |
|
15427 |
|
15428 |
|
15429 | $$6({
|
15430 | target: 'Array',
|
15431 | proto: true,
|
15432 | forced: FORCED
|
15433 | }, {
|
15434 | sort: function sort(comparefn) {
|
15435 | if (comparefn !== undefined) aCallable(comparefn);
|
15436 | var array = toObject(this);
|
15437 | if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
|
15438 | var items = [];
|
15439 | var arrayLength = lengthOfArrayLike$1(array);
|
15440 | var itemsLength, index;
|
15441 |
|
15442 | for (index = 0; index < arrayLength; index++) {
|
15443 | if (index in array) push(items, array[index]);
|
15444 | }
|
15445 |
|
15446 | internalSort(items, getSortCompare(comparefn));
|
15447 | itemsLength = items.length;
|
15448 | index = 0;
|
15449 |
|
15450 | while (index < itemsLength) array[index] = items[index++];
|
15451 |
|
15452 | while (index < arrayLength) delete array[index++];
|
15453 |
|
15454 | return array;
|
15455 | }
|
15456 | });
|
15457 |
|
15458 | var entryVirtual$4 = entryVirtual$k;
|
15459 | var sort$2 = entryVirtual$4('Array').sort;
|
15460 |
|
15461 | var isPrototypeOf$6 = objectIsPrototypeOf;
|
15462 | var method$4 = sort$2;
|
15463 | var ArrayPrototype$4 = Array.prototype;
|
15464 |
|
15465 | var sort$1 = function (it) {
|
15466 | var own = it.sort;
|
15467 | return it === ArrayPrototype$4 || isPrototypeOf$6(ArrayPrototype$4, it) && own === ArrayPrototype$4.sort ? method$4 : own;
|
15468 | };
|
15469 |
|
15470 | var parent$5 = sort$1;
|
15471 | var sort = parent$5;
|
15472 |
|
15473 | (function (module) {
|
15474 | module.exports = sort;
|
15475 | })(sort$3);
|
15476 |
|
15477 | var _sortInstanceProperty = getDefaultExportFromCjs(sort$3.exports);
|
15478 |
|
15479 |
|
15480 |
|
15481 |
|
15482 |
|
15483 |
|
15484 |
|
15485 |
|
15486 |
|
15487 | function convertHiddenOptions(moment, body, hiddenDates) {
|
15488 | if (hiddenDates && !_Array$isArray$1(hiddenDates)) {
|
15489 | return convertHiddenOptions(moment, body, [hiddenDates]);
|
15490 | }
|
15491 |
|
15492 | body.hiddenDates = [];
|
15493 |
|
15494 | if (hiddenDates) {
|
15495 | if (_Array$isArray$1(hiddenDates) == true) {
|
15496 | var _context;
|
15497 |
|
15498 | for (var i = 0; i < hiddenDates.length; i++) {
|
15499 | if (_repeatInstanceProperty(hiddenDates[i]) === undefined) {
|
15500 | var dateItem = {};
|
15501 | dateItem.start = moment(hiddenDates[i].start).toDate().valueOf();
|
15502 | dateItem.end = moment(hiddenDates[i].end).toDate().valueOf();
|
15503 | body.hiddenDates.push(dateItem);
|
15504 | }
|
15505 | }
|
15506 |
|
15507 | _sortInstanceProperty(_context = body.hiddenDates).call(_context, function (a, b) {
|
15508 | return a.start - b.start;
|
15509 | });
|
15510 |
|
15511 | }
|
15512 | }
|
15513 | }
|
15514 |
|
15515 |
|
15516 |
|
15517 |
|
15518 |
|
15519 |
|
15520 |
|
15521 |
|
15522 |
|
15523 | function updateHiddenDates(moment, body, hiddenDates) {
|
15524 | if (hiddenDates && !_Array$isArray$1(hiddenDates)) {
|
15525 | return updateHiddenDates(moment, body, [hiddenDates]);
|
15526 | }
|
15527 |
|
15528 | if (hiddenDates && body.domProps.centerContainer.width !== undefined) {
|
15529 | convertHiddenOptions(moment, body, hiddenDates);
|
15530 | var start = moment(body.range.start);
|
15531 | var end = moment(body.range.end);
|
15532 | var totalRange = body.range.end - body.range.start;
|
15533 | var pixelTime = totalRange / body.domProps.centerContainer.width;
|
15534 |
|
15535 | for (var i = 0; i < hiddenDates.length; i++) {
|
15536 | if (_repeatInstanceProperty(hiddenDates[i]) !== undefined) {
|
15537 | var startDate = moment(hiddenDates[i].start);
|
15538 | var endDate = moment(hiddenDates[i].end);
|
15539 |
|
15540 | if (startDate._d == "Invalid Date") {
|
15541 | throw new Error("Supplied start date is not valid: ".concat(hiddenDates[i].start));
|
15542 | }
|
15543 |
|
15544 | if (endDate._d == "Invalid Date") {
|
15545 | throw new Error("Supplied end date is not valid: ".concat(hiddenDates[i].end));
|
15546 | }
|
15547 |
|
15548 | var duration = endDate - startDate;
|
15549 |
|
15550 | if (duration >= 4 * pixelTime) {
|
15551 | var offset = 0;
|
15552 | var runUntil = end.clone();
|
15553 |
|
15554 | switch (_repeatInstanceProperty(hiddenDates[i])) {
|
15555 | case "daily":
|
15556 |
|
15557 | if (startDate.day() != endDate.day()) {
|
15558 | offset = 1;
|
15559 | }
|
15560 |
|
15561 | startDate.dayOfYear(start.dayOfYear());
|
15562 | startDate.year(start.year());
|
15563 | startDate.subtract(7, 'days');
|
15564 | endDate.dayOfYear(start.dayOfYear());
|
15565 | endDate.year(start.year());
|
15566 | endDate.subtract(7 - offset, 'days');
|
15567 | runUntil.add(1, 'weeks');
|
15568 | break;
|
15569 |
|
15570 | case "weekly":
|
15571 | {
|
15572 | var dayOffset = endDate.diff(startDate, 'days');
|
15573 | var day = startDate.day();
|
15574 |
|
15575 | startDate.date(start.date());
|
15576 | startDate.month(start.month());
|
15577 | startDate.year(start.year());
|
15578 | endDate = startDate.clone();
|
15579 |
|
15580 | startDate.day(day);
|
15581 | endDate.day(day);
|
15582 | endDate.add(dayOffset, 'days');
|
15583 | startDate.subtract(1, 'weeks');
|
15584 | endDate.subtract(1, 'weeks');
|
15585 | runUntil.add(1, 'weeks');
|
15586 | break;
|
15587 | }
|
15588 |
|
15589 | case "monthly":
|
15590 | if (startDate.month() != endDate.month()) {
|
15591 | offset = 1;
|
15592 | }
|
15593 |
|
15594 | startDate.month(start.month());
|
15595 | startDate.year(start.year());
|
15596 | startDate.subtract(1, 'months');
|
15597 | endDate.month(start.month());
|
15598 | endDate.year(start.year());
|
15599 | endDate.subtract(1, 'months');
|
15600 | endDate.add(offset, 'months');
|
15601 | runUntil.add(1, 'months');
|
15602 | break;
|
15603 |
|
15604 | case "yearly":
|
15605 | if (startDate.year() != endDate.year()) {
|
15606 | offset = 1;
|
15607 | }
|
15608 |
|
15609 | startDate.year(start.year());
|
15610 | startDate.subtract(1, 'years');
|
15611 | endDate.year(start.year());
|
15612 | endDate.subtract(1, 'years');
|
15613 | endDate.add(offset, 'years');
|
15614 | runUntil.add(1, 'years');
|
15615 | break;
|
15616 |
|
15617 | default:
|
15618 | console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", _repeatInstanceProperty(hiddenDates[i]));
|
15619 | return;
|
15620 | }
|
15621 |
|
15622 | while (startDate < runUntil) {
|
15623 | body.hiddenDates.push({
|
15624 | start: startDate.valueOf(),
|
15625 | end: endDate.valueOf()
|
15626 | });
|
15627 |
|
15628 | switch (_repeatInstanceProperty(hiddenDates[i])) {
|
15629 | case "daily":
|
15630 | startDate.add(1, 'days');
|
15631 | endDate.add(1, 'days');
|
15632 | break;
|
15633 |
|
15634 | case "weekly":
|
15635 | startDate.add(1, 'weeks');
|
15636 | endDate.add(1, 'weeks');
|
15637 | break;
|
15638 |
|
15639 | case "monthly":
|
15640 | startDate.add(1, 'months');
|
15641 | endDate.add(1, 'months');
|
15642 | break;
|
15643 |
|
15644 | case "yearly":
|
15645 | startDate.add(1, 'y');
|
15646 | endDate.add(1, 'y');
|
15647 | break;
|
15648 |
|
15649 | default:
|
15650 | console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", _repeatInstanceProperty(hiddenDates[i]));
|
15651 | return;
|
15652 | }
|
15653 | }
|
15654 |
|
15655 | body.hiddenDates.push({
|
15656 | start: startDate.valueOf(),
|
15657 | end: endDate.valueOf()
|
15658 | });
|
15659 | }
|
15660 | }
|
15661 | }
|
15662 |
|
15663 |
|
15664 | removeDuplicates(body);
|
15665 |
|
15666 | var startHidden = getIsHidden(body.range.start, body.hiddenDates);
|
15667 | var endHidden = getIsHidden(body.range.end, body.hiddenDates);
|
15668 | var rangeStart = body.range.start;
|
15669 | var rangeEnd = body.range.end;
|
15670 |
|
15671 | if (startHidden.hidden == true) {
|
15672 | rangeStart = body.range.startToFront == true ? startHidden.startDate - 1 : startHidden.endDate + 1;
|
15673 | }
|
15674 |
|
15675 | if (endHidden.hidden == true) {
|
15676 | rangeEnd = body.range.endToFront == true ? endHidden.startDate - 1 : endHidden.endDate + 1;
|
15677 | }
|
15678 |
|
15679 | if (startHidden.hidden == true || endHidden.hidden == true) {
|
15680 | body.range._applyRange(rangeStart, rangeEnd);
|
15681 | }
|
15682 | }
|
15683 | }
|
15684 |
|
15685 |
|
15686 |
|
15687 |
|
15688 |
|
15689 |
|
15690 |
|
15691 | function removeDuplicates(body) {
|
15692 | var _context2;
|
15693 |
|
15694 | var hiddenDates = body.hiddenDates;
|
15695 | var safeDates = [];
|
15696 |
|
15697 | for (var i = 0; i < hiddenDates.length; i++) {
|
15698 | for (var j = 0; j < hiddenDates.length; j++) {
|
15699 | if (i != j && hiddenDates[j].remove != true && hiddenDates[i].remove != true) {
|
15700 |
|
15701 | if (hiddenDates[j].start >= hiddenDates[i].start && hiddenDates[j].end <= hiddenDates[i].end) {
|
15702 | hiddenDates[j].remove = true;
|
15703 | }
|
15704 | else if (hiddenDates[j].start >= hiddenDates[i].start && hiddenDates[j].start <= hiddenDates[i].end) {
|
15705 | hiddenDates[i].end = hiddenDates[j].end;
|
15706 | hiddenDates[j].remove = true;
|
15707 | }
|
15708 | else if (hiddenDates[j].end >= hiddenDates[i].start && hiddenDates[j].end <= hiddenDates[i].end) {
|
15709 | hiddenDates[i].start = hiddenDates[j].start;
|
15710 | hiddenDates[j].remove = true;
|
15711 | }
|
15712 | }
|
15713 | }
|
15714 | }
|
15715 |
|
15716 | for (i = 0; i < hiddenDates.length; i++) {
|
15717 | if (hiddenDates[i].remove !== true) {
|
15718 | safeDates.push(hiddenDates[i]);
|
15719 | }
|
15720 | }
|
15721 |
|
15722 | body.hiddenDates = safeDates;
|
15723 |
|
15724 | _sortInstanceProperty(_context2 = body.hiddenDates).call(_context2, function (a, b) {
|
15725 | return a.start - b.start;
|
15726 | });
|
15727 |
|
15728 | }
|
15729 |
|
15730 |
|
15731 |
|
15732 |
|
15733 |
|
15734 | function printDates(dates) {
|
15735 | for (var i = 0; i < dates.length; i++) {
|
15736 | console.log(i, new Date(dates[i].start), new Date(dates[i].end), dates[i].start, dates[i].end, dates[i].remove);
|
15737 | }
|
15738 | }
|
15739 |
|
15740 |
|
15741 |
|
15742 |
|
15743 |
|
15744 |
|
15745 |
|
15746 | function stepOverHiddenDates(moment, timeStep, previousTime) {
|
15747 | var stepInHidden = false;
|
15748 | var currentValue = timeStep.current.valueOf();
|
15749 |
|
15750 | for (var i = 0; i < timeStep.hiddenDates.length; i++) {
|
15751 | var startDate = timeStep.hiddenDates[i].start;
|
15752 | var endDate = timeStep.hiddenDates[i].end;
|
15753 |
|
15754 | if (currentValue >= startDate && currentValue < endDate) {
|
15755 | stepInHidden = true;
|
15756 | break;
|
15757 | }
|
15758 | }
|
15759 |
|
15760 | if (stepInHidden == true && currentValue < timeStep._end.valueOf() && currentValue != previousTime) {
|
15761 | var prevValue = moment(previousTime);
|
15762 | var newValue = moment(endDate);
|
15763 |
|
15764 | if (prevValue.year() != newValue.year()) {
|
15765 | timeStep.switchedYear = true;
|
15766 | } else if (prevValue.month() != newValue.month()) {
|
15767 | timeStep.switchedMonth = true;
|
15768 | } else if (prevValue.dayOfYear() != newValue.dayOfYear()) {
|
15769 | timeStep.switchedDay = true;
|
15770 | }
|
15771 |
|
15772 | timeStep.current = newValue;
|
15773 | }
|
15774 | }
|
15775 |
|
15776 |
|
15777 |
|
15778 |
|
15779 |
|
15780 |
|
15781 |
|
15782 |
|
15783 |
|
15784 |
|
15785 |
|
15786 |
|
15787 |
|
15788 |
|
15789 |
|
15790 |
|
15791 |
|
15792 |
|
15793 |
|
15794 |
|
15795 |
|
15796 |
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 |
|
15802 |
|
15803 |
|
15804 |
|
15805 |
|
15806 | function toScreen(Core, time, width) {
|
15807 | var conversion;
|
15808 |
|
15809 | if (Core.body.hiddenDates.length == 0) {
|
15810 | conversion = Core.range.conversion(width);
|
15811 | return (time.valueOf() - conversion.offset) * conversion.scale;
|
15812 | } else {
|
15813 | var hidden = getIsHidden(time, Core.body.hiddenDates);
|
15814 |
|
15815 | if (hidden.hidden == true) {
|
15816 | time = hidden.startDate;
|
15817 | }
|
15818 |
|
15819 | var duration = getHiddenDurationBetween(Core.body.hiddenDates, Core.range.start, Core.range.end);
|
15820 |
|
15821 | if (time < Core.range.start) {
|
15822 | conversion = Core.range.conversion(width, duration);
|
15823 | var hiddenBeforeStart = getHiddenDurationBeforeStart(Core.body.hiddenDates, time, conversion.offset);
|
15824 | time = Core.options.moment(time).toDate().valueOf();
|
15825 | time = time + hiddenBeforeStart;
|
15826 | return -(conversion.offset - time.valueOf()) * conversion.scale;
|
15827 | } else if (time > Core.range.end) {
|
15828 | var rangeAfterEnd = {
|
15829 | start: Core.range.start,
|
15830 | end: time
|
15831 | };
|
15832 | time = correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, rangeAfterEnd, time);
|
15833 | conversion = Core.range.conversion(width, duration);
|
15834 | return (time.valueOf() - conversion.offset) * conversion.scale;
|
15835 | } else {
|
15836 | time = correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, Core.range, time);
|
15837 | conversion = Core.range.conversion(width, duration);
|
15838 | return (time.valueOf() - conversion.offset) * conversion.scale;
|
15839 | }
|
15840 | }
|
15841 | }
|
15842 |
|
15843 |
|
15844 |
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 |
|
15851 | function toTime(Core, x, width) {
|
15852 | if (Core.body.hiddenDates.length == 0) {
|
15853 | var conversion = Core.range.conversion(width);
|
15854 | return new Date(x / conversion.scale + conversion.offset);
|
15855 | } else {
|
15856 | var hiddenDuration = getHiddenDurationBetween(Core.body.hiddenDates, Core.range.start, Core.range.end);
|
15857 | var totalDuration = Core.range.end - Core.range.start - hiddenDuration;
|
15858 | var partialDuration = totalDuration * x / width;
|
15859 | var accumulatedHiddenDuration = getAccumulatedHiddenDuration(Core.body.hiddenDates, Core.range, partialDuration);
|
15860 | return new Date(accumulatedHiddenDuration + partialDuration + Core.range.start);
|
15861 | }
|
15862 | }
|
15863 |
|
15864 |
|
15865 |
|
15866 |
|
15867 |
|
15868 |
|
15869 |
|
15870 |
|
15871 |
|
15872 | function getHiddenDurationBetween(hiddenDates, start, end) {
|
15873 | var duration = 0;
|
15874 |
|
15875 | for (var i = 0; i < hiddenDates.length; i++) {
|
15876 | var startDate = hiddenDates[i].start;
|
15877 | var endDate = hiddenDates[i].end;
|
15878 |
|
15879 | if (startDate >= start && endDate < end) {
|
15880 | duration += endDate - startDate;
|
15881 | }
|
15882 | }
|
15883 |
|
15884 | return duration;
|
15885 | }
|
15886 |
|
15887 |
|
15888 |
|
15889 |
|
15890 |
|
15891 |
|
15892 |
|
15893 |
|
15894 |
|
15895 | function getHiddenDurationBeforeStart(hiddenDates, start, end) {
|
15896 | var duration = 0;
|
15897 |
|
15898 | for (var i = 0; i < hiddenDates.length; i++) {
|
15899 | var startDate = hiddenDates[i].start;
|
15900 | var endDate = hiddenDates[i].end;
|
15901 |
|
15902 | if (startDate >= start && endDate <= end) {
|
15903 | duration += endDate - startDate;
|
15904 | }
|
15905 | }
|
15906 |
|
15907 | return duration;
|
15908 | }
|
15909 |
|
15910 |
|
15911 |
|
15912 |
|
15913 |
|
15914 |
|
15915 |
|
15916 |
|
15917 |
|
15918 | function correctTimeForHidden(moment, hiddenDates, range, time) {
|
15919 | time = moment(time).toDate().valueOf();
|
15920 | time -= getHiddenDurationBefore(moment, hiddenDates, range, time);
|
15921 | return time;
|
15922 | }
|
15923 |
|
15924 |
|
15925 |
|
15926 |
|
15927 |
|
15928 |
|
15929 |
|
15930 |
|
15931 |
|
15932 | function getHiddenDurationBefore(moment, hiddenDates, range, time) {
|
15933 | var timeOffset = 0;
|
15934 | time = moment(time).toDate().valueOf();
|
15935 |
|
15936 | for (var i = 0; i < hiddenDates.length; i++) {
|
15937 | var startDate = hiddenDates[i].start;
|
15938 | var endDate = hiddenDates[i].end;
|
15939 |
|
15940 | if (startDate >= range.start && endDate < range.end) {
|
15941 | if (time >= endDate) {
|
15942 | timeOffset += endDate - startDate;
|
15943 | }
|
15944 | }
|
15945 | }
|
15946 |
|
15947 | return timeOffset;
|
15948 | }
|
15949 |
|
15950 |
|
15951 |
|
15952 |
|
15953 |
|
15954 |
|
15955 |
|
15956 |
|
15957 |
|
15958 | function getAccumulatedHiddenDuration(hiddenDates, range, requiredDuration) {
|
15959 | var hiddenDuration = 0;
|
15960 | var duration = 0;
|
15961 | var previousPoint = range.start;
|
15962 |
|
15963 | for (var i = 0; i < hiddenDates.length; i++) {
|
15964 | var startDate = hiddenDates[i].start;
|
15965 | var endDate = hiddenDates[i].end;
|
15966 |
|
15967 | if (startDate >= range.start && endDate < range.end) {
|
15968 | duration += startDate - previousPoint;
|
15969 | previousPoint = endDate;
|
15970 |
|
15971 | if (duration >= requiredDuration) {
|
15972 | break;
|
15973 | } else {
|
15974 | hiddenDuration += endDate - startDate;
|
15975 | }
|
15976 | }
|
15977 | }
|
15978 |
|
15979 | return hiddenDuration;
|
15980 | }
|
15981 |
|
15982 |
|
15983 |
|
15984 |
|
15985 |
|
15986 |
|
15987 |
|
15988 |
|
15989 |
|
15990 | function snapAwayFromHidden(hiddenDates, time, direction, correctionEnabled) {
|
15991 | var isHidden = getIsHidden(time, hiddenDates);
|
15992 |
|
15993 | if (isHidden.hidden == true) {
|
15994 | if (direction < 0) {
|
15995 | if (correctionEnabled == true) {
|
15996 | return isHidden.startDate - (isHidden.endDate - time) - 1;
|
15997 | } else {
|
15998 | return isHidden.startDate - 1;
|
15999 | }
|
16000 | } else {
|
16001 | if (correctionEnabled == true) {
|
16002 | return isHidden.endDate + (time - isHidden.startDate) + 1;
|
16003 | } else {
|
16004 | return isHidden.endDate + 1;
|
16005 | }
|
16006 | }
|
16007 | } else {
|
16008 | return time;
|
16009 | }
|
16010 | }
|
16011 |
|
16012 |
|
16013 |
|
16014 |
|
16015 |
|
16016 |
|
16017 |
|
16018 |
|
16019 | function getIsHidden(time, hiddenDates) {
|
16020 | for (var i = 0; i < hiddenDates.length; i++) {
|
16021 | var startDate = hiddenDates[i].start;
|
16022 | var endDate = hiddenDates[i].end;
|
16023 |
|
16024 | if (time >= startDate && time < endDate) {
|
16025 |
|
16026 | return {
|
16027 | hidden: true,
|
16028 | startDate: startDate,
|
16029 | endDate: endDate
|
16030 | };
|
16031 | }
|
16032 | }
|
16033 |
|
16034 | return {
|
16035 | hidden: false,
|
16036 | startDate: startDate,
|
16037 | endDate: endDate
|
16038 | };
|
16039 | }
|
16040 |
|
16041 | var DateUtil = Object.freeze({
|
16042 | __proto__: null,
|
16043 | convertHiddenOptions: convertHiddenOptions,
|
16044 | updateHiddenDates: updateHiddenDates,
|
16045 | removeDuplicates: removeDuplicates,
|
16046 | printDates: printDates,
|
16047 | stepOverHiddenDates: stepOverHiddenDates,
|
16048 | toScreen: toScreen,
|
16049 | toTime: toTime,
|
16050 | getHiddenDurationBetween: getHiddenDurationBetween,
|
16051 | getHiddenDurationBeforeStart: getHiddenDurationBeforeStart,
|
16052 | correctTimeForHidden: correctTimeForHidden,
|
16053 | getHiddenDurationBefore: getHiddenDurationBefore,
|
16054 | getAccumulatedHiddenDuration: getAccumulatedHiddenDuration,
|
16055 | snapAwayFromHidden: snapAwayFromHidden,
|
16056 | getIsHidden: getIsHidden
|
16057 | });
|
16058 |
|
16059 | function _createSuper$c(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
16060 |
|
16061 | function _isNativeReflectConstruct$c() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
16062 |
|
16063 |
|
16064 |
|
16065 |
|
16066 |
|
16067 |
|
16068 | var Range = function (_Component) {
|
16069 | _inherits(Range, _Component);
|
16070 |
|
16071 | var _super = _createSuper$c(Range);
|
16072 |
|
16073 | |
16074 |
|
16075 |
|
16076 |
|
16077 |
|
16078 |
|
16079 | function Range(body, options) {
|
16080 | var _context, _context2, _context3, _context4, _context5, _context6, _context7;
|
16081 |
|
16082 | var _this;
|
16083 |
|
16084 | _classCallCheck(this, Range);
|
16085 |
|
16086 | _this = _super.call(this);
|
16087 | var now = moment$2().hours(0).minutes(0).seconds(0).milliseconds(0);
|
16088 | var start = now.clone().add(-3, 'days').valueOf();
|
16089 | var end = now.clone().add(3, 'days').valueOf();
|
16090 | _this.millisecondsPerPixelCache = undefined;
|
16091 |
|
16092 | if (options === undefined) {
|
16093 | _this.start = start;
|
16094 | _this.end = end;
|
16095 | } else {
|
16096 | _this.start = options.start || start;
|
16097 | _this.end = options.end || end;
|
16098 | }
|
16099 |
|
16100 | _this.rolling = false;
|
16101 | _this.body = body;
|
16102 | _this.deltaDifference = 0;
|
16103 | _this.scaleOffset = 0;
|
16104 | _this.startToFront = false;
|
16105 | _this.endToFront = true;
|
16106 |
|
16107 | _this.defaultOptions = {
|
16108 | rtl: false,
|
16109 | start: null,
|
16110 | end: null,
|
16111 | moment: moment$2,
|
16112 | direction: 'horizontal',
|
16113 |
|
16114 | moveable: true,
|
16115 | zoomable: true,
|
16116 | min: null,
|
16117 | max: null,
|
16118 | zoomMin: 10,
|
16119 |
|
16120 | zoomMax: 1000 * 60 * 60 * 24 * 365 * 10000,
|
16121 |
|
16122 | rollingMode: {
|
16123 | follow: false,
|
16124 | offset: 0.5
|
16125 | }
|
16126 | };
|
16127 | _this.options = availableUtils.extend({}, _this.defaultOptions);
|
16128 | _this.props = {
|
16129 | touch: {}
|
16130 | };
|
16131 | _this.animationTimer = null;
|
16132 |
|
16133 | _this.body.emitter.on('panstart', _bindInstanceProperty(_context = _this._onDragStart).call(_context, _assertThisInitialized$1(_this)));
|
16134 |
|
16135 | _this.body.emitter.on('panmove', _bindInstanceProperty(_context2 = _this._onDrag).call(_context2, _assertThisInitialized$1(_this)));
|
16136 |
|
16137 | _this.body.emitter.on('panend', _bindInstanceProperty(_context3 = _this._onDragEnd).call(_context3, _assertThisInitialized$1(_this)));
|
16138 |
|
16139 |
|
16140 | _this.body.emitter.on('mousewheel', _bindInstanceProperty(_context4 = _this._onMouseWheel).call(_context4, _assertThisInitialized$1(_this)));
|
16141 |
|
16142 |
|
16143 | _this.body.emitter.on('touch', _bindInstanceProperty(_context5 = _this._onTouch).call(_context5, _assertThisInitialized$1(_this)));
|
16144 |
|
16145 | _this.body.emitter.on('pinch', _bindInstanceProperty(_context6 = _this._onPinch).call(_context6, _assertThisInitialized$1(_this)));
|
16146 |
|
16147 |
|
16148 | _this.body.dom.rollingModeBtn.addEventListener('click', _bindInstanceProperty(_context7 = _this.startRolling).call(_context7, _assertThisInitialized$1(_this)));
|
16149 |
|
16150 | _this.setOptions(options);
|
16151 |
|
16152 | return _this;
|
16153 | }
|
16154 | |
16155 |
|
16156 |
|
16157 |
|
16158 |
|
16159 |
|
16160 |
|
16161 |
|
16162 |
|
16163 |
|
16164 |
|
16165 |
|
16166 |
|
16167 |
|
16168 |
|
16169 |
|
16170 |
|
16171 |
|
16172 | _createClass(Range, [{
|
16173 | key: "setOptions",
|
16174 | value: function setOptions(options) {
|
16175 | if (options) {
|
16176 |
|
16177 | var fields = ['animation', 'direction', 'min', 'max', 'zoomMin', 'zoomMax', 'moveable', 'zoomable', 'moment', 'activate', 'hiddenDates', 'zoomKey', 'zoomFriction', 'rtl', 'showCurrentTime', 'rollingMode', 'horizontalScroll'];
|
16178 | availableUtils.selectiveExtend(fields, this.options, options);
|
16179 |
|
16180 | if (options.rollingMode && options.rollingMode.follow) {
|
16181 | this.startRolling();
|
16182 | }
|
16183 |
|
16184 | if ('start' in options || 'end' in options) {
|
16185 |
|
16186 | this.setRange(options.start, options.end);
|
16187 | }
|
16188 | }
|
16189 | }
|
16190 | |
16191 |
|
16192 |
|
16193 |
|
16194 | }, {
|
16195 | key: "startRolling",
|
16196 | value: function startRolling() {
|
16197 | var me = this;
|
16198 | |
16199 |
|
16200 |
|
16201 |
|
16202 | function update() {
|
16203 | me.stopRolling();
|
16204 | me.rolling = true;
|
16205 | var interval = me.end - me.start;
|
16206 | var t = availableUtils.convert(new Date(), 'Date').valueOf();
|
16207 | var rollingModeOffset = me.options.rollingMode && me.options.rollingMode.offset || 0.5;
|
16208 | var start = t - interval * rollingModeOffset;
|
16209 | var end = t + interval * (1 - rollingModeOffset);
|
16210 | var options = {
|
16211 | animation: false
|
16212 | };
|
16213 | me.setRange(start, end, options);
|
16214 |
|
16215 | var scale = me.conversion(me.body.domProps.center.width).scale;
|
16216 | interval = 1 / scale / 10;
|
16217 | if (interval < 30) interval = 30;
|
16218 | if (interval > 1000) interval = 1000;
|
16219 | me.body.dom.rollingModeBtn.style.visibility = "hidden";
|
16220 |
|
16221 | me.currentTimeTimer = _setTimeout(update, interval);
|
16222 | }
|
16223 |
|
16224 | update();
|
16225 | }
|
16226 | |
16227 |
|
16228 |
|
16229 |
|
16230 | }, {
|
16231 | key: "stopRolling",
|
16232 | value: function stopRolling() {
|
16233 | if (this.currentTimeTimer !== undefined) {
|
16234 | clearTimeout(this.currentTimeTimer);
|
16235 | this.rolling = false;
|
16236 | this.body.dom.rollingModeBtn.style.visibility = "visible";
|
16237 | }
|
16238 | }
|
16239 | |
16240 |
|
16241 |
|
16242 |
|
16243 |
|
16244 |
|
16245 |
|
16246 |
|
16247 |
|
16248 |
|
16249 |
|
16250 |
|
16251 |
|
16252 |
|
16253 |
|
16254 |
|
16255 |
|
16256 |
|
16257 |
|
16258 |
|
16259 |
|
16260 |
|
16261 | }, {
|
16262 | key: "setRange",
|
16263 | value: function setRange(start, end, options, callback, frameCallback) {
|
16264 | if (!options) {
|
16265 | options = {};
|
16266 | }
|
16267 |
|
16268 | if (options.byUser !== true) {
|
16269 | options.byUser = false;
|
16270 | }
|
16271 |
|
16272 | var me = this;
|
16273 | var finalStart = start != undefined ? availableUtils.convert(start, 'Date').valueOf() : null;
|
16274 | var finalEnd = end != undefined ? availableUtils.convert(end, 'Date').valueOf() : null;
|
16275 |
|
16276 | this._cancelAnimation();
|
16277 |
|
16278 | this.millisecondsPerPixelCache = undefined;
|
16279 |
|
16280 | if (options.animation) {
|
16281 |
|
16282 | var initStart = this.start;
|
16283 | var initEnd = this.end;
|
16284 | var duration = _typeof(options.animation) === 'object' && 'duration' in options.animation ? options.animation.duration : 500;
|
16285 | var easingName = _typeof(options.animation) === 'object' && 'easingFunction' in options.animation ? options.animation.easingFunction : 'easeInOutQuad';
|
16286 | var easingFunction = availableUtils.easingFunctions[easingName];
|
16287 |
|
16288 | if (!easingFunction) {
|
16289 | var _context8;
|
16290 |
|
16291 | throw new Error(_concatInstanceProperty(_context8 = "Unknown easing function ".concat(_JSON$stringify(easingName), ". Choose from: ")).call(_context8, _Object$keys(availableUtils.easingFunctions).join(', ')));
|
16292 | }
|
16293 |
|
16294 | var initTime = _Date$now();
|
16295 |
|
16296 | var anyChanged = false;
|
16297 |
|
16298 | var next = function next() {
|
16299 | if (!me.props.touch.dragging) {
|
16300 | var now = _Date$now();
|
16301 |
|
16302 | var time = now - initTime;
|
16303 | var ease = easingFunction(time / duration);
|
16304 | var done = time > duration;
|
16305 | var s = done || finalStart === null ? finalStart : initStart + (finalStart - initStart) * ease;
|
16306 | var e = done || finalEnd === null ? finalEnd : initEnd + (finalEnd - initEnd) * ease;
|
16307 | changed = me._applyRange(s, e);
|
16308 | updateHiddenDates(me.options.moment, me.body, me.options.hiddenDates);
|
16309 | anyChanged = anyChanged || changed;
|
16310 | var params = {
|
16311 | start: new Date(me.start),
|
16312 | end: new Date(me.end),
|
16313 | byUser: options.byUser,
|
16314 | event: options.event
|
16315 | };
|
16316 |
|
16317 | if (frameCallback) {
|
16318 | frameCallback(ease, changed, done);
|
16319 | }
|
16320 |
|
16321 | if (changed) {
|
16322 | me.body.emitter.emit('rangechange', params);
|
16323 | }
|
16324 |
|
16325 | if (done) {
|
16326 | if (anyChanged) {
|
16327 | me.body.emitter.emit('rangechanged', params);
|
16328 |
|
16329 | if (callback) {
|
16330 | return callback();
|
16331 | }
|
16332 | }
|
16333 | } else {
|
16334 |
|
16335 |
|
16336 | me.animationTimer = _setTimeout(next, 20);
|
16337 | }
|
16338 | }
|
16339 | };
|
16340 |
|
16341 | return next();
|
16342 | } else {
|
16343 | var changed = this._applyRange(finalStart, finalEnd);
|
16344 |
|
16345 | updateHiddenDates(this.options.moment, this.body, this.options.hiddenDates);
|
16346 |
|
16347 | if (changed) {
|
16348 | var params = {
|
16349 | start: new Date(this.start),
|
16350 | end: new Date(this.end),
|
16351 | byUser: options.byUser,
|
16352 | event: options.event
|
16353 | };
|
16354 | this.body.emitter.emit('rangechange', params);
|
16355 | clearTimeout(me.timeoutID);
|
16356 | me.timeoutID = _setTimeout(function () {
|
16357 | me.body.emitter.emit('rangechanged', params);
|
16358 | }, 200);
|
16359 |
|
16360 | if (callback) {
|
16361 | return callback();
|
16362 | }
|
16363 | }
|
16364 | }
|
16365 | }
|
16366 | |
16367 |
|
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 | }, {
|
16373 | key: "getMillisecondsPerPixel",
|
16374 | value: function getMillisecondsPerPixel() {
|
16375 | if (this.millisecondsPerPixelCache === undefined) {
|
16376 | this.millisecondsPerPixelCache = (this.end - this.start) / this.body.dom.center.clientWidth;
|
16377 | }
|
16378 |
|
16379 | return this.millisecondsPerPixelCache;
|
16380 | }
|
16381 | |
16382 |
|
16383 |
|
16384 |
|
16385 |
|
16386 | }, {
|
16387 | key: "_cancelAnimation",
|
16388 | value: function _cancelAnimation() {
|
16389 | if (this.animationTimer) {
|
16390 | clearTimeout(this.animationTimer);
|
16391 | this.animationTimer = null;
|
16392 | }
|
16393 | }
|
16394 | |
16395 |
|
16396 |
|
16397 |
|
16398 |
|
16399 |
|
16400 |
|
16401 |
|
16402 |
|
16403 |
|
16404 | }, {
|
16405 | key: "_applyRange",
|
16406 | value: function _applyRange(start, end) {
|
16407 | var newStart = start != null ? availableUtils.convert(start, 'Date').valueOf() : this.start;
|
16408 | var newEnd = end != null ? availableUtils.convert(end, 'Date').valueOf() : this.end;
|
16409 | var max = this.options.max != null ? availableUtils.convert(this.options.max, 'Date').valueOf() : null;
|
16410 | var min = this.options.min != null ? availableUtils.convert(this.options.min, 'Date').valueOf() : null;
|
16411 | var diff;
|
16412 |
|
16413 | if (isNaN(newStart) || newStart === null) {
|
16414 | throw new Error("Invalid start \"".concat(start, "\""));
|
16415 | }
|
16416 |
|
16417 | if (isNaN(newEnd) || newEnd === null) {
|
16418 | throw new Error("Invalid end \"".concat(end, "\""));
|
16419 | }
|
16420 |
|
16421 |
|
16422 | if (newEnd < newStart) {
|
16423 | newEnd = newStart;
|
16424 | }
|
16425 |
|
16426 |
|
16427 | if (min !== null) {
|
16428 | if (newStart < min) {
|
16429 | diff = min - newStart;
|
16430 | newStart += diff;
|
16431 | newEnd += diff;
|
16432 |
|
16433 | if (max != null) {
|
16434 | if (newEnd > max) {
|
16435 | newEnd = max;
|
16436 | }
|
16437 | }
|
16438 | }
|
16439 | }
|
16440 |
|
16441 |
|
16442 | if (max !== null) {
|
16443 | if (newEnd > max) {
|
16444 | diff = newEnd - max;
|
16445 | newStart -= diff;
|
16446 | newEnd -= diff;
|
16447 |
|
16448 | if (min != null) {
|
16449 | if (newStart < min) {
|
16450 | newStart = min;
|
16451 | }
|
16452 | }
|
16453 | }
|
16454 | }
|
16455 |
|
16456 |
|
16457 | if (this.options.zoomMin !== null) {
|
16458 | var zoomMin = _parseFloat(this.options.zoomMin);
|
16459 |
|
16460 | if (zoomMin < 0) {
|
16461 | zoomMin = 0;
|
16462 | }
|
16463 |
|
16464 | if (newEnd - newStart < zoomMin) {
|
16465 |
|
16466 | var compensation = 0.5;
|
16467 |
|
16468 | if (this.end - this.start === zoomMin && newStart >= this.start - compensation && newEnd <= this.end) {
|
16469 |
|
16470 | newStart = this.start;
|
16471 | newEnd = this.end;
|
16472 | } else {
|
16473 |
|
16474 | diff = zoomMin - (newEnd - newStart);
|
16475 | newStart -= diff / 2;
|
16476 | newEnd += diff / 2;
|
16477 | }
|
16478 | }
|
16479 | }
|
16480 |
|
16481 |
|
16482 | if (this.options.zoomMax !== null) {
|
16483 | var zoomMax = _parseFloat(this.options.zoomMax);
|
16484 |
|
16485 | if (zoomMax < 0) {
|
16486 | zoomMax = 0;
|
16487 | }
|
16488 |
|
16489 | if (newEnd - newStart > zoomMax) {
|
16490 | if (this.end - this.start === zoomMax && newStart < this.start && newEnd > this.end) {
|
16491 |
|
16492 | newStart = this.start;
|
16493 | newEnd = this.end;
|
16494 | } else {
|
16495 |
|
16496 | diff = newEnd - newStart - zoomMax;
|
16497 | newStart += diff / 2;
|
16498 | newEnd -= diff / 2;
|
16499 | }
|
16500 | }
|
16501 | }
|
16502 |
|
16503 | var changed = this.start != newStart || this.end != newEnd;
|
16504 |
|
16505 | if (!(newStart >= this.start && newStart <= this.end || newEnd >= this.start && newEnd <= this.end) && !(this.start >= newStart && this.start <= newEnd || this.end >= newStart && this.end <= newEnd)) {
|
16506 | this.body.emitter.emit('checkRangedItems');
|
16507 | }
|
16508 |
|
16509 | this.start = newStart;
|
16510 | this.end = newEnd;
|
16511 | return changed;
|
16512 | }
|
16513 | |
16514 |
|
16515 |
|
16516 |
|
16517 |
|
16518 | }, {
|
16519 | key: "getRange",
|
16520 | value: function getRange() {
|
16521 | return {
|
16522 | start: this.start,
|
16523 | end: this.end
|
16524 | };
|
16525 | }
|
16526 | |
16527 |
|
16528 |
|
16529 |
|
16530 |
|
16531 |
|
16532 |
|
16533 |
|
16534 | }, {
|
16535 | key: "conversion",
|
16536 | value: function conversion(width, totalHidden) {
|
16537 | return Range.conversion(this.start, this.end, width, totalHidden);
|
16538 | }
|
16539 | |
16540 |
|
16541 |
|
16542 |
|
16543 |
|
16544 |
|
16545 |
|
16546 |
|
16547 |
|
16548 |
|
16549 | }, {
|
16550 | key: "_onDragStart",
|
16551 | value:
|
16552 | |
16553 |
|
16554 |
|
16555 |
|
16556 |
|
16557 | function _onDragStart(event) {
|
16558 | this.deltaDifference = 0;
|
16559 | this.previousDelta = 0;
|
16560 |
|
16561 | if (!this.options.moveable) return;
|
16562 |
|
16563 | if (!this._isInsideRange(event)) return;
|
16564 |
|
16565 |
|
16566 | if (!this.props.touch.allowDragging) return;
|
16567 | this.stopRolling();
|
16568 | this.props.touch.start = this.start;
|
16569 | this.props.touch.end = this.end;
|
16570 | this.props.touch.dragging = true;
|
16571 |
|
16572 | if (this.body.dom.root) {
|
16573 | this.body.dom.root.style.cursor = 'move';
|
16574 | }
|
16575 | }
|
16576 | |
16577 |
|
16578 |
|
16579 |
|
16580 |
|
16581 |
|
16582 | }, {
|
16583 | key: "_onDrag",
|
16584 | value: function _onDrag(event) {
|
16585 | if (!event) return;
|
16586 | if (!this.props.touch.dragging) return;
|
16587 |
|
16588 | if (!this.options.moveable) return;
|
16589 |
|
16590 |
|
16591 |
|
16592 | if (!this.props.touch.allowDragging) return;
|
16593 | var direction = this.options.direction;
|
16594 | validateDirection(direction);
|
16595 | var delta = direction == 'horizontal' ? event.deltaX : event.deltaY;
|
16596 | delta -= this.deltaDifference;
|
16597 | var interval = this.props.touch.end - this.props.touch.start;
|
16598 |
|
16599 | var duration = getHiddenDurationBetween(this.body.hiddenDates, this.start, this.end);
|
16600 | interval -= duration;
|
16601 | var width = direction == 'horizontal' ? this.body.domProps.center.width : this.body.domProps.center.height;
|
16602 | var diffRange;
|
16603 |
|
16604 | if (this.options.rtl) {
|
16605 | diffRange = delta / width * interval;
|
16606 | } else {
|
16607 | diffRange = -delta / width * interval;
|
16608 | }
|
16609 |
|
16610 | var newStart = this.props.touch.start + diffRange;
|
16611 | var newEnd = this.props.touch.end + diffRange;
|
16612 |
|
16613 | var safeStart = snapAwayFromHidden(this.body.hiddenDates, newStart, this.previousDelta - delta, true);
|
16614 | var safeEnd = snapAwayFromHidden(this.body.hiddenDates, newEnd, this.previousDelta - delta, true);
|
16615 |
|
16616 | if (safeStart != newStart || safeEnd != newEnd) {
|
16617 | this.deltaDifference += delta;
|
16618 | this.props.touch.start = safeStart;
|
16619 | this.props.touch.end = safeEnd;
|
16620 |
|
16621 | this._onDrag(event);
|
16622 |
|
16623 | return;
|
16624 | }
|
16625 |
|
16626 | this.previousDelta = delta;
|
16627 |
|
16628 | this._applyRange(newStart, newEnd);
|
16629 |
|
16630 | var startDate = new Date(this.start);
|
16631 | var endDate = new Date(this.end);
|
16632 |
|
16633 | this.body.emitter.emit('rangechange', {
|
16634 | start: startDate,
|
16635 | end: endDate,
|
16636 | byUser: true,
|
16637 | event: event
|
16638 | });
|
16639 |
|
16640 | this.body.emitter.emit('panmove');
|
16641 | }
|
16642 | |
16643 |
|
16644 |
|
16645 |
|
16646 |
|
16647 |
|
16648 | }, {
|
16649 | key: "_onDragEnd",
|
16650 | value: function _onDragEnd(event) {
|
16651 | if (!this.props.touch.dragging) return;
|
16652 |
|
16653 | if (!this.options.moveable) return;
|
16654 |
|
16655 |
|
16656 |
|
16657 | if (!this.props.touch.allowDragging) return;
|
16658 | this.props.touch.dragging = false;
|
16659 |
|
16660 | if (this.body.dom.root) {
|
16661 | this.body.dom.root.style.cursor = 'auto';
|
16662 | }
|
16663 |
|
16664 |
|
16665 | this.body.emitter.emit('rangechanged', {
|
16666 | start: new Date(this.start),
|
16667 | end: new Date(this.end),
|
16668 | byUser: true,
|
16669 | event: event
|
16670 | });
|
16671 | }
|
16672 | |
16673 |
|
16674 |
|
16675 |
|
16676 |
|
16677 |
|
16678 |
|
16679 | }, {
|
16680 | key: "_onMouseWheel",
|
16681 | value: function _onMouseWheel(event) {
|
16682 |
|
16683 | var delta = 0;
|
16684 |
|
16685 | if (event.wheelDelta) {
|
16686 |
|
16687 | delta = event.wheelDelta / 120;
|
16688 | } else if (event.detail) {
|
16689 |
|
16690 |
|
16691 |
|
16692 | delta = -event.detail / 3;
|
16693 | } else if (event.deltaY) {
|
16694 | delta = -event.deltaY / 3;
|
16695 | }
|
16696 |
|
16697 |
|
16698 | if (this.options.zoomKey && !event[this.options.zoomKey] && this.options.zoomable || !this.options.zoomable && this.options.moveable) {
|
16699 | return;
|
16700 | }
|
16701 |
|
16702 |
|
16703 | if (!(this.options.zoomable && this.options.moveable)) return;
|
16704 |
|
16705 | if (!this._isInsideRange(event)) return;
|
16706 |
|
16707 |
|
16708 |
|
16709 | if (delta) {
|
16710 |
|
16711 |
|
16712 |
|
16713 | var zoomFriction = this.options.zoomFriction || 5;
|
16714 | var scale;
|
16715 |
|
16716 | if (delta < 0) {
|
16717 | scale = 1 - delta / zoomFriction;
|
16718 | } else {
|
16719 | scale = 1 / (1 + delta / zoomFriction);
|
16720 | }
|
16721 |
|
16722 |
|
16723 | var pointerDate;
|
16724 |
|
16725 | if (this.rolling) {
|
16726 | var rollingModeOffset = this.options.rollingMode && this.options.rollingMode.offset || 0.5;
|
16727 | pointerDate = this.start + (this.end - this.start) * rollingModeOffset;
|
16728 | } else {
|
16729 | var pointer = this.getPointer({
|
16730 | x: event.clientX,
|
16731 | y: event.clientY
|
16732 | }, this.body.dom.center);
|
16733 | pointerDate = this._pointerToDate(pointer);
|
16734 | }
|
16735 |
|
16736 | this.zoom(scale, pointerDate, delta, event);
|
16737 |
|
16738 |
|
16739 | event.preventDefault();
|
16740 | }
|
16741 | }
|
16742 | |
16743 |
|
16744 |
|
16745 |
|
16746 |
|
16747 |
|
16748 | }, {
|
16749 | key: "_onTouch",
|
16750 | value: function _onTouch(event) {
|
16751 |
|
16752 | this.props.touch.start = this.start;
|
16753 | this.props.touch.end = this.end;
|
16754 | this.props.touch.allowDragging = true;
|
16755 | this.props.touch.center = null;
|
16756 | this.props.touch.centerDate = null;
|
16757 | this.scaleOffset = 0;
|
16758 | this.deltaDifference = 0;
|
16759 |
|
16760 | availableUtils.preventDefault(event);
|
16761 | }
|
16762 | |
16763 |
|
16764 |
|
16765 |
|
16766 |
|
16767 |
|
16768 | }, {
|
16769 | key: "_onPinch",
|
16770 | value: function _onPinch(event) {
|
16771 |
|
16772 | if (!(this.options.zoomable && this.options.moveable)) return;
|
16773 |
|
16774 | availableUtils.preventDefault(event);
|
16775 | this.props.touch.allowDragging = false;
|
16776 |
|
16777 | if (!this.props.touch.center) {
|
16778 | this.props.touch.center = this.getPointer(event.center, this.body.dom.center);
|
16779 | this.props.touch.centerDate = this._pointerToDate(this.props.touch.center);
|
16780 | }
|
16781 |
|
16782 | this.stopRolling();
|
16783 | var scale = 1 / (event.scale + this.scaleOffset);
|
16784 | var centerDate = this.props.touch.centerDate;
|
16785 | var hiddenDuration = getHiddenDurationBetween(this.body.hiddenDates, this.start, this.end);
|
16786 | var hiddenDurationBefore = getHiddenDurationBefore(this.options.moment, this.body.hiddenDates, this, centerDate);
|
16787 | var hiddenDurationAfter = hiddenDuration - hiddenDurationBefore;
|
16788 |
|
16789 | var newStart = centerDate - hiddenDurationBefore + (this.props.touch.start - (centerDate - hiddenDurationBefore)) * scale;
|
16790 | var newEnd = centerDate + hiddenDurationAfter + (this.props.touch.end - (centerDate + hiddenDurationAfter)) * scale;
|
16791 |
|
16792 | this.startToFront = 1 - scale <= 0;
|
16793 |
|
16794 | this.endToFront = scale - 1 <= 0;
|
16795 |
|
16796 | var safeStart = snapAwayFromHidden(this.body.hiddenDates, newStart, 1 - scale, true);
|
16797 | var safeEnd = snapAwayFromHidden(this.body.hiddenDates, newEnd, scale - 1, true);
|
16798 |
|
16799 | if (safeStart != newStart || safeEnd != newEnd) {
|
16800 | this.props.touch.start = safeStart;
|
16801 | this.props.touch.end = safeEnd;
|
16802 | this.scaleOffset = 1 - event.scale;
|
16803 | newStart = safeStart;
|
16804 | newEnd = safeEnd;
|
16805 | }
|
16806 |
|
16807 | var options = {
|
16808 | animation: false,
|
16809 | byUser: true,
|
16810 | event: event
|
16811 | };
|
16812 | this.setRange(newStart, newEnd, options);
|
16813 | this.startToFront = false;
|
16814 |
|
16815 | this.endToFront = true;
|
16816 | }
|
16817 | |
16818 |
|
16819 |
|
16820 |
|
16821 |
|
16822 |
|
16823 |
|
16824 |
|
16825 | }, {
|
16826 | key: "_isInsideRange",
|
16827 | value: function _isInsideRange(event) {
|
16828 |
|
16829 |
|
16830 | var clientX = event.center ? event.center.x : event.clientX;
|
16831 | var centerContainerRect = this.body.dom.centerContainer.getBoundingClientRect();
|
16832 | var x = this.options.rtl ? clientX - centerContainerRect.left : centerContainerRect.right - clientX;
|
16833 | var time = this.body.util.toTime(x);
|
16834 | return time >= this.start && time <= this.end;
|
16835 | }
|
16836 | |
16837 |
|
16838 |
|
16839 |
|
16840 |
|
16841 |
|
16842 |
|
16843 | }, {
|
16844 | key: "_pointerToDate",
|
16845 | value: function _pointerToDate(pointer) {
|
16846 | var conversion;
|
16847 | var direction = this.options.direction;
|
16848 | validateDirection(direction);
|
16849 |
|
16850 | if (direction == 'horizontal') {
|
16851 | return this.body.util.toTime(pointer.x).valueOf();
|
16852 | } else {
|
16853 | var height = this.body.domProps.center.height;
|
16854 | conversion = this.conversion(height);
|
16855 | return pointer.y / conversion.scale + conversion.offset;
|
16856 | }
|
16857 | }
|
16858 | |
16859 |
|
16860 |
|
16861 |
|
16862 |
|
16863 |
|
16864 |
|
16865 |
|
16866 | }, {
|
16867 | key: "getPointer",
|
16868 | value: function getPointer(touch, element) {
|
16869 | var elementRect = element.getBoundingClientRect();
|
16870 |
|
16871 | if (this.options.rtl) {
|
16872 | return {
|
16873 | x: elementRect.right - touch.x,
|
16874 | y: touch.y - elementRect.top
|
16875 | };
|
16876 | } else {
|
16877 | return {
|
16878 | x: touch.x - elementRect.left,
|
16879 | y: touch.y - elementRect.top
|
16880 | };
|
16881 | }
|
16882 | }
|
16883 | |
16884 |
|
16885 |
|
16886 |
|
16887 |
|
16888 |
|
16889 |
|
16890 |
|
16891 |
|
16892 |
|
16893 |
|
16894 |
|
16895 |
|
16896 | }, {
|
16897 | key: "zoom",
|
16898 | value: function zoom(scale, center, delta, event) {
|
16899 |
|
16900 | if (center == null) {
|
16901 | center = (this.start + this.end) / 2;
|
16902 | }
|
16903 |
|
16904 | var hiddenDuration = getHiddenDurationBetween(this.body.hiddenDates, this.start, this.end);
|
16905 | var hiddenDurationBefore = getHiddenDurationBefore(this.options.moment, this.body.hiddenDates, this, center);
|
16906 | var hiddenDurationAfter = hiddenDuration - hiddenDurationBefore;
|
16907 |
|
16908 | var newStart = center - hiddenDurationBefore + (this.start - (center - hiddenDurationBefore)) * scale;
|
16909 | var newEnd = center + hiddenDurationAfter + (this.end - (center + hiddenDurationAfter)) * scale;
|
16910 |
|
16911 | this.startToFront = delta > 0 ? false : true;
|
16912 |
|
16913 | this.endToFront = -delta > 0 ? false : true;
|
16914 |
|
16915 | var safeStart = snapAwayFromHidden(this.body.hiddenDates, newStart, delta, true);
|
16916 | var safeEnd = snapAwayFromHidden(this.body.hiddenDates, newEnd, -delta, true);
|
16917 |
|
16918 | if (safeStart != newStart || safeEnd != newEnd) {
|
16919 | newStart = safeStart;
|
16920 | newEnd = safeEnd;
|
16921 | }
|
16922 |
|
16923 | var options = {
|
16924 | animation: false,
|
16925 | byUser: true,
|
16926 | event: event
|
16927 | };
|
16928 | this.setRange(newStart, newEnd, options);
|
16929 | this.startToFront = false;
|
16930 |
|
16931 | this.endToFront = true;
|
16932 | }
|
16933 | |
16934 |
|
16935 |
|
16936 |
|
16937 |
|
16938 |
|
16939 |
|
16940 | }, {
|
16941 | key: "move",
|
16942 | value: function move(delta) {
|
16943 |
|
16944 | var diff = this.end - this.start;
|
16945 |
|
16946 | var newStart = this.start + diff * delta;
|
16947 | var newEnd = this.end + diff * delta;
|
16948 |
|
16949 | this.start = newStart;
|
16950 | this.end = newEnd;
|
16951 | }
|
16952 | |
16953 |
|
16954 |
|
16955 |
|
16956 |
|
16957 | }, {
|
16958 | key: "moveTo",
|
16959 | value: function moveTo(_moveTo) {
|
16960 | var center = (this.start + this.end) / 2;
|
16961 | var diff = center - _moveTo;
|
16962 |
|
16963 | var newStart = this.start - diff;
|
16964 | var newEnd = this.end - diff;
|
16965 | var options = {
|
16966 | animation: false,
|
16967 | byUser: true,
|
16968 | event: null
|
16969 | };
|
16970 | this.setRange(newStart, newEnd, options);
|
16971 | }
|
16972 | }], [{
|
16973 | key: "conversion",
|
16974 | value: function conversion(start, end, width, totalHidden) {
|
16975 | if (totalHidden === undefined) {
|
16976 | totalHidden = 0;
|
16977 | }
|
16978 |
|
16979 | if (width != 0 && end - start != 0) {
|
16980 | return {
|
16981 | offset: start,
|
16982 | scale: width / (end - start - totalHidden)
|
16983 | };
|
16984 | } else {
|
16985 | return {
|
16986 | offset: 0,
|
16987 | scale: 1
|
16988 | };
|
16989 | }
|
16990 | }
|
16991 | }]);
|
16992 |
|
16993 | return Range;
|
16994 | }(Component);
|
16995 |
|
16996 | function validateDirection(direction) {
|
16997 | if (direction != 'horizontal' && direction != 'vertical') {
|
16998 | throw new TypeError("Unknown direction \"".concat(direction, "\". Choose \"horizontal\" or \"vertical\"."));
|
16999 | }
|
17000 | }
|
17001 |
|
17002 | var some$3 = {exports: {}};
|
17003 |
|
17004 | var $$5 = _export;
|
17005 | var $some = arrayIteration.some;
|
17006 | var arrayMethodIsStrict$1 = arrayMethodIsStrict$6;
|
17007 | var STRICT_METHOD$1 = arrayMethodIsStrict$1('some');
|
17008 |
|
17009 |
|
17010 | $$5({
|
17011 | target: 'Array',
|
17012 | proto: true,
|
17013 | forced: !STRICT_METHOD$1
|
17014 | }, {
|
17015 | some: function some(callbackfn
|
17016 | /* , thisArg */
|
17017 | ) {
|
17018 | return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
17019 | }
|
17020 | });
|
17021 |
|
17022 | var entryVirtual$3 = entryVirtual$k;
|
17023 | var some$2 = entryVirtual$3('Array').some;
|
17024 |
|
17025 | var isPrototypeOf$5 = objectIsPrototypeOf;
|
17026 | var method$3 = some$2;
|
17027 | var ArrayPrototype$3 = Array.prototype;
|
17028 |
|
17029 | var some$1 = function (it) {
|
17030 | var own = it.some;
|
17031 | return it === ArrayPrototype$3 || isPrototypeOf$5(ArrayPrototype$3, it) && own === ArrayPrototype$3.some ? method$3 : own;
|
17032 | };
|
17033 |
|
17034 | var parent$4 = some$1;
|
17035 | var some = parent$4;
|
17036 |
|
17037 | (function (module) {
|
17038 | module.exports = some;
|
17039 | })(some$3);
|
17040 |
|
17041 | var _someInstanceProperty = getDefaultExportFromCjs(some$3.exports);
|
17042 |
|
17043 | var setInterval$1 = {exports: {}};
|
17044 |
|
17045 | var path$1 = path$r;
|
17046 | var setInterval = path$1.setInterval;
|
17047 |
|
17048 | (function (module) {
|
17049 | module.exports = setInterval;
|
17050 | })(setInterval$1);
|
17051 |
|
17052 | var _setInterval = getDefaultExportFromCjs(setInterval$1.exports);
|
17053 |
|
17054 | var _firstTarget = null;
|
17055 |
|
17056 |
|
17057 |
|
17058 |
|
17059 |
|
17060 |
|
17061 |
|
17062 |
|
17063 |
|
17064 |
|
17065 |
|
17066 |
|
17067 |
|
17068 |
|
17069 |
|
17070 |
|
17071 |
|
17072 |
|
17073 |
|
17074 |
|
17075 |
|
17076 |
|
17077 |
|
17078 |
|
17079 | function propagating(hammer, options) {
|
17080 | var _options = options || {
|
17081 | preventDefault: false
|
17082 | };
|
17083 |
|
17084 | if (hammer.Manager) {
|
17085 |
|
17086 |
|
17087 | var Hammer = hammer;
|
17088 |
|
17089 | var PropagatingHammer = function (element, options) {
|
17090 | var o = Object.create(_options);
|
17091 | if (options) Hammer.assign(o, options);
|
17092 | return propagating(new Hammer(element, o), o);
|
17093 | };
|
17094 |
|
17095 | Hammer.assign(PropagatingHammer, Hammer);
|
17096 |
|
17097 | PropagatingHammer.Manager = function (element, options) {
|
17098 | var o = Object.create(_options);
|
17099 | if (options) Hammer.assign(o, options);
|
17100 | return propagating(new Hammer.Manager(element, o), o);
|
17101 | };
|
17102 |
|
17103 | return PropagatingHammer;
|
17104 | }
|
17105 |
|
17106 |
|
17107 |
|
17108 | var wrapper = Object.create(hammer);
|
17109 |
|
17110 | var element = hammer.element;
|
17111 | if (!element.hammer) element.hammer = [];
|
17112 | element.hammer.push(wrapper);
|
17113 |
|
17114 |
|
17115 | hammer.on('hammer.input', function (event) {
|
17116 | if (_options.preventDefault === true || _options.preventDefault === event.pointerType) {
|
17117 | event.preventDefault();
|
17118 | }
|
17119 |
|
17120 | if (event.isFirst) {
|
17121 | _firstTarget = event.target;
|
17122 | }
|
17123 | });
|
17124 |
|
17125 |
|
17126 | wrapper._handlers = {};
|
17127 | |
17128 |
|
17129 |
|
17130 |
|
17131 |
|
17132 |
|
17133 |
|
17134 | wrapper.on = function (events, handler) {
|
17135 |
|
17136 | split(events).forEach(function (event) {
|
17137 | var _handlers = wrapper._handlers[event];
|
17138 |
|
17139 | if (!_handlers) {
|
17140 | wrapper._handlers[event] = _handlers = [];
|
17141 |
|
17142 | hammer.on(event, propagatedHandler);
|
17143 | }
|
17144 |
|
17145 | _handlers.push(handler);
|
17146 | });
|
17147 | return wrapper;
|
17148 | };
|
17149 | |
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 | wrapper.off = function (events, handler) {
|
17160 |
|
17161 | split(events).forEach(function (event) {
|
17162 | var _handlers = wrapper._handlers[event];
|
17163 |
|
17164 | if (_handlers) {
|
17165 | _handlers = handler ? _handlers.filter(function (h) {
|
17166 | return h !== handler;
|
17167 | }) : [];
|
17168 |
|
17169 | if (_handlers.length > 0) {
|
17170 | wrapper._handlers[event] = _handlers;
|
17171 | } else {
|
17172 |
|
17173 | hammer.off(event, propagatedHandler);
|
17174 | delete wrapper._handlers[event];
|
17175 | }
|
17176 | }
|
17177 | });
|
17178 | return wrapper;
|
17179 | };
|
17180 | |
17181 |
|
17182 |
|
17183 |
|
17184 |
|
17185 |
|
17186 |
|
17187 | wrapper.emit = function (eventType, event) {
|
17188 | _firstTarget = event.target;
|
17189 | hammer.emit(eventType, event);
|
17190 | };
|
17191 |
|
17192 | wrapper.destroy = function () {
|
17193 |
|
17194 | var hammers = hammer.element.hammer;
|
17195 | var idx = hammers.indexOf(wrapper);
|
17196 | if (idx !== -1) hammers.splice(idx, 1);
|
17197 | if (!hammers.length) delete hammer.element.hammer;
|
17198 |
|
17199 | wrapper._handlers = {};
|
17200 |
|
17201 | hammer.destroy();
|
17202 | };
|
17203 |
|
17204 |
|
17205 | function split(events) {
|
17206 | return events.match(/[^ ]+/g);
|
17207 | }
|
17208 | |
17209 |
|
17210 |
|
17211 |
|
17212 |
|
17213 |
|
17214 | function propagatedHandler(event) {
|
17215 |
|
17216 | if (event.type !== 'hammer.input') {
|
17217 |
|
17218 |
|
17219 | if (!event.srcEvent._handled) {
|
17220 | event.srcEvent._handled = {};
|
17221 | }
|
17222 |
|
17223 | if (event.srcEvent._handled[event.type]) {
|
17224 | return;
|
17225 | } else {
|
17226 | event.srcEvent._handled[event.type] = true;
|
17227 | }
|
17228 | }
|
17229 |
|
17230 |
|
17231 | var stopped = false;
|
17232 |
|
17233 | event.stopPropagation = function () {
|
17234 | stopped = true;
|
17235 | };
|
17236 |
|
17237 |
|
17238 | var srcStop = event.srcEvent.stopPropagation.bind(event.srcEvent);
|
17239 |
|
17240 | if (typeof srcStop == "function") {
|
17241 | event.srcEvent.stopPropagation = function () {
|
17242 | srcStop();
|
17243 | event.stopPropagation();
|
17244 | };
|
17245 | }
|
17246 |
|
17247 |
|
17248 | event.firstTarget = _firstTarget;
|
17249 |
|
17250 | var elem = _firstTarget;
|
17251 |
|
17252 | while (elem && !stopped) {
|
17253 | var elemHammer = elem.hammer;
|
17254 |
|
17255 | if (elemHammer) {
|
17256 | var _handlers;
|
17257 |
|
17258 | for (var k = 0; k < elemHammer.length; k++) {
|
17259 | _handlers = elemHammer[k]._handlers[event.type];
|
17260 | if (_handlers) for (var i = 0; i < _handlers.length && !stopped; i++) {
|
17261 | _handlers[i](event);
|
17262 | }
|
17263 | }
|
17264 | }
|
17265 |
|
17266 | elem = elem.parentNode;
|
17267 | }
|
17268 | }
|
17269 |
|
17270 | return wrapper;
|
17271 | }
|
17272 |
|
17273 |
|
17274 |
|
17275 |
|
17276 |
|
17277 |
|
17278 |
|
17279 |
|
17280 |
|
17281 | function hammerMock() {
|
17282 | var noop = function noop() {};
|
17283 |
|
17284 | return {
|
17285 | on: noop,
|
17286 | off: noop,
|
17287 | destroy: noop,
|
17288 | emit: noop,
|
17289 | get: function get(m) {
|
17290 |
|
17291 | return {
|
17292 | set: noop
|
17293 | };
|
17294 | }
|
17295 | };
|
17296 | }
|
17297 |
|
17298 | var modifiedHammer;
|
17299 |
|
17300 | if (typeof window !== 'undefined') {
|
17301 | var OurHammer = window['Hammer'] || Hammer$3;
|
17302 | modifiedHammer = propagating(OurHammer, {
|
17303 | preventDefault: 'mouse'
|
17304 | });
|
17305 | } else {
|
17306 | modifiedHammer = function modifiedHammer() {
|
17307 | return (
|
17308 | hammerMock()
|
17309 | );
|
17310 | };
|
17311 | }
|
17312 |
|
17313 | var Hammer = modifiedHammer;
|
17314 |
|
17315 |
|
17316 |
|
17317 |
|
17318 |
|
17319 |
|
17320 | function onTouch(hammer, callback) {
|
17321 | callback.inputHandler = function (event) {
|
17322 | if (event.isFirst) {
|
17323 | callback(event);
|
17324 | }
|
17325 | };
|
17326 |
|
17327 | hammer.on('hammer.input', callback.inputHandler);
|
17328 | }
|
17329 |
|
17330 |
|
17331 |
|
17332 |
|
17333 |
|
17334 |
|
17335 |
|
17336 | function onRelease(hammer, callback) {
|
17337 | callback.inputHandler = function (event) {
|
17338 | if (event.isFinal) {
|
17339 | callback(event);
|
17340 | }
|
17341 | };
|
17342 |
|
17343 | return hammer.on('hammer.input', callback.inputHandler);
|
17344 | }
|
17345 |
|
17346 |
|
17347 |
|
17348 |
|
17349 |
|
17350 |
|
17351 |
|
17352 |
|
17353 |
|
17354 |
|
17355 | function disablePreventDefaultVertically(pinchRecognizer) {
|
17356 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
17357 |
|
17358 | pinchRecognizer.getTouchAction = function () {
|
17359 |
|
17360 | return [TOUCH_ACTION_PAN_Y];
|
17361 | };
|
17362 |
|
17363 | return pinchRecognizer;
|
17364 | }
|
17365 |
|
17366 |
|
17367 |
|
17368 |
|
17369 |
|
17370 |
|
17371 |
|
17372 |
|
17373 |
|
17374 |
|
17375 |
|
17376 |
|
17377 |
|
17378 |
|
17379 |
|
17380 |
|
17381 |
|
17382 |
|
17383 |
|
17384 |
|
17385 |
|
17386 |
|
17387 |
|
17388 | var TimeStep = function () {
|
17389 | |
17390 |
|
17391 |
|
17392 |
|
17393 |
|
17394 |
|
17395 |
|
17396 |
|
17397 |
|
17398 | function TimeStep(start, end, minimumStep, hiddenDates, options) {
|
17399 | _classCallCheck(this, TimeStep);
|
17400 |
|
17401 | this.moment = options && options.moment || moment$2;
|
17402 | this.options = options ? options : {};
|
17403 |
|
17404 | this.current = this.moment();
|
17405 | this._start = this.moment();
|
17406 | this._end = this.moment();
|
17407 | this.autoScale = true;
|
17408 | this.scale = 'day';
|
17409 | this.step = 1;
|
17410 |
|
17411 | this.setRange(start, end, minimumStep);
|
17412 |
|
17413 | this.switchedDay = false;
|
17414 | this.switchedMonth = false;
|
17415 | this.switchedYear = false;
|
17416 |
|
17417 | if (_Array$isArray$1(hiddenDates)) {
|
17418 | this.hiddenDates = hiddenDates;
|
17419 | } else if (hiddenDates != undefined) {
|
17420 | this.hiddenDates = [hiddenDates];
|
17421 | } else {
|
17422 | this.hiddenDates = [];
|
17423 | }
|
17424 |
|
17425 | this.format = TimeStep.FORMAT;
|
17426 | }
|
17427 | |
17428 |
|
17429 |
|
17430 |
|
17431 |
|
17432 |
|
17433 |
|
17434 | _createClass(TimeStep, [{
|
17435 | key: "setMoment",
|
17436 | value: function setMoment(moment) {
|
17437 | this.moment = moment;
|
17438 |
|
17439 | this.current = this.moment(this.current.valueOf());
|
17440 | this._start = this.moment(this._start.valueOf());
|
17441 | this._end = this.moment(this._end.valueOf());
|
17442 | }
|
17443 | |
17444 |
|
17445 |
|
17446 |
|
17447 |
|
17448 |
|
17449 |
|
17450 | }, {
|
17451 | key: "setFormat",
|
17452 | value: function setFormat(format) {
|
17453 | var defaultFormat = availableUtils.deepExtend({}, TimeStep.FORMAT);
|
17454 | this.format = availableUtils.deepExtend(defaultFormat, format);
|
17455 | }
|
17456 | |
17457 |
|
17458 |
|
17459 |
|
17460 |
|
17461 |
|
17462 |
|
17463 |
|
17464 |
|
17465 |
|
17466 |
|
17467 | }, {
|
17468 | key: "setRange",
|
17469 | value: function setRange(start, end, minimumStep) {
|
17470 | if (!(start instanceof Date) || !(end instanceof Date)) {
|
17471 | throw "No legal start or end date in method setRange";
|
17472 | }
|
17473 |
|
17474 | this._start = start != undefined ? this.moment(start.valueOf()) : _Date$now();
|
17475 | this._end = end != undefined ? this.moment(end.valueOf()) : _Date$now();
|
17476 |
|
17477 | if (this.autoScale) {
|
17478 | this.setMinimumStep(minimumStep);
|
17479 | }
|
17480 | }
|
17481 | |
17482 |
|
17483 |
|
17484 |
|
17485 | }, {
|
17486 | key: "start",
|
17487 | value: function start() {
|
17488 | this.current = this._start.clone();
|
17489 | this.roundToMinor();
|
17490 | }
|
17491 | |
17492 |
|
17493 |
|
17494 |
|
17495 |
|
17496 | }, {
|
17497 | key: "roundToMinor",
|
17498 | value: function roundToMinor() {
|
17499 |
|
17500 |
|
17501 | if (this.scale == 'week') {
|
17502 | this.current.weekday(0);
|
17503 | }
|
17504 |
|
17505 |
|
17506 |
|
17507 | switch (this.scale) {
|
17508 | case 'year':
|
17509 | this.current.year(this.step * Math.floor(this.current.year() / this.step));
|
17510 | this.current.month(0);
|
17511 |
|
17512 |
|
17513 | case 'month':
|
17514 | this.current.date(1);
|
17515 |
|
17516 |
|
17517 | case 'week':
|
17518 |
|
17519 | case 'day':
|
17520 |
|
17521 | case 'weekday':
|
17522 | this.current.hours(0);
|
17523 |
|
17524 |
|
17525 | case 'hour':
|
17526 | this.current.minutes(0);
|
17527 |
|
17528 |
|
17529 | case 'minute':
|
17530 | this.current.seconds(0);
|
17531 |
|
17532 |
|
17533 | case 'second':
|
17534 | this.current.milliseconds(0);
|
17535 |
|
17536 |
|
17537 | }
|
17538 |
|
17539 | if (this.step != 1) {
|
17540 |
|
17541 | var priorCurrent = this.current.clone();
|
17542 |
|
17543 | switch (this.scale) {
|
17544 | case 'millisecond':
|
17545 | this.current.subtract(this.current.milliseconds() % this.step, 'milliseconds');
|
17546 | break;
|
17547 |
|
17548 | case 'second':
|
17549 | this.current.subtract(this.current.seconds() % this.step, 'seconds');
|
17550 | break;
|
17551 |
|
17552 | case 'minute':
|
17553 | this.current.subtract(this.current.minutes() % this.step, 'minutes');
|
17554 | break;
|
17555 |
|
17556 | case 'hour':
|
17557 | this.current.subtract(this.current.hours() % this.step, 'hours');
|
17558 | break;
|
17559 |
|
17560 | case 'weekday':
|
17561 |
|
17562 | case 'day':
|
17563 | this.current.subtract((this.current.date() - 1) % this.step, 'day');
|
17564 | break;
|
17565 |
|
17566 | case 'week':
|
17567 | this.current.subtract(this.current.week() % this.step, 'week');
|
17568 | break;
|
17569 |
|
17570 | case 'month':
|
17571 | this.current.subtract(this.current.month() % this.step, 'month');
|
17572 | break;
|
17573 |
|
17574 | case 'year':
|
17575 | this.current.subtract(this.current.year() % this.step, 'year');
|
17576 | break;
|
17577 | }
|
17578 |
|
17579 | if (!priorCurrent.isSame(this.current)) {
|
17580 | this.current = this.moment(snapAwayFromHidden(this.hiddenDates, this.current.valueOf(), -1, true));
|
17581 | }
|
17582 | }
|
17583 | }
|
17584 | |
17585 |
|
17586 |
|
17587 |
|
17588 |
|
17589 | }, {
|
17590 | key: "hasNext",
|
17591 | value: function hasNext() {
|
17592 | return this.current.valueOf() <= this._end.valueOf();
|
17593 | }
|
17594 | |
17595 |
|
17596 |
|
17597 |
|
17598 | }, {
|
17599 | key: "next",
|
17600 | value: function next() {
|
17601 | var prev = this.current.valueOf();
|
17602 |
|
17603 |
|
17604 | switch (this.scale) {
|
17605 | case 'millisecond':
|
17606 | this.current.add(this.step, 'millisecond');
|
17607 | break;
|
17608 |
|
17609 | case 'second':
|
17610 | this.current.add(this.step, 'second');
|
17611 | break;
|
17612 |
|
17613 | case 'minute':
|
17614 | this.current.add(this.step, 'minute');
|
17615 | break;
|
17616 |
|
17617 | case 'hour':
|
17618 | this.current.add(this.step, 'hour');
|
17619 |
|
17620 | if (this.current.month() < 6) {
|
17621 | this.current.subtract(this.current.hours() % this.step, 'hour');
|
17622 | } else {
|
17623 | if (this.current.hours() % this.step !== 0) {
|
17624 | this.current.add(this.step - this.current.hours() % this.step, 'hour');
|
17625 | }
|
17626 | }
|
17627 |
|
17628 | break;
|
17629 |
|
17630 | case 'weekday':
|
17631 |
|
17632 | case 'day':
|
17633 | this.current.add(this.step, 'day');
|
17634 | break;
|
17635 |
|
17636 | case 'week':
|
17637 | if (this.current.weekday() !== 0) {
|
17638 |
|
17639 | this.current.weekday(0);
|
17640 |
|
17641 | this.current.add(this.step, 'week');
|
17642 | } else if (this.options.showMajorLabels === false) {
|
17643 | this.current.add(this.step, 'week');
|
17644 | } else {
|
17645 |
|
17646 | var nextWeek = this.current.clone();
|
17647 | nextWeek.add(1, 'week');
|
17648 |
|
17649 | if (nextWeek.isSame(this.current, 'month')) {
|
17650 |
|
17651 | this.current.add(this.step, 'week');
|
17652 | } else {
|
17653 |
|
17654 | this.current.add(this.step, 'week');
|
17655 | this.current.date(1);
|
17656 | }
|
17657 | }
|
17658 |
|
17659 | break;
|
17660 |
|
17661 | case 'month':
|
17662 | this.current.add(this.step, 'month');
|
17663 | break;
|
17664 |
|
17665 | case 'year':
|
17666 | this.current.add(this.step, 'year');
|
17667 | break;
|
17668 | }
|
17669 |
|
17670 | if (this.step != 1) {
|
17671 |
|
17672 | switch (this.scale) {
|
17673 | case 'millisecond':
|
17674 | if (this.current.milliseconds() > 0 && this.current.milliseconds() < this.step) this.current.milliseconds(0);
|
17675 | break;
|
17676 |
|
17677 | case 'second':
|
17678 | if (this.current.seconds() > 0 && this.current.seconds() < this.step) this.current.seconds(0);
|
17679 | break;
|
17680 |
|
17681 | case 'minute':
|
17682 | if (this.current.minutes() > 0 && this.current.minutes() < this.step) this.current.minutes(0);
|
17683 | break;
|
17684 |
|
17685 | case 'hour':
|
17686 | if (this.current.hours() > 0 && this.current.hours() < this.step) this.current.hours(0);
|
17687 | break;
|
17688 |
|
17689 | case 'weekday':
|
17690 |
|
17691 | case 'day':
|
17692 | if (this.current.date() < this.step + 1) this.current.date(1);
|
17693 | break;
|
17694 |
|
17695 | case 'week':
|
17696 | if (this.current.week() < this.step) this.current.week(1);
|
17697 | break;
|
17698 |
|
17699 |
|
17700 | case 'month':
|
17701 | if (this.current.month() < this.step) this.current.month(0);
|
17702 | break;
|
17703 | }
|
17704 | }
|
17705 |
|
17706 |
|
17707 | if (this.current.valueOf() == prev) {
|
17708 | this.current = this._end.clone();
|
17709 | }
|
17710 |
|
17711 |
|
17712 | this.switchedDay = false;
|
17713 | this.switchedMonth = false;
|
17714 | this.switchedYear = false;
|
17715 | stepOverHiddenDates(this.moment, this, prev);
|
17716 | }
|
17717 | |
17718 |
|
17719 |
|
17720 |
|
17721 |
|
17722 | }, {
|
17723 | key: "getCurrent",
|
17724 | value: function getCurrent() {
|
17725 | return this.current.clone();
|
17726 | }
|
17727 | |
17728 |
|
17729 |
|
17730 |
|
17731 |
|
17732 |
|
17733 |
|
17734 |
|
17735 |
|
17736 |
|
17737 |
|
17738 |
|
17739 |
|
17740 | }, {
|
17741 | key: "setScale",
|
17742 | value: function setScale(params) {
|
17743 | if (params && typeof params.scale == 'string') {
|
17744 | this.scale = params.scale;
|
17745 | this.step = params.step > 0 ? params.step : 1;
|
17746 | this.autoScale = false;
|
17747 | }
|
17748 | }
|
17749 | |
17750 |
|
17751 |
|
17752 |
|
17753 |
|
17754 | }, {
|
17755 | key: "setAutoScale",
|
17756 | value: function setAutoScale(enable) {
|
17757 | this.autoScale = enable;
|
17758 | }
|
17759 | |
17760 |
|
17761 |
|
17762 |
|
17763 |
|
17764 | }, {
|
17765 | key: "setMinimumStep",
|
17766 | value: function setMinimumStep(minimumStep) {
|
17767 | if (minimumStep == undefined) {
|
17768 | return;
|
17769 | }
|
17770 |
|
17771 |
|
17772 | var stepYear = 1000 * 60 * 60 * 24 * 30 * 12;
|
17773 | var stepMonth = 1000 * 60 * 60 * 24 * 30;
|
17774 | var stepDay = 1000 * 60 * 60 * 24;
|
17775 | var stepHour = 1000 * 60 * 60;
|
17776 | var stepMinute = 1000 * 60;
|
17777 | var stepSecond = 1000;
|
17778 | var stepMillisecond = 1;
|
17779 |
|
17780 | if (stepYear * 1000 > minimumStep) {
|
17781 | this.scale = 'year';
|
17782 | this.step = 1000;
|
17783 | }
|
17784 |
|
17785 | if (stepYear * 500 > minimumStep) {
|
17786 | this.scale = 'year';
|
17787 | this.step = 500;
|
17788 | }
|
17789 |
|
17790 | if (stepYear * 100 > minimumStep) {
|
17791 | this.scale = 'year';
|
17792 | this.step = 100;
|
17793 | }
|
17794 |
|
17795 | if (stepYear * 50 > minimumStep) {
|
17796 | this.scale = 'year';
|
17797 | this.step = 50;
|
17798 | }
|
17799 |
|
17800 | if (stepYear * 10 > minimumStep) {
|
17801 | this.scale = 'year';
|
17802 | this.step = 10;
|
17803 | }
|
17804 |
|
17805 | if (stepYear * 5 > minimumStep) {
|
17806 | this.scale = 'year';
|
17807 | this.step = 5;
|
17808 | }
|
17809 |
|
17810 | if (stepYear > minimumStep) {
|
17811 | this.scale = 'year';
|
17812 | this.step = 1;
|
17813 | }
|
17814 |
|
17815 | if (stepMonth * 3 > minimumStep) {
|
17816 | this.scale = 'month';
|
17817 | this.step = 3;
|
17818 | }
|
17819 |
|
17820 | if (stepMonth > minimumStep) {
|
17821 | this.scale = 'month';
|
17822 | this.step = 1;
|
17823 | }
|
17824 |
|
17825 | if (stepDay * 7 > minimumStep && this.options.showWeekScale) {
|
17826 | this.scale = 'week';
|
17827 | this.step = 1;
|
17828 | }
|
17829 |
|
17830 | if (stepDay * 2 > minimumStep) {
|
17831 | this.scale = 'day';
|
17832 | this.step = 2;
|
17833 | }
|
17834 |
|
17835 | if (stepDay > minimumStep) {
|
17836 | this.scale = 'day';
|
17837 | this.step = 1;
|
17838 | }
|
17839 |
|
17840 | if (stepDay / 2 > minimumStep) {
|
17841 | this.scale = 'weekday';
|
17842 | this.step = 1;
|
17843 | }
|
17844 |
|
17845 | if (stepHour * 4 > minimumStep) {
|
17846 | this.scale = 'hour';
|
17847 | this.step = 4;
|
17848 | }
|
17849 |
|
17850 | if (stepHour > minimumStep) {
|
17851 | this.scale = 'hour';
|
17852 | this.step = 1;
|
17853 | }
|
17854 |
|
17855 | if (stepMinute * 15 > minimumStep) {
|
17856 | this.scale = 'minute';
|
17857 | this.step = 15;
|
17858 | }
|
17859 |
|
17860 | if (stepMinute * 10 > minimumStep) {
|
17861 | this.scale = 'minute';
|
17862 | this.step = 10;
|
17863 | }
|
17864 |
|
17865 | if (stepMinute * 5 > minimumStep) {
|
17866 | this.scale = 'minute';
|
17867 | this.step = 5;
|
17868 | }
|
17869 |
|
17870 | if (stepMinute > minimumStep) {
|
17871 | this.scale = 'minute';
|
17872 | this.step = 1;
|
17873 | }
|
17874 |
|
17875 | if (stepSecond * 15 > minimumStep) {
|
17876 | this.scale = 'second';
|
17877 | this.step = 15;
|
17878 | }
|
17879 |
|
17880 | if (stepSecond * 10 > minimumStep) {
|
17881 | this.scale = 'second';
|
17882 | this.step = 10;
|
17883 | }
|
17884 |
|
17885 | if (stepSecond * 5 > minimumStep) {
|
17886 | this.scale = 'second';
|
17887 | this.step = 5;
|
17888 | }
|
17889 |
|
17890 | if (stepSecond > minimumStep) {
|
17891 | this.scale = 'second';
|
17892 | this.step = 1;
|
17893 | }
|
17894 |
|
17895 | if (stepMillisecond * 200 > minimumStep) {
|
17896 | this.scale = 'millisecond';
|
17897 | this.step = 200;
|
17898 | }
|
17899 |
|
17900 | if (stepMillisecond * 100 > minimumStep) {
|
17901 | this.scale = 'millisecond';
|
17902 | this.step = 100;
|
17903 | }
|
17904 |
|
17905 | if (stepMillisecond * 50 > minimumStep) {
|
17906 | this.scale = 'millisecond';
|
17907 | this.step = 50;
|
17908 | }
|
17909 |
|
17910 | if (stepMillisecond * 10 > minimumStep) {
|
17911 | this.scale = 'millisecond';
|
17912 | this.step = 10;
|
17913 | }
|
17914 |
|
17915 | if (stepMillisecond * 5 > minimumStep) {
|
17916 | this.scale = 'millisecond';
|
17917 | this.step = 5;
|
17918 | }
|
17919 |
|
17920 | if (stepMillisecond > minimumStep) {
|
17921 | this.scale = 'millisecond';
|
17922 | this.step = 1;
|
17923 | }
|
17924 | }
|
17925 | |
17926 |
|
17927 |
|
17928 |
|
17929 |
|
17930 |
|
17931 |
|
17932 |
|
17933 |
|
17934 |
|
17935 |
|
17936 | }, {
|
17937 | key: "isMajor",
|
17938 | value:
|
17939 | |
17940 |
|
17941 |
|
17942 |
|
17943 |
|
17944 | function isMajor() {
|
17945 | if (this.switchedYear == true) {
|
17946 | switch (this.scale) {
|
17947 | case 'year':
|
17948 | case 'month':
|
17949 | case 'week':
|
17950 | case 'weekday':
|
17951 | case 'day':
|
17952 | case 'hour':
|
17953 | case 'minute':
|
17954 | case 'second':
|
17955 | case 'millisecond':
|
17956 | return true;
|
17957 |
|
17958 | default:
|
17959 | return false;
|
17960 | }
|
17961 | } else if (this.switchedMonth == true) {
|
17962 | switch (this.scale) {
|
17963 | case 'week':
|
17964 | case 'weekday':
|
17965 | case 'day':
|
17966 | case 'hour':
|
17967 | case 'minute':
|
17968 | case 'second':
|
17969 | case 'millisecond':
|
17970 | return true;
|
17971 |
|
17972 | default:
|
17973 | return false;
|
17974 | }
|
17975 | } else if (this.switchedDay == true) {
|
17976 | switch (this.scale) {
|
17977 | case 'millisecond':
|
17978 | case 'second':
|
17979 | case 'minute':
|
17980 | case 'hour':
|
17981 | return true;
|
17982 |
|
17983 | default:
|
17984 | return false;
|
17985 | }
|
17986 | }
|
17987 |
|
17988 | var date = this.moment(this.current);
|
17989 |
|
17990 | switch (this.scale) {
|
17991 | case 'millisecond':
|
17992 | return date.milliseconds() == 0;
|
17993 |
|
17994 | case 'second':
|
17995 | return date.seconds() == 0;
|
17996 |
|
17997 | case 'minute':
|
17998 | return date.hours() == 0 && date.minutes() == 0;
|
17999 |
|
18000 | case 'hour':
|
18001 | return date.hours() == 0;
|
18002 |
|
18003 | case 'weekday':
|
18004 |
|
18005 | case 'day':
|
18006 | return this.options.showWeekScale ? date.isoWeekday() == 1 : date.date() == 1;
|
18007 |
|
18008 | case 'week':
|
18009 | return date.date() == 1;
|
18010 |
|
18011 | case 'month':
|
18012 | return date.month() == 0;
|
18013 |
|
18014 | case 'year':
|
18015 | return false;
|
18016 |
|
18017 | default:
|
18018 | return false;
|
18019 | }
|
18020 | }
|
18021 | |
18022 |
|
18023 |
|
18024 |
|
18025 |
|
18026 |
|
18027 |
|
18028 |
|
18029 | }, {
|
18030 | key: "getLabelMinor",
|
18031 | value: function getLabelMinor(date) {
|
18032 | if (date == undefined) {
|
18033 | date = this.current;
|
18034 | }
|
18035 |
|
18036 | if (date instanceof Date) {
|
18037 | date = this.moment(date);
|
18038 | }
|
18039 |
|
18040 | if (typeof this.format.minorLabels === "function") {
|
18041 | return this.format.minorLabels(date, this.scale, this.step);
|
18042 | }
|
18043 |
|
18044 | var format = this.format.minorLabels[this.scale];
|
18045 |
|
18046 | switch (this.scale) {
|
18047 | case 'week':
|
18048 |
|
18049 |
|
18050 | if (date.date() === 1 && date.weekday() !== 0) {
|
18051 | return "";
|
18052 | }
|
18053 |
|
18054 | default:
|
18055 |
|
18056 | return format && format.length > 0 ? this.moment(date).format(format) : '';
|
18057 | }
|
18058 | }
|
18059 | |
18060 |
|
18061 |
|
18062 |
|
18063 |
|
18064 |
|
18065 |
|
18066 |
|
18067 | }, {
|
18068 | key: "getLabelMajor",
|
18069 | value: function getLabelMajor(date) {
|
18070 | if (date == undefined) {
|
18071 | date = this.current;
|
18072 | }
|
18073 |
|
18074 | if (date instanceof Date) {
|
18075 | date = this.moment(date);
|
18076 | }
|
18077 |
|
18078 | if (typeof this.format.majorLabels === "function") {
|
18079 | return this.format.majorLabels(date, this.scale, this.step);
|
18080 | }
|
18081 |
|
18082 | var format = this.format.majorLabels[this.scale];
|
18083 | return format && format.length > 0 ? this.moment(date).format(format) : '';
|
18084 | }
|
18085 | |
18086 |
|
18087 |
|
18088 |
|
18089 |
|
18090 | }, {
|
18091 | key: "getClassName",
|
18092 | value: function getClassName() {
|
18093 | var _context;
|
18094 |
|
18095 | var _moment = this.moment;
|
18096 | var m = this.moment(this.current);
|
18097 | var current = m.locale ? m.locale('en') : m.lang('en');
|
18098 |
|
18099 | var step = this.step;
|
18100 | var classNames = [];
|
18101 | |
18102 |
|
18103 |
|
18104 |
|
18105 |
|
18106 |
|
18107 | function even(value) {
|
18108 | return value / step % 2 == 0 ? ' vis-even' : ' vis-odd';
|
18109 | }
|
18110 | |
18111 |
|
18112 |
|
18113 |
|
18114 |
|
18115 |
|
18116 |
|
18117 | function today(date) {
|
18118 | if (date.isSame(_Date$now(), 'day')) {
|
18119 | return ' vis-today';
|
18120 | }
|
18121 |
|
18122 | if (date.isSame(_moment().add(1, 'day'), 'day')) {
|
18123 | return ' vis-tomorrow';
|
18124 | }
|
18125 |
|
18126 | if (date.isSame(_moment().add(-1, 'day'), 'day')) {
|
18127 | return ' vis-yesterday';
|
18128 | }
|
18129 |
|
18130 | return '';
|
18131 | }
|
18132 | |
18133 |
|
18134 |
|
18135 |
|
18136 |
|
18137 |
|
18138 |
|
18139 | function currentWeek(date) {
|
18140 | return date.isSame(_Date$now(), 'week') ? ' vis-current-week' : '';
|
18141 | }
|
18142 | |
18143 |
|
18144 |
|
18145 |
|
18146 |
|
18147 |
|
18148 |
|
18149 | function currentMonth(date) {
|
18150 | return date.isSame(_Date$now(), 'month') ? ' vis-current-month' : '';
|
18151 | }
|
18152 | |
18153 |
|
18154 |
|
18155 |
|
18156 |
|
18157 |
|
18158 |
|
18159 | function currentYear(date) {
|
18160 | return date.isSame(_Date$now(), 'year') ? ' vis-current-year' : '';
|
18161 | }
|
18162 |
|
18163 | switch (this.scale) {
|
18164 | case 'millisecond':
|
18165 | classNames.push(today(current));
|
18166 | classNames.push(even(current.milliseconds()));
|
18167 | break;
|
18168 |
|
18169 | case 'second':
|
18170 | classNames.push(today(current));
|
18171 | classNames.push(even(current.seconds()));
|
18172 | break;
|
18173 |
|
18174 | case 'minute':
|
18175 | classNames.push(today(current));
|
18176 | classNames.push(even(current.minutes()));
|
18177 | break;
|
18178 |
|
18179 | case 'hour':
|
18180 | classNames.push(_concatInstanceProperty(_context = "vis-h".concat(current.hours())).call(_context, this.step == 4 ? '-h' + (current.hours() + 4) : ''));
|
18181 | classNames.push(today(current));
|
18182 | classNames.push(even(current.hours()));
|
18183 | break;
|
18184 |
|
18185 | case 'weekday':
|
18186 | classNames.push("vis-".concat(current.format('dddd').toLowerCase()));
|
18187 | classNames.push(today(current));
|
18188 | classNames.push(currentWeek(current));
|
18189 | classNames.push(even(current.date()));
|
18190 | break;
|
18191 |
|
18192 | case 'day':
|
18193 | classNames.push("vis-day".concat(current.date()));
|
18194 | classNames.push("vis-".concat(current.format('MMMM').toLowerCase()));
|
18195 | classNames.push(today(current));
|
18196 | classNames.push(currentMonth(current));
|
18197 | classNames.push(this.step <= 2 ? today(current) : '');
|
18198 | classNames.push(this.step <= 2 ? "vis-".concat(current.format('dddd').toLowerCase()) : '');
|
18199 | classNames.push(even(current.date() - 1));
|
18200 | break;
|
18201 |
|
18202 | case 'week':
|
18203 | classNames.push("vis-week".concat(current.format('w')));
|
18204 | classNames.push(currentWeek(current));
|
18205 | classNames.push(even(current.week()));
|
18206 | break;
|
18207 |
|
18208 | case 'month':
|
18209 | classNames.push("vis-".concat(current.format('MMMM').toLowerCase()));
|
18210 | classNames.push(currentMonth(current));
|
18211 | classNames.push(even(current.month()));
|
18212 | break;
|
18213 |
|
18214 | case 'year':
|
18215 | classNames.push("vis-year".concat(current.year()));
|
18216 | classNames.push(currentYear(current));
|
18217 | classNames.push(even(current.year()));
|
18218 | break;
|
18219 | }
|
18220 |
|
18221 | return _filterInstanceProperty(classNames).call(classNames, String).join(" ");
|
18222 | }
|
18223 | }], [{
|
18224 | key: "snap",
|
18225 | value: function snap(date, scale, step) {
|
18226 | var clone = moment$2(date);
|
18227 |
|
18228 | if (scale == 'year') {
|
18229 | var year = clone.year() + Math.round(clone.month() / 12);
|
18230 | clone.year(Math.round(year / step) * step);
|
18231 | clone.month(0);
|
18232 | clone.date(0);
|
18233 | clone.hours(0);
|
18234 | clone.minutes(0);
|
18235 | clone.seconds(0);
|
18236 | clone.milliseconds(0);
|
18237 | } else if (scale == 'month') {
|
18238 | if (clone.date() > 15) {
|
18239 | clone.date(1);
|
18240 | clone.add(1, 'month');
|
18241 | } else {
|
18242 | clone.date(1);
|
18243 | }
|
18244 |
|
18245 | clone.hours(0);
|
18246 | clone.minutes(0);
|
18247 | clone.seconds(0);
|
18248 | clone.milliseconds(0);
|
18249 | } else if (scale == 'week') {
|
18250 | if (clone.weekday() > 2) {
|
18251 |
|
18252 | clone.weekday(0);
|
18253 | clone.add(1, 'week');
|
18254 | } else {
|
18255 | clone.weekday(0);
|
18256 | }
|
18257 |
|
18258 | clone.hours(0);
|
18259 | clone.minutes(0);
|
18260 | clone.seconds(0);
|
18261 | clone.milliseconds(0);
|
18262 | } else if (scale == 'day') {
|
18263 |
|
18264 | switch (step) {
|
18265 | case 5:
|
18266 | case 2:
|
18267 | clone.hours(Math.round(clone.hours() / 24) * 24);
|
18268 | break;
|
18269 |
|
18270 | default:
|
18271 | clone.hours(Math.round(clone.hours() / 12) * 12);
|
18272 | break;
|
18273 | }
|
18274 |
|
18275 | clone.minutes(0);
|
18276 | clone.seconds(0);
|
18277 | clone.milliseconds(0);
|
18278 | } else if (scale == 'weekday') {
|
18279 |
|
18280 | switch (step) {
|
18281 | case 5:
|
18282 | case 2:
|
18283 | clone.hours(Math.round(clone.hours() / 12) * 12);
|
18284 | break;
|
18285 |
|
18286 | default:
|
18287 | clone.hours(Math.round(clone.hours() / 6) * 6);
|
18288 | break;
|
18289 | }
|
18290 |
|
18291 | clone.minutes(0);
|
18292 | clone.seconds(0);
|
18293 | clone.milliseconds(0);
|
18294 | } else if (scale == 'hour') {
|
18295 | switch (step) {
|
18296 | case 4:
|
18297 | clone.minutes(Math.round(clone.minutes() / 60) * 60);
|
18298 | break;
|
18299 |
|
18300 | default:
|
18301 | clone.minutes(Math.round(clone.minutes() / 30) * 30);
|
18302 | break;
|
18303 | }
|
18304 |
|
18305 | clone.seconds(0);
|
18306 | clone.milliseconds(0);
|
18307 | } else if (scale == 'minute') {
|
18308 |
|
18309 | switch (step) {
|
18310 | case 15:
|
18311 | case 10:
|
18312 | clone.minutes(Math.round(clone.minutes() / 5) * 5);
|
18313 | clone.seconds(0);
|
18314 | break;
|
18315 |
|
18316 | case 5:
|
18317 | clone.seconds(Math.round(clone.seconds() / 60) * 60);
|
18318 | break;
|
18319 |
|
18320 | default:
|
18321 | clone.seconds(Math.round(clone.seconds() / 30) * 30);
|
18322 | break;
|
18323 | }
|
18324 |
|
18325 | clone.milliseconds(0);
|
18326 | } else if (scale == 'second') {
|
18327 |
|
18328 | switch (step) {
|
18329 | case 15:
|
18330 | case 10:
|
18331 | clone.seconds(Math.round(clone.seconds() / 5) * 5);
|
18332 | clone.milliseconds(0);
|
18333 | break;
|
18334 |
|
18335 | case 5:
|
18336 | clone.milliseconds(Math.round(clone.milliseconds() / 1000) * 1000);
|
18337 | break;
|
18338 |
|
18339 | default:
|
18340 | clone.milliseconds(Math.round(clone.milliseconds() / 500) * 500);
|
18341 | break;
|
18342 | }
|
18343 | } else if (scale == 'millisecond') {
|
18344 | var _step = step > 5 ? step / 2 : 1;
|
18345 |
|
18346 | clone.milliseconds(Math.round(clone.milliseconds() / _step) * _step);
|
18347 | }
|
18348 |
|
18349 | return clone;
|
18350 | }
|
18351 | }]);
|
18352 |
|
18353 | return TimeStep;
|
18354 | }();
|
18355 |
|
18356 |
|
18357 | TimeStep.FORMAT = {
|
18358 | minorLabels: {
|
18359 | millisecond: 'SSS',
|
18360 | second: 's',
|
18361 | minute: 'HH:mm',
|
18362 | hour: 'HH:mm',
|
18363 | weekday: 'ddd D',
|
18364 | day: 'D',
|
18365 | week: 'w',
|
18366 | month: 'MMM',
|
18367 | year: 'YYYY'
|
18368 | },
|
18369 | majorLabels: {
|
18370 | millisecond: 'HH:mm:ss',
|
18371 | second: 'D MMMM HH:mm',
|
18372 | minute: 'ddd D MMMM',
|
18373 | hour: 'ddd D MMMM',
|
18374 | weekday: 'MMMM YYYY',
|
18375 | day: 'MMMM YYYY',
|
18376 | week: 'MMMM YYYY',
|
18377 | month: 'YYYY',
|
18378 | year: ''
|
18379 | }
|
18380 | };
|
18381 |
|
18382 | function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$b(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
18383 |
|
18384 | function _isNativeReflectConstruct$b() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
18385 |
|
18386 |
|
18387 | var TimeAxis = function (_Component) {
|
18388 | _inherits(TimeAxis, _Component);
|
18389 |
|
18390 | var _super = _createSuper$b(TimeAxis);
|
18391 |
|
18392 | |
18393 |
|
18394 |
|
18395 |
|
18396 |
|
18397 |
|
18398 |
|
18399 | function TimeAxis(body, options) {
|
18400 | var _this;
|
18401 |
|
18402 | _classCallCheck(this, TimeAxis);
|
18403 |
|
18404 | _this = _super.call(this);
|
18405 | _this.dom = {
|
18406 | foreground: null,
|
18407 | lines: [],
|
18408 | majorTexts: [],
|
18409 | minorTexts: [],
|
18410 | redundant: {
|
18411 | lines: [],
|
18412 | majorTexts: [],
|
18413 | minorTexts: []
|
18414 | }
|
18415 | };
|
18416 | _this.props = {
|
18417 | range: {
|
18418 | start: 0,
|
18419 | end: 0,
|
18420 | minimumStep: 0
|
18421 | },
|
18422 | lineTop: 0
|
18423 | };
|
18424 | _this.defaultOptions = {
|
18425 | orientation: {
|
18426 | axis: 'bottom'
|
18427 | },
|
18428 |
|
18429 | showMinorLabels: true,
|
18430 | showMajorLabels: true,
|
18431 | showWeekScale: false,
|
18432 | maxMinorChars: 7,
|
18433 | format: availableUtils.extend({}, TimeStep.FORMAT),
|
18434 | moment: moment$2,
|
18435 | timeAxis: null
|
18436 | };
|
18437 | _this.options = availableUtils.extend({}, _this.defaultOptions);
|
18438 | _this.body = body;
|
18439 |
|
18440 | _this._create();
|
18441 |
|
18442 | _this.setOptions(options);
|
18443 |
|
18444 | return _this;
|
18445 | }
|
18446 | |
18447 |
|
18448 |
|
18449 |
|
18450 |
|
18451 |
|
18452 |
|
18453 |
|
18454 |
|
18455 |
|
18456 |
|
18457 | _createClass(TimeAxis, [{
|
18458 | key: "setOptions",
|
18459 | value: function setOptions(options) {
|
18460 | if (options) {
|
18461 |
|
18462 | availableUtils.selectiveExtend(['showMinorLabels', 'showMajorLabels', 'showWeekScale', 'maxMinorChars', 'hiddenDates', 'timeAxis', 'moment', 'rtl'], this.options, options);
|
18463 |
|
18464 | availableUtils.selectiveDeepExtend(['format'], this.options, options);
|
18465 |
|
18466 | if ('orientation' in options) {
|
18467 | if (typeof options.orientation === 'string') {
|
18468 | this.options.orientation.axis = options.orientation;
|
18469 | } else if (_typeof(options.orientation) === 'object' && 'axis' in options.orientation) {
|
18470 | this.options.orientation.axis = options.orientation.axis;
|
18471 | }
|
18472 | }
|
18473 |
|
18474 |
|
18475 |
|
18476 | if ('locale' in options) {
|
18477 | if (typeof moment$2.locale === 'function') {
|
18478 |
|
18479 | moment$2.locale(options.locale);
|
18480 | } else {
|
18481 | moment$2.lang(options.locale);
|
18482 | }
|
18483 | }
|
18484 | }
|
18485 | }
|
18486 | |
18487 |
|
18488 |
|
18489 |
|
18490 | }, {
|
18491 | key: "_create",
|
18492 | value: function _create() {
|
18493 | this.dom.foreground = document.createElement('div');
|
18494 | this.dom.background = document.createElement('div');
|
18495 | this.dom.foreground.className = 'vis-time-axis vis-foreground';
|
18496 | this.dom.background.className = 'vis-time-axis vis-background';
|
18497 | }
|
18498 | |
18499 |
|
18500 |
|
18501 |
|
18502 | }, {
|
18503 | key: "destroy",
|
18504 | value: function destroy() {
|
18505 |
|
18506 | if (this.dom.foreground.parentNode) {
|
18507 | this.dom.foreground.parentNode.removeChild(this.dom.foreground);
|
18508 | }
|
18509 |
|
18510 | if (this.dom.background.parentNode) {
|
18511 | this.dom.background.parentNode.removeChild(this.dom.background);
|
18512 | }
|
18513 |
|
18514 | this.body = null;
|
18515 | }
|
18516 | |
18517 |
|
18518 |
|
18519 |
|
18520 |
|
18521 | }, {
|
18522 | key: "redraw",
|
18523 | value: function redraw() {
|
18524 | var props = this.props;
|
18525 | var foreground = this.dom.foreground;
|
18526 | var background = this.dom.background;
|
18527 |
|
18528 | var parent = this.options.orientation.axis == 'top' ? this.body.dom.top : this.body.dom.bottom;
|
18529 | var parentChanged = foreground.parentNode !== parent;
|
18530 |
|
18531 | this._calculateCharSize();
|
18532 |
|
18533 |
|
18534 | var showMinorLabels = this.options.showMinorLabels && this.options.orientation.axis !== 'none';
|
18535 | var showMajorLabels = this.options.showMajorLabels && this.options.orientation.axis !== 'none';
|
18536 |
|
18537 | props.minorLabelHeight = showMinorLabels ? props.minorCharHeight : 0;
|
18538 | props.majorLabelHeight = showMajorLabels ? props.majorCharHeight : 0;
|
18539 | props.height = props.minorLabelHeight + props.majorLabelHeight;
|
18540 | props.width = foreground.offsetWidth;
|
18541 | props.minorLineHeight = this.body.domProps.root.height - props.majorLabelHeight - (this.options.orientation.axis == 'top' ? this.body.domProps.bottom.height : this.body.domProps.top.height);
|
18542 | props.minorLineWidth = 1;
|
18543 |
|
18544 | props.majorLineHeight = props.minorLineHeight + props.majorLabelHeight;
|
18545 | props.majorLineWidth = 1;
|
18546 |
|
18547 |
|
18548 | var foregroundNextSibling = foreground.nextSibling;
|
18549 | var backgroundNextSibling = background.nextSibling;
|
18550 | foreground.parentNode && foreground.parentNode.removeChild(foreground);
|
18551 | background.parentNode && background.parentNode.removeChild(background);
|
18552 | foreground.style.height = "".concat(this.props.height, "px");
|
18553 |
|
18554 | this._repaintLabels();
|
18555 |
|
18556 |
|
18557 | if (foregroundNextSibling) {
|
18558 | parent.insertBefore(foreground, foregroundNextSibling);
|
18559 | } else {
|
18560 | parent.appendChild(foreground);
|
18561 | }
|
18562 |
|
18563 | if (backgroundNextSibling) {
|
18564 | this.body.dom.backgroundVertical.insertBefore(background, backgroundNextSibling);
|
18565 | } else {
|
18566 | this.body.dom.backgroundVertical.appendChild(background);
|
18567 | }
|
18568 |
|
18569 | return this._isResized() || parentChanged;
|
18570 | }
|
18571 | |
18572 |
|
18573 |
|
18574 |
|
18575 |
|
18576 | }, {
|
18577 | key: "_repaintLabels",
|
18578 | value: function _repaintLabels() {
|
18579 | var orientation = this.options.orientation.axis;
|
18580 |
|
18581 | var start = availableUtils.convert(this.body.range.start, 'Number');
|
18582 | var end = availableUtils.convert(this.body.range.end, 'Number');
|
18583 | var timeLabelsize = this.body.util.toTime((this.props.minorCharWidth || 10) * this.options.maxMinorChars).valueOf();
|
18584 | var minimumStep = timeLabelsize - getHiddenDurationBefore(this.options.moment, this.body.hiddenDates, this.body.range, timeLabelsize);
|
18585 | minimumStep -= this.body.util.toTime(0).valueOf();
|
18586 | var step = new TimeStep(new Date(start), new Date(end), minimumStep, this.body.hiddenDates, this.options);
|
18587 | step.setMoment(this.options.moment);
|
18588 |
|
18589 | if (this.options.format) {
|
18590 | step.setFormat(this.options.format);
|
18591 | }
|
18592 |
|
18593 | if (this.options.timeAxis) {
|
18594 | step.setScale(this.options.timeAxis);
|
18595 | }
|
18596 |
|
18597 | this.step = step;
|
18598 |
|
18599 |
|
18600 |
|
18601 | var dom = this.dom;
|
18602 | dom.redundant.lines = dom.lines;
|
18603 | dom.redundant.majorTexts = dom.majorTexts;
|
18604 | dom.redundant.minorTexts = dom.minorTexts;
|
18605 | dom.lines = [];
|
18606 | dom.majorTexts = [];
|
18607 | dom.minorTexts = [];
|
18608 | var current;
|
18609 | var next;
|
18610 | var x;
|
18611 | var xNext;
|
18612 | var isMajor;
|
18613 | var showMinorGrid;
|
18614 | var width = 0;
|
18615 | var prevWidth;
|
18616 | var line;
|
18617 | var xFirstMajorLabel = undefined;
|
18618 | var count = 0;
|
18619 | var MAX = 1000;
|
18620 | var className;
|
18621 | step.start();
|
18622 | next = step.getCurrent();
|
18623 | xNext = this.body.util.toScreen(next);
|
18624 |
|
18625 | while (step.hasNext() && count < MAX) {
|
18626 | count++;
|
18627 | isMajor = step.isMajor();
|
18628 | className = step.getClassName();
|
18629 | current = next;
|
18630 | x = xNext;
|
18631 | step.next();
|
18632 | next = step.getCurrent();
|
18633 | xNext = this.body.util.toScreen(next);
|
18634 | prevWidth = width;
|
18635 | width = xNext - x;
|
18636 |
|
18637 | switch (step.scale) {
|
18638 | case 'week':
|
18639 | showMinorGrid = true;
|
18640 | break;
|
18641 |
|
18642 | default:
|
18643 | showMinorGrid = width >= prevWidth * 0.4;
|
18644 | break;
|
18645 |
|
18646 | }
|
18647 |
|
18648 | if (this.options.showMinorLabels && showMinorGrid) {
|
18649 | var label = this._repaintMinorText(x, step.getLabelMinor(current), orientation, className);
|
18650 |
|
18651 | label.style.width = "".concat(width, "px");
|
18652 | }
|
18653 |
|
18654 | if (isMajor && this.options.showMajorLabels) {
|
18655 | if (x > 0) {
|
18656 | if (xFirstMajorLabel == undefined) {
|
18657 | xFirstMajorLabel = x;
|
18658 | }
|
18659 |
|
18660 | label = this._repaintMajorText(x, step.getLabelMajor(current), orientation, className);
|
18661 | }
|
18662 |
|
18663 | line = this._repaintMajorLine(x, width, orientation, className);
|
18664 | } else {
|
18665 |
|
18666 | if (showMinorGrid) {
|
18667 | line = this._repaintMinorLine(x, width, orientation, className);
|
18668 | } else {
|
18669 | if (line) {
|
18670 |
|
18671 | line.style.width = "".concat(_parseInt(line.style.width) + width, "px");
|
18672 | }
|
18673 | }
|
18674 | }
|
18675 | }
|
18676 |
|
18677 | if (count === MAX && !warnedForOverflow) {
|
18678 | console.warn("Something is wrong with the Timeline scale. Limited drawing of grid lines to ".concat(MAX, " lines."));
|
18679 | warnedForOverflow = true;
|
18680 | }
|
18681 |
|
18682 |
|
18683 | if (this.options.showMajorLabels) {
|
18684 | var leftTime = this.body.util.toTime(0);
|
18685 |
|
18686 | var leftText = step.getLabelMajor(leftTime);
|
18687 | var widthText = leftText.length * (this.props.majorCharWidth || 10) + 10;
|
18688 |
|
18689 | if (xFirstMajorLabel == undefined || widthText < xFirstMajorLabel) {
|
18690 | this._repaintMajorText(0, leftText, orientation, className);
|
18691 | }
|
18692 | }
|
18693 |
|
18694 |
|
18695 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.dom.redundant, function (arr) {
|
18696 | while (arr.length) {
|
18697 | var elem = arr.pop();
|
18698 |
|
18699 | if (elem && elem.parentNode) {
|
18700 | elem.parentNode.removeChild(elem);
|
18701 | }
|
18702 | }
|
18703 | });
|
18704 | }
|
18705 | |
18706 |
|
18707 |
|
18708 |
|
18709 |
|
18710 |
|
18711 |
|
18712 |
|
18713 |
|
18714 |
|
18715 | }, {
|
18716 | key: "_repaintMinorText",
|
18717 | value: function _repaintMinorText(x, text, orientation, className) {
|
18718 |
|
18719 | var label = this.dom.redundant.minorTexts.shift();
|
18720 |
|
18721 | if (!label) {
|
18722 |
|
18723 | var content = document.createTextNode('');
|
18724 | label = document.createElement('div');
|
18725 | label.appendChild(content);
|
18726 | this.dom.foreground.appendChild(label);
|
18727 | }
|
18728 |
|
18729 | this.dom.minorTexts.push(label);
|
18730 | label.innerHTML = availableUtils.xss(text);
|
18731 | var y = orientation == 'top' ? this.props.majorLabelHeight : 0;
|
18732 |
|
18733 | this._setXY(label, x, y);
|
18734 |
|
18735 | label.className = "vis-text vis-minor ".concat(className);
|
18736 |
|
18737 | return label;
|
18738 | }
|
18739 | |
18740 |
|
18741 |
|
18742 |
|
18743 |
|
18744 |
|
18745 |
|
18746 |
|
18747 |
|
18748 |
|
18749 | }, {
|
18750 | key: "_repaintMajorText",
|
18751 | value: function _repaintMajorText(x, text, orientation, className) {
|
18752 |
|
18753 | var label = this.dom.redundant.majorTexts.shift();
|
18754 |
|
18755 | if (!label) {
|
18756 |
|
18757 | var content = document.createElement('div');
|
18758 | label = document.createElement('div');
|
18759 | label.appendChild(content);
|
18760 | this.dom.foreground.appendChild(label);
|
18761 | }
|
18762 |
|
18763 | label.childNodes[0].innerHTML = availableUtils.xss(text);
|
18764 | label.className = "vis-text vis-major ".concat(className);
|
18765 |
|
18766 | var y = orientation == 'top' ? 0 : this.props.minorLabelHeight;
|
18767 |
|
18768 | this._setXY(label, x, y);
|
18769 |
|
18770 | this.dom.majorTexts.push(label);
|
18771 | return label;
|
18772 | }
|
18773 | |
18774 |
|
18775 |
|
18776 |
|
18777 |
|
18778 |
|
18779 |
|
18780 |
|
18781 | }, {
|
18782 | key: "_setXY",
|
18783 | value: function _setXY(label, x, y) {
|
18784 | var _context;
|
18785 |
|
18786 |
|
18787 | var directionX = this.options.rtl ? x * -1 : x;
|
18788 | label.style.transform = _concatInstanceProperty(_context = "translate(".concat(directionX, "px, ")).call(_context, y, "px)");
|
18789 | }
|
18790 | |
18791 |
|
18792 |
|
18793 |
|
18794 |
|
18795 |
|
18796 |
|
18797 |
|
18798 |
|
18799 |
|
18800 | }, {
|
18801 | key: "_repaintMinorLine",
|
18802 | value: function _repaintMinorLine(left, width, orientation, className) {
|
18803 | var _context2;
|
18804 |
|
18805 |
|
18806 | var line = this.dom.redundant.lines.shift();
|
18807 |
|
18808 | if (!line) {
|
18809 |
|
18810 | line = document.createElement('div');
|
18811 | this.dom.background.appendChild(line);
|
18812 | }
|
18813 |
|
18814 | this.dom.lines.push(line);
|
18815 | var props = this.props;
|
18816 | line.style.width = "".concat(width, "px");
|
18817 | line.style.height = "".concat(props.minorLineHeight, "px");
|
18818 | var y = orientation == 'top' ? props.majorLabelHeight : this.body.domProps.top.height;
|
18819 | var x = left - props.minorLineWidth / 2;
|
18820 |
|
18821 | this._setXY(line, x, y);
|
18822 |
|
18823 | line.className = _concatInstanceProperty(_context2 = "vis-grid ".concat(this.options.rtl ? 'vis-vertical-rtl' : 'vis-vertical', " vis-minor ")).call(_context2, className);
|
18824 | return line;
|
18825 | }
|
18826 | |
18827 |
|
18828 |
|
18829 |
|
18830 |
|
18831 |
|
18832 |
|
18833 |
|
18834 |
|
18835 |
|
18836 | }, {
|
18837 | key: "_repaintMajorLine",
|
18838 | value: function _repaintMajorLine(left, width, orientation, className) {
|
18839 | var _context3;
|
18840 |
|
18841 |
|
18842 | var line = this.dom.redundant.lines.shift();
|
18843 |
|
18844 | if (!line) {
|
18845 |
|
18846 | line = document.createElement('div');
|
18847 | this.dom.background.appendChild(line);
|
18848 | }
|
18849 |
|
18850 | this.dom.lines.push(line);
|
18851 | var props = this.props;
|
18852 | line.style.width = "".concat(width, "px");
|
18853 | line.style.height = "".concat(props.majorLineHeight, "px");
|
18854 | var y = orientation == 'top' ? 0 : this.body.domProps.top.height;
|
18855 | var x = left - props.majorLineWidth / 2;
|
18856 |
|
18857 | this._setXY(line, x, y);
|
18858 |
|
18859 | line.className = _concatInstanceProperty(_context3 = "vis-grid ".concat(this.options.rtl ? 'vis-vertical-rtl' : 'vis-vertical', " vis-major ")).call(_context3, className);
|
18860 | return line;
|
18861 | }
|
18862 | |
18863 |
|
18864 |
|
18865 |
|
18866 |
|
18867 |
|
18868 | }, {
|
18869 | key: "_calculateCharSize",
|
18870 | value: function _calculateCharSize() {
|
18871 |
|
18872 |
|
18873 |
|
18874 | if (!this.dom.measureCharMinor) {
|
18875 | this.dom.measureCharMinor = document.createElement('DIV');
|
18876 | this.dom.measureCharMinor.className = 'vis-text vis-minor vis-measure';
|
18877 | this.dom.measureCharMinor.style.position = 'absolute';
|
18878 | this.dom.measureCharMinor.appendChild(document.createTextNode('0'));
|
18879 | this.dom.foreground.appendChild(this.dom.measureCharMinor);
|
18880 | }
|
18881 |
|
18882 | this.props.minorCharHeight = this.dom.measureCharMinor.clientHeight;
|
18883 | this.props.minorCharWidth = this.dom.measureCharMinor.clientWidth;
|
18884 |
|
18885 | if (!this.dom.measureCharMajor) {
|
18886 | this.dom.measureCharMajor = document.createElement('DIV');
|
18887 | this.dom.measureCharMajor.className = 'vis-text vis-major vis-measure';
|
18888 | this.dom.measureCharMajor.style.position = 'absolute';
|
18889 | this.dom.measureCharMajor.appendChild(document.createTextNode('0'));
|
18890 | this.dom.foreground.appendChild(this.dom.measureCharMajor);
|
18891 | }
|
18892 |
|
18893 | this.props.majorCharHeight = this.dom.measureCharMajor.clientHeight;
|
18894 | this.props.majorCharWidth = this.dom.measureCharMajor.clientWidth;
|
18895 | }
|
18896 | }]);
|
18897 |
|
18898 | return TimeAxis;
|
18899 | }(Component);
|
18900 |
|
18901 | var warnedForOverflow = false;
|
18902 |
|
18903 |
|
18904 |
|
18905 |
|
18906 | function keycharm(options) {
|
18907 | var preventDefault = options && options.preventDefault || false;
|
18908 | var container = options && options.container || window;
|
18909 | var _exportFunctions = {};
|
18910 | var _bound = {
|
18911 | keydown: {},
|
18912 | keyup: {}
|
18913 | };
|
18914 | var _keys = {};
|
18915 | var i;
|
18916 |
|
18917 | for (i = 97; i <= 122; i++) {
|
18918 | _keys[String.fromCharCode(i)] = {
|
18919 | code: 65 + (i - 97),
|
18920 | shift: false
|
18921 | };
|
18922 | }
|
18923 |
|
18924 |
|
18925 | for (i = 65; i <= 90; i++) {
|
18926 | _keys[String.fromCharCode(i)] = {
|
18927 | code: i,
|
18928 | shift: true
|
18929 | };
|
18930 | }
|
18931 |
|
18932 |
|
18933 | for (i = 0; i <= 9; i++) {
|
18934 | _keys['' + i] = {
|
18935 | code: 48 + i,
|
18936 | shift: false
|
18937 | };
|
18938 | }
|
18939 |
|
18940 |
|
18941 | for (i = 1; i <= 12; i++) {
|
18942 | _keys['F' + i] = {
|
18943 | code: 111 + i,
|
18944 | shift: false
|
18945 | };
|
18946 | }
|
18947 |
|
18948 |
|
18949 | for (i = 0; i <= 9; i++) {
|
18950 | _keys['num' + i] = {
|
18951 | code: 96 + i,
|
18952 | shift: false
|
18953 | };
|
18954 | }
|
18955 |
|
18956 |
|
18957 | _keys['num*'] = {
|
18958 | code: 106,
|
18959 | shift: false
|
18960 | };
|
18961 | _keys['num+'] = {
|
18962 | code: 107,
|
18963 | shift: false
|
18964 | };
|
18965 | _keys['num-'] = {
|
18966 | code: 109,
|
18967 | shift: false
|
18968 | };
|
18969 | _keys['num/'] = {
|
18970 | code: 111,
|
18971 | shift: false
|
18972 | };
|
18973 | _keys['num.'] = {
|
18974 | code: 110,
|
18975 | shift: false
|
18976 | };
|
18977 |
|
18978 | _keys['left'] = {
|
18979 | code: 37,
|
18980 | shift: false
|
18981 | };
|
18982 | _keys['up'] = {
|
18983 | code: 38,
|
18984 | shift: false
|
18985 | };
|
18986 | _keys['right'] = {
|
18987 | code: 39,
|
18988 | shift: false
|
18989 | };
|
18990 | _keys['down'] = {
|
18991 | code: 40,
|
18992 | shift: false
|
18993 | };
|
18994 |
|
18995 | _keys['space'] = {
|
18996 | code: 32,
|
18997 | shift: false
|
18998 | };
|
18999 | _keys['enter'] = {
|
19000 | code: 13,
|
19001 | shift: false
|
19002 | };
|
19003 | _keys['shift'] = {
|
19004 | code: 16,
|
19005 | shift: undefined
|
19006 | };
|
19007 | _keys['esc'] = {
|
19008 | code: 27,
|
19009 | shift: false
|
19010 | };
|
19011 | _keys['backspace'] = {
|
19012 | code: 8,
|
19013 | shift: false
|
19014 | };
|
19015 | _keys['tab'] = {
|
19016 | code: 9,
|
19017 | shift: false
|
19018 | };
|
19019 | _keys['ctrl'] = {
|
19020 | code: 17,
|
19021 | shift: false
|
19022 | };
|
19023 | _keys['alt'] = {
|
19024 | code: 18,
|
19025 | shift: false
|
19026 | };
|
19027 | _keys['delete'] = {
|
19028 | code: 46,
|
19029 | shift: false
|
19030 | };
|
19031 | _keys['pageup'] = {
|
19032 | code: 33,
|
19033 | shift: false
|
19034 | };
|
19035 | _keys['pagedown'] = {
|
19036 | code: 34,
|
19037 | shift: false
|
19038 | };
|
19039 |
|
19040 | _keys['='] = {
|
19041 | code: 187,
|
19042 | shift: false
|
19043 | };
|
19044 | _keys['-'] = {
|
19045 | code: 189,
|
19046 | shift: false
|
19047 | };
|
19048 | _keys[']'] = {
|
19049 | code: 221,
|
19050 | shift: false
|
19051 | };
|
19052 | _keys['['] = {
|
19053 | code: 219,
|
19054 | shift: false
|
19055 | };
|
19056 |
|
19057 | var down = function (event) {
|
19058 | handleEvent(event, 'keydown');
|
19059 | };
|
19060 |
|
19061 | var up = function (event) {
|
19062 | handleEvent(event, 'keyup');
|
19063 | };
|
19064 |
|
19065 |
|
19066 | var handleEvent = function (event, type) {
|
19067 | if (_bound[type][event.keyCode] !== undefined) {
|
19068 | var bound = _bound[type][event.keyCode];
|
19069 |
|
19070 | for (var i = 0; i < bound.length; i++) {
|
19071 | if (bound[i].shift === undefined) {
|
19072 | bound[i].fn(event);
|
19073 | } else if (bound[i].shift == true && event.shiftKey == true) {
|
19074 | bound[i].fn(event);
|
19075 | } else if (bound[i].shift == false && event.shiftKey == false) {
|
19076 | bound[i].fn(event);
|
19077 | }
|
19078 | }
|
19079 |
|
19080 | if (preventDefault == true) {
|
19081 | event.preventDefault();
|
19082 | }
|
19083 | }
|
19084 | };
|
19085 |
|
19086 |
|
19087 | _exportFunctions.bind = function (key, callback, type) {
|
19088 | if (type === undefined) {
|
19089 | type = 'keydown';
|
19090 | }
|
19091 |
|
19092 | if (_keys[key] === undefined) {
|
19093 | throw new Error("unsupported key: " + key);
|
19094 | }
|
19095 |
|
19096 | if (_bound[type][_keys[key].code] === undefined) {
|
19097 | _bound[type][_keys[key].code] = [];
|
19098 | }
|
19099 |
|
19100 | _bound[type][_keys[key].code].push({
|
19101 | fn: callback,
|
19102 | shift: _keys[key].shift
|
19103 | });
|
19104 | };
|
19105 |
|
19106 |
|
19107 | _exportFunctions.bindAll = function (callback, type) {
|
19108 | if (type === undefined) {
|
19109 | type = 'keydown';
|
19110 | }
|
19111 |
|
19112 | for (var key in _keys) {
|
19113 | if (_keys.hasOwnProperty(key)) {
|
19114 | _exportFunctions.bind(key, callback, type);
|
19115 | }
|
19116 | }
|
19117 | };
|
19118 |
|
19119 |
|
19120 | _exportFunctions.getKey = function (event) {
|
19121 | for (var key in _keys) {
|
19122 | if (_keys.hasOwnProperty(key)) {
|
19123 | if (event.shiftKey == true && _keys[key].shift == true && event.keyCode == _keys[key].code) {
|
19124 | return key;
|
19125 | } else if (event.shiftKey == false && _keys[key].shift == false && event.keyCode == _keys[key].code) {
|
19126 | return key;
|
19127 | } else if (event.keyCode == _keys[key].code && key == 'shift') {
|
19128 | return key;
|
19129 | }
|
19130 | }
|
19131 | }
|
19132 |
|
19133 | return "unknown key, currently not supported";
|
19134 | };
|
19135 |
|
19136 |
|
19137 | _exportFunctions.unbind = function (key, callback, type) {
|
19138 | if (type === undefined) {
|
19139 | type = 'keydown';
|
19140 | }
|
19141 |
|
19142 | if (_keys[key] === undefined) {
|
19143 | throw new Error("unsupported key: " + key);
|
19144 | }
|
19145 |
|
19146 | if (callback !== undefined) {
|
19147 | var newBindings = [];
|
19148 | var bound = _bound[type][_keys[key].code];
|
19149 |
|
19150 | if (bound !== undefined) {
|
19151 | for (var i = 0; i < bound.length; i++) {
|
19152 | if (!(bound[i].fn == callback && bound[i].shift == _keys[key].shift)) {
|
19153 | newBindings.push(_bound[type][_keys[key].code][i]);
|
19154 | }
|
19155 | }
|
19156 | }
|
19157 |
|
19158 | _bound[type][_keys[key].code] = newBindings;
|
19159 | } else {
|
19160 | _bound[type][_keys[key].code] = [];
|
19161 | }
|
19162 | };
|
19163 |
|
19164 |
|
19165 | _exportFunctions.reset = function () {
|
19166 | _bound = {
|
19167 | keydown: {},
|
19168 | keyup: {}
|
19169 | };
|
19170 | };
|
19171 |
|
19172 |
|
19173 | _exportFunctions.destroy = function () {
|
19174 | _bound = {
|
19175 | keydown: {},
|
19176 | keyup: {}
|
19177 | };
|
19178 | container.removeEventListener('keydown', down, true);
|
19179 | container.removeEventListener('keyup', up, true);
|
19180 | };
|
19181 |
|
19182 |
|
19183 | container.addEventListener('keydown', down, true);
|
19184 | container.addEventListener('keyup', up, true);
|
19185 |
|
19186 | return _exportFunctions;
|
19187 | }
|
19188 |
|
19189 |
|
19190 |
|
19191 |
|
19192 |
|
19193 |
|
19194 |
|
19195 |
|
19196 |
|
19197 |
|
19198 |
|
19199 |
|
19200 | function Activator(container) {
|
19201 | var _context, _context2;
|
19202 |
|
19203 | this.active = false;
|
19204 | this.dom = {
|
19205 | container: container
|
19206 | };
|
19207 | this.dom.overlay = document.createElement('div');
|
19208 | this.dom.overlay.className = 'vis-overlay';
|
19209 | this.dom.container.appendChild(this.dom.overlay);
|
19210 | this.hammer = Hammer(this.dom.overlay);
|
19211 | this.hammer.on('tap', _bindInstanceProperty(_context = this._onTapOverlay).call(_context, this));
|
19212 |
|
19213 | var me = this;
|
19214 | var events = ['tap', 'doubletap', 'press', 'pinch', 'pan', 'panstart', 'panmove', 'panend'];
|
19215 |
|
19216 | _forEachInstanceProperty(events).call(events, function (event) {
|
19217 | me.hammer.on(event, function (event) {
|
19218 | event.stopPropagation();
|
19219 | });
|
19220 | });
|
19221 |
|
19222 |
|
19223 | if (document && document.body) {
|
19224 | this.onClick = function (event) {
|
19225 | if (!_hasParent(event.target, container)) {
|
19226 | me.deactivate();
|
19227 | }
|
19228 | };
|
19229 |
|
19230 | document.body.addEventListener('click', this.onClick);
|
19231 | }
|
19232 |
|
19233 | if (this.keycharm !== undefined) {
|
19234 | this.keycharm.destroy();
|
19235 | }
|
19236 |
|
19237 | this.keycharm = keycharm();
|
19238 |
|
19239 | this.escListener = _bindInstanceProperty(_context2 = this.deactivate).call(_context2, this);
|
19240 | }
|
19241 |
|
19242 |
|
19243 | Emitter(Activator.prototype);
|
19244 |
|
19245 | Activator.current = null;
|
19246 |
|
19247 |
|
19248 |
|
19249 |
|
19250 | Activator.prototype.destroy = function () {
|
19251 | this.deactivate();
|
19252 |
|
19253 | this.dom.overlay.parentNode.removeChild(this.dom.overlay);
|
19254 |
|
19255 | if (this.onClick) {
|
19256 | document.body.removeEventListener('click', this.onClick);
|
19257 | }
|
19258 |
|
19259 |
|
19260 | if (this.keycharm !== undefined) {
|
19261 | this.keycharm.destroy();
|
19262 | }
|
19263 |
|
19264 | this.keycharm = null;
|
19265 |
|
19266 | this.hammer.destroy();
|
19267 | this.hammer = null;
|
19268 | };
|
19269 |
|
19270 |
|
19271 |
|
19272 |
|
19273 |
|
19274 |
|
19275 | Activator.prototype.activate = function () {
|
19276 | var _context3;
|
19277 |
|
19278 |
|
19279 | if (Activator.current) {
|
19280 | Activator.current.deactivate();
|
19281 | }
|
19282 |
|
19283 | Activator.current = this;
|
19284 | this.active = true;
|
19285 | this.dom.overlay.style.display = 'none';
|
19286 | availableUtils.addClassName(this.dom.container, 'vis-active');
|
19287 | this.emit('change');
|
19288 | this.emit('activate');
|
19289 |
|
19290 |
|
19291 | _bindInstanceProperty(_context3 = this.keycharm).call(_context3, 'esc', this.escListener);
|
19292 | };
|
19293 |
|
19294 |
|
19295 |
|
19296 |
|
19297 |
|
19298 |
|
19299 | Activator.prototype.deactivate = function () {
|
19300 | if (Activator.current === this) {
|
19301 | Activator.current = null;
|
19302 | }
|
19303 |
|
19304 | this.active = false;
|
19305 | this.dom.overlay.style.display = '';
|
19306 | availableUtils.removeClassName(this.dom.container, 'vis-active');
|
19307 | this.keycharm.unbind('esc', this.escListener);
|
19308 | this.emit('change');
|
19309 | this.emit('deactivate');
|
19310 | };
|
19311 |
|
19312 |
|
19313 |
|
19314 |
|
19315 |
|
19316 |
|
19317 |
|
19318 | Activator.prototype._onTapOverlay = function (event) {
|
19319 |
|
19320 | this.activate();
|
19321 | event.stopPropagation();
|
19322 | };
|
19323 |
|
19324 |
|
19325 |
|
19326 |
|
19327 |
|
19328 |
|
19329 |
|
19330 |
|
19331 |
|
19332 |
|
19333 |
|
19334 | function _hasParent(element, parent) {
|
19335 | while (element) {
|
19336 | if (element === parent) {
|
19337 | return true;
|
19338 | }
|
19339 |
|
19340 | element = element.parentNode;
|
19341 | }
|
19342 |
|
19343 | return false;
|
19344 | }
|
19345 |
|
19346 |
|
19347 |
|
19348 |
|
19349 |
|
19350 |
|
19351 | var en = {
|
19352 | current: 'current',
|
19353 | time: 'time',
|
19354 | deleteSelected: 'Delete selected'
|
19355 | };
|
19356 | var en_EN = en;
|
19357 | var en_US = en;
|
19358 |
|
19359 | var it = {
|
19360 | current: 'attuale',
|
19361 | time: 'tempo',
|
19362 | deleteSelected: 'Cancella la selezione'
|
19363 | };
|
19364 | var it_IT = it;
|
19365 | var it_CH = it;
|
19366 |
|
19367 | var nl = {
|
19368 | current: 'huidige',
|
19369 | time: 'tijd',
|
19370 | deleteSelected: 'Selectie verwijderen'
|
19371 | };
|
19372 | var nl_NL = nl;
|
19373 | var nl_BE = nl;
|
19374 |
|
19375 | var de = {
|
19376 | current: 'Aktuelle',
|
19377 | time: 'Zeit',
|
19378 | deleteSelected: "L\xF6sche Auswahl"
|
19379 | };
|
19380 | var de_DE = de;
|
19381 |
|
19382 | var fr = {
|
19383 | current: 'actuel',
|
19384 | time: 'heure',
|
19385 | deleteSelected: 'Effacer la selection'
|
19386 | };
|
19387 | var fr_FR = fr;
|
19388 | var fr_CA = fr;
|
19389 | var fr_BE = fr;
|
19390 |
|
19391 | var es = {
|
19392 | current: 'corriente',
|
19393 | time: 'hora',
|
19394 | deleteSelected: "Eliminar selecci\xF3n"
|
19395 | };
|
19396 | var es_ES = es;
|
19397 |
|
19398 | var uk = {
|
19399 | current: 'поточний',
|
19400 | time: 'час',
|
19401 | deleteSelected: 'Видалити обране'
|
19402 | };
|
19403 | var uk_UA = uk;
|
19404 |
|
19405 | var ru = {
|
19406 | current: 'текущее',
|
19407 | time: 'время',
|
19408 | deleteSelected: 'Удалить выбранное'
|
19409 | };
|
19410 | var ru_RU = ru;
|
19411 |
|
19412 | var pl = {
|
19413 | current: 'aktualny',
|
19414 | time: 'czas',
|
19415 | deleteSelected: 'Usuń wybrane'
|
19416 | };
|
19417 | var pl_PL = pl;
|
19418 |
|
19419 | var pt = {
|
19420 | current: 'atual',
|
19421 | time: 'data',
|
19422 | deleteSelected: 'Apagar selecionado'
|
19423 | };
|
19424 | var pt_BR = pt;
|
19425 | var pt_PT = pt;
|
19426 |
|
19427 | var ja = {
|
19428 | current: '現在',
|
19429 | time: '時刻',
|
19430 | deleteSelected: '選択されたものを削除'
|
19431 | };
|
19432 | var ja_JP = ja;
|
19433 |
|
19434 | var sv = {
|
19435 | current: 'nuvarande',
|
19436 | time: 'tid',
|
19437 | deleteSelected: 'Radera valda'
|
19438 | };
|
19439 | var sv_SE = sv;
|
19440 |
|
19441 | var nb = {
|
19442 | current: 'nåværende',
|
19443 | time: 'tid',
|
19444 | deleteSelected: 'Slett valgte'
|
19445 | };
|
19446 | var nb_NO = nb;
|
19447 | var nn = nb;
|
19448 | var nn_NO = nb;
|
19449 |
|
19450 | var lt = {
|
19451 | current: 'einamas',
|
19452 | time: 'laikas',
|
19453 | deleteSelected: 'Pašalinti pasirinktą'
|
19454 | };
|
19455 | var lt_LT = lt;
|
19456 | var locales = {
|
19457 | en: en,
|
19458 | en_EN: en_EN,
|
19459 | en_US: en_US,
|
19460 | it: it,
|
19461 | it_IT: it_IT,
|
19462 | it_CH: it_CH,
|
19463 | nl: nl,
|
19464 | nl_NL: nl_NL,
|
19465 | nl_BE: nl_BE,
|
19466 | de: de,
|
19467 | de_DE: de_DE,
|
19468 | fr: fr,
|
19469 | fr_FR: fr_FR,
|
19470 | fr_CA: fr_CA,
|
19471 | fr_BE: fr_BE,
|
19472 | es: es,
|
19473 | es_ES: es_ES,
|
19474 | uk: uk,
|
19475 | uk_UA: uk_UA,
|
19476 | ru: ru,
|
19477 | ru_RU: ru_RU,
|
19478 | pl: pl,
|
19479 | pl_PL: pl_PL,
|
19480 | pt: pt,
|
19481 | pt_BR: pt_BR,
|
19482 | pt_PT: pt_PT,
|
19483 | ja: ja,
|
19484 | ja_JP: ja_JP,
|
19485 | lt: lt,
|
19486 | lt_LT: lt_LT,
|
19487 | sv: sv,
|
19488 | sv_SE: sv_SE,
|
19489 | nb: nb,
|
19490 | nn: nn,
|
19491 | nb_NO: nb_NO,
|
19492 | nn_NO: nn_NO
|
19493 | };
|
19494 |
|
19495 | function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
19496 |
|
19497 | function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
19498 |
|
19499 |
|
19500 | var CustomTime = function (_Component) {
|
19501 | _inherits(CustomTime, _Component);
|
19502 |
|
19503 | var _super = _createSuper$a(CustomTime);
|
19504 |
|
19505 | |
19506 |
|
19507 |
|
19508 |
|
19509 |
|
19510 |
|
19511 |
|
19512 |
|
19513 |
|
19514 | function CustomTime(body, options) {
|
19515 | var _context;
|
19516 |
|
19517 | var _this;
|
19518 |
|
19519 | _classCallCheck(this, CustomTime);
|
19520 |
|
19521 | _this = _super.call(this);
|
19522 | _this.body = body;
|
19523 |
|
19524 | _this.defaultOptions = {
|
19525 | moment: moment$2,
|
19526 | locales: locales,
|
19527 | locale: 'en',
|
19528 | id: undefined,
|
19529 | title: undefined
|
19530 | };
|
19531 | _this.options = availableUtils.extend({}, _this.defaultOptions);
|
19532 |
|
19533 | _this.setOptions(options);
|
19534 |
|
19535 | _this.options.locales = availableUtils.extend({}, locales, _this.options.locales);
|
19536 | var defaultLocales = _this.defaultOptions.locales[_this.defaultOptions.locale];
|
19537 |
|
19538 | _forEachInstanceProperty(_context = _Object$keys(_this.options.locales)).call(_context, function (locale) {
|
19539 | _this.options.locales[locale] = availableUtils.extend({}, defaultLocales, _this.options.locales[locale]);
|
19540 | });
|
19541 |
|
19542 | if (options && options.time != null) {
|
19543 | _this.customTime = options.time;
|
19544 | } else {
|
19545 | _this.customTime = new Date();
|
19546 | }
|
19547 |
|
19548 | _this.eventParams = {};
|
19549 |
|
19550 |
|
19551 | _this._create();
|
19552 |
|
19553 | return _this;
|
19554 | }
|
19555 | |
19556 |
|
19557 |
|
19558 |
|
19559 |
|
19560 |
|
19561 |
|
19562 |
|
19563 |
|
19564 | _createClass(CustomTime, [{
|
19565 | key: "setOptions",
|
19566 | value: function setOptions(options) {
|
19567 | if (options) {
|
19568 |
|
19569 | availableUtils.selectiveExtend(['moment', 'locale', 'locales', 'id', 'title', 'rtl', 'snap'], this.options, options);
|
19570 | }
|
19571 | }
|
19572 | |
19573 |
|
19574 |
|
19575 |
|
19576 |
|
19577 | }, {
|
19578 | key: "_create",
|
19579 | value: function _create() {
|
19580 | var _context2, _context3, _context4;
|
19581 |
|
19582 | var bar = document.createElement('div');
|
19583 | bar['custom-time'] = this;
|
19584 | bar.className = "vis-custom-time ".concat(this.options.id || '');
|
19585 | bar.style.position = 'absolute';
|
19586 | bar.style.top = '0px';
|
19587 | bar.style.height = '100%';
|
19588 | this.bar = bar;
|
19589 | var drag = document.createElement('div');
|
19590 | drag.style.position = 'relative';
|
19591 | drag.style.top = '0px';
|
19592 |
|
19593 | if (this.options.rtl) {
|
19594 | drag.style.right = '-10px';
|
19595 | } else {
|
19596 | drag.style.left = '-10px';
|
19597 | }
|
19598 |
|
19599 | drag.style.height = '100%';
|
19600 | drag.style.width = '20px';
|
19601 | |
19602 |
|
19603 |
|
19604 |
|
19605 |
|
19606 | function onMouseWheel(e) {
|
19607 | this.body.range._onMouseWheel(e);
|
19608 | }
|
19609 |
|
19610 | if (drag.addEventListener) {
|
19611 |
|
19612 | drag.addEventListener("mousewheel", _bindInstanceProperty(onMouseWheel).call(onMouseWheel, this), false);
|
19613 |
|
19614 | drag.addEventListener("DOMMouseScroll", _bindInstanceProperty(onMouseWheel).call(onMouseWheel, this), false);
|
19615 | } else {
|
19616 |
|
19617 | drag.attachEvent("onmousewheel", _bindInstanceProperty(onMouseWheel).call(onMouseWheel, this));
|
19618 | }
|
19619 |
|
19620 | bar.appendChild(drag);
|
19621 |
|
19622 | this.hammer = new Hammer(drag);
|
19623 | this.hammer.on('panstart', _bindInstanceProperty(_context2 = this._onDragStart).call(_context2, this));
|
19624 | this.hammer.on('panmove', _bindInstanceProperty(_context3 = this._onDrag).call(_context3, this));
|
19625 | this.hammer.on('panend', _bindInstanceProperty(_context4 = this._onDragEnd).call(_context4, this));
|
19626 | this.hammer.get('pan').set({
|
19627 | threshold: 5,
|
19628 | direction: Hammer.DIRECTION_ALL
|
19629 | });
|
19630 |
|
19631 | this.hammer.get('press').set({
|
19632 | time: 10000
|
19633 | });
|
19634 | }
|
19635 | |
19636 |
|
19637 |
|
19638 |
|
19639 | }, {
|
19640 | key: "destroy",
|
19641 | value: function destroy() {
|
19642 | this.hide();
|
19643 | this.hammer.destroy();
|
19644 | this.hammer = null;
|
19645 | this.body = null;
|
19646 | }
|
19647 | |
19648 |
|
19649 |
|
19650 |
|
19651 |
|
19652 | }, {
|
19653 | key: "redraw",
|
19654 | value: function redraw() {
|
19655 | var parent = this.body.dom.backgroundVertical;
|
19656 |
|
19657 | if (this.bar.parentNode != parent) {
|
19658 |
|
19659 | if (this.bar.parentNode) {
|
19660 | this.bar.parentNode.removeChild(this.bar);
|
19661 | }
|
19662 |
|
19663 | parent.appendChild(this.bar);
|
19664 | }
|
19665 |
|
19666 | var x = this.body.util.toScreen(this.customTime);
|
19667 | var locale = this.options.locales[this.options.locale];
|
19668 |
|
19669 | if (!locale) {
|
19670 | if (!this.warned) {
|
19671 | console.warn("WARNING: options.locales['".concat(this.options.locale, "'] not found. See https://visjs.github.io/vis-timeline/docs/timeline/#Localization"));
|
19672 | this.warned = true;
|
19673 | }
|
19674 |
|
19675 | locale = this.options.locales['en'];
|
19676 | }
|
19677 |
|
19678 | var title = this.options.title;
|
19679 |
|
19680 | if (title === undefined) {
|
19681 | var _context5;
|
19682 |
|
19683 | title = _concatInstanceProperty(_context5 = "".concat(locale.time, ": ")).call(_context5, this.options.moment(this.customTime).format('dddd, MMMM Do YYYY, H:mm:ss'));
|
19684 | title = title.charAt(0).toUpperCase() + title.substring(1);
|
19685 | } else if (typeof title === "function") {
|
19686 | title = title.call(this, this.customTime);
|
19687 | }
|
19688 |
|
19689 | this.options.rtl ? this.bar.style.right = "".concat(x, "px") : this.bar.style.left = "".concat(x, "px");
|
19690 | this.bar.title = title;
|
19691 | return false;
|
19692 | }
|
19693 | |
19694 |
|
19695 |
|
19696 |
|
19697 | }, {
|
19698 | key: "hide",
|
19699 | value: function hide() {
|
19700 |
|
19701 | if (this.bar.parentNode) {
|
19702 | this.bar.parentNode.removeChild(this.bar);
|
19703 | }
|
19704 | }
|
19705 | |
19706 |
|
19707 |
|
19708 |
|
19709 |
|
19710 | }, {
|
19711 | key: "setCustomTime",
|
19712 | value: function setCustomTime(time) {
|
19713 | this.customTime = availableUtils.convert(time, 'Date');
|
19714 | this.redraw();
|
19715 | }
|
19716 | |
19717 |
|
19718 |
|
19719 |
|
19720 |
|
19721 | }, {
|
19722 | key: "getCustomTime",
|
19723 | value: function getCustomTime() {
|
19724 | return new Date(this.customTime.valueOf());
|
19725 | }
|
19726 | |
19727 |
|
19728 |
|
19729 |
|
19730 |
|
19731 |
|
19732 | }, {
|
19733 | key: "setCustomMarker",
|
19734 | value: function setCustomMarker(title, editable) {
|
19735 | var marker = document.createElement('div');
|
19736 | marker.className = "vis-custom-time-marker";
|
19737 | marker.innerHTML = availableUtils.xss(title);
|
19738 | marker.style.position = 'absolute';
|
19739 |
|
19740 | if (editable) {
|
19741 | var _context6, _context7;
|
19742 |
|
19743 | marker.setAttribute('contenteditable', 'true');
|
19744 | marker.addEventListener('pointerdown', function () {
|
19745 | marker.focus();
|
19746 | });
|
19747 | marker.addEventListener('input', _bindInstanceProperty(_context6 = this._onMarkerChange).call(_context6, this));
|
19748 |
|
19749 | marker.title = title;
|
19750 | marker.addEventListener('blur', _bindInstanceProperty(_context7 = function _context7(event) {
|
19751 | if (this.title != event.target.innerHTML) {
|
19752 | this._onMarkerChanged(event);
|
19753 |
|
19754 | this.title = event.target.innerHTML;
|
19755 | }
|
19756 | }).call(_context7, this));
|
19757 | }
|
19758 |
|
19759 | this.bar.appendChild(marker);
|
19760 | }
|
19761 | |
19762 |
|
19763 |
|
19764 |
|
19765 |
|
19766 | }, {
|
19767 | key: "setCustomTitle",
|
19768 | value: function setCustomTitle(title) {
|
19769 | this.options.title = title;
|
19770 | }
|
19771 | |
19772 |
|
19773 |
|
19774 |
|
19775 |
|
19776 |
|
19777 | }, {
|
19778 | key: "_onDragStart",
|
19779 | value: function _onDragStart(event) {
|
19780 | this.eventParams.dragging = true;
|
19781 | this.eventParams.customTime = this.customTime;
|
19782 | event.stopPropagation();
|
19783 | }
|
19784 | |
19785 |
|
19786 |
|
19787 |
|
19788 |
|
19789 |
|
19790 | }, {
|
19791 | key: "_onDrag",
|
19792 | value: function _onDrag(event) {
|
19793 | if (!this.eventParams.dragging) return;
|
19794 | var deltaX = this.options.rtl ? -1 * event.deltaX : event.deltaX;
|
19795 | var x = this.body.util.toScreen(this.eventParams.customTime) + deltaX;
|
19796 | var time = this.body.util.toTime(x);
|
19797 | var scale = this.body.util.getScale();
|
19798 | var step = this.body.util.getStep();
|
19799 | var snap = this.options.snap;
|
19800 | var snappedTime = snap ? snap(time, scale, step) : time;
|
19801 | this.setCustomTime(snappedTime);
|
19802 |
|
19803 | this.body.emitter.emit('timechange', {
|
19804 | id: this.options.id,
|
19805 | time: new Date(this.customTime.valueOf()),
|
19806 | event: event
|
19807 | });
|
19808 | event.stopPropagation();
|
19809 | }
|
19810 | |
19811 |
|
19812 |
|
19813 |
|
19814 |
|
19815 |
|
19816 | }, {
|
19817 | key: "_onDragEnd",
|
19818 | value: function _onDragEnd(event) {
|
19819 | if (!this.eventParams.dragging) return;
|
19820 |
|
19821 | this.body.emitter.emit('timechanged', {
|
19822 | id: this.options.id,
|
19823 | time: new Date(this.customTime.valueOf()),
|
19824 | event: event
|
19825 | });
|
19826 | event.stopPropagation();
|
19827 | }
|
19828 | |
19829 |
|
19830 |
|
19831 |
|
19832 |
|
19833 |
|
19834 | }, {
|
19835 | key: "_onMarkerChange",
|
19836 | value: function _onMarkerChange(event) {
|
19837 | this.body.emitter.emit('markerchange', {
|
19838 | id: this.options.id,
|
19839 | title: event.target.innerHTML,
|
19840 | event: event
|
19841 | });
|
19842 | event.stopPropagation();
|
19843 | }
|
19844 | |
19845 |
|
19846 |
|
19847 |
|
19848 |
|
19849 |
|
19850 | }, {
|
19851 | key: "_onMarkerChanged",
|
19852 | value: function _onMarkerChanged(event) {
|
19853 | this.body.emitter.emit('markerchanged', {
|
19854 | id: this.options.id,
|
19855 | title: event.target.innerHTML,
|
19856 | event: event
|
19857 | });
|
19858 | event.stopPropagation();
|
19859 | }
|
19860 | |
19861 |
|
19862 |
|
19863 |
|
19864 |
|
19865 |
|
19866 |
|
19867 | }], [{
|
19868 | key: "customTimeFromTarget",
|
19869 | value: function customTimeFromTarget(event) {
|
19870 | var target = event.target;
|
19871 |
|
19872 | while (target) {
|
19873 | if (target.hasOwnProperty('custom-time')) {
|
19874 | return target['custom-time'];
|
19875 | }
|
19876 |
|
19877 | target = target.parentNode;
|
19878 | }
|
19879 |
|
19880 | return null;
|
19881 | }
|
19882 | }]);
|
19883 |
|
19884 | return CustomTime;
|
19885 | }(Component);
|
19886 |
|
19887 |
|
19888 |
|
19889 |
|
19890 |
|
19891 |
|
19892 | var Core = function () {
|
19893 | function Core() {
|
19894 | _classCallCheck(this, Core);
|
19895 | }
|
19896 |
|
19897 | _createClass(Core, [{
|
19898 | key: "_create",
|
19899 | value:
|
19900 | |
19901 |
|
19902 |
|
19903 |
|
19904 |
|
19905 |
|
19906 |
|
19907 | function _create(container) {
|
19908 | var _this = this,
|
19909 | _context,
|
19910 | _context2,
|
19911 | _context3;
|
19912 |
|
19913 | this.dom = {};
|
19914 | this.dom.container = container;
|
19915 | this.dom.container.style.position = 'relative';
|
19916 | this.dom.root = document.createElement('div');
|
19917 | this.dom.background = document.createElement('div');
|
19918 | this.dom.backgroundVertical = document.createElement('div');
|
19919 | this.dom.backgroundHorizontal = document.createElement('div');
|
19920 | this.dom.centerContainer = document.createElement('div');
|
19921 | this.dom.leftContainer = document.createElement('div');
|
19922 | this.dom.rightContainer = document.createElement('div');
|
19923 | this.dom.center = document.createElement('div');
|
19924 | this.dom.left = document.createElement('div');
|
19925 | this.dom.right = document.createElement('div');
|
19926 | this.dom.top = document.createElement('div');
|
19927 | this.dom.bottom = document.createElement('div');
|
19928 | this.dom.shadowTop = document.createElement('div');
|
19929 | this.dom.shadowBottom = document.createElement('div');
|
19930 | this.dom.shadowTopLeft = document.createElement('div');
|
19931 | this.dom.shadowBottomLeft = document.createElement('div');
|
19932 | this.dom.shadowTopRight = document.createElement('div');
|
19933 | this.dom.shadowBottomRight = document.createElement('div');
|
19934 | this.dom.rollingModeBtn = document.createElement('div');
|
19935 | this.dom.loadingScreen = document.createElement('div');
|
19936 | this.dom.root.className = 'vis-timeline';
|
19937 | this.dom.background.className = 'vis-panel vis-background';
|
19938 | this.dom.backgroundVertical.className = 'vis-panel vis-background vis-vertical';
|
19939 | this.dom.backgroundHorizontal.className = 'vis-panel vis-background vis-horizontal';
|
19940 | this.dom.centerContainer.className = 'vis-panel vis-center';
|
19941 | this.dom.leftContainer.className = 'vis-panel vis-left';
|
19942 | this.dom.rightContainer.className = 'vis-panel vis-right';
|
19943 | this.dom.top.className = 'vis-panel vis-top';
|
19944 | this.dom.bottom.className = 'vis-panel vis-bottom';
|
19945 | this.dom.left.className = 'vis-content';
|
19946 | this.dom.center.className = 'vis-content';
|
19947 | this.dom.right.className = 'vis-content';
|
19948 | this.dom.shadowTop.className = 'vis-shadow vis-top';
|
19949 | this.dom.shadowBottom.className = 'vis-shadow vis-bottom';
|
19950 | this.dom.shadowTopLeft.className = 'vis-shadow vis-top';
|
19951 | this.dom.shadowBottomLeft.className = 'vis-shadow vis-bottom';
|
19952 | this.dom.shadowTopRight.className = 'vis-shadow vis-top';
|
19953 | this.dom.shadowBottomRight.className = 'vis-shadow vis-bottom';
|
19954 | this.dom.rollingModeBtn.className = 'vis-rolling-mode-btn';
|
19955 | this.dom.loadingScreen.className = 'vis-loading-screen';
|
19956 | this.dom.root.appendChild(this.dom.background);
|
19957 | this.dom.root.appendChild(this.dom.backgroundVertical);
|
19958 | this.dom.root.appendChild(this.dom.backgroundHorizontal);
|
19959 | this.dom.root.appendChild(this.dom.centerContainer);
|
19960 | this.dom.root.appendChild(this.dom.leftContainer);
|
19961 | this.dom.root.appendChild(this.dom.rightContainer);
|
19962 | this.dom.root.appendChild(this.dom.top);
|
19963 | this.dom.root.appendChild(this.dom.bottom);
|
19964 | this.dom.root.appendChild(this.dom.rollingModeBtn);
|
19965 | this.dom.centerContainer.appendChild(this.dom.center);
|
19966 | this.dom.leftContainer.appendChild(this.dom.left);
|
19967 | this.dom.rightContainer.appendChild(this.dom.right);
|
19968 | this.dom.centerContainer.appendChild(this.dom.shadowTop);
|
19969 | this.dom.centerContainer.appendChild(this.dom.shadowBottom);
|
19970 | this.dom.leftContainer.appendChild(this.dom.shadowTopLeft);
|
19971 | this.dom.leftContainer.appendChild(this.dom.shadowBottomLeft);
|
19972 | this.dom.rightContainer.appendChild(this.dom.shadowTopRight);
|
19973 | this.dom.rightContainer.appendChild(this.dom.shadowBottomRight);
|
19974 |
|
19975 | this.props = {
|
19976 | root: {},
|
19977 | background: {},
|
19978 | centerContainer: {},
|
19979 | leftContainer: {},
|
19980 | rightContainer: {},
|
19981 | center: {},
|
19982 | left: {},
|
19983 | right: {},
|
19984 | top: {},
|
19985 | bottom: {},
|
19986 | border: {},
|
19987 | scrollTop: 0,
|
19988 | scrollTopMin: 0
|
19989 | };
|
19990 | this.on('rangechange', function () {
|
19991 | if (_this.initialDrawDone === true) {
|
19992 | _this._redraw();
|
19993 | }
|
19994 | });
|
19995 | this.on('rangechanged', function () {
|
19996 | if (!_this.initialRangeChangeDone) {
|
19997 | _this.initialRangeChangeDone = true;
|
19998 | }
|
19999 | });
|
20000 | this.on('touch', _bindInstanceProperty(_context = this._onTouch).call(_context, this));
|
20001 | this.on('panmove', _bindInstanceProperty(_context2 = this._onDrag).call(_context2, this));
|
20002 | var me = this;
|
20003 | this._origRedraw = _bindInstanceProperty(_context3 = this._redraw).call(_context3, this);
|
20004 | this._redraw = availableUtils.throttle(this._origRedraw);
|
20005 | this.on('_change', function (properties) {
|
20006 | if (me.itemSet && me.itemSet.initialItemSetDrawn && properties && properties.queue == true) {
|
20007 | me._redraw();
|
20008 | } else {
|
20009 | me._origRedraw();
|
20010 | }
|
20011 | });
|
20012 |
|
20013 |
|
20014 | this.hammer = new Hammer(this.dom.root);
|
20015 | var pinchRecognizer = this.hammer.get('pinch').set({
|
20016 | enable: true
|
20017 | });
|
20018 | pinchRecognizer && disablePreventDefaultVertically(pinchRecognizer);
|
20019 | this.hammer.get('pan').set({
|
20020 | threshold: 5,
|
20021 | direction: Hammer.DIRECTION_ALL
|
20022 | });
|
20023 | this.timelineListeners = {};
|
20024 | var events = ['tap', 'doubletap', 'press', 'pinch', 'pan', 'panstart', 'panmove', 'panend'
|
20025 |
|
20026 |
|
20027 |
|
20028 |
|
20029 | ];
|
20030 |
|
20031 | _forEachInstanceProperty(events).call(events, function (type) {
|
20032 | var listener = function listener(event) {
|
20033 | if (me.isActive()) {
|
20034 | me.emit(type, event);
|
20035 | }
|
20036 | };
|
20037 |
|
20038 | me.hammer.on(type, listener);
|
20039 | me.timelineListeners[type] = listener;
|
20040 | });
|
20041 |
|
20042 |
|
20043 | onTouch(this.hammer, function (event) {
|
20044 | me.emit('touch', event);
|
20045 | });
|
20046 |
|
20047 | onRelease(this.hammer, function (event) {
|
20048 | me.emit('release', event);
|
20049 | });
|
20050 | |
20051 |
|
20052 |
|
20053 |
|
20054 |
|
20055 | function onMouseWheel(event) {
|
20056 |
|
20057 | var LINE_HEIGHT = 40;
|
20058 | var PAGE_HEIGHT = 800;
|
20059 |
|
20060 | if (this.isActive()) {
|
20061 | this.emit('mousewheel', event);
|
20062 | }
|
20063 |
|
20064 |
|
20065 | var deltaX = 0;
|
20066 | var deltaY = 0;
|
20067 |
|
20068 | if ('detail' in event) {
|
20069 | deltaY = event.detail * -1;
|
20070 | }
|
20071 |
|
20072 | if ('wheelDelta' in event) {
|
20073 | deltaY = event.wheelDelta;
|
20074 | }
|
20075 |
|
20076 | if ('wheelDeltaY' in event) {
|
20077 | deltaY = event.wheelDeltaY;
|
20078 | }
|
20079 |
|
20080 | if ('wheelDeltaX' in event) {
|
20081 | deltaX = event.wheelDeltaX * -1;
|
20082 | }
|
20083 |
|
20084 |
|
20085 | if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
|
20086 | deltaX = deltaY * -1;
|
20087 | deltaY = 0;
|
20088 | }
|
20089 |
|
20090 |
|
20091 | if ('deltaY' in event) {
|
20092 | deltaY = event.deltaY * -1;
|
20093 | }
|
20094 |
|
20095 | if ('deltaX' in event) {
|
20096 | deltaX = event.deltaX;
|
20097 | }
|
20098 |
|
20099 |
|
20100 | if (event.deltaMode) {
|
20101 | if (event.deltaMode === 1) {
|
20102 |
|
20103 | deltaX *= LINE_HEIGHT;
|
20104 | deltaY *= LINE_HEIGHT;
|
20105 | } else {
|
20106 |
|
20107 | deltaX *= LINE_HEIGHT;
|
20108 | deltaY *= PAGE_HEIGHT;
|
20109 | }
|
20110 | }
|
20111 |
|
20112 |
|
20113 | if (this.options.preferZoom) {
|
20114 | if (!this.options.zoomKey || event[this.options.zoomKey]) return;
|
20115 | } else {
|
20116 | if (this.options.zoomKey && event[this.options.zoomKey]) return;
|
20117 | }
|
20118 |
|
20119 |
|
20120 | if (!this.options.verticalScroll && !this.options.horizontalScroll) return;
|
20121 |
|
20122 | if (this.options.verticalScroll && Math.abs(deltaY) >= Math.abs(deltaX)) {
|
20123 | var current = this.props.scrollTop;
|
20124 | var adjusted = current + deltaY;
|
20125 |
|
20126 | if (this.isActive()) {
|
20127 | var newScrollTop = this._setScrollTop(adjusted);
|
20128 |
|
20129 | if (newScrollTop !== current) {
|
20130 | this._redraw();
|
20131 |
|
20132 | this.emit('scroll', event);
|
20133 |
|
20134 |
|
20135 | event.preventDefault();
|
20136 | }
|
20137 | }
|
20138 | } else if (this.options.horizontalScroll) {
|
20139 | var delta = Math.abs(deltaX) >= Math.abs(deltaY) ? deltaX : deltaY;
|
20140 |
|
20141 | var diff = delta / 120 * (this.range.end - this.range.start) / 20;
|
20142 |
|
20143 | var newStart = this.range.start + diff;
|
20144 | var newEnd = this.range.end + diff;
|
20145 | var options = {
|
20146 | animation: false,
|
20147 | byUser: true,
|
20148 | event: event
|
20149 | };
|
20150 | this.range.setRange(newStart, newEnd, options);
|
20151 | event.preventDefault();
|
20152 | }
|
20153 | }
|
20154 |
|
20155 |
|
20156 | var wheelType = "onwheel" in document.createElement("div") ? "wheel" :
|
20157 | document.onmousewheel !== undefined ? "mousewheel" :
|
20158 |
|
20159 |
|
20160 | this.dom.centerContainer.addEventListener ? "DOMMouseScroll" : "onmousewheel";
|
20161 | this.dom.top.addEventListener ? "DOMMouseScroll" : "onmousewheel";
|
20162 | this.dom.bottom.addEventListener ? "DOMMouseScroll" : "onmousewheel";
|
20163 | this.dom.centerContainer.addEventListener(wheelType, _bindInstanceProperty(onMouseWheel).call(onMouseWheel, this), false);
|
20164 | this.dom.top.addEventListener(wheelType, _bindInstanceProperty(onMouseWheel).call(onMouseWheel, this), false);
|
20165 | this.dom.bottom.addEventListener(wheelType, _bindInstanceProperty(onMouseWheel).call(onMouseWheel, this), false);
|
20166 | |
20167 |
|
20168 |
|
20169 |
|
20170 |
|
20171 | function onMouseScrollSide(event) {
|
20172 | if (!me.options.verticalScroll) return;
|
20173 | event.preventDefault();
|
20174 |
|
20175 | if (me.isActive()) {
|
20176 | var adjusted = -event.target.scrollTop;
|
20177 |
|
20178 | me._setScrollTop(adjusted);
|
20179 |
|
20180 | me._redraw();
|
20181 |
|
20182 | me.emit('scrollSide', event);
|
20183 | }
|
20184 | }
|
20185 |
|
20186 | this.dom.left.parentNode.addEventListener('scroll', _bindInstanceProperty(onMouseScrollSide).call(onMouseScrollSide, this));
|
20187 | this.dom.right.parentNode.addEventListener('scroll', _bindInstanceProperty(onMouseScrollSide).call(onMouseScrollSide, this));
|
20188 | var itemAddedToTimeline = false;
|
20189 | |
20190 |
|
20191 |
|
20192 |
|
20193 |
|
20194 |
|
20195 | function handleDragOver(event) {
|
20196 | var _context4;
|
20197 |
|
20198 | if (event.preventDefault) {
|
20199 | me.emit('dragover', me.getEventProperties(event));
|
20200 | event.preventDefault();
|
20201 | }
|
20202 |
|
20203 |
|
20204 | if (!(_indexOfInstanceProperty(_context4 = event.target.className).call(_context4, "timeline") > -1)) return;
|
20205 |
|
20206 | if (itemAddedToTimeline) return;
|
20207 | event.dataTransfer.dropEffect = 'move';
|
20208 | itemAddedToTimeline = true;
|
20209 | return false;
|
20210 | }
|
20211 | |
20212 |
|
20213 |
|
20214 |
|
20215 |
|
20216 |
|
20217 |
|
20218 | function handleDrop(event) {
|
20219 |
|
20220 | if (event.preventDefault) {
|
20221 | event.preventDefault();
|
20222 | }
|
20223 |
|
20224 | if (event.stopPropagation) {
|
20225 | event.stopPropagation();
|
20226 | }
|
20227 |
|
20228 |
|
20229 | try {
|
20230 | var itemData = JSON.parse(event.dataTransfer.getData("text"));
|
20231 | if (!itemData || !itemData.content) return;
|
20232 | } catch (err) {
|
20233 | return false;
|
20234 | }
|
20235 |
|
20236 | itemAddedToTimeline = false;
|
20237 | event.center = {
|
20238 | x: event.clientX,
|
20239 | y: event.clientY
|
20240 | };
|
20241 |
|
20242 | if (itemData.target !== 'item') {
|
20243 | me.itemSet._onAddItem(event);
|
20244 | } else {
|
20245 | me.itemSet._onDropObjectOnItem(event);
|
20246 | }
|
20247 |
|
20248 | me.emit('drop', me.getEventProperties(event));
|
20249 | return false;
|
20250 | }
|
20251 |
|
20252 | this.dom.center.addEventListener('dragover', _bindInstanceProperty(handleDragOver).call(handleDragOver, this), false);
|
20253 | this.dom.center.addEventListener('drop', _bindInstanceProperty(handleDrop).call(handleDrop, this), false);
|
20254 | this.customTimes = [];
|
20255 |
|
20256 | this.touch = {};
|
20257 | this.redrawCount = 0;
|
20258 | this.initialDrawDone = false;
|
20259 | this.initialRangeChangeDone = false;
|
20260 |
|
20261 | if (!container) throw new Error('No container provided');
|
20262 | container.appendChild(this.dom.root);
|
20263 | container.appendChild(this.dom.loadingScreen);
|
20264 | }
|
20265 | |
20266 |
|
20267 |
|
20268 |
|
20269 |
|
20270 |
|
20271 |
|
20272 |
|
20273 |
|
20274 |
|
20275 |
|
20276 |
|
20277 |
|
20278 |
|
20279 |
|
20280 |
|
20281 |
|
20282 |
|
20283 |
|
20284 |
|
20285 |
|
20286 |
|
20287 |
|
20288 |
|
20289 |
|
20290 |
|
20291 | }, {
|
20292 | key: "setOptions",
|
20293 | value: function setOptions(options) {
|
20294 | var _context7;
|
20295 |
|
20296 | if (options) {
|
20297 |
|
20298 | var fields = ['width', 'height', 'minHeight', 'maxHeight', 'autoResize', 'start', 'end', 'clickToUse', 'dataAttributes', 'hiddenDates', 'locale', 'locales', 'moment', 'preferZoom', 'rtl', 'zoomKey', 'horizontalScroll', 'verticalScroll', 'longSelectPressTime', 'snap'];
|
20299 | availableUtils.selectiveExtend(fields, this.options, options);
|
20300 | this.dom.rollingModeBtn.style.visibility = 'hidden';
|
20301 |
|
20302 | if (this.options.rtl) {
|
20303 | this.dom.container.style.direction = "rtl";
|
20304 | this.dom.backgroundVertical.className = 'vis-panel vis-background vis-vertical-rtl';
|
20305 | }
|
20306 |
|
20307 | if (this.options.verticalScroll) {
|
20308 | if (this.options.rtl) {
|
20309 | this.dom.rightContainer.className = 'vis-panel vis-right vis-vertical-scroll';
|
20310 | } else {
|
20311 | this.dom.leftContainer.className = 'vis-panel vis-left vis-vertical-scroll';
|
20312 | }
|
20313 | }
|
20314 |
|
20315 | if (_typeof(this.options.orientation) !== 'object') {
|
20316 | this.options.orientation = {
|
20317 | item: undefined,
|
20318 | axis: undefined
|
20319 | };
|
20320 | }
|
20321 |
|
20322 | if ('orientation' in options) {
|
20323 | if (typeof options.orientation === 'string') {
|
20324 | this.options.orientation = {
|
20325 | item: options.orientation,
|
20326 | axis: options.orientation
|
20327 | };
|
20328 | } else if (_typeof(options.orientation) === 'object') {
|
20329 | if ('item' in options.orientation) {
|
20330 | this.options.orientation.item = options.orientation.item;
|
20331 | }
|
20332 |
|
20333 | if ('axis' in options.orientation) {
|
20334 | this.options.orientation.axis = options.orientation.axis;
|
20335 | }
|
20336 | }
|
20337 | }
|
20338 |
|
20339 | if (this.options.orientation.axis === 'both') {
|
20340 | if (!this.timeAxis2) {
|
20341 | var timeAxis2 = this.timeAxis2 = new TimeAxis(this.body);
|
20342 |
|
20343 | timeAxis2.setOptions = function (options) {
|
20344 | var _options = options ? availableUtils.extend({}, options) : {};
|
20345 |
|
20346 | _options.orientation = 'top';
|
20347 |
|
20348 | TimeAxis.prototype.setOptions.call(timeAxis2, _options);
|
20349 | };
|
20350 |
|
20351 | this.components.push(timeAxis2);
|
20352 | }
|
20353 | } else {
|
20354 | if (this.timeAxis2) {
|
20355 | var _context5;
|
20356 |
|
20357 | var index = _indexOfInstanceProperty(_context5 = this.components).call(_context5, this.timeAxis2);
|
20358 |
|
20359 | if (index !== -1) {
|
20360 | var _context6;
|
20361 |
|
20362 | _spliceInstanceProperty(_context6 = this.components).call(_context6, index, 1);
|
20363 | }
|
20364 |
|
20365 | this.timeAxis2.destroy();
|
20366 | this.timeAxis2 = null;
|
20367 | }
|
20368 | }
|
20369 |
|
20370 |
|
20371 | if (typeof options.drawPoints == 'function') {
|
20372 | options.drawPoints = {
|
20373 | onRender: options.drawPoints
|
20374 | };
|
20375 | }
|
20376 |
|
20377 | if ('hiddenDates' in this.options) {
|
20378 | convertHiddenOptions(this.options.moment, this.body, this.options.hiddenDates);
|
20379 | }
|
20380 |
|
20381 | if ('clickToUse' in options) {
|
20382 | if (options.clickToUse) {
|
20383 | if (!this.activator) {
|
20384 | this.activator = new Activator(this.dom.root);
|
20385 | }
|
20386 | } else {
|
20387 | if (this.activator) {
|
20388 | this.activator.destroy();
|
20389 | delete this.activator;
|
20390 | }
|
20391 | }
|
20392 | }
|
20393 |
|
20394 |
|
20395 | this._initAutoResize();
|
20396 | }
|
20397 |
|
20398 |
|
20399 | _forEachInstanceProperty(_context7 = this.components).call(_context7, function (component) {
|
20400 | return component.setOptions(options);
|
20401 | });
|
20402 |
|
20403 |
|
20404 | if ('configure' in options) {
|
20405 | var _context8;
|
20406 |
|
20407 | if (!this.configurator) {
|
20408 | this.configurator = this._createConfigurator();
|
20409 | }
|
20410 |
|
20411 | this.configurator.setOptions(options.configure);
|
20412 |
|
20413 | var appliedOptions = availableUtils.deepExtend({}, this.options);
|
20414 |
|
20415 | _forEachInstanceProperty(_context8 = this.components).call(_context8, function (component) {
|
20416 | availableUtils.deepExtend(appliedOptions, component.options);
|
20417 | });
|
20418 |
|
20419 | this.configurator.setModuleOptions({
|
20420 | global: appliedOptions
|
20421 | });
|
20422 | }
|
20423 |
|
20424 | this._redraw();
|
20425 | }
|
20426 | |
20427 |
|
20428 |
|
20429 |
|
20430 |
|
20431 | }, {
|
20432 | key: "isActive",
|
20433 | value: function isActive() {
|
20434 | return !this.activator || this.activator.active;
|
20435 | }
|
20436 | |
20437 |
|
20438 |
|
20439 |
|
20440 | }, {
|
20441 | key: "destroy",
|
20442 | value: function destroy() {
|
20443 | var _context9;
|
20444 |
|
20445 |
|
20446 | this.setItems(null);
|
20447 | this.setGroups(null);
|
20448 |
|
20449 | this.off();
|
20450 |
|
20451 | this._stopAutoResize();
|
20452 |
|
20453 |
|
20454 | if (this.dom.root.parentNode) {
|
20455 | this.dom.root.parentNode.removeChild(this.dom.root);
|
20456 | }
|
20457 |
|
20458 | this.dom = null;
|
20459 |
|
20460 | if (this.activator) {
|
20461 | this.activator.destroy();
|
20462 | delete this.activator;
|
20463 | }
|
20464 |
|
20465 |
|
20466 | for (var event in this.timelineListeners) {
|
20467 | if (this.timelineListeners.hasOwnProperty(event)) {
|
20468 | delete this.timelineListeners[event];
|
20469 | }
|
20470 | }
|
20471 |
|
20472 | this.timelineListeners = null;
|
20473 | this.hammer && this.hammer.destroy();
|
20474 | this.hammer = null;
|
20475 |
|
20476 | _forEachInstanceProperty(_context9 = this.components).call(_context9, function (component) {
|
20477 | return component.destroy();
|
20478 | });
|
20479 |
|
20480 | this.body = null;
|
20481 | }
|
20482 | |
20483 |
|
20484 |
|
20485 |
|
20486 |
|
20487 |
|
20488 | }, {
|
20489 | key: "setCustomTime",
|
20490 | value: function setCustomTime(time, id) {
|
20491 | var _context10;
|
20492 |
|
20493 | var customTimes = _filterInstanceProperty(_context10 = this.customTimes).call(_context10, function (component) {
|
20494 | return id === component.options.id;
|
20495 | });
|
20496 |
|
20497 | if (customTimes.length === 0) {
|
20498 | throw new Error("No custom time bar found with id ".concat(_JSON$stringify(id)));
|
20499 | }
|
20500 |
|
20501 | if (customTimes.length > 0) {
|
20502 | customTimes[0].setCustomTime(time);
|
20503 | }
|
20504 | }
|
20505 | |
20506 |
|
20507 |
|
20508 |
|
20509 |
|
20510 |
|
20511 | }, {
|
20512 | key: "getCustomTime",
|
20513 | value: function getCustomTime(id) {
|
20514 | var _context11;
|
20515 |
|
20516 | var customTimes = _filterInstanceProperty(_context11 = this.customTimes).call(_context11, function (component) {
|
20517 | return component.options.id === id;
|
20518 | });
|
20519 |
|
20520 | if (customTimes.length === 0) {
|
20521 | throw new Error("No custom time bar found with id ".concat(_JSON$stringify(id)));
|
20522 | }
|
20523 |
|
20524 | return customTimes[0].getCustomTime();
|
20525 | }
|
20526 | |
20527 |
|
20528 |
|
20529 |
|
20530 |
|
20531 |
|
20532 |
|
20533 | }, {
|
20534 | key: "setCustomTimeMarker",
|
20535 | value: function setCustomTimeMarker(title, id, editable) {
|
20536 | var _context12;
|
20537 |
|
20538 | var customTimes = _filterInstanceProperty(_context12 = this.customTimes).call(_context12, function (component) {
|
20539 | return component.options.id === id;
|
20540 | });
|
20541 |
|
20542 | if (customTimes.length === 0) {
|
20543 | throw new Error("No custom time bar found with id ".concat(_JSON$stringify(id)));
|
20544 | }
|
20545 |
|
20546 | if (customTimes.length > 0) {
|
20547 | customTimes[0].setCustomMarker(title, editable);
|
20548 | }
|
20549 | }
|
20550 | |
20551 |
|
20552 |
|
20553 |
|
20554 |
|
20555 |
|
20556 |
|
20557 | }, {
|
20558 | key: "setCustomTimeTitle",
|
20559 | value: function setCustomTimeTitle(title, id) {
|
20560 | var _context13;
|
20561 |
|
20562 | var customTimes = _filterInstanceProperty(_context13 = this.customTimes).call(_context13, function (component) {
|
20563 | return component.options.id === id;
|
20564 | });
|
20565 |
|
20566 | if (customTimes.length === 0) {
|
20567 | throw new Error("No custom time bar found with id ".concat(_JSON$stringify(id)));
|
20568 | }
|
20569 |
|
20570 | if (customTimes.length > 0) {
|
20571 | return customTimes[0].setCustomTitle(title);
|
20572 | }
|
20573 | }
|
20574 | |
20575 |
|
20576 |
|
20577 |
|
20578 |
|
20579 |
|
20580 |
|
20581 | }, {
|
20582 | key: "getEventProperties",
|
20583 | value: function getEventProperties(event) {
|
20584 | return {
|
20585 | event: event
|
20586 | };
|
20587 | }
|
20588 | |
20589 |
|
20590 |
|
20591 |
|
20592 |
|
20593 |
|
20594 |
|
20595 |
|
20596 |
|
20597 |
|
20598 |
|
20599 | }, {
|
20600 | key: "addCustomTime",
|
20601 | value: function addCustomTime(time, id) {
|
20602 | var _context14;
|
20603 |
|
20604 | var timestamp = time !== undefined ? availableUtils.convert(time, 'Date') : new Date();
|
20605 |
|
20606 | var exists = _someInstanceProperty(_context14 = this.customTimes).call(_context14, function (customTime) {
|
20607 | return customTime.options.id === id;
|
20608 | });
|
20609 |
|
20610 | if (exists) {
|
20611 | throw new Error("A custom time with id ".concat(_JSON$stringify(id), " already exists"));
|
20612 | }
|
20613 |
|
20614 | var customTime = new CustomTime(this.body, availableUtils.extend({}, this.options, {
|
20615 | time: timestamp,
|
20616 | id: id,
|
20617 | snap: this.itemSet ? this.itemSet.options.snap : this.options.snap
|
20618 | }));
|
20619 | this.customTimes.push(customTime);
|
20620 | this.components.push(customTime);
|
20621 |
|
20622 | this._redraw();
|
20623 |
|
20624 | return id;
|
20625 | }
|
20626 | |
20627 |
|
20628 |
|
20629 |
|
20630 |
|
20631 |
|
20632 | }, {
|
20633 | key: "removeCustomTime",
|
20634 | value: function removeCustomTime(id) {
|
20635 | var _context15,
|
20636 | _this2 = this;
|
20637 |
|
20638 | var customTimes = _filterInstanceProperty(_context15 = this.customTimes).call(_context15, function (bar) {
|
20639 | return bar.options.id === id;
|
20640 | });
|
20641 |
|
20642 | if (customTimes.length === 0) {
|
20643 | throw new Error("No custom time bar found with id ".concat(_JSON$stringify(id)));
|
20644 | }
|
20645 |
|
20646 | _forEachInstanceProperty(customTimes).call(customTimes, function (customTime) {
|
20647 | var _context16, _context17, _context18, _context19;
|
20648 |
|
20649 | _spliceInstanceProperty(_context16 = _this2.customTimes).call(_context16, _indexOfInstanceProperty(_context17 = _this2.customTimes).call(_context17, customTime), 1);
|
20650 |
|
20651 | _spliceInstanceProperty(_context18 = _this2.components).call(_context18, _indexOfInstanceProperty(_context19 = _this2.components).call(_context19, customTime), 1);
|
20652 |
|
20653 | customTime.destroy();
|
20654 | });
|
20655 | }
|
20656 | |
20657 |
|
20658 |
|
20659 |
|
20660 |
|
20661 | }, {
|
20662 | key: "getVisibleItems",
|
20663 | value: function getVisibleItems() {
|
20664 | return this.itemSet && this.itemSet.getVisibleItems() || [];
|
20665 | }
|
20666 | |
20667 |
|
20668 |
|
20669 |
|
20670 |
|
20671 | }, {
|
20672 | key: "getItemsAtCurrentTime",
|
20673 | value: function getItemsAtCurrentTime(timeOfEvent) {
|
20674 | this.time = timeOfEvent;
|
20675 | return this.itemSet && this.itemSet.getItemsAtCurrentTime(this.time) || [];
|
20676 | }
|
20677 | |
20678 |
|
20679 |
|
20680 |
|
20681 |
|
20682 | }, {
|
20683 | key: "getVisibleGroups",
|
20684 | value: function getVisibleGroups() {
|
20685 | return this.itemSet && this.itemSet.getVisibleGroups() || [];
|
20686 | }
|
20687 | |
20688 |
|
20689 |
|
20690 |
|
20691 |
|
20692 |
|
20693 |
|
20694 |
|
20695 |
|
20696 |
|
20697 |
|
20698 |
|
20699 | }, {
|
20700 | key: "fit",
|
20701 | value: function fit(options, callback) {
|
20702 | var range = this.getDataRange();
|
20703 |
|
20704 | if (range.min === null && range.max === null) {
|
20705 | return;
|
20706 | }
|
20707 |
|
20708 |
|
20709 | var interval = range.max - range.min;
|
20710 | var min = new Date(range.min.valueOf() - interval * 0.01);
|
20711 | var max = new Date(range.max.valueOf() + interval * 0.01);
|
20712 | var animation = options && options.animation !== undefined ? options.animation : true;
|
20713 | this.range.setRange(min, max, {
|
20714 | animation: animation
|
20715 | }, callback);
|
20716 | }
|
20717 | |
20718 |
|
20719 |
|
20720 |
|
20721 |
|
20722 |
|
20723 | }, {
|
20724 | key: "getDataRange",
|
20725 | value: function getDataRange() {
|
20726 |
|
20727 | throw new Error('Cannot invoke abstract method getDataRange');
|
20728 | }
|
20729 | |
20730 |
|
20731 |
|
20732 |
|
20733 |
|
20734 |
|
20735 |
|
20736 |
|
20737 |
|
20738 |
|
20739 |
|
20740 |
|
20741 |
|
20742 |
|
20743 |
|
20744 |
|
20745 |
|
20746 |
|
20747 |
|
20748 |
|
20749 |
|
20750 |
|
20751 |
|
20752 | }, {
|
20753 | key: "setWindow",
|
20754 | value: function setWindow(start, end, options, callback) {
|
20755 | if (typeof arguments[2] == "function") {
|
20756 | callback = arguments[2];
|
20757 | options = {};
|
20758 | }
|
20759 |
|
20760 | var animation;
|
20761 | var range;
|
20762 |
|
20763 | if (arguments.length == 1) {
|
20764 | range = arguments[0];
|
20765 | animation = range.animation !== undefined ? range.animation : true;
|
20766 | this.range.setRange(range.start, range.end, {
|
20767 | animation: animation
|
20768 | });
|
20769 | } else if (arguments.length == 2 && typeof arguments[1] == "function") {
|
20770 | range = arguments[0];
|
20771 | callback = arguments[1];
|
20772 | animation = range.animation !== undefined ? range.animation : true;
|
20773 | this.range.setRange(range.start, range.end, {
|
20774 | animation: animation
|
20775 | }, callback);
|
20776 | } else {
|
20777 | animation = options && options.animation !== undefined ? options.animation : true;
|
20778 | this.range.setRange(start, end, {
|
20779 | animation: animation
|
20780 | }, callback);
|
20781 | }
|
20782 | }
|
20783 | |
20784 |
|
20785 |
|
20786 |
|
20787 |
|
20788 |
|
20789 |
|
20790 |
|
20791 |
|
20792 |
|
20793 |
|
20794 |
|
20795 |
|
20796 | }, {
|
20797 | key: "moveTo",
|
20798 | value: function moveTo(time, options, callback) {
|
20799 | if (typeof arguments[1] == "function") {
|
20800 | callback = arguments[1];
|
20801 | options = {};
|
20802 | }
|
20803 |
|
20804 | var interval = this.range.end - this.range.start;
|
20805 | var t = availableUtils.convert(time, 'Date').valueOf();
|
20806 | var start = t - interval / 2;
|
20807 | var end = t + interval / 2;
|
20808 | var animation = options && options.animation !== undefined ? options.animation : true;
|
20809 | this.range.setRange(start, end, {
|
20810 | animation: animation
|
20811 | }, callback);
|
20812 | }
|
20813 | |
20814 |
|
20815 |
|
20816 |
|
20817 |
|
20818 | }, {
|
20819 | key: "getWindow",
|
20820 | value: function getWindow() {
|
20821 | var range = this.range.getRange();
|
20822 | return {
|
20823 | start: new Date(range.start),
|
20824 | end: new Date(range.end)
|
20825 | };
|
20826 | }
|
20827 | |
20828 |
|
20829 |
|
20830 |
|
20831 |
|
20832 |
|
20833 |
|
20834 |
|
20835 |
|
20836 |
|
20837 |
|
20838 |
|
20839 |
|
20840 | }, {
|
20841 | key: "zoomIn",
|
20842 | value: function zoomIn(percentage, options, callback) {
|
20843 | if (!percentage || percentage < 0 || percentage > 1) return;
|
20844 |
|
20845 | if (typeof arguments[1] == "function") {
|
20846 | callback = arguments[1];
|
20847 | options = {};
|
20848 | }
|
20849 |
|
20850 | var range = this.getWindow();
|
20851 | var start = range.start.valueOf();
|
20852 | var end = range.end.valueOf();
|
20853 | var interval = end - start;
|
20854 | var newInterval = interval / (1 + percentage);
|
20855 | var distance = (interval - newInterval) / 2;
|
20856 | var newStart = start + distance;
|
20857 | var newEnd = end - distance;
|
20858 | this.setWindow(newStart, newEnd, options, callback);
|
20859 | }
|
20860 | |
20861 |
|
20862 |
|
20863 |
|
20864 |
|
20865 |
|
20866 |
|
20867 |
|
20868 |
|
20869 |
|
20870 |
|
20871 |
|
20872 |
|
20873 | }, {
|
20874 | key: "zoomOut",
|
20875 | value: function zoomOut(percentage, options, callback) {
|
20876 | if (!percentage || percentage < 0 || percentage > 1) return;
|
20877 |
|
20878 | if (typeof arguments[1] == "function") {
|
20879 | callback = arguments[1];
|
20880 | options = {};
|
20881 | }
|
20882 |
|
20883 | var range = this.getWindow();
|
20884 | var start = range.start.valueOf();
|
20885 | var end = range.end.valueOf();
|
20886 | var interval = end - start;
|
20887 | var newStart = start - interval * percentage / 2;
|
20888 | var newEnd = end + interval * percentage / 2;
|
20889 | this.setWindow(newStart, newEnd, options, callback);
|
20890 | }
|
20891 | |
20892 |
|
20893 |
|
20894 |
|
20895 |
|
20896 |
|
20897 | }, {
|
20898 | key: "redraw",
|
20899 | value: function redraw() {
|
20900 | this._redraw();
|
20901 | }
|
20902 | |
20903 |
|
20904 |
|
20905 |
|
20906 |
|
20907 |
|
20908 | }, {
|
20909 | key: "_redraw",
|
20910 | value: function _redraw() {
|
20911 | var _context20;
|
20912 |
|
20913 | this.redrawCount++;
|
20914 | var dom = this.dom;
|
20915 | if (!dom || !dom.container || dom.root.offsetWidth == 0) return;
|
20916 |
|
20917 | var resized = false;
|
20918 | var options = this.options;
|
20919 | var props = this.props;
|
20920 | updateHiddenDates(this.options.moment, this.body, this.options.hiddenDates);
|
20921 |
|
20922 | if (options.orientation == 'top') {
|
20923 | availableUtils.addClassName(dom.root, 'vis-top');
|
20924 | availableUtils.removeClassName(dom.root, 'vis-bottom');
|
20925 | } else {
|
20926 | availableUtils.removeClassName(dom.root, 'vis-top');
|
20927 | availableUtils.addClassName(dom.root, 'vis-bottom');
|
20928 | }
|
20929 |
|
20930 | if (options.rtl) {
|
20931 | availableUtils.addClassName(dom.root, 'vis-rtl');
|
20932 | availableUtils.removeClassName(dom.root, 'vis-ltr');
|
20933 | } else {
|
20934 | availableUtils.addClassName(dom.root, 'vis-ltr');
|
20935 | availableUtils.removeClassName(dom.root, 'vis-rtl');
|
20936 | }
|
20937 |
|
20938 |
|
20939 | dom.root.style.maxHeight = availableUtils.option.asSize(options.maxHeight, '');
|
20940 | dom.root.style.minHeight = availableUtils.option.asSize(options.minHeight, '');
|
20941 | dom.root.style.width = availableUtils.option.asSize(options.width, '');
|
20942 | var rootOffsetWidth = dom.root.offsetWidth;
|
20943 |
|
20944 | props.border.left = 1;
|
20945 | props.border.right = 1;
|
20946 | props.border.top = 1;
|
20947 | props.border.bottom = 1;
|
20948 |
|
20949 |
|
20950 | props.center.height = dom.center.offsetHeight;
|
20951 | props.left.height = dom.left.offsetHeight;
|
20952 | props.right.height = dom.right.offsetHeight;
|
20953 | props.top.height = dom.top.clientHeight || -props.border.top;
|
20954 | props.bottom.height = Math.round(dom.bottom.getBoundingClientRect().height) || dom.bottom.clientHeight || -props.border.bottom;
|
20955 |
|
20956 |
|
20957 |
|
20958 | var contentHeight = Math.max(props.left.height, props.center.height, props.right.height);
|
20959 | var autoHeight = props.top.height + contentHeight + props.bottom.height + props.border.top + props.border.bottom;
|
20960 | dom.root.style.height = availableUtils.option.asSize(options.height, "".concat(autoHeight, "px"));
|
20961 |
|
20962 | props.root.height = dom.root.offsetHeight;
|
20963 | props.background.height = props.root.height;
|
20964 | var containerHeight = props.root.height - props.top.height - props.bottom.height;
|
20965 | props.centerContainer.height = containerHeight;
|
20966 | props.leftContainer.height = containerHeight;
|
20967 | props.rightContainer.height = props.leftContainer.height;
|
20968 |
|
20969 | props.root.width = rootOffsetWidth;
|
20970 | props.background.width = props.root.width;
|
20971 |
|
20972 | if (!this.initialDrawDone) {
|
20973 | props.scrollbarWidth = availableUtils.getScrollBarWidth();
|
20974 | }
|
20975 |
|
20976 | var leftContainerClientWidth = dom.leftContainer.clientWidth;
|
20977 | var rightContainerClientWidth = dom.rightContainer.clientWidth;
|
20978 |
|
20979 | if (options.verticalScroll) {
|
20980 | if (options.rtl) {
|
20981 | props.left.width = leftContainerClientWidth || -props.border.left;
|
20982 | props.right.width = rightContainerClientWidth + props.scrollbarWidth || -props.border.right;
|
20983 | } else {
|
20984 | props.left.width = leftContainerClientWidth + props.scrollbarWidth || -props.border.left;
|
20985 | props.right.width = rightContainerClientWidth || -props.border.right;
|
20986 | }
|
20987 | } else {
|
20988 | props.left.width = leftContainerClientWidth || -props.border.left;
|
20989 | props.right.width = rightContainerClientWidth || -props.border.right;
|
20990 | }
|
20991 |
|
20992 | this._setDOM();
|
20993 |
|
20994 |
|
20995 |
|
20996 | var offset = this._updateScrollTop();
|
20997 |
|
20998 |
|
20999 | if (options.orientation.item != 'top') {
|
21000 | offset += Math.max(props.centerContainer.height - props.center.height - props.border.top - props.border.bottom, 0);
|
21001 | }
|
21002 |
|
21003 | dom.center.style.transform = "translateY(".concat(offset, "px)");
|
21004 |
|
21005 | var visibilityTop = props.scrollTop == 0 ? 'hidden' : '';
|
21006 | var visibilityBottom = props.scrollTop == props.scrollTopMin ? 'hidden' : '';
|
21007 | dom.shadowTop.style.visibility = visibilityTop;
|
21008 | dom.shadowBottom.style.visibility = visibilityBottom;
|
21009 | dom.shadowTopLeft.style.visibility = visibilityTop;
|
21010 | dom.shadowBottomLeft.style.visibility = visibilityBottom;
|
21011 | dom.shadowTopRight.style.visibility = visibilityTop;
|
21012 | dom.shadowBottomRight.style.visibility = visibilityBottom;
|
21013 |
|
21014 | if (options.verticalScroll) {
|
21015 | dom.rightContainer.className = 'vis-panel vis-right vis-vertical-scroll';
|
21016 | dom.leftContainer.className = 'vis-panel vis-left vis-vertical-scroll';
|
21017 | dom.shadowTopRight.style.visibility = "hidden";
|
21018 | dom.shadowBottomRight.style.visibility = "hidden";
|
21019 | dom.shadowTopLeft.style.visibility = "hidden";
|
21020 | dom.shadowBottomLeft.style.visibility = "hidden";
|
21021 | dom.left.style.top = '0px';
|
21022 | dom.right.style.top = '0px';
|
21023 | }
|
21024 |
|
21025 | if (!options.verticalScroll || props.center.height < props.centerContainer.height) {
|
21026 | dom.left.style.top = "".concat(offset, "px");
|
21027 | dom.right.style.top = "".concat(offset, "px");
|
21028 | dom.rightContainer.className = dom.rightContainer.className.replace(new RegExp('(?:^|\\s)' + 'vis-vertical-scroll' + '(?:\\s|$)'), ' ');
|
21029 | dom.leftContainer.className = dom.leftContainer.className.replace(new RegExp('(?:^|\\s)' + 'vis-vertical-scroll' + '(?:\\s|$)'), ' ');
|
21030 | props.left.width = leftContainerClientWidth || -props.border.left;
|
21031 | props.right.width = rightContainerClientWidth || -props.border.right;
|
21032 |
|
21033 | this._setDOM();
|
21034 | }
|
21035 |
|
21036 |
|
21037 | var contentsOverflow = props.center.height > props.centerContainer.height;
|
21038 | this.hammer.get('pan').set({
|
21039 | direction: contentsOverflow ? Hammer.DIRECTION_ALL : Hammer.DIRECTION_HORIZONTAL
|
21040 | });
|
21041 |
|
21042 | this.hammer.get('press').set({
|
21043 | time: this.options.longSelectPressTime
|
21044 | });
|
21045 |
|
21046 | _forEachInstanceProperty(_context20 = this.components).call(_context20, function (component) {
|
21047 | resized = component.redraw() || resized;
|
21048 | });
|
21049 |
|
21050 | var MAX_REDRAW = 5;
|
21051 |
|
21052 | if (resized) {
|
21053 | if (this.redrawCount < MAX_REDRAW) {
|
21054 | this.body.emitter.emit('_change');
|
21055 | return;
|
21056 | } else {
|
21057 | console.log('WARNING: infinite loop in redraw?');
|
21058 | }
|
21059 | } else {
|
21060 | this.redrawCount = 0;
|
21061 | }
|
21062 |
|
21063 |
|
21064 | this.body.emitter.emit("changed");
|
21065 | }
|
21066 | |
21067 |
|
21068 |
|
21069 |
|
21070 | }, {
|
21071 | key: "_setDOM",
|
21072 | value: function _setDOM() {
|
21073 | var props = this.props;
|
21074 | var dom = this.dom;
|
21075 | props.leftContainer.width = props.left.width;
|
21076 | props.rightContainer.width = props.right.width;
|
21077 | var centerWidth = props.root.width - props.left.width - props.right.width;
|
21078 | props.center.width = centerWidth;
|
21079 | props.centerContainer.width = centerWidth;
|
21080 | props.top.width = centerWidth;
|
21081 | props.bottom.width = centerWidth;
|
21082 |
|
21083 | dom.background.style.height = "".concat(props.background.height, "px");
|
21084 | dom.backgroundVertical.style.height = "".concat(props.background.height, "px");
|
21085 | dom.backgroundHorizontal.style.height = "".concat(props.centerContainer.height, "px");
|
21086 | dom.centerContainer.style.height = "".concat(props.centerContainer.height, "px");
|
21087 | dom.leftContainer.style.height = "".concat(props.leftContainer.height, "px");
|
21088 | dom.rightContainer.style.height = "".concat(props.rightContainer.height, "px");
|
21089 | dom.background.style.width = "".concat(props.background.width, "px");
|
21090 | dom.backgroundVertical.style.width = "".concat(props.centerContainer.width, "px");
|
21091 | dom.backgroundHorizontal.style.width = "".concat(props.background.width, "px");
|
21092 | dom.centerContainer.style.width = "".concat(props.center.width, "px");
|
21093 | dom.top.style.width = "".concat(props.top.width, "px");
|
21094 | dom.bottom.style.width = "".concat(props.bottom.width, "px");
|
21095 |
|
21096 | dom.background.style.left = '0';
|
21097 | dom.background.style.top = '0';
|
21098 | dom.backgroundVertical.style.left = "".concat(props.left.width + props.border.left, "px");
|
21099 | dom.backgroundVertical.style.top = '0';
|
21100 | dom.backgroundHorizontal.style.left = '0';
|
21101 | dom.backgroundHorizontal.style.top = "".concat(props.top.height, "px");
|
21102 | dom.centerContainer.style.left = "".concat(props.left.width, "px");
|
21103 | dom.centerContainer.style.top = "".concat(props.top.height, "px");
|
21104 | dom.leftContainer.style.left = '0';
|
21105 | dom.leftContainer.style.top = "".concat(props.top.height, "px");
|
21106 | dom.rightContainer.style.left = "".concat(props.left.width + props.center.width, "px");
|
21107 | dom.rightContainer.style.top = "".concat(props.top.height, "px");
|
21108 | dom.top.style.left = "".concat(props.left.width, "px");
|
21109 | dom.top.style.top = '0';
|
21110 | dom.bottom.style.left = "".concat(props.left.width, "px");
|
21111 | dom.bottom.style.top = "".concat(props.top.height + props.centerContainer.height, "px");
|
21112 | dom.center.style.left = '0';
|
21113 | dom.left.style.left = '0';
|
21114 | dom.right.style.left = '0';
|
21115 | }
|
21116 | |
21117 |
|
21118 |
|
21119 |
|
21120 |
|
21121 |
|
21122 |
|
21123 |
|
21124 | }, {
|
21125 | key: "setCurrentTime",
|
21126 | value: function setCurrentTime(time) {
|
21127 | if (!this.currentTime) {
|
21128 | throw new Error('Option showCurrentTime must be true');
|
21129 | }
|
21130 |
|
21131 | this.currentTime.setCurrentTime(time);
|
21132 | }
|
21133 | |
21134 |
|
21135 |
|
21136 |
|
21137 |
|
21138 |
|
21139 | }, {
|
21140 | key: "getCurrentTime",
|
21141 | value: function getCurrentTime() {
|
21142 | if (!this.currentTime) {
|
21143 | throw new Error('Option showCurrentTime must be true');
|
21144 | }
|
21145 |
|
21146 | return this.currentTime.getCurrentTime();
|
21147 | }
|
21148 | |
21149 |
|
21150 |
|
21151 |
|
21152 |
|
21153 |
|
21154 |
|
21155 |
|
21156 | }, {
|
21157 | key: "_toTime",
|
21158 | value: function _toTime(x) {
|
21159 | return toTime(this, x, this.props.center.width);
|
21160 | }
|
21161 | |
21162 |
|
21163 |
|
21164 |
|
21165 |
|
21166 |
|
21167 |
|
21168 |
|
21169 | }, {
|
21170 | key: "_toGlobalTime",
|
21171 | value: function _toGlobalTime(x) {
|
21172 | return toTime(this, x, this.props.root.width);
|
21173 |
|
21174 | }
|
21175 | |
21176 |
|
21177 |
|
21178 |
|
21179 |
|
21180 |
|
21181 |
|
21182 |
|
21183 |
|
21184 | }, {
|
21185 | key: "_toScreen",
|
21186 | value: function _toScreen(time) {
|
21187 | return toScreen(this, time, this.props.center.width);
|
21188 | }
|
21189 | |
21190 |
|
21191 |
|
21192 |
|
21193 |
|
21194 |
|
21195 |
|
21196 |
|
21197 |
|
21198 |
|
21199 | }, {
|
21200 | key: "_toGlobalScreen",
|
21201 | value: function _toGlobalScreen(time) {
|
21202 | return toScreen(this, time, this.props.root.width);
|
21203 |
|
21204 | }
|
21205 | |
21206 |
|
21207 |
|
21208 |
|
21209 |
|
21210 | }, {
|
21211 | key: "_initAutoResize",
|
21212 | value: function _initAutoResize() {
|
21213 | if (this.options.autoResize == true) {
|
21214 | this._startAutoResize();
|
21215 | } else {
|
21216 | this._stopAutoResize();
|
21217 | }
|
21218 | }
|
21219 | |
21220 |
|
21221 |
|
21222 |
|
21223 |
|
21224 |
|
21225 | }, {
|
21226 | key: "_startAutoResize",
|
21227 | value: function _startAutoResize() {
|
21228 | var me = this;
|
21229 |
|
21230 | this._stopAutoResize();
|
21231 |
|
21232 | this._onResize = function () {
|
21233 | if (me.options.autoResize != true) {
|
21234 |
|
21235 | me._stopAutoResize();
|
21236 |
|
21237 | return;
|
21238 | }
|
21239 |
|
21240 | if (me.dom.root) {
|
21241 | var rootOffsetHeight = me.dom.root.offsetHeight;
|
21242 | var rootOffsetWidth = me.dom.root.offsetWidth;
|
21243 |
|
21244 |
|
21245 |
|
21246 |
|
21247 | if (rootOffsetWidth != me.props.lastWidth || rootOffsetHeight != me.props.lastHeight) {
|
21248 | me.props.lastWidth = rootOffsetWidth;
|
21249 | me.props.lastHeight = rootOffsetHeight;
|
21250 | me.props.scrollbarWidth = availableUtils.getScrollBarWidth();
|
21251 | me.body.emitter.emit('_change');
|
21252 | }
|
21253 | }
|
21254 | };
|
21255 |
|
21256 |
|
21257 | availableUtils.addEventListener(window, 'resize', this._onResize);
|
21258 |
|
21259 | if (me.dom.root) {
|
21260 | me.props.lastWidth = me.dom.root.offsetWidth;
|
21261 | me.props.lastHeight = me.dom.root.offsetHeight;
|
21262 | }
|
21263 |
|
21264 | this.watchTimer = _setInterval(this._onResize, 1000);
|
21265 | }
|
21266 | |
21267 |
|
21268 |
|
21269 |
|
21270 |
|
21271 | }, {
|
21272 | key: "_stopAutoResize",
|
21273 | value: function _stopAutoResize() {
|
21274 | if (this.watchTimer) {
|
21275 | clearInterval(this.watchTimer);
|
21276 | this.watchTimer = undefined;
|
21277 | }
|
21278 |
|
21279 |
|
21280 | if (this._onResize) {
|
21281 | availableUtils.removeEventListener(window, 'resize', this._onResize);
|
21282 | this._onResize = null;
|
21283 | }
|
21284 | }
|
21285 | |
21286 |
|
21287 |
|
21288 |
|
21289 |
|
21290 |
|
21291 | }, {
|
21292 | key: "_onTouch",
|
21293 | value: function _onTouch(event) {
|
21294 |
|
21295 | this.touch.allowDragging = true;
|
21296 | this.touch.initialScrollTop = this.props.scrollTop;
|
21297 | }
|
21298 | |
21299 |
|
21300 |
|
21301 |
|
21302 |
|
21303 |
|
21304 | }, {
|
21305 | key: "_onPinch",
|
21306 | value: function _onPinch(event) {
|
21307 |
|
21308 | this.touch.allowDragging = false;
|
21309 | }
|
21310 | |
21311 |
|
21312 |
|
21313 |
|
21314 |
|
21315 |
|
21316 | }, {
|
21317 | key: "_onDrag",
|
21318 | value: function _onDrag(event) {
|
21319 | if (!event) return;
|
21320 |
|
21321 |
|
21322 | if (!this.touch.allowDragging) return;
|
21323 | var delta = event.deltaY;
|
21324 |
|
21325 | var oldScrollTop = this._getScrollTop();
|
21326 |
|
21327 | var newScrollTop = this._setScrollTop(this.touch.initialScrollTop + delta);
|
21328 |
|
21329 | if (this.options.verticalScroll) {
|
21330 | this.dom.left.parentNode.scrollTop = -this.props.scrollTop;
|
21331 | this.dom.right.parentNode.scrollTop = -this.props.scrollTop;
|
21332 | }
|
21333 |
|
21334 | if (newScrollTop != oldScrollTop) {
|
21335 | this.emit("verticalDrag");
|
21336 | }
|
21337 | }
|
21338 | |
21339 |
|
21340 |
|
21341 |
|
21342 |
|
21343 |
|
21344 |
|
21345 | }, {
|
21346 | key: "_setScrollTop",
|
21347 | value: function _setScrollTop(scrollTop) {
|
21348 | this.props.scrollTop = scrollTop;
|
21349 |
|
21350 | this._updateScrollTop();
|
21351 |
|
21352 | return this.props.scrollTop;
|
21353 | }
|
21354 | |
21355 |
|
21356 |
|
21357 |
|
21358 |
|
21359 |
|
21360 | }, {
|
21361 | key: "_updateScrollTop",
|
21362 | value: function _updateScrollTop() {
|
21363 |
|
21364 | var scrollTopMin = Math.min(this.props.centerContainer.height - this.props.border.top - this.props.border.bottom - this.props.center.height, 0);
|
21365 |
|
21366 | if (scrollTopMin != this.props.scrollTopMin) {
|
21367 |
|
21368 |
|
21369 | if (this.options.orientation.item != 'top') {
|
21370 | this.props.scrollTop += scrollTopMin - this.props.scrollTopMin;
|
21371 | }
|
21372 |
|
21373 | this.props.scrollTopMin = scrollTopMin;
|
21374 | }
|
21375 |
|
21376 |
|
21377 | if (this.props.scrollTop > 0) this.props.scrollTop = 0;
|
21378 | if (this.props.scrollTop < scrollTopMin) this.props.scrollTop = scrollTopMin;
|
21379 |
|
21380 | if (this.options.verticalScroll) {
|
21381 | this.dom.left.parentNode.scrollTop = -this.props.scrollTop;
|
21382 | this.dom.right.parentNode.scrollTop = -this.props.scrollTop;
|
21383 | }
|
21384 |
|
21385 | return this.props.scrollTop;
|
21386 | }
|
21387 | |
21388 |
|
21389 |
|
21390 |
|
21391 |
|
21392 |
|
21393 | }, {
|
21394 | key: "_getScrollTop",
|
21395 | value: function _getScrollTop() {
|
21396 | return this.props.scrollTop;
|
21397 | }
|
21398 | |
21399 |
|
21400 |
|
21401 |
|
21402 |
|
21403 |
|
21404 | }, {
|
21405 | key: "_createConfigurator",
|
21406 | value: function _createConfigurator() {
|
21407 | throw new Error('Cannot invoke abstract method _createConfigurator');
|
21408 | }
|
21409 | }]);
|
21410 |
|
21411 | return Core;
|
21412 | }();
|
21413 |
|
21414 |
|
21415 | Emitter(Core.prototype);
|
21416 |
|
21417 | function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
21418 |
|
21419 | function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
21420 |
|
21421 |
|
21422 |
|
21423 |
|
21424 | var CurrentTime = function (_Component) {
|
21425 | _inherits(CurrentTime, _Component);
|
21426 |
|
21427 | var _super = _createSuper$9(CurrentTime);
|
21428 |
|
21429 | |
21430 |
|
21431 |
|
21432 |
|
21433 |
|
21434 |
|
21435 |
|
21436 |
|
21437 | function CurrentTime(body, options) {
|
21438 | var _context;
|
21439 |
|
21440 | var _this;
|
21441 |
|
21442 | _classCallCheck(this, CurrentTime);
|
21443 |
|
21444 | _this = _super.call(this);
|
21445 | _this.body = body;
|
21446 |
|
21447 | _this.defaultOptions = {
|
21448 | rtl: false,
|
21449 | showCurrentTime: true,
|
21450 | alignCurrentTime: undefined,
|
21451 | moment: moment$2,
|
21452 | locales: locales,
|
21453 | locale: 'en'
|
21454 | };
|
21455 | _this.options = availableUtils.extend({}, _this.defaultOptions);
|
21456 |
|
21457 | _this.setOptions(options);
|
21458 |
|
21459 | _this.options.locales = availableUtils.extend({}, locales, _this.options.locales);
|
21460 | var defaultLocales = _this.defaultOptions.locales[_this.defaultOptions.locale];
|
21461 |
|
21462 | _forEachInstanceProperty(_context = _Object$keys(_this.options.locales)).call(_context, function (locale) {
|
21463 | _this.options.locales[locale] = availableUtils.extend({}, defaultLocales, _this.options.locales[locale]);
|
21464 | });
|
21465 |
|
21466 | _this.offset = 0;
|
21467 |
|
21468 | _this._create();
|
21469 |
|
21470 | return _this;
|
21471 | }
|
21472 | |
21473 |
|
21474 |
|
21475 |
|
21476 |
|
21477 |
|
21478 | _createClass(CurrentTime, [{
|
21479 | key: "_create",
|
21480 | value: function _create() {
|
21481 | var bar = document.createElement('div');
|
21482 | bar.className = 'vis-current-time';
|
21483 | bar.style.position = 'absolute';
|
21484 | bar.style.top = '0px';
|
21485 | bar.style.height = '100%';
|
21486 | this.bar = bar;
|
21487 | }
|
21488 | |
21489 |
|
21490 |
|
21491 |
|
21492 | }, {
|
21493 | key: "destroy",
|
21494 | value: function destroy() {
|
21495 | this.options.showCurrentTime = false;
|
21496 | this.redraw();
|
21497 |
|
21498 | this.body = null;
|
21499 | }
|
21500 | |
21501 |
|
21502 |
|
21503 |
|
21504 |
|
21505 |
|
21506 |
|
21507 | }, {
|
21508 | key: "setOptions",
|
21509 | value: function setOptions(options) {
|
21510 | if (options) {
|
21511 |
|
21512 | availableUtils.selectiveExtend(['rtl', 'showCurrentTime', 'alignCurrentTime', 'moment', 'locale', 'locales'], this.options, options);
|
21513 | }
|
21514 | }
|
21515 | |
21516 |
|
21517 |
|
21518 |
|
21519 |
|
21520 | }, {
|
21521 | key: "redraw",
|
21522 | value: function redraw() {
|
21523 | if (this.options.showCurrentTime) {
|
21524 | var _context2, _context3;
|
21525 |
|
21526 | var parent = this.body.dom.backgroundVertical;
|
21527 |
|
21528 | if (this.bar.parentNode != parent) {
|
21529 |
|
21530 | if (this.bar.parentNode) {
|
21531 | this.bar.parentNode.removeChild(this.bar);
|
21532 | }
|
21533 |
|
21534 | parent.appendChild(this.bar);
|
21535 | this.start();
|
21536 | }
|
21537 |
|
21538 | var now = this.options.moment(_Date$now() + this.offset);
|
21539 |
|
21540 | if (this.options.alignCurrentTime) {
|
21541 | now = now.startOf(this.options.alignCurrentTime);
|
21542 | }
|
21543 |
|
21544 | var x = this.body.util.toScreen(now);
|
21545 | var locale = this.options.locales[this.options.locale];
|
21546 |
|
21547 | if (!locale) {
|
21548 | if (!this.warned) {
|
21549 | console.warn("WARNING: options.locales['".concat(this.options.locale, "'] not found. See https://visjs.github.io/vis-timeline/docs/timeline/#Localization"));
|
21550 | this.warned = true;
|
21551 | }
|
21552 |
|
21553 | locale = this.options.locales['en'];
|
21554 | }
|
21555 |
|
21556 | var title = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(locale.current, " ")).call(_context3, locale.time, ": ")).call(_context2, now.format('dddd, MMMM Do YYYY, H:mm:ss'));
|
21557 |
|
21558 | title = title.charAt(0).toUpperCase() + title.substring(1);
|
21559 |
|
21560 | if (this.options.rtl) {
|
21561 | this.bar.style.transform = "translateX(".concat(x * -1, "px)");
|
21562 | } else {
|
21563 | this.bar.style.transform = "translateX(".concat(x, "px)");
|
21564 | }
|
21565 |
|
21566 | this.bar.title = title;
|
21567 | } else {
|
21568 |
|
21569 | if (this.bar.parentNode) {
|
21570 | this.bar.parentNode.removeChild(this.bar);
|
21571 | }
|
21572 |
|
21573 | this.stop();
|
21574 | }
|
21575 |
|
21576 | return false;
|
21577 | }
|
21578 | |
21579 |
|
21580 |
|
21581 |
|
21582 | }, {
|
21583 | key: "start",
|
21584 | value: function start() {
|
21585 | var me = this;
|
21586 | |
21587 |
|
21588 |
|
21589 |
|
21590 | function update() {
|
21591 | me.stop();
|
21592 |
|
21593 | var scale = me.body.range.conversion(me.body.domProps.center.width).scale;
|
21594 | var interval = 1 / scale / 10;
|
21595 | if (interval < 30) interval = 30;
|
21596 | if (interval > 1000) interval = 1000;
|
21597 | me.redraw();
|
21598 | me.body.emitter.emit('currentTimeTick');
|
21599 |
|
21600 | me.currentTimeTimer = _setTimeout(update, interval);
|
21601 | }
|
21602 |
|
21603 | update();
|
21604 | }
|
21605 | |
21606 |
|
21607 |
|
21608 |
|
21609 | }, {
|
21610 | key: "stop",
|
21611 | value: function stop() {
|
21612 | if (this.currentTimeTimer !== undefined) {
|
21613 | clearTimeout(this.currentTimeTimer);
|
21614 | delete this.currentTimeTimer;
|
21615 | }
|
21616 | }
|
21617 | |
21618 |
|
21619 |
|
21620 |
|
21621 |
|
21622 |
|
21623 |
|
21624 | }, {
|
21625 | key: "setCurrentTime",
|
21626 | value: function setCurrentTime(time) {
|
21627 | var t = availableUtils.convert(time, 'Date').valueOf();
|
21628 |
|
21629 | var now = _Date$now();
|
21630 |
|
21631 | this.offset = t - now;
|
21632 | this.redraw();
|
21633 | }
|
21634 | |
21635 |
|
21636 |
|
21637 |
|
21638 |
|
21639 | }, {
|
21640 | key: "getCurrentTime",
|
21641 | value: function getCurrentTime() {
|
21642 | return new Date(_Date$now() + this.offset);
|
21643 | }
|
21644 | }]);
|
21645 |
|
21646 | return CurrentTime;
|
21647 | }(Component);
|
21648 |
|
21649 | var find$3 = {exports: {}};
|
21650 |
|
21651 | var $$4 = _export;
|
21652 | var $find = arrayIteration.find;
|
21653 | var FIND = 'find';
|
21654 | var SKIPS_HOLES$1 = true;
|
21655 |
|
21656 | if (FIND in []) Array(1)[FIND](function () {
|
21657 | SKIPS_HOLES$1 = false;
|
21658 | });
|
21659 |
|
21660 |
|
21661 | $$4({
|
21662 | target: 'Array',
|
21663 | proto: true,
|
21664 | forced: SKIPS_HOLES$1
|
21665 | }, {
|
21666 | find: function find(callbackfn
|
21667 | /* , that = undefined */
|
21668 | ) {
|
21669 | return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
21670 | }
|
21671 | });
|
21672 |
|
21673 | var entryVirtual$2 = entryVirtual$k;
|
21674 | var find$2 = entryVirtual$2('Array').find;
|
21675 |
|
21676 | var isPrototypeOf$4 = objectIsPrototypeOf;
|
21677 | var method$2 = find$2;
|
21678 | var ArrayPrototype$2 = Array.prototype;
|
21679 |
|
21680 | var find$1 = function (it) {
|
21681 | var own = it.find;
|
21682 | return it === ArrayPrototype$2 || isPrototypeOf$4(ArrayPrototype$2, it) && own === ArrayPrototype$2.find ? method$2 : own;
|
21683 | };
|
21684 |
|
21685 | var parent$3 = find$1;
|
21686 | var find = parent$3;
|
21687 |
|
21688 | (function (module) {
|
21689 | module.exports = find;
|
21690 | })(find$3);
|
21691 |
|
21692 | var _findInstanceProperty = getDefaultExportFromCjs(find$3.exports);
|
21693 |
|
21694 | var set$2 = {exports: {}};
|
21695 |
|
21696 | var internalMetadata = {exports: {}};
|
21697 |
|
21698 | var fails$3 = fails$s;
|
21699 | var arrayBufferNonExtensible = fails$3(function () {
|
21700 | if (typeof ArrayBuffer == 'function') {
|
21701 | var buffer = new ArrayBuffer(8);
|
21702 |
|
21703 | if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', {
|
21704 | value: 8
|
21705 | });
|
21706 | }
|
21707 | });
|
21708 |
|
21709 | var fails$2 = fails$s;
|
21710 | var isObject$2 = isObject$g;
|
21711 | var classof = classofRaw$1;
|
21712 | var ARRAY_BUFFER_NON_EXTENSIBLE = arrayBufferNonExtensible;
|
21713 |
|
21714 | var $isExtensible = Object.isExtensible;
|
21715 | var FAILS_ON_PRIMITIVES = fails$2(function () {
|
21716 | $isExtensible(1);
|
21717 | });
|
21718 |
|
21719 |
|
21720 | var objectIsExtensible = FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE ? function isExtensible(it) {
|
21721 | if (!isObject$2(it)) return false;
|
21722 | if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
|
21723 | return $isExtensible ? $isExtensible(it) : true;
|
21724 | } : $isExtensible;
|
21725 |
|
21726 | var fails$1 = fails$s;
|
21727 | var freezing = !fails$1(function () {
|
21728 |
|
21729 | return Object.isExtensible(Object.preventExtensions({}));
|
21730 | });
|
21731 |
|
21732 | var $$3 = _export;
|
21733 | var uncurryThis = functionUncurryThis;
|
21734 | var hiddenKeys = hiddenKeys$6;
|
21735 | var isObject$1 = isObject$g;
|
21736 | var hasOwn = hasOwnProperty_1;
|
21737 | var defineProperty$2 = objectDefineProperty.f;
|
21738 | var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
|
21739 | var getOwnPropertyNamesExternalModule = objectGetOwnPropertyNamesExternal;
|
21740 | var isExtensible = objectIsExtensible;
|
21741 | var uid = uid$4;
|
21742 | var FREEZING = freezing;
|
21743 | var REQUIRED = false;
|
21744 | var METADATA = uid('meta');
|
21745 | var id = 0;
|
21746 |
|
21747 | var setMetadata = function (it) {
|
21748 | defineProperty$2(it, METADATA, {
|
21749 | value: {
|
21750 | objectID: 'O' + id++,
|
21751 |
|
21752 | weakData: {}
|
21753 |
|
21754 | }
|
21755 | });
|
21756 | };
|
21757 |
|
21758 | var fastKey$1 = function (it, create) {
|
21759 |
|
21760 | if (!isObject$1(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
21761 |
|
21762 | if (!hasOwn(it, METADATA)) {
|
21763 |
|
21764 | if (!isExtensible(it)) return 'F';
|
21765 |
|
21766 | if (!create) return 'E';
|
21767 |
|
21768 | setMetadata(it);
|
21769 | }
|
21770 |
|
21771 | return it[METADATA].objectID;
|
21772 | };
|
21773 |
|
21774 | var getWeakData = function (it, create) {
|
21775 | if (!hasOwn(it, METADATA)) {
|
21776 |
|
21777 | if (!isExtensible(it)) return true;
|
21778 |
|
21779 | if (!create) return false;
|
21780 |
|
21781 | setMetadata(it);
|
21782 | }
|
21783 |
|
21784 | return it[METADATA].weakData;
|
21785 | };
|
21786 |
|
21787 |
|
21788 | var onFreeze = function (it) {
|
21789 | if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
|
21790 | return it;
|
21791 | };
|
21792 |
|
21793 | var enable = function () {
|
21794 | meta.enable = function () {
|
21795 |
|
21796 | };
|
21797 |
|
21798 | REQUIRED = true;
|
21799 | var getOwnPropertyNames = getOwnPropertyNamesModule.f;
|
21800 | var splice = uncurryThis([].splice);
|
21801 | var test = {};
|
21802 | test[METADATA] = 1;
|
21803 |
|
21804 | if (getOwnPropertyNames(test).length) {
|
21805 | getOwnPropertyNamesModule.f = function (it) {
|
21806 | var result = getOwnPropertyNames(it);
|
21807 |
|
21808 | for (var i = 0, length = result.length; i < length; i++) {
|
21809 | if (result[i] === METADATA) {
|
21810 | splice(result, i, 1);
|
21811 | break;
|
21812 | }
|
21813 | }
|
21814 |
|
21815 | return result;
|
21816 | };
|
21817 |
|
21818 | $$3({
|
21819 | target: 'Object',
|
21820 | stat: true,
|
21821 | forced: true
|
21822 | }, {
|
21823 | getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
|
21824 | });
|
21825 | }
|
21826 | };
|
21827 |
|
21828 | var meta = internalMetadata.exports = {
|
21829 | enable: enable,
|
21830 | fastKey: fastKey$1,
|
21831 | getWeakData: getWeakData,
|
21832 | onFreeze: onFreeze
|
21833 | };
|
21834 | hiddenKeys[METADATA] = true;
|
21835 |
|
21836 | var global$3 = global$N;
|
21837 | var bind$1 = functionBindContext;
|
21838 | var call = functionCall;
|
21839 | var anObject = anObject$b;
|
21840 | var tryToString = tryToString$4;
|
21841 | var isArrayIteratorMethod = isArrayIteratorMethod$2;
|
21842 | var lengthOfArrayLike = lengthOfArrayLike$b;
|
21843 | var isPrototypeOf$3 = objectIsPrototypeOf;
|
21844 | var getIterator = getIterator$2;
|
21845 | var getIteratorMethod = getIteratorMethod$8;
|
21846 | var iteratorClose = iteratorClose$2;
|
21847 | var TypeError$2 = global$3.TypeError;
|
21848 |
|
21849 | var Result = function (stopped, result) {
|
21850 | this.stopped = stopped;
|
21851 | this.result = result;
|
21852 | };
|
21853 |
|
21854 | var ResultPrototype = Result.prototype;
|
21855 |
|
21856 | var iterate$2 = function (iterable, unboundFunction, options) {
|
21857 | var that = options && options.that;
|
21858 | var AS_ENTRIES = !!(options && options.AS_ENTRIES);
|
21859 | var IS_ITERATOR = !!(options && options.IS_ITERATOR);
|
21860 | var INTERRUPTED = !!(options && options.INTERRUPTED);
|
21861 | var fn = bind$1(unboundFunction, that);
|
21862 | var iterator, iterFn, index, length, result, next, step;
|
21863 |
|
21864 | var stop = function (condition) {
|
21865 | if (iterator) iteratorClose(iterator, 'normal', condition);
|
21866 | return new Result(true, condition);
|
21867 | };
|
21868 |
|
21869 | var callFn = function (value) {
|
21870 | if (AS_ENTRIES) {
|
21871 | anObject(value);
|
21872 | return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
|
21873 | }
|
21874 |
|
21875 | return INTERRUPTED ? fn(value, stop) : fn(value);
|
21876 | };
|
21877 |
|
21878 | if (IS_ITERATOR) {
|
21879 | iterator = iterable;
|
21880 | } else {
|
21881 | iterFn = getIteratorMethod(iterable);
|
21882 | if (!iterFn) throw TypeError$2(tryToString(iterable) + ' is not iterable');
|
21883 |
|
21884 | if (isArrayIteratorMethod(iterFn)) {
|
21885 | for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
|
21886 | result = callFn(iterable[index]);
|
21887 | if (result && isPrototypeOf$3(ResultPrototype, result)) return result;
|
21888 | }
|
21889 |
|
21890 | return new Result(false);
|
21891 | }
|
21892 |
|
21893 | iterator = getIterator(iterable, iterFn);
|
21894 | }
|
21895 |
|
21896 | next = iterator.next;
|
21897 |
|
21898 | while (!(step = call(next, iterator)).done) {
|
21899 | try {
|
21900 | result = callFn(step.value);
|
21901 | } catch (error) {
|
21902 | iteratorClose(iterator, 'throw', error);
|
21903 | }
|
21904 |
|
21905 | if (typeof result == 'object' && result && isPrototypeOf$3(ResultPrototype, result)) return result;
|
21906 | }
|
21907 |
|
21908 | return new Result(false);
|
21909 | };
|
21910 |
|
21911 | var global$2 = global$N;
|
21912 | var isPrototypeOf$2 = objectIsPrototypeOf;
|
21913 | var TypeError$1 = global$2.TypeError;
|
21914 |
|
21915 | var anInstance$2 = function (it, Prototype) {
|
21916 | if (isPrototypeOf$2(Prototype, it)) return it;
|
21917 | throw TypeError$1('Incorrect invocation');
|
21918 | };
|
21919 |
|
21920 | var $$2 = _export;
|
21921 | var global$1 = global$N;
|
21922 | var InternalMetadataModule = internalMetadata.exports;
|
21923 | var fails = fails$s;
|
21924 | var createNonEnumerableProperty = createNonEnumerableProperty$6;
|
21925 | var iterate$1 = iterate$2;
|
21926 | var anInstance$1 = anInstance$2;
|
21927 | var isCallable = isCallable$h;
|
21928 | var isObject = isObject$g;
|
21929 | var setToStringTag = setToStringTag$5;
|
21930 | var defineProperty$1 = objectDefineProperty.f;
|
21931 | var forEach = arrayIteration.forEach;
|
21932 | var DESCRIPTORS$2 = descriptors;
|
21933 | var InternalStateModule$1 = internalState;
|
21934 | var setInternalState$1 = InternalStateModule$1.set;
|
21935 | var internalStateGetterFor$1 = InternalStateModule$1.getterFor;
|
21936 |
|
21937 | var collection$1 = function (CONSTRUCTOR_NAME, wrapper, common) {
|
21938 | var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
|
21939 | var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
|
21940 | var ADDER = IS_MAP ? 'set' : 'add';
|
21941 | var NativeConstructor = global$1[CONSTRUCTOR_NAME];
|
21942 | var NativePrototype = NativeConstructor && NativeConstructor.prototype;
|
21943 | var exported = {};
|
21944 | var Constructor;
|
21945 |
|
21946 | if (!DESCRIPTORS$2 || !isCallable(NativeConstructor) || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
|
21947 | new NativeConstructor().entries().next();
|
21948 | }))) {
|
21949 |
|
21950 | Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
|
21951 | InternalMetadataModule.enable();
|
21952 | } else {
|
21953 | Constructor = wrapper(function (target, iterable) {
|
21954 | setInternalState$1(anInstance$1(target, Prototype), {
|
21955 | type: CONSTRUCTOR_NAME,
|
21956 | collection: new NativeConstructor()
|
21957 | });
|
21958 | if (iterable != undefined) iterate$1(iterable, target[ADDER], {
|
21959 | that: target,
|
21960 | AS_ENTRIES: IS_MAP
|
21961 | });
|
21962 | });
|
21963 | var Prototype = Constructor.prototype;
|
21964 | var getInternalState = internalStateGetterFor$1(CONSTRUCTOR_NAME);
|
21965 | forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
|
21966 | var IS_ADDER = KEY == 'add' || KEY == 'set';
|
21967 |
|
21968 | if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
|
21969 | createNonEnumerableProperty(Prototype, KEY, function (a, b) {
|
21970 | var collection = getInternalState(this).collection;
|
21971 | if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
|
21972 | var result = collection[KEY](a === 0 ? 0 : a, b);
|
21973 | return IS_ADDER ? this : result;
|
21974 | });
|
21975 | }
|
21976 | });
|
21977 | IS_WEAK || defineProperty$1(Prototype, 'size', {
|
21978 | configurable: true,
|
21979 | get: function () {
|
21980 | return getInternalState(this).collection.size;
|
21981 | }
|
21982 | });
|
21983 | }
|
21984 |
|
21985 | setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
|
21986 | exported[CONSTRUCTOR_NAME] = Constructor;
|
21987 | $$2({
|
21988 | global: true,
|
21989 | forced: true
|
21990 | }, exported);
|
21991 | if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
|
21992 | return Constructor;
|
21993 | };
|
21994 |
|
21995 | var redefine = redefine$4;
|
21996 |
|
21997 | var redefineAll$1 = function (target, src, options) {
|
21998 | for (var key in src) {
|
21999 | if (options && options.unsafe && target[key]) target[key] = src[key];else redefine(target, key, src[key], options);
|
22000 | }
|
22001 |
|
22002 | return target;
|
22003 | };
|
22004 |
|
22005 | var getBuiltIn = getBuiltIn$9;
|
22006 | var definePropertyModule = objectDefineProperty;
|
22007 | var wellKnownSymbol = wellKnownSymbol$j;
|
22008 | var DESCRIPTORS$1 = descriptors;
|
22009 | var SPECIES = wellKnownSymbol('species');
|
22010 |
|
22011 | var setSpecies$1 = function (CONSTRUCTOR_NAME) {
|
22012 | var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
|
22013 | var defineProperty = definePropertyModule.f;
|
22014 |
|
22015 | if (DESCRIPTORS$1 && Constructor && !Constructor[SPECIES]) {
|
22016 | defineProperty(Constructor, SPECIES, {
|
22017 | configurable: true,
|
22018 | get: function () {
|
22019 | return this;
|
22020 | }
|
22021 | });
|
22022 | }
|
22023 | };
|
22024 |
|
22025 | var defineProperty = objectDefineProperty.f;
|
22026 | var create = objectCreate;
|
22027 | var redefineAll = redefineAll$1;
|
22028 | var bind = functionBindContext;
|
22029 | var anInstance = anInstance$2;
|
22030 | var iterate = iterate$2;
|
22031 | var defineIterator = defineIterator$3;
|
22032 | var setSpecies = setSpecies$1;
|
22033 | var DESCRIPTORS = descriptors;
|
22034 | var fastKey = internalMetadata.exports.fastKey;
|
22035 | var InternalStateModule = internalState;
|
22036 | var setInternalState = InternalStateModule.set;
|
22037 | var internalStateGetterFor = InternalStateModule.getterFor;
|
22038 | var collectionStrong$1 = {
|
22039 | getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
|
22040 | var Constructor = wrapper(function (that, iterable) {
|
22041 | anInstance(that, Prototype);
|
22042 | setInternalState(that, {
|
22043 | type: CONSTRUCTOR_NAME,
|
22044 | index: create(null),
|
22045 | first: undefined,
|
22046 | last: undefined,
|
22047 | size: 0
|
22048 | });
|
22049 | if (!DESCRIPTORS) that.size = 0;
|
22050 | if (iterable != undefined) iterate(iterable, that[ADDER], {
|
22051 | that: that,
|
22052 | AS_ENTRIES: IS_MAP
|
22053 | });
|
22054 | });
|
22055 | var Prototype = Constructor.prototype;
|
22056 | var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
|
22057 |
|
22058 | var define = function (that, key, value) {
|
22059 | var state = getInternalState(that);
|
22060 | var entry = getEntry(that, key);
|
22061 | var previous, index;
|
22062 |
|
22063 | if (entry) {
|
22064 | entry.value = value;
|
22065 | } else {
|
22066 | state.last = entry = {
|
22067 | index: index = fastKey(key, true),
|
22068 | key: key,
|
22069 | value: value,
|
22070 | previous: previous = state.last,
|
22071 | next: undefined,
|
22072 | removed: false
|
22073 | };
|
22074 | if (!state.first) state.first = entry;
|
22075 | if (previous) previous.next = entry;
|
22076 | if (DESCRIPTORS) state.size++;else that.size++;
|
22077 |
|
22078 | if (index !== 'F') state.index[index] = entry;
|
22079 | }
|
22080 |
|
22081 | return that;
|
22082 | };
|
22083 |
|
22084 | var getEntry = function (that, key) {
|
22085 | var state = getInternalState(that);
|
22086 |
|
22087 | var index = fastKey(key);
|
22088 | var entry;
|
22089 | if (index !== 'F') return state.index[index];
|
22090 |
|
22091 | for (entry = state.first; entry; entry = entry.next) {
|
22092 | if (entry.key == key) return entry;
|
22093 | }
|
22094 | };
|
22095 |
|
22096 | redefineAll(Prototype, {
|
22097 |
|
22098 |
|
22099 |
|
22100 | clear: function clear() {
|
22101 | var that = this;
|
22102 | var state = getInternalState(that);
|
22103 | var data = state.index;
|
22104 | var entry = state.first;
|
22105 |
|
22106 | while (entry) {
|
22107 | entry.removed = true;
|
22108 | if (entry.previous) entry.previous = entry.previous.next = undefined;
|
22109 | delete data[entry.index];
|
22110 | entry = entry.next;
|
22111 | }
|
22112 |
|
22113 | state.first = state.last = undefined;
|
22114 | if (DESCRIPTORS) state.size = 0;else that.size = 0;
|
22115 | },
|
22116 |
|
22117 |
|
22118 |
|
22119 | 'delete': function (key) {
|
22120 | var that = this;
|
22121 | var state = getInternalState(that);
|
22122 | var entry = getEntry(that, key);
|
22123 |
|
22124 | if (entry) {
|
22125 | var next = entry.next;
|
22126 | var prev = entry.previous;
|
22127 | delete state.index[entry.index];
|
22128 | entry.removed = true;
|
22129 | if (prev) prev.next = next;
|
22130 | if (next) next.previous = prev;
|
22131 | if (state.first == entry) state.first = next;
|
22132 | if (state.last == entry) state.last = prev;
|
22133 | if (DESCRIPTORS) state.size--;else that.size--;
|
22134 | }
|
22135 |
|
22136 | return !!entry;
|
22137 | },
|
22138 |
|
22139 |
|
22140 |
|
22141 | forEach: function forEach(callbackfn
|
22142 | /* , that = undefined */
|
22143 | ) {
|
22144 | var state = getInternalState(this);
|
22145 | var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
22146 | var entry;
|
22147 |
|
22148 | while (entry = entry ? entry.next : state.first) {
|
22149 | boundFunction(entry.value, entry.key, this);
|
22150 |
|
22151 | while (entry && entry.removed) entry = entry.previous;
|
22152 | }
|
22153 | },
|
22154 |
|
22155 |
|
22156 |
|
22157 | has: function has(key) {
|
22158 | return !!getEntry(this, key);
|
22159 | }
|
22160 | });
|
22161 | redefineAll(Prototype, IS_MAP ? {
|
22162 |
|
22163 |
|
22164 | get: function get(key) {
|
22165 | var entry = getEntry(this, key);
|
22166 | return entry && entry.value;
|
22167 | },
|
22168 |
|
22169 |
|
22170 | set: function set(key, value) {
|
22171 | return define(this, key === 0 ? 0 : key, value);
|
22172 | }
|
22173 | } : {
|
22174 |
|
22175 |
|
22176 | add: function add(value) {
|
22177 | return define(this, value = value === 0 ? 0 : value, value);
|
22178 | }
|
22179 | });
|
22180 | if (DESCRIPTORS) defineProperty(Prototype, 'size', {
|
22181 | get: function () {
|
22182 | return getInternalState(this).size;
|
22183 | }
|
22184 | });
|
22185 | return Constructor;
|
22186 | },
|
22187 | setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
|
22188 | var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
|
22189 | var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
|
22190 | var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
|
22191 |
|
22192 |
|
22193 |
|
22194 |
|
22195 |
|
22196 |
|
22197 |
|
22198 |
|
22199 |
|
22200 | defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
|
22201 | setInternalState(this, {
|
22202 | type: ITERATOR_NAME,
|
22203 | target: iterated,
|
22204 | state: getInternalCollectionState(iterated),
|
22205 | kind: kind,
|
22206 | last: undefined
|
22207 | });
|
22208 | }, function () {
|
22209 | var state = getInternalIteratorState(this);
|
22210 | var kind = state.kind;
|
22211 | var entry = state.last;
|
22212 |
|
22213 | while (entry && entry.removed) entry = entry.previous;
|
22214 |
|
22215 |
|
22216 | if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
|
22217 |
|
22218 | state.target = undefined;
|
22219 | return {
|
22220 | value: undefined,
|
22221 | done: true
|
22222 | };
|
22223 | }
|
22224 |
|
22225 |
|
22226 | if (kind == 'keys') return {
|
22227 | value: entry.key,
|
22228 | done: false
|
22229 | };
|
22230 | if (kind == 'values') return {
|
22231 | value: entry.value,
|
22232 | done: false
|
22233 | };
|
22234 | return {
|
22235 | value: [entry.key, entry.value],
|
22236 | done: false
|
22237 | };
|
22238 | }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
|
22239 |
|
22240 |
|
22241 |
|
22242 | setSpecies(CONSTRUCTOR_NAME);
|
22243 | }
|
22244 | };
|
22245 |
|
22246 | var collection = collection$1;
|
22247 | var collectionStrong = collectionStrong$1;
|
22248 |
|
22249 |
|
22250 | collection('Set', function (init) {
|
22251 | return function Set() {
|
22252 | return init(this, arguments.length ? arguments[0] : undefined);
|
22253 | };
|
22254 | }, collectionStrong);
|
22255 |
|
22256 | var path = path$r;
|
22257 | var set$1 = path.Set;
|
22258 |
|
22259 | var parent$2 = set$1;
|
22260 | var set = parent$2;
|
22261 |
|
22262 | (function (module) {
|
22263 | module.exports = set;
|
22264 | })(set$2);
|
22265 |
|
22266 | var _Set = /*@__PURE__*/getDefaultExportFromCjs(set$2.exports);
|
22267 |
|
22268 | var findIndex$3 = {exports: {}};
|
22269 |
|
22270 | var $$1 = _export;
|
22271 | var $findIndex = arrayIteration.findIndex;
|
22272 | var FIND_INDEX = 'findIndex';
|
22273 | var SKIPS_HOLES = true;
|
22274 |
|
22275 | if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () {
|
22276 | SKIPS_HOLES = false;
|
22277 | });
|
22278 |
|
22279 |
|
22280 | $$1({
|
22281 | target: 'Array',
|
22282 | proto: true,
|
22283 | forced: SKIPS_HOLES
|
22284 | }, {
|
22285 | findIndex: function findIndex(callbackfn
|
22286 | /* , that = undefined */
|
22287 | ) {
|
22288 | return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
22289 | }
|
22290 | });
|
22291 |
|
22292 | var entryVirtual$1 = entryVirtual$k;
|
22293 | var findIndex$2 = entryVirtual$1('Array').findIndex;
|
22294 |
|
22295 | var isPrototypeOf$1 = objectIsPrototypeOf;
|
22296 | var method$1 = findIndex$2;
|
22297 | var ArrayPrototype$1 = Array.prototype;
|
22298 |
|
22299 | var findIndex$1 = function (it) {
|
22300 | var own = it.findIndex;
|
22301 | return it === ArrayPrototype$1 || isPrototypeOf$1(ArrayPrototype$1, it) && own === ArrayPrototype$1.findIndex ? method$1 : own;
|
22302 | };
|
22303 |
|
22304 | var parent$1 = findIndex$1;
|
22305 | var findIndex = parent$1;
|
22306 |
|
22307 | (function (module) {
|
22308 | module.exports = findIndex;
|
22309 | })(findIndex$3);
|
22310 |
|
22311 | var _findIndexInstanceProperty = getDefaultExportFromCjs(findIndex$3.exports);
|
22312 |
|
22313 | function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
22314 |
|
22315 | function _unsupportedIterableToArray$5(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = _sliceInstanceProperty(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
|
22316 |
|
22317 | function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
22318 |
|
22319 | var EPSILON = 0.001;
|
22320 |
|
22321 |
|
22322 |
|
22323 |
|
22324 |
|
22325 |
|
22326 | function orderByStart(items) {
|
22327 | _sortInstanceProperty(items).call(items, function (a, b) {
|
22328 | return a.data.start - b.data.start;
|
22329 | });
|
22330 | }
|
22331 |
|
22332 |
|
22333 |
|
22334 |
|
22335 |
|
22336 |
|
22337 | function orderByEnd(items) {
|
22338 | _sortInstanceProperty(items).call(items, function (a, b) {
|
22339 | var aTime = 'end' in a.data ? a.data.end : a.data.start;
|
22340 | var bTime = 'end' in b.data ? b.data.end : b.data.start;
|
22341 | return aTime - bTime;
|
22342 | });
|
22343 | }
|
22344 |
|
22345 |
|
22346 |
|
22347 |
|
22348 |
|
22349 |
|
22350 |
|
22351 |
|
22352 |
|
22353 |
|
22354 |
|
22355 |
|
22356 |
|
22357 |
|
22358 |
|
22359 | function stack(items, margin, force, shouldBailItemsRedrawFunction) {
|
22360 | var stackingResult = performStacking(items, margin.item, false, function (item) {
|
22361 | return item.stack && (force || item.top === null);
|
22362 | }, function (item) {
|
22363 | return item.stack;
|
22364 | }, function (item) {
|
22365 | return margin.axis;
|
22366 | }, shouldBailItemsRedrawFunction);
|
22367 |
|
22368 | return stackingResult === null;
|
22369 | }
|
22370 |
|
22371 |
|
22372 |
|
22373 |
|
22374 |
|
22375 |
|
22376 |
|
22377 |
|
22378 |
|
22379 |
|
22380 |
|
22381 | function substack(items, margin, subgroup) {
|
22382 | var subgroupHeight = performStacking(items, margin.item, false, function (item) {
|
22383 | return item.stack;
|
22384 | }, function (item) {
|
22385 | return true;
|
22386 | }, function (item) {
|
22387 | return item.baseTop;
|
22388 | });
|
22389 | subgroup.height = subgroupHeight - subgroup.top + 0.5 * margin.item.vertical;
|
22390 | }
|
22391 |
|
22392 |
|
22393 |
|
22394 |
|
22395 |
|
22396 |
|
22397 |
|
22398 |
|
22399 |
|
22400 |
|
22401 |
|
22402 | function nostack(items, margin, subgroups, isStackSubgroups) {
|
22403 | for (var _i = 0; _i < items.length; _i++) {
|
22404 | if (items[_i].data.subgroup == undefined) {
|
22405 | items[_i].top = margin.item.vertical;
|
22406 | } else if (items[_i].data.subgroup !== undefined && isStackSubgroups) {
|
22407 | var newTop = 0;
|
22408 |
|
22409 | for (var subgroup in subgroups) {
|
22410 | if (subgroups.hasOwnProperty(subgroup)) {
|
22411 | if (subgroups[subgroup].visible == true && subgroups[subgroup].index < subgroups[items[_i].data.subgroup].index) {
|
22412 | newTop += subgroups[subgroup].height;
|
22413 | subgroups[items[_i].data.subgroup].top = newTop;
|
22414 | }
|
22415 | }
|
22416 | }
|
22417 |
|
22418 | items[_i].top = newTop + 0.5 * margin.item.vertical;
|
22419 | }
|
22420 | }
|
22421 |
|
22422 | if (!isStackSubgroups) {
|
22423 | stackSubgroups(items, margin, subgroups);
|
22424 | }
|
22425 | }
|
22426 |
|
22427 |
|
22428 |
|
22429 |
|
22430 |
|
22431 |
|
22432 |
|
22433 |
|
22434 |
|
22435 | function stackSubgroups(items, margin, subgroups) {
|
22436 | var _context;
|
22437 |
|
22438 | performStacking(_sortInstanceProperty(_context = _Object$values2(subgroups)).call(_context, function (a, b) {
|
22439 | if (a.index > b.index) return 1;
|
22440 | if (a.index < b.index) return -1;
|
22441 | return 0;
|
22442 | }), {
|
22443 | vertical: 0
|
22444 | }, true, function (item) {
|
22445 | return true;
|
22446 | }, function (item) {
|
22447 | return true;
|
22448 | }, function (item) {
|
22449 | return 0;
|
22450 | });
|
22451 |
|
22452 | for (var _i2 = 0; _i2 < items.length; _i2++) {
|
22453 | if (items[_i2].data.subgroup !== undefined) {
|
22454 | items[_i2].top = subgroups[items[_i2].data.subgroup].top + 0.5 * margin.item.vertical;
|
22455 | }
|
22456 | }
|
22457 | }
|
22458 |
|
22459 |
|
22460 |
|
22461 |
|
22462 |
|
22463 |
|
22464 |
|
22465 |
|
22466 |
|
22467 |
|
22468 |
|
22469 | function stackSubgroupsWithInnerStack(subgroupItems, margin, subgroups) {
|
22470 | var doSubStack = false;
|
22471 |
|
22472 | var subgroupOrder = [];
|
22473 |
|
22474 | for (var subgroup in subgroups) {
|
22475 | if (subgroups[subgroup].hasOwnProperty("index")) {
|
22476 | subgroupOrder[subgroups[subgroup].index] = subgroup;
|
22477 | } else {
|
22478 | subgroupOrder.push(subgroup);
|
22479 | }
|
22480 | }
|
22481 |
|
22482 | for (var j = 0; j < subgroupOrder.length; j++) {
|
22483 | subgroup = subgroupOrder[j];
|
22484 |
|
22485 | if (subgroups.hasOwnProperty(subgroup)) {
|
22486 | doSubStack = doSubStack || subgroups[subgroup].stack;
|
22487 | subgroups[subgroup].top = 0;
|
22488 |
|
22489 | for (var otherSubgroup in subgroups) {
|
22490 | if (subgroups[otherSubgroup].visible && subgroups[subgroup].index > subgroups[otherSubgroup].index) {
|
22491 | subgroups[subgroup].top += subgroups[otherSubgroup].height;
|
22492 | }
|
22493 | }
|
22494 |
|
22495 | var items = subgroupItems[subgroup];
|
22496 |
|
22497 | for (var _i3 = 0; _i3 < items.length; _i3++) {
|
22498 | if (items[_i3].data.subgroup !== undefined) {
|
22499 | items[_i3].top = subgroups[items[_i3].data.subgroup].top + 0.5 * margin.item.vertical;
|
22500 |
|
22501 | if (subgroups[subgroup].stack) {
|
22502 | items[_i3].baseTop = items[_i3].top;
|
22503 | }
|
22504 | }
|
22505 | }
|
22506 |
|
22507 | if (doSubStack && subgroups[subgroup].stack) {
|
22508 | substack(subgroupItems[subgroup], margin, subgroups[subgroup]);
|
22509 | }
|
22510 | }
|
22511 | }
|
22512 | }
|
22513 |
|
22514 |
|
22515 |
|
22516 |
|
22517 |
|
22518 |
|
22519 |
|
22520 |
|
22521 |
|
22522 |
|
22523 |
|
22524 |
|
22525 |
|
22526 |
|
22527 |
|
22528 |
|
22529 |
|
22530 |
|
22531 |
|
22532 |
|
22533 |
|
22534 |
|
22535 |
|
22536 |
|
22537 |
|
22538 | function performStacking(items, margins, compareTimes, shouldStack, shouldOthersStack, getInitialHeight, shouldBail) {
|
22539 |
|
22540 | var getItemStart = function getItemStart(item) {
|
22541 | return item.start;
|
22542 | };
|
22543 |
|
22544 | var getItemEnd = function getItemEnd(item) {
|
22545 | return item.end;
|
22546 | };
|
22547 |
|
22548 | if (!compareTimes) {
|
22549 |
|
22550 | var rtl = !!(items[0] && items[0].options.rtl);
|
22551 |
|
22552 | if (rtl) {
|
22553 | getItemStart = function getItemStart(item) {
|
22554 | return item.right;
|
22555 | };
|
22556 | } else {
|
22557 | getItemStart = function getItemStart(item) {
|
22558 | return item.left;
|
22559 | };
|
22560 | }
|
22561 |
|
22562 | getItemEnd = function getItemEnd(item) {
|
22563 | return getItemStart(item) + item.width + margins.horizontal;
|
22564 | };
|
22565 | }
|
22566 |
|
22567 | var itemsToPosition = [];
|
22568 | var itemsAlreadyPositioned = [];
|
22569 |
|
22570 |
|
22571 |
|
22572 |
|
22573 |
|
22574 | var previousStart = null;
|
22575 | var insertionIndex = 0;
|
22576 |
|
22577 | var _iterator = _createForOfIteratorHelper$5(items),
|
22578 | _step;
|
22579 |
|
22580 | try {
|
22581 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
22582 | var item = _step.value;
|
22583 |
|
22584 | if (shouldStack(item)) {
|
22585 | itemsToPosition.push(item);
|
22586 | } else {
|
22587 | if (shouldOthersStack(item)) {
|
22588 | (function () {
|
22589 | var itemStart = getItemStart(item);
|
22590 |
|
22591 |
|
22592 |
|
22593 |
|
22594 |
|
22595 |
|
22596 |
|
22597 |
|
22598 |
|
22599 |
|
22600 | if (previousStart !== null && itemStart < previousStart - EPSILON) {
|
22601 | insertionIndex = 0;
|
22602 | }
|
22603 |
|
22604 | previousStart = itemStart;
|
22605 | insertionIndex = findIndexFrom(itemsAlreadyPositioned, function (i) {
|
22606 | return getItemStart(i) - EPSILON > itemStart;
|
22607 | }, insertionIndex);
|
22608 |
|
22609 | _spliceInstanceProperty(itemsAlreadyPositioned).call(itemsAlreadyPositioned, insertionIndex, 0, item);
|
22610 |
|
22611 | insertionIndex++;
|
22612 | })();
|
22613 | }
|
22614 | }
|
22615 | }
|
22616 |
|
22617 | } catch (err) {
|
22618 | _iterator.e(err);
|
22619 | } finally {
|
22620 | _iterator.f();
|
22621 | }
|
22622 |
|
22623 | previousStart = null;
|
22624 | var previousEnd = null;
|
22625 | insertionIndex = 0;
|
22626 | var horizontalOverlapStartIndex = 0;
|
22627 | var horizontalOverlapEndIndex = 0;
|
22628 | var maxHeight = 0;
|
22629 |
|
22630 | var _loop = function _loop() {
|
22631 | var _context2, _context3;
|
22632 |
|
22633 | var item = itemsToPosition.shift();
|
22634 | item.top = getInitialHeight(item);
|
22635 | var itemStart = getItemStart(item);
|
22636 | var itemEnd = getItemEnd(item);
|
22637 |
|
22638 | if (previousStart !== null && itemStart < previousStart - EPSILON) {
|
22639 | horizontalOverlapStartIndex = 0;
|
22640 | horizontalOverlapEndIndex = 0;
|
22641 | insertionIndex = 0;
|
22642 | previousEnd = null;
|
22643 | }
|
22644 |
|
22645 | previousStart = itemStart;
|
22646 |
|
22647 | horizontalOverlapStartIndex = findIndexFrom(itemsAlreadyPositioned, function (i) {
|
22648 | return itemStart < getItemEnd(i) - EPSILON;
|
22649 | }, horizontalOverlapStartIndex);
|
22650 |
|
22651 | if (previousEnd === null || previousEnd < itemEnd - EPSILON) {
|
22652 | horizontalOverlapEndIndex = findIndexFrom(itemsAlreadyPositioned, function (i) {
|
22653 | return itemEnd < getItemStart(i) - EPSILON;
|
22654 | }, Math.max(horizontalOverlapStartIndex, horizontalOverlapEndIndex));
|
22655 | }
|
22656 |
|
22657 | if (previousEnd !== null && previousEnd - EPSILON > itemEnd) {
|
22658 | horizontalOverlapEndIndex = findLastIndexBetween(itemsAlreadyPositioned, function (i) {
|
22659 | return itemEnd + EPSILON >= getItemStart(i);
|
22660 | }, horizontalOverlapStartIndex, horizontalOVerlapEndIndex) + 1;
|
22661 | }
|
22662 |
|
22663 |
|
22664 | var horizontallyCollidingItems = _sortInstanceProperty(_context2 = _filterInstanceProperty(_context3 = _sliceInstanceProperty(itemsAlreadyPositioned).call(itemsAlreadyPositioned, horizontalOverlapStartIndex, horizontalOverlapEndIndex)).call(_context3, function (i) {
|
22665 | return itemStart < getItemEnd(i) - EPSILON && itemEnd - EPSILON > getItemStart(i);
|
22666 | })).call(_context2, function (a, b) {
|
22667 | return a.top - b.top;
|
22668 | });
|
22669 |
|
22670 |
|
22671 | for (var i2 = 0; i2 < horizontallyCollidingItems.length; i2++) {
|
22672 | var otherItem = horizontallyCollidingItems[i2];
|
22673 |
|
22674 | if (checkVerticalSpatialCollision(item, otherItem, margins)) {
|
22675 | item.top = otherItem.top + otherItem.height + margins.vertical;
|
22676 | }
|
22677 | }
|
22678 |
|
22679 | if (shouldOthersStack(item)) {
|
22680 |
|
22681 |
|
22682 |
|
22683 | insertionIndex = findIndexFrom(itemsAlreadyPositioned, function (i) {
|
22684 | return getItemStart(i) - EPSILON > itemStart;
|
22685 | }, insertionIndex);
|
22686 |
|
22687 | _spliceInstanceProperty(itemsAlreadyPositioned).call(itemsAlreadyPositioned, insertionIndex, 0, item);
|
22688 |
|
22689 | insertionIndex++;
|
22690 | }
|
22691 |
|
22692 |
|
22693 | var currentHeight = item.top + item.height;
|
22694 |
|
22695 | if (currentHeight > maxHeight) {
|
22696 | maxHeight = currentHeight;
|
22697 | }
|
22698 |
|
22699 | if (shouldBail && shouldBail()) {
|
22700 | return {
|
22701 | v: null
|
22702 | };
|
22703 | }
|
22704 | };
|
22705 |
|
22706 | while (itemsToPosition.length > 0) {
|
22707 | var _ret = _loop();
|
22708 |
|
22709 | if (_typeof(_ret) === "object") return _ret.v;
|
22710 | }
|
22711 |
|
22712 | return maxHeight;
|
22713 | }
|
22714 |
|
22715 |
|
22716 |
|
22717 |
|
22718 |
|
22719 |
|
22720 |
|
22721 |
|
22722 |
|
22723 |
|
22724 |
|
22725 |
|
22726 | function checkVerticalSpatialCollision(a, b, margin) {
|
22727 | return a.top - margin.vertical + EPSILON < b.top + b.height && a.top + a.height + margin.vertical - EPSILON > b.top;
|
22728 | }
|
22729 |
|
22730 |
|
22731 |
|
22732 |
|
22733 |
|
22734 |
|
22735 |
|
22736 |
|
22737 |
|
22738 |
|
22739 |
|
22740 |
|
22741 | function findIndexFrom(arr, predicate, startIndex) {
|
22742 | var _context4;
|
22743 |
|
22744 | if (!startIndex) {
|
22745 | startIndex = 0;
|
22746 | }
|
22747 |
|
22748 | var matchIndex = _findIndexInstanceProperty(_context4 = _sliceInstanceProperty(arr).call(arr, startIndex)).call(_context4, predicate);
|
22749 |
|
22750 | if (matchIndex === -1) {
|
22751 | return arr.length;
|
22752 | }
|
22753 |
|
22754 | return matchIndex + startIndex;
|
22755 | }
|
22756 |
|
22757 |
|
22758 |
|
22759 |
|
22760 |
|
22761 |
|
22762 |
|
22763 |
|
22764 |
|
22765 |
|
22766 |
|
22767 |
|
22768 |
|
22769 | function findLastIndexBetween(arr, predicate, startIndex, endIndex) {
|
22770 | if (!startIndex) {
|
22771 | startIndex = 0;
|
22772 | }
|
22773 |
|
22774 | if (!endIndex) {
|
22775 | endIndex = arr.length;
|
22776 | }
|
22777 |
|
22778 | for (i = endIndex - 1; i >= startIndex; i--) {
|
22779 | if (predicate(arr[i])) {
|
22780 | return i;
|
22781 | }
|
22782 | }
|
22783 |
|
22784 | return startIndex - 1;
|
22785 | }
|
22786 |
|
22787 | var stack$1 = Object.freeze({
|
22788 | __proto__: null,
|
22789 | orderByStart: orderByStart,
|
22790 | orderByEnd: orderByEnd,
|
22791 | stack: stack,
|
22792 | substack: substack,
|
22793 | nostack: nostack,
|
22794 | stackSubgroups: stackSubgroups,
|
22795 | stackSubgroupsWithInnerStack: stackSubgroupsWithInnerStack
|
22796 | });
|
22797 |
|
22798 | var UNGROUPED$3 = '__ungrouped__';
|
22799 |
|
22800 | var BACKGROUND$2 = '__background__';
|
22801 |
|
22802 | var ReservedGroupIds$1 = {
|
22803 | UNGROUPED: UNGROUPED$3,
|
22804 | BACKGROUND: BACKGROUND$2
|
22805 | };
|
22806 |
|
22807 |
|
22808 |
|
22809 |
|
22810 | var Group = function () {
|
22811 | |
22812 |
|
22813 |
|
22814 |
|
22815 |
|
22816 |
|
22817 | function Group(groupId, data, itemSet) {
|
22818 | var _this = this;
|
22819 |
|
22820 | _classCallCheck(this, Group);
|
22821 |
|
22822 | this.groupId = groupId;
|
22823 | this.subgroups = {};
|
22824 | this.subgroupStack = {};
|
22825 | this.subgroupStackAll = false;
|
22826 | this.subgroupVisibility = {};
|
22827 | this.doInnerStack = false;
|
22828 | this.shouldBailStackItems = false;
|
22829 | this.subgroupIndex = 0;
|
22830 | this.subgroupOrderer = data && data.subgroupOrder;
|
22831 | this.itemSet = itemSet;
|
22832 | this.isVisible = null;
|
22833 | this.stackDirty = true;
|
22834 |
|
22835 |
|
22836 |
|
22837 |
|
22838 |
|
22839 | this._disposeCallbacks = [];
|
22840 |
|
22841 | if (data && data.nestedGroups) {
|
22842 | this.nestedGroups = data.nestedGroups;
|
22843 |
|
22844 | if (data.showNested == false) {
|
22845 | this.showNested = false;
|
22846 | } else {
|
22847 | this.showNested = true;
|
22848 | }
|
22849 | }
|
22850 |
|
22851 | if (data && data.subgroupStack) {
|
22852 | if (typeof data.subgroupStack === "boolean") {
|
22853 | this.doInnerStack = data.subgroupStack;
|
22854 | this.subgroupStackAll = data.subgroupStack;
|
22855 | } else {
|
22856 |
|
22857 |
|
22858 | for (var key in data.subgroupStack) {
|
22859 | this.subgroupStack[key] = data.subgroupStack[key];
|
22860 | this.doInnerStack = this.doInnerStack || data.subgroupStack[key];
|
22861 | }
|
22862 | }
|
22863 | }
|
22864 |
|
22865 | if (data && data.heightMode) {
|
22866 | this.heightMode = data.heightMode;
|
22867 | } else {
|
22868 | this.heightMode = itemSet.options.groupHeightMode;
|
22869 | }
|
22870 |
|
22871 | this.nestedInGroup = null;
|
22872 | this.dom = {};
|
22873 | this.props = {
|
22874 | label: {
|
22875 | width: 0,
|
22876 | height: 0
|
22877 | }
|
22878 | };
|
22879 | this.className = null;
|
22880 | this.items = {};
|
22881 |
|
22882 | this.visibleItems = [];
|
22883 |
|
22884 | this.itemsInRange = [];
|
22885 |
|
22886 | this.orderedItems = {
|
22887 | byStart: [],
|
22888 | byEnd: []
|
22889 | };
|
22890 | this.checkRangedItems = false;
|
22891 |
|
22892 | var handleCheckRangedItems = function handleCheckRangedItems() {
|
22893 | _this.checkRangedItems = true;
|
22894 | };
|
22895 |
|
22896 | this.itemSet.body.emitter.on("checkRangedItems", handleCheckRangedItems);
|
22897 |
|
22898 | this._disposeCallbacks.push(function () {
|
22899 | _this.itemSet.body.emitter.off("checkRangedItems", handleCheckRangedItems);
|
22900 | });
|
22901 |
|
22902 | this._create();
|
22903 |
|
22904 | this.setData(data);
|
22905 | }
|
22906 | |
22907 |
|
22908 |
|
22909 |
|
22910 |
|
22911 |
|
22912 | _createClass(Group, [{
|
22913 | key: "_create",
|
22914 | value: function _create() {
|
22915 | var label = document.createElement('div');
|
22916 |
|
22917 | if (this.itemSet.options.groupEditable.order) {
|
22918 | label.className = 'vis-label draggable';
|
22919 | } else {
|
22920 | label.className = 'vis-label';
|
22921 | }
|
22922 |
|
22923 | this.dom.label = label;
|
22924 | var inner = document.createElement('div');
|
22925 | inner.className = 'vis-inner';
|
22926 | label.appendChild(inner);
|
22927 | this.dom.inner = inner;
|
22928 | var foreground = document.createElement('div');
|
22929 | foreground.className = 'vis-group';
|
22930 | foreground['vis-group'] = this;
|
22931 | this.dom.foreground = foreground;
|
22932 | this.dom.background = document.createElement('div');
|
22933 | this.dom.background.className = 'vis-group';
|
22934 | this.dom.axis = document.createElement('div');
|
22935 | this.dom.axis.className = 'vis-group';
|
22936 |
|
22937 |
|
22938 |
|
22939 | this.dom.marker = document.createElement('div');
|
22940 | this.dom.marker.style.visibility = 'hidden';
|
22941 | this.dom.marker.style.position = 'absolute';
|
22942 | this.dom.marker.innerHTML = '';
|
22943 | this.dom.background.appendChild(this.dom.marker);
|
22944 | }
|
22945 | |
22946 |
|
22947 |
|
22948 |
|
22949 |
|
22950 | }, {
|
22951 | key: "setData",
|
22952 | value: function setData(data) {
|
22953 | if (this.itemSet.groupTouchParams.isDragging) return;
|
22954 |
|
22955 | var content;
|
22956 | var templateFunction;
|
22957 |
|
22958 | if (data && data.subgroupVisibility) {
|
22959 | for (var key in data.subgroupVisibility) {
|
22960 | this.subgroupVisibility[key] = data.subgroupVisibility[key];
|
22961 | }
|
22962 | }
|
22963 |
|
22964 | if (this.itemSet.options && this.itemSet.options.groupTemplate) {
|
22965 | var _context;
|
22966 |
|
22967 | templateFunction = _bindInstanceProperty(_context = this.itemSet.options.groupTemplate).call(_context, this);
|
22968 | content = templateFunction(data, this.dom.inner);
|
22969 | } else {
|
22970 | content = data && data.content;
|
22971 | }
|
22972 |
|
22973 | if (content instanceof Element) {
|
22974 | while (this.dom.inner.firstChild) {
|
22975 | this.dom.inner.removeChild(this.dom.inner.firstChild);
|
22976 | }
|
22977 |
|
22978 | this.dom.inner.appendChild(content);
|
22979 | } else if (content instanceof Object && content.isReactComponent) ; else if (content instanceof Object) {
|
22980 | templateFunction(data, this.dom.inner);
|
22981 | } else if (content !== undefined && content !== null) {
|
22982 | this.dom.inner.innerHTML = availableUtils.xss(content);
|
22983 | } else {
|
22984 | this.dom.inner.innerHTML = availableUtils.xss(this.groupId || '');
|
22985 | }
|
22986 |
|
22987 |
|
22988 | this.dom.label.title = data && data.title || '';
|
22989 |
|
22990 | if (!this.dom.inner.firstChild) {
|
22991 | availableUtils.addClassName(this.dom.inner, 'vis-hidden');
|
22992 | } else {
|
22993 | availableUtils.removeClassName(this.dom.inner, 'vis-hidden');
|
22994 | }
|
22995 |
|
22996 | if (data && data.nestedGroups) {
|
22997 | if (!this.nestedGroups || this.nestedGroups != data.nestedGroups) {
|
22998 | this.nestedGroups = data.nestedGroups;
|
22999 | }
|
23000 |
|
23001 | if (data.showNested !== undefined || this.showNested === undefined) {
|
23002 | if (data.showNested == false) {
|
23003 | this.showNested = false;
|
23004 | } else {
|
23005 | this.showNested = true;
|
23006 | }
|
23007 | }
|
23008 |
|
23009 | availableUtils.addClassName(this.dom.label, 'vis-nesting-group');
|
23010 |
|
23011 | if (this.showNested) {
|
23012 | availableUtils.removeClassName(this.dom.label, 'collapsed');
|
23013 | availableUtils.addClassName(this.dom.label, 'expanded');
|
23014 | } else {
|
23015 | availableUtils.removeClassName(this.dom.label, 'expanded');
|
23016 | availableUtils.addClassName(this.dom.label, 'collapsed');
|
23017 | }
|
23018 | } else if (this.nestedGroups) {
|
23019 | this.nestedGroups = null;
|
23020 | availableUtils.removeClassName(this.dom.label, 'collapsed');
|
23021 | availableUtils.removeClassName(this.dom.label, 'expanded');
|
23022 | availableUtils.removeClassName(this.dom.label, 'vis-nesting-group');
|
23023 | }
|
23024 |
|
23025 | if (data && (data.treeLevel || data.nestedInGroup)) {
|
23026 | availableUtils.addClassName(this.dom.label, 'vis-nested-group');
|
23027 |
|
23028 | if (data.treeLevel) {
|
23029 | availableUtils.addClassName(this.dom.label, 'vis-group-level-' + data.treeLevel);
|
23030 | } else {
|
23031 |
|
23032 | availableUtils.addClassName(this.dom.label, 'vis-group-level-unknown-but-gte1');
|
23033 | }
|
23034 | } else {
|
23035 | availableUtils.addClassName(this.dom.label, 'vis-group-level-0');
|
23036 | }
|
23037 |
|
23038 |
|
23039 | var className = data && data.className || null;
|
23040 |
|
23041 | if (className != this.className) {
|
23042 | if (this.className) {
|
23043 | availableUtils.removeClassName(this.dom.label, this.className);
|
23044 | availableUtils.removeClassName(this.dom.foreground, this.className);
|
23045 | availableUtils.removeClassName(this.dom.background, this.className);
|
23046 | availableUtils.removeClassName(this.dom.axis, this.className);
|
23047 | }
|
23048 |
|
23049 | availableUtils.addClassName(this.dom.label, className);
|
23050 | availableUtils.addClassName(this.dom.foreground, className);
|
23051 | availableUtils.addClassName(this.dom.background, className);
|
23052 | availableUtils.addClassName(this.dom.axis, className);
|
23053 | this.className = className;
|
23054 | }
|
23055 |
|
23056 |
|
23057 | if (this.style) {
|
23058 | availableUtils.removeCssText(this.dom.label, this.style);
|
23059 | this.style = null;
|
23060 | }
|
23061 |
|
23062 | if (data && data.style) {
|
23063 | availableUtils.addCssText(this.dom.label, data.style);
|
23064 | this.style = data.style;
|
23065 | }
|
23066 | }
|
23067 | |
23068 |
|
23069 |
|
23070 |
|
23071 |
|
23072 | }, {
|
23073 | key: "getLabelWidth",
|
23074 | value: function getLabelWidth() {
|
23075 | return this.props.label.width;
|
23076 | }
|
23077 | |
23078 |
|
23079 |
|
23080 |
|
23081 |
|
23082 | }, {
|
23083 | key: "_didMarkerHeightChange",
|
23084 | value: function _didMarkerHeightChange() {
|
23085 | var markerHeight = this.dom.marker.clientHeight;
|
23086 |
|
23087 | if (markerHeight != this.lastMarkerHeight) {
|
23088 | this.lastMarkerHeight = markerHeight;
|
23089 | var redrawQueue = {};
|
23090 | var redrawQueueLength = 0;
|
23091 |
|
23092 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.items, function (item, key) {
|
23093 | item.dirty = true;
|
23094 |
|
23095 | if (item.displayed) {
|
23096 | var returnQueue = true;
|
23097 | redrawQueue[key] = item.redraw(returnQueue);
|
23098 | redrawQueueLength = redrawQueue[key].length;
|
23099 | }
|
23100 | });
|
23101 |
|
23102 | var needRedraw = redrawQueueLength > 0;
|
23103 |
|
23104 | if (needRedraw) {
|
23105 | var _loop = function _loop(i) {
|
23106 | _forEachInstanceProperty(availableUtils).call(availableUtils, redrawQueue, function (fns) {
|
23107 | fns[i]();
|
23108 | });
|
23109 | };
|
23110 |
|
23111 |
|
23112 | for (var i = 0; i < redrawQueueLength; i++) {
|
23113 | _loop(i);
|
23114 | }
|
23115 | }
|
23116 |
|
23117 | return true;
|
23118 | } else {
|
23119 | return false;
|
23120 | }
|
23121 | }
|
23122 | |
23123 |
|
23124 |
|
23125 |
|
23126 |
|
23127 | }, {
|
23128 | key: "_calculateGroupSizeAndPosition",
|
23129 | value: function _calculateGroupSizeAndPosition() {
|
23130 | var _this$dom$foreground = this.dom.foreground,
|
23131 | offsetTop = _this$dom$foreground.offsetTop,
|
23132 | offsetLeft = _this$dom$foreground.offsetLeft,
|
23133 | offsetWidth = _this$dom$foreground.offsetWidth;
|
23134 | this.top = offsetTop;
|
23135 | this.right = offsetLeft;
|
23136 | this.width = offsetWidth;
|
23137 | }
|
23138 | |
23139 |
|
23140 |
|
23141 |
|
23142 |
|
23143 | }, {
|
23144 | key: "_shouldBailItemsRedraw",
|
23145 | value: function _shouldBailItemsRedraw() {
|
23146 | var me = this;
|
23147 | var timeoutOptions = this.itemSet.options.onTimeout;
|
23148 | var bailOptions = {
|
23149 | relativeBailingTime: this.itemSet.itemsSettingTime,
|
23150 | bailTimeMs: timeoutOptions && timeoutOptions.timeoutMs,
|
23151 | userBailFunction: timeoutOptions && timeoutOptions.callback,
|
23152 | shouldBailStackItems: this.shouldBailStackItems
|
23153 | };
|
23154 | var bail = null;
|
23155 |
|
23156 | if (!this.itemSet.initialDrawDone) {
|
23157 | if (bailOptions.shouldBailStackItems) {
|
23158 | return true;
|
23159 | }
|
23160 |
|
23161 | if (Math.abs(_Date$now() - new Date(bailOptions.relativeBailingTime)) > bailOptions.bailTimeMs) {
|
23162 | if (bailOptions.userBailFunction && this.itemSet.userContinueNotBail == null) {
|
23163 | bailOptions.userBailFunction(function (didUserContinue) {
|
23164 | me.itemSet.userContinueNotBail = didUserContinue;
|
23165 | bail = !didUserContinue;
|
23166 | });
|
23167 | } else if (me.itemSet.userContinueNotBail == false) {
|
23168 | bail = true;
|
23169 | } else {
|
23170 | bail = false;
|
23171 | }
|
23172 | }
|
23173 | }
|
23174 |
|
23175 | return bail;
|
23176 | }
|
23177 | |
23178 |
|
23179 |
|
23180 |
|
23181 |
|
23182 |
|
23183 |
|
23184 |
|
23185 |
|
23186 | }, {
|
23187 | key: "_redrawItems",
|
23188 | value: function _redrawItems(forceRestack, lastIsVisible, margin, range) {
|
23189 | var _this2 = this;
|
23190 |
|
23191 | var restack = forceRestack || this.stackDirty || this.isVisible && !lastIsVisible;
|
23192 |
|
23193 | if (restack) {
|
23194 | var _context2, _context3, _context4, _context5, _context6, _context7;
|
23195 |
|
23196 | var orderedItems = {
|
23197 | byEnd: _filterInstanceProperty(_context2 = this.orderedItems.byEnd).call(_context2, function (item) {
|
23198 | return !item.isCluster;
|
23199 | }),
|
23200 | byStart: _filterInstanceProperty(_context3 = this.orderedItems.byStart).call(_context3, function (item) {
|
23201 | return !item.isCluster;
|
23202 | })
|
23203 | };
|
23204 | var orderedClusters = {
|
23205 | byEnd: _toConsumableArray(new _Set(_filterInstanceProperty(_context4 = _mapInstanceProperty(_context5 = this.orderedItems.byEnd).call(_context5, function (item) {
|
23206 | return item.cluster;
|
23207 | })).call(_context4, function (item) {
|
23208 | return !!item;
|
23209 | }))),
|
23210 | byStart: _toConsumableArray(new _Set(_filterInstanceProperty(_context6 = _mapInstanceProperty(_context7 = this.orderedItems.byStart).call(_context7, function (item) {
|
23211 | return item.cluster;
|
23212 | })).call(_context6, function (item) {
|
23213 | return !!item;
|
23214 | })))
|
23215 | };
|
23216 | |
23217 |
|
23218 |
|
23219 |
|
23220 |
|
23221 | var getVisibleItems = function getVisibleItems() {
|
23222 | var _context8, _context9, _context10;
|
23223 |
|
23224 | var visibleItems = _this2._updateItemsInRange(orderedItems, _filterInstanceProperty(_context8 = _this2.visibleItems).call(_context8, function (item) {
|
23225 | return !item.isCluster;
|
23226 | }), range);
|
23227 |
|
23228 | var visibleClusters = _this2._updateClustersInRange(orderedClusters, _filterInstanceProperty(_context9 = _this2.visibleItems).call(_context9, function (item) {
|
23229 | return item.isCluster;
|
23230 | }), range);
|
23231 |
|
23232 | return _concatInstanceProperty(_context10 = []).call(_context10, _toConsumableArray(visibleItems), _toConsumableArray(visibleClusters));
|
23233 | };
|
23234 | |
23235 |
|
23236 |
|
23237 |
|
23238 |
|
23239 |
|
23240 |
|
23241 | var getVisibleItemsGroupedBySubgroup = function getVisibleItemsGroupedBySubgroup(orderFn) {
|
23242 | var visibleSubgroupsItems = {};
|
23243 |
|
23244 | var _loop2 = function _loop2(subgroup) {
|
23245 | var _context11;
|
23246 |
|
23247 | var items = _filterInstanceProperty(_context11 = _this2.visibleItems).call(_context11, function (item) {
|
23248 | return item.data.subgroup === subgroup;
|
23249 | });
|
23250 |
|
23251 | visibleSubgroupsItems[subgroup] = orderFn ? _sortInstanceProperty(items).call(items, function (a, b) {
|
23252 | return orderFn(a.data, b.data);
|
23253 | }) : items;
|
23254 | };
|
23255 |
|
23256 | for (var subgroup in _this2.subgroups) {
|
23257 | _loop2(subgroup);
|
23258 | }
|
23259 |
|
23260 | return visibleSubgroupsItems;
|
23261 | };
|
23262 |
|
23263 | if (typeof this.itemSet.options.order === 'function') {
|
23264 |
|
23265 |
|
23266 | var me = this;
|
23267 |
|
23268 | if (this.doInnerStack && this.itemSet.options.stackSubgroups) {
|
23269 |
|
23270 | var visibleSubgroupsItems = getVisibleItemsGroupedBySubgroup(this.itemSet.options.order);
|
23271 | stackSubgroupsWithInnerStack(visibleSubgroupsItems, margin, this.subgroups);
|
23272 | this.visibleItems = getVisibleItems();
|
23273 |
|
23274 | this._updateSubGroupHeights(margin);
|
23275 | } else {
|
23276 | var _context12, _context13, _context14, _context15;
|
23277 |
|
23278 | this.visibleItems = getVisibleItems();
|
23279 |
|
23280 | this._updateSubGroupHeights(margin);
|
23281 |
|
23282 |
|
23283 |
|
23284 | var customOrderedItems = _sortInstanceProperty(_context12 = _filterInstanceProperty(_context13 = _sliceInstanceProperty(_context14 = this.visibleItems).call(_context14)).call(_context13, function (item) {
|
23285 | return item.isCluster || !item.isCluster && !item.cluster;
|
23286 | })).call(_context12, function (a, b) {
|
23287 | return me.itemSet.options.order(a.data, b.data);
|
23288 | });
|
23289 |
|
23290 | this.shouldBailStackItems = stack(customOrderedItems, margin, true, _bindInstanceProperty(_context15 = this._shouldBailItemsRedraw).call(_context15, this));
|
23291 | }
|
23292 | } else {
|
23293 |
|
23294 | this.visibleItems = getVisibleItems();
|
23295 |
|
23296 | this._updateSubGroupHeights(margin);
|
23297 |
|
23298 | if (this.itemSet.options.stack) {
|
23299 | if (this.doInnerStack && this.itemSet.options.stackSubgroups) {
|
23300 | var _visibleSubgroupsItems = getVisibleItemsGroupedBySubgroup();
|
23301 |
|
23302 | stackSubgroupsWithInnerStack(_visibleSubgroupsItems, margin, this.subgroups);
|
23303 | } else {
|
23304 | var _context16;
|
23305 |
|
23306 |
|
23307 | this.shouldBailStackItems = stack(this.visibleItems, margin, true, _bindInstanceProperty(_context16 = this._shouldBailItemsRedraw).call(_context16, this));
|
23308 | }
|
23309 | } else {
|
23310 |
|
23311 | nostack(this.visibleItems, margin, this.subgroups, this.itemSet.options.stackSubgroups);
|
23312 | }
|
23313 | }
|
23314 |
|
23315 | for (var i = 0; i < this.visibleItems.length; i++) {
|
23316 | this.visibleItems[i].repositionX();
|
23317 |
|
23318 | if (this.subgroupVisibility[this.visibleItems[i].data.subgroup] !== undefined) {
|
23319 | if (!this.subgroupVisibility[this.visibleItems[i].data.subgroup]) {
|
23320 | this.visibleItems[i].hide();
|
23321 | }
|
23322 | }
|
23323 | }
|
23324 |
|
23325 | if (this.itemSet.options.cluster) {
|
23326 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.items, function (item) {
|
23327 | if (item.cluster && item.displayed) {
|
23328 | item.hide();
|
23329 | }
|
23330 | });
|
23331 | }
|
23332 |
|
23333 | if (this.shouldBailStackItems) {
|
23334 | this.itemSet.body.emitter.emit('destroyTimeline');
|
23335 | }
|
23336 |
|
23337 | this.stackDirty = false;
|
23338 | }
|
23339 | }
|
23340 | |
23341 |
|
23342 |
|
23343 |
|
23344 |
|
23345 |
|
23346 |
|
23347 | }, {
|
23348 | key: "_didResize",
|
23349 | value: function _didResize(resized, height) {
|
23350 | resized = availableUtils.updateProperty(this, 'height', height) || resized;
|
23351 |
|
23352 | var labelWidth = this.dom.inner.clientWidth;
|
23353 | var labelHeight = this.dom.inner.clientHeight;
|
23354 | resized = availableUtils.updateProperty(this.props.label, 'width', labelWidth) || resized;
|
23355 | resized = availableUtils.updateProperty(this.props.label, 'height', labelHeight) || resized;
|
23356 | return resized;
|
23357 | }
|
23358 | |
23359 |
|
23360 |
|
23361 |
|
23362 |
|
23363 | }, {
|
23364 | key: "_applyGroupHeight",
|
23365 | value: function _applyGroupHeight(height) {
|
23366 | this.dom.background.style.height = "".concat(height, "px");
|
23367 | this.dom.foreground.style.height = "".concat(height, "px");
|
23368 | this.dom.label.style.height = "".concat(height, "px");
|
23369 | }
|
23370 | |
23371 |
|
23372 |
|
23373 |
|
23374 |
|
23375 | }, {
|
23376 | key: "_updateItemsVerticalPosition",
|
23377 | value: function _updateItemsVerticalPosition(margin) {
|
23378 | for (var i = 0, ii = this.visibleItems.length; i < ii; i++) {
|
23379 | var item = this.visibleItems[i];
|
23380 | item.repositionY(margin);
|
23381 |
|
23382 | if (!this.isVisible && this.groupId != ReservedGroupIds$1.BACKGROUND) {
|
23383 | if (item.displayed) item.hide();
|
23384 | }
|
23385 | }
|
23386 | }
|
23387 | |
23388 |
|
23389 |
|
23390 |
|
23391 |
|
23392 |
|
23393 |
|
23394 |
|
23395 |
|
23396 | }, {
|
23397 | key: "redraw",
|
23398 | value: function redraw(range, margin, forceRestack, returnQueue) {
|
23399 | var _this3 = this,
|
23400 | _context17,
|
23401 | _context18,
|
23402 | _context21,
|
23403 | _context23,
|
23404 | _context27;
|
23405 |
|
23406 | var resized = false;
|
23407 | var lastIsVisible = this.isVisible;
|
23408 | var height;
|
23409 | var queue = [function () {
|
23410 | forceRestack = _this3._didMarkerHeightChange.call(_this3) || forceRestack;
|
23411 | },
|
23412 | _bindInstanceProperty(_context17 = this._updateSubGroupHeights).call(_context17, this, margin),
|
23413 | _bindInstanceProperty(_context18 = this._calculateGroupSizeAndPosition).call(_context18, this), function () {
|
23414 | var _context19;
|
23415 |
|
23416 | _this3.isVisible = _bindInstanceProperty(_context19 = _this3._isGroupVisible).call(_context19, _this3)(range, margin);
|
23417 | }, function () {
|
23418 | var _context20;
|
23419 |
|
23420 | _bindInstanceProperty(_context20 = _this3._redrawItems).call(_context20, _this3)(forceRestack, lastIsVisible, margin, range);
|
23421 | },
|
23422 | _bindInstanceProperty(_context21 = this._updateSubgroupsSizes).call(_context21, this), function () {
|
23423 | var _context22;
|
23424 |
|
23425 | height = _bindInstanceProperty(_context22 = _this3._calculateHeight).call(_context22, _this3)(margin);
|
23426 | },
|
23427 | _bindInstanceProperty(_context23 = this._calculateGroupSizeAndPosition).call(_context23, this), function () {
|
23428 | var _context24;
|
23429 |
|
23430 | resized = _bindInstanceProperty(_context24 = _this3._didResize).call(_context24, _this3)(resized, height);
|
23431 | }, function () {
|
23432 | var _context25;
|
23433 |
|
23434 | _bindInstanceProperty(_context25 = _this3._applyGroupHeight).call(_context25, _this3)(height);
|
23435 | }, function () {
|
23436 | var _context26;
|
23437 |
|
23438 | _bindInstanceProperty(_context26 = _this3._updateItemsVerticalPosition).call(_context26, _this3)(margin);
|
23439 | }, _bindInstanceProperty(_context27 = function _context27() {
|
23440 | if (!_this3.isVisible && _this3.height) {
|
23441 | resized = false;
|
23442 | }
|
23443 |
|
23444 | return resized;
|
23445 | }).call(_context27, this)];
|
23446 |
|
23447 | if (returnQueue) {
|
23448 | return queue;
|
23449 | } else {
|
23450 | var result;
|
23451 |
|
23452 | _forEachInstanceProperty(queue).call(queue, function (fn) {
|
23453 | result = fn();
|
23454 | });
|
23455 |
|
23456 | return result;
|
23457 | }
|
23458 | }
|
23459 | |
23460 |
|
23461 |
|
23462 |
|
23463 |
|
23464 |
|
23465 |
|
23466 | }, {
|
23467 | key: "_updateSubGroupHeights",
|
23468 | value: function _updateSubGroupHeights(margin) {
|
23469 | var _this4 = this;
|
23470 |
|
23471 | if (_Object$keys(this.subgroups).length > 0) {
|
23472 | var me = this;
|
23473 |
|
23474 | this._resetSubgroups();
|
23475 |
|
23476 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.visibleItems, function (item) {
|
23477 | if (item.data.subgroup !== undefined) {
|
23478 | me.subgroups[item.data.subgroup].height = Math.max(me.subgroups[item.data.subgroup].height, item.height + margin.item.vertical);
|
23479 | me.subgroups[item.data.subgroup].visible = typeof _this4.subgroupVisibility[item.data.subgroup] === 'undefined' ? true : Boolean(_this4.subgroupVisibility[item.data.subgroup]);
|
23480 | }
|
23481 | });
|
23482 | }
|
23483 | }
|
23484 | |
23485 |
|
23486 |
|
23487 |
|
23488 |
|
23489 |
|
23490 |
|
23491 |
|
23492 |
|
23493 | }, {
|
23494 | key: "_isGroupVisible",
|
23495 | value: function _isGroupVisible(range, margin) {
|
23496 | return this.top <= range.body.domProps.centerContainer.height - range.body.domProps.scrollTop + margin.axis && this.top + this.height + margin.axis >= -range.body.domProps.scrollTop;
|
23497 | }
|
23498 | |
23499 |
|
23500 |
|
23501 |
|
23502 |
|
23503 |
|
23504 |
|
23505 | }, {
|
23506 | key: "_calculateHeight",
|
23507 | value: function _calculateHeight(margin) {
|
23508 |
|
23509 | var height;
|
23510 | var items;
|
23511 |
|
23512 | if (this.heightMode === 'fixed') {
|
23513 | items = availableUtils.toArray(this.items);
|
23514 | } else {
|
23515 |
|
23516 | items = this.visibleItems;
|
23517 | }
|
23518 |
|
23519 | if (items.length > 0) {
|
23520 | var min = items[0].top;
|
23521 | var max = items[0].top + items[0].height;
|
23522 |
|
23523 | _forEachInstanceProperty(availableUtils).call(availableUtils, items, function (item) {
|
23524 | min = Math.min(min, item.top);
|
23525 | max = Math.max(max, item.top + item.height);
|
23526 | });
|
23527 |
|
23528 | if (min > margin.axis) {
|
23529 |
|
23530 | var offset = min - margin.axis;
|
23531 | max -= offset;
|
23532 |
|
23533 | _forEachInstanceProperty(availableUtils).call(availableUtils, items, function (item) {
|
23534 | item.top -= offset;
|
23535 | });
|
23536 | }
|
23537 |
|
23538 | height = Math.ceil(max + margin.item.vertical / 2);
|
23539 |
|
23540 | if (this.heightMode !== "fitItems") {
|
23541 | height = Math.max(height, this.props.label.height);
|
23542 | }
|
23543 | } else {
|
23544 | height = this.props.label.height;
|
23545 | }
|
23546 |
|
23547 | return height;
|
23548 | }
|
23549 | |
23550 |
|
23551 |
|
23552 |
|
23553 | }, {
|
23554 | key: "show",
|
23555 | value: function show() {
|
23556 | if (!this.dom.label.parentNode) {
|
23557 | this.itemSet.dom.labelSet.appendChild(this.dom.label);
|
23558 | }
|
23559 |
|
23560 | if (!this.dom.foreground.parentNode) {
|
23561 | this.itemSet.dom.foreground.appendChild(this.dom.foreground);
|
23562 | }
|
23563 |
|
23564 | if (!this.dom.background.parentNode) {
|
23565 | this.itemSet.dom.background.appendChild(this.dom.background);
|
23566 | }
|
23567 |
|
23568 | if (!this.dom.axis.parentNode) {
|
23569 | this.itemSet.dom.axis.appendChild(this.dom.axis);
|
23570 | }
|
23571 | }
|
23572 | |
23573 |
|
23574 |
|
23575 |
|
23576 | }, {
|
23577 | key: "hide",
|
23578 | value: function hide() {
|
23579 | var label = this.dom.label;
|
23580 |
|
23581 | if (label.parentNode) {
|
23582 | label.parentNode.removeChild(label);
|
23583 | }
|
23584 |
|
23585 | var foreground = this.dom.foreground;
|
23586 |
|
23587 | if (foreground.parentNode) {
|
23588 | foreground.parentNode.removeChild(foreground);
|
23589 | }
|
23590 |
|
23591 | var background = this.dom.background;
|
23592 |
|
23593 | if (background.parentNode) {
|
23594 | background.parentNode.removeChild(background);
|
23595 | }
|
23596 |
|
23597 | var axis = this.dom.axis;
|
23598 |
|
23599 | if (axis.parentNode) {
|
23600 | axis.parentNode.removeChild(axis);
|
23601 | }
|
23602 | }
|
23603 | |
23604 |
|
23605 |
|
23606 |
|
23607 |
|
23608 | }, {
|
23609 | key: "add",
|
23610 | value: function add(item) {
|
23611 | var _context28;
|
23612 |
|
23613 | this.items[item.id] = item;
|
23614 | item.setParent(this);
|
23615 | this.stackDirty = true;
|
23616 |
|
23617 | if (item.data.subgroup !== undefined) {
|
23618 | this._addToSubgroup(item);
|
23619 |
|
23620 | this.orderSubgroups();
|
23621 | }
|
23622 |
|
23623 | if (!_includesInstanceProperty(_context28 = this.visibleItems).call(_context28, item)) {
|
23624 | var range = this.itemSet.body.range;
|
23625 |
|
23626 | this._checkIfVisible(item, this.visibleItems, range);
|
23627 | }
|
23628 | }
|
23629 | |
23630 |
|
23631 |
|
23632 |
|
23633 |
|
23634 |
|
23635 | }, {
|
23636 | key: "_addToSubgroup",
|
23637 | value: function _addToSubgroup(item) {
|
23638 | var subgroupId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : item.data.subgroup;
|
23639 |
|
23640 | if (subgroupId != undefined && this.subgroups[subgroupId] === undefined) {
|
23641 | this.subgroups[subgroupId] = {
|
23642 | height: 0,
|
23643 | top: 0,
|
23644 | start: item.data.start,
|
23645 | end: item.data.end || item.data.start,
|
23646 | visible: false,
|
23647 | index: this.subgroupIndex,
|
23648 | items: [],
|
23649 | stack: this.subgroupStackAll || this.subgroupStack[subgroupId] || false
|
23650 | };
|
23651 | this.subgroupIndex++;
|
23652 | }
|
23653 |
|
23654 | if (new Date(item.data.start) < new Date(this.subgroups[subgroupId].start)) {
|
23655 | this.subgroups[subgroupId].start = item.data.start;
|
23656 | }
|
23657 |
|
23658 | var itemEnd = item.data.end || item.data.start;
|
23659 |
|
23660 | if (new Date(itemEnd) > new Date(this.subgroups[subgroupId].end)) {
|
23661 | this.subgroups[subgroupId].end = itemEnd;
|
23662 | }
|
23663 |
|
23664 | this.subgroups[subgroupId].items.push(item);
|
23665 | }
|
23666 | |
23667 |
|
23668 |
|
23669 |
|
23670 | }, {
|
23671 | key: "_updateSubgroupsSizes",
|
23672 | value: function _updateSubgroupsSizes() {
|
23673 | var me = this;
|
23674 |
|
23675 | if (me.subgroups) {
|
23676 | var _loop3 = function _loop3(subgroup) {
|
23677 | var _context29;
|
23678 |
|
23679 | var initialEnd = me.subgroups[subgroup].items[0].data.end || me.subgroups[subgroup].items[0].data.start;
|
23680 | var newStart = me.subgroups[subgroup].items[0].data.start;
|
23681 | var newEnd = initialEnd - 1;
|
23682 |
|
23683 | _forEachInstanceProperty(_context29 = me.subgroups[subgroup].items).call(_context29, function (item) {
|
23684 | if (new Date(item.data.start) < new Date(newStart)) {
|
23685 | newStart = item.data.start;
|
23686 | }
|
23687 |
|
23688 | var itemEnd = item.data.end || item.data.start;
|
23689 |
|
23690 | if (new Date(itemEnd) > new Date(newEnd)) {
|
23691 | newEnd = itemEnd;
|
23692 | }
|
23693 | });
|
23694 |
|
23695 | me.subgroups[subgroup].start = newStart;
|
23696 | me.subgroups[subgroup].end = new Date(newEnd - 1);
|
23697 | };
|
23698 |
|
23699 | for (var subgroup in me.subgroups) {
|
23700 | _loop3(subgroup);
|
23701 | }
|
23702 | }
|
23703 | }
|
23704 | |
23705 |
|
23706 |
|
23707 |
|
23708 | }, {
|
23709 | key: "orderSubgroups",
|
23710 | value: function orderSubgroups() {
|
23711 | if (this.subgroupOrderer !== undefined) {
|
23712 | var sortArray = [];
|
23713 |
|
23714 | if (typeof this.subgroupOrderer == 'string') {
|
23715 | for (var subgroup in this.subgroups) {
|
23716 | sortArray.push({
|
23717 | subgroup: subgroup,
|
23718 | sortField: this.subgroups[subgroup].items[0].data[this.subgroupOrderer]
|
23719 | });
|
23720 | }
|
23721 |
|
23722 | _sortInstanceProperty(sortArray).call(sortArray, function (a, b) {
|
23723 | return a.sortField - b.sortField;
|
23724 | });
|
23725 | } else if (typeof this.subgroupOrderer == 'function') {
|
23726 | for (var _subgroup in this.subgroups) {
|
23727 | sortArray.push(this.subgroups[_subgroup].items[0].data);
|
23728 | }
|
23729 |
|
23730 | _sortInstanceProperty(sortArray).call(sortArray, this.subgroupOrderer);
|
23731 | }
|
23732 |
|
23733 | if (sortArray.length > 0) {
|
23734 | for (var i = 0; i < sortArray.length; i++) {
|
23735 | this.subgroups[sortArray[i].subgroup].index = i;
|
23736 | }
|
23737 | }
|
23738 | }
|
23739 | }
|
23740 | |
23741 |
|
23742 |
|
23743 |
|
23744 | }, {
|
23745 | key: "_resetSubgroups",
|
23746 | value: function _resetSubgroups() {
|
23747 | for (var subgroup in this.subgroups) {
|
23748 | if (this.subgroups.hasOwnProperty(subgroup)) {
|
23749 | this.subgroups[subgroup].visible = false;
|
23750 | this.subgroups[subgroup].height = 0;
|
23751 | }
|
23752 | }
|
23753 | }
|
23754 | |
23755 |
|
23756 |
|
23757 |
|
23758 |
|
23759 | }, {
|
23760 | key: "remove",
|
23761 | value: function remove(item) {
|
23762 | var _context30, _context31;
|
23763 |
|
23764 | delete this.items[item.id];
|
23765 | item.setParent(null);
|
23766 | this.stackDirty = true;
|
23767 |
|
23768 | var index = _indexOfInstanceProperty(_context30 = this.visibleItems).call(_context30, item);
|
23769 |
|
23770 | if (index != -1) _spliceInstanceProperty(_context31 = this.visibleItems).call(_context31, index, 1);
|
23771 |
|
23772 | if (item.data.subgroup !== undefined) {
|
23773 | this._removeFromSubgroup(item);
|
23774 |
|
23775 | this.orderSubgroups();
|
23776 | }
|
23777 | }
|
23778 | |
23779 |
|
23780 |
|
23781 |
|
23782 |
|
23783 |
|
23784 | }, {
|
23785 | key: "_removeFromSubgroup",
|
23786 | value: function _removeFromSubgroup(item) {
|
23787 | var subgroupId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : item.data.subgroup;
|
23788 |
|
23789 | if (subgroupId != undefined) {
|
23790 | var subgroup = this.subgroups[subgroupId];
|
23791 |
|
23792 | if (subgroup) {
|
23793 | var _context32;
|
23794 |
|
23795 | var itemIndex = _indexOfInstanceProperty(_context32 = subgroup.items).call(_context32, item);
|
23796 |
|
23797 |
|
23798 | if (itemIndex >= 0) {
|
23799 | var _context33;
|
23800 |
|
23801 | _spliceInstanceProperty(_context33 = subgroup.items).call(_context33, itemIndex, 1);
|
23802 |
|
23803 | if (!subgroup.items.length) {
|
23804 | delete this.subgroups[subgroupId];
|
23805 | } else {
|
23806 | this._updateSubgroupsSizes();
|
23807 | }
|
23808 | }
|
23809 | }
|
23810 | }
|
23811 | }
|
23812 | |
23813 |
|
23814 |
|
23815 |
|
23816 |
|
23817 | }, {
|
23818 | key: "removeFromDataSet",
|
23819 | value: function removeFromDataSet(item) {
|
23820 | this.itemSet.removeItem(item.id);
|
23821 | }
|
23822 | |
23823 |
|
23824 |
|
23825 |
|
23826 | }, {
|
23827 | key: "order",
|
23828 | value: function order() {
|
23829 | var array = availableUtils.toArray(this.items);
|
23830 | var startArray = [];
|
23831 | var endArray = [];
|
23832 |
|
23833 | for (var i = 0; i < array.length; i++) {
|
23834 | if (array[i].data.end !== undefined) {
|
23835 | endArray.push(array[i]);
|
23836 | }
|
23837 |
|
23838 | startArray.push(array[i]);
|
23839 | }
|
23840 |
|
23841 | this.orderedItems = {
|
23842 | byStart: startArray,
|
23843 | byEnd: endArray
|
23844 | };
|
23845 | orderByStart(this.orderedItems.byStart);
|
23846 | orderByEnd(this.orderedItems.byEnd);
|
23847 | }
|
23848 | |
23849 |
|
23850 |
|
23851 |
|
23852 |
|
23853 |
|
23854 |
|
23855 |
|
23856 |
|
23857 | }, {
|
23858 | key: "_updateItemsInRange",
|
23859 | value: function _updateItemsInRange(orderedItems, oldVisibleItems, range) {
|
23860 | var visibleItems = [];
|
23861 | var visibleItemsLookup = {};
|
23862 |
|
23863 | if (!this.isVisible && this.groupId != ReservedGroupIds$1.BACKGROUND) {
|
23864 | for (var i = 0; i < oldVisibleItems.length; i++) {
|
23865 | var item = oldVisibleItems[i];
|
23866 | if (item.displayed) item.hide();
|
23867 | }
|
23868 |
|
23869 | return visibleItems;
|
23870 | }
|
23871 |
|
23872 | var interval = (range.end - range.start) / 4;
|
23873 | var lowerBound = range.start - interval;
|
23874 | var upperBound = range.end + interval;
|
23875 |
|
23876 | var startSearchFunction = function startSearchFunction(value) {
|
23877 | if (value < lowerBound) {
|
23878 | return -1;
|
23879 | } else if (value <= upperBound) {
|
23880 | return 0;
|
23881 | } else {
|
23882 | return 1;
|
23883 | }
|
23884 | };
|
23885 |
|
23886 |
|
23887 | var endSearchFunction = function endSearchFunction(data) {
|
23888 | var start = data.start,
|
23889 | end = data.end;
|
23890 |
|
23891 | if (end < lowerBound) {
|
23892 | return -1;
|
23893 | } else if (start <= upperBound) {
|
23894 | return 0;
|
23895 | } else {
|
23896 | return 1;
|
23897 | }
|
23898 | };
|
23899 |
|
23900 |
|
23901 |
|
23902 |
|
23903 | if (oldVisibleItems.length > 0) {
|
23904 | for (var _i = 0; _i < oldVisibleItems.length; _i++) {
|
23905 | this._checkIfVisibleWithReference(oldVisibleItems[_i], visibleItems, visibleItemsLookup, range);
|
23906 | }
|
23907 | }
|
23908 |
|
23909 |
|
23910 | var initialPosByStart = availableUtils.binarySearchCustom(orderedItems.byStart, startSearchFunction, 'data', 'start');
|
23911 |
|
23912 | this._traceVisible(initialPosByStart, orderedItems.byStart, visibleItems, visibleItemsLookup, function (item) {
|
23913 | return item.data.start < lowerBound || item.data.start > upperBound;
|
23914 | });
|
23915 |
|
23916 |
|
23917 |
|
23918 | if (this.checkRangedItems == true) {
|
23919 | this.checkRangedItems = false;
|
23920 |
|
23921 | for (var _i2 = 0; _i2 < orderedItems.byEnd.length; _i2++) {
|
23922 | this._checkIfVisibleWithReference(orderedItems.byEnd[_i2], visibleItems, visibleItemsLookup, range);
|
23923 | }
|
23924 | } else {
|
23925 |
|
23926 | var initialPosByEnd = availableUtils.binarySearchCustom(orderedItems.byEnd, endSearchFunction, 'data');
|
23927 |
|
23928 | this._traceVisible(initialPosByEnd, orderedItems.byEnd, visibleItems, visibleItemsLookup, function (item) {
|
23929 | return item.data.end < lowerBound || item.data.start > upperBound;
|
23930 | });
|
23931 | }
|
23932 |
|
23933 | var redrawQueue = {};
|
23934 | var redrawQueueLength = 0;
|
23935 |
|
23936 | for (var _i3 = 0; _i3 < visibleItems.length; _i3++) {
|
23937 | var _item = visibleItems[_i3];
|
23938 |
|
23939 | if (!_item.displayed) {
|
23940 | var returnQueue = true;
|
23941 | redrawQueue[_i3] = _item.redraw(returnQueue);
|
23942 | redrawQueueLength = redrawQueue[_i3].length;
|
23943 | }
|
23944 | }
|
23945 |
|
23946 | var needRedraw = redrawQueueLength > 0;
|
23947 |
|
23948 | if (needRedraw) {
|
23949 | var _loop4 = function _loop4(j) {
|
23950 | _forEachInstanceProperty(availableUtils).call(availableUtils, redrawQueue, function (fns) {
|
23951 | fns[j]();
|
23952 | });
|
23953 | };
|
23954 |
|
23955 |
|
23956 | for (var j = 0; j < redrawQueueLength; j++) {
|
23957 | _loop4(j);
|
23958 | }
|
23959 | }
|
23960 |
|
23961 | for (var _i4 = 0; _i4 < visibleItems.length; _i4++) {
|
23962 | visibleItems[_i4].repositionX();
|
23963 | }
|
23964 |
|
23965 | return visibleItems;
|
23966 | }
|
23967 | |
23968 |
|
23969 |
|
23970 |
|
23971 |
|
23972 |
|
23973 |
|
23974 |
|
23975 |
|
23976 | }, {
|
23977 | key: "_traceVisible",
|
23978 | value: function _traceVisible(initialPos, items, visibleItems, visibleItemsLookup, breakCondition) {
|
23979 | if (initialPos != -1) {
|
23980 | for (var i = initialPos; i >= 0; i--) {
|
23981 | var item = items[i];
|
23982 |
|
23983 | if (breakCondition(item)) {
|
23984 | break;
|
23985 | } else {
|
23986 | if (!(item.isCluster && !item.hasItems()) && !item.cluster) {
|
23987 | if (visibleItemsLookup[item.id] === undefined) {
|
23988 | visibleItemsLookup[item.id] = true;
|
23989 | visibleItems.push(item);
|
23990 | }
|
23991 | }
|
23992 | }
|
23993 | }
|
23994 |
|
23995 | for (var _i5 = initialPos + 1; _i5 < items.length; _i5++) {
|
23996 | var _item2 = items[_i5];
|
23997 |
|
23998 | if (breakCondition(_item2)) {
|
23999 | break;
|
24000 | } else {
|
24001 | if (!(_item2.isCluster && !_item2.hasItems()) && !_item2.cluster) {
|
24002 | if (visibleItemsLookup[_item2.id] === undefined) {
|
24003 | visibleItemsLookup[_item2.id] = true;
|
24004 | visibleItems.push(_item2);
|
24005 | }
|
24006 | }
|
24007 | }
|
24008 | }
|
24009 | }
|
24010 | }
|
24011 | |
24012 |
|
24013 |
|
24014 |
|
24015 |
|
24016 |
|
24017 |
|
24018 |
|
24019 |
|
24020 |
|
24021 |
|
24022 |
|
24023 | }, {
|
24024 | key: "_checkIfVisible",
|
24025 | value: function _checkIfVisible(item, visibleItems, range) {
|
24026 | if (item.isVisible(range)) {
|
24027 | if (!item.displayed) item.show();
|
24028 |
|
24029 | item.repositionX();
|
24030 | visibleItems.push(item);
|
24031 | } else {
|
24032 | if (item.displayed) item.hide();
|
24033 | }
|
24034 | }
|
24035 | |
24036 |
|
24037 |
|
24038 |
|
24039 |
|
24040 |
|
24041 |
|
24042 |
|
24043 |
|
24044 |
|
24045 |
|
24046 |
|
24047 |
|
24048 | }, {
|
24049 | key: "_checkIfVisibleWithReference",
|
24050 | value: function _checkIfVisibleWithReference(item, visibleItems, visibleItemsLookup, range) {
|
24051 | if (item.isVisible(range)) {
|
24052 | if (visibleItemsLookup[item.id] === undefined) {
|
24053 | visibleItemsLookup[item.id] = true;
|
24054 | visibleItems.push(item);
|
24055 | }
|
24056 | } else {
|
24057 | if (item.displayed) item.hide();
|
24058 | }
|
24059 | }
|
24060 | |
24061 |
|
24062 |
|
24063 |
|
24064 |
|
24065 |
|
24066 |
|
24067 |
|
24068 |
|
24069 | }, {
|
24070 | key: "_updateClustersInRange",
|
24071 | value: function _updateClustersInRange(orderedClusters, oldVisibleClusters, range) {
|
24072 |
|
24073 | var visibleClusters = [];
|
24074 | var visibleClustersLookup = {};
|
24075 |
|
24076 | if (oldVisibleClusters.length > 0) {
|
24077 | for (var i = 0; i < oldVisibleClusters.length; i++) {
|
24078 | this._checkIfVisibleWithReference(oldVisibleClusters[i], visibleClusters, visibleClustersLookup, range);
|
24079 | }
|
24080 | }
|
24081 |
|
24082 | for (var _i6 = 0; _i6 < orderedClusters.byStart.length; _i6++) {
|
24083 | this._checkIfVisibleWithReference(orderedClusters.byStart[_i6], visibleClusters, visibleClustersLookup, range);
|
24084 | }
|
24085 |
|
24086 | for (var _i7 = 0; _i7 < orderedClusters.byEnd.length; _i7++) {
|
24087 | this._checkIfVisibleWithReference(orderedClusters.byEnd[_i7], visibleClusters, visibleClustersLookup, range);
|
24088 | }
|
24089 |
|
24090 | var redrawQueue = {};
|
24091 | var redrawQueueLength = 0;
|
24092 |
|
24093 | for (var _i8 = 0; _i8 < visibleClusters.length; _i8++) {
|
24094 | var item = visibleClusters[_i8];
|
24095 |
|
24096 | if (!item.displayed) {
|
24097 | var returnQueue = true;
|
24098 | redrawQueue[_i8] = item.redraw(returnQueue);
|
24099 | redrawQueueLength = redrawQueue[_i8].length;
|
24100 | }
|
24101 | }
|
24102 |
|
24103 | var needRedraw = redrawQueueLength > 0;
|
24104 |
|
24105 | if (needRedraw) {
|
24106 |
|
24107 | for (var j = 0; j < redrawQueueLength; j++) {
|
24108 | _forEachInstanceProperty(availableUtils).call(availableUtils, redrawQueue, function (fns) {
|
24109 | fns[j]();
|
24110 | });
|
24111 | }
|
24112 | }
|
24113 |
|
24114 | for (var _i9 = 0; _i9 < visibleClusters.length; _i9++) {
|
24115 | visibleClusters[_i9].repositionX();
|
24116 | }
|
24117 |
|
24118 | return visibleClusters;
|
24119 | }
|
24120 | |
24121 |
|
24122 |
|
24123 |
|
24124 |
|
24125 |
|
24126 |
|
24127 | }, {
|
24128 | key: "changeSubgroup",
|
24129 | value: function changeSubgroup(item, oldSubgroup, newSubgroup) {
|
24130 | this._removeFromSubgroup(item, oldSubgroup);
|
24131 |
|
24132 | this._addToSubgroup(item, newSubgroup);
|
24133 |
|
24134 | this.orderSubgroups();
|
24135 | }
|
24136 | |
24137 |
|
24138 |
|
24139 |
|
24140 |
|
24141 | }, {
|
24142 | key: "dispose",
|
24143 | value: function dispose() {
|
24144 | this.hide();
|
24145 | var disposeCallback;
|
24146 |
|
24147 | while (disposeCallback = this._disposeCallbacks.pop()) {
|
24148 | disposeCallback();
|
24149 | }
|
24150 | }
|
24151 | }]);
|
24152 |
|
24153 | return Group;
|
24154 | }();
|
24155 |
|
24156 | function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
24157 |
|
24158 | function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
24159 |
|
24160 |
|
24161 |
|
24162 |
|
24163 |
|
24164 | var BackgroundGroup = function (_Group) {
|
24165 | _inherits(BackgroundGroup, _Group);
|
24166 |
|
24167 | var _super = _createSuper$8(BackgroundGroup);
|
24168 |
|
24169 | |
24170 |
|
24171 |
|
24172 |
|
24173 |
|
24174 | function BackgroundGroup(groupId, data, itemSet) {
|
24175 | var _this;
|
24176 |
|
24177 | _classCallCheck(this, BackgroundGroup);
|
24178 |
|
24179 | _this = _super.call(this, groupId, data, itemSet);
|
24180 |
|
24181 | _this.width = 0;
|
24182 | _this.height = 0;
|
24183 | _this.top = 0;
|
24184 | _this.left = 0;
|
24185 | return _this;
|
24186 | }
|
24187 | |
24188 |
|
24189 |
|
24190 |
|
24191 |
|
24192 |
|
24193 |
|
24194 |
|
24195 |
|
24196 | _createClass(BackgroundGroup, [{
|
24197 | key: "redraw",
|
24198 | value: function redraw(range, margin, forceRestack) {
|
24199 |
|
24200 | var resized = false;
|
24201 | this.visibleItems = this._updateItemsInRange(this.orderedItems, this.visibleItems, range);
|
24202 |
|
24203 | this.width = this.dom.background.offsetWidth;
|
24204 |
|
24205 | this.dom.background.style.height = '0';
|
24206 |
|
24207 | for (var i = 0, ii = this.visibleItems.length; i < ii; i++) {
|
24208 | var item = this.visibleItems[i];
|
24209 | item.repositionY(margin);
|
24210 | }
|
24211 |
|
24212 | return resized;
|
24213 | }
|
24214 | |
24215 |
|
24216 |
|
24217 |
|
24218 | }, {
|
24219 | key: "show",
|
24220 | value: function show() {
|
24221 | if (!this.dom.background.parentNode) {
|
24222 | this.itemSet.dom.background.appendChild(this.dom.background);
|
24223 | }
|
24224 | }
|
24225 | }]);
|
24226 |
|
24227 | return BackgroundGroup;
|
24228 | }(Group);
|
24229 |
|
24230 | function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
24231 |
|
24232 | function _unsupportedIterableToArray$4(o, minLen) { var _context8; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = _sliceInstanceProperty(_context8 = Object.prototype.toString.call(o)).call(_context8, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
|
24233 |
|
24234 | function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
24235 |
|
24236 |
|
24237 |
|
24238 |
|
24239 | var Item = function () {
|
24240 | |
24241 |
|
24242 |
|
24243 |
|
24244 |
|
24245 |
|
24246 |
|
24247 |
|
24248 |
|
24249 | function Item(data, conversion, options) {
|
24250 | var _context,
|
24251 | _this = this;
|
24252 |
|
24253 | _classCallCheck(this, Item);
|
24254 |
|
24255 | this.id = null;
|
24256 | this.parent = null;
|
24257 | this.data = data;
|
24258 | this.dom = null;
|
24259 | this.conversion = conversion || {};
|
24260 | this.defaultOptions = {
|
24261 | locales: locales,
|
24262 | locale: 'en'
|
24263 | };
|
24264 | this.options = availableUtils.extend({}, this.defaultOptions, options);
|
24265 | this.options.locales = availableUtils.extend({}, locales, this.options.locales);
|
24266 | var defaultLocales = this.defaultOptions.locales[this.defaultOptions.locale];
|
24267 |
|
24268 | _forEachInstanceProperty(_context = _Object$keys(this.options.locales)).call(_context, function (locale) {
|
24269 | _this.options.locales[locale] = availableUtils.extend({}, defaultLocales, _this.options.locales[locale]);
|
24270 | });
|
24271 |
|
24272 | this.selected = false;
|
24273 | this.displayed = false;
|
24274 | this.groupShowing = true;
|
24275 | this.selectable = options && options.selectable || false;
|
24276 | this.dirty = true;
|
24277 | this.top = null;
|
24278 | this.right = null;
|
24279 | this.left = null;
|
24280 | this.width = null;
|
24281 | this.height = null;
|
24282 | this.setSelectability(data);
|
24283 | this.editable = null;
|
24284 |
|
24285 | this._updateEditStatus();
|
24286 | }
|
24287 | |
24288 |
|
24289 |
|
24290 |
|
24291 |
|
24292 | _createClass(Item, [{
|
24293 | key: "select",
|
24294 | value: function select() {
|
24295 | if (this.selectable) {
|
24296 | this.selected = true;
|
24297 | this.dirty = true;
|
24298 | if (this.displayed) this.redraw();
|
24299 | }
|
24300 | }
|
24301 | |
24302 |
|
24303 |
|
24304 |
|
24305 | }, {
|
24306 | key: "unselect",
|
24307 | value: function unselect() {
|
24308 | this.selected = false;
|
24309 | this.dirty = true;
|
24310 | if (this.displayed) this.redraw();
|
24311 | }
|
24312 | |
24313 |
|
24314 |
|
24315 |
|
24316 |
|
24317 |
|
24318 | }, {
|
24319 | key: "setData",
|
24320 | value: function setData(data) {
|
24321 | var groupChanged = data.group != undefined && this.data.group != data.group;
|
24322 |
|
24323 | if (groupChanged && this.parent != null) {
|
24324 | this.parent.itemSet._moveToGroup(this, data.group);
|
24325 | }
|
24326 |
|
24327 | this.setSelectability(data);
|
24328 |
|
24329 | if (this.parent) {
|
24330 | this.parent.stackDirty = true;
|
24331 | }
|
24332 |
|
24333 | var subGroupChanged = data.subgroup != undefined && this.data.subgroup != data.subgroup;
|
24334 |
|
24335 | if (subGroupChanged && this.parent != null) {
|
24336 | this.parent.changeSubgroup(this, this.data.subgroup, data.subgroup);
|
24337 | }
|
24338 |
|
24339 | this.data = data;
|
24340 |
|
24341 | this._updateEditStatus();
|
24342 |
|
24343 | this.dirty = true;
|
24344 | if (this.displayed) this.redraw();
|
24345 | }
|
24346 | |
24347 |
|
24348 |
|
24349 |
|
24350 |
|
24351 |
|
24352 | }, {
|
24353 | key: "setSelectability",
|
24354 | value: function setSelectability(data) {
|
24355 | if (data) {
|
24356 | this.selectable = typeof data.selectable === 'undefined' ? true : Boolean(data.selectable);
|
24357 | }
|
24358 | }
|
24359 | |
24360 |
|
24361 |
|
24362 |
|
24363 |
|
24364 | }, {
|
24365 | key: "setParent",
|
24366 | value: function setParent(parent) {
|
24367 | if (this.displayed) {
|
24368 | this.hide();
|
24369 | this.parent = parent;
|
24370 |
|
24371 | if (this.parent) {
|
24372 | this.show();
|
24373 | }
|
24374 | } else {
|
24375 | this.parent = parent;
|
24376 | }
|
24377 | }
|
24378 | |
24379 |
|
24380 |
|
24381 |
|
24382 |
|
24383 |
|
24384 | }, {
|
24385 | key: "isVisible",
|
24386 | value: function isVisible(range) {
|
24387 |
|
24388 | return false;
|
24389 | }
|
24390 | |
24391 |
|
24392 |
|
24393 |
|
24394 |
|
24395 | }, {
|
24396 | key: "show",
|
24397 | value: function show() {
|
24398 | return false;
|
24399 | }
|
24400 | |
24401 |
|
24402 |
|
24403 |
|
24404 |
|
24405 | }, {
|
24406 | key: "hide",
|
24407 | value: function hide() {
|
24408 | return false;
|
24409 | }
|
24410 | |
24411 |
|
24412 |
|
24413 |
|
24414 | }, {
|
24415 | key: "redraw",
|
24416 | value: function redraw() {
|
24417 | }
|
24418 | |
24419 |
|
24420 |
|
24421 |
|
24422 | }, {
|
24423 | key: "repositionX",
|
24424 | value: function repositionX() {
|
24425 | }
|
24426 | |
24427 |
|
24428 |
|
24429 |
|
24430 | }, {
|
24431 | key: "repositionY",
|
24432 | value: function repositionY() {
|
24433 | }
|
24434 | |
24435 |
|
24436 |
|
24437 |
|
24438 |
|
24439 | }, {
|
24440 | key: "_repaintDragCenter",
|
24441 | value: function _repaintDragCenter() {
|
24442 | if (this.selected && this.editable.updateTime && !this.dom.dragCenter) {
|
24443 | var _context2, _context3;
|
24444 |
|
24445 | var me = this;
|
24446 |
|
24447 | var dragCenter = document.createElement('div');
|
24448 | dragCenter.className = 'vis-drag-center';
|
24449 | dragCenter.dragCenterItem = this;
|
24450 | this.hammerDragCenter = new Hammer(dragCenter);
|
24451 | this.hammerDragCenter.on('tap', function (event) {
|
24452 | me.parent.itemSet.body.emitter.emit('click', {
|
24453 | event: event,
|
24454 | item: me.id
|
24455 | });
|
24456 | });
|
24457 | this.hammerDragCenter.on('doubletap', function (event) {
|
24458 | event.stopPropagation();
|
24459 |
|
24460 | me.parent.itemSet._onUpdateItem(me);
|
24461 |
|
24462 | me.parent.itemSet.body.emitter.emit('doubleClick', {
|
24463 | event: event,
|
24464 | item: me.id
|
24465 | });
|
24466 | });
|
24467 | this.hammerDragCenter.on('panstart', function (event) {
|
24468 |
|
24469 | event.stopPropagation();
|
24470 |
|
24471 | me.parent.itemSet._onDragStart(event);
|
24472 | });
|
24473 | this.hammerDragCenter.on('panmove', _bindInstanceProperty(_context2 = me.parent.itemSet._onDrag).call(_context2, me.parent.itemSet));
|
24474 | this.hammerDragCenter.on('panend', _bindInstanceProperty(_context3 = me.parent.itemSet._onDragEnd).call(_context3, me.parent.itemSet));
|
24475 |
|
24476 | this.hammerDragCenter.get('press').set({
|
24477 | time: 10000
|
24478 | });
|
24479 |
|
24480 | if (this.dom.box) {
|
24481 | if (this.dom.dragLeft) {
|
24482 | this.dom.box.insertBefore(dragCenter, this.dom.dragLeft);
|
24483 | } else {
|
24484 | this.dom.box.appendChild(dragCenter);
|
24485 | }
|
24486 | } else if (this.dom.point) {
|
24487 | this.dom.point.appendChild(dragCenter);
|
24488 | }
|
24489 |
|
24490 | this.dom.dragCenter = dragCenter;
|
24491 | } else if (!this.selected && this.dom.dragCenter) {
|
24492 |
|
24493 | if (this.dom.dragCenter.parentNode) {
|
24494 | this.dom.dragCenter.parentNode.removeChild(this.dom.dragCenter);
|
24495 | }
|
24496 |
|
24497 | this.dom.dragCenter = null;
|
24498 |
|
24499 | if (this.hammerDragCenter) {
|
24500 | this.hammerDragCenter.destroy();
|
24501 | this.hammerDragCenter = null;
|
24502 | }
|
24503 | }
|
24504 | }
|
24505 | |
24506 |
|
24507 |
|
24508 |
|
24509 |
|
24510 |
|
24511 | }, {
|
24512 | key: "_repaintDeleteButton",
|
24513 | value: function _repaintDeleteButton(anchor) {
|
24514 | var editable = (this.options.editable.overrideItems || this.editable == null) && this.options.editable.remove || !this.options.editable.overrideItems && this.editable != null && this.editable.remove;
|
24515 |
|
24516 | if (this.selected && editable && !this.dom.deleteButton) {
|
24517 |
|
24518 | var me = this;
|
24519 | var deleteButton = document.createElement('div');
|
24520 |
|
24521 | if (this.options.rtl) {
|
24522 | deleteButton.className = 'vis-delete-rtl';
|
24523 | } else {
|
24524 | deleteButton.className = 'vis-delete';
|
24525 | }
|
24526 |
|
24527 | var optionsLocale = this.options.locales[this.options.locale];
|
24528 |
|
24529 | if (!optionsLocale) {
|
24530 | if (!this.warned) {
|
24531 | console.warn("WARNING: options.locales['".concat(this.options.locale, "'] not found. See https://visjs.github.io/vis-timeline/docs/timeline/#Localization"));
|
24532 | this.warned = true;
|
24533 | }
|
24534 |
|
24535 | optionsLocale = this.options.locales['en'];
|
24536 | }
|
24537 |
|
24538 | deleteButton.title = optionsLocale.deleteSelected;
|
24539 |
|
24540 | this.hammerDeleteButton = new Hammer(deleteButton).on('tap', function (event) {
|
24541 | event.stopPropagation();
|
24542 | me.parent.removeFromDataSet(me);
|
24543 | });
|
24544 | anchor.appendChild(deleteButton);
|
24545 | this.dom.deleteButton = deleteButton;
|
24546 | } else if ((!this.selected || !editable) && this.dom.deleteButton) {
|
24547 |
|
24548 | if (this.dom.deleteButton.parentNode) {
|
24549 | this.dom.deleteButton.parentNode.removeChild(this.dom.deleteButton);
|
24550 | }
|
24551 |
|
24552 | this.dom.deleteButton = null;
|
24553 |
|
24554 | if (this.hammerDeleteButton) {
|
24555 | this.hammerDeleteButton.destroy();
|
24556 | this.hammerDeleteButton = null;
|
24557 | }
|
24558 | }
|
24559 | }
|
24560 | |
24561 |
|
24562 |
|
24563 |
|
24564 |
|
24565 |
|
24566 | }, {
|
24567 | key: "_repaintOnItemUpdateTimeTooltip",
|
24568 | value: function _repaintOnItemUpdateTimeTooltip(anchor) {
|
24569 | if (!this.options.tooltipOnItemUpdateTime) return;
|
24570 | var editable = (this.options.editable.updateTime || this.data.editable === true) && this.data.editable !== false;
|
24571 |
|
24572 | if (this.selected && editable && !this.dom.onItemUpdateTimeTooltip) {
|
24573 | var onItemUpdateTimeTooltip = document.createElement('div');
|
24574 | onItemUpdateTimeTooltip.className = 'vis-onUpdateTime-tooltip';
|
24575 | anchor.appendChild(onItemUpdateTimeTooltip);
|
24576 | this.dom.onItemUpdateTimeTooltip = onItemUpdateTimeTooltip;
|
24577 | } else if (!this.selected && this.dom.onItemUpdateTimeTooltip) {
|
24578 |
|
24579 | if (this.dom.onItemUpdateTimeTooltip.parentNode) {
|
24580 | this.dom.onItemUpdateTimeTooltip.parentNode.removeChild(this.dom.onItemUpdateTimeTooltip);
|
24581 | }
|
24582 |
|
24583 | this.dom.onItemUpdateTimeTooltip = null;
|
24584 | }
|
24585 |
|
24586 |
|
24587 | if (this.dom.onItemUpdateTimeTooltip) {
|
24588 |
|
24589 | this.dom.onItemUpdateTimeTooltip.style.visibility = this.parent.itemSet.touchParams.itemIsDragging ? 'visible' : 'hidden';
|
24590 |
|
24591 | this.dom.onItemUpdateTimeTooltip.style.transform = 'translateX(-50%)';
|
24592 | this.dom.onItemUpdateTimeTooltip.style.left = '50%';
|
24593 |
|
24594 | var tooltipOffset = 50;
|
24595 |
|
24596 | var scrollTop = this.parent.itemSet.body.domProps.scrollTop;
|
24597 |
|
24598 |
|
24599 | var itemDistanceFromTop;
|
24600 |
|
24601 | if (this.options.orientation.item == 'top') {
|
24602 | itemDistanceFromTop = this.top;
|
24603 | } else {
|
24604 | itemDistanceFromTop = this.parent.height - this.top - this.height;
|
24605 | }
|
24606 |
|
24607 | var isCloseToTop = itemDistanceFromTop + this.parent.top - tooltipOffset < -scrollTop;
|
24608 |
|
24609 | if (isCloseToTop) {
|
24610 | this.dom.onItemUpdateTimeTooltip.style.bottom = "";
|
24611 | this.dom.onItemUpdateTimeTooltip.style.top = "".concat(this.height + 2, "px");
|
24612 | } else {
|
24613 | this.dom.onItemUpdateTimeTooltip.style.top = "";
|
24614 | this.dom.onItemUpdateTimeTooltip.style.bottom = "".concat(this.height + 2, "px");
|
24615 | }
|
24616 |
|
24617 |
|
24618 | var content;
|
24619 | var templateFunction;
|
24620 |
|
24621 | if (this.options.tooltipOnItemUpdateTime && this.options.tooltipOnItemUpdateTime.template) {
|
24622 | var _context4;
|
24623 |
|
24624 | templateFunction = _bindInstanceProperty(_context4 = this.options.tooltipOnItemUpdateTime.template).call(_context4, this);
|
24625 | content = templateFunction(this.data);
|
24626 | } else {
|
24627 | content = "start: ".concat(moment$2(this.data.start).format('MM/DD/YYYY hh:mm'));
|
24628 |
|
24629 | if (this.data.end) {
|
24630 | content += "<br> end: ".concat(moment$2(this.data.end).format('MM/DD/YYYY hh:mm'));
|
24631 | }
|
24632 | }
|
24633 |
|
24634 | this.dom.onItemUpdateTimeTooltip.innerHTML = availableUtils.xss(content);
|
24635 | }
|
24636 | }
|
24637 | |
24638 |
|
24639 |
|
24640 |
|
24641 |
|
24642 |
|
24643 | }, {
|
24644 | key: "_getItemData",
|
24645 | value: function _getItemData() {
|
24646 | return this.parent.itemSet.itemsData.get(this.id);
|
24647 | }
|
24648 | |
24649 |
|
24650 |
|
24651 |
|
24652 |
|
24653 |
|
24654 | }, {
|
24655 | key: "_updateContents",
|
24656 | value: function _updateContents(element) {
|
24657 | var content;
|
24658 | var changed;
|
24659 | var templateFunction;
|
24660 | var itemVisibleFrameContent;
|
24661 | var visibleFrameTemplateFunction;
|
24662 |
|
24663 | var itemData = this._getItemData();
|
24664 |
|
24665 |
|
24666 | var frameElement = this.dom.box || this.dom.point;
|
24667 | var itemVisibleFrameContentElement = frameElement.getElementsByClassName('vis-item-visible-frame')[0];
|
24668 |
|
24669 | if (this.options.visibleFrameTemplate) {
|
24670 | var _context5;
|
24671 |
|
24672 | visibleFrameTemplateFunction = _bindInstanceProperty(_context5 = this.options.visibleFrameTemplate).call(_context5, this);
|
24673 | itemVisibleFrameContent = availableUtils.xss(visibleFrameTemplateFunction(itemData, itemVisibleFrameContentElement));
|
24674 | } else {
|
24675 | itemVisibleFrameContent = '';
|
24676 | }
|
24677 |
|
24678 | if (itemVisibleFrameContentElement) {
|
24679 | if (itemVisibleFrameContent instanceof Object && !(itemVisibleFrameContent instanceof Element)) {
|
24680 | visibleFrameTemplateFunction(itemData, itemVisibleFrameContentElement);
|
24681 | } else {
|
24682 | changed = this._contentToString(this.itemVisibleFrameContent) !== this._contentToString(itemVisibleFrameContent);
|
24683 |
|
24684 | if (changed) {
|
24685 |
|
24686 | if (itemVisibleFrameContent instanceof Element) {
|
24687 | itemVisibleFrameContentElement.innerHTML = '';
|
24688 | itemVisibleFrameContentElement.appendChild(itemVisibleFrameContent);
|
24689 | } else if (itemVisibleFrameContent != undefined) {
|
24690 | itemVisibleFrameContentElement.innerHTML = availableUtils.xss(itemVisibleFrameContent);
|
24691 | } else {
|
24692 | if (!(this.data.type == 'background' && this.data.content === undefined)) {
|
24693 | throw new Error("Property \"content\" missing in item ".concat(this.id));
|
24694 | }
|
24695 | }
|
24696 |
|
24697 | this.itemVisibleFrameContent = itemVisibleFrameContent;
|
24698 | }
|
24699 | }
|
24700 | }
|
24701 |
|
24702 | if (this.options.template) {
|
24703 | var _context6;
|
24704 |
|
24705 | templateFunction = _bindInstanceProperty(_context6 = this.options.template).call(_context6, this);
|
24706 | content = templateFunction(itemData, element, this.data);
|
24707 | } else {
|
24708 | content = this.data.content;
|
24709 | }
|
24710 |
|
24711 | if (content instanceof Object && !(content instanceof Element)) {
|
24712 | templateFunction(itemData, element);
|
24713 | } else {
|
24714 | changed = this._contentToString(this.content) !== this._contentToString(content);
|
24715 |
|
24716 | if (changed) {
|
24717 |
|
24718 | if (content instanceof Element) {
|
24719 | element.innerHTML = '';
|
24720 | element.appendChild(content);
|
24721 | } else if (content != undefined) {
|
24722 | element.innerHTML = availableUtils.xss(content);
|
24723 | } else {
|
24724 | if (!(this.data.type == 'background' && this.data.content === undefined)) {
|
24725 | throw new Error("Property \"content\" missing in item ".concat(this.id));
|
24726 | }
|
24727 | }
|
24728 |
|
24729 | this.content = content;
|
24730 | }
|
24731 | }
|
24732 | }
|
24733 | |
24734 |
|
24735 |
|
24736 |
|
24737 |
|
24738 |
|
24739 | }, {
|
24740 | key: "_updateDataAttributes",
|
24741 | value: function _updateDataAttributes(element) {
|
24742 | if (this.options.dataAttributes && this.options.dataAttributes.length > 0) {
|
24743 | var attributes = [];
|
24744 |
|
24745 | if (_Array$isArray$1(this.options.dataAttributes)) {
|
24746 | attributes = this.options.dataAttributes;
|
24747 | } else if (this.options.dataAttributes == 'all') {
|
24748 | attributes = _Object$keys(this.data);
|
24749 | } else {
|
24750 | return;
|
24751 | }
|
24752 |
|
24753 | var _iterator = _createForOfIteratorHelper$4(attributes),
|
24754 | _step;
|
24755 |
|
24756 | try {
|
24757 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
24758 | var name = _step.value;
|
24759 | var value = this.data[name];
|
24760 |
|
24761 | if (value != null) {
|
24762 | element.setAttribute("data-".concat(name), value);
|
24763 | } else {
|
24764 | element.removeAttribute("data-".concat(name));
|
24765 | }
|
24766 | }
|
24767 | } catch (err) {
|
24768 | _iterator.e(err);
|
24769 | } finally {
|
24770 | _iterator.f();
|
24771 | }
|
24772 | }
|
24773 | }
|
24774 | |
24775 |
|
24776 |
|
24777 |
|
24778 |
|
24779 |
|
24780 | }, {
|
24781 | key: "_updateStyle",
|
24782 | value: function _updateStyle(element) {
|
24783 |
|
24784 | if (this.style) {
|
24785 | availableUtils.removeCssText(element, this.style);
|
24786 | this.style = null;
|
24787 | }
|
24788 |
|
24789 |
|
24790 | if (this.data.style) {
|
24791 | availableUtils.addCssText(element, this.data.style);
|
24792 | this.style = this.data.style;
|
24793 | }
|
24794 | }
|
24795 | |
24796 |
|
24797 |
|
24798 |
|
24799 |
|
24800 |
|
24801 |
|
24802 | }, {
|
24803 | key: "_contentToString",
|
24804 | value: function _contentToString(content) {
|
24805 | if (typeof content === 'string') return content;
|
24806 | if (content && 'outerHTML' in content) return content.outerHTML;
|
24807 | return content;
|
24808 | }
|
24809 | |
24810 |
|
24811 |
|
24812 |
|
24813 | }, {
|
24814 | key: "_updateEditStatus",
|
24815 | value: function _updateEditStatus() {
|
24816 | if (this.options) {
|
24817 | if (typeof this.options.editable === 'boolean') {
|
24818 | this.editable = {
|
24819 | updateTime: this.options.editable,
|
24820 | updateGroup: this.options.editable,
|
24821 | remove: this.options.editable
|
24822 | };
|
24823 | } else if (_typeof(this.options.editable) === 'object') {
|
24824 | this.editable = {};
|
24825 | availableUtils.selectiveExtend(['updateTime', 'updateGroup', 'remove'], this.editable, this.options.editable);
|
24826 | }
|
24827 | }
|
24828 |
|
24829 |
|
24830 | if (!this.options || !this.options.editable || this.options.editable.overrideItems !== true) {
|
24831 | if (this.data) {
|
24832 | if (typeof this.data.editable === 'boolean') {
|
24833 | this.editable = {
|
24834 | updateTime: this.data.editable,
|
24835 | updateGroup: this.data.editable,
|
24836 | remove: this.data.editable
|
24837 | };
|
24838 | } else if (_typeof(this.data.editable) === 'object') {
|
24839 |
|
24840 |
|
24841 | this.editable = {};
|
24842 | availableUtils.selectiveExtend(['updateTime', 'updateGroup', 'remove'], this.editable, this.data.editable);
|
24843 | }
|
24844 | }
|
24845 | }
|
24846 | }
|
24847 | |
24848 |
|
24849 |
|
24850 |
|
24851 |
|
24852 | }, {
|
24853 | key: "getWidthLeft",
|
24854 | value: function getWidthLeft() {
|
24855 | return 0;
|
24856 | }
|
24857 | |
24858 |
|
24859 |
|
24860 |
|
24861 |
|
24862 | }, {
|
24863 | key: "getWidthRight",
|
24864 | value: function getWidthRight() {
|
24865 | return 0;
|
24866 | }
|
24867 | |
24868 |
|
24869 |
|
24870 |
|
24871 |
|
24872 | }, {
|
24873 | key: "getTitle",
|
24874 | value: function getTitle() {
|
24875 | if (this.options.tooltip && this.options.tooltip.template) {
|
24876 | var _context7;
|
24877 |
|
24878 | var templateFunction = _bindInstanceProperty(_context7 = this.options.tooltip.template).call(_context7, this);
|
24879 |
|
24880 | return templateFunction(this._getItemData(), this.data);
|
24881 | }
|
24882 |
|
24883 | return this.data.title;
|
24884 | }
|
24885 | }]);
|
24886 |
|
24887 | return Item;
|
24888 | }();
|
24889 |
|
24890 | Item.prototype.stack = true;
|
24891 |
|
24892 | function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
24893 |
|
24894 | function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
24895 |
|
24896 |
|
24897 |
|
24898 |
|
24899 |
|
24900 | var BoxItem = function (_Item) {
|
24901 | _inherits(BoxItem, _Item);
|
24902 |
|
24903 | var _super = _createSuper$7(BoxItem);
|
24904 |
|
24905 | |
24906 |
|
24907 |
|
24908 |
|
24909 |
|
24910 |
|
24911 |
|
24912 |
|
24913 | function BoxItem(data, conversion, options) {
|
24914 | var _this;
|
24915 |
|
24916 | _classCallCheck(this, BoxItem);
|
24917 |
|
24918 | _this = _super.call(this, data, conversion, options);
|
24919 | _this.props = {
|
24920 | dot: {
|
24921 | width: 0,
|
24922 | height: 0
|
24923 | },
|
24924 | line: {
|
24925 | width: 0,
|
24926 | height: 0
|
24927 | }
|
24928 | };
|
24929 |
|
24930 | if (data) {
|
24931 | if (data.start == undefined) {
|
24932 | throw new Error("Property \"start\" missing in item ".concat(data));
|
24933 | }
|
24934 | }
|
24935 |
|
24936 | return _this;
|
24937 | }
|
24938 | |
24939 |
|
24940 |
|
24941 |
|
24942 |
|
24943 |
|
24944 |
|
24945 | _createClass(BoxItem, [{
|
24946 | key: "isVisible",
|
24947 | value: function isVisible(range) {
|
24948 | if (this.cluster) {
|
24949 | return false;
|
24950 | }
|
24951 |
|
24952 |
|
24953 | var isVisible;
|
24954 | var align = this.data.align || this.options.align;
|
24955 | var widthInMs = this.width * range.getMillisecondsPerPixel();
|
24956 |
|
24957 | if (align == 'right') {
|
24958 | isVisible = this.data.start.getTime() > range.start && this.data.start.getTime() - widthInMs < range.end;
|
24959 | } else if (align == 'left') {
|
24960 | isVisible = this.data.start.getTime() + widthInMs > range.start && this.data.start.getTime() < range.end;
|
24961 | } else {
|
24962 |
|
24963 | isVisible = this.data.start.getTime() + widthInMs / 2 > range.start && this.data.start.getTime() - widthInMs / 2 < range.end;
|
24964 | }
|
24965 |
|
24966 | return isVisible;
|
24967 | }
|
24968 | |
24969 |
|
24970 |
|
24971 |
|
24972 |
|
24973 | }, {
|
24974 | key: "_createDomElement",
|
24975 | value: function _createDomElement() {
|
24976 | if (!this.dom) {
|
24977 |
|
24978 | this.dom = {};
|
24979 |
|
24980 | this.dom.box = document.createElement('DIV');
|
24981 |
|
24982 | this.dom.content = document.createElement('DIV');
|
24983 | this.dom.content.className = 'vis-item-content';
|
24984 | this.dom.box.appendChild(this.dom.content);
|
24985 |
|
24986 | this.dom.line = document.createElement('DIV');
|
24987 | this.dom.line.className = 'vis-line';
|
24988 |
|
24989 | this.dom.dot = document.createElement('DIV');
|
24990 | this.dom.dot.className = 'vis-dot';
|
24991 |
|
24992 | this.dom.box['vis-item'] = this;
|
24993 | this.dirty = true;
|
24994 | }
|
24995 | }
|
24996 | |
24997 |
|
24998 |
|
24999 |
|
25000 |
|
25001 | }, {
|
25002 | key: "_appendDomElement",
|
25003 | value: function _appendDomElement() {
|
25004 | if (!this.parent) {
|
25005 | throw new Error('Cannot redraw item: no parent attached');
|
25006 | }
|
25007 |
|
25008 | if (!this.dom.box.parentNode) {
|
25009 | var foreground = this.parent.dom.foreground;
|
25010 | if (!foreground) throw new Error('Cannot redraw item: parent has no foreground container element');
|
25011 | foreground.appendChild(this.dom.box);
|
25012 | }
|
25013 |
|
25014 | if (!this.dom.line.parentNode) {
|
25015 | var background = this.parent.dom.background;
|
25016 | if (!background) throw new Error('Cannot redraw item: parent has no background container element');
|
25017 | background.appendChild(this.dom.line);
|
25018 | }
|
25019 |
|
25020 | if (!this.dom.dot.parentNode) {
|
25021 | var axis = this.parent.dom.axis;
|
25022 | if (!background) throw new Error('Cannot redraw item: parent has no axis container element');
|
25023 | axis.appendChild(this.dom.dot);
|
25024 | }
|
25025 |
|
25026 | this.displayed = true;
|
25027 | }
|
25028 | |
25029 |
|
25030 |
|
25031 |
|
25032 |
|
25033 | }, {
|
25034 | key: "_updateDirtyDomComponents",
|
25035 | value: function _updateDirtyDomComponents() {
|
25036 |
|
25037 |
|
25038 |
|
25039 |
|
25040 | if (this.dirty) {
|
25041 | this._updateContents(this.dom.content);
|
25042 |
|
25043 | this._updateDataAttributes(this.dom.box);
|
25044 |
|
25045 | this._updateStyle(this.dom.box);
|
25046 |
|
25047 | var editable = this.editable.updateTime || this.editable.updateGroup;
|
25048 |
|
25049 | var className = (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '') + (editable ? ' vis-editable' : ' vis-readonly');
|
25050 | this.dom.box.className = "vis-item vis-box".concat(className);
|
25051 | this.dom.line.className = "vis-item vis-line".concat(className);
|
25052 | this.dom.dot.className = "vis-item vis-dot".concat(className);
|
25053 | }
|
25054 | }
|
25055 | |
25056 |
|
25057 |
|
25058 |
|
25059 |
|
25060 |
|
25061 | }, {
|
25062 | key: "_getDomComponentsSizes",
|
25063 | value: function _getDomComponentsSizes() {
|
25064 | return {
|
25065 | previous: {
|
25066 | right: this.dom.box.style.right,
|
25067 | left: this.dom.box.style.left
|
25068 | },
|
25069 | dot: {
|
25070 | height: this.dom.dot.offsetHeight,
|
25071 | width: this.dom.dot.offsetWidth
|
25072 | },
|
25073 | line: {
|
25074 | width: this.dom.line.offsetWidth
|
25075 | },
|
25076 | box: {
|
25077 | width: this.dom.box.offsetWidth,
|
25078 | height: this.dom.box.offsetHeight
|
25079 | }
|
25080 | };
|
25081 | }
|
25082 | |
25083 |
|
25084 |
|
25085 |
|
25086 |
|
25087 |
|
25088 | }, {
|
25089 | key: "_updateDomComponentsSizes",
|
25090 | value: function _updateDomComponentsSizes(sizes) {
|
25091 | if (this.options.rtl) {
|
25092 | this.dom.box.style.right = "0px";
|
25093 | } else {
|
25094 | this.dom.box.style.left = "0px";
|
25095 | }
|
25096 |
|
25097 |
|
25098 | this.props.dot.height = sizes.dot.height;
|
25099 | this.props.dot.width = sizes.dot.width;
|
25100 | this.props.line.width = sizes.line.width;
|
25101 | this.width = sizes.box.width;
|
25102 | this.height = sizes.box.height;
|
25103 |
|
25104 | if (this.options.rtl) {
|
25105 | this.dom.box.style.right = sizes.previous.right;
|
25106 | } else {
|
25107 | this.dom.box.style.left = sizes.previous.left;
|
25108 | }
|
25109 |
|
25110 | this.dirty = false;
|
25111 | }
|
25112 | |
25113 |
|
25114 |
|
25115 |
|
25116 |
|
25117 | }, {
|
25118 | key: "_repaintDomAdditionals",
|
25119 | value: function _repaintDomAdditionals() {
|
25120 | this._repaintOnItemUpdateTimeTooltip(this.dom.box);
|
25121 |
|
25122 | this._repaintDragCenter();
|
25123 |
|
25124 | this._repaintDeleteButton(this.dom.box);
|
25125 | }
|
25126 | |
25127 |
|
25128 |
|
25129 |
|
25130 |
|
25131 |
|
25132 | }, {
|
25133 | key: "redraw",
|
25134 | value: function redraw(returnQueue) {
|
25135 | var _context,
|
25136 | _context2,
|
25137 | _context3,
|
25138 | _this2 = this,
|
25139 | _context5;
|
25140 |
|
25141 | var sizes;
|
25142 | var queue = [
|
25143 | _bindInstanceProperty(_context = this._createDomElement).call(_context, this),
|
25144 | _bindInstanceProperty(_context2 = this._appendDomElement).call(_context2, this),
|
25145 | _bindInstanceProperty(_context3 = this._updateDirtyDomComponents).call(_context3, this), function () {
|
25146 | if (_this2.dirty) {
|
25147 | sizes = _this2._getDomComponentsSizes();
|
25148 | }
|
25149 | }, function () {
|
25150 | if (_this2.dirty) {
|
25151 | var _context4;
|
25152 |
|
25153 | _bindInstanceProperty(_context4 = _this2._updateDomComponentsSizes).call(_context4, _this2)(sizes);
|
25154 | }
|
25155 | },
|
25156 | _bindInstanceProperty(_context5 = this._repaintDomAdditionals).call(_context5, this)];
|
25157 |
|
25158 | if (returnQueue) {
|
25159 | return queue;
|
25160 | } else {
|
25161 | var result;
|
25162 |
|
25163 | _forEachInstanceProperty(queue).call(queue, function (fn) {
|
25164 | result = fn();
|
25165 | });
|
25166 |
|
25167 | return result;
|
25168 | }
|
25169 | }
|
25170 | |
25171 |
|
25172 |
|
25173 |
|
25174 |
|
25175 |
|
25176 |
|
25177 | }, {
|
25178 | key: "show",
|
25179 | value: function show(returnQueue) {
|
25180 | if (!this.displayed) {
|
25181 | return this.redraw(returnQueue);
|
25182 | }
|
25183 | }
|
25184 | |
25185 |
|
25186 |
|
25187 |
|
25188 | }, {
|
25189 | key: "hide",
|
25190 | value: function hide() {
|
25191 | if (this.displayed) {
|
25192 | var dom = this.dom;
|
25193 | if (dom.box.remove) dom.box.remove();else if (dom.box.parentNode) dom.box.parentNode.removeChild(dom.box);
|
25194 |
|
25195 | if (dom.line.remove) dom.line.remove();else if (dom.line.parentNode) dom.line.parentNode.removeChild(dom.line);
|
25196 |
|
25197 | if (dom.dot.remove) dom.dot.remove();else if (dom.dot.parentNode) dom.dot.parentNode.removeChild(dom.dot);
|
25198 |
|
25199 | this.displayed = false;
|
25200 | }
|
25201 | }
|
25202 | |
25203 |
|
25204 |
|
25205 |
|
25206 | }, {
|
25207 | key: "repositionXY",
|
25208 | value: function repositionXY() {
|
25209 | var rtl = this.options.rtl;
|
25210 |
|
25211 | var repositionXY = function repositionXY(element, x, y) {
|
25212 | var _context6;
|
25213 |
|
25214 | var rtl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25215 | if (x === undefined && y === undefined) return;
|
25216 |
|
25217 | var directionX = rtl ? x * -1 : x;
|
25218 |
|
25219 | if (y === undefined) {
|
25220 | element.style.transform = "translateX(".concat(directionX, "px)");
|
25221 | return;
|
25222 | }
|
25223 |
|
25224 |
|
25225 | if (x === undefined) {
|
25226 | element.style.transform = "translateY(".concat(y, "px)");
|
25227 | return;
|
25228 | }
|
25229 |
|
25230 | element.style.transform = _concatInstanceProperty(_context6 = "translate(".concat(directionX, "px, ")).call(_context6, y, "px)");
|
25231 | };
|
25232 |
|
25233 | repositionXY(this.dom.box, this.boxX, this.boxY, rtl);
|
25234 | repositionXY(this.dom.dot, this.dotX, this.dotY, rtl);
|
25235 | repositionXY(this.dom.line, this.lineX, this.lineY, rtl);
|
25236 | }
|
25237 | |
25238 |
|
25239 |
|
25240 |
|
25241 |
|
25242 | }, {
|
25243 | key: "repositionX",
|
25244 | value: function repositionX() {
|
25245 | var start = this.conversion.toScreen(this.data.start);
|
25246 | var align = this.data.align === undefined ? this.options.align : this.data.align;
|
25247 | var lineWidth = this.props.line.width;
|
25248 | var dotWidth = this.props.dot.width;
|
25249 |
|
25250 | if (align == 'right') {
|
25251 |
|
25252 | this.boxX = start - this.width;
|
25253 | this.lineX = start - lineWidth;
|
25254 | this.dotX = start - lineWidth / 2 - dotWidth / 2;
|
25255 | } else if (align == 'left') {
|
25256 |
|
25257 | this.boxX = start;
|
25258 | this.lineX = start;
|
25259 | this.dotX = start + lineWidth / 2 - dotWidth / 2;
|
25260 | } else {
|
25261 |
|
25262 | this.boxX = start - this.width / 2;
|
25263 | this.lineX = this.options.rtl ? start - lineWidth : start - lineWidth / 2;
|
25264 | this.dotX = start - dotWidth / 2;
|
25265 | }
|
25266 |
|
25267 | if (this.options.rtl) this.right = this.boxX;else this.left = this.boxX;
|
25268 | this.repositionXY();
|
25269 | }
|
25270 | |
25271 |
|
25272 |
|
25273 |
|
25274 |
|
25275 | }, {
|
25276 | key: "repositionY",
|
25277 | value: function repositionY() {
|
25278 | var orientation = this.options.orientation.item;
|
25279 | var lineStyle = this.dom.line.style;
|
25280 |
|
25281 | if (orientation == 'top') {
|
25282 | var lineHeight = this.parent.top + this.top + 1;
|
25283 | this.boxY = this.top || 0;
|
25284 | lineStyle.height = "".concat(lineHeight, "px");
|
25285 | lineStyle.bottom = '';
|
25286 | lineStyle.top = '0';
|
25287 | } else {
|
25288 |
|
25289 | var itemSetHeight = this.parent.itemSet.props.height;
|
25290 |
|
25291 | var _lineHeight = itemSetHeight - this.parent.top - this.parent.height + this.top;
|
25292 |
|
25293 | this.boxY = this.parent.height - this.top - (this.height || 0);
|
25294 | lineStyle.height = "".concat(_lineHeight, "px");
|
25295 | lineStyle.top = '';
|
25296 | lineStyle.bottom = '0';
|
25297 | }
|
25298 |
|
25299 | this.dotY = -this.props.dot.height / 2;
|
25300 | this.repositionXY();
|
25301 | }
|
25302 | |
25303 |
|
25304 |
|
25305 |
|
25306 |
|
25307 | }, {
|
25308 | key: "getWidthLeft",
|
25309 | value: function getWidthLeft() {
|
25310 | return this.width / 2;
|
25311 | }
|
25312 | |
25313 |
|
25314 |
|
25315 |
|
25316 |
|
25317 | }, {
|
25318 | key: "getWidthRight",
|
25319 | value: function getWidthRight() {
|
25320 | return this.width / 2;
|
25321 | }
|
25322 | }]);
|
25323 |
|
25324 | return BoxItem;
|
25325 | }(Item);
|
25326 |
|
25327 | function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
25328 |
|
25329 | function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
25330 |
|
25331 |
|
25332 |
|
25333 |
|
25334 |
|
25335 | var PointItem = function (_Item) {
|
25336 | _inherits(PointItem, _Item);
|
25337 |
|
25338 | var _super = _createSuper$6(PointItem);
|
25339 |
|
25340 | |
25341 |
|
25342 |
|
25343 |
|
25344 |
|
25345 |
|
25346 |
|
25347 |
|
25348 | function PointItem(data, conversion, options) {
|
25349 | var _this;
|
25350 |
|
25351 | _classCallCheck(this, PointItem);
|
25352 |
|
25353 | _this = _super.call(this, data, conversion, options);
|
25354 | _this.props = {
|
25355 | dot: {
|
25356 | top: 0,
|
25357 | width: 0,
|
25358 | height: 0
|
25359 | },
|
25360 | content: {
|
25361 | height: 0,
|
25362 | marginLeft: 0,
|
25363 | marginRight: 0
|
25364 | }
|
25365 | };
|
25366 |
|
25367 | if (data) {
|
25368 | if (data.start == undefined) {
|
25369 | throw new Error("Property \"start\" missing in item ".concat(data));
|
25370 | }
|
25371 | }
|
25372 |
|
25373 | return _this;
|
25374 | }
|
25375 | |
25376 |
|
25377 |
|
25378 |
|
25379 |
|
25380 |
|
25381 |
|
25382 | _createClass(PointItem, [{
|
25383 | key: "isVisible",
|
25384 | value: function isVisible(range) {
|
25385 | if (this.cluster) {
|
25386 | return false;
|
25387 | }
|
25388 |
|
25389 |
|
25390 | var widthInMs = this.width * range.getMillisecondsPerPixel();
|
25391 | return this.data.start.getTime() + widthInMs > range.start && this.data.start < range.end;
|
25392 | }
|
25393 | |
25394 |
|
25395 |
|
25396 |
|
25397 |
|
25398 | }, {
|
25399 | key: "_createDomElement",
|
25400 | value: function _createDomElement() {
|
25401 | if (!this.dom) {
|
25402 |
|
25403 | this.dom = {};
|
25404 |
|
25405 | this.dom.point = document.createElement('div');
|
25406 |
|
25407 |
|
25408 | this.dom.content = document.createElement('div');
|
25409 | this.dom.content.className = 'vis-item-content';
|
25410 | this.dom.point.appendChild(this.dom.content);
|
25411 |
|
25412 | this.dom.dot = document.createElement('div');
|
25413 | this.dom.point.appendChild(this.dom.dot);
|
25414 |
|
25415 | this.dom.point['vis-item'] = this;
|
25416 | this.dirty = true;
|
25417 | }
|
25418 | }
|
25419 | |
25420 |
|
25421 |
|
25422 |
|
25423 |
|
25424 | }, {
|
25425 | key: "_appendDomElement",
|
25426 | value: function _appendDomElement() {
|
25427 | if (!this.parent) {
|
25428 | throw new Error('Cannot redraw item: no parent attached');
|
25429 | }
|
25430 |
|
25431 | if (!this.dom.point.parentNode) {
|
25432 | var foreground = this.parent.dom.foreground;
|
25433 |
|
25434 | if (!foreground) {
|
25435 | throw new Error('Cannot redraw item: parent has no foreground container element');
|
25436 | }
|
25437 |
|
25438 | foreground.appendChild(this.dom.point);
|
25439 | }
|
25440 |
|
25441 | this.displayed = true;
|
25442 | }
|
25443 | |
25444 |
|
25445 |
|
25446 |
|
25447 |
|
25448 | }, {
|
25449 | key: "_updateDirtyDomComponents",
|
25450 | value: function _updateDirtyDomComponents() {
|
25451 |
|
25452 |
|
25453 |
|
25454 |
|
25455 | if (this.dirty) {
|
25456 | this._updateContents(this.dom.content);
|
25457 |
|
25458 | this._updateDataAttributes(this.dom.point);
|
25459 |
|
25460 | this._updateStyle(this.dom.point);
|
25461 |
|
25462 | var editable = this.editable.updateTime || this.editable.updateGroup;
|
25463 |
|
25464 | var className = (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '') + (editable ? ' vis-editable' : ' vis-readonly');
|
25465 | this.dom.point.className = "vis-item vis-point".concat(className);
|
25466 | this.dom.dot.className = "vis-item vis-dot".concat(className);
|
25467 | }
|
25468 | }
|
25469 | |
25470 |
|
25471 |
|
25472 |
|
25473 |
|
25474 |
|
25475 | }, {
|
25476 | key: "_getDomComponentsSizes",
|
25477 | value: function _getDomComponentsSizes() {
|
25478 | return {
|
25479 | dot: {
|
25480 | width: this.dom.dot.offsetWidth,
|
25481 | height: this.dom.dot.offsetHeight
|
25482 | },
|
25483 | content: {
|
25484 | width: this.dom.content.offsetWidth,
|
25485 | height: this.dom.content.offsetHeight
|
25486 | },
|
25487 | point: {
|
25488 | width: this.dom.point.offsetWidth,
|
25489 | height: this.dom.point.offsetHeight
|
25490 | }
|
25491 | };
|
25492 | }
|
25493 | |
25494 |
|
25495 |
|
25496 |
|
25497 |
|
25498 |
|
25499 | }, {
|
25500 | key: "_updateDomComponentsSizes",
|
25501 | value: function _updateDomComponentsSizes(sizes) {
|
25502 |
|
25503 | this.props.dot.width = sizes.dot.width;
|
25504 | this.props.dot.height = sizes.dot.height;
|
25505 | this.props.content.height = sizes.content.height;
|
25506 |
|
25507 | if (this.options.rtl) {
|
25508 | this.dom.content.style.marginRight = "".concat(this.props.dot.width / 2, "px");
|
25509 | } else {
|
25510 | this.dom.content.style.marginLeft = "".concat(this.props.dot.width / 2, "px");
|
25511 | }
|
25512 |
|
25513 |
|
25514 |
|
25515 | this.width = sizes.point.width;
|
25516 | this.height = sizes.point.height;
|
25517 |
|
25518 | this.dom.dot.style.top = "".concat((this.height - this.props.dot.height) / 2, "px");
|
25519 | var dotWidth = this.props.dot.width;
|
25520 | var translateX = this.options.rtl ? dotWidth / 2 : dotWidth / 2 * -1;
|
25521 | this.dom.dot.style.transform = "translateX(".concat(translateX, "px");
|
25522 | this.dirty = false;
|
25523 | }
|
25524 | |
25525 |
|
25526 |
|
25527 |
|
25528 |
|
25529 | }, {
|
25530 | key: "_repaintDomAdditionals",
|
25531 | value: function _repaintDomAdditionals() {
|
25532 | this._repaintOnItemUpdateTimeTooltip(this.dom.point);
|
25533 |
|
25534 | this._repaintDragCenter();
|
25535 |
|
25536 | this._repaintDeleteButton(this.dom.point);
|
25537 | }
|
25538 | |
25539 |
|
25540 |
|
25541 |
|
25542 |
|
25543 |
|
25544 | }, {
|
25545 | key: "redraw",
|
25546 | value: function redraw(returnQueue) {
|
25547 | var _context,
|
25548 | _context2,
|
25549 | _context3,
|
25550 | _this2 = this,
|
25551 | _context5;
|
25552 |
|
25553 | var sizes;
|
25554 | var queue = [
|
25555 | _bindInstanceProperty(_context = this._createDomElement).call(_context, this),
|
25556 | _bindInstanceProperty(_context2 = this._appendDomElement).call(_context2, this),
|
25557 | _bindInstanceProperty(_context3 = this._updateDirtyDomComponents).call(_context3, this), function () {
|
25558 | if (_this2.dirty) {
|
25559 | sizes = _this2._getDomComponentsSizes();
|
25560 | }
|
25561 | }, function () {
|
25562 | if (_this2.dirty) {
|
25563 | var _context4;
|
25564 |
|
25565 | _bindInstanceProperty(_context4 = _this2._updateDomComponentsSizes).call(_context4, _this2)(sizes);
|
25566 | }
|
25567 | },
|
25568 | _bindInstanceProperty(_context5 = this._repaintDomAdditionals).call(_context5, this)];
|
25569 |
|
25570 | if (returnQueue) {
|
25571 | return queue;
|
25572 | } else {
|
25573 | var result;
|
25574 |
|
25575 | _forEachInstanceProperty(queue).call(queue, function (fn) {
|
25576 | result = fn();
|
25577 | });
|
25578 |
|
25579 | return result;
|
25580 | }
|
25581 | }
|
25582 | |
25583 |
|
25584 |
|
25585 |
|
25586 | }, {
|
25587 | key: "repositionXY",
|
25588 | value: function repositionXY() {
|
25589 | var rtl = this.options.rtl;
|
25590 |
|
25591 | var repositionXY = function repositionXY(element, x, y) {
|
25592 | var _context6;
|
25593 |
|
25594 | var rtl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25595 | if (x === undefined && y === undefined) return;
|
25596 |
|
25597 | var directionX = rtl ? x * -1 : x;
|
25598 |
|
25599 | if (y === undefined) {
|
25600 | element.style.transform = "translateX(".concat(directionX, "px)");
|
25601 | return;
|
25602 | }
|
25603 |
|
25604 |
|
25605 | if (x === undefined) {
|
25606 | element.style.transform = "translateY(".concat(y, "px)");
|
25607 | return;
|
25608 | }
|
25609 |
|
25610 | element.style.transform = _concatInstanceProperty(_context6 = "translate(".concat(directionX, "px, ")).call(_context6, y, "px)");
|
25611 | };
|
25612 |
|
25613 | repositionXY(this.dom.point, this.pointX, this.pointY, rtl);
|
25614 | }
|
25615 | |
25616 |
|
25617 |
|
25618 |
|
25619 |
|
25620 |
|
25621 |
|
25622 | }, {
|
25623 | key: "show",
|
25624 | value: function show(returnQueue) {
|
25625 | if (!this.displayed) {
|
25626 | return this.redraw(returnQueue);
|
25627 | }
|
25628 | }
|
25629 | |
25630 |
|
25631 |
|
25632 |
|
25633 | }, {
|
25634 | key: "hide",
|
25635 | value: function hide() {
|
25636 | if (this.displayed) {
|
25637 | if (this.dom.point.parentNode) {
|
25638 | this.dom.point.parentNode.removeChild(this.dom.point);
|
25639 | }
|
25640 |
|
25641 | this.displayed = false;
|
25642 | }
|
25643 | }
|
25644 | |
25645 |
|
25646 |
|
25647 |
|
25648 |
|
25649 | }, {
|
25650 | key: "repositionX",
|
25651 | value: function repositionX() {
|
25652 | var start = this.conversion.toScreen(this.data.start);
|
25653 | this.pointX = start;
|
25654 |
|
25655 | if (this.options.rtl) {
|
25656 | this.right = start - this.props.dot.width;
|
25657 | } else {
|
25658 | this.left = start - this.props.dot.width;
|
25659 | }
|
25660 |
|
25661 | this.repositionXY();
|
25662 | }
|
25663 | |
25664 |
|
25665 |
|
25666 |
|
25667 |
|
25668 | }, {
|
25669 | key: "repositionY",
|
25670 | value: function repositionY() {
|
25671 | var orientation = this.options.orientation.item;
|
25672 |
|
25673 | if (orientation == 'top') {
|
25674 | this.pointY = this.top;
|
25675 | } else {
|
25676 | this.pointY = this.parent.height - this.top - this.height;
|
25677 | }
|
25678 |
|
25679 | this.repositionXY();
|
25680 | }
|
25681 | |
25682 |
|
25683 |
|
25684 |
|
25685 |
|
25686 | }, {
|
25687 | key: "getWidthLeft",
|
25688 | value: function getWidthLeft() {
|
25689 | return this.props.dot.width;
|
25690 | }
|
25691 | |
25692 |
|
25693 |
|
25694 |
|
25695 |
|
25696 | }, {
|
25697 | key: "getWidthRight",
|
25698 | value: function getWidthRight() {
|
25699 | return this.props.dot.width;
|
25700 | }
|
25701 | }]);
|
25702 |
|
25703 | return PointItem;
|
25704 | }(Item);
|
25705 |
|
25706 | function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
25707 |
|
25708 | function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
25709 |
|
25710 |
|
25711 |
|
25712 |
|
25713 |
|
25714 | var RangeItem = function (_Item) {
|
25715 | _inherits(RangeItem, _Item);
|
25716 |
|
25717 | var _super = _createSuper$5(RangeItem);
|
25718 |
|
25719 | |
25720 |
|
25721 |
|
25722 |
|
25723 |
|
25724 |
|
25725 |
|
25726 |
|
25727 | function RangeItem(data, conversion, options) {
|
25728 | var _this;
|
25729 |
|
25730 | _classCallCheck(this, RangeItem);
|
25731 |
|
25732 | _this = _super.call(this, data, conversion, options);
|
25733 | _this.props = {
|
25734 | content: {
|
25735 | width: 0
|
25736 | }
|
25737 | };
|
25738 | _this.overflow = false;
|
25739 |
|
25740 |
|
25741 | if (data) {
|
25742 | if (data.start == undefined) {
|
25743 | throw new Error("Property \"start\" missing in item ".concat(data.id));
|
25744 | }
|
25745 |
|
25746 | if (data.end == undefined) {
|
25747 | throw new Error("Property \"end\" missing in item ".concat(data.id));
|
25748 | }
|
25749 | }
|
25750 |
|
25751 | return _this;
|
25752 | }
|
25753 | |
25754 |
|
25755 |
|
25756 |
|
25757 |
|
25758 |
|
25759 |
|
25760 |
|
25761 | _createClass(RangeItem, [{
|
25762 | key: "isVisible",
|
25763 | value: function isVisible(range) {
|
25764 | if (this.cluster) {
|
25765 | return false;
|
25766 | }
|
25767 |
|
25768 |
|
25769 | return this.data.start < range.end && this.data.end > range.start;
|
25770 | }
|
25771 | |
25772 |
|
25773 |
|
25774 |
|
25775 |
|
25776 | }, {
|
25777 | key: "_createDomElement",
|
25778 | value: function _createDomElement() {
|
25779 | if (!this.dom) {
|
25780 |
|
25781 | this.dom = {};
|
25782 |
|
25783 | this.dom.box = document.createElement('div');
|
25784 |
|
25785 |
|
25786 | this.dom.frame = document.createElement('div');
|
25787 | this.dom.frame.className = 'vis-item-overflow';
|
25788 | this.dom.box.appendChild(this.dom.frame);
|
25789 |
|
25790 | this.dom.visibleFrame = document.createElement('div');
|
25791 | this.dom.visibleFrame.className = 'vis-item-visible-frame';
|
25792 | this.dom.box.appendChild(this.dom.visibleFrame);
|
25793 |
|
25794 | this.dom.content = document.createElement('div');
|
25795 | this.dom.content.className = 'vis-item-content';
|
25796 | this.dom.frame.appendChild(this.dom.content);
|
25797 |
|
25798 | this.dom.box['vis-item'] = this;
|
25799 | this.dirty = true;
|
25800 | }
|
25801 | }
|
25802 | |
25803 |
|
25804 |
|
25805 |
|
25806 |
|
25807 | }, {
|
25808 | key: "_appendDomElement",
|
25809 | value: function _appendDomElement() {
|
25810 | if (!this.parent) {
|
25811 | throw new Error('Cannot redraw item: no parent attached');
|
25812 | }
|
25813 |
|
25814 | if (!this.dom.box.parentNode) {
|
25815 | var foreground = this.parent.dom.foreground;
|
25816 |
|
25817 | if (!foreground) {
|
25818 | throw new Error('Cannot redraw item: parent has no foreground container element');
|
25819 | }
|
25820 |
|
25821 | foreground.appendChild(this.dom.box);
|
25822 | }
|
25823 |
|
25824 | this.displayed = true;
|
25825 | }
|
25826 | |
25827 |
|
25828 |
|
25829 |
|
25830 |
|
25831 | }, {
|
25832 | key: "_updateDirtyDomComponents",
|
25833 | value: function _updateDirtyDomComponents() {
|
25834 |
|
25835 |
|
25836 |
|
25837 |
|
25838 | if (this.dirty) {
|
25839 | this._updateContents(this.dom.content);
|
25840 |
|
25841 | this._updateDataAttributes(this.dom.box);
|
25842 |
|
25843 | this._updateStyle(this.dom.box);
|
25844 |
|
25845 | var editable = this.editable.updateTime || this.editable.updateGroup;
|
25846 |
|
25847 | var className = (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '') + (editable ? ' vis-editable' : ' vis-readonly');
|
25848 | this.dom.box.className = this.baseClassName + className;
|
25849 |
|
25850 |
|
25851 | this.dom.content.style.maxWidth = 'none';
|
25852 | }
|
25853 | }
|
25854 | |
25855 |
|
25856 |
|
25857 |
|
25858 |
|
25859 |
|
25860 | }, {
|
25861 | key: "_getDomComponentsSizes",
|
25862 | value: function _getDomComponentsSizes() {
|
25863 |
|
25864 | this.overflow = window.getComputedStyle(this.dom.frame).overflow !== 'hidden';
|
25865 | this.whiteSpace = window.getComputedStyle(this.dom.content).whiteSpace !== 'nowrap';
|
25866 | return {
|
25867 | content: {
|
25868 | width: this.dom.content.offsetWidth
|
25869 | },
|
25870 | box: {
|
25871 | height: this.dom.box.offsetHeight
|
25872 | }
|
25873 | };
|
25874 | }
|
25875 | |
25876 |
|
25877 |
|
25878 |
|
25879 |
|
25880 |
|
25881 | }, {
|
25882 | key: "_updateDomComponentsSizes",
|
25883 | value: function _updateDomComponentsSizes(sizes) {
|
25884 | this.props.content.width = sizes.content.width;
|
25885 | this.height = sizes.box.height;
|
25886 | this.dom.content.style.maxWidth = '';
|
25887 | this.dirty = false;
|
25888 | }
|
25889 | |
25890 |
|
25891 |
|
25892 |
|
25893 |
|
25894 | }, {
|
25895 | key: "_repaintDomAdditionals",
|
25896 | value: function _repaintDomAdditionals() {
|
25897 | this._repaintOnItemUpdateTimeTooltip(this.dom.box);
|
25898 |
|
25899 | this._repaintDeleteButton(this.dom.box);
|
25900 |
|
25901 | this._repaintDragCenter();
|
25902 |
|
25903 | this._repaintDragLeft();
|
25904 |
|
25905 | this._repaintDragRight();
|
25906 | }
|
25907 | |
25908 |
|
25909 |
|
25910 |
|
25911 |
|
25912 |
|
25913 | }, {
|
25914 | key: "redraw",
|
25915 | value: function redraw(returnQueue) {
|
25916 | var _context,
|
25917 | _context2,
|
25918 | _context3,
|
25919 | _this2 = this,
|
25920 | _context6;
|
25921 |
|
25922 | var sizes;
|
25923 | var queue = [
|
25924 | _bindInstanceProperty(_context = this._createDomElement).call(_context, this),
|
25925 | _bindInstanceProperty(_context2 = this._appendDomElement).call(_context2, this),
|
25926 | _bindInstanceProperty(_context3 = this._updateDirtyDomComponents).call(_context3, this), function () {
|
25927 | if (_this2.dirty) {
|
25928 | var _context4;
|
25929 |
|
25930 | sizes = _bindInstanceProperty(_context4 = _this2._getDomComponentsSizes).call(_context4, _this2)();
|
25931 | }
|
25932 | }, function () {
|
25933 | if (_this2.dirty) {
|
25934 | var _context5;
|
25935 |
|
25936 | _bindInstanceProperty(_context5 = _this2._updateDomComponentsSizes).call(_context5, _this2)(sizes);
|
25937 | }
|
25938 | },
|
25939 | _bindInstanceProperty(_context6 = this._repaintDomAdditionals).call(_context6, this)];
|
25940 |
|
25941 | if (returnQueue) {
|
25942 | return queue;
|
25943 | } else {
|
25944 | var result;
|
25945 |
|
25946 | _forEachInstanceProperty(queue).call(queue, function (fn) {
|
25947 | result = fn();
|
25948 | });
|
25949 |
|
25950 | return result;
|
25951 | }
|
25952 | }
|
25953 | |
25954 |
|
25955 |
|
25956 |
|
25957 |
|
25958 |
|
25959 |
|
25960 | }, {
|
25961 | key: "show",
|
25962 | value: function show(returnQueue) {
|
25963 | if (!this.displayed) {
|
25964 | return this.redraw(returnQueue);
|
25965 | }
|
25966 | }
|
25967 | |
25968 |
|
25969 |
|
25970 |
|
25971 | }, {
|
25972 | key: "hide",
|
25973 | value: function hide() {
|
25974 | if (this.displayed) {
|
25975 | var box = this.dom.box;
|
25976 |
|
25977 | if (box.parentNode) {
|
25978 | box.parentNode.removeChild(box);
|
25979 | }
|
25980 |
|
25981 | this.displayed = false;
|
25982 | }
|
25983 | }
|
25984 | |
25985 |
|
25986 |
|
25987 |
|
25988 |
|
25989 |
|
25990 |
|
25991 |
|
25992 |
|
25993 |
|
25994 | }, {
|
25995 | key: "repositionX",
|
25996 | value: function repositionX(limitSize) {
|
25997 | var parentWidth = this.parent.width;
|
25998 | var start = this.conversion.toScreen(this.data.start);
|
25999 | var end = this.conversion.toScreen(this.data.end);
|
26000 | var align = this.data.align === undefined ? this.options.align : this.data.align;
|
26001 | var contentStartPosition;
|
26002 | var contentWidth;
|
26003 |
|
26004 |
|
26005 | if (this.data.limitSize !== false && (limitSize === undefined || limitSize === true)) {
|
26006 | if (start < -parentWidth) {
|
26007 | start = -parentWidth;
|
26008 | }
|
26009 |
|
26010 | if (end > 2 * parentWidth) {
|
26011 | end = 2 * parentWidth;
|
26012 | }
|
26013 | }
|
26014 |
|
26015 |
|
26016 | var boxWidth = Math.max(Math.round((end - start) * 1000) / 1000, 1);
|
26017 |
|
26018 | if (this.overflow) {
|
26019 | if (this.options.rtl) {
|
26020 | this.right = start;
|
26021 | } else {
|
26022 | this.left = start;
|
26023 | }
|
26024 |
|
26025 | this.width = boxWidth + this.props.content.width;
|
26026 | contentWidth = this.props.content.width;
|
26027 |
|
26028 |
|
26029 | } else {
|
26030 | if (this.options.rtl) {
|
26031 | this.right = start;
|
26032 | } else {
|
26033 | this.left = start;
|
26034 | }
|
26035 |
|
26036 | this.width = boxWidth;
|
26037 | contentWidth = Math.min(end - start, this.props.content.width);
|
26038 | }
|
26039 |
|
26040 | if (this.options.rtl) {
|
26041 | this.dom.box.style.transform = "translateX(".concat(this.right * -1, "px)");
|
26042 | } else {
|
26043 | this.dom.box.style.transform = "translateX(".concat(this.left, "px)");
|
26044 | }
|
26045 |
|
26046 | this.dom.box.style.width = "".concat(boxWidth, "px");
|
26047 |
|
26048 | if (this.whiteSpace) {
|
26049 | this.height = this.dom.box.offsetHeight;
|
26050 | }
|
26051 |
|
26052 | switch (align) {
|
26053 | case 'left':
|
26054 | this.dom.content.style.transform = 'translateX(0)';
|
26055 | break;
|
26056 |
|
26057 | case 'right':
|
26058 | if (this.options.rtl) {
|
26059 | var translateX = Math.max(boxWidth - contentWidth, 0) * -1;
|
26060 | this.dom.content.style.transform = "translateX(".concat(translateX, "px)");
|
26061 | } else {
|
26062 | this.dom.content.style.transform = "translateX(".concat(Math.max(boxWidth - contentWidth, 0), "px)");
|
26063 | }
|
26064 |
|
26065 | break;
|
26066 |
|
26067 | case 'center':
|
26068 | if (this.options.rtl) {
|
26069 | var _translateX = Math.max((boxWidth - contentWidth) / 2, 0) * -1;
|
26070 |
|
26071 | this.dom.content.style.transform = "translateX(".concat(_translateX, "px)");
|
26072 | } else {
|
26073 | this.dom.content.style.transform = "translateX(".concat(Math.max((boxWidth - contentWidth) / 2, 0), "px)");
|
26074 | }
|
26075 |
|
26076 | break;
|
26077 |
|
26078 | default:
|
26079 |
|
26080 |
|
26081 | if (this.overflow) {
|
26082 | if (end > 0) {
|
26083 | contentStartPosition = Math.max(-start, 0);
|
26084 | } else {
|
26085 | contentStartPosition = -contentWidth;
|
26086 | }
|
26087 | } else {
|
26088 | if (start < 0) {
|
26089 | contentStartPosition = -start;
|
26090 | } else {
|
26091 | contentStartPosition = 0;
|
26092 | }
|
26093 | }
|
26094 |
|
26095 | if (this.options.rtl) {
|
26096 | var _translateX2 = contentStartPosition * -1;
|
26097 |
|
26098 | this.dom.content.style.transform = "translateX(".concat(_translateX2, "px)");
|
26099 | } else {
|
26100 | this.dom.content.style.transform = "translateX(".concat(contentStartPosition, "px)");
|
26101 | }
|
26102 |
|
26103 | }
|
26104 | }
|
26105 | |
26106 |
|
26107 |
|
26108 |
|
26109 |
|
26110 | }, {
|
26111 | key: "repositionY",
|
26112 | value: function repositionY() {
|
26113 | var orientation = this.options.orientation.item;
|
26114 | var box = this.dom.box;
|
26115 |
|
26116 | if (orientation == 'top') {
|
26117 | box.style.top = "".concat(this.top, "px");
|
26118 | } else {
|
26119 | box.style.top = "".concat(this.parent.height - this.top - this.height, "px");
|
26120 | }
|
26121 | }
|
26122 | |
26123 |
|
26124 |
|
26125 |
|
26126 |
|
26127 | }, {
|
26128 | key: "_repaintDragLeft",
|
26129 | value: function _repaintDragLeft() {
|
26130 | if ((this.selected || this.options.itemsAlwaysDraggable.range) && this.editable.updateTime && !this.dom.dragLeft) {
|
26131 |
|
26132 | var dragLeft = document.createElement('div');
|
26133 | dragLeft.className = 'vis-drag-left';
|
26134 | dragLeft.dragLeftItem = this;
|
26135 | this.dom.box.appendChild(dragLeft);
|
26136 | this.dom.dragLeft = dragLeft;
|
26137 | } else if (!this.selected && !this.options.itemsAlwaysDraggable.range && this.dom.dragLeft) {
|
26138 |
|
26139 | if (this.dom.dragLeft.parentNode) {
|
26140 | this.dom.dragLeft.parentNode.removeChild(this.dom.dragLeft);
|
26141 | }
|
26142 |
|
26143 | this.dom.dragLeft = null;
|
26144 | }
|
26145 | }
|
26146 | |
26147 |
|
26148 |
|
26149 |
|
26150 |
|
26151 | }, {
|
26152 | key: "_repaintDragRight",
|
26153 | value: function _repaintDragRight() {
|
26154 | if ((this.selected || this.options.itemsAlwaysDraggable.range) && this.editable.updateTime && !this.dom.dragRight) {
|
26155 |
|
26156 | var dragRight = document.createElement('div');
|
26157 | dragRight.className = 'vis-drag-right';
|
26158 | dragRight.dragRightItem = this;
|
26159 | this.dom.box.appendChild(dragRight);
|
26160 | this.dom.dragRight = dragRight;
|
26161 | } else if (!this.selected && !this.options.itemsAlwaysDraggable.range && this.dom.dragRight) {
|
26162 |
|
26163 | if (this.dom.dragRight.parentNode) {
|
26164 | this.dom.dragRight.parentNode.removeChild(this.dom.dragRight);
|
26165 | }
|
26166 |
|
26167 | this.dom.dragRight = null;
|
26168 | }
|
26169 | }
|
26170 | }]);
|
26171 |
|
26172 | return RangeItem;
|
26173 | }(Item);
|
26174 |
|
26175 | RangeItem.prototype.baseClassName = 'vis-item vis-range';
|
26176 |
|
26177 | function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
26178 |
|
26179 | function _isNativeReflectConstruct$4() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
26180 |
|
26181 |
|
26182 |
|
26183 |
|
26184 |
|
26185 | var BackgroundItem = function (_Item) {
|
26186 | _inherits(BackgroundItem, _Item);
|
26187 |
|
26188 | var _super = _createSuper$4(BackgroundItem);
|
26189 |
|
26190 | |
26191 |
|
26192 |
|
26193 |
|
26194 |
|
26195 |
|
26196 |
|
26197 |
|
26198 |
|
26199 |
|
26200 | function BackgroundItem(data, conversion, options) {
|
26201 | var _this;
|
26202 |
|
26203 | _classCallCheck(this, BackgroundItem);
|
26204 |
|
26205 | _this = _super.call(this, data, conversion, options);
|
26206 | _this.props = {
|
26207 | content: {
|
26208 | width: 0
|
26209 | }
|
26210 | };
|
26211 | _this.overflow = false;
|
26212 |
|
26213 |
|
26214 | if (data) {
|
26215 | if (data.start == undefined) {
|
26216 | throw new Error("Property \"start\" missing in item ".concat(data.id));
|
26217 | }
|
26218 |
|
26219 | if (data.end == undefined) {
|
26220 | throw new Error("Property \"end\" missing in item ".concat(data.id));
|
26221 | }
|
26222 | }
|
26223 |
|
26224 | return _this;
|
26225 | }
|
26226 | |
26227 |
|
26228 |
|
26229 |
|
26230 |
|
26231 |
|
26232 |
|
26233 | _createClass(BackgroundItem, [{
|
26234 | key: "isVisible",
|
26235 | value: function isVisible(range) {
|
26236 |
|
26237 | return this.data.start < range.end && this.data.end > range.start;
|
26238 | }
|
26239 | |
26240 |
|
26241 |
|
26242 |
|
26243 |
|
26244 | }, {
|
26245 | key: "_createDomElement",
|
26246 | value: function _createDomElement() {
|
26247 | if (!this.dom) {
|
26248 |
|
26249 | this.dom = {};
|
26250 |
|
26251 | this.dom.box = document.createElement('div');
|
26252 |
|
26253 |
|
26254 | this.dom.frame = document.createElement('div');
|
26255 | this.dom.frame.className = 'vis-item-overflow';
|
26256 | this.dom.box.appendChild(this.dom.frame);
|
26257 |
|
26258 | this.dom.content = document.createElement('div');
|
26259 | this.dom.content.className = 'vis-item-content';
|
26260 | this.dom.frame.appendChild(this.dom.content);
|
26261 |
|
26262 |
|
26263 |
|
26264 | this.dirty = true;
|
26265 | }
|
26266 | }
|
26267 | |
26268 |
|
26269 |
|
26270 |
|
26271 |
|
26272 | }, {
|
26273 | key: "_appendDomElement",
|
26274 | value: function _appendDomElement() {
|
26275 | if (!this.parent) {
|
26276 | throw new Error('Cannot redraw item: no parent attached');
|
26277 | }
|
26278 |
|
26279 | if (!this.dom.box.parentNode) {
|
26280 | var background = this.parent.dom.background;
|
26281 |
|
26282 | if (!background) {
|
26283 | throw new Error('Cannot redraw item: parent has no background container element');
|
26284 | }
|
26285 |
|
26286 | background.appendChild(this.dom.box);
|
26287 | }
|
26288 |
|
26289 | this.displayed = true;
|
26290 | }
|
26291 | |
26292 |
|
26293 |
|
26294 |
|
26295 |
|
26296 | }, {
|
26297 | key: "_updateDirtyDomComponents",
|
26298 | value: function _updateDirtyDomComponents() {
|
26299 |
|
26300 |
|
26301 |
|
26302 |
|
26303 | if (this.dirty) {
|
26304 | this._updateContents(this.dom.content);
|
26305 |
|
26306 | this._updateDataAttributes(this.dom.content);
|
26307 |
|
26308 | this._updateStyle(this.dom.box);
|
26309 |
|
26310 |
|
26311 | var className = (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '');
|
26312 | this.dom.box.className = this.baseClassName + className;
|
26313 | }
|
26314 | }
|
26315 | |
26316 |
|
26317 |
|
26318 |
|
26319 |
|
26320 |
|
26321 | }, {
|
26322 | key: "_getDomComponentsSizes",
|
26323 | value: function _getDomComponentsSizes() {
|
26324 |
|
26325 | this.overflow = window.getComputedStyle(this.dom.content).overflow !== 'hidden';
|
26326 | return {
|
26327 | content: {
|
26328 | width: this.dom.content.offsetWidth
|
26329 | }
|
26330 | };
|
26331 | }
|
26332 | |
26333 |
|
26334 |
|
26335 |
|
26336 |
|
26337 |
|
26338 | }, {
|
26339 | key: "_updateDomComponentsSizes",
|
26340 | value: function _updateDomComponentsSizes(sizes) {
|
26341 |
|
26342 | this.props.content.width = sizes.content.width;
|
26343 | this.height = 0;
|
26344 |
|
26345 | this.dirty = false;
|
26346 | }
|
26347 | |
26348 |
|
26349 |
|
26350 |
|
26351 |
|
26352 | }, {
|
26353 | key: "_repaintDomAdditionals",
|
26354 | value: function _repaintDomAdditionals() {}
|
26355 | |
26356 |
|
26357 |
|
26358 |
|
26359 |
|
26360 |
|
26361 | }, {
|
26362 | key: "redraw",
|
26363 | value: function redraw(returnQueue) {
|
26364 | var _context,
|
26365 | _context2,
|
26366 | _context3,
|
26367 | _this2 = this,
|
26368 | _context6;
|
26369 |
|
26370 | var sizes;
|
26371 | var queue = [
|
26372 | _bindInstanceProperty(_context = this._createDomElement).call(_context, this),
|
26373 | _bindInstanceProperty(_context2 = this._appendDomElement).call(_context2, this), _bindInstanceProperty(_context3 = this._updateDirtyDomComponents).call(_context3, this), function () {
|
26374 | if (_this2.dirty) {
|
26375 | var _context4;
|
26376 |
|
26377 | sizes = _bindInstanceProperty(_context4 = _this2._getDomComponentsSizes).call(_context4, _this2)();
|
26378 | }
|
26379 | }, function () {
|
26380 | if (_this2.dirty) {
|
26381 | var _context5;
|
26382 |
|
26383 | _bindInstanceProperty(_context5 = _this2._updateDomComponentsSizes).call(_context5, _this2)(sizes);
|
26384 | }
|
26385 | },
|
26386 | _bindInstanceProperty(_context6 = this._repaintDomAdditionals).call(_context6, this)];
|
26387 |
|
26388 | if (returnQueue) {
|
26389 | return queue;
|
26390 | } else {
|
26391 | var result;
|
26392 |
|
26393 | _forEachInstanceProperty(queue).call(queue, function (fn) {
|
26394 | result = fn();
|
26395 | });
|
26396 |
|
26397 | return result;
|
26398 | }
|
26399 | }
|
26400 | |
26401 |
|
26402 |
|
26403 |
|
26404 |
|
26405 | }, {
|
26406 | key: "repositionY",
|
26407 | value: function repositionY(margin) {
|
26408 |
|
26409 | var height;
|
26410 | var orientation = this.options.orientation.item;
|
26411 |
|
26412 | if (this.data.subgroup !== undefined) {
|
26413 |
|
26414 | var itemSubgroup = this.data.subgroup;
|
26415 | this.dom.box.style.height = "".concat(this.parent.subgroups[itemSubgroup].height, "px");
|
26416 |
|
26417 | if (orientation == 'top') {
|
26418 | this.dom.box.style.top = "".concat(this.parent.top + this.parent.subgroups[itemSubgroup].top, "px");
|
26419 | } else {
|
26420 | this.dom.box.style.top = "".concat(this.parent.top + this.parent.height - this.parent.subgroups[itemSubgroup].top - this.parent.subgroups[itemSubgroup].height, "px");
|
26421 | }
|
26422 |
|
26423 | this.dom.box.style.bottom = '';
|
26424 | }
|
26425 | else {
|
26426 |
|
26427 | if (this.parent instanceof BackgroundGroup) {
|
26428 |
|
26429 | height = Math.max(this.parent.height, this.parent.itemSet.body.domProps.center.height, this.parent.itemSet.body.domProps.centerContainer.height);
|
26430 | this.dom.box.style.bottom = orientation == 'bottom' ? '0' : '';
|
26431 | this.dom.box.style.top = orientation == 'top' ? '0' : '';
|
26432 | } else {
|
26433 | height = this.parent.height;
|
26434 |
|
26435 | this.dom.box.style.top = "".concat(this.parent.top, "px");
|
26436 | this.dom.box.style.bottom = '';
|
26437 | }
|
26438 | }
|
26439 |
|
26440 | this.dom.box.style.height = "".concat(height, "px");
|
26441 | }
|
26442 | }]);
|
26443 |
|
26444 | return BackgroundItem;
|
26445 | }(Item);
|
26446 |
|
26447 | BackgroundItem.prototype.baseClassName = 'vis-item vis-background';
|
26448 | BackgroundItem.prototype.stack = false;
|
26449 |
|
26450 |
|
26451 |
|
26452 |
|
26453 |
|
26454 | BackgroundItem.prototype.show = RangeItem.prototype.show;
|
26455 |
|
26456 |
|
26457 |
|
26458 |
|
26459 |
|
26460 | BackgroundItem.prototype.hide = RangeItem.prototype.hide;
|
26461 |
|
26462 |
|
26463 |
|
26464 |
|
26465 |
|
26466 | BackgroundItem.prototype.repositionX = RangeItem.prototype.repositionX;
|
26467 |
|
26468 |
|
26469 |
|
26470 |
|
26471 |
|
26472 | var Popup = function () {
|
26473 | |
26474 |
|
26475 |
|
26476 |
|
26477 | function Popup(container, overflowMethod) {
|
26478 | _classCallCheck(this, Popup);
|
26479 |
|
26480 | this.container = container;
|
26481 | this.overflowMethod = overflowMethod || 'cap';
|
26482 | this.x = 0;
|
26483 | this.y = 0;
|
26484 | this.padding = 5;
|
26485 | this.hidden = false;
|
26486 |
|
26487 | this.frame = document.createElement('div');
|
26488 | this.frame.className = 'vis-tooltip';
|
26489 | this.container.appendChild(this.frame);
|
26490 | }
|
26491 | |
26492 |
|
26493 |
|
26494 |
|
26495 |
|
26496 |
|
26497 | _createClass(Popup, [{
|
26498 | key: "setPosition",
|
26499 | value: function setPosition(x, y) {
|
26500 | this.x = _parseInt(x);
|
26501 | this.y = _parseInt(y);
|
26502 | }
|
26503 | |
26504 |
|
26505 |
|
26506 |
|
26507 |
|
26508 | }, {
|
26509 | key: "setText",
|
26510 | value: function setText(content) {
|
26511 | if (content instanceof Element) {
|
26512 | this.frame.innerHTML = '';
|
26513 | this.frame.appendChild(content);
|
26514 | } else {
|
26515 | this.frame.innerHTML = availableUtils.xss(content);
|
26516 | }
|
26517 | }
|
26518 | |
26519 |
|
26520 |
|
26521 |
|
26522 |
|
26523 | }, {
|
26524 | key: "show",
|
26525 | value: function show(doShow) {
|
26526 | if (doShow === undefined) {
|
26527 | doShow = true;
|
26528 | }
|
26529 |
|
26530 | if (doShow === true) {
|
26531 | var height = this.frame.clientHeight;
|
26532 | var width = this.frame.clientWidth;
|
26533 | var maxHeight = this.frame.parentNode.clientHeight;
|
26534 | var maxWidth = this.frame.parentNode.clientWidth;
|
26535 | var left = 0,
|
26536 | top = 0;
|
26537 |
|
26538 | if (this.overflowMethod == 'flip' || this.overflowMethod == 'none') {
|
26539 | var isLeft = false,
|
26540 | isTop = true;
|
26541 |
|
26542 | if (this.overflowMethod == 'flip') {
|
26543 | if (this.y - height < this.padding) {
|
26544 | isTop = false;
|
26545 | }
|
26546 |
|
26547 | if (this.x + width > maxWidth - this.padding) {
|
26548 | isLeft = true;
|
26549 | }
|
26550 | }
|
26551 |
|
26552 | if (isLeft) {
|
26553 | left = this.x - width;
|
26554 | } else {
|
26555 | left = this.x;
|
26556 | }
|
26557 |
|
26558 | if (isTop) {
|
26559 | top = this.y - height;
|
26560 | } else {
|
26561 | top = this.y;
|
26562 | }
|
26563 | } else {
|
26564 |
|
26565 | top = this.y - height;
|
26566 |
|
26567 | if (top + height + this.padding > maxHeight) {
|
26568 | top = maxHeight - height - this.padding;
|
26569 | }
|
26570 |
|
26571 | if (top < this.padding) {
|
26572 | top = this.padding;
|
26573 | }
|
26574 |
|
26575 | left = this.x;
|
26576 |
|
26577 | if (left + width + this.padding > maxWidth) {
|
26578 | left = maxWidth - width - this.padding;
|
26579 | }
|
26580 |
|
26581 | if (left < this.padding) {
|
26582 | left = this.padding;
|
26583 | }
|
26584 | }
|
26585 |
|
26586 | this.frame.style.left = left + "px";
|
26587 | this.frame.style.top = top + "px";
|
26588 | this.frame.style.visibility = "visible";
|
26589 | this.hidden = false;
|
26590 | } else {
|
26591 | this.hide();
|
26592 | }
|
26593 | }
|
26594 | |
26595 |
|
26596 |
|
26597 |
|
26598 | }, {
|
26599 | key: "hide",
|
26600 | value: function hide() {
|
26601 | this.hidden = true;
|
26602 | this.frame.style.left = "0";
|
26603 | this.frame.style.top = "0";
|
26604 | this.frame.style.visibility = "hidden";
|
26605 | }
|
26606 | |
26607 |
|
26608 |
|
26609 |
|
26610 | }, {
|
26611 | key: "destroy",
|
26612 | value: function destroy() {
|
26613 | this.frame.parentNode.removeChild(this.frame);
|
26614 | }
|
26615 | }]);
|
26616 |
|
26617 | return Popup;
|
26618 | }();
|
26619 |
|
26620 | var every$3 = {exports: {}};
|
26621 |
|
26622 | var $ = _export;
|
26623 | var $every = arrayIteration.every;
|
26624 | var arrayMethodIsStrict = arrayMethodIsStrict$6;
|
26625 | var STRICT_METHOD = arrayMethodIsStrict('every');
|
26626 |
|
26627 |
|
26628 | $({
|
26629 | target: 'Array',
|
26630 | proto: true,
|
26631 | forced: !STRICT_METHOD
|
26632 | }, {
|
26633 | every: function every(callbackfn
|
26634 | /* , thisArg */
|
26635 | ) {
|
26636 | return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
26637 | }
|
26638 | });
|
26639 |
|
26640 | var entryVirtual = entryVirtual$k;
|
26641 | var every$2 = entryVirtual('Array').every;
|
26642 |
|
26643 | var isPrototypeOf = objectIsPrototypeOf;
|
26644 | var method = every$2;
|
26645 | var ArrayPrototype = Array.prototype;
|
26646 |
|
26647 | var every$1 = function (it) {
|
26648 | var own = it.every;
|
26649 | return it === ArrayPrototype || isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every ? method : own;
|
26650 | };
|
26651 |
|
26652 | var parent = every$1;
|
26653 | var every = parent;
|
26654 |
|
26655 | (function (module) {
|
26656 | module.exports = every;
|
26657 | })(every$3);
|
26658 |
|
26659 | var _everyInstanceProperty = getDefaultExportFromCjs(every$3.exports);
|
26660 |
|
26661 | function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
26662 |
|
26663 | function _unsupportedIterableToArray$3(o, minLen) { var _context14; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = _sliceInstanceProperty(_context14 = Object.prototype.toString.call(o)).call(_context14, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
26664 |
|
26665 | function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
26666 |
|
26667 | function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
26668 |
|
26669 | function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
26670 |
|
26671 |
|
26672 |
|
26673 |
|
26674 | var ClusterItem = function (_Item) {
|
26675 | _inherits(ClusterItem, _Item);
|
26676 |
|
26677 | var _super = _createSuper$3(ClusterItem);
|
26678 |
|
26679 | |
26680 |
|
26681 |
|
26682 |
|
26683 |
|
26684 |
|
26685 |
|
26686 |
|
26687 |
|
26688 | function ClusterItem(data, conversion, options) {
|
26689 | var _this;
|
26690 |
|
26691 | _classCallCheck(this, ClusterItem);
|
26692 |
|
26693 | var modifiedOptions = _Object$assign({}, {
|
26694 | fitOnDoubleClick: true
|
26695 | }, options, {
|
26696 | editable: false
|
26697 | });
|
26698 |
|
26699 | _this = _super.call(this, data, conversion, modifiedOptions);
|
26700 | _this.props = {
|
26701 | content: {
|
26702 | width: 0,
|
26703 | height: 0
|
26704 | }
|
26705 | };
|
26706 |
|
26707 | if (!data || data.uiItems == undefined) {
|
26708 | throw new Error('Property "uiItems" missing in item ' + data.id);
|
26709 | }
|
26710 |
|
26711 | _this.id = v4();
|
26712 | _this.group = data.group;
|
26713 |
|
26714 | _this._setupRange();
|
26715 |
|
26716 | _this.emitter = _this.data.eventEmitter;
|
26717 | _this.range = _this.data.range;
|
26718 | _this.attached = false;
|
26719 | _this.isCluster = true;
|
26720 | _this.data.isCluster = true;
|
26721 | return _this;
|
26722 | }
|
26723 | |
26724 |
|
26725 |
|
26726 |
|
26727 |
|
26728 |
|
26729 | _createClass(ClusterItem, [{
|
26730 | key: "hasItems",
|
26731 | value: function hasItems() {
|
26732 | return this.data.uiItems && this.data.uiItems.length && this.attached;
|
26733 | }
|
26734 | |
26735 |
|
26736 |
|
26737 |
|
26738 |
|
26739 | }, {
|
26740 | key: "setUiItems",
|
26741 | value: function setUiItems(items) {
|
26742 | this.detach();
|
26743 | this.data.uiItems = items;
|
26744 |
|
26745 | this._setupRange();
|
26746 |
|
26747 | this.attach();
|
26748 | }
|
26749 | |
26750 |
|
26751 |
|
26752 |
|
26753 |
|
26754 |
|
26755 | }, {
|
26756 | key: "isVisible",
|
26757 | value: function isVisible(range) {
|
26758 | var rangeWidth = this.data.end ? this.data.end - this.data.start : 0;
|
26759 | var widthInMs = this.width * range.getMillisecondsPerPixel();
|
26760 | var end = Math.max(this.data.start.getTime() + rangeWidth, this.data.start.getTime() + widthInMs);
|
26761 | return this.data.start < range.end && end > range.start && this.hasItems();
|
26762 | }
|
26763 | |
26764 |
|
26765 |
|
26766 |
|
26767 |
|
26768 | }, {
|
26769 | key: "getData",
|
26770 | value: function getData() {
|
26771 | return {
|
26772 | isCluster: true,
|
26773 | id: this.id,
|
26774 | items: this.data.items || [],
|
26775 | data: this.data
|
26776 | };
|
26777 | }
|
26778 | |
26779 |
|
26780 |
|
26781 |
|
26782 |
|
26783 |
|
26784 | }, {
|
26785 | key: "redraw",
|
26786 | value: function redraw(returnQueue) {
|
26787 | var _context, _context2, _context3, _context4, _context5, _context7;
|
26788 |
|
26789 | var sizes;
|
26790 | var queue = [
|
26791 | _bindInstanceProperty(_context = this._createDomElement).call(_context, this),
|
26792 | _bindInstanceProperty(_context2 = this._appendDomElement).call(_context2, this),
|
26793 | _bindInstanceProperty(_context3 = this._updateDirtyDomComponents).call(_context3, this), _bindInstanceProperty(_context4 = function _context4() {
|
26794 | if (this.dirty) {
|
26795 | sizes = this._getDomComponentsSizes();
|
26796 | }
|
26797 | }).call(_context4, this), _bindInstanceProperty(_context5 = function _context5() {
|
26798 | if (this.dirty) {
|
26799 | var _context6;
|
26800 |
|
26801 | _bindInstanceProperty(_context6 = this._updateDomComponentsSizes).call(_context6, this)(sizes);
|
26802 | }
|
26803 | }).call(_context5, this),
|
26804 | _bindInstanceProperty(_context7 = this._repaintDomAdditionals).call(_context7, this)];
|
26805 |
|
26806 | if (returnQueue) {
|
26807 | return queue;
|
26808 | } else {
|
26809 | var result;
|
26810 |
|
26811 | _forEachInstanceProperty(queue).call(queue, function (fn) {
|
26812 | result = fn();
|
26813 | });
|
26814 |
|
26815 | return result;
|
26816 | }
|
26817 | }
|
26818 | |
26819 |
|
26820 |
|
26821 |
|
26822 | }, {
|
26823 | key: "show",
|
26824 | value: function show() {
|
26825 | if (!this.displayed) {
|
26826 | this.redraw();
|
26827 | }
|
26828 | }
|
26829 | |
26830 |
|
26831 |
|
26832 |
|
26833 | }, {
|
26834 | key: "hide",
|
26835 | value: function hide() {
|
26836 | if (this.displayed) {
|
26837 | var dom = this.dom;
|
26838 |
|
26839 | if (dom.box.parentNode) {
|
26840 | dom.box.parentNode.removeChild(dom.box);
|
26841 | }
|
26842 |
|
26843 | if (this.options.showStipes) {
|
26844 | if (dom.line.parentNode) {
|
26845 | dom.line.parentNode.removeChild(dom.line);
|
26846 | }
|
26847 |
|
26848 | if (dom.dot.parentNode) {
|
26849 | dom.dot.parentNode.removeChild(dom.dot);
|
26850 | }
|
26851 | }
|
26852 |
|
26853 | this.displayed = false;
|
26854 | }
|
26855 | }
|
26856 | |
26857 |
|
26858 |
|
26859 |
|
26860 | }, {
|
26861 | key: "repositionX",
|
26862 | value: function repositionX() {
|
26863 | var start = this.conversion.toScreen(this.data.start);
|
26864 | var end = this.data.end ? this.conversion.toScreen(this.data.end) : 0;
|
26865 |
|
26866 | if (end) {
|
26867 | this.repositionXWithRanges(start, end);
|
26868 | } else {
|
26869 | var align = this.data.align === undefined ? this.options.align : this.data.align;
|
26870 | this.repositionXWithoutRanges(start, align);
|
26871 | }
|
26872 |
|
26873 | if (this.options.showStipes) {
|
26874 | this.dom.line.style.display = this._isStipeVisible() ? 'block' : 'none';
|
26875 | this.dom.dot.style.display = this._isStipeVisible() ? 'block' : 'none';
|
26876 |
|
26877 | if (this._isStipeVisible()) {
|
26878 | this.repositionStype(start, end);
|
26879 | }
|
26880 | }
|
26881 | }
|
26882 | |
26883 |
|
26884 |
|
26885 |
|
26886 |
|
26887 |
|
26888 | }, {
|
26889 | key: "repositionStype",
|
26890 | value: function repositionStype(start, end) {
|
26891 | this.dom.line.style.display = 'block';
|
26892 | this.dom.dot.style.display = 'block';
|
26893 | var lineOffsetWidth = this.dom.line.offsetWidth;
|
26894 | var dotOffsetWidth = this.dom.dot.offsetWidth;
|
26895 |
|
26896 | if (end) {
|
26897 | var lineOffset = lineOffsetWidth + start + (end - start) / 2;
|
26898 | var dotOffset = lineOffset - dotOffsetWidth / 2;
|
26899 | var lineOffsetDirection = this.options.rtl ? lineOffset * -1 : lineOffset;
|
26900 | var dotOffsetDirection = this.options.rtl ? dotOffset * -1 : dotOffset;
|
26901 | this.dom.line.style.transform = "translateX(".concat(lineOffsetDirection, "px)");
|
26902 | this.dom.dot.style.transform = "translateX(".concat(dotOffsetDirection, "px)");
|
26903 | } else {
|
26904 | var _lineOffsetDirection = this.options.rtl ? start * -1 : start;
|
26905 |
|
26906 | var _dotOffsetDirection = this.options.rtl ? (start - dotOffsetWidth / 2) * -1 : start - dotOffsetWidth / 2;
|
26907 |
|
26908 | this.dom.line.style.transform = "translateX(".concat(_lineOffsetDirection, "px)");
|
26909 | this.dom.dot.style.transform = "translateX(".concat(_dotOffsetDirection, "px)");
|
26910 | }
|
26911 | }
|
26912 | |
26913 |
|
26914 |
|
26915 |
|
26916 |
|
26917 |
|
26918 | }, {
|
26919 | key: "repositionXWithoutRanges",
|
26920 | value: function repositionXWithoutRanges(start, align) {
|
26921 |
|
26922 | if (align == 'right') {
|
26923 | if (this.options.rtl) {
|
26924 | this.right = start - this.width;
|
26925 |
|
26926 | this.dom.box.style.right = this.right + 'px';
|
26927 | } else {
|
26928 | this.left = start - this.width;
|
26929 |
|
26930 | this.dom.box.style.left = this.left + 'px';
|
26931 | }
|
26932 | } else if (align == 'left') {
|
26933 | if (this.options.rtl) {
|
26934 | this.right = start;
|
26935 |
|
26936 | this.dom.box.style.right = this.right + 'px';
|
26937 | } else {
|
26938 | this.left = start;
|
26939 |
|
26940 | this.dom.box.style.left = this.left + 'px';
|
26941 | }
|
26942 | } else {
|
26943 |
|
26944 | if (this.options.rtl) {
|
26945 | this.right = start - this.width / 2;
|
26946 |
|
26947 | this.dom.box.style.right = this.right + 'px';
|
26948 | } else {
|
26949 | this.left = start - this.width / 2;
|
26950 |
|
26951 | this.dom.box.style.left = this.left + 'px';
|
26952 | }
|
26953 | }
|
26954 | }
|
26955 | |
26956 |
|
26957 |
|
26958 |
|
26959 |
|
26960 |
|
26961 | }, {
|
26962 | key: "repositionXWithRanges",
|
26963 | value: function repositionXWithRanges(start, end) {
|
26964 | var boxWidth = Math.round(Math.max(end - start + 0.5, 1));
|
26965 |
|
26966 | if (this.options.rtl) {
|
26967 | this.right = start;
|
26968 | } else {
|
26969 | this.left = start;
|
26970 | }
|
26971 |
|
26972 | this.width = Math.max(boxWidth, this.minWidth || 0);
|
26973 |
|
26974 | if (this.options.rtl) {
|
26975 | this.dom.box.style.right = this.right + 'px';
|
26976 | } else {
|
26977 | this.dom.box.style.left = this.left + 'px';
|
26978 | }
|
26979 |
|
26980 | this.dom.box.style.width = boxWidth + 'px';
|
26981 | }
|
26982 | |
26983 |
|
26984 |
|
26985 |
|
26986 | }, {
|
26987 | key: "repositionY",
|
26988 | value: function repositionY() {
|
26989 | var orientation = this.options.orientation.item;
|
26990 | var box = this.dom.box;
|
26991 |
|
26992 | if (orientation == 'top') {
|
26993 | box.style.top = (this.top || 0) + 'px';
|
26994 | } else {
|
26995 |
|
26996 | box.style.top = (this.parent.height - this.top - this.height || 0) + 'px';
|
26997 | }
|
26998 |
|
26999 | if (this.options.showStipes) {
|
27000 | if (orientation == 'top') {
|
27001 | this.dom.line.style.top = '0';
|
27002 | this.dom.line.style.height = this.parent.top + this.top + 1 + 'px';
|
27003 | this.dom.line.style.bottom = '';
|
27004 | } else {
|
27005 |
|
27006 | var itemSetHeight = this.parent.itemSet.props.height;
|
27007 | var lineHeight = itemSetHeight - this.parent.top - this.parent.height + this.top;
|
27008 | this.dom.line.style.top = itemSetHeight - lineHeight + 'px';
|
27009 | this.dom.line.style.bottom = '0';
|
27010 | }
|
27011 |
|
27012 | this.dom.dot.style.top = -this.dom.dot.offsetHeight / 2 + 'px';
|
27013 | }
|
27014 | }
|
27015 | |
27016 |
|
27017 |
|
27018 |
|
27019 |
|
27020 | }, {
|
27021 | key: "getWidthLeft",
|
27022 | value: function getWidthLeft() {
|
27023 | return this.width / 2;
|
27024 | }
|
27025 | |
27026 |
|
27027 |
|
27028 |
|
27029 |
|
27030 | }, {
|
27031 | key: "getWidthRight",
|
27032 | value: function getWidthRight() {
|
27033 | return this.width / 2;
|
27034 | }
|
27035 | |
27036 |
|
27037 |
|
27038 |
|
27039 | }, {
|
27040 | key: "move",
|
27041 | value: function move() {
|
27042 | this.repositionX();
|
27043 | this.repositionY();
|
27044 | }
|
27045 | |
27046 |
|
27047 |
|
27048 |
|
27049 | }, {
|
27050 | key: "attach",
|
27051 | value: function attach() {
|
27052 | var _context8;
|
27053 |
|
27054 | var _iterator = _createForOfIteratorHelper$3(this.data.uiItems),
|
27055 | _step;
|
27056 |
|
27057 | try {
|
27058 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
27059 | var item = _step.value;
|
27060 | item.cluster = this;
|
27061 | }
|
27062 | } catch (err) {
|
27063 | _iterator.e(err);
|
27064 | } finally {
|
27065 | _iterator.f();
|
27066 | }
|
27067 |
|
27068 | this.data.items = _mapInstanceProperty(_context8 = this.data.uiItems).call(_context8, function (item) {
|
27069 | return item.data;
|
27070 | });
|
27071 | this.attached = true;
|
27072 | this.dirty = true;
|
27073 | }
|
27074 | |
27075 |
|
27076 |
|
27077 |
|
27078 |
|
27079 |
|
27080 | }, {
|
27081 | key: "detach",
|
27082 | value: function detach() {
|
27083 | var detachFromParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
27084 |
|
27085 | if (!this.hasItems()) {
|
27086 | return;
|
27087 | }
|
27088 |
|
27089 | var _iterator2 = _createForOfIteratorHelper$3(this.data.uiItems),
|
27090 | _step2;
|
27091 |
|
27092 | try {
|
27093 | for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
27094 | var item = _step2.value;
|
27095 | delete item.cluster;
|
27096 | }
|
27097 | } catch (err) {
|
27098 | _iterator2.e(err);
|
27099 | } finally {
|
27100 | _iterator2.f();
|
27101 | }
|
27102 |
|
27103 | this.attached = false;
|
27104 |
|
27105 | if (detachFromParent && this.group) {
|
27106 | this.group.remove(this);
|
27107 | this.group = null;
|
27108 | }
|
27109 |
|
27110 | this.data.items = [];
|
27111 | this.dirty = true;
|
27112 | }
|
27113 | |
27114 |
|
27115 |
|
27116 |
|
27117 | }, {
|
27118 | key: "_onDoubleClick",
|
27119 | value: function _onDoubleClick() {
|
27120 | this._fit();
|
27121 | }
|
27122 | |
27123 |
|
27124 |
|
27125 |
|
27126 | }, {
|
27127 | key: "_setupRange",
|
27128 | value: function _setupRange() {
|
27129 | var _context9, _context10, _context11;
|
27130 |
|
27131 | var stats = _mapInstanceProperty(_context9 = this.data.uiItems).call(_context9, function (item) {
|
27132 | return {
|
27133 | start: item.data.start.valueOf(),
|
27134 | end: item.data.end ? item.data.end.valueOf() : item.data.start.valueOf()
|
27135 | };
|
27136 | });
|
27137 |
|
27138 | this.data.min = Math.min.apply(Math, _toConsumableArray(_mapInstanceProperty(stats).call(stats, function (s) {
|
27139 | return Math.min(s.start, s.end || s.start);
|
27140 | })));
|
27141 | this.data.max = Math.max.apply(Math, _toConsumableArray(_mapInstanceProperty(stats).call(stats, function (s) {
|
27142 | return Math.max(s.start, s.end || s.start);
|
27143 | })));
|
27144 |
|
27145 | var centers = _mapInstanceProperty(_context10 = this.data.uiItems).call(_context10, function (item) {
|
27146 | return item.center;
|
27147 | });
|
27148 |
|
27149 | var avg = _reduceInstanceProperty(centers).call(centers, function (sum, value) {
|
27150 | return sum + value;
|
27151 | }, 0) / this.data.uiItems.length;
|
27152 |
|
27153 | if (_someInstanceProperty(_context11 = this.data.uiItems).call(_context11, function (item) {
|
27154 | return item.data.end;
|
27155 | })) {
|
27156 |
|
27157 | this.data.start = new Date(this.data.min);
|
27158 | this.data.end = new Date(this.data.max);
|
27159 | } else {
|
27160 | this.data.start = new Date(avg);
|
27161 | this.data.end = null;
|
27162 | }
|
27163 | }
|
27164 | |
27165 |
|
27166 |
|
27167 |
|
27168 |
|
27169 | }, {
|
27170 | key: "_getUiItems",
|
27171 | value: function _getUiItems() {
|
27172 | var _this2 = this;
|
27173 |
|
27174 | if (this.data.uiItems && this.data.uiItems.length) {
|
27175 | var _context12;
|
27176 |
|
27177 | return _filterInstanceProperty(_context12 = this.data.uiItems).call(_context12, function (item) {
|
27178 | return item.cluster === _this2;
|
27179 | });
|
27180 | }
|
27181 |
|
27182 | return [];
|
27183 | }
|
27184 | |
27185 |
|
27186 |
|
27187 |
|
27188 | }, {
|
27189 | key: "_createDomElement",
|
27190 | value: function _createDomElement() {
|
27191 | if (!this.dom) {
|
27192 |
|
27193 | this.dom = {};
|
27194 |
|
27195 | this.dom.box = document.createElement('DIV');
|
27196 |
|
27197 | this.dom.content = document.createElement('DIV');
|
27198 | this.dom.content.className = 'vis-item-content';
|
27199 | this.dom.box.appendChild(this.dom.content);
|
27200 |
|
27201 | if (this.options.showStipes) {
|
27202 |
|
27203 | this.dom.line = document.createElement('DIV');
|
27204 | this.dom.line.className = 'vis-cluster-line';
|
27205 | this.dom.line.style.display = 'none';
|
27206 |
|
27207 | this.dom.dot = document.createElement('DIV');
|
27208 | this.dom.dot.className = 'vis-cluster-dot';
|
27209 | this.dom.dot.style.display = 'none';
|
27210 | }
|
27211 |
|
27212 | if (this.options.fitOnDoubleClick) {
|
27213 | var _context13;
|
27214 |
|
27215 | this.dom.box.ondblclick = _bindInstanceProperty(_context13 = ClusterItem.prototype._onDoubleClick).call(_context13, this);
|
27216 | }
|
27217 |
|
27218 |
|
27219 | this.dom.box['vis-item'] = this;
|
27220 | this.dirty = true;
|
27221 | }
|
27222 | }
|
27223 | |
27224 |
|
27225 |
|
27226 |
|
27227 | }, {
|
27228 | key: "_appendDomElement",
|
27229 | value: function _appendDomElement() {
|
27230 | if (!this.parent) {
|
27231 | throw new Error('Cannot redraw item: no parent attached');
|
27232 | }
|
27233 |
|
27234 | if (!this.dom.box.parentNode) {
|
27235 | var foreground = this.parent.dom.foreground;
|
27236 |
|
27237 | if (!foreground) {
|
27238 | throw new Error('Cannot redraw item: parent has no foreground container element');
|
27239 | }
|
27240 |
|
27241 | foreground.appendChild(this.dom.box);
|
27242 | }
|
27243 |
|
27244 | var background = this.parent.dom.background;
|
27245 |
|
27246 | if (this.options.showStipes) {
|
27247 | if (!this.dom.line.parentNode) {
|
27248 | if (!background) throw new Error('Cannot redraw item: parent has no background container element');
|
27249 | background.appendChild(this.dom.line);
|
27250 | }
|
27251 |
|
27252 | if (!this.dom.dot.parentNode) {
|
27253 | var axis = this.parent.dom.axis;
|
27254 | if (!background) throw new Error('Cannot redraw item: parent has no axis container element');
|
27255 | axis.appendChild(this.dom.dot);
|
27256 | }
|
27257 | }
|
27258 |
|
27259 | this.displayed = true;
|
27260 | }
|
27261 | |
27262 |
|
27263 |
|
27264 |
|
27265 | }, {
|
27266 | key: "_updateDirtyDomComponents",
|
27267 | value: function _updateDirtyDomComponents() {
|
27268 |
|
27269 |
|
27270 |
|
27271 |
|
27272 | if (this.dirty) {
|
27273 | this._updateContents(this.dom.content);
|
27274 |
|
27275 | this._updateDataAttributes(this.dom.box);
|
27276 |
|
27277 | this._updateStyle(this.dom.box);
|
27278 |
|
27279 |
|
27280 | var className = this.baseClassName + ' ' + (this.data.className ? ' ' + this.data.className : '') + (this.selected ? ' vis-selected' : '') + ' vis-readonly';
|
27281 | this.dom.box.className = 'vis-item ' + className;
|
27282 |
|
27283 | if (this.options.showStipes) {
|
27284 | this.dom.line.className = 'vis-item vis-cluster-line ' + (this.selected ? ' vis-selected' : '');
|
27285 | this.dom.dot.className = 'vis-item vis-cluster-dot ' + (this.selected ? ' vis-selected' : '');
|
27286 | }
|
27287 |
|
27288 | if (this.data.end) {
|
27289 |
|
27290 |
|
27291 | this.dom.content.style.maxWidth = 'none';
|
27292 | }
|
27293 | }
|
27294 | }
|
27295 | |
27296 |
|
27297 |
|
27298 |
|
27299 |
|
27300 | }, {
|
27301 | key: "_getDomComponentsSizes",
|
27302 | value: function _getDomComponentsSizes() {
|
27303 | var sizes = {
|
27304 | previous: {
|
27305 | right: this.dom.box.style.right,
|
27306 | left: this.dom.box.style.left
|
27307 | },
|
27308 | box: {
|
27309 | width: this.dom.box.offsetWidth,
|
27310 | height: this.dom.box.offsetHeight
|
27311 | }
|
27312 | };
|
27313 |
|
27314 | if (this.options.showStipes) {
|
27315 | sizes.dot = {
|
27316 | height: this.dom.dot.offsetHeight,
|
27317 | width: this.dom.dot.offsetWidth
|
27318 | };
|
27319 | sizes.line = {
|
27320 | width: this.dom.line.offsetWidth
|
27321 | };
|
27322 | }
|
27323 |
|
27324 | return sizes;
|
27325 | }
|
27326 | |
27327 |
|
27328 |
|
27329 |
|
27330 |
|
27331 | }, {
|
27332 | key: "_updateDomComponentsSizes",
|
27333 | value: function _updateDomComponentsSizes(sizes) {
|
27334 | if (this.options.rtl) {
|
27335 | this.dom.box.style.right = "0px";
|
27336 | } else {
|
27337 | this.dom.box.style.left = "0px";
|
27338 | }
|
27339 |
|
27340 |
|
27341 | if (!this.data.end) {
|
27342 | this.width = sizes.box.width;
|
27343 | } else {
|
27344 | this.minWidth = sizes.box.width;
|
27345 | }
|
27346 |
|
27347 | this.height = sizes.box.height;
|
27348 |
|
27349 | if (this.options.rtl) {
|
27350 | this.dom.box.style.right = sizes.previous.right;
|
27351 | } else {
|
27352 | this.dom.box.style.left = sizes.previous.left;
|
27353 | }
|
27354 |
|
27355 | this.dirty = false;
|
27356 | }
|
27357 | |
27358 |
|
27359 |
|
27360 |
|
27361 | }, {
|
27362 | key: "_repaintDomAdditionals",
|
27363 | value: function _repaintDomAdditionals() {
|
27364 | this._repaintOnItemUpdateTimeTooltip(this.dom.box);
|
27365 | }
|
27366 | |
27367 |
|
27368 |
|
27369 |
|
27370 |
|
27371 |
|
27372 | }, {
|
27373 | key: "_isStipeVisible",
|
27374 | value: function _isStipeVisible() {
|
27375 | return this.minWidth >= this.width || !this.data.end;
|
27376 | }
|
27377 | |
27378 |
|
27379 |
|
27380 |
|
27381 |
|
27382 |
|
27383 | }, {
|
27384 | key: "_getFitRange",
|
27385 | value: function _getFitRange() {
|
27386 | var offset = 0.05 * (this.data.max - this.data.min) / 2;
|
27387 | return {
|
27388 | fitStart: this.data.min - offset,
|
27389 | fitEnd: this.data.max + offset
|
27390 | };
|
27391 | }
|
27392 | |
27393 |
|
27394 |
|
27395 |
|
27396 |
|
27397 | }, {
|
27398 | key: "_fit",
|
27399 | value: function _fit() {
|
27400 | if (this.emitter) {
|
27401 | var _this$_getFitRange = this._getFitRange(),
|
27402 | fitStart = _this$_getFitRange.fitStart,
|
27403 | fitEnd = _this$_getFitRange.fitEnd;
|
27404 |
|
27405 | var fitArgs = {
|
27406 | start: new Date(fitStart),
|
27407 | end: new Date(fitEnd),
|
27408 | animation: true
|
27409 | };
|
27410 | this.emitter.emit('fit', fitArgs);
|
27411 | }
|
27412 | }
|
27413 | |
27414 |
|
27415 |
|
27416 |
|
27417 |
|
27418 |
|
27419 | }, {
|
27420 | key: "_getItemData",
|
27421 | value: function _getItemData() {
|
27422 | return this.data;
|
27423 | }
|
27424 | }]);
|
27425 |
|
27426 | return ClusterItem;
|
27427 | }(Item);
|
27428 |
|
27429 | ClusterItem.prototype.baseClassName = 'vis-item vis-range vis-cluster';
|
27430 |
|
27431 | function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
27432 |
|
27433 | function _unsupportedIterableToArray$2(o, minLen) { var _context4; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = _sliceInstanceProperty(_context4 = Object.prototype.toString.call(o)).call(_context4, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
27434 |
|
27435 | function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
27436 | var UNGROUPED$2 = '__ungrouped__';
|
27437 |
|
27438 | var BACKGROUND$1 = '__background__';
|
27439 |
|
27440 | var ReservedGroupIds = {
|
27441 | UNGROUPED: UNGROUPED$2,
|
27442 | BACKGROUND: BACKGROUND$1
|
27443 | };
|
27444 |
|
27445 |
|
27446 |
|
27447 |
|
27448 | var ClusterGenerator = function () {
|
27449 | |
27450 |
|
27451 |
|
27452 |
|
27453 | function ClusterGenerator(itemSet) {
|
27454 | _classCallCheck(this, ClusterGenerator);
|
27455 |
|
27456 | this.itemSet = itemSet;
|
27457 | this.groups = {};
|
27458 | this.cache = {};
|
27459 | this.cache[-1] = [];
|
27460 | }
|
27461 | |
27462 |
|
27463 |
|
27464 |
|
27465 |
|
27466 |
|
27467 |
|
27468 |
|
27469 |
|
27470 | _createClass(ClusterGenerator, [{
|
27471 | key: "createClusterItem",
|
27472 | value: function createClusterItem(itemData, conversion, options) {
|
27473 | var newItem = new ClusterItem(itemData, conversion, options);
|
27474 | return newItem;
|
27475 | }
|
27476 | |
27477 |
|
27478 |
|
27479 |
|
27480 |
|
27481 |
|
27482 |
|
27483 |
|
27484 |
|
27485 |
|
27486 |
|
27487 | }, {
|
27488 | key: "setItems",
|
27489 | value: function setItems(items, options) {
|
27490 | this.items = items || [];
|
27491 | this.dataChanged = true;
|
27492 | this.applyOnChangedLevel = false;
|
27493 |
|
27494 | if (options && options.applyOnChangedLevel) {
|
27495 | this.applyOnChangedLevel = options.applyOnChangedLevel;
|
27496 | }
|
27497 | }
|
27498 | |
27499 |
|
27500 |
|
27501 |
|
27502 |
|
27503 | }, {
|
27504 | key: "updateData",
|
27505 | value: function updateData() {
|
27506 | this.dataChanged = true;
|
27507 | this.applyOnChangedLevel = false;
|
27508 | }
|
27509 | |
27510 |
|
27511 |
|
27512 |
|
27513 |
|
27514 |
|
27515 |
|
27516 |
|
27517 | }, {
|
27518 | key: "getClusters",
|
27519 | value: function getClusters(oldClusters, scale, options) {
|
27520 | var _ref = typeof options === "boolean" ? {} : options,
|
27521 | maxItems = _ref.maxItems,
|
27522 | clusterCriteria = _ref.clusterCriteria;
|
27523 |
|
27524 | if (!clusterCriteria) {
|
27525 | clusterCriteria = function clusterCriteria() {
|
27526 | return true;
|
27527 | };
|
27528 | }
|
27529 |
|
27530 | maxItems = maxItems || 1;
|
27531 | var level = -1;
|
27532 | var granularity = 2;
|
27533 | var timeWindow = 0;
|
27534 |
|
27535 | if (scale > 0) {
|
27536 | if (scale >= 1) {
|
27537 | return [];
|
27538 | }
|
27539 |
|
27540 | level = Math.abs(Math.round(Math.log(100 / scale) / Math.log(granularity)));
|
27541 | timeWindow = Math.abs(Math.pow(granularity, level));
|
27542 | }
|
27543 |
|
27544 |
|
27545 | if (this.dataChanged) {
|
27546 | var levelChanged = level != this.cacheLevel;
|
27547 | var applyDataNow = this.applyOnChangedLevel ? levelChanged : true;
|
27548 |
|
27549 | if (applyDataNow) {
|
27550 | this._dropLevelsCache();
|
27551 |
|
27552 | this._filterData();
|
27553 | }
|
27554 | }
|
27555 |
|
27556 | this.cacheLevel = level;
|
27557 | var clusters = this.cache[level];
|
27558 |
|
27559 | if (!clusters) {
|
27560 | clusters = [];
|
27561 |
|
27562 | for (var groupName in this.groups) {
|
27563 | if (this.groups.hasOwnProperty(groupName)) {
|
27564 | var items = this.groups[groupName];
|
27565 | var iMax = items.length;
|
27566 | var i = 0;
|
27567 |
|
27568 | while (i < iMax) {
|
27569 |
|
27570 | var item = items[i];
|
27571 | var neighbors = 1;
|
27572 |
|
27573 |
|
27574 | var j = i - 1;
|
27575 |
|
27576 | while (j >= 0 && item.center - items[j].center < timeWindow / 2) {
|
27577 | if (!items[j].cluster && clusterCriteria(item.data, items[j].data)) {
|
27578 | neighbors++;
|
27579 | }
|
27580 |
|
27581 | j--;
|
27582 | }
|
27583 |
|
27584 |
|
27585 | var k = i + 1;
|
27586 |
|
27587 | while (k < items.length && items[k].center - item.center < timeWindow / 2) {
|
27588 | if (clusterCriteria(item.data, items[k].data)) {
|
27589 | neighbors++;
|
27590 | }
|
27591 |
|
27592 | k++;
|
27593 | }
|
27594 |
|
27595 |
|
27596 | var l = clusters.length - 1;
|
27597 |
|
27598 | while (l >= 0 && item.center - clusters[l].center < timeWindow) {
|
27599 | if (item.group == clusters[l].group && clusterCriteria(item.data, clusters[l].data)) {
|
27600 | neighbors++;
|
27601 | }
|
27602 |
|
27603 | l--;
|
27604 | }
|
27605 |
|
27606 |
|
27607 | if (neighbors > maxItems) {
|
27608 |
|
27609 | var num = neighbors - maxItems + 1;
|
27610 | var clusterItems = [];
|
27611 |
|
27612 |
|
27613 | var m = i;
|
27614 |
|
27615 | while (clusterItems.length < num && m < items.length) {
|
27616 | if (clusterCriteria(items[i].data, items[m].data)) {
|
27617 | clusterItems.push(items[m]);
|
27618 | }
|
27619 |
|
27620 | m++;
|
27621 | }
|
27622 |
|
27623 | var groupId = this.itemSet.getGroupId(item.data);
|
27624 | var group = this.itemSet.groups[groupId] || this.itemSet.groups[ReservedGroupIds.UNGROUPED];
|
27625 |
|
27626 | var cluster = this._getClusterForItems(clusterItems, group, oldClusters, options);
|
27627 |
|
27628 | clusters.push(cluster);
|
27629 | i += num;
|
27630 | } else {
|
27631 | delete item.cluster;
|
27632 | i += 1;
|
27633 | }
|
27634 | }
|
27635 | }
|
27636 | }
|
27637 |
|
27638 | this.cache[level] = clusters;
|
27639 | }
|
27640 |
|
27641 | return clusters;
|
27642 | }
|
27643 | |
27644 |
|
27645 |
|
27646 |
|
27647 |
|
27648 | }, {
|
27649 | key: "_filterData",
|
27650 | value: function _filterData() {
|
27651 |
|
27652 | var groups = {};
|
27653 | this.groups = groups;
|
27654 |
|
27655 | for (var _i = 0, _Object$values = _Object$values2(this.items); _i < _Object$values.length; _i++) {
|
27656 | var item = _Object$values[_i];
|
27657 |
|
27658 | var groupName = item.parent ? item.parent.groupId : '';
|
27659 | var group = groups[groupName];
|
27660 |
|
27661 | if (!group) {
|
27662 | group = [];
|
27663 | groups[groupName] = group;
|
27664 | }
|
27665 |
|
27666 | group.push(item);
|
27667 |
|
27668 | if (item.data.start) {
|
27669 | if (item.data.end) {
|
27670 |
|
27671 | item.center = (item.data.start.valueOf() + item.data.end.valueOf()) / 2;
|
27672 | } else {
|
27673 |
|
27674 | item.center = item.data.start.valueOf();
|
27675 | }
|
27676 | }
|
27677 | }
|
27678 |
|
27679 |
|
27680 | for (var currentGroupName in groups) {
|
27681 | if (groups.hasOwnProperty(currentGroupName)) {
|
27682 | var _context;
|
27683 |
|
27684 | _sortInstanceProperty(_context = groups[currentGroupName]).call(_context, function (a, b) {
|
27685 | return a.center - b.center;
|
27686 | });
|
27687 | }
|
27688 | }
|
27689 |
|
27690 | this.dataChanged = false;
|
27691 | }
|
27692 | |
27693 |
|
27694 |
|
27695 |
|
27696 |
|
27697 |
|
27698 |
|
27699 |
|
27700 |
|
27701 |
|
27702 | }, {
|
27703 | key: "_getClusterForItems",
|
27704 | value: function _getClusterForItems(clusterItems, group, oldClusters, options) {
|
27705 | var _context2;
|
27706 |
|
27707 | var oldClustersLookup = _mapInstanceProperty(_context2 = oldClusters || []).call(_context2, function (cluster) {
|
27708 | var _context3;
|
27709 |
|
27710 | return {
|
27711 | cluster: cluster,
|
27712 | itemsIds: new _Set(_mapInstanceProperty(_context3 = cluster.data.uiItems).call(_context3, function (item) {
|
27713 | return item.id;
|
27714 | }))
|
27715 | };
|
27716 | });
|
27717 |
|
27718 | var cluster;
|
27719 |
|
27720 | if (oldClustersLookup.length) {
|
27721 | var _iterator = _createForOfIteratorHelper$2(oldClustersLookup),
|
27722 | _step;
|
27723 |
|
27724 | try {
|
27725 | var _loop = function _loop() {
|
27726 | var oldClusterData = _step.value;
|
27727 |
|
27728 | if (oldClusterData.itemsIds.size === clusterItems.length && _everyInstanceProperty(clusterItems).call(clusterItems, function (clusterItem) {
|
27729 | return oldClusterData.itemsIds.has(clusterItem.id);
|
27730 | })) {
|
27731 | cluster = oldClusterData.cluster;
|
27732 | return "break";
|
27733 | }
|
27734 | };
|
27735 |
|
27736 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
27737 | var _ret = _loop();
|
27738 |
|
27739 | if (_ret === "break") break;
|
27740 | }
|
27741 | } catch (err) {
|
27742 | _iterator.e(err);
|
27743 | } finally {
|
27744 | _iterator.f();
|
27745 | }
|
27746 | }
|
27747 |
|
27748 | if (cluster) {
|
27749 | cluster.setUiItems(clusterItems);
|
27750 |
|
27751 | if (cluster.group !== group) {
|
27752 | if (cluster.group) {
|
27753 | cluster.group.remove(cluster);
|
27754 | }
|
27755 |
|
27756 | if (group) {
|
27757 | group.add(cluster);
|
27758 | cluster.group = group;
|
27759 | }
|
27760 | }
|
27761 |
|
27762 | return cluster;
|
27763 | }
|
27764 |
|
27765 | var titleTemplate = options.titleTemplate || '';
|
27766 | var conversion = {
|
27767 | toScreen: this.itemSet.body.util.toScreen,
|
27768 | toTime: this.itemSet.body.util.toTime
|
27769 | };
|
27770 | var title = titleTemplate.replace(/{count}/, clusterItems.length);
|
27771 | var clusterContent = '<div title="' + title + '">' + clusterItems.length + '</div>';
|
27772 |
|
27773 | var clusterOptions = _Object$assign({}, options, this.itemSet.options);
|
27774 |
|
27775 | var data = {
|
27776 | 'content': clusterContent,
|
27777 | 'title': title,
|
27778 | 'group': group,
|
27779 | 'uiItems': clusterItems,
|
27780 | 'eventEmitter': this.itemSet.body.emitter,
|
27781 | 'range': this.itemSet.body.range
|
27782 | };
|
27783 | cluster = this.createClusterItem(data, conversion, clusterOptions);
|
27784 |
|
27785 | if (group) {
|
27786 | group.add(cluster);
|
27787 | cluster.group = group;
|
27788 | }
|
27789 |
|
27790 | cluster.attach();
|
27791 | return cluster;
|
27792 | }
|
27793 | |
27794 |
|
27795 |
|
27796 |
|
27797 |
|
27798 | }, {
|
27799 | key: "_dropLevelsCache",
|
27800 | value: function _dropLevelsCache() {
|
27801 | this.cache = {};
|
27802 | this.cacheLevel = -1;
|
27803 | this.cache[this.cacheLevel] = [];
|
27804 | }
|
27805 | }]);
|
27806 |
|
27807 | return ClusterGenerator;
|
27808 | }();
|
27809 |
|
27810 | function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
27811 |
|
27812 | function _unsupportedIterableToArray$1(o, minLen) { var _context34; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = _sliceInstanceProperty(_context34 = Object.prototype.toString.call(o)).call(_context34, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
27813 |
|
27814 | function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
27815 |
|
27816 | function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
27817 |
|
27818 | function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
27819 | var UNGROUPED$1 = '__ungrouped__';
|
27820 |
|
27821 | var BACKGROUND = '__background__';
|
27822 |
|
27823 |
|
27824 |
|
27825 |
|
27826 |
|
27827 |
|
27828 | var ItemSet = function (_Component) {
|
27829 | _inherits(ItemSet, _Component);
|
27830 |
|
27831 | var _super = _createSuper$2(ItemSet);
|
27832 |
|
27833 | |
27834 |
|
27835 |
|
27836 |
|
27837 |
|
27838 |
|
27839 | function ItemSet(body, options) {
|
27840 | var _this;
|
27841 |
|
27842 | _classCallCheck(this, ItemSet);
|
27843 |
|
27844 | _this = _super.call(this);
|
27845 | _this.body = body;
|
27846 | _this.defaultOptions = {
|
27847 | type: null,
|
27848 |
|
27849 | orientation: {
|
27850 | item: 'bottom'
|
27851 |
|
27852 | },
|
27853 | align: 'auto',
|
27854 |
|
27855 | stack: true,
|
27856 | stackSubgroups: true,
|
27857 | groupOrderSwap: function groupOrderSwap(fromGroup, toGroup, groups) {
|
27858 |
|
27859 | var targetOrder = toGroup.order;
|
27860 | toGroup.order = fromGroup.order;
|
27861 | fromGroup.order = targetOrder;
|
27862 | },
|
27863 | groupOrder: 'order',
|
27864 | selectable: true,
|
27865 | multiselect: false,
|
27866 | longSelectPressTime: 251,
|
27867 | itemsAlwaysDraggable: {
|
27868 | item: false,
|
27869 | range: false
|
27870 | },
|
27871 | editable: {
|
27872 | updateTime: false,
|
27873 | updateGroup: false,
|
27874 | add: false,
|
27875 | remove: false,
|
27876 | overrideItems: false
|
27877 | },
|
27878 | groupEditable: {
|
27879 | order: false,
|
27880 | add: false,
|
27881 | remove: false
|
27882 | },
|
27883 | snap: TimeStep.snap,
|
27884 |
|
27885 | onDropObjectOnItem: function onDropObjectOnItem(objectData, item, callback) {
|
27886 | callback(item);
|
27887 | },
|
27888 | onAdd: function onAdd(item, callback) {
|
27889 | callback(item);
|
27890 | },
|
27891 | onUpdate: function onUpdate(item, callback) {
|
27892 | callback(item);
|
27893 | },
|
27894 | onMove: function onMove(item, callback) {
|
27895 | callback(item);
|
27896 | },
|
27897 | onRemove: function onRemove(item, callback) {
|
27898 | callback(item);
|
27899 | },
|
27900 | onMoving: function onMoving(item, callback) {
|
27901 | callback(item);
|
27902 | },
|
27903 | onAddGroup: function onAddGroup(item, callback) {
|
27904 | callback(item);
|
27905 | },
|
27906 | onMoveGroup: function onMoveGroup(item, callback) {
|
27907 | callback(item);
|
27908 | },
|
27909 | onRemoveGroup: function onRemoveGroup(item, callback) {
|
27910 | callback(item);
|
27911 | },
|
27912 | margin: {
|
27913 | item: {
|
27914 | horizontal: 10,
|
27915 | vertical: 10
|
27916 | },
|
27917 | axis: 20
|
27918 | },
|
27919 | showTooltips: true,
|
27920 | tooltip: {
|
27921 | followMouse: false,
|
27922 | overflowMethod: 'flip',
|
27923 | delay: 500
|
27924 | },
|
27925 | tooltipOnItemUpdateTime: false
|
27926 | };
|
27927 |
|
27928 | _this.options = availableUtils.extend({}, _this.defaultOptions);
|
27929 | _this.options.rtl = options.rtl;
|
27930 | _this.options.onTimeout = options.onTimeout;
|
27931 | _this.conversion = {
|
27932 | toScreen: body.util.toScreen,
|
27933 | toTime: body.util.toTime
|
27934 | };
|
27935 | _this.dom = {};
|
27936 | _this.props = {};
|
27937 | _this.hammer = null;
|
27938 |
|
27939 | var me = _assertThisInitialized$1(_this);
|
27940 |
|
27941 | _this.itemsData = null;
|
27942 |
|
27943 | _this.groupsData = null;
|
27944 |
|
27945 | _this.itemsSettingTime = null;
|
27946 | _this.initialItemSetDrawn = false;
|
27947 | _this.userContinueNotBail = null;
|
27948 | _this.sequentialSelection = false;
|
27949 |
|
27950 | _this.itemListeners = {
|
27951 | 'add': function add(event, params, senderId) {
|
27952 |
|
27953 | me._onAdd(params.items);
|
27954 |
|
27955 | if (me.options.cluster) {
|
27956 | me.clusterGenerator.setItems(me.items, {
|
27957 | applyOnChangedLevel: false
|
27958 | });
|
27959 | }
|
27960 |
|
27961 | me.redraw();
|
27962 | },
|
27963 | 'update': function update(event, params, senderId) {
|
27964 |
|
27965 | me._onUpdate(params.items);
|
27966 |
|
27967 | if (me.options.cluster) {
|
27968 | me.clusterGenerator.setItems(me.items, {
|
27969 | applyOnChangedLevel: false
|
27970 | });
|
27971 | }
|
27972 |
|
27973 | me.redraw();
|
27974 | },
|
27975 | 'remove': function remove(event, params, senderId) {
|
27976 |
|
27977 | me._onRemove(params.items);
|
27978 |
|
27979 | if (me.options.cluster) {
|
27980 | me.clusterGenerator.setItems(me.items, {
|
27981 | applyOnChangedLevel: false
|
27982 | });
|
27983 | }
|
27984 |
|
27985 | me.redraw();
|
27986 | }
|
27987 | };
|
27988 |
|
27989 | _this.groupListeners = {
|
27990 | 'add': function add(event, params, senderId) {
|
27991 |
|
27992 | me._onAddGroups(params.items);
|
27993 |
|
27994 | if (me.groupsData && me.groupsData.length > 0) {
|
27995 | var _context;
|
27996 |
|
27997 | var groupsData = me.groupsData.getDataSet();
|
27998 |
|
27999 | _forEachInstanceProperty(_context = groupsData.get()).call(_context, function (groupData) {
|
28000 | if (groupData.nestedGroups) {
|
28001 | var _context2;
|
28002 |
|
28003 | if (groupData.showNested != false) {
|
28004 | groupData.showNested = true;
|
28005 | }
|
28006 |
|
28007 | var updatedGroups = [];
|
28008 |
|
28009 | _forEachInstanceProperty(_context2 = groupData.nestedGroups).call(_context2, function (nestedGroupId) {
|
28010 | var updatedNestedGroup = groupsData.get(nestedGroupId);
|
28011 |
|
28012 | if (!updatedNestedGroup) {
|
28013 | return;
|
28014 | }
|
28015 |
|
28016 | updatedNestedGroup.nestedInGroup = groupData.id;
|
28017 |
|
28018 | if (groupData.showNested == false) {
|
28019 | updatedNestedGroup.visible = false;
|
28020 | }
|
28021 |
|
28022 | updatedGroups = _concatInstanceProperty(updatedGroups).call(updatedGroups, updatedNestedGroup);
|
28023 | });
|
28024 |
|
28025 | groupsData.update(updatedGroups, senderId);
|
28026 | }
|
28027 | });
|
28028 | }
|
28029 | },
|
28030 | 'update': function update(event, params, senderId) {
|
28031 |
|
28032 | me._onUpdateGroups(params.items);
|
28033 | },
|
28034 | 'remove': function remove(event, params, senderId) {
|
28035 |
|
28036 | me._onRemoveGroups(params.items);
|
28037 | }
|
28038 | };
|
28039 | _this.items = {};
|
28040 |
|
28041 | _this.groups = {};
|
28042 |
|
28043 | _this.groupIds = [];
|
28044 | _this.selection = [];
|
28045 |
|
28046 | _this.popup = null;
|
28047 | _this.popupTimer = null;
|
28048 | _this.touchParams = {};
|
28049 |
|
28050 | _this.groupTouchParams = {
|
28051 | group: null,
|
28052 | isDragging: false
|
28053 | };
|
28054 |
|
28055 | _this._create();
|
28056 |
|
28057 | _this.setOptions(options);
|
28058 |
|
28059 | _this.clusters = [];
|
28060 | return _this;
|
28061 | }
|
28062 | |
28063 |
|
28064 |
|
28065 |
|
28066 |
|
28067 | _createClass(ItemSet, [{
|
28068 | key: "_create",
|
28069 | value: function _create() {
|
28070 | var _this2 = this,
|
28071 | _context3,
|
28072 | _context4,
|
28073 | _context5,
|
28074 | _context6,
|
28075 | _context7,
|
28076 | _context8,
|
28077 | _context9,
|
28078 | _context10,
|
28079 | _context11,
|
28080 | _context12,
|
28081 | _context13,
|
28082 | _context14,
|
28083 | _context15,
|
28084 | _context16,
|
28085 | _context17;
|
28086 |
|
28087 | var frame = document.createElement('div');
|
28088 | frame.className = 'vis-itemset';
|
28089 | frame['vis-itemset'] = this;
|
28090 | this.dom.frame = frame;
|
28091 |
|
28092 | var background = document.createElement('div');
|
28093 | background.className = 'vis-background';
|
28094 | frame.appendChild(background);
|
28095 | this.dom.background = background;
|
28096 |
|
28097 | var foreground = document.createElement('div');
|
28098 | foreground.className = 'vis-foreground';
|
28099 | frame.appendChild(foreground);
|
28100 | this.dom.foreground = foreground;
|
28101 |
|
28102 | var axis = document.createElement('div');
|
28103 | axis.className = 'vis-axis';
|
28104 | this.dom.axis = axis;
|
28105 |
|
28106 | var labelSet = document.createElement('div');
|
28107 | labelSet.className = 'vis-labelset';
|
28108 | this.dom.labelSet = labelSet;
|
28109 |
|
28110 | this._updateUngrouped();
|
28111 |
|
28112 |
|
28113 | var backgroundGroup = new BackgroundGroup(BACKGROUND, null, this);
|
28114 | backgroundGroup.show();
|
28115 | this.groups[BACKGROUND] = backgroundGroup;
|
28116 |
|
28117 |
|
28118 |
|
28119 |
|
28120 | this.hammer = new Hammer(this.body.dom.centerContainer);
|
28121 |
|
28122 | this.hammer.on('hammer.input', function (event) {
|
28123 | if (event.isFirst) {
|
28124 | _this2._onTouch(event);
|
28125 | }
|
28126 | });
|
28127 | this.hammer.on('panstart', _bindInstanceProperty(_context3 = this._onDragStart).call(_context3, this));
|
28128 | this.hammer.on('panmove', _bindInstanceProperty(_context4 = this._onDrag).call(_context4, this));
|
28129 | this.hammer.on('panend', _bindInstanceProperty(_context5 = this._onDragEnd).call(_context5, this));
|
28130 | this.hammer.get('pan').set({
|
28131 | threshold: 5,
|
28132 | direction: Hammer.ALL
|
28133 | });
|
28134 |
|
28135 | this.hammer.get('press').set({
|
28136 | time: 10000
|
28137 | });
|
28138 |
|
28139 | this.hammer.on('tap', _bindInstanceProperty(_context6 = this._onSelectItem).call(_context6, this));
|
28140 |
|
28141 | this.hammer.on('press', _bindInstanceProperty(_context7 = this._onMultiSelectItem).call(_context7, this));
|
28142 |
|
28143 | this.hammer.get('press').set({
|
28144 | time: 10000
|
28145 | });
|
28146 |
|
28147 | this.hammer.on('doubletap', _bindInstanceProperty(_context8 = this._onAddItem).call(_context8, this));
|
28148 |
|
28149 | if (this.options.rtl) {
|
28150 | this.groupHammer = new Hammer(this.body.dom.rightContainer);
|
28151 | } else {
|
28152 | this.groupHammer = new Hammer(this.body.dom.leftContainer);
|
28153 | }
|
28154 |
|
28155 | this.groupHammer.on('tap', _bindInstanceProperty(_context9 = this._onGroupClick).call(_context9, this));
|
28156 | this.groupHammer.on('panstart', _bindInstanceProperty(_context10 = this._onGroupDragStart).call(_context10, this));
|
28157 | this.groupHammer.on('panmove', _bindInstanceProperty(_context11 = this._onGroupDrag).call(_context11, this));
|
28158 | this.groupHammer.on('panend', _bindInstanceProperty(_context12 = this._onGroupDragEnd).call(_context12, this));
|
28159 | this.groupHammer.get('pan').set({
|
28160 | threshold: 5,
|
28161 | direction: Hammer.DIRECTION_VERTICAL
|
28162 | });
|
28163 | this.body.dom.centerContainer.addEventListener('mouseover', _bindInstanceProperty(_context13 = this._onMouseOver).call(_context13, this));
|
28164 | this.body.dom.centerContainer.addEventListener('mouseout', _bindInstanceProperty(_context14 = this._onMouseOut).call(_context14, this));
|
28165 | this.body.dom.centerContainer.addEventListener('mousemove', _bindInstanceProperty(_context15 = this._onMouseMove).call(_context15, this));
|
28166 |
|
28167 | this.body.dom.centerContainer.addEventListener('contextmenu', _bindInstanceProperty(_context16 = this._onDragEnd).call(_context16, this));
|
28168 | this.body.dom.centerContainer.addEventListener('mousewheel', _bindInstanceProperty(_context17 = this._onMouseWheel).call(_context17, this));
|
28169 |
|
28170 | this.show();
|
28171 | }
|
28172 | |
28173 |
|
28174 |
|
28175 |
|
28176 |
|
28177 |
|
28178 |
|
28179 |
|
28180 |
|
28181 |
|
28182 |
|
28183 |
|
28184 |
|
28185 |
|
28186 |
|
28187 |
|
28188 |
|
28189 |
|
28190 |
|
28191 |
|
28192 |
|
28193 |
|
28194 |
|
28195 |
|
28196 |
|
28197 |
|
28198 |
|
28199 |
|
28200 |
|
28201 |
|
28202 |
|
28203 |
|
28204 |
|
28205 |
|
28206 |
|
28207 |
|
28208 |
|
28209 |
|
28210 |
|
28211 |
|
28212 |
|
28213 |
|
28214 |
|
28215 |
|
28216 |
|
28217 |
|
28218 |
|
28219 |
|
28220 |
|
28221 |
|
28222 |
|
28223 |
|
28224 |
|
28225 |
|
28226 |
|
28227 |
|
28228 |
|
28229 |
|
28230 |
|
28231 |
|
28232 |
|
28233 |
|
28234 |
|
28235 |
|
28236 |
|
28237 | }, {
|
28238 | key: "setOptions",
|
28239 | value: function setOptions(options) {
|
28240 | var _this3 = this;
|
28241 |
|
28242 | if (options) {
|
28243 | var _context18, _context20;
|
28244 |
|
28245 |
|
28246 | var fields = ['type', 'rtl', 'align', 'order', 'stack', 'stackSubgroups', 'selectable', 'multiselect', 'sequentialSelection', 'multiselectPerGroup', 'longSelectPressTime', 'groupOrder', 'dataAttributes', 'template', 'groupTemplate', 'visibleFrameTemplate', 'hide', 'snap', 'groupOrderSwap', 'showTooltips', 'tooltip', 'tooltipOnItemUpdateTime', 'groupHeightMode', 'onTimeout'];
|
28247 | availableUtils.selectiveExtend(fields, this.options, options);
|
28248 |
|
28249 | if ('itemsAlwaysDraggable' in options) {
|
28250 | if (typeof options.itemsAlwaysDraggable === 'boolean') {
|
28251 | this.options.itemsAlwaysDraggable.item = options.itemsAlwaysDraggable;
|
28252 | this.options.itemsAlwaysDraggable.range = false;
|
28253 | } else if (_typeof(options.itemsAlwaysDraggable) === 'object') {
|
28254 | availableUtils.selectiveExtend(['item', 'range'], this.options.itemsAlwaysDraggable, options.itemsAlwaysDraggable);
|
28255 |
|
28256 | if (!this.options.itemsAlwaysDraggable.item) {
|
28257 | this.options.itemsAlwaysDraggable.range = false;
|
28258 | }
|
28259 | }
|
28260 | }
|
28261 |
|
28262 | if ('sequentialSelection' in options) {
|
28263 | if (typeof options.sequentialSelection === 'boolean') {
|
28264 | this.options.sequentialSelection = options.sequentialSelection;
|
28265 | }
|
28266 | }
|
28267 |
|
28268 | if ('orientation' in options) {
|
28269 | if (typeof options.orientation === 'string') {
|
28270 | this.options.orientation.item = options.orientation === 'top' ? 'top' : 'bottom';
|
28271 | } else if (_typeof(options.orientation) === 'object' && 'item' in options.orientation) {
|
28272 | this.options.orientation.item = options.orientation.item;
|
28273 | }
|
28274 | }
|
28275 |
|
28276 | if ('margin' in options) {
|
28277 | if (typeof options.margin === 'number') {
|
28278 | this.options.margin.axis = options.margin;
|
28279 | this.options.margin.item.horizontal = options.margin;
|
28280 | this.options.margin.item.vertical = options.margin;
|
28281 | } else if (_typeof(options.margin) === 'object') {
|
28282 | availableUtils.selectiveExtend(['axis'], this.options.margin, options.margin);
|
28283 |
|
28284 | if ('item' in options.margin) {
|
28285 | if (typeof options.margin.item === 'number') {
|
28286 | this.options.margin.item.horizontal = options.margin.item;
|
28287 | this.options.margin.item.vertical = options.margin.item;
|
28288 | } else if (_typeof(options.margin.item) === 'object') {
|
28289 | availableUtils.selectiveExtend(['horizontal', 'vertical'], this.options.margin.item, options.margin.item);
|
28290 | }
|
28291 | }
|
28292 | }
|
28293 | }
|
28294 |
|
28295 | _forEachInstanceProperty(_context18 = ['locale', 'locales']).call(_context18, function (key) {
|
28296 | if (key in options) {
|
28297 | _this3.options[key] = options[key];
|
28298 | }
|
28299 | });
|
28300 |
|
28301 | if ('editable' in options) {
|
28302 | if (typeof options.editable === 'boolean') {
|
28303 | this.options.editable.updateTime = options.editable;
|
28304 | this.options.editable.updateGroup = options.editable;
|
28305 | this.options.editable.add = options.editable;
|
28306 | this.options.editable.remove = options.editable;
|
28307 | this.options.editable.overrideItems = false;
|
28308 | } else if (_typeof(options.editable) === 'object') {
|
28309 | availableUtils.selectiveExtend(['updateTime', 'updateGroup', 'add', 'remove', 'overrideItems'], this.options.editable, options.editable);
|
28310 | }
|
28311 | }
|
28312 |
|
28313 | if ('groupEditable' in options) {
|
28314 | if (typeof options.groupEditable === 'boolean') {
|
28315 | this.options.groupEditable.order = options.groupEditable;
|
28316 | this.options.groupEditable.add = options.groupEditable;
|
28317 | this.options.groupEditable.remove = options.groupEditable;
|
28318 | } else if (_typeof(options.groupEditable) === 'object') {
|
28319 | availableUtils.selectiveExtend(['order', 'add', 'remove'], this.options.groupEditable, options.groupEditable);
|
28320 | }
|
28321 | }
|
28322 |
|
28323 |
|
28324 | var addCallback = function addCallback(name) {
|
28325 | var fn = options[name];
|
28326 |
|
28327 | if (fn) {
|
28328 | if (!(typeof fn === 'function')) {
|
28329 | var _context19;
|
28330 |
|
28331 | throw new Error(_concatInstanceProperty(_context19 = "option ".concat(name, " must be a function ")).call(_context19, name, "(item, callback)"));
|
28332 | }
|
28333 |
|
28334 | _this3.options[name] = fn;
|
28335 | }
|
28336 | };
|
28337 |
|
28338 | _forEachInstanceProperty(_context20 = ['onDropObjectOnItem', 'onAdd', 'onUpdate', 'onRemove', 'onMove', 'onMoving', 'onAddGroup', 'onMoveGroup', 'onRemoveGroup']).call(_context20, addCallback);
|
28339 |
|
28340 | if (options.cluster) {
|
28341 | _Object$assign(this.options, {
|
28342 | cluster: options.cluster
|
28343 | });
|
28344 |
|
28345 | if (!this.clusterGenerator) {
|
28346 | this.clusterGenerator = new ClusterGenerator(this);
|
28347 | }
|
28348 |
|
28349 | this.clusterGenerator.setItems(this.items, {
|
28350 | applyOnChangedLevel: false
|
28351 | });
|
28352 | this.markDirty({
|
28353 | refreshItems: true,
|
28354 | restackGroups: true
|
28355 | });
|
28356 | this.redraw();
|
28357 | } else if (this.clusterGenerator) {
|
28358 | this._detachAllClusters();
|
28359 |
|
28360 | this.clusters = [];
|
28361 | this.clusterGenerator = null;
|
28362 | this.options.cluster = undefined;
|
28363 | this.markDirty({
|
28364 | refreshItems: true,
|
28365 | restackGroups: true
|
28366 | });
|
28367 | this.redraw();
|
28368 | } else {
|
28369 |
|
28370 | this.markDirty();
|
28371 | }
|
28372 | }
|
28373 | }
|
28374 | |
28375 |
|
28376 |
|
28377 |
|
28378 |
|
28379 |
|
28380 | }, {
|
28381 | key: "markDirty",
|
28382 | value: function markDirty(options) {
|
28383 | this.groupIds = [];
|
28384 |
|
28385 | if (options) {
|
28386 | if (options.refreshItems) {
|
28387 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.items, function (item) {
|
28388 | item.dirty = true;
|
28389 | if (item.displayed) item.redraw();
|
28390 | });
|
28391 | }
|
28392 |
|
28393 | if (options.restackGroups) {
|
28394 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groups, function (group, key) {
|
28395 | if (key === BACKGROUND) return;
|
28396 | group.stackDirty = true;
|
28397 | });
|
28398 | }
|
28399 | }
|
28400 | }
|
28401 | |
28402 |
|
28403 |
|
28404 |
|
28405 | }, {
|
28406 | key: "destroy",
|
28407 | value: function destroy() {
|
28408 | this.clearPopupTimer();
|
28409 | this.hide();
|
28410 | this.setItems(null);
|
28411 | this.setGroups(null);
|
28412 | this.hammer && this.hammer.destroy();
|
28413 | this.groupHammer && this.groupHammer.destroy();
|
28414 | this.hammer = null;
|
28415 | this.body = null;
|
28416 | this.conversion = null;
|
28417 | }
|
28418 | |
28419 |
|
28420 |
|
28421 |
|
28422 | }, {
|
28423 | key: "hide",
|
28424 | value: function hide() {
|
28425 |
|
28426 | if (this.dom.frame.parentNode) {
|
28427 | this.dom.frame.parentNode.removeChild(this.dom.frame);
|
28428 | }
|
28429 |
|
28430 |
|
28431 | if (this.dom.axis.parentNode) {
|
28432 | this.dom.axis.parentNode.removeChild(this.dom.axis);
|
28433 | }
|
28434 |
|
28435 |
|
28436 | if (this.dom.labelSet.parentNode) {
|
28437 | this.dom.labelSet.parentNode.removeChild(this.dom.labelSet);
|
28438 | }
|
28439 | }
|
28440 | |
28441 |
|
28442 |
|
28443 |
|
28444 | }, {
|
28445 | key: "show",
|
28446 | value: function show() {
|
28447 |
|
28448 | if (!this.dom.frame.parentNode) {
|
28449 | this.body.dom.center.appendChild(this.dom.frame);
|
28450 | }
|
28451 |
|
28452 |
|
28453 | if (!this.dom.axis.parentNode) {
|
28454 | this.body.dom.backgroundVertical.appendChild(this.dom.axis);
|
28455 | }
|
28456 |
|
28457 |
|
28458 | if (!this.dom.labelSet.parentNode) {
|
28459 | if (this.options.rtl) {
|
28460 | this.body.dom.right.appendChild(this.dom.labelSet);
|
28461 | } else {
|
28462 | this.body.dom.left.appendChild(this.dom.labelSet);
|
28463 | }
|
28464 | }
|
28465 | }
|
28466 | |
28467 |
|
28468 |
|
28469 |
|
28470 |
|
28471 | }, {
|
28472 | key: "setPopupTimer",
|
28473 | value: function setPopupTimer(popup) {
|
28474 | this.clearPopupTimer();
|
28475 |
|
28476 | if (popup) {
|
28477 | var delay = this.options.tooltip.delay || typeof this.options.tooltip.delay === 'number' ? this.options.tooltip.delay : 500;
|
28478 | this.popupTimer = _setTimeout(function () {
|
28479 | popup.show();
|
28480 | }, delay);
|
28481 | }
|
28482 | }
|
28483 | |
28484 |
|
28485 |
|
28486 |
|
28487 | }, {
|
28488 | key: "clearPopupTimer",
|
28489 | value: function clearPopupTimer() {
|
28490 | if (this.popupTimer != null) {
|
28491 | clearTimeout(this.popupTimer);
|
28492 | this.popupTimer = null;
|
28493 | }
|
28494 | }
|
28495 | |
28496 |
|
28497 |
|
28498 |
|
28499 |
|
28500 |
|
28501 |
|
28502 |
|
28503 | }, {
|
28504 | key: "setSelection",
|
28505 | value: function setSelection(ids) {
|
28506 | var _context21;
|
28507 |
|
28508 | if (ids == undefined) {
|
28509 | ids = [];
|
28510 | }
|
28511 |
|
28512 | if (!_Array$isArray$1(ids)) {
|
28513 | ids = [ids];
|
28514 | }
|
28515 |
|
28516 | var idsToDeselect = _filterInstanceProperty(_context21 = this.selection).call(_context21, function (id) {
|
28517 | return _indexOfInstanceProperty(ids).call(ids, id) === -1;
|
28518 | });
|
28519 |
|
28520 |
|
28521 | var _iterator = _createForOfIteratorHelper$1(idsToDeselect),
|
28522 | _step;
|
28523 |
|
28524 | try {
|
28525 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
28526 | var selectedId = _step.value;
|
28527 | var item = this.getItemById(selectedId);
|
28528 |
|
28529 | if (item) {
|
28530 | item.unselect();
|
28531 | }
|
28532 | }
|
28533 |
|
28534 | } catch (err) {
|
28535 | _iterator.e(err);
|
28536 | } finally {
|
28537 | _iterator.f();
|
28538 | }
|
28539 |
|
28540 | this.selection = _toConsumableArray(ids);
|
28541 |
|
28542 | var _iterator2 = _createForOfIteratorHelper$1(ids),
|
28543 | _step2;
|
28544 |
|
28545 | try {
|
28546 | for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
28547 | var id = _step2.value;
|
28548 |
|
28549 | var _item2 = this.getItemById(id);
|
28550 |
|
28551 | if (_item2) {
|
28552 | _item2.select();
|
28553 | }
|
28554 | }
|
28555 | } catch (err) {
|
28556 | _iterator2.e(err);
|
28557 | } finally {
|
28558 | _iterator2.f();
|
28559 | }
|
28560 | }
|
28561 | |
28562 |
|
28563 |
|
28564 |
|
28565 |
|
28566 | }, {
|
28567 | key: "getSelection",
|
28568 | value: function getSelection() {
|
28569 | var _context22;
|
28570 |
|
28571 | return _concatInstanceProperty(_context22 = this.selection).call(_context22, []);
|
28572 | }
|
28573 | |
28574 |
|
28575 |
|
28576 |
|
28577 |
|
28578 | }, {
|
28579 | key: "getVisibleItems",
|
28580 | value: function getVisibleItems() {
|
28581 | var range = this.body.range.getRange();
|
28582 | var right;
|
28583 | var left;
|
28584 |
|
28585 | if (this.options.rtl) {
|
28586 | right = this.body.util.toScreen(range.start);
|
28587 | left = this.body.util.toScreen(range.end);
|
28588 | } else {
|
28589 | left = this.body.util.toScreen(range.start);
|
28590 | right = this.body.util.toScreen(range.end);
|
28591 | }
|
28592 |
|
28593 | var ids = [];
|
28594 |
|
28595 | for (var groupId in this.groups) {
|
28596 | if (this.groups.hasOwnProperty(groupId)) {
|
28597 | var group = this.groups[groupId];
|
28598 | var rawVisibleItems = group.isVisible ? group.visibleItems : [];
|
28599 |
|
28600 |
|
28601 | var _iterator3 = _createForOfIteratorHelper$1(rawVisibleItems),
|
28602 | _step3;
|
28603 |
|
28604 | try {
|
28605 | for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
28606 | var item = _step3.value;
|
28607 |
|
28608 |
|
28609 | if (this.options.rtl) {
|
28610 | if (item.right < left && item.right + item.width > right) {
|
28611 | ids.push(item.id);
|
28612 | }
|
28613 | } else {
|
28614 | if (item.left < right && item.left + item.width > left) {
|
28615 | ids.push(item.id);
|
28616 | }
|
28617 | }
|
28618 | }
|
28619 | } catch (err) {
|
28620 | _iterator3.e(err);
|
28621 | } finally {
|
28622 | _iterator3.f();
|
28623 | }
|
28624 | }
|
28625 | }
|
28626 |
|
28627 | return ids;
|
28628 | }
|
28629 | |
28630 |
|
28631 |
|
28632 |
|
28633 |
|
28634 | }, {
|
28635 | key: "getItemsAtCurrentTime",
|
28636 | value: function getItemsAtCurrentTime(timeOfEvent) {
|
28637 | var right;
|
28638 | var left;
|
28639 |
|
28640 | if (this.options.rtl) {
|
28641 | right = this.body.util.toScreen(timeOfEvent);
|
28642 | left = this.body.util.toScreen(timeOfEvent);
|
28643 | } else {
|
28644 | left = this.body.util.toScreen(timeOfEvent);
|
28645 | right = this.body.util.toScreen(timeOfEvent);
|
28646 | }
|
28647 |
|
28648 | var ids = [];
|
28649 |
|
28650 | for (var groupId in this.groups) {
|
28651 | if (this.groups.hasOwnProperty(groupId)) {
|
28652 | var group = this.groups[groupId];
|
28653 | var rawVisibleItems = group.isVisible ? group.visibleItems : [];
|
28654 |
|
28655 |
|
28656 | var _iterator4 = _createForOfIteratorHelper$1(rawVisibleItems),
|
28657 | _step4;
|
28658 |
|
28659 | try {
|
28660 | for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
28661 | var item = _step4.value;
|
28662 |
|
28663 | if (this.options.rtl) {
|
28664 | if (item.right < left && item.right + item.width > right) {
|
28665 | ids.push(item.id);
|
28666 | }
|
28667 | } else {
|
28668 | if (item.left < right && item.left + item.width > left) {
|
28669 | ids.push(item.id);
|
28670 | }
|
28671 | }
|
28672 | }
|
28673 | } catch (err) {
|
28674 | _iterator4.e(err);
|
28675 | } finally {
|
28676 | _iterator4.f();
|
28677 | }
|
28678 | }
|
28679 | }
|
28680 |
|
28681 | return ids;
|
28682 | }
|
28683 | |
28684 |
|
28685 |
|
28686 |
|
28687 |
|
28688 | }, {
|
28689 | key: "getVisibleGroups",
|
28690 | value: function getVisibleGroups() {
|
28691 | var ids = [];
|
28692 |
|
28693 | for (var groupId in this.groups) {
|
28694 | if (this.groups.hasOwnProperty(groupId)) {
|
28695 | var group = this.groups[groupId];
|
28696 |
|
28697 | if (group.isVisible) {
|
28698 | ids.push(groupId);
|
28699 | }
|
28700 | }
|
28701 | }
|
28702 |
|
28703 | return ids;
|
28704 | }
|
28705 | |
28706 |
|
28707 |
|
28708 |
|
28709 |
|
28710 |
|
28711 | }, {
|
28712 | key: "getItemById",
|
28713 | value: function getItemById(id) {
|
28714 | var _context23;
|
28715 |
|
28716 | return this.items[id] || _findInstanceProperty(_context23 = this.clusters).call(_context23, function (cluster) {
|
28717 | return cluster.id === id;
|
28718 | });
|
28719 | }
|
28720 | |
28721 |
|
28722 |
|
28723 |
|
28724 |
|
28725 |
|
28726 | }, {
|
28727 | key: "_deselect",
|
28728 | value: function _deselect(id) {
|
28729 | var selection = this.selection;
|
28730 |
|
28731 | for (var i = 0, ii = selection.length; i < ii; i++) {
|
28732 | if (selection[i] == id) {
|
28733 |
|
28734 | _spliceInstanceProperty(selection).call(selection, i, 1);
|
28735 |
|
28736 | break;
|
28737 | }
|
28738 | }
|
28739 | }
|
28740 | |
28741 |
|
28742 |
|
28743 |
|
28744 |
|
28745 | }, {
|
28746 | key: "redraw",
|
28747 | value: function redraw() {
|
28748 | var _this4 = this;
|
28749 |
|
28750 | var margin = this.options.margin;
|
28751 | var range = this.body.range;
|
28752 | var asSize = availableUtils.option.asSize;
|
28753 | var options = this.options;
|
28754 | var orientation = options.orientation.item;
|
28755 | var resized = false;
|
28756 | var frame = this.dom.frame;
|
28757 |
|
28758 | this.props.top = this.body.domProps.top.height + this.body.domProps.border.top;
|
28759 |
|
28760 | if (this.options.rtl) {
|
28761 | this.props.right = this.body.domProps.right.width + this.body.domProps.border.right;
|
28762 | } else {
|
28763 | this.props.left = this.body.domProps.left.width + this.body.domProps.border.left;
|
28764 | }
|
28765 |
|
28766 |
|
28767 | frame.className = 'vis-itemset';
|
28768 |
|
28769 | if (this.options.cluster) {
|
28770 | this._clusterItems();
|
28771 | }
|
28772 |
|
28773 |
|
28774 | resized = this._orderGroups() || resized;
|
28775 |
|
28776 |
|
28777 | var visibleInterval = range.end - range.start;
|
28778 | var zoomed = visibleInterval != this.lastVisibleInterval || this.props.width != this.props.lastWidth;
|
28779 | var scrolled = range.start != this.lastRangeStart;
|
28780 | var changedStackOption = options.stack != this.lastStack;
|
28781 | var changedStackSubgroupsOption = options.stackSubgroups != this.lastStackSubgroups;
|
28782 | var forceRestack = zoomed || scrolled || changedStackOption || changedStackSubgroupsOption;
|
28783 | this.lastVisibleInterval = visibleInterval;
|
28784 | this.lastRangeStart = range.start;
|
28785 | this.lastStack = options.stack;
|
28786 | this.lastStackSubgroups = options.stackSubgroups;
|
28787 | this.props.lastWidth = this.props.width;
|
28788 |
|
28789 | var firstGroup = this._firstGroup();
|
28790 |
|
28791 | var firstMargin = {
|
28792 | item: margin.item,
|
28793 | axis: margin.axis
|
28794 | };
|
28795 | var nonFirstMargin = {
|
28796 | item: margin.item,
|
28797 | axis: margin.item.vertical / 2
|
28798 | };
|
28799 | var height = 0;
|
28800 | var minHeight = margin.axis + margin.item.vertical;
|
28801 |
|
28802 | this.groups[BACKGROUND].redraw(range, nonFirstMargin, forceRestack);
|
28803 | var redrawQueue = {};
|
28804 | var redrawQueueLength = 0;
|
28805 |
|
28806 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groups, function (group, key) {
|
28807 | if (key === BACKGROUND) return;
|
28808 | var groupMargin = group == firstGroup ? firstMargin : nonFirstMargin;
|
28809 | var returnQueue = true;
|
28810 | redrawQueue[key] = group.redraw(range, groupMargin, forceRestack, returnQueue);
|
28811 | redrawQueueLength = redrawQueue[key].length;
|
28812 | });
|
28813 |
|
28814 | var needRedraw = redrawQueueLength > 0;
|
28815 |
|
28816 | if (needRedraw) {
|
28817 | (function () {
|
28818 | var redrawResults = {};
|
28819 |
|
28820 | var _loop = function _loop(i) {
|
28821 | _forEachInstanceProperty(availableUtils).call(availableUtils, redrawQueue, function (fns, key) {
|
28822 | redrawResults[key] = fns[i]();
|
28823 | });
|
28824 | };
|
28825 |
|
28826 | for (var i = 0; i < redrawQueueLength; i++) {
|
28827 | _loop(i);
|
28828 | }
|
28829 |
|
28830 |
|
28831 | _forEachInstanceProperty(availableUtils).call(availableUtils, _this4.groups, function (group, key) {
|
28832 | if (key === BACKGROUND) return;
|
28833 | var groupResized = redrawResults[key];
|
28834 | resized = groupResized || resized;
|
28835 | height += group.height;
|
28836 | });
|
28837 |
|
28838 | height = Math.max(height, minHeight);
|
28839 | })();
|
28840 | }
|
28841 |
|
28842 | height = Math.max(height, minHeight);
|
28843 |
|
28844 | frame.style.height = asSize(height);
|
28845 |
|
28846 | this.props.width = frame.offsetWidth;
|
28847 | this.props.height = height;
|
28848 |
|
28849 | this.dom.axis.style.top = asSize(orientation == 'top' ? this.body.domProps.top.height + this.body.domProps.border.top : this.body.domProps.top.height + this.body.domProps.centerContainer.height);
|
28850 |
|
28851 | if (this.options.rtl) {
|
28852 | this.dom.axis.style.right = '0';
|
28853 | } else {
|
28854 | this.dom.axis.style.left = '0';
|
28855 | }
|
28856 |
|
28857 | this.hammer.get('press').set({
|
28858 | time: this.options.longSelectPressTime
|
28859 | });
|
28860 | this.initialItemSetDrawn = true;
|
28861 |
|
28862 | resized = this._isResized() || resized;
|
28863 | return resized;
|
28864 | }
|
28865 | |
28866 |
|
28867 |
|
28868 |
|
28869 |
|
28870 |
|
28871 | }, {
|
28872 | key: "_firstGroup",
|
28873 | value: function _firstGroup() {
|
28874 | var firstGroupIndex = this.options.orientation.item == 'top' ? 0 : this.groupIds.length - 1;
|
28875 | var firstGroupId = this.groupIds[firstGroupIndex];
|
28876 | var firstGroup = this.groups[firstGroupId] || this.groups[UNGROUPED$1];
|
28877 | return firstGroup || null;
|
28878 | }
|
28879 | |
28880 |
|
28881 |
|
28882 |
|
28883 |
|
28884 |
|
28885 | }, {
|
28886 | key: "_updateUngrouped",
|
28887 | value: function _updateUngrouped() {
|
28888 | var ungrouped = this.groups[UNGROUPED$1];
|
28889 | var item;
|
28890 | var itemId;
|
28891 |
|
28892 | if (this.groupsData) {
|
28893 |
|
28894 | if (ungrouped) {
|
28895 | ungrouped.dispose();
|
28896 | delete this.groups[UNGROUPED$1];
|
28897 |
|
28898 | for (itemId in this.items) {
|
28899 | if (this.items.hasOwnProperty(itemId)) {
|
28900 | item = this.items[itemId];
|
28901 | item.parent && item.parent.remove(item);
|
28902 | var groupId = this.getGroupId(item.data);
|
28903 | var group = this.groups[groupId];
|
28904 | group && group.add(item) || item.hide();
|
28905 | }
|
28906 | }
|
28907 | }
|
28908 | } else {
|
28909 |
|
28910 | if (!ungrouped) {
|
28911 | var id = null;
|
28912 | var data = null;
|
28913 | ungrouped = new Group(id, data, this);
|
28914 | this.groups[UNGROUPED$1] = ungrouped;
|
28915 |
|
28916 | for (itemId in this.items) {
|
28917 | if (this.items.hasOwnProperty(itemId)) {
|
28918 | item = this.items[itemId];
|
28919 | ungrouped.add(item);
|
28920 | }
|
28921 | }
|
28922 |
|
28923 | ungrouped.show();
|
28924 | }
|
28925 | }
|
28926 | }
|
28927 | |
28928 |
|
28929 |
|
28930 |
|
28931 |
|
28932 | }, {
|
28933 | key: "getLabelSet",
|
28934 | value: function getLabelSet() {
|
28935 | return this.dom.labelSet;
|
28936 | }
|
28937 | |
28938 |
|
28939 |
|
28940 |
|
28941 |
|
28942 | }, {
|
28943 | key: "setItems",
|
28944 | value: function setItems(items) {
|
28945 | this.itemsSettingTime = new Date();
|
28946 | var me = this;
|
28947 | var ids;
|
28948 | var oldItemsData = this.itemsData;
|
28949 |
|
28950 | if (!items) {
|
28951 | this.itemsData = null;
|
28952 | } else if (isDataViewLike(items)) {
|
28953 | this.itemsData = typeCoerceDataSet(items);
|
28954 | } else {
|
28955 | throw new TypeError('Data must implement the interface of DataSet or DataView');
|
28956 | }
|
28957 |
|
28958 | if (oldItemsData) {
|
28959 |
|
28960 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.itemListeners, function (callback, event) {
|
28961 | oldItemsData.off(event, callback);
|
28962 | });
|
28963 |
|
28964 |
|
28965 | oldItemsData.dispose();
|
28966 |
|
28967 | ids = oldItemsData.getIds();
|
28968 |
|
28969 | this._onRemove(ids);
|
28970 | }
|
28971 |
|
28972 | if (this.itemsData) {
|
28973 |
|
28974 | var id = this.id;
|
28975 |
|
28976 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.itemListeners, function (callback, event) {
|
28977 | me.itemsData.on(event, callback, id);
|
28978 | });
|
28979 |
|
28980 |
|
28981 | ids = this.itemsData.getIds();
|
28982 |
|
28983 | this._onAdd(ids);
|
28984 |
|
28985 |
|
28986 | this._updateUngrouped();
|
28987 | }
|
28988 |
|
28989 | this.body.emitter.emit('_change', {
|
28990 | queue: true
|
28991 | });
|
28992 | }
|
28993 | |
28994 |
|
28995 |
|
28996 |
|
28997 |
|
28998 | }, {
|
28999 | key: "getItems",
|
29000 | value: function getItems() {
|
29001 | return this.itemsData != null ? this.itemsData.rawDS : null;
|
29002 | }
|
29003 | |
29004 |
|
29005 |
|
29006 |
|
29007 |
|
29008 | }, {
|
29009 | key: "setGroups",
|
29010 | value: function setGroups(groups) {
|
29011 | var me = this;
|
29012 | var ids;
|
29013 |
|
29014 | if (this.groupsData) {
|
29015 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groupListeners, function (callback, event) {
|
29016 | me.groupsData.off(event, callback);
|
29017 | });
|
29018 |
|
29019 |
|
29020 | ids = this.groupsData.getIds();
|
29021 | this.groupsData = null;
|
29022 |
|
29023 | this._onRemoveGroups(ids);
|
29024 |
|
29025 | }
|
29026 |
|
29027 |
|
29028 | if (!groups) {
|
29029 | this.groupsData = null;
|
29030 | } else if (isDataViewLike(groups)) {
|
29031 | this.groupsData = groups;
|
29032 | } else {
|
29033 | throw new TypeError('Data must implement the interface of DataSet or DataView');
|
29034 | }
|
29035 |
|
29036 | if (this.groupsData) {
|
29037 | var _context24;
|
29038 |
|
29039 |
|
29040 | var groupsData = this.groupsData.getDataSet();
|
29041 |
|
29042 | _forEachInstanceProperty(_context24 = groupsData.get()).call(_context24, function (group) {
|
29043 | if (group.nestedGroups) {
|
29044 | var _context25;
|
29045 |
|
29046 | _forEachInstanceProperty(_context25 = group.nestedGroups).call(_context25, function (nestedGroupId) {
|
29047 | var updatedNestedGroup = groupsData.get(nestedGroupId);
|
29048 | updatedNestedGroup.nestedInGroup = group.id;
|
29049 |
|
29050 | if (group.showNested == false) {
|
29051 | updatedNestedGroup.visible = false;
|
29052 | }
|
29053 |
|
29054 | groupsData.update(updatedNestedGroup);
|
29055 | });
|
29056 | }
|
29057 | });
|
29058 |
|
29059 |
|
29060 | var id = this.id;
|
29061 |
|
29062 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groupListeners, function (callback, event) {
|
29063 | me.groupsData.on(event, callback, id);
|
29064 | });
|
29065 |
|
29066 |
|
29067 | ids = this.groupsData.getIds();
|
29068 |
|
29069 | this._onAddGroups(ids);
|
29070 | }
|
29071 |
|
29072 |
|
29073 | this._updateUngrouped();
|
29074 |
|
29075 |
|
29076 | this._order();
|
29077 |
|
29078 | if (this.options.cluster) {
|
29079 | this.clusterGenerator.updateData();
|
29080 |
|
29081 | this._clusterItems();
|
29082 |
|
29083 | this.markDirty({
|
29084 | refreshItems: true,
|
29085 | restackGroups: true
|
29086 | });
|
29087 | }
|
29088 |
|
29089 | this.body.emitter.emit('_change', {
|
29090 | queue: true
|
29091 | });
|
29092 | }
|
29093 | |
29094 |
|
29095 |
|
29096 |
|
29097 |
|
29098 | }, {
|
29099 | key: "getGroups",
|
29100 | value: function getGroups() {
|
29101 | return this.groupsData;
|
29102 | }
|
29103 | |
29104 |
|
29105 |
|
29106 |
|
29107 |
|
29108 | }, {
|
29109 | key: "removeItem",
|
29110 | value: function removeItem(id) {
|
29111 | var _this5 = this;
|
29112 |
|
29113 | var item = this.itemsData.get(id);
|
29114 |
|
29115 | if (item) {
|
29116 |
|
29117 | this.options.onRemove(item, function (item) {
|
29118 | if (item) {
|
29119 |
|
29120 |
|
29121 | _this5.itemsData.remove(id);
|
29122 | }
|
29123 | });
|
29124 | }
|
29125 | }
|
29126 | |
29127 |
|
29128 |
|
29129 |
|
29130 |
|
29131 |
|
29132 |
|
29133 | }, {
|
29134 | key: "_getType",
|
29135 | value: function _getType(itemData) {
|
29136 | return itemData.type || this.options.type || (itemData.end ? 'range' : 'box');
|
29137 | }
|
29138 | |
29139 |
|
29140 |
|
29141 |
|
29142 |
|
29143 |
|
29144 |
|
29145 | }, {
|
29146 | key: "getGroupId",
|
29147 | value: function getGroupId(itemData) {
|
29148 | var type = this._getType(itemData);
|
29149 |
|
29150 | if (type == 'background' && itemData.group == undefined) {
|
29151 | return BACKGROUND;
|
29152 | } else {
|
29153 | return this.groupsData ? itemData.group : UNGROUPED$1;
|
29154 | }
|
29155 | }
|
29156 | |
29157 |
|
29158 |
|
29159 |
|
29160 |
|
29161 |
|
29162 | }, {
|
29163 | key: "_onUpdate",
|
29164 | value: function _onUpdate(ids) {
|
29165 | var _this6 = this;
|
29166 |
|
29167 | var me = this;
|
29168 |
|
29169 | _forEachInstanceProperty(ids).call(ids, function (id) {
|
29170 | var itemData = me.itemsData.get(id);
|
29171 | var item = me.items[id];
|
29172 | var type = itemData ? me._getType(itemData) : null;
|
29173 | var constructor = ItemSet.types[type];
|
29174 | var selected;
|
29175 |
|
29176 | if (item) {
|
29177 |
|
29178 | if (!constructor || !(item instanceof constructor)) {
|
29179 |
|
29180 | selected = item.selected;
|
29181 |
|
29182 | me._removeItem(item);
|
29183 |
|
29184 | item = null;
|
29185 | } else {
|
29186 | me._updateItem(item, itemData);
|
29187 | }
|
29188 | }
|
29189 |
|
29190 | if (!item && itemData) {
|
29191 |
|
29192 | if (constructor) {
|
29193 | item = new constructor(itemData, me.conversion, me.options);
|
29194 | item.id = id; // TODO: not so nice setting id afterwards
|
29195 |
|
29196 | me._addItem(item);
|
29197 |
|
29198 | if (selected) {
|
29199 | _this6.selection.push(id);
|
29200 |
|
29201 | item.select();
|
29202 | }
|
29203 | } else {
|
29204 | throw new TypeError("Unknown item type \"".concat(type, "\""));
|
29205 | }
|
29206 | }
|
29207 | });
|
29208 |
|
29209 | this._order();
|
29210 |
|
29211 | if (this.options.cluster) {
|
29212 | this.clusterGenerator.setItems(this.items, {
|
29213 | applyOnChangedLevel: false
|
29214 | });
|
29215 |
|
29216 | this._clusterItems();
|
29217 | }
|
29218 |
|
29219 | this.body.emitter.emit('_change', {
|
29220 | queue: true
|
29221 | });
|
29222 | }
|
29223 | |
29224 |
|
29225 |
|
29226 |
|
29227 |
|
29228 |
|
29229 | }, {
|
29230 | key: "_onRemove",
|
29231 | value: function _onRemove(ids) {
|
29232 | var count = 0;
|
29233 | var me = this;
|
29234 |
|
29235 | _forEachInstanceProperty(ids).call(ids, function (id) {
|
29236 | var item = me.items[id];
|
29237 |
|
29238 | if (item) {
|
29239 | count++;
|
29240 |
|
29241 | me._removeItem(item);
|
29242 | }
|
29243 | });
|
29244 |
|
29245 | if (count) {
|
29246 |
|
29247 | this._order();
|
29248 |
|
29249 | this.body.emitter.emit('_change', {
|
29250 | queue: true
|
29251 | });
|
29252 | }
|
29253 | }
|
29254 | |
29255 |
|
29256 |
|
29257 |
|
29258 |
|
29259 | }, {
|
29260 | key: "_order",
|
29261 | value: function _order() {
|
29262 |
|
29263 |
|
29264 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groups, function (group) {
|
29265 | group.order();
|
29266 | });
|
29267 | }
|
29268 | |
29269 |
|
29270 |
|
29271 |
|
29272 |
|
29273 |
|
29274 | }, {
|
29275 | key: "_onUpdateGroups",
|
29276 | value: function _onUpdateGroups(ids) {
|
29277 | this._onAddGroups(ids);
|
29278 | }
|
29279 | |
29280 |
|
29281 |
|
29282 |
|
29283 |
|
29284 |
|
29285 | }, {
|
29286 | key: "_onAddGroups",
|
29287 | value: function _onAddGroups(ids) {
|
29288 | var me = this;
|
29289 |
|
29290 | _forEachInstanceProperty(ids).call(ids, function (id) {
|
29291 | var groupData = me.groupsData.get(id);
|
29292 | var group = me.groups[id];
|
29293 |
|
29294 | if (!group) {
|
29295 |
|
29296 | if (id == UNGROUPED$1 || id == BACKGROUND) {
|
29297 | throw new Error("Illegal group id. ".concat(id, " is a reserved id."));
|
29298 | }
|
29299 |
|
29300 | var groupOptions = _Object$create(me.options);
|
29301 |
|
29302 | availableUtils.extend(groupOptions, {
|
29303 | height: null
|
29304 | });
|
29305 | group = new Group(id, groupData, me);
|
29306 | me.groups[id] = group;
|
29307 |
|
29308 | for (var itemId in me.items) {
|
29309 | if (me.items.hasOwnProperty(itemId)) {
|
29310 | var item = me.items[itemId];
|
29311 |
|
29312 | if (item.data.group == id) {
|
29313 | group.add(item);
|
29314 | }
|
29315 | }
|
29316 | }
|
29317 |
|
29318 | group.order();
|
29319 | group.show();
|
29320 | } else {
|
29321 |
|
29322 | group.setData(groupData);
|
29323 | }
|
29324 | });
|
29325 |
|
29326 | this.body.emitter.emit('_change', {
|
29327 | queue: true
|
29328 | });
|
29329 | }
|
29330 | |
29331 |
|
29332 |
|
29333 |
|
29334 |
|
29335 |
|
29336 | }, {
|
29337 | key: "_onRemoveGroups",
|
29338 | value: function _onRemoveGroups(ids) {
|
29339 | var _this7 = this;
|
29340 |
|
29341 | _forEachInstanceProperty(ids).call(ids, function (id) {
|
29342 | var group = _this7.groups[id];
|
29343 |
|
29344 | if (group) {
|
29345 | group.dispose();
|
29346 | delete _this7.groups[id];
|
29347 | }
|
29348 | });
|
29349 |
|
29350 | if (this.options.cluster) {
|
29351 | this.clusterGenerator.updateData();
|
29352 |
|
29353 | this._clusterItems();
|
29354 | }
|
29355 |
|
29356 | this.markDirty({
|
29357 | restackGroups: !!this.options.cluster
|
29358 | });
|
29359 | this.body.emitter.emit('_change', {
|
29360 | queue: true
|
29361 | });
|
29362 | }
|
29363 | |
29364 |
|
29365 |
|
29366 |
|
29367 |
|
29368 |
|
29369 | }, {
|
29370 | key: "_orderGroups",
|
29371 | value: function _orderGroups() {
|
29372 | if (this.groupsData) {
|
29373 |
|
29374 | var groupIds = this.groupsData.getIds({
|
29375 | order: this.options.groupOrder
|
29376 | });
|
29377 | groupIds = this._orderNestedGroups(groupIds);
|
29378 | var changed = !availableUtils.equalArray(groupIds, this.groupIds);
|
29379 |
|
29380 | if (changed) {
|
29381 |
|
29382 | var groups = this.groups;
|
29383 |
|
29384 | _forEachInstanceProperty(groupIds).call(groupIds, function (groupId) {
|
29385 | groups[groupId].hide();
|
29386 | });
|
29387 |
|
29388 |
|
29389 | _forEachInstanceProperty(groupIds).call(groupIds, function (groupId) {
|
29390 | groups[groupId].show();
|
29391 | });
|
29392 |
|
29393 | this.groupIds = groupIds;
|
29394 | }
|
29395 |
|
29396 | return changed;
|
29397 | } else {
|
29398 | return false;
|
29399 | }
|
29400 | }
|
29401 | |
29402 |
|
29403 |
|
29404 |
|
29405 |
|
29406 |
|
29407 |
|
29408 |
|
29409 | }, {
|
29410 | key: "_orderNestedGroups",
|
29411 | value: function _orderNestedGroups(groupIds) {
|
29412 | var _this8 = this;
|
29413 |
|
29414 | |
29415 |
|
29416 |
|
29417 |
|
29418 |
|
29419 |
|
29420 |
|
29421 |
|
29422 | function getOrderedNestedGroups(t, groupIds) {
|
29423 | var result = [];
|
29424 |
|
29425 | _forEachInstanceProperty(groupIds).call(groupIds, function (groupId) {
|
29426 | result.push(groupId);
|
29427 | var groupData = t.groupsData.get(groupId);
|
29428 |
|
29429 | if (groupData.nestedGroups) {
|
29430 | var _context26;
|
29431 |
|
29432 | var nestedGroupIds = _mapInstanceProperty(_context26 = t.groupsData.get({
|
29433 | filter: function filter(nestedGroup) {
|
29434 | return nestedGroup.nestedInGroup == groupId;
|
29435 | },
|
29436 | order: t.options.groupOrder
|
29437 | })).call(_context26, function (nestedGroup) {
|
29438 | return nestedGroup.id;
|
29439 | });
|
29440 |
|
29441 | result = _concatInstanceProperty(result).call(result, getOrderedNestedGroups(t, nestedGroupIds));
|
29442 | }
|
29443 | });
|
29444 |
|
29445 | return result;
|
29446 | }
|
29447 |
|
29448 | var topGroupIds = _filterInstanceProperty(groupIds).call(groupIds, function (groupId) {
|
29449 | return !_this8.groupsData.get(groupId).nestedInGroup;
|
29450 | });
|
29451 |
|
29452 | return getOrderedNestedGroups(this, topGroupIds);
|
29453 | }
|
29454 | |
29455 |
|
29456 |
|
29457 |
|
29458 |
|
29459 |
|
29460 | }, {
|
29461 | key: "_addItem",
|
29462 | value: function _addItem(item) {
|
29463 | this.items[item.id] = item;
|
29464 |
|
29465 | var groupId = this.getGroupId(item.data);
|
29466 | var group = this.groups[groupId];
|
29467 |
|
29468 | if (!group) {
|
29469 | item.groupShowing = false;
|
29470 | } else if (group && group.data && group.data.showNested) {
|
29471 | item.groupShowing = true;
|
29472 | }
|
29473 |
|
29474 | if (group) group.add(item);
|
29475 | }
|
29476 | |
29477 |
|
29478 |
|
29479 |
|
29480 |
|
29481 |
|
29482 |
|
29483 | }, {
|
29484 | key: "_updateItem",
|
29485 | value: function _updateItem(item, itemData) {
|
29486 |
|
29487 | item.setData(itemData);
|
29488 | var groupId = this.getGroupId(item.data);
|
29489 | var group = this.groups[groupId];
|
29490 |
|
29491 | if (!group) {
|
29492 | item.groupShowing = false;
|
29493 | } else if (group && group.data && group.data.showNested) {
|
29494 | item.groupShowing = true;
|
29495 | }
|
29496 | }
|
29497 | |
29498 |
|
29499 |
|
29500 |
|
29501 |
|
29502 |
|
29503 |
|
29504 | }, {
|
29505 | key: "_removeItem",
|
29506 | value: function _removeItem(item) {
|
29507 | var _context27, _context28;
|
29508 |
|
29509 |
|
29510 | item.hide();
|
29511 |
|
29512 | delete this.items[item.id];
|
29513 |
|
29514 | var index = _indexOfInstanceProperty(_context27 = this.selection).call(_context27, item.id);
|
29515 |
|
29516 | if (index != -1) _spliceInstanceProperty(_context28 = this.selection).call(_context28, index, 1);
|
29517 |
|
29518 | item.parent && item.parent.remove(item);
|
29519 |
|
29520 | if (this.popup != null) {
|
29521 | this.popup.hide();
|
29522 | }
|
29523 | }
|
29524 | |
29525 |
|
29526 |
|
29527 |
|
29528 |
|
29529 |
|
29530 |
|
29531 | }, {
|
29532 | key: "_constructByEndArray",
|
29533 | value: function _constructByEndArray(array) {
|
29534 | var endArray = [];
|
29535 |
|
29536 | for (var i = 0; i < array.length; i++) {
|
29537 | if (array[i] instanceof RangeItem) {
|
29538 | endArray.push(array[i]);
|
29539 | }
|
29540 | }
|
29541 |
|
29542 | return endArray;
|
29543 | }
|
29544 | |
29545 |
|
29546 |
|
29547 |
|
29548 |
|
29549 |
|
29550 |
|
29551 |
|
29552 |
|
29553 |
|
29554 |
|
29555 | }, {
|
29556 | key: "_onTouch",
|
29557 | value: function _onTouch(event) {
|
29558 |
|
29559 | this.touchParams.item = this.itemFromTarget(event);
|
29560 | this.touchParams.dragLeftItem = event.target.dragLeftItem || false;
|
29561 | this.touchParams.dragRightItem = event.target.dragRightItem || false;
|
29562 | this.touchParams.itemProps = null;
|
29563 | }
|
29564 | |
29565 |
|
29566 |
|
29567 |
|
29568 |
|
29569 |
|
29570 |
|
29571 |
|
29572 | }, {
|
29573 | key: "_getGroupIndex",
|
29574 | value: function _getGroupIndex(groupId) {
|
29575 | for (var i = 0; i < this.groupIds.length; i++) {
|
29576 | if (groupId == this.groupIds[i]) return i;
|
29577 | }
|
29578 | }
|
29579 | |
29580 |
|
29581 |
|
29582 |
|
29583 |
|
29584 |
|
29585 | }, {
|
29586 | key: "_onDragStart",
|
29587 | value: function _onDragStart(event) {
|
29588 | var _this9 = this;
|
29589 |
|
29590 | if (this.touchParams.itemIsDragging) {
|
29591 | return;
|
29592 | }
|
29593 |
|
29594 | var item = this.touchParams.item || null;
|
29595 | var me = this;
|
29596 | var props;
|
29597 |
|
29598 | if (item && (item.selected || this.options.itemsAlwaysDraggable.item)) {
|
29599 | if (this.options.editable.overrideItems && !this.options.editable.updateTime && !this.options.editable.updateGroup) {
|
29600 | return;
|
29601 | }
|
29602 |
|
29603 |
|
29604 | if (item.editable != null && !item.editable.updateTime && !item.editable.updateGroup && !this.options.editable.overrideItems) {
|
29605 | return;
|
29606 | }
|
29607 |
|
29608 | var dragLeftItem = this.touchParams.dragLeftItem;
|
29609 | var dragRightItem = this.touchParams.dragRightItem;
|
29610 | this.touchParams.itemIsDragging = true;
|
29611 | this.touchParams.selectedItem = item;
|
29612 |
|
29613 | if (dragLeftItem) {
|
29614 | props = {
|
29615 | item: dragLeftItem,
|
29616 | initialX: event.center.x,
|
29617 | dragLeft: true,
|
29618 | data: this._cloneItemData(item.data)
|
29619 | };
|
29620 | this.touchParams.itemProps = [props];
|
29621 | } else if (dragRightItem) {
|
29622 | props = {
|
29623 | item: dragRightItem,
|
29624 | initialX: event.center.x,
|
29625 | dragRight: true,
|
29626 | data: this._cloneItemData(item.data)
|
29627 | };
|
29628 | this.touchParams.itemProps = [props];
|
29629 | } else if (this.options.editable.add && (event.srcEvent.ctrlKey || event.srcEvent.metaKey)) {
|
29630 |
|
29631 | this._onDragStartAddItem(event);
|
29632 | } else {
|
29633 | if (this.groupIds.length < 1) {
|
29634 |
|
29635 |
|
29636 | this.redraw();
|
29637 | }
|
29638 |
|
29639 | var baseGroupIndex = this._getGroupIndex(item.data.group);
|
29640 |
|
29641 | var itemsToDrag = this.options.itemsAlwaysDraggable.item && !item.selected ? [item.id] : this.getSelection();
|
29642 | this.touchParams.itemProps = _mapInstanceProperty(itemsToDrag).call(itemsToDrag, function (id) {
|
29643 | var item = me.items[id];
|
29644 |
|
29645 | var groupIndex = me._getGroupIndex(item.data.group);
|
29646 |
|
29647 | return {
|
29648 | item: item,
|
29649 | initialX: event.center.x,
|
29650 | groupOffset: baseGroupIndex - groupIndex,
|
29651 | data: _this9._cloneItemData(item.data)
|
29652 | };
|
29653 | });
|
29654 | }
|
29655 |
|
29656 | event.stopPropagation();
|
29657 | } else if (this.options.editable.add && (event.srcEvent.ctrlKey || event.srcEvent.metaKey)) {
|
29658 |
|
29659 | this._onDragStartAddItem(event);
|
29660 | }
|
29661 | }
|
29662 | |
29663 |
|
29664 |
|
29665 |
|
29666 |
|
29667 |
|
29668 | }, {
|
29669 | key: "_onDragStartAddItem",
|
29670 | value: function _onDragStartAddItem(event) {
|
29671 | var snap = this.options.snap || null;
|
29672 | var frameRect = this.dom.frame.getBoundingClientRect();
|
29673 |
|
29674 | var x = this.options.rtl ? frameRect.right - event.center.x + 10 : event.center.x - frameRect.left - 10;
|
29675 | var time = this.body.util.toTime(x);
|
29676 | var scale = this.body.util.getScale();
|
29677 | var step = this.body.util.getStep();
|
29678 | var start = snap ? snap(time, scale, step) : time;
|
29679 | var end = start;
|
29680 | var itemData = {
|
29681 | type: 'range',
|
29682 | start: start,
|
29683 | end: end,
|
29684 | content: 'new item'
|
29685 | };
|
29686 | var id = v4();
|
29687 | itemData[this.itemsData.idProp] = id;
|
29688 | var group = this.groupFromTarget(event);
|
29689 |
|
29690 | if (group) {
|
29691 | itemData.group = group.groupId;
|
29692 | }
|
29693 |
|
29694 | var newItem = new RangeItem(itemData, this.conversion, this.options);
|
29695 | newItem.id = id;
|
29696 |
|
29697 | newItem.data = this._cloneItemData(itemData);
|
29698 |
|
29699 | this._addItem(newItem);
|
29700 |
|
29701 | this.touchParams.selectedItem = newItem;
|
29702 | var props = {
|
29703 | item: newItem,
|
29704 | initialX: event.center.x,
|
29705 | data: newItem.data
|
29706 | };
|
29707 |
|
29708 | if (this.options.rtl) {
|
29709 | props.dragLeft = true;
|
29710 | } else {
|
29711 | props.dragRight = true;
|
29712 | }
|
29713 |
|
29714 | this.touchParams.itemProps = [props];
|
29715 | event.stopPropagation();
|
29716 | }
|
29717 | |
29718 |
|
29719 |
|
29720 |
|
29721 |
|
29722 |
|
29723 | }, {
|
29724 | key: "_onDrag",
|
29725 | value: function _onDrag(event) {
|
29726 | var _this10 = this;
|
29727 |
|
29728 | if (this.popup != null && this.options.showTooltips && !this.popup.hidden) {
|
29729 |
|
29730 | var container = this.body.dom.centerContainer;
|
29731 | var containerRect = container.getBoundingClientRect();
|
29732 | this.popup.setPosition(event.center.x - containerRect.left + container.offsetLeft, event.center.y - containerRect.top + container.offsetTop);
|
29733 | this.popup.show();
|
29734 | }
|
29735 |
|
29736 | if (this.touchParams.itemProps) {
|
29737 | var _context29;
|
29738 |
|
29739 | event.stopPropagation();
|
29740 | var me = this;
|
29741 | var snap = this.options.snap || null;
|
29742 | var domRootOffsetLeft = this.body.dom.root.offsetLeft;
|
29743 | var xOffset = this.options.rtl ? domRootOffsetLeft + this.body.domProps.right.width : domRootOffsetLeft + this.body.domProps.left.width;
|
29744 | var scale = this.body.util.getScale();
|
29745 | var step = this.body.util.getStep();
|
29746 |
|
29747 | var selectedItem = this.touchParams.selectedItem;
|
29748 | var updateGroupAllowed = (this.options.editable.overrideItems || selectedItem.editable == null) && this.options.editable.updateGroup || !this.options.editable.overrideItems && selectedItem.editable != null && selectedItem.editable.updateGroup;
|
29749 | var newGroupBase = null;
|
29750 |
|
29751 | if (updateGroupAllowed && selectedItem) {
|
29752 | if (selectedItem.data.group != undefined) {
|
29753 |
|
29754 | var group = me.groupFromTarget(event);
|
29755 |
|
29756 | if (group) {
|
29757 |
|
29758 |
|
29759 | newGroupBase = this._getGroupIndex(group.groupId);
|
29760 | }
|
29761 | }
|
29762 | }
|
29763 |
|
29764 |
|
29765 | _forEachInstanceProperty(_context29 = this.touchParams.itemProps).call(_context29, function (props) {
|
29766 | var current = me.body.util.toTime(event.center.x - xOffset);
|
29767 | var initial = me.body.util.toTime(props.initialX - xOffset);
|
29768 | var offset;
|
29769 | var initialStart;
|
29770 | var initialEnd;
|
29771 | var start;
|
29772 | var end;
|
29773 |
|
29774 | if (_this10.options.rtl) {
|
29775 | offset = -(current - initial);
|
29776 | } else {
|
29777 | offset = current - initial;
|
29778 | }
|
29779 |
|
29780 | var itemData = _this10._cloneItemData(props.item.data);
|
29781 |
|
29782 |
|
29783 | if (props.item.editable != null && !props.item.editable.updateTime && !props.item.editable.updateGroup && !me.options.editable.overrideItems) {
|
29784 | return;
|
29785 | }
|
29786 |
|
29787 | var updateTimeAllowed = (_this10.options.editable.overrideItems || selectedItem.editable == null) && _this10.options.editable.updateTime || !_this10.options.editable.overrideItems && selectedItem.editable != null && selectedItem.editable.updateTime;
|
29788 |
|
29789 | if (updateTimeAllowed) {
|
29790 | if (props.dragLeft) {
|
29791 |
|
29792 | if (_this10.options.rtl) {
|
29793 | if (itemData.end != undefined) {
|
29794 | initialEnd = availableUtils.convert(props.data.end, 'Date');
|
29795 | end = new Date(initialEnd.valueOf() + offset);
|
29796 |
|
29797 | itemData.end = snap ? snap(end, scale, step) : end;
|
29798 | }
|
29799 | } else {
|
29800 | if (itemData.start != undefined) {
|
29801 | initialStart = availableUtils.convert(props.data.start, 'Date');
|
29802 | start = new Date(initialStart.valueOf() + offset);
|
29803 |
|
29804 | itemData.start = snap ? snap(start, scale, step) : start;
|
29805 | }
|
29806 | }
|
29807 | } else if (props.dragRight) {
|
29808 |
|
29809 | if (_this10.options.rtl) {
|
29810 | if (itemData.start != undefined) {
|
29811 | initialStart = availableUtils.convert(props.data.start, 'Date');
|
29812 | start = new Date(initialStart.valueOf() + offset);
|
29813 |
|
29814 | itemData.start = snap ? snap(start, scale, step) : start;
|
29815 | }
|
29816 | } else {
|
29817 | if (itemData.end != undefined) {
|
29818 | initialEnd = availableUtils.convert(props.data.end, 'Date');
|
29819 | end = new Date(initialEnd.valueOf() + offset);
|
29820 |
|
29821 | itemData.end = snap ? snap(end, scale, step) : end;
|
29822 | }
|
29823 | }
|
29824 | } else {
|
29825 |
|
29826 | if (itemData.start != undefined) {
|
29827 | initialStart = availableUtils.convert(props.data.start, 'Date').valueOf();
|
29828 | start = new Date(initialStart + offset);
|
29829 |
|
29830 | if (itemData.end != undefined) {
|
29831 | initialEnd = availableUtils.convert(props.data.end, 'Date');
|
29832 | var duration = initialEnd.valueOf() - initialStart.valueOf();
|
29833 |
|
29834 | itemData.start = snap ? snap(start, scale, step) : start;
|
29835 | itemData.end = new Date(itemData.start.valueOf() + duration);
|
29836 | } else {
|
29837 |
|
29838 | itemData.start = snap ? snap(start, scale, step) : start;
|
29839 | }
|
29840 | }
|
29841 | }
|
29842 | }
|
29843 |
|
29844 | if (updateGroupAllowed && !props.dragLeft && !props.dragRight && newGroupBase != null) {
|
29845 | if (itemData.group != undefined) {
|
29846 | var newOffset = newGroupBase - props.groupOffset;
|
29847 |
|
29848 | newOffset = Math.max(0, newOffset);
|
29849 | newOffset = Math.min(me.groupIds.length - 1, newOffset);
|
29850 | itemData.group = me.groupIds[newOffset];
|
29851 | }
|
29852 | }
|
29853 |
|
29854 |
|
29855 | itemData = _this10._cloneItemData(itemData);
|
29856 |
|
29857 | me.options.onMoving(itemData, function (itemData) {
|
29858 | if (itemData) {
|
29859 | props.item.setData(_this10._cloneItemData(itemData, 'Date'));
|
29860 | }
|
29861 | });
|
29862 | });
|
29863 |
|
29864 | this.body.emitter.emit('_change');
|
29865 | }
|
29866 | }
|
29867 | |
29868 |
|
29869 |
|
29870 |
|
29871 |
|
29872 |
|
29873 |
|
29874 | }, {
|
29875 | key: "_moveToGroup",
|
29876 | value: function _moveToGroup(item, groupId) {
|
29877 | var group = this.groups[groupId];
|
29878 |
|
29879 | if (group && group.groupId != item.data.group) {
|
29880 | var oldGroup = item.parent;
|
29881 | oldGroup.remove(item);
|
29882 | oldGroup.order();
|
29883 | item.data.group = group.groupId;
|
29884 | group.add(item);
|
29885 | group.order();
|
29886 | }
|
29887 | }
|
29888 | |
29889 |
|
29890 |
|
29891 |
|
29892 |
|
29893 |
|
29894 | }, {
|
29895 | key: "_onDragEnd",
|
29896 | value: function _onDragEnd(event) {
|
29897 | var _this11 = this;
|
29898 |
|
29899 | this.touchParams.itemIsDragging = false;
|
29900 |
|
29901 | if (this.touchParams.itemProps) {
|
29902 | event.stopPropagation();
|
29903 | var me = this;
|
29904 | var itemProps = this.touchParams.itemProps;
|
29905 | this.touchParams.itemProps = null;
|
29906 |
|
29907 | _forEachInstanceProperty(itemProps).call(itemProps, function (props) {
|
29908 | var id = props.item.id;
|
29909 | var exists = me.itemsData.get(id) != null;
|
29910 |
|
29911 | if (!exists) {
|
29912 |
|
29913 | me.options.onAdd(props.item.data, function (itemData) {
|
29914 | me._removeItem(props.item);
|
29915 |
|
29916 |
|
29917 | if (itemData) {
|
29918 | me.itemsData.add(itemData);
|
29919 | }
|
29920 |
|
29921 |
|
29922 | me.body.emitter.emit('_change');
|
29923 | });
|
29924 | } else {
|
29925 |
|
29926 | var itemData = _this11._cloneItemData(props.item.data);
|
29927 |
|
29928 |
|
29929 | me.options.onMove(itemData, function (itemData) {
|
29930 | if (itemData) {
|
29931 |
|
29932 | itemData[_this11.itemsData.idProp] = id;
|
29933 |
|
29934 | _this11.itemsData.update(itemData);
|
29935 | } else {
|
29936 |
|
29937 | props.item.setData(props.data);
|
29938 | me.body.emitter.emit('_change');
|
29939 | }
|
29940 | });
|
29941 | }
|
29942 | });
|
29943 | }
|
29944 | }
|
29945 | |
29946 |
|
29947 |
|
29948 |
|
29949 |
|
29950 |
|
29951 | }, {
|
29952 | key: "_onGroupClick",
|
29953 | value: function _onGroupClick(event) {
|
29954 | var _this12 = this;
|
29955 |
|
29956 | var group = this.groupFromTarget(event);
|
29957 |
|
29958 | _setTimeout(function () {
|
29959 | _this12.toggleGroupShowNested(group);
|
29960 | }, 1);
|
29961 | }
|
29962 | |
29963 |
|
29964 |
|
29965 |
|
29966 |
|
29967 |
|
29968 | }, {
|
29969 | key: "toggleGroupShowNested",
|
29970 | value: function toggleGroupShowNested(group) {
|
29971 | var _context30;
|
29972 |
|
29973 | var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
29974 | if (!group || !group.nestedGroups) return;
|
29975 | var groupsData = this.groupsData.getDataSet();
|
29976 |
|
29977 | if (force != undefined) {
|
29978 | group.showNested = !!force;
|
29979 | } else {
|
29980 | group.showNested = !group.showNested;
|
29981 | }
|
29982 |
|
29983 | var nestingGroup = groupsData.get(group.groupId);
|
29984 | nestingGroup.showNested = group.showNested;
|
29985 | var fullNestedGroups = group.nestedGroups;
|
29986 | var nextLevel = fullNestedGroups;
|
29987 |
|
29988 | while (nextLevel.length > 0) {
|
29989 | var current = nextLevel;
|
29990 | nextLevel = [];
|
29991 |
|
29992 | for (var i = 0; i < current.length; i++) {
|
29993 | var node = groupsData.get(current[i]);
|
29994 |
|
29995 | if (node.nestedGroups) {
|
29996 | nextLevel = _concatInstanceProperty(nextLevel).call(nextLevel, node.nestedGroups);
|
29997 | }
|
29998 | }
|
29999 |
|
30000 | if (nextLevel.length > 0) {
|
30001 | fullNestedGroups = _concatInstanceProperty(fullNestedGroups).call(fullNestedGroups, nextLevel);
|
30002 | }
|
30003 | }
|
30004 |
|
30005 | var nestedGroups = _mapInstanceProperty(_context30 = groupsData.get(fullNestedGroups)).call(_context30, function (nestedGroup) {
|
30006 | if (nestedGroup.visible == undefined) {
|
30007 | nestedGroup.visible = true;
|
30008 | }
|
30009 |
|
30010 | nestedGroup.visible = !!nestingGroup.showNested;
|
30011 | return nestedGroup;
|
30012 | });
|
30013 |
|
30014 | groupsData.update(_concatInstanceProperty(nestedGroups).call(nestedGroups, nestingGroup));
|
30015 |
|
30016 | if (nestingGroup.showNested) {
|
30017 | availableUtils.removeClassName(group.dom.label, 'collapsed');
|
30018 | availableUtils.addClassName(group.dom.label, 'expanded');
|
30019 | } else {
|
30020 | availableUtils.removeClassName(group.dom.label, 'expanded');
|
30021 | availableUtils.addClassName(group.dom.label, 'collapsed');
|
30022 | }
|
30023 | }
|
30024 | |
30025 |
|
30026 |
|
30027 |
|
30028 |
|
30029 | }, {
|
30030 | key: "toggleGroupDragClassName",
|
30031 | value: function toggleGroupDragClassName(group) {
|
30032 | group.dom.label.classList.toggle('vis-group-is-dragging');
|
30033 | group.dom.foreground.classList.toggle('vis-group-is-dragging');
|
30034 | }
|
30035 | |
30036 |
|
30037 |
|
30038 |
|
30039 |
|
30040 |
|
30041 |
|
30042 | }, {
|
30043 | key: "_onGroupDragStart",
|
30044 | value: function _onGroupDragStart(event) {
|
30045 | if (this.groupTouchParams.isDragging) return;
|
30046 |
|
30047 | if (this.options.groupEditable.order) {
|
30048 | this.groupTouchParams.group = this.groupFromTarget(event);
|
30049 |
|
30050 | if (this.groupTouchParams.group) {
|
30051 | event.stopPropagation();
|
30052 | this.groupTouchParams.isDragging = true;
|
30053 | this.toggleGroupDragClassName(this.groupTouchParams.group);
|
30054 | this.groupTouchParams.originalOrder = this.groupsData.getIds({
|
30055 | order: this.options.groupOrder
|
30056 | });
|
30057 | }
|
30058 | }
|
30059 | }
|
30060 | |
30061 |
|
30062 |
|
30063 |
|
30064 |
|
30065 |
|
30066 |
|
30067 | }, {
|
30068 | key: "_onGroupDrag",
|
30069 | value: function _onGroupDrag(event) {
|
30070 | if (this.options.groupEditable.order && this.groupTouchParams.group) {
|
30071 | event.stopPropagation();
|
30072 | var groupsData = this.groupsData.getDataSet();
|
30073 |
|
30074 | var group = this.groupFromTarget(event);
|
30075 |
|
30076 | if (group && group.height != this.groupTouchParams.group.height) {
|
30077 | var movingUp = group.top < this.groupTouchParams.group.top;
|
30078 | var clientY = event.center ? event.center.y : event.clientY;
|
30079 | var targetGroup = group.dom.foreground.getBoundingClientRect();
|
30080 | var draggedGroupHeight = this.groupTouchParams.group.height;
|
30081 |
|
30082 | if (movingUp) {
|
30083 |
|
30084 | if (targetGroup.top + draggedGroupHeight < clientY) {
|
30085 | return;
|
30086 | }
|
30087 | } else {
|
30088 | var targetGroupHeight = group.height;
|
30089 |
|
30090 | if (targetGroup.top + targetGroupHeight - draggedGroupHeight > clientY) {
|
30091 | return;
|
30092 | }
|
30093 | }
|
30094 | }
|
30095 |
|
30096 | if (group && group != this.groupTouchParams.group) {
|
30097 | var _targetGroup = groupsData.get(group.groupId);
|
30098 |
|
30099 | var draggedGroup = groupsData.get(this.groupTouchParams.group.groupId);
|
30100 |
|
30101 | if (draggedGroup && _targetGroup) {
|
30102 | this.options.groupOrderSwap(draggedGroup, _targetGroup, groupsData);
|
30103 | groupsData.update(draggedGroup);
|
30104 | groupsData.update(_targetGroup);
|
30105 | }
|
30106 |
|
30107 |
|
30108 | var newOrder = groupsData.getIds({
|
30109 | order: this.options.groupOrder
|
30110 | });
|
30111 |
|
30112 | if (!availableUtils.equalArray(newOrder, this.groupTouchParams.originalOrder)) {
|
30113 | var origOrder = this.groupTouchParams.originalOrder;
|
30114 | var draggedId = this.groupTouchParams.group.groupId;
|
30115 | var numGroups = Math.min(origOrder.length, newOrder.length);
|
30116 | var curPos = 0;
|
30117 | var newOffset = 0;
|
30118 | var orgOffset = 0;
|
30119 |
|
30120 | while (curPos < numGroups) {
|
30121 |
|
30122 | while (curPos + newOffset < numGroups && curPos + orgOffset < numGroups && newOrder[curPos + newOffset] == origOrder[curPos + orgOffset]) {
|
30123 | curPos++;
|
30124 | }
|
30125 |
|
30126 |
|
30127 | if (curPos + newOffset >= numGroups) {
|
30128 | break;
|
30129 | }
|
30130 |
|
30131 |
|
30132 |
|
30133 | if (newOrder[curPos + newOffset] == draggedId) {
|
30134 | newOffset = 1;
|
30135 | }
|
30136 | else if (origOrder[curPos + orgOffset] == draggedId) {
|
30137 | orgOffset = 1;
|
30138 | }
|
30139 |
|
30140 | else {
|
30141 | var slippedPosition = _indexOfInstanceProperty(newOrder).call(newOrder, origOrder[curPos + orgOffset]);
|
30142 |
|
30143 | var switchGroup = groupsData.get(newOrder[curPos + newOffset]);
|
30144 | var shouldBeGroup = groupsData.get(origOrder[curPos + orgOffset]);
|
30145 | this.options.groupOrderSwap(switchGroup, shouldBeGroup, groupsData);
|
30146 | groupsData.update(switchGroup);
|
30147 | groupsData.update(shouldBeGroup);
|
30148 | var switchGroupId = newOrder[curPos + newOffset];
|
30149 | newOrder[curPos + newOffset] = origOrder[curPos + orgOffset];
|
30150 | newOrder[slippedPosition] = switchGroupId;
|
30151 | curPos++;
|
30152 | }
|
30153 | }
|
30154 | }
|
30155 | }
|
30156 | }
|
30157 | }
|
30158 | |
30159 |
|
30160 |
|
30161 |
|
30162 |
|
30163 |
|
30164 |
|
30165 | }, {
|
30166 | key: "_onGroupDragEnd",
|
30167 | value: function _onGroupDragEnd(event) {
|
30168 | this.groupTouchParams.isDragging = false;
|
30169 |
|
30170 | if (this.options.groupEditable.order && this.groupTouchParams.group) {
|
30171 | event.stopPropagation();
|
30172 |
|
30173 | var me = this;
|
30174 | var id = me.groupTouchParams.group.groupId;
|
30175 | var dataset = me.groupsData.getDataSet();
|
30176 | var groupData = availableUtils.extend({}, dataset.get(id));
|
30177 |
|
30178 | me.options.onMoveGroup(groupData, function (groupData) {
|
30179 | if (groupData) {
|
30180 |
|
30181 | groupData[dataset._idProp] = id;
|
30182 |
|
30183 | dataset.update(groupData);
|
30184 | } else {
|
30185 |
|
30186 | var newOrder = dataset.getIds({
|
30187 | order: me.options.groupOrder
|
30188 | });
|
30189 |
|
30190 | if (!availableUtils.equalArray(newOrder, me.groupTouchParams.originalOrder)) {
|
30191 | var origOrder = me.groupTouchParams.originalOrder;
|
30192 | var numGroups = Math.min(origOrder.length, newOrder.length);
|
30193 | var curPos = 0;
|
30194 |
|
30195 | while (curPos < numGroups) {
|
30196 |
|
30197 | while (curPos < numGroups && newOrder[curPos] == origOrder[curPos]) {
|
30198 | curPos++;
|
30199 | }
|
30200 |
|
30201 |
|
30202 | if (curPos >= numGroups) {
|
30203 | break;
|
30204 | }
|
30205 |
|
30206 |
|
30207 |
|
30208 | var slippedPosition = _indexOfInstanceProperty(newOrder).call(newOrder, origOrder[curPos]);
|
30209 |
|
30210 | var switchGroup = dataset.get(newOrder[curPos]);
|
30211 | var shouldBeGroup = dataset.get(origOrder[curPos]);
|
30212 | me.options.groupOrderSwap(switchGroup, shouldBeGroup, dataset);
|
30213 | dataset.update(switchGroup);
|
30214 | dataset.update(shouldBeGroup);
|
30215 | var switchGroupId = newOrder[curPos];
|
30216 | newOrder[curPos] = origOrder[curPos];
|
30217 | newOrder[slippedPosition] = switchGroupId;
|
30218 | curPos++;
|
30219 | }
|
30220 | }
|
30221 | }
|
30222 | });
|
30223 | me.body.emitter.emit('groupDragged', {
|
30224 | groupId: id
|
30225 | });
|
30226 | this.toggleGroupDragClassName(this.groupTouchParams.group);
|
30227 | this.groupTouchParams.group = null;
|
30228 | }
|
30229 | }
|
30230 | |
30231 |
|
30232 |
|
30233 |
|
30234 |
|
30235 |
|
30236 | }, {
|
30237 | key: "_onSelectItem",
|
30238 | value: function _onSelectItem(event) {
|
30239 | if (!this.options.selectable) return;
|
30240 | var ctrlKey = event.srcEvent && (event.srcEvent.ctrlKey || event.srcEvent.metaKey);
|
30241 | var shiftKey = event.srcEvent && event.srcEvent.shiftKey;
|
30242 |
|
30243 | if (ctrlKey || shiftKey) {
|
30244 | this._onMultiSelectItem(event);
|
30245 |
|
30246 | return;
|
30247 | }
|
30248 |
|
30249 | var oldSelection = this.getSelection();
|
30250 | var item = this.itemFromTarget(event);
|
30251 | var selection = item && item.selectable ? [item.id] : [];
|
30252 | this.setSelection(selection);
|
30253 | var newSelection = this.getSelection();
|
30254 |
|
30255 |
|
30256 | if (newSelection.length > 0 || oldSelection.length > 0) {
|
30257 | this.body.emitter.emit('select', {
|
30258 | items: newSelection,
|
30259 | event: event
|
30260 | });
|
30261 | }
|
30262 | }
|
30263 | |
30264 |
|
30265 |
|
30266 |
|
30267 |
|
30268 |
|
30269 | }, {
|
30270 | key: "_onMouseOver",
|
30271 | value: function _onMouseOver(event) {
|
30272 | var item = this.itemFromTarget(event);
|
30273 | if (!item) return;
|
30274 |
|
30275 | var related = this.itemFromRelatedTarget(event);
|
30276 |
|
30277 | if (item === related) {
|
30278 |
|
30279 | return;
|
30280 | }
|
30281 |
|
30282 | var title = item.getTitle();
|
30283 |
|
30284 | if (this.options.showTooltips && title) {
|
30285 | if (this.popup == null) {
|
30286 | this.popup = new Popup(this.body.dom.root, this.options.tooltip.overflowMethod || 'flip');
|
30287 | }
|
30288 |
|
30289 | this.popup.setText(title);
|
30290 | var container = this.body.dom.centerContainer;
|
30291 | var containerRect = container.getBoundingClientRect();
|
30292 | this.popup.setPosition(event.clientX - containerRect.left + container.offsetLeft, event.clientY - containerRect.top + container.offsetTop);
|
30293 | this.setPopupTimer(this.popup);
|
30294 | } else {
|
30295 |
|
30296 |
|
30297 | this.clearPopupTimer();
|
30298 |
|
30299 | if (this.popup != null) {
|
30300 | this.popup.hide();
|
30301 | }
|
30302 | }
|
30303 |
|
30304 | this.body.emitter.emit('itemover', {
|
30305 | item: item.id,
|
30306 | event: event
|
30307 | });
|
30308 | }
|
30309 | |
30310 |
|
30311 |
|
30312 |
|
30313 |
|
30314 |
|
30315 |
|
30316 | }, {
|
30317 | key: "_onMouseOut",
|
30318 | value: function _onMouseOut(event) {
|
30319 | var item = this.itemFromTarget(event);
|
30320 | if (!item) return;
|
30321 |
|
30322 | var related = this.itemFromRelatedTarget(event);
|
30323 |
|
30324 | if (item === related) {
|
30325 |
|
30326 | return;
|
30327 | }
|
30328 |
|
30329 | this.clearPopupTimer();
|
30330 |
|
30331 | if (this.popup != null) {
|
30332 | this.popup.hide();
|
30333 | }
|
30334 |
|
30335 | this.body.emitter.emit('itemout', {
|
30336 | item: item.id,
|
30337 | event: event
|
30338 | });
|
30339 | }
|
30340 | |
30341 |
|
30342 |
|
30343 |
|
30344 |
|
30345 |
|
30346 |
|
30347 | }, {
|
30348 | key: "_onMouseMove",
|
30349 | value: function _onMouseMove(event) {
|
30350 | var item = this.itemFromTarget(event);
|
30351 | if (!item) return;
|
30352 |
|
30353 | if (this.popupTimer != null) {
|
30354 |
|
30355 | this.setPopupTimer(this.popup);
|
30356 | }
|
30357 |
|
30358 | if (this.options.showTooltips && this.options.tooltip.followMouse && this.popup && !this.popup.hidden) {
|
30359 | var container = this.body.dom.centerContainer;
|
30360 | var containerRect = container.getBoundingClientRect();
|
30361 | this.popup.setPosition(event.clientX - containerRect.left + container.offsetLeft, event.clientY - containerRect.top + container.offsetTop);
|
30362 | this.popup.show();
|
30363 | }
|
30364 | }
|
30365 | |
30366 |
|
30367 |
|
30368 |
|
30369 |
|
30370 |
|
30371 | }, {
|
30372 | key: "_onMouseWheel",
|
30373 | value: function _onMouseWheel(event) {
|
30374 | if (this.touchParams.itemIsDragging) {
|
30375 | this._onDragEnd(event);
|
30376 | }
|
30377 | }
|
30378 | |
30379 |
|
30380 |
|
30381 |
|
30382 |
|
30383 |
|
30384 | }, {
|
30385 | key: "_onUpdateItem",
|
30386 | value: function _onUpdateItem(item) {
|
30387 | if (!this.options.selectable) return;
|
30388 | if (!this.options.editable.updateTime && !this.options.editable.updateGroup) return;
|
30389 | var me = this;
|
30390 |
|
30391 | if (item) {
|
30392 |
|
30393 | var itemData = me.itemsData.get(item.id);
|
30394 |
|
30395 | this.options.onUpdate(itemData, function (itemData) {
|
30396 | if (itemData) {
|
30397 | me.itemsData.update(itemData);
|
30398 | }
|
30399 | });
|
30400 | }
|
30401 | }
|
30402 | |
30403 |
|
30404 |
|
30405 |
|
30406 |
|
30407 |
|
30408 |
|
30409 | }, {
|
30410 | key: "_onDropObjectOnItem",
|
30411 | value: function _onDropObjectOnItem(event) {
|
30412 | var item = this.itemFromTarget(event);
|
30413 | var objectData = JSON.parse(event.dataTransfer.getData("text"));
|
30414 | this.options.onDropObjectOnItem(objectData, item);
|
30415 | }
|
30416 | |
30417 |
|
30418 |
|
30419 |
|
30420 |
|
30421 |
|
30422 | }, {
|
30423 | key: "_onAddItem",
|
30424 | value: function _onAddItem(event) {
|
30425 | if (!this.options.selectable) return;
|
30426 | if (!this.options.editable.add) return;
|
30427 | var me = this;
|
30428 | var snap = this.options.snap || null;
|
30429 |
|
30430 | var frameRect = this.dom.frame.getBoundingClientRect();
|
30431 | var x = this.options.rtl ? frameRect.right - event.center.x : event.center.x - frameRect.left;
|
30432 | var start = this.body.util.toTime(x);
|
30433 | var scale = this.body.util.getScale();
|
30434 | var step = this.body.util.getStep();
|
30435 | var end;
|
30436 | var newItemData;
|
30437 |
|
30438 | if (event.type == 'drop') {
|
30439 | newItemData = JSON.parse(event.dataTransfer.getData("text"));
|
30440 | newItemData.content = newItemData.content ? newItemData.content : 'new item';
|
30441 | newItemData.start = newItemData.start ? newItemData.start : snap ? snap(start, scale, step) : start;
|
30442 | newItemData.type = newItemData.type || 'box';
|
30443 | newItemData[this.itemsData.idProp] = newItemData.id || v4();
|
30444 |
|
30445 | if (newItemData.type == 'range' && !newItemData.end) {
|
30446 | end = this.body.util.toTime(x + this.props.width / 5);
|
30447 | newItemData.end = snap ? snap(end, scale, step) : end;
|
30448 | }
|
30449 | } else {
|
30450 | newItemData = {
|
30451 | start: snap ? snap(start, scale, step) : start,
|
30452 | content: 'new item'
|
30453 | };
|
30454 | newItemData[this.itemsData.idProp] = v4();
|
30455 |
|
30456 | if (this.options.type === 'range') {
|
30457 | end = this.body.util.toTime(x + this.props.width / 5);
|
30458 | newItemData.end = snap ? snap(end, scale, step) : end;
|
30459 | }
|
30460 | }
|
30461 |
|
30462 | var group = this.groupFromTarget(event);
|
30463 |
|
30464 | if (group) {
|
30465 | newItemData.group = group.groupId;
|
30466 | }
|
30467 |
|
30468 |
|
30469 | newItemData = this._cloneItemData(newItemData);
|
30470 |
|
30471 | this.options.onAdd(newItemData, function (item) {
|
30472 | if (item) {
|
30473 | me.itemsData.add(item);
|
30474 |
|
30475 | if (event.type == 'drop') {
|
30476 | me.setSelection([item.id]);
|
30477 | }
|
30478 |
|
30479 | }
|
30480 | });
|
30481 | }
|
30482 | |
30483 |
|
30484 |
|
30485 |
|
30486 |
|
30487 |
|
30488 | }, {
|
30489 | key: "_onMultiSelectItem",
|
30490 | value: function _onMultiSelectItem(event) {
|
30491 | var _this13 = this;
|
30492 |
|
30493 | if (!this.options.selectable) return;
|
30494 | var item = this.itemFromTarget(event);
|
30495 |
|
30496 | if (item) {
|
30497 |
|
30498 | var selection = this.options.multiselect ? this.getSelection()
|
30499 | : [];
|
30500 |
|
30501 | var shiftKey = event.srcEvent && event.srcEvent.shiftKey || false;
|
30502 |
|
30503 | if ((shiftKey || this.options.sequentialSelection) && this.options.multiselect) {
|
30504 |
|
30505 | var itemGroup = this.itemsData.get(item.id).group;
|
30506 |
|
30507 | var lastSelectedGroup = undefined;
|
30508 |
|
30509 | if (this.options.multiselectPerGroup) {
|
30510 | if (selection.length > 0) {
|
30511 | lastSelectedGroup = this.itemsData.get(selection[0]).group;
|
30512 | }
|
30513 | }
|
30514 |
|
30515 |
|
30516 | if (!this.options.multiselectPerGroup || lastSelectedGroup == undefined || lastSelectedGroup == itemGroup) {
|
30517 | selection.push(item.id);
|
30518 | }
|
30519 |
|
30520 | var range = ItemSet._getItemRange(this.itemsData.get(selection));
|
30521 |
|
30522 | if (!this.options.multiselectPerGroup || lastSelectedGroup == itemGroup) {
|
30523 |
|
30524 | selection = [];
|
30525 |
|
30526 | for (var id in this.items) {
|
30527 | if (this.items.hasOwnProperty(id)) {
|
30528 | var _item = this.items[id];
|
30529 | var start = _item.data.start;
|
30530 | var end = _item.data.end !== undefined ? _item.data.end : start;
|
30531 |
|
30532 | if (start >= range.min && end <= range.max && (!this.options.multiselectPerGroup || lastSelectedGroup == this.itemsData.get(_item.id).group) && !(_item instanceof BackgroundItem)) {
|
30533 | selection.push(_item.id);
|
30534 | }
|
30535 | }
|
30536 | }
|
30537 | }
|
30538 | } else {
|
30539 |
|
30540 | var index = _indexOfInstanceProperty(selection).call(selection, item.id);
|
30541 |
|
30542 | if (index == -1) {
|
30543 |
|
30544 | selection.push(item.id);
|
30545 | } else {
|
30546 |
|
30547 | _spliceInstanceProperty(selection).call(selection, index, 1);
|
30548 | }
|
30549 | }
|
30550 |
|
30551 | var filteredSelection = _filterInstanceProperty(selection).call(selection, function (item) {
|
30552 | return _this13.getItemById(item).selectable;
|
30553 | });
|
30554 |
|
30555 | this.setSelection(filteredSelection);
|
30556 | this.body.emitter.emit('select', {
|
30557 | items: this.getSelection(),
|
30558 | event: event
|
30559 | });
|
30560 | }
|
30561 | }
|
30562 | |
30563 |
|
30564 |
|
30565 |
|
30566 |
|
30567 |
|
30568 |
|
30569 | }, {
|
30570 | key: "itemFromElement",
|
30571 | value:
|
30572 | |
30573 |
|
30574 |
|
30575 |
|
30576 |
|
30577 |
|
30578 | function itemFromElement(element) {
|
30579 | var cur = element;
|
30580 |
|
30581 | while (cur) {
|
30582 | if (cur.hasOwnProperty('vis-item')) {
|
30583 | return cur['vis-item'];
|
30584 | }
|
30585 |
|
30586 | cur = cur.parentNode;
|
30587 | }
|
30588 |
|
30589 | return null;
|
30590 | }
|
30591 | |
30592 |
|
30593 |
|
30594 |
|
30595 |
|
30596 |
|
30597 |
|
30598 | }, {
|
30599 | key: "itemFromTarget",
|
30600 | value: function itemFromTarget(event) {
|
30601 | return this.itemFromElement(event.target);
|
30602 | }
|
30603 | |
30604 |
|
30605 |
|
30606 |
|
30607 |
|
30608 |
|
30609 |
|
30610 | }, {
|
30611 | key: "itemFromRelatedTarget",
|
30612 | value: function itemFromRelatedTarget(event) {
|
30613 | return this.itemFromElement(event.relatedTarget);
|
30614 | }
|
30615 | |
30616 |
|
30617 |
|
30618 |
|
30619 |
|
30620 |
|
30621 |
|
30622 | }, {
|
30623 | key: "groupFromTarget",
|
30624 | value: function groupFromTarget(event) {
|
30625 | var clientY = event.center ? event.center.y : event.clientY;
|
30626 | var groupIds = this.groupIds;
|
30627 |
|
30628 | if (groupIds.length <= 0 && this.groupsData) {
|
30629 | groupIds = this.groupsData.getIds({
|
30630 | order: this.options.groupOrder
|
30631 | });
|
30632 | }
|
30633 |
|
30634 | for (var i = 0; i < groupIds.length; i++) {
|
30635 | var groupId = groupIds[i];
|
30636 | var group = this.groups[groupId];
|
30637 | var foreground = group.dom.foreground;
|
30638 | var foregroundRect = foreground.getBoundingClientRect();
|
30639 |
|
30640 | if (clientY >= foregroundRect.top && clientY < foregroundRect.top + foreground.offsetHeight) {
|
30641 | return group;
|
30642 | }
|
30643 |
|
30644 | if (this.options.orientation.item === 'top') {
|
30645 | if (i === this.groupIds.length - 1 && clientY > foregroundRect.top) {
|
30646 | return group;
|
30647 | }
|
30648 | } else {
|
30649 | if (i === 0 && clientY < foregroundRect.top + foreground.offset) {
|
30650 | return group;
|
30651 | }
|
30652 | }
|
30653 | }
|
30654 |
|
30655 | return null;
|
30656 | }
|
30657 | |
30658 |
|
30659 |
|
30660 |
|
30661 |
|
30662 |
|
30663 |
|
30664 | }, {
|
30665 | key: "_cloneItemData",
|
30666 | value:
|
30667 | |
30668 |
|
30669 |
|
30670 |
|
30671 |
|
30672 |
|
30673 |
|
30674 |
|
30675 |
|
30676 | function _cloneItemData(itemData, type) {
|
30677 | var clone = availableUtils.extend({}, itemData);
|
30678 |
|
30679 | if (!type) {
|
30680 |
|
30681 | type = this.itemsData.type;
|
30682 | }
|
30683 |
|
30684 | if (clone.start != undefined) {
|
30685 | clone.start = availableUtils.convert(clone.start, type && type.start || 'Date');
|
30686 | }
|
30687 |
|
30688 | if (clone.end != undefined) {
|
30689 | clone.end = availableUtils.convert(clone.end, type && type.end || 'Date');
|
30690 | }
|
30691 |
|
30692 | return clone;
|
30693 | }
|
30694 | |
30695 |
|
30696 |
|
30697 |
|
30698 |
|
30699 |
|
30700 | }, {
|
30701 | key: "_clusterItems",
|
30702 | value: function _clusterItems() {
|
30703 | if (!this.options.cluster) {
|
30704 | return;
|
30705 | }
|
30706 |
|
30707 | var _this$body$range$conv = this.body.range.conversion(this.body.domProps.center.width),
|
30708 | scale = _this$body$range$conv.scale;
|
30709 |
|
30710 | var clusters = this.clusterGenerator.getClusters(this.clusters, scale, this.options.cluster);
|
30711 |
|
30712 | if (this.clusters != clusters) {
|
30713 | this._detachAllClusters();
|
30714 |
|
30715 | if (clusters) {
|
30716 | var _iterator5 = _createForOfIteratorHelper$1(clusters),
|
30717 | _step5;
|
30718 |
|
30719 | try {
|
30720 | for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
30721 | var cluster = _step5.value;
|
30722 | cluster.attach();
|
30723 | }
|
30724 | } catch (err) {
|
30725 | _iterator5.e(err);
|
30726 | } finally {
|
30727 | _iterator5.f();
|
30728 | }
|
30729 |
|
30730 | this.clusters = clusters;
|
30731 | }
|
30732 |
|
30733 | this._updateClusters(clusters);
|
30734 | }
|
30735 | }
|
30736 | |
30737 |
|
30738 |
|
30739 |
|
30740 |
|
30741 | }, {
|
30742 | key: "_detachAllClusters",
|
30743 | value: function _detachAllClusters() {
|
30744 | if (this.options.cluster) {
|
30745 | if (this.clusters && this.clusters.length) {
|
30746 | var _iterator6 = _createForOfIteratorHelper$1(this.clusters),
|
30747 | _step6;
|
30748 |
|
30749 | try {
|
30750 | for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
30751 | var cluster = _step6.value;
|
30752 | cluster.detach();
|
30753 | }
|
30754 | } catch (err) {
|
30755 | _iterator6.e(err);
|
30756 | } finally {
|
30757 | _iterator6.f();
|
30758 | }
|
30759 | }
|
30760 | }
|
30761 | }
|
30762 | |
30763 |
|
30764 |
|
30765 |
|
30766 |
|
30767 |
|
30768 | }, {
|
30769 | key: "_updateClusters",
|
30770 | value: function _updateClusters(clusters) {
|
30771 | if (this.clusters && this.clusters.length) {
|
30772 | var _context31;
|
30773 |
|
30774 | var newClustersIds = new _Set(_mapInstanceProperty(clusters).call(clusters, function (cluster) {
|
30775 | return cluster.id;
|
30776 | }));
|
30777 |
|
30778 | var clustersToUnselect = _filterInstanceProperty(_context31 = this.clusters).call(_context31, function (cluster) {
|
30779 | return !newClustersIds.has(cluster.id);
|
30780 | });
|
30781 |
|
30782 | var selectionChanged = false;
|
30783 |
|
30784 | var _iterator7 = _createForOfIteratorHelper$1(clustersToUnselect),
|
30785 | _step7;
|
30786 |
|
30787 | try {
|
30788 | for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
30789 | var _context32;
|
30790 |
|
30791 | var cluster = _step7.value;
|
30792 |
|
30793 | var selectedIdx = _indexOfInstanceProperty(_context32 = this.selection).call(_context32, cluster.id);
|
30794 |
|
30795 | if (selectedIdx !== -1) {
|
30796 | var _context33;
|
30797 |
|
30798 | cluster.unselect();
|
30799 |
|
30800 | _spliceInstanceProperty(_context33 = this.selection).call(_context33, selectedIdx, 1);
|
30801 |
|
30802 | selectionChanged = true;
|
30803 | }
|
30804 | }
|
30805 | } catch (err) {
|
30806 | _iterator7.e(err);
|
30807 | } finally {
|
30808 | _iterator7.f();
|
30809 | }
|
30810 |
|
30811 | if (selectionChanged) {
|
30812 | var newSelection = this.getSelection();
|
30813 | this.body.emitter.emit('select', {
|
30814 | items: newSelection,
|
30815 | event: event
|
30816 | });
|
30817 | }
|
30818 | }
|
30819 |
|
30820 | this.clusters = clusters || [];
|
30821 | }
|
30822 | }], [{
|
30823 | key: "_getItemRange",
|
30824 | value: function _getItemRange(itemsData) {
|
30825 | var max = null;
|
30826 | var min = null;
|
30827 |
|
30828 | _forEachInstanceProperty(itemsData).call(itemsData, function (data) {
|
30829 | if (min == null || data.start < min) {
|
30830 | min = data.start;
|
30831 | }
|
30832 |
|
30833 | if (data.end != undefined) {
|
30834 | if (max == null || data.end > max) {
|
30835 | max = data.end;
|
30836 | }
|
30837 | } else {
|
30838 | if (max == null || data.start > max) {
|
30839 | max = data.start;
|
30840 | }
|
30841 | }
|
30842 | });
|
30843 |
|
30844 | return {
|
30845 | min: min,
|
30846 | max: max
|
30847 | };
|
30848 | }
|
30849 | }, {
|
30850 | key: "itemSetFromTarget",
|
30851 | value: function itemSetFromTarget(event) {
|
30852 | var target = event.target;
|
30853 |
|
30854 | while (target) {
|
30855 | if (target.hasOwnProperty('vis-itemset')) {
|
30856 | return target['vis-itemset'];
|
30857 | }
|
30858 |
|
30859 | target = target.parentNode;
|
30860 | }
|
30861 |
|
30862 | return null;
|
30863 | }
|
30864 | }]);
|
30865 |
|
30866 | return ItemSet;
|
30867 | }(Component);
|
30868 |
|
30869 |
|
30870 | ItemSet.types = {
|
30871 | background: BackgroundItem,
|
30872 | box: BoxItem,
|
30873 | range: RangeItem,
|
30874 | point: PointItem
|
30875 | };
|
30876 |
|
30877 |
|
30878 |
|
30879 |
|
30880 |
|
30881 |
|
30882 | ItemSet.prototype._onAdd = ItemSet.prototype._onUpdate;
|
30883 |
|
30884 | var errorFound = false;
|
30885 | var allOptions$2;
|
30886 | var printStyle = 'background: #FFeeee; color: #dd0000';
|
30887 |
|
30888 |
|
30889 |
|
30890 |
|
30891 | var Validator = function () {
|
30892 | |
30893 |
|
30894 |
|
30895 | function Validator() {
|
30896 | _classCallCheck(this, Validator);
|
30897 | }
|
30898 | |
30899 |
|
30900 |
|
30901 |
|
30902 |
|
30903 |
|
30904 |
|
30905 |
|
30906 |
|
30907 |
|
30908 | _createClass(Validator, null, [{
|
30909 | key: "validate",
|
30910 | value: function validate(options, referenceOptions, subObject) {
|
30911 | errorFound = false;
|
30912 | allOptions$2 = referenceOptions;
|
30913 | var usedOptions = referenceOptions;
|
30914 |
|
30915 | if (subObject !== undefined) {
|
30916 | usedOptions = referenceOptions[subObject];
|
30917 | }
|
30918 |
|
30919 | Validator.parse(options, usedOptions, []);
|
30920 | return errorFound;
|
30921 | }
|
30922 | |
30923 |
|
30924 |
|
30925 |
|
30926 |
|
30927 |
|
30928 |
|
30929 |
|
30930 | }, {
|
30931 | key: "parse",
|
30932 | value: function parse(options, referenceOptions, path) {
|
30933 | for (var option in options) {
|
30934 | if (options.hasOwnProperty(option)) {
|
30935 | Validator.check(option, options, referenceOptions, path);
|
30936 | }
|
30937 | }
|
30938 | }
|
30939 | |
30940 |
|
30941 |
|
30942 |
|
30943 |
|
30944 |
|
30945 |
|
30946 |
|
30947 |
|
30948 | }, {
|
30949 | key: "check",
|
30950 | value: function check(option, options, referenceOptions, path) {
|
30951 | if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
|
30952 | Validator.getSuggestion(option, referenceOptions, path);
|
30953 | return;
|
30954 | }
|
30955 |
|
30956 | var referenceOption = option;
|
30957 | var is_object = true;
|
30958 |
|
30959 | if (referenceOptions[option] === undefined && referenceOptions.__any__ !== undefined) {
|
30960 |
|
30961 |
|
30962 |
|
30963 |
|
30964 | referenceOption = '__any__';
|
30965 |
|
30966 |
|
30967 | is_object = Validator.getType(options[option]) === 'object';
|
30968 | }
|
30969 |
|
30970 | var refOptionObj = referenceOptions[referenceOption];
|
30971 |
|
30972 | if (is_object && refOptionObj.__type__ !== undefined) {
|
30973 | refOptionObj = refOptionObj.__type__;
|
30974 | }
|
30975 |
|
30976 | Validator.checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path);
|
30977 | }
|
30978 | |
30979 |
|
30980 |
|
30981 |
|
30982 |
|
30983 |
|
30984 |
|
30985 |
|
30986 |
|
30987 |
|
30988 |
|
30989 | }, {
|
30990 | key: "checkFields",
|
30991 | value: function checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) {
|
30992 | var log = function log(message) {
|
30993 | console.log('%c' + message + Validator.printLocation(path, option), printStyle);
|
30994 | };
|
30995 |
|
30996 | var optionType = Validator.getType(options[option]);
|
30997 | var refOptionType = refOptionObj[optionType];
|
30998 |
|
30999 | if (refOptionType !== undefined) {
|
31000 |
|
31001 | if (Validator.getType(refOptionType) === 'array' && _indexOfInstanceProperty(refOptionType).call(refOptionType, options[option]) === -1) {
|
31002 | log('Invalid option detected in "' + option + '".' + ' Allowed values are:' + Validator.print(refOptionType) + ' not "' + options[option] + '". ');
|
31003 | errorFound = true;
|
31004 | } else if (optionType === 'object' && referenceOption !== "__any__") {
|
31005 | path = availableUtils.copyAndExtendArray(path, option);
|
31006 | Validator.parse(options[option], referenceOptions[referenceOption], path);
|
31007 | }
|
31008 | } else if (refOptionObj['any'] === undefined) {
|
31009 |
|
31010 | log('Invalid type received for "' + option + '". Expected: ' + Validator.print(_Object$keys(refOptionObj)) + '. Received [' + optionType + '] "' + options[option] + '"');
|
31011 | errorFound = true;
|
31012 | }
|
31013 | }
|
31014 | |
31015 |
|
31016 |
|
31017 |
|
31018 |
|
31019 |
|
31020 |
|
31021 | }, {
|
31022 | key: "getType",
|
31023 | value: function getType(object) {
|
31024 | var type = _typeof(object);
|
31025 |
|
31026 | if (type === 'object') {
|
31027 | if (object === null) {
|
31028 | return 'null';
|
31029 | }
|
31030 |
|
31031 | if (object instanceof Boolean) {
|
31032 | return 'boolean';
|
31033 | }
|
31034 |
|
31035 | if (object instanceof Number) {
|
31036 | return 'number';
|
31037 | }
|
31038 |
|
31039 | if (object instanceof String) {
|
31040 | return 'string';
|
31041 | }
|
31042 |
|
31043 | if (_Array$isArray$1(object)) {
|
31044 | return 'array';
|
31045 | }
|
31046 |
|
31047 | if (object instanceof Date) {
|
31048 | return 'date';
|
31049 | }
|
31050 |
|
31051 | if (object.nodeType !== undefined) {
|
31052 | return 'dom';
|
31053 | }
|
31054 |
|
31055 | if (object._isAMomentObject === true) {
|
31056 | return 'moment';
|
31057 | }
|
31058 |
|
31059 | return 'object';
|
31060 | } else if (type === 'number') {
|
31061 | return 'number';
|
31062 | } else if (type === 'boolean') {
|
31063 | return 'boolean';
|
31064 | } else if (type === 'string') {
|
31065 | return 'string';
|
31066 | } else if (type === undefined) {
|
31067 | return 'undefined';
|
31068 | }
|
31069 |
|
31070 | return type;
|
31071 | }
|
31072 | |
31073 |
|
31074 |
|
31075 |
|
31076 |
|
31077 |
|
31078 |
|
31079 | }, {
|
31080 | key: "getSuggestion",
|
31081 | value: function getSuggestion(option, options, path) {
|
31082 | var localSearch = Validator.findInOptions(option, options, path, false);
|
31083 | var globalSearch = Validator.findInOptions(option, allOptions$2, [], true);
|
31084 | var localSearchThreshold = 8;
|
31085 | var globalSearchThreshold = 4;
|
31086 | var msg;
|
31087 |
|
31088 | if (localSearch.indexMatch !== undefined) {
|
31089 | msg = ' in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n';
|
31090 | } else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) {
|
31091 | msg = ' in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was misplaced? Matching option found at: ' + Validator.printLocation(globalSearch.path, globalSearch.closestMatch, '');
|
31092 | } else if (localSearch.distance <= localSearchThreshold) {
|
31093 | msg = '. Did you mean "' + localSearch.closestMatch + '"?' + Validator.printLocation(localSearch.path, option);
|
31094 | } else {
|
31095 | msg = '. Did you mean one of these: ' + Validator.print(_Object$keys(options)) + Validator.printLocation(path, option);
|
31096 | }
|
31097 |
|
31098 | console.log('%cUnknown option detected: "' + option + '"' + msg, printStyle);
|
31099 | errorFound = true;
|
31100 | }
|
31101 | |
31102 |
|
31103 |
|
31104 |
|
31105 |
|
31106 |
|
31107 |
|
31108 |
|
31109 |
|
31110 |
|
31111 | }, {
|
31112 | key: "findInOptions",
|
31113 | value: function findInOptions(option, options, path) {
|
31114 | var recursive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
31115 | var min = 1e9;
|
31116 | var closestMatch = '';
|
31117 | var closestMatchPath = [];
|
31118 | var lowerCaseOption = option.toLowerCase();
|
31119 | var indexMatch = undefined;
|
31120 |
|
31121 | for (var op in options) {
|
31122 |
|
31123 | var distance = void 0;
|
31124 |
|
31125 | if (options[op].__type__ !== undefined && recursive === true) {
|
31126 | var result = Validator.findInOptions(option, options[op], availableUtils.copyAndExtendArray(path, op));
|
31127 |
|
31128 | if (min > result.distance) {
|
31129 | closestMatch = result.closestMatch;
|
31130 | closestMatchPath = result.path;
|
31131 | min = result.distance;
|
31132 | indexMatch = result.indexMatch;
|
31133 | }
|
31134 | } else {
|
31135 | var _context;
|
31136 |
|
31137 | if (_indexOfInstanceProperty(_context = op.toLowerCase()).call(_context, lowerCaseOption) !== -1) {
|
31138 | indexMatch = op;
|
31139 | }
|
31140 |
|
31141 | distance = Validator.levenshteinDistance(option, op);
|
31142 |
|
31143 | if (min > distance) {
|
31144 | closestMatch = op;
|
31145 | closestMatchPath = availableUtils.copyArray(path);
|
31146 | min = distance;
|
31147 | }
|
31148 | }
|
31149 | }
|
31150 |
|
31151 | return {
|
31152 | closestMatch: closestMatch,
|
31153 | path: closestMatchPath,
|
31154 | distance: min,
|
31155 | indexMatch: indexMatch
|
31156 | };
|
31157 | }
|
31158 | |
31159 |
|
31160 |
|
31161 |
|
31162 |
|
31163 |
|
31164 |
|
31165 |
|
31166 | }, {
|
31167 | key: "printLocation",
|
31168 | value: function printLocation(path, option) {
|
31169 | var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Problem value found at: \n';
|
31170 | var str = '\n\n' + prefix + 'options = {\n';
|
31171 |
|
31172 | for (var i = 0; i < path.length; i++) {
|
31173 | for (var j = 0; j < i + 1; j++) {
|
31174 | str += ' ';
|
31175 | }
|
31176 |
|
31177 | str += path[i] + ': {\n';
|
31178 | }
|
31179 |
|
31180 | for (var _j = 0; _j < path.length + 1; _j++) {
|
31181 | str += ' ';
|
31182 | }
|
31183 |
|
31184 | str += option + '\n';
|
31185 |
|
31186 | for (var _i = 0; _i < path.length + 1; _i++) {
|
31187 | for (var _j2 = 0; _j2 < path.length - _i; _j2++) {
|
31188 | str += ' ';
|
31189 | }
|
31190 |
|
31191 | str += '}\n';
|
31192 | }
|
31193 |
|
31194 | return str + '\n\n';
|
31195 | }
|
31196 | |
31197 |
|
31198 |
|
31199 |
|
31200 |
|
31201 |
|
31202 | }, {
|
31203 | key: "print",
|
31204 | value: function print(options) {
|
31205 | return _JSON$stringify(options).replace(/(\")|(\[)|(\])|(,"__type__")/g, "").replace(/(\,)/g, ', ');
|
31206 | }
|
31207 | |
31208 |
|
31209 |
|
31210 |
|
31211 |
|
31212 |
|
31213 |
|
31214 |
|
31215 |
|
31216 |
|
31217 |
|
31218 |
|
31219 |
|
31220 |
|
31221 |
|
31222 |
|
31223 |
|
31224 |
|
31225 | }, {
|
31226 | key: "levenshteinDistance",
|
31227 | value: function levenshteinDistance(a, b) {
|
31228 | if (a.length === 0) return b.length;
|
31229 | if (b.length === 0) return a.length;
|
31230 | var matrix = [];
|
31231 |
|
31232 | var i;
|
31233 |
|
31234 | for (i = 0; i <= b.length; i++) {
|
31235 | matrix[i] = [i];
|
31236 | }
|
31237 |
|
31238 |
|
31239 | var j;
|
31240 |
|
31241 | for (j = 0; j <= a.length; j++) {
|
31242 | matrix[0][j] = j;
|
31243 | }
|
31244 |
|
31245 |
|
31246 | for (i = 1; i <= b.length; i++) {
|
31247 | for (j = 1; j <= a.length; j++) {
|
31248 | if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
31249 | matrix[i][j] = matrix[i - 1][j - 1];
|
31250 | } else {
|
31251 | matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1,
|
31252 | Math.min(matrix[i][j - 1] + 1,
|
31253 | matrix[i - 1][j] + 1));
|
31254 | }
|
31255 | }
|
31256 | }
|
31257 |
|
31258 | return matrix[b.length][a.length];
|
31259 | }
|
31260 | }]);
|
31261 |
|
31262 | return Validator;
|
31263 | }();
|
31264 |
|
31265 |
|
31266 |
|
31267 |
|
31268 |
|
31269 |
|
31270 |
|
31271 |
|
31272 | var string$1 = 'string';
|
31273 | var bool$1 = 'boolean';
|
31274 | var number$1 = 'number';
|
31275 | var array$1 = 'array';
|
31276 | var date$1 = 'date';
|
31277 | var object$1 = 'object';
|
31278 |
|
31279 | var dom$1 = 'dom';
|
31280 | var moment$1 = 'moment';
|
31281 | var any$1 = 'any';
|
31282 | var allOptions$1 = {
|
31283 | configure: {
|
31284 | enabled: {
|
31285 | 'boolean': bool$1
|
31286 | },
|
31287 | filter: {
|
31288 | 'boolean': bool$1,
|
31289 | 'function': 'function'
|
31290 | },
|
31291 | container: {
|
31292 | dom: dom$1
|
31293 | },
|
31294 | __type__: {
|
31295 | object: object$1,
|
31296 | 'boolean': bool$1,
|
31297 | 'function': 'function'
|
31298 | }
|
31299 | },
|
31300 |
|
31301 | align: {
|
31302 | string: string$1
|
31303 | },
|
31304 | alignCurrentTime: {
|
31305 | string: string$1,
|
31306 | 'undefined': 'undefined'
|
31307 | },
|
31308 | rtl: {
|
31309 | 'boolean': bool$1,
|
31310 | 'undefined': 'undefined'
|
31311 | },
|
31312 | rollingMode: {
|
31313 | follow: {
|
31314 | 'boolean': bool$1
|
31315 | },
|
31316 | offset: {
|
31317 | number: number$1,
|
31318 | 'undefined': 'undefined'
|
31319 | },
|
31320 | __type__: {
|
31321 | object: object$1
|
31322 | }
|
31323 | },
|
31324 | onTimeout: {
|
31325 | timeoutMs: {
|
31326 | number: number$1
|
31327 | },
|
31328 | callback: {
|
31329 | 'function': 'function'
|
31330 | },
|
31331 | __type__: {
|
31332 | object: object$1
|
31333 | }
|
31334 | },
|
31335 | verticalScroll: {
|
31336 | 'boolean': bool$1,
|
31337 | 'undefined': 'undefined'
|
31338 | },
|
31339 | horizontalScroll: {
|
31340 | 'boolean': bool$1,
|
31341 | 'undefined': 'undefined'
|
31342 | },
|
31343 | autoResize: {
|
31344 | 'boolean': bool$1
|
31345 | },
|
31346 | throttleRedraw: {
|
31347 | number: number$1
|
31348 | },
|
31349 |
|
31350 | clickToUse: {
|
31351 | 'boolean': bool$1
|
31352 | },
|
31353 | dataAttributes: {
|
31354 | string: string$1,
|
31355 | array: array$1
|
31356 | },
|
31357 | editable: {
|
31358 | add: {
|
31359 | 'boolean': bool$1,
|
31360 | 'undefined': 'undefined'
|
31361 | },
|
31362 | remove: {
|
31363 | 'boolean': bool$1,
|
31364 | 'undefined': 'undefined'
|
31365 | },
|
31366 | updateGroup: {
|
31367 | 'boolean': bool$1,
|
31368 | 'undefined': 'undefined'
|
31369 | },
|
31370 | updateTime: {
|
31371 | 'boolean': bool$1,
|
31372 | 'undefined': 'undefined'
|
31373 | },
|
31374 | overrideItems: {
|
31375 | 'boolean': bool$1,
|
31376 | 'undefined': 'undefined'
|
31377 | },
|
31378 | __type__: {
|
31379 | 'boolean': bool$1,
|
31380 | object: object$1
|
31381 | }
|
31382 | },
|
31383 | end: {
|
31384 | number: number$1,
|
31385 | date: date$1,
|
31386 | string: string$1,
|
31387 | moment: moment$1
|
31388 | },
|
31389 | format: {
|
31390 | minorLabels: {
|
31391 | millisecond: {
|
31392 | string: string$1,
|
31393 | 'undefined': 'undefined'
|
31394 | },
|
31395 | second: {
|
31396 | string: string$1,
|
31397 | 'undefined': 'undefined'
|
31398 | },
|
31399 | minute: {
|
31400 | string: string$1,
|
31401 | 'undefined': 'undefined'
|
31402 | },
|
31403 | hour: {
|
31404 | string: string$1,
|
31405 | 'undefined': 'undefined'
|
31406 | },
|
31407 | weekday: {
|
31408 | string: string$1,
|
31409 | 'undefined': 'undefined'
|
31410 | },
|
31411 | day: {
|
31412 | string: string$1,
|
31413 | 'undefined': 'undefined'
|
31414 | },
|
31415 | week: {
|
31416 | string: string$1,
|
31417 | 'undefined': 'undefined'
|
31418 | },
|
31419 | month: {
|
31420 | string: string$1,
|
31421 | 'undefined': 'undefined'
|
31422 | },
|
31423 | year: {
|
31424 | string: string$1,
|
31425 | 'undefined': 'undefined'
|
31426 | },
|
31427 | __type__: {
|
31428 | object: object$1,
|
31429 | 'function': 'function'
|
31430 | }
|
31431 | },
|
31432 | majorLabels: {
|
31433 | millisecond: {
|
31434 | string: string$1,
|
31435 | 'undefined': 'undefined'
|
31436 | },
|
31437 | second: {
|
31438 | string: string$1,
|
31439 | 'undefined': 'undefined'
|
31440 | },
|
31441 | minute: {
|
31442 | string: string$1,
|
31443 | 'undefined': 'undefined'
|
31444 | },
|
31445 | hour: {
|
31446 | string: string$1,
|
31447 | 'undefined': 'undefined'
|
31448 | },
|
31449 | weekday: {
|
31450 | string: string$1,
|
31451 | 'undefined': 'undefined'
|
31452 | },
|
31453 | day: {
|
31454 | string: string$1,
|
31455 | 'undefined': 'undefined'
|
31456 | },
|
31457 | week: {
|
31458 | string: string$1,
|
31459 | 'undefined': 'undefined'
|
31460 | },
|
31461 | month: {
|
31462 | string: string$1,
|
31463 | 'undefined': 'undefined'
|
31464 | },
|
31465 | year: {
|
31466 | string: string$1,
|
31467 | 'undefined': 'undefined'
|
31468 | },
|
31469 | __type__: {
|
31470 | object: object$1,
|
31471 | 'function': 'function'
|
31472 | }
|
31473 | },
|
31474 | __type__: {
|
31475 | object: object$1
|
31476 | }
|
31477 | },
|
31478 | moment: {
|
31479 | 'function': 'function'
|
31480 | },
|
31481 | groupHeightMode: {
|
31482 | string: string$1
|
31483 | },
|
31484 | groupOrder: {
|
31485 | string: string$1,
|
31486 | 'function': 'function'
|
31487 | },
|
31488 | groupEditable: {
|
31489 | add: {
|
31490 | 'boolean': bool$1,
|
31491 | 'undefined': 'undefined'
|
31492 | },
|
31493 | remove: {
|
31494 | 'boolean': bool$1,
|
31495 | 'undefined': 'undefined'
|
31496 | },
|
31497 | order: {
|
31498 | 'boolean': bool$1,
|
31499 | 'undefined': 'undefined'
|
31500 | },
|
31501 | __type__: {
|
31502 | 'boolean': bool$1,
|
31503 | object: object$1
|
31504 | }
|
31505 | },
|
31506 | groupOrderSwap: {
|
31507 | 'function': 'function'
|
31508 | },
|
31509 | height: {
|
31510 | string: string$1,
|
31511 | number: number$1
|
31512 | },
|
31513 | hiddenDates: {
|
31514 | start: {
|
31515 | date: date$1,
|
31516 | number: number$1,
|
31517 | string: string$1,
|
31518 | moment: moment$1
|
31519 | },
|
31520 | end: {
|
31521 | date: date$1,
|
31522 | number: number$1,
|
31523 | string: string$1,
|
31524 | moment: moment$1
|
31525 | },
|
31526 | repeat: {
|
31527 | string: string$1
|
31528 | },
|
31529 | __type__: {
|
31530 | object: object$1,
|
31531 | array: array$1
|
31532 | }
|
31533 | },
|
31534 | itemsAlwaysDraggable: {
|
31535 | item: {
|
31536 | 'boolean': bool$1,
|
31537 | 'undefined': 'undefined'
|
31538 | },
|
31539 | range: {
|
31540 | 'boolean': bool$1,
|
31541 | 'undefined': 'undefined'
|
31542 | },
|
31543 | __type__: {
|
31544 | 'boolean': bool$1,
|
31545 | object: object$1
|
31546 | }
|
31547 | },
|
31548 | limitSize: {
|
31549 | 'boolean': bool$1
|
31550 | },
|
31551 | locale: {
|
31552 | string: string$1
|
31553 | },
|
31554 | locales: {
|
31555 | __any__: {
|
31556 | any: any$1
|
31557 | },
|
31558 | __type__: {
|
31559 | object: object$1
|
31560 | }
|
31561 | },
|
31562 | longSelectPressTime: {
|
31563 | number: number$1
|
31564 | },
|
31565 | margin: {
|
31566 | axis: {
|
31567 | number: number$1
|
31568 | },
|
31569 | item: {
|
31570 | horizontal: {
|
31571 | number: number$1,
|
31572 | 'undefined': 'undefined'
|
31573 | },
|
31574 | vertical: {
|
31575 | number: number$1,
|
31576 | 'undefined': 'undefined'
|
31577 | },
|
31578 | __type__: {
|
31579 | object: object$1,
|
31580 | number: number$1
|
31581 | }
|
31582 | },
|
31583 | __type__: {
|
31584 | object: object$1,
|
31585 | number: number$1
|
31586 | }
|
31587 | },
|
31588 | max: {
|
31589 | date: date$1,
|
31590 | number: number$1,
|
31591 | string: string$1,
|
31592 | moment: moment$1
|
31593 | },
|
31594 | maxHeight: {
|
31595 | number: number$1,
|
31596 | string: string$1
|
31597 | },
|
31598 | maxMinorChars: {
|
31599 | number: number$1
|
31600 | },
|
31601 | min: {
|
31602 | date: date$1,
|
31603 | number: number$1,
|
31604 | string: string$1,
|
31605 | moment: moment$1
|
31606 | },
|
31607 | minHeight: {
|
31608 | number: number$1,
|
31609 | string: string$1
|
31610 | },
|
31611 | moveable: {
|
31612 | 'boolean': bool$1
|
31613 | },
|
31614 | multiselect: {
|
31615 | 'boolean': bool$1
|
31616 | },
|
31617 | multiselectPerGroup: {
|
31618 | 'boolean': bool$1
|
31619 | },
|
31620 | onAdd: {
|
31621 | 'function': 'function'
|
31622 | },
|
31623 | onDropObjectOnItem: {
|
31624 | 'function': 'function'
|
31625 | },
|
31626 | onUpdate: {
|
31627 | 'function': 'function'
|
31628 | },
|
31629 | onMove: {
|
31630 | 'function': 'function'
|
31631 | },
|
31632 | onMoving: {
|
31633 | 'function': 'function'
|
31634 | },
|
31635 | onRemove: {
|
31636 | 'function': 'function'
|
31637 | },
|
31638 | onAddGroup: {
|
31639 | 'function': 'function'
|
31640 | },
|
31641 | onMoveGroup: {
|
31642 | 'function': 'function'
|
31643 | },
|
31644 | onRemoveGroup: {
|
31645 | 'function': 'function'
|
31646 | },
|
31647 | onInitialDrawComplete: {
|
31648 | 'function': 'function'
|
31649 | },
|
31650 | order: {
|
31651 | 'function': 'function'
|
31652 | },
|
31653 | orientation: {
|
31654 | axis: {
|
31655 | string: string$1,
|
31656 | 'undefined': 'undefined'
|
31657 | },
|
31658 | item: {
|
31659 | string: string$1,
|
31660 | 'undefined': 'undefined'
|
31661 | },
|
31662 | __type__: {
|
31663 | string: string$1,
|
31664 | object: object$1
|
31665 | }
|
31666 | },
|
31667 | selectable: {
|
31668 | 'boolean': bool$1
|
31669 | },
|
31670 | sequentialSelection: {
|
31671 | 'boolean': bool$1
|
31672 | },
|
31673 | showCurrentTime: {
|
31674 | 'boolean': bool$1
|
31675 | },
|
31676 | showMajorLabels: {
|
31677 | 'boolean': bool$1
|
31678 | },
|
31679 | showMinorLabels: {
|
31680 | 'boolean': bool$1
|
31681 | },
|
31682 | showWeekScale: {
|
31683 | 'boolean': bool$1
|
31684 | },
|
31685 | stack: {
|
31686 | 'boolean': bool$1
|
31687 | },
|
31688 | stackSubgroups: {
|
31689 | 'boolean': bool$1
|
31690 | },
|
31691 | cluster: {
|
31692 | maxItems: {
|
31693 | 'number': number$1,
|
31694 | 'undefined': 'undefined'
|
31695 | },
|
31696 | titleTemplate: {
|
31697 | 'string': string$1,
|
31698 | 'undefined': 'undefined'
|
31699 | },
|
31700 | clusterCriteria: {
|
31701 | 'function': 'function',
|
31702 | 'undefined': 'undefined'
|
31703 | },
|
31704 | showStipes: {
|
31705 | 'boolean': bool$1,
|
31706 | 'undefined': 'undefined'
|
31707 | },
|
31708 | fitOnDoubleClick: {
|
31709 | 'boolean': bool$1,
|
31710 | 'undefined': 'undefined'
|
31711 | },
|
31712 | __type__: {
|
31713 | 'boolean': bool$1,
|
31714 | object: object$1
|
31715 | }
|
31716 | },
|
31717 | snap: {
|
31718 | 'function': 'function',
|
31719 | 'null': 'null'
|
31720 | },
|
31721 | start: {
|
31722 | date: date$1,
|
31723 | number: number$1,
|
31724 | string: string$1,
|
31725 | moment: moment$1
|
31726 | },
|
31727 | template: {
|
31728 | 'function': 'function'
|
31729 | },
|
31730 | loadingScreenTemplate: {
|
31731 | 'function': 'function'
|
31732 | },
|
31733 | groupTemplate: {
|
31734 | 'function': 'function'
|
31735 | },
|
31736 | visibleFrameTemplate: {
|
31737 | string: string$1,
|
31738 | 'function': 'function'
|
31739 | },
|
31740 | showTooltips: {
|
31741 | 'boolean': bool$1
|
31742 | },
|
31743 | tooltip: {
|
31744 | followMouse: {
|
31745 | 'boolean': bool$1
|
31746 | },
|
31747 | overflowMethod: {
|
31748 | 'string': ['cap', 'flip', 'none']
|
31749 | },
|
31750 | delay: {
|
31751 | number: number$1
|
31752 | },
|
31753 | template: {
|
31754 | 'function': 'function'
|
31755 | },
|
31756 | __type__: {
|
31757 | object: object$1
|
31758 | }
|
31759 | },
|
31760 | tooltipOnItemUpdateTime: {
|
31761 | template: {
|
31762 | 'function': 'function'
|
31763 | },
|
31764 | __type__: {
|
31765 | 'boolean': bool$1,
|
31766 | object: object$1
|
31767 | }
|
31768 | },
|
31769 | timeAxis: {
|
31770 | scale: {
|
31771 | string: string$1,
|
31772 | 'undefined': 'undefined'
|
31773 | },
|
31774 | step: {
|
31775 | number: number$1,
|
31776 | 'undefined': 'undefined'
|
31777 | },
|
31778 | __type__: {
|
31779 | object: object$1
|
31780 | }
|
31781 | },
|
31782 | type: {
|
31783 | string: string$1
|
31784 | },
|
31785 | width: {
|
31786 | string: string$1,
|
31787 | number: number$1
|
31788 | },
|
31789 | preferZoom: {
|
31790 | 'boolean': bool$1
|
31791 | },
|
31792 | zoomable: {
|
31793 | 'boolean': bool$1
|
31794 | },
|
31795 | zoomKey: {
|
31796 | string: ['ctrlKey', 'altKey', 'shiftKey', 'metaKey', '']
|
31797 | },
|
31798 | zoomFriction: {
|
31799 | number: number$1
|
31800 | },
|
31801 | zoomMax: {
|
31802 | number: number$1
|
31803 | },
|
31804 | zoomMin: {
|
31805 | number: number$1
|
31806 | },
|
31807 | xss: {
|
31808 | disabled: {
|
31809 | boolean: bool$1
|
31810 | },
|
31811 | filterOptions: {
|
31812 | __any__: {
|
31813 | any: any$1
|
31814 | },
|
31815 | __type__: {
|
31816 | object: object$1
|
31817 | }
|
31818 | },
|
31819 | __type__: {
|
31820 | object: object$1
|
31821 | }
|
31822 | },
|
31823 | __type__: {
|
31824 | object: object$1
|
31825 | }
|
31826 | };
|
31827 | var configureOptions$1 = {
|
31828 | global: {
|
31829 | align: ['center', 'left', 'right'],
|
31830 | alignCurrentTime: ['none', 'year', 'month', 'quarter', 'week', 'isoWeek', 'day', 'date', 'hour', 'minute', 'second'],
|
31831 | direction: false,
|
31832 | autoResize: true,
|
31833 | clickToUse: false,
|
31834 |
|
31835 | editable: {
|
31836 | add: false,
|
31837 | remove: false,
|
31838 | updateGroup: false,
|
31839 | updateTime: false
|
31840 | },
|
31841 | end: '',
|
31842 | format: {
|
31843 | minorLabels: {
|
31844 | millisecond: 'SSS',
|
31845 | second: 's',
|
31846 | minute: 'HH:mm',
|
31847 | hour: 'HH:mm',
|
31848 | weekday: 'ddd D',
|
31849 | day: 'D',
|
31850 | week: 'w',
|
31851 | month: 'MMM',
|
31852 | year: 'YYYY'
|
31853 | },
|
31854 | majorLabels: {
|
31855 | millisecond: 'HH:mm:ss',
|
31856 | second: 'D MMMM HH:mm',
|
31857 | minute: 'ddd D MMMM',
|
31858 | hour: 'ddd D MMMM',
|
31859 | weekday: 'MMMM YYYY',
|
31860 | day: 'MMMM YYYY',
|
31861 | week: 'MMMM YYYY',
|
31862 | month: 'YYYY',
|
31863 | year: ''
|
31864 | }
|
31865 | },
|
31866 | groupHeightMode: ['auto', 'fixed', 'fitItems'],
|
31867 |
|
31868 | groupsDraggable: false,
|
31869 | height: '',
|
31870 |
|
31871 | locale: '',
|
31872 | longSelectPressTime: 251,
|
31873 | margin: {
|
31874 | axis: [20, 0, 100, 1],
|
31875 | item: {
|
31876 | horizontal: [10, 0, 100, 1],
|
31877 | vertical: [10, 0, 100, 1]
|
31878 | }
|
31879 | },
|
31880 | max: '',
|
31881 | maxHeight: '',
|
31882 | maxMinorChars: [7, 0, 20, 1],
|
31883 | min: '',
|
31884 | minHeight: '',
|
31885 | moveable: false,
|
31886 | multiselect: false,
|
31887 | multiselectPerGroup: false,
|
31888 |
|
31889 |
|
31890 |
|
31891 |
|
31892 |
|
31893 |
|
31894 | orientation: {
|
31895 | axis: ['both', 'bottom', 'top'],
|
31896 | item: ['bottom', 'top']
|
31897 | },
|
31898 | preferZoom: false,
|
31899 | selectable: true,
|
31900 | showCurrentTime: false,
|
31901 | showMajorLabels: true,
|
31902 | showMinorLabels: true,
|
31903 | stack: true,
|
31904 | stackSubgroups: true,
|
31905 | cluster: false,
|
31906 |
|
31907 | start: '',
|
31908 |
|
31909 |
|
31910 |
|
31911 |
|
31912 |
|
31913 | showTooltips: true,
|
31914 | tooltip: {
|
31915 | followMouse: false,
|
31916 | overflowMethod: 'flip',
|
31917 | delay: [500, 0, 99999, 100]
|
31918 | },
|
31919 | tooltipOnItemUpdateTime: false,
|
31920 | type: ['box', 'point', 'range', 'background'],
|
31921 | width: '100%',
|
31922 | zoomable: true,
|
31923 | zoomKey: ['ctrlKey', 'altKey', 'shiftKey', 'metaKey', ''],
|
31924 | zoomMax: [315360000000000, 10, 315360000000000, 1],
|
31925 | zoomMin: [10, 10, 315360000000000, 1],
|
31926 | xss: {
|
31927 | disabled: false
|
31928 | }
|
31929 | }
|
31930 | };
|
31931 |
|
31932 | var htmlColors = {
|
31933 | black: '#000000',
|
31934 | navy: '#000080',
|
31935 | darkblue: '#00008B',
|
31936 | mediumblue: '#0000CD',
|
31937 | blue: '#0000FF',
|
31938 | darkgreen: '#006400',
|
31939 | green: '#008000',
|
31940 | teal: '#008080',
|
31941 | darkcyan: '#008B8B',
|
31942 | deepskyblue: '#00BFFF',
|
31943 | darkturquoise: '#00CED1',
|
31944 | mediumspringgreen: '#00FA9A',
|
31945 | lime: '#00FF00',
|
31946 | springgreen: '#00FF7F',
|
31947 | aqua: '#00FFFF',
|
31948 | cyan: '#00FFFF',
|
31949 | midnightblue: '#191970',
|
31950 | dodgerblue: '#1E90FF',
|
31951 | lightseagreen: '#20B2AA',
|
31952 | forestgreen: '#228B22',
|
31953 | seagreen: '#2E8B57',
|
31954 | darkslategray: '#2F4F4F',
|
31955 | limegreen: '#32CD32',
|
31956 | mediumseagreen: '#3CB371',
|
31957 | turquoise: '#40E0D0',
|
31958 | royalblue: '#4169E1',
|
31959 | steelblue: '#4682B4',
|
31960 | darkslateblue: '#483D8B',
|
31961 | mediumturquoise: '#48D1CC',
|
31962 | indigo: '#4B0082',
|
31963 | darkolivegreen: '#556B2F',
|
31964 | cadetblue: '#5F9EA0',
|
31965 | cornflowerblue: '#6495ED',
|
31966 | mediumaquamarine: '#66CDAA',
|
31967 | dimgray: '#696969',
|
31968 | slateblue: '#6A5ACD',
|
31969 | olivedrab: '#6B8E23',
|
31970 | slategray: '#708090',
|
31971 | lightslategray: '#778899',
|
31972 | mediumslateblue: '#7B68EE',
|
31973 | lawngreen: '#7CFC00',
|
31974 | chartreuse: '#7FFF00',
|
31975 | aquamarine: '#7FFFD4',
|
31976 | maroon: '#800000',
|
31977 | purple: '#800080',
|
31978 | olive: '#808000',
|
31979 | gray: '#808080',
|
31980 | skyblue: '#87CEEB',
|
31981 | lightskyblue: '#87CEFA',
|
31982 | blueviolet: '#8A2BE2',
|
31983 | darkred: '#8B0000',
|
31984 | darkmagenta: '#8B008B',
|
31985 | saddlebrown: '#8B4513',
|
31986 | darkseagreen: '#8FBC8F',
|
31987 | lightgreen: '#90EE90',
|
31988 | mediumpurple: '#9370D8',
|
31989 | darkviolet: '#9400D3',
|
31990 | palegreen: '#98FB98',
|
31991 | darkorchid: '#9932CC',
|
31992 | yellowgreen: '#9ACD32',
|
31993 | sienna: '#A0522D',
|
31994 | brown: '#A52A2A',
|
31995 | darkgray: '#A9A9A9',
|
31996 | lightblue: '#ADD8E6',
|
31997 | greenyellow: '#ADFF2F',
|
31998 | paleturquoise: '#AFEEEE',
|
31999 | lightsteelblue: '#B0C4DE',
|
32000 | powderblue: '#B0E0E6',
|
32001 | firebrick: '#B22222',
|
32002 | darkgoldenrod: '#B8860B',
|
32003 | mediumorchid: '#BA55D3',
|
32004 | rosybrown: '#BC8F8F',
|
32005 | darkkhaki: '#BDB76B',
|
32006 | silver: '#C0C0C0',
|
32007 | mediumvioletred: '#C71585',
|
32008 | indianred: '#CD5C5C',
|
32009 | peru: '#CD853F',
|
32010 | chocolate: '#D2691E',
|
32011 | tan: '#D2B48C',
|
32012 | lightgrey: '#D3D3D3',
|
32013 | palevioletred: '#D87093',
|
32014 | thistle: '#D8BFD8',
|
32015 | orchid: '#DA70D6',
|
32016 | goldenrod: '#DAA520',
|
32017 | crimson: '#DC143C',
|
32018 | gainsboro: '#DCDCDC',
|
32019 | plum: '#DDA0DD',
|
32020 | burlywood: '#DEB887',
|
32021 | lightcyan: '#E0FFFF',
|
32022 | lavender: '#E6E6FA',
|
32023 | darksalmon: '#E9967A',
|
32024 | violet: '#EE82EE',
|
32025 | palegoldenrod: '#EEE8AA',
|
32026 | lightcoral: '#F08080',
|
32027 | khaki: '#F0E68C',
|
32028 | aliceblue: '#F0F8FF',
|
32029 | honeydew: '#F0FFF0',
|
32030 | azure: '#F0FFFF',
|
32031 | sandybrown: '#F4A460',
|
32032 | wheat: '#F5DEB3',
|
32033 | beige: '#F5F5DC',
|
32034 | whitesmoke: '#F5F5F5',
|
32035 | mintcream: '#F5FFFA',
|
32036 | ghostwhite: '#F8F8FF',
|
32037 | salmon: '#FA8072',
|
32038 | antiquewhite: '#FAEBD7',
|
32039 | linen: '#FAF0E6',
|
32040 | lightgoldenrodyellow: '#FAFAD2',
|
32041 | oldlace: '#FDF5E6',
|
32042 | red: '#FF0000',
|
32043 | fuchsia: '#FF00FF',
|
32044 | magenta: '#FF00FF',
|
32045 | deeppink: '#FF1493',
|
32046 | orangered: '#FF4500',
|
32047 | tomato: '#FF6347',
|
32048 | hotpink: '#FF69B4',
|
32049 | coral: '#FF7F50',
|
32050 | darkorange: '#FF8C00',
|
32051 | lightsalmon: '#FFA07A',
|
32052 | orange: '#FFA500',
|
32053 | lightpink: '#FFB6C1',
|
32054 | pink: '#FFC0CB',
|
32055 | gold: '#FFD700',
|
32056 | peachpuff: '#FFDAB9',
|
32057 | navajowhite: '#FFDEAD',
|
32058 | moccasin: '#FFE4B5',
|
32059 | bisque: '#FFE4C4',
|
32060 | mistyrose: '#FFE4E1',
|
32061 | blanchedalmond: '#FFEBCD',
|
32062 | papayawhip: '#FFEFD5',
|
32063 | lavenderblush: '#FFF0F5',
|
32064 | seashell: '#FFF5EE',
|
32065 | cornsilk: '#FFF8DC',
|
32066 | lemonchiffon: '#FFFACD',
|
32067 | floralwhite: '#FFFAF0',
|
32068 | snow: '#FFFAFA',
|
32069 | yellow: '#FFFF00',
|
32070 | lightyellow: '#FFFFE0',
|
32071 | ivory: '#FFFFF0',
|
32072 | white: '#FFFFFF'
|
32073 | };
|
32074 |
|
32075 |
|
32076 |
|
32077 |
|
32078 | var ColorPicker = function () {
|
32079 | |
32080 |
|
32081 |
|
32082 | function ColorPicker() {
|
32083 | var pixelRatio = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
32084 |
|
32085 | _classCallCheck(this, ColorPicker);
|
32086 |
|
32087 | this.pixelRatio = pixelRatio;
|
32088 | this.generated = false;
|
32089 | this.centerCoordinates = {
|
32090 | x: 289 / 2,
|
32091 | y: 289 / 2
|
32092 | };
|
32093 | this.r = 289 * 0.49;
|
32094 | this.color = {
|
32095 | r: 255,
|
32096 | g: 255,
|
32097 | b: 255,
|
32098 | a: 1.0
|
32099 | };
|
32100 | this.hueCircle = undefined;
|
32101 | this.initialColor = {
|
32102 | r: 255,
|
32103 | g: 255,
|
32104 | b: 255,
|
32105 | a: 1.0
|
32106 | };
|
32107 | this.previousColor = undefined;
|
32108 | this.applied = false;
|
32109 |
|
32110 | this.updateCallback = function () {};
|
32111 |
|
32112 | this.closeCallback = function () {};
|
32113 |
|
32114 |
|
32115 | this._create();
|
32116 | }
|
32117 | |
32118 |
|
32119 |
|
32120 |
|
32121 |
|
32122 |
|
32123 | _createClass(ColorPicker, [{
|
32124 | key: "insertTo",
|
32125 | value: function insertTo(container) {
|
32126 | if (this.hammer !== undefined) {
|
32127 | this.hammer.destroy();
|
32128 | this.hammer = undefined;
|
32129 | }
|
32130 |
|
32131 | this.container = container;
|
32132 | this.container.appendChild(this.frame);
|
32133 |
|
32134 | this._bindHammer();
|
32135 |
|
32136 | this._setSize();
|
32137 | }
|
32138 | |
32139 |
|
32140 |
|
32141 |
|
32142 |
|
32143 | }, {
|
32144 | key: "setUpdateCallback",
|
32145 | value: function setUpdateCallback(callback) {
|
32146 | if (typeof callback === 'function') {
|
32147 | this.updateCallback = callback;
|
32148 | } else {
|
32149 | throw new Error("Function attempted to set as colorPicker update callback is not a function.");
|
32150 | }
|
32151 | }
|
32152 | |
32153 |
|
32154 |
|
32155 |
|
32156 |
|
32157 | }, {
|
32158 | key: "setCloseCallback",
|
32159 | value: function setCloseCallback(callback) {
|
32160 | if (typeof callback === 'function') {
|
32161 | this.closeCallback = callback;
|
32162 | } else {
|
32163 | throw new Error("Function attempted to set as colorPicker closing callback is not a function.");
|
32164 | }
|
32165 | }
|
32166 | |
32167 |
|
32168 |
|
32169 |
|
32170 |
|
32171 |
|
32172 |
|
32173 | }, {
|
32174 | key: "_isColorString",
|
32175 | value: function _isColorString(color) {
|
32176 | if (typeof color === 'string') {
|
32177 | return htmlColors[color];
|
32178 | }
|
32179 | }
|
32180 | |
32181 |
|
32182 |
|
32183 |
|
32184 |
|
32185 |
|
32186 |
|
32187 |
|
32188 |
|
32189 |
|
32190 |
|
32191 |
|
32192 |
|
32193 | }, {
|
32194 | key: "setColor",
|
32195 | value: function setColor(color) {
|
32196 | var setInitial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
32197 |
|
32198 | if (color === 'none') {
|
32199 | return;
|
32200 | }
|
32201 |
|
32202 | var rgba;
|
32203 |
|
32204 | var htmlColor = this._isColorString(color);
|
32205 |
|
32206 | if (htmlColor !== undefined) {
|
32207 | color = htmlColor;
|
32208 | }
|
32209 |
|
32210 |
|
32211 | if (availableUtils.isString(color) === true) {
|
32212 | if (availableUtils.isValidRGB(color) === true) {
|
32213 | var rgbaArray = color.substr(4).substr(0, color.length - 5).split(',');
|
32214 | rgba = {
|
32215 | r: rgbaArray[0],
|
32216 | g: rgbaArray[1],
|
32217 | b: rgbaArray[2],
|
32218 | a: 1.0
|
32219 | };
|
32220 | } else if (availableUtils.isValidRGBA(color) === true) {
|
32221 | var _rgbaArray = color.substr(5).substr(0, color.length - 6).split(',');
|
32222 |
|
32223 | rgba = {
|
32224 | r: _rgbaArray[0],
|
32225 | g: _rgbaArray[1],
|
32226 | b: _rgbaArray[2],
|
32227 | a: _rgbaArray[3]
|
32228 | };
|
32229 | } else if (availableUtils.isValidHex(color) === true) {
|
32230 | var rgbObj = availableUtils.hexToRGB(color);
|
32231 | rgba = {
|
32232 | r: rgbObj.r,
|
32233 | g: rgbObj.g,
|
32234 | b: rgbObj.b,
|
32235 | a: 1.0
|
32236 | };
|
32237 | }
|
32238 | } else {
|
32239 | if (color instanceof Object) {
|
32240 | if (color.r !== undefined && color.g !== undefined && color.b !== undefined) {
|
32241 | var alpha = color.a !== undefined ? color.a : '1.0';
|
32242 | rgba = {
|
32243 | r: color.r,
|
32244 | g: color.g,
|
32245 | b: color.b,
|
32246 | a: alpha
|
32247 | };
|
32248 | }
|
32249 | }
|
32250 | }
|
32251 |
|
32252 |
|
32253 | if (rgba === undefined) {
|
32254 | throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: " + _JSON$stringify(color));
|
32255 | } else {
|
32256 | this._setColor(rgba, setInitial);
|
32257 | }
|
32258 | }
|
32259 | |
32260 |
|
32261 |
|
32262 |
|
32263 |
|
32264 | }, {
|
32265 | key: "show",
|
32266 | value: function show() {
|
32267 | if (this.closeCallback !== undefined) {
|
32268 | this.closeCallback();
|
32269 | this.closeCallback = undefined;
|
32270 | }
|
32271 |
|
32272 | this.applied = false;
|
32273 | this.frame.style.display = 'block';
|
32274 |
|
32275 | this._generateHueCircle();
|
32276 | }
|
32277 |
|
32278 | |
32279 |
|
32280 |
|
32281 |
|
32282 |
|
32283 |
|
32284 |
|
32285 | }, {
|
32286 | key: "_hide",
|
32287 | value: function _hide() {
|
32288 | var _this = this;
|
32289 |
|
32290 | var storePrevious = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
32291 |
|
32292 |
|
32293 | if (storePrevious === true) {
|
32294 | this.previousColor = availableUtils.extend({}, this.color);
|
32295 | }
|
32296 |
|
32297 | if (this.applied === true) {
|
32298 | this.updateCallback(this.initialColor);
|
32299 | }
|
32300 |
|
32301 | this.frame.style.display = 'none';
|
32302 |
|
32303 |
|
32304 | _setTimeout(function () {
|
32305 | if (_this.closeCallback !== undefined) {
|
32306 | _this.closeCallback();
|
32307 |
|
32308 | _this.closeCallback = undefined;
|
32309 | }
|
32310 | }, 0);
|
32311 | }
|
32312 | |
32313 |
|
32314 |
|
32315 |
|
32316 |
|
32317 | }, {
|
32318 | key: "_save",
|
32319 | value: function _save() {
|
32320 | this.updateCallback(this.color);
|
32321 | this.applied = false;
|
32322 |
|
32323 | this._hide();
|
32324 | }
|
32325 | |
32326 |
|
32327 |
|
32328 |
|
32329 |
|
32330 | }, {
|
32331 | key: "_apply",
|
32332 | value: function _apply() {
|
32333 | this.applied = true;
|
32334 | this.updateCallback(this.color);
|
32335 |
|
32336 | this._updatePicker(this.color);
|
32337 | }
|
32338 | |
32339 |
|
32340 |
|
32341 |
|
32342 |
|
32343 | }, {
|
32344 | key: "_loadLast",
|
32345 | value: function _loadLast() {
|
32346 | if (this.previousColor !== undefined) {
|
32347 | this.setColor(this.previousColor, false);
|
32348 | } else {
|
32349 | alert("There is no last color to load...");
|
32350 | }
|
32351 | }
|
32352 | |
32353 |
|
32354 |
|
32355 |
|
32356 |
|
32357 |
|
32358 |
|
32359 | }, {
|
32360 | key: "_setColor",
|
32361 | value: function _setColor(rgba) {
|
32362 | var setInitial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
32363 |
|
32364 |
|
32365 | if (setInitial === true) {
|
32366 | this.initialColor = availableUtils.extend({}, rgba);
|
32367 | }
|
32368 |
|
32369 | this.color = rgba;
|
32370 | var hsv = availableUtils.RGBToHSV(rgba.r, rgba.g, rgba.b);
|
32371 | var angleConvert = 2 * Math.PI;
|
32372 | var radius = this.r * hsv.s;
|
32373 | var x = this.centerCoordinates.x + radius * Math.sin(angleConvert * hsv.h);
|
32374 | var y = this.centerCoordinates.y + radius * Math.cos(angleConvert * hsv.h);
|
32375 | this.colorPickerSelector.style.left = x - 0.5 * this.colorPickerSelector.clientWidth + 'px';
|
32376 | this.colorPickerSelector.style.top = y - 0.5 * this.colorPickerSelector.clientHeight + 'px';
|
32377 |
|
32378 | this._updatePicker(rgba);
|
32379 | }
|
32380 | |
32381 |
|
32382 |
|
32383 |
|
32384 |
|
32385 |
|
32386 | }, {
|
32387 | key: "_setOpacity",
|
32388 | value: function _setOpacity(value) {
|
32389 | this.color.a = value / 100;
|
32390 |
|
32391 | this._updatePicker(this.color);
|
32392 | }
|
32393 | |
32394 |
|
32395 |
|
32396 |
|
32397 |
|
32398 |
|
32399 | }, {
|
32400 | key: "_setBrightness",
|
32401 | value: function _setBrightness(value) {
|
32402 | var hsv = availableUtils.RGBToHSV(this.color.r, this.color.g, this.color.b);
|
32403 | hsv.v = value / 100;
|
32404 | var rgba = availableUtils.HSVToRGB(hsv.h, hsv.s, hsv.v);
|
32405 | rgba['a'] = this.color.a;
|
32406 | this.color = rgba;
|
32407 |
|
32408 | this._updatePicker();
|
32409 | }
|
32410 | |
32411 |
|
32412 |
|
32413 |
|
32414 |
|
32415 |
|
32416 | }, {
|
32417 | key: "_updatePicker",
|
32418 | value: function _updatePicker() {
|
32419 | var rgba = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.color;
|
32420 | var hsv = availableUtils.RGBToHSV(rgba.r, rgba.g, rgba.b);
|
32421 | var ctx = this.colorPickerCanvas.getContext('2d');
|
32422 |
|
32423 | if (this.pixelRation === undefined) {
|
32424 | this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
|
32425 | }
|
32426 |
|
32427 | ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
|
32428 |
|
32429 | var w = this.colorPickerCanvas.clientWidth;
|
32430 | var h = this.colorPickerCanvas.clientHeight;
|
32431 | ctx.clearRect(0, 0, w, h);
|
32432 | ctx.putImageData(this.hueCircle, 0, 0);
|
32433 | ctx.fillStyle = 'rgba(0,0,0,' + (1 - hsv.v) + ')';
|
32434 | ctx.circle(this.centerCoordinates.x, this.centerCoordinates.y, this.r);
|
32435 |
|
32436 | _fillInstanceProperty(ctx).call(ctx);
|
32437 |
|
32438 | this.brightnessRange.value = 100 * hsv.v;
|
32439 | this.opacityRange.value = 100 * rgba.a;
|
32440 | this.initialColorDiv.style.backgroundColor = 'rgba(' + this.initialColor.r + ',' + this.initialColor.g + ',' + this.initialColor.b + ',' + this.initialColor.a + ')';
|
32441 | this.newColorDiv.style.backgroundColor = 'rgba(' + this.color.r + ',' + this.color.g + ',' + this.color.b + ',' + this.color.a + ')';
|
32442 | }
|
32443 | |
32444 |
|
32445 |
|
32446 |
|
32447 |
|
32448 | }, {
|
32449 | key: "_setSize",
|
32450 | value: function _setSize() {
|
32451 | this.colorPickerCanvas.style.width = '100%';
|
32452 | this.colorPickerCanvas.style.height = '100%';
|
32453 | this.colorPickerCanvas.width = 289 * this.pixelRatio;
|
32454 | this.colorPickerCanvas.height = 289 * this.pixelRatio;
|
32455 | }
|
32456 | |
32457 |
|
32458 |
|
32459 |
|
32460 |
|
32461 |
|
32462 | }, {
|
32463 | key: "_create",
|
32464 | value: function _create() {
|
32465 | var _context, _context2, _context3, _context4;
|
32466 |
|
32467 | this.frame = document.createElement('div');
|
32468 | this.frame.className = 'vis-color-picker';
|
32469 | this.colorPickerDiv = document.createElement('div');
|
32470 | this.colorPickerSelector = document.createElement('div');
|
32471 | this.colorPickerSelector.className = 'vis-selector';
|
32472 | this.colorPickerDiv.appendChild(this.colorPickerSelector);
|
32473 | this.colorPickerCanvas = document.createElement('canvas');
|
32474 | this.colorPickerDiv.appendChild(this.colorPickerCanvas);
|
32475 |
|
32476 | if (!this.colorPickerCanvas.getContext) {
|
32477 | var noCanvas = document.createElement('DIV');
|
32478 | noCanvas.style.color = 'red';
|
32479 | noCanvas.style.fontWeight = 'bold';
|
32480 | noCanvas.style.padding = '10px';
|
32481 | noCanvas.innerHTML = 'Error: your browser does not support HTML canvas';
|
32482 | this.colorPickerCanvas.appendChild(noCanvas);
|
32483 | } else {
|
32484 | var ctx = this.colorPickerCanvas.getContext("2d");
|
32485 | this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
|
32486 | this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
|
32487 | }
|
32488 |
|
32489 | this.colorPickerDiv.className = 'vis-color';
|
32490 | this.opacityDiv = document.createElement('div');
|
32491 | this.opacityDiv.className = 'vis-opacity';
|
32492 | this.brightnessDiv = document.createElement('div');
|
32493 | this.brightnessDiv.className = 'vis-brightness';
|
32494 | this.arrowDiv = document.createElement('div');
|
32495 | this.arrowDiv.className = 'vis-arrow';
|
32496 | this.opacityRange = document.createElement('input');
|
32497 |
|
32498 | try {
|
32499 | this.opacityRange.type = 'range';
|
32500 |
|
32501 | this.opacityRange.min = '0';
|
32502 | this.opacityRange.max = '100';
|
32503 | }
|
32504 | catch (err) {}
|
32505 |
|
32506 |
|
32507 | this.opacityRange.value = '100';
|
32508 | this.opacityRange.className = 'vis-range';
|
32509 | this.brightnessRange = document.createElement('input');
|
32510 |
|
32511 | try {
|
32512 | this.brightnessRange.type = 'range';
|
32513 |
|
32514 | this.brightnessRange.min = '0';
|
32515 | this.brightnessRange.max = '100';
|
32516 | }
|
32517 | catch (err) {}
|
32518 |
|
32519 |
|
32520 | this.brightnessRange.value = '100';
|
32521 | this.brightnessRange.className = 'vis-range';
|
32522 | this.opacityDiv.appendChild(this.opacityRange);
|
32523 | this.brightnessDiv.appendChild(this.brightnessRange);
|
32524 | var me = this;
|
32525 |
|
32526 | this.opacityRange.onchange = function () {
|
32527 | me._setOpacity(this.value);
|
32528 | };
|
32529 |
|
32530 | this.opacityRange.oninput = function () {
|
32531 | me._setOpacity(this.value);
|
32532 | };
|
32533 |
|
32534 | this.brightnessRange.onchange = function () {
|
32535 | me._setBrightness(this.value);
|
32536 | };
|
32537 |
|
32538 | this.brightnessRange.oninput = function () {
|
32539 | me._setBrightness(this.value);
|
32540 | };
|
32541 |
|
32542 | this.brightnessLabel = document.createElement("div");
|
32543 | this.brightnessLabel.className = "vis-label vis-brightness";
|
32544 | this.brightnessLabel.innerHTML = 'brightness:';
|
32545 | this.opacityLabel = document.createElement("div");
|
32546 | this.opacityLabel.className = "vis-label vis-opacity";
|
32547 | this.opacityLabel.innerHTML = 'opacity:';
|
32548 | this.newColorDiv = document.createElement("div");
|
32549 | this.newColorDiv.className = "vis-new-color";
|
32550 | this.newColorDiv.innerHTML = 'new';
|
32551 | this.initialColorDiv = document.createElement("div");
|
32552 | this.initialColorDiv.className = "vis-initial-color";
|
32553 | this.initialColorDiv.innerHTML = 'initial';
|
32554 | this.cancelButton = document.createElement("div");
|
32555 | this.cancelButton.className = "vis-button vis-cancel";
|
32556 | this.cancelButton.innerHTML = 'cancel';
|
32557 | this.cancelButton.onclick = _bindInstanceProperty(_context = this._hide).call(_context, this, false);
|
32558 | this.applyButton = document.createElement("div");
|
32559 | this.applyButton.className = "vis-button vis-apply";
|
32560 | this.applyButton.innerHTML = 'apply';
|
32561 | this.applyButton.onclick = _bindInstanceProperty(_context2 = this._apply).call(_context2, this);
|
32562 | this.saveButton = document.createElement("div");
|
32563 | this.saveButton.className = "vis-button vis-save";
|
32564 | this.saveButton.innerHTML = 'save';
|
32565 | this.saveButton.onclick = _bindInstanceProperty(_context3 = this._save).call(_context3, this);
|
32566 | this.loadButton = document.createElement("div");
|
32567 | this.loadButton.className = "vis-button vis-load";
|
32568 | this.loadButton.innerHTML = 'load last';
|
32569 | this.loadButton.onclick = _bindInstanceProperty(_context4 = this._loadLast).call(_context4, this);
|
32570 | this.frame.appendChild(this.colorPickerDiv);
|
32571 | this.frame.appendChild(this.arrowDiv);
|
32572 | this.frame.appendChild(this.brightnessLabel);
|
32573 | this.frame.appendChild(this.brightnessDiv);
|
32574 | this.frame.appendChild(this.opacityLabel);
|
32575 | this.frame.appendChild(this.opacityDiv);
|
32576 | this.frame.appendChild(this.newColorDiv);
|
32577 | this.frame.appendChild(this.initialColorDiv);
|
32578 | this.frame.appendChild(this.cancelButton);
|
32579 | this.frame.appendChild(this.applyButton);
|
32580 | this.frame.appendChild(this.saveButton);
|
32581 | this.frame.appendChild(this.loadButton);
|
32582 | }
|
32583 | |
32584 |
|
32585 |
|
32586 |
|
32587 |
|
32588 | }, {
|
32589 | key: "_bindHammer",
|
32590 | value: function _bindHammer() {
|
32591 | var _this2 = this;
|
32592 |
|
32593 | this.drag = {};
|
32594 | this.pinch = {};
|
32595 | this.hammer = new Hammer(this.colorPickerCanvas);
|
32596 | this.hammer.get('pinch').set({
|
32597 | enable: true
|
32598 | });
|
32599 | onTouch(this.hammer, function (event) {
|
32600 | _this2._moveSelector(event);
|
32601 | });
|
32602 | this.hammer.on('tap', function (event) {
|
32603 | _this2._moveSelector(event);
|
32604 | });
|
32605 | this.hammer.on('panstart', function (event) {
|
32606 | _this2._moveSelector(event);
|
32607 | });
|
32608 | this.hammer.on('panmove', function (event) {
|
32609 | _this2._moveSelector(event);
|
32610 | });
|
32611 | this.hammer.on('panend', function (event) {
|
32612 | _this2._moveSelector(event);
|
32613 | });
|
32614 | }
|
32615 | |
32616 |
|
32617 |
|
32618 |
|
32619 |
|
32620 | }, {
|
32621 | key: "_generateHueCircle",
|
32622 | value: function _generateHueCircle() {
|
32623 | if (this.generated === false) {
|
32624 | var ctx = this.colorPickerCanvas.getContext('2d');
|
32625 |
|
32626 | if (this.pixelRation === undefined) {
|
32627 | this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
|
32628 | }
|
32629 |
|
32630 | ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
|
32631 |
|
32632 | var w = this.colorPickerCanvas.clientWidth;
|
32633 | var h = this.colorPickerCanvas.clientHeight;
|
32634 | ctx.clearRect(0, 0, w, h);
|
32635 |
|
32636 | var x, y, hue, sat;
|
32637 | this.centerCoordinates = {
|
32638 | x: w * 0.5,
|
32639 | y: h * 0.5
|
32640 | };
|
32641 | this.r = 0.49 * w;
|
32642 | var angleConvert = 2 * Math.PI / 360;
|
32643 | var hfac = 1 / 360;
|
32644 | var sfac = 1 / this.r;
|
32645 | var rgb;
|
32646 |
|
32647 | for (hue = 0; hue < 360; hue++) {
|
32648 | for (sat = 0; sat < this.r; sat++) {
|
32649 | x = this.centerCoordinates.x + sat * Math.sin(angleConvert * hue);
|
32650 | y = this.centerCoordinates.y + sat * Math.cos(angleConvert * hue);
|
32651 | rgb = availableUtils.HSVToRGB(hue * hfac, sat * sfac, 1);
|
32652 | ctx.fillStyle = 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
32653 | ctx.fillRect(x - 0.5, y - 0.5, 2, 2);
|
32654 | }
|
32655 | }
|
32656 |
|
32657 | ctx.strokeStyle = 'rgba(0,0,0,1)';
|
32658 | ctx.circle(this.centerCoordinates.x, this.centerCoordinates.y, this.r);
|
32659 | ctx.stroke();
|
32660 | this.hueCircle = ctx.getImageData(0, 0, w, h);
|
32661 | }
|
32662 |
|
32663 | this.generated = true;
|
32664 | }
|
32665 | |
32666 |
|
32667 |
|
32668 |
|
32669 |
|
32670 |
|
32671 |
|
32672 | }, {
|
32673 | key: "_moveSelector",
|
32674 | value: function _moveSelector(event) {
|
32675 | var rect = this.colorPickerDiv.getBoundingClientRect();
|
32676 | var left = event.center.x - rect.left;
|
32677 | var top = event.center.y - rect.top;
|
32678 | var centerY = 0.5 * this.colorPickerDiv.clientHeight;
|
32679 | var centerX = 0.5 * this.colorPickerDiv.clientWidth;
|
32680 | var x = left - centerX;
|
32681 | var y = top - centerY;
|
32682 | var angle = Math.atan2(x, y);
|
32683 | var radius = 0.98 * Math.min(Math.sqrt(x * x + y * y), centerX);
|
32684 | var newTop = Math.cos(angle) * radius + centerY;
|
32685 | var newLeft = Math.sin(angle) * radius + centerX;
|
32686 | this.colorPickerSelector.style.top = newTop - 0.5 * this.colorPickerSelector.clientHeight + 'px';
|
32687 | this.colorPickerSelector.style.left = newLeft - 0.5 * this.colorPickerSelector.clientWidth + 'px';
|
32688 |
|
32689 | var h = angle / (2 * Math.PI);
|
32690 | h = h < 0 ? h + 1 : h;
|
32691 | var s = radius / this.r;
|
32692 | var hsv = availableUtils.RGBToHSV(this.color.r, this.color.g, this.color.b);
|
32693 | hsv.h = h;
|
32694 | hsv.s = s;
|
32695 | var rgba = availableUtils.HSVToRGB(hsv.h, hsv.s, hsv.v);
|
32696 | rgba['a'] = this.color.a;
|
32697 | this.color = rgba;
|
32698 |
|
32699 | this.initialColorDiv.style.backgroundColor = 'rgba(' + this.initialColor.r + ',' + this.initialColor.g + ',' + this.initialColor.b + ',' + this.initialColor.a + ')';
|
32700 | this.newColorDiv.style.backgroundColor = 'rgba(' + this.color.r + ',' + this.color.g + ',' + this.color.b + ',' + this.color.a + ')';
|
32701 | }
|
32702 | }]);
|
32703 |
|
32704 | return ColorPicker;
|
32705 | }();
|
32706 |
|
32707 |
|
32708 |
|
32709 |
|
32710 |
|
32711 |
|
32712 |
|
32713 |
|
32714 |
|
32715 |
|
32716 |
|
32717 | var Configurator = function () {
|
32718 | |
32719 |
|
32720 |
|
32721 |
|
32722 |
|
32723 |
|
32724 | function Configurator(parentModule, defaultContainer, configureOptions) {
|
32725 | var pixelRatio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
32726 |
|
32727 | _classCallCheck(this, Configurator);
|
32728 |
|
32729 | this.parent = parentModule;
|
32730 | this.changedOptions = [];
|
32731 | this.container = defaultContainer;
|
32732 | this.allowCreation = false;
|
32733 | this.options = {};
|
32734 | this.initialized = false;
|
32735 | this.popupCounter = 0;
|
32736 | this.defaultOptions = {
|
32737 | enabled: false,
|
32738 | filter: true,
|
32739 | container: undefined,
|
32740 | showButton: true
|
32741 | };
|
32742 | availableUtils.extend(this.options, this.defaultOptions);
|
32743 | this.configureOptions = configureOptions;
|
32744 | this.moduleOptions = {};
|
32745 | this.domElements = [];
|
32746 | this.popupDiv = {};
|
32747 | this.popupLimit = 5;
|
32748 | this.popupHistory = {};
|
32749 | this.colorPicker = new ColorPicker(pixelRatio);
|
32750 | this.wrapper = undefined;
|
32751 | }
|
32752 | |
32753 |
|
32754 |
|
32755 |
|
32756 |
|
32757 |
|
32758 |
|
32759 |
|
32760 | _createClass(Configurator, [{
|
32761 | key: "setOptions",
|
32762 | value: function setOptions(options) {
|
32763 | if (options !== undefined) {
|
32764 |
|
32765 | this.popupHistory = {};
|
32766 |
|
32767 | this._removePopup();
|
32768 |
|
32769 | var enabled = true;
|
32770 |
|
32771 | if (typeof options === 'string') {
|
32772 | this.options.filter = options;
|
32773 | } else if (_Array$isArray$1(options)) {
|
32774 | this.options.filter = options.join();
|
32775 | } else if (_typeof(options) === 'object') {
|
32776 | if (options == null) {
|
32777 | throw new TypeError('options cannot be null');
|
32778 | }
|
32779 |
|
32780 | if (options.container !== undefined) {
|
32781 | this.options.container = options.container;
|
32782 | }
|
32783 |
|
32784 | if (_filterInstanceProperty(options) !== undefined) {
|
32785 | this.options.filter = _filterInstanceProperty(options);
|
32786 | }
|
32787 |
|
32788 | if (options.showButton !== undefined) {
|
32789 | this.options.showButton = options.showButton;
|
32790 | }
|
32791 |
|
32792 | if (options.enabled !== undefined) {
|
32793 | enabled = options.enabled;
|
32794 | }
|
32795 | } else if (typeof options === 'boolean') {
|
32796 | this.options.filter = true;
|
32797 | enabled = options;
|
32798 | } else if (typeof options === 'function') {
|
32799 | this.options.filter = options;
|
32800 | enabled = true;
|
32801 | }
|
32802 |
|
32803 | if (_filterInstanceProperty(this.options) === false) {
|
32804 | enabled = false;
|
32805 | }
|
32806 |
|
32807 | this.options.enabled = enabled;
|
32808 | }
|
32809 |
|
32810 | this._clean();
|
32811 | }
|
32812 | |
32813 |
|
32814 |
|
32815 |
|
32816 |
|
32817 | }, {
|
32818 | key: "setModuleOptions",
|
32819 | value: function setModuleOptions(moduleOptions) {
|
32820 | this.moduleOptions = moduleOptions;
|
32821 |
|
32822 | if (this.options.enabled === true) {
|
32823 | this._clean();
|
32824 |
|
32825 | if (this.options.container !== undefined) {
|
32826 | this.container = this.options.container;
|
32827 | }
|
32828 |
|
32829 | this._create();
|
32830 | }
|
32831 | }
|
32832 | |
32833 |
|
32834 |
|
32835 |
|
32836 |
|
32837 | }, {
|
32838 | key: "_create",
|
32839 | value: function _create() {
|
32840 | this._clean();
|
32841 |
|
32842 | this.changedOptions = [];
|
32843 |
|
32844 | var filter = _filterInstanceProperty(this.options);
|
32845 |
|
32846 | var counter = 0;
|
32847 | var show = false;
|
32848 |
|
32849 | for (var option in this.configureOptions) {
|
32850 | if (this.configureOptions.hasOwnProperty(option)) {
|
32851 | this.allowCreation = false;
|
32852 | show = false;
|
32853 |
|
32854 | if (typeof filter === 'function') {
|
32855 | show = filter(option, []);
|
32856 | show = show || this._handleObject(this.configureOptions[option], [option], true);
|
32857 | } else if (filter === true || _indexOfInstanceProperty(filter).call(filter, option) !== -1) {
|
32858 | show = true;
|
32859 | }
|
32860 |
|
32861 | if (show !== false) {
|
32862 | this.allowCreation = true;
|
32863 |
|
32864 | if (counter > 0) {
|
32865 | this._makeItem([]);
|
32866 | }
|
32867 |
|
32868 |
|
32869 | this._makeHeader(option);
|
32870 |
|
32871 |
|
32872 | this._handleObject(this.configureOptions[option], [option]);
|
32873 | }
|
32874 |
|
32875 | counter++;
|
32876 | }
|
32877 | }
|
32878 |
|
32879 | this._makeButton();
|
32880 |
|
32881 | this._push();
|
32882 |
|
32883 | }
|
32884 | |
32885 |
|
32886 |
|
32887 |
|
32888 |
|
32889 | }, {
|
32890 | key: "_push",
|
32891 | value: function _push() {
|
32892 | this.wrapper = document.createElement('div');
|
32893 | this.wrapper.className = 'vis-configuration-wrapper';
|
32894 | this.container.appendChild(this.wrapper);
|
32895 |
|
32896 | for (var i = 0; i < this.domElements.length; i++) {
|
32897 | this.wrapper.appendChild(this.domElements[i]);
|
32898 | }
|
32899 |
|
32900 | this._showPopupIfNeeded();
|
32901 | }
|
32902 | |
32903 |
|
32904 |
|
32905 |
|
32906 |
|
32907 | }, {
|
32908 | key: "_clean",
|
32909 | value: function _clean() {
|
32910 | for (var i = 0; i < this.domElements.length; i++) {
|
32911 | this.wrapper.removeChild(this.domElements[i]);
|
32912 | }
|
32913 |
|
32914 | if (this.wrapper !== undefined) {
|
32915 | this.container.removeChild(this.wrapper);
|
32916 | this.wrapper = undefined;
|
32917 | }
|
32918 |
|
32919 | this.domElements = [];
|
32920 |
|
32921 | this._removePopup();
|
32922 | }
|
32923 | |
32924 |
|
32925 |
|
32926 |
|
32927 |
|
32928 |
|
32929 |
|
32930 | }, {
|
32931 | key: "_getValue",
|
32932 | value: function _getValue(path) {
|
32933 | var base = this.moduleOptions;
|
32934 |
|
32935 | for (var i = 0; i < path.length; i++) {
|
32936 | if (base[path[i]] !== undefined) {
|
32937 | base = base[path[i]];
|
32938 | } else {
|
32939 | base = undefined;
|
32940 | break;
|
32941 | }
|
32942 | }
|
32943 |
|
32944 | return base;
|
32945 | }
|
32946 | |
32947 |
|
32948 |
|
32949 |
|
32950 |
|
32951 |
|
32952 |
|
32953 |
|
32954 | }, {
|
32955 | key: "_makeItem",
|
32956 | value: function _makeItem(path) {
|
32957 | if (this.allowCreation === true) {
|
32958 | var item = document.createElement('div');
|
32959 | item.className = 'vis-configuration vis-config-item vis-config-s' + path.length;
|
32960 |
|
32961 | for (var _len = arguments.length, domElements = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
32962 | domElements[_key - 1] = arguments[_key];
|
32963 | }
|
32964 |
|
32965 | _forEachInstanceProperty(domElements).call(domElements, function (element) {
|
32966 | item.appendChild(element);
|
32967 | });
|
32968 |
|
32969 | this.domElements.push(item);
|
32970 | return this.domElements.length;
|
32971 | }
|
32972 |
|
32973 | return 0;
|
32974 | }
|
32975 | |
32976 |
|
32977 |
|
32978 |
|
32979 |
|
32980 |
|
32981 | }, {
|
32982 | key: "_makeHeader",
|
32983 | value: function _makeHeader(name) {
|
32984 | var div = document.createElement('div');
|
32985 | div.className = 'vis-configuration vis-config-header';
|
32986 | div.innerHTML = availableUtils.xss(name);
|
32987 |
|
32988 | this._makeItem([], div);
|
32989 | }
|
32990 | |
32991 |
|
32992 |
|
32993 |
|
32994 |
|
32995 |
|
32996 |
|
32997 |
|
32998 |
|
32999 | }, {
|
33000 | key: "_makeLabel",
|
33001 | value: function _makeLabel(name, path) {
|
33002 | var objectLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
33003 | var div = document.createElement('div');
|
33004 | div.className = 'vis-configuration vis-config-label vis-config-s' + path.length;
|
33005 |
|
33006 | if (objectLabel === true) {
|
33007 | div.innerHTML = availableUtils.xss('<i><b>' + name + ':</b></i>');
|
33008 | } else {
|
33009 | div.innerHTML = availableUtils.xss(name + ':');
|
33010 | }
|
33011 |
|
33012 | return div;
|
33013 | }
|
33014 | |
33015 |
|
33016 |
|
33017 |
|
33018 |
|
33019 |
|
33020 |
|
33021 |
|
33022 | }, {
|
33023 | key: "_makeDropdown",
|
33024 | value: function _makeDropdown(arr, value, path) {
|
33025 | var select = document.createElement('select');
|
33026 | select.className = 'vis-configuration vis-config-select';
|
33027 | var selectedValue = 0;
|
33028 |
|
33029 | if (value !== undefined) {
|
33030 | if (_indexOfInstanceProperty(arr).call(arr, value) !== -1) {
|
33031 | selectedValue = _indexOfInstanceProperty(arr).call(arr, value);
|
33032 | }
|
33033 | }
|
33034 |
|
33035 | for (var i = 0; i < arr.length; i++) {
|
33036 | var option = document.createElement('option');
|
33037 | option.value = arr[i];
|
33038 |
|
33039 | if (i === selectedValue) {
|
33040 | option.selected = 'selected';
|
33041 | }
|
33042 |
|
33043 | option.innerHTML = arr[i];
|
33044 | select.appendChild(option);
|
33045 | }
|
33046 |
|
33047 | var me = this;
|
33048 |
|
33049 | select.onchange = function () {
|
33050 | me._update(this.value, path);
|
33051 | };
|
33052 |
|
33053 | var label = this._makeLabel(path[path.length - 1], path);
|
33054 |
|
33055 | this._makeItem(path, label, select);
|
33056 | }
|
33057 | |
33058 |
|
33059 |
|
33060 |
|
33061 |
|
33062 |
|
33063 |
|
33064 |
|
33065 | }, {
|
33066 | key: "_makeRange",
|
33067 | value: function _makeRange(arr, value, path) {
|
33068 | var defaultValue = arr[0];
|
33069 | var min = arr[1];
|
33070 | var max = arr[2];
|
33071 | var step = arr[3];
|
33072 | var range = document.createElement('input');
|
33073 | range.className = 'vis-configuration vis-config-range';
|
33074 |
|
33075 | try {
|
33076 | range.type = 'range';
|
33077 |
|
33078 | range.min = min;
|
33079 | range.max = max;
|
33080 | }
|
33081 | catch (err) {}
|
33082 |
|
33083 |
|
33084 | range.step = step;
|
33085 |
|
33086 | var popupString = '';
|
33087 | var popupValue = 0;
|
33088 |
|
33089 | if (value !== undefined) {
|
33090 | var factor = 1.20;
|
33091 |
|
33092 | if (value < 0 && value * factor < min) {
|
33093 | range.min = Math.ceil(value * factor);
|
33094 | popupValue = range.min;
|
33095 | popupString = 'range increased';
|
33096 | } else if (value / factor < min) {
|
33097 | range.min = Math.ceil(value / factor);
|
33098 | popupValue = range.min;
|
33099 | popupString = 'range increased';
|
33100 | }
|
33101 |
|
33102 | if (value * factor > max && max !== 1) {
|
33103 | range.max = Math.ceil(value * factor);
|
33104 | popupValue = range.max;
|
33105 | popupString = 'range increased';
|
33106 | }
|
33107 |
|
33108 | range.value = value;
|
33109 | } else {
|
33110 | range.value = defaultValue;
|
33111 | }
|
33112 |
|
33113 | var input = document.createElement('input');
|
33114 | input.className = 'vis-configuration vis-config-rangeinput';
|
33115 | input.value = Number(range.value);
|
33116 | var me = this;
|
33117 |
|
33118 | range.onchange = function () {
|
33119 | input.value = this.value;
|
33120 |
|
33121 | me._update(Number(this.value), path);
|
33122 | };
|
33123 |
|
33124 | range.oninput = function () {
|
33125 | input.value = this.value;
|
33126 | };
|
33127 |
|
33128 | var label = this._makeLabel(path[path.length - 1], path);
|
33129 |
|
33130 | var itemIndex = this._makeItem(path, label, range, input);
|
33131 |
|
33132 |
|
33133 | if (popupString !== '' && this.popupHistory[itemIndex] !== popupValue) {
|
33134 | this.popupHistory[itemIndex] = popupValue;
|
33135 |
|
33136 | this._setupPopup(popupString, itemIndex);
|
33137 | }
|
33138 | }
|
33139 | |
33140 |
|
33141 |
|
33142 |
|
33143 |
|
33144 | }, {
|
33145 | key: "_makeButton",
|
33146 | value: function _makeButton() {
|
33147 | var _this = this;
|
33148 |
|
33149 | if (this.options.showButton === true) {
|
33150 | var generateButton = document.createElement('div');
|
33151 | generateButton.className = 'vis-configuration vis-config-button';
|
33152 | generateButton.innerHTML = 'generate options';
|
33153 |
|
33154 | generateButton.onclick = function () {
|
33155 | _this._printOptions();
|
33156 | };
|
33157 |
|
33158 | generateButton.onmouseover = function () {
|
33159 | generateButton.className = 'vis-configuration vis-config-button hover';
|
33160 | };
|
33161 |
|
33162 | generateButton.onmouseout = function () {
|
33163 | generateButton.className = 'vis-configuration vis-config-button';
|
33164 | };
|
33165 |
|
33166 | this.optionsContainer = document.createElement('div');
|
33167 | this.optionsContainer.className = 'vis-configuration vis-config-option-container';
|
33168 | this.domElements.push(this.optionsContainer);
|
33169 | this.domElements.push(generateButton);
|
33170 | }
|
33171 | }
|
33172 | |
33173 |
|
33174 |
|
33175 |
|
33176 |
|
33177 |
|
33178 |
|
33179 | }, {
|
33180 | key: "_setupPopup",
|
33181 | value: function _setupPopup(string, index) {
|
33182 | var _this2 = this;
|
33183 |
|
33184 | if (this.initialized === true && this.allowCreation === true && this.popupCounter < this.popupLimit) {
|
33185 | var div = document.createElement("div");
|
33186 | div.id = "vis-configuration-popup";
|
33187 | div.className = "vis-configuration-popup";
|
33188 | div.innerHTML = availableUtils.xss(string);
|
33189 |
|
33190 | div.onclick = function () {
|
33191 | _this2._removePopup();
|
33192 | };
|
33193 |
|
33194 | this.popupCounter += 1;
|
33195 | this.popupDiv = {
|
33196 | html: div,
|
33197 | index: index
|
33198 | };
|
33199 | }
|
33200 | }
|
33201 | |
33202 |
|
33203 |
|
33204 |
|
33205 |
|
33206 | }, {
|
33207 | key: "_removePopup",
|
33208 | value: function _removePopup() {
|
33209 | if (this.popupDiv.html !== undefined) {
|
33210 | this.popupDiv.html.parentNode.removeChild(this.popupDiv.html);
|
33211 | clearTimeout(this.popupDiv.hideTimeout);
|
33212 | clearTimeout(this.popupDiv.deleteTimeout);
|
33213 | this.popupDiv = {};
|
33214 | }
|
33215 | }
|
33216 | |
33217 |
|
33218 |
|
33219 |
|
33220 |
|
33221 | }, {
|
33222 | key: "_showPopupIfNeeded",
|
33223 | value: function _showPopupIfNeeded() {
|
33224 | var _this3 = this;
|
33225 |
|
33226 | if (this.popupDiv.html !== undefined) {
|
33227 | var correspondingElement = this.domElements[this.popupDiv.index];
|
33228 | var rect = correspondingElement.getBoundingClientRect();
|
33229 | this.popupDiv.html.style.left = rect.left + "px";
|
33230 | this.popupDiv.html.style.top = rect.top - 30 + "px";
|
33231 |
|
33232 | document.body.appendChild(this.popupDiv.html);
|
33233 | this.popupDiv.hideTimeout = _setTimeout(function () {
|
33234 | _this3.popupDiv.html.style.opacity = 0;
|
33235 | }, 1500);
|
33236 | this.popupDiv.deleteTimeout = _setTimeout(function () {
|
33237 | _this3._removePopup();
|
33238 | }, 1800);
|
33239 | }
|
33240 | }
|
33241 | |
33242 |
|
33243 |
|
33244 |
|
33245 |
|
33246 |
|
33247 |
|
33248 |
|
33249 | }, {
|
33250 | key: "_makeCheckbox",
|
33251 | value: function _makeCheckbox(defaultValue, value, path) {
|
33252 | var checkbox = document.createElement('input');
|
33253 | checkbox.type = 'checkbox';
|
33254 | checkbox.className = 'vis-configuration vis-config-checkbox';
|
33255 | checkbox.checked = defaultValue;
|
33256 |
|
33257 | if (value !== undefined) {
|
33258 | checkbox.checked = value;
|
33259 |
|
33260 | if (value !== defaultValue) {
|
33261 | if (_typeof(defaultValue) === 'object') {
|
33262 | if (value !== defaultValue.enabled) {
|
33263 | this.changedOptions.push({
|
33264 | path: path,
|
33265 | value: value
|
33266 | });
|
33267 | }
|
33268 | } else {
|
33269 | this.changedOptions.push({
|
33270 | path: path,
|
33271 | value: value
|
33272 | });
|
33273 | }
|
33274 | }
|
33275 | }
|
33276 |
|
33277 | var me = this;
|
33278 |
|
33279 | checkbox.onchange = function () {
|
33280 | me._update(this.checked, path);
|
33281 | };
|
33282 |
|
33283 | var label = this._makeLabel(path[path.length - 1], path);
|
33284 |
|
33285 | this._makeItem(path, label, checkbox);
|
33286 | }
|
33287 | |
33288 |
|
33289 |
|
33290 |
|
33291 |
|
33292 |
|
33293 |
|
33294 |
|
33295 | }, {
|
33296 | key: "_makeTextInput",
|
33297 | value: function _makeTextInput(defaultValue, value, path) {
|
33298 | var checkbox = document.createElement('input');
|
33299 | checkbox.type = 'text';
|
33300 | checkbox.className = 'vis-configuration vis-config-text';
|
33301 | checkbox.value = value;
|
33302 |
|
33303 | if (value !== defaultValue) {
|
33304 | this.changedOptions.push({
|
33305 | path: path,
|
33306 | value: value
|
33307 | });
|
33308 | }
|
33309 |
|
33310 | var me = this;
|
33311 |
|
33312 | checkbox.onchange = function () {
|
33313 | me._update(this.value, path);
|
33314 | };
|
33315 |
|
33316 | var label = this._makeLabel(path[path.length - 1], path);
|
33317 |
|
33318 | this._makeItem(path, label, checkbox);
|
33319 | }
|
33320 | |
33321 |
|
33322 |
|
33323 |
|
33324 |
|
33325 |
|
33326 |
|
33327 |
|
33328 | }, {
|
33329 | key: "_makeColorField",
|
33330 | value: function _makeColorField(arr, value, path) {
|
33331 | var _this4 = this;
|
33332 |
|
33333 | var defaultColor = arr[1];
|
33334 | var div = document.createElement('div');
|
33335 | value = value === undefined ? defaultColor : value;
|
33336 |
|
33337 | if (value !== 'none') {
|
33338 | div.className = 'vis-configuration vis-config-colorBlock';
|
33339 | div.style.backgroundColor = value;
|
33340 | } else {
|
33341 | div.className = 'vis-configuration vis-config-colorBlock none';
|
33342 | }
|
33343 |
|
33344 | value = value === undefined ? defaultColor : value;
|
33345 |
|
33346 | div.onclick = function () {
|
33347 | _this4._showColorPicker(value, div, path);
|
33348 | };
|
33349 |
|
33350 | var label = this._makeLabel(path[path.length - 1], path);
|
33351 |
|
33352 | this._makeItem(path, label, div);
|
33353 | }
|
33354 | |
33355 |
|
33356 |
|
33357 |
|
33358 |
|
33359 |
|
33360 |
|
33361 |
|
33362 | }, {
|
33363 | key: "_showColorPicker",
|
33364 | value: function _showColorPicker(value, div, path) {
|
33365 | var _this5 = this;
|
33366 |
|
33367 |
|
33368 | div.onclick = function () {};
|
33369 |
|
33370 | this.colorPicker.insertTo(div);
|
33371 | this.colorPicker.show();
|
33372 | this.colorPicker.setColor(value);
|
33373 | this.colorPicker.setUpdateCallback(function (color) {
|
33374 | var colorString = 'rgba(' + color.r + ',' + color.g + ',' + color.b + ',' + color.a + ')';
|
33375 | div.style.backgroundColor = colorString;
|
33376 |
|
33377 | _this5._update(colorString, path);
|
33378 | });
|
33379 |
|
33380 | this.colorPicker.setCloseCallback(function () {
|
33381 | div.onclick = function () {
|
33382 | _this5._showColorPicker(value, div, path);
|
33383 | };
|
33384 | });
|
33385 | }
|
33386 | |
33387 |
|
33388 |
|
33389 |
|
33390 |
|
33391 |
|
33392 |
|
33393 |
|
33394 |
|
33395 | }, {
|
33396 | key: "_handleObject",
|
33397 | value: function _handleObject(obj) {
|
33398 | var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
33399 | var checkOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
33400 | var show = false;
|
33401 |
|
33402 | var filter = _filterInstanceProperty(this.options);
|
33403 |
|
33404 | var visibleInSet = false;
|
33405 |
|
33406 | for (var subObj in obj) {
|
33407 | if (obj.hasOwnProperty(subObj)) {
|
33408 | show = true;
|
33409 | var item = obj[subObj];
|
33410 | var newPath = availableUtils.copyAndExtendArray(path, subObj);
|
33411 |
|
33412 | if (typeof filter === 'function') {
|
33413 | show = filter(subObj, path);
|
33414 |
|
33415 | if (show === false) {
|
33416 | if (!_Array$isArray$1(item) && typeof item !== 'string' && typeof item !== 'boolean' && item instanceof Object) {
|
33417 | this.allowCreation = false;
|
33418 | show = this._handleObject(item, newPath, true);
|
33419 | this.allowCreation = checkOnly === false;
|
33420 | }
|
33421 | }
|
33422 | }
|
33423 |
|
33424 | if (show !== false) {
|
33425 | visibleInSet = true;
|
33426 |
|
33427 | var value = this._getValue(newPath);
|
33428 |
|
33429 | if (_Array$isArray$1(item)) {
|
33430 | this._handleArray(item, value, newPath);
|
33431 | } else if (typeof item === 'string') {
|
33432 | this._makeTextInput(item, value, newPath);
|
33433 | } else if (typeof item === 'boolean') {
|
33434 | this._makeCheckbox(item, value, newPath);
|
33435 | } else if (item instanceof Object) {
|
33436 |
|
33437 | var draw = true;
|
33438 |
|
33439 | if (_indexOfInstanceProperty(path).call(path, 'physics') !== -1) {
|
33440 | if (this.moduleOptions.physics.solver !== subObj) {
|
33441 | draw = false;
|
33442 | }
|
33443 | }
|
33444 |
|
33445 | if (draw === true) {
|
33446 |
|
33447 | if (item.enabled !== undefined) {
|
33448 | var enabledPath = availableUtils.copyAndExtendArray(newPath, 'enabled');
|
33449 |
|
33450 | var enabledValue = this._getValue(enabledPath);
|
33451 |
|
33452 | if (enabledValue === true) {
|
33453 | var label = this._makeLabel(subObj, newPath, true);
|
33454 |
|
33455 | this._makeItem(newPath, label);
|
33456 |
|
33457 | visibleInSet = this._handleObject(item, newPath) || visibleInSet;
|
33458 | } else {
|
33459 | this._makeCheckbox(item, enabledValue, newPath);
|
33460 | }
|
33461 | } else {
|
33462 | var _label = this._makeLabel(subObj, newPath, true);
|
33463 |
|
33464 | this._makeItem(newPath, _label);
|
33465 |
|
33466 | visibleInSet = this._handleObject(item, newPath) || visibleInSet;
|
33467 | }
|
33468 | }
|
33469 | } else {
|
33470 | console.error('dont know how to handle', item, subObj, newPath);
|
33471 | }
|
33472 | }
|
33473 | }
|
33474 | }
|
33475 |
|
33476 | return visibleInSet;
|
33477 | }
|
33478 | |
33479 |
|
33480 |
|
33481 |
|
33482 |
|
33483 |
|
33484 |
|
33485 |
|
33486 | }, {
|
33487 | key: "_handleArray",
|
33488 | value: function _handleArray(arr, value, path) {
|
33489 | if (typeof arr[0] === 'string' && arr[0] === 'color') {
|
33490 | this._makeColorField(arr, value, path);
|
33491 |
|
33492 | if (arr[1] !== value) {
|
33493 | this.changedOptions.push({
|
33494 | path: path,
|
33495 | value: value
|
33496 | });
|
33497 | }
|
33498 | } else if (typeof arr[0] === 'string') {
|
33499 | this._makeDropdown(arr, value, path);
|
33500 |
|
33501 | if (arr[0] !== value) {
|
33502 | this.changedOptions.push({
|
33503 | path: path,
|
33504 | value: value
|
33505 | });
|
33506 | }
|
33507 | } else if (typeof arr[0] === 'number') {
|
33508 | this._makeRange(arr, value, path);
|
33509 |
|
33510 | if (arr[0] !== value) {
|
33511 | this.changedOptions.push({
|
33512 | path: path,
|
33513 | value: Number(value)
|
33514 | });
|
33515 | }
|
33516 | }
|
33517 | }
|
33518 | |
33519 |
|
33520 |
|
33521 |
|
33522 |
|
33523 |
|
33524 |
|
33525 | }, {
|
33526 | key: "_update",
|
33527 | value: function _update(value, path) {
|
33528 | var options = this._constructOptions(value, path);
|
33529 |
|
33530 | if (this.parent.body && this.parent.body.emitter && this.parent.body.emitter.emit) {
|
33531 | this.parent.body.emitter.emit("configChange", options);
|
33532 | }
|
33533 |
|
33534 | this.initialized = true;
|
33535 | this.parent.setOptions(options);
|
33536 | }
|
33537 | |
33538 |
|
33539 |
|
33540 |
|
33541 |
|
33542 |
|
33543 |
|
33544 |
|
33545 |
|
33546 | }, {
|
33547 | key: "_constructOptions",
|
33548 | value: function _constructOptions(value, path) {
|
33549 | var optionsObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
33550 | var pointer = optionsObj;
|
33551 |
|
33552 | value = value === 'true' ? true : value;
|
33553 | value = value === 'false' ? false : value;
|
33554 |
|
33555 | for (var i = 0; i < path.length; i++) {
|
33556 | if (path[i] !== 'global') {
|
33557 | if (pointer[path[i]] === undefined) {
|
33558 | pointer[path[i]] = {};
|
33559 | }
|
33560 |
|
33561 | if (i !== path.length - 1) {
|
33562 | pointer = pointer[path[i]];
|
33563 | } else {
|
33564 | pointer[path[i]] = value;
|
33565 | }
|
33566 | }
|
33567 | }
|
33568 |
|
33569 | return optionsObj;
|
33570 | }
|
33571 | |
33572 |
|
33573 |
|
33574 |
|
33575 | }, {
|
33576 | key: "_printOptions",
|
33577 | value: function _printOptions() {
|
33578 | var options = this.getOptions();
|
33579 | this.optionsContainer.innerHTML = '<pre>var options = ' + _JSON$stringify(options, null, 2) + '</pre>';
|
33580 | }
|
33581 | |
33582 |
|
33583 |
|
33584 |
|
33585 |
|
33586 | }, {
|
33587 | key: "getOptions",
|
33588 | value: function getOptions() {
|
33589 | var options = {};
|
33590 |
|
33591 | for (var i = 0; i < this.changedOptions.length; i++) {
|
33592 | this._constructOptions(this.changedOptions[i].value, this.changedOptions[i].path, options);
|
33593 | }
|
33594 |
|
33595 | return options;
|
33596 | }
|
33597 | }]);
|
33598 |
|
33599 | return Configurator;
|
33600 | }();
|
33601 |
|
33602 | function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
33603 |
|
33604 | function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
33605 |
|
33606 |
|
33607 |
|
33608 |
|
33609 |
|
33610 | var Timeline = function (_Core) {
|
33611 | _inherits(Timeline, _Core);
|
33612 |
|
33613 | var _super = _createSuper$1(Timeline);
|
33614 |
|
33615 | |
33616 |
|
33617 |
|
33618 |
|
33619 |
|
33620 |
|
33621 |
|
33622 | function Timeline(container, items, groups, options) {
|
33623 | var _context2, _context3, _context4, _context5, _context6, _context7, _context8;
|
33624 |
|
33625 | var _this;
|
33626 |
|
33627 | _classCallCheck(this, Timeline);
|
33628 |
|
33629 | _this = _super.call(this);
|
33630 | _this.initTime = new Date();
|
33631 | _this.itemsDone = false;
|
33632 |
|
33633 | if (!(_assertThisInitialized$1(_this) instanceof Timeline)) {
|
33634 | throw new SyntaxError('Constructor must be called with the new operator');
|
33635 | }
|
33636 |
|
33637 |
|
33638 | if (!(_Array$isArray$1(groups) || isDataViewLike(groups)) && groups instanceof Object) {
|
33639 | var forthArgument = options;
|
33640 | options = groups;
|
33641 | groups = forthArgument;
|
33642 | }
|
33643 |
|
33644 |
|
33645 |
|
33646 | if (options && options.throttleRedraw) {
|
33647 | console.warn("Timeline option \"throttleRedraw\" is DEPRICATED and no longer supported. It will be removed in the next MAJOR release.");
|
33648 | }
|
33649 |
|
33650 | var me = _assertThisInitialized$1(_this);
|
33651 |
|
33652 | _this.defaultOptions = {
|
33653 | autoResize: true,
|
33654 | longSelectPressTime: 251,
|
33655 | orientation: {
|
33656 | axis: 'bottom',
|
33657 |
|
33658 | item: 'bottom'
|
33659 |
|
33660 | },
|
33661 | moment: moment$2
|
33662 | };
|
33663 | _this.options = availableUtils.deepExtend({}, _this.defaultOptions);
|
33664 | options && availableUtils.setupXSSProtection(options.xss);
|
33665 |
|
33666 | _this._create(container);
|
33667 |
|
33668 | if (!options || options && typeof options.rtl == "undefined") {
|
33669 | _this.dom.root.style.visibility = 'hidden';
|
33670 | var directionFromDom;
|
33671 | var domNode = _this.dom.root;
|
33672 |
|
33673 | while (!directionFromDom && domNode) {
|
33674 | directionFromDom = window.getComputedStyle(domNode, null).direction;
|
33675 | domNode = domNode.parentElement;
|
33676 | }
|
33677 |
|
33678 | _this.options.rtl = directionFromDom && directionFromDom.toLowerCase() == "rtl";
|
33679 | } else {
|
33680 | _this.options.rtl = options.rtl;
|
33681 | }
|
33682 |
|
33683 | if (options) {
|
33684 | if (options.rollingMode) {
|
33685 | _this.options.rollingMode = options.rollingMode;
|
33686 | }
|
33687 |
|
33688 | if (options.onInitialDrawComplete) {
|
33689 | _this.options.onInitialDrawComplete = options.onInitialDrawComplete;
|
33690 | }
|
33691 |
|
33692 | if (options.onTimeout) {
|
33693 | _this.options.onTimeout = options.onTimeout;
|
33694 | }
|
33695 |
|
33696 | if (options.loadingScreenTemplate) {
|
33697 | _this.options.loadingScreenTemplate = options.loadingScreenTemplate;
|
33698 | }
|
33699 | }
|
33700 |
|
33701 |
|
33702 | var loadingScreenFragment = document.createElement('div');
|
33703 |
|
33704 | if (_this.options.loadingScreenTemplate) {
|
33705 | var _context;
|
33706 |
|
33707 | var templateFunction = _bindInstanceProperty(_context = _this.options.loadingScreenTemplate).call(_context, _assertThisInitialized$1(_this));
|
33708 |
|
33709 | var loadingScreen = templateFunction(_this.dom.loadingScreen);
|
33710 |
|
33711 | if (loadingScreen instanceof Object && !(loadingScreen instanceof Element)) {
|
33712 | templateFunction(loadingScreenFragment);
|
33713 | } else {
|
33714 | if (loadingScreen instanceof Element) {
|
33715 | loadingScreenFragment.innerHTML = '';
|
33716 | loadingScreenFragment.appendChild(loadingScreen);
|
33717 | } else if (loadingScreen != undefined) {
|
33718 | loadingScreenFragment.innerHTML = availableUtils.xss(loadingScreen);
|
33719 | }
|
33720 | }
|
33721 | }
|
33722 |
|
33723 | _this.dom.loadingScreen.appendChild(loadingScreenFragment);
|
33724 |
|
33725 |
|
33726 | _this.components = [];
|
33727 | _this.body = {
|
33728 | dom: _this.dom,
|
33729 | domProps: _this.props,
|
33730 | emitter: {
|
33731 | on: _bindInstanceProperty(_context2 = _this.on).call(_context2, _assertThisInitialized$1(_this)),
|
33732 | off: _bindInstanceProperty(_context3 = _this.off).call(_context3, _assertThisInitialized$1(_this)),
|
33733 | emit: _bindInstanceProperty(_context4 = _this.emit).call(_context4, _assertThisInitialized$1(_this))
|
33734 | },
|
33735 | hiddenDates: [],
|
33736 | util: {
|
33737 | getScale: function getScale() {
|
33738 | return me.timeAxis.step.scale;
|
33739 | },
|
33740 | getStep: function getStep() {
|
33741 | return me.timeAxis.step.step;
|
33742 | },
|
33743 | toScreen: _bindInstanceProperty(_context5 = me._toScreen).call(_context5, me),
|
33744 | toGlobalScreen: _bindInstanceProperty(_context6 = me._toGlobalScreen).call(_context6, me),
|
33745 |
|
33746 | toTime: _bindInstanceProperty(_context7 = me._toTime).call(_context7, me),
|
33747 | toGlobalTime: _bindInstanceProperty(_context8 = me._toGlobalTime).call(_context8, me)
|
33748 | }
|
33749 | };
|
33750 |
|
33751 | _this.range = new Range(_this.body, _this.options);
|
33752 |
|
33753 | _this.components.push(_this.range);
|
33754 |
|
33755 | _this.body.range = _this.range;
|
33756 |
|
33757 | _this.timeAxis = new TimeAxis(_this.body, _this.options);
|
33758 | _this.timeAxis2 = null;
|
33759 |
|
33760 | _this.components.push(_this.timeAxis);
|
33761 |
|
33762 |
|
33763 | _this.currentTime = new CurrentTime(_this.body, _this.options);
|
33764 |
|
33765 | _this.components.push(_this.currentTime);
|
33766 |
|
33767 |
|
33768 | _this.itemSet = new ItemSet(_this.body, _this.options);
|
33769 |
|
33770 | _this.components.push(_this.itemSet);
|
33771 |
|
33772 | _this.itemsData = null;
|
33773 |
|
33774 | _this.groupsData = null;
|
33775 |
|
33776 | function emit(eventName, event) {
|
33777 | if (!me.hasListeners(eventName)) {
|
33778 | return;
|
33779 | }
|
33780 |
|
33781 | me.emit(eventName, me.getEventProperties(event));
|
33782 | }
|
33783 |
|
33784 | _this.dom.root.onclick = function (event) {
|
33785 | emit('click', event);
|
33786 | };
|
33787 |
|
33788 | _this.dom.root.ondblclick = function (event) {
|
33789 | emit('doubleClick', event);
|
33790 | };
|
33791 |
|
33792 | _this.dom.root.oncontextmenu = function (event) {
|
33793 | emit('contextmenu', event);
|
33794 | };
|
33795 |
|
33796 | _this.dom.root.onmouseover = function (event) {
|
33797 | emit('mouseOver', event);
|
33798 | };
|
33799 |
|
33800 | if (window.PointerEvent) {
|
33801 | _this.dom.root.onpointerdown = function (event) {
|
33802 | emit('mouseDown', event);
|
33803 | };
|
33804 |
|
33805 | _this.dom.root.onpointermove = function (event) {
|
33806 | emit('mouseMove', event);
|
33807 | };
|
33808 |
|
33809 | _this.dom.root.onpointerup = function (event) {
|
33810 | emit('mouseUp', event);
|
33811 | };
|
33812 | } else {
|
33813 | _this.dom.root.onmousemove = function (event) {
|
33814 | emit('mouseMove', event);
|
33815 | };
|
33816 |
|
33817 | _this.dom.root.onmousedown = function (event) {
|
33818 | emit('mouseDown', event);
|
33819 | };
|
33820 |
|
33821 | _this.dom.root.onmouseup = function (event) {
|
33822 | emit('mouseUp', event);
|
33823 | };
|
33824 | }
|
33825 |
|
33826 |
|
33827 | _this.initialFitDone = false;
|
33828 |
|
33829 | _this.on('changed', function () {
|
33830 | if (me.itemsData == null) return;
|
33831 |
|
33832 | if (!me.initialFitDone && !me.options.rollingMode) {
|
33833 | me.initialFitDone = true;
|
33834 |
|
33835 | if (me.options.start != undefined || me.options.end != undefined) {
|
33836 | if (me.options.start == undefined || me.options.end == undefined) {
|
33837 | var range = me.getItemRange();
|
33838 | }
|
33839 |
|
33840 | var start = me.options.start != undefined ? me.options.start : range.min;
|
33841 | var end = me.options.end != undefined ? me.options.end : range.max;
|
33842 | me.setWindow(start, end, {
|
33843 | animation: false
|
33844 | });
|
33845 | } else {
|
33846 | me.fit({
|
33847 | animation: false
|
33848 | });
|
33849 | }
|
33850 | }
|
33851 |
|
33852 | if (!me.initialDrawDone && (me.initialRangeChangeDone || !me.options.start && !me.options.end || me.options.rollingMode)) {
|
33853 | me.initialDrawDone = true;
|
33854 | me.itemSet.initialDrawDone = true;
|
33855 | me.dom.root.style.visibility = 'visible';
|
33856 | me.dom.loadingScreen.parentNode.removeChild(me.dom.loadingScreen);
|
33857 |
|
33858 | if (me.options.onInitialDrawComplete) {
|
33859 | _setTimeout(function () {
|
33860 | return me.options.onInitialDrawComplete();
|
33861 | }, 0);
|
33862 | }
|
33863 | }
|
33864 | });
|
33865 |
|
33866 | _this.on('destroyTimeline', function () {
|
33867 | me.destroy();
|
33868 | });
|
33869 |
|
33870 |
|
33871 | if (options) {
|
33872 | _this.setOptions(options);
|
33873 | }
|
33874 |
|
33875 | _this.body.emitter.on('fit', function (args) {
|
33876 | _this._onFit(args);
|
33877 |
|
33878 | _this.redraw();
|
33879 | });
|
33880 |
|
33881 |
|
33882 | if (groups) {
|
33883 | _this.setGroups(groups);
|
33884 | }
|
33885 |
|
33886 |
|
33887 | if (items) {
|
33888 | _this.setItems(items);
|
33889 | }
|
33890 |
|
33891 |
|
33892 | _this._redraw();
|
33893 |
|
33894 | return _this;
|
33895 | }
|
33896 | |
33897 |
|
33898 |
|
33899 |
|
33900 |
|
33901 |
|
33902 |
|
33903 | _createClass(Timeline, [{
|
33904 | key: "_createConfigurator",
|
33905 | value: function _createConfigurator() {
|
33906 | return new Configurator(this, this.dom.container, configureOptions$1);
|
33907 | }
|
33908 | |
33909 |
|
33910 |
|
33911 |
|
33912 |
|
33913 |
|
33914 |
|
33915 |
|
33916 | }, {
|
33917 | key: "redraw",
|
33918 | value: function redraw() {
|
33919 | this.itemSet && this.itemSet.markDirty({
|
33920 | refreshItems: true
|
33921 | });
|
33922 |
|
33923 | this._redraw();
|
33924 | }
|
33925 | |
33926 |
|
33927 |
|
33928 |
|
33929 |
|
33930 | }, {
|
33931 | key: "setOptions",
|
33932 | value: function setOptions(options) {
|
33933 |
|
33934 | var errorFound = Validator.validate(options, allOptions$1);
|
33935 |
|
33936 | if (errorFound === true) {
|
33937 | console.log('%cErrors have been found in the supplied options object.', printStyle);
|
33938 | }
|
33939 |
|
33940 | Core.prototype.setOptions.call(this, options);
|
33941 |
|
33942 | if ('type' in options) {
|
33943 | if (options.type !== this.options.type) {
|
33944 | this.options.type = options.type;
|
33945 |
|
33946 | var itemsData = this.itemsData;
|
33947 |
|
33948 | if (itemsData) {
|
33949 | var selection = this.getSelection();
|
33950 | this.setItems(null);
|
33951 |
|
33952 | this.setItems(itemsData.rawDS);
|
33953 |
|
33954 | this.setSelection(selection);
|
33955 | }
|
33956 | }
|
33957 | }
|
33958 | }
|
33959 | |
33960 |
|
33961 |
|
33962 |
|
33963 |
|
33964 | }, {
|
33965 | key: "setItems",
|
33966 | value: function setItems(items) {
|
33967 | this.itemsDone = false;
|
33968 |
|
33969 | var newDataSet;
|
33970 |
|
33971 | if (!items) {
|
33972 | newDataSet = null;
|
33973 | } else if (isDataViewLike(items)) {
|
33974 | newDataSet = typeCoerceDataSet(items);
|
33975 | } else {
|
33976 |
|
33977 | newDataSet = typeCoerceDataSet(new DataSet(items));
|
33978 | }
|
33979 |
|
33980 |
|
33981 | if (this.itemsData) {
|
33982 |
|
33983 | this.itemsData.dispose();
|
33984 | }
|
33985 |
|
33986 | this.itemsData = newDataSet;
|
33987 | this.itemSet && this.itemSet.setItems(newDataSet != null ? newDataSet.rawDS : null);
|
33988 | }
|
33989 | |
33990 |
|
33991 |
|
33992 |
|
33993 |
|
33994 | }, {
|
33995 | key: "setGroups",
|
33996 | value: function setGroups(groups) {
|
33997 |
|
33998 | var newDataSet;
|
33999 |
|
34000 | var filter = function filter(group) {
|
34001 | return group.visible !== false;
|
34002 | };
|
34003 |
|
34004 | if (!groups) {
|
34005 | newDataSet = null;
|
34006 | } else {
|
34007 |
|
34008 | if (_Array$isArray$1(groups)) groups = new DataSet(groups);
|
34009 | newDataSet = new DataView(groups, {
|
34010 | filter: filter
|
34011 | });
|
34012 | }
|
34013 |
|
34014 |
|
34015 |
|
34016 |
|
34017 |
|
34018 |
|
34019 |
|
34020 |
|
34021 |
|
34022 |
|
34023 |
|
34024 |
|
34025 | if (this.groupsData != null && typeof this.groupsData.setData === "function") {
|
34026 | this.groupsData.setData(null);
|
34027 | }
|
34028 |
|
34029 | this.groupsData = newDataSet;
|
34030 | this.itemSet.setGroups(newDataSet);
|
34031 | }
|
34032 | |
34033 |
|
34034 |
|
34035 |
|
34036 |
|
34037 | }, {
|
34038 | key: "setData",
|
34039 | value: function setData(data) {
|
34040 | if (data && data.groups) {
|
34041 | this.setGroups(data.groups);
|
34042 | }
|
34043 |
|
34044 | if (data && data.items) {
|
34045 | this.setItems(data.items);
|
34046 | }
|
34047 | }
|
34048 | |
34049 |
|
34050 |
|
34051 |
|
34052 |
|
34053 |
|
34054 |
|
34055 |
|
34056 |
|
34057 |
|
34058 |
|
34059 |
|
34060 |
|
34061 |
|
34062 |
|
34063 |
|
34064 |
|
34065 |
|
34066 | }, {
|
34067 | key: "setSelection",
|
34068 | value: function setSelection(ids, options) {
|
34069 | this.itemSet && this.itemSet.setSelection(ids);
|
34070 |
|
34071 | if (options && options.focus) {
|
34072 | this.focus(ids, options);
|
34073 | }
|
34074 | }
|
34075 | |
34076 |
|
34077 |
|
34078 |
|
34079 |
|
34080 | }, {
|
34081 | key: "getSelection",
|
34082 | value: function getSelection() {
|
34083 | return this.itemSet && this.itemSet.getSelection() || [];
|
34084 | }
|
34085 | |
34086 |
|
34087 |
|
34088 |
|
34089 |
|
34090 |
|
34091 |
|
34092 |
|
34093 |
|
34094 |
|
34095 |
|
34096 |
|
34097 |
|
34098 |
|
34099 |
|
34100 |
|
34101 | }, {
|
34102 | key: "focus",
|
34103 | value: function focus(id, options) {
|
34104 | if (!this.itemsData || id == undefined) return;
|
34105 | var ids = _Array$isArray$1(id) ? id : [id];
|
34106 |
|
34107 | var itemsData = this.itemsData.get(ids);
|
34108 |
|
34109 | var start = null;
|
34110 | var end = null;
|
34111 |
|
34112 | _forEachInstanceProperty(itemsData).call(itemsData, function (itemData) {
|
34113 | var s = itemData.start.valueOf();
|
34114 | var e = 'end' in itemData ? itemData.end.valueOf() : itemData.start.valueOf();
|
34115 |
|
34116 | if (start === null || s < start) {
|
34117 | start = s;
|
34118 | }
|
34119 |
|
34120 | if (end === null || e > end) {
|
34121 | end = e;
|
34122 | }
|
34123 | });
|
34124 |
|
34125 | if (start !== null && end !== null) {
|
34126 | var me = this;
|
34127 |
|
34128 | var item = this.itemSet.items[ids[0]];
|
34129 | var startPos = this._getScrollTop() * -1;
|
34130 | var initialVerticalScroll = null;
|
34131 |
|
34132 | var verticalAnimationFrame = function verticalAnimationFrame(ease, willDraw, done) {
|
34133 | var verticalScroll = getItemVerticalScroll(me, item);
|
34134 |
|
34135 | if (verticalScroll === false) {
|
34136 | return;
|
34137 | }
|
34138 |
|
34139 | if (!initialVerticalScroll) {
|
34140 | initialVerticalScroll = verticalScroll;
|
34141 | }
|
34142 |
|
34143 | if (initialVerticalScroll.itemTop == verticalScroll.itemTop && !initialVerticalScroll.shouldScroll) {
|
34144 | return;
|
34145 | } else if (initialVerticalScroll.itemTop != verticalScroll.itemTop && verticalScroll.shouldScroll) {
|
34146 |
|
34147 | initialVerticalScroll = verticalScroll;
|
34148 | startPos = me._getScrollTop() * -1;
|
34149 | }
|
34150 |
|
34151 | var from = startPos;
|
34152 | var to = initialVerticalScroll.scrollOffset;
|
34153 | var scrollTop = done ? to : from + (to - from) * ease;
|
34154 |
|
34155 | me._setScrollTop(-scrollTop);
|
34156 |
|
34157 | if (!willDraw) {
|
34158 | me._redraw();
|
34159 | }
|
34160 | };
|
34161 |
|
34162 |
|
34163 | var setFinalVerticalPosition = function setFinalVerticalPosition() {
|
34164 | var finalVerticalScroll = getItemVerticalScroll(me, item);
|
34165 |
|
34166 | if (finalVerticalScroll.shouldScroll && finalVerticalScroll.itemTop != initialVerticalScroll.itemTop) {
|
34167 | me._setScrollTop(-finalVerticalScroll.scrollOffset);
|
34168 |
|
34169 | me._redraw();
|
34170 | }
|
34171 | };
|
34172 |
|
34173 |
|
34174 |
|
34175 | var finalVerticalCallback = function finalVerticalCallback() {
|
34176 |
|
34177 | setFinalVerticalPosition();
|
34178 |
|
34179 | _setTimeout(setFinalVerticalPosition, 100);
|
34180 | };
|
34181 |
|
34182 |
|
34183 | var zoom = options && options.zoom !== undefined ? options.zoom : true;
|
34184 | var middle = (start + end) / 2;
|
34185 | var interval = zoom ? (end - start) * 1.1 : Math.max(this.range.end - this.range.start, (end - start) * 1.1);
|
34186 | var animation = options && options.animation !== undefined ? options.animation : true;
|
34187 |
|
34188 | if (!animation) {
|
34189 |
|
34190 | initialVerticalScroll = {
|
34191 | shouldScroll: false,
|
34192 | scrollOffset: -1,
|
34193 | itemTop: -1
|
34194 | };
|
34195 | }
|
34196 |
|
34197 | this.range.setRange(middle - interval / 2, middle + interval / 2, {
|
34198 | animation: animation
|
34199 | }, finalVerticalCallback, verticalAnimationFrame);
|
34200 | }
|
34201 | }
|
34202 | |
34203 |
|
34204 |
|
34205 |
|
34206 |
|
34207 |
|
34208 |
|
34209 |
|
34210 |
|
34211 |
|
34212 |
|
34213 |
|
34214 | }, {
|
34215 | key: "fit",
|
34216 | value: function fit(options, callback) {
|
34217 | var animation = options && options.animation !== undefined ? options.animation : true;
|
34218 | var range;
|
34219 |
|
34220 | if (this.itemsData.length === 1 && this.itemsData.get()[0].end === undefined) {
|
34221 |
|
34222 | range = this.getDataRange();
|
34223 | this.moveTo(range.min.valueOf(), {
|
34224 | animation: animation
|
34225 | }, callback);
|
34226 | } else {
|
34227 |
|
34228 | range = this.getItemRange();
|
34229 | this.range.setRange(range.min, range.max, {
|
34230 | animation: animation
|
34231 | }, callback);
|
34232 | }
|
34233 | }
|
34234 | |
34235 |
|
34236 |
|
34237 |
|
34238 |
|
34239 |
|
34240 |
|
34241 | }, {
|
34242 | key: "getItemRange",
|
34243 | value: function getItemRange() {
|
34244 | var _this2 = this;
|
34245 |
|
34246 |
|
34247 | var range = this.getDataRange();
|
34248 | var min = range.min !== null ? range.min.valueOf() : null;
|
34249 | var max = range.max !== null ? range.max.valueOf() : null;
|
34250 | var minItem = null;
|
34251 | var maxItem = null;
|
34252 |
|
34253 | if (min != null && max != null) {
|
34254 | var interval = max - min;
|
34255 |
|
34256 | if (interval <= 0) {
|
34257 | interval = 10;
|
34258 | }
|
34259 |
|
34260 | var factor = interval / this.props.center.width;
|
34261 | var redrawQueue = {};
|
34262 | var redrawQueueLength = 0;
|
34263 |
|
34264 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.itemSet.items, function (item, key) {
|
34265 | if (item.groupShowing) {
|
34266 | var returnQueue = true;
|
34267 | redrawQueue[key] = item.redraw(returnQueue);
|
34268 | redrawQueueLength = redrawQueue[key].length;
|
34269 | }
|
34270 | });
|
34271 |
|
34272 | var needRedraw = redrawQueueLength > 0;
|
34273 |
|
34274 | if (needRedraw) {
|
34275 | var _loop = function _loop(i) {
|
34276 | _forEachInstanceProperty(availableUtils).call(availableUtils, redrawQueue, function (fns) {
|
34277 | fns[i]();
|
34278 | });
|
34279 | };
|
34280 |
|
34281 |
|
34282 | for (var i = 0; i < redrawQueueLength; i++) {
|
34283 | _loop(i);
|
34284 | }
|
34285 | }
|
34286 |
|
34287 |
|
34288 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.itemSet.items, function (item) {
|
34289 | var start = getStart(item);
|
34290 | var end = getEnd(item);
|
34291 | var startSide;
|
34292 | var endSide;
|
34293 |
|
34294 | if (_this2.options.rtl) {
|
34295 | startSide = start - (item.getWidthRight() + 10) * factor;
|
34296 | endSide = end + (item.getWidthLeft() + 10) * factor;
|
34297 | } else {
|
34298 | startSide = start - (item.getWidthLeft() + 10) * factor;
|
34299 | endSide = end + (item.getWidthRight() + 10) * factor;
|
34300 | }
|
34301 |
|
34302 | if (startSide < min) {
|
34303 | min = startSide;
|
34304 | minItem = item;
|
34305 | }
|
34306 |
|
34307 | if (endSide > max) {
|
34308 | max = endSide;
|
34309 | maxItem = item;
|
34310 | }
|
34311 | });
|
34312 |
|
34313 | if (minItem && maxItem) {
|
34314 | var lhs = minItem.getWidthLeft() + 10;
|
34315 | var rhs = maxItem.getWidthRight() + 10;
|
34316 | var delta = this.props.center.width - lhs - rhs;
|
34317 |
|
34318 | if (delta > 0) {
|
34319 | if (this.options.rtl) {
|
34320 | min = getStart(minItem) - rhs * interval / delta;
|
34321 |
|
34322 | max = getEnd(maxItem) + lhs * interval / delta;
|
34323 | } else {
|
34324 | min = getStart(minItem) - lhs * interval / delta;
|
34325 |
|
34326 | max = getEnd(maxItem) + rhs * interval / delta;
|
34327 | }
|
34328 | }
|
34329 | }
|
34330 | }
|
34331 |
|
34332 | return {
|
34333 | min: min != null ? new Date(min) : null,
|
34334 | max: max != null ? new Date(max) : null
|
34335 | };
|
34336 | }
|
34337 | |
34338 |
|
34339 |
|
34340 |
|
34341 |
|
34342 | }, {
|
34343 | key: "getDataRange",
|
34344 | value: function getDataRange() {
|
34345 | var min = null;
|
34346 | var max = null;
|
34347 |
|
34348 | if (this.itemsData) {
|
34349 | var _context9;
|
34350 |
|
34351 | _forEachInstanceProperty(_context9 = this.itemsData).call(_context9, function (item) {
|
34352 | var start = availableUtils.convert(item.start, 'Date').valueOf();
|
34353 | var end = availableUtils.convert(item.end != undefined ? item.end : item.start, 'Date').valueOf();
|
34354 |
|
34355 | if (min === null || start < min) {
|
34356 | min = start;
|
34357 | }
|
34358 |
|
34359 | if (max === null || end > max) {
|
34360 | max = end;
|
34361 | }
|
34362 | });
|
34363 | }
|
34364 |
|
34365 | return {
|
34366 | min: min != null ? new Date(min) : null,
|
34367 | max: max != null ? new Date(max) : null
|
34368 | };
|
34369 | }
|
34370 | |
34371 |
|
34372 |
|
34373 |
|
34374 |
|
34375 |
|
34376 |
|
34377 | }, {
|
34378 | key: "getEventProperties",
|
34379 | value: function getEventProperties(event) {
|
34380 | var clientX = event.center ? event.center.x : event.clientX;
|
34381 | var clientY = event.center ? event.center.y : event.clientY;
|
34382 | var centerContainerRect = this.dom.centerContainer.getBoundingClientRect();
|
34383 | var x = this.options.rtl ? centerContainerRect.right - clientX : clientX - centerContainerRect.left;
|
34384 | var y = clientY - centerContainerRect.top;
|
34385 | var item = this.itemSet.itemFromTarget(event);
|
34386 | var group = this.itemSet.groupFromTarget(event);
|
34387 | var customTime = CustomTime.customTimeFromTarget(event);
|
34388 | var snap = this.itemSet.options.snap || null;
|
34389 | var scale = this.body.util.getScale();
|
34390 | var step = this.body.util.getStep();
|
34391 |
|
34392 | var time = this._toTime(x);
|
34393 |
|
34394 | var snappedTime = snap ? snap(time, scale, step) : time;
|
34395 | var element = availableUtils.getTarget(event);
|
34396 | var what = null;
|
34397 |
|
34398 | if (item != null) {
|
34399 | what = 'item';
|
34400 | } else if (customTime != null) {
|
34401 | what = 'custom-time';
|
34402 | } else if (availableUtils.hasParent(element, this.timeAxis.dom.foreground)) {
|
34403 | what = 'axis';
|
34404 | } else if (this.timeAxis2 && availableUtils.hasParent(element, this.timeAxis2.dom.foreground)) {
|
34405 | what = 'axis';
|
34406 | } else if (availableUtils.hasParent(element, this.itemSet.dom.labelSet)) {
|
34407 | what = 'group-label';
|
34408 | } else if (availableUtils.hasParent(element, this.currentTime.bar)) {
|
34409 | what = 'current-time';
|
34410 | } else if (availableUtils.hasParent(element, this.dom.center)) {
|
34411 | what = 'background';
|
34412 | }
|
34413 |
|
34414 | return {
|
34415 | event: event,
|
34416 | item: item ? item.id : null,
|
34417 | isCluster: item ? !!item.isCluster : false,
|
34418 | items: item ? item.items || [] : null,
|
34419 | group: group ? group.groupId : null,
|
34420 | customTime: customTime ? customTime.options.id : null,
|
34421 | what: what,
|
34422 | pageX: event.srcEvent ? event.srcEvent.pageX : event.pageX,
|
34423 | pageY: event.srcEvent ? event.srcEvent.pageY : event.pageY,
|
34424 | x: x,
|
34425 | y: y,
|
34426 | time: time,
|
34427 | snappedTime: snappedTime
|
34428 | };
|
34429 | }
|
34430 | |
34431 |
|
34432 |
|
34433 |
|
34434 | }, {
|
34435 | key: "toggleRollingMode",
|
34436 | value: function toggleRollingMode() {
|
34437 | if (this.range.rolling) {
|
34438 | this.range.stopRolling();
|
34439 | } else {
|
34440 | if (this.options.rollingMode == undefined) {
|
34441 | this.setOptions(this.options);
|
34442 | }
|
34443 |
|
34444 | this.range.startRolling();
|
34445 | }
|
34446 | }
|
34447 | |
34448 |
|
34449 |
|
34450 |
|
34451 |
|
34452 | }, {
|
34453 | key: "_redraw",
|
34454 | value: function _redraw() {
|
34455 | Core.prototype._redraw.call(this);
|
34456 | }
|
34457 | |
34458 |
|
34459 |
|
34460 |
|
34461 |
|
34462 |
|
34463 | }, {
|
34464 | key: "_onFit",
|
34465 | value: function _onFit(args) {
|
34466 | var start = args.start,
|
34467 | end = args.end,
|
34468 | animation = args.animation;
|
34469 |
|
34470 | if (!end) {
|
34471 | this.moveTo(start.valueOf(), {
|
34472 | animation: animation
|
34473 | });
|
34474 | } else {
|
34475 | this.range.setRange(start, end, {
|
34476 | animation: animation
|
34477 | });
|
34478 | }
|
34479 | }
|
34480 | }]);
|
34481 |
|
34482 | return Timeline;
|
34483 | }(Core);
|
34484 |
|
34485 | function getStart(item) {
|
34486 | return availableUtils.convert(item.data.start, 'Date').valueOf();
|
34487 | }
|
34488 |
|
34489 |
|
34490 |
|
34491 |
|
34492 |
|
34493 |
|
34494 |
|
34495 | function getEnd(item) {
|
34496 | var end = item.data.end != undefined ? item.data.end : item.data.start;
|
34497 | return availableUtils.convert(end, 'Date').valueOf();
|
34498 | }
|
34499 |
|
34500 |
|
34501 |
|
34502 |
|
34503 |
|
34504 |
|
34505 |
|
34506 | function getItemVerticalScroll(timeline, item) {
|
34507 | if (!item.parent) {
|
34508 |
|
34509 | return false;
|
34510 | }
|
34511 |
|
34512 | var itemsetHeight = timeline.options.rtl ? timeline.props.rightContainer.height : timeline.props.leftContainer.height;
|
34513 | var contentHeight = timeline.props.center.height;
|
34514 | var group = item.parent;
|
34515 | var offset = group.top;
|
34516 | var shouldScroll = true;
|
34517 | var orientation = timeline.timeAxis.options.orientation.axis;
|
34518 |
|
34519 | var itemTop = function itemTop() {
|
34520 | if (orientation == "bottom") {
|
34521 | return group.height - item.top - item.height;
|
34522 | } else {
|
34523 | return item.top;
|
34524 | }
|
34525 | };
|
34526 |
|
34527 | var currentScrollHeight = timeline._getScrollTop() * -1;
|
34528 | var targetOffset = offset + itemTop();
|
34529 | var height = item.height;
|
34530 |
|
34531 | if (targetOffset < currentScrollHeight) {
|
34532 | if (offset + itemsetHeight <= offset + itemTop() + height) {
|
34533 | offset += itemTop() - timeline.itemSet.options.margin.item.vertical;
|
34534 | }
|
34535 | } else if (targetOffset + height > currentScrollHeight + itemsetHeight) {
|
34536 | offset += itemTop() + height - itemsetHeight + timeline.itemSet.options.margin.item.vertical;
|
34537 | } else {
|
34538 | shouldScroll = false;
|
34539 | }
|
34540 |
|
34541 | offset = Math.min(offset, contentHeight - itemsetHeight);
|
34542 | return {
|
34543 | shouldScroll: shouldScroll,
|
34544 | scrollOffset: offset,
|
34545 | itemTop: targetOffset
|
34546 | };
|
34547 | }
|
34548 |
|
34549 |
|
34550 |
|
34551 |
|
34552 |
|
34553 |
|
34554 |
|
34555 |
|
34556 | function prepareElements(JSONcontainer) {
|
34557 |
|
34558 | for (var elementType in JSONcontainer) {
|
34559 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
34560 | JSONcontainer[elementType].redundant = JSONcontainer[elementType].used;
|
34561 | JSONcontainer[elementType].used = [];
|
34562 | }
|
34563 | }
|
34564 | }
|
34565 |
|
34566 |
|
34567 |
|
34568 |
|
34569 |
|
34570 |
|
34571 |
|
34572 |
|
34573 | function cleanupElements(JSONcontainer) {
|
34574 |
|
34575 | for (var elementType in JSONcontainer) {
|
34576 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
34577 | if (JSONcontainer[elementType].redundant) {
|
34578 | for (var i = 0; i < JSONcontainer[elementType].redundant.length; i++) {
|
34579 | JSONcontainer[elementType].redundant[i].parentNode.removeChild(JSONcontainer[elementType].redundant[i]);
|
34580 | }
|
34581 |
|
34582 | JSONcontainer[elementType].redundant = [];
|
34583 | }
|
34584 | }
|
34585 | }
|
34586 | }
|
34587 |
|
34588 |
|
34589 |
|
34590 |
|
34591 |
|
34592 | function resetElements(JSONcontainer) {
|
34593 | prepareElements(JSONcontainer);
|
34594 | cleanupElements(JSONcontainer);
|
34595 | prepareElements(JSONcontainer);
|
34596 | }
|
34597 |
|
34598 |
|
34599 |
|
34600 |
|
34601 |
|
34602 |
|
34603 |
|
34604 |
|
34605 |
|
34606 |
|
34607 |
|
34608 | function getSVGElement(elementType, JSONcontainer, svgContainer) {
|
34609 | var element;
|
34610 |
|
34611 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
34612 |
|
34613 |
|
34614 | if (JSONcontainer[elementType].redundant.length > 0) {
|
34615 | element = JSONcontainer[elementType].redundant[0];
|
34616 | JSONcontainer[elementType].redundant.shift();
|
34617 | } else {
|
34618 |
|
34619 | element = document.createElementNS('http://www.w3.org/2000/svg', elementType);
|
34620 | svgContainer.appendChild(element);
|
34621 | }
|
34622 | } else {
|
34623 |
|
34624 | element = document.createElementNS('http://www.w3.org/2000/svg', elementType);
|
34625 | JSONcontainer[elementType] = {
|
34626 | used: [],
|
34627 | redundant: []
|
34628 | };
|
34629 | svgContainer.appendChild(element);
|
34630 | }
|
34631 |
|
34632 | JSONcontainer[elementType].used.push(element);
|
34633 | return element;
|
34634 | }
|
34635 |
|
34636 |
|
34637 |
|
34638 |
|
34639 |
|
34640 |
|
34641 |
|
34642 |
|
34643 |
|
34644 |
|
34645 |
|
34646 | function getDOMElement(elementType, JSONcontainer, DOMContainer, insertBefore) {
|
34647 | var element;
|
34648 |
|
34649 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
34650 |
|
34651 |
|
34652 | if (JSONcontainer[elementType].redundant.length > 0) {
|
34653 | element = JSONcontainer[elementType].redundant[0];
|
34654 | JSONcontainer[elementType].redundant.shift();
|
34655 | } else {
|
34656 |
|
34657 | element = document.createElement(elementType);
|
34658 |
|
34659 | if (insertBefore !== undefined) {
|
34660 | DOMContainer.insertBefore(element, insertBefore);
|
34661 | } else {
|
34662 | DOMContainer.appendChild(element);
|
34663 | }
|
34664 | }
|
34665 | } else {
|
34666 |
|
34667 | element = document.createElement(elementType);
|
34668 | JSONcontainer[elementType] = {
|
34669 | used: [],
|
34670 | redundant: []
|
34671 | };
|
34672 |
|
34673 | if (insertBefore !== undefined) {
|
34674 | DOMContainer.insertBefore(element, insertBefore);
|
34675 | } else {
|
34676 | DOMContainer.appendChild(element);
|
34677 | }
|
34678 | }
|
34679 |
|
34680 | JSONcontainer[elementType].used.push(element);
|
34681 | return element;
|
34682 | }
|
34683 |
|
34684 |
|
34685 |
|
34686 |
|
34687 |
|
34688 |
|
34689 |
|
34690 |
|
34691 |
|
34692 |
|
34693 |
|
34694 |
|
34695 |
|
34696 |
|
34697 | function drawPoint(x, y, groupTemplate, JSONcontainer, svgContainer, labelObj) {
|
34698 | var point;
|
34699 |
|
34700 | if (groupTemplate.style == 'circle') {
|
34701 | point = getSVGElement('circle', JSONcontainer, svgContainer);
|
34702 | point.setAttributeNS(null, "cx", x);
|
34703 | point.setAttributeNS(null, "cy", y);
|
34704 | point.setAttributeNS(null, "r", 0.5 * groupTemplate.size);
|
34705 | } else {
|
34706 | point = getSVGElement('rect', JSONcontainer, svgContainer);
|
34707 | point.setAttributeNS(null, "x", x - 0.5 * groupTemplate.size);
|
34708 | point.setAttributeNS(null, "y", y - 0.5 * groupTemplate.size);
|
34709 | point.setAttributeNS(null, "width", groupTemplate.size);
|
34710 | point.setAttributeNS(null, "height", groupTemplate.size);
|
34711 | }
|
34712 |
|
34713 | if (groupTemplate.styles !== undefined) {
|
34714 | point.setAttributeNS(null, "style", groupTemplate.styles);
|
34715 | }
|
34716 |
|
34717 | point.setAttributeNS(null, "class", groupTemplate.className + " vis-point");
|
34718 |
|
34719 | if (labelObj) {
|
34720 | var label = getSVGElement('text', JSONcontainer, svgContainer);
|
34721 |
|
34722 | if (labelObj.xOffset) {
|
34723 | x = x + labelObj.xOffset;
|
34724 | }
|
34725 |
|
34726 | if (labelObj.yOffset) {
|
34727 | y = y + labelObj.yOffset;
|
34728 | }
|
34729 |
|
34730 | if (labelObj.content) {
|
34731 | label.textContent = labelObj.content;
|
34732 | }
|
34733 |
|
34734 | if (labelObj.className) {
|
34735 | label.setAttributeNS(null, "class", labelObj.className + " vis-label");
|
34736 | }
|
34737 |
|
34738 | label.setAttributeNS(null, "x", x);
|
34739 | label.setAttributeNS(null, "y", y);
|
34740 | }
|
34741 |
|
34742 | return point;
|
34743 | }
|
34744 |
|
34745 |
|
34746 |
|
34747 |
|
34748 |
|
34749 |
|
34750 |
|
34751 |
|
34752 |
|
34753 |
|
34754 |
|
34755 |
|
34756 |
|
34757 | function drawBar(x, y, width, height, className, JSONcontainer, svgContainer, style) {
|
34758 | if (height != 0) {
|
34759 | if (height < 0) {
|
34760 | height *= -1;
|
34761 | y -= height;
|
34762 | }
|
34763 |
|
34764 | var rect = getSVGElement('rect', JSONcontainer, svgContainer);
|
34765 | rect.setAttributeNS(null, "x", x - 0.5 * width);
|
34766 | rect.setAttributeNS(null, "y", y);
|
34767 | rect.setAttributeNS(null, "width", width);
|
34768 | rect.setAttributeNS(null, "height", height);
|
34769 | rect.setAttributeNS(null, "class", className);
|
34770 |
|
34771 | if (style) {
|
34772 | rect.setAttributeNS(null, "style", style);
|
34773 | }
|
34774 | }
|
34775 | }
|
34776 |
|
34777 |
|
34778 |
|
34779 |
|
34780 |
|
34781 | function getNavigatorLanguage() {
|
34782 | try {
|
34783 | if (!navigator) return 'en';
|
34784 |
|
34785 | if (navigator.languages && navigator.languages.length) {
|
34786 | return navigator.languages;
|
34787 | } else {
|
34788 | return navigator.userLanguage || navigator.language || navigator.browserLanguage || 'en';
|
34789 | }
|
34790 | } catch (error) {
|
34791 | return 'en';
|
34792 | }
|
34793 | }
|
34794 |
|
34795 |
|
34796 | var DataScale = function () {
|
34797 | |
34798 |
|
34799 |
|
34800 |
|
34801 |
|
34802 |
|
34803 |
|
34804 |
|
34805 |
|
34806 |
|
34807 |
|
34808 |
|
34809 | function DataScale(start, end, autoScaleStart, autoScaleEnd, containerHeight, majorCharHeight) {
|
34810 | var zeroAlign = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
34811 | var formattingFunction = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
34812 |
|
34813 | _classCallCheck(this, DataScale);
|
34814 |
|
34815 | this.majorSteps = [1, 2, 5, 10];
|
34816 | this.minorSteps = [0.25, 0.5, 1, 2];
|
34817 | this.customLines = null;
|
34818 | this.containerHeight = containerHeight;
|
34819 | this.majorCharHeight = majorCharHeight;
|
34820 | this._start = start;
|
34821 | this._end = end;
|
34822 | this.scale = 1;
|
34823 | this.minorStepIdx = -1;
|
34824 | this.magnitudefactor = 1;
|
34825 | this.determineScale();
|
34826 | this.zeroAlign = zeroAlign;
|
34827 | this.autoScaleStart = autoScaleStart;
|
34828 | this.autoScaleEnd = autoScaleEnd;
|
34829 | this.formattingFunction = formattingFunction;
|
34830 |
|
34831 | if (autoScaleStart || autoScaleEnd) {
|
34832 | var me = this;
|
34833 |
|
34834 | var roundToMinor = function roundToMinor(value) {
|
34835 | var rounded = value - value % (me.magnitudefactor * me.minorSteps[me.minorStepIdx]);
|
34836 |
|
34837 | if (value % (me.magnitudefactor * me.minorSteps[me.minorStepIdx]) > 0.5 * (me.magnitudefactor * me.minorSteps[me.minorStepIdx])) {
|
34838 | return rounded + me.magnitudefactor * me.minorSteps[me.minorStepIdx];
|
34839 | } else {
|
34840 | return rounded;
|
34841 | }
|
34842 | };
|
34843 |
|
34844 | if (autoScaleStart) {
|
34845 | this._start -= this.magnitudefactor * 2 * this.minorSteps[this.minorStepIdx];
|
34846 | this._start = roundToMinor(this._start);
|
34847 | }
|
34848 |
|
34849 | if (autoScaleEnd) {
|
34850 | this._end += this.magnitudefactor * this.minorSteps[this.minorStepIdx];
|
34851 | this._end = roundToMinor(this._end);
|
34852 | }
|
34853 |
|
34854 | this.determineScale();
|
34855 | }
|
34856 | }
|
34857 | |
34858 |
|
34859 |
|
34860 |
|
34861 |
|
34862 |
|
34863 | _createClass(DataScale, [{
|
34864 | key: "setCharHeight",
|
34865 | value: function setCharHeight(majorCharHeight) {
|
34866 | this.majorCharHeight = majorCharHeight;
|
34867 | }
|
34868 | |
34869 |
|
34870 |
|
34871 |
|
34872 |
|
34873 | }, {
|
34874 | key: "setHeight",
|
34875 | value: function setHeight(containerHeight) {
|
34876 | this.containerHeight = containerHeight;
|
34877 | }
|
34878 | |
34879 |
|
34880 |
|
34881 |
|
34882 | }, {
|
34883 | key: "determineScale",
|
34884 | value: function determineScale() {
|
34885 | var range = this._end - this._start;
|
34886 | this.scale = this.containerHeight / range;
|
34887 | var minimumStepValue = this.majorCharHeight / this.scale;
|
34888 | var orderOfMagnitude = range > 0 ? Math.round(Math.log(range) / Math.LN10) : 0;
|
34889 | this.minorStepIdx = -1;
|
34890 | this.magnitudefactor = Math.pow(10, orderOfMagnitude);
|
34891 | var start = 0;
|
34892 |
|
34893 | if (orderOfMagnitude < 0) {
|
34894 | start = orderOfMagnitude;
|
34895 | }
|
34896 |
|
34897 | var solutionFound = false;
|
34898 |
|
34899 | for (var l = start; Math.abs(l) <= Math.abs(orderOfMagnitude); l++) {
|
34900 | this.magnitudefactor = Math.pow(10, l);
|
34901 |
|
34902 | for (var j = 0; j < this.minorSteps.length; j++) {
|
34903 | var stepSize = this.magnitudefactor * this.minorSteps[j];
|
34904 |
|
34905 | if (stepSize >= minimumStepValue) {
|
34906 | solutionFound = true;
|
34907 | this.minorStepIdx = j;
|
34908 | break;
|
34909 | }
|
34910 | }
|
34911 |
|
34912 | if (solutionFound === true) {
|
34913 | break;
|
34914 | }
|
34915 | }
|
34916 | }
|
34917 | |
34918 |
|
34919 |
|
34920 |
|
34921 |
|
34922 |
|
34923 | }, {
|
34924 | key: "is_major",
|
34925 | value: function is_major(value) {
|
34926 | return value % (this.magnitudefactor * this.majorSteps[this.minorStepIdx]) === 0;
|
34927 | }
|
34928 | |
34929 |
|
34930 |
|
34931 |
|
34932 |
|
34933 | }, {
|
34934 | key: "getStep",
|
34935 | value: function getStep() {
|
34936 | return this.magnitudefactor * this.minorSteps[this.minorStepIdx];
|
34937 | }
|
34938 | |
34939 |
|
34940 |
|
34941 |
|
34942 |
|
34943 | }, {
|
34944 | key: "getFirstMajor",
|
34945 | value: function getFirstMajor() {
|
34946 | var majorStep = this.magnitudefactor * this.majorSteps[this.minorStepIdx];
|
34947 | return this.convertValue(this._start + (majorStep - this._start % majorStep) % majorStep);
|
34948 | }
|
34949 | |
34950 |
|
34951 |
|
34952 |
|
34953 |
|
34954 |
|
34955 | }, {
|
34956 | key: "formatValue",
|
34957 | value: function formatValue(current) {
|
34958 | var returnValue = current.toPrecision(5);
|
34959 |
|
34960 | if (typeof this.formattingFunction === 'function') {
|
34961 | returnValue = this.formattingFunction(current);
|
34962 | }
|
34963 |
|
34964 | if (typeof returnValue === 'number') {
|
34965 | return "".concat(returnValue);
|
34966 | } else if (typeof returnValue === 'string') {
|
34967 | return returnValue;
|
34968 | } else {
|
34969 | return current.toPrecision(5);
|
34970 | }
|
34971 | }
|
34972 | |
34973 |
|
34974 |
|
34975 |
|
34976 |
|
34977 | }, {
|
34978 | key: "getLines",
|
34979 | value: function getLines() {
|
34980 | var lines = [];
|
34981 | var step = this.getStep();
|
34982 | var bottomOffset = (step - this._start % step) % step;
|
34983 |
|
34984 | for (var i = this._start + bottomOffset; this._end - i > 0.00001; i += step) {
|
34985 | if (i != this._start) {
|
34986 |
|
34987 | lines.push({
|
34988 | major: this.is_major(i),
|
34989 | y: this.convertValue(i),
|
34990 | val: this.formatValue(i)
|
34991 | });
|
34992 | }
|
34993 | }
|
34994 |
|
34995 | return lines;
|
34996 | }
|
34997 | |
34998 |
|
34999 |
|
35000 |
|
35001 |
|
35002 | }, {
|
35003 | key: "followScale",
|
35004 | value: function followScale(other) {
|
35005 | var oldStepIdx = this.minorStepIdx;
|
35006 | var oldStart = this._start;
|
35007 | var oldEnd = this._end;
|
35008 | var me = this;
|
35009 |
|
35010 | var increaseMagnitude = function increaseMagnitude() {
|
35011 | me.magnitudefactor *= 2;
|
35012 | };
|
35013 |
|
35014 | var decreaseMagnitude = function decreaseMagnitude() {
|
35015 | me.magnitudefactor /= 2;
|
35016 | };
|
35017 |
|
35018 | if (other.minorStepIdx <= 1 && this.minorStepIdx <= 1 || other.minorStepIdx > 1 && this.minorStepIdx > 1) ; else if (other.minorStepIdx < this.minorStepIdx) {
|
35019 |
|
35020 | this.minorStepIdx = 1;
|
35021 |
|
35022 | if (oldStepIdx == 2) {
|
35023 | increaseMagnitude();
|
35024 | } else {
|
35025 | increaseMagnitude();
|
35026 | increaseMagnitude();
|
35027 | }
|
35028 | } else {
|
35029 |
|
35030 | this.minorStepIdx = 2;
|
35031 |
|
35032 | if (oldStepIdx == 1) {
|
35033 | decreaseMagnitude();
|
35034 | } else {
|
35035 | decreaseMagnitude();
|
35036 | decreaseMagnitude();
|
35037 | }
|
35038 | }
|
35039 |
|
35040 |
|
35041 | var otherZero = other.convertValue(0);
|
35042 | var otherStep = other.getStep() * other.scale;
|
35043 | var done = false;
|
35044 | var count = 0;
|
35045 |
|
35046 | while (!done && count++ < 5) {
|
35047 | //Get my stats:
|
35048 | this.scale = otherStep / (this.minorSteps[this.minorStepIdx] * this.magnitudefactor);
|
35049 | var newRange = this.containerHeight / this.scale; //For the case the magnitudefactor has changed:
|
35050 |
|
35051 | this._start = oldStart;
|
35052 | this._end = this._start + newRange;
|
35053 | var myOriginalZero = this._end * this.scale;
|
35054 | var majorStep = this.magnitudefactor * this.majorSteps[this.minorStepIdx];
|
35055 | var majorOffset = this.getFirstMajor() - other.getFirstMajor();
|
35056 |
|
35057 | if (this.zeroAlign) {
|
35058 | var zeroOffset = otherZero - myOriginalZero;
|
35059 | this._end += zeroOffset / this.scale;
|
35060 | this._start = this._end - newRange;
|
35061 | } else {
|
35062 | if (!this.autoScaleStart) {
|
35063 | this._start += majorStep - majorOffset / this.scale;
|
35064 | this._end = this._start + newRange;
|
35065 | } else {
|
35066 | this._start -= majorOffset / this.scale;
|
35067 | this._end = this._start + newRange;
|
35068 | }
|
35069 | }
|
35070 |
|
35071 | if (!this.autoScaleEnd && this._end > oldEnd + 0.00001) {
|
35072 | //Need to decrease magnitude to prevent scale overshoot! (end)
|
35073 | decreaseMagnitude();
|
35074 | done = false;
|
35075 | continue;
|
35076 | }
|
35077 |
|
35078 | if (!this.autoScaleStart && this._start < oldStart - 0.00001) {
|
35079 | if (this.zeroAlign && oldStart >= 0) {
|
35080 | console.warn("Can't adhere to given 'min' range, due to zeroalign");
|
35081 | } else {
|
35082 | //Need to decrease magnitude to prevent scale overshoot! (start)
|
35083 | decreaseMagnitude();
|
35084 | done = false;
|
35085 | continue;
|
35086 | }
|
35087 | }
|
35088 |
|
35089 | if (this.autoScaleStart && this.autoScaleEnd && newRange < oldEnd - oldStart) {
|
35090 | increaseMagnitude();
|
35091 | done = false;
|
35092 | continue;
|
35093 | }
|
35094 |
|
35095 | done = true;
|
35096 | }
|
35097 | }
|
35098 | /**
|
35099 | * convert value
|
35100 | * @param {number} value
|
35101 | * @returns {number}
|
35102 | */
|
35103 |
|
35104 | }, {
|
35105 | key: "convertValue",
|
35106 | value: function convertValue(value) {
|
35107 | return this.containerHeight - (value - this._start) * this.scale;
|
35108 | }
|
35109 | /**
|
35110 | * returns screen to value
|
35111 | * @param {number} pixels
|
35112 | * @returns {number}
|
35113 | */
|
35114 |
|
35115 | }, {
|
35116 | key: "screenToValue",
|
35117 | value: function screenToValue(pixels) {
|
35118 | return (this.containerHeight - pixels) / this.scale + this._start;
|
35119 | }
|
35120 | }]);
|
35121 |
|
35122 | return DataScale;
|
35123 | }();
|
35124 |
|
35125 | function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray$1(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
35126 |
|
35127 | function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from$1(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
35128 |
|
35129 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
35130 |
|
35131 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
35132 |
|
35133 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
35134 | /** A horizontal time axis */
|
35135 |
|
35136 | var DataAxis = /*#__PURE__*/function (_Component) {
|
35137 | _inherits(DataAxis, _Component);
|
35138 |
|
35139 | var _super = _createSuper(DataAxis);
|
35140 |
|
35141 | /**
|
35142 | * @param {Object} body
|
35143 | * @param {Object} [options] See DataAxis.setOptions for the available
|
35144 | * options.
|
35145 | * @param {SVGElement} svg
|
35146 | * @param {timeline.LineGraph.options} linegraphOptions
|
35147 | * @constructor DataAxis
|
35148 | * @extends Component
|
35149 | */
|
35150 | function DataAxis(body, options, svg, linegraphOptions) {
|
35151 | var _this;
|
35152 |
|
35153 | _classCallCheck(this, DataAxis);
|
35154 |
|
35155 | _this = _super.call(this);
|
35156 | _this.id = v4();
|
35157 | _this.body = body;
|
35158 | _this.defaultOptions = {
|
35159 | orientation: 'left',
|
35160 | // supported: 'left', 'right'
|
35161 | showMinorLabels: true,
|
35162 | showMajorLabels: true,
|
35163 | showWeekScale: false,
|
35164 | icons: false,
|
35165 | majorLinesOffset: 7,
|
35166 | minorLinesOffset: 4,
|
35167 | labelOffsetX: 10,
|
35168 | labelOffsetY: 2,
|
35169 | iconWidth: 20,
|
35170 | width: '40px',
|
35171 | visible: true,
|
35172 | alignZeros: true,
|
35173 | left: {
|
35174 | range: {
|
35175 | min: undefined,
|
35176 | max: undefined
|
35177 | },
|
35178 | format: function format(value) {
|
35179 | return "".concat(_parseFloat(value.toPrecision(3)));
|
35180 | },
|
35181 | title: {
|
35182 | text: undefined,
|
35183 | style: undefined
|
35184 | }
|
35185 | },
|
35186 | right: {
|
35187 | range: {
|
35188 | min: undefined,
|
35189 | max: undefined
|
35190 | },
|
35191 | format: function format(value) {
|
35192 | return "".concat(_parseFloat(value.toPrecision(3)));
|
35193 | },
|
35194 | title: {
|
35195 | text: undefined,
|
35196 | style: undefined
|
35197 | }
|
35198 | }
|
35199 | };
|
35200 | _this.linegraphOptions = linegraphOptions;
|
35201 | _this.linegraphSVG = svg;
|
35202 | _this.props = {};
|
35203 | _this.DOMelements = {
|
35204 | // dynamic elements
|
35205 | lines: {},
|
35206 | labels: {},
|
35207 | title: {}
|
35208 | };
|
35209 | _this.dom = {};
|
35210 | _this.scale = undefined;
|
35211 | _this.range = {
|
35212 | start: 0,
|
35213 | end: 0
|
35214 | };
|
35215 | _this.options = availableUtils.extend({}, _this.defaultOptions);
|
35216 | _this.conversionFactor = 1;
|
35217 |
|
35218 | _this.setOptions(options);
|
35219 |
|
35220 | _this.width = Number("".concat(_this.options.width).replace("px", ""));
|
35221 | _this.minWidth = _this.width;
|
35222 | _this.height = _this.linegraphSVG.getBoundingClientRect().height;
|
35223 | _this.hidden = false;
|
35224 | _this.stepPixels = 25;
|
35225 | _this.zeroCrossing = -1;
|
35226 | _this.amountOfSteps = -1;
|
35227 | _this.lineOffset = 0;
|
35228 | _this.master = true;
|
35229 | _this.masterAxis = null;
|
35230 | _this.svgElements = {};
|
35231 | _this.iconsRemoved = false;
|
35232 | _this.groups = {};
|
35233 | _this.amountOfGroups = 0; // create the HTML DOM
|
35234 |
|
35235 | _this._create();
|
35236 |
|
35237 | if (_this.scale == undefined) {
|
35238 | _this._redrawLabels();
|
35239 | }
|
35240 |
|
35241 | _this.framework = {
|
35242 | svg: _this.svg,
|
35243 | svgElements: _this.svgElements,
|
35244 | options: _this.options,
|
35245 | groups: _this.groups
|
35246 | };
|
35247 |
|
35248 | var me = _assertThisInitialized$1(_this);
|
35249 |
|
35250 | _this.body.emitter.on("verticalDrag", function () {
|
35251 | me.dom.lineContainer.style.top = "".concat(me.body.domProps.scrollTop, "px");
|
35252 | });
|
35253 |
|
35254 | return _this;
|
35255 | }
|
35256 | /**
|
35257 | * Adds group to data axis
|
35258 | * @param {string} label
|
35259 | * @param {object} graphOptions
|
35260 | */
|
35261 |
|
35262 |
|
35263 | _createClass(DataAxis, [{
|
35264 | key: "addGroup",
|
35265 | value: function addGroup(label, graphOptions) {
|
35266 | if (!this.groups.hasOwnProperty(label)) {
|
35267 | this.groups[label] = graphOptions;
|
35268 | }
|
35269 |
|
35270 | this.amountOfGroups += 1;
|
35271 | }
|
35272 | /**
|
35273 | * updates group of data axis
|
35274 | * @param {string} label
|
35275 | * @param {object} graphOptions
|
35276 | */
|
35277 |
|
35278 | }, {
|
35279 | key: "updateGroup",
|
35280 | value: function updateGroup(label, graphOptions) {
|
35281 | if (!this.groups.hasOwnProperty(label)) {
|
35282 | this.amountOfGroups += 1;
|
35283 | }
|
35284 |
|
35285 | this.groups[label] = graphOptions;
|
35286 | }
|
35287 | /**
|
35288 | * removes group of data axis
|
35289 | * @param {string} label
|
35290 | */
|
35291 |
|
35292 | }, {
|
35293 | key: "removeGroup",
|
35294 | value: function removeGroup(label) {
|
35295 | if (this.groups.hasOwnProperty(label)) {
|
35296 | delete this.groups[label];
|
35297 | this.amountOfGroups -= 1;
|
35298 | }
|
35299 | }
|
35300 | /**
|
35301 | * sets options
|
35302 | * @param {object} options
|
35303 | */
|
35304 |
|
35305 | }, {
|
35306 | key: "setOptions",
|
35307 | value: function setOptions(options) {
|
35308 | if (options) {
|
35309 | var redraw = false;
|
35310 |
|
35311 | if (this.options.orientation != options.orientation && options.orientation !== undefined) {
|
35312 | redraw = true;
|
35313 | }
|
35314 |
|
35315 | var fields = ['orientation', 'showMinorLabels', 'showMajorLabels', 'icons', 'majorLinesOffset', 'minorLinesOffset', 'labelOffsetX', 'labelOffsetY', 'iconWidth', 'width', 'visible', 'left', 'right', 'alignZeros'];
|
35316 | availableUtils.selectiveDeepExtend(fields, this.options, options);
|
35317 | this.minWidth = Number("".concat(this.options.width).replace("px", ""));
|
35318 |
|
35319 | if (redraw === true && this.dom.frame) {
|
35320 | this.hide();
|
35321 | this.show();
|
35322 | }
|
35323 | }
|
35324 | }
|
35325 | /**
|
35326 | * Create the HTML DOM for the DataAxis
|
35327 | */
|
35328 |
|
35329 | }, {
|
35330 | key: "_create",
|
35331 | value: function _create() {
|
35332 | this.dom.frame = document.createElement('div');
|
35333 | this.dom.frame.style.width = this.options.width;
|
35334 | this.dom.frame.style.height = this.height;
|
35335 | this.dom.lineContainer = document.createElement('div');
|
35336 | this.dom.lineContainer.style.width = '100%';
|
35337 | this.dom.lineContainer.style.height = this.height;
|
35338 | this.dom.lineContainer.style.position = 'relative';
|
35339 | this.dom.lineContainer.style.visibility = 'visible';
|
35340 | this.dom.lineContainer.style.display = 'block'; // create svg element for graph drawing.
|
35341 |
|
35342 | this.svg = document.createElementNS('http://www.w3.org/2000/svg', "svg");
|
35343 | this.svg.style.position = "absolute";
|
35344 | this.svg.style.top = '0px';
|
35345 | this.svg.style.height = '100%';
|
35346 | this.svg.style.width = '100%';
|
35347 | this.svg.style.display = "block";
|
35348 | this.dom.frame.appendChild(this.svg);
|
35349 | }
|
35350 | /**
|
35351 | * redraws groups icons
|
35352 | */
|
35353 |
|
35354 | }, {
|
35355 | key: "_redrawGroupIcons",
|
35356 | value: function _redrawGroupIcons() {
|
35357 | prepareElements(this.svgElements);
|
35358 | var x;
|
35359 | var iconWidth = this.options.iconWidth;
|
35360 | var iconHeight = 15;
|
35361 | var iconOffset = 4;
|
35362 | var y = iconOffset + 0.5 * iconHeight;
|
35363 |
|
35364 | if (this.options.orientation === 'left') {
|
35365 | x = iconOffset;
|
35366 | } else {
|
35367 | x = this.width - iconWidth - iconOffset;
|
35368 | }
|
35369 |
|
35370 | var groupArray = _Object$keys(this.groups);
|
35371 |
|
35372 | _sortInstanceProperty(groupArray).call(groupArray, function (a, b) {
|
35373 | return a < b ? -1 : 1;
|
35374 | });
|
35375 |
|
35376 | var _iterator = _createForOfIteratorHelper(groupArray),
|
35377 | _step;
|
35378 |
|
35379 | try {
|
35380 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
35381 | var groupId = _step.value;
|
35382 |
|
35383 | if (this.groups[groupId].visible === true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] === true)) {
|
35384 | this.groups[groupId].getLegend(iconWidth, iconHeight, this.framework, x, y);
|
35385 | y += iconHeight + iconOffset;
|
35386 | }
|
35387 | }
|
35388 | } catch (err) {
|
35389 | _iterator.e(err);
|
35390 | } finally {
|
35391 | _iterator.f();
|
35392 | }
|
35393 |
|
35394 | cleanupElements(this.svgElements);
|
35395 | this.iconsRemoved = false;
|
35396 | }
|
35397 | /**
|
35398 | * Cleans up icons
|
35399 | */
|
35400 |
|
35401 | }, {
|
35402 | key: "_cleanupIcons",
|
35403 | value: function _cleanupIcons() {
|
35404 | if (this.iconsRemoved === false) {
|
35405 | prepareElements(this.svgElements);
|
35406 | cleanupElements(this.svgElements);
|
35407 | this.iconsRemoved = true;
|
35408 | }
|
35409 | }
|
35410 | /**
|
35411 | * Create the HTML DOM for the DataAxis
|
35412 | */
|
35413 |
|
35414 | }, {
|
35415 | key: "show",
|
35416 | value: function show() {
|
35417 | this.hidden = false;
|
35418 |
|
35419 | if (!this.dom.frame.parentNode) {
|
35420 | if (this.options.orientation === 'left') {
|
35421 | this.body.dom.left.appendChild(this.dom.frame);
|
35422 | } else {
|
35423 | this.body.dom.right.appendChild(this.dom.frame);
|
35424 | }
|
35425 | }
|
35426 |
|
35427 | if (!this.dom.lineContainer.parentNode) {
|
35428 | this.body.dom.backgroundHorizontal.appendChild(this.dom.lineContainer);
|
35429 | }
|
35430 |
|
35431 | this.dom.lineContainer.style.display = 'block';
|
35432 | }
|
35433 | /**
|
35434 | * Create the HTML DOM for the DataAxis
|
35435 | */
|
35436 |
|
35437 | }, {
|
35438 | key: "hide",
|
35439 | value: function hide() {
|
35440 | this.hidden = true;
|
35441 |
|
35442 | if (this.dom.frame.parentNode) {
|
35443 | this.dom.frame.parentNode.removeChild(this.dom.frame);
|
35444 | }
|
35445 |
|
35446 | this.dom.lineContainer.style.display = 'none';
|
35447 | }
|
35448 | /**
|
35449 | * Set a range (start and end)
|
35450 | * @param {number} start
|
35451 | * @param {number} end
|
35452 | */
|
35453 |
|
35454 | }, {
|
35455 | key: "setRange",
|
35456 | value: function setRange(start, end) {
|
35457 | this.range.start = start;
|
35458 | this.range.end = end;
|
35459 | }
|
35460 | /**
|
35461 | * Repaint the component
|
35462 | * @return {boolean} Returns true if the component is resized
|
35463 | */
|
35464 |
|
35465 | }, {
|
35466 | key: "redraw",
|
35467 | value: function redraw() {
|
35468 | var resized = false;
|
35469 | var activeGroups = 0; // Make sure the line container adheres to the vertical scrolling.
|
35470 |
|
35471 | this.dom.lineContainer.style.top = "".concat(this.body.domProps.scrollTop, "px");
|
35472 |
|
35473 | for (var groupId in this.groups) {
|
35474 | if (this.groups.hasOwnProperty(groupId)) {
|
35475 | if (this.groups[groupId].visible === true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] === true)) {
|
35476 | activeGroups++;
|
35477 | }
|
35478 | }
|
35479 | }
|
35480 |
|
35481 | if (this.amountOfGroups === 0 || activeGroups === 0) {
|
35482 | this.hide();
|
35483 | } else {
|
35484 | this.show();
|
35485 | this.height = Number(this.linegraphSVG.style.height.replace("px", "")); // svg offsetheight did not work in firefox and explorer...
|
35486 |
|
35487 | this.dom.lineContainer.style.height = "".concat(this.height, "px");
|
35488 | this.width = this.options.visible === true ? Number("".concat(this.options.width).replace("px", "")) : 0;
|
35489 | var props = this.props;
|
35490 | var frame = this.dom.frame; // update classname
|
35491 |
|
35492 | frame.className = 'vis-data-axis'; // calculate character width and height
|
35493 |
|
35494 | this._calculateCharSize();
|
35495 |
|
35496 | var orientation = this.options.orientation;
|
35497 | var showMinorLabels = this.options.showMinorLabels;
|
35498 | var showMajorLabels = this.options.showMajorLabels;
|
35499 | var backgroundHorizontalOffsetWidth = this.body.dom.backgroundHorizontal.offsetWidth; // determine the width and height of the elements for the axis
|
35500 |
|
35501 | props.minorLabelHeight = showMinorLabels ? props.minorCharHeight : 0;
|
35502 | props.majorLabelHeight = showMajorLabels ? props.majorCharHeight : 0;
|
35503 | props.minorLineWidth = backgroundHorizontalOffsetWidth - this.lineOffset - this.width + 2 * this.options.minorLinesOffset;
|
35504 | props.minorLineHeight = 1;
|
35505 | props.majorLineWidth = backgroundHorizontalOffsetWidth - this.lineOffset - this.width + 2 * this.options.majorLinesOffset;
|
35506 | props.majorLineHeight = 1; // take frame offline while updating (is almost twice as fast)
|
35507 |
|
35508 | if (orientation === 'left') {
|
35509 | frame.style.top = '0';
|
35510 | frame.style.left = '0';
|
35511 | frame.style.bottom = '';
|
35512 | frame.style.width = "".concat(this.width, "px");
|
35513 | frame.style.height = "".concat(this.height, "px");
|
35514 | this.props.width = this.body.domProps.left.width;
|
35515 | this.props.height = this.body.domProps.left.height;
|
35516 | } else {
|
35517 | // right
|
35518 | frame.style.top = '';
|
35519 | frame.style.bottom = '0';
|
35520 | frame.style.left = '0';
|
35521 | frame.style.width = "".concat(this.width, "px");
|
35522 | frame.style.height = "".concat(this.height, "px");
|
35523 | this.props.width = this.body.domProps.right.width;
|
35524 | this.props.height = this.body.domProps.right.height;
|
35525 | }
|
35526 |
|
35527 | resized = this._redrawLabels();
|
35528 | resized = this._isResized() || resized;
|
35529 |
|
35530 | if (this.options.icons === true) {
|
35531 | this._redrawGroupIcons();
|
35532 | } else {
|
35533 | this._cleanupIcons();
|
35534 | }
|
35535 |
|
35536 | this._redrawTitle(orientation);
|
35537 | }
|
35538 |
|
35539 | return resized;
|
35540 | }
|
35541 | /**
|
35542 | * Repaint major and minor text labels and vertical grid lines
|
35543 | *
|
35544 | * @returns {boolean}
|
35545 | * @private
|
35546 | */
|
35547 |
|
35548 | }, {
|
35549 | key: "_redrawLabels",
|
35550 | value: function _redrawLabels() {
|
35551 | var _this2 = this;
|
35552 |
|
35553 | var resized = false;
|
35554 | prepareElements(this.DOMelements.lines);
|
35555 | prepareElements(this.DOMelements.labels);
|
35556 | var orientation = this.options['orientation'];
|
35557 | var customRange = this.options[orientation].range != undefined ? this.options[orientation].range : {}; //Override range with manual options:
|
35558 |
|
35559 | var autoScaleEnd = true;
|
35560 |
|
35561 | if (customRange.max != undefined) {
|
35562 | this.range.end = customRange.max;
|
35563 | autoScaleEnd = false;
|
35564 | }
|
35565 |
|
35566 | var autoScaleStart = true;
|
35567 |
|
35568 | if (customRange.min != undefined) {
|
35569 | this.range.start = customRange.min;
|
35570 | autoScaleStart = false;
|
35571 | }
|
35572 |
|
35573 | this.scale = new DataScale(this.range.start, this.range.end, autoScaleStart, autoScaleEnd, this.dom.frame.offsetHeight, this.props.majorCharHeight, this.options.alignZeros, this.options[orientation].format);
|
35574 |
|
35575 | if (this.master === false && this.masterAxis != undefined) {
|
35576 | this.scale.followScale(this.masterAxis.scale);
|
35577 | this.dom.lineContainer.style.display = 'none';
|
35578 | } else {
|
35579 | this.dom.lineContainer.style.display = 'block';
|
35580 | } //Is updated in side-effect of _redrawLabel():
|
35581 |
|
35582 |
|
35583 | this.maxLabelSize = 0;
|
35584 | var lines = this.scale.getLines();
|
35585 |
|
35586 | _forEachInstanceProperty(lines).call(lines, function (line) {
|
35587 | var y = line.y;
|
35588 | var isMajor = line.major;
|
35589 |
|
35590 | if (_this2.options['showMinorLabels'] && isMajor === false) {
|
35591 | _this2._redrawLabel(y - 2, line.val, orientation, 'vis-y-axis vis-minor', _this2.props.minorCharHeight);
|
35592 | }
|
35593 |
|
35594 | if (isMajor) {
|
35595 | if (y >= 0) {
|
35596 | _this2._redrawLabel(y - 2, line.val, orientation, 'vis-y-axis vis-major', _this2.props.majorCharHeight);
|
35597 | }
|
35598 | }
|
35599 |
|
35600 | if (_this2.master === true) {
|
35601 | if (isMajor) {
|
35602 | _this2._redrawLine(y, orientation, 'vis-grid vis-horizontal vis-major', _this2.options.majorLinesOffset, _this2.props.majorLineWidth);
|
35603 | } else {
|
35604 | _this2._redrawLine(y, orientation, 'vis-grid vis-horizontal vis-minor', _this2.options.minorLinesOffset, _this2.props.minorLineWidth);
|
35605 | }
|
35606 | }
|
35607 | }); // Note that title is rotated, so we're using the height, not width!
|
35608 |
|
35609 |
|
35610 | var titleWidth = 0;
|
35611 |
|
35612 | if (this.options[orientation].title !== undefined && this.options[orientation].title.text !== undefined) {
|
35613 | titleWidth = this.props.titleCharHeight;
|
35614 | }
|
35615 |
|
35616 | var offset = this.options.icons === true ? Math.max(this.options.iconWidth, titleWidth) + this.options.labelOffsetX + 15 : titleWidth + this.options.labelOffsetX + 15; // this will resize the yAxis to accommodate the labels.
|
35617 |
|
35618 | if (this.maxLabelSize > this.width - offset && this.options.visible === true) {
|
35619 | this.width = this.maxLabelSize + offset;
|
35620 | this.options.width = "".concat(this.width, "px");
|
35621 | cleanupElements(this.DOMelements.lines);
|
35622 | cleanupElements(this.DOMelements.labels);
|
35623 | this.redraw();
|
35624 | resized = true;
|
35625 | } // this will resize the yAxis if it is too big for the labels.
|
35626 | else if (this.maxLabelSize < this.width - offset && this.options.visible === true && this.width > this.minWidth) {
|
35627 | this.width = Math.max(this.minWidth, this.maxLabelSize + offset);
|
35628 | this.options.width = "".concat(this.width, "px");
|
35629 | cleanupElements(this.DOMelements.lines);
|
35630 | cleanupElements(this.DOMelements.labels);
|
35631 | this.redraw();
|
35632 | resized = true;
|
35633 | } else {
|
35634 | cleanupElements(this.DOMelements.lines);
|
35635 | cleanupElements(this.DOMelements.labels);
|
35636 | resized = false;
|
35637 | }
|
35638 |
|
35639 | return resized;
|
35640 | }
|
35641 | /**
|
35642 | * converts value
|
35643 | * @param {number} value
|
35644 | * @returns {number} converted number
|
35645 | */
|
35646 |
|
35647 | }, {
|
35648 | key: "convertValue",
|
35649 | value: function convertValue(value) {
|
35650 | return this.scale.convertValue(value);
|
35651 | }
|
35652 | /**
|
35653 | * converts value
|
35654 | * @param {number} x
|
35655 | * @returns {number} screen value
|
35656 | */
|
35657 |
|
35658 | }, {
|
35659 | key: "screenToValue",
|
35660 | value: function screenToValue(x) {
|
35661 | return this.scale.screenToValue(x);
|
35662 | }
|
35663 | /**
|
35664 | * Create a label for the axis at position x
|
35665 | *
|
35666 | * @param {number} y
|
35667 | * @param {string} text
|
35668 | * @param {'top'|'right'|'bottom'|'left'} orientation
|
35669 | * @param {string} className
|
35670 | * @param {number} characterHeight
|
35671 | * @private
|
35672 | */
|
35673 |
|
35674 | }, {
|
35675 | key: "_redrawLabel",
|
35676 | value: function _redrawLabel(y, text, orientation, className, characterHeight) {
|
35677 | // reuse redundant label
|
35678 | var label = getDOMElement('div', this.DOMelements.labels, this.dom.frame); //this.dom.redundant.labels.shift();
|
35679 |
|
35680 | label.className = className;
|
35681 | label.innerHTML = availableUtils.xss(text);
|
35682 |
|
35683 | if (orientation === 'left') {
|
35684 | label.style.left = "-".concat(this.options.labelOffsetX, "px");
|
35685 | label.style.textAlign = "right";
|
35686 | } else {
|
35687 | label.style.right = "-".concat(this.options.labelOffsetX, "px");
|
35688 | label.style.textAlign = "left";
|
35689 | }
|
35690 |
|
35691 | label.style.top = "".concat(y - 0.5 * characterHeight + this.options.labelOffsetY, "px");
|
35692 | text += '';
|
35693 | var largestWidth = Math.max(this.props.majorCharWidth, this.props.minorCharWidth);
|
35694 |
|
35695 | if (this.maxLabelSize < text.length * largestWidth) {
|
35696 | this.maxLabelSize = text.length * largestWidth;
|
35697 | }
|
35698 | }
|
35699 | /**
|
35700 | * Create a minor line for the axis at position y
|
35701 | * @param {number} y
|
35702 | * @param {'top'|'right'|'bottom'|'left'} orientation
|
35703 | * @param {string} className
|
35704 | * @param {number} offset
|
35705 | * @param {number} width
|
35706 | */
|
35707 |
|
35708 | }, {
|
35709 | key: "_redrawLine",
|
35710 | value: function _redrawLine(y, orientation, className, offset, width) {
|
35711 | if (this.master === true) {
|
35712 | var line = getDOMElement('div', this.DOMelements.lines, this.dom.lineContainer); //this.dom.redundant.lines.shift();
|
35713 |
|
35714 | line.className = className;
|
35715 | line.innerHTML = '';
|
35716 |
|
35717 | if (orientation === 'left') {
|
35718 | line.style.left = "".concat(this.width - offset, "px");
|
35719 | } else {
|
35720 | line.style.right = "".concat(this.width - offset, "px");
|
35721 | }
|
35722 |
|
35723 | line.style.width = "".concat(width, "px");
|
35724 | line.style.top = "".concat(y, "px");
|
35725 | }
|
35726 | }
|
35727 | /**
|
35728 | * Create a title for the axis
|
35729 | * @private
|
35730 | * @param {'top'|'right'|'bottom'|'left'} orientation
|
35731 | */
|
35732 |
|
35733 | }, {
|
35734 | key: "_redrawTitle",
|
35735 | value: function _redrawTitle(orientation) {
|
35736 | prepareElements(this.DOMelements.title); // Check if the title is defined for this axes
|
35737 |
|
35738 | if (this.options[orientation].title !== undefined && this.options[orientation].title.text !== undefined) {
|
35739 | var title = getDOMElement('div', this.DOMelements.title, this.dom.frame);
|
35740 | title.className = "vis-y-axis vis-title vis-".concat(orientation);
|
35741 | title.innerHTML = availableUtils.xss(this.options[orientation].title.text); // Add style - if provided
|
35742 |
|
35743 | if (this.options[orientation].title.style !== undefined) {
|
35744 | availableUtils.addCssText(title, this.options[orientation].title.style);
|
35745 | }
|
35746 |
|
35747 | if (orientation === 'left') {
|
35748 | title.style.left = "".concat(this.props.titleCharHeight, "px");
|
35749 | } else {
|
35750 | title.style.right = "".concat(this.props.titleCharHeight, "px");
|
35751 | }
|
35752 |
|
35753 | title.style.width = "".concat(this.height, "px");
|
35754 | } // we need to clean up in case we did not use all elements.
|
35755 |
|
35756 |
|
35757 | cleanupElements(this.DOMelements.title);
|
35758 | }
|
35759 | /**
|
35760 | * Determine the size of text on the axis (both major and minor axis).
|
35761 | * The size is calculated only once and then cached in this.props.
|
35762 | * @private
|
35763 | */
|
35764 |
|
35765 | }, {
|
35766 | key: "_calculateCharSize",
|
35767 | value: function _calculateCharSize() {
|
35768 | // determine the char width and height on the minor axis
|
35769 | if (!('minorCharHeight' in this.props)) {
|
35770 | var textMinor = document.createTextNode('0');
|
35771 | var measureCharMinor = document.createElement('div');
|
35772 | measureCharMinor.className = 'vis-y-axis vis-minor vis-measure';
|
35773 | measureCharMinor.appendChild(textMinor);
|
35774 | this.dom.frame.appendChild(measureCharMinor);
|
35775 | this.props.minorCharHeight = measureCharMinor.clientHeight;
|
35776 | this.props.minorCharWidth = measureCharMinor.clientWidth;
|
35777 | this.dom.frame.removeChild(measureCharMinor);
|
35778 | }
|
35779 |
|
35780 | if (!('majorCharHeight' in this.props)) {
|
35781 | var textMajor = document.createTextNode('0');
|
35782 | var measureCharMajor = document.createElement('div');
|
35783 | measureCharMajor.className = 'vis-y-axis vis-major vis-measure';
|
35784 | measureCharMajor.appendChild(textMajor);
|
35785 | this.dom.frame.appendChild(measureCharMajor);
|
35786 | this.props.majorCharHeight = measureCharMajor.clientHeight;
|
35787 | this.props.majorCharWidth = measureCharMajor.clientWidth;
|
35788 | this.dom.frame.removeChild(measureCharMajor);
|
35789 | }
|
35790 |
|
35791 | if (!('titleCharHeight' in this.props)) {
|
35792 | var textTitle = document.createTextNode('0');
|
35793 | var measureCharTitle = document.createElement('div');
|
35794 | measureCharTitle.className = 'vis-y-axis vis-title vis-measure';
|
35795 | measureCharTitle.appendChild(textTitle);
|
35796 | this.dom.frame.appendChild(measureCharTitle);
|
35797 | this.props.titleCharHeight = measureCharTitle.clientHeight;
|
35798 | this.props.titleCharWidth = measureCharTitle.clientWidth;
|
35799 | this.dom.frame.removeChild(measureCharTitle);
|
35800 | }
|
35801 | }
|
35802 | }]);
|
35803 |
|
35804 | return DataAxis;
|
35805 | }(Component);
|
35806 |
|
35807 | /**
|
35808 | *
|
35809 | * @param {number | string} groupId
|
35810 | * @param {Object} options // TODO: Describe options
|
35811 | *
|
35812 | * @constructor Points
|
35813 | */
|
35814 |
|
35815 | function Points(groupId, options) {// eslint-disable-line no-unused-vars
|
35816 | }
|
35817 | /**
|
35818 | * draw the data points
|
35819 | *
|
35820 | * @param {Array} dataset
|
35821 | * @param {GraphGroup} group
|
35822 | * @param {Object} framework | SVG DOM element
|
35823 | * @param {number} [offset]
|
35824 | */
|
35825 |
|
35826 |
|
35827 | Points.draw = function (dataset, group, framework, offset) {
|
35828 | offset = offset || 0;
|
35829 | var callback = getCallback(framework, group);
|
35830 |
|
35831 | for (var i = 0; i < dataset.length; i++) {
|
35832 | if (!callback) {
|
35833 | // draw the point the simple way.
|
35834 | drawPoint(dataset[i].screen_x + offset, dataset[i].screen_y, getGroupTemplate(group), framework.svgElements, framework.svg, dataset[i].label);
|
35835 | } else {
|
35836 | var callbackResult = callback(dataset[i], group); // result might be true, false or an object
|
35837 |
|
35838 | if (callbackResult === true || _typeof(callbackResult) === 'object') {
|
35839 | drawPoint(dataset[i].screen_x + offset, dataset[i].screen_y, getGroupTemplate(group, callbackResult), framework.svgElements, framework.svg, dataset[i].label);
|
35840 | }
|
35841 | }
|
35842 | }
|
35843 | };
|
35844 |
|
35845 | Points.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) {
|
35846 | var fillHeight = iconHeight * 0.5;
|
35847 | var outline = getSVGElement("rect", framework.svgElements, framework.svg);
|
35848 | outline.setAttributeNS(null, "x", x);
|
35849 | outline.setAttributeNS(null, "y", y - fillHeight);
|
35850 | outline.setAttributeNS(null, "width", iconWidth);
|
35851 | outline.setAttributeNS(null, "height", 2 * fillHeight);
|
35852 | outline.setAttributeNS(null, "class", "vis-outline"); //Don't call callback on icon
|
35853 |
|
35854 | drawPoint(x + 0.5 * iconWidth, y, getGroupTemplate(group), framework.svgElements, framework.svg);
|
35855 | };
|
35856 | /**
|
35857 | *
|
35858 | * @param {vis.Group} group
|
35859 | * @param {any} callbackResult
|
35860 | * @returns {{style: *, styles: (*|string), size: *, className: *}}
|
35861 | */
|
35862 |
|
35863 |
|
35864 | function getGroupTemplate(group, callbackResult) {
|
35865 | callbackResult = typeof callbackResult === 'undefined' ? {} : callbackResult;
|
35866 | return {
|
35867 | style: callbackResult.style || group.options.drawPoints.style,
|
35868 | styles: callbackResult.styles || group.options.drawPoints.styles,
|
35869 | size: callbackResult.size || group.options.drawPoints.size,
|
35870 | className: callbackResult.className || group.className
|
35871 | };
|
35872 | }
|
35873 | /**
|
35874 | *
|
35875 | * @param {Object} framework | SVG DOM element
|
35876 | * @param {vis.Group} group
|
35877 | * @returns {function}
|
35878 | */
|
35879 |
|
35880 |
|
35881 | function getCallback(framework, group) {
|
35882 | var callback = undefined; // check for the graph2d onRender
|
35883 |
|
35884 | if (framework.options && framework.options.drawPoints && framework.options.drawPoints.onRender && typeof framework.options.drawPoints.onRender == 'function') {
|
35885 | callback = framework.options.drawPoints.onRender;
|
35886 | } // override it with the group onRender if defined
|
35887 |
|
35888 |
|
35889 | if (group.group.options && group.group.options.drawPoints && group.group.options.drawPoints.onRender && typeof group.group.options.drawPoints.onRender == 'function') {
|
35890 | callback = group.group.options.drawPoints.onRender;
|
35891 | }
|
35892 |
|
35893 | return callback;
|
35894 | }
|
35895 |
|
35896 | /**
|
35897 | *
|
35898 | * @param {vis.GraphGroup.id} groupId
|
35899 | * @param {Object} options // TODO: Describe options
|
35900 | * @constructor Bargraph
|
35901 | */
|
35902 |
|
35903 | function Bargraph(groupId, options) {// eslint-disable-line no-unused-vars
|
35904 | }
|
35905 |
|
35906 | Bargraph.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) {
|
35907 | var fillHeight = iconHeight * 0.5;
|
35908 | var outline = getSVGElement("rect", framework.svgElements, framework.svg);
|
35909 | outline.setAttributeNS(null, "x", x);
|
35910 | outline.setAttributeNS(null, "y", y - fillHeight);
|
35911 | outline.setAttributeNS(null, "width", iconWidth);
|
35912 | outline.setAttributeNS(null, "height", 2 * fillHeight);
|
35913 | outline.setAttributeNS(null, "class", "vis-outline");
|
35914 | var barWidth = Math.round(0.3 * iconWidth);
|
35915 | var originalWidth = group.options.barChart.width;
|
35916 | var scale = originalWidth / barWidth;
|
35917 | var bar1Height = Math.round(0.4 * iconHeight);
|
35918 | var bar2Height = Math.round(0.75 * iconHeight);
|
35919 | var offset = Math.round((iconWidth - 2 * barWidth) / 3);
|
35920 | drawBar(x + 0.5 * barWidth + offset, y + fillHeight - bar1Height - 1, barWidth, bar1Height, group.className + ' vis-bar', framework.svgElements, framework.svg, group.style);
|
35921 | drawBar(x + 1.5 * barWidth + offset + 2, y + fillHeight - bar2Height - 1, barWidth, bar2Height, group.className + ' vis-bar', framework.svgElements, framework.svg, group.style);
|
35922 |
|
35923 | if (group.options.drawPoints.enabled == true) {
|
35924 | var groupTemplate = {
|
35925 | style: group.options.drawPoints.style,
|
35926 | styles: group.options.drawPoints.styles,
|
35927 | size: group.options.drawPoints.size / scale,
|
35928 | className: group.className
|
35929 | };
|
35930 | drawPoint(x + 0.5 * barWidth + offset, y + fillHeight - bar1Height - 1, groupTemplate, framework.svgElements, framework.svg);
|
35931 | drawPoint(x + 1.5 * barWidth + offset + 2, y + fillHeight - bar2Height - 1, groupTemplate, framework.svgElements, framework.svg);
|
35932 | }
|
35933 | };
|
35934 | /**
|
35935 | * draw a bar graph
|
35936 | *
|
35937 | * @param {Array.<vis.GraphGroup.id>} groupIds
|
35938 | * @param {Object} processedGroupData
|
35939 | * @param {{svg: Object, svgElements: Array.<Object>, options: Object, groups: Array.<vis.Group>}} framework
|
35940 | */
|
35941 |
|
35942 |
|
35943 | Bargraph.draw = function (groupIds, processedGroupData, framework) {
|
35944 | var combinedData = [];
|
35945 | var intersections = {};
|
35946 | var coreDistance;
|
35947 | var key, drawData;
|
35948 | var group;
|
35949 | var i, j;
|
35950 | var barPoints = 0; // combine all barchart data
|
35951 |
|
35952 | for (i = 0; i < groupIds.length; i++) {
|
35953 | group = framework.groups[groupIds[i]];
|
35954 |
|
35955 | if (group.options.style === 'bar') {
|
35956 | if (group.visible === true && (framework.options.groups.visibility[groupIds[i]] === undefined || framework.options.groups.visibility[groupIds[i]] === true)) {
|
35957 | for (j = 0; j < processedGroupData[groupIds[i]].length; j++) {
|
35958 | combinedData.push({
|
35959 | screen_x: processedGroupData[groupIds[i]][j].screen_x,
|
35960 | screen_end: processedGroupData[groupIds[i]][j].screen_end,
|
35961 | screen_y: processedGroupData[groupIds[i]][j].screen_y,
|
35962 | x: processedGroupData[groupIds[i]][j].x,
|
35963 | end: processedGroupData[groupIds[i]][j].end,
|
35964 | y: processedGroupData[groupIds[i]][j].y,
|
35965 | groupId: groupIds[i],
|
35966 | label: processedGroupData[groupIds[i]][j].label
|
35967 | });
|
35968 | barPoints += 1;
|
35969 | }
|
35970 | }
|
35971 | }
|
35972 | }
|
35973 |
|
35974 | if (barPoints === 0) {
|
35975 | return;
|
35976 | } // sort by time and by group
|
35977 |
|
35978 |
|
35979 | _sortInstanceProperty(combinedData).call(combinedData, function (a, b) {
|
35980 | if (a.screen_x === b.screen_x) {
|
35981 | return a.groupId < b.groupId ? -1 : 1;
|
35982 | } else {
|
35983 | return a.screen_x - b.screen_x;
|
35984 | }
|
35985 | }); // get intersections
|
35986 |
|
35987 |
|
35988 | Bargraph._getDataIntersections(intersections, combinedData); // plot barchart
|
35989 |
|
35990 |
|
35991 | for (i = 0; i < combinedData.length; i++) {
|
35992 | group = framework.groups[combinedData[i].groupId];
|
35993 | var minWidth = group.options.barChart.minWidth != undefined ? group.options.barChart.minWidth : 0.1 * group.options.barChart.width;
|
35994 | key = combinedData[i].screen_x;
|
35995 | var heightOffset = 0;
|
35996 |
|
35997 | if (intersections[key] === undefined) {
|
35998 | if (i + 1 < combinedData.length) {
|
35999 | coreDistance = Math.abs(combinedData[i + 1].screen_x - key);
|
36000 | }
|
36001 |
|
36002 | drawData = Bargraph._getSafeDrawData(coreDistance, group, minWidth);
|
36003 | } else {
|
36004 | var nextKey = i + (intersections[key].amount - intersections[key].resolved);
|
36005 |
|
36006 | if (nextKey < combinedData.length) {
|
36007 | coreDistance = Math.abs(combinedData[nextKey].screen_x - key);
|
36008 | }
|
36009 |
|
36010 | drawData = Bargraph._getSafeDrawData(coreDistance, group, minWidth);
|
36011 | intersections[key].resolved += 1;
|
36012 |
|
36013 | if (group.options.stack === true && group.options.excludeFromStacking !== true) {
|
36014 | if (combinedData[i].screen_y < group.zeroPosition) {
|
36015 | heightOffset = intersections[key].accumulatedNegative;
|
36016 | intersections[key].accumulatedNegative += group.zeroPosition - combinedData[i].screen_y;
|
36017 | } else {
|
36018 | heightOffset = intersections[key].accumulatedPositive;
|
36019 | intersections[key].accumulatedPositive += group.zeroPosition - combinedData[i].screen_y;
|
36020 | }
|
36021 | } else if (group.options.barChart.sideBySide === true) {
|
36022 | drawData.width = drawData.width / intersections[key].amount;
|
36023 | drawData.offset += intersections[key].resolved * drawData.width - 0.5 * drawData.width * (intersections[key].amount + 1);
|
36024 | }
|
36025 | }
|
36026 |
|
36027 | var dataWidth = drawData.width;
|
36028 | var start = combinedData[i].screen_x; // are we drawing explicit boxes? (we supplied an end value)
|
36029 |
|
36030 | if (combinedData[i].screen_end != undefined) {
|
36031 | dataWidth = combinedData[i].screen_end - combinedData[i].screen_x;
|
36032 | start += dataWidth * 0.5;
|
36033 | } else {
|
36034 | start += drawData.offset;
|
36035 | }
|
36036 |
|
36037 | drawBar(start, combinedData[i].screen_y - heightOffset, dataWidth, group.zeroPosition - combinedData[i].screen_y, group.className + ' vis-bar', framework.svgElements, framework.svg, group.style); // draw points
|
36038 |
|
36039 | if (group.options.drawPoints.enabled === true) {
|
36040 | var pointData = {
|
36041 | screen_x: combinedData[i].screen_x,
|
36042 | screen_y: combinedData[i].screen_y - heightOffset,
|
36043 | x: combinedData[i].x,
|
36044 | y: combinedData[i].y,
|
36045 | groupId: combinedData[i].groupId,
|
36046 | label: combinedData[i].label
|
36047 | };
|
36048 | Points.draw([pointData], group, framework, drawData.offset); //DOMutil.drawPoint(combinedData[i].x + drawData.offset, combinedData[i].y, group, framework.svgElements, framework.svg);
|
36049 | }
|
36050 | }
|
36051 | };
|
36052 | /**
|
36053 | * Fill the intersections object with counters of how many datapoints share the same x coordinates
|
36054 | * @param {Object} intersections
|
36055 | * @param {Array.<Object>} combinedData
|
36056 | * @private
|
36057 | */
|
36058 |
|
36059 |
|
36060 | Bargraph._getDataIntersections = function (intersections, combinedData) {
|
36061 | // get intersections
|
36062 | var coreDistance;
|
36063 |
|
36064 | for (var i = 0; i < combinedData.length; i++) {
|
36065 | if (i + 1 < combinedData.length) {
|
36066 | coreDistance = Math.abs(combinedData[i + 1].screen_x - combinedData[i].screen_x);
|
36067 | }
|
36068 |
|
36069 | if (i > 0) {
|
36070 | coreDistance = Math.min(coreDistance, Math.abs(combinedData[i - 1].screen_x - combinedData[i].screen_x));
|
36071 | }
|
36072 |
|
36073 | if (coreDistance === 0) {
|
36074 | if (intersections[combinedData[i].screen_x] === undefined) {
|
36075 | intersections[combinedData[i].screen_x] = {
|
36076 | amount: 0,
|
36077 | resolved: 0,
|
36078 | accumulatedPositive: 0,
|
36079 | accumulatedNegative: 0
|
36080 | };
|
36081 | }
|
36082 |
|
36083 | intersections[combinedData[i].screen_x].amount += 1;
|
36084 | }
|
36085 | }
|
36086 | };
|
36087 | /**
|
36088 | * Get the width and offset for bargraphs based on the coredistance between datapoints
|
36089 | *
|
36090 | * @param {number} coreDistance
|
36091 | * @param {vis.Group} group
|
36092 | * @param {number} minWidth
|
36093 | * @returns {{width: number, offset: number}}
|
36094 | * @private
|
36095 | */
|
36096 |
|
36097 |
|
36098 | Bargraph._getSafeDrawData = function (coreDistance, group, minWidth) {
|
36099 | var width, offset;
|
36100 |
|
36101 | if (coreDistance < group.options.barChart.width && coreDistance > 0) {
|
36102 | width = coreDistance < minWidth ? minWidth : coreDistance;
|
36103 | offset = 0; // recalculate offset with the new width;
|
36104 |
|
36105 | if (group.options.barChart.align === 'left') {
|
36106 | offset -= 0.5 * coreDistance;
|
36107 | } else if (group.options.barChart.align === 'right') {
|
36108 | offset += 0.5 * coreDistance;
|
36109 | }
|
36110 | } else {
|
36111 | // default settings
|
36112 | width = group.options.barChart.width;
|
36113 | offset = 0;
|
36114 |
|
36115 | if (group.options.barChart.align === 'left') {
|
36116 | offset -= 0.5 * group.options.barChart.width;
|
36117 | } else if (group.options.barChart.align === 'right') {
|
36118 | offset += 0.5 * group.options.barChart.width;
|
36119 | }
|
36120 | }
|
36121 |
|
36122 | return {
|
36123 | width: width,
|
36124 | offset: offset
|
36125 | };
|
36126 | };
|
36127 |
|
36128 | Bargraph.getStackedYRange = function (combinedData, groupRanges, groupIds, groupLabel, orientation) {
|
36129 | if (combinedData.length > 0) {
|
36130 | // sort by time and by group
|
36131 | _sortInstanceProperty(combinedData).call(combinedData, function (a, b) {
|
36132 | if (a.screen_x === b.screen_x) {
|
36133 | return a.groupId < b.groupId ? -1 : 1;
|
36134 | } else {
|
36135 | return a.screen_x - b.screen_x;
|
36136 | }
|
36137 | });
|
36138 |
|
36139 | var intersections = {};
|
36140 |
|
36141 | Bargraph._getDataIntersections(intersections, combinedData);
|
36142 |
|
36143 | groupRanges[groupLabel] = Bargraph._getStackedYRange(intersections, combinedData);
|
36144 | groupRanges[groupLabel].yAxisOrientation = orientation;
|
36145 | groupIds.push(groupLabel);
|
36146 | }
|
36147 | };
|
36148 |
|
36149 | Bargraph._getStackedYRange = function (intersections, combinedData) {
|
36150 | var key;
|
36151 | var yMin = combinedData[0].screen_y;
|
36152 | var yMax = combinedData[0].screen_y;
|
36153 |
|
36154 | for (var i = 0; i < combinedData.length; i++) {
|
36155 | key = combinedData[i].screen_x;
|
36156 |
|
36157 | if (intersections[key] === undefined) {
|
36158 | yMin = yMin > combinedData[i].screen_y ? combinedData[i].screen_y : yMin;
|
36159 | yMax = yMax < combinedData[i].screen_y ? combinedData[i].screen_y : yMax;
|
36160 | } else {
|
36161 | if (combinedData[i].screen_y < 0) {
|
36162 | intersections[key].accumulatedNegative += combinedData[i].screen_y;
|
36163 | } else {
|
36164 | intersections[key].accumulatedPositive += combinedData[i].screen_y;
|
36165 | }
|
36166 | }
|
36167 | }
|
36168 |
|
36169 | for (var xpos in intersections) {
|
36170 | if (intersections.hasOwnProperty(xpos)) {
|
36171 | yMin = yMin > intersections[xpos].accumulatedNegative ? intersections[xpos].accumulatedNegative : yMin;
|
36172 | yMin = yMin > intersections[xpos].accumulatedPositive ? intersections[xpos].accumulatedPositive : yMin;
|
36173 | yMax = yMax < intersections[xpos].accumulatedNegative ? intersections[xpos].accumulatedNegative : yMax;
|
36174 | yMax = yMax < intersections[xpos].accumulatedPositive ? intersections[xpos].accumulatedPositive : yMax;
|
36175 | }
|
36176 | }
|
36177 |
|
36178 | return {
|
36179 | min: yMin,
|
36180 | max: yMax
|
36181 | };
|
36182 | };
|
36183 |
|
36184 | /**
|
36185 | *
|
36186 | * @param {vis.GraphGroup.id} groupId
|
36187 | * @param {Object} options // TODO: Describe options
|
36188 | * @constructor Line
|
36189 | */
|
36190 |
|
36191 | function Line(groupId, options) {// eslint-disable-line no-unused-vars
|
36192 | }
|
36193 |
|
36194 | Line.calcPath = function (dataset, group) {
|
36195 | if (dataset != null) {
|
36196 | if (dataset.length > 0) {
|
36197 | var d = []; // construct path from dataset
|
36198 |
|
36199 | if (group.options.interpolation.enabled == true) {
|
36200 | d = Line._catmullRom(dataset, group);
|
36201 | } else {
|
36202 | d = Line._linear(dataset);
|
36203 | }
|
36204 |
|
36205 | return d;
|
36206 | }
|
36207 | }
|
36208 | };
|
36209 |
|
36210 | Line.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) {
|
36211 | var fillHeight = iconHeight * 0.5;
|
36212 | var path, fillPath;
|
36213 | var outline = getSVGElement("rect", framework.svgElements, framework.svg);
|
36214 | outline.setAttributeNS(null, "x", x);
|
36215 | outline.setAttributeNS(null, "y", y - fillHeight);
|
36216 | outline.setAttributeNS(null, "width", iconWidth);
|
36217 | outline.setAttributeNS(null, "height", 2 * fillHeight);
|
36218 | outline.setAttributeNS(null, "class", "vis-outline");
|
36219 | path = getSVGElement("path", framework.svgElements, framework.svg);
|
36220 | path.setAttributeNS(null, "class", group.className);
|
36221 |
|
36222 | if (group.style !== undefined) {
|
36223 | path.setAttributeNS(null, "style", group.style);
|
36224 | }
|
36225 |
|
36226 | path.setAttributeNS(null, "d", "M" + x + "," + y + " L" + (x + iconWidth) + "," + y + "");
|
36227 |
|
36228 | if (group.options.shaded.enabled == true) {
|
36229 | fillPath = getSVGElement("path", framework.svgElements, framework.svg);
|
36230 |
|
36231 | if (group.options.shaded.orientation == 'top') {
|
36232 | fillPath.setAttributeNS(null, "d", "M" + x + ", " + (y - fillHeight) + "L" + x + "," + y + " L" + (x + iconWidth) + "," + y + " L" + (x + iconWidth) + "," + (y - fillHeight));
|
36233 | } else {
|
36234 | fillPath.setAttributeNS(null, "d", "M" + x + "," + y + " " + "L" + x + "," + (y + fillHeight) + " " + "L" + (x + iconWidth) + "," + (y + fillHeight) + "L" + (x + iconWidth) + "," + y);
|
36235 | }
|
36236 |
|
36237 | fillPath.setAttributeNS(null, "class", group.className + " vis-icon-fill");
|
36238 |
|
36239 | if (group.options.shaded.style !== undefined && group.options.shaded.style !== "") {
|
36240 | fillPath.setAttributeNS(null, "style", group.options.shaded.style);
|
36241 | }
|
36242 | }
|
36243 |
|
36244 | if (group.options.drawPoints.enabled == true) {
|
36245 | var groupTemplate = {
|
36246 | style: group.options.drawPoints.style,
|
36247 | styles: group.options.drawPoints.styles,
|
36248 | size: group.options.drawPoints.size,
|
36249 | className: group.className
|
36250 | };
|
36251 | drawPoint(x + 0.5 * iconWidth, y, groupTemplate, framework.svgElements, framework.svg);
|
36252 | }
|
36253 | };
|
36254 |
|
36255 | Line.drawShading = function (pathArray, group, subPathArray, framework) {
|
36256 | // append shading to the path
|
36257 | if (group.options.shaded.enabled == true) {
|
36258 | var svgHeight = Number(framework.svg.style.height.replace('px', ''));
|
36259 | var fillPath = getSVGElement('path', framework.svgElements, framework.svg);
|
36260 | var type = "L";
|
36261 |
|
36262 | if (group.options.interpolation.enabled == true) {
|
36263 | type = "C";
|
36264 | }
|
36265 |
|
36266 | var dFill;
|
36267 | var zero = 0;
|
36268 |
|
36269 | if (group.options.shaded.orientation == 'top') {
|
36270 | zero = 0;
|
36271 | } else if (group.options.shaded.orientation == 'bottom') {
|
36272 | zero = svgHeight;
|
36273 | } else {
|
36274 | zero = Math.min(Math.max(0, group.zeroPosition), svgHeight);
|
36275 | }
|
36276 |
|
36277 | if (group.options.shaded.orientation == 'group' && subPathArray != null && subPathArray != undefined) {
|
36278 | dFill = 'M' + pathArray[0][0] + "," + pathArray[0][1] + " " + this.serializePath(pathArray, type, false) + ' L' + subPathArray[subPathArray.length - 1][0] + "," + subPathArray[subPathArray.length - 1][1] + " " + this.serializePath(subPathArray, type, true) + subPathArray[0][0] + "," + subPathArray[0][1] + " Z";
|
36279 | } else {
|
36280 | dFill = 'M' + pathArray[0][0] + "," + pathArray[0][1] + " " + this.serializePath(pathArray, type, false) + ' V' + zero + ' H' + pathArray[0][0] + " Z";
|
36281 | }
|
36282 |
|
36283 | fillPath.setAttributeNS(null, 'class', group.className + ' vis-fill');
|
36284 |
|
36285 | if (group.options.shaded.style !== undefined) {
|
36286 | fillPath.setAttributeNS(null, 'style', group.options.shaded.style);
|
36287 | }
|
36288 |
|
36289 | fillPath.setAttributeNS(null, 'd', dFill);
|
36290 | }
|
36291 | };
|
36292 | /**
|
36293 | * draw a line graph
|
36294 | *
|
36295 | * @param {Array.<Object>} pathArray
|
36296 | * @param {vis.Group} group
|
36297 | * @param {{svg: Object, svgElements: Array.<Object>, options: Object, groups: Array.<vis.Group>}} framework
|
36298 | */
|
36299 |
|
36300 |
|
36301 | Line.draw = function (pathArray, group, framework) {
|
36302 | if (pathArray != null && pathArray != undefined) {
|
36303 | var path = getSVGElement('path', framework.svgElements, framework.svg);
|
36304 | path.setAttributeNS(null, "class", group.className);
|
36305 |
|
36306 | if (group.style !== undefined) {
|
36307 | path.setAttributeNS(null, "style", group.style);
|
36308 | }
|
36309 |
|
36310 | var type = "L";
|
36311 |
|
36312 | if (group.options.interpolation.enabled == true) {
|
36313 | type = "C";
|
36314 | } // copy properties to path for drawing.
|
36315 |
|
36316 |
|
36317 | path.setAttributeNS(null, 'd', 'M' + pathArray[0][0] + "," + pathArray[0][1] + " " + this.serializePath(pathArray, type, false));
|
36318 | }
|
36319 | };
|
36320 |
|
36321 | Line.serializePath = function (pathArray, type, inverse) {
|
36322 | if (pathArray.length < 2) {
|
36323 | //Too little data to create a path.
|
36324 | return "";
|
36325 | }
|
36326 |
|
36327 | var d = type;
|
36328 | var i;
|
36329 |
|
36330 | if (inverse) {
|
36331 | for (i = pathArray.length - 2; i > 0; i--) {
|
36332 | d += pathArray[i][0] + "," + pathArray[i][1] + " ";
|
36333 | }
|
36334 | } else {
|
36335 | for (i = 1; i < pathArray.length; i++) {
|
36336 | d += pathArray[i][0] + "," + pathArray[i][1] + " ";
|
36337 | }
|
36338 | }
|
36339 |
|
36340 | return d;
|
36341 | };
|
36342 | /**
|
36343 | * This uses an uniform parametrization of the interpolation algorithm:
|
36344 | * 'On the Parameterization of Catmull-Rom Curves' by Cem Yuksel et al.
|
36345 | * @param {Array.<Object>} data
|
36346 | * @returns {string}
|
36347 | * @private
|
36348 | */
|
36349 |
|
36350 |
|
36351 | Line._catmullRomUniform = function (data) {
|
36352 | // catmull rom
|
36353 | var p0, p1, p2, p3, bp1, bp2;
|
36354 | var d = [];
|
36355 | d.push([Math.round(data[0].screen_x), Math.round(data[0].screen_y)]);
|
36356 | var normalization = 1 / 6;
|
36357 | var length = data.length;
|
36358 |
|
36359 | for (var i = 0; i < length - 1; i++) {
|
36360 | p0 = i == 0 ? data[0] : data[i - 1];
|
36361 | p1 = data[i];
|
36362 | p2 = data[i + 1];
|
36363 | p3 = i + 2 < length ? data[i + 2] : p2; // Catmull-Rom to Cubic Bezier conversion matrix
|
36364 | // 0 1 0 0
|
36365 | // -1/6 1 1/6 0
|
36366 | // 0 1/6 1 -1/6
|
36367 | // 0 0 1 0
|
36368 | // bp0 = { x: p1.x, y: p1.y };
|
36369 |
|
36370 | bp1 = {
|
36371 | screen_x: (-p0.screen_x + 6 * p1.screen_x + p2.screen_x) * normalization,
|
36372 | screen_y: (-p0.screen_y + 6 * p1.screen_y + p2.screen_y) * normalization
|
36373 | };
|
36374 | bp2 = {
|
36375 | screen_x: (p1.screen_x + 6 * p2.screen_x - p3.screen_x) * normalization,
|
36376 | screen_y: (p1.screen_y + 6 * p2.screen_y - p3.screen_y) * normalization
|
36377 | }; // bp0 = { x: p2.x, y: p2.y };
|
36378 |
|
36379 | d.push([bp1.screen_x, bp1.screen_y]);
|
36380 | d.push([bp2.screen_x, bp2.screen_y]);
|
36381 | d.push([p2.screen_x, p2.screen_y]);
|
36382 | }
|
36383 |
|
36384 | return d;
|
36385 | };
|
36386 | /**
|
36387 | * This uses either the chordal or centripetal parameterization of the catmull-rom algorithm.
|
36388 | * By default, the centripetal parameterization is used because this gives the nicest results.
|
36389 | * These parameterizations are relatively heavy because the distance between 4 points have to be calculated.
|
36390 | *
|
36391 | * One optimization can be used to reuse distances since this is a sliding window approach.
|
36392 | * @param {Array.<Object>} data
|
36393 | * @param {vis.GraphGroup} group
|
36394 | * @returns {string}
|
36395 | * @private
|
36396 | */
|
36397 |
|
36398 |
|
36399 | Line._catmullRom = function (data, group) {
|
36400 | var alpha = group.options.interpolation.alpha;
|
36401 |
|
36402 | if (alpha == 0 || alpha === undefined) {
|
36403 | return this._catmullRomUniform(data);
|
36404 | } else {
|
36405 | var p0, p1, p2, p3, bp1, bp2, d1, d2, d3, A, B, N, M;
|
36406 | var d3powA, d2powA, d3pow2A, d2pow2A, d1pow2A, d1powA;
|
36407 | var d = [];
|
36408 | d.push([Math.round(data[0].screen_x), Math.round(data[0].screen_y)]);
|
36409 | var length = data.length;
|
36410 |
|
36411 | for (var i = 0; i < length - 1; i++) {
|
36412 | p0 = i == 0 ? data[0] : data[i - 1];
|
36413 | p1 = data[i];
|
36414 | p2 = data[i + 1];
|
36415 | p3 = i + 2 < length ? data[i + 2] : p2;
|
36416 | d1 = Math.sqrt(Math.pow(p0.screen_x - p1.screen_x, 2) + Math.pow(p0.screen_y - p1.screen_y, 2));
|
36417 | d2 = Math.sqrt(Math.pow(p1.screen_x - p2.screen_x, 2) + Math.pow(p1.screen_y - p2.screen_y, 2));
|
36418 | d3 = Math.sqrt(Math.pow(p2.screen_x - p3.screen_x, 2) + Math.pow(p2.screen_y - p3.screen_y, 2)); // Catmull-Rom to Cubic Bezier conversion matrix
|
36419 | // A = 2d1^2a + 3d1^a * d2^a + d3^2a
|
36420 | // B = 2d3^2a + 3d3^a * d2^a + d2^2a
|
36421 | // [ 0 1 0 0 ]
|
36422 | // [ -d2^2a /N A/N d1^2a /N 0 ]
|
36423 | // [ 0 d3^2a /M B/M -d2^2a /M ]
|
36424 | // [ 0 0 1 0 ]
|
36425 |
|
36426 | d3powA = Math.pow(d3, alpha);
|
36427 | d3pow2A = Math.pow(d3, 2 * alpha);
|
36428 | d2powA = Math.pow(d2, alpha);
|
36429 | d2pow2A = Math.pow(d2, 2 * alpha);
|
36430 | d1powA = Math.pow(d1, alpha);
|
36431 | d1pow2A = Math.pow(d1, 2 * alpha);
|
36432 | A = 2 * d1pow2A + 3 * d1powA * d2powA + d2pow2A;
|
36433 | B = 2 * d3pow2A + 3 * d3powA * d2powA + d2pow2A;
|
36434 | N = 3 * d1powA * (d1powA + d2powA);
|
36435 |
|
36436 | if (N > 0) {
|
36437 | N = 1 / N;
|
36438 | }
|
36439 |
|
36440 | M = 3 * d3powA * (d3powA + d2powA);
|
36441 |
|
36442 | if (M > 0) {
|
36443 | M = 1 / M;
|
36444 | }
|
36445 |
|
36446 | bp1 = {
|
36447 | screen_x: (-d2pow2A * p0.screen_x + A * p1.screen_x + d1pow2A * p2.screen_x) * N,
|
36448 | screen_y: (-d2pow2A * p0.screen_y + A * p1.screen_y + d1pow2A * p2.screen_y) * N
|
36449 | };
|
36450 | bp2 = {
|
36451 | screen_x: (d3pow2A * p1.screen_x + B * p2.screen_x - d2pow2A * p3.screen_x) * M,
|
36452 | screen_y: (d3pow2A * p1.screen_y + B * p2.screen_y - d2pow2A * p3.screen_y) * M
|
36453 | };
|
36454 |
|
36455 | if (bp1.screen_x == 0 && bp1.screen_y == 0) {
|
36456 | bp1 = p1;
|
36457 | }
|
36458 |
|
36459 | if (bp2.screen_x == 0 && bp2.screen_y == 0) {
|
36460 | bp2 = p2;
|
36461 | }
|
36462 |
|
36463 | d.push([bp1.screen_x, bp1.screen_y]);
|
36464 | d.push([bp2.screen_x, bp2.screen_y]);
|
36465 | d.push([p2.screen_x, p2.screen_y]);
|
36466 | }
|
36467 |
|
36468 | return d;
|
36469 | }
|
36470 | };
|
36471 | /**
|
36472 | * this generates the SVG path for a linear drawing between datapoints.
|
36473 | * @param {Array.<Object>} data
|
36474 | * @returns {string}
|
36475 | * @private
|
36476 | */
|
36477 |
|
36478 |
|
36479 | Line._linear = function (data) {
|
36480 | // linear
|
36481 | var d = [];
|
36482 |
|
36483 | for (var i = 0; i < data.length; i++) {
|
36484 | d.push([data[i].screen_x, data[i].screen_y]);
|
36485 | }
|
36486 |
|
36487 | return d;
|
36488 | };
|
36489 |
|
36490 | /**
|
36491 | * /**
|
36492 | * @param {object} group | the object of the group from the dataset
|
36493 | * @param {string} groupId | ID of the group
|
36494 | * @param {object} options | the default options
|
36495 | * @param {array} groupsUsingDefaultStyles | this array has one entree.
|
36496 | * It is passed as an array so it is passed by reference.
|
36497 | * It enumerates through the default styles
|
36498 | * @constructor GraphGroup
|
36499 | */
|
36500 |
|
36501 | function GraphGroup(group, groupId, options, groupsUsingDefaultStyles) {
|
36502 | this.id = groupId;
|
36503 | var fields = ['sampling', 'style', 'sort', 'yAxisOrientation', 'barChart', 'drawPoints', 'shaded', 'interpolation', 'zIndex', 'excludeFromStacking', 'excludeFromLegend'];
|
36504 | this.options = availableUtils.selectiveBridgeObject(fields, options);
|
36505 | this.usingDefaultStyle = group.className === undefined;
|
36506 | this.groupsUsingDefaultStyles = groupsUsingDefaultStyles;
|
36507 | this.zeroPosition = 0;
|
36508 | this.update(group);
|
36509 |
|
36510 | if (this.usingDefaultStyle == true) {
|
36511 | this.groupsUsingDefaultStyles[0] += 1;
|
36512 | }
|
36513 |
|
36514 | this.itemsData = [];
|
36515 | this.visible = group.visible === undefined ? true : group.visible;
|
36516 | }
|
36517 | /**
|
36518 | * this loads a reference to all items in this group into this group.
|
36519 | * @param {array} items
|
36520 | */
|
36521 |
|
36522 |
|
36523 | GraphGroup.prototype.setItems = function (items) {
|
36524 | if (items != null) {
|
36525 | this.itemsData = items;
|
36526 |
|
36527 | if (_sortInstanceProperty(this.options) == true) {
|
36528 | availableUtils.insertSort(this.itemsData, function (a, b) {
|
36529 | return a.x > b.x ? 1 : -1;
|
36530 | });
|
36531 | }
|
36532 | } else {
|
36533 | this.itemsData = [];
|
36534 | }
|
36535 | };
|
36536 |
|
36537 | GraphGroup.prototype.getItems = function () {
|
36538 | return this.itemsData;
|
36539 | };
|
36540 | /**
|
36541 | * this is used for barcharts and shading, this way, we only have to calculate it once.
|
36542 | * @param {number} pos
|
36543 | */
|
36544 |
|
36545 |
|
36546 | GraphGroup.prototype.setZeroPosition = function (pos) {
|
36547 | this.zeroPosition = pos;
|
36548 | };
|
36549 | /**
|
36550 | * set the options of the graph group over the default options.
|
36551 | * @param {Object} options
|
36552 | */
|
36553 |
|
36554 |
|
36555 | GraphGroup.prototype.setOptions = function (options) {
|
36556 | if (options !== undefined) {
|
36557 | var fields = ['sampling', 'style', 'sort', 'yAxisOrientation', 'barChart', 'zIndex', 'excludeFromStacking', 'excludeFromLegend'];
|
36558 | availableUtils.selectiveDeepExtend(fields, this.options, options); // if the group's drawPoints is a function delegate the callback to the onRender property
|
36559 |
|
36560 | if (typeof options.drawPoints == 'function') {
|
36561 | options.drawPoints = {
|
36562 | onRender: options.drawPoints
|
36563 | };
|
36564 | }
|
36565 |
|
36566 | availableUtils.mergeOptions(this.options, options, 'interpolation');
|
36567 | availableUtils.mergeOptions(this.options, options, 'drawPoints');
|
36568 | availableUtils.mergeOptions(this.options, options, 'shaded');
|
36569 |
|
36570 | if (options.interpolation) {
|
36571 | if (_typeof(options.interpolation) == 'object') {
|
36572 | if (options.interpolation.parametrization) {
|
36573 | if (options.interpolation.parametrization == 'uniform') {
|
36574 | this.options.interpolation.alpha = 0;
|
36575 | } else if (options.interpolation.parametrization == 'chordal') {
|
36576 | this.options.interpolation.alpha = 1.0;
|
36577 | } else {
|
36578 | this.options.interpolation.parametrization = 'centripetal';
|
36579 | this.options.interpolation.alpha = 0.5;
|
36580 | }
|
36581 | }
|
36582 | }
|
36583 | }
|
36584 | }
|
36585 | };
|
36586 | /**
|
36587 | * this updates the current group class with the latest group dataset entree, used in _updateGroup in linegraph
|
36588 | * @param {vis.Group} group
|
36589 | */
|
36590 |
|
36591 |
|
36592 | GraphGroup.prototype.update = function (group) {
|
36593 | this.group = group;
|
36594 | this.content = group.content || 'graph';
|
36595 | this.className = group.className || this.className || 'vis-graph-group' + this.groupsUsingDefaultStyles[0] % 10;
|
36596 | this.visible = group.visible === undefined ? true : group.visible;
|
36597 | this.style = group.style;
|
36598 | this.setOptions(group.options);
|
36599 | };
|
36600 | /**
|
36601 | * return the legend entree for this group.
|
36602 | *
|
36603 | * @param {number} iconWidth
|
36604 | * @param {number} iconHeight
|
36605 | * @param {{svg: (*|Element), svgElements: Object, options: Object, groups: Array.<Object>}} framework
|
36606 | * @param {number} x
|
36607 | * @param {number} y
|
36608 | * @returns {{icon: (*|Element), label: (*|string), orientation: *}}
|
36609 | */
|
36610 |
|
36611 |
|
36612 | GraphGroup.prototype.getLegend = function (iconWidth, iconHeight, framework, x, y) {
|
36613 | if (framework == undefined || framework == null) {
|
36614 | var svg = document.createElementNS('http://www.w3.org/2000/svg', "svg");
|
36615 | framework = {
|
36616 | svg: svg,
|
36617 | svgElements: {},
|
36618 | options: this.options,
|
36619 | groups: [this]
|
36620 | };
|
36621 | }
|
36622 |
|
36623 | if (x == undefined || x == null) {
|
36624 | x = 0;
|
36625 | }
|
36626 |
|
36627 | if (y == undefined || y == null) {
|
36628 | y = 0.5 * iconHeight;
|
36629 | }
|
36630 |
|
36631 | switch (this.options.style) {
|
36632 | case "line":
|
36633 | Line.drawIcon(this, x, y, iconWidth, iconHeight, framework);
|
36634 | break;
|
36635 |
|
36636 | case "points": //explicit no break
|
36637 |
|
36638 | case "point":
|
36639 | Points.drawIcon(this, x, y, iconWidth, iconHeight, framework);
|
36640 | break;
|
36641 |
|
36642 | case "bar":
|
36643 | Bargraph.drawIcon(this, x, y, iconWidth, iconHeight, framework);
|
36644 | break;
|
36645 | }
|
36646 |
|
36647 | return {
|
36648 | icon: framework.svg,
|
36649 | label: this.content,
|
36650 | orientation: this.options.yAxisOrientation
|
36651 | };
|
36652 | };
|
36653 |
|
36654 | GraphGroup.prototype.getYRange = function (groupData) {
|
36655 | var yMin = groupData[0].y;
|
36656 | var yMax = groupData[0].y;
|
36657 |
|
36658 | for (var j = 0; j < groupData.length; j++) {
|
36659 | yMin = yMin > groupData[j].y ? groupData[j].y : yMin;
|
36660 | yMax = yMax < groupData[j].y ? groupData[j].y : yMax;
|
36661 | }
|
36662 |
|
36663 | return {
|
36664 | min: yMin,
|
36665 | max: yMax,
|
36666 | yAxisOrientation: this.options.yAxisOrientation
|
36667 | };
|
36668 | };
|
36669 |
|
36670 | /**
|
36671 | * Legend for Graph2d
|
36672 | *
|
36673 | * @param {vis.Graph2d.body} body
|
36674 | * @param {vis.Graph2d.options} options
|
36675 | * @param {number} side
|
36676 | * @param {vis.LineGraph.options} linegraphOptions
|
36677 | * @constructor Legend
|
36678 | * @extends Component
|
36679 | */
|
36680 |
|
36681 | function Legend(body, options, side, linegraphOptions) {
|
36682 | this.body = body;
|
36683 | this.defaultOptions = {
|
36684 | enabled: false,
|
36685 | icons: true,
|
36686 | iconSize: 20,
|
36687 | iconSpacing: 6,
|
36688 | left: {
|
36689 | visible: true,
|
36690 | position: 'top-left' // top/bottom - left,center,right
|
36691 |
|
36692 | },
|
36693 | right: {
|
36694 | visible: true,
|
36695 | position: 'top-right' // top/bottom - left,center,right
|
36696 |
|
36697 | }
|
36698 | };
|
36699 | this.side = side;
|
36700 | this.options = availableUtils.extend({}, this.defaultOptions);
|
36701 | this.linegraphOptions = linegraphOptions;
|
36702 | this.svgElements = {};
|
36703 | this.dom = {};
|
36704 | this.groups = {};
|
36705 | this.amountOfGroups = 0;
|
36706 |
|
36707 | this._create();
|
36708 |
|
36709 | this.framework = {
|
36710 | svg: this.svg,
|
36711 | svgElements: this.svgElements,
|
36712 | options: this.options,
|
36713 | groups: this.groups
|
36714 | };
|
36715 | this.setOptions(options);
|
36716 | }
|
36717 |
|
36718 | Legend.prototype = new Component();
|
36719 |
|
36720 | Legend.prototype.clear = function () {
|
36721 | this.groups = {};
|
36722 | this.amountOfGroups = 0;
|
36723 | };
|
36724 |
|
36725 | Legend.prototype.addGroup = function (label, graphOptions) {
|
36726 | // Include a group only if the group option 'excludeFromLegend: false' is not set.
|
36727 | if (graphOptions.options.excludeFromLegend != true) {
|
36728 | if (!this.groups.hasOwnProperty(label)) {
|
36729 | this.groups[label] = graphOptions;
|
36730 | }
|
36731 |
|
36732 | this.amountOfGroups += 1;
|
36733 | }
|
36734 | };
|
36735 |
|
36736 | Legend.prototype.updateGroup = function (label, graphOptions) {
|
36737 | this.groups[label] = graphOptions;
|
36738 | };
|
36739 |
|
36740 | Legend.prototype.removeGroup = function (label) {
|
36741 | if (this.groups.hasOwnProperty(label)) {
|
36742 | delete this.groups[label];
|
36743 | this.amountOfGroups -= 1;
|
36744 | }
|
36745 | };
|
36746 |
|
36747 | Legend.prototype._create = function () {
|
36748 | this.dom.frame = document.createElement('div');
|
36749 | this.dom.frame.className = 'vis-legend';
|
36750 | this.dom.frame.style.position = "absolute";
|
36751 | this.dom.frame.style.top = "10px";
|
36752 | this.dom.frame.style.display = "block";
|
36753 | this.dom.textArea = document.createElement('div');
|
36754 | this.dom.textArea.className = 'vis-legend-text';
|
36755 | this.dom.textArea.style.position = "relative";
|
36756 | this.dom.textArea.style.top = "0px";
|
36757 | this.svg = document.createElementNS('http://www.w3.org/2000/svg', "svg");
|
36758 | this.svg.style.position = 'absolute';
|
36759 | this.svg.style.top = 0 + 'px';
|
36760 | this.svg.style.width = this.options.iconSize + 5 + 'px';
|
36761 | this.svg.style.height = '100%';
|
36762 | this.dom.frame.appendChild(this.svg);
|
36763 | this.dom.frame.appendChild(this.dom.textArea);
|
36764 | };
|
36765 | /**
|
36766 | * Hide the component from the DOM
|
36767 | */
|
36768 |
|
36769 |
|
36770 | Legend.prototype.hide = function () {
|
36771 | // remove the frame containing the items
|
36772 | if (this.dom.frame.parentNode) {
|
36773 | this.dom.frame.parentNode.removeChild(this.dom.frame);
|
36774 | }
|
36775 | };
|
36776 | /**
|
36777 | * Show the component in the DOM (when not already visible).
|
36778 | */
|
36779 |
|
36780 |
|
36781 | Legend.prototype.show = function () {
|
36782 | // show frame containing the items
|
36783 | if (!this.dom.frame.parentNode) {
|
36784 | this.body.dom.center.appendChild(this.dom.frame);
|
36785 | }
|
36786 | };
|
36787 |
|
36788 | Legend.prototype.setOptions = function (options) {
|
36789 | var fields = ['enabled', 'orientation', 'icons', 'left', 'right'];
|
36790 | availableUtils.selectiveDeepExtend(fields, this.options, options);
|
36791 | };
|
36792 |
|
36793 | Legend.prototype.redraw = function () {
|
36794 | var activeGroups = 0;
|
36795 |
|
36796 | var groupArray = _Object$keys(this.groups);
|
36797 |
|
36798 | _sortInstanceProperty(groupArray).call(groupArray, function (a, b) {
|
36799 | return a < b ? -1 : 1;
|
36800 | });
|
36801 |
|
36802 | for (var i = 0; i < groupArray.length; i++) {
|
36803 | var groupId = groupArray[i];
|
36804 |
|
36805 | if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) {
|
36806 | activeGroups++;
|
36807 | }
|
36808 | }
|
36809 |
|
36810 | if (this.options[this.side].visible == false || this.amountOfGroups == 0 || this.options.enabled == false || activeGroups == 0) {
|
36811 | this.hide();
|
36812 | } else {
|
36813 | this.show();
|
36814 |
|
36815 | if (this.options[this.side].position == 'top-left' || this.options[this.side].position == 'bottom-left') {
|
36816 | this.dom.frame.style.left = '4px';
|
36817 | this.dom.frame.style.textAlign = "left";
|
36818 | this.dom.textArea.style.textAlign = "left";
|
36819 | this.dom.textArea.style.left = this.options.iconSize + 15 + 'px';
|
36820 | this.dom.textArea.style.right = '';
|
36821 | this.svg.style.left = 0 + 'px';
|
36822 | this.svg.style.right = '';
|
36823 | } else {
|
36824 | this.dom.frame.style.right = '4px';
|
36825 | this.dom.frame.style.textAlign = "right";
|
36826 | this.dom.textArea.style.textAlign = "right";
|
36827 | this.dom.textArea.style.right = this.options.iconSize + 15 + 'px';
|
36828 | this.dom.textArea.style.left = '';
|
36829 | this.svg.style.right = 0 + 'px';
|
36830 | this.svg.style.left = '';
|
36831 | }
|
36832 |
|
36833 | if (this.options[this.side].position == 'top-left' || this.options[this.side].position == 'top-right') {
|
36834 | this.dom.frame.style.top = 4 - Number(this.body.dom.center.style.top.replace("px", "")) + 'px';
|
36835 | this.dom.frame.style.bottom = '';
|
36836 | } else {
|
36837 | var scrollableHeight = this.body.domProps.center.height - this.body.domProps.centerContainer.height;
|
36838 | this.dom.frame.style.bottom = 4 + scrollableHeight + Number(this.body.dom.center.style.top.replace("px", "")) + 'px';
|
36839 | this.dom.frame.style.top = '';
|
36840 | }
|
36841 |
|
36842 | if (this.options.icons == false) {
|
36843 | this.dom.frame.style.width = this.dom.textArea.offsetWidth + 10 + 'px';
|
36844 | this.dom.textArea.style.right = '';
|
36845 | this.dom.textArea.style.left = '';
|
36846 | this.svg.style.width = '0px';
|
36847 | } else {
|
36848 | this.dom.frame.style.width = this.options.iconSize + 15 + this.dom.textArea.offsetWidth + 10 + 'px';
|
36849 | this.drawLegendIcons();
|
36850 | }
|
36851 |
|
36852 | var content = '';
|
36853 |
|
36854 | for (i = 0; i < groupArray.length; i++) {
|
36855 | groupId = groupArray[i];
|
36856 |
|
36857 | if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) {
|
36858 | content += this.groups[groupId].content + '<br />';
|
36859 | }
|
36860 | }
|
36861 |
|
36862 | this.dom.textArea.innerHTML = availableUtils.xss(content);
|
36863 | this.dom.textArea.style.lineHeight = 0.75 * this.options.iconSize + this.options.iconSpacing + 'px';
|
36864 | }
|
36865 | };
|
36866 |
|
36867 | Legend.prototype.drawLegendIcons = function () {
|
36868 | if (this.dom.frame.parentNode) {
|
36869 | var groupArray = _Object$keys(this.groups);
|
36870 |
|
36871 | _sortInstanceProperty(groupArray).call(groupArray, function (a, b) {
|
36872 | return a < b ? -1 : 1;
|
36873 | }); // this resets the elements so the order is maintained
|
36874 |
|
36875 |
|
36876 | resetElements(this.svgElements);
|
36877 | var padding = window.getComputedStyle(this.dom.frame).paddingTop;
|
36878 | var iconOffset = Number(padding.replace('px', ''));
|
36879 | var x = iconOffset;
|
36880 | var iconWidth = this.options.iconSize;
|
36881 | var iconHeight = 0.75 * this.options.iconSize;
|
36882 | var y = iconOffset + 0.5 * iconHeight + 3;
|
36883 | this.svg.style.width = iconWidth + 5 + iconOffset + 'px';
|
36884 |
|
36885 | for (var i = 0; i < groupArray.length; i++) {
|
36886 | var groupId = groupArray[i];
|
36887 |
|
36888 | if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) {
|
36889 | this.groups[groupId].getLegend(iconWidth, iconHeight, this.framework, x, y);
|
36890 | y += iconHeight + this.options.iconSpacing;
|
36891 | }
|
36892 | }
|
36893 | }
|
36894 | };
|
36895 |
|
36896 | var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items
|
36897 |
|
36898 | /**
|
36899 | * This is the constructor of the LineGraph. It requires a Timeline body and options.
|
36900 | *
|
36901 | * @param {vis.Timeline.body} body
|
36902 | * @param {Object} options
|
36903 | * @constructor LineGraph
|
36904 | * @extends Component
|
36905 | */
|
36906 |
|
36907 | function LineGraph(body, options) {
|
36908 | this.id = v4();
|
36909 | this.body = body;
|
36910 | this.defaultOptions = {
|
36911 | yAxisOrientation: 'left',
|
36912 | defaultGroup: 'default',
|
36913 | sort: true,
|
36914 | sampling: true,
|
36915 | stack: false,
|
36916 | graphHeight: '400px',
|
36917 | shaded: {
|
36918 | enabled: false,
|
36919 | orientation: 'bottom' // top, bottom, zero
|
36920 |
|
36921 | },
|
36922 | style: 'line',
|
36923 | // line, bar
|
36924 | barChart: {
|
36925 | width: 50,
|
36926 | sideBySide: false,
|
36927 | align: 'center' // left, center, right
|
36928 |
|
36929 | },
|
36930 | interpolation: {
|
36931 | enabled: true,
|
36932 | parametrization: 'centripetal',
|
36933 | // uniform (alpha = 0.0), chordal (alpha = 1.0), centripetal (alpha = 0.5)
|
36934 | alpha: 0.5
|
36935 | },
|
36936 | drawPoints: {
|
36937 | enabled: true,
|
36938 | size: 6,
|
36939 | style: 'square' // square, circle
|
36940 |
|
36941 | },
|
36942 | dataAxis: {},
|
36943 | //Defaults are done on DataAxis level
|
36944 | legend: {},
|
36945 | //Defaults are done on Legend level
|
36946 | groups: {
|
36947 | visibility: {}
|
36948 | }
|
36949 | }; // options is shared by this lineGraph and all its items
|
36950 |
|
36951 | this.options = availableUtils.extend({}, this.defaultOptions);
|
36952 | this.dom = {};
|
36953 | this.props = {};
|
36954 | this.hammer = null;
|
36955 | this.groups = {};
|
36956 | this.abortedGraphUpdate = false;
|
36957 | this.updateSVGheight = false;
|
36958 | this.updateSVGheightOnResize = false;
|
36959 | this.forceGraphUpdate = true;
|
36960 | var me = this;
|
36961 | this.itemsData = null; // DataSet
|
36962 |
|
36963 | this.groupsData = null; // DataSet
|
36964 | // listeners for the DataSet of the items
|
36965 |
|
36966 | this.itemListeners = {
|
36967 | 'add': function add(event, params, senderId) {
|
36968 | // eslint-disable-line no-unused-vars
|
36969 | me._onAdd(params.items);
|
36970 | },
|
36971 | 'update': function update(event, params, senderId) {
|
36972 | // eslint-disable-line no-unused-vars
|
36973 | me._onUpdate(params.items);
|
36974 | },
|
36975 | 'remove': function remove(event, params, senderId) {
|
36976 | // eslint-disable-line no-unused-vars
|
36977 | me._onRemove(params.items);
|
36978 | }
|
36979 | }; // listeners for the DataSet of the groups
|
36980 |
|
36981 | this.groupListeners = {
|
36982 | 'add': function add(event, params, senderId) {
|
36983 | // eslint-disable-line no-unused-vars
|
36984 | me._onAddGroups(params.items);
|
36985 | },
|
36986 | 'update': function update(event, params, senderId) {
|
36987 | // eslint-disable-line no-unused-vars
|
36988 | me._onUpdateGroups(params.items);
|
36989 | },
|
36990 | 'remove': function remove(event, params, senderId) {
|
36991 | // eslint-disable-line no-unused-vars
|
36992 | me._onRemoveGroups(params.items);
|
36993 | }
|
36994 | };
|
36995 | this.items = {}; // object with an Item for every data item
|
36996 |
|
36997 | this.selection = []; // list with the ids of all selected nodes
|
36998 |
|
36999 | this.lastStart = this.body.range.start;
|
37000 | this.touchParams = {}; // stores properties while dragging
|
37001 |
|
37002 | this.svgElements = {};
|
37003 | this.setOptions(options);
|
37004 | this.groupsUsingDefaultStyles = [0];
|
37005 | this.body.emitter.on('rangechanged', function () {
|
37006 | me.svg.style.left = availableUtils.option.asSize(-me.props.width);
|
37007 | me.forceGraphUpdate = true; //Is this local redraw necessary? (Core also does a change event!)
|
37008 |
|
37009 | me.redraw.call(me);
|
37010 | }); // create the HTML DOM
|
37011 |
|
37012 | this._create();
|
37013 |
|
37014 | this.framework = {
|
37015 | svg: this.svg,
|
37016 | svgElements: this.svgElements,
|
37017 | options: this.options,
|
37018 | groups: this.groups
|
37019 | };
|
37020 | }
|
37021 |
|
37022 | LineGraph.prototype = new Component();
|
37023 | /**
|
37024 | * Create the HTML DOM for the ItemSet
|
37025 | */
|
37026 |
|
37027 | LineGraph.prototype._create = function () {
|
37028 | var frame = document.createElement('div');
|
37029 | frame.className = 'vis-line-graph';
|
37030 | this.dom.frame = frame; // create svg element for graph drawing.
|
37031 |
|
37032 | this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
37033 | this.svg.style.position = 'relative';
|
37034 | this.svg.style.height = ('' + this.options.graphHeight).replace('px', '') + 'px';
|
37035 | this.svg.style.display = 'block';
|
37036 | frame.appendChild(this.svg); // data axis
|
37037 |
|
37038 | this.options.dataAxis.orientation = 'left';
|
37039 | this.yAxisLeft = new DataAxis(this.body, this.options.dataAxis, this.svg, this.options.groups);
|
37040 | this.options.dataAxis.orientation = 'right';
|
37041 | this.yAxisRight = new DataAxis(this.body, this.options.dataAxis, this.svg, this.options.groups);
|
37042 | delete this.options.dataAxis.orientation; // legends
|
37043 |
|
37044 | this.legendLeft = new Legend(this.body, this.options.legend, 'left', this.options.groups);
|
37045 | this.legendRight = new Legend(this.body, this.options.legend, 'right', this.options.groups);
|
37046 | this.show();
|
37047 | };
|
37048 | /**
|
37049 | * set the options of the LineGraph. the mergeOptions is used for subObjects that have an enabled element.
|
37050 | * @param {object} options
|
37051 | */
|
37052 |
|
37053 |
|
37054 | LineGraph.prototype.setOptions = function (options) {
|
37055 | if (options) {
|
37056 | var fields = ['sampling', 'defaultGroup', 'stack', 'height', 'graphHeight', 'yAxisOrientation', 'style', 'barChart', 'dataAxis', 'sort', 'groups'];
|
37057 |
|
37058 | if (options.graphHeight === undefined && options.height !== undefined) {
|
37059 | this.updateSVGheight = true;
|
37060 | this.updateSVGheightOnResize = true;
|
37061 | } else if (this.body.domProps.centerContainer.height !== undefined && options.graphHeight !== undefined) {
|
37062 | if (_parseInt((options.graphHeight + '').replace("px", '')) < this.body.domProps.centerContainer.height) {
|
37063 | this.updateSVGheight = true;
|
37064 | }
|
37065 | }
|
37066 |
|
37067 | availableUtils.selectiveDeepExtend(fields, this.options, options);
|
37068 | availableUtils.mergeOptions(this.options, options, 'interpolation');
|
37069 | availableUtils.mergeOptions(this.options, options, 'drawPoints');
|
37070 | availableUtils.mergeOptions(this.options, options, 'shaded');
|
37071 | availableUtils.mergeOptions(this.options, options, 'legend');
|
37072 |
|
37073 | if (options.interpolation) {
|
37074 | if (_typeof(options.interpolation) == 'object') {
|
37075 | if (options.interpolation.parametrization) {
|
37076 | if (options.interpolation.parametrization == 'uniform') {
|
37077 | this.options.interpolation.alpha = 0;
|
37078 | } else if (options.interpolation.parametrization == 'chordal') {
|
37079 | this.options.interpolation.alpha = 1.0;
|
37080 | } else {
|
37081 | this.options.interpolation.parametrization = 'centripetal';
|
37082 | this.options.interpolation.alpha = 0.5;
|
37083 | }
|
37084 | }
|
37085 | }
|
37086 | }
|
37087 |
|
37088 | if (this.yAxisLeft) {
|
37089 | if (options.dataAxis !== undefined) {
|
37090 | this.yAxisLeft.setOptions(this.options.dataAxis);
|
37091 | this.yAxisRight.setOptions(this.options.dataAxis);
|
37092 | }
|
37093 | }
|
37094 |
|
37095 | if (this.legendLeft) {
|
37096 | if (options.legend !== undefined) {
|
37097 | this.legendLeft.setOptions(this.options.legend);
|
37098 | this.legendRight.setOptions(this.options.legend);
|
37099 | }
|
37100 | }
|
37101 |
|
37102 | if (this.groups.hasOwnProperty(UNGROUPED)) {
|
37103 | this.groups[UNGROUPED].setOptions(options);
|
37104 | }
|
37105 | } // this is used to redraw the graph if the visibility of the groups is changed.
|
37106 |
|
37107 |
|
37108 | if (this.dom.frame) {
|
37109 | //not on initial run?
|
37110 | this.forceGraphUpdate = true;
|
37111 | this.body.emitter.emit("_change", {
|
37112 | queue: true
|
37113 | });
|
37114 | }
|
37115 | };
|
37116 | /**
|
37117 | * Hide the component from the DOM
|
37118 | */
|
37119 |
|
37120 |
|
37121 | LineGraph.prototype.hide = function () {
|
37122 | // remove the frame containing the items
|
37123 | if (this.dom.frame.parentNode) {
|
37124 | this.dom.frame.parentNode.removeChild(this.dom.frame);
|
37125 | }
|
37126 | };
|
37127 | /**
|
37128 | * Show the component in the DOM (when not already visible).
|
37129 | */
|
37130 |
|
37131 |
|
37132 | LineGraph.prototype.show = function () {
|
37133 | // show frame containing the items
|
37134 | if (!this.dom.frame.parentNode) {
|
37135 | this.body.dom.center.appendChild(this.dom.frame);
|
37136 | }
|
37137 | };
|
37138 | /**
|
37139 | * Set items
|
37140 | * @param {vis.DataSet | null} items
|
37141 | */
|
37142 |
|
37143 |
|
37144 | LineGraph.prototype.setItems = function (items) {
|
37145 | var me = this,
|
37146 | ids,
|
37147 | oldItemsData = this.itemsData; // replace the dataset
|
37148 |
|
37149 | if (!items) {
|
37150 | this.itemsData = null;
|
37151 | } else if (isDataViewLike(items)) {
|
37152 | this.itemsData = typeCoerceDataSet(items);
|
37153 | } else {
|
37154 | throw new TypeError('Data must implement the interface of DataSet or DataView');
|
37155 | }
|
37156 |
|
37157 | if (oldItemsData) {
|
37158 | // unsubscribe from old dataset
|
37159 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.itemListeners, function (callback, event) {
|
37160 | oldItemsData.off(event, callback);
|
37161 | }); // stop maintaining a coerced version of the old data set
|
37162 |
|
37163 |
|
37164 | oldItemsData.dispose(); // remove all drawn items
|
37165 |
|
37166 | ids = oldItemsData.getIds();
|
37167 |
|
37168 | this._onRemove(ids);
|
37169 | }
|
37170 |
|
37171 | if (this.itemsData) {
|
37172 | // subscribe to new dataset
|
37173 | var id = this.id;
|
37174 |
|
37175 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.itemListeners, function (callback, event) {
|
37176 | me.itemsData.on(event, callback, id);
|
37177 | }); // add all new items
|
37178 |
|
37179 |
|
37180 | ids = this.itemsData.getIds();
|
37181 |
|
37182 | this._onAdd(ids);
|
37183 | }
|
37184 | };
|
37185 | /**
|
37186 | * Set groups
|
37187 | * @param {vis.DataSet} groups
|
37188 | */
|
37189 |
|
37190 |
|
37191 | LineGraph.prototype.setGroups = function (groups) {
|
37192 | var me = this;
|
37193 | var ids; // unsubscribe from current dataset
|
37194 |
|
37195 | if (this.groupsData) {
|
37196 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groupListeners, function (callback, event) {
|
37197 | me.groupsData.off(event, callback);
|
37198 | }); // remove all drawn groups
|
37199 |
|
37200 |
|
37201 | ids = this.groupsData.getIds();
|
37202 | this.groupsData = null;
|
37203 |
|
37204 | for (var i = 0; i < ids.length; i++) {
|
37205 | this._removeGroup(ids[i]);
|
37206 | }
|
37207 | } // replace the dataset
|
37208 |
|
37209 |
|
37210 | if (!groups) {
|
37211 | this.groupsData = null;
|
37212 | } else if (isDataViewLike(groups)) {
|
37213 | this.groupsData = groups;
|
37214 | } else {
|
37215 | throw new TypeError('Data must implement the interface of DataSet or DataView');
|
37216 | }
|
37217 |
|
37218 | if (this.groupsData) {
|
37219 | // subscribe to new dataset
|
37220 | var id = this.id;
|
37221 |
|
37222 | _forEachInstanceProperty(availableUtils).call(availableUtils, this.groupListeners, function (callback, event) {
|
37223 | me.groupsData.on(event, callback, id);
|
37224 | }); // draw all ms
|
37225 |
|
37226 |
|
37227 | ids = this.groupsData.getIds();
|
37228 |
|
37229 | this._onAddGroups(ids);
|
37230 | }
|
37231 | };
|
37232 |
|
37233 | LineGraph.prototype._onUpdate = function (ids) {
|
37234 | this._updateAllGroupData(ids);
|
37235 | };
|
37236 |
|
37237 | LineGraph.prototype._onAdd = function (ids) {
|
37238 | this._onUpdate(ids);
|
37239 | };
|
37240 |
|
37241 | LineGraph.prototype._onRemove = function (ids) {
|
37242 | this._onUpdate(ids);
|
37243 | };
|
37244 |
|
37245 | LineGraph.prototype._onUpdateGroups = function (groupIds) {
|
37246 | this._updateAllGroupData(null, groupIds);
|
37247 | };
|
37248 |
|
37249 | LineGraph.prototype._onAddGroups = function (groupIds) {
|
37250 | this._onUpdateGroups(groupIds);
|
37251 | };
|
37252 | /**
|
37253 | * this cleans the group out off the legends and the dataaxis, updates the ungrouped and updates the graph
|
37254 | * @param {Array} groupIds
|
37255 | * @private
|
37256 | */
|
37257 |
|
37258 |
|
37259 | LineGraph.prototype._onRemoveGroups = function (groupIds) {
|
37260 | for (var i = 0; i < groupIds.length; i++) {
|
37261 | this._removeGroup(groupIds[i]);
|
37262 | }
|
37263 |
|
37264 | this.forceGraphUpdate = true;
|
37265 | this.body.emitter.emit("_change", {
|
37266 | queue: true
|
37267 | });
|
37268 | };
|
37269 | /**
|
37270 | * this cleans the group out off the legends and the dataaxis
|
37271 | * @param {vis.GraphGroup.id} groupId
|
37272 | * @private
|
37273 | */
|
37274 |
|
37275 |
|
37276 | LineGraph.prototype._removeGroup = function (groupId) {
|
37277 | if (this.groups.hasOwnProperty(groupId)) {
|
37278 | if (this.groups[groupId].options.yAxisOrientation == 'right') {
|
37279 | this.yAxisRight.removeGroup(groupId);
|
37280 | this.legendRight.removeGroup(groupId);
|
37281 | this.legendRight.redraw();
|
37282 | } else {
|
37283 | this.yAxisLeft.removeGroup(groupId);
|
37284 | this.legendLeft.removeGroup(groupId);
|
37285 | this.legendLeft.redraw();
|
37286 | }
|
37287 |
|
37288 | delete this.groups[groupId];
|
37289 | }
|
37290 | };
|
37291 | /**
|
37292 | * update a group object with the group dataset entree
|
37293 | *
|
37294 | * @param {vis.GraphGroup} group
|
37295 | * @param {vis.GraphGroup.id} groupId
|
37296 | * @private
|
37297 | */
|
37298 |
|
37299 |
|
37300 | LineGraph.prototype._updateGroup = function (group, groupId) {
|
37301 | if (!this.groups.hasOwnProperty(groupId)) {
|
37302 | this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles);
|
37303 |
|
37304 | if (this.groups[groupId].options.yAxisOrientation == 'right') {
|
37305 | this.yAxisRight.addGroup(groupId, this.groups[groupId]);
|
37306 | this.legendRight.addGroup(groupId, this.groups[groupId]);
|
37307 | } else {
|
37308 | this.yAxisLeft.addGroup(groupId, this.groups[groupId]);
|
37309 | this.legendLeft.addGroup(groupId, this.groups[groupId]);
|
37310 | }
|
37311 | } else {
|
37312 | this.groups[groupId].update(group);
|
37313 |
|
37314 | if (this.groups[groupId].options.yAxisOrientation == 'right') {
|
37315 | this.yAxisRight.updateGroup(groupId, this.groups[groupId]);
|
37316 | this.legendRight.updateGroup(groupId, this.groups[groupId]); //If yAxisOrientation changed, clean out the group from the other axis.
|
37317 |
|
37318 | this.yAxisLeft.removeGroup(groupId);
|
37319 | this.legendLeft.removeGroup(groupId);
|
37320 | } else {
|
37321 | this.yAxisLeft.updateGroup(groupId, this.groups[groupId]);
|
37322 | this.legendLeft.updateGroup(groupId, this.groups[groupId]); //If yAxisOrientation changed, clean out the group from the other axis.
|
37323 |
|
37324 | this.yAxisRight.removeGroup(groupId);
|
37325 | this.legendRight.removeGroup(groupId);
|
37326 | }
|
37327 | }
|
37328 |
|
37329 | this.legendLeft.redraw();
|
37330 | this.legendRight.redraw();
|
37331 | };
|
37332 | /**
|
37333 | * this updates all groups, it is used when there is an update the the itemset.
|
37334 | *
|
37335 | * @param {Array} ids
|
37336 | * @param {Array} groupIds
|
37337 | * @private
|
37338 | */
|
37339 |
|
37340 |
|
37341 | LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
|
37342 | if (this.itemsData != null) {
|
37343 | var groupsContent = {};
|
37344 | var items = this.itemsData.get();
|
37345 | var fieldId = this.itemsData.idProp;
|
37346 | var idMap = {};
|
37347 |
|
37348 | if (ids) {
|
37349 | _mapInstanceProperty(ids).call(ids, function (id) {
|
37350 | idMap[id] = id;
|
37351 | });
|
37352 | } //pre-Determine array sizes, for more efficient memory claim
|
37353 |
|
37354 |
|
37355 | var groupCounts = {};
|
37356 |
|
37357 | for (var i = 0; i < items.length; i++) {
|
37358 | var item = items[i];
|
37359 | var groupId = item.group;
|
37360 |
|
37361 | if (groupId === null || groupId === undefined) {
|
37362 | groupId = UNGROUPED;
|
37363 | }
|
37364 |
|
37365 | groupCounts.hasOwnProperty(groupId) ? groupCounts[groupId]++ : groupCounts[groupId] = 1;
|
37366 | } //Pre-load arrays from existing groups if items are not changed (not in ids)
|
37367 |
|
37368 |
|
37369 | var existingItemsMap = {};
|
37370 |
|
37371 | if (!groupIds && ids) {
|
37372 | for (groupId in this.groups) {
|
37373 | if (this.groups.hasOwnProperty(groupId)) {
|
37374 | group = this.groups[groupId];
|
37375 | var existing_items = group.getItems();
|
37376 | groupsContent[groupId] = _filterInstanceProperty(existing_items).call(existing_items, function (item) {
|
37377 | existingItemsMap[item[fieldId]] = item[fieldId];
|
37378 | return item[fieldId] !== idMap[item[fieldId]];
|
37379 | });
|
37380 | var newLength = groupCounts[groupId];
|
37381 | groupCounts[groupId] -= groupsContent[groupId].length;
|
37382 |
|
37383 | if (groupsContent[groupId].length < newLength) {
|
37384 | groupsContent[groupId][newLength - 1] = {};
|
37385 | }
|
37386 | }
|
37387 | }
|
37388 | } //Now insert data into the arrays.
|
37389 |
|
37390 |
|
37391 | for (i = 0; i < items.length; i++) {
|
37392 | item = items[i];
|
37393 | groupId = item.group;
|
37394 |
|
37395 | if (groupId === null || groupId === undefined) {
|
37396 | groupId = UNGROUPED;
|
37397 | }
|
37398 |
|
37399 | if (!groupIds && ids && item[fieldId] !== idMap[item[fieldId]] && existingItemsMap.hasOwnProperty(item[fieldId])) {
|
37400 | continue;
|
37401 | }
|
37402 |
|
37403 | if (!groupsContent.hasOwnProperty(groupId)) {
|
37404 | groupsContent[groupId] = new Array(groupCounts[groupId]);
|
37405 | } //Copy data (because of unmodifiable DataView input.
|
37406 |
|
37407 |
|
37408 | var extended = availableUtils.bridgeObject(item);
|
37409 | extended.x = availableUtils.convert(item.x, 'Date');
|
37410 | extended.end = availableUtils.convert(item.end, 'Date');
|
37411 | extended.orginalY = item.y; //real Y
|
37412 |
|
37413 | extended.y = Number(item.y);
|
37414 | extended[fieldId] = item[fieldId];
|
37415 | var index = groupsContent[groupId].length - groupCounts[groupId]--;
|
37416 | groupsContent[groupId][index] = extended;
|
37417 | } //Make sure all groups are present, to allow removal of old groups
|
37418 |
|
37419 |
|
37420 | for (groupId in this.groups) {
|
37421 | if (this.groups.hasOwnProperty(groupId)) {
|
37422 | if (!groupsContent.hasOwnProperty(groupId)) {
|
37423 | groupsContent[groupId] = new Array(0);
|
37424 | }
|
37425 | }
|
37426 | } //Update legendas, style and axis
|
37427 |
|
37428 |
|
37429 | for (groupId in groupsContent) {
|
37430 | if (groupsContent.hasOwnProperty(groupId)) {
|
37431 | if (groupsContent[groupId].length == 0) {
|
37432 | if (this.groups.hasOwnProperty(groupId)) {
|
37433 | this._removeGroup(groupId);
|
37434 | }
|
37435 | } else {
|
37436 | var group = undefined;
|
37437 |
|
37438 | if (this.groupsData != undefined) {
|
37439 | group = this.groupsData.get(groupId);
|
37440 | }
|
37441 |
|
37442 | if (group == undefined) {
|
37443 | group = {
|
37444 | id: groupId,
|
37445 | content: this.options.defaultGroup + groupId
|
37446 | };
|
37447 | }
|
37448 |
|
37449 | this._updateGroup(group, groupId);
|
37450 |
|
37451 | this.groups[groupId].setItems(groupsContent[groupId]);
|
37452 | }
|
37453 | }
|
37454 | }
|
37455 |
|
37456 | this.forceGraphUpdate = true;
|
37457 | this.body.emitter.emit("_change", {
|
37458 | queue: true
|
37459 | });
|
37460 | }
|
37461 | };
|
37462 | /**
|
37463 | * Redraw the component, mandatory function
|
37464 | * @return {boolean} Returns true if the component is resized
|
37465 | */
|
37466 |
|
37467 |
|
37468 | LineGraph.prototype.redraw = function () {
|
37469 | var resized = false; // calculate actual size and position
|
37470 |
|
37471 | this.props.width = this.dom.frame.offsetWidth;
|
37472 | this.props.height = this.body.domProps.centerContainer.height - this.body.domProps.border.top - this.body.domProps.border.bottom; // check if this component is resized
|
37473 |
|
37474 | resized = this._isResized() || resized; // check whether zoomed (in that case we need to re-stack everything)
|
37475 |
|
37476 | var visibleInterval = this.body.range.end - this.body.range.start;
|
37477 | var zoomed = visibleInterval != this.lastVisibleInterval;
|
37478 | this.lastVisibleInterval = visibleInterval; // the svg element is three times as big as the width, this allows for fully dragging left and right
|
37479 | // without reloading the graph. the controls for this are bound to events in the constructor
|
37480 |
|
37481 | if (resized == true) {
|
37482 | var _context;
|
37483 |
|
37484 | this.svg.style.width = availableUtils.option.asSize(3 * this.props.width);
|
37485 | this.svg.style.left = availableUtils.option.asSize(-this.props.width); // if the height of the graph is set as proportional, change the height of the svg
|
37486 |
|
37487 | if (_indexOfInstanceProperty(_context = this.options.height + '').call(_context, "%") != -1 || this.updateSVGheightOnResize == true) {
|
37488 | this.updateSVGheight = true;
|
37489 | }
|
37490 | } // update the height of the graph on each redraw of the graph.
|
37491 |
|
37492 |
|
37493 | if (this.updateSVGheight == true) {
|
37494 | if (this.options.graphHeight != this.props.height + 'px') {
|
37495 | this.options.graphHeight = this.props.height + 'px';
|
37496 | this.svg.style.height = this.props.height + 'px';
|
37497 | }
|
37498 |
|
37499 | this.updateSVGheight = false;
|
37500 | } else {
|
37501 | this.svg.style.height = ('' + this.options.graphHeight).replace('px', '') + 'px';
|
37502 | } // zoomed is here to ensure that animations are shown correctly.
|
37503 |
|
37504 |
|
37505 | if (resized == true || zoomed == true || this.abortedGraphUpdate == true || this.forceGraphUpdate == true) {
|
37506 | resized = this._updateGraph() || resized;
|
37507 | this.forceGraphUpdate = false;
|
37508 | this.lastStart = this.body.range.start;
|
37509 | this.svg.style.left = -this.props.width + 'px';
|
37510 | } else {
|
37511 | // move the whole svg while dragging
|
37512 | if (this.lastStart != 0) {
|
37513 | var offset = this.body.range.start - this.lastStart;
|
37514 | var range = this.body.range.end - this.body.range.start;
|
37515 |
|
37516 | if (this.props.width != 0) {
|
37517 | var rangePerPixelInv = this.props.width / range;
|
37518 | var xOffset = offset * rangePerPixelInv;
|
37519 | this.svg.style.left = -this.props.width - xOffset + 'px';
|
37520 | }
|
37521 | }
|
37522 | }
|
37523 |
|
37524 | this.legendLeft.redraw();
|
37525 | this.legendRight.redraw();
|
37526 | return resized;
|
37527 | };
|
37528 |
|
37529 | LineGraph.prototype._getSortedGroupIds = function () {
|
37530 | // getting group Ids
|
37531 | var grouplist = [];
|
37532 |
|
37533 | for (var groupId in this.groups) {
|
37534 | if (this.groups.hasOwnProperty(groupId)) {
|
37535 | var group = this.groups[groupId];
|
37536 |
|
37537 | if (group.visible == true && (this.options.groups.visibility[groupId] === undefined || this.options.groups.visibility[groupId] == true)) {
|
37538 | grouplist.push({
|
37539 | id: groupId,
|
37540 | zIndex: group.options.zIndex
|
37541 | });
|
37542 | }
|
37543 | }
|
37544 | }
|
37545 |
|
37546 | availableUtils.insertSort(grouplist, function (a, b) {
|
37547 | var az = a.zIndex;
|
37548 | var bz = b.zIndex;
|
37549 | if (az === undefined) az = 0;
|
37550 | if (bz === undefined) bz = 0;
|
37551 | return az == bz ? 0 : az < bz ? -1 : 1;
|
37552 | });
|
37553 | var groupIds = new Array(grouplist.length);
|
37554 |
|
37555 | for (var i = 0; i < grouplist.length; i++) {
|
37556 | groupIds[i] = grouplist[i].id;
|
37557 | }
|
37558 |
|
37559 | return groupIds;
|
37560 | };
|
37561 | /**
|
37562 | * Update and redraw the graph.
|
37563 | *
|
37564 | * @returns {boolean}
|
37565 | * @private
|
37566 | */
|
37567 |
|
37568 |
|
37569 | LineGraph.prototype._updateGraph = function () {
|
37570 | // reset the svg elements
|
37571 | prepareElements(this.svgElements);
|
37572 |
|
37573 | if (this.props.width != 0 && this.itemsData != null) {
|
37574 | var group, i;
|
37575 | var groupRanges = {};
|
37576 | var changeCalled = false; // this is the range of the SVG canvas
|
37577 |
|
37578 | var minDate = this.body.util.toGlobalTime(-this.body.domProps.root.width);
|
37579 | var maxDate = this.body.util.toGlobalTime(2 * this.body.domProps.root.width); // getting group Ids
|
37580 |
|
37581 | var groupIds = this._getSortedGroupIds();
|
37582 |
|
37583 | if (groupIds.length > 0) {
|
37584 | var groupsData = {}; // fill groups data, this only loads the data we require based on the timewindow
|
37585 |
|
37586 | this._getRelevantData(groupIds, groupsData, minDate, maxDate); // apply sampling, if disabled, it will pass through this function.
|
37587 |
|
37588 |
|
37589 | this._applySampling(groupIds, groupsData); // we transform the X coordinates to detect collisions
|
37590 |
|
37591 |
|
37592 | for (i = 0; i < groupIds.length; i++) {
|
37593 | this._convertXcoordinates(groupsData[groupIds[i]]);
|
37594 | } // now all needed data has been collected we start the processing.
|
37595 |
|
37596 |
|
37597 | this._getYRanges(groupIds, groupsData, groupRanges); // update the Y axis first, we use this data to draw at the correct Y points
|
37598 |
|
37599 |
|
37600 | changeCalled = this._updateYAxis(groupIds, groupRanges); // at changeCalled, abort this update cycle as the graph needs another update with new Width input from the Redraw container.
|
37601 | // Cleanup SVG elements on abort.
|
37602 |
|
37603 | if (changeCalled == true) {
|
37604 | cleanupElements(this.svgElements);
|
37605 | this.abortedGraphUpdate = true;
|
37606 | return true;
|
37607 | }
|
37608 |
|
37609 | this.abortedGraphUpdate = false; // With the yAxis scaled correctly, use this to get the Y values of the points.
|
37610 |
|
37611 | var below = undefined;
|
37612 |
|
37613 | for (i = 0; i < groupIds.length; i++) {
|
37614 | group = this.groups[groupIds[i]];
|
37615 |
|
37616 | if (this.options.stack === true && this.options.style === 'line') {
|
37617 | if (group.options.excludeFromStacking == undefined || !group.options.excludeFromStacking) {
|
37618 | if (below != undefined) {
|
37619 | this._stack(groupsData[group.id], groupsData[below.id]);
|
37620 |
|
37621 | if (group.options.shaded.enabled == true && group.options.shaded.orientation !== "group") {
|
37622 | if (group.options.shaded.orientation == "top" && below.options.shaded.orientation !== "group") {
|
37623 | below.options.shaded.orientation = "group";
|
37624 | below.options.shaded.groupId = group.id;
|
37625 | } else {
|
37626 | group.options.shaded.orientation = "group";
|
37627 | group.options.shaded.groupId = below.id;
|
37628 | }
|
37629 | }
|
37630 | }
|
37631 |
|
37632 | below = group;
|
37633 | }
|
37634 | }
|
37635 |
|
37636 | this._convertYcoordinates(groupsData[groupIds[i]], group);
|
37637 | } //Precalculate paths and draw shading if appropriate. This will make sure the shading is always behind any lines.
|
37638 |
|
37639 |
|
37640 | var paths = {};
|
37641 |
|
37642 | for (i = 0; i < groupIds.length; i++) {
|
37643 | group = this.groups[groupIds[i]];
|
37644 |
|
37645 | if (group.options.style === 'line' && group.options.shaded.enabled == true) {
|
37646 | var dataset = groupsData[groupIds[i]];
|
37647 |
|
37648 | if (dataset == null || dataset.length == 0) {
|
37649 | continue;
|
37650 | }
|
37651 |
|
37652 | if (!paths.hasOwnProperty(groupIds[i])) {
|
37653 | paths[groupIds[i]] = Line.calcPath(dataset, group);
|
37654 | }
|
37655 |
|
37656 | if (group.options.shaded.orientation === "group") {
|
37657 | var subGroupId = group.options.shaded.groupId;
|
37658 |
|
37659 | if (_indexOfInstanceProperty(groupIds).call(groupIds, subGroupId) === -1) {
|
37660 | console.log(group.id + ": Unknown shading group target given:" + subGroupId);
|
37661 | continue;
|
37662 | }
|
37663 |
|
37664 | if (!paths.hasOwnProperty(subGroupId)) {
|
37665 | paths[subGroupId] = Line.calcPath(groupsData[subGroupId], this.groups[subGroupId]);
|
37666 | }
|
37667 |
|
37668 | Line.drawShading(paths[groupIds[i]], group, paths[subGroupId], this.framework);
|
37669 | } else {
|
37670 | Line.drawShading(paths[groupIds[i]], group, undefined, this.framework);
|
37671 | }
|
37672 | }
|
37673 | } // draw the groups, calculating paths if still necessary.
|
37674 |
|
37675 |
|
37676 | Bargraph.draw(groupIds, groupsData, this.framework);
|
37677 |
|
37678 | for (i = 0; i < groupIds.length; i++) {
|
37679 | group = this.groups[groupIds[i]];
|
37680 |
|
37681 | if (groupsData[groupIds[i]].length > 0) {
|
37682 | switch (group.options.style) {
|
37683 | case "line":
|
37684 | if (!paths.hasOwnProperty(groupIds[i])) {
|
37685 | paths[groupIds[i]] = Line.calcPath(groupsData[groupIds[i]], group);
|
37686 | }
|
37687 |
|
37688 | Line.draw(paths[groupIds[i]], group, this.framework);
|
37689 | // eslint-disable-line no-fallthrough
|
37690 |
|
37691 | case "point": // eslint-disable-line no-fallthrough
|
37692 |
|
37693 | case "points":
|
37694 | if (group.options.style == "point" || group.options.style == "points" || group.options.drawPoints.enabled == true) {
|
37695 | Points.draw(groupsData[groupIds[i]], group, this.framework);
|
37696 | }
|
37697 |
|
37698 | break;
|
37699 |
|
37700 | }
|
37701 | }
|
37702 | }
|
37703 | }
|
37704 | } // cleanup unused svg elements
|
37705 |
|
37706 |
|
37707 | cleanupElements(this.svgElements);
|
37708 | return false;
|
37709 | };
|
37710 |
|
37711 | LineGraph.prototype._stack = function (data, subData) {
|
37712 | var index, dx, dy, subPrevPoint, subNextPoint;
|
37713 | index = 0; // for each data point we look for a matching on in the set below
|
37714 |
|
37715 | for (var j = 0; j < data.length; j++) {
|
37716 | subPrevPoint = undefined;
|
37717 | subNextPoint = undefined; // we look for time matches or a before-after point
|
37718 |
|
37719 | for (var k = index; k < subData.length; k++) {
|
37720 | // if times match exactly
|
37721 | if (subData[k].x === data[j].x) {
|
37722 | subPrevPoint = subData[k];
|
37723 | subNextPoint = subData[k];
|
37724 | index = k;
|
37725 | break;
|
37726 | } else if (subData[k].x > data[j].x) {
|
37727 | // overshoot
|
37728 | subNextPoint = subData[k];
|
37729 |
|
37730 | if (k == 0) {
|
37731 | subPrevPoint = subNextPoint;
|
37732 | } else {
|
37733 | subPrevPoint = subData[k - 1];
|
37734 | }
|
37735 |
|
37736 | index = k;
|
37737 | break;
|
37738 | }
|
37739 | } // in case the last data point has been used, we assume it stays like this.
|
37740 |
|
37741 |
|
37742 | if (subNextPoint === undefined) {
|
37743 | subPrevPoint = subData[subData.length - 1];
|
37744 | subNextPoint = subData[subData.length - 1];
|
37745 | } // linear interpolation
|
37746 |
|
37747 |
|
37748 | dx = subNextPoint.x - subPrevPoint.x;
|
37749 | dy = subNextPoint.y - subPrevPoint.y;
|
37750 |
|
37751 | if (dx == 0) {
|
37752 | data[j].y = data[j].orginalY + subNextPoint.y;
|
37753 | } else {
|
37754 | data[j].y = data[j].orginalY + dy / dx * (data[j].x - subPrevPoint.x) + subPrevPoint.y; // ax + b where b is data[j].y
|
37755 | }
|
37756 | }
|
37757 | };
|
37758 | /**
|
37759 | * first select and preprocess the data from the datasets.
|
37760 | * the groups have their preselection of data, we now loop over this data to see
|
37761 | * what data we need to draw. Sorted data is much faster.
|
37762 | * more optimization is possible by doing the sampling before and using the binary search
|
37763 | * to find the end date to determine the increment.
|
37764 | *
|
37765 | * @param {array} groupIds
|
37766 | * @param {object} groupsData
|
37767 | * @param {date} minDate
|
37768 | * @param {date} maxDate
|
37769 | * @private
|
37770 | */
|
37771 |
|
37772 |
|
37773 | LineGraph.prototype._getRelevantData = function (groupIds, groupsData, minDate, maxDate) {
|
37774 | var group, i, j, item;
|
37775 |
|
37776 | if (groupIds.length > 0) {
|
37777 | for (i = 0; i < groupIds.length; i++) {
|
37778 | group = this.groups[groupIds[i]];
|
37779 | var itemsData = group.getItems(); // optimization for sorted data
|
37780 |
|
37781 | if (_sortInstanceProperty(group.options) == true) {
|
37782 | var dateComparator = function dateComparator(a, b) {
|
37783 | return a.getTime() == b.getTime() ? 0 : a < b ? -1 : 1;
|
37784 | };
|
37785 |
|
37786 | var first = Math.max(0, availableUtils.binarySearchValue(itemsData, minDate, 'x', 'before', dateComparator));
|
37787 | var last = Math.min(itemsData.length, availableUtils.binarySearchValue(itemsData, maxDate, 'x', 'after', dateComparator) + 1);
|
37788 |
|
37789 | if (last <= 0) {
|
37790 | last = itemsData.length;
|
37791 | }
|
37792 |
|
37793 | var dataContainer = new Array(last - first);
|
37794 |
|
37795 | for (j = first; j < last; j++) {
|
37796 | item = group.itemsData[j];
|
37797 | dataContainer[j - first] = item;
|
37798 | }
|
37799 |
|
37800 | groupsData[groupIds[i]] = dataContainer;
|
37801 | } else {
|
37802 | // If unsorted data, all data is relevant, just returning entire structure
|
37803 | groupsData[groupIds[i]] = group.itemsData;
|
37804 | }
|
37805 | }
|
37806 | }
|
37807 | };
|
37808 | /**
|
37809 | *
|
37810 | * @param {Array.<vis.GraphGroup.id>} groupIds
|
37811 | * @param {vis.DataSet} groupsData
|
37812 | * @private
|
37813 | */
|
37814 |
|
37815 |
|
37816 | LineGraph.prototype._applySampling = function (groupIds, groupsData) {
|
37817 | var group;
|
37818 |
|
37819 | if (groupIds.length > 0) {
|
37820 | for (var i = 0; i < groupIds.length; i++) {
|
37821 | group = this.groups[groupIds[i]];
|
37822 |
|
37823 | if (group.options.sampling == true) {
|
37824 | var dataContainer = groupsData[groupIds[i]];
|
37825 |
|
37826 | if (dataContainer.length > 0) {
|
37827 | var increment = 1;
|
37828 | var amountOfPoints = dataContainer.length; // the global screen is used because changing the width of the yAxis may affect the increment, resulting in an endless loop
|
37829 | // of width changing of the yAxis.
|
37830 | //TODO: This assumes sorted data, but that's not guaranteed!
|
37831 |
|
37832 | var xDistance = this.body.util.toGlobalScreen(dataContainer[dataContainer.length - 1].x) - this.body.util.toGlobalScreen(dataContainer[0].x);
|
37833 | var pointsPerPixel = amountOfPoints / xDistance;
|
37834 | increment = Math.min(Math.ceil(0.2 * amountOfPoints), Math.max(1, Math.round(pointsPerPixel)));
|
37835 | var sampledData = new Array(amountOfPoints);
|
37836 |
|
37837 | for (var j = 0; j < amountOfPoints; j += increment) {
|
37838 | var idx = Math.round(j / increment);
|
37839 | sampledData[idx] = dataContainer[j];
|
37840 | }
|
37841 |
|
37842 | groupsData[groupIds[i]] = _spliceInstanceProperty(sampledData).call(sampledData, 0, Math.round(amountOfPoints / increment));
|
37843 | }
|
37844 | }
|
37845 | }
|
37846 | }
|
37847 | };
|
37848 | /**
|
37849 | *
|
37850 | * @param {Array.<vis.GraphGroup.id>} groupIds
|
37851 | * @param {vis.DataSet} groupsData
|
37852 | * @param {object} groupRanges | this is being filled here
|
37853 | * @private
|
37854 | */
|
37855 |
|
37856 |
|
37857 | LineGraph.prototype._getYRanges = function (groupIds, groupsData, groupRanges) {
|
37858 | var groupData, group, i;
|
37859 | var combinedDataLeft = [];
|
37860 | var combinedDataRight = [];
|
37861 | var options;
|
37862 |
|
37863 | if (groupIds.length > 0) {
|
37864 | for (i = 0; i < groupIds.length; i++) {
|
37865 | groupData = groupsData[groupIds[i]];
|
37866 | options = this.groups[groupIds[i]].options;
|
37867 |
|
37868 | if (groupData.length > 0) {
|
37869 | group = this.groups[groupIds[i]]; // if bar graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
37870 |
|
37871 | if (options.stack === true && options.style === 'bar') {
|
37872 | if (options.yAxisOrientation === 'left') {
|
37873 | combinedDataLeft = _concatInstanceProperty(combinedDataLeft).call(combinedDataLeft, groupData);
|
37874 | } else {
|
37875 | combinedDataRight = _concatInstanceProperty(combinedDataRight).call(combinedDataRight, groupData);
|
37876 | }
|
37877 | } else {
|
37878 | groupRanges[groupIds[i]] = group.getYRange(groupData, groupIds[i]);
|
37879 | }
|
37880 | }
|
37881 | } // if bar graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
37882 |
|
37883 |
|
37884 | Bargraph.getStackedYRange(combinedDataLeft, groupRanges, groupIds, '__barStackLeft', 'left');
|
37885 | Bargraph.getStackedYRange(combinedDataRight, groupRanges, groupIds, '__barStackRight', 'right');
|
37886 | }
|
37887 | };
|
37888 | /**
|
37889 | * this sets the Y ranges for the Y axis. It also determines which of the axis should be shown or hidden.
|
37890 | * @param {Array.<vis.GraphGroup.id>} groupIds
|
37891 | * @param {Object} groupRanges
|
37892 | * @returns {boolean} resized
|
37893 | * @private
|
37894 | */
|
37895 |
|
37896 |
|
37897 | LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
|
37898 | var resized = false;
|
37899 | var yAxisLeftUsed = false;
|
37900 | var yAxisRightUsed = false;
|
37901 | var minLeft = 1e9,
|
37902 | minRight = 1e9,
|
37903 | maxLeft = -1e9,
|
37904 | maxRight = -1e9,
|
37905 | minVal,
|
37906 | maxVal; // if groups are present
|
37907 |
|
37908 | if (groupIds.length > 0) {
|
37909 | // this is here to make sure that if there are no items in the axis but there are groups, that there is no infinite draw/redraw loop.
|
37910 | for (var i = 0; i < groupIds.length; i++) {
|
37911 | var group = this.groups[groupIds[i]];
|
37912 |
|
37913 | if (group && group.options.yAxisOrientation != 'right') {
|
37914 | yAxisLeftUsed = true;
|
37915 | minLeft = 1e9;
|
37916 | maxLeft = -1e9;
|
37917 | } else if (group && group.options.yAxisOrientation) {
|
37918 | yAxisRightUsed = true;
|
37919 | minRight = 1e9;
|
37920 | maxRight = -1e9;
|
37921 | }
|
37922 | } // if there are items:
|
37923 |
|
37924 |
|
37925 | for (i = 0; i < groupIds.length; i++) {
|
37926 | if (groupRanges.hasOwnProperty(groupIds[i])) {
|
37927 | if (groupRanges[groupIds[i]].ignore !== true) {
|
37928 | minVal = groupRanges[groupIds[i]].min;
|
37929 | maxVal = groupRanges[groupIds[i]].max;
|
37930 |
|
37931 | if (groupRanges[groupIds[i]].yAxisOrientation != 'right') {
|
37932 | yAxisLeftUsed = true;
|
37933 | minLeft = minLeft > minVal ? minVal : minLeft;
|
37934 | maxLeft = maxLeft < maxVal ? maxVal : maxLeft;
|
37935 | } else {
|
37936 | yAxisRightUsed = true;
|
37937 | minRight = minRight > minVal ? minVal : minRight;
|
37938 | maxRight = maxRight < maxVal ? maxVal : maxRight;
|
37939 | }
|
37940 | }
|
37941 | }
|
37942 | }
|
37943 |
|
37944 | if (yAxisLeftUsed == true) {
|
37945 | this.yAxisLeft.setRange(minLeft, maxLeft);
|
37946 | }
|
37947 |
|
37948 | if (yAxisRightUsed == true) {
|
37949 | this.yAxisRight.setRange(minRight, maxRight);
|
37950 | }
|
37951 | }
|
37952 |
|
37953 | resized = this._toggleAxisVisiblity(yAxisLeftUsed, this.yAxisLeft) || resized;
|
37954 | resized = this._toggleAxisVisiblity(yAxisRightUsed, this.yAxisRight) || resized;
|
37955 |
|
37956 | if (yAxisRightUsed == true && yAxisLeftUsed == true) {
|
37957 | this.yAxisLeft.drawIcons = true;
|
37958 | this.yAxisRight.drawIcons = true;
|
37959 | } else {
|
37960 | this.yAxisLeft.drawIcons = false;
|
37961 | this.yAxisRight.drawIcons = false;
|
37962 | }
|
37963 |
|
37964 | this.yAxisRight.master = !yAxisLeftUsed;
|
37965 | this.yAxisRight.masterAxis = this.yAxisLeft;
|
37966 |
|
37967 | if (this.yAxisRight.master == false) {
|
37968 | if (yAxisRightUsed == true) {
|
37969 | this.yAxisLeft.lineOffset = this.yAxisRight.width;
|
37970 | } else {
|
37971 | this.yAxisLeft.lineOffset = 0;
|
37972 | }
|
37973 |
|
37974 | resized = this.yAxisLeft.redraw() || resized;
|
37975 | resized = this.yAxisRight.redraw() || resized;
|
37976 | } else {
|
37977 | resized = this.yAxisRight.redraw() || resized;
|
37978 | } // clean the accumulated lists
|
37979 |
|
37980 |
|
37981 | var tempGroups = ['__barStackLeft', '__barStackRight', '__lineStackLeft', '__lineStackRight'];
|
37982 |
|
37983 | for (i = 0; i < tempGroups.length; i++) {
|
37984 | if (_indexOfInstanceProperty(groupIds).call(groupIds, tempGroups[i]) != -1) {
|
37985 | _spliceInstanceProperty(groupIds).call(groupIds, _indexOfInstanceProperty(groupIds).call(groupIds, tempGroups[i]), 1);
|
37986 | }
|
37987 | }
|
37988 |
|
37989 | return resized;
|
37990 | };
|
37991 | /**
|
37992 | * This shows or hides the Y axis if needed. If there is a change, the changed event is emitted by the updateYAxis function
|
37993 | *
|
37994 | * @param {boolean} axisUsed
|
37995 | * @param {vis.DataAxis} axis
|
37996 | * @returns {boolean}
|
37997 | * @private
|
37998 | */
|
37999 |
|
38000 |
|
38001 | LineGraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
|
38002 | var changed = false;
|
38003 |
|
38004 | if (axisUsed == false) {
|
38005 | if (axis.dom.frame.parentNode && axis.hidden == false) {
|
38006 | axis.hide();
|
38007 | changed = true;
|
38008 | }
|
38009 | } else {
|
38010 | if (!axis.dom.frame.parentNode && axis.hidden == true) {
|
38011 | axis.show();
|
38012 | changed = true;
|
38013 | }
|
38014 | }
|
38015 |
|
38016 | return changed;
|
38017 | };
|
38018 | /**
|
38019 | * This uses the DataAxis object to generate the correct X coordinate on the SVG window. It uses the
|
38020 | * util function toScreen to get the x coordinate from the timestamp. It also pre-filters the data and get the minMax ranges for
|
38021 | * the yAxis.
|
38022 | *
|
38023 | * @param {Array.<Object>} datapoints
|
38024 | * @private
|
38025 | */
|
38026 |
|
38027 |
|
38028 | LineGraph.prototype._convertXcoordinates = function (datapoints) {
|
38029 | var toScreen = this.body.util.toScreen;
|
38030 |
|
38031 | for (var i = 0; i < datapoints.length; i++) {
|
38032 | datapoints[i].screen_x = toScreen(datapoints[i].x) + this.props.width;
|
38033 | datapoints[i].screen_y = datapoints[i].y; //starting point for range calculations
|
38034 |
|
38035 | if (datapoints[i].end != undefined) {
|
38036 | datapoints[i].screen_end = toScreen(datapoints[i].end) + this.props.width;
|
38037 | } else {
|
38038 | datapoints[i].screen_end = undefined;
|
38039 | }
|
38040 | }
|
38041 | };
|
38042 | /**
|
38043 | * This uses the DataAxis object to generate the correct X coordinate on the SVG window. It uses the
|
38044 | * util function toScreen to get the x coordinate from the timestamp. It also pre-filters the data and get the minMax ranges for
|
38045 | * the yAxis.
|
38046 | *
|
38047 | * @param {Array.<Object>} datapoints
|
38048 | * @param {vis.GraphGroup} group
|
38049 | * @private
|
38050 | */
|
38051 |
|
38052 |
|
38053 | LineGraph.prototype._convertYcoordinates = function (datapoints, group) {
|
38054 | var axis = this.yAxisLeft;
|
38055 | var svgHeight = Number(this.svg.style.height.replace('px', ''));
|
38056 |
|
38057 | if (group.options.yAxisOrientation == 'right') {
|
38058 | axis = this.yAxisRight;
|
38059 | }
|
38060 |
|
38061 | for (var i = 0; i < datapoints.length; i++) {
|
38062 | datapoints[i].screen_y = Math.round(axis.convertValue(datapoints[i].y));
|
38063 | }
|
38064 |
|
38065 | group.setZeroPosition(Math.min(svgHeight, axis.convertValue(0)));
|
38066 | };
|
38067 |
|
38068 | /**
|
38069 | * This object contains all possible options. It will check if the types are correct, if required if the option is one
|
38070 | * of the allowed values.
|
38071 | *
|
38072 | * __any__ means that the name of the property does not matter.
|
38073 | * __type__ is a required field for all objects and contains the allowed types of all objects
|
38074 | */
|
38075 | var string = 'string';
|
38076 | var bool = 'boolean';
|
38077 | var number = 'number';
|
38078 | var array = 'array';
|
38079 | var date = 'date';
|
38080 | var object = 'object'; // should only be in a __type__ property
|
38081 |
|
38082 | var dom = 'dom';
|
38083 | var moment = 'moment';
|
38084 | var any = 'any';
|
38085 | var allOptions = {
|
38086 | configure: {
|
38087 | enabled: {
|
38088 | 'boolean': bool
|
38089 | },
|
38090 | filter: {
|
38091 | 'boolean': bool,
|
38092 | 'function': 'function'
|
38093 | },
|
38094 | container: {
|
38095 | dom: dom
|
38096 | },
|
38097 | __type__: {
|
38098 | object: object,
|
38099 | 'boolean': bool,
|
38100 | 'function': 'function'
|
38101 | }
|
38102 | },
|
38103 | //globals :
|
38104 | alignCurrentTime: {
|
38105 | string: string,
|
38106 | 'undefined': 'undefined'
|
38107 | },
|
38108 | yAxisOrientation: {
|
38109 | string: ['left', 'right']
|
38110 | },
|
38111 | defaultGroup: {
|
38112 | string: string
|
38113 | },
|
38114 | sort: {
|
38115 | 'boolean': bool
|
38116 | },
|
38117 | sampling: {
|
38118 | 'boolean': bool
|
38119 | },
|
38120 | stack: {
|
38121 | 'boolean': bool
|
38122 | },
|
38123 | graphHeight: {
|
38124 | string: string,
|
38125 | number: number
|
38126 | },
|
38127 | shaded: {
|
38128 | enabled: {
|
38129 | 'boolean': bool
|
38130 | },
|
38131 | orientation: {
|
38132 | string: ['bottom', 'top', 'zero', 'group']
|
38133 | },
|
38134 | // top, bottom, zero, group
|
38135 | groupId: {
|
38136 | object: object
|
38137 | },
|
38138 | __type__: {
|
38139 | 'boolean': bool,
|
38140 | object: object
|
38141 | }
|
38142 | },
|
38143 | style: {
|
38144 | string: ['line', 'bar', 'points']
|
38145 | },
|
38146 | // line, bar
|
38147 | barChart: {
|
38148 | width: {
|
38149 | number: number
|
38150 | },
|
38151 | minWidth: {
|
38152 | number: number
|
38153 | },
|
38154 | sideBySide: {
|
38155 | 'boolean': bool
|
38156 | },
|
38157 | align: {
|
38158 | string: ['left', 'center', 'right']
|
38159 | },
|
38160 | __type__: {
|
38161 | object: object
|
38162 | }
|
38163 | },
|
38164 | interpolation: {
|
38165 | enabled: {
|
38166 | 'boolean': bool
|
38167 | },
|
38168 | parametrization: {
|
38169 | string: ['centripetal', 'chordal', 'uniform']
|
38170 | },
|
38171 | // uniform (alpha = 0.0), chordal (alpha = 1.0), centripetal (alpha = 0.5)
|
38172 | alpha: {
|
38173 | number: number
|
38174 | },
|
38175 | __type__: {
|
38176 | object: object,
|
38177 | 'boolean': bool
|
38178 | }
|
38179 | },
|
38180 | drawPoints: {
|
38181 | enabled: {
|
38182 | 'boolean': bool
|
38183 | },
|
38184 | onRender: {
|
38185 | 'function': 'function'
|
38186 | },
|
38187 | size: {
|
38188 | number: number
|
38189 | },
|
38190 | style: {
|
38191 | string: ['square', 'circle']
|
38192 | },
|
38193 | // square, circle
|
38194 | __type__: {
|
38195 | object: object,
|
38196 | 'boolean': bool,
|
38197 | 'function': 'function'
|
38198 | }
|
38199 | },
|
38200 | dataAxis: {
|
38201 | showMinorLabels: {
|
38202 | 'boolean': bool
|
38203 | },
|
38204 | showMajorLabels: {
|
38205 | 'boolean': bool
|
38206 | },
|
38207 | showWeekScale: {
|
38208 | 'boolean': bool
|
38209 | },
|
38210 | icons: {
|
38211 | 'boolean': bool
|
38212 | },
|
38213 | width: {
|
38214 | string: string,
|
38215 | number: number
|
38216 | },
|
38217 | visible: {
|
38218 | 'boolean': bool
|
38219 | },
|
38220 | alignZeros: {
|
38221 | 'boolean': bool
|
38222 | },
|
38223 | left: {
|
38224 | range: {
|
38225 | min: {
|
38226 | number: number,
|
38227 | 'undefined': 'undefined'
|
38228 | },
|
38229 | max: {
|
38230 | number: number,
|
38231 | 'undefined': 'undefined'
|
38232 | },
|
38233 | __type__: {
|
38234 | object: object
|
38235 | }
|
38236 | },
|
38237 | format: {
|
38238 | 'function': 'function'
|
38239 | },
|
38240 | title: {
|
38241 | text: {
|
38242 | string: string,
|
38243 | number: number,
|
38244 | 'undefined': 'undefined'
|
38245 | },
|
38246 | style: {
|
38247 | string: string,
|
38248 | 'undefined': 'undefined'
|
38249 | },
|
38250 | __type__: {
|
38251 | object: object
|
38252 | }
|
38253 | },
|
38254 | __type__: {
|
38255 | object: object
|
38256 | }
|
38257 | },
|
38258 | right: {
|
38259 | range: {
|
38260 | min: {
|
38261 | number: number,
|
38262 | 'undefined': 'undefined'
|
38263 | },
|
38264 | max: {
|
38265 | number: number,
|
38266 | 'undefined': 'undefined'
|
38267 | },
|
38268 | __type__: {
|
38269 | object: object
|
38270 | }
|
38271 | },
|
38272 | format: {
|
38273 | 'function': 'function'
|
38274 | },
|
38275 | title: {
|
38276 | text: {
|
38277 | string: string,
|
38278 | number: number,
|
38279 | 'undefined': 'undefined'
|
38280 | },
|
38281 | style: {
|
38282 | string: string,
|
38283 | 'undefined': 'undefined'
|
38284 | },
|
38285 | __type__: {
|
38286 | object: object
|
38287 | }
|
38288 | },
|
38289 | __type__: {
|
38290 | object: object
|
38291 | }
|
38292 | },
|
38293 | __type__: {
|
38294 | object: object
|
38295 | }
|
38296 | },
|
38297 | legend: {
|
38298 | enabled: {
|
38299 | 'boolean': bool
|
38300 | },
|
38301 | icons: {
|
38302 | 'boolean': bool
|
38303 | },
|
38304 | left: {
|
38305 | visible: {
|
38306 | 'boolean': bool
|
38307 | },
|
38308 | position: {
|
38309 | string: ['top-right', 'bottom-right', 'top-left', 'bottom-left']
|
38310 | },
|
38311 | __type__: {
|
38312 | object: object
|
38313 | }
|
38314 | },
|
38315 | right: {
|
38316 | visible: {
|
38317 | 'boolean': bool
|
38318 | },
|
38319 | position: {
|
38320 | string: ['top-right', 'bottom-right', 'top-left', 'bottom-left']
|
38321 | },
|
38322 | __type__: {
|
38323 | object: object
|
38324 | }
|
38325 | },
|
38326 | __type__: {
|
38327 | object: object,
|
38328 | 'boolean': bool
|
38329 | }
|
38330 | },
|
38331 | groups: {
|
38332 | visibility: {
|
38333 | any: any
|
38334 | },
|
38335 | __type__: {
|
38336 | object: object
|
38337 | }
|
38338 | },
|
38339 | autoResize: {
|
38340 | 'boolean': bool
|
38341 | },
|
38342 | throttleRedraw: {
|
38343 | number: number
|
38344 | },
|
38345 | // TODO: DEPRICATED see https://github.com/almende/vis/issues/2511
|
38346 | clickToUse: {
|
38347 | 'boolean': bool
|
38348 | },
|
38349 | end: {
|
38350 | number: number,
|
38351 | date: date,
|
38352 | string: string,
|
38353 | moment: moment
|
38354 | },
|
38355 | format: {
|
38356 | minorLabels: {
|
38357 | millisecond: {
|
38358 | string: string,
|
38359 | 'undefined': 'undefined'
|
38360 | },
|
38361 | second: {
|
38362 | string: string,
|
38363 | 'undefined': 'undefined'
|
38364 | },
|
38365 | minute: {
|
38366 | string: string,
|
38367 | 'undefined': 'undefined'
|
38368 | },
|
38369 | hour: {
|
38370 | string: string,
|
38371 | 'undefined': 'undefined'
|
38372 | },
|
38373 | weekday: {
|
38374 | string: string,
|
38375 | 'undefined': 'undefined'
|
38376 | },
|
38377 | day: {
|
38378 | string: string,
|
38379 | 'undefined': 'undefined'
|
38380 | },
|
38381 | week: {
|
38382 | string: string,
|
38383 | 'undefined': 'undefined'
|
38384 | },
|
38385 | month: {
|
38386 | string: string,
|
38387 | 'undefined': 'undefined'
|
38388 | },
|
38389 | quarter: {
|
38390 | string: string,
|
38391 | 'undefined': 'undefined'
|
38392 | },
|
38393 | year: {
|
38394 | string: string,
|
38395 | 'undefined': 'undefined'
|
38396 | },
|
38397 | __type__: {
|
38398 | object: object
|
38399 | }
|
38400 | },
|
38401 | majorLabels: {
|
38402 | millisecond: {
|
38403 | string: string,
|
38404 | 'undefined': 'undefined'
|
38405 | },
|
38406 | second: {
|
38407 | string: string,
|
38408 | 'undefined': 'undefined'
|
38409 | },
|
38410 | minute: {
|
38411 | string: string,
|
38412 | 'undefined': 'undefined'
|
38413 | },
|
38414 | hour: {
|
38415 | string: string,
|
38416 | 'undefined': 'undefined'
|
38417 | },
|
38418 | weekday: {
|
38419 | string: string,
|
38420 | 'undefined': 'undefined'
|
38421 | },
|
38422 | day: {
|
38423 | string: string,
|
38424 | 'undefined': 'undefined'
|
38425 | },
|
38426 | week: {
|
38427 | string: string,
|
38428 | 'undefined': 'undefined'
|
38429 | },
|
38430 | month: {
|
38431 | string: string,
|
38432 | 'undefined': 'undefined'
|
38433 | },
|
38434 | quarter: {
|
38435 | string: string,
|
38436 | 'undefined': 'undefined'
|
38437 | },
|
38438 | year: {
|
38439 | string: string,
|
38440 | 'undefined': 'undefined'
|
38441 | },
|
38442 | __type__: {
|
38443 | object: object
|
38444 | }
|
38445 | },
|
38446 | __type__: {
|
38447 | object: object
|
38448 | }
|
38449 | },
|
38450 | moment: {
|
38451 | 'function': 'function'
|
38452 | },
|
38453 | height: {
|
38454 | string: string,
|
38455 | number: number
|
38456 | },
|
38457 | hiddenDates: {
|
38458 | start: {
|
38459 | date: date,
|
38460 | number: number,
|
38461 | string: string,
|
38462 | moment: moment
|
38463 | },
|
38464 | end: {
|
38465 | date: date,
|
38466 | number: number,
|
38467 | string: string,
|
38468 | moment: moment
|
38469 | },
|
38470 | repeat: {
|
38471 | string: string
|
38472 | },
|
38473 | __type__: {
|
38474 | object: object,
|
38475 | array: array
|
38476 | }
|
38477 | },
|
38478 | locale: {
|
38479 | string: string
|
38480 | },
|
38481 | locales: {
|
38482 | __any__: {
|
38483 | any: any
|
38484 | },
|
38485 | __type__: {
|
38486 | object: object
|
38487 | }
|
38488 | },
|
38489 | max: {
|
38490 | date: date,
|
38491 | number: number,
|
38492 | string: string,
|
38493 | moment: moment
|
38494 | },
|
38495 | maxHeight: {
|
38496 | number: number,
|
38497 | string: string
|
38498 | },
|
38499 | maxMinorChars: {
|
38500 | number: number
|
38501 | },
|
38502 | min: {
|
38503 | date: date,
|
38504 | number: number,
|
38505 | string: string,
|
38506 | moment: moment
|
38507 | },
|
38508 | minHeight: {
|
38509 | number: number,
|
38510 | string: string
|
38511 | },
|
38512 | moveable: {
|
38513 | 'boolean': bool
|
38514 | },
|
38515 | multiselect: {
|
38516 | 'boolean': bool
|
38517 | },
|
38518 | orientation: {
|
38519 | string: string
|
38520 | },
|
38521 | showCurrentTime: {
|
38522 | 'boolean': bool
|
38523 | },
|
38524 | showMajorLabels: {
|
38525 | 'boolean': bool
|
38526 | },
|
38527 | showMinorLabels: {
|
38528 | 'boolean': bool
|
38529 | },
|
38530 | showWeekScale: {
|
38531 | 'boolean': bool
|
38532 | },
|
38533 | snap: {
|
38534 | 'function': 'function',
|
38535 | 'null': 'null'
|
38536 | },
|
38537 | start: {
|
38538 | date: date,
|
38539 | number: number,
|
38540 | string: string,
|
38541 | moment: moment
|
38542 | },
|
38543 | timeAxis: {
|
38544 | scale: {
|
38545 | string: string,
|
38546 | 'undefined': 'undefined'
|
38547 | },
|
38548 | step: {
|
38549 | number: number,
|
38550 | 'undefined': 'undefined'
|
38551 | },
|
38552 | __type__: {
|
38553 | object: object
|
38554 | }
|
38555 | },
|
38556 | width: {
|
38557 | string: string,
|
38558 | number: number
|
38559 | },
|
38560 | zoomable: {
|
38561 | 'boolean': bool
|
38562 | },
|
38563 | zoomKey: {
|
38564 | string: ['ctrlKey', 'altKey', 'metaKey', '']
|
38565 | },
|
38566 | zoomMax: {
|
38567 | number: number
|
38568 | },
|
38569 | zoomMin: {
|
38570 | number: number
|
38571 | },
|
38572 | zIndex: {
|
38573 | number: number
|
38574 | },
|
38575 | __type__: {
|
38576 | object: object
|
38577 | }
|
38578 | };
|
38579 | var configureOptions = {
|
38580 | global: {
|
38581 | alignCurrentTime: ['none', 'year', 'month', 'quarter', 'week', 'isoWeek', 'day', 'date', 'hour', 'minute', 'second'],
|
38582 | //yAxisOrientation: ['left','right'], // TDOO: enable as soon as Grahp2d doesn't crash when changing this on the fly
|
38583 | sort: true,
|
38584 | sampling: true,
|
38585 | stack: false,
|
38586 | shaded: {
|
38587 | enabled: false,
|
38588 | orientation: ['zero', 'top', 'bottom', 'group'] // zero, top, bottom
|
38589 |
|
38590 | },
|
38591 | style: ['line', 'bar', 'points'],
|
38592 | // line, bar
|
38593 | barChart: {
|
38594 | width: [50, 5, 100, 5],
|
38595 | minWidth: [50, 5, 100, 5],
|
38596 | sideBySide: false,
|
38597 | align: ['left', 'center', 'right'] // left, center, right
|
38598 |
|
38599 | },
|
38600 | interpolation: {
|
38601 | enabled: true,
|
38602 | parametrization: ['centripetal', 'chordal', 'uniform'] // uniform (alpha = 0.0), chordal (alpha = 1.0), centripetal (alpha = 0.5)
|
38603 |
|
38604 | },
|
38605 | drawPoints: {
|
38606 | enabled: true,
|
38607 | size: [6, 2, 30, 1],
|
38608 | style: ['square', 'circle'] // square, circle
|
38609 |
|
38610 | },
|
38611 | dataAxis: {
|
38612 | showMinorLabels: true,
|
38613 | showMajorLabels: true,
|
38614 | showWeekScale: false,
|
38615 | icons: false,
|
38616 | width: [40, 0, 200, 1],
|
38617 | visible: true,
|
38618 | alignZeros: true,
|
38619 | left: {
|
38620 | //range: {min:'undefined': 'undefined'ined,max:'undefined': 'undefined'ined},
|
38621 | //format: function (value) {return value;},
|
38622 | title: {
|
38623 | text: '',
|
38624 | style: ''
|
38625 | }
|
38626 | },
|
38627 | right: {
|
38628 | //range: {min:'undefined': 'undefined'ined,max:'undefined': 'undefined'ined},
|
38629 | //format: function (value) {return value;},
|
38630 | title: {
|
38631 | text: '',
|
38632 | style: ''
|
38633 | }
|
38634 | }
|
38635 | },
|
38636 | legend: {
|
38637 | enabled: false,
|
38638 | icons: true,
|
38639 | left: {
|
38640 | visible: true,
|
38641 | position: ['top-right', 'bottom-right', 'top-left', 'bottom-left'] // top/bottom - left,right
|
38642 |
|
38643 | },
|
38644 | right: {
|
38645 | visible: true,
|
38646 | position: ['top-right', 'bottom-right', 'top-left', 'bottom-left'] // top/bottom - left,right
|
38647 |
|
38648 | }
|
38649 | },
|
38650 | autoResize: true,
|
38651 | clickToUse: false,
|
38652 | end: '',
|
38653 | format: {
|
38654 | minorLabels: {
|
38655 | millisecond: 'SSS',
|
38656 | second: 's',
|
38657 | minute: 'HH:mm',
|
38658 | hour: 'HH:mm',
|
38659 | weekday: 'ddd D',
|
38660 | day: 'D',
|
38661 | week: 'w',
|
38662 | month: 'MMM',
|
38663 | quarter: '[Q]Q',
|
38664 | year: 'YYYY'
|
38665 | },
|
38666 | majorLabels: {
|
38667 | millisecond: 'HH:mm:ss',
|
38668 | second: 'D MMMM HH:mm',
|
38669 | minute: 'ddd D MMMM',
|
38670 | hour: 'ddd D MMMM',
|
38671 | weekday: 'MMMM YYYY',
|
38672 | day: 'MMMM YYYY',
|
38673 | week: 'MMMM YYYY',
|
38674 | month: 'YYYY',
|
38675 | quarter: 'YYYY',
|
38676 | year: ''
|
38677 | }
|
38678 | },
|
38679 | height: '',
|
38680 | locale: '',
|
38681 | max: '',
|
38682 | maxHeight: '',
|
38683 | maxMinorChars: [7, 0, 20, 1],
|
38684 | min: '',
|
38685 | minHeight: '',
|
38686 | moveable: true,
|
38687 | orientation: ['both', 'bottom', 'top'],
|
38688 | showCurrentTime: false,
|
38689 | showMajorLabels: true,
|
38690 | showMinorLabels: true,
|
38691 | showWeekScale: false,
|
38692 | start: '',
|
38693 | width: '100%',
|
38694 | zoomable: true,
|
38695 | zoomKey: ['ctrlKey', 'altKey', 'metaKey', ''],
|
38696 | zoomMax: [315360000000000, 10, 315360000000000, 1],
|
38697 | zoomMin: [10, 10, 315360000000000, 1],
|
38698 | zIndex: 0
|
38699 | }
|
38700 | };
|
38701 |
|
38702 | /**
|
38703 | * Create a timeline visualization
|
38704 | * @param {HTMLElement} container
|
38705 | * @param {vis.DataSet | Array} [items]
|
38706 | * @param {vis.DataSet | Array | vis.DataView | Object} [groups]
|
38707 | * @param {Object} [options] See Graph2d.setOptions for the available options.
|
38708 | * @constructor Graph2d
|
38709 | * @extends Core
|
38710 | */
|
38711 |
|
38712 | function Graph2d(container, items, groups, options) {
|
38713 | var _context, _context2, _context3, _context4, _context5, _context6, _context7;
|
38714 |
|
38715 | // if the third element is options, the forth is groups (optionally);
|
38716 | if (!(_Array$isArray$1(groups) || isDataViewLike(groups)) && groups instanceof Object) {
|
38717 | var forthArgument = options;
|
38718 | options = groups;
|
38719 | groups = forthArgument;
|
38720 | } // TODO: REMOVE THIS in the next MAJOR release
|
38721 | // see https://github.com/almende/vis/issues/2511
|
38722 |
|
38723 |
|
38724 | if (options && options.throttleRedraw) {
|
38725 | console.warn("Graph2d option \"throttleRedraw\" is DEPRICATED and no longer supported. It will be removed in the next MAJOR release.");
|
38726 | }
|
38727 |
|
38728 | var me = this;
|
38729 | this.defaultOptions = {
|
38730 | start: null,
|
38731 | end: null,
|
38732 | autoResize: true,
|
38733 | orientation: {
|
38734 | axis: 'bottom',
|
38735 | // axis orientation: 'bottom', 'top', or 'both'
|
38736 | item: 'bottom' // not relevant for Graph2d
|
38737 |
|
38738 | },
|
38739 | moment: moment$2,
|
38740 | width: null,
|
38741 | height: null,
|
38742 | maxHeight: null,
|
38743 | minHeight: null
|
38744 | };
|
38745 | this.options = availableUtils.deepExtend({}, this.defaultOptions); // Create the DOM, props, and emitter
|
38746 |
|
38747 | this._create(container); // all components listed here will be repainted automatically
|
38748 |
|
38749 |
|
38750 | this.components = [];
|
38751 | this.body = {
|
38752 | dom: this.dom,
|
38753 | domProps: this.props,
|
38754 | emitter: {
|
38755 | on: _bindInstanceProperty(_context = this.on).call(_context, this),
|
38756 | off: _bindInstanceProperty(_context2 = this.off).call(_context2, this),
|
38757 | emit: _bindInstanceProperty(_context3 = this.emit).call(_context3, this)
|
38758 | },
|
38759 | hiddenDates: [],
|
38760 | util: {
|
38761 | getScale: function getScale() {
|
38762 | return me.timeAxis.step.scale;
|
38763 | },
|
38764 | getStep: function getStep() {
|
38765 | return me.timeAxis.step.step;
|
38766 | },
|
38767 | toScreen: _bindInstanceProperty(_context4 = me._toScreen).call(_context4, me),
|
38768 | toGlobalScreen: _bindInstanceProperty(_context5 = me._toGlobalScreen).call(_context5, me),
|
38769 | // this refers to the root.width
|
38770 | toTime: _bindInstanceProperty(_context6 = me._toTime).call(_context6, me),
|
38771 | toGlobalTime: _bindInstanceProperty(_context7 = me._toGlobalTime).call(_context7, me)
|
38772 | }
|
38773 | }; // range
|
38774 |
|
38775 | this.range = new Range(this.body);
|
38776 | this.components.push(this.range);
|
38777 | this.body.range = this.range; // time axis
|
38778 |
|
38779 | this.timeAxis = new TimeAxis(this.body);
|
38780 | this.components.push(this.timeAxis); //this.body.util.snap = this.timeAxis.snap.bind(this.timeAxis);
|
38781 | // current time bar
|
38782 |
|
38783 | this.currentTime = new CurrentTime(this.body);
|
38784 | this.components.push(this.currentTime); // item set
|
38785 |
|
38786 | this.linegraph = new LineGraph(this.body);
|
38787 | this.components.push(this.linegraph);
|
38788 | this.itemsData = null; // DataSet
|
38789 |
|
38790 | this.groupsData = null; // DataSet
|
38791 |
|
38792 | this.on('tap', function (event) {
|
38793 | me.emit('click', me.getEventProperties(event));
|
38794 | });
|
38795 | this.on('doubletap', function (event) {
|
38796 | me.emit('doubleClick', me.getEventProperties(event));
|
38797 | });
|
38798 |
|
38799 | this.dom.root.oncontextmenu = function (event) {
|
38800 | me.emit('contextmenu', me.getEventProperties(event));
|
38801 | }; //Single time autoscale/fit
|
38802 |
|
38803 |
|
38804 | this.initialFitDone = false;
|
38805 | this.on('changed', function () {
|
38806 | if (me.itemsData == null) return;
|
38807 |
|
38808 | if (!me.initialFitDone && !me.options.rollingMode) {
|
38809 | me.initialFitDone = true;
|
38810 |
|
38811 | if (me.options.start != undefined || me.options.end != undefined) {
|
38812 | if (me.options.start == undefined || me.options.end == undefined) {
|
38813 | var range = me.getItemRange();
|
38814 | }
|
38815 |
|
38816 | var start = me.options.start != undefined ? me.options.start : range.min;
|
38817 | var end = me.options.end != undefined ? me.options.end : range.max;
|
38818 | me.setWindow(start, end, {
|
38819 | animation: false
|
38820 | });
|
38821 | } else {
|
38822 | me.fit({
|
38823 | animation: false
|
38824 | });
|
38825 | }
|
38826 | }
|
38827 |
|
38828 | if (!me.initialDrawDone && (me.initialRangeChangeDone || !me.options.start && !me.options.end || me.options.rollingMode)) {
|
38829 | me.initialDrawDone = true;
|
38830 | me.dom.root.style.visibility = 'visible';
|
38831 | me.dom.loadingScreen.parentNode.removeChild(me.dom.loadingScreen);
|
38832 |
|
38833 | if (me.options.onInitialDrawComplete) {
|
38834 | _setTimeout(function () {
|
38835 | return me.options.onInitialDrawComplete();
|
38836 | }, 0);
|
38837 | }
|
38838 | }
|
38839 | }); // apply options
|
38840 |
|
38841 | if (options) {
|
38842 | this.setOptions(options);
|
38843 | } // IMPORTANT: THIS HAPPENS BEFORE SET ITEMS!
|
38844 |
|
38845 |
|
38846 | if (groups) {
|
38847 | this.setGroups(groups);
|
38848 | } // create itemset
|
38849 |
|
38850 |
|
38851 | if (items) {
|
38852 | this.setItems(items);
|
38853 | } // draw for the first time
|
38854 |
|
38855 |
|
38856 | this._redraw();
|
38857 | } // Extend the functionality from Core
|
38858 |
|
38859 |
|
38860 | Graph2d.prototype = new Core();
|
38861 |
|
38862 | Graph2d.prototype.setOptions = function (options) {
|
38863 | // validate options
|
38864 | var errorFound = Validator.validate(options, allOptions);
|
38865 |
|
38866 | if (errorFound === true) {
|
38867 | console.log('%cErrors have been found in the supplied options object.', printStyle);
|
38868 | }
|
38869 |
|
38870 | Core.prototype.setOptions.call(this, options);
|
38871 | };
|
38872 | /**
|
38873 | * Set items
|
38874 | * @param {vis.DataSet | Array | null} items
|
38875 | */
|
38876 |
|
38877 |
|
38878 | Graph2d.prototype.setItems = function (items) {
|
38879 | var initialLoad = this.itemsData == null; // convert to type DataSet when needed
|
38880 |
|
38881 | var newDataSet;
|
38882 |
|
38883 | if (!items) {
|
38884 | newDataSet = null;
|
38885 | } else if (isDataViewLike(items)) {
|
38886 | newDataSet = typeCoerceDataSet(items);
|
38887 | } else {
|
38888 | // turn an array into a dataset
|
38889 | newDataSet = typeCoerceDataSet(new DataSet(items));
|
38890 | } // set items
|
38891 |
|
38892 |
|
38893 | if (this.itemsData) {
|
38894 | // stop maintaining a coerced version of the old data set
|
38895 | this.itemsData.dispose();
|
38896 | }
|
38897 |
|
38898 | this.itemsData = newDataSet;
|
38899 | this.linegraph && this.linegraph.setItems(newDataSet != null ? newDataSet.rawDS : null);
|
38900 |
|
38901 | if (initialLoad) {
|
38902 | if (this.options.start != undefined || this.options.end != undefined) {
|
38903 | var start = this.options.start != undefined ? this.options.start : null;
|
38904 | var end = this.options.end != undefined ? this.options.end : null;
|
38905 | this.setWindow(start, end, {
|
38906 | animation: false
|
38907 | });
|
38908 | } else {
|
38909 | this.fit({
|
38910 | animation: false
|
38911 | });
|
38912 | }
|
38913 | }
|
38914 | };
|
38915 | /**
|
38916 | * Set groups
|
38917 | * @param {vis.DataSet | Array} groups
|
38918 | */
|
38919 |
|
38920 |
|
38921 | Graph2d.prototype.setGroups = function (groups) {
|
38922 | // convert to type DataSet when needed
|
38923 | var newDataSet;
|
38924 |
|
38925 | if (!groups) {
|
38926 | newDataSet = null;
|
38927 | } else if (isDataViewLike(groups)) {
|
38928 | newDataSet = groups;
|
38929 | } else {
|
38930 | // turn an array into a dataset
|
38931 | newDataSet = new DataSet(groups);
|
38932 | }
|
38933 |
|
38934 | this.groupsData = newDataSet;
|
38935 | this.linegraph.setGroups(newDataSet);
|
38936 | };
|
38937 | /**
|
38938 | * Returns an object containing an SVG element with the icon of the group (size determined by iconWidth and iconHeight), the label of the group (content) and the yAxisOrientation of the group (left or right).
|
38939 | * @param {vis.GraphGroup.id} groupId
|
38940 | * @param {number} width
|
38941 | * @param {number} height
|
38942 | * @returns {{icon: SVGElement, label: string, orientation: string}|string}
|
38943 | */
|
38944 |
|
38945 |
|
38946 | Graph2d.prototype.getLegend = function (groupId, width, height) {
|
38947 | if (width === undefined) {
|
38948 | width = 15;
|
38949 | }
|
38950 |
|
38951 | if (height === undefined) {
|
38952 | height = 15;
|
38953 | }
|
38954 |
|
38955 | if (this.linegraph.groups[groupId] !== undefined) {
|
38956 | return this.linegraph.groups[groupId].getLegend(width, height);
|
38957 | } else {
|
38958 | return "cannot find group:'" + groupId + "'";
|
38959 | }
|
38960 | };
|
38961 | /**
|
38962 | * This checks if the visible option of the supplied group (by ID) is true or false.
|
38963 | * @param {vis.GraphGroup.id} groupId
|
38964 | * @returns {boolean}
|
38965 | */
|
38966 |
|
38967 |
|
38968 | Graph2d.prototype.isGroupVisible = function (groupId) {
|
38969 | if (this.linegraph.groups[groupId] !== undefined) {
|
38970 | return this.linegraph.groups[groupId].visible && (this.linegraph.options.groups.visibility[groupId] === undefined || this.linegraph.options.groups.visibility[groupId] == true);
|
38971 | } else {
|
38972 | return false;
|
38973 | }
|
38974 | };
|
38975 | /**
|
38976 | * Get the data range of the item set.
|
38977 | * @returns {{min: Date, max: Date}} range A range with a start and end Date.
|
38978 | * When no minimum is found, min==null
|
38979 | * When no maximum is found, max==null
|
38980 | */
|
38981 |
|
38982 |
|
38983 | Graph2d.prototype.getDataRange = function () {
|
38984 | var min = null;
|
38985 | var max = null; // calculate min from start filed
|
38986 |
|
38987 | for (var groupId in this.linegraph.groups) {
|
38988 | if (this.linegraph.groups.hasOwnProperty(groupId)) {
|
38989 | if (this.linegraph.groups[groupId].visible == true) {
|
38990 | for (var i = 0; i < this.linegraph.groups[groupId].itemsData.length; i++) {
|
38991 | var item = this.linegraph.groups[groupId].itemsData[i];
|
38992 | var value = availableUtils.convert(item.x, 'Date').valueOf();
|
38993 | min = min == null ? value : min > value ? value : min;
|
38994 | max = max == null ? value : max < value ? value : max;
|
38995 | }
|
38996 | }
|
38997 | }
|
38998 | }
|
38999 |
|
39000 | return {
|
39001 | min: min != null ? new Date(min) : null,
|
39002 | max: max != null ? new Date(max) : null
|
39003 | };
|
39004 | };
|
39005 | /**
|
39006 | * Generate Timeline related information from an event
|
39007 | * @param {Event} event
|
39008 | * @return {Object} An object with related information, like on which area
|
39009 | * The event happened, whether clicked on an item, etc.
|
39010 | */
|
39011 |
|
39012 |
|
39013 | Graph2d.prototype.getEventProperties = function (event) {
|
39014 | var clientX = event.center ? event.center.x : event.clientX;
|
39015 | var clientY = event.center ? event.center.y : event.clientY;
|
39016 | var x = clientX - availableUtils.getAbsoluteLeft(this.dom.centerContainer);
|
39017 | var y = clientY - availableUtils.getAbsoluteTop(this.dom.centerContainer);
|
39018 |
|
39019 | var time = this._toTime(x);
|
39020 |
|
39021 | var customTime = CustomTime.customTimeFromTarget(event);
|
39022 | var element = availableUtils.getTarget(event);
|
39023 | var what = null;
|
39024 |
|
39025 | if (availableUtils.hasParent(element, this.timeAxis.dom.foreground)) {
|
39026 | what = 'axis';
|
39027 | } else if (this.timeAxis2 && availableUtils.hasParent(element, this.timeAxis2.dom.foreground)) {
|
39028 | what = 'axis';
|
39029 | } else if (availableUtils.hasParent(element, this.linegraph.yAxisLeft.dom.frame)) {
|
39030 | what = 'data-axis';
|
39031 | } else if (availableUtils.hasParent(element, this.linegraph.yAxisRight.dom.frame)) {
|
39032 | what = 'data-axis';
|
39033 | } else if (availableUtils.hasParent(element, this.linegraph.legendLeft.dom.frame)) {
|
39034 | what = 'legend';
|
39035 | } else if (availableUtils.hasParent(element, this.linegraph.legendRight.dom.frame)) {
|
39036 | what = 'legend';
|
39037 | } else if (customTime != null) {
|
39038 | what = 'custom-time';
|
39039 | } else if (availableUtils.hasParent(element, this.currentTime.bar)) {
|
39040 | what = 'current-time';
|
39041 | } else if (availableUtils.hasParent(element, this.dom.center)) {
|
39042 | what = 'background';
|
39043 | }
|
39044 |
|
39045 | var value = [];
|
39046 | var yAxisLeft = this.linegraph.yAxisLeft;
|
39047 | var yAxisRight = this.linegraph.yAxisRight;
|
39048 |
|
39049 | if (!yAxisLeft.hidden && this.itemsData.length > 0) {
|
39050 | value.push(yAxisLeft.screenToValue(y));
|
39051 | }
|
39052 |
|
39053 | if (!yAxisRight.hidden && this.itemsData.length > 0) {
|
39054 | value.push(yAxisRight.screenToValue(y));
|
39055 | }
|
39056 |
|
39057 | return {
|
39058 | event: event,
|
39059 | customTime: customTime ? customTime.options.id : null,
|
39060 | what: what,
|
39061 | pageX: event.srcEvent ? event.srcEvent.pageX : event.pageX,
|
39062 | pageY: event.srcEvent ? event.srcEvent.pageY : event.pageY,
|
39063 | x: x,
|
39064 | y: y,
|
39065 | time: time,
|
39066 | value: value
|
39067 | };
|
39068 | };
|
39069 | /**
|
39070 | * Load a configurator
|
39071 | * @return {Object}
|
39072 | * @private
|
39073 | */
|
39074 |
|
39075 |
|
39076 | Graph2d.prototype._createConfigurator = function () {
|
39077 | return new Configurator(this, this.dom.container, configureOptions);
|
39078 | };
|
39079 |
|
39080 | // Locales have to be supplied by the user.
|
39081 | var defaultLanguage = getNavigatorLanguage();
|
39082 | moment$3.locale(defaultLanguage);
|
39083 | var timeline = {
|
39084 | Core: Core,
|
39085 | DateUtil: DateUtil,
|
39086 | Range: Range,
|
39087 | stack: stack$1,
|
39088 | TimeStep: TimeStep,
|
39089 | components: {
|
39090 | items: {
|
39091 | Item: Item,
|
39092 | BackgroundItem: BackgroundItem,
|
39093 | BoxItem: BoxItem,
|
39094 | ClusterItem: ClusterItem,
|
39095 | PointItem: PointItem,
|
39096 | RangeItem: RangeItem
|
39097 | },
|
39098 | BackgroundGroup: BackgroundGroup,
|
39099 | Component: Component,
|
39100 | CurrentTime: CurrentTime,
|
39101 | CustomTime: CustomTime,
|
39102 | DataAxis: DataAxis,
|
39103 | DataScale: DataScale,
|
39104 | GraphGroup: GraphGroup,
|
39105 | Group: Group,
|
39106 | ItemSet: ItemSet,
|
39107 | Legend: Legend,
|
39108 | LineGraph: LineGraph,
|
39109 | TimeAxis: TimeAxis
|
39110 | }
|
39111 | };
|
39112 |
|
39113 | export { Graph2d, Timeline, timeline };
|
39114 | //# sourceMappingURL=vis-timeline-graph2d.js.map
|